/** * Edit template/css form (use Ajax) * * @param string $what case (template|css) * @param string $theme Theme name * @param integer $id Template ID * @return void */ public function edit($what, $theme, $id) { // load dictionaries $this->dict->get_wordarray(array('form', 'template')); // get object $mod = new Template_model(); $item = $mod->get_by_id($id, 'templates', 'id_theme, name, css'); // path to file $file = $what == 'template' ? PATH . 'themes/' . $theme . '/templates/' . $item->name . '.php' : PATH . 'themes/' . $theme . '/css/' . $item->css . '.css'; // build the form $fields = array(); $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id, 'name' => 'id'); $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $item->id_theme, 'name' => 'id_theme'); $fields[] = array('label' => _FILE, 'type' => 'textarea', 'value' => htmlentities($this->replace(1, file_get_contents($file))), 'name' => 'code', 'extra' => 'class="editfile"', 'rule' => 'required', 'extra' => 'class="large"'); // if submitted if (X4Route_core::$post) { $e = X4Validation_helper::form($fields, 'editor'); if ($e) { $this->editing($_POST, $file); } else { $this->notice($fields); } die; } // contents $view = new X4View_core('editor'); $view->title = _EDIT . ' ' . $item->name; // form builder $view->form = X4Form_helper::doform('editor', $_SERVER["REQUEST_URI"], $fields, array(_RESET, _SUBMIT, 'buttons'), 'post', '', 'onclick="setForm(\'editor\');"'); $view->js = ' <script> window.addEvent("domready", function() { $("code").addClass("code"); }); </script>'; $view->render(TRUE); }
/** * Register SEO data * * @access private * @param array $_post _POST array * @return void */ private function reg_seo($_post) { $msg = null; // check permissions $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'pages', $_post['id'], 2); if (is_null($msg)) { // get object $mod = new Page_model('', '', $_post['id']); $page = $mod->get_by_id($_post['id'], 'pages', 'id_area, lang, url, xfrom'); // this pages cannot be changed $no_change = array('home', 'msg', 'search'); // remove slash from url if ($page->id_area > 1) { $_post['url'] = str_replace('/', '-', $_post['url']); } // handle _post $post = array('url' => !in_array($page->url, $no_change) ? X4Utils_helper::unspace($_post['url']) : $page->url, 'name' => $_post['name'], 'title' => $_post['title'], 'description' => $_post['description'], 'xfrom' => !in_array($page->url, $no_change) ? $_post['xfrom'] : $page->xfrom, 'hidden' => intval(isset($_post['hidden'])), 'xkeys' => $_post['xkeys'], 'robot' => $_post['robot'], 'redirect_code' => $_post['redirect_code'], 'redirect' => $_post['redirect'], 'tpl' => $_post['tpl']); // check if a page with the same URL already exists $check = (bool) $mod->exists($post['url'], $_post['id']); if ($check) { $msg = AdmUtils_helper::set_msg(false, '', $this->dict->get_word('_PAGE_ALREADY_EXISTS', 'msg')); } else { // set css for the page $tmod = new Template_model(); $css = $tmod->get_css($page->id_area, $_post['tpl']); $post['css'] = $css; // update page data $result = $mod->update_page($_post['id'], $post, $this->site->site->domain); if (APC) { apc_clear_cache(); apc_clear_cache('user'); apc_clear_cache('opcode'); } // set message $msg = AdmUtils_helper::set_msg($result); // set what update if ($result[1]) { $msg->update[] = array('element' => 'topic', 'url' => BASE_URL . 'pages/index/' . $page->id_area . '/' . $page->lang . '/' . str_replace('/', '-', $page->xfrom) . '/0/', 'title' => null); } } } $this->response($msg); }
/** * Save to database * * @access public * @param Template_Entity $entity * @return boolean TRUE on success, FALSE on failure. */ public function save_to_database(Template_Entity $entity) { // Check for fields and add as necessary $this->_add_protect_javascript_col(); return parent::save_to_database($entity); }