Пример #1
0
 /**
  * Edit User profile
  *
  * @return  void
  */
 public function _default()
 {
     // load dictionaries
     $this->dict->get_wordarray(array('form', 'login', 'users', 'profile'));
     // get object
     $user = new User_model();
     $u = $user->get_by_id($_SESSION['xuid']);
     // build the form
     $fields = array();
     $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $u->id, 'name' => 'id');
     $lmod = new Language_model();
     $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="band inner-pad clearfix"><div class="one-half xs-one-whole">');
     $fields[] = array('label' => _LANGUAGE, 'type' => 'select', 'value' => $u->lang, 'options' => array($lmod->get_alanguages(1), 'code', 'language'), 'name' => 'lang', 'extra' => 'class="large"');
     $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-half xs-one-whole">');
     $fields[] = array('label' => _USERNAME, 'type' => 'text', 'value' => $u->username, 'name' => 'username', 'suggestion' => _USERNAME_RULE, 'rule' => 'required|alphanumeric|minlength§5', 'extra' => 'class="large"');
     $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div>');
     $fields[] = array('label' => null, 'type' => 'html', 'value' => '<h4 class="acenter">' . _PASSWORD_CHANGE_MSG . '</h4>');
     $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="band inner-pad clearfix"><div class="one-half xs-one-whole">');
     $fields[] = array('label' => _PASSWORD, 'type' => 'password', 'value' => '', 'name' => 'password', 'suggestion' => _PASSWORD_RULE, 'rule' => 'alphanumeric|minlength§5', 'extra' => 'class="large"');
     $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-half xs-one-whole">');
     $fields[] = array('label' => _REPEAT_PASSWORD, 'type' => 'password', 'value' => '', 'name' => 'password2', 'rule' => 'equal-password', 'extra' => 'class="large"');
     $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div>');
     $fields[] = array('label' => _DESCRIPTION, 'type' => 'textarea', 'value' => $u->description, 'name' => 'description', 'sanitize' => 'string', 'rule' => 'required');
     $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="band inner-pad clearfix"><div class="one-half xs-one-whole">');
     $fields[] = array('label' => _EMAIL, 'type' => 'text', 'value' => $u->mail, 'name' => 'mail', 'rule' => 'required|mail', 'extra' => 'class="large"');
     $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-half xs-one-whole">');
     $fields[] = array('label' => _PHONE, 'type' => 'text', 'value' => $u->phone, 'name' => 'phone', 'rule' => 'phone', 'extra' => 'class="large"');
     $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div>');
     // if submitted
     if (X4Route_core::$post) {
         $e = X4Validation_helper::form($fields, 'profile');
         if ($e) {
             $this->profiling($_POST);
         } else {
             $this->notice($fields);
         }
         die;
     }
     // get page
     $page = $this->get_page('profile');
     // content
     $view = new X4View_core('container');
     $view->content = new X4View_core('editor');
     $view->content->close = false;
     $view->content->page = $page;
     // form builder
     $view->content->title = _EDIT_PROFILE;
     $view->content->form = '<div class="band"><div class="one-third push-one-third sm-one-whole sm-push-none">' . X4Form_helper::doform('profile', $_SERVER["REQUEST_URI"], $fields, array(_RESET, _SUBMIT, 'buttons'), 'post', '', 'onclick="setForm(\'profile\');"') . '</div></div>';
     $view->render(TRUE);
 }
Пример #2
0
 /**
  * Edit site form (use Ajax)
  *
  * @param   integer  $id Site ID
  * @return  void
  */
 public function edit($id)
 {
     // load dictionary
     $this->dict->get_wordarray(array('form', 'sites'));
     // get object
     $site = $this->site->get_by_id($id);
     // build the form
     $fields = array();
     $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id, 'name' => 'id');
     $fields[] = array('label' => _X3CMS . ' ' . _VERSION, 'type' => 'text', 'value' => $site->version, 'name' => 'version', 'extra' => 'class="large" disabled="disabled"');
     $fields[] = array('label' => _KEYCODE, 'type' => 'text', 'value' => $site->xcode, 'name' => 'xcode', 'extra' => 'class="large"');
     $fields[] = array('label' => _DOMAIN, 'type' => 'text', 'value' => $site->domain, 'name' => 'domain', 'rule' => 'required|url', 'extra' => 'class="large"');
     // if submitted
     if (X4Route_core::$post) {
         $e = X4Validation_helper::form($fields, 'editor');
         if ($e) {
             $this->editing($_POST);
         } else {
             $this->notice($fields);
         }
         die;
     }
     // contents
     $view = new X4View_core('editor');
     $view->title = _EDIT_SITE;
     // form builder
     $view->form = X4Form_helper::doform('editor', $_SERVER["REQUEST_URI"], $fields, array(_RESET, _SUBMIT, 'buttons'), 'post', '', 'onclick="setForm(\'editor\');"');
     $view->render(TRUE);
 }
