예제 #1
0
 /**
  * Page compositing
  *
  * @param   integer $id_page Page ID
  * @param   string  $by sort key
  * @return  void
  */
 public function compose($id_page, $by = 'name')
 {
     // load dictionaries
     $this->dict->get_wordarray(array('sections', 'form', 'articles'));
     // get object
     $mod = new Page_model('', '', $id_page);
     $page_to_edit = $mod->get_page_by_id($id_page);
     // get page
     $page = $this->get_page('sections/compose');
     $navbar = array($this->site->get_bredcrumb($page), array('pages' => 'index/' . $page_to_edit->id_area . '/' . $page_to_edit->lang));
     // content
     $view = new X4View_core('left');
     // left
     $view->left = new X4View_core('sections/compose');
     $view->left->navbar = $navbar;
     $view->left->pagetoedit = $page_to_edit;
     $smod = new Section_model();
     $view->left->mod = $smod;
     // get contexts
     $view->left->dict = $this->dict;
     $view->left->codes = $smod->get_contexts($page_to_edit->id_area, $page_to_edit->lang);
     // get articles in area/language
     $view->left->articles = $smod->get_articles_to_publish($page_to_edit, $by);
     // get sections
     $view->left->sections = $smod->get_sections($page_to_edit);
     $view->left->referer = urlencode('sections/compose/' . $id_page);
     // template image
     $theme = $mod->get_theme($page_to_edit->id_area);
     $view->left->layout = file_exists(PATH . 'themes/' . $theme->name . '/img/' . $page_to_edit->tpl . '.png') ? ROOT . 'themes/' . $theme->name . '/img/' . $page_to_edit->tpl . '.png' : '';
     $view->render(TRUE);
 }
예제 #2
0
 /**
  * Display system messages
  *
  * @param   string	$what Dictionary what
  * @param   string	$personal_msg Alternative message
  * @return  void
  */
 public function message($what = '', $personal_msg = '')
 {
     // load dictionary
     $this->dict->get_words();
     // get page
     $page = $this->get_page('msg');
     $view = new X4View_core(X4Utils_helper::set_tpl($page->tpl));
     $view->page = $page;
     // get menus
     $view->navbar = array($this->site->get_bredcrumb($page));
     $view->menus = $this->site->get_menus($page->id_area);
     // content
     $view->args = X4Route_core::$args;
     $qs = !empty(X4Route_core::$query_string) ? X4Route_core::get_query_string() : array();
     // set title
     if (isset($qs['ok'])) {
         switch ($qs['ok']) {
             case 1:
                 $title = _CONGRATULATIONS;
                 break;
             case 2:
                 $title = _MSG_OK;
                 break;
         }
     } else {
         $title = _WARNING;
     }
     // get message
     $msg = empty($personal_msg) ? $this->dict->get_message($title, strtoupper($what), 'msg') : $this->dict->build_message($title, $personal_msg, 'msg');
     $sections = $this->site->get_sections($page->id);
     $sections[1] = array($msg);
     $view->sections = $sections;
     $view->render(TRUE);
 }
예제 #3
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);
 }
예제 #4
0
 /**
  * Display error message
  *
  * @param   string	$what Dictionary what
  * @return  void
  */
 public function message($what = '')
 {
     // load dictionary
     $this->dict->get_words();
     // get page
     $page = $this->get_page('msg');
     $view = new X4View_core(AdmUtils_helper::set_tpl($page->tpl, $this->site->area->theme));
     $view->site = $this->site;
     $view->page = $page;
     // reset base URL
     X4Utils_helper::set_base_url(ROOT . LL . X4Route_core::$area . '/' . DC);
     // get menu
     $view->menus = $this->site->get_menus($page->id_area);
     // get message
     $view->sections = array($this->dict->get_message(_WARNING, strtoupper($what), 'msg'));
     $view->render(TRUE);
 }
예제 #5
0
 /**
  * Display system messages
  *
  * @param   string	$what Dictionary what
  * @return  void
  */
 public function message($what = '')
 {
     // load global dictionary
     $this->dict->get_words();
     // get page
     $page = $this->get_page('msg');
     $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));
     // content
     $view->args = X4Route_core::$args;
     $view->content = new X4View_core('msg');
     $view->content->title = _WARNING;
     // load the message
     $view->content->msg = $this->dict->get_word($what, 'msg');
     $view->render(TRUE);
 }
예제 #6
0
    /**
     * Show Plugin's instructions
     *
     * @param   string 	$module Plugin name
     * @param   string 	$lang Language code
     * @return  void
     */
    public function help($module, $lang)
    {
        // load dictionary
        $this->dict->get_wordarray(array('modules'));
        // contents
        $view = new X4View_core('editor');
        $view->title = _MODULE_INSTRUCTIONS . ': ' . $module;
        $view->form = '<div id="scrolled">
						<pre>' . nl2br(htmlspecialchars(file_get_contents(PATH . 'plugins/' . $module . '/instructions_' . $lang . '.txt'))) . '</pre>
					</div>' . BR . BR;
        $view->js = '
<script>
window.addEvent("domready", function()
{
	var myScroll = new Scrollable($("scrolled"));
});
</script>';
        $view->render(TRUE);
    }
