コード例 #1
0
 public function getCMSFields()
 {
     Requirements::css(BLOGGER_DIR . '/css/cms.css');
     $self =& $this;
     $this->beforeUpdateCMSFields(function ($fields) use($self) {
         $fields->addFieldsToTab('Root.Main', array(HeaderField::create('Post Options', 3), $publishDate = DatetimeField::create("PublishDate", _t("BlogPost.PublishDate", "Publish Date")), ListboxField::create("Categories", _t("BlogPost.Categories", "Categories"), $self->Parent()->Categories()->map()->toArray())->setMultiple(true), ListboxField::create("Tags", _t("BlogPost.Tags", "Tags"), $self->Parent()->Tags()->map()->toArray())->setMultiple(true)));
         $publishDate->getDateField()->setConfig("showcalendar", true);
         // Add featured image
         $fields->insertBefore($uploadField = UploadField::create("FeaturedImage", _t("BlogPost.FeaturedImage", "Featured Image")), "Content");
         $uploadField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
     });
     $fields = parent::getCMSFields();
     // We're going to make an SEO tab and move all the usual crap there
     $menuTitle = $fields->dataFieldByName('MenuTitle');
     $urlSegment = $fields->dataFieldByName('URLSegment');
     $fields->addFieldsToTab('Root.SEO', array($menuTitle, $urlSegment));
     $metaField = $fields->fieldByName('Root.Main.Metadata');
     if ($metaField) {
         $metaFields = $metaField->getChildren();
         if ($metaFields->count() > 0) {
             $tab = $fields->findOrMakeTab('Root.SEO');
             $tab->push(HeaderField::create('Meta', 3));
             foreach ($metaFields as $field) {
                 $tab->push($field);
             }
         }
         $fields->removeByName('Metadata');
     }
     return $fields;
 }
コード例 #2
0
 public function getDefaultSearchContext()
 {
     $context = parent::getDefaultSearchContext();
     $fields = $context->getFields();
     $fields->push(CheckboxField::create("HasBeenUsed"));
     //add date range filtering
     $fields->push(ToggleCompositeField::create("StartDate", "Start Date", array(DateField::create("q[StartDateFrom]", "From")->setConfig('showcalendar', true), DateField::create("q[StartDateTo]", "To")->setConfig('showcalendar', true))));
     $fields->push(ToggleCompositeField::create("EndDate", "End Date", array(DateField::create("q[EndDateFrom]", "From")->setConfig('showcalendar', true), DateField::create("q[EndDateTo]", "To")->setConfig('showcalendar', true))));
     //must be enabled in config, because some sites may have many products = slow load time, or memory maxes out
     //future solution is using an ajaxified field
     if (self::config()->filter_by_product) {
         $fields->push(ListboxField::create("Products", "Products", Product::get()->map()->toArray())->setMultiple(true));
     }
     if (self::config()->filter_by_category) {
         $fields->push(ListboxField::create("Categories", "Categories", ProductCategory::get()->map()->toArray())->setMultiple(true));
     }
     if ($field = $fields->fieldByName("Code")) {
         $field->setDescription("This can be a partial match.");
     }
     //get the array, to maniplulate name, and fullname seperately
     $filters = $context->getFilters();
     $filters['StartDateFrom'] = GreaterThanOrEqualFilter::create('StartDate');
     $filters['StartDateTo'] = LessThanOrEqualFilter::create('StartDate');
     $filters['EndDateFrom'] = GreaterThanOrEqualFilter::create('EndDate');
     $filters['EndDateTo'] = LessThanOrEqualFilter::create('EndDate');
     $context->setFilters($filters);
     return $context;
 }
 /**
  * 
  * @param FieldList $fields
  * @return void
  */
 public function updateCMSFields(FieldList $fields)
 {
     $controller = Controller::curr();
     if ($controller instanceof SecuredAssetAdmin || $controller instanceof CMSSecuredFileAddController) {
         Requirements::combine_files('securedassetsadmincmsfields.js', array(SECURED_FILES_MODULE_DIR . '/thirdparty/javascript/jquery-ui/timepicker/jquery-ui-sliderAccess.js', SECURED_FILES_MODULE_DIR . '/thirdparty/javascript/jquery-ui/timepicker/jquery-ui-timepicker-addon.min.js', SECURED_FILES_MODULE_DIR . "/javascript/SecuredFilesLeftAndMain.js"));
         Requirements::css(SECURED_FILES_MODULE_DIR . '/thirdparty/javascript/jquery-ui/timepicker/jquery-ui-timepicker-addon.min.css');
         Requirements::css(SECURED_FILES_MODULE_DIR . "/css/SecuredFilesLeftAndMain.css");
         Requirements::javascript(SECURED_FILES_MODULE_DIR . "/javascript/SecuredFilesLeftAndMain.js");
         if ($this->isFile()) {
             $buttonsSecurity = $this->showButtonsSecurity();
             $buttonsEmbargoExpiry = $this->showButtonsEmbargoExpiry();
             // Embargo field
             $embargoTypeField = new OptionSetField("EmbargoType", "", array("None" => _t('AdvancedSecuredFiles.NONENICE', "None"), "Indefinitely" => _t('AdvancedSecuredFiles.INDEFINITELYNICE', "Hide document indefinitely"), "UntilAFixedDate" => _t('AdvancedSecuredFiles.UNTILAFIXEDDATENICE', 'Hide until set date')));
             $embargoUntilDateField = DatetimeField::create('EmbargoedUntilDate', '');
             $embargoUntilDateField->getDateField()->setConfig('showcalendar', true)->setConfig('dateformat', 'dd-MM-yyyy')->setConfig('datavalueformat', 'dd-MM-yyyy')->setAttribute('readonly', true);
             $embargoUntilDateField->getTimeField()->setAttribute('readonly', true);
             // Expiry field
             $expireTypeField = new OptionSetField("ExpiryType", "", array("None" => _t('AdvancedSecuredFiles.NONENICE', "None"), "AtAFixedDate" => _t('AdvancedSecuredFiles.ATAFIXEDDATENICE', 'Set file to expire on')));
             $expiryDatetime = DatetimeField::create('ExpireAtDate', '');
             $expiryDatetime->getDateField()->setConfig('showcalendar', true)->setConfig('dateformat', 'dd-MM-yyyy')->setConfig('datavalueformat', 'dd-MM-yyyy')->setAttribute('readonly', true);
             $expiryDatetime->getTimeField()->setAttribute('readonly', true);
             $securitySettingsGroup = FieldGroup::create(FieldGroup::create($embargoTypeField, $embargoUntilDateField)->addExtraClass('embargo option-change-datetime')->setName("EmbargoGroupField"), FieldGroup::create($expireTypeField, $expiryDatetime)->addExtraClass('expiry option-change-datetime')->setName("ExpiryGroupField"));
         } else {
             $buttonsSecurity = $this->showButtonsSecurity();
             $buttonsEmbargoExpiry = '';
             $securitySettingsGroup = FieldGroup::create();
         }
         $canViewTypeField = new OptionSetField("CanViewType", "", array("Inherit" => _t('AdvancedSecuredFiles.INHERIT', "Inherit from parent folder"), "Anyone" => _t('SiteTree.ACCESSANYONE', 'Anyone'), "LoggedInUsers" => _t('SiteTree.ACCESSLOGGEDIN', 'Logged-in users'), "OnlyTheseUsers" => _t('SiteTree.ACCESSONLYTHESE', 'Only these people (choose from list)')));
         $canEditTypeField = new OptionSetField("CanEditType", "", array("Inherit" => _t('AdvancedSecuredFiles.INHERIT', "Inherit from parent folder"), "LoggedInUsers" => _t('SiteTree.ACCESSLOGGEDIN', 'Logged-in users'), "OnlyTheseUsers" => _t('SiteTree.ACCESSONLYTHESE', 'Only these people (choose from list)')));
         $groupsMap = array();
         foreach (Group::get() as $group) {
             // Listboxfield values are escaped, use ASCII char instead of »
             $groupsMap[$group->ID] = $group->getBreadcrumbs(' > ');
         }
         asort($groupsMap);
         $viewerGroupsField = ListboxField::create("ViewerGroups", _t('AdvancedSecuredFiles.VIEWERGROUPS', "Viewer Groups"))->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('AdvancedSecuredFiles.GroupPlaceholder', 'Click to select group'));
         $editorGroupsField = ListBoxField::create("EditorGroups", _t('AdvancedSecuredFiles.EDITORGROUPS', "Editor Groups"))->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('AdvancedSecuredFiles.GroupPlaceholder', 'Click to select group'));
         $securitySettingsGroup->push(FieldGroup::create($canViewTypeField, $viewerGroupsField)->addExtraClass('whocanview option-change-listbox')->setName("CanViewGroupField"));
         $securitySettingsGroup->push(FieldGroup::create($canEditTypeField, $editorGroupsField)->addExtraClass('whocanedit option-change-listbox')->setName("CanEditGroupField"));
         $securitySettingsGroup->setName("SecuritySettingsGroupField")->addExtraClass('security-settings');
         $showAdvanced = AdvancedAssetsFilesSiteConfig::is_security_enabled() || $this->isFile() && AdvancedAssetsFilesSiteConfig::is_embargoexpiry_enabled();
         if ($showAdvanced) {
             $fields->insertAfter(LiteralField::create('BottomTaskSelection', $this->owner->renderWith('componentField', ArrayData::create(array('ComponentSecurity' => AdvancedAssetsFilesSiteConfig::component_cms_icon('security'), 'ComponentEmbargoExpiry' => AdvancedAssetsFilesSiteConfig::component_cms_icon('embargoexpiry'), 'ButtonsSecurity' => $buttonsSecurity, 'ButtonsEmbargoExpiry' => $buttonsEmbargoExpiry)))), "ParentID");
             $fields->insertAfter($securitySettingsGroup, "BottomTaskSelection");
         }
     }
     if (!is_a($this->owner, "Folder") && is_a($this->owner, "File")) {
         $parentIDField = $fields->dataFieldByName("ParentID");
         if ($controller instanceof SecuredAssetAdmin) {
             $securedRoot = FileSecured::getSecuredRoot();
             $parentIDField->setTreeBaseID($securedRoot->ID);
             $parentIDField->setFilterFunction(create_function('$node', "return \$node->Secured == 1;"));
         } else {
             $parentIDField->setFilterFunction(create_function('$node', "return \$node->Secured == 0;"));
         }
         // SilverStripe core has a bug for search function now, so disable it for now.
         $parentIDField->setShowSearch(false);
     }
 }
