App-Office-CMS

 view release on metacpan or  search on metacpan

lib/App/Office/CMS/Controller/Site.pm  view on Meta::CPAN

		{
			message    => $self -> param('view') -> site -> display($site, $design),
			target_div => 'update_site_div',
		}
	});

} # End of display.

# -----------------------------------------------

sub duplicate
{
	my($self) = @_;

	$self -> log(debug => 'duplicate()');

	my($message);

	try
	{
		my($design);
		my($site);

		($message, $site, $design) = $self -> process_site_and_design_form('duplicate_site');

		if (! $message)
		{
			if (! $$site{new_name})
			{
				$message = $self -> param('view') -> format_errors({'Missing name' => ['You must specify a name for the new site']});
			}
			else
			{
				$message = $self -> param('db') -> site -> duplicate($site);
			}
		}
	}
	catch
	{
		$message = $_;
	};

	# search_result_div is always on screen (under the Edit Site tab).
	# It appears there by virtue of being within search.tx.
	# The other thing is, we wish to use JS to zap the displayed site
	# and the displayed search results, because that data is obsolete.

	return JSON::XS -> new -> utf8 -> encode
	({
		results =>
		{
			message    => $message,
			target_div => 'update_site_message_div',
		}
	});

} # End of duplicate.

# -----------------------------------------------

sub update
{
	my($self) = @_;

	$self -> log(debug => 'update()');

	my($target_div) = 'update_site_message_div';

	my($message);

	try
	{
		my($design);
		my($site);

		($message, $site, $design) = $self -> process_site_and_design_form('update');

		if (! $message)
		{
			# Success.
			# Note: If the user typed in a new site name, this will
			# call add for the site (effectively) and add for the design.
			# Note: If the user typed in a new design name, this will
			# call update for the site and add for the design.

			$message = $self -> param('db') -> site -> update($site, $design);
		}
	}
	catch
	{
		$message = $_;
	};

	# search_result_div is always on screen (under the Edit Site tab).
	# It appears there by virtue of being within search.tx.
	# update_site_message_div is only on screen (under the Edit Site tab),
	# when a site has been successfully displayed by clicking on a search result.
	# It appears there by virtue of being within site.tx.

	return JSON::XS -> new -> utf8 -> encode
	({
		results =>
		{
			message    => $message,
			target_div => $target_div,
		}
	});

} # End of update.

# -----------------------------------------------

1;



( run in 0.547 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )