예제 #1
0
 /**
  * Load the form
  *
  * @return	void
  */
 private function loadForm()
 {
     // create form
     $this->frm = new BackendForm('settingsThemes');
     // theme
     $this->frm->addDropdown('theme', BackendModel::getThemes(), BackendModel::getModuleSetting('core', 'theme', 'core'));
 }
예제 #2
0
 /**
  * Load necessary data.
  *
  * @return	void.
  */
 private function loadData()
 {
     // get data
     $this->selectedTheme = $this->getParameter('theme', 'string');
     // build available themes
     $this->availableThemes = BackendModel::getThemes();
     // determine selected theme, based upon submitted form or default theme
     $this->selectedTheme = SpoonFilter::getValue($this->selectedTheme, array_keys($this->availableThemes), BackendModel::getModuleSetting('core', 'theme', 'core'));
 }
예제 #3
0
 /**
  * Load the form
  *
  * @return	void
  */
 private function loadForm()
 {
     // create form
     $this->frm = new BackendForm('edit');
     // init var
     $maximumBlocks = 30;
     $defaultId = BackendModel::getModuleSetting($this->getModule(), 'default_template');
     // create elements
     $this->frm->addDropdown('theme', BackendModel::getThemes(), BackendModel::getModuleSetting('core', 'theme', 'core'));
     $this->frm->addText('label', $this->record['label']);
     $this->frm->addText('file', str_replace('core/layout/templates/', '', $this->record['path']));
     $this->frm->addDropdown('num_blocks', array_combine(range(1, $maximumBlocks), range(1, $maximumBlocks)), $this->record['num_blocks']);
     $this->frm->addTextarea('format', str_replace('],[', "],\n[", $this->record['data']['format']));
     $this->frm->addCheckbox('active', $this->record['active'] == 'Y');
     $this->frm->addCheckbox('default', $this->record['id'] == $defaultId);
     // if this is the default template we can't alter the active/default state
     if ($this->record['id'] == $defaultId) {
         $this->frm->getField('active')->setAttributes(array('disabled' => 'disabled'));
         $this->frm->getField('default')->setAttributes(array('disabled' => 'disabled'));
     }
     // if the template is in use we cant alter the active state
     if (BackendPagesModel::isTemplateInUse($this->id)) {
         $this->frm->getField('active')->setAttributes(array('disabled' => 'disabled'));
     }
     // init vars
     $names = array();
     $blocks = array();
     $widgets = array();
     $extras = BackendPagesModel::getExtras();
     // loop extras to populate the default extras
     foreach ($extras as $item) {
         if ($item['type'] == 'block') {
             $blocks[$item['id']] = ucfirst(BL::lbl($item['label']));
             if (isset($item['data']['extra_label'])) {
                 $blocks[$item['id']] = ucfirst($item['data']['extra_label']);
             }
         } elseif ($item['type'] == 'widget') {
             $widgets[$item['id']] = ucfirst(BL::lbl(SpoonFilter::toCamelCase($item['module']))) . ': ' . ucfirst(BL::lbl($item['label']));
             if (isset($item['data']['extra_label'])) {
                 $widgets[$item['id']] = ucfirst(BL::lbl(SpoonFilter::toCamelCase($item['module']))) . ': ' . $item['data']['extra_label'];
             }
         }
     }
     // sort
     asort($blocks, SORT_STRING);
     asort($widgets, SORT_STRING);
     // create array
     $defaultExtras = array('' => array('editor' => BL::lbl('Editor')), ucfirst(BL::lbl('Modules')) => $blocks, ucfirst(BL::lbl('Widgets')) => $widgets);
     // add some fields
     for ($i = 1; $i <= $maximumBlocks; $i++) {
         // grab values
         $name = isset($this->record['data']['names'][$i - 1]) ? $this->record['data']['names'][$i - 1] : null;
         $extra = isset($this->record['data']['default_extras'][$i - 1]) ? $this->record['data']['default_extras'][$i - 1] : null;
         // build array
         $names[$i]['i'] = $i;
         $names[$i]['formElements']['txtName'] = $this->frm->addText('name_' . $i, $name);
         $names[$i]['formElements']['ddmType'] = $this->frm->addDropdown('type_' . $i, $defaultExtras, $extra);
     }
     // assign
     $this->tpl->assign('names', $names);
 }