public function get_root_category()
 {
     $root = new RichRootCategory();
     $root->set_authorizations(WebConfig::load()->get_authorizations());
     $root->set_description(WebConfig::load()->get_root_category_description());
     return $root;
 }
 private function build_view()
 {
     $config = WebConfig::load();
     $weblink = $this->get_weblink();
     $category = $weblink->get_category();
     $keywords = $weblink->get_keywords();
     $has_keywords = count($keywords) > 0;
     $this->tpl->put_all(array_merge($weblink->get_array_tpl_vars(), array('C_COMMENTS_ENABLED' => $config->are_comments_enabled(), 'C_NOTATION_ENABLED' => $config->is_notation_enabled(), 'C_KEYWORDS' => $has_keywords, 'NOT_VISIBLE_MESSAGE' => MessageHelper::display(LangLoader::get_message('element.not_visible', 'status-messages-common'), MessageHelper::WARNING))));
     if ($config->are_comments_enabled()) {
         $comments_topic = new WebCommentsTopic($weblink);
         $comments_topic->set_id_in_module($weblink->get_id());
         $comments_topic->set_url(WebUrlBuilder::display($category->get_id(), $category->get_rewrited_name(), $weblink->get_id(), $weblink->get_rewrited_name()));
         $this->tpl->put('COMMENTS', $comments_topic->display());
     }
     if ($has_keywords) {
         $this->build_keywords_view($keywords);
     }
 }
Beispiel #3
0
    /**
     * {@inheritdoc}
     */
    public function synchronize()
    {
        $this->partners_weblinks = array();
        $now = new Date();
        $config = WebConfig::load();
        $result = PersistenceContext::get_querier()->select('
			SELECT web.id, web.name, web.partner_picture
			FROM ' . WebSetup::$web_table . ' web
			LEFT JOIN ' . DB_TABLE_COMMENTS_TOPIC . ' com ON com.id_in_module = web.id AND com.module_id = \'web\'
			LEFT JOIN ' . DB_TABLE_AVERAGE_NOTES . ' notes ON notes.id_in_module = web.id AND notes.module_name = \'web\'
			WHERE web.approbation_type = 1 OR (web.approbation_type = 2 AND (web.start_date > :timestamp_now OR (end_date != 0 AND end_date < :timestamp_now))) AND partner = 1
			ORDER BY web.privileged_partner DESC, ' . $config->get_sort_type() . ' ' . $config->get_sort_mode() . '
			LIMIT :partners_number_in_menu OFFSET 0', array('timestamp_now' => $now->get_timestamp(), 'partners_number_in_menu' => (int) $config->get_partners_number_in_menu()));
        while ($row = $result->fetch()) {
            $this->partners_weblinks[$row['id']] = $row;
        }
        $result->dispose();
    }
    private function get_pagination($condition, $parameters, $field, $mode, $page)
    {
        $result = PersistenceContext::get_querier()->select_single_row_query('SELECT COUNT(*) AS weblinks_number
		FROM ' . WebSetup::$web_table . ' web
		LEFT JOIN ' . DB_TABLE_KEYWORDS_RELATIONS . ' relation ON relation.module_id = \'web\' AND relation.id_in_module = web.id 
		' . $condition, $parameters);
        $pagination = new ModulePagination($page, $result['weblinks_number'], (int) WebConfig::load()->get_items_number_per_page());
        $pagination->set_url(WebUrlBuilder::display_tag($this->get_keyword()->get_rewrited_name(), $field, $mode, '%d'));
        if ($pagination->current_page_is_empty() && $page > 1) {
            $error_controller = PHPBoostErrors::unexisting_page();
            DispatchManager::redirect($error_controller);
        }
        return $pagination;
    }
Beispiel #5
0
 public function set_properties(array $properties)
 {
     $this->id = $properties['id'];
     $this->id_category = $properties['id_category'];
     $this->name = $properties['name'];
     $this->rewrited_name = $properties['rewrited_name'];
     $this->url = new Url($properties['url']);
     $this->contents = $properties['contents'];
     $this->short_contents = $properties['short_contents'];
     $this->approbation_type = $properties['approbation_type'];
     $this->start_date = !empty($properties['start_date']) ? new Date($properties['start_date'], Timezone::SERVER_TIMEZONE) : null;
     $this->end_date = !empty($properties['end_date']) ? new Date($properties['end_date'], Timezone::SERVER_TIMEZONE) : null;
     $this->end_date_enabled = !empty($properties['end_date']);
     $this->creation_date = new Date($properties['creation_date'], Timezone::SERVER_TIMEZONE);
     $this->number_views = $properties['number_views'];
     $this->partner = (bool) $properties['partner'];
     $this->partner_picture = new Url($properties['partner_picture']);
     $this->privileged_partner = (bool) $properties['privileged_partner'];
     $user = new User();
     if (!empty($properties['user_id'])) {
         $user->set_properties($properties);
     } else {
         $user->init_visitor_user();
     }
     $this->set_author_user($user);
     $notation = new Notation();
     $notation->set_module_name('web');
     $notation->set_notation_scale(WebConfig::load()->get_notation_scale());
     $notation->set_id_in_module($properties['id']);
     $notation->set_number_notes($properties['number_notes']);
     $notation->set_average_notes($properties['average_notes']);
     $notation->set_user_already_noted(!empty($properties['note']));
     $this->notation = $notation;
 }
 private function get_pagination($condition, $parameters, $field, $mode, $page, $subcategories_page)
 {
     $weblinks_number = WebService::count($condition, $parameters);
     $pagination = new ModulePagination($page, $weblinks_number, (int) WebConfig::load()->get_items_number_per_page());
     $pagination->set_url(WebUrlBuilder::display_category($this->get_category()->get_id(), $this->get_category()->get_rewrited_name(), $field, $mode, '%d', $subcategories_page));
     if ($pagination->current_page_is_empty() && $page > 1) {
         $error_controller = PHPBoostErrors::unexisting_page();
         DispatchManager::redirect($error_controller);
     }
     return $pagination;
 }
 /**
  * @desc Return the authorized categories.
  */
 public static function get_authorized_categories($current_id_category)
 {
     $search_category_children_options = new SearchCategoryChildrensOptions();
     $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
     if (AppContext::get_current_user()->is_guest()) {
         $search_category_children_options->set_allow_only_member_level_authorizations(WebConfig::load()->are_descriptions_displayed_to_guests());
     }
     $categories = self::get_categories_manager()->get_childrens($current_id_category, $search_category_children_options, true);
     return array_keys($categories);
 }
 private function init()
 {
     $this->config = WebConfig::load();
     $this->lang = LangLoader::get('common', 'web');
     $this->admin_common_lang = LangLoader::get('admin-common');
 }