Пример #1
0
 /**
  * Edit article by ID
  *
  * @param	integer	$id Article ID
  * @return  void
  */
 public function edit($id = 0)
 {
     if ($id == 0) {
         $this->_default();
     } else {
         // load dictionaries
         $this->dict->get_wordarray(array('form', 'articles'));
         // get object
         $mod = new Article_model();
         $i = $mod->get_by_id($id);
         // cannot edit locked items
         if ($i->xlock == 1) {
             $this->_default();
         }
         // switch editor
         // default use Tiny MCE
         if (empty($i->xschema)) {
             // tinymce
             $fields = array();
             $fields[] = array('label' => null, 'type' => 'hidden', 'value' => 0, 'name' => 'schema');
             $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $_SERVER["HTTP_REFERER"], 'name' => 'from');
             $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $i->bid, 'name' => 'bid');
             $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $i->id_area, 'name' => 'id_area');
             $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $i->lang, 'name' => 'lang');
             $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $i->code_context, 'name' => 'code_context');
             $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $i->id_page, 'name' => 'id_page');
             $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $i->xkeys, 'name' => 'xkeys');
             $fields[] = array('label' => null, 'type' => 'hidden', 'value' => stripslashes($i->name), 'name' => 'name');
             $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $i->module, 'name' => 'module');
             $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $i->param, 'name' => 'param');
             // the only field not hidden
             $fields[] = array('label' => '', 'type' => 'textarea', 'value' => $i->content, 'name' => 'content');
         } else {
             // TODO: schema editor
         }
     }
     // if submitted
     if (X4Route_core::$post) {
         $e = X4Validation_helper::form($fields, 'editor');
         if ($e) {
             $this->editing($id, $_POST);
             die;
         } else {
             X4Utils_helper::set_error($fields);
         }
     }
     // get page
     $page = $this->get_page('x3admin');
     $view = new X4View_core(X4Utils_helper::set_tpl($page->tpl));
     $view->page = $page;
     // get menus
     $view->menus = $this->site->get_menus($page->id_area);
     $view->navbar = array($this->site->get_bredcrumb($page));
     // sections
     $view->args = array();
     $view->sections = array('', '');
     // content
     $view->content = new X4View_core('editor');
     $view->content->title = _EDIT_ARTICLE;
     // form builder
     $view->content->form = X4Form_helper::doform('editor', $_SERVER["REQUEST_URI"], $fields, array(_RESET, _SUBMIT, 'buttons'));
     if (empty($i->xschema)) {
         $view->content->tinymce = new X4View_core('tinymce');
         $view->content->tinymce->id_area = $page->id_area;
         $view->content->tinymce->tinybrowser = true;
     }
     $view->render(TRUE);
 }
Пример #2
0
 /**
  * Recovery password
  *
  * @return  void
  */
 public function recovery()
 {
     // load dictionary
     $this->dict->get_wordarray(array('login', 'form', 'pwd_recovery'));
     // get page
     $page = $this->get_page('login/recovery');
     $view = new X4View_core(X4Utils_helper::set_tpl($page->tpl));
     $view->page = $page;
     // get menus
     $view->menus = array();
     $view->navbar = array($this->site->get_bredcrumb($page));
     // build the form
     $fields = array();
     // antispam control
     $fields[] = array('label' => null, 'type' => 'hidden', 'value' => time(), 'name' => 'antispam');
     $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $page->id_area, 'name' => 'id_area');
     $fields[] = array('label' => _MAIL, 'type' => 'text', 'value' => '', 'name' => 'email', 'rule' => 'required|mail', 'sanitize' => 'string', 'extra' => 'class="large"');
     // if submitted, check control field
     if (X4Route_core::$post && array_key_exists(strrev('formrecovery'), $_POST)) {
         $e = X4Validation_helper::form($fields, 'formrecovery');
         if ($e && !isset($_POST['antispam'])) {
             $this->do_recovery($_POST);
             die;
         } else {
             X4Utils_helper::set_error($fields);
         }
     }
     // content
     $view->content = new X4View_core('recovery');
     // msg
     if (isset($_SESSION['msg']) && !empty($_SESSION['msg'])) {
         $view->content->msg = $_SESSION['msg'];
         unset($_SESSION['msg']);
     }
     // form builder
     $view->content->form = X4Form_helper::doform('formrecovery', $_SERVER['REQUEST_URI'], $fields, array(null, _SEND, 'buttons'));
     $view->render(TRUE);
 }