Пример #3
0
    /**
     * Date settings form for time window of article's version (use Ajax)
     *
     * @param   integer $id Article ID
     * @return  void
     */
    public function setdate($id)
    {
        // load dictionaries
        $this->dict->get_wordarray(array('form', 'history', 'articles'));
        // get object
        $mod = new Article_model();
        $obj = $mod->get_by_id($id, 'articles', 'date_in, date_out');
        // build the form
        $fields = array();
        $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="band inner-pad clearfix"><div class="one-half xs-one-whole">');
        $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id, 'name' => 'id');
        $fields[] = array('label' => _START_DATE, 'type' => 'text', 'value' => date('Y-m-d', $obj->date_in), 'name' => 'date_in', 'rule' => 'required|date', 'extra' => 'class="date date_toggled large"');
        $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-half xs-one-whole">');
        $fields[] = array('label' => _END_DATE, 'type' => 'text', 'value' => $obj->date_out > 0 ? date('Y-m-d', $obj->date_out) : '', 'name' => 'date_out', 'suggestion' => _LEAVE_EMPTY_FOR_UNDEFINED, 'rule' => 'date|after-date_in', 'extra' => 'class="date date_toggled large sweep"');
        $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div>');
        // if submitted
        if (X4Route_core::$post) {
            $e = X4Validation_helper::form($fields, 'editor');
            if ($e) {
                $this->setting_date($_POST);
            } else {
                $this->notice($fields);
            }
            die;
        }
        // content
        $view = new X4View_core('editor');
        $view->title = _SET_DATE;
        // 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()
{
	if ($chk($$("input.date"))) {
		pickerize(1);
	}
});
</script>';
        $view->render(TRUE);
    }
Пример #4
0
    /**
     * 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);
    }
Пример #5
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);
 }
Пример #6
0
    /**
     * 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);
    }
Пример #7
0
    /**
     * Edit User permission on table's records
     *
     * @param   integer	$id_user User ID
     * @param   integer	$id_area Area ID
     * @param   string	$table Table name
     * @return  void
     */
    public function permissions($id_user, $id_area, $table)
    {
        // load dictionaries
        $this->dict->get_wordarray(array('form', 'groups', 'users'));
        $mod = new Permission_model();
        // get user name
        $u = $mod->get_by_id($id_user, 'users', 'username');
        // get area name
        $a = $mod->get_by_id($id_area, 'areas', 'name');
        // get user privileges on the table
        $what = $mod->get_detail($id_user, $id_area, $table);
        // permission levels
        $l = $mod->get_levels();
        $fields = array();
        $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id_user, 'name' => 'id_user');
        $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id_area, 'name' => 'id_area');
        $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $table, 'name' => 'what');
        $c = 0;
        // if table is not empty
        if ($what) {
            $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="band inner-pad clearfix">');
            // each record
            foreach ($what as $i) {
                $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="one-half xs-one-whole">');
                $value = is_null($i->level) ? 0 : $i->level;
                $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $i->id, 'name' => 'id_' . $c);
                $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $value, 'name' => 'old_value_' . $c);
                $fields[] = array('label' => $i->name, 'type' => 'select', 'value' => $value, 'name' => 'value_' . $c, 'options' => array($l, 'id', 'name', 0), 'suggestion' => strip_tags($i->description), 'extra' => 'class="large"');
                $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div>');
                $c++;
            }
            $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div>');
        }
        // if submitted
        if (X4Route_core::$post) {
            $e = X4Validation_helper::form($fields, 'detpriv');
            if ($e) {
                $this->detailing($_POST);
            } else {
                $this->notice($fields);
            }
            die;
        }
        // content
        $view = new X4View_core('editor');
        $view->title = _EDIT_PRIV . ': ' . $a->name . _TRAIT_ . ucfirst($table);
        // form builder
        $view->form = '<div id="scrolled">' . X4Form_helper::doform('detpriv', $_SERVER["REQUEST_URI"], $fields, array(_RESET, _SUBMIT, 'buttons'), 'post', '', 'onclick="setForm(\'detpriv\');"') . '</div>';
        $view->js = '
<script>
window.addEvent("domready", function()
{
	var myScroll = new Scrollable($("scrolled"));
});
</script>';
        $view->render(TRUE);
    }
