public function indexAction()
 {
     // Get the user properties
     $values = $this->_properties->getProperties(array("title", "subtitle", "background_image", "header_image", "theme", "css_enabled", "css_content", "has_colors"));
     $colors = $this->_properties->getProperties(array("color_title", "color_subtitle", "color_sidebar_border", "color_background", "color_link", "color_sidebar_text", "color_sidebar_header"));
     // Get the form and assign the values
     $form = $this->getForm();
     $form->populate($values);
     $this->view->form = $form;
     // Get the color form
     $form = $this->getFormColors();
     $this->view->formtheme = $form;
     // Get the css form
     $form = $this->getFormCss();
     $form->populate($values);
     $this->view->formcss = $form;
     // Do we have a background image ?
     if (isset($values['background_image'])) {
         $this->view->background_image = $values['background_image'];
     }
     // Do we have a header image ?
     if (isset($values['header_image'])) {
         $this->view->header_image = $values['header_image'];
     }
     // Get available themes
     $this->view->themes = Themes::getAvailableThemes();
     $this->view->theme = $this->_properties->getProperty('theme');
     // Custom css & colors
     $this->view->css_enabled = $values['css_enabled'];
     $this->view->css_content = $values['css_content'];
     $this->view->colors = $colors;
     $this->view->has_colors = $values['has_colors'];
     $this->view->onload = "onDesignLoad();";
     // Get errror and status messages
     $this->view->status_messages = $this->getStatusMessages();
     $this->view->error_messages = $this->getErrorMessages();
     // Common view elements
     $this->common();
     // Specific scripts
     $this->view->headScript()->appendFile('js/tab/tab.js');
     $this->view->headScript()->appendFile('js/yahoo/yahoo.color.js');
     $this->view->headScript()->appendFile('js/colorpicker/colorpicker.js');
     $this->view->headScript()->appendFile('js/controllers/design.js');
     // Specific CSS
     $this->view->headLink()->appendStylesheet('style/colorpicker.css');
 }
 protected function common()
 {
     // Set the timezone to the user timezone
     $timezone = $this->_properties->getProperty('timezone');
     date_default_timezone_set($timezone);
     // Assgin a different layout if embedded
     if ($this->_embed) {
         if ($this->_embed == 'page') {
             $this->_helper->layout->setlayout('embed_page');
         } else {
             $this->_helper->layout->disableLayout();
         }
     }
     // Fetch the user configured widgets
     if (!$this->_embed) {
         $w = new Widgets();
         $this->view->widgets = $w->getWidgets($this->_user->id);
     }
     // User provided footer (e.g. tracker)
     $user_footer = $this->_properties->getProperty('footer');
     $this->view->user_footer = $user_footer;
     // Javascript
     $this->view->headScript()->appendFile('js/prototype/prototype.js');
     $this->view->headScript()->appendFile('js/scriptaculous/builder.js');
     $this->view->headScript()->appendFile('js/scriptaculous/builder.js');
     $this->view->headScript()->appendFile('js/scriptaculous/effects.js');
     $this->view->headScript()->appendFile('js/scriptaculous/dragdrop.js');
     $this->view->headScript()->appendFile('js/scriptaculous/controls.js');
     $this->view->headScript()->appendFile('js/scriptaculous/slider.js');
     $this->view->headScript()->appendFile('js/scriptaculous/sound.js');
     $this->view->headScript()->appendFile('js/storytlr/validateForm.js');
     $this->view->headScript()->appendFile('js/storytlr/common.js');
     $this->view->headScript()->appendFile('js/controllers/adminbar.js');
     $this->view->headScript()->appendFile('js/accordion/accordion.js');
     // Meta
     $this->view->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8');
     // CSS
     $this->view->headLink()->appendStylesheet('style/toolbar.css');
     $this->view->headLink()->appendStylesheet('themes/' . $this->_properties->getProperty('theme') . '/style.css');
     // Colors
     $colors = $this->_properties->getProperties(array("color_title", "color_subtitle", "color_sidebar_border", "color_background", "color_link", "color_sidebar_text", "color_sidebar_header"));
     $this->view->colors = $colors;
     // Error and status messages
     $this->view->status_messages = $this->getStatusMessages();
     $this->view->error_messages = $this->getErrorMessages();
     // User details
     $this->view->username = $this->_user->username;
     $this->view->user_id = $this->_user->id;
     $this->view->admin = $this->_admin;
     // Theme
     $themes = Themes::getAvailableThemes();
     $theme = $this->_properties->getProperty('theme');
     $this->view->theme = $theme;
     $this->view->theme_data = $themes[$theme];
     // Pages
     $pages = new Pages();
     $this->view->pages = $pages->getPages();
     // Page layout
     $this->view->background_image = $this->_properties->getProperty('background_image');
     $this->view->header_image = $this->_properties->getProperty('header_image');
     $this->view->has_colors = $this->_properties->getProperty('has_colors');
     $this->view->css_enabled = $this->_properties->getProperty('css_enabled');
     $this->view->css_content = $this->_properties->getProperty('css_content');
     $this->view->title = $this->_properties->getProperty('title');
     $this->view->subtitle = $this->_properties->getProperty('subtitle');
     $this->view->disqus = $this->_properties->getProperty('disqus');
     $this->view->googlefc = $this->_properties->getProperty('googlefc');
     $this->view->footer = $this->_properties->getProperty('footer');
 }