/**
  * 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);
 }
Beispiel #2
0
 /**
  * Returns JSON object of one entity
  *
  */
 public function get_entity()
 {
     // Contains ether a page dot article string, ether one page or article ID
     $rel = $this->input->post('rel');
     $type = $this->input->post('type');
     $rel = explode('.', $rel);
     $id_article = !empty($rel[1]) ? $rel[1] : NULL;
     $id_page = $rel[0];
     // returned entity array
     $entity = array();
     $page = array();
     switch ($type) {
         case 'article':
             if ($id_article) {
                 // Get article
                 $article = $this->article_model->get(array('id_page' => $id_page, 'id_article' => $id_article), Settings::get_lang('default'));
                 // Get the corresponding page
                 if (!empty($article)) {
                     $page = $this->page_model->get_by_id($id_page, Settings::get_lang('default'));
                 }
                 if (!empty($article) && !empty($page)) {
                     $entity = array('page' => $page, 'article' => $article);
                 }
             }
             break;
         case 'page':
             $page = $this->page_model->get_by_id($id_page, Settings::get_lang('default'));
             $entity = array('page' => $page);
             break;
     }
     $this->response($entity);
 }
Beispiel #3
0
 /**
  * When called, reloads the Page Edition panel
  *
  * @param   int    $id_page
  */
 protected function _reload_panel($id_page)
 {
     $page = $this->page_model->get_by_id($id_page, Settings::get_lang('default'));
     $page['menu'] = $this->menu_model->get($page['id_menu']);
     $title = empty($page['title']) ? $page['name'] : $page['title'];
     $this->callback[] = array('fn' => 'ION.splitPanel', 'args' => array('urlMain' => admin_url(TRUE) . 'page/edit/' . $id_page, 'urlOptions' => admin_url(TRUE) . 'page/get_options/' . $id_page, 'title' => lang('ionize_title_edit_page') . ' : ' . $title));
     $this->callback[] = array('fn' => $page['menu']['name'] . 'Tree.updateElement', 'args' => array($page, 'page'));
 }
Beispiel #4
0
 /**
  * Rebuilds the pages URLs
  *
  */
 public function rebuild_urls()
 {
     $this->url_model->clean_table();
     $nb = $this->page_model->rebuild_urls();
     $this->url_model->delete_empty_urls();
     $result = array('title' => lang('ionize_title_rebuild_pages_urls'), 'status' => 'success', 'message' => lang('ionize_message_check_ok'));
     $this->xhr_output($result);
 }
 function get($name)
 {
     $page = 'Sorry, page not available';
     $pages = array();
     $this->db->select('*');
     if ($name) {
         $this->db->where('name', $name);
     }
     $this->db->where('status', 'publish');
     $this->db->from(self::table_name);
     $query = $this->db->get();
     foreach ($query->result() as $c) {
         if ($name) {
             return $c;
         }
         $c = new Page_model();
         $c->_load_from_query($c);
         $page = $c->page;
     }
     return $page;
 }