Пример #8
0
 /**
  * Editor file
  *
  * @param integer	$id_file	File ID
  * @return  void
  */
 public function editor($id_file)
 {
     $this->dict->get_wordarray(array('files', 'form'));
     // get page
     $page = $this->get_page('files/editor');
     $navbar = array($this->site->get_bredcrumb($page));
     // content
     $view = new X4View_core('container_two');
     // right
     $view->right = new X4View_core('editor');
     $view->right->close = false;
     // left
     $view->content = new X4View_core('files/file_editor');
     $view->content->page = $page;
     $mod = new File_model();
     $file = $mod->get_by_id($id_file);
     if ($file) {
         // if the file exists
         $view->content->navbar = $navbar;
         $view->content->id_area = $file->id_area;
         $view->content->file = $file;
         $view->content->file_path = $mod->file_path;
         // switch to set where display the form
         $form = 'right';
         $tinymce = false;
         $reset = _RESET;
         $submit = _SUBMIT;
         // build the form
         $fields = array();
         // switch by type
         switch ($file->xtype) {
             case 0:
                 // images
                 // image size
                 $size = file_exists($mod->file_path . 'img/' . $file->name) ? getimagesize($mod->file_path . 'img/' . $file->name) : '';
                 $view->content->width = $size[0];
                 $view->content->height = $size[1];
                 // editor form
                 $fields[] = array('label' => null, 'type' => 'html', 'value' => '<h3> Zoom 1:<span id="zoom_label">1</span></h3>');
                 $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id_file, 'name' => 'id');
                 $fields[] = array('label' => null, 'type' => 'hidden', 'value' => 1, 'name' => 'zoom');
                 $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="band inner-pad clearfix"><div class="one-half xs-one-whole">');
                 $fields[] = array('label' => _IMAGE_XCOORD, 'type' => 'text', 'value' => 0, 'name' => 'xcoord', 'rule' => 'numeric', 'extra' => 'class="aright large"');
                 $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-half xs-one-whole">');
                 $fields[] = array('label' => _IMAGE_YCOORD, 'type' => 'text', 'value' => 0, 'name' => 'ycoord', 'rule' => 'numeric', 'extra' => 'class="aright large"');
                 $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div>');
                 $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="band inner-pad clearfix"><div class="one-half xs-one-whole">');
                 $fields[] = array('label' => _IMAGE_WIDTH, 'type' => 'text', 'value' => $size[0], 'name' => 'width', 'rule' => 'numeric', 'extra' => 'class="aright large"');
                 $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-half xs-one-whole">');
                 $fields[] = array('label' => _IMAGE_HEIGHT, 'type' => 'text', 'value' => $size[1], 'name' => 'height', 'rule' => 'numeric', 'extra' => 'class="aright large"');
                 $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div>');
                 $fields[] = array('label' => _IMAGE_LOCK_RATIO, 'type' => 'checkbox', 'value' => 1, 'name' => 'ratio');
                 $fields[] = array('label' => _IMAGE_ROTATE, 'type' => 'slider', 'value' => 0, 'name' => 'slider');
                 $fields[] = array('label' => null, 'type' => 'text', 'value' => 0, 'name' => 'rotate', 'extra' => 'readonly class="large acenter noborder"');
                 $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="acenter" style="overflow:hidden;"><img id="imagethumb" src="' . FPATH . 'img/' . $file->name . '?t=' . time() . '" style="max-width:250px" /></div>');
                 $fields[] = array('label' => _IMAGE_AS_NEW, 'type' => 'checkbox', 'value' => 1, 'name' => 'asnew', 'checked' => 1);
                 break;
             case 1:
                 // generic file
                 // template
                 $form = 'left';
                 $view->right = '';
                 $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id_file, 'name' => 'id');
                 $content = file_get_contents(APATH . 'files/filemanager/files/' . $file->name);
                 $fields[] = array('label' => _TEMPLATE_EDIT, 'type' => 'textarea', 'value' => $content, 'name' => 'content');
                 break;
             case 2:
                 // media files
                 $mime = X4Files_helper::get_mime(APATH . 'files/filemanager/media/' . $file->name);
                 $data = X4getid3_helper::analyze(APATH . 'files/filemanager/media/' . $file->name);
                 $view->content->mime = $mime;
                 $view->content->width = $data['video']['resolution_x'];
                 $view->content->height = $data['video']['resolution_y'];
                 $fields[] = array('label' => null, 'type' => 'html', 'value' => '<h3> Filesize: ' . number_format($data['filesize'] / (1024 * 1024), 2, '.', ',') . ' MB</h3><p>' . _VIDEO_FORMAT_MSG . '</p>');
                 $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id_file, 'name' => 'id');
                 $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $mime, 'name' => 'old_format');
                 if ($mime != 'video/x-flv' && $mime != 'application/vnd.adobe.flash.movie' && $mime != 'application/x-shockwave-flash') {
                     $fields[] = array('label' => _VIDEO_GET_IMAGE, 'type' => 'checkbox', 'value' => 1, 'name' => 'capture');
                 }
                 $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div id="video_section"><h4>' . _VIDEO_EDIT . '</h4>');
                 $options = array(array('value' => 'video/quicktime', 'option' => 'MOV'), array('value' => 'video/mp4', 'option' => 'MP4'), array('value' => 'video/webm', 'option' => 'WEBM'), array('value' => 'video/ogg', 'option' => 'OGV mime 1'), array('value' => 'application/ogg', 'option' => 'OGV mime 2'), array('value' => 'video/x-flv', 'option' => 'FLV'), array('value' => 'video/avi', 'option' => 'AVI'), array('value' => 'application/vnd.adobe.flash.movie', 'option' => 'SWF flash-movie'), array('value' => 'application/x-shockwave-flash', 'option' => 'SWF shockwave-flash'));
                 $fields[] = array('label' => _VIDEO_FORMAT, 'type' => 'select', 'value' => $mime, 'options' => array(X4Utils_helper::array2obj($options, 'value', 'option'), 'value', 'option'), 'name' => 'format', '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' => null, 'type' => 'hidden', 'value' => $data['video']['resolution_x'], 'name' => 'old_width');
                 $fields[] = array('label' => _IMAGE_WIDTH, 'type' => 'text', 'value' => $data['video']['resolution_x'], 'name' => 'width', 'rule' => 'numeric|min§1', 'extra' => 'class="aright large"');
                 $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-half xs-one-whole">');
                 $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $data['video']['resolution_y'], 'name' => 'old_height');
                 $fields[] = array('label' => _IMAGE_HEIGHT, 'type' => 'text', 'value' => $data['video']['resolution_y'], 'name' => 'height', 'rule' => 'numeric|min§1', 'extra' => 'class="aright large"');
                 $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div>');
                 if ($mime != 'application/vnd.adobe.flash.movie' && $mime != 'application/x-shockwave-flash') {
                     $fields[] = array('label' => _IMAGE_LOCK_RATIO, 'type' => 'checkbox', 'value' => 1, 'name' => 'ratio');
                     $fields[] = array('label' => _IMAGE_AS_NEW, 'type' => 'checkbox', 'value' => 1, 'name' => 'asnew', 'checked' => 1);
                 } else {
                     $fields[] = array('label' => null, 'type' => 'html', 'value' => '<h4>' . _VIDEO_SWF_MSG . '</h4>');
                     $reset = null;
                     $submit = null;
                 }
                 $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div id="image_section"><h4>' . _VIDEO_GET_IMAGE . '</h4>');
                 $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="band inner-pad clearfix"><div class="one-half xs-one-whole">');
                 $fields[] = array('label' => _IMAGE_WIDTH, 'type' => 'text', 'value' => $data['video']['resolution_x'], 'name' => 'iwidth', 'rule' => 'numeric|min§1', 'extra' => 'class="aright large"');
                 $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-half xs-one-whole">');
                 $fields[] = array('label' => _IMAGE_HEIGHT, 'type' => 'text', 'value' => $data['video']['resolution_y'], 'name' => 'iheight', 'rule' => 'numeric|min§1', 'extra' => 'class="aright large"');
                 $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div>');
                 $fields[] = array('label' => _VIDEO_SEC, 'type' => 'text', 'value' => 0, 'name' => 'sec', 'rule' => 'numeric', 'extra' => 'class="large aright" readonly', 'suggestion' => _VIDEO_SEC_MSG);
                 $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div>');
                 break;
             case 3:
                 // template
                 $form = 'left';
                 $tinymce = true;
                 $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id_file, 'name' => 'id');
                 $content = file_get_contents(APATH . 'files/filemanager/template/' . $file->name);
                 $fields[] = array('label' => _TEMPLATE_EDIT, 'type' => 'textarea', 'value' => $content, 'name' => 'content');
                 break;
         }
         if ($form == 'right') {
             $view->right->title = $file->name;
             $view->right->form = X4Form_helper::doform('editor', $_SERVER["REQUEST_URI"], $fields, array($reset, $submit, 'buttons'), 'post', '', 'onclick="setForm(\'editor\')";', 'onclick="reset_editor()"');
         } else {
             if ($tinymce) {
                 // edit template
                 $view->content->form = X4Form_helper::doform('editor', $_SERVER["REQUEST_URI"], $fields, array($reset, $submit, 'buttons'), 'post', '', 'onclick="setForm(\'editor\', \'content\')";', 'onclick="reset_editor()"');
                 $view->content->tinymce = new X4View_core('tinymce');
                 $view->content->tinymce->id_area = $file->id_area;
             } else {
                 // edit generic text file
                 $view->content->form = X4Form_helper::doform('editor', $_SERVER["REQUEST_URI"], $fields, array($reset, $submit, 'buttons'), 'post', '', 'onclick="setForm(\'editor\')";', 'onclick="reset_editor()"');
             }
         }
         // if submitted
         if (X4Route_core::$post) {
             $e = X4Validation_helper::form($fields, 'editor');
             if ($e) {
                 $this->saving($id_file, $_POST);
             } else {
                 $this->notice($fields);
             }
             die;
         }
         $view->render(TRUE);
     } else {
         header('Location: ' . BASE_URL . 'files');
     }
 }
