App-Office-CMS
view release on metacpan or search on metacpan
lib/App/Office/CMS/Controller/Initialize.pm view on Meta::CPAN
package App::Office::CMS::Controller::Initialize;
use parent 'App::Office::CMS::Controller';
use strict;
use warnings;
use Text::Xslate 'mark_raw';
# We don't use Moo because we isa CGI::Application.
our $VERSION = '0.93';
# -----------------------------------------------
sub build_about_html
{
my($self) = @_;
$self -> log(debug => 'build_about_html()');
my($config) = $self -> param('config');
my(@tr);
push @tr, {left => 'Program', right => "$$config{program_name} $$config{program_version}"};
push @tr, {left => 'Author', right => $$config{program_author} };
push @tr, {left => 'Help', right => mark_raw(qq|<a href="$$config{program_faq_url}">FAQ</a>|)};
# Make YUI happy by turning the HTML into 1 long line.
my($html) = $self -> param('templater') -> render('table.tx', {data => [@tr]});
$html =~ s/\n//g;
return $html;
} # End of build_about_html.
# -----------------------------------------------
sub build_head_init
{
my($self) = @_;
$self -> log(debug => 'build_head_init()');
# These things are called by YAHOO.util.Event.onDOMReady(init).
# We use $site_count like this:
# o If there are no sites yet, default to the New Site tab.
# o If there are some sites, default to the Edit Site tab.
my($about_html) = $self -> build_about_html;
my($new_site_html) = $self -> param('view') -> site -> build_new_site_html;
my($search_html) = $self -> param('view') -> search -> build_search_html;
my($site_count) = $self -> param('db') -> get_site_count;
# Add tabs left-to-right to the tabview.
# Warning: These tabs are numbered 0 .. N by YUI.
# To make a specific tab active, e.g. after it's contents are updated
# via AJAX, the tab number is used. See:
# page.js lines 13 & 39: tab_view.set('activeIndex', 2); // Edit Pages tab.
my($head_init) = <<EJS;
var new_site_tab = new YAHOO.widget.Tab
({
label: "New Site",
content: '$new_site_html',
active: $site_count ? false : true
});
tab_view.addTab(new_site_tab);
new_site_tab.addListener('click', make_new_site_name_focus);
var edit_site_tab = new YAHOO.widget.Tab
({
label: "Edit Site",
content: '$search_html',
active: $site_count ? true : false
});
tab_view.addTab(edit_site_tab);
edit_site_tab.addListener('click', make_search_name_focus);
var edit_page_tab = new YAHOO.widget.Tab
({
label: "Edit Pages",
content: '<div id="update_page_div"><h3 align="center">Acess via Edit Site...</h3></div>',
active: false
});
tab_view.addTab(edit_page_tab);
edit_page_tab.addListener('click', make_update_page_name_focus);
var edit_content_tab = new YAHOO.widget.Tab
({
label: "Edit Content",
content: '<div id="update_content_div"><h3 align="center">Access via Edit Pages...</h3></div>',
active: false
});
tab_view.addTab(edit_content_tab);
edit_content_tab.addListener('click', make_update_content_name_focus);
var about_tab = new YAHOO.widget.Tab
({
label: "About",
content: '$about_html',
active: false
});
tab_view.addTab(about_tab);
// Add tab view to document.
tab_view.appendTo("tabview_container");
if ($site_count)
{
make_search_name_focus();
}
else
{
make_new_site_name_focus();
( run in 1.292 second using v1.01-cache-2.11-cpan-39bf76dae61 )