コード例 #4
0
ファイル: Block.php プロジェクト: mhssmnn/silverstripe-blocks
 public function getCMSFields()
 {
     Requirements::add_i18n_javascript(BLOCKS_DIR . '/javascript/lang');
     // this line is a temporary patch until I can work out why this dependency isn't being
     // loaded in some cases...
     if (!$this->blockManager) {
         $this->blockManager = singleton('BlockManager');
     }
     $fields = parent::getCMSFields();
     // ClassNmae - block type/class field
     $classes = $this->blockManager->getBlockClasses();
     $fields->addFieldToTab('Root.Main', DropdownField::create('ClassName', 'Block Type', $classes)->addExtraClass('block-type'), 'Title');
     // BlockArea - display areas field if on page edit controller
     if (Controller::curr()->class == 'CMSPageEditController') {
         $currentPage = Controller::curr()->currentPage();
         $fields->addFieldToTab('Root.Main', DropdownField::create('ManyMany[BlockArea]', 'BlockArea', $this->blockManager->getAreasForPageType($currentPage->ClassName))->setHasEmptyDefault(true)->setRightTitle($currentPage->areasPreviewButton()), 'ClassName');
     }
     $fields->removeFieldFromTab('Root', 'BlockSets');
     $fields->removeFieldFromTab('Root', 'Pages');
     // legacy fields, will be removed in later release
     $fields->removeByName('Weight');
     $fields->removeByName('Area');
     $fields->removeByName('Published');
     if ($this->blockManager->getUseExtraCSSClasses()) {
         $fields->addFieldToTab('Root.Main', $fields->dataFieldByName('ExtraCSSClasses'), 'Title');
     } else {
         $fields->removeByName('ExtraCSSClasses');
     }
     // Viewer groups
     $fields->removeFieldFromTab('Root', 'ViewerGroups');
     $groupsMap = Group::get()->map('ID', 'Breadcrumbs')->toArray();
     asort($groupsMap);
     $viewersOptionsField = new OptionsetField("CanViewType", _t('SiteTree.ACCESSHEADER', "Who can view this page?"));
     $viewerGroupsField = ListboxField::create("ViewerGroups", _t('SiteTree.VIEWERGROUPS', "Viewer Groups"))->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('SiteTree.GroupPlaceholder', 'Click to select group'));
     $viewersOptionsSource = array();
     $viewersOptionsSource["Anyone"] = _t('SiteTree.ACCESSANYONE', "Anyone");
     $viewersOptionsSource["LoggedInUsers"] = _t('SiteTree.ACCESSLOGGEDIN', "Logged-in users");
     $viewersOptionsSource["OnlyTheseUsers"] = _t('SiteTree.ACCESSONLYTHESE', "Only these people (choose from list)");
     $viewersOptionsField->setSource($viewersOptionsSource)->setValue("Anyone");
     $fields->addFieldsToTab('Root.ViewerGroups', array($viewersOptionsField, $viewerGroupsField));
     // Disabled for now, until we can list ALL pages this block is applied to (inc via sets)
     // As otherwise it could be misleading
     // Show a GridField (list only) with pages which this block is used on
     // $fields->removeFieldFromTab('Root.Pages', 'Pages');
     // $fields->addFieldsToTab('Root.Pages',
     // 		new GridField(
     // 				'Pages',
     // 				'Used on pages',
     // 				$this->Pages(),
     // 				$gconf = GridFieldConfig_Base::create()));
     // enhance gridfield with edit links to pages if GFEditSiteTreeItemButtons is available
     // a GFRecordEditor (default) combined with BetterButtons already gives the possibility to
     // edit versioned records (Pages), but STbutton loads them in their own interface instead
     // of GFdetailform
     // if(class_exists('GridFieldEditSiteTreeItemButton')){
     // 	$gconf->addComponent(new GridFieldEditSiteTreeItemButton());
     // }
     return $fields;
 }
コード例 #5
0
 /**
  *	Update the page filtering, allowing CMS searchable content tagging.
  */
 public function updateSearchForm($form)
 {
     // Update the page filtering, allowing multiple tags.
     Requirements::javascript(FUSION_PATH . '/javascript/fusion.js');
     // Instantiate a field containing the existing tags.
     $form->Fields()->insertBefore(ListboxField::create('q[Tagging]', 'Tags', FusionTag::get()->map('Title', 'Title')->toArray(), ($filtering = $this->owner->getRequest()->getVar('q')) && isset($filtering['Tagging']) ? $filtering['Tagging'] : array(), null, true), 'q[Term]');
     // Allow extension.
     $this->owner->extend('updateCMSMainTaggingExtensionSearchForm', $form);
 }
コード例 #6
0
 /**
  * Adds variations specific fields to the CMS.
  */
 public function updateCMSFields(FieldList $fields)
 {
     $fields->addFieldsToTab('Root.Variations', array(ListboxField::create("VariationAttributeTypes", _t('ProductVariationsExtension.ATTRIBUTES', "Attributes"), ProductAttributeType::get()->map("ID", "Title")->toArray())->setMultiple(true)->setDescription(_t('ProductVariationsExtension.ATTRIBUTES_DESCRIPTION', "These are fields to indicate the way(s) each variation varies. Once selected, they can be edited on each variation.")), GridField::create("Variations", _t('ProductVariationsExtension.VARIATIONS', "Variations"), $this->owner->Variations(), GridFieldConfig_RecordEditor::create())));
     if ($this->owner->Variations()->exists()) {
         $fields->addFieldToTab('Root.Pricing', LabelField::create('variationspriceinstructinos', _t('ProductVariationsExtension.VARIATIONS_INSTRUCTIONS', "Price - Because you have one or more variations, the price can be set in the \"Variations\" tab.")));
         $fields->removeFieldFromTab('Root.Pricing', 'BasePrice');
         $fields->removeFieldFromTab('Root.Pricing', 'CostPrice');
         $fields->removeFieldFromTab('Root.Main', 'InternalItemID');
     }
 }
コード例 #7
0
 public function updateCMSFields($fields)
 {
     $topLevelGroups = Group::get()->filter('ParentID', 0)->map()->toArray();
     $groups = ListboxField::create('LoggedInGroups', 'Groups representing logged in users', $topLevelGroups);
     $groups->setMultiple(true);
     $fields->addFieldToTab('Root.MicroBlogSettings', $groups);
     $allGroups = Group::get()->map()->toArray();
     $groups = ListboxField::create('TargetedGroups', 'Groups users can selectively post to', $allGroups);
     $groups->setMultiple(true);
     $fields->addFieldToTab('Root.MicroBlogSettings', $groups);
 }
コード例 #8
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $metricsMap = array();
     foreach (Metric::get() as $metric) {
         $metricsMap[$metric->ID] = $metric->Name;
     }
     $metricsField = \ListboxField::create('Metrics', 'Metrics')->setMultiple(true)->setSource($metricsMap);
     $fields->addFieldToTab('Root.Main', $metricsField);
     return $fields;
 }