Пример #9
0
 /** 
  * Edit widget
  *
  * @return  void
  */
 public function edit()
 {
     // load dictionaries
     $this->dict->get_wordarray(array('form', 'widgets'));
     // get available widgets
     $mod = new Widget_model();
     $items = $mod->get_available_widgets($_SESSION['xuid']);
     $view = new X4View_core('editor');
     $view->title = _WIDGETS_NEW;
     if ($items) {
         // build the form
         $fields = array();
         $fields[] = array('label' => _WIDGETS_AVAILABLE, 'type' => 'select', 'value' => '', 'name' => 'id', 'options' => array($items, 'id', 'what', ''), 'disabled' => 'wid', 'rule' => 'required');
         // if submitted
         if (X4Route_core::$post) {
             $e = X4Validation_helper::form($fields, 'editor');
             if ($e) {
                 $this->editing($_POST);
             } else {
                 $this->notice($fields);
             }
             die;
         }
         // contents
         $view->msg = _WIDGETS_NEW_MSG;
         // form builder
         $view->form = X4Form_helper::doform('editor', $_SERVER["REQUEST_URI"], $fields, array(_RESET, _SUBMIT, 'buttons'), 'post', '', 'onclick="setForm(\'editor\');"');
     } else {
         $view->form = '<p>' . _NO_WIDGETS_TO_SET . '</p>';
     }
     $view->render(TRUE);
 }
