public static function recordTags($phrase, $model, $obj) { $tags = TagTools::splitPhrase($phrase); foreach ($tags as $settag) { $tag = new Tag(); if ($model == "etime") { $modelTag = new EtimeTag(); } else { $modelTag = new EventTag(); } $tag->setTag($settag); $c = new Criteria(); $c->add(TagPeer::NORMALIZED_TAG, $tag->getNormalizedTag()); $tag_exists = TagPeer::doSelectOne($c); if (!$tag_exists) { $tag->save(); } else { $tag = $tag_exists; } if ($model == "etime") { $modelTag->setEtime($obj); } else { $modelTag->setEvent($obj); } $modelTag->setTag($tag); $modelTag->save(); } return true; }
/** * 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')); $location = new TextField('Location', 'Location'); $fields->addFieldToTab('Root.Main', $location); $tagfield = TagField::create('EventTags', 'Event Tags', EventTag::get(), $this->EventTags())->setShouldLazyLoad(true)->setCanCreate(true); $fields->addFieldToTab('Root.Main', $tagfield); return $fields; }
public function addEventTag(EventTag $l) { $this->collEventTags[] = $l; $l->setEvent($this); }