App-Office-CMS
view release on metacpan or search on metacpan
lib/App/Office/CMS/Controller.pm view on Meta::CPAN
if ($design)
{
# Update user's choices.
#$$design{menu_orientation_id} = $$site{menu_orientation_id};
#$$design{os_type_id} = $$site{os_type_id};
$$design{output_directory} = $$site{output_directory};
$$design{output_doc_root} = $$site{output_doc_root};
}
elsif ($action =~ /(?:add|duplicate_site|update)/)
{
# When duplicating a site, the default design manufactured here is ignored.
$design = $self -> param('db') -> build_default_design($$site_match{id}, $$site{design_name}, $$site{menu_orientation_id}, $$site{os_type_id}, $$site{output_directory}, $$site{output_doc_root});
}
else
{
$message = "Error: No design matches the name '$$site{design_name}' for site '$$site{name}'";
}
}
elsif ($action =~ /(?:add|update)/)
{
$site_match = $self -> param('db') -> build_default_site($$site{name});
$design = $self -> param('db') -> build_default_design(0, $$site{design_name}, $$site{menu_orientation_id}, $$site{os_type_id}, $$site{output_directory}, $$site{output_doc_root});
}
else
{
$message = "Error: No site matches the name '$$site{name}'";
}
# Note: By returning $site_match, we loose the CGI form fields.
return ($message, $site_match, $design);
} # End of check_site_and_design_names.
# -----------------------------------------------
sub log
{
my($self, $level, $s) = @_;
$self -> param('db') -> log($level, $s);
} # End of log.
# -----------------------------------------------
sub process_page_form
{
my($self, $action) = @_;
$self -> log(debug => "process_page_form($action)");
my($data) = App::Office::CMS::Util::Validator -> new
(
config => $self -> param('config'),
db => $self -> param('db'),
query => $self -> query,
) -> validate_page;
my($asset);
my($message);
my($page);
if ($$data{_rejects})
{
$self -> log(debug => 'Page data is not valid');
$message => $self -> param('view') -> format_errors($$data{_rejects});
}
else
{
$self -> log(debug => 'Page data is valid');
$page = $self -> build_page_hash($data);
($message, $page, $asset) = $self -> check_page_name($page, $action);
}
return ($message, $page, $asset);
} # End of process_page_form.
# -----------------------------------------------
sub process_site_and_design_form
{
my($self, $action) = @_;
$self -> log(debug => "process_site_and_design_form($action)");
my($data) = App::Office::CMS::Util::Validator -> new
(
config => $self -> param('config'),
db => $self -> param('db'),
query => $self -> query,
) -> validate_site_and_design;
my($design);
my($message);
my($site);
if ($$data{_rejects})
{
$self -> log(debug => 'Site and design data is not valid');
$message = $self -> param('view') -> format_errors($$data{_rejects});
}
else
{
$self -> log(debug => 'Site and design data is valid');
$site = $self -> build_site_hash($data);
($message, $site, $design) = $self -> check_site_and_design_names($site, $action);
}
return ($message, $site, $design);
} # End of process_site_and_design_form.
# -----------------------------------------------
sub teardown
{
my($self) = @_;
$self -> log(debug => 'teardown()');
# This is mandatory under Plack.
$self -> param('session') -> flush;
} # End of teardown.
# -----------------------------------------------
1;
( run in 1.079 second using v1.01-cache-2.11-cpan-39bf76dae61 )