public function get_search_form($args)
 {
     global $LANG;
     $tpl = new FileTemplate('forum/forum_search_form.tpl');
     require_once PATH_TO_ROOT . '/forum/forum_functions.php';
     require_once PATH_TO_ROOT . '/forum/forum_defines.php';
     load_module_lang('forum');
     //Chargement de la langue du module.
     $search = $args['search'];
     $idcat = !empty($args['ForumIdcat']) ? NumberHelper::numeric($args['ForumIdcat']) : -1;
     $time = !empty($args['ForumTime']) ? NumberHelper::numeric($args['ForumTime']) : 0;
     $where = !empty($args['ForumWhere']) ? TextHelper::strprotect($args['ForumWhere']) : 'all';
     //Liste des catégories.
     $search_category_children_options = new SearchCategoryChildrensOptions();
     $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
     $categories_tree = ForumService::get_categories_manager()->get_select_categories_form_field('cats', '', $idcat, $search_category_children_options);
     $method = new ReflectionMethod('AbstractFormFieldChoice', 'get_options');
     $method->setAccessible(true);
     $categories_tree_options = $method->invoke($categories_tree);
     $cat_list = '';
     foreach ($categories_tree_options as $option) {
         if ($option->get_raw_value()) {
             $cat = ForumService::get_categories_manager()->get_categories_cache()->get_category($option->get_raw_value());
             if (!$cat->get_url()) {
                 $cat_list .= $option->display()->render();
             }
         }
     }
     $date_lang = LangLoader::get('date-common');
     $tpl->put_all(array('L_DATE' => $date_lang['date'], 'L_DAY' => $date_lang['day'], 'L_DAYS' => $date_lang['days'], 'L_MONTH' => $date_lang['month'], 'L_MONTHS' => $date_lang['month'], 'L_YEAR' => $date_lang['year'], 'IS_SELECTED_30000' => $time == 30000 ? ' selected="selected"' : '', 'IS_SELECTED_1' => $time == 1 ? ' selected="selected"' : '', 'IS_SELECTED_7' => $time == 7 ? ' selected="selected"' : '', 'IS_SELECTED_15' => $time == 15 ? ' selected="selected"' : '', 'IS_SELECTED_30' => $time == 30 ? ' selected="selected"' : '', 'IS_SELECTED_180' => $time == 180 ? ' selected="selected"' : '', 'IS_SELECTED_360' => $time == 360 ? ' selected="selected"' : '', 'L_OPTIONS' => $LANG['options'], 'L_TITLE' => $LANG['title'], 'L_CONTENTS' => $LANG['content'], 'IS_TITLE_CHECKED' => $where == 'title' ? ' checked="checked"' : '', 'IS_CONTENTS_CHECKED' => $where == 'contents' ? ' checked="checked"' : '', 'IS_ALL_CHECKED' => $where == 'all' ? ' checked="checked"' : '', 'L_CATEGORY' => $LANG['category'], 'L_ALL_CATS' => $LANG['all'], 'IS_ALL_CATS_SELECTED' => $idcat == '-1' ? ' selected="selected"' : '', 'CATS' => $cat_list));
     return $tpl->render();
 }
    private function build_form(HTTPRequestCustom $request)
    {
        $form = new HTMLForm(__CLASS__);
        $fieldset = new FormFieldsetHTML('web', $this->get_weblink()->get_id() === null ? $this->lang['web.add'] : $this->lang['web.edit']);
        $form->add_fieldset($fieldset);
        $fieldset->add_field(new FormFieldTextEditor('name', $this->common_lang['form.name'], $this->get_weblink()->get_name(), array('required' => true)));
        $search_category_children_options = new SearchCategoryChildrensOptions();
        $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
        $search_category_children_options->add_authorizations_bits(Category::CONTRIBUTION_AUTHORIZATIONS);
        $fieldset->add_field(WebService::get_categories_manager()->get_select_categories_form_field('id_category', $this->common_lang['form.category'], $this->get_weblink()->get_id_category(), $search_category_children_options));
        $fieldset->add_field(new FormFieldUrlEditor('url', $this->common_lang['form.url'], $this->get_weblink()->get_url()->absolute(), array('required' => true)));
        $fieldset->add_field(new FormFieldRichTextEditor('contents', $this->common_lang['form.description'], $this->get_weblink()->get_contents(), array('rows' => 15, 'required' => true)));
        $fieldset->add_field(new FormFieldCheckbox('short_contents_enabled', $this->common_lang['form.short_contents.enabled'], $this->get_weblink()->is_short_contents_enabled(), array('description' => StringVars::replace_vars($this->common_lang['form.short_contents.enabled.description'], array('number' => WebConfig::NUMBER_CARACTERS_BEFORE_CUT)), 'events' => array('click' => '
			if (HTMLForms.getField("short_contents_enabled").getValue()) {
				HTMLForms.getField("short_contents").enable();
			} else { 
				HTMLForms.getField("short_contents").disable();
			}'))));
        $fieldset->add_field(new FormFieldRichTextEditor('short_contents', $this->common_lang['form.short_contents'], $this->get_weblink()->get_short_contents(), array('hidden' => !$this->get_weblink()->is_short_contents_enabled())));
        $other_fieldset = new FormFieldsetHTML('other', $this->common_lang['form.other']);
        $form->add_fieldset($other_fieldset);
        $other_fieldset->add_field(new FormFieldCheckbox('partner', $this->lang['web.form.partner'], $this->get_weblink()->is_partner(), array('events' => array('click' => '
				if (HTMLForms.getField("partner").getValue()) {
					HTMLForms.getField("partner_picture").enable();
					HTMLForms.getField("privileged_partner").enable();
				} else {
					HTMLForms.getField("partner_picture").disable();
					HTMLForms.getField("privileged_partner").disable();
				}'))));
        $other_fieldset->add_field(new FormFieldUploadPictureFile('partner_picture', $this->lang['web.form.partner_picture'], $this->get_weblink()->get_partner_picture()->relative(), array('hidden' => !$this->get_weblink()->is_partner())));
        $other_fieldset->add_field(new FormFieldCheckbox('privileged_partner', $this->lang['web.form.privileged_partner'], $this->get_weblink()->is_privileged_partner(), array('description' => $this->lang['web.form.privileged_partner.explain'], 'hidden' => !$this->get_weblink()->is_partner())));
        $other_fieldset->add_field(WebService::get_keywords_manager()->get_form_field($this->get_weblink()->get_id(), 'keywords', $this->common_lang['form.keywords'], array('description' => $this->common_lang['form.keywords.description'])));
        if (!$this->is_contributor_member()) {
            $publication_fieldset = new FormFieldsetHTML('publication', $this->common_lang['form.approbation']);
            $form->add_fieldset($publication_fieldset);
            $publication_fieldset->add_field(new FormFieldDateTime('creation_date', $this->common_lang['form.date.creation'], $this->get_weblink()->get_creation_date(), array('required' => true)));
            $publication_fieldset->add_field(new FormFieldSimpleSelectChoice('approbation_type', $this->common_lang['form.approbation'], $this->get_weblink()->get_approbation_type(), array(new FormFieldSelectChoiceOption($this->common_lang['form.approbation.not'], WebLink::NOT_APPROVAL), new FormFieldSelectChoiceOption($this->common_lang['form.approbation.now'], WebLink::APPROVAL_NOW), new FormFieldSelectChoiceOption($this->common_lang['status.approved.date'], WebLink::APPROVAL_DATE)), array('events' => array('change' => '
				if (HTMLForms.getField("approbation_type").getValue() == 2) {
					jQuery("#' . __CLASS__ . '_start_date_field").show();
					HTMLForms.getField("end_date_enabled").enable();
				} else { 
					jQuery("#' . __CLASS__ . '_start_date_field").hide();
					HTMLForms.getField("end_date_enabled").disable();
				}'))));
            $publication_fieldset->add_field(new FormFieldDateTime('start_date', $this->common_lang['form.date.start'], $this->get_weblink()->get_start_date() === null ? new Date() : $this->get_weblink()->get_start_date(), array('hidden' => $this->get_weblink()->get_approbation_type() != WebLink::APPROVAL_DATE)));
            $publication_fieldset->add_field(new FormFieldCheckbox('end_date_enabled', $this->common_lang['form.date.end.enable'], $this->get_weblink()->is_end_date_enabled(), array('hidden' => $this->get_weblink()->get_approbation_type() != WebLink::APPROVAL_DATE, 'events' => array('click' => '
			if (HTMLForms.getField("end_date_enabled").getValue()) {
				HTMLForms.getField("end_date").enable();
			} else { 
				HTMLForms.getField("end_date").disable();
			}'))));
            $publication_fieldset->add_field(new FormFieldDateTime('end_date', $this->common_lang['form.date.end'], $this->get_weblink()->get_end_date() === null ? new Date() : $this->get_weblink()->get_end_date(), array('hidden' => !$this->get_weblink()->is_end_date_enabled())));
        }
        $this->build_contribution_fieldset($form);
        $fieldset->add_field(new FormFieldHidden('referrer', $request->get_url_referrer()));
        $this->submit_button = new FormButtonDefaultSubmit();
        $form->add_button($this->submit_button);
        $form->add_button(new FormButtonReset());
        $this->form = $form;
    }
 /**
  * @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);
     $categories = self::get_categories_manager()->get_childrens($current_id_category, $search_category_children_options, true);
     return array_keys($categories);
 }
    private function build_form(HTTPRequestCustom $request)
    {
        $common_lang = LangLoader::get('common');
        $date_lang = LangLoader::get('date-common');
        $event_content = $this->get_event()->get_content();
        $form = new HTMLForm(__CLASS__);
        $fieldset = new FormFieldsetHTML('event', $this->lang['calendar.titles.event']);
        $form->add_fieldset($fieldset);
        $fieldset->add_field(new FormFieldTextEditor('title', $common_lang['form.title'], $event_content->get_title(), array('required' => true)));
        $search_category_children_options = new SearchCategoryChildrensOptions();
        $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
        $search_category_children_options->add_authorizations_bits(Category::CONTRIBUTION_AUTHORIZATIONS);
        $fieldset->add_field(CalendarService::get_categories_manager()->get_select_categories_form_field('category_id', LangLoader::get_message('category', 'categories-common'), $event_content->get_category_id(), $search_category_children_options));
        $fieldset->add_field(new FormFieldRichTextEditor('contents', $common_lang['form.contents'], $event_content->get_contents(), array('rows' => 15, 'required' => true)));
        $fieldset->add_field($start_date = new FormFieldDateTime('start_date', $this->lang['calendar.labels.start_date'], $this->get_event()->get_start_date(), array('required' => true)));
        $fieldset->add_field($end_date = new FormFieldDateTime('end_date', $this->lang['calendar.labels.end_date'], $this->get_event()->get_end_date(), array('required' => true)));
        $form->add_constraint(new FormConstraintFieldsDifferenceSuperior($start_date, $end_date));
        $fieldset->add_field(new FormFieldSimpleSelectChoice('repeat_type', $this->lang['calendar.labels.repeat_type'], $event_content->get_repeat_type(), array(new FormFieldSelectChoiceOption($this->lang['calendar.labels.repeat.never'], CalendarEventContent::NEVER), new FormFieldSelectChoiceOption($date_lang['every_day'], CalendarEventContent::DAILY), new FormFieldSelectChoiceOption($date_lang['every_week'], CalendarEventContent::WEEKLY), new FormFieldSelectChoiceOption($date_lang['every_month'], CalendarEventContent::MONTHLY), new FormFieldSelectChoiceOption($date_lang['every_year'], CalendarEventContent::YEARLY)), array('events' => array('change' => '
			if (HTMLForms.getField("repeat_type").getValue() != "' . CalendarEventContent::NEVER . '") {
				HTMLForms.getField("repeat_number").enable();
			} else {
				HTMLForms.getField("repeat_number").disable();
			}'))));
        $fieldset->add_field(new FormFieldNumberEditor('repeat_number', $this->lang['calendar.labels.repeat_number'], $event_content->get_repeat_number(), array('min' => 1, 'max' => 150, 'hidden' => $event_content->get_repeat_type() == CalendarEventContent::NEVER), array(new FormFieldConstraintIntegerRange(1, 150))));
        $fieldset->add_field(new FormFieldShortMultiLineTextEditor('location', $this->lang['calendar.labels.location'], $event_content->get_location()));
        $fieldset->add_field(new FormFieldCheckbox('registration_authorized', $this->lang['calendar.labels.registration_authorized'], $event_content->is_registration_authorized(), array('events' => array('click' => '
			if (HTMLForms.getField("registration_authorized").getValue()) {
				HTMLForms.getField("max_registered_members").enable();
				HTMLForms.getField("last_registration_date_enabled").enable();
				jQuery("#' . __CLASS__ . '_register_authorizations").show();
			} else {
				HTMLForms.getField("max_registered_members").disable();
				HTMLForms.getField("last_registration_date_enabled").disable();
				jQuery("#' . __CLASS__ . '_register_authorizations").hide();
			}'))));
        $fieldset->add_field(new FormFieldNumberEditor('max_registered_members', $this->lang['calendar.labels.max_registered_members'], $event_content->get_max_registered_members(), array('description' => $this->lang['calendar.labels.max_registered_members.explain'], 'hidden' => !$event_content->is_registration_authorized()), array(new FormFieldConstraintRegex('`^[0-9]+$`i'))));
        $fieldset->add_field(new FormFieldCheckbox('last_registration_date_enabled', $this->lang['calendar.labels.last_registration_date_enabled'], $event_content->is_last_registration_date_enabled(), array('hidden' => !$event_content->is_registration_authorized(), 'events' => array('click' => '
			if (HTMLForms.getField("last_registration_date_enabled").getValue()) {
				HTMLForms.getField("last_registration_date").enable();
			} else {
				HTMLForms.getField("last_registration_date").disable();
			}'))));
        $fieldset->add_field(new FormFieldDateTime('last_registration_date', $this->lang['calendar.labels.last_registration_date'], $event_content->get_last_registration_date(), array('hidden' => !$event_content->is_last_registration_date_enabled())));
        $auth_settings = new AuthorizationsSettings(array(new ActionAuthorization($this->lang['calendar.authorizations.display_registered_users'], CalendarEventContent::DISPLAY_REGISTERED_USERS_AUTHORIZATION), new ActionAuthorization($this->lang['calendar.authorizations.register'], CalendarEventContent::REGISTER_AUTHORIZATION)));
        $auth_settings->build_from_auth_array($event_content->get_register_authorizations());
        $auth_setter = new FormFieldAuthorizationsSetter('register_authorizations', $auth_settings, array('hidden' => !$event_content->is_registration_authorized()));
        $fieldset->add_field($auth_setter);
        if (!$this->is_contributor_member()) {
            $fieldset->add_field(new FormFieldCheckbox('approved', $common_lang['form.approve'], $event_content->is_approved()));
        }
        $this->build_contribution_fieldset($form);
        $fieldset->add_field(new FormFieldHidden('referrer', $request->get_url_referrer()));
        $this->submit_button = new FormButtonDefaultSubmit();
        $form->add_button($this->submit_button);
        $form->add_button(new FormButtonReset());
        $this->form = $form;
    }
 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(ArticlesConfig::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 build_form(HTTPRequestCustom $request)
 {
     $form = new HTMLForm(__CLASS__);
     $fieldset = new FormFieldsetHTML('faq', $this->get_faq_question()->get_id() === null ? $this->lang['faq.add'] : $this->lang['faq.edit']);
     $form->add_fieldset($fieldset);
     $fieldset->add_field(new FormFieldTextEditor('question', $this->lang['faq.form.question'], $this->get_faq_question()->get_question(), array('required' => true)));
     $search_category_children_options = new SearchCategoryChildrensOptions();
     $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
     $search_category_children_options->add_authorizations_bits(Category::CONTRIBUTION_AUTHORIZATIONS);
     $fieldset->add_field(FaqService::get_categories_manager()->get_select_categories_form_field('id_category', $this->common_lang['form.category'], $this->get_faq_question()->get_id_category(), $search_category_children_options));
     $fieldset->add_field(new FormFieldRichTextEditor('answer', $this->lang['faq.form.answer'], $this->get_faq_question()->get_answer(), array('rows' => 15, 'required' => true)));
     if (!$this->is_contributor_member()) {
         $fieldset->add_field(new FormFieldCheckbox('approved', $this->common_lang['form.approve'], $this->get_faq_question()->is_approved()));
     }
     $this->build_contribution_fieldset($form);
     $fieldset->add_field(new FormFieldHidden('referrer', $request->get_url_referrer()));
     $this->submit_button = new FormButtonDefaultSubmit();
     $form->add_button($this->submit_button);
     $form->add_button(new FormButtonReset());
     $this->form = $form;
 }
    protected function build_form(HTTPRequestCustom $request)
    {
        $form = new HTMLForm(__CLASS__);
        $fieldset = new FormFieldsetHTML('category', $this->get_title());
        $form->add_fieldset($fieldset);
        $fieldset->add_field(new FormFieldTextEditor('name', $this->common_lang['form.name'], $this->get_category()->get_name(), array('required' => true)));
        $fieldset->add_field(new FormFieldCheckbox('personalize_rewrited_name', $this->common_lang['form.rewrited_name.personalize'], $this->get_category()->rewrited_name_is_personalized(), array('events' => array('click' => '
		if (HTMLForms.getField("personalize_rewrited_name").getValue()) {
			HTMLForms.getField("rewrited_name").enable();
		} else { 
			HTMLForms.getField("rewrited_name").disable();
		}'))));
        $fieldset->add_field(new FormFieldTextEditor('rewrited_name', $this->common_lang['form.rewrited_name'], $this->get_category()->get_rewrited_name(), array('description' => $this->common_lang['form.rewrited_name.description'], 'hidden' => !$this->get_category()->rewrited_name_is_personalized()), array(new FormFieldConstraintRegex('`^[a-z0-9\\-]+$`i'))));
        $search_category_children_options = new SearchCategoryChildrensOptions();
        if ($this->get_category()->get_id()) {
            $search_category_children_options->add_category_in_excluded_categories($this->get_category()->get_id());
        }
        $fieldset->add_field($this->get_categories_manager()->get_select_categories_form_field('id_parent', $this->common_lang['form.category'], $this->get_category()->get_id_parent(), $search_category_children_options));
        $this->build_fieldset_options($form);
        $fieldset_authorizations = new FormFieldsetHTML('authorizations_fieldset', $this->common_lang['authorizations']);
        $form->add_fieldset($fieldset_authorizations);
        $root_auth = $this->get_categories_manager()->get_categories_cache()->get_category(Category::ROOT_CATEGORY)->get_authorizations();
        $fieldset_authorizations->add_field(new FormFieldCheckbox('special_authorizations', $this->common_lang['authorizations'], !$this->get_category()->auth_is_equals($root_auth), array('description' => $this->lang['category.form.authorizations.description'], 'events' => array('click' => '
		if (HTMLForms.getField("special_authorizations").getValue()) {
			jQuery("#' . __CLASS__ . '_authorizations").show();
		} else { 
			jQuery("#' . __CLASS__ . '_authorizations").hide();
		}'))));
        $auth_settings = $this->get_authorizations_settings();
        $auth_setter = new FormFieldAuthorizationsSetter('authorizations', $auth_settings, array('hidden' => $this->get_category()->auth_is_equals($root_auth)));
        $auth_settings->build_from_auth_array($this->get_category()->get_authorizations());
        $fieldset_authorizations->add_field($auth_setter);
        $fieldset->add_field(new FormFieldHidden('referrer', $request->get_url_referrer()));
        $this->submit_button = new FormButtonDefaultSubmit();
        $form->add_button($this->submit_button);
        $form->add_button(new FormButtonReset());
        $this->form = $form;
    }
    private function build_form(HTTPRequestCustom $request)
    {
        $form = new HTMLForm(__CLASS__);
        $fieldset = new FormFieldsetHTML('news', $this->lang['news']);
        $form->add_fieldset($fieldset);
        $fieldset->add_field(new FormFieldTextEditor('name', $this->common_lang['form.name'], $this->get_news()->get_name(), array('required' => true)));
        if (!$this->is_contributor_member()) {
            $fieldset->add_field(new FormFieldCheckbox('personalize_rewrited_name', $this->common_lang['form.rewrited_name.personalize'], $this->get_news()->rewrited_name_is_personalized(), array('events' => array('click' => '
			if (HTMLForms.getField("personalize_rewrited_name").getValue()) {
				HTMLForms.getField("rewrited_name").enable();
			} else { 
				HTMLForms.getField("rewrited_name").disable();
			}'))));
            $fieldset->add_field(new FormFieldTextEditor('rewrited_name', $this->common_lang['form.rewrited_name'], $this->get_news()->get_rewrited_name(), array('description' => $this->common_lang['form.rewrited_name.description'], 'hidden' => !$this->get_news()->rewrited_name_is_personalized()), array(new FormFieldConstraintRegex('`^[a-z0-9\\-]+$`i'))));
        }
        $search_category_children_options = new SearchCategoryChildrensOptions();
        $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
        $search_category_children_options->add_authorizations_bits(Category::CONTRIBUTION_AUTHORIZATIONS);
        $fieldset->add_field(NewsService::get_categories_manager()->get_select_categories_form_field('id_cat', $this->common_lang['form.category'], $this->get_news()->get_id_cat(), $search_category_children_options));
        $fieldset->add_field(new FormFieldRichTextEditor('contents', $this->common_lang['form.contents'], $this->get_news()->get_contents(), array('rows' => 15, 'required' => true)));
        $fieldset->add_field(new FormFieldCheckbox('enable_short_contents', $this->lang['news.form.short_contents.enabled'], $this->get_news()->get_short_contents_enabled(), array('description' => StringVars::replace_vars($this->lang['news.form.short_contents.enabled.description'], array('number' => NewsConfig::load()->get_number_character_to_cut())), 'events' => array('click' => '
			if (HTMLForms.getField("enable_short_contents").getValue()) {
				HTMLForms.getField("short_contents").enable();
			} else { 
				HTMLForms.getField("short_contents").disable();
			}'))));
        $fieldset->add_field(new FormFieldRichTextEditor('short_contents', $this->lang['news.form.short_contents'], $this->get_news()->get_short_contents(), array('hidden' => !$this->get_news()->get_short_contents_enabled(), 'description' => !NewsConfig::load()->get_display_condensed_enabled() ? '<span class="color-alert">' . $this->lang['news.form.short_contents.description'] . '</span>' : '')));
        $other_fieldset = new FormFieldsetHTML('other', $this->common_lang['form.other']);
        $form->add_fieldset($other_fieldset);
        $other_fieldset->add_field(new FormFieldUploadFile('picture', $this->common_lang['form.picture'], $this->get_news()->get_picture()->relative()));
        $other_fieldset->add_field(NewsService::get_keywords_manager()->get_form_field($this->get_news()->get_id(), 'keywords', $this->common_lang['form.keywords'], array('description' => $this->common_lang['form.keywords.description'])));
        $other_fieldset->add_field(new NewsFormFieldSelectSources('sources', $this->common_lang['form.sources'], $this->get_news()->get_sources()));
        if (!$this->is_contributor_member()) {
            $publication_fieldset = new FormFieldsetHTML('publication', $this->common_lang['form.approbation']);
            $form->add_fieldset($publication_fieldset);
            $publication_fieldset->add_field(new FormFieldDateTime('creation_date', $this->common_lang['form.date.creation'], $this->get_news()->get_creation_date(), array('required' => true)));
            $publication_fieldset->add_field(new FormFieldSimpleSelectChoice('approbation_type', $this->common_lang['form.approbation'], $this->get_news()->get_approbation_type(), array(new FormFieldSelectChoiceOption($this->common_lang['form.approbation.not'], News::NOT_APPROVAL), new FormFieldSelectChoiceOption($this->common_lang['form.approbation.now'], News::APPROVAL_NOW), new FormFieldSelectChoiceOption($this->common_lang['status.approved.date'], News::APPROVAL_DATE)), array('events' => array('change' => '
				if (HTMLForms.getField("approbation_type").getValue() == 2) {
					jQuery("#' . __CLASS__ . '_start_date_field").show();
					HTMLForms.getField("end_date_enable").enable();
				} else { 
					jQuery("#' . __CLASS__ . '_start_date_field").hide();
					HTMLForms.getField("end_date_enable").disable();
				}'))));
            $publication_fieldset->add_field(new FormFieldDateTime('start_date', $this->common_lang['form.date.start'], $this->get_news()->get_start_date() === null ? new Date() : $this->get_news()->get_start_date(), array('hidden' => $this->get_news()->get_approbation_type() != News::APPROVAL_DATE)));
            $publication_fieldset->add_field(new FormFieldCheckbox('end_date_enable', $this->common_lang['form.date.end.enable'], $this->get_news()->end_date_enabled(), array('hidden' => $this->get_news()->get_approbation_type() != News::APPROVAL_DATE, 'events' => array('click' => '
			if (HTMLForms.getField("end_date_enable").getValue()) {
				HTMLForms.getField("end_date").enable();
			} else { 
				HTMLForms.getField("end_date").disable();
			}'))));
            $publication_fieldset->add_field(new FormFieldDateTime('end_date', $this->common_lang['form.date.end'], $this->get_news()->get_end_date() === null ? new Date() : $this->get_news()->get_end_date(), array('hidden' => !$this->get_news()->end_date_enabled())));
            $publication_fieldset->add_field(new FormFieldCheckbox('top_list', $this->lang['news.form.top_list'], $this->get_news()->top_list_enabled()));
        }
        $this->build_contribution_fieldset($form);
        $fieldset->add_field(new FormFieldHidden('referrer', $request->get_url_referrer()));
        $this->submit_button = new FormButtonDefaultSubmit();
        $form->add_button($this->submit_button);
        $form->add_button(new FormButtonReset());
        $this->form = $form;
    }
Esempio n. 9
0
    define('TITLE', $MEDIA_LANG['delete_media']);
    require_once '../kernel/header.php';
    AppContext::get_response()->redirect('media' . url('.php?cat=' . $media['idcat'], '-' . $media['idcat'] . '.php'));
} elseif ($add >= 0 && !$submit || $edit > 0) {
    $editor = AppContext::get_content_formatting_service()->get_default_editor();
    $editor->set_identifier('contents');
    $tpl->put_all(array('C_ADD_MEDIA' => true, 'U_TARGET' => url('media_action.php'), 'L_TITLE' => $MEDIA_LANG['media_name'], 'L_WIDTH' => $MEDIA_LANG['media_width'], 'L_HEIGHT' => $MEDIA_LANG['media_height'], 'L_U_MEDIA' => $MEDIA_LANG['media_url'], 'L_CONTENTS' => $MEDIA_LANG['media_description'], 'KERNEL_EDITOR' => $editor->display(), 'L_APPROVED' => $MEDIA_LANG['media_approved'], 'L_CONTRIBUTION_LEGEND' => $LANG['contribution'], 'L_NOTICE_CONTRIBUTION' => $MEDIA_LANG['notice_contribution'], 'L_CONTRIBUTION_COUNTERPART' => $MEDIA_LANG['contribution_counterpart'], 'L_CONTRIBUTION_COUNTERPART_EXPLAIN' => $MEDIA_LANG['contribution_counterpart_explain'], 'L_REQUIRE' => LangLoader::get_message('form.explain_required_fields', 'status-messages-common'), 'L_REQUIRE_NAME' => $MEDIA_LANG['require_name'], 'L_REQUIRE_URL' => $MEDIA_LANG['require_url'], 'L_RESET' => $LANG['reset'], 'L_PREVIEW' => $LANG['preview'], 'L_SUBMIT' => $edit > 0 ? $LANG['update'] : $LANG['submit']));
    // Construction du tableau des catégories musicales.
    $categories = MediaService::get_categories_manager()->get_categories_cache()->get_categories();
    $js_id_music = array();
    foreach ($categories as $cat) {
        if ($cat->get_content_type() == MediaConfig::CONTENT_TYPE_MUSIC) {
            $js_id_music[] = $cat->get_id();
        }
    }
    $search_category_children_options = new SearchCategoryChildrensOptions();
    $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
    $search_category_children_options->add_authorizations_bits(Category::CONTRIBUTION_AUTHORIZATIONS);
    $media = '';
    // Édition.
    if ($edit > 0) {
        try {
            $media = PersistenceContext::get_querier()->select_single_row(PREFIX . 'media', array('*'), 'WHERE id=:id', array('id' => $edit));
        } catch (RowNotFoundException $e) {
            $error_controller = PHPBoostErrors::unexisting_page();
            DispatchManager::redirect($error_controller);
        }
        if (!MediaAuthorizationsService::check_authorizations($media['idcat'])->moderation()) {
            $error_controller = PHPBoostErrors::user_not_authorized();
            DispatchManager::redirect($error_controller);
        }
Esempio n. 10
0
     //On crée une pagination (si activé) si le nombre de topics est trop important.
     $page = AppContext::get_request()->get_getint('pt', 1);
     $topic_pagination = new ModulePagination($page, $row['nbr_msg'], $config->get_number_messages_per_page(), Pagination::LIGHT_PAGINATION);
     $topic_pagination->set_url(new Url('/forum/topic.php?id=' . $row['id'] . '&amp;pt=%d'));
     $group_color = User::get_group_color($row['groups'], $row['user_level']);
     $tpl->assign_block_vars('topics', array('C_PAGINATION' => $topic_pagination->has_several_pages(), 'C_IMG_POLL' => !empty($row['question']), 'C_IMG_TRACK' => !empty($row['idtrack']), 'C_DISPLAY_MSG' => $config->is_message_before_topic_title_displayed() && $config->is_message_before_topic_title_icon_displayed() && $row['display_msg'], 'C_HOT_TOPIC' => $row['type'] == '0' && $row['status'] != '0' && $row['nbr_msg'] > $config->get_number_messages_per_page(), 'C_BLINK' => $blink, 'IMG_ANNOUNCE' => $img_announce, 'ANCRE' => $new_ancre, 'TYPE' => $type[$row['type']], 'TITLE' => stripslashes($row['title']), 'AUTHOR' => !empty($row['login']) ? '<a href="' . UserUrlBuilder::profile($row['user_id'])->rel() . '" class="small ' . UserService::get_level_class($row['user_level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . '>' . $row['login'] . '</a>' : '<em>' . $LANG['guest'] . '</em>', 'DESC' => $row['subtitle'], 'PAGINATION' => $topic_pagination->display(), 'MSG' => $row['nbr_msg'] - 1, 'VUS' => $row['nbr_views'], 'U_TOPIC_VARS' => url('.php?id=' . $row['id'], '-' . $row['id'] . $rewrited_title . '.php'), 'U_LAST_MSG' => $last_msg, 'L_DISPLAY_MSG' => $config->is_message_before_topic_title_displayed() && $row['display_msg'] ? $config->get_message_before_topic_title() : ''));
 }
 $result->dispose();
 //Le membre a déjà lu tous les messages.
 if ($nbr_topics == 0) {
     $tpl->put_all(array('C_NO_TOPICS' => true, 'L_NO_TOPICS' => '0 ' . $LANG['no_last_read']));
 }
 //Listes les utilisateurs en lignes.
 list($users_list, $total_admin, $total_modo, $total_member, $total_visit, $total_online) = forum_list_user_online("AND s.location_script LIKE '%" . "/forum/lastread.php%'");
 //Liste des catégories.
 $search_category_children_options = new SearchCategoryChildrensOptions();
 $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
 $categories_tree = ForumService::get_categories_manager()->get_select_categories_form_field('cats', '', Category::ROOT_CATEGORY, $search_category_children_options);
 $method = new ReflectionMethod('AbstractFormFieldChoice', 'get_options');
 $method->setAccessible(true);
 $categories_tree_options = $method->invoke($categories_tree);
 $cat_list = '';
 foreach ($categories_tree_options as $option) {
     if ($option->get_raw_value()) {
         $cat = ForumService::get_categories_manager()->get_categories_cache()->get_category($option->get_raw_value());
         if (!$cat->get_url()) {
             $cat_list .= $option->display()->render();
         }
     }
 }
 $vars_tpl = array('C_USER_CONNECTED' => AppContext::get_current_user()->check_level(User::MEMBER_LEVEL), 'TOTAL_ONLINE' => $total_online, 'USERS_ONLINE' => $total_online - $total_visit == 0 ? '<em>' . $LANG['no_member_online'] . '</em>' : $users_list, 'ADMIN' => $total_admin, 'MODO' => $total_modo, 'MEMBER' => $total_member, 'GUEST' => $total_visit, 'SELECT_CAT' => $cat_list, 'L_USER' => $total_online > 1 ? $LANG['user_s'] : $LANG['user'], 'L_ADMIN' => $total_admin > 1 ? $LANG['admin_s'] : $LANG['admin'], 'L_MODO' => $total_modo > 1 ? $LANG['modo_s'] : $LANG['modo'], 'L_MEMBER' => $total_member > 1 ? $LANG['member_s'] : $LANG['member'], 'L_GUEST' => $total_visit > 1 ? $LANG['guest_s'] : $LANG['guest'], 'L_AND' => $LANG['and'], 'L_ONLINE' => strtolower($LANG['online']), 'C_PAGINATION' => $pagination->has_several_pages(), 'FORUM_NAME' => $config->get_forum_name(), 'PAGINATION' => $pagination->display(), 'U_CHANGE_CAT' => 'unread.php' . '&amp;token=' . AppContext::get_session()->get_token(), 'U_ONCHANGE' => url(".php?id=' + this.options[this.selectedIndex].value + '", "forum-' + this.options[this.selectedIndex].value + '.php"), 'U_ONCHANGE_CAT' => url("index.php?id=' + this.options[this.selectedIndex].value + '", "cat-' + this.options[this.selectedIndex].value + '.php"), 'U_FORUM_CAT' => '<a href="' . PATH_TO_ROOT . '/forum/lastread.php' . '">' . $LANG['show_last_read'] . '</a>', 'U_POST_NEW_SUBJECT' => '', 'L_FORUM_INDEX' => $LANG['forum_index'], 'L_FORUM' => $LANG['forum'], 'L_AUTHOR' => $LANG['author'], 'L_TOPIC' => $nbr_topics > 1 ? $LANG['topic_s'] : $LANG['topic'], 'L_MESSAGE' => $LANG['replies'], 'L_ANSWERS' => $LANG['answers'], 'L_VIEW' => $LANG['views'], 'L_LAST_MESSAGE' => $LANG['last_message']);
Esempio n. 11
0
     //On recherche les clées correspondante à celles trouvée dans la bdd.
     $key = array_search($row['path'], $array_pics);
     if ($key !== false) {
         unset($array_pics[$key]);
     }
     //On supprime ces clées du tableau.
 }
 $result->dispose();
 //Colonnes des images.
 $nbr_pics = count($array_pics);
 $nbr_column_pics = $nbr_pics > $config->get_columns_number() ? $config->get_columns_number() : $nbr_pics;
 $nbr_column_pics = !empty($nbr_column_pics) ? $nbr_column_pics : 1;
 $column_width_pics = floor(100 / $nbr_column_pics);
 $selectbox_width = floor(100 - 10 * $nbr_column_pics);
 //Liste des catégories.
 $search_category_children_options = new SearchCategoryChildrensOptions();
 $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
 $search_category_children_options->add_authorizations_bits(Category::WRITE_AUTHORIZATIONS);
 $categories_tree = GalleryService::get_categories_manager()->get_select_categories_form_field('category', '', $idcat, $search_category_children_options);
 $method = new ReflectionMethod('AbstractFormFieldChoice', 'get_options');
 $method->setAccessible(true);
 $categories_tree_options = $method->invoke($categories_tree);
 $categories_list = '';
 foreach ($categories_tree_options as $option) {
     $categories_list .= $option->display()->render();
 }
 $root_categories_tree = GalleryService::get_categories_manager()->get_select_categories_form_field('root_cat', '', $idcat, $search_category_children_options);
 $root_categories_tree_options = $method->invoke($root_categories_tree);
 $root_categories_list = '';
 foreach ($root_categories_tree_options as $option) {
     $root_categories_list .= $option->display()->render();
Esempio n. 12
0
        } else {
            $db_where = null;
        }
    } else {
        $cat = 0;
        $db_where = null;
        $sub_cats = true;
    }
    $nbr_media = PersistenceContext::get_querier()->count(PREFIX . "media", 'WHERE ' . ($sub_cats && !empty($authorized_categories) ? 'idcat IN :authorized_categories' : 'idcat = :idcat') . (is_null($db_where) ? '' : ' AND infos = :infos'), array('authorized_categories' => $authorized_categories, 'idcat' => !empty($cat) ? $cat : 0, 'infos' => $db_where));
    $categories_cache = MediaService::get_categories_manager()->get_categories_cache();
    //On crée une pagination si le nombre de fichier est trop important.
    $page = AppContext::get_request()->get_getint('p', 1);
    $pagination = new ModulePagination($page, $nbr_media, $NUMBER_ELEMENTS_PER_PAGE);
    $pagination->set_url(new Url('/media/moderation_media.php?p=%d'));
    if ($pagination->current_page_is_empty() && $page > 1) {
        $error_controller = PHPBoostErrors::unexisting_page();
        DispatchManager::redirect($error_controller);
    }
    $result = PersistenceContext::get_querier()->select("SELECT media.*, media_cats.name AS cat_name\n\t\tFROM " . MediaSetup::$media_table . " media\n\t\tLEFT JOIN " . MediaSetup::$media_cats_table . " media_cats ON media_cats.id = media.idcat\n\t\tWHERE " . ($sub_cats && !empty($authorized_categories) ? 'idcat IN :authorized_categories' : 'idcat = :idcat') . (is_null($db_where) ? '' : ' AND infos = :infos') . "\n\t\tORDER BY infos ASC, timestamp DESC\n\t\tLIMIT :number_items_per_page OFFSET :display_from", array('authorized_categories' => $authorized_categories, 'idcat' => !empty($cat) ? $cat : 0, 'infos' => $db_where, 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()));
    while ($row = $result->fetch()) {
        $js_array[] = $row['id'];
        $tpl->assign_block_vars('files', array('ID' => $row['id'], 'NAME' => $row['name'], 'U_FILE' => url('media.php?id=' . $row['id'], 'media-' . $row['id'] . '-' . $row['idcat'] . '+' . Url::encode_rewrite($row['name']) . '.php'), 'U_EDIT' => url('media_action.php?edit=' . $row['id']), 'CAT' => $categories_cache->category_exists($row['idcat']) ? $row['cat_name'] : $LANG['unknown'], 'U_CAT' => url('media.php?cat=' . $row['idcat']), 'COLOR' => $row['infos'] == MEDIA_STATUS_UNVISIBLE ? '#FFEE99' : ($row['infos'] == MEDIA_STATUS_APROBED ? '#CCFFCC' : '#FFCCCC'), 'SHOW' => $row['infos'] == MEDIA_STATUS_APROBED ? ' checked="checked"' : '', 'HIDE' => $row['infos'] == MEDIA_STATUS_UNVISIBLE ? ' checked="checked"' : '', 'UNAPROBED' => $row['infos'] == MEDIA_STATUS_UNAPROBED ? ' checked="checked"' : ''));
    }
    $result->dispose();
    $search_category_children_options = new SearchCategoryChildrensOptions();
    $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
    $search_category_children_options->add_authorizations_bits(Category::CONTRIBUTION_AUTHORIZATIONS);
    $tpl->put_all(array('C_DISPLAY' => true, 'C_PAGINATION' => $pagination->has_several_pages(), 'L_FILTER' => $MEDIA_LANG['filter'], 'L_DISPLAY_FILE' => $MEDIA_LANG['display_file'], 'L_ALL' => $MEDIA_LANG['all_file'], 'SELECTED_ALL' => is_null($db_where) ? ' selected="selected"' : '', 'L_FVISIBLE' => $MEDIA_LANG['visible'], 'SELECTED_VISIBLE' => $db_where === MEDIA_STATUS_APROBED ? ' selected="selected"' : '', 'L_FUNVISIBLE' => $MEDIA_LANG['unvisible'], 'SELECTED_UNVISIBLE' => $db_where === MEDIA_STATUS_UNVISIBLE ? ' selected="selected"' : '', 'L_FUNAPROBED' => $MEDIA_LANG['unaprobed'], 'SELECTED_UNAPROBED' => $db_where === MEDIA_STATUS_UNAPROBED ? ' selected="selected"' : '', 'L_CATEGORIES' => $MEDIA_LANG['from_cats'], 'CATEGORIES_TREE' => MediaService::get_categories_manager()->get_select_categories_form_field('idcat', LangLoader::get_message('form.category', 'common'), $cat, $search_category_children_options)->display()->render(), 'L_INCLUDE_SUB_CATS' => $MEDIA_LANG['include_sub_cats'], 'SUB_CATS' => is_null($sub_cats) ? ' checked="checked"' : ($sub_cats ? ' checked="checked"' : ''), 'L_MODO_PANEL' => $LANG['modo_panel'], 'L_NAME' => $LANG['name'], 'L_VISIBLE' => $MEDIA_LANG['show_media_short'], 'L_UNVISIBLE' => $MEDIA_LANG['hide_media_short'], 'L_UNAPROBED' => $MEDIA_LANG['unaprobed_media_short'], 'C_NO_MODERATION' => $nbr_media > 0 ? 0 : 1, 'L_NO_MODERATION' => $MEDIA_LANG['no_media_moderate'], 'L_CONFIRM_DELETE_ALL' => str_replace('\'', '\\\'', $MEDIA_LANG['confirm_delete_media_all']), 'L_LEGEND' => $MEDIA_LANG['legend'], 'L_FILE_UNAPROBED' => $MEDIA_LANG['file_unaprobed'], 'L_FILE_UNVISIBLE' => $MEDIA_LANG['file_unvisible'], 'L_FILE_VISIBLE' => $MEDIA_LANG['file_visible'], 'PAGINATION' => $pagination->display(), 'L_SUBMIT' => $LANG['submit'], 'L_RESET' => $LANG['reset'], 'JS_ARRAY' => '"' . implode('", "', $js_array) . '"'));
}
$tpl->display();
require_once '../kernel/footer.php';
 private function get_category_childrens(Category $category, $enable_recursive_exploration = true)
 {
     $options = new SearchCategoryChildrensOptions();
     $options->add_category_in_excluded_categories($category->get_id());
     $options->set_enable_recursive_exploration($enable_recursive_exploration);
     return $this->get_categories_manager()->get_childrens($category->get_id(), $options);
 }
    protected function build_form(HTTPRequestCustom $request)
    {
        $form = new HTMLForm(__CLASS__);
        $fieldset = new FormFieldsetHTML('category', $this->get_title());
        $form->add_fieldset($fieldset);
        $fieldset->add_field(new FormFieldSimpleSelectChoice('type', LangLoader::get_message('type', 'main'), $this->get_category()->get_type(), array(new FormFieldSelectChoiceOption(LangLoader::get_message('category', 'categories-common'), ForumCategory::TYPE_CATEGORY), new FormFieldSelectChoiceOption(LangLoader::get_message('module_title', 'common', 'forum'), ForumCategory::TYPE_FORUM), new FormFieldSelectChoiceOption(LangLoader::get_message('link', 'admin'), ForumCategory::TYPE_URL)), array('events' => array('change' => '
				if (HTMLForms.getField("type").getValue() == ' . ForumCategory::TYPE_CATEGORY . ') {
					HTMLForms.getField("id_parent").disable();
					HTMLForms.getField("description").disable();
					HTMLForms.getField("url").disable();
					if (HTMLForms.getField("special_authorizations").getValue()) {
						jQuery("#' . __CLASS__ . '_authorizations > div").eq(1).hide();
						jQuery("#' . __CLASS__ . '_authorizations > div").eq(2).hide();
					}
				} else if (HTMLForms.getField("type").getValue() == ' . ForumCategory::TYPE_FORUM . ') {
					HTMLForms.getField("id_parent").enable();
					HTMLForms.getField("description").enable();
					HTMLForms.getField("url").disable();
					if (HTMLForms.getField("special_authorizations").getValue()) {
						jQuery("#' . __CLASS__ . '_authorizations > div").eq(1).show();
						jQuery("#' . __CLASS__ . '_authorizations > div").eq(2).show();
					}
				} else {
					HTMLForms.getField("id_parent").enable();
					HTMLForms.getField("description").enable();
					HTMLForms.getField("url").enable();
					if (HTMLForms.getField("special_authorizations").getValue()) {
						jQuery("#' . __CLASS__ . '_authorizations > div").eq(1).hide();
						jQuery("#' . __CLASS__ . '_authorizations > div").eq(2).hide();
					}
				}'))));
        $fieldset->add_field(new FormFieldTextEditor('name', $this->common_lang['form.name'], $this->get_category()->get_name(), array('required' => true)));
        $fieldset->add_field(new FormFieldCheckbox('personalize_rewrited_name', $this->common_lang['form.rewrited_name.personalize'], $this->get_category()->rewrited_name_is_personalized(), array('events' => array('click' => '
		if (HTMLForms.getField("personalize_rewrited_name").getValue()) {
			HTMLForms.getField("rewrited_name").enable();
		} else { 
			HTMLForms.getField("rewrited_name").disable();
		}'))));
        $fieldset->add_field(new FormFieldTextEditor('rewrited_name', $this->common_lang['form.rewrited_name'], $this->get_category()->get_rewrited_name(), array('description' => $this->common_lang['form.rewrited_name.description'], 'hidden' => !$this->get_category()->rewrited_name_is_personalized()), array(new FormFieldConstraintRegex('`^[a-z0-9\\-]+$`i'))));
        $fieldset->add_field(new FormFieldRichTextEditor('description', $this->common_lang['form.description'], $this->get_category()->get_description(), array('hidden' => $this->get_category()->get_type() == ForumCategory::TYPE_CATEGORY)));
        $search_category_children_options = new SearchCategoryChildrensOptions();
        $search_category_children_options->add_category_in_excluded_categories(Category::ROOT_CATEGORY);
        if ($this->get_category()->get_id()) {
            $search_category_children_options->add_category_in_excluded_categories($this->get_category()->get_id());
        }
        $fieldset->add_field($this->get_categories_manager()->get_select_categories_form_field('id_parent', $this->common_lang['form.category'], $this->get_category()->get_id_parent(), $search_category_children_options, array('required' => true, 'hidden' => $this->get_category()->get_type() == ForumCategory::TYPE_CATEGORY)));
        $fieldset->add_field(new FormFieldUrlEditor('url', LangLoader::get_message('form.url', 'common'), $this->get_category()->get_url(), array('required' => true, 'hidden' => $this->get_category()->get_type() != ForumCategory::TYPE_URL)));
        $fieldset_authorizations = new FormFieldsetHTML('authorizations_fieldset', $this->common_lang['authorizations']);
        $form->add_fieldset($fieldset_authorizations);
        $root_auth = $this->get_categories_manager()->get_categories_cache()->get_category(Category::ROOT_CATEGORY)->get_authorizations();
        $fieldset_authorizations->add_field(new FormFieldCheckbox('special_authorizations', $this->common_lang['authorizations'], !$this->get_category()->auth_is_equals($root_auth), array('description' => $this->lang['category.form.authorizations.description'], 'events' => array('click' => '
		if (HTMLForms.getField("special_authorizations").getValue()) {
			jQuery("#' . __CLASS__ . '_authorizations").show();
			if (HTMLForms.getField("type").getValue() == ' . ForumCategory::TYPE_CATEGORY . ' || HTMLForms.getField("type").getValue() == ' . ForumCategory::TYPE_URL . ') {
				jQuery("#' . __CLASS__ . '_authorizations > div").eq(1).hide();
				jQuery("#' . __CLASS__ . '_authorizations > div").eq(2).hide();
			}
		} else { 
			jQuery("#' . __CLASS__ . '_authorizations").hide();
		}'))));
        // Autorisations cachées à l'édition Si le type est catégorie ou url
        $fieldset_authorizations->add_field(new FormFieldFree('hide_authorizations', '', '
		<script>
		<!--
		jQuery(document).ready(function() {
			if (HTMLForms.getField("special_authorizations").getValue() && (HTMLForms.getField("type").getValue() == ' . ForumCategory::TYPE_CATEGORY . ' || HTMLForms.getField("type").getValue() == ' . ForumCategory::TYPE_URL . ')) {
				jQuery("#' . __CLASS__ . '_authorizations > div").eq(1).hide();
				jQuery("#' . __CLASS__ . '_authorizations > div").eq(2).hide();
			}
			});
		-->
		</script>'));
        $auth_settings = $this->get_authorizations_settings();
        $auth_setter = new FormFieldAuthorizationsSetter('authorizations', $auth_settings, array('hidden' => $this->get_category()->auth_is_equals($root_auth)));
        $auth_settings->build_from_auth_array($this->get_category()->get_authorizations());
        $fieldset_authorizations->add_field($auth_setter);
        $fieldset->add_field(new FormFieldHidden('referrer', $request->get_url_referrer()));
        $this->submit_button = new FormButtonDefaultSubmit();
        $form->add_button($this->submit_button);
        $form->add_button(new FormButtonReset());
        $this->form = $form;
    }
Esempio n. 15
0
        $tpl->assign_block_vars('image_up', array('NAME' => stripslashes($imageup['name']), 'IMG' => '<a href="gallery.php?cat=' . $imageup['idcat'] . '&amp;id=' . $g_idpics . '#pics_max"><img src="pics/' . $imageup['path'] . '" alt="' . $imageup['name'] . '" /></a>', 'L_SUCCESS_UPLOAD' => $LANG['success_upload_img'], 'U_CAT' => '<a href="gallery.php?cat=' . $imageup['idcat'] . '">' . $categories[$imageup['idcat']]->get_name() . '</a>'));
    }
    //Affichage du quota d'image uploadée.
    $category_authorizations = GalleryService::get_categories_manager()->get_heritated_authorizations($id_category, Category::WRITE_AUTHORIZATIONS, Authorizations::AUTH_PARENT_PRIORITY);
    $quota = isset($category_authorizations['r-1']) ? $category_authorizations['r-1'] != '3' : true;
    if ($quota) {
        switch (AppContext::get_current_user()->get_level()) {
            case 2:
                $l_pics_quota = $LANG['illimited'];
                break;
            case 1:
                $l_pics_quota = $config->get_moderator_max_pics_number();
                break;
            default:
                $l_pics_quota = $config->get_member_max_pics_number();
        }
        $nbr_upload_pics = $Gallery->get_nbr_upload_pics(AppContext::get_current_user()->get_id());
        $tpl->assign_block_vars('image_quota', array('L_IMAGE_QUOTA' => sprintf($LANG['image_quota'], $nbr_upload_pics, $l_pics_quota)));
    }
    $search_category_children_options = new SearchCategoryChildrensOptions();
    $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
    $search_category_children_options->add_authorizations_bits(Category::WRITE_AUTHORIZATIONS);
    $tpl->put_all(array('CAT_ID' => $id_category, 'GALLERY' => !empty($id_category) ? $categories[$id_category]->get_name() : $LANG['gallery'], 'CATEGORIES_TREE' => GalleryService::get_categories_manager()->get_select_categories_form_field('cat', LangLoader::get_message('form.category', 'common'), $id_category, $search_category_children_options)->display()->render(), 'WIDTH_MAX' => $config->get_max_width(), 'HEIGHT_MAX' => $config->get_max_height(), 'WEIGHT_MAX' => $config->get_max_weight(), 'IMG_FORMAT' => 'JPG, PNG, GIF', 'L_IMG_FORMAT' => $LANG['img_format'], 'L_WIDTH_MAX' => $LANG['width_max'], 'L_HEIGHT_MAX' => $LANG['height_max'], 'L_WEIGHT_MAX' => $LANG['weight_max'], 'L_ADD_IMG' => $LANG['add_pic'], 'L_GALLERY' => $LANG['gallery'], 'L_GALLERY_INDEX' => $LANG['gallery_index'], 'L_CATEGORIES' => $LANG['categories'], 'L_NAME' => $LANG['name'], 'L_UNIT_PX' => LangLoader::get_message('unit.pixels', 'common'), 'L_UNIT_KO' => LangLoader::get_message('unit.kilobytes', 'common'), 'L_UPLOAD' => $LANG['upload_img'], 'U_GALLERY_CAT_LINKS' => $cat_links, 'U_GALLERY_ACTION_ADD' => GalleryUrlBuilder::get_link_cat_add($id_category, null, AppContext::get_session()->get_token()), 'U_INDEX' => url('.php')));
    $tpl->display();
} else {
    $module = AppContext::get_extension_provider_service()->get_provider('gallery');
    if ($module->has_extension_point(HomePageExtensionPoint::EXTENSION_POINT)) {
        echo $module->get_extension_point(HomePageExtensionPoint::EXTENSION_POINT)->get_home_page()->get_view()->display();
    }
}
require_once '../kernel/footer.php';
    private function build_view()
    {
        global $LANG, $Bread_crumb;
        load_module_lang('gallery');
        $g_idpics = retrieve(GET, 'id', 0);
        $g_views = retrieve(GET, 'views', false);
        $g_notes = retrieve(GET, 'notes', false);
        $g_sort = retrieve(GET, 'sort', '');
        $g_sort = !empty($g_sort) ? 'sort=' . $g_sort : '';
        //Récupération du mode d'ordonnement.
        if (preg_match('`([a-z]+)_([a-z]+)`', $g_sort, $array_match)) {
            $g_type = $array_match[1];
            $g_mode = $array_match[2];
        } else {
            list($g_type, $g_mode) = array('date', 'desc');
        }
        $comments_topic = new GalleryCommentsTopic();
        $config = GalleryConfig::load();
        $category = $this->get_category();
        $categories = GalleryService::get_categories_manager()->get_categories_cache()->get_childrens($category->get_id());
        $authorized_categories = GalleryService::get_authorized_categories($category->get_id());
        $Gallery = new Gallery();
        $nbr_pics = $this->db_querier->count(GallerySetup::$gallery_table, 'WHERE idcat=:idcat AND aprob = 1', array('idcat' => $category->get_id()));
        $total_cat = count($categories);
        //On crée une pagination si le nombre de catégories est trop important.
        $page = AppContext::get_request()->get_getint('p', 1);
        $pagination = new ModulePagination($page, $total_cat, $config->get_categories_number_per_page());
        $pagination->set_url(new Url('/gallery/gallery.php?p=%d&amp;cat=' . $category->get_id() . '&amp;id=' . $g_idpics . '&amp;' . $g_sort));
        if ($pagination->current_page_is_empty() && $page > 1) {
            $error_controller = PHPBoostErrors::unexisting_page();
            DispatchManager::redirect($error_controller);
        }
        //Colonnes des catégories.
        $nbr_column_cats = $total_cat > $config->get_columns_number() ? $config->get_columns_number() : $total_cat;
        $nbr_column_cats = !empty($nbr_column_cats) ? $nbr_column_cats : 1;
        $column_width_cats = floor(100 / $nbr_column_cats);
        //Colonnes des images.
        $nbr_column_pics = $nbr_pics > $config->get_columns_number() ? $config->get_columns_number() : $nbr_pics;
        $nbr_column_pics = !empty($nbr_column_pics) ? $nbr_column_pics : 1;
        $column_width_pics = floor(100 / $nbr_column_pics);
        $is_admin = AppContext::get_current_user()->check_level(User::ADMIN_LEVEL);
        $is_modo = GalleryAuthorizationsService::check_authorizations($category->get_id())->moderation();
        $module_data_path = $this->tpl->get_pictures_data_path();
        $rewrite_title = Url::encode_rewrite($category->get_name());
        ##### Catégorie disponibles #####
        $nbr_cat_displayed = 0;
        if ($total_cat > 0 && empty($g_idpics)) {
            $this->tpl->put('C_GALLERY_CATS', true);
            $j = 0;
            $result = $this->db_querier->select('SELECT @id_cat:= gallery_cats.id, gallery_cats.*,
			(SELECT COUNT(*) FROM ' . GallerySetup::$gallery_table . '
				WHERE idcat IN (
					@id_cat,
					(SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . GallerySetup::$gallery_cats_table . ' WHERE id_parent = @id_cat), 
					(SELECT GROUP_CONCAT(childs.id SEPARATOR \',\') FROM ' . GallerySetup::$gallery_cats_table . ' parents
					INNER JOIN ' . GallerySetup::$gallery_cats_table . ' childs ON parents.id = childs.id_parent
					WHERE parents.id_parent = @id_cat)
				)
				AND aprob = 1
			) AS nbr_pics
			FROM ' . GallerySetup::$gallery_cats_table . ' gallery_cats
			WHERE id_parent = :id_category
			AND id IN :authorized_categories
			ORDER BY id_parent, c_order
			LIMIT :number_items_per_page OFFSET :display_from', array('id_category' => $category->get_id(), 'authorized_categories' => $authorized_categories, 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()));
            while ($row = $result->fetch()) {
                $category_image = new Url($row['image']);
                $this->tpl->assign_block_vars('sub_categories_list', array('C_CATEGORY_IMAGE' => !empty($row['image']), 'CATEGORY_NAME' => $row['name'], 'CATEGORY_IMAGE' => $category_image->rel(), 'PICTURES_NUMBER' => sprintf($LANG['nbr_pics_info'], $row['nbr_pics']), 'U_CATEGORY' => GalleryUrlBuilder::get_link_cat($row['id'], $row['name'])));
                $nbr_cat_displayed++;
            }
            $result->dispose();
        }
        $category_description = FormatingHelper::second_parse($category->get_description());
        $this->tpl->put_all(array('C_ROOT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY, 'C_CATEGORY_DESCRIPTION' => $category_description, 'C_SUB_CATEGORIES' => $nbr_cat_displayed > 0, 'C_SUBCATEGORIES_PAGINATION' => $pagination->has_several_pages(), 'SUBCATEGORIES_PAGINATION' => $pagination->display(), 'ARRAY_JS' => '', 'NBR_PICS' => 0, 'MAX_START' => 0, 'START_THUMB' => 0, 'END_THUMB' => 0, 'COLUMNS_NUMBER' => $nbr_column_pics, 'CATS_COLUMNS_WIDTH' => $column_width_cats, 'COLUMN_WIDTH_PICS' => $column_width_pics, 'CATEGORY_DESCRIPTION' => $category_description, 'U_EDIT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY ? GalleryUrlBuilder::configuration()->rel() : GalleryUrlBuilder::edit_category($category->get_id())->rel(), 'CAT_ID' => $category->get_id(), 'DISPLAY_MODE' => $config->get_pics_enlargement_mode(), 'GALLERY' => $category->get_id() != Category::ROOT_CATEGORY ? $this->lang['module_title'] . ' - ' . $category->get_name() : $this->lang['module_title'], 'HEIGHT_MAX' => $config->get_mini_max_height(), 'WIDTH_MAX' => $column_width_pics, 'MODULE_DATA_PATH' => $module_data_path, 'L_APROB' => $LANG['aprob'], 'L_UNAPROB' => $LANG['unaprob'], 'L_FILE_FORBIDDEN_CHARS' => $LANG['file_forbidden_chars'], 'L_TOTAL_IMG' => $category->get_id() != Category::ROOT_CATEGORY ? sprintf($LANG['total_img_cat'], $nbr_pics) : '', 'L_ADD_IMG' => $LANG['add_pic'], 'L_GALLERY' => $this->lang['module_title'], 'L_CATEGORIES' => $category->get_id_parent() >= 0 ? $LANG['sub_album'] : $LANG['album'], 'L_NAME' => $LANG['name'], 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_MOVETO' => $LANG['moveto'], 'L_DELETE' => LangLoader::get_message('delete', 'common'), 'L_SUBMIT' => $LANG['submit'], 'L_ALREADY_VOTED' => $LANG['already_vote'], 'L_ORDER_BY' => LangLoader::get_message('sort_by', 'common') . (isset($LANG[$g_type]) ? ' ' . strtolower($LANG[$g_type]) : ''), 'L_DIRECTION' => $LANG['direction'], 'L_DISPLAY' => LangLoader::get_message('display', 'common'), 'U_INDEX' => url('.php'), 'U_BEST_VIEWS' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?views=1&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '.php?views=1'), 'U_BEST_NOTES' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?notes=1&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '.php?notes=1'), 'U_ASC' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $category->get_id() . '&amp;sort=' . $g_type . '_' . 'asc', '-' . $category->get_id() . '.php?sort=' . $g_type . '_' . 'asc'), 'U_DESC' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $category->get_id() . '&amp;sort=' . $g_type . '_' . 'desc', '-' . $category->get_id() . '.php?sort=' . $g_type . '_' . 'desc'), 'U_ORDER_BY_NAME' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=name_desc&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=name_desc'), 'U_ORDER_BY_DATE' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=date_desc&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=date_desc'), 'U_ORDER_BY_VIEWS' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=views_desc&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=views_desc'), 'U_ORDER_BY_NOTES' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=notes_desc&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=notes_desc'), 'U_ORDER_BY_COM' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=com_desc&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=com_desc'), 'L_BEST_VIEWS' => $LANG['best_views'], 'L_BEST_NOTES' => $LANG['best_notes'], 'L_ASC' => $LANG['asc'], 'L_DESC' => $LANG['desc'], 'L_DATE' => LangLoader::get_message('date', 'date-common'), 'L_VIEWS' => $LANG['views'], 'L_NOTES' => LangLoader::get_message('notes', 'common'), 'L_COM' => $LANG['com_s']));
        ##### Affichage des photos #####
        if ($nbr_pics > 0) {
            switch ($g_type) {
                case 'name':
                    $sort_type = 'g.name';
                    break;
                case 'date':
                    $sort_type = 'g.timestamp';
                    break;
                case 'views':
                    $sort_type = 'g.views';
                    break;
                case 'notes':
                    $sort_type = 'notes.average_notes';
                    break;
                case 'com':
                    $sort_type = 'com.number_comments';
                    break;
                default:
                    $sort_type = 'g.timestamp';
            }
            switch ($g_mode) {
                case 'desc':
                    $sort_mode = 'DESC';
                    break;
                case 'asc':
                    $sort_mode = 'ASC';
                    break;
                default:
                    $sort_mode = 'DESC';
            }
            $g_sql_sort = ' ORDER BY ' . $sort_type . ' ' . $sort_mode;
            if ($g_views) {
                $g_sql_sort = ' ORDER BY g.views DESC';
            } elseif ($g_notes) {
                $g_sql_sort = ' ORDER BY notes.average_notes DESC';
            }
            $this->tpl->put('C_GALLERY_PICS', true);
            //Affichage d'une photo demandée.
            if (!empty($g_idpics)) {
                $info_pics = $this->db_querier->select_single_row_query("SELECT g.*, m.display_name, m.groups, m.level, notes.average_notes, notes.number_notes, note.note\n\t\t\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = g.user_id\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_COMMENTS_TOPIC . " com ON com.id_in_module = g.id AND com.module_id = 'gallery'\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_AVERAGE_NOTES . " notes ON notes.id_in_module = g.id AND notes.module_name = 'gallery'\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_NOTE . " note ON note.id_in_module = g.id AND note.module_name = 'gallery' AND note.user_id = :user_id\n\t\t\t\t\tWHERE g.idcat = :idcat AND g.id = :id AND g.aprob = 1\n\t\t\t\t\t" . $g_sql_sort, array('user_id' => AppContext::get_current_user()->get_id(), 'idcat' => $category->get_id(), 'id' => $g_idpics));
                if (!empty($info_pics['id'])) {
                    $Bread_crumb->add(stripslashes($info_pics['name']), PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $info_pics['idcat'] . '&amp;id=' . $info_pics['id'], '-' . $info_pics['idcat'] . '-' . $info_pics['id'] . '.php'));
                    //Affichage miniatures.
                    $id_previous = 0;
                    $id_next = 0;
                    $nbr_pics_display_before = floor(($nbr_column_pics - 1) / 2);
                    //Nombres de photos de chaque côté de la miniature de la photo affichée.
                    $nbr_pics_display_after = $nbr_column_pics - 1 - floor($nbr_pics_display_before);
                    list($i, $reach_pics_pos, $pos_pics, $thumbnails_before, $thumbnails_after, $start_thumbnails, $end_thumbnails) = array(0, false, 0, 0, 0, $nbr_pics_display_before, $nbr_pics_display_after);
                    $array_pics = array();
                    $array_js = 'var array_pics = new Array();';
                    $result = $this->db_querier->select("SELECT g.id, g.idcat, g.path\n\t\t\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\t\t\tWHERE g.idcat = :idcat AND g.aprob = 1\n\t\t\t\t\t" . $g_sql_sort, array('idcat' => $category->get_id()));
                    while ($row = $result->fetch()) {
                        //Si la miniature n'existe pas (cache vidé) on regénère la miniature à partir de l'image en taille réelle.
                        if (!file_exists(PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'])) {
                            $Gallery->Resize_pics(PATH_TO_ROOT . '/gallery/pics/' . $row['path']);
                        }
                        //Redimensionnement + création miniature
                        //Affichage de la liste des miniatures sous l'image.
                        $array_pics[] = '<td class="center" style="height:' . ($config->get_mini_max_height() + 16) . 'px"><span id="thumb' . $i . '"><a href="gallery' . url('.php?cat=' . $row['idcat'] . '&amp;id=' . $row['id'] . '&amp;sort=' . $g_sort, '-' . $row['idcat'] . '-' . $row['id'] . '.php?sort=' . $g_sort) . '#pics_max' . '"><img src="pics/thumbnails/' . $row['path'] . '" alt="' . $row['path'] . '" /></a></span></td>';
                        if ($row['id'] == $g_idpics) {
                            $reach_pics_pos = true;
                            $pos_pics = $i;
                        } else {
                            if (!$reach_pics_pos) {
                                $thumbnails_before++;
                                $id_previous = $row['id'];
                            } else {
                                $thumbnails_after++;
                                if (empty($id_next)) {
                                    $id_next = $row['id'];
                                }
                            }
                        }
                        $array_js .= 'array_pics[' . $i . '] = new Array();' . "\n";
                        $array_js .= 'array_pics[' . $i . '][\'link\'] = \'' . GalleryUrlBuilder::get_link_item($row['idcat'], $row['id']) . '#pics_max' . "';\n";
                        $array_js .= 'array_pics[' . $i . '][\'path\'] = \'' . $row['path'] . "';\n";
                        $i++;
                    }
                    $result->dispose();
                    $activ_note = $config->is_notation_enabled() && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL);
                    if ($activ_note) {
                        //Affichage notation.
                        $notation = new Notation();
                        $notation->set_module_name('gallery');
                        $notation->set_id_in_module($info_pics['id']);
                        $notation->set_notation_scale($config->get_notation_scale());
                        $notation->set_number_notes($info_pics['number_notes']);
                        $notation->set_average_notes($info_pics['average_notes']);
                        $notation->set_user_already_noted(!empty($info_pics['note']));
                    }
                    if ($thumbnails_before < $nbr_pics_display_before) {
                        $end_thumbnails += $nbr_pics_display_before - $thumbnails_before;
                    }
                    if ($thumbnails_after < $nbr_pics_display_after) {
                        $start_thumbnails += $nbr_pics_display_after - $thumbnails_after;
                    }
                    $html_protected_name = $info_pics['name'];
                    $comments_topic->set_id_in_module($info_pics['id']);
                    $comments_topic->set_url(new Url('/gallery/gallery.php?cat=' . $category->get_id() . '&id=' . $g_idpics . '&com=0'));
                    //Liste des catégories.
                    $search_category_children_options = new SearchCategoryChildrensOptions();
                    $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
                    $search_category_children_options->add_authorizations_bits(Category::WRITE_AUTHORIZATIONS);
                    $categories_tree = GalleryService::get_categories_manager()->get_select_categories_form_field($info_pics['id'] . 'cat', '', $info_pics['idcat'], $search_category_children_options);
                    $method = new ReflectionMethod('AbstractFormFieldChoice', 'get_options');
                    $method->setAccessible(true);
                    $categories_tree_options = $method->invoke($categories_tree);
                    $cat_list = '';
                    foreach ($categories_tree_options as $option) {
                        $cat_list .= $option->display()->render();
                    }
                    $group_color = User::get_group_color($info_pics['groups'], $info_pics['level']);
                    //Affichage de l'image et de ses informations.
                    $this->tpl->put_all(array('C_GALLERY_PICS_MAX' => true, 'C_GALLERY_PICS_MODO' => $is_modo, 'C_AUTHOR_DISPLAYED' => $config->is_author_displayed(), 'C_VIEWS_COUNTER_ENABLED' => $config->is_views_counter_enabled(), 'C_TITLE_ENABLED' => $config->is_title_enabled(), 'C_COMMENTS_ENABLED' => $config->are_comments_enabled(), 'C_NOTATION_ENABLED' => $config->is_notation_enabled(), 'ID' => $info_pics['id'], 'NAME' => '<span id="fi_' . $info_pics['id'] . '">' . stripslashes($info_pics['name']) . '</span> <span id="fi' . $info_pics['id'] . '"></span>', 'POSTOR' => '<a class="small ' . UserService::get_level_class($info_pics['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . ' href="' . UserUrlBuilder::profile($info_pics['user_id'])->rel() . '">' . $info_pics['display_name'] . '</a>', 'DATE' => Date::to_format($info_pics['timestamp'], Date::FORMAT_DAY_MONTH_YEAR), 'VIEWS' => $info_pics['views'] + 1, 'DIMENSION' => $info_pics['width'] . ' x ' . $info_pics['height'], 'SIZE' => NumberHelper::round($info_pics['weight'] / 1024, 1), 'L_COMMENTS' => CommentsService::get_number_and_lang_comments('gallery', $info_pics['id']), 'KERNEL_NOTATION' => $activ_note ? NotationService::display_active_image($notation) : '', 'COLSPAN' => $config->get_columns_number() + 2, 'CAT' => $cat_list, 'RENAME' => $html_protected_name, 'RENAME_CUT' => $html_protected_name, 'IMG_APROB' => $info_pics['aprob'] == 1 ? 'fa fa-eye-slash' : 'fa fa-eye', 'ARRAY_JS' => $array_js, 'NBR_PICS' => $i - 1, 'MAX_START' => $i - 1 - $nbr_column_pics, 'START_THUMB' => $pos_pics - $start_thumbnails > 0 ? $pos_pics - $start_thumbnails : 0, 'END_THUMB' => $pos_pics + $end_thumbnails, 'L_KB' => LangLoader::get_message('unit.kilobytes', 'common'), 'L_INFORMATIONS' => $LANG['informations'], 'L_NAME' => $LANG['name'], 'L_POSTOR' => $LANG['postor'], 'L_VIEWS' => $LANG['views'], 'L_ADD_ON' => $LANG['add_on'], 'L_DIMENSION' => $LANG['dimension'], 'L_SIZE' => $LANG['size'], 'L_NOTE' => LangLoader::get_message('note', 'common'), 'L_COM' => $LANG['com'], 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_APROB_IMG' => $info_pics['aprob'] == 1 ? $LANG['unaprob'] : $LANG['aprob'], 'L_THUMBNAILS' => $LANG['thumbnails'], 'U_DEL' => url('gallery.php?del=' . $info_pics['id'] . '&amp;token=' . AppContext::get_session()->get_token() . '&amp;cat=' . $category->get_id()), 'U_MOVE' => url('gallery.php?id=' . $info_pics['id'] . '&amp;token=' . AppContext::get_session()->get_token() . '&amp;move=\' + this.options[this.selectedIndex].value'), 'U_PREVIOUS' => $pos_pics > 0 ? '<a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_previous) . '#pics_max"><i class="fa fa-arrow-left fa-2x"></i></a> <a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_previous) . '#pics_max">' . $LANG['previous'] . '</a>' : '', 'U_NEXT' => $pos_pics < $i - 1 ? '<a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_next) . '#pics_max">' . $LANG['next'] . '</a> <a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_next) . '#pics_max"><i class="fa fa-arrow-right fa-2x"></i></a>' : '', 'U_LEFT_THUMBNAILS' => $pos_pics - $start_thumbnails > 0 ? '<span id="display_left"><a href="javascript:display_thumbnails(\'left\')"><i class="fa fa-arrow-left fa-2x"></i></a></span>' : '<span id="display_left"></span>', 'U_RIGHT_THUMBNAILS' => $pos_pics - $start_thumbnails <= $i - 1 - $nbr_column_pics ? '<span id="display_right"><a href="javascript:display_thumbnails(\'right\')"><i class="fa fa-arrow-right fa-2x"></i></a></span>' : '<span id="display_right"></span>', 'U_COMMENTS' => GalleryUrlBuilder::get_link_item($info_pics['idcat'], $info_pics['id'], 0, $g_sort) . '#comments-list', 'U_IMG_MAX' => 'show_pics.php?id=' . $info_pics['id'] . '&amp;cat=' . $info_pics['idcat']));
                    //Affichage de la liste des miniatures sous l'image.
                    $i = 0;
                    foreach ($array_pics as $pics) {
                        if ($i >= $pos_pics - $start_thumbnails && $i <= $pos_pics + $end_thumbnails) {
                            $this->tpl->assign_block_vars('list_preview_pics', array('PICS' => $pics));
                        }
                        $i++;
                    }
                    //Commentaires
                    if (AppContext::get_request()->get_getint('com', 0) == 0 && $config->are_comments_enabled()) {
                        $this->tpl->put_all(array('COMMENTS' => CommentsService::display($comments_topic)->render()));
                    }
                }
            } else {
                $sort = retrieve(GET, 'sort', '');
                //On crée une pagination si le nombre de photos est trop important.
                $page = AppContext::get_request()->get_getint('pp', 1);
                $pagination = new ModulePagination($page, $nbr_pics, $config->get_pics_number_per_page());
                $pagination->set_url(new Url('/gallery/gallery.php?pp=%d' . (!empty($sort) ? '&amp;sort=' . $sort : '') . '&amp;cat=' . $category->get_id()));
                if ($pagination->current_page_is_empty() && $page > 1) {
                    $error_controller = PHPBoostErrors::unexisting_page();
                    DispatchManager::redirect($error_controller);
                }
                $this->tpl->put_all(array('C_GALLERY_MODO' => $is_modo, 'C_PICTURE_NAME_DISPLAYED' => $config->is_title_enabled(), 'C_AUTHOR_DISPLAYED' => $config->is_author_displayed(), 'C_VIEWS_COUNTER_ENABLED' => $config->is_views_counter_enabled(), 'C_COMMENTS_ENABLED' => $config->are_comments_enabled(), 'C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_VIEW' => $LANG['view'], 'L_VIEWS' => $LANG['views']));
                $is_connected = AppContext::get_current_user()->check_level(User::MEMBER_LEVEL);
                $j = 0;
                $result = $this->db_querier->select("SELECT g.id, g.idcat, g.name, g.path, g.timestamp, g.aprob, g.width, g.height, g.user_id, g.views, g.aprob, m.display_name, m.groups, m.level, notes.average_notes, notes.number_notes, note.note\n\t\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = g.user_id\n\t\t\t\tLEFT JOIN " . DB_TABLE_COMMENTS_TOPIC . " com ON com.id_in_module = g.id AND com.module_id = 'gallery'\n\t\t\t\tLEFT JOIN " . DB_TABLE_AVERAGE_NOTES . " notes ON notes.id_in_module = g.id AND notes.module_name = 'gallery'\n\t\t\t\tLEFT JOIN " . DB_TABLE_NOTE . " note ON note.id_in_module = g.id AND note.module_name = 'gallery' AND note.user_id = :user_id\n\t\t\t\tWHERE g.idcat = :idcat AND g.aprob = 1\n\t\t\t\t" . $g_sql_sort . "\n\t\t\t\tLIMIT :number_items_per_page OFFSET :display_from", array('user_id' => AppContext::get_current_user()->get_id(), 'idcat' => $category->get_id(), 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()));
                while ($row = $result->fetch()) {
                    //Si la miniature n'existe pas (cache vidé) on regénère la miniature à partir de l'image en taille réelle.
                    if (!file_exists(PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'])) {
                        $Gallery->Resize_pics(PATH_TO_ROOT . '/gallery/pics/' . $row['path']);
                    }
                    //Redimensionnement + création miniature
                    $onclick = '';
                    //Affichage de l'image en grand.
                    if ($config->get_pics_enlargement_mode() == GalleryConfig::FULL_SCREEN) {
                        $display_link = PATH_TO_ROOT . '/gallery/pics/' . $row['path'] . '" onmousedown="increment_view(' . $row['id'] . ');" title="' . str_replace('"', '', stripslashes($row['name']));
                    } elseif ($config->get_pics_enlargement_mode() == GalleryConfig::POPUP) {
                        $onclick = 'increment_view(' . $row['id'] . ');display_pics_popup(\'' . PATH_TO_ROOT . '/gallery/show_pics' . url('.php?id=' . $row['id'] . '&amp;cat=' . $row['idcat']) . '\', \'' . $row['width'] . '\', \'' . $row['height'] . '\');return false;';
                        $display_link = '';
                    } elseif ($config->get_pics_enlargement_mode() == GalleryConfig::RESIZE) {
                        $onclick = 'increment_view(' . $row['id'] . ');display_pics(' . $row['id'] . ', \'' . PATH_TO_ROOT . '/gallery/show_pics' . url('.php?id=' . $row['id'] . '&amp;cat=' . $row['idcat']) . '\');return false;';
                        $display_link = '';
                    } else {
                        $onclick = true;
                        $display_link = url('gallery.php?cat=' . $row['idcat'] . '&amp;id=' . $row['id'], 'gallery-' . $row['idcat'] . '-' . $row['id'] . '.php') . '#pics_max';
                    }
                    //Liste des catégories.
                    $search_category_children_options = new SearchCategoryChildrensOptions();
                    $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
                    $search_category_children_options->add_authorizations_bits(Category::WRITE_AUTHORIZATIONS);
                    $categories_tree = GalleryService::get_categories_manager()->get_select_categories_form_field($row['id'] . 'cat', '', $row['idcat'], $search_category_children_options);
                    $method = new ReflectionMethod('AbstractFormFieldChoice', 'get_options');
                    $method->setAccessible(true);
                    $categories_tree_options = $method->invoke($categories_tree);
                    $cat_list = '';
                    foreach ($categories_tree_options as $option) {
                        $cat_list .= $option->display()->render();
                    }
                    $notation = new Notation();
                    $notation->set_module_name('gallery');
                    $notation->set_notation_scale($config->get_notation_scale());
                    $notation->set_id_in_module($row['id']);
                    $notation->set_number_notes($row['number_notes']);
                    $notation->set_average_notes($row['average_notes']);
                    $notation->set_user_already_noted(!empty($row['note']));
                    $group_color = User::get_group_color($row['groups'], $row['level']);
                    $comments_topic->set_id_in_module($row['id']);
                    $html_protected_name = $row['name'];
                    $this->tpl->assign_block_vars('pics_list', array('C_IMG_APROB' => $row['aprob'] == 1, 'C_OPEN_TR' => is_int($j++ / $nbr_column_pics), 'C_CLOSE_TR' => is_int($j / $nbr_column_pics), 'ID' => $row['id'], 'APROB' => $row['aprob'], 'PATH' => $row['path'], 'NAME' => stripslashes($row['name']), 'SHORT_NAME' => TextHelper::wordwrap_html(stripslashes($row['name']), 22, ' '), 'POSTOR' => $LANG['by'] . (!empty($row['display_name']) ? ' <a class="small ' . UserService::get_level_class($row['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . ' href="' . UserUrlBuilder::profile($row['user_id'])->rel() . '">' . $row['display_name'] . '</a>' : ' ' . $LANG['guest']), 'VIEWS' => $row['views'], 'L_VIEWS' => $row['views'] > 1 ? $LANG['views'] : $LANG['view'], 'L_COMMENTS' => CommentsService::get_number_and_lang_comments('gallery', $row['id']), 'KERNEL_NOTATION' => $config->is_notation_enabled() && $is_connected ? NotationService::display_active_image($notation) : NotationService::display_static_image($notation), 'CAT' => $cat_list, 'ONCLICK' => $onclick, 'RENAME' => $html_protected_name, 'RENAME_CUT' => $html_protected_name, 'L_APROB_IMG' => $row['aprob'] == 1 ? $LANG['unaprob'] : $LANG['aprob'], 'U_PICTURE_LINK' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $row['idcat'] . '&amp;id=' . $row['id'], '-' . $row['idcat'] . '-' . $row['id'] . '.php'), 'U_PICTURE' => PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'], 'U_DEL' => url('gallery.php?del=' . $row['id'] . '&amp;token=' . AppContext::get_session()->get_token() . '&amp;cat=' . $category->get_id()), 'U_MOVE' => url('gallery.php?id=' . $row['id'] . '&amp;token=' . AppContext::get_session()->get_token() . '&amp;move=\' + this.options[this.selectedIndex].value'), 'U_DISPLAY' => $display_link, 'U_COMMENTS' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $row['idcat'] . '&amp;id=' . $row['id'] . '&amp;com=0', '-' . $row['idcat'] . '-' . $row['id'] . '.php?com=0') . '#comments-list'));
                }
                $result->dispose();
                //Création des cellules du tableau si besoin est.
                while (!is_int($j / $nbr_column_pics)) {
                    $this->tpl->assign_block_vars('end_table', array('TD_END' => '<td class="td-end" style="width:' . $column_width_pics . '%">&nbsp;</td>', 'TR_END' => is_int(++$j / $nbr_column_pics) ? '</tr>' : ''));
                }
            }
        }
    }
 /**
  * @desc Category[string] the childrens Categories map (id => category) for category id
  * @param int $id_category
  * @param SearchCategoryChildrensOptions $search_category_children_options
  */
 public function get_childrens($id_category, SearchCategoryChildrensOptions $search_category_children_options, $add_this = false)
 {
     if (!$this->get_categories_cache()->category_exists($id_category)) {
         throw new CategoryNotFoundException($id_category);
     }
     $categories = $this->categories_cache->get_categories();
     $root_category = $categories[Category::ROOT_CATEGORY];
     $childrens_categories = array();
     if ($add_this) {
         $childrens_categories[$id_category] = $this->categories_cache->get_category($id_category);
     }
     if ($search_category_children_options->is_excluded_categories_recursive() && $search_category_children_options->category_is_excluded($root_category) || !$search_category_children_options->check_authorizations($root_category)) {
         return array();
     }
     if ($id_category == Category::ROOT_CATEGORY && !$search_category_children_options->category_is_excluded($root_category)) {
         $childrens_categories[Category::ROOT_CATEGORY] = $root_category;
     }
     return $this->build_children_map($id_category, $categories, $id_category, $search_category_children_options, $childrens_categories);
 }
    private function build_form(HTTPRequestCustom $request)
    {
        $form = new HTMLForm(__CLASS__);
        $fieldset = new FormFieldsetHTML('articles', $this->lang['articles']);
        $form->add_fieldset($fieldset);
        $fieldset->add_field(new FormFieldTextEditor('title', $this->common_lang['form.title'], $this->get_article()->get_title(), array('required' => true)));
        if (!$this->is_contributor_member()) {
            $fieldset->add_field(new FormFieldCheckbox('personalize_rewrited_title', $this->common_lang['form.rewrited_name.personalize'], $this->get_article()->rewrited_title_is_personalized(), array('events' => array('click' => '
					if (HTMLForms.getField("personalize_rewrited_title").getValue()) {
						HTMLForms.getField("rewrited_title").enable();
					} else { 
						HTMLForms.getField("rewrited_title").disable();
					}'))));
            $fieldset->add_field(new FormFieldTextEditor('rewrited_title', $this->common_lang['form.rewrited_name'], $this->get_article()->get_rewrited_title(), array('description' => $this->common_lang['form.rewrited_name.description'], 'hidden' => !$this->get_article()->rewrited_title_is_personalized()), array(new FormFieldConstraintRegex('`^[a-z0-9\\-]+$`i'))));
        }
        $search_category_children_options = new SearchCategoryChildrensOptions();
        $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
        $search_category_children_options->add_authorizations_bits(Category::CONTRIBUTION_AUTHORIZATIONS);
        $fieldset->add_field(ArticlesService::get_categories_manager()->get_select_categories_form_field('id_category', $this->common_lang['form.category'], $this->get_article()->get_id_category(), $search_category_children_options));
        $fieldset->add_field(new FormFieldCheckbox('enable_description', $this->lang['articles.form.description_enabled'], $this->get_article()->get_description_enabled(), array('description' => StringVars::replace_vars($this->lang['articles.form.description_enabled.description'], array('number' => ArticlesConfig::load()->get_number_character_to_cut())), 'events' => array('click' => '
					if (HTMLForms.getField("enable_description").getValue()) {
						HTMLForms.getField("description").enable();
					} else { 
						HTMLForms.getField("description").disable();
					}'))));
        $fieldset->add_field(new FormFieldRichTextEditor('description', StringVars::replace_vars($this->lang['articles.form.description'], array('number' => ArticlesConfig::load()->get_number_character_to_cut())), $this->get_article()->get_description(), array('rows' => 3, 'hidden' => !$this->get_article()->get_description_enabled())));
        $fieldset->add_field(new FormFieldRichTextEditor('contents', $this->common_lang['form.contents'], $this->get_article()->get_contents(), array('rows' => 15, 'required' => true)));
        $onclick_action = 'javascript:bbcode_page();';
        $fieldset->add_field(new FormFieldActionLink('add_page', $this->lang['articles.form.add_page'], $onclick_action, PATH_TO_ROOT . '/articles/templates/images/pagebreak.png'));
        $other_fieldset = new FormFieldsetHTML('other', $this->common_lang['form.other']);
        $form->add_fieldset($other_fieldset);
        $other_fieldset->add_field(new FormFieldCheckbox('author_name_displayed', LangLoader::get_message('config.author_displayed', 'admin-common'), $this->get_article()->get_author_name_displayed()));
        $other_fieldset->add_field(new FormFieldCheckbox('notation_enabled', LangLoader::get_message('config.notation_enabled', 'admin-common'), $this->get_article()->get_notation_enabled()));
        $other_fieldset->add_field(new FormFieldUploadPictureFile('picture', $this->common_lang['form.picture'], $this->get_article()->get_picture()->relative()));
        $other_fieldset->add_field(ArticlesService::get_keywords_manager()->get_form_field($this->get_article()->get_id(), 'keywords', $this->common_lang['form.keywords'], array('description' => $this->common_lang['form.keywords.description'])));
        $other_fieldset->add_field(new ArticlesFormFieldSelectSources('sources', $this->common_lang['form.sources'], $this->get_article()->get_sources()));
        if (!$this->is_contributor_member()) {
            $publication_fieldset = new FormFieldsetHTML('publication', $this->common_lang['form.approbation']);
            $form->add_fieldset($publication_fieldset);
            $publication_fieldset->add_field(new FormFieldDateTime('date_created', $this->common_lang['form.date.creation'], $this->get_article()->get_date_created(), array('required' => true)));
            $publication_fieldset->add_field(new FormFieldSimpleSelectChoice('publishing_state', $this->common_lang['form.approbation'], $this->get_article()->get_publishing_state(), array(new FormFieldSelectChoiceOption($this->common_lang['form.approbation.not'], Article::NOT_PUBLISHED), new FormFieldSelectChoiceOption($this->common_lang['form.approbation.now'], Article::PUBLISHED_NOW), new FormFieldSelectChoiceOption($this->common_lang['status.approved.date'], Article::PUBLISHED_DATE)), array('events' => array('change' => '
				if (HTMLForms.getField("publishing_state").getValue() == 2) {
					jQuery("#' . __CLASS__ . '_publishing_start_date_field").show();
					HTMLForms.getField("end_date_enable").enable();
				} else { 
					jQuery("#' . __CLASS__ . '_publishing_start_date_field").hide();
					HTMLForms.getField("end_date_enable").disable();
				}'))));
            $publication_fieldset->add_field(new FormFieldDateTime('publishing_start_date', $this->common_lang['form.date.start'], $this->get_article()->get_publishing_start_date() === null ? new Date() : $this->get_article()->get_publishing_start_date(), array('hidden' => $this->get_article()->get_publishing_state() != Article::PUBLISHED_DATE)));
            $publication_fieldset->add_field(new FormFieldCheckbox('end_date_enable', $this->common_lang['form.date.end.enable'], $this->get_article()->end_date_enabled(), array('hidden' => $this->get_article()->get_publishing_state() != Article::PUBLISHED_DATE, 'events' => array('click' => '
						if (HTMLForms.getField("end_date_enable").getValue()) {
							HTMLForms.getField("publishing_end_date").enable();
						} else { 
							HTMLForms.getField("publishing_end_date").disable();
						}'))));
            $publication_fieldset->add_field(new FormFieldDateTime('publishing_end_date', $this->common_lang['form.date.end'], $this->get_article()->get_publishing_end_date() === null ? new date() : $this->get_article()->get_publishing_end_date(), array('hidden' => !$this->get_article()->end_date_enabled())));
        }
        $this->build_contribution_fieldset($form);
        $fieldset->add_field(new FormFieldHidden('referrer', $request->get_url_referrer()));
        $this->submit_button = new FormButtonDefaultSubmit();
        $form->add_button($this->submit_button);
        $form->add_button(new FormButtonReset());
        $this->form = $form;
        // Positionnement à la bonne page quand on édite un article avec plusieurs pages
        if ($this->get_article()->get_id() !== null) {
            $current_page = $request->get_getstring('page', '');
            $this->tpl->put('C_PAGE', !empty($current_page));
            if (!empty($current_page)) {
                $article_contents = $this->article->get_contents();
                //If article doesn't begin with a page, we insert one
                if (substr(trim($article_contents), 0, 6) != '[page]') {
                    $article_contents = '[page]&nbsp;[/page]' . $article_contents;
                }
                //Removing [page] bbcode
                $article_contents_clean = preg_split('`\\[page\\].+\\[/page\\](.*)`Us', $article_contents, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
                //Retrieving pages
                preg_match_all('`\\[page\\]([^[]+)\\[/page\\]`U', $article_contents, $array_page);
                $page_name = isset($array_page[1][$current_page - 1]) && $array_page[1][$current_page - 1] != '&nbsp;' ? $array_page[1][$current_page - 1] : '';
                $this->tpl->put('PAGE', TextHelper::to_js_string($page_name));
            }
        }
    }
    private function build_view()
    {
        global $LANG, $config, $nbr_msg_not_read, $tpl_top, $tpl_bottom;
        $id_get = retrieve(GET, 'id', 0);
        try {
            $this->category = ForumService::get_categories_manager()->get_categories_cache()->get_category($id_get);
        } catch (CategoryNotFoundException $e) {
        }
        require_once PATH_TO_ROOT . '/forum/forum_begin.php';
        require_once PATH_TO_ROOT . '/forum/forum_tools.php';
        $this->view = new FileTemplate('forum/forum_index.tpl');
        //Affichage des sous-catégories de la catégorie.
        $display_cat = !empty($id_get);
        //Vérification des autorisations.
        $authorized_categories = ForumService::get_authorized_categories($id_get);
        //Calcul du temps de péremption, ou de dernière vue des messages par à rapport à la configuration.
        $max_time_msg = forum_limit_time_msg();
        $is_guest = AppContext::get_current_user()->get_id() == -1;
        $total_topic = 0;
        $total_msg = 0;
        $i = 0;
        //On liste les catégories et sous-catégories.
        $result = PersistenceContext::get_querier()->select('SELECT @id_cat:= c.id, c.id AS cid, c.id_parent, c.name, c.rewrited_name, c.description as subname, c.url, c.last_topic_id, t.id AS tid, t.idcat, t.title, t.last_timestamp, t.last_user_id, t.last_msg_id, t.nbr_msg AS t_nbr_msg, t.display_msg, t.status, m.user_id, m.display_name as login, m.level as user_level, m.groups, v.last_view_id,
		(SELECT COUNT(*) FROM ' . ForumSetup::$forum_topics_table . '
			WHERE idcat IN (
				@id_cat,
				(SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . ForumSetup::$forum_cats_table . ' WHERE id_parent = @id_cat), 
				(SELECT GROUP_CONCAT(childs.id SEPARATOR \',\') FROM ' . ForumSetup::$forum_cats_table . ' parents
				INNER JOIN ' . ForumSetup::$forum_cats_table . ' childs ON parents.id = childs.id_parent
				WHERE parents.id_parent = @id_cat)
			)
		) AS nbr_topic,
		(SELECT COUNT(*) FROM ' . ForumSetup::$forum_message_table . '
			WHERE idtopic IN (
				(SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . ForumSetup::$forum_topics_table . ' WHERE idcat = @id_cat), 
				(SELECT GROUP_CONCAT(t.id SEPARATOR \',\') FROM ' . ForumSetup::$forum_topics_table . ' t LEFT JOIN ' . ForumSetup::$forum_cats_table . ' c ON t.idcat = c.id WHERE id_parent = @id_cat)
			)
		) AS nbr_msg
		FROM ' . ForumSetup::$forum_cats_table . ' c
		LEFT JOIN ' . ForumSetup::$forum_topics_table . ' t ON t.id = c.last_topic_id
		LEFT JOIN ' . ForumSetup::$forum_view_table . ' v ON v.user_id = :user_id AND v.idtopic = t.id
		LEFT JOIN ' . DB_TABLE_MEMBER . ' m ON m.user_id = t.last_user_id
		WHERE ' . ($display_cat ? 'c.id_parent = :id_cat AND ' : '') . 'c.id IN :authorized_categories
		ORDER BY c.id, c.id_parent, c.c_order', array('id_cat' => $id_get, 'user_id' => AppContext::get_current_user()->get_id(), 'authorized_categories' => $authorized_categories));
        $categories = array();
        while ($row = $result->fetch()) {
            $categories[] = $row;
        }
        $result->dispose();
        $display_sub_cats = false;
        $is_sub_forum = array();
        foreach ($categories as $row) {
            $this->view->assign_block_vars('forums_list', array());
            if ($row['id_parent'] == Category::ROOT_CATEGORY && $i > 0 && $display_sub_cats) {
                $this->view->assign_block_vars('forums_list.endcats', array());
            }
            $i++;
            if ($row['id_parent'] == Category::ROOT_CATEGORY) {
                $this->view->assign_block_vars('forums_list.cats', array('IDCAT' => $row['cid'], 'NAME' => $row['name'], 'U_FORUM_VARS' => ForumUrlBuilder::display_category($row['cid'], $row['rewrited_name'])->rel()));
                $display_sub_cats = true;
            } else {
                if (in_array($row['id_parent'], $is_sub_forum)) {
                    $is_sub_forum[] = $row['cid'];
                }
                if (($display_sub_cats || !empty($id_get)) && !in_array($row['cid'], $is_sub_forum)) {
                    if ($display_cat) {
                        $this->view->assign_block_vars('forums_list.cats', array('IDCAT' => $this->category->get_id(), 'NAME' => $this->category->get_name(), 'U_FORUM_VARS' => PATH_TO_ROOT . '/forum/' . url('index.php?id=' . $this->category->get_id(), 'cat-' . $this->category->get_id() . '+' . $this->category->get_rewrited_name() . '.php')));
                        $display_cat = false;
                    }
                    $subforums = '';
                    $this->view->put_all(array('C_FORUM_ROOT_CAT' => false, 'C_FORUM_CHILD_CAT' => true, 'C_END_S_CATS' => false));
                    $children = ForumService::get_categories_manager()->get_categories_cache()->get_childrens($row['cid']);
                    if ($children) {
                        foreach ($children as $id => $child) {
                            if ($child->get_id_parent() == $row['cid'] && ForumAuthorizationsService::check_authorizations($child->get_id())->read()) {
                                $is_sub_forum[] = $child->get_id();
                                $link = $child->get_url() ? '<a href="' . $child->get_url() . '" class="small">' : '<a href="forum' . url('.php?id=' . $child->get_id(), '-' . $child->get_id() . '+' . $child->get_rewrited_name() . '.php') . '" class="small">';
                                $subforums .= !empty($subforums) ? ', ' . $link . $child->get_name() . '</a>' : $link . $child->get_name() . '</a>';
                            }
                        }
                        $subforums = '<strong>' . $LANG['subforum_s'] . '</strong>: ' . $subforums;
                    }
                    if (!empty($row['last_topic_id'])) {
                        //Si le dernier message lu est présent on redirige vers lui, sinon on redirige vers le dernier posté.
                        if (!empty($row['last_view_id'])) {
                            $last_msg_id = $row['last_view_id'];
                            $last_page = 'idm=' . $row['last_view_id'] . '&amp;';
                            $last_page_rewrite = '-0-' . $row['last_view_id'];
                        } else {
                            $last_msg_id = $row['last_msg_id'];
                            $last_page = ceil($row['t_nbr_msg'] / $config->get_number_messages_per_page());
                            $last_page_rewrite = $last_page > 1 ? '-' . $last_page : '';
                            $last_page = $last_page > 1 ? 'pt=' . $last_page . '&amp;' : '';
                        }
                        $last_topic_title = ($config->is_message_before_topic_title_displayed() && $row['display_msg'] ? $config->get_message_before_topic_title() : '') . ' ' . $row['title'];
                        $last_topic_title = stripslashes(strlen(TextHelper::html_entity_decode($last_topic_title)) > 20 ? TextHelper::substr_html($last_topic_title, 0, 20) . '...' : $last_topic_title);
                        $row['login'] = !empty($row['login']) ? $row['login'] : $LANG['guest'];
                        $group_color = User::get_group_color($row['groups'], $row['user_level']);
                        $last = '<a href="' . PATH_TO_ROOT . '/forum/topic' . url('.php?id=' . $row['tid'], '-' . $row['tid'] . '+' . Url::encode_rewrite($row['title']) . '.php') . '" class="small">' . $last_topic_title . '</a><br />
						<a href="' . PATH_TO_ROOT . '/forum/topic' . url('.php?' . $last_page . 'id=' . $row['tid'], '-' . $row['tid'] . $last_page_rewrite . '+' . Url::encode_rewrite($row['title']) . '.php') . '#m' . $last_msg_id . '"><i class="fa fa-hand-o-right"></i></a> ' . $LANG['on'] . ' ' . Date::to_format($row['last_timestamp'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE) . '<br />' . $LANG['by'] . ' ' . ($row['last_user_id'] != '-1' ? '<a href="' . UserUrlBuilder::profile($row['last_user_id'])->rel() . '" class="small ' . UserService::get_level_class($row['user_level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . '>' . $row['login'] . '</a>' : '<em>' . $LANG['guest'] . '</em>');
                    } else {
                        $row['last_timestamp'] = '';
                        $last = '<br />' . $LANG['no_message'] . '<br /><br />';
                    }
                    //Vérifications des topics Lu/non Lus.
                    $img_announce = 'fa-announce';
                    $blink = false;
                    if (!$is_guest) {
                        if ($row['last_view_id'] != $row['last_msg_id'] && $row['last_timestamp'] >= $max_time_msg) {
                            $img_announce = $img_announce . '-new';
                            //Image affiché aux visiteurs.
                            $blink = true;
                        }
                    }
                    $img_announce .= $row['status'] == '0' ? '-lock' : '';
                    $total_topic += $row['nbr_topic'];
                    $total_msg += $row['nbr_msg'];
                    $this->view->assign_block_vars('forums_list.subcats', array('C_BLINK' => $blink, 'IMG_ANNOUNCE' => $img_announce, 'NAME' => $row['name'], 'DESC' => FormatingHelper::second_parse($row['subname']), 'SUBFORUMS' => !empty($subforums) && !empty($row['subname']) ? '<br />' . $subforums : $subforums, 'NBR_TOPIC' => $row['nbr_topic'], 'NBR_MSG' => $row['nbr_msg'], 'U_FORUM_URL' => $row['url'], 'U_FORUM_VARS' => ForumUrlBuilder::display_forum($row['cid'], $row['rewrited_name'])->rel(), 'U_LAST_TOPIC' => $last));
                }
            }
        }
        if ($i > 0) {
            $this->view->assign_block_vars('forums_list', array());
            $this->view->assign_block_vars('forums_list.endcats', array());
        }
        $site_path = GeneralConfig::get_default_site_path();
        if (GeneralConfig::load()->get_module_home_page() == 'forum') {
            list($users_list, $total_admin, $total_modo, $total_member, $total_visit, $total_online) = forum_list_user_online("AND s.location_script = '" . $site_path . "/forum/' OR s.location_script = '" . $site_path . "/forum/index.php' OR s.location_script = '" . $site_path . "/index.php' OR s.location_script = '" . $site_path . "/'");
        } else {
            $where = "AND s.location_script LIKE '%" . $site_path . "/forum/%'";
            if (!empty($id_get)) {
                $where = "AND s.location_script LIKE '%" . $site_path . url('/forum/index.php?id=' . $id_get, '/forum/cat-' . $id_get . ($this->category !== false && $id_get != Category::ROOT_CATEGORY ? '+' . $this->category->get_rewrited_name() : '') . '.php') . "'";
            }
            list($users_list, $total_admin, $total_modo, $total_member, $total_visit, $total_online) = forum_list_user_online($where);
        }
        //Liste des catégories.
        $search_category_children_options = new SearchCategoryChildrensOptions();
        $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
        $categories_tree = ForumService::get_categories_manager()->get_select_categories_form_field('cats', '', $id_get, $search_category_children_options);
        $method = new ReflectionMethod('AbstractFormFieldChoice', 'get_options');
        $method->setAccessible(true);
        $categories_tree_options = $method->invoke($categories_tree);
        $cat_list = '';
        foreach ($categories_tree_options as $option) {
            if ($option->get_raw_value()) {
                $cat = ForumService::get_categories_manager()->get_categories_cache()->get_category($option->get_raw_value());
                if (!$cat->get_url()) {
                    $cat_list .= $option->display()->render();
                }
            }
        }
        $vars_tpl = array('FORUM_NAME' => $config->get_forum_name(), 'NBR_MSG' => $total_msg, 'NBR_TOPIC' => $total_topic, 'C_USER_CONNECTED' => AppContext::get_current_user()->check_level(User::MEMBER_LEVEL), 'TOTAL_ONLINE' => $total_online, 'USERS_ONLINE' => $total_online - $total_visit == 0 ? '<em>' . $LANG['no_member_online'] . '</em>' : $users_list, 'ADMIN' => $total_admin, 'MODO' => $total_modo, 'MEMBER' => $total_member, 'GUEST' => $total_visit, 'SELECT_CAT' => !empty($id_get) ? $cat_list : '', 'C_TOTAL_POST' => true, 'U_ONCHANGE' => PATH_TO_ROOT . "/forum/" . url("index.php?id=' + this.options[this.selectedIndex].value + '", "forum-' + this.options[this.selectedIndex].value + '.php"), 'U_ONCHANGE_CAT' => PATH_TO_ROOT . "/forum/" . url("/index.php?id=' + this.options[this.selectedIndex].value + '", "cat-' + this.options[this.selectedIndex].value + '.php"), 'L_FORUM_INDEX' => $LANG['forum_index'], 'L_FORUM' => $LANG['forum'], 'L_TOPIC' => $total_topic > 1 ? $LANG['topic_s'] : $LANG['topic'], 'L_MESSAGE' => $total_msg > 1 ? $LANG['message_s'] : $LANG['message'], 'L_LAST_MESSAGE' => $LANG['last_message'], 'L_STATS' => $LANG['stats'], 'L_DISPLAY_UNREAD_MSG' => $LANG['show_not_reads'], 'L_MARK_AS_READ' => $LANG['mark_as_read'], 'L_TOTAL_POST' => $LANG['nbr_message'], 'L_DISTRIBUTED' => strtolower($LANG['distributed']), 'L_AND' => $LANG['and'], 'L_USER' => $total_online > 1 ? $LANG['user_s'] : $LANG['user'], 'L_ADMIN' => $total_admin > 1 ? $LANG['admin_s'] : $LANG['admin'], 'L_MODO' => $total_modo > 1 ? $LANG['modo_s'] : $LANG['modo'], 'L_MEMBER' => $total_member > 1 ? $LANG['member_s'] : $LANG['member'], 'L_GUEST' => $total_visit > 1 ? $LANG['guest_s'] : $LANG['guest'], 'L_AND' => $LANG['and'], 'L_ONLINE' => strtolower($LANG['online']));
        $this->view->put_all($vars_tpl);
        $tpl_top->put_all($vars_tpl);
        $tpl_bottom->put_all($vars_tpl);
        $this->view->put('forum_top', $tpl_top);
        $this->view->put('forum_bottom', $tpl_bottom);
        return $this->view;
    }