/** * Page compositing * * @param integer $id_page Page ID * @param string $by sort key * @return void */ public function compose($id_page, $by = 'name') { // load dictionaries $this->dict->get_wordarray(array('sections', 'form', 'articles')); // get object $mod = new Page_model('', '', $id_page); $page_to_edit = $mod->get_page_by_id($id_page); // get page $page = $this->get_page('sections/compose'); $navbar = array($this->site->get_bredcrumb($page), array('pages' => 'index/' . $page_to_edit->id_area . '/' . $page_to_edit->lang)); // content $view = new X4View_core('left'); // left $view->left = new X4View_core('sections/compose'); $view->left->navbar = $navbar; $view->left->pagetoedit = $page_to_edit; $smod = new Section_model(); $view->left->mod = $smod; // get contexts $view->left->dict = $this->dict; $view->left->codes = $smod->get_contexts($page_to_edit->id_area, $page_to_edit->lang); // get articles in area/language $view->left->articles = $smod->get_articles_to_publish($page_to_edit, $by); // get sections $view->left->sections = $smod->get_sections($page_to_edit); $view->left->referer = urlencode('sections/compose/' . $id_page); // template image $theme = $mod->get_theme($page_to_edit->id_area); $view->left->layout = file_exists(PATH . 'themes/' . $theme->name . '/img/' . $page_to_edit->tpl . '.png') ? ROOT . 'themes/' . $theme->name . '/img/' . $page_to_edit->tpl . '.png' : ''; $view->render(TRUE); }
/** * Edit SEO data of a page (use Ajax) * * @param integer $id Page ID * @return void */ public function seo($id) { // load dictionaries $this->dict->get_wordarray(array('form', 'pages')); // get object $mod = new Page_model('', '', $id); $page = $mod->get_page_by_id($id); // build the form $fields = array(); $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id, 'name' => 'id'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="band inner-pad clearfix"><div class="one-half xs-one-whole">'); $fields[] = array('label' => _FROM_PAGE, 'type' => 'select', 'value' => $page->xfrom, 'options' => array($mod->get_pages('', 0, $page->url), 'url', 'title'), 'name' => 'xfrom', 'rule' => 'required', 'extra' => 'class="large"'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-half xs-one-whole">'); $fields[] = array('label' => _NOT_IN_MAP, 'type' => 'checkbox', 'value' => $page->hidden, 'name' => 'hidden', 'checked' => $page->hidden); $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div>'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div id="accordion" class="gap-top">'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '<h4 class="context">' . _TEMPLATE . '</h4><div class="section">'); $fields[] = array('label' => _TEMPLATE, 'type' => 'select', 'value' => $page->tpl, 'options' => array($mod->get_templates(), 'name', 'description'), 'name' => 'tpl', 'extra' => 'class="large"'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><h4 class="context">' . _SEO_TOOLS . '</h4><div class="section">'); $fields[] = array('label' => _URL, 'type' => 'text', 'value' => $page->url, 'name' => 'url', 'rule' => 'required', 'extra' => 'class="large"'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="band inner-pad clearfix"><div class="one-half xs-one-whole">'); $fields[] = array('label' => _NAME, 'type' => 'text', 'value' => $page->name, 'name' => 'name', 'rule' => 'required', 'extra' => 'class="large"'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-half xs-one-whole">'); $fields[] = array('label' => _TITLE, 'type' => 'text', 'value' => $page->title, 'name' => 'title', 'rule' => 'required', 'extra' => 'class="large"'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div>'); $fields[] = array('label' => _DESCRIPTION, 'type' => 'textarea', 'value' => $page->description, 'name' => 'description'); $fields[] = array('label' => _KEYS, 'type' => 'textarea', 'value' => $page->xkeys, 'name' => 'xkeys'); $fields[] = array('label' => _ROBOT, 'type' => 'text', 'value' => $page->robot, 'name' => 'robot', 'suggestion' => _ROBOT_MSG, 'extra' => 'class="large"'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="band inner-pad clearfix"><div class="one-fifth xs-one-whole">'); $codes = array(301, 302); $fields[] = array('label' => _REDIRECT_CODE, 'type' => 'select', 'value' => $page->redirect_code, 'name' => 'redirect_code', 'options' => array(X4Array_helper::simplearray2obj($codes, 'value', 'option'), 'value', 'option', 0), 'extra' => 'class="large"'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="four-fifth xs-one-whole">'); $fields[] = array('label' => _REDIRECT, 'type' => 'text', 'value' => $page->redirect, 'name' => 'redirect', 'rule' => 'requiredif§redirect_code§!0|url', 'suggestion' => _REDIRECT_MSG, 'extra' => 'class="large"'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div>'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div>'); // if submitted if (X4Route_core::$post) { $e = X4Validation_helper::form($fields, 'editor'); if ($e) { $this->reg_seo($_POST); } else { $this->notice($fields); } die; } // contents $view = new X4View_core('editor'); $view->title = _SEO_TOOLS; // form builder $view->form = '<div id="scrolled">' . X4Form_helper::doform('editor', BASE_URL . 'pages/seo/' . $id, $fields, array(_RESET, _SUBMIT, 'buttons'), 'post', '', 'onclick="setForm(\'editor\');"') . '</div>'; $view->js = ' <script> window.addEvent("domready", function() { var myScroll = new Scrollable($("scrolled")); saccordion("accordion", "#accordion h4", "#accordion .section"); }); </script>'; $view->render(TRUE); }