Revision 18 (by ahitrov@rambler.ru, 2010/04/19 15:32:24) Неактивная кнопка при создании секции. Наведенная ошибка
<& "/contenido/components/header.msn" &>
<& "/contenido/components/naviline.msn", sect_id => $owner->id &>

<script type="text/javascript">
<!--
function set_create_button( oSelect, sBtnID ) {
	if ( oSelect.value == '' ) {
		$('#'+sBtnID).attr('disabled','disabled');
	} else {
		$('#'+sBtnID).removeAttr('disabled');
	}
}
//-->
</script>

% if ( (length($class)<=0) && (! ref($section)) )
% {

%	if ($id)
%	{
<div align="center" style="font-size:110%; color:red;">
������ � ��������������� <% $id %> �� �������
</div>
<br><br>
%	}

<!-- ���� � ������� ����� ������ ��� �������� -->
<table width="50%" border="0"><tr><td>
<fieldset>
<legend>�������� ��� ������ ��� ��������</legend>
<& "/contenido/components/new_objects_form.msn", proto => 'sections', sect_id => $owner->id &>
</fieldset>
</td></tr></table>

% } else {

<& "/contenido/components/obj_list_js.msn", object => $section &>
<& "/contenido/components/object_form.msn", object => $section, proto => 'sections', sect_id => $owner->id &>

% }

</body>
</html>
<%ARGS>

	$class => undef
	$sect_id => undef
	$pid => undef
	$id => undef
	$ret => undef

	$delete => undef
	$save => undef
	$move => undef

</%ARGS>
<%INIT>
	# �������� ���������� ������ - �� ������ ���� ����� ����...
	if ($class)
	{
		my @correct_classes = @{ $state->{available_sections} };
		if (! (grep { $_ eq $class } @correct_classes))
		{
			# ����� �����, �� �� �� ����������
			$class = undef;
		}
	}

	my $section;
	if ($id && ($id !~ /\D/) && ($id > 0))
	{
		# ��������� ����� �������������� ������
		if ($user->section_accesses($user, $id) != 2)
		{
			$m->clear_buffer;
			$m->abort(403);
		}

		$section = $keeper->get_section_by_id($id);
	}

	if ( ($class) && (length($class) > 0) && (! ref($section)) )
	{
		$section = new $class ($keeper);
	}

	if ( (! $sect_id) && ref($section) && $section->id )
	{
		$sect_id = $section->pid;
	}
	if ( $pid > 0 )
	{
		if (ref($section) && $section->id)
		{
			$sect_id = $pid			if ($section->id != $pid);
		} else {
			$sect_id = $pid;
		}
	}

	my $owner = $keeper->get_section_by_id ($sect_id || $Contenido::Section::ROOT || 1);
	if (! ref($owner))
	{
		$owner = $keeper->get_section_by_id ($Contenido::Section::ROOT || 1);
	}
	if (! ref($owner))
	{
		warn "Contenido Die: �� ���� ����� �������� ������\n";
		return undef;
	}


	# ��������...
	if ( defined($id) && ($id > 0) && ($delete == 1) )
	{
		$section = $keeper->get_section_by_id($id);
		$section->delete();

		$r->header_out("Location", "sections.html?id=".$owner->id);
		$r->status(302);
		$r->send_http_header();
		$m->abort();
	}

	# ���������� �����...
	elsif ( $save == 1 )
	{
		if ($m->comp('/contenido/components/set_properties.msn', object => $section, SETS => \%ARGS) != 1)
		{
			# ������, ���� �� ����������...
		}
		$section->pid($sect_id);
		$section->store();

		if ($ARGS{_save_and_leave})
		{
			$r->header_out("Location", "sections.html?id=".$owner->id);
			$r->status(302);
			$r->send_http_header();
			$m->abort();
		}
		elsif ($ARGS{_save_and_again})
		{
			$r->header_out("Location", "section.html?class=".$section->class()."&sect_id=".$owner->id());
			$r->status(302);
			$r->send_http_header();
			$m->abort();
		}


		$r->header_out("Location", "section.html?id=".$section->id);
		$r->status(302);
		$r->send_http_header();
		$m->abort();
	}

	# �����������...
	elsif ($move) {
		warn "MOVING to $move";
		$section->move($move);
		$r->header_out("Location", $ret ? "sections.html?id=".$ret : 'index.html');
		$r->status(302);
		$r->send_http_header();
		$m->abort();
	}

</%INIT>