Пример #10
0
 /**
  * New / Edit category form (use Ajax)
  *
  * @param   integer	$id_area Area ID
  * @param   integer	$id Category ID
  * @return  void
  */
 public function edit($id_area, $lang, $tag = '', $id = 0)
 {
     // load dictionaries
     $this->dict->get_wordarray(array('form', 'categories'));
     // handle id
     $chk = false;
     if ($id < 0) {
         $id = 0;
         $chk = true;
     }
     // get object
     $mod = new Category_model();
     $m = $id ? $mod->get_by_id($id) : new Category_obj($id_area, $lang, $tag);
     // build the form
     $fields = array();
     $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id, 'name' => 'id');
     if (MULTIAREA) {
         $amod = new Area_model();
         $fields[] = array('label' => _AREA, 'type' => 'select', 'value' => $m->id_area, 'options' => array($amod->get_areas(), 'id', 'name'), 'name' => 'id_area', 'extra' => 'class="large"');
     } else {
         $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $m->id_area, 'name' => 'id_area');
     }
     if (MULTILANGUAGE) {
         $lmod = new Language_model();
         $fields[] = array('label' => _LANGUAGE, 'type' => 'select', 'value' => $m->lang, 'options' => array($lmod->get_languages(), 'code', 'language'), 'name' => 'lang', 'extra' => 'class="large"');
     } else {
         $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $m->lang, 'name' => 'lang');
     }
     $fields[] = array('label' => _TITLE, 'type' => 'text', 'value' => $m->title, 'name' => 'title', 'rule' => 'required', 'extra' => 'class="large"');
     $fields[] = array('label' => _CATEGORY_TAG, 'type' => 'text', 'value' => $m->tag, 'name' => 'tag', 'extra' => 'class="large"', 'suggestion' => _CATEGORY_TAG_MSG);
     // if submitted
     if (X4Route_core::$post) {
         $e = X4Validation_helper::form($fields, 'editor');
         if ($e) {
             $this->editing($id, $_POST);
         } else {
             $this->notice($fields);
         }
         die;
     }
     // content
     $view = new X4View_core('editor');
     $view->title = $id ? _EDIT_CATEGORY : _ADD_CATEGORY;
     // form builder
     $view->form = X4Form_helper::doform('editor', $_SERVER["REQUEST_URI"], $fields, array(_RESET, _SUBMIT, 'buttons'), 'post', '', 'onclick="setForm(\'editor\');"');
     $view->js = '';
     if ($id > 0 || $chk) {
         $view->render(TRUE);
     } else {
         return $view->render();
     }
 }
Пример #11
0
    /**
     * Edit group permission (use Ajax)
     *
     * @param   integer	$id_group Group ID
     * @return  void
     */
    public function gperm($id_group)
    {
        // load dictionaries
        $this->dict->get_wordarray(array('form', 'groups'));
        // get objects (group permissions)
        $mod = new Permission_model();
        $gp = X4Utils_helper::obj2array($mod->get_gprivs($id_group), 'what', 'level');
        // get area data
        $g = $mod->get_by_id($id_group, 'groups', 'id_area');
        $a = $mod->get_by_id($g->id_area, 'areas', 'private');
        // build the form
        $fields = array();
        $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id_group, 'name' => 'id');
        $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $a->private, 'name' => 'xrif');
        // available permission levels
        $l = $mod->get_levels();
        $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="band inner-pad clearfix">');
        // registered group permissions
        $types = $mod->get_privtypes($a->private);
        foreach ($types as $i) {
            $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="one-half xs-one-whole">');
            // actual permission level
            $value = isset($gp[$i->name]) ? $gp[$i->name] : 0;
            $fields[] = array('label' => constant($i->description), 'type' => 'select', 'value' => $value, 'name' => $i->name, 'options' => array($l, 'id', 'name', 0), 'extra' => 'class="large"');
            $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $value, 'name' => 'old_' . $i->name);
            $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div>');
        }
        $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div>');
        // if submitted
        if (X4Route_core::$post) {
            $e = X4Validation_helper::form($fields, 'gprivs');
            if ($e) {
                $this->permitting($_POST);
            } else {
                $this->notice($fields);
            }
            die;
        }
        // contents
        $view = new X4View_core('editor');
        $view->title = _GROUP_PERMISSION;
        // form builder
        $view->form = '<div id="scrolled">' . X4Form_helper::doform('gprivs', $_SERVER["REQUEST_URI"], $fields, array(_RESET, _SUBMIT, 'buttons'), 'post', '', 'onclick="setForm(\'gprivs\');"') . '</div>';
        $view->js = '
<script>
window.addEvent("domready", function()
{
	var myScroll = new Scrollable($("scrolled"));
});
</script>';
        $view->render(TRUE);
    }
Пример #12
0
 /**
  * New / Edit menu form (use Ajax)
  *
  * @param   integer  $id_theme Theme id
  * @param   integer  $id item ID (if 0 then is a new item)
  * @return  void
  */
 public function edit($id_theme, $id = 0)
 {
     // load dictionaries
     $this->dict->get_wordarray(array('form', 'menus'));
     // get object
     $menu = new Menu_model();
     $m = $id ? $menu->get_by_id($id) : new Menu_obj($id_theme);
     // build the form
     $fields = array();
     $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id, 'name' => 'id');
     $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $m->id_theme, 'name' => 'id_theme');
     $fields[] = array('label' => _NAME, 'type' => 'text', 'value' => $m->name, 'name' => 'name', 'rule' => 'required', 'extra' => 'class="large"');
     $fields[] = array('label' => _DESCRIPTION, 'type' => 'textarea', 'value' => $m->description, 'name' => 'description', 'extra' => 'class="large"');
     // 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_MENU : _ADD_MENU;
     // form builder
     $view->form = X4Form_helper::doform('editor', $_SERVER["REQUEST_URI"], $fields, array(_RESET, _SUBMIT, 'buttons'), 'post', '', 'onclick="setForm(\'editor\');"');
     $view->render(TRUE);
 }
