Exemple #1
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);
 }
 /**
  * Default method
  * Display paginated articles with specified key
  *
  * @param object	$page object
  * @param array		$args array of args
  * @param string	$param parameter (the key)
  * @return string
  */
 public function get_module($page, $args, $param = '')
 {
     $out = '';
     // pagination index
     $pp = isset($args[0]) ? intval($args[0]) : 0;
     // tag index
     $tag = isset($args[1]) && $args[1] == 'tag' ? urldecode($args[2]) : false;
     if (!empty($param)) {
         if ($tag) {
             $mod = new X3get_by_key_model();
             $items = X4Pagination_helper::paginate($mod->get_articles_by_key_and_tag($page->id_area, $page->lang, $param, $tag), $pp);
             $out .= '<div class="block"><h3>' . _TAG . ': ' . htmlentities($tag) . '</h3></div>';
         } else {
             $items = X4Pagination_helper::paginate($this->site->get_articles_by_key($page->id_area, $page->lang, $param), $pp);
         }
         // use pagination
         if ($items[0]) {
             foreach ($items[0] as $i) {
                 if (!empty($i->content)) {
                     $out .= '<div class="block">' . X4Utils_helper::online_edit($i, 0);
                     // options
                     $out .= X4Utils_helper::get_block_options($i);
                     // check excerpt
                     if ($i->excerpt) {
                         $text = X4Utils_helper::excerpt($i->content);
                         $out .= X4Utils_helper::reset_url(stripslashes($text[0]));
                     } else {
                         $out .= X4Utils_helper::reset_url(stripslashes($i->content));
                     }
                     $out .= '<div class="clear"></div>';
                     // display tags
                     if ($i->show_tags && !empty($i->tags)) {
                         $out .= '<p class="tags"><span>' . _TAGS . '</span>: ';
                         $tt = explode(',', $i->tags);
                         foreach ($tt as $t) {
                             $t = trim($t);
                             $out .= '<a href="' . BASE_URL . $page->url . '/0/tag/' . urlencode($t) . '" title="' . _TAG . '">' . $t . '</a> ';
                         }
                         $out .= '</p>';
                     }
                     $out .= '</div>';
                 }
                 // module
                 if (!empty($i->module)) {
                     $out .= X4Utils_helper::module($this->site, $page, $args, $i->module, $i->param);
                 }
             }
             // pager
             $out .= '<div id="pager">' . X4Pagination_helper::pager(BASE_URL . $page->url . '/', $items[1]) . '</div>';
         } else {
             $out .= '<div class="block"><p>' . _NO_ITEMS . '</p></div>';
         }
     }
     return $out;
 }
 /**
  * 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);
 }
Exemple #4
0
 /**
  * Admin area dashboard
  * This page displays Notices and Bookmarks
  *
  * @return  void
  */
 public function dashboard()
 {
     // load dictionaries
     $this->dict->get_wordarray(array('widgets', 'home'));
     // get page
     $page = $this->get_page('home');
     $view = new X4View_core(X4Utils_helper::set_tpl($page->tpl));
     $view->page = $page;
     // content
     $view->content = new X4View_core('home');
     // notices
     $view->content->notices = NOTICES ? $this->get_notices($page->lang) : '';
     // widgets
     $mod = new Widget_model();
     $view->content->widgets = $mod->widgets();
     $view->render(TRUE);
 }
Exemple #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);
 }
Exemple #6
0
 /**
  * Return error message
  *
  * @param   mixed 	$fields Form array or boolean
  * @param   string 	$title Dialog title
  * @param   boolean     $session If true save message in a session var
  * @return  void
  */
 public function notice($fields, $title = '_form_not_valid', $session = false)
 {
     $dict = new X4Dict_model(X4Route_core::$folder, X4Route_core::$lang);
     $error = $dict->get_word($title, 'form');
     $fields = X4Utils_helper::normalize_form($fields);
     foreach ($fields as $i) {
         if (isset($i['error'])) {
             foreach ($i['error'] as $ii) {
                 // set the available label
                 $label = is_null($i['label']) && isset($i['alabel']) || isset($i['alabel']) ? $i['alabel'] : $i['label'];
                 // for related fields
                 if (isset($i['related'][$i['name']])) {
                     $src = array('XXXRELATEDXXX');
                     $rpl = array();
                     $related = $i['related'][$i['name']];
                     if (isset($fields[$related])) {
                         // if is a related field
                         $rpl[] = is_null($fields[$related]['label']) && isset($fields[$related]['alabel']) || isset($fields[$related]['alabel']) ? $fields[$related]['alabel'] : $fields[$related]['label'];
                     } else {
                         // if is a related value
                         $rpl[] = $related;
                     }
                     if (isset($i['relatedvalue'][$i['name']])) {
                         $src[] = 'XXXVALUEXXX';
                         $rpl[] = $i['relatedvalue'][$i['name']];
                     }
                     $error .= '<br /><u>' . $label . '</u> ' . str_replace($src, $rpl, $dict->get_word($ii, 'form'));
                 } else {
                     $error .= '<br /><u>' . $label . '</u> ' . $dict->get_word($ii, 'form');
                 }
             }
         }
     }
     if ($session) {
         $_SESSION['msg'] = $error;
     } else {
         // set message
         $msg = AdmUtils_helper::set_msg(false, $error, $error);
         $this->response($msg);
     }
 }
