/** * Build captcha image * * @param integer background * @return image file */ public function captcha($bg0 = 255, $bg1 = 255, $bg2 = 255) { $b0 = 255; if ($bg0 == '_default') { $bg0 = $b0; } X4Form_helper::captcha(5, 'whitrabt.ttf', array($bg0, $bg1, $bg2)); }
/** * 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); }
/** * Delete Language form (use Ajax) * * @param integer $id Language ID * @return void */ public function delete($id) { // load dictionary $this->dict->get_wordarray(array('form', 'languages')); // build the form $fields = array(); $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id, 'name' => 'id'); // if submitted if (X4Route_core::$post) { $this->deleting($_POST); die; } // get object $mod = new Language_model(); $obj = $mod->get_by_id($id, 'languages', 'language'); // contents $view = new X4View_core('delete'); $view->title = _DELETE_LANG; $view->item = $obj->language; // form builder $view->form = X4Form_helper::doform('delete', $_SERVER["REQUEST_URI"], $fields, array(null, _YES, 'buttons'), 'post', '', 'onclick="setForm(\'delete\');"'); $view->render(TRUE); }
/** * Uninstall a theme (use Ajax) * * @param integer $id Theme ID * @return void */ public function uninstall($id) { // load dictionary $this->dict->get_wordarray(array('form', 'themes')); // get object $theme = new Theme_model(); $obj = $theme->get_by_id($id, 'themes', 'name'); // build the form $fields = array(); $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id, 'name' => 'id'); $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $obj->name, 'name' => 'name'); // if submitted if (X4Route_core::$post) { $this->uninstalling($_POST); die; } // contents $view = new X4View_core('uninstall'); $view->title = _UNINSTALL_THEME; $view->msg = ''; $view->item = $obj->name; // form builder $view->form = X4Form_helper::doform('uninstall', $_SERVER["REQUEST_URI"], $fields, array(null, _YES, 'buttons'), 'post', '', 'onclick="setForm(\'uninstall\');"'); $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); }
/** * Delete a version of an Article form (use Ajax) * * @param integer $id Article id * @return void */ public function delete_version($id) { // load dictionaries $this->dict->get_wordarray(array('form', 'articles')); // build the form $fields = array(); $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id, 'name' => 'id'); // if submitted if (X4Route_core::$post) { $this->deleting_version($id); die; } // get object $mod = new Article_model(); $obj = $mod->get_by_id($id, 'articles', 'updated'); // contents $view = new X4View_core('delete'); $view->title = _DELETE_ARTICLE; $view->item = $obj->updated; // form builder $view->form = X4Form_helper::doform('delete', $_SERVER["REQUEST_URI"], $fields, array(_NO, _YES, 'xcenter'), 'post', '', 'onclick="setForm(\'delete\');"'); $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); }
/** * 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'); } }
/** * 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); }
/** * Delete context form (use Ajax) * * @param integer $id Context ID * @return void */ public function delete($id) { // get object $mod = new Context_model(); $obj = $mod->get_by_id($id, 'contexts', 'id_area, lang, name, code'); // only added context can be deleted if ($obj->code > 100) { // load dictionaries $this->dict->get_wordarray(array('form', 'contexts')); // build the form $fields = array(); $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id, 'name' => 'id'); // if submitted if (X4Route_core::$post) { $this->deleting($id, $obj); die; } // contents $view = new X4View_core('delete'); $view->title = _DELETE_CONTEXT; $view->item = $obj->name; // form builder $view->form = X4Form_helper::doform('delete', $_SERVER["REQUEST_URI"], $fields, array(null, _YES, 'buttons'), 'post', '', 'onclick="setForm(\'delete\');"'); $view->render(TRUE); } }