コード例 #9
0
 /**
  *	Display the appropriate CMS media page fields and respective media type attributes.
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // Display the media type as read only.
     $fields->addFieldToTab('Root.Main', ReadonlyField::create('Type', 'Type', $this->MediaType()->Title), 'Title');
     // Display a notification that the parent holder contains mixed children.
     $parent = $this->getParent();
     if ($parent && $parent->getMediaHolderChildren()->exists()) {
         Requirements::css(MEDIAWESOME_PATH . '/css/mediawesome.css');
         $fields->addFieldToTab('Root.Main', LiteralField::create('MediaNotification', "<p class='mediawesome notification'><strong>Mixed {$this->MediaType()->Title} Holder</strong></p>"), 'Type');
     }
     // Display the remaining media page fields.
     $fields->addFieldToTab('Root.Main', TextField::create('ExternalLink')->setRightTitle('An <strong>optional</strong> redirect URL to the media source'), 'URLSegment');
     $fields->addFieldToTab('Root.Main', $date = DatetimeField::create('Date'), 'Content');
     $date->getDateField()->setConfig('showcalendar', true);
     // Allow customisation of categories and tags respective to the current page.
     $tags = MediaTag::get()->map()->toArray();
     $fields->findOrMakeTab('Root.CategoriesTags', 'Categories and Tags');
     $fields->addFieldToTab('Root.CategoriesTags', $categoriesList = ListboxField::create('Categories', 'Categories', $tags)->setMultiple(true));
     $fields->addFieldToTab('Root.CategoriesTags', $tagsList = ListboxField::create('Tags', 'Tags', $tags)->setMultiple(true));
     if (!$tags) {
         $categoriesList->setAttribute('disabled', 'true');
         $tagsList->setAttribute('disabled', 'true');
     }
     // Allow customisation of media type attribute content respective to the current page.
     if ($this->MediaAttributes()->exists()) {
         foreach ($this->MediaAttributes() as $attribute) {
             if (strripos($attribute->Title, 'Time') || strripos($attribute->Title, 'Date') || stripos($attribute->Title, 'When')) {
                 // Display an attribute as a date time field where appropriate.
                 $fields->addFieldToTab('Root.Main', $custom = DatetimeField::create("{$attribute->ID}_MediaAttribute", $attribute->Title, $attribute->Content), 'Content');
                 $custom->getDateField()->setConfig('showcalendar', true);
             } else {
                 $fields->addFieldToTab('Root.Main', $custom = TextField::create("{$attribute->ID}_MediaAttribute", $attribute->Title, $attribute->Content), 'Content');
             }
             $custom->setRightTitle('Custom <strong>' . strtolower($this->MediaType()->Title) . '</strong> attribute');
         }
     }
     // Display an abstract field for content summarisation.
     $fields->addfieldToTab('Root.Main', $abstract = TextareaField::create('Abstract'), 'Content');
     $abstract->setRightTitle('A concise summary of the content');
     $abstract->setRows(6);
     // Allow customisation of images and attachments.
     $type = strtolower($this->MediaType()->Title);
     $fields->findOrMakeTab('Root.ImagesAttachments', 'Images and Attachments');
     $fields->addFieldToTab('Root.ImagesAttachments', $images = UploadField::create('Images'));
     $images->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif', 'bmp'));
     $images->setFolderName("media-{$type}/{$this->ID}/images");
     $fields->addFieldToTab('Root.ImagesAttachments', $attachments = UploadField::create('Attachments'));
     $attachments->setFolderName("media-{$type}/{$this->ID}/attachments");
     // Allow extension customisation.
     $this->extend('updateMediaPageCMSFields', $fields);
     return $fields;
 }
 public function getSettingsFields()
 {
     $fields = parent::getSettingsFields();
     $groupsMap = array();
     foreach (Group::get() as $group) {
         // Listboxfield values are escaped, use ASCII char instead of &raquo;
         $groupsMap[$group->ID] = $group->getBreadcrumbs(' > ');
     }
     asort($groupsMap);
     $fields->addFieldToTab("Root.Settings", ListboxField::create("PosterGroups", _t("Discussion.PosterGroups", "Groups that can post"))->setMultiple(true)->setSource($groupsMap)->setValue(null, $this->PosterGroups()), "CanViewType");
     $fields->addFieldToTab("Root.Settings", ListboxField::create("ModeratorGroups", _t("Discussion.ModeratorGroups", "Groups that can moderate"))->setMultiple(true)->setSource($groupsMap)->setValue(null, $this->ModeratorGroups()), "CanViewType");
     return $fields;
 }
コード例 #11
0
 /**
  * getCMSFields
  * @return FieldList
  **/
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->dataFieldByName('Title')->setTitle('Article Title');
     $fields->dataFieldByName('Content')->setTitle('Article Content');
     $config = $this->config();
     // publish date
     $fields->addFieldToTab('Root.Main', DateField::create('PublishDate')->setAttribute('placeholder', $this->dbObject('Created')->Format('M d, Y')), 'Content');
     // tags
     if ($config->enable_tags) {
         $tagSource = function () {
             return NewsTag::get()->map()->toArray();
         };
         $fields->addFieldToTab('Root.Main', ListboxField::create('Tags', 'Tags', $tagSource(), null, null, true)->useAddnew('NewsTag', $tagSource), 'Content');
     }
     // author
     if ($config->author_mode == 'string') {
         $fields->addFieldToTab('Root.Main', TextField::create('Author', 'Author'), 'Content');
     }
     if ($config->author_mode == 'object') {
         $authorSource = function () {
             return NewsAuthor::get()->map('ID', 'Name')->toArray();
         };
         $fields->addFieldToTab('Root.Main', DropdownField::create('NewsAuthorID', 'Author', $authorSource())->useAddNew('NewsAuthor', $authorSource)->setHasEmptyDefault(true), 'Content');
     }
     // featured
     if ($config->enable_featured_articles) {
         $fields->addFieldToTab('Root.Main', CheckboxField::create('Featured', _t('NewsArticle.FEATURED', 'Feature this article')), 'Content');
     }
     // images
     if ($config->enable_images) {
         $fields->addFieldToTab('Root.FilesAndImages', UploadField::create('Image')->setAllowedFileCategories('image')->setAllowedMaxFileNumber(1)->setFolderName($config->get('image_folder')));
     }
     // attachments
     if ($config->enable_attachments) {
         $fields->addFieldToTab('Root.FilesAndImages', UploadField::create('Attachment')->setAllowedFileCategories('doc')->setAllowedMaxFileNumber(1)->setFolderName($config->get('attachment_folder')));
     }
     // summary
     if ($config->enable_summary) {
         $fields->addFieldToTab('Root.Main', HTMLEditorField::create('Summary', 'Article Summary'), 'Content');
     }
     // parent
     $holders = NewsHolder::get();
     if ($holders->count() > 1) {
         $fields->addFieldToTab('Root.Main', DropdownField::create('ParentID', 'News Section', $holders->map()->toArray()), 'Title');
     } else {
         $fields->addFieldToTab('Root.Main', HiddenField::create('ParentID', 'News Section', $holders->first()->ID), 'Title');
     }
     $this->extend('updateArticleCMSFields', $fields);
     return $fields;
 }
コード例 #12
0
 public function updateCMSFields(FieldList $fields)
 {
     $categories = function () {
         //TODO: This should only be the case for public events
         return PublicEventCategory::get()->map()->toArray();
     };
     $categoriesField = ListboxField::create('Categories', 'Categories')->setMultiple(true)->setSource($categories());
     //If the quickaddnew module is installed, use it to allow
     //for easy adding of categories
     if (class_exists('QuickAddNewExtension')) {
         $categoriesField->useAddNew('PublicEventCategory', $categories);
     }
     $fields->addFieldToTab('Root.Main', $categoriesField);
 }