Exemple #7
0
 /**
  * Export a pdf
  *
  * @static
  * @param	string	$title		Document title
  * @param	string	$css		CSS Contents
  * @param	string	$html		HTML Contents
  * @param	string	$page_format 	Default A4
  * @param	string	$orientation	Can be P|L
  * @return boolean
  */
 public static function pdf_export($title, $css, $html, $page_format = 'A4', $orientation = 'P')
 {
     // language set
     $l = array();
     $l['a_meta_charset'] = 'UTF-8';
     $l['a_meta_dir'] = 'rtl';
     $l['a_meta_language'] = X4Route_core::$lang;
     $l['w_page'] = _PAGE;
     X4Core_core::auto_load('mpdf_library');
     // create the PDF object
     $mpdf = new mPDF(X4Route_core::$lang, $page_format, 0, 0, 0, 0, 0, 0, $orientation);
     $title = SERVICE . ' - ' . $title . ' - ' . date('Y-m-d H:i:s');
     $mpdf->SetAuthor($_SESSION['nickname']);
     $mpdf->SetCreator(SERVICE);
     $mpdf->SetTitle($title);
     $mpdf->SetDisplayMode('fullwidth');
     $mpdf->WriteHTML($css, 1);
     $mpdf->WriteHTML($html, 2);
     $filename = X4Utils_helper::unspace(str_replace(' - ', '-', $title), true);
     $mpdf->Output($filename . '.pdf', 'D');
     exit;
 }
 /**
  * Save article
  *
  * @param   string	$bid
  * @return  void
  */
 public function update($bid)
 {
     // load dictionaries
     $this->dict->get_words();
     // get article id
     $mod = new Article_model();
     $item = $mod->get_by_bid($bid);
     // check permission
     AdmUtils_helper::chklevel($_SESSION['xuid'], 'articles', $item->id, 2);
     // only if there are differences
     if ($item->content != $_POST['content']) {
         // tinymce
         $post = array('bid' => $bid, 'id_area' => $item->id_area, 'lang' => $item->lang, 'code_context' => $item->code_context, 'id_page' => $item->id_page, 'date_in' => time(), 'xkeys' => $item->xkeys, 'name' => $item->name, 'content' => $_POST['content'], 'excerpt' => 0, 'author' => $_SESSION['mail'], 'module' => $item->module, 'param' => $item->param, 'id_editor' => $_SESSION['xuid'], 'xon' => AUTOREFRESH);
         // insert new article's version
         $result = $mod->insert($post);
         if ($result[1]) {
             // add permission
             $perm = new Permission_model();
             // privs permissions
             $array[] = array('action' => 'insert', 'id_what' => $result[0], 'id_user' => $_SESSION['xuid'], 'level' => 4);
             $res = $perm->pexec('articles', $array, $item->id_area);
         }
         // set message
         X4Utils_helper::set_msg($result);
         echo $_SESSION['msg'];
         unset($_SESSION['msg']);
     } else {
         echo '';
     }
 }
 /**
  * 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);
 }
Exemple #10
0
 /**
  * Register site data
  *
  * @access	private
  * @param   array 	$_post _POST array
  * @return  void
  */
 private function editing($_post)
 {
     $msg = null;
     // check permission
     $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'sites', $_post['id'], 4);
     if (is_null($msg)) {
         // handle _post
         $post = array('xcode' => X4Utils_helper::unspace($_post['xcode']), 'domain' => $_post['domain']);
         // do update
         $result = $this->site->update($_post['id'], $post);
         // set message
         $msg = AdmUtils_helper::set_msg($result);
         // set what update
         if ($result[1]) {
             $msg->update[] = array('element' => 'topic', 'url' => BASE_URL . 'sites/show/1', 'title' => null);
         }
     }
     $this->response($msg);
 }
Exemple #11
0
 /**
  * Clean a string
  *
  * @static
  * @param string	$str string to clean
  * @param boolean	$deep If true replace '.' too
  * @param boolean	$negative If true replace - with _
  * @return string
  */
 public static function unspace($str, $deep = false, $negative = false)
 {
     $str = trim($str);
     $str = X4Utils_helper::to7bit($str, 'UTF-8');
     $str = strtolower(html_entity_decode($str));
     if (function_exists('preg_replace_callback')) {
         // strip special chars
         $str = preg_replace_callback('/[àèéìòùç]+/is', function ($m) {
             $r = '';
             switch ($m[0]) {
                 case 'à':
                     $r = 'a';
                     break;
                 case 'è':
                 case 'é':
                     $r = 'e';
                     break;
                 case 'ì':
                     $r = 'i';
                     break;
                 case 'ò':
                     $r = 'o';
                     break;
                 case 'ù':
                     $r = 'u';
                     break;
                 case 'ç':
                     $r = 'c';
                     break;
             }
             return $r;
         }, $str);
         // clean
         $regex = $deep ? '/[^a-z0-9-]+/is' : '/[^a-z0-9-\\/\\.]+/is';
         $res = preg_replace_callback($regex, function ($m) {
             return '-';
         }, $str);
         // remove duplicates
         $res = preg_replace_callback('/-(-*)/', function ($m) {
             return '-';
         }, $res);
     } else {
         $str = preg_replace('/[àèéìòùç]+/e', '-', $str);
         // clean
         $res = $deep ? preg_replace('/[^a-z0-9-\\.]+/', '-', $str) : preg_replace('/[^a-z0-9-\\/\\.]+/', '-', $str);
         // remove duplicates
         $res = preg_replace('/-(-*)/', '-', $res);
     }
     return $negative ? str_replace('-', '_', $res) : $res;
 }
