コード例 #1
0
    private function build_form()
    {
        $form = new HTMLForm(__CLASS__);
        $fieldset = new FormFieldsetHTML('config', $this->admin_common_lang['configuration']);
        $form->add_fieldset($fieldset);
        $fieldset->add_field(new FormFieldNumberEditor('items_number_per_page', $this->admin_common_lang['config.items_number_per_page'], $this->config->get_items_number_per_page(), array('min' => 1, 'max' => 50, 'required' => true), array(new FormFieldConstraintIntegerRange(1, 50))));
        $fieldset->add_field(new FormFieldNumberEditor('categories_number_per_page', $this->admin_common_lang['config.categories_number_per_page'], $this->config->get_categories_number_per_page(), array('min' => 1, 'max' => 50, 'required' => true), array(new FormFieldConstraintIntegerRange(1, 50))));
        $fieldset->add_field(new FormFieldNumberEditor('columns_number_per_line', $this->admin_common_lang['config.columns_number_per_line'], $this->config->get_columns_number_per_line(), array('min' => 1, 'max' => 4, 'required' => true), array(new FormFieldConstraintIntegerRange(1, 4))));
        $fieldset->add_field(new FormFieldCheckbox('author_displayed', $this->admin_common_lang['config.author_displayed'], $this->config->is_author_displayed()));
        $fieldset->add_field(new FormFieldCheckbox('comments_enabled', $this->admin_common_lang['config.comments_enabled'], $this->config->are_comments_enabled()));
        $fieldset->add_field(new FormFieldCheckbox('notation_enabled', $this->admin_common_lang['config.notation_enabled'], $this->config->is_notation_enabled(), array('events' => array('click' => '
				if (HTMLForms.getField("notation_enabled").getValue()) {
					HTMLForms.getField("notation_scale").enable();
				} else {
					HTMLForms.getField("notation_scale").disable();
				}'))));
        $fieldset->add_field(new FormFieldNumberEditor('notation_scale', $this->admin_common_lang['config.notation_scale'], $this->config->get_notation_scale(), array('min' => 3, 'max' => 20, 'required' => true, 'hidden' => !$this->config->is_notation_enabled()), array(new FormFieldConstraintIntegerRange(3, 20))));
        $fieldset->add_field(new FormFieldNumberEditor('max_video_width', $this->lang['config.max_video_width'], $this->config->get_max_video_width(), array('min' => 50, 'max' => 2000, 'required' => true), array(new FormFieldConstraintIntegerRange(50, 2000))));
        $fieldset->add_field(new FormFieldNumberEditor('max_video_height', $this->lang['config.max_video_height'], $this->config->get_max_video_height(), array('min' => 50, 'max' => 2000, 'required' => true), array(new FormFieldConstraintIntegerRange(50, 2000))));
        $fieldset->add_field(new FormFieldRichTextEditor('root_category_description', $this->admin_common_lang['config.root_category_description'], $this->config->get_root_category_description(), array('rows' => 8, 'cols' => 47)));
        $fieldset->add_field(new FormFieldSimpleSelectChoice('root_category_content_type', $this->lang['config.root_category_content_type'], $this->config->get_root_category_content_type(), array(new FormFieldSelectChoiceOption($this->lang['content_type.music_and_video'], MediaConfig::CONTENT_TYPE_MUSIC_AND_VIDEO), new FormFieldSelectChoiceOption($this->lang['content_type.music'], MediaConfig::CONTENT_TYPE_MUSIC), new FormFieldSelectChoiceOption($this->lang['content_type.video'], MediaConfig::CONTENT_TYPE_VIDEO))));
        $common_lang = LangLoader::get('common');
        $fieldset_authorizations = new FormFieldsetHTML('authorizations_fieldset', $common_lang['authorizations'], array('description' => $this->admin_common_lang['config.authorizations.explain']));
        $form->add_fieldset($fieldset_authorizations);
        $auth_settings = new AuthorizationsSettings(array(new ActionAuthorization($common_lang['authorizations.read'], Category::READ_AUTHORIZATIONS), new ActionAuthorization($common_lang['authorizations.write'], Category::WRITE_AUTHORIZATIONS), new ActionAuthorization($common_lang['authorizations.contribution'], Category::CONTRIBUTION_AUTHORIZATIONS), new ActionAuthorization($common_lang['authorizations.moderation'], Category::MODERATION_AUTHORIZATIONS)));
        $auth_setter = new FormFieldAuthorizationsSetter('authorizations', $auth_settings);
        $auth_settings->build_from_auth_array($this->config->get_authorizations());
        $fieldset_authorizations->add_field($auth_setter);
        $this->submit_button = new FormButtonDefaultSubmit();
        $form->add_button($this->submit_button);
        $form->add_button(new FormButtonReset());
        $this->form = $form;
    }