Beispiel #6
0
 /**
  * Reloads the Edition panel
  *
  * @param	int		$id_page
  * @param	int		$id_article
  */
 protected function _reload_panel($id_page, $id_article)
 {
     $page = $this->page_model->get_by_id($id_page);
     $id_menu = array_key_exists('id_menu', $page) ? (int) $page['id_menu'] : 0;
     $page['menu'] = $this->menu_model->get($id_menu);
     // Main data
     $article = $this->article_model->get_by_id($id_article);
     $article_lang = $this->article_model->get_by_id($id_article, Settings::get_lang('default'));
     $title = empty($article_lang['title']) ? $article_lang['name'] : $article_lang['title'];
     // Correcting some lang data
     $article_lang['online'] = $article['online'];
     $this->callback[] = array('fn' => 'ION.splitPanel', 'args' => array('urlMain' => admin_url(TRUE) . 'article/edit/' . $id_page . '.' . $id_article, 'urlOptions' => admin_url(TRUE) . 'article/get_options/' . $id_page . '.' . $id_article, 'title' => lang('ionize_title_edit_article') . ' : ' . $title));
     $this->callback[] = array('fn' => array_key_exists('name', $page['menu']) ? $page['menu']['name'] . 'Tree.updateElement' : '', 'args' => array($article_lang, 'article'));
 }
 protected function _processGetRow($row = array())
 {
     $row = parent::_processGetRow($row);
     foreach (array('content_start_date', 'content_end_date') as $date_field) {
         if (!empty($row[$date_field]) && $row[$date_field] > 1) {
             $content_date = explode(' ', $row[$date_field]);
             $content_time = explode(':', $content_date[1]);
             if ($content_time[0] > 12) {
                 $content_time_1 = $content_time[0] - 12;
                 $content_time_3 = 'pm';
             } else {
                 $content_time_1 = $content_time[0];
                 $content_time_3 = 'am';
             }
             $content_time_2 = $content_time[1];
             $row[$date_field . '_day'] = $content_date[0];
             $row[$date_field . '_time'] = array($content_time_1, $content_time_2, $content_time_3);
         } else {
             $row[$date_field . '_day'] = '';
             $row[$date_field . '_time'] = array('', '', '');
         }
     }
     if (!empty($row['queue_date'])) {
         if ($row['queue_date'] != EMPTY_DATE) {
             // Page has a queue date
             $row['queue_date_period'] = 'date';
             $queue_date = explode(' ', $row['queue_date']);
             $row['queue_date_day'] = $queue_date[0];
             $row['queue_date_time'] = $queue_date[1];
         } else {
             // No queue date - set to now
             $row['queue_date_period'] = 'now';
             $row['queue_date_day'] = '';
             $row['queue_date_time'] = '';
         }
     }
     return $row;
 }
Beispiel #8
0
 /**
  * Returns the element definition list
  * Used to admin elements (elements_definition_list and element_definition views)
  *
  * XHR call
  *
  */
 function get_element_definition_list()
 {
     $elements = $this->element_definition_model->get_lang_list(array('order_by' => 'ordering ASC'), Settings::get_lang('default'));
     $elements_lang = $this->element_definition_model->get_all('element_definition_lang');
     // Elements
     foreach ($elements as &$element) {
         $element['languages'] = array();
         // Translated elements.
         foreach (Settings::get_languages() as $lang) {
             $element['languages'][$lang['lang']] = array('title' => '');
             foreach ($elements_lang as $ld) {
                 if ($ld['id_element_definition'] == $element['id_element_definition'] && $ld['lang'] == $lang['lang']) {
                     $element['languages'][$lang['lang']] = $ld;
                 }
             }
         }
         // Element's fields
         $element['fields'] = $this->extend_field_model->get_list(array('parent' => 'element', 'id_parent' => $element['id_element_definition']), Settings::get_lang('default'));
         // Element usages on pages, articles
         $query = $this->db->where('id_element_definition = ' . $element['id_element_definition'])->from('element')->get();
         $usages = $query->result_array();
         foreach ($usages as $index => $usageElement) {
             if ($usageElement['parent'] === 'page') {
                 // get page: parent page of element
                 $usages[$index]['page'] = $this->page_model->get_by_id($usageElement['id_parent']);
                 $usages[$index]['article'] = null;
             } else {
                 // get page: parent page of article which is parent of element
                 $usages[$index]['article'] = $this->article_model->get_by_id($usageElement['id_parent']);
                 $usages[$index]['page'] = $this->page_model->get_by_id($usages[$index]['article']['id_page']);
             }
         }
         $element['usages'] = $usages;
     }
     $this->template['elements'] = $elements;
     $this->output('element/definition/list');
 }
