/** * Show themes * * @return void */ public function _default() { // load dictionary $this->dict->get_wordarray(array('themes')); // get page $page = $this->get_page('themes'); // content $view = new X4View_core('container'); $view->content = new X4View_core('themes/theme_list'); $view->content->page = $page; $theme = new Theme_model(); // installed themes $view->content->theme_in = $theme->get_installed(); // installable themes $view->content->theme_out = $theme->get_installable(); $view->render(TRUE); }
/** * New / Edit area form (use Ajax) * * @param integer $id item ID (if 0 then is a new item) * @return void */ public function edit($id = 0) { // load dictionaries $this->dict->get_wordarray(array('form', 'areas', 'themes')); // handle id $chk = false; if ($id < 0) { $id = 0; $chk = true; } // get area object $mod = new Area_model(); $item = $id ? $mod->get_area_data($id) : new Area_obj(); // build the form $fields = array(); $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id, 'name' => 'id'); // user can't change names of default areas if ($id == 0 || $id > 3) { $fields[] = array('label' => _NAME, 'type' => 'text', 'value' => $item->name, 'name' => 'name', 'rule' => 'required', 'extra' => 'class="large"'); } else { $fields[] = array('label' => null, 'type' => 'html', 'value' => '<h4>' . _AREA . ': ' . $item->name . '</h4>'); $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $item->name, 'name' => 'name'); } $fields[] = array('label' => _TITLE, 'type' => 'text', 'value' => $item->title, 'name' => 'title', 'rule' => 'required', 'extra' => 'class="large"'); $fields[] = array('label' => _DESCRIPTION, 'type' => 'textarea', 'value' => $item->description, 'name' => 'description'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="band inner-pad clearfix"><div class="one-half xs-one-whole">'); // languages section $lang = new Language_model(); $fields[] = array('label' => _ENABLED_LANGUAGES, 'type' => 'select', 'value' => $lang->get_alang_array($id), 'options' => array($lang->get_languages(), 'code', 'language'), 'name' => 'languages', 'rule' => 'required', 'extra' => 'class="large"', 'multiple' => 4); $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-half xs-one-whole">'); $fields[] = array('label' => _DEFAULT_LANG, 'type' => 'select', 'value' => $item->code, 'options' => array($lang->get_languages(), 'code', 'language'), 'name' => 'lang', 'rule' => 'inarray§languages', 'extra' => 'class="large"'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div>'); // theme section $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $item->id_theme, 'name' => 'old_id_theme'); // admin area can't change theme if ($id != 1) { $theme = new Theme_model(); $fields[] = array('label' => _THEME, 'type' => 'select', 'value' => $item->id_theme, 'name' => 'id_theme', 'options' => array($theme->get_installed(), 'id', 'description'), 'extra' => 'class="large"'); } else { $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $item->id_theme, 'name' => 'id_theme'); } $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="band inner-pad clearfix"><div class="one-half xs-one-whole">'); // areas subsequent to the default can be set as private if ($id == 0 || $id > 3) { $fields[] = array('label' => _FOLDER, 'type' => 'select', 'value' => $item->folder, 'name' => 'folder', 'options' => array($mod->get_folders(), 'folder', 'folder'), 'extra' => 'class="large"'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-half xs-one-whole">'); $fields[] = array('label' => _PRIVATE, 'type' => 'checkbox', 'value' => 1, 'name' => 'private', 'checked' => $item->private); } else { $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $item->folder, 'name' => 'folder'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-half xs-one-whole">'); $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $item->private, 'name' => 'private'); } $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div>'); // if submitted if (X4Route_core::$post) { $e = X4Validation_helper::form($fields, 'editor'); if ($e) { $this->editing($id, $_POST); } else { $this->notice($fields); } die; } // contents $view = new X4View_core('editor'); $view->title = $id ? _EDIT_AREA : _ADD_AREA; // form builder $view->form = X4Form_helper::doform('editor', BASE_URL . 'areas/edit/' . $id, $fields, array(_RESET, _SUBMIT, 'buttons'), 'post', '', 'onclick="setForm(\'editor\');"'); $view->js = ''; if ($id > 0 || $chk) { $view->render(TRUE); } else { return $view->render(); } }