コード例 #1
0
 private function create_module_map_sections($categories, $id_cat, $auth_mode)
 {
     $category = $this->categories_manager->get_categories_cache()->get_category($id_cat);
     $this_category = new SitemapLink($category->get_name(), $this->get_category_url($category));
     $section = new SitemapSection($this_category);
     $i = 0;
     foreach ($categories as $id => $category) {
         if ($auth_mode == Sitemap::AUTH_PUBLIC) {
             $this_auth = Authorizations::check_auth(RANK_TYPE, User::VISITOR_LEVEL, $category->get_authorizations(), Category::READ_AUTHORIZATIONS);
         } else {
             $this_auth = AppContext::get_current_user()->check_auth($category->get_authorizations(), Category::READ_AUTHORIZATIONS);
         }
         if ($this_auth && $id != Category::ROOT_CATEGORY && $category->get_id_parent() == $id_cat) {
             $section->add($this->create_module_map_sections($categories, $id, $auth_mode));
             $i++;
         }
     }
     if ($i == 0) {
         $section = $this_category;
     }
     return $section;
 }
コード例 #2
0
 private function create_module_map_sections($id_cat, $auth_mode)
 {
     global $LANG;
     $categories_cache = WikiCategoriesCache::load();
     $categories = $categories_cache->get_categories();
     $this_category = new SitemapLink(stripslashes($categories[$id_cat]['title']), new Url('/wiki/' . url('wiki.php?title=' . $categories[$id_cat]['encoded_title'], $categories[$id_cat]['encoded_title'])));
     $category = new SitemapSection($this_category);
     $i = 0;
     $keys = array_keys($categories);
     $num_cats = $categories_cache->get_number_categories();
     $properties = array();
     for ($j = 0; $j < $num_cats; $j++) {
         $id = $keys[$j];
         $properties = $categories[$id];
         if ($id != 0 && $properties['id_parent'] == $id_cat) {
             $category->add($this->create_module_map_sections($id, $auth_mode));
             $i++;
         }
     }
     if ($i == 0) {
         $category = $this_category;
     }
     return $category;
 }
コード例 #3
0
 private function create_module_map_sections($id_cat, $auth_mode)
 {
     global $LANG;
     $pages_config = PagesConfig::load();
     $categories_cache = PagesCategoriesCache::load();
     $categories = $categories_cache->get_categories();
     //Configuration des authorisations
     $config_authorizations = $pages_config->get_authorizations();
     $this_category = new SitemapLink($categories[$id_cat]['title'], new Url('/pages/' . url('pages.php?title=' . Url::encode_rewrite($categories[$id_cat]['title']), Url::encode_rewrite($categories[$id_cat]['title']))));
     $category = new SitemapSection($this_category);
     $i = 0;
     $keys = array_keys($categories);
     $num_cats = $categories_cache->get_number_categories();
     $properties = array();
     for ($j = 0; $j < $num_cats; $j++) {
         $id = $keys[$j];
         $properties = $categories[$id];
         if ($auth_mode == Sitemap::AUTH_PUBLIC) {
             $this_auth = is_array($properties['auth']) ? Authorizations::check_auth(RANK_TYPE, User::VISITOR_LEVEL, $properties['auth'], READ_PAGE) : Authorizations::check_auth(RANK_TYPE, User::VISITOR_LEVEL, $config_authorizations, READ_PAGE);
         } elseif ($auth_mode == Sitemap::AUTH_USER) {
             if (AppContext::get_current_user()->get_level() == User::ADMIN_LEVEL) {
                 $this_auth = true;
             } else {
                 $this_auth = is_array($properties['auth']) ? Authorizations::check_auth(RANK_TYPE, AppContext::get_current_user()->get_level(), $properties['auth'], READ_PAGE) : Authorizations::check_auth(RANK_TYPE, AppContext::get_current_user()->get_level(), $config_authorizations, READ_PAGE);
             }
         }
         if ($this_auth && $id != 0 && $properties['id_parent'] == $id_cat) {
             $category->add($this->create_module_map_sections($id, $auth_mode));
             $i++;
         }
     }
     if ($i == 0) {
         $category = $this_category;
     }
     return $category;
 }
コード例 #4
0
ファイル: Sitemap.class.php プロジェクト: AroundPBT/PHPBoost
 /**
  * @desc Adds to the site map all the kernel links.
  * @param int $mode USER_MODE ou SEARCH_ENGINE_MODE, it depends on if you want to show it to a user in particular or to anybody
  * @param int $auth_mode AUTH_GUEST or AUTH_USERS, it depends if you want to display only the public pages or also the private ones.
  */
 private function build_kernel_map($mode = self::USER_MODE, $auth_mode = self::AUTH_PUBLIC)
 {
     global $LANG;
     //We consider the kernel as a module
     $kernel_map = new ModuleMap(new SitemapLink($LANG['home'], new Url(Environment::get_home_page())));
     //The site description
     $kernel_map->set_description(nl2br(GeneralConfig::load()->get_site_description()));
     //All the links which not need to be present in the search engine results.
     if ($mode == self::USER_MODE) {
         if (AppContext::get_current_user()->check_auth(UserAccountsConfig::load()->get_auth_read_members(), UserAccountsConfig::AUTH_READ_MEMBERS_BIT)) {
             $kernel_map->add(new SitemapLink(LangLoader::get_message('members-list', 'user-common'), UserUrlBuilder::home()));
         }
         //Member space
         if ($auth_mode == self::AUTH_USER && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL)) {
             //We create a section for that
             $member_space_section = new SitemapSection(new SitemapLink($LANG['my_private_profile'], UserUrlBuilder::profile(AppContext::get_current_user()->get_id())));
             //Profile edition
             $member_space_section->add(new SitemapLink(LangLoader::get_message('profile.edit', 'user-common'), UserUrlBuilder::edit_profile(AppContext::get_current_user()->get_id())));
             //Private messaging
             $member_space_section->add(new SitemapLink($LANG['private_messaging'], UserUrlBuilder::personnal_message(AppContext::get_current_user()->get_id())));
             //Contribution panel
             $member_space_section->add(new SitemapLink($LANG['contribution_panel'], UserUrlBuilder::contribution_panel()));
             //Administration panel
             if (AppContext::get_current_user()->check_level(User::ADMIN_LEVEL)) {
                 $member_space_section->add(new SitemapLink($LANG['admin_panel'], UserUrlBuilder::administration()));
             }
             //We add it to the kernel map
             $kernel_map->add($member_space_section);
         }
     }
     //The kernel map is added to the site map
     $this->add($kernel_map);
 }
コード例 #5
0
 /**
  * @desc Builds a ModuleMap object
  * @param SitemapLink $link Link associated to the root of the module
  * @param string $module_id Id of the corresponding module
  */
 public function __construct(SitemapLink $link, $module_id = '')
 {
     parent::__construct($link);
     $this->module_id = $module_id;
 }