Ejemplo n.º 1
0
 /**
  * Load the form
  *
  * @return	void
  */
 private function loadForm()
 {
     // create form
     $this->frm = new BackendForm('add');
     // init var
     $maximumBlocks = 30;
     // create elements
     $this->frm->addDropdown('theme', $this->availableThemes, $this->selectedTheme);
     $this->frm->addText('label');
     $this->frm->addText('file');
     $this->frm->addDropdown('num_blocks', array_combine(range(1, $maximumBlocks), range(1, $maximumBlocks)), 3);
     $this->frm->addTextarea('format');
     $this->frm->addCheckbox('active', true);
     $this->frm->addCheckbox('default');
     // 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 ($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++) {
         $names[$i]['i'] = $i;
         $names[$i]['formElements']['txtName'] = $this->frm->addText('name_' . $i);
         $names[$i]['formElements']['ddmType'] = $this->frm->addDropdown('type_' . $i, $defaultExtras);
     }
     // assign
     $this->tpl->assign('names', $names);
 }
Ejemplo n.º 2
0
 /**
  * Parse
  *
  * @return	void
  */
 protected function parse()
 {
     // set
     $this->record['url'] = $this->meta->getURL();
     if ($this->id == 1) {
         $this->record['url'] = '';
     }
     // parse some variables
     $this->tpl->assign('item', $this->record);
     $this->tpl->assign('templates', $this->templates);
     $this->tpl->assign('blocks', $this->blocks);
     $this->tpl->assign('extrasData', json_encode(BackendPagesModel::getExtrasData()));
     $this->tpl->assign('extrasById', json_encode(BackendPagesModel::getExtras()));
     $this->tpl->assign('prefixURL', rtrim(BackendPagesModel::getFullURL($this->record['parent_id']), '/'));
     // init var
     $showDelete = true;
     // has children?
     if (BackendPagesModel::getFirstChildId($this->record['id']) !== false) {
         $showDelete = false;
     }
     if (!$this->record['delete_allowed']) {
         $showDelete = false;
     }
     // show deletebutton
     $this->tpl->assign('showDelete', $showDelete);
     // assign template
     $this->tpl->assignArray($this->templates[$this->record['template_id']], 'template');
     // parse the form
     $this->frm->parse($this->tpl);
     // parse datagrids
     $this->tpl->assign('revisions', $this->dgRevisions->getNumResults() != 0 ? $this->dgRevisions->getContent() : false);
     $this->tpl->assign('drafts', $this->dgDrafts->getNumResults() != 0 ? $this->dgDrafts->getContent() : false);
     // parse the tree
     $this->tpl->assign('tree', BackendPagesModel::getTreeHTML());
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 4
0
 /**
  * Parse
  *
  * @return	void
  */
 protected function parse()
 {
     // parse some variables
     $this->tpl->assign('templates', $this->templates);
     $this->tpl->assign('blocks', $this->blocks);
     $this->tpl->assign('extrasData', json_encode(BackendPagesModel::getExtrasData()));
     $this->tpl->assign('extrasById', json_encode(BackendPagesModel::getExtras()));
     $this->tpl->assign('prefixURL', rtrim(BackendPagesModel::getFullURL(1), '/'));
     // get default template id
     $defaultTemplateId = BackendModel::getModuleSetting($this->getModule(), 'default_template', 1);
     // assign template
     $this->tpl->assignArray($this->templates[$defaultTemplateId], 'template');
     // parse the form
     $this->frm->parse($this->tpl);
     // parse the tree
     $this->tpl->assign('tree', BackendPagesModel::getTreeHTML());
 }