コード例 #13
0
    public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->removeByName('Order');
        $fields->removeByName('ProcessInfo');
        $fields->removeByName('StopStageID');
        $fields->removeByName('StopButton');
        $fields->removeByName('ContinueButton');
        $fields->removeByName('DecisionPoint');
        $fields->removeByName('CaseFinal');
        $fields->insertBefore(new LiteralField('StageTitle', '<h3 class="process-info-header">
			<span class="step-label">
				<span class="flyout">3</span><span class="arrow"></span>
				<span class="title">Stage Settings</span>
			</span>
		</h3>'), 'Title');
        $caseFinalMap = ProcessCase::get()->filter(array('ParentProcessID' => $this->ParentID))->map("ID", "Title")->toArray();
        asort($caseFinalMap);
        $case = ListboxField::create('CaseFinal', 'Final step for these Cases')->setMultiple(true)->setSource($caseFinalMap)->setAttribute('data-placeholder', _t('ProcessAdmin.Cases', 'Cases', 'Placeholder text for a dropdown'));
        $fields->insertAfter($case, 'Title');
        $fields->insertAfter($group = new CompositeField($label = new LabelField('switchLabel', 'Act as Decision Point'), new CheckboxField('DecisionPoint', '')), 'ParentID');
        $group->addExtraClass("field special process-noborder");
        $label->addExtraClass("left");
        $fields->dataFieldByName('Content')->setRows(10);
        if ($this->ID > 0) {
            $fields->addFieldToTab('Root.Main', new LiteralField('SaveRecord', '<p></p>'));
            $fields->addFieldToTab('Root.Main', $processInfo = new CompositeField($grid = new GridField('ProcessInfo', 'Information for this stage', $this->ProcessInfo()->sort(array('TypeID' => 'ASC', 'ProcessCaseID' => 'ASC', 'LinksToAnotherStageID' => 'ASC')), $gridConfig = GridFieldConfig_RelationEditor::create())));
            $gridConfig->addComponent(new GridFieldSortableRows('Order'));
            $processInfo->addExtraClass('process-spacing');
            $grid->addExtraClass('toggle-grid');
        } else {
            $fields->addFieldToTab('Root.Main', new LiteralField('SaveRecord', '<p class="message info">Save this stage to add info</p>'));
        }
        $fields->insertBefore(new LiteralField('StageTitleInfo', '<h3 class="process-info-header">
				<span class="step-label">
					<span class="flyout">4</span><span class="arrow"></span>
					<span class="title">Information</span>
				</span>
			</h3>'), 'SaveRecord');
        $stopStage = ProcessStopStage::get();
        if ($stopStage) {
            $fields->insertBefore($inner = new CompositeField(new LiteralField('Decision', '<h3>Decision Point</h3>'), new LiteralField('ExplainStop', '<label class="right">Choose a stop stage if you would like this stage to act as a decision point</label>'), $stop = new DropdownField('StopStageID', 'Stop Stage', $stopStage->map('ID', 'Title')), $continue = new TextField('ContinueButton', 'Button: Continue (e.g. "Yes")'), new TextField('StopButton', 'Button: Stop (e.g. "No")')), 'ProcessInfo');
            $stop->setEmptyString('No stop after this stage');
            $inner->addExtraClass('message special toggle-decide');
            $continue->addExtraClass('process-noborder');
            $stop->addExtraClass('process-noborder');
        }
        return $fields;
    }
コード例 #14
0
 public function getCMSFields()
 {
     $datefield = DateField::create('Date')->setTitle('Article Date');
     $datefield->setConfig('showcalendar', true);
     $datefield->setConfig('dateformat', 'MM/dd/YYYY');
     $imagefield = UploadField::create('Photo')->setTitle('Featured Photo');
     $imagefield->folderName = 'News';
     $imagefield->getValidator()->allowedExtensions = array('jpg', 'jpeg', 'gif', 'png');
     $imagefield->getValidator()->setAllowedMaxFileSize('2097152');
     // 2 MB in bytes
     $categoriesMap = NewsCategory::get()->filter('NewsHolderID', $this->Parent()->ID)->sort('Title ASC')->map('ID', 'Title')->toArray();
     $fields = parent::getCMSFields();
     $fields->addFieldsToTab('Root.Main', array($datefield, TextField::create('Author')->setTitle('Author Name'), $imagefield, ListboxField::create('NewsCategories')->setTitle('Category')->setMultiple(true)->setSource($categoriesMap)), 'Content');
     return $fields;
 }
コード例 #15
0
 public function updateCMSFields(FieldList $fields)
 {
     if ($this->owner->ID) {
         $srcTags = function () {
             $tags = array();
             foreach (DMSTag::get() as $t) {
                 $tags[$t->ID] = $t->Category . ($t->isValueDefined() ? ' -> ' . $t->Value : '');
             }
             return $tags;
         };
         $selectTags = ListboxField::create('DocumentTags', _t('DMSDocumentExtension.Tags', 'Tags'), $srcTags(), implode(',', $this->owner->Tags()->column()), null, true)->useAddNew('DMSTag', $srcTags, FieldList::create(TextField::create('Category', _t('DMSDocumentExtension.Category', 'Category *')), TextField::create('Value', _t('DMSDocumentExtension.Value', 'Value')), HiddenField::create('MultiValue', null, 1)));
         $fields->insertAfter($selectTags, 'Description');
         $fields->insertAfter(CheckboxField::create('ShowTagsFrontend', _t('DMSDocumentExtension.ShowTagsFrontend', 'Show document tags in frontend?')), 'DocumentTags');
     }
 }
コード例 #16
0
 /**
  *	Display the appropriate tagging field.
  */
 public function updateCMSFields(FieldList $fields)
 {
     $fields->removeByName('FusionTags');
     // Determine whether consolidated tags are found in the existing relationships.
     $types = array();
     foreach (singleton('FusionService')->getFusionTagTypes() as $type => $field) {
         $types[$type] = $type;
     }
     $types = array_intersect($this->owner->many_many(), $types);
     if (empty($types)) {
         // There are no consolidated tags found, therefore instantiate a tagging field.
         $fields->addFieldToTab('Root.Tagging', ListboxField::create('FusionTags', 'Tags', FusionTag::get()->map()->toArray())->setMultiple(true));
     }
     // Allow extension.
     $this->owner->extend('updateTaggingExtensionCMSFields', $fields);
 }
コード例 #17
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->insertAfter($gameFormContent = new HTMLEditorField('GameLiveContent', 'Game selection form detail'), 'Content');
     $gameFormContent->setRows(20);
     $regOpen = new CheckboxField('OpenGameReg', '');
     $fields->insertBefore($cField = new CompositeField(array($label = new LabelField('OpenGameRegLabel', 'Open game selection (all)'), $regOpen)), 'Content');
     $cField->addExtraClass('field');
     $regOpen->addExtraClass('mts');
     $label->addExtraClass('left');
     $groupsMap = array();
     foreach (Group::get() as $group) {
         // Listboxfield values are escaped, use ASCII char instead of &raquo;
         $groupsMap[$group->ID] = $group->getBreadcrumbs(' > ');
     }
     asort($groupsMap);
     $fields->insertBefore(ListboxField::create('OpenGameRegForGroups', "Open game selection for group (limited)")->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('Member.ADDGROUP', 'Add group', 'Placeholder text for a dropdown')), 'Content');
     return $fields;
 }
 /**
  *
  * @param FieldList $fields
  */
 public function updateCMSFields(FieldList $fields)
 {
     $helpText = LiteralField::create("ContentReviewHelp", _t("ContentReview.DEFAULTSETTINGSHELP", "These content review settings will apply to all pages that does not have specific Content Review schedule."));
     $fields->addFieldToTab("Root.ContentReview", $helpText);
     $reviewFrequency = DropdownField::create("ReviewPeriodDays", _t("ContentReview.REVIEWFREQUENCY", "Review frequency"), SiteTreeContentReview::get_schedule())->setDescription(_t("ContentReview.REVIEWFREQUENCYDESCRIPTION", "The review date will be set to this far in the future whenever the page is published"));
     $fields->addFieldToTab("Root.ContentReview", $reviewFrequency);
     $users = Permission::get_members_by_permission(array("CMS_ACCESS_CMSMain", "ADMIN"));
     $usersMap = $users->map("ID", "Title")->toArray();
     asort($usersMap);
     $userField = ListboxField::create("OwnerUsers", _t("ContentReview.PAGEOWNERUSERS", "Users"), $usersMap)->setMultiple(true)->setAttribute("data-placeholder", _t("ContentReview.ADDUSERS", "Add users"))->setDescription(_t("ContentReview.OWNERUSERSDESCRIPTION", "Page owners that are responsible for reviews"));
     $fields->addFieldToTab("Root.ContentReview", $userField);
     $groupsMap = array();
     foreach (Group::get() as $group) {
         // Listboxfield values are escaped, use ASCII char instead of &raquo;
         $groupsMap[$group->ID] = $group->getBreadcrumbs(" > ");
     }
     asort($groupsMap);
     $groupField = ListboxField::create("OwnerGroups", _t("ContentReview.PAGEOWNERGROUPS", "Groups"), $groupsMap)->setMultiple(true)->setAttribute("data-placeholder", _t("ContentReview.ADDGROUP", "Add groups"))->setDescription(_t("ContentReview.OWNERGROUPSDESCRIPTION", "Page owners that are responsible for reviews"));
     $fields->addFieldToTab("Root.ContentReview", $groupField);
 }
コード例 #19
0
 /**
  * Get the fields that are sent to the CMS. In
  * your extensions: updateCMSFields($fields)
  *
  * @return FieldList
  */
 function getCMSFields()
 {
     Requirements::javascript(CMS_DIR . "/javascript/SitetreeAccess.js");
     $groupsMap = Group::get()->map('ID', 'Breadcrumbs')->toArray();
     asort($groupsMap);
     $fields = new FieldList(new TabSet("Root", $tabMain = new Tab('Main', $titleField = new TextField("Title", _t('SiteConfig.SITETITLE', "Site title")), $taglineField = new TextField("Tagline", _t('SiteConfig.SITETAGLINE', "Site Tagline/Slogan")), $themeDropdownField = new DropdownField("Theme", _t('SiteConfig.THEME', 'Theme'), $this->getAvailableThemes())), $tabAccess = new Tab('Access', $viewersOptionsField = new OptionsetField("CanViewType", _t('SiteConfig.VIEWHEADER', "Who can view pages on this site?")), $viewerGroupsField = ListboxField::create("ViewerGroups", _t('SiteTree.VIEWERGROUPS', "Viewer Groups"))->setMultiple(true)->setSource($groupsMap), $editorsOptionsField = new OptionsetField("CanEditType", _t('SiteConfig.EDITHEADER', "Who can edit pages on this site?")), $editorGroupsField = ListboxField::create("EditorGroups", _t('SiteTree.EDITORGROUPS', "Editor Groups"))->setMultiple(true)->setSource($groupsMap), $topLevelCreatorsOptionsField = new OptionsetField("CanCreateTopLevelType", _t('SiteConfig.TOPLEVELCREATE', "Who can create pages in the root of the site?")), $topLevelCreatorsGroupsField = ListboxField::create("CreateTopLevelGroups", _t('SiteTree.TOPLEVELCREATORGROUPS', "Top level creators"))->setMultiple(true)->setSource($groupsMap))));
     $themeDropdownField->setEmptyString(_t('SiteConfig.DEFAULTTHEME', '(Use default theme)'));
     $viewersOptionsSource = array();
     $viewersOptionsSource["Anyone"] = _t('SiteTree.ACCESSANYONE', "Anyone");
     $viewersOptionsSource["LoggedInUsers"] = _t('SiteTree.ACCESSLOGGEDIN', "Logged-in users");
     $viewersOptionsSource["OnlyTheseUsers"] = _t('SiteTree.ACCESSONLYTHESE', "Only these people (choose from list)");
     $viewersOptionsField->setSource($viewersOptionsSource);
     $editorsOptionsSource = array();
     $editorsOptionsSource["LoggedInUsers"] = _t('SiteTree.EDITANYONE', "Anyone who can log-in to the CMS");
     $editorsOptionsSource["OnlyTheseUsers"] = _t('SiteTree.EDITONLYTHESE', "Only these people (choose from list)");
     $editorsOptionsField->setSource($editorsOptionsSource);
     $topLevelCreatorsOptionsField->setSource($editorsOptionsSource);
     // Translatable doesn't handle updateCMSFields on DataObjects,
     // so add it here to save the current Locale,
     // because onBeforeWrite does not work.
     if (class_exists('Translatable') && Object::has_extension('SiteConfig', "Translatable")) {
         $fields->push(new HiddenField("Locale"));
     }
     if (!Permission::check('EDIT_SITECONFIG')) {
         $fields->makeFieldReadonly($viewersOptionsField);
         $fields->makeFieldReadonly($viewerGroupsField);
         $fields->makeFieldReadonly($editorsOptionsField);
         $fields->makeFieldReadonly($editorGroupsField);
         $fields->makeFieldReadonly($topLevelCreatorsOptionsField);
         $fields->makeFieldReadonly($topLevelCreatorsGroupsField);
         $fields->makeFieldReadonly($taglineField);
         $fields->makeFieldReadonly($titleField);
     }
     if (file_exists(BASE_PATH . '/install.php')) {
         $fields->addFieldToTab("Root.Main", new LiteralField("InstallWarningHeader", "<p class=\"message warning\">" . _t("SiteTree.REMOVE_INSTALL_WARNING", "Warning: You should remove install.php from this SilverStripe install for security reasons.") . "</p>"), "Title");
     }
     $tabMain->setTitle(_t('SiteConfig.TABMAIN', "Main"));
     $tabAccess->setTitle(_t('SiteConfig.TABACCESS', "Access"));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
コード例 #20
0
ファイル: Story.php プロジェクト: krissihall/sm_ss
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab('Root.Main', new TextField('Description', 'Story Summary'), 'Content');
     $fields->addFieldToTab('Root.Main', new UploadField('CoverImage', 'Cover Image'), 'Content');
     $fields->addFieldToTab('Root.Main', new DropdownField('Rating', 'Story Rating', $this->dbObject('Rating')->enumValues()), 'Content');
     $fields->addFieldToTab('Root.Main', new DropdownField('StoryStatus', 'Story Status', $this->dbObject('StoryStatus')->enumValues()), 'Content');
     $fields->addFieldToTab('Root.Main', new DropdownField('Type', 'Story Type', $this->dbObject('Type')->enumValues()), 'Content');
     $fields->addFieldToTab('Root.Main', $dateField = new DateField('Added', 'Added on (for example: 12/20/2010)'), 'Content');
     $dateField->setConfig('showcalendar', true);
     $dateField->setConfig('dateformat', 'MM/dd/YYYY');
     $characters = DataObject::get('Character');
     if (!empty($characters)) {
         // create an array('ID'=>'Name')
         $characterMap = $characters->map("ID", "Name", "Please Select");
         // create a Multi-select group based on the array
         $fields->addFieldToTab('Root.Details', ListboxField::Create('Characters', 'Select a Character')->setMultiple(true)->setSource($characterMap));
     }
     $series = DataObject::get('Series');
     if (!empty($series)) {
         // create an array('ID'=>'Name')
         $seriesMap = $series->map("ID", "Name", "Please Select");
         // create a Multi-select group based on the array
         $fields->addFieldToTab('Root.Details', ListboxField::Create('Series', 'Select a Series')->setMultiple(true)->setSource($seriesMap));
     }
     $genres = DataObject::get('Genre');
     if (!empty($genres)) {
         // create an array('ID'=>'Name')
         $genreMap = $genres->map("ID", "Name", "Please Select");
         // create a Multi-select group based on the array
         $fields->addFieldToTab('Root.Details', ListboxField::Create('Genres', 'Select a Genre')->setMultiple(true)->setSource($genreMap));
     }
     $authors = DataObject::get('Author');
     if (!empty($authors)) {
         // create an array('ID'=>'Name')
         $authorMap = $authors->map("ID", "Name", "Please Select");
         // create a Multi-select group based on the array
         $fields->addFieldToTab('Root.Details', ListboxField::create('Authors', 'Select an Author')->setMultiple(true)->setSource($authorMap));
     }
     return $fields;
 }
コード例 #21
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeFieldFromTab('Root', 'ViewerGroups');
     $viewersOptionsSource['LoggedInUsers'] = _t('TimedNotice.ACCESSLOGGEDIN', 'Logged-in users');
     $viewersOptionsSource['OnlyTheseUsers'] = _t('TimedNotice.ACCESSONLYTHESE', 'Only these people (choose from list)');
     $fields->addFieldToTab('Root.Main', $canViewTypeField = OptionsetField::create("CanViewType", _t('TimedNotice.ACCESSHEADER', "Who should see this notice?"), $viewersOptionsSource));
     $groupsMap = Group::get()->map('ID', 'Breadcrumbs')->toArray();
     asort($groupsMap);
     $fields->addFieldToTab('Root.Main', $viewerGroupsField = ListboxField::create("ViewerGroups", _t('TimedNotice.VIEWERGROUPS', "Only people in these groups"))->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('TimedNotice.GroupPlaceholder', 'Click to select group')));
     $viewerGroupsField->displayIf("CanViewType")->isEqualTo("OnlyTheseUsers");
     $fields->addFieldToTab('Root.Main', DropdownField::create('MessageType', 'Message Type', ArrayLib::valuekey($this->config()->get('message_types'))), 'Message');
     $fields->addFieldToTab('Root.Main', ReadonlyField::create('TZNote', 'Note', sprintf(_t('TimedNotice.TZNote', 'Your dates and times should be based on the server timezone: %s'), date_default_timezone_get())), 'StartTime');
     $start = $fields->dataFieldByName('StartTime');
     $end = $fields->dataFieldByName('EndTime');
     $start->getDateField()->setConfig('showcalendar', true);
     $end->getDateField()->setConfig('showcalendar', true);
     $start->setTimeField(TimePickerField::create('StartTime[time]', '')->addExtraClass('fieldgroup-field'));
     $end->setTimeField(TimePickerField::create('EndTime[time]', '')->addExtraClass('fieldgroup-field'));
     return $fields;
 }
