/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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'); } }
/** * 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(); } }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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(); } }
/** * 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); }