예제 #1
0
파일: article.php 프로젝트: rockylo/ionize
 /**
  * Edit one article
  *
  * @param	string	$rel	article REL. Composed by the page ID and the article ID
  *							Example : 1.23
  *							1 : id_page
  *							23 : id_article
  */
 public function edit($rel)
 {
     // IDs
     $rel = explode(".", $rel);
     $id_page = !empty($rel[1]) ? $rel[0] : '0';
     $id_article = !empty($rel[1]) ? $rel[1] : NULL;
     $resource = $this->_get_resource_name('backend', 'article', $id_article);
     $page_resource = $this->_get_resource_name('backend', 'page', $id_page);
     if (Authority::can('edit', 'admin/article') && Authority::can('edit', $resource, NULL, TRUE) && Authority::can('edit', $page_resource, NULL, TRUE)) {
         // Edit article if ID exists
         if (!is_null($id_article)) {
             $article = $this->article_model->get_by_id($id_article);
             if (!empty($article)) {
                 // Loads the modules addons
                 $this->load_modules_addons($article);
                 // Page context of the current edited article
                 $article['id_page'] = $id_page;
                 // Data & Lang Data
                 $this->template = array_merge($this->template, $article);
                 $this->article_model->feed_lang_template($id_article, $this->template);
                 // Extends fields
                 $extend_fields = $this->extend_field_model->get_element_extend_fields('article', $id_article);
                 $this->template['has_translated_extend_fields'] = $this->_has_translated_extend_fields($extend_fields);
                 $this->template['extend_fields'] = $extend_fields;
                 // Link : Depending on the context
                 $context = $this->article_model->get_context($id_article, $id_page);
                 if (!empty($context)) {
                     $this->template['main_parent'] = $context['main_parent'];
                     $pages = $this->page_model->get_parent_array($id_page, array(), Settings::get_lang('default'));
                     // Breadcrump
                     $breadcrump = array();
                     foreach ($pages as $page) {
                         $breadcrump[] = !empty($page['title']) ? $page['title'] : $page['name'];
                     }
                     $this->template['breadcrump'] = implode(' > ', $breadcrump);
                 } else {
                     $this->template['main_parent'] = '0';
                 }
                 Event::fire('Article.edit', $this->template);
                 $this->output('article/article');
             }
         }
     } else {
         $this->output(self::$_DENY_MAIN_VIEW);
     }
 }
예제 #2
0
파일: page.php 프로젝트: trk/ionize
 /**
  * Edit one page
  *
  * @param	string	$id_page
  */
 public function edit($id_page)
 {
     $resource = $this->_get_resource_name('backend', 'page', $id_page);
     if (Authority::can('edit', 'admin/page') && Authority::can('edit', $resource, null, true)) {
         // Data
         $page = $this->page_model->get_by_id($id_page);
         if (!empty($page)) {
             $this->load_modules_addons($page);
             // Correct the menu ID (for phantom pages)
             if ($page['id_menu'] == '0') {
                 $page['id_menu'] = '1';
             }
             // Data & Lang Data
             $this->template = array_merge($this->template, $page);
             $this->page_model->feed_lang_template($id_page, $this->template);
             // Array of path to the element. Gives the complete URL to the element.
             $this->template['parent_array'] = $this->page_model->get_parent_array($id_page);
             // Breadcrumbs
             $pages = $this->page_model->get_parent_array($id_page, array(), Settings::get_lang('default'));
             $breadcrumps = array();
             foreach ($pages as $page) {
                 $breadcrumps[] = !empty($page['title']) ? $page['title'] : $page['name'];
             }
             $this->template['breadcrump'] = implode(' > ', $breadcrumps);
             // Extend fields
             $this->template['extend_fields'] = $this->extend_field_model->get_element_extend_fields('page', $id_page);
             // URLs
             $this->template['urls'] = $this->url_model->get_entity_urls('page', $id_page);
             // Output
             $this->output('page/page');
         } else {
             $this->error(lang('ionize_message_page_not_exist'));
         }
     } else {
         $this->output(self::$_DENY_MAIN_VIEW);
     }
 }
예제 #3
0
파일: dashboard.php 프로젝트: trk/ionize
 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');
 }