Exemple #12
0
 /**
  * Register SEO data
  *
  * @access	private
  * @param   array 	$_post _POST array
  * @return  void
  */
 private function reg_seo($_post)
 {
     $msg = null;
     // check permissions
     $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'pages', $_post['id'], 2);
     if (is_null($msg)) {
         // get object
         $mod = new Page_model('', '', $_post['id']);
         $page = $mod->get_by_id($_post['id'], 'pages', 'id_area, lang, url, xfrom');
         // this pages cannot be changed
         $no_change = array('home', 'msg', 'search');
         // remove slash from url
         if ($page->id_area > 1) {
             $_post['url'] = str_replace('/', '-', $_post['url']);
         }
         // handle _post
         $post = array('url' => !in_array($page->url, $no_change) ? X4Utils_helper::unspace($_post['url']) : $page->url, 'name' => $_post['name'], 'title' => $_post['title'], 'description' => $_post['description'], 'xfrom' => !in_array($page->url, $no_change) ? $_post['xfrom'] : $page->xfrom, 'hidden' => intval(isset($_post['hidden'])), 'xkeys' => $_post['xkeys'], 'robot' => $_post['robot'], 'redirect_code' => $_post['redirect_code'], 'redirect' => $_post['redirect'], 'tpl' => $_post['tpl']);
         // check if a page with the same URL already exists
         $check = (bool) $mod->exists($post['url'], $_post['id']);
         if ($check) {
             $msg = AdmUtils_helper::set_msg(false, '', $this->dict->get_word('_PAGE_ALREADY_EXISTS', 'msg'));
         } else {
             // set css for the page
             $tmod = new Template_model();
             $css = $tmod->get_css($page->id_area, $_post['tpl']);
             $post['css'] = $css;
             // update page data
             $result = $mod->update_page($_post['id'], $post, $this->site->site->domain);
             if (APC) {
                 apc_clear_cache();
                 apc_clear_cache('user');
                 apc_clear_cache('opcode');
             }
             // set message
             $msg = AdmUtils_helper::set_msg($result);
             // set what update
             if ($result[1]) {
                 $msg->update[] = array('element' => 'topic', 'url' => BASE_URL . 'pages/index/' . $page->id_area . '/' . $page->lang . '/' . str_replace('/', '-', $page->xfrom) . '/0/', 'title' => null);
             }
         }
     }
     $this->response($msg);
 }
    /**
     * New / Edit article form
     * The form is simplified if site use simple editing
     *
     * @param   integer $id_area Area ID
     * @param   string	$lang Language code
     * @param   integer	$code_context Context code
     * @param   string	$bid, the unique ID of articles
     * @param   integer	$id_page Page ID (for simple editing)
     * @param   boolean	$duplicate Duplicate article resetting bid
     * @return  void
     */
    public function edit($id_area = 2, $lang = '', $code_context = 0, $bid = 0, $id_page = 0, $duplicate = 0)
    {
        // set language
        $lang = empty($lang) ? X4Route_core::$lang : $lang;
        // load dictionaries
        $this->dict->get_wordarray(array('form', 'articles'));
        // referer
        $qs = X4Route_core::get_query_string();
        $referer = isset($qs['ref']) ? $qs['ref'] : '';
        $mod = new Article_model();
        // simple editing
        if ($id_page && $bid != 'x3') {
            $bid = $mod->get_bid_by_id_page($id_page);
        }
        // get object
        $item = $bid && $bid != 'x3' ? $mod->get_by_bid($bid) : new Article_obj($id_area, $lang, $code_context);
        // dedicated page when called from composer
        if ($bid == 'x3') {
            $item->id_page = $id_page;
        }
        // if duplicate reset bid
        if ($duplicate) {
            $item->name = _COPY_OF . ' ' . $item->name;
            $item->bid = $mod->get_new_bid();
        }
        // build the form
        $fields = array();
        $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="band double-inner-pad clearfix"><div id="left-box" class="four-fifth md-three-fourth sm-two-third xs-one-whole">');
        $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $referer, 'name' => 'from');
        $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $item->bid, 'name' => 'bid');
        $lmod = new Language_model();
        if ($id_page == 0 || $bid == 'x3') {
            // advanced editing
            // area
            $amod = new Area_model();
            $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="band clearfix"><div class="one-fourth sm-one-half pad-right xs-one-whole xs-pad-none">');
            $fields[] = array('label' => _AREA, 'type' => 'select', 'value' => $item->id_area, 'options' => array($amod->get_areas(), 'id', 'name'), 'name' => 'id_area', 'extra' => 'class="large spinner spin2"');
            $fields[] = array('label' => null, 'type' => 'hidden', 'value' => 'module|' . BASE_URL . 'articles/refresh_module|id_area', 'name' => 'spinner1_data');
            $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-fourth sm-one-half pad-right xs-one-whole sm-pad-none">');
            // language
            $fields[] = array('label' => _LANGUAGE, 'type' => 'select', 'value' => $item->lang, 'options' => array($lmod->get_languages(), 'code', 'language'), 'name' => 'lang', 'extra' => 'class="large spinner spin2"');
            // value = id_to_update|url|ids_to_get
            $fields[] = array('label' => null, 'type' => 'hidden', 'value' => 'code_context|' . BASE_URL . 'articles/refresh_context|id_area|lang', 'name' => 'spinner2_data');
            $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-fourth sm-one-half pad-right xs-one-whole xs-pad-none">');
            // contexts
            $cmod = new Context_model();
            $fields[] = array('label' => _CONTEXT, 'type' => 'select', 'value' => $item->code_context, 'options' => array($cmod->get_contexts($item->id_area, $item->lang), 'code', 'name'), 'name' => 'code_context', 'extra' => 'class="large spin2"');
            $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $item->code_context, 'name' => 'old_context');
            // value = id_to_update|url|ids_to_get
            $fields[] = array('label' => null, 'type' => 'hidden', 'value' => 'id_page|' . BASE_URL . 'articles/refresh_pages|id_area|lang|code_context', 'name' => 'spinner3_data');
            $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-fourth sm-one-half xs-one-whole">');
            $fields[] = array('label' => _PAGE, 'type' => 'select', 'value' => $item->id_page, 'options' => $item->id_page ? array($cmod->get_pages($item->id_area, $item->lang, 1), 'id', 'name') : array(), 'name' => 'id_page', 'extra' => 'class="large"');
            $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div>');
        } else {
            // simple editing
            // hidden fields
            $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $item->id_area, 'name' => 'id_area');
            $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $item->lang, 'name' => 'lang');
            $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $item->code_context, 'name' => 'code_context');
            $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $item->code_context, 'name' => 'old_context');
            $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $item->id_page, 'name' => 'id_page');
        }
        // classification section
        $fields[] = array('label' => _NAME, 'type' => 'text', 'value' => stripslashes($item->name), 'name' => 'name', 'rule' => 'required', 'extra' => 'class="large"');
        // content
        $fields[] = array('label' => _CONTENT, 'type' => 'textarea', 'value' => $item->content, 'name' => 'content');
        if (EDITOR_SCRIPTS) {
            // content
            $fields[] = array('label' => _SCRIPT, 'type' => 'textarea', 'value' => htmlentities($item->js), 'name' => 'js', 'extra' => 'class="NoEditor"', 'suggestion' => _SCRIPT_MSG);
        } else {
            $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $item->js, 'name' => 'js');
        }
        // plugin section
        $fields[] = array('label' => null, 'type' => 'html', 'value' => '<h3>' . _PLUGIN . '</h3>
						<div class="band clearfix"><div class="one-half pad-right">');
        $plugin = new X4Plugin_model();
        // for APC
        $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $item->module, 'name' => 'old_module');
        $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $item->param, 'name' => 'old_param');
        $fields[] = array('label' => _MODULE, 'type' => 'select', 'value' => $item->module, 'options' => array($plugin->get_modules($id_area, 0), 'name', 'description', ''), 'name' => 'module', 'extra' => 'class="large"');
        $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-half pad-left">');
        $fields[] = array('label' => _PARAM, 'type' => 'text', 'value' => $item->param, 'name' => 'param', 'extra' => 'class="large"');
        $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div></div>
				<div id="right-box" class="one-fifth md-one-fourth sm-one-third xs-one-whole xs-hidden">');
        // time window section
        $fields[] = array('label' => null, 'type' => 'html', 'value' => '<h2>' . _TIME_WINDOW . '</h2><div class="band clearfix inner-pad"><div class="one-half sm-one-whole">');
        $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $item->date_in, 'name' => 'old_date_in');
        $fields[] = array('label' => _START_DATE, 'type' => 'text', 'value' => date('Y-m-d', $item->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 sm-one-whole">');
        $fields[] = array('label' => _END_DATE, 'type' => 'text', 'value' => $item->date_out == 0 ? '' : date('Y-m-d', $item->date_out), 'name' => 'date_out', 'rule' => 'date', 'extra' => 'class="date date_toggled large"', 'suggestion' => _NO_END_MSG);
        // classification section
        $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div><h2>' . _ORGANIZATION . '</h2>');
        // categories
        $camod = new Category_model();
        $fields[] = array('label' => _CATEGORY, 'type' => 'select', 'value' => $item->category, 'options' => array($camod->get_categories($item->id_area, $item->lang), 'name', 'description', 0), 'name' => 'category', 'extra' => 'class="large"');
        // xkeys
        $fields[] = array('label' => _KEYS, 'type' => 'text', 'value' => $item->xkeys, 'name' => 'xkeys', 'extra' => 'class="large"');
        // tags
        $fields[] = array('label' => _TAGS, 'type' => 'text', 'value' => $item->tags, 'name' => 'tags', 'extra' => 'class="large"');
        // author
        $fields[] = array('label' => _AUTHOR, 'type' => 'text', 'value' => empty($item->author) ? $_SESSION['mail'] : $item->author, 'name' => 'author', 'rule' => 'required', 'extra' => 'class="large"');
        if (EDITOR_OPTIONS) {
            // options section
            $fields[] = array('label' => null, 'type' => 'html', 'value' => '<h2>' . _OPTIONS . '</h2>
                            <div class="band clearfix">
                                <div class="one-half sm-one-whole">');
            $fields[] = array('label' => _SHOW_AUTHOR, 'type' => 'checkbox', 'value' => $item->show_author, 'name' => 'show_author', 'checked' => $item->show_author);
            $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-half sm-one-whole">');
            $fields[] = array('label' => _SHOW_DATE, 'type' => 'checkbox', 'value' => $item->show_date, 'name' => 'show_date', 'checked' => $item->show_date);
            $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-half sm-one-whole">');
            $fields[] = array('label' => _SHOW_TAGS, 'type' => 'checkbox', 'value' => $item->show_tags, 'name' => 'show_tags', 'checked' => $item->show_tags);
            $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-half sm-one-whole">');
            $fields[] = array('label' => _SHOW_ACTIONS, 'type' => 'checkbox', 'value' => $item->show_actions, 'name' => 'show_actions', 'checked' => $item->show_actions);
            $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div>');
        }
        $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div>');
        /*
        // TODO: maybe in the future
        		$fields[] = array(
        			'label' => _SCHEMA,
        			'type' => 'textarea', 
        			'value' => $item->xschema,
        			'name' => 'xschema',
        			'extra' => 'class="mceNoEditor"'
        		);
        */
        // if submitted
        if (X4Route_core::$post) {
            $e = X4Validation_helper::form($fields, 'editor');
            if ($e) {
                $this->editing($item, $_POST);
            } else {
                $this->notice($fields);
            }
            die;
        }
        // content
        $view = new X4View_core('tabber');
        $view->tabs = array();
        $view->down = new X4View_core('editor');
        $view->down->close = false;
        // Set the navbar
        $page = $this->get_page('articles/edit');
        $ref = isset($_SESSION['referer']) ? $_SESSION['referer'] : 'index/' . $id_area . '/' . $lang;
        $navbar = array($this->site->get_bredcrumb($page), array('articles' => $ref));
        $pmod = new Page_model();
        if ($id_page && $bid != 'x3') {
            // simple editing
            $page = $pmod->get_by_id($id_page);
            $view->title = _CONTENT_EDITOR . ' <a class="bta" href="' . BASE_URL . 'pages/index/' . $page->id_area . '/' . $page->lang . '/' . $page->xfrom . '/1" title="' . _GO_BACK . '">' . stripslashes($page->name) . '</a>' . _TRAIT_ . $lang;
            $view->down->js = '';
        } else {
            // generic back
            $back = '<a class="bta" href="' . BASE_URL . 'pages/index/' . $id_area . '/' . $lang . '/home/1" title="' . _GO_BACK . '">' . _PAGES . '</a>';
            if ($bid) {
                if ($item->id_page) {
                    // back to the right page
                    $page = $pmod->get_by_id($item->id_page);
                    $back = ADVANCED_EDITING ? '<a class="bta" href="' . BASE_URL . 'sections/compose/' . $page->id . '" title="' . _GO_BACK . '">' . stripslashes($page->name) . '</a>' : '<a class="bta" href="' . BASE_URL . 'pages/index/' . $page->id_area . '/' . $page->lang . '/' . $page->xfrom . '/1" title="' . _GO_BACK . '">' . stripslashes($page->name) . '</a>';
                }
                $view->title = $back . _TRAIT_ . _EDIT_ARTICLE . _TRAIT_ . $lang;
            } else {
                $view->title = $back . _TRAIT_ . _ADD_ARTICLE . _TRAIT_ . $lang;
            }
            $view->down->js = '
<script>
window.addEvent("domready", function()
{
	if ($chk($("spinner1_data"))) {
		var sdata = $("spinner1_data").get("value").split("|");
		spinnerize(sdata, ".spinner");
	}
	
	if ($chk($("spinner2_data"))) {
		var sdata = $("spinner2_data").get("value").split("|");
		spinnerize(sdata, ".spinner");
	}
	
	if ($chk($("spinner3_data"))) {
		var sdata = $("spinner3_data").get("value").split("|");
		spinnerize(sdata, ".spin2");
	}
});
</script>
			';
        }
        $view->down->js .= '
<script>
window.addEvent("domready", function()
{
	X3.content("filters","articles/filter/' . $id_area . '/' . $lang . '", "' . addslashes(X4Utils_helper::navbar($navbar, ' . ')) . '");
	buttonize("tabber", "bta", "topic");
	pickerize(1);
	
	$("module").addEvent("change", function(event, target){
    	event.preventDefault();
    	v = this.get("value");
    	if (v.length == 0) {
    	   $("param").set("value", "");
    	} else {
    	   X3.modal("", "' . _ARTICLE_PARAM_SETTING . '", "' . BASE_URL . 'articles/param/' . $id_area . '/' . $lang . '/"+v);
    	}
    });
    
    $("param").addEvent("focus", function(event, target){
    	event.preventDefault();
    	m = $("module").get("value");
    	if (m != "") {
            v = this.get("value");
            X3.modal("", "' . _ARTICLE_PARAM_SETTING . '", "' . BASE_URL . 'articles/param/' . $id_area . '/' . $lang . '/"+m+"/"+v);
        }
    });
});
</script>';
        // form builder
        $view->down->form = X4Form_helper::doform('editor', $_SERVER["REQUEST_URI"], $fields, array(_RESET, _SUBMIT, 'buttons'), 'post', '', 'onclick="setForm(\'editor\', \'content\');"');
        $view->down->tinymce = new X4View_core('tinymce');
        $view->down->tinymce->id_area = $id_area;
        // rtl
        if ($lmod->rtl($lang)) {
            $view->down->tinymce->rtl = 1;
        }
        $view->render(TRUE);
    }
Exemple #14
0
			</div>';
    }
    echo '</div></form>';
    // pagination
    echo '<div id="file_pager" class="pager">' . X4Pagination_helper::pager(BASE_URL . 'files/index/' . $id_area . '/' . urlencode($category) . '/' . urlencode($subcategory) . '/' . $xtype . '/', $items[1], 5, false, '', 'btp') . '</div>';
} else {
    echo '<p>' . _NO_ITEMS . '</p>';
}
?>
<script>
window.addEvent('domready', function()
{
	X3.content('filters','files/filter/<?php 
echo $id_area . '/' . urlencode($category) . '/' . $subcategory . '/' . $str;
?>
', '<?php 
echo X4Utils_helper::navbar($navbar, ' . ', false);
?>
');
	buttonize('file_pager', 'btp', 'topic');
	buttonize('topic', 'btm', 'topic');
	buttonize('topic', 'bta', 'modal');
	actionize('topic',  'btl', 'topic', escape('files/index/<?php 
echo $id_area . '/' . urlencode($category) . '/' . urlencode($subcategory) . '/' . $xtype;
?>
'));
	linking('ul.inline-list a');
	blanking();
});
</script>
 /**
  * Register Edit / New Category form data
  *
  * @access	private
  * @param   integer $id item ID (if 0 then is a new item)
  * @param   array 	$_post _POST array
  * @return  void
  */
 private function editing($id, $_post)
 {
     $msg = null;
     // check permission
     $msg = $id ? AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'categories', $_post['id'], 3) : AdmUtils_helper::chk_priv_level($_SESSION['xuid'], '_category_creation', 0, 4);
     if (is_null($msg)) {
         // handle _post
         $post = array('id_area' => $_post['id_area'], 'lang' => $_post['lang'], 'title' => $_post['title'], 'name' => X4Utils_helper::unspace($_post['title']), 'tag' => X4Utils_helper::unspace($_post['tag']));
         $mod = new Category_model();
         // check if category already exists
         $check = $mod->exists($post, $id);
         if ($check) {
             $msg = AdmUtils_helper::set_msg(false, '', $this->dict->get_word('_CATEGORY_ALREADY_EXISTS', 'msg'));
         } else {
             // update or insert
             if ($id) {
                 $result = $mod->update($_post['id'], $post);
             } else {
                 $result = $mod->insert($post);
                 // create permissions
                 if ($result[1]) {
                     $perm = new Permission_model();
                     $array[] = array('action' => 'insert', 'id_what' => $result[0], 'id_user' => $_SESSION['xuid'], 'level' => 4);
                     $res = $perm->pexec('categories', $array, $_post['id_area']);
                 }
             }
             // set message
             $msg = AdmUtils_helper::set_msg($result);
             // set what update
             if ($result[1]) {
                 $msg->update[] = array('element' => 'topic', 'url' => BASE_URL . 'categories/index/' . $post['id_area'] . '/' . $post['lang'] . '/' . $post['tag'], 'title' => null);
             }
         }
     }
     $this->response($msg);
 }
Exemple #16
0
 /**
  * Get a file
  * the path of the file will remain anonymous
  *
  * @param string	$file file with path
  * @param string	$filename file dname for the download
  * @param boolean	$download force the download
  * @return file
  */
 public static function get_file($file, $filename = '', $download = true)
 {
     if (file_exists($file)) {
         $download_name = empty($filename) ? basename($file) : X4Utils_helper::unspace($filename);
         $mime = self::get_mime($file);
         if ($download) {
             header('Content-Description: File Transfer');
             header('Cache-Control: private');
             header('Content-type: ' . $mime);
             header('Content-Disposition: attachment; filename=' . $download_name);
             header('Content-Transfer-Encoding: Binary');
             header('Expires: 0');
             header('Cache-Control: must-revalidate');
             header('Pragma: public');
             header('Content-Length:' . filesize($file));
         } else {
             header('Content-Description: File Transfer');
             header('Cache-Control: private');
             header('Content-type: ' . $mime);
             header('Content-Disposition: inline; filename=' . $download_name);
             header('Content-Transfer-Encoding: Binary');
             header('Expires: 0');
             header('Cache-Control: must-revalidate');
             header('Pragma: public');
             // for adobe reader
             if ($mime == 'application/pdf') {
                 header("Content-Range: bytes");
             }
             header('Content-Length:' . filesize($file));
         }
         ob_clean();
         flush();
         readfile($file);
         exit;
     }
 }
 /**
  * Create a basic dictionary
  *
  * @param string    $area
  * @param string    $name
  * @return void
  */
 public function dictionary($area, $name)
 {
     if ($area == 'admin') {
         // get the final name
         $name = X4Utils_helper::unspace($name, true, true);
         // create the dictionary section
         $mod = new X3cli_model();
         $res = $mod->create_dictionary($area, $name);
         if (!is_null($res)) {
             echo NL . 'The dictionary section "' . $name . '" was created successfully!' . NL;
         } else {
             echo NL . 'WARNING: an error occurred' . NL;
         }
     } else {
         // dictionary is available only for admin area
         echo NL . 'WARNING: you can create dictionary section only for the "admin" area' . NL;
     }
 }
Exemple #18
0
		h = parseInt(this.get("value"));
		if (ratio > 0 && h > 0) {
			$("width").set("value", Math.round(ratio*h));
		}
	});
	
	' . $capture . '
});
</script>';
        break;
    case 3:
        // templates
        echo $tinymce;
        echo '<h1>' . _TEMPLATE_EDIT . ': ' . $file->name . '</h1>
		<p>' . _TEMPLATE_MSG . '</p>
		' . $form;
        $js .= '
