Пример #1
0
 /**
  * Uninstall a theme (use Ajax)
  *
  * @param   integer	$id Theme ID
  * @return  void
  */
 public function uninstall($id)
 {
     // load dictionary
     $this->dict->get_wordarray(array('form', 'themes'));
     // get object
     $theme = new Theme_model();
     $obj = $theme->get_by_id($id, 'themes', 'name');
     // build the form
     $fields = array();
     $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id, 'name' => 'id');
     $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $obj->name, 'name' => 'name');
     // if submitted
     if (X4Route_core::$post) {
         $this->uninstalling($_POST);
         die;
     }
     // contents
     $view = new X4View_core('uninstall');
     $view->title = _UNINSTALL_THEME;
     $view->msg = '';
     $view->item = $obj->name;
     // form builder
     $view->form = X4Form_helper::doform('uninstall', $_SERVER["REQUEST_URI"], $fields, array(null, _YES, 'buttons'), 'post', '', 'onclick="setForm(\'uninstall\');"');
     $view->render(TRUE);
 }
Пример #2
0
 /**
  * Install a new template (use Ajax)
  *
  * @param   integer $id_theme Theme ID
  * @param   string	$template_name Template name
  * @return  void
  */
 public function install($id_theme, $template_name)
 {
     // load dictionaries
     $this->dict->get_wordarray(array('form', 'templates', 'sections'));
     // content
     $view = new X4View_core('editor');
     $view->title = _INSTALL_TEMPLATE;
     // check the template name
     if (strstr(urldecode($template_name), ' ') != '') {
         $view->form = '<h2>' . _WARNING . '</h2><p>' . _INVALID_TEMPLATE . BR . '<strong>>>&nbsp;' . urldecode($template_name) . '&nbsp;<<</strong><br />&nbsp;</p>';
     } else {
         // get theme object
         $mod = new Theme_model();
         $theme = $mod->get_by_id($id_theme);
         // build the form
         $fields = array();
         $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id_theme, 'name' => 'id_theme');
         $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $template_name, 'name' => 'name', 'extra' => 'class="large"');
         $fields[] = array('label' => null, 'type' => 'html', 'value' => '<h4>' . _TEMPLATE . ': ' . $template_name . '</h4>');
         $fields[] = array('label' => _DESCRIPTION, 'type' => 'textarea', 'value' => '', 'name' => 'description', 'extra' => 'class="large"');
         // load available CSS style sheets
         $fields[] = array('label' => _CSS, 'type' => 'select', 'value' => 'base', 'options' => array($this->get_css($theme->name), 'value', 'option'), 'name' => 'css', 'extra' => 'class="large"');
         $fields[] = array('label' => _SECTIONS, 'type' => 'text', 'value' => 1, 'name' => 'sections', 'rule' => 'required|numeric', 'extra' => 'class="aright large"');
         // if submitted
         if (X4Route_core::$post) {
             $e = X4Validation_helper::form($fields, 'editor');
             if ($e) {
                 $this->installing($_POST);
             } else {
                 $this->notice($fields);
             }
             die;
         }
         // form builder
         $view->form = X4Form_helper::doform('editor', $_SERVER["REQUEST_URI"], $fields, array(_RESET, _SUBMIT, 'buttons'), 'post', '', 'onclick="setForm(\'editor\');"');
     }
     $view->render(TRUE);
 }