Пример #13
0
 /**
  * Import all dictionary words from another area (use Ajax)
  *
  * @param   string 	$lang Language code
  * @param   string 	$area Area name
  * @return  void
  */
 public function import($lang, $area)
 {
     // load dictionaries
     $this->dict->get_wordarray(array('form', 'dictionary'));
     // build the form
     $fields = array();
     $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $lang, 'name' => 'lang');
     $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $area, 'name' => 'area', 'extra' => 'class="large"');
     $fields[] = array('label' => null, 'type' => 'html', 'value' => '<h4>' . _IMPORT_INTO . ' ' . $lang . '/' . $area . '</h4>' . _IMPORT_INTO_MSG);
     $dict = new Dictionary_model();
     $fields[] = array('label' => _SECTION, 'type' => 'select', 'value' => '', 'name' => 'what', 'options' => array($dict->get_section_options(), 'value', 'option'), 'rule' => 'required', 'extra' => 'class="large"');
     // if submitted
     if (X4Route_core::$post) {
         $e = X4Validation_helper::form($fields, 'import');
         if ($e) {
             $this->importing($_POST);
         } else {
             $this->notice($fields);
         }
         die;
     }
     // contents
     $view = new X4View_core('editor');
     $view->title = _IMPORT_KEYS;
     // form builder
     $view->form = X4Form_helper::doform('import', $_SERVER["REQUEST_URI"], $fields, array(_RESET, _SUBMIT, 'buttons'), 'post', '', 'onclick="setForm(\'import\');"');
     $view->render(TRUE);
 }
Пример #14
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);
 }
Пример #15
0
    /**
     * Plugin configuration form (use Ajax)
     *
     * @param   integer  $id Module ID
     * @return  void
     */
    public function config($id)
    {
        // load dictionaries
        $this->dict->get_wordarray(array('modules', 'form'));
        // get object
        $plug = new X4Plugin_model();
        $plugin = $plug->get_by_id($id);
        // get params
        $params = $plug->get_param($plugin->name, $plugin->id_area);
        // build the form
        $fields = array();
        $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id, 'name' => 'id');
        $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $plugin->name, 'name' => 'xrif');
        $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $plugin->id_area, 'name' => 'id_area');
        // Build specific fields
        foreach ($params as $i) {
            switch ($i->xtype) {
                case 'HIDDEN':
                    // do nothing
                    break;
                case '0|1':
                case 'BOOLEAN':
                    // boolean
                    $tmp = array('label' => ucfirst(str_replace('_', ' ', $i->name)) . _TRAIT_ . $i->description, 'type' => 'checkbox', 'value' => $i->xvalue, 'name' => $i->name, 'rule' => '', 'suggestion' => _ON . '/' . _OFF);
                    if ($i->xvalue == '1') {
                        $tmp['checked'] = 1;
                    }
                    break;
                case 'IMG':
                    // TODO: manage image set as param
                    break;
                case 'INTEGER':
                    // integer
                    $tmp = array('label' => ucfirst(str_replace('_', ' ', $i->name)) . _TRAIT_ . $i->description, 'type' => 'text', 'value' => $i->xvalue, 'name' => $i->name, 'suggestion' => $i->xtype, 'extra' => 'class="aright large"', 'rule' => 'numeric');
                    break;
                case 'EMAIL':
                    // email
                    $tmp = array('label' => ucfirst(str_replace('_', ' ', $i->name)) . _TRAIT_ . $i->description, 'type' => 'text', 'value' => $i->xvalue, 'name' => $i->name, 'suggestion' => $i->xtype, 'rule' => 'mail', 'extra' => 'class="large"');
                    break;
                case 'BLOB':
                    // long string
                    $tmp = array('label' => ucfirst(str_replace('_', ' ', $i->name)) . _TRAIT_ . $i->description, 'type' => 'textarea', 'value' => $i->xvalue, 'name' => $i->name, 'rule' => '', 'suggestion' => $i->xtype, 'extra' => 'class="large"');
                    break;
                default:
                    // string
                    $tmp = array('label' => ucfirst(str_replace('_', ' ', $i->name)) . _TRAIT_ . $i->description, 'type' => 'text', 'value' => $i->xvalue, 'name' => $i->name, 'rule' => '', 'suggestion' => $i->xtype, 'extra' => 'class="large"');
                    break;
            }
            if ($i->required == '1') {
                $tmp['rule'] = 'required|' . $tmp['rule'];
            }
            if ($i->xtype != 'HIDDEN') {
                $fields[] = $tmp;
            }
        }
        // if submitted
        if (X4Route_core::$post) {
            $e = X4Validation_helper::form($fields, 'configure');
            if ($e) {
                $this->configure($plugin, $_POST);
            } else {
                $this->notice($fields);
            }
            die;
        }
        // contents
        $view = new X4View_core('editor');
        $view->title = _MODULE_CONFIG . ': ' . $plugin->name;
        // form builder
        $view->form = '<div id="scrolled">' . X4Form_helper::doform('configure', $_SERVER["REQUEST_URI"], $fields, array(_RESET, _SUBMIT, 'buttons'), 'post', '', 'onclick="setForm(\'configure\');"') . '</div>';
        $view->js = '