<script>
var reset_editor = function() {
	window.location = root+"home/start/files-editor-' . $file->id . '/"+escape("Template editor");
}

var ratio = 0;
window.addEvent("domready", function()
{
	X3.content("filters","files/filter/0", "' . addslashes(X4Utils_helper::navbar($navbar, ' . ', false)) . '");
});
</script>';
        break;
}
echo $js;
Exemple #19
0
 * @license		http://www.gnu.org/licenses/agpl.htm
 * @package		X3CMS
 */
// section 1
if (!empty($sections[1])) {
    foreach ($sections[1] as $i) {
        if (!empty($i->content)) {
            // options
            echo X4Utils_helper::get_block_options($i);
            echo X4Utils_helper::reset_url(stripslashes($i->content . NL . html_entity_decode($i->js)));
        }
        if (!empty($i->module)) {
            echo stripslashes(X4Utils_helper::module($this->site, $page, $args, $i->module, $i->param));
        }
        // javascript for admin side
        if ($page->id_area == 1 && $navbar != '') {
            // update breadcrumb
            echo '
<script>
window.addEvent("domready", function() {
    $("page-title").set("html", "' . addslashes(X4Utils_helper::navbar($navbar, ' . ', false)) . '");
    buttonize("page-title", null, "topic");
});
</script>';
        }
    }
} elseif (isset($content)) {
    echo $content;
} else {
    echo '<h1>' . _WARNING . '</h1><p>' . _GLOBAL_PAGE_NOT_FOUND . '</p>';
}
Exemple #20
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');
     }
 }
 /**
  * Register User profile
  *
  * @access	private
  * @param   array 	$_post _POST array
  * @return  void
  */
 private function profiling($_post)
 {
     $msg = null;
     // ther'is no permission check because each user can only change his profile
     // handle _post
     $post = array('lang' => $_post['lang'], 'username' => $_post['username'], 'description' => strip_tags($_post['description']), 'mail' => $_post['mail'], 'phone' => $_post['phone']);
     // check for password update
     if (!empty($_post['password'])) {
         $post['password'] = X4Utils_helper::hashing($_post['password']);
     }
     $user = new User_model();
     // check if username or email address are already used by another user
     $check = (bool) $user->exists($post['username'], $post['mail'], $_SESSION['xuid']);
     if ($check) {
         $msg = AdmUtils_helper::set_msg($false, '', $this->dict->get_word('_USER_ALREADY_EXISTS', 'msg'));
     } else {
         // update profile
         $result = $user->update($_SESSION['xuid'], $post);
         // if user changes his password then send a reminder
         if ($result[1] && !empty($_post['password'])) {
             // build subject and message
             $s = array('DOMAIN', 'USERNAME', 'PASSWORD');
             $r = array($this->site->site->domain, $_post['username'], $_post['password']);
             $subject = str_replace($s, $r, _SUBJECT_PROFILE);
             $msg = str_replace($s, $r, _MSG_PROFILE);
             $to = array(array('mail' => $_post['mail'], 'name' => $_post['username']));
             // send
             X4Mailer_helper::mailto(MAIL, false, $subject, $msg, $to);
         }
         // set message
         $this->dict->get_words();
         $msg = AdmUtils_helper::set_msg($result);
         // set update
         if ($result[1]) {
             $msg->update[] = array('element' => 'topic', 'url' => urldecode(BASE_URL . 'profile'), 'title' => null);
         }
     }
     $this->response($msg);
 }
    /**
     * 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);
    }
Exemple #23
0
    // max number of columns
    $n = sizeof($sections[2]);
    $widths = array('', '12', '6', '4', '3');
    foreach ($sections[2] as $i) {
        if (!empty($i->content) || !empty($i->module)) {
            $class = $n >= $x ? $widths[$x] : $widths[$n];
            if ($c > 0 && $c % $x == 0) {
                $n = $n - $x;
                $class = $n >= $x ? $widths[$x] : $widths[$n];
                echo '</div><div class="row">';
            }
            echo '<div class="col-xs-12 col-sm-6 col-md-' . $class . '">' . X4Utils_helper::online_edit($i, 2) . X4Utils_helper::get_block_options($i);
            echo '<div class="block" id="' . $i->bid . '">' . X4Utils_helper::reset_url(stripslashes($i->content)) . '</div>';
            // module
            if (!empty($i->module)) {
                echo stripslashes(X4Utils_helper::module($this->site, $page, $args, $i->module, $i->param));
            }
            echo '</div>';
        }
        $c++;
    }
    echo '</div>
		</div>';
}
?>
	</div>
</div>

<div id="footer">
	<p class="text-center small">
        <a href="http://www.x3cms.net" title="X3 your next Content Management System">X3 CMS</a> powered by <a href="http://www.cblu.net" title="Cblu.net - Software &amp; Web design">Cblu.net</a><br />
Exemple #24
0
<?php

defined('ROOT') or die('No direct script access.');
/**
 * X3 CMS - A smart Content Management System
 *
 * @author		Paolo Certo
 * @copyright	(c) CBlu.net di Paolo Certo
 * @license		http://www.gnu.org/licenses/agpl.htm
 * @package		X3CMS
 */