예제 #7
0
 /**
  * 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);
     }
 }
예제 #8
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);
 }
예제 #9
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);
 }
예제 #10
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);
 }
예제 #11
0
 /**
  * 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);
 }
예제 #12
0
 /**
  * Reset password
  * send an email with new credentials
  *
  * @param   integer	$id User ID
  * @param   string	$md5 Encrypted verification code
  * @return  void
  */
 public function reset($id, $md5)
 {
     $mod = new X4Auth_model('users');
     $user = $mod->get_by_id($id, 'users', 'last_in, password, mail, username');
     if ($user) {
         // user exists
         if (md5($user->last_in . SITE . $user->password) == $md5 && time() - strtotime($user->last_in) < 604800) {
             $new_pwd = X4Text_helper::random_string(6);
             $result = $mod->reset($user->mail, $new_pwd);
             if ($result) {
                 // load dictionary
                 $this->dict->get_wordarray(array('login', 'pwd_recovery'));
                 $src = array('XXXUSERNAMEXXX', 'XXXPASSWORDXXX');
                 $rpl = array($user->username, $new_pwd);
                 $view = new X4View_core(X4Utils_helper::set_tpl('mail'));
                 $view->subject = SERVICE . ' - ' . _RECOVERY_SUBJECT;
                 $view->message = str_replace($src, $rpl, _RECOVERY_BODY_RESET);
                 // build msg
                 $body = $view->__toString();
                 $msg = mb_convert_encoding($body, 'ISO-8859-1', 'auto');
                 // recipients
                 $to = array(array('mail' => $user->mail, 'name' => $user->username));
                 $check = X4Mailer_helper::mailto(MAIL, true, $view->subject, $msg, $to, array());
                 X4Utils_helper::set_msg($check, _RECOVERY_PWD_OK, _MSG_ERROR);
                 header('Location: ' . BASE_URL . 'login/recovery');
                 die;
             }
             // log
             if (LOGS) {
                 $mod->logger($user->id, 1, 'users', 'recovery password completed for ' . $user->mail);
             }
         } else {
             if (LOGS) {
                 $mod->logger($user->id, 1, 'users', 'recovery password failed for ' . $user->mail);
             }
         }
     } else {
         if (LOGS) {
             $mod->logger($user->id, 1, 'users', 'recovery password attempt from unknown id ' . $id);
         }
     }
     X4Utils_helper::set_msg(false, '', _RECOVERY_PWD_ERROR);
     header('Location: ' . BASE_URL . 'login/recovery');
     die;
 }
예제 #13
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);
    }
예제 #14
0
 /**
  * Generic page override __call
  *
  * @param string	url/controller name
  * @param array		array of arguments
  * @return void
  */
 public function __call($url, $args)
 {
     // dict
     $this->dict->get_words();
     // get page data
     $page = $this->site->get_page($url);
     if ($page) {
         // check login if area is private
         if ($this->site->area->private && !in_array($url, $this->admitted)) {
             if (file_exists(APATH . 'controllers/' . X4Route_core::$area . '/login.php')) {
                 X4Utils_helper::logged($page->id_area, X4Route_core::$area . '/login');
             } else {
                 X4Utils_helper::logged($page->id_area, 'public/home');
             }
         }
         // set view
         $view = new X4View_core(X4Utils_helper::set_tpl($page->tpl));
         $view->page = $page;
         $view->args = $args;
         // get menus
         $view->menus = $this->site->get_menus($page->id_area);
         $view->navbar = array($this->site->get_bredcrumb($page));
         // get sections
         $view->sections = $this->site->get_sections($page->id);
         $view->render(true);
     } else {
         // check for redirects
         $url = X4Route_core::get_uri();
         $mod = new X4Plugin_model();
         $redirect = $mod->check_redirect(array('Page_model'), $url);
         if (!$redirect) {
             header('HTTP/1.0 404 Not Found');
             header('Location: ' . BASE_URL . 'msg/message/_page_not_found');
         } else {
             // redirect to
             header('Location: ' . $this->site->site->domain . '/' . $redirect->url, true, $redirect->redirect_code);
         }
     }
 }
예제 #15
0
 /**
  * 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);
 }
예제 #16
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');
     }
 }
예제 #17
0
 /**
  * Help on line
  *
  * @param   string  $url Remote URL
  * @return  void
  */
 public function hol($lang, $area, $page, $suffix = '')
 {
     // load dictionaries
     $this->dict->get_wordarray(array('home'));
     // left
     $view = new X4View_core('container');
     // get remote contents
     $content = @file_get_contents('http://www.x3cms.net/' . $lang . '/help/' . $page . '/' . $this->remotize());
     $src = array('src="/cms');
     $rpl = array('src="http://www.x3cms.net/cms');
     // return contents or error message
     $view->content = empty($content) ? '<p>' . _UNABLE_TO_CONNECT . '</p>' : '<div id="help">' . str_replace($src, $rpl, $content) . '</div>';
     $view->render(TRUE);
 }
예제 #18
0
 /**
  * Admin area menu
  *
  * @return  void
  */
 public function menu()
 {
     // content
     $view = new X4View_core('menu');
     $view->menus = $this->site->get_menus(1);
     $view->render(TRUE);
 }
예제 #19
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);
 }
예제 #20
0
 /**
  * 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);
 }
예제 #21
0
 /**
  * Show areas map (tree view)
  *
  * @param   integer $id_area Area ID
  * @param   string  $lang language code
  * @return  void
  */
 public function map($id_area, $lang)
 {
     // load the dictionary
     $this->dict->get_wordarray(array('areas'));
     // content
     $view = new X4View_core('areas/map');
     $mod = new Page_model($id_area, $lang);
     $view->area = $mod->get_by_id($id_area, 'areas');
     $view->lang = $lang;
     $view->map = $this->site->get_map($mod->get_page('home'), false, false);
     $view->render(TRUE);
 }