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 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; }
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; }