Beispiel #9
0
 function test_pattern()
 {
     // blognone
     //$url = "/news/28710/กไอซีที-เริ่มโครงการ-wi-fi-ฟรี-28-ธค-นี้-ที่สยามดิสคัฟเวอรี่";
     //$url = "/news/28710/กไอซีที-เริ่มโครงการ-wi-fi-ฟรี-28-ธค-นี้-ที่สยามดิสคัฟเวอรี่#comment-368466";
     // dek-d
     //$url = "/board/view.php?id=2340585";
     //$url = "/board/view.php?pno=6&id=2340585";
     // lcdtv
     //$url = "./detail.asp?param_id=850";
     $url = "/mainblog.php?id=goirish2011&month=01-02-2012&group=24&gblog=54";
     $domain_id = 22;
     $sub_comment = $this->custom_model->get_value('domain', 'sub_comment_pattern', $domain_id);
     $child = $this->custom_model->get_value('domain', 'child_pattern', $domain_id);
     echo $url;
     echo "<br>";
     if (preg_match($child, $url)) {
         echo "child";
     } else {
         if ($sub_comment != null && preg_match($sub_comment, $url)) {
             echo "sub_comment";
         } else {
             echo "bad";
         }
     }
     echo "<hr>";
     $parent_page_id = 67045;
     // if url start with "?", get parent page (which is not also a sub_comment page) and entail
     if ($url[0] == "?") {
         $parent = new Page_model();
         $parent->init($parent_page_id);
         while ($parent->sub_comment) {
             $parent->init($parent->parent_page_id);
         }
         $str = explode("?", $parent->url);
         $url = $str[0] . $url;
     }
     // if url start with ".", trim it out
     if ($url[0] == ".") {
         $url = substr($url, 1);
     }
     echo "url:" . $url;
 }
Beispiel #10
0
 /**
  * Remove deleted page records and relations to it from DB.
  *
  * @return	int		Amount of deleted pages that have been removed
  */
 public function remove_deleted_pages()
 {
     $this->page_model->remove_deleted_pages();
     $result = array('status' => 'success', 'message' => lang('ionize_message_check_ok'));
     $this->xhr_output($result);
 }
    /**
     * 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);
    }
Beispiel #12
0
 /**
  * Duplicate an area for another language (secret method)
  * If you need to add another language to an area you can call this script
  * /admin/pages/duplicate_area_lang/ID_AREA/OLD_LANG/NEW_LANG
  *
  * @param   integer $id_area Area ID
  * @param   string  $old_lang Old language to copy
  * @param   string  $new_lang New language to set
  * @return  string
  */
 public function duplicate_area_lang($id_area, $old_lang, $new_lang)
 {
     // Comment the next row to enable the method
     die('Operation disabled!');
     $mod = new Page_model();
     // duplicate
     $res = $mod->duplicate_area_lang($id_area, $old_lang, $new_lang);
     if ($res[1]) {
         // refactory permissions
         $mod = new Permission_model();
         $mod->refactory($_SESSION['xuid']);
         echo '<h1>CONGRATULATIONS!</h1>';
         echo '<p>The changes on the database are applied.</p>';
         // print instructions for manual changes
         echo '<p>Follow this instructions to perform manual changes.</p>
         <ul>
             <li>Install the following modules: ' . implode(', ', $res[0]) . ' and configure them if needed</li>
         </ul>
         <p>Done!</p>
         
         <p>NOTE: this operation acts on the pages and articles of the CMS, if you use plugins you have to check if you need to duplicate contents.</p>';
     } else {
         echo '<h1>WARNING!</h1>';
         echo '<p>Something went wrong, changes are not applied.</p>';
     }
     die;
 }
Beispiel #13
0
/**
 * lay page tu key va render ra view
 * 
 * @param mixed $key
 */