<script>
window.addEvent("domready", function()
{
var myScroll = new Scrollable($("scrolled"));
});
</script>';
        $view->render(TRUE);
    }
Пример #16
0
 /**
  * Display search results
  *
  * @return  void
  */
 public function _default()
 {
     // load dictionary
     $this->dict->get_wordarray(array('search'));
     // get page data
     $page = $this->get_page('search');
     $view = new X4View_core(X4Utils_helper::set_tpl($page->tpl));
     $view->page = $page;
     // build the message
     $tmp = '';
     // search
     // if submitted
     if (X4Route_core::$post && trim($_POST['search']) != '') {
         // found counter
         $tot = 0;
         // sanitize
         $str = X4Validation_helper::sanitize(strtolower($_POST['search']), 'string');
         // handle _POST
         $str = explode(' ', addslashes($str));
         // search in area's articles
         $found = $this->site->search($page->id_area, $str);
         // build links to items found
         if ($found) {
             // update counter
             $tot += sizeof($found);
             // set message
             $tmp .= '<strong>' . _SEARCH_PAGES . '</strong></p><ul class="search_result">';
             // build links to items found
             foreach ($found as $i) {
                 $tmp .= '<li><a href="' . $i->url . '" title="' . stripslashes($i->description) . '">' . stripslashes($i->name) . '</a>' . _TRAIT_ . nl2br(stripslashes($i->description)) . '</li>';
             }
             $tmp .= '</ul>';
         }
         // modules
         $plug = new X4Plugin_model();
         // get searchable plugins
         $searchable = $plug->get_searchable($page->id_area);
         if ($searchable) {
             foreach ($searchable as $i) {
                 // model to load
                 $model = ucfirst($i->name) . '_model';
                 $mod = new $model();
                 // get page URL to use as link
                 if (isset($mod->search_param)) {
                     $to_page = $this->site->get_page_to($page->id_area, $page->lang, $i->name, $mod->search_param);
                 } else {
                     $to_page = $this->site->get_page_to($page->id_area, $page->lang, $i->name, '*');
                 }
                 // perform plugin search
                 $found = $mod->search($page->id_area, $page->lang, $str);
                 // build links to items found
                 if ($found) {
                     // plugin name
                     $plugin = strtoupper($i->name);
                     // update counter
                     $tot += sizeof($found);
                     // set message
                     if (defined('_SEARCH_' . $plugin)) {
                         $tmp .= '<strong>' . constant('_SEARCH_' . $plugin) . '</strong></p>';
                     }
                     // build links to items found
                     $tmp .= '<ul class="search_result">';
                     foreach ($found as $ii) {
                         // create url
                         $url = isset($mod->personalized_url) && $mod->personalized_url ? $mod->get_url($ii, $to_page) : $to_page . '/' . $ii->id . '/detail';
                         // item name
                         $item = stripslashes($ii->name);
                         $description = empty($ii->description) ? '' : _TRAIT_ . stripslashes($ii->description);
                         // link to item
                         $tmp .= '<li><a href="' . $url . '" title="' . $item . '">' . $item . '</a>' . $description . '</li>';
                     }
                     $tmp .= '</ul>';
                 }
             }
         }
         // if found
         if ($tot) {
             $tmp = '<p>' . _SEARCH_FOUND . ' ' . $tot . ' ' . _SEARCH_ITEMS . '</p>' . $tmp;
         } else {
             $tmp .= '<p>' . _SEARCH_ZERO_RESULT . '</p>';
         }
         $msg = new Obj_msg(_SEARCH_RESULT, _SEARCH_OF . ' <strong>' . addslashes($_POST['search']) . '</strong>' . $tmp, false);
     } else {
         // empty request
         $msg = new Obj_msg(_SEARCH_RESULT, '<p>' . _SEARCH_MSG_SEARCH_EMPTY . '</p>');
     }
     // get menus
     $view->menus = $this->site->get_menus($page->id_area);
     $view->navbar = array($this->site->get_bredcrumb($page));
     // popolate section
     $sections = $this->site->get_sections($page->id);
     $sections[1] = array($msg);
     $view->sections = $sections;
     $view->render(TRUE);
 }