コード例 #22
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->dataFieldByName('Title')->setTitle('City Hotel Name');
     $fields->dataFieldByName('Content')->setTitle('City Hotel Introduction');
     $fields->insertBefore(NumericField::create("NoOfRooms")->setTitle("Total Number of Rooms"), 'Content');
     $fields->insertBefore(TextField::create("AirportDistance")->setTitle("Distance from Airport"), 'Content');
     $fields->addFieldToTab('Root.Main', new DropdownField('AtollID', 'Atoll', Atolls::get()->map('ID', 'Name')), 'Content');
     $fields->addFieldToTab('Root.Main', new DropdownField('IslandID', 'Island', Islands::get()->map('ID', 'Name')), 'Content');
     $fields->addFieldToTab('Root.Main', new DropdownField('CategoryID', 'Category', Categories::get()->map('ID', 'Name')), 'Content');
     $fields->addFieldToTab('Root.Main', new DropdownField('TransferTypeID', 'TransferType', TransferTypes::get()->map('ID', 'Name')), 'Content');
     $fields->insertBefore(NumericField::create("Rating")->setTitle("Star Rating"), 'Content');
     $fields->insertBefore(CheckboxField::create("InSide")->setTitle("Show City Hotel in Slide Show"), 'Content');
     $fields->insertBefore(CheckboxField::create("Featured")->setTitle("Show City Hotel in Featured List"), 'Content');
     $fields->insertBefore(TextField::create("Cordinates")->setTitle("Map Cordinates, Longitute & Latitude, separated by comma"), 'Content');
     $imgfield = UploadField::create('FeaturedPhoto')->setTitle("Default Cover Photo");
     $imgfield->getValidator()->allowedExtensions = array('jpg', 'jpeg', 'gif', 'png');
     $fields->insertBefore($imgfield, 'Content');
     $defaultTag = $this->Tags()->column('ID');
     // print_r($defaultTag);
     $tagMap = Tags::get()->map('ID', 'Name')->toArray();
     $tagList = ListboxField::create('Tags', 'Tags')->setMultiple(true)->setSource($tagMap)->setDefaultItems($defaultTag);
     $fields->addFieldToTab('Root.Main', $tagList, 'Content');
     $defaultItem = $this->HolidayTypes()->column('ID');
     $Map = HolidayTypes::get()->map('ID', 'Name')->toArray();
     $List = ListboxField::create('HolidayTypes', 'Holiday Types')->setMultiple(true)->setSource($Map)->setDefaultItems($defaultItem);
     $fields->addFieldToTab('Root.Main', $List, 'Content');
     $fields->addFieldToTab('Root.CityHotelImages', $uploadField = new uploadField($name = "CityHotelImages", $title = "Upload one or more images (max 10 in total)"));
     $uploadField->setAllowedMaxFileNumber(10);
     $gridConfig = GridFieldConfig_RelationEditor::create();
     $GridField = new GridField('Rooms', 'Rooms', $this->Rooms(), $gridConfig);
     $fields->addFieldToTab("Root.Rooms", $GridField);
     $GridField = new GridField('Dining', 'Dining', $this->Dining(), $gridConfig);
     $fields->addFieldToTab("Root.Dining", $GridField);
     $GridField = new GridField('Facilities', 'Facilities', $this->Facilities(), $gridConfig);
     $fields->addFieldToTab("Root.Facilities", $GridField);
     $GridField = new GridField('Activities', 'Activities', $this->Activities(), $gridConfig);
     $fields->addFieldToTab("Root.Activities", $GridField);
     return $fields;
 }