echo stripslashes(X4Utils_helper::build_menu('A', $menus['admin_global'], 1, 'ALL', 5, true, 'id="nav"'));
?>
<script>
$('nav').MooDropMenu();
linking('#nav li a');
</script>
Exemple #25
0
 /**
  * Reset password
  *
  * @param   string	$mail Subscriber mail
  * @param   string	$new_pwd Subscriber password
  * @return  integer
  */
 public function reset($mail, $new_pwd)
 {
     $id = $this->db->query_var('SELECT id FROM ' . $this->table . ' WHERE mail = ' . $this->db->escape(strtolower($mail)));
     if ($id) {
         $array = array('password' => X4Utils_helper::hashing($new_pwd));
         $result = $this->update($id, $array);
         return intval($result[1]);
     } else {
         return 0;
     }
 }
Exemple #26
0
 /**
  * Get file types
  *
  * @return  array	Array of objects
  */
 public function get_types()
 {
     $a = array(array('name' => _ALL_FILES, 'value' => -1), array('name' => _DOCUMENTS, 'value' => 1), array('name' => _IMAGES, 'value' => 0), array('name' => _MEDIA, 'value' => 2), array('name' => _TEMPLATES, 'value' => 3));
     return X4Utils_helper::array2obj($a, 'value', 'name');
 }
 /**
  * Constructor
  * check if user is logged
  *
  * @return  void
  */
 public function __construct()
 {
     parent::__construct();
     X4Utils_helper::logged();
 }
 /**
  * Return an array of CSS files by theme
  *
  * @param   string	$theme Theme name
  * @return  array	Array of objects
  */
 private function get_css($theme)
 {
     // css file list
     $css = array();
     $files = glob(PATH . 'themes/' . $theme . '/css/*');
     foreach ($files as $i) {
         $name = str_replace(array('screen.css', '.css'), '', basename($i));
         $css[] = array('v' => $name, 'o' => $name);
     }
     return X4Utils_helper::array2obj($css, 'v', 'o');
 }
 /**
  * Register Edit / New language data
  *
  * @access	private
  * @param   integer $id item ID (if 0 then is a new item)
  * @param   array 	$_post _POST array
  * @return  void
  */
 private function editing($id, $_post)
 {
     $msg = null;
     // check permission
     if ($id) {
         $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'languages', $_post['id'], 3);
     } else {
         $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], '_language_creation', 0, 4);
     }
     if (is_null($msg)) {
         // handle _post
         $post = array('code' => X4Utils_helper::unspace($_post['code']), 'language' => $_post['language'], 'rtl' => intval(isset($_post['rtl'])));
         $lang = new Language_model();
         // check if language already exists
         $check = $lang->exists($post, $id);
         if ($check) {
             $msg = AdmUtils_helper::set_msg(false, '', $this->dict->get_word('_LANGUAGE_ALREADY_EXISTS', 'msg'));
         } else {
             // update or insert
             if ($id) {
                 $result = $lang->update($_post['id'], $post);
             } else {
                 $result = $lang->insert($post);
                 // create permissions
                 if ($result[1]) {
                     $perm = new Permission_model();
                     $array[] = array('action' => 'insert', 'id_what' => $result[0], 'id_user' => $_SESSION['xuid'], 'level' => 4);
                     $res = $perm->pexec('languages', $array, 1);
                 }
             }
             // set message
             $msg = AdmUtils_helper::set_msg($result);
             // set what update
             if ($result[1]) {
                 $msg->update[] = array('element' => 'tdown', 'url' => BASE_URL . 'languages', 'title' => null);
             }
         }
     }
     $this->response($msg);
 }
Exemple #30
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;
 }