Пример #17
0
 /**
  * Validate a form
  * on each field you can mix many rules (with |) and some rules can contains parameter (with § as separator)
  *
  * @static
  * @param array		array of form fields
  * @param string	form name
  * @return boolean
  */
 public static function form(&$fields, $form_name = '', $method = 'post')
 {
     // share the array of fields in the class
     self::$fields = $fields;
     // share the array of data
     self::$data = $method == 'post' ? $_POST : $_GET;
     $e = true;
     // check x4token
     if (!empty($form_name) && (!isset(self::$data['x4token']) || self::$data['x4token'] != md5($_SESSION['token'] . $form_name))) {
         $e = false;
         $_SESSION['token'] = uniqid(rand(), TRUE);
     } else {
         $n = sizeof($fields);
         for ($i = 0; $i < $n; $i++) {
             // check errors
             if (isset($fields[$i]['rule'])) {
                 $token = explode('|', $fields[$i]['rule']);
                 foreach ($token as $ii) {
                     // handle multiple select
                     $name = self::get_name($fields[$i]);
                     // get parameters
                     $tok = explode('§', $ii);
                     // set rule function name
                     $rule = '_' . $tok[0];
                     // if we have this validation function
                     if (method_exists(__CLASS__, $rule)) {
                         if (in_array($rule, self::$special_rules)) {
                             // special rules
                             self::$rule($fields[$i], $tok, $e, self::$data, $_FILES);
                         } else {
                             // here rules checked only if the field value is not empty
                             if (!empty(self::$data[$fields[$i]['name']])) {
                                 self::$rule($fields[$i], $tok, $e, self::$data, $_FILES);
                             }
                         }
                     }
                 }
             }
             // assign the value
             if (!in_array($fields[$i]['type'], X4Form_helper::$exclude) && (isset($fields[$i]['name']) && isset(self::$data[$fields[$i]['name']]) && !empty(self::$data[$fields[$i]['name']]))) {
                 switch ($fields[$i]['type']) {
                     case 'checkbox':
                         $fields[$i]['value'] = 1;
                         $fields[$i]['checked'] = intval(isset(self::$data[$fields[$i]['name']]));
                         break;
                     case 'mcheckbox':
                         $fields[$i]['checked'] = isset(self::$data[$fields[$i]['name']]) ? self::$data[$fields[$i]['name']] : array();
                         break;
                     case 'radio':
                         if (isset(self::$data[$fields[$i]['name']])) {
                             $fields[$i]['checked'] = self::$data[$fields[$i]['name']];
                         }
                         break;
                     default:
                         // check for sanitize
                         $fields[$i]['value'] = isset($fields[$i]['sanitize']) ? self::sanitize(self::$data[$fields[$i]['name']], $fields[$i]['sanitize']) : self::$data[$fields[$i]['name']];
                         break;
                 }
             }
         }
     }
     return $e;
 }
Пример #18
0
 /**
  * New / Edit language 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', 'languages'));
     // handle id
     $chk = false;
     if ($id < 0) {
         $id = 0;
         $chk = true;
     }
     // get object
     $lang = new Language_model();
     $o = $id ? $lang->get_by_id($id) : new Lang_obj();
     // 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' => _CODE, 'type' => 'text', 'value' => $o->code, 'name' => 'code', 'rule' => 'required|minlength§2|maxlength§2', 'extra' => 'class="large"');
     $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-half xs-one-whole">');
     $fields[] = array('label' => _LANGUAGE, 'type' => 'text', 'value' => $o->language, 'name' => 'language', 'rule' => 'required', 'extra' => 'class="large"');
     $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div>');
     $fields[] = array('label' => _RTL_LANGUAGE, 'type' => 'checkbox', 'value' => $o->rtl, 'name' => 'rtl', 'checked' => $o->rtl);
     // 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_LANG : _ADD_LANG;
     // form builder
     $view->form = X4Form_helper::doform('editor', $_SERVER["REQUEST_URI"], $fields, array(_RESET, _SUBMIT, 'buttons'), 'post', '', 'onclick="setForm(\'editor\');"');
     if ($id > 0 || $chk) {
         $view->render(TRUE);
     } else {
         return $view->render();
     }
 }
Пример #19
0
    /**
     * SEO form data (use Ajax)
     *
     * @param   integer $id_area area ID
     * @return  void
     */
    public function seo($id_area)
    {
        // load dictionaries
        $this->dict->get_wordarray(array('form', 'areas', 'themes'));
        // build the form
        $fields = array();
        $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id_area, 'name' => 'id_area');
        $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div id="accordion">');
        // get the current data,
        // areas data relating to SEO are stored in 'alang'
        $lang = new Language_model();
        $m = $lang->get_seo_data($id_area);
        $c = 0;
        // for each enabled language
        foreach ($m as $i) {
            $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $i->id, 'name' => 'id_' . $c);
            $fields[] = array('label' => null, 'type' => 'html', 'value' => '<h4 class="context">' . ucfirst($i->language) . '</h4><div class="section">');
            $fields[] = array('label' => _NAME, 'type' => 'text', 'value' => $i->title, 'name' => 'title_' . $c, 'rule' => 'required', 'extra' => 'class="large"');
            $fields[] = array('label' => _DESCRIPTION, 'type' => 'textarea', 'value' => $i->description, 'name' => 'description_' . $c);
            $fields[] = array('label' => _KEYS, 'type' => 'textarea', 'value' => $i->keywords, 'name' => 'keywords_' . $c);
            $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div>');
            $c++;
        }
        $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div>');
        // if submitted
        if (X4Route_core::$post) {
            $e = X4Validation_helper::form($fields, 'editor');
            if ($e) {
                $this->editing_seo_data($id_area, $_POST);
            } else {
                $this->notice($fields);
            }
            die;
        }
        // contents
        $view = new X4View_core('editor');
        $view->title = _SEO_DATA;
        // 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()
{
	saccordion("accordion", "#accordion h4", "#accordion .section");
});
</script>';
        $view->render(TRUE);
    }