コード例 #23
0
ファイル: SiteConfig.php プロジェクト: 8secs/cocina
 /**
  * Get the fields that are sent to the CMS. In
  * your extensions: updateCMSFields($fields)
  *
  * @return FieldList
  */
 public function getCMSFields()
 {
     $groupsMap = array();
     foreach (Group::get() as $group) {
         // Listboxfield values are escaped, use ASCII char instead of &raquo;
         $groupsMap[$group->ID] = $group->getBreadcrumbs(' > ');
     }
     asort($groupsMap);
     $fields = new FieldList(new TabSet("Root", $tabMain = new Tab('Main', $titleField = new TextField("Title", _t('SiteConfig.SITETITLE', "Site title")), $taglineField = new TextField("Tagline", _t('SiteConfig.SITETAGLINE', "Site Tagline/Slogan")), $themeDropdownField = new DropdownField("Theme", _t('SiteConfig.THEME', 'Theme'), $this->getAvailableThemes())), $tabAccess = new Tab('Access', $viewersOptionsField = new OptionsetField("CanViewType", _t('SiteConfig.VIEWHEADER', "Who can view pages on this site?")), $viewerGroupsField = ListboxField::create("ViewerGroups", _t('SiteTree.VIEWERGROUPS', "Viewer Groups"))->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('SiteTree.GroupPlaceholder', 'Click to select group')), $editorsOptionsField = new OptionsetField("CanEditType", _t('SiteConfig.EDITHEADER', "Who can edit pages on this site?")), $editorGroupsField = ListboxField::create("EditorGroups", _t('SiteTree.EDITORGROUPS', "Editor Groups"))->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('SiteTree.GroupPlaceholder', 'Click to select group')), $topLevelCreatorsOptionsField = new OptionsetField("CanCreateTopLevelType", _t('SiteConfig.TOPLEVELCREATE', "Who can create pages in the root of the site?")), $topLevelCreatorsGroupsField = ListboxField::create("CreateTopLevelGroups", _t('SiteTree.TOPLEVELCREATORGROUPS', "Top level creators"))->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('SiteTree.GroupPlaceholder', 'Click to select group')))), new HiddenField('ID'));
     $themeDropdownField->setEmptyString(_t('SiteConfig.DEFAULTTHEME', '(Use default theme)'));
     $viewersOptionsSource = array();
     $viewersOptionsSource["Anyone"] = _t('SiteTree.ACCESSANYONE', "Anyone");
     $viewersOptionsSource["LoggedInUsers"] = _t('SiteTree.ACCESSLOGGEDIN', "Logged-in users");
     $viewersOptionsSource["OnlyTheseUsers"] = _t('SiteTree.ACCESSONLYTHESE', "Only these people (choose from list)");
     $viewersOptionsField->setSource($viewersOptionsSource);
     $editorsOptionsSource = array();
     $editorsOptionsSource["LoggedInUsers"] = _t('SiteTree.EDITANYONE', "Anyone who can log-in to the CMS");
     $editorsOptionsSource["OnlyTheseUsers"] = _t('SiteTree.EDITONLYTHESE', "Only these people (choose from list)");
     $editorsOptionsField->setSource($editorsOptionsSource);
     $topLevelCreatorsOptionsField->setSource($editorsOptionsSource);
     if (!Permission::check('EDIT_SITECONFIG')) {
         $fields->makeFieldReadonly($viewersOptionsField);
         $fields->makeFieldReadonly($viewerGroupsField);
         $fields->makeFieldReadonly($editorsOptionsField);
         $fields->makeFieldReadonly($editorGroupsField);
         $fields->makeFieldReadonly($topLevelCreatorsOptionsField);
         $fields->makeFieldReadonly($topLevelCreatorsGroupsField);
         $fields->makeFieldReadonly($taglineField);
         $fields->makeFieldReadonly($titleField);
     }
     if (file_exists(BASE_PATH . '/install.php')) {
         $fields->addFieldToTab("Root.Main", new LiteralField("InstallWarningHeader", "<p class=\"message warning\">" . _t("SiteTree.REMOVE_INSTALL_WARNING", "Warning: You should remove install.php from this SilverStripe install for security reasons.") . "</p>"), "Title");
     }
     $tabMain->setTitle(_t('SiteConfig.TABMAIN', "Main"));
     $tabAccess->setTitle(_t('SiteConfig.TABACCESS', "Access"));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
コード例 #24
0
 /**
  *	Display the appropriate fusion tag fields.
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // Determine whether the tag types should be displayed.
     $types = array();
     foreach ($this->service->getFusionTagTypes() as $type => $field) {
         $types[$type] = $type;
     }
     if (count($types)) {
         // The serialised representation will require a custom field to display correctly.
         $fields->replaceField('TagTypes', $list = ListboxField::create('Types', 'Tag Types', $types)->setMultiple(true));
         // Disable existing tag types to prevent deletion.
         $items = is_string($this->TagTypes) ? array_keys(unserialize($this->TagTypes)) : array();
         $list->setValue($items);
         $list->setDisabledItems($items);
     } else {
         // There are no existing or configuration defined tag types.
         $fields->removeByName('TagTypes');
     }
     // Allow extension.
     $this->extend('updateFusionTagCMSFields', $fields);
     return $fields;
 }
コード例 #25
0
ファイル: Member.php プロジェクト: hemant-chakka/awss
 /**
  * Return a {@link FieldList} of fields that would appropriate for editing
  * this member.
  *
  * @return FieldList Return a FieldList of fields that would appropriate for
  *                   editing this member.
  */
 public function getCMSFields()
 {
     require_once 'Zend/Date.php';
     $self = $this;
     $this->beforeUpdateCMSFields(function ($fields) use($self) {
         $mainFields = $fields->fieldByName("Root")->fieldByName("Main")->Children;
         $password = new ConfirmedPasswordField('Password', null, null, null, true);
         $password->setCanBeEmpty(true);
         if (!$self->ID) {
             $password->showOnClick = false;
         }
         $mainFields->replaceField('Password', $password);
         $mainFields->replaceField('Locale', new DropdownField("Locale", _t('Member.INTERFACELANG', "Interface Language", 'Language of the CMS'), i18n::get_existing_translations()));
         $mainFields->removeByName('RememberLoginToken');
         $mainFields->removeByName('AutoLoginHash');
         $mainFields->removeByName('AutoLoginExpired');
         $mainFields->removeByName('PasswordEncryption');
         $mainFields->removeByName('PasswordExpiry');
         $mainFields->removeByName('LockedOutUntil');
         if (!$self->config()->lock_out_after_incorrect_logins) {
             $mainFields->removeByName('FailedLoginCount');
         }
         $mainFields->removeByName('Salt');
         $mainFields->removeByName('NumVisit');
         $mainFields->makeFieldReadonly('LastVisited');
         $fields->removeByName('Subscriptions');
         // Groups relation will get us into logical conflicts because
         // Members are displayed within  group edit form in SecurityAdmin
         $fields->removeByName('Groups');
         if (Permission::check('EDIT_PERMISSIONS')) {
             $groupsMap = array();
             foreach (Group::get() as $group) {
                 // Listboxfield values are escaped, use ASCII char instead of &raquo;
                 $groupsMap[$group->ID] = $group->getBreadcrumbs(' > ');
             }
             asort($groupsMap);
             $fields->addFieldToTab('Root.Main', ListboxField::create('DirectGroups', singleton('Group')->i18n_plural_name())->setMultiple(true)->setSource($groupsMap)->setAttribute('data-placeholder', _t('Member.ADDGROUP', 'Add group', 'Placeholder text for a dropdown')));
             // Add permission field (readonly to avoid complicated group assignment logic).
             // This should only be available for existing records, as new records start
             // with no permissions until they have a group assignment anyway.
             if ($self->ID) {
                 $permissionsField = new PermissionCheckboxSetField_Readonly('Permissions', false, 'Permission', 'GroupID', $self->getManyManyComponents('Groups'));
                 $fields->findOrMakeTab('Root.Permissions', singleton('Permission')->i18n_plural_name());
                 $fields->addFieldToTab('Root.Permissions', $permissionsField);
             }
         }
         $permissionsTab = $fields->fieldByName("Root")->fieldByName('Permissions');
         if ($permissionsTab) {
             $permissionsTab->addExtraClass('readonly');
         }
         $defaultDateFormat = Zend_Locale_Format::getDateFormat(new Zend_Locale($self->Locale));
         $dateFormatMap = array('MMM d, yyyy' => Zend_Date::now()->toString('MMM d, yyyy'), 'yyyy/MM/dd' => Zend_Date::now()->toString('yyyy/MM/dd'), 'MM/dd/yyyy' => Zend_Date::now()->toString('MM/dd/yyyy'), 'dd/MM/yyyy' => Zend_Date::now()->toString('dd/MM/yyyy'));
         $dateFormatMap[$defaultDateFormat] = Zend_Date::now()->toString($defaultDateFormat) . sprintf(' (%s)', _t('Member.DefaultDateTime', 'default'));
         $mainFields->push($dateFormatField = new MemberDatetimeOptionsetField('DateFormat', $self->fieldLabel('DateFormat'), $dateFormatMap));
         $dateFormatField->setValue($self->DateFormat);
         $defaultTimeFormat = Zend_Locale_Format::getTimeFormat(new Zend_Locale($self->Locale));
         $timeFormatMap = array('h:mm a' => Zend_Date::now()->toString('h:mm a'), 'H:mm' => Zend_Date::now()->toString('H:mm'));
         $timeFormatMap[$defaultTimeFormat] = Zend_Date::now()->toString($defaultTimeFormat) . sprintf(' (%s)', _t('Member.DefaultDateTime', 'default'));
         $mainFields->push($timeFormatField = new MemberDatetimeOptionsetField('TimeFormat', $self->fieldLabel('TimeFormat'), $timeFormatMap));
         $timeFormatField->setValue($self->TimeFormat);
     });
     return parent::getCMSFields();
 }
コード例 #26
0
ファイル: DNEnvironment.php プロジェクト: udomsak/deploynaut
 /**
  * Build a set of multi-select fields for assigning permissions to a pair of group and member many_many relations
  *
  * @param string $groupField Group field name
  * @param string $memberField Member field name
  * @param array $groups List of groups
  * @param array $members List of members
  * @return FieldGroup
  */
 protected function buildPermissionField($groupField, $memberField, $groups, $members)
 {
     return FieldGroup::create(ListboxField::create($groupField, false, $groups)->setMultiple(true)->setAttribute('data-placeholder', 'Groups')->setAttribute('placeholder', 'Groups')->setAttribute('style', 'width: 400px;'), ListboxField::create($memberField, false, $members)->setMultiple(true)->setAttribute('data-placeholder', 'Members')->setAttribute('placeholder', 'Members')->setAttribute('style', 'width: 400px;'));
 }
