function getCMSFields() { $fields = parent::getCMSFields(); $tf1 = new TagField('TestTagString', "Single column tags (try 'one', 'two', 'three', 'four')", 'TestTag'); $fields->addFieldToTab('Root.Content.Main', $tf1); $tf2 = new TagField('TestTags', "Relation tags (try 'one', 'two', 'three', 'four')", null, 'TestTag'); $fields->addFieldToTab('Root.Content.Main', $tf2); $tf3 = new TagField('FixedTags', "Fixed tags (try 'PHP', 'Ruby', 'Python')", null, 'TestTag'); $tf3->setCustomTags(array('PHP', 'Ruby', 'Python')); $fields->addFieldToTab('Root.Content.Main', $tf3); return $fields; }
/** * Edit the cms fields in the CMS * * @return FieldList */ public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab('Root.Main', DateField::create('DatePublished', 'Enter a published date')->setConfig('dateformat', 'dd-MM-yyyy')->setConfig('dmyseparator', ' ')->setConfig('showcalendar', true)); $fields->addFieldToTab('Root.Main', $uploadField = new UploadField($name = 'ArticleSummaryImage', $title = 'Upload an article summary image')); $fields->addFieldToTab('Root.Main', new HTMLEditorField('Summary', 'Summary')); $tagfield = TagField::create('NewsTags', 'News Tags', NewsTag::get(), $this->NewsTags())->setShouldLazyLoad(true)->setCanCreate(true); $fields->addFieldToTab('Root.Main', $tagfield); return $fields; }
public function getFrontendFields() { $fields = $this->scaffoldFormFields(array( 'restrictFields' => array( 'FirstName', 'Surname', 'Email', 'Introduction', 'Region', ), 'fieldClasses' => array( 'Email' => 'EmailField', ) ) ); $tagField = new TagField('Skills', 'Skills'); $tagField->setTagTopicClass('Developer'); $fields->push($tagField); return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab("Root.Main", new TextField("Description", "Description", "", 100)); $conf = GridFieldConfig_RelationEditor::create(10); $conf->addComponent($sortable = new GridFieldSortableRows('SortID')); //Append new GalleryItems to the top $sortable->setAppendToTop(true); $field = TagField::create('GalleryTags', 'Gallery Tags', GalleryTag::get(), $this->GalleryTags())->setShouldLazyLoad(true)->setCanCreate(true); // new tag DataObjects can be created; $fields->addFieldToTab('Root.Tags', $field); $fields->addFieldToTab('Root.MyAlbum', new GridField('GalleryItems', 'My Album', $this->GalleryItems(), $conf)); return $fields; }
public function updateCMSFields(\FieldList $fields) { parent::updateCMSFields($fields); // Add Categories & Tags fields //if($this->owner->Parent()->getFilterableArchiveConfigValue('categories_active')){ if (Config::inst()->get($this->owner->Parent()->className, 'categories_active')) { // $categoriesField = ListboxField::create( // "Categories", // _t("FilterableArchive.Categories", "Categories"), // $this->owner->Parent()->Categories()->map()->toArray() // )->setMultiple(true); // Use tagfield instead (allows inline creation) //$availableCats = FilterCategory::get()->filter('HolderPageID',$this->owner->ParentID); $availableCats = $this->owner->Parent()->Categories(); $categoriesField = new TagField('Categories', _t("FilterableArchive.Categories", "Categories"), $availableCats, $this->owner->Categories()); //$categoriesField->setShouldLazyLoad(true); // tags should be lazy loaded (nope, gets all instead of just the parent's cats/tags) $categoriesField->setCanCreate(true); // new tag DataObjects can be created (@TODO check privileges) $fields->insertbefore($categoriesField, "Content"); } //if($this->owner->Parent()->getFilterableArchiveConfigValue('tags_active')){ if (Config::inst()->get($this->owner->Parent()->className, 'tags_active')) { // $tagsField = ListboxField::create( // "Tags", // _t("BlogPost.Tags", "Tags"), // $this->owner->Parent()->Tags()->map()->toArray() // )->setMultiple(true); // Use tagfield instead (allows inline creation) //$availableTags = FilterTag::get()->filter('HolderPageID',$this->owner->ParentID); $availableTags = $this->owner->Parent()->Tags(); $tagsField = new TagField('Tags', _t("FilterableArchive.Tags", "Tags"), $availableTags, $this->owner->Tags()); //$tagsField->setShouldLazyLoad(true); // tags should be lazy loaded (nope, gets all instead of just the parent's cats/tags) $tagsField->setCanCreate(true); // new tag DataObjects can be created (@TODO check privileges) $fields->insertAfter($tagsField, "Categories"); } }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName("Tags"); $fields->removeByName("Notes"); $tag_field = TagField::create('Tags', null, ContactTag::get(), $this->Tags())->setRightTitle(_t("Contacts.TagDescription", "List of tags related to this contact, seperated by a comma."))->setShouldLazyLoad(true); if ($this->ID) { $gridField = GridField::create('Notes', 'Notes', $this->Notes()); $config = GridFieldConfig_RelationEditor::create(); $gridField->setConfig($config); $fields->addFieldToTab("Root.Notes", $gridField); } $fields->addFieldToTab("Root.Main", $tag_field); return $fields; }
/** * {@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; }
function testItIgnoresNewTagsIfCannotCreate() { $record = new TagFieldTestBlogPost(); $record->write(); $tag = TagFieldTestBlogTag::get()->filter('Title', 'Tag1')->first(); $field = new TagField('Tags', '', new DataList('TagFieldTestBlogTag'), array($tag->ID, 'Tag3')); $field->setCanCreate(false); $field->saveInto($record); /** * @var TagFieldTestBlogPost $record */ $record = DataObject::get_by_id('TagFieldTestBlogPost', $record->ID); $this->compareExpectedAndActualTags(array('Tag1'), $record); }
/** * A simple form for creating blog entries */ function BlogEntryForm() { if (!Permission::check('BLOGMANAGEMENT')) { return Security::permissionFailure(); } $id = 0; if ($this->request->latestParam('ID')) { $id = (int) $this->request->latestParam('ID'); } $codeparser = new BBCodeParser(); $membername = Member::currentMember() ? Member::currentMember()->getName() : ""; if (BlogEntry::$allow_wysiwyg_editing) { $contentfield = new HtmlEditorField("BlogPost", _t("BlogEntry.CN")); } else { $contentfield = new CompositeField(new LiteralField("BBCodeHelper", "<a id=\"BBCodeHint\" target='new'>" . _t("BlogEntry.BBH") . "</a><div class='clear'><!-- --></div>"), new TextareaField("BlogPost", _t("BlogEntry.CN"), 20), new LiteralField("BBCodeTags", "<div id=\"BBTagsHolder\">" . $codeparser->useable_tagsHTML() . "</div>")); } if (class_exists('TagField')) { $tagfield = new TagField('Tags', null, null, 'BlogEntry'); $tagfield->setSeparator(', '); } else { $tagfield = new TextField('Tags'); } $field = 'TextField'; if (!$this->AllowCustomAuthors && !Permission::check('ADMIN')) { $field = 'ReadonlyField'; } $fields = new FieldSet(new HiddenField("ID", "ID"), new TextField("Title", _t('BlogHolder.SJ', "Subject")), new $field("Author", _t('BlogEntry.AU'), $membername), $contentfield, $tagfield, new LiteralField("Tagsnote", " <label id='tagsnote'>" . _t('BlogHolder.TE', "For example: sport, personal, science fiction") . "<br/>" . _t('BlogHolder.SPUC', "Please separate tags using commas.") . "</label>")); $submitAction = new FormAction('postblog', _t('BlogHolder.POST', 'Post blog entry')); $actions = new FieldSet($submitAction); $validator = new RequiredFields('Title', 'BlogPost'); $form = new Form($this, 'BlogEntryForm', $fields, $actions, $validator); if ($id != 0) { $entry = DataObject::get_by_id('BlogEntry', $id); if ($entry->IsOwner()) { $form->loadDataFrom($entry); $form->datafieldByName('BlogPost')->setValue($entry->Content); } } else { $form->loadDataFrom(array("Author" => Cookie::get("BlogHolder_Name"))); } return $form; }
/** * A simple form for creating blog entries */ function BlogEntryForm() { if(!Permission::check('BLOGMANAGEMENT')) return Security::permissionFailure(); Requirements::javascript('jsparty/behaviour.js'); Requirements::javascript('jsparty/prototype.js'); Requirements::javascript('jsparty/scriptaculous/effects.js'); Requirements::javascript('cms/javascript/PageCommentInterface.js'); Requirements::javascript('blog/javascript/bbcodehelp.js'); $id = 0; if(Director::urlParam('ID')) { $id = (int) Director::urlParam('ID'); } $codeparser = new BBCodeParser(); $membername = Member::currentMember() ? Member::currentMember()->getName() : ""; if(BlogEntry::$allow_wysiwyg_editing) { $contentfield = new HtmlEditorField("BlogPost", _t("BlogEntry.CN")); } else { $contentfield = new CompositeField( new LiteralField("BBCodeHelper","<a id=\"BBCodeHint\" target='new'>"._t("BlogEntry.BBH")."</a><div class='clear'><!-- --></div>" ), new TextareaField("BlogPost", _t("BlogEntry.CN"),20), // This is called BlogPost as the id #Content is generally used already new LiteralField("BBCodeTags","<div id=\"BBTagsHolder\">".$codeparser->useable_tagsHTML()."</div>") ); } if(class_exists('TagField')) { $tagfield = new TagField('Tags', null, null, 'BlogEntry'); $tagfield->setSeparator(', '); } else { $tagfield = new TextField('Tags'); } $fields = new FieldSet( new HiddenField("ID", "ID"), new TextField("Title",_t('BlogHolder.SJ', "Subject")), new TextField("Author",_t('BlogEntry.AU'),$membername), $contentfield, $tagfield, new LiteralField("Tagsnote"," <label id='tagsnote'>"._t('BlogHolder.TE', "For example: sport, personal, science fiction")."<br/>" . _t('BlogHolder.SPUC', "Please separate tags using commas.")."</label>") ); $submitAction = new FormAction('postblog', _t('BlogHolder.POST', 'Post blog entry')); $actions = new FieldSet($submitAction); $validator = new RequiredFields('Title','Content'); $form = new Form($this, 'BlogEntryForm',$fields, $actions,$validator); if($id != 0) { $entry = DataObject::get_by_id('BlogEntry', $id); $form->loadNonBlankDataFrom($entry); $form->datafieldByName('BlogPost')->setValue($entry->Content); } else { $form->loadNonBlankDataFrom(array("Author" => Cookie::get("BlogHolder_Name"))); } return $form; }
/** * * @return FieldSet */ public function updateCMSFields(Fieldset $fields) { $tagField = new TagField('Tags', null, null, 'Page'); $tagField->setSeparator(','); $fields->addFieldToTab('Root.Content.Tags', $tagField); }