function renderPage($key, $get_by = 'content')
{
    $contentModel = new Page_model();
    $contentObj = $contentModel->getby_key($key);
    $str = '';
    if (isset($contentObj[$get_by])) {
        $str = $contentObj[$get_by];
    }
    $html = html_entity_decode($str, ENT_QUOTES, 'UTF-8');
    return $html;
}
Beispiel #14
0
 function index()
 {
     // Articles
     $articles = $this->article_model->get_lang_list(array('order_by' => 'updated DESC'), Settings::get_lang('default'));
     // Last 10 articles
     $last_articles = array();
     $max = count($articles) > 9 ? 10 : count($articles);
     $count = 0;
     if (!empty($articles)) {
         foreach ($articles as $article) {
             if (Authority::can('access', 'backend/menu/' . $article['id_menu'], NULL, TRUE) && Authority::can('access', 'backend/page/' . $article['id_page'], NULL, TRUE) && Authority::can('access', 'backend/article/' . $article['id_article'], NULL, TRUE)) {
                 $last_articles[] = $article;
                 $count++;
                 if ($count == $max) {
                     break;
                 }
             }
         }
     }
     // Orphan articles
     $orphan_articles = array();
     foreach ($articles as $article) {
         if (!$article['id_page']) {
             $orphan_articles[] = $article;
         }
     }
     // Orphan pages
     $orphan_pages = $this->page_model->get_lang_list(array('id_menu' => '0', 'order_by' => 'name ASC'), Settings::get_lang('default'));
     // Last connected /registered users
     $logged_user_role = User()->get_role();
     $users = $this->user_model->get_list_with_role(array('limit' => '10', 'order_by' => 'last_visit DESC', 'last_visit <>' => ''));
     $last_registered_users = $this->user_model->get_list_with_role(array('limit' => '10', 'order_by' => 'join_date DESC'));
     // Updates on last articles
     foreach ($last_articles as &$article) {
         // User name update
         foreach ($users as $user) {
             if ($user['username'] == $article['updater']) {
                 $article['updater'] = $user['screen_name'];
             }
             if ($user['username'] == $article['author']) {
                 $article['author'] = $user['screen_name'];
             }
         }
         $pages = $this->page_model->get_parent_array($article['id_page'], array(), Settings::get_lang('default'));
         $breadcrumb = array();
         foreach ($pages as $page) {
             $breadcrumb[] = !empty($page['title']) ? $page['title'] : $page['name'];
         }
         $article['breadcrumb'] = implode(' > ', $breadcrumb);
     }
     // Updates on orphan pages
     foreach ($orphan_pages as &$page) {
         // User name update
         foreach ($users as $user) {
             if ($user['username'] == $page['updater']) {
                 $page['updater'] = $user['screen_name'];
             }
             if ($user['username'] == $page['author']) {
                 $page['author'] = $user['screen_name'];
             }
         }
     }
     // Updates on orphan articles
     foreach ($orphan_articles as &$article) {
         // User name update
         foreach ($users as $user) {
             if ($user['username'] == $article['updater']) {
                 $article['updater'] = $user['screen_name'];
             }
             if ($user['username'] == $article['author']) {
                 $article['author'] = $user['screen_name'];
             }
         }
     }
     // Flags
     $settings = Settings::get_settings();
     $flags = array();
     foreach ($settings as $key => $setting) {
         if (strpos($key, 'flag') !== FALSE && $setting != '') {
             $flags[substr($key, -1)] = $setting;
         }
     }
     // Put installed module list to template
     $installed_modules = Modules()->get_installed_modules();
     $modules = array();
     foreach ($installed_modules as $module) {
         if ($module['has_admin'] && Authority::can('access', 'module/' . $module['key'])) {
             $modules[] = $module;
         }
     }
     $this->template['modules'] = $modules;
     $this->template['flags'] = $flags;
     $this->template['last_articles'] = $last_articles;
     $this->template['orphan_pages'] = $orphan_pages;
     $this->template['orphan_articles'] = $orphan_articles;
     $this->template['users'] = $users;
     $this->template['last_registered_users'] = $last_registered_users;
     $this->output('desktop/dashboard');
 }
Beispiel #15
0
 function _save($id)
 {
     $page_model = new Page_model();
     if ($id) {
         $page = $page_model->get_from_id($id);
         $page->save($_POST);
     } else {
         $page = $page_model;
         $id = $page->create($_POST);
     }
     return $id;
 }
Beispiel #16
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);
 }