コード例 #27
0
 /**
  * Caution: Only call on instances, not through a singleton.
  * The "root group" fields will be created through {@link SecurityAdmin->EditForm()}.
  *
  * @return FieldList
  */
 public function getCMSFields()
 {
     Requirements::javascript(FRAMEWORK_DIR . '/javascript/PermissionCheckboxSetField.js');
     $fields = new FieldList(new TabSet("Root", new Tab('Members', _t('SecurityAdmin.MEMBERS', 'Members'), new TextField("Title", $this->fieldLabel('Title')), $parentidfield = DropdownField::create('ParentID', $this->fieldLabel('Parent'), Group::get()->exclude('ID', $this->ID)->map('ID', 'Breadcrumbs'))->setEmptyString(' '), new TextareaField('Description', $this->fieldLabel('Description'))), $permissionsTab = new Tab('Permissions', _t('SecurityAdmin.PERMISSIONS', 'Permissions'), $permissionsField = new PermissionCheckboxSetField('Permissions', false, 'Permission', 'GroupID', $this))));
     $parentidfield->setDescription(_t('Group.GroupReminder', 'If you choose a parent group, this group will take all it\'s roles'));
     // Filter permissions
     // TODO SecurityAdmin coupling, not easy to get to the form fields through GridFieldDetailForm
     $permissionsField->setHiddenPermissions((array) Config::inst()->get('SecurityAdmin', 'hidden_permissions'));
     if ($this->ID) {
         $group = $this;
         $config = GridFieldConfig_RelationEditor::create();
         $config->addComponent(new GridFieldButtonRow('after'));
         $config->addComponents(new GridFieldExportButton('buttons-after-left'));
         $config->addComponents(new GridFieldPrintButton('buttons-after-left'));
         $config->getComponentByType('GridFieldAddExistingAutocompleter')->setResultsFormat('$Title ($Email)')->setSearchFields(array('FirstName', 'Surname', 'Email'));
         $config->getComponentByType('GridFieldDetailForm')->setValidator(new Member_Validator())->setItemEditFormCallback(function ($form, $component) use($group) {
             $record = $form->getRecord();
             $groupsField = $form->Fields()->dataFieldByName('DirectGroups');
             if ($groupsField) {
                 // If new records are created in a group context,
                 // set this group by default.
                 if ($record && !$record->ID) {
                     $groupsField->setValue($group->ID);
                 } elseif ($record && $record->ID) {
                     // TODO Mark disabled once chosen.js supports it
                     // $groupsField->setDisabledItems(array($group->ID));
                     $form->Fields()->replaceField('DirectGroups', $groupsField->performReadonlyTransformation());
                 }
             }
         });
         $memberList = GridField::create('Members', false, $this->DirectMembers(), $config)->addExtraClass('members_grid');
         // @todo Implement permission checking on GridField
         //$memberList->setPermissions(array('edit', 'delete', 'export', 'add', 'inlineadd'));
         $fields->addFieldToTab('Root.Members', $memberList);
     }
     // Only add a dropdown for HTML editor configurations if more than one is available.
     // Otherwise Member->getHtmlEditorConfigForCMS() will default to the 'cms' configuration.
     $editorConfigMap = HtmlEditorConfig::get_available_configs_map();
     if (count($editorConfigMap) > 1) {
         $fields->addFieldToTab('Root.Permissions', new DropdownField('HtmlEditorConfig', 'HTML Editor Configuration', $editorConfigMap), 'Permissions');
     }
     if (!Permission::check('EDIT_PERMISSIONS')) {
         $fields->removeFieldFromTab('Root', 'Permissions');
     }
     // Only show the "Roles" tab if permissions are granted to edit them,
     // and at least one role exists
     if (Permission::check('APPLY_ROLES') && DataObject::get('PermissionRole')) {
         $fields->findOrMakeTab('Root.Roles', _t('SecurityAdmin.ROLES', 'Roles'));
         $fields->addFieldToTab('Root.Roles', new LiteralField("", "<p>" . _t('SecurityAdmin.ROLESDESCRIPTION', "Roles are predefined sets of permissions, and can be assigned to groups.<br />" . "They are inherited from parent groups if required.") . '<br />' . sprintf('<a href="%s" class="add-role">%s</a>', singleton('SecurityAdmin')->Link('show/root#Root_Roles'), _t('Group.RolesAddEditLink', 'Manage roles')) . "</p>"));
         // Add roles (and disable all checkboxes for inherited roles)
         $allRoles = PermissionRole::get();
         if (!Permission::check('ADMIN')) {
             $allRoles = $allRoles->filter("OnlyAdminCanApply", 0);
         }
         if ($this->ID) {
             $groupRoles = $this->Roles();
             $inheritedRoles = new ArrayList();
             $ancestors = $this->getAncestors();
             foreach ($ancestors as $ancestor) {
                 $ancestorRoles = $ancestor->Roles();
                 if ($ancestorRoles) {
                     $inheritedRoles->merge($ancestorRoles);
                 }
             }
             $groupRoleIDs = $groupRoles->column('ID') + $inheritedRoles->column('ID');
             $inheritedRoleIDs = $inheritedRoles->column('ID');
         } else {
             $groupRoleIDs = array();
             $inheritedRoleIDs = array();
         }
         $rolesField = ListboxField::create('Roles', false, $allRoles->map()->toArray())->setDefaultItems($groupRoleIDs)->setAttribute('data-placeholder', _t('Group.AddRole', 'Add a role for this group'))->setDisabledItems($inheritedRoleIDs);
         if (!$allRoles->Count()) {
             $rolesField->setAttribute('data-placeholder', _t('Group.NoRoles', 'No roles found'));
         }
         $fields->addFieldToTab('Root.Roles', $rolesField);
     }
     $fields->push($idField = new HiddenField("ID"));
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
コード例 #28
0
ファイル: DNProject.php プロジェクト: ss23/deploynaut
 /**
  *
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $environments = $fields->dataFieldByName("Environments");
     $fields->fieldByName("Root")->removeByName("Viewers");
     $fields->fieldByName("Root")->removeByName("Environments");
     $fields->fieldByName("Root")->removeByName("LocalCVSPath");
     $fields->dataFieldByName('DiskQuotaMB')->setDescription('This is the maximum amount of disk space (in megabytes) that all environments within this project can use for stored snapshots');
     $fields->fieldByName('Root.Main.Name')->setTitle('Project name')->setDescription('Changing the name will <strong>reset</strong> the deploy configuration and avoid using non alphanumeric characters');
     $fields->fieldByName('Root.Main.CVSPath')->setTitle('Git repository')->setDescription('E.g. git@github.com:silverstripe/silverstripe-installer.git');
     $workspaceField = new ReadonlyField('LocalWorkspace', 'Git workspace', $this->getLocalCVSPath());
     $workspaceField->setDescription('This is where the GIT repository are located on this server');
     $fields->insertAfter($workspaceField, 'CVSPath');
     $readAccessGroups = ListboxField::create('Viewers', 'Project viewers', Group::get()->map()->toArray())->setMultiple(true)->setDescription('These groups can view the project in the front-end.');
     $fields->addFieldToTab("Root.Main", $readAccessGroups);
     $this->setCreateProjectFolderField($fields);
     $this->setEnvironmentFields($fields, $environments);
     return $fields;
 }
コード例 #29
0
 /**
  * {@inheritdoc}
  */
 public function getCMSFields()
 {
     Requirements::css(BLOGGER_DIR . '/css/cms.css');
     Requirements::javascript(BLOGGER_DIR . '/js/cms.js');
     $self =& $this;
     $this->beforeUpdateCMSFields(function ($fields) use($self) {
         $uploadField = UploadField::create('FeaturedImage', _t('BlogPost.FeaturedImage', 'Featured Image'));
         $uploadField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif'));
         /**
          * @var FieldList $fields
          */
         $fields->insertAfter($uploadField, 'Content');
         $summary = HtmlEditorField::create('Summary', false);
         $summary->setRows(5);
         $summary->setDescription(_t('BlogPost.SUMMARY_DESCRIPTION', 'If no summary is specified the first 30 words will be used.'));
         $summaryHolder = ToggleCompositeField::create('CustomSummary', _t('BlogPost.CUSTOMSUMMARY', 'Add A Custom Summary'), array($summary));
         $summaryHolder->setHeadingLevel(4);
         $summaryHolder->addExtraClass('custom-summary');
         $fields->insertAfter($summaryHolder, 'FeaturedImage');
         $fields->push(HiddenField::create('MenuTitle'));
         $urlSegment = $fields->dataFieldByName('URLSegment');
         $urlSegment->setURLPrefix($self->Parent()->RelativeLink());
         $fields->removeFieldsFromTab('Root.Main', array('MenuTitle', 'URLSegment'));
         $authorField = ListboxField::create('Authors', _t('BlogPost.Authors', 'Authors'), $self->getCandidateAuthors()->map()->toArray())->setMultiple(true);
         $authorNames = TextField::create('AuthorNames', _t('BlogPost.AdditionalCredits', 'Additional Credits'), null, 1024)->setDescription(_t('BlogPost.AdditionalCredits_Description', 'If some authors of this post don\'t have CMS access, enter their name(s) here. You can separate multiple names with a comma.'));
         if (!$self->canEditAuthors()) {
             $authorField = $authorField->performDisabledTransformation();
             $authorNames = $authorNames->performDisabledTransformation();
         }
         $publishDate = DatetimeField::create('PublishDate', _t('BlogPost.PublishDate', 'Publish Date'));
         $publishDate->getDateField()->setConfig('showcalendar', true);
         if (!$self->PublishDate) {
             $publishDate->setDescription(_t('BlogPost.PublishDate_Description', 'Will be set to "now" if published without a value.'));
         }
         // Get categories and tags
         $parent = $self->Parent();
         $categories = $parent instanceof Blog ? $parent->Categories() : BlogCategory::get();
         $tags = $parent instanceof Blog ? $parent->Tags() : BlogTag::get();
         $options = BlogAdminSidebar::create($publishDate, $urlSegment, TagField::create('Categories', _t('BlogPost.Categories', 'Categories'), $categories, $self->Categories())->setCanCreate($self->canCreateCategories())->setShouldLazyLoad(true), TagField::create('Tags', _t('BlogPost.Tags', 'Tags'), $tags, $self->Tags())->setCanCreate($self->canCreateTags())->setShouldLazyLoad(true), $authorField, $authorNames)->setTitle('Post Options');
         $options->setName('blog-admin-sidebar');
         $fields->insertBefore($options, 'Root');
     });
     $fields = parent::getCMSFields();
     $fields->fieldByName('Root')->setTemplate('TabSet_holder');
     return $fields;
 }
コード例 #30
0
ファイル: Blog.php プロジェクト: unculture/silverstripe-blog
    /**
     * {@inheritdoc}
     */
    public function getSettingsFields()
    {
        $fields = parent::getSettingsFields();
        $fields->addFieldToTab('Root.Settings', NumericField::create('PostsPerPage', _t('Blog.PostsPerPage', 'Posts Per Page')));
        $members = $this->getCandidateUsers()->map()->toArray();
        $editorField = ListboxField::create('Editors', 'Editors', $members)->setMultiple(true)->setRightTitle('<a class="toggle-description">help</a>')->setDescription('
				An editor has control over specific Blogs, and all posts included within it. Short of being able to assign other editors to a blog, they are able to handle most changes to their assigned blog.<br />
				<br />
				Editors have these permissions:<br />
				<br />
				Update or publish any BlogPost in their Blog<br />
				Update or publish their Blog<br />
				Assign/unassign writers to their Blog<br />
				Assign/unassign contributors to their Blog<br />
				Assign/unassign any member as an author of a particular BlogPost
			');
        if (!$this->canEditEditors()) {
            $editorField = $editorField->performDisabledTransformation();
        }
        $writerField = ListboxField::create('Writers', 'Writers', $members)->setMultiple(true)->setRightTitle('<a class="toggle-description">help</a>')->setDescription('
				A writer has full control over creating, editing and publishing BlogPosts they have authored or have been assigned to. Writers are unable to edit BlogPosts to which they are not assigned.<br />
				<br />
				Writers have these permissions:<br />
				<br />
				Update or publish any BlogPost they have authored or have been assigned to<br />
				Assign/unassign any member as an author of a particular BlogPost they have authored or have been assigned to
			');
        if (!$this->canEditWriters()) {
            $writerField = $writerField->performDisabledTransformation();
        }
        $contributorField = ListboxField::create('Contributors', 'Contributors', $members)->setMultiple(true)->setRightTitle('<a class="toggle-description">help</a>')->setDescription('
				Contributors have the ability to create or edit BlogPosts, but are unable to publish without authorisation of an editor. They are also unable to assign other contributing authors to any of their BlogPosts.<br />
				<br />
				Contributors have these permissions:<br />
				<br />
				Update any BlogPost they have authored or have been assigned to
			');
        if (!$this->canEditContributors()) {
            $contributorField = $contributorField->performDisabledTransformation();
        }
        $fields->addFieldsToTab('Root.Users', array($editorField, $writerField, $contributorField));
        return $fields;
    }