function test_should_store_zero_strings_as_intergers()
 {
     $Tag = new Tag(array('name' => 'Ticket #21'));
     $this->assertTrue($Tag->save());
     $this->assertEqual($Tag->get('score'), 100);
     $Tag->setAttributes(array('score' => '0'));
     $this->assertTrue($Tag->save());
     $Tag =& $Tag->find($Tag->id);
     $this->assertIdentical($Tag->get('score'), 0);
 }
 public function allPagesToCache()
 {
     // Get each page type to define its sub-urls
     $urls = array();
     // memory intensive depending on number of pages
     $pages = SiteTree::get()->where("ClassName != 'BlogEntry'");
     //remove Blog pages from cache due to Form SecurityID issue
     foreach ($pages as $page) {
         array_push($urls, $page->Link());
         if ($page->ClassName == 'ProjectPage') {
             //add ajax pages for each projectpage
             array_push($urls, $page->Link() . 'ajax');
         }
     }
     //add tag pages
     $tags = Tag::get()->filter(array('HasTagPage' => 1));
     foreach ($tags as $tag) {
         array_push($urls, '/tag/' . $tag->Slug);
     }
     //add location pages
     $locations = Location::get();
     foreach ($locations as $location) {
         array_push($urls, '/location/' . $location->Slug);
     }
     return $urls;
 }
 public function getCMSFields()
 {
     $fields = FieldList::create(TabSet::create('Root'))->text('Title')->text('Code', 'Code', '', 5)->textarea('Description')->numeric('SessionCount', 'Number of sessions')->numeric('AlternateCount', 'Number of alternates')->checkbox('VotingVisible', "This category is visible to voters")->checkbox('ChairVisible', "This category is visible to track chairs")->hidden('SummitID', 'SummitID');
     if ($this->ID > 0) {
         //tags
         $config = new GridFieldConfig_RelationEditor(100);
         $config->removeComponentsByType(new GridFieldDataColumns());
         $config->removeComponentsByType(new GridFieldDetailForm());
         $completer = $config->getComponentByType('GridFieldAddExistingAutocompleter');
         $completer->setResultsFormat('$Tag');
         $completer->setSearchFields(array('Tag'));
         $completer->setSearchList(Tag::get());
         $editconf = new GridFieldDetailForm();
         $editconf->setFields(FieldList::create(TextField::create('Tag', 'Tag'), DropdownField::create('ManyMany[Group]', 'Group', array('topics' => 'Topics', 'speaker' => 'Speaker', 'openstack projects mentioned' => 'OpenStack Projects Mentioned'))));
         $summaryfieldsconf = new GridFieldDataColumns();
         $summaryfieldsconf->setDisplayFields(array('Tag' => 'Tag', 'Group' => 'Group'));
         $config->addComponent($editconf);
         $config->addComponent($summaryfieldsconf, new GridFieldFilterHeader());
         $tags = new GridField('AllowedTags', 'Tags', $this->AllowedTags(), $config);
         $fields->addFieldToTab('Root.Main', $tags);
         // extra questions for call-for-presentations
         $config = new GridFieldConfig_RelationEditor();
         $config->removeComponentsByType('GridFieldAddNewButton');
         $multi_class_selector = new GridFieldAddNewMultiClass();
         $multi_class_selector->setClasses(array('TrackTextBoxQuestionTemplate' => 'TextBox', 'TrackCheckBoxQuestionTemplate' => 'CheckBox', 'TrackCheckBoxListQuestionTemplate' => 'CheckBoxList', 'TrackRadioButtonListQuestionTemplate' => 'RadioButtonList', 'TrackDropDownQuestionTemplate' => 'ComboBox', 'TrackLiteralContentQuestionTemplate' => 'Literal'));
         $config->addComponent($multi_class_selector);
         $questions = new GridField('ExtraQuestions', 'Track Specific Questions', $this->ExtraQuestions(), $config);
         $fields->addFieldToTab('Root.Main', $questions);
     }
     return $fields;
 }
示例#4
0
 protected function __str__()
 {
     if ($this->none()) {
         return "";
     }
     $result = new Tag("content");
     foreach ($this->access_members() as $name => $value) {
         if (!empty($value)) {
             switch ($name) {
                 case "type":
                 case "mode":
                     $result->param($name, $value);
                     break;
                 case "lang":
                 case "base":
                     $result->param("xml:" . $name, $value);
                     break;
                 case "value":
                     $result->value($value);
                     break;
             }
         }
     }
     return $result->get();
 }
示例#5
0
 public function test_get_tag()
 {
     $this->tag->insert();
     $t = Tag::get($this->text);
     $this->assertEquals($t->tag_text, $this->tag->tag_text);
     $t->delete();
 }
示例#6
0
文件: Mixi.php 项目: hisaboh/w2t
 public function post_diary($title, $summary)
 {
     $tag = new Tag("entry");
     $tag->param("xmlns", "http://www.w3.org/2007/app");
     $tag->add(new Tag("title", $title));
     $tag->add(new Tag("summary", $summary));
     $this->raw($tag->get("utf-8"));
     $this->do_post("http://mixi.jp/atom/diary/member_id=" . $this->member_id);
 }
示例#7
0
 protected function getPresentationFields()
 {
     $categorySource = Summit::get_active()->Categories()->map('ID', 'FormattedTitleAndDescription')->toArray();
     $categorySource['other'] = '<h4 class="category-label">Other topic...</h4>';
     $fields = FieldList::create()->text('Title', 'Proposed Presentation Title')->configure()->setAttribute('autofocus', 'TRUE')->end()->dropdown('Level', 'Please select the level of your presentation content')->configure()->setEmptyString('-- Select one --')->setSource(Presentation::create()->dbObject('Level')->enumValues())->end()->tinyMCEEditor('Description', 'Abstract')->configure()->setRows(20)->end()->literal('ShortDescriptionHelp', '<hr/><p>YouTube and other services limit the length of your presentation\'s description. Please provide a shorter, YouTube-friendly summary below.</p>')->literal('ShortDescriptionWordCount', '<p id="word-count"></p>')->tinyMCEEditor('ShortDescription', 'Short Description (450 Word Max)')->configure()->setRows(7)->setWordCount(450)->end()->literal('HR', '<hr/>')->optionset('CategoryID', 'What is the general topic of the presentation?')->configure()->setSource($categorySource)->end()->text('OtherTopic', 'Other topic (if one above does not match)')->configure()->displayIf('CategoryID')->isEqualTo('other')->end()->end()->literal('TagHelp', '<p>You can optionally add tags help attendees find presentations that interest them. Examples: <i>nova, ubuntu, ldap.</i></p>')->bootstrapTag('Tags', 'Presentation Tags (Optional)')->configure()->setLabelField('Tag')->setSource(Tag::get())->setPrefetch(Tag::get()->leftJoin('Presentation_Tags', 'TagID = Tag.ID')->sort('COUNT(Tag.ID)', 'DESC')->limit(10)->alterDataQuery(function ($query) {
         $query->groupby('Tag.ID');
     }))->setFreeInput(true)->end();
     return $fields;
 }
 public function getCMSFields()
 {
     $fields = FieldList::create(TabSet::create('Root'));
     if ($this->SchedID) {
         return $fields->tab('SchedData')->readonly('Title')->readonly('Description')->readonly('EventStart')->readonly('EventEnd')->readonly('EventKey')->readonly('EventType')->readonly('Goers')->readonly('SchedID')->readonly('InviteOnly')->readonly('Seats')->readonly('Venue')->readonly('VenueID')->tab('EditableData')->checkbox('DisplayOnSite')->text('YouTubeID')->dropdown('CategoryID', 'Category', PresentationCategory::get()->map('ID', 'Title'))->listbox('PresentationSpeakers')->configure()->setSource(PresentationSpeaker::get()->map('ID', 'Title')->toArray())->setMultiple(true)->end()->imageUpload('VideoThumbnail')->upload('RelatedMedia')->tag('Tags', 'Tags', Tag::get(), $this->Tags());
     } else {
         return $fields->text('Title')->dropdown('CategoryID', 'Category', PresentationCategory::get()->map('ID', 'Title'))->tag('Tags', 'Tags', Tag::get(), $this->Tags())->date('EventStart')->configure()->setConfig('showcalendar', true)->end()->date('EventEnd')->configure()->setConfig('showcalendar', true)->end()->htmlEditor('Description')->checkbox('InviteOnly')->numeric('Seats')->text('Venue')->text('YouTubeID')->imageUpload('VideoThumbnail')->upload('RelatedMedia')->checkbox('DisplayOnSite');
     }
 }
示例#9
0
 /**
  * @param string[] $tags
  * @return void
  */
 public function registerTags($tags)
 {
     $tags = explode(',', $tags);
     foreach ($tags as $tag_name) {
         $tag = Tag::get("Tag", "Tag = '" . $tag_name . "'")->first();
         if (!$tag) {
             $tag = new Tag();
             $tag->Tag = $tag_name;
             $tag->write();
         }
         $this->addTag($tag);
     }
 }
示例#10
0
文件: RssSource.php 项目: hisaboh/w2t
 protected function __str__()
 {
     $result = new Tag("source");
     foreach ($this->access_members() as $name => $value) {
         if (!empty($value)) {
             switch ($name) {
                 case "url":
                 case "value":
                     $result->param($name, $value);
                     break;
             }
         }
     }
     return $result->get();
 }
示例#11
0
	public function new_recipe() {
    // Get data
    $tag = new Tag();
    $data['page_title'] = "- Create a Recipe";
    $data['tags'] = $tag->get()->all;

    // Header
    $this->load->view("header", $data);

    // Body of page
    $this->load->view('recipes/new_recipe');

    // Footer
    $this->load->view('footer');
  }
 public function saveInto(DataObjectInterface $record)
 {
     if ($this->name) {
         $tags = explode(',', $this->dataValue());
         if (!$record instanceof SummitEvent) {
             return;
         }
         $record->Tags()->removeAll();
         foreach ($tags as $t) {
             $tag = Tag::get()->filter('Tag', $t)->first();
             if (is_null($tag)) {
                 $tag = Tag::create(array('Tag' => $t));
                 $tag->write();
             }
             $record->Tags()->add($tag);
         }
     }
 }
示例#13
0
文件: AtomLink.php 项目: hisaboh/w2t
 protected function __str__()
 {
     if ($this->none()) {
         return "";
     }
     $result = new Tag("link");
     foreach ($this->access_members() as $name => $value) {
         if (!empty($value)) {
             switch ($name) {
                 case "href":
                 case "rel":
                 case "type":
                     $result->param($name, $value);
                     break;
             }
         }
     }
     return $result->get();
 }
示例#14
0
 protected function __str__()
 {
     if ($this->none()) {
         return "";
     }
     $result = new Tag("author");
     foreach ($this->access_members() as $name => $value) {
         if (!empty($value)) {
             switch ($name) {
                 case "name":
                 case "url":
                 case "email":
                     $result->add(new Tag($name, $value));
                     $bool = true;
                     break;
             }
         }
     }
     return $result->get();
 }
 /**
  * Setup the list of records to show.
  * @param type $params array of filter-rules.
  * @param type $sort
  * @param type $limit
  * @return \ArrayList with the records.
  */
 public function sourceRecords($params, $sort, $limit)
 {
     if ($sort) {
         $parts = explode(' ', $sort);
         $field = $parts[0];
         $direction = $parts[1];
     }
     $where = null;
     if (isset($params['Title']) && $params['Title'] != '') {
         $where = 'Title LIKE \'%' . $params['Title'] . '%\'';
     }
     $ret = Tag::get()->where($where);
     $returnSet = new ArrayList();
     if ($ret) {
         foreach ($ret as $record) {
             $record->Itemcount = $record->News()->count();
             $returnSet->push($record);
         }
     }
     return $returnSet;
 }
示例#16
0
文件: RssItem.php 项目: hisaboh/w2t
 protected function __str__()
 {
     $result = new Tag("item");
     foreach ($this->access_members() as $name => $value) {
         if (!empty($value)) {
             switch ($name) {
                 case "title":
                 case "link":
                 case "description":
                 case "author":
                 case "category":
                 case "comments":
                 case "guid":
                     $result->add(new Tag($name, $value));
                     break;
                 case "pubDate":
                     $result->add(new Tag($name, $this->formatDate($value)));
                     break;
                 default:
                     if (is_array($this->{$name})) {
                         foreach ($this->{$name} as $o) {
                             $channel->add($o);
                         }
                         break;
                     } else {
                         if (is_object($this->{$name})) {
                             $channel->add($value);
                             break;
                         } else {
                             $channel->add(new Tag($name, $value));
                             break;
                         }
                     }
             }
         }
     }
     return $result->get();
 }
 /**
  * @todo Make this language-specific
  * @return Tag All tags in a list.
  */
 public function allTags()
 {
     return Tag::get();
 }
 public function updateCMSFields(FieldList $f)
 {
     //clear all fields
     $oldFields = $f->toArray();
     foreach ($oldFields as $field) {
         $f->remove($field);
     }
     $_REQUEST['SummitID'] = $this->owner->ID;
     $f->add($rootTab = new TabSet("Root", $tabMain = new Tab('Main')));
     $summit_time_zone = null;
     if ($this->owner->TimeZone) {
         $time_zone_list = timezone_identifiers_list();
         $summit_time_zone = $time_zone_list[$this->owner->TimeZone];
     }
     if ($this->owner->RandomVotingLists()->exists()) {
         $f->addFieldToTab('Root.Main', HeaderField::create('The presentations in this summit have been randomised for voting', 4));
     }
     $f->addFieldToTab('Root.Main', new TextField('Title', 'Title'));
     $f->addFieldToTab('Root.Main', $link = new TextField('Link', 'Summit Page Link'));
     $link->setDescription('The link to the site page for this summit. Eg: <em>/summit/vancouver-2015/</em>');
     $f->addFieldToTab('Root.Main', new CheckboxField('Active', 'This is the active summit'));
     $f->addFieldToTab('Root.Main', $date_label = new TextField('DateLabel', 'Date label'));
     $date_label->setDescription('A readable piece of text representing the date, e.g. <em>May 12-20, 2015</em> or <em>December 2016</em>');
     $f->addFieldToTab('Root.Main', $registration_link = new TextField('RegistrationLink', 'Registration Link'));
     $registration_link->setDescription('Link to the site where tickets can be purchased.');
     $f->addFieldsToTab('Root.Dates', $ddl_timezone = new DropdownField('TimeZone', 'Time Zone', DateTimeZone::listIdentifiers()));
     $ddl_timezone->setEmptyString('-- Select a Timezone --');
     if ($summit_time_zone) {
         $f->addFieldToTab('Root.Dates', new HeaderField("All dates below are in <span style='color:red;'>{$summit_time_zone}</span> time."));
     } else {
         $f->addFieldToTab('Root.Dates', new HeaderField("All dates below in the timezone of the summit's venue."));
     }
     $f->addFieldToTab('Root.Dates', $date = new DatetimeField('SummitBeginDate', "When does the summit begin?"));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->getDateField()->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Dates', $date = new DatetimeField('SummitEndDate', "When does the summit end?"));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->getDateField()->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Dates', $date = new DatetimeField('StartShowingVenuesDate', "When do you begin showing venues?"));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->getDateField()->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Dates', $date = new DatetimeField('SubmissionBeginDate', "When do submissions begin?"));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->getDateField()->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Dates', $date = new DatetimeField('SubmissionEndDate', "When do submissions end?"));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->getDateField()->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Dates', $date = new DatetimeField('VotingBeginDate', "When does voting begin?"));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->getDateField()->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Dates', $date = new DatetimeField('VotingEndDate', "When does voting end?"));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->getDateField()->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Dates', $date = new DatetimeField('SelectionBeginDate', "When do selections begin?"));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->getDateField()->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Dates', $date = new DatetimeField('SelectionEndDate', "When do selections end?"));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->getDateField()->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Dates', $date = new DatetimeField('RegistrationBeginDate', "When does registration begin?"));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->getDateField()->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Dates', $date = new DatetimeField('RegistrationEndDate', "When does registration end?"));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->getDateField()->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Dates', $date = new DateField('ScheduleDefaultStartDate', "Default Start Date to show on schedule page?"));
     $date->setConfig('showcalendar', true);
     $date->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldsToTab('Root.Main', new NumericField('MaxSubmissionAllowedPerUser', 'Max. Submission Allowed Per User'));
     $logo_field = new UploadField('Logo', 'Logo');
     $logo_field->setAllowedMaxFileNumber(1);
     $logo_field->setAllowedFileCategories('image');
     $logo_field->setFolderName('summits/logos/');
     $logo_field->getValidator()->setAllowedMaxFileSize(1024 * 1024 * 1);
     $f->addFieldToTab('Root.Main', $logo_field);
     $f->addFieldToTab('Root.Main', new TextField('ComingSoonBtnText', 'Coming Soon Btn Text'));
     $f->addFieldToTab('Root.Main', new TextField('ExternalEventId', 'Eventbrite Event Id'));
     if ($this->owner->ID > 0) {
         $summit_id = $this->owner->ID;
         // tracks
         $config = GridFieldConfig_RecordEditor::create(25);
         $categories = new GridField('Categories', 'Presentation Categories', $this->owner->getCategories(), $config);
         $f->addFieldToTab('Root.Presentation Categories', $categories);
         $config = GridFieldConfig_RelationEditor::create(25);
         $config->removeComponentsByType(new GridFieldDataColumns());
         $config->removeComponentsByType(new GridFieldDetailForm());
         $config->addComponent(new GridFieldUpdateDefaultCategoryTags());
         $default_tags = new GridField('CategoryDefaultTags', 'Category Default Tags', $this->owner->CategoryDefaultTags(), $config);
         $completer = $config->getComponentByType('GridFieldAddExistingAutocompleter');
         $completer->setResultsFormat('$Tag');
         $completer->setSearchFields(array('Tag'));
         $completer->setSearchList(Tag::get());
         $editconf = new GridFieldDetailForm();
         $editconf->setFields(FieldList::create(TextField::create('Tag', 'Tag'), DropdownField::create('ManyMany[Group]', 'Group', array('topics' => 'Topics', 'speaker' => 'Speaker', 'openstack projects mentioned' => 'OpenStack Projects Mentioned'))));
         $summaryfieldsconf = new GridFieldDataColumns();
         $summaryfieldsconf->setDisplayFields(array('Tag' => 'Tag', 'Group' => 'Group'));
         $config->addComponent($editconf);
         $config->addComponent($summaryfieldsconf, new GridFieldFilterHeader());
         $f->addFieldToTab('Root.Presentation Categories', $default_tags);
         // track groups
         $config = GridFieldConfig_RecordEditor::create(25);
         $config->removeComponentsByType('GridFieldAddNewButton');
         $multi_class_selector = new GridFieldAddNewMultiClass();
         $multi_class_selector->setClasses(array('PresentationCategoryGroup' => 'Category Group', 'PrivatePresentationCategoryGroup' => 'Private Category Group'));
         $config->addComponent($multi_class_selector);
         $categories = new GridField('CategoryGroups', 'Category Groups', $this->owner->CategoryGroups(), $config);
         $f->addFieldToTab('Root.Category Groups', $categories);
         // locations
         $config = GridFieldConfig_RecordEditor::create();
         $config->removeComponentsByType('GridFieldAddNewButton');
         $multi_class_selector = new GridFieldAddNewMultiClass();
         $multi_class_selector->setClasses(array('SummitVenue' => 'Venue', 'SummitHotel' => 'Hotel', 'SummitAirport' => 'Airport', 'SummitExternalLocation' => 'External Location'));
         $config->addComponent($multi_class_selector);
         $config->addComponent($sort = new GridFieldSortableRows('Order'));
         $gridField = new GridField('Locations', 'Locations', $this->owner->Locations()->where("ClassName <> 'SummitVenueRoom' "), $config);
         $f->addFieldToTab('Root.Locations', $gridField);
         // types
         $config = GridFieldConfig_RecordEditor::create();
         $config->addComponent(new GridFieldAddDefaultSummitTypes());
         $gridField = new GridField('SummitTypes', 'SummitTypes', $this->owner->Types(), $config);
         $f->addFieldToTab('Root.SummitTypes', $gridField);
         // event types
         $config = GridFieldConfig_RecordEditor::create();
         $config->addComponent(new GridFieldAddDefaultEventTypes());
         $gridField = new GridField('EventTypes', 'EventTypes', $this->owner->EventTypes(), $config);
         $f->addFieldToTab('Root.EventTypes', $gridField);
         //schedule
         $config = GridFieldConfig_RecordEditor::create(25);
         $config->addComponent(new GridFieldAjaxRefresh(1000, false));
         $config->removeComponentsByType('GridFieldDeleteAction');
         $gridField = new GridField('Schedule', 'Schedule', $this->owner->Events()->filter('Published', true)->sort(array('StartDate' => 'ASC', 'EndDate' => 'ASC')), $config);
         $config->getComponentByType("GridFieldDataColumns")->setFieldCasting(array("Description" => "HTMLText->BigSummary"));
         $f->addFieldToTab('Root.Schedule', $gridField);
         $config->addComponent(new GridFieldPublishSummitEventAction());
         // events
         $config = GridFieldConfig_RecordEditor::create(25);
         $config->addComponent(new GridFieldPublishSummitEventAction());
         $config->addComponent(new GridFieldAjaxRefresh(1000, false));
         $config->addComponent($bulk_summit_types = new GridFieldBulkActionAssignSummitTypeSummitEvents());
         $bulk_summit_types->setTitle('Set Summit Type');
         $gridField = new GridField('Events', 'Events', $this->owner->Events()->filter('ClassName', 'SummitEvent'), $config);
         $config->getComponentByType("GridFieldDataColumns")->setFieldCasting(array("Description" => "HTMLText->BigSummary"));
         $f->addFieldToTab('Root.Events', $gridField);
         //track selection list presentations
         $config = GridFieldConfig_RecordEditor::create(25);
         $gridField = new GridField('TrackChairsSelectionLists', 'TrackChairs Selection Lists', SummitSelectedPresentationList::get()->filter('ListType', 'Group')->where(' CategoryID IN ( SELECT ID FROM PresentationCategory WHERE SummitID = ' . $summit_id . ')'), $config);
         $f->addFieldToTab('Root.TrackChairs Selection Lists', $gridField);
         // attendees
         $config = GridFieldConfig_RecordEditor::create(25);
         $gridField = new GridField('Attendees', 'Attendees', $this->owner->Attendees(), $config);
         $f->addFieldToTab('Root.Attendees', $gridField);
         //tickets types
         $config = GridFieldConfig_RecordEditor::create(25);
         $gridField = new GridField('SummitTicketTypes', 'Ticket Types', $this->owner->SummitTicketTypes(), $config);
         $f->addFieldToTab('Root.TicketTypes', $gridField);
         // promo codes
         $config = GridFieldConfig_RecordEditor::create(50);
         $config->removeComponentsByType('GridFieldAddNewButton');
         $multi_class_selector = new GridFieldAddNewMultiClass();
         $multi_class_selector->setClasses(array('SpeakerSummitRegistrationPromoCode' => 'Speaker Promo Code'));
         $config->addComponent($multi_class_selector);
         $promo_codes = new GridField('SummitRegistrationPromoCodes', 'Registration Promo Codes', $this->owner->SummitRegistrationPromoCodes(), $config);
         $f->addFieldToTab('Root.RegistrationPromoCodes', $promo_codes);
         // speakers
         $config = GridFieldConfig_RecordEditor::create(25);
         $gridField = new GridField('Speakers', 'Speakers', $this->owner->Speakers(false), $config);
         $config->getComponentByType("GridFieldDataColumns")->setFieldCasting(array("Bio" => "HTMLText->BigSummary"));
         $f->addFieldToTab('Root.Speakers', $gridField);
         // presentations
         $config = GridFieldConfig_RecordEditor::create(25);
         $config->addComponent(new GridFieldPublishSummitEventAction());
         $config->addComponent(new GridFieldAjaxRefresh(1000, false));
         $config->addComponent($bulk_summit_types = new GridFieldBulkActionAssignSummitTypeSummitEvents());
         $bulk_summit_types->setTitle('Set Summit Type');
         $gridField = new GridField('Presentations', 'Presentations', $this->owner->Presentations()->where(" Title IS NOT NULL AND Title <>'' "), $config);
         $config->getComponentByType("GridFieldDataColumns")->setFieldCasting(array("Description" => "HTMLText->BigSummary"));
         $f->addFieldToTab('Root.Presentations', $gridField);
         // push notifications
         $config = GridFieldConfig_RecordEditor::create(25);
         $config->addComponent(new GridFieldAjaxRefresh(1000, false));
         $config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array('Channel' => 'Channel', 'Message' => 'Message', 'Owner.FullName' => 'Owner', 'IsSent' => 'Is Sent?', 'SentDate' => 'Sent Date'));
         $config->getComponentByType('GridFieldDetailForm')->setItemRequestClass('GridFieldDetailFormPushNotification');
         $gridField = new GridField('Notifications', 'Notifications', $this->owner->Notifications(), $config);
         $f->addFieldToTab('Root.PushNotifications', $gridField);
         //entity events
         $config = GridFieldConfig_RecordEditor::create(25);
         $config->addComponent(new GridFieldAjaxRefresh(1000, false));
         $config->addComponent(new GridFieldWipeDevicesDataAction());
         $config->addComponent(new GridFieldDeleteAllSummitEntityEventsAction());
         $config->removeComponentsByType('GridFieldAddNewButton');
         $gridField = new GridField('EntityEvents', 'EntityEvents', $this->owner->EntityEvents(), $config);
         $f->addFieldToTab('Root.EntityEvents', $gridField);
         //TrackChairs
         $config = GridFieldConfig_RecordEditor::create(25);
         $config->addComponent(new GridFieldAjaxRefresh(1000, false));
         $gridField = new GridField('TrackChairs', 'TrackChairs', $this->owner->TrackChairs(), $config);
         $f->addFieldToTab('Root.TrackChairs', $gridField);
         //RSVP templates
         $config = GridFieldConfig_RecordEditor::create(40);
         $config->addComponent(new GridFieldAjaxRefresh(1000, false));
         $gridField = new GridField('RSVPTemplates', 'RSVPTemplates', $this->owner->RSVPTemplates(), $config);
         $f->addFieldToTab('Root.RSVPTemplates', $gridField);
     }
 }
示例#19
0
 public function getCMSFields()
 {
     return FieldList::create(TabSet::create('Root'))->text('Title')->dropdown('Level', 'Level', $this->dbObject('Level')->enumValues())->dropdown('CategoryID', 'Category', PresentationCategory::get()->map('ID', 'Title'))->dropdown('Status', 'Status')->configure()->setSource(array_combine($this->config()->status_options, $this->config()->status_options))->end()->listbox('Topics', 'Topics', PresentationTopic::get()->map('ID', 'Title')->toArray())->configure()->setMultiple(true)->end()->tag('Tags', 'Tags', Tag::get(), $this->Tags())->text('OtherTopic', 'Other topic')->htmlEditor('Description')->htmlEditor('ShortDescription')->tab('Preview')->literal('preview', sprintf('<iframe width="%s" height="%s" frameborder="0" src="%s"></iframe>', '100%', '400', Director::absoluteBaseURL() . $this->PreviewLink()));
 }
 /**
  * test whether the URLSegment exists already on another tag
  * @param string $URLSegment
  * @return boolean if urlsegment already exists yes or no.
  */
 public function LookForExistingURLSegment($URLSegment)
 {
     return Tag::get()->filter(array("URLSegment" => $URLSegment))->exclude(array("ID" => $this->ID))->count() != 0;
 }
示例#21
0
文件: Rss.php 项目: hisaboh/w2t
 protected function __str__()
 {
     $result = new Tag("rss");
     $channel = new Tag("channel");
     foreach ($this->access_members() as $name => $value) {
         if (!empty($value)) {
             switch ($name) {
                 case "version":
                     $result->param("version", $value);
                     break;
                 case "title":
                 case "link":
                 case "description":
                 case "language":
                 case "copyright":
                 case "docs":
                 case "managingEditor":
                 case "webMaster":
                     $channel->add(new Tag($name, $value));
                     break;
                 case "lastBuildDate":
                 case "pubDate":
                     $channel->add(new Tag($name, $this->formatDate($value)));
                     break;
                 default:
                     if (is_array($this->{$name})) {
                         foreach ($this->{$name} as $o) {
                             $channel->add($o);
                         }
                         break;
                     } else {
                         if (is_object($this->{$name})) {
                             $channel->add($value);
                             break;
                         } else {
                             $channel->add(new Tag($name, $value));
                             break;
                         }
                     }
             }
         }
     }
     $result->add($channel);
     return $result->get();
     /***
     			$src = text('
     						<rss version="2.0">
     							<channel>
     								<title>rhaco</title>
     								<link>http://rhaco.org</link>
     								<description>php</description>
     								<language>ja</language>
     								<copyright>rhaco.org</copyright>
     								<docs>hogehoge</docs>
     								<lastBuildDate>2007-10-10T10:10:10+09:00</lastBuildDate>
     								<managingEditor>tokushima</managingEditor>
     								<pubDate>2007-10-10T10:10:10+09:00</pubDate>
     								<webMaster>kazutaka</webMaster>
     								<item><title>rhaco</title><link>http://rhaco.org</link><description>rhaco desc</description></item>
     								<item><title>everes</title><link>http://www.everes.net</link><description>everes desc</description></item>
     							</channel>
     						</rss>
     					');
     					$xml = Rss::parse($src);
     					eq(str_replace(array("\n","\t"),"",$src),(string)$xml);
     		*/
 }
示例#22
0
 function index()
 {
     $defaults = array('page' => 1, 'limit' => 20, 'context_order' => 'count');
     list($params, $id, $slug) = $this->parse_params(func_get_args());
     $params = array_merge($defaults, $params);
     $t = new Tag();
     if ($this->method !== 'get') {
         if (is_null($id)) {
             $this->error('400', 'ID is required.');
         }
         $tag = $t->get_by_id($id);
         if ($this->method === 'delete') {
             $tag->delete();
             exit;
         } else {
             $tag->name = $this->input->post('name');
             $tag->save();
             $this->redirect('/tags/' . $tag->id);
         }
     }
     if (!$slug && is_null($id)) {
         $final = $t->listing($params);
     } else {
         $slug = urldecode($slug);
         if ($slug) {
             $t->where('name', $slug)->get();
         } else {
             $t->get_by_id($id);
         }
         $tag_array = $t->to_array();
         $params['tag'] = $t->id;
         $params['tag_slug'] = $t->name;
         list($final, $counts) = $this->aggregate('tag', $params);
         $final['counts'] = $counts;
         $final = array_merge($tag_array, $final);
         $prev = new Tag();
         $next = new Tag();
         $prev->where('id !=', $t->id);
         $next->where('id !=', $t->id);
         if ($params['context_order'] === 'count') {
             $prev->group_start();
             $prev->where_func('', array('@content_count', '+', '@text_count', '+', '@album_count', '>', $t->essay_count + $t->album_count + $t->content_count), null);
             $prev->or_group_start();
             $prev->where_func('', array('@content_count', '+', '@text_count', '+', '@album_count', '=', $t->essay_count + $t->album_count + $t->content_count), null);
             $prev->where('name <', $t->name);
             $prev->group_end();
             $prev->group_end();
             $next->group_start();
             $next->where_func('', array('@content_count', '+', '@text_count', '+', '@album_count', '<', $t->essay_count + $t->album_count + $t->content_count), null);
             $next->or_group_start();
             $next->where_func('', array('@content_count', '+', '@text_count', '+', '@album_count', '=', $t->essay_count + $t->album_count + $t->content_count), null);
             $next->where('name >', $t->name);
             $next->group_end();
             $next->group_end();
             $prev->order_by_func('', array('@content_count', '+', '@text_count', '+', '@album_count'), 'ASC');
             $next->order_by_func('', array('@content_count', '+', '@text_count', '+', '@album_count'), 'DESC');
         } else {
             $prev->where('name <', $t->name);
             $next->where('name >', $t->name);
         }
         $prev->order_by('name DESC');
         $next->order_by('name ASC');
         $max = $next->get_clone()->count();
         $min = $prev->get_clone()->count();
         $final['context'] = array();
         $final['context']['total'] = $max + $min + 1;
         $final['context']['position'] = $min + 1;
         $final['context']['previous'] = $final['context']['next'] = false;
         $prev->get();
         $next->get();
         if ($prev->exists()) {
             $final['context']['previous'] = $prev->to_array();
         }
         if ($next->exists()) {
             $final['context']['next'] = $next->to_array();
         }
     }
     $this->set_response_data($final);
 }
示例#23
0
文件: Atom.php 项目: hisaboh/w2t
 protected function __str__()
 {
     $result = new Tag("feed");
     $result->param("xmlns", self::$XMLNS);
     foreach ($this->access_members() as $name => $value) {
         if (!empty($value)) {
             switch ($name) {
                 case "title":
                 case "subtitle":
                 case "id":
                 case "generator":
                     $result->add(new Tag($name, $value));
                     break;
                 case "author":
                     foreach ($this->{$name} as $o) {
                         $result->add($o);
                     }
                     break;
                 case "updated":
                     $result->add(new Tag($name, Date::format_atom($value)));
                     break;
                 default:
                     if (is_array($this->{$name})) {
                         foreach ($this->{$name} as $o) {
                             $result->add($o);
                         }
                         break;
                     } else {
                         if (is_object($this->{$name})) {
                             $result->add($value);
                             break;
                         } else {
                             $result->add(new Tag($name, $value));
                             break;
                         }
                     }
             }
         }
     }
     return $result->get();
     /***
     			$src = text('
     				<feed xmlns="http://www.w3.org/2005/Atom">
     				<title>atom10 feed</title>
     				<subtitle>atom10 sub title</subtitle>
     				<updated>2007-07-18T16:16:31+00:00</updated>
     				<generator>tokushima</generator>
     				<link href="http://tokushimakazutaka.com" rel="abc" type="xyz" />
     
     				<author>
     					<url>http://tokushimakazutaka.com</url>
     					<name>tokushima</name>
     					<email>tokushima@hoge.hoge</email>
     				</author>
     
     				<entry>
     					<title>rhaco</title>
     					<summary type="xml" xml:lang="ja">summary test</summary>
     					<content type="text/xml" mode="abc" xml:lang="ja" xml:base="base">atom content</content>
     					<link href="http://rhaco.org" rel="abc" type="xyz" />
     					<link href="http://conveyor.rhaco.org" rel="abc" type="conveyor" />
     					<link href="http://lib.rhaco.org" rel="abc" type="lib" />
     
     				 <updated>2007-07-18T16:16:31+00:00</updated>
     				 <issued>2007-07-18T16:16:31+00:00</issued>
     				 <published>2007-07-18T16:16:31+00:00</published>
     				 <id>rhaco</id>
     				<author>
     					<url>http://rhaco.org</url>
     					<name>rhaco</name>
     					<email>rhaco@rhaco.org</email>
     				</author>
     				</entry>
     
     				<entry>
     					<title>django</title>
     					<summary type="xml" xml:lang="ja">summary test</summary>
     					<content type="text/xml" mode="abc" xml:lang="ja" xml:base="base">atom content</content>
     					<link href="http://djangoproject.jp" rel="abc" type="xyz" />
     
     				 <updated>2007-07-18T16:16:31+00:00</updated>
     				 <issued>2007-07-18T16:16:31+00:00</issued>
     				 <published>2007-07-18T16:16:31+00:00</published>
     				 <id>django</id>
     				<author>
     					<url>http://www.everes.net</url>
     					<name>everes</name>
     					<email>everes@hoge.hoge</email>
     				</author>
     				</entry>
     
     				</feed>
     			');
     
     			$xml = Atom::parse($src);
     			$result = text('
     							<feed xmlns="http://www.w3.org/2005/Atom">
     							<title>atom10 feed</title>
     							<subtitle>atom10 sub title</subtitle>
     							<id>rhaco</id>
     							<generator>tokushima</generator>
     							<updated>2007-07-18T16:16:31Z</updated>
     							<link rel="abc" type="xyz" href="http://tokushimakazutaka.com" />
     							<entry>
     								<id>rhaco</id>
     								<title>rhaco</title>
     								<published>2007-07-18T16:16:31Z</published>
     								<updated>2007-07-18T16:16:31Z</updated>
     								<issued>2007-07-18T16:16:31Z</issued>
     								<content type="text/xml" mode="abc" xml:lang="ja" xml:base="base">atom content</content>
     								<summary type="xml" xml:lang="ja">summary test</summary>
     								<link rel="abc" type="xyz" href="http://rhaco.org" />
     								<link rel="abc" type="conveyor" href="http://conveyor.rhaco.org" />
     								<link rel="abc" type="lib" href="http://lib.rhaco.org" />
     								<author>
     									<name>rhaco</name>
     									<url>http://rhaco.org</url>
     									<email>rhaco@rhaco.org</email>
     								</author>
     							</entry>
     							<entry>
     								<id>django</id>
     								<title>django</title>
     								<published>2007-07-18T16:16:31Z</published>
     								<updated>2007-07-18T16:16:31Z</updated>
     								<issued>2007-07-18T16:16:31Z</issued>
     								<content type="text/xml" mode="abc" xml:lang="ja" xml:base="base">atom content</content>
     								<summary type="xml" xml:lang="ja">summary test</summary>
     								<link rel="abc" type="xyz" href="http://djangoproject.jp" />
     								<author>
     									<name>everes</name>
     									<url>http://www.everes.net</url>
     									<email>everes@hoge.hoge</email>
     								</author>
     							</entry>
     							<author>
     								<name>tokushima</name>
     								<url>http://tokushimakazutaka.com</url>
     								<email>tokushima@hoge.hoge</email>
     							</author>
     							</feed>
     						');
     			$result = str_replace(array("\n","\t"),"",$result);
     			eq($result,(string)$xml);
     		 */
 }
示例#24
0
文件: home.php 项目: kuitang/sdi
 function models()
 {
     $t = new Tag();
     $t->get();
     foreach ($t->all as $myt) {
         echo $myt;
     }
 }
示例#25
0
文件: Opml.php 项目: hisaboh/w2t
 protected function __str__()
 {
     $out = new Tag("opml");
     $out->param("version", $this->version());
     $head = new Tag("head");
     if ($this->isTitle()) {
         $head->add(new Tag("title", $this->title()));
     }
     if ($this->isDateCreated()) {
         $head->add(new Tag("dateCreated", $this->formatDate($this->dateCreated())));
     }
     if ($this->isDateModified()) {
         $head->add(new Tag("dateModified", $this->formatDate($this->dateModified())));
     }
     if ($this->isOwnerName()) {
         $head->add(new Tag("ownerName", $this->ownerName()));
     }
     if ($this->isOwnerEmail()) {
         $head->add(new Tag("ownerEmail", $this->ownerEmail()));
     }
     if ($this->isExpansionState()) {
         $head->add(new Tag("expansionState", $this->expansionState()));
     }
     if ($this->isVertScrollState()) {
         $head->add(new Tag("vertScrollState", $this->vertScrollState()));
     }
     if ($this->isWindowTop()) {
         $head->add(new Tag("windowTop", $this->windowTop()));
     }
     if ($this->isWindowLeft()) {
         $head->add(new Tag("windowLeft", $this->windowLeft()));
     }
     if ($this->isWindowBottom()) {
         $head->add(new Tag("windowBottom", $this->windowBottom()));
     }
     if ($this->isWindowRight()) {
         $head->add(new Tag("windowRight", $this->windowRight()));
     }
     $out->adde($head);
     $body = new Tag("body");
     foreach ($this->arOutline() as $outline) {
         $body->add($outline->get());
     }
     $out->add($body->get());
     return $out();
 }
示例#26
0
 function getTagIdByValue($value)
 {
     $t = new Tag($this->POD);
     $t->load('value', $value);
     if ($t->success()) {
         return $t->get('id');
     } else {
         $t->set('value', $value);
         $t->save();
         return $t->get('id');
     }
 }
    /**
     * Setup the fields that are visible ONLY when the item exists already.
     * @param News $owner
     * @param SiteConfig $siteConfig
     */
    private function existingItem(News $owner, SiteConfig $siteConfig)
    {
        if (!$owner->ID) {
            $member = Member::currentUser();
            $this->field_list['Root.Main'][13] = ReadonlyField::create('Tags', $owner->fieldLabel('Tags'), _t('News.TAGAFTERID', 'Tags can be added after the item has been saved'));
            $owner->Type = 'news';
            $owner->Author = $member->FirstName . ' ' . $member->Surname;
        } else {
            if (class_exists('MultiSelectField')) {
                /** I like multiselectfield and needed a reason to commit something */
                $this->field_list['Root.Main'][13] = MultiSelectField::create('Tags', $owner->fieldLabel('Tags'), $this->owner);
            } else {
                $this->field_list['Root.Main'][13] = CheckboxSetField::create('Tags', $owner->fieldLabel('Tags'), Tag::get()->map('ID', 'Title'));
            }
            $this->field_list['Root.Main'][2] = LiteralField::create('Dummy', '<div id="Dummy" class="field readonly">
	<label class="left" for="Form_ItemEditForm_Dummy">Link</label>
	<div class="middleColumn">
	<span id="Form_ItemEditForm_Dummy" class="readonly">
		<a href="' . $owner->AbsoluteLink() . '" target="_blank">' . $owner->AbsoluteLink() . '</a>
	</span>
	</div>
	</div>');
            if ($siteConfig->EnableSlideshow) {
                /** @var GridFieldConfig_RecordEditor $gridFieldConfig */
                $gridFieldConfig = GridFieldConfig_RecordEditor::create();
                $gridFieldConfig->addComponent(new GridFieldBulkUpload());
                $gridFieldConfig->addComponent(new GridFieldOrderableRows('SortOrder'));
                $gridFieldConfig->getComponentByType('GridFieldBulkUpload')->setUfSetup('setFolderName', $this->getRootFolderName($siteConfig));
                if (class_exists('GridFieldGalleryTheme')) {
                    $gridFieldConfig->addComponent(new GridFieldGalleryTheme('Image'));
                    /**
                     * as gallery theme breaks sorting with GridFieldOrderableRows
                     * let's use SortableRows as a fallback when installed
                     *
                     * @todo remove later this when gridfield extension works with gallery theme
                     */
                    if (class_exists('GridFieldSortableRows')) {
                        $gridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder'));
                        $gridFieldConfig->removeComponentsByType('GridFieldOrderableRows');
                    }
                }
                $this->field_list['Root'][] = Tab::create('SlideshowImages', $owner->fieldLabel('SlideshowImages'), GridField::create('SlideshowImage', _t('News.IMAGES', 'Slideshow images'), $owner->SlideshowImages()->sort('SortOrder'), $gridFieldConfig));
            }
        }
    }
示例#28
0
 public function getCMSFields()
 {
     Requirements::customScript("\n        jQuery( document ).ready(function() {\n            jQuery('body').on('change','#Form_ItemEditForm_RSVPTemplateID',\n                function(){\n                    jQuery('#Form_ItemEditForm_action_save').click();\n                }\n            );\n        });");
     $summit_id = isset($_REQUEST['SummitID']) ? $_REQUEST['SummitID'] : $this->SummitID;
     $f = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main')));
     $f->addFieldToTab('Root.Main', new TextField('Title', 'Title'));
     $f->addFieldToTab('Root.Main', new HtmlEditorField('Description', 'Description'));
     $f->addFieldToTab('Root.Main', new HtmlEditorField('ShortDescription', 'Abstract'));
     $f->addFieldToTab('Root.Main', new TextField('HeadCount', 'HeadCount'));
     $f->tag('Tags', 'Tags', Tag::get(), $this->Tags())->configure()->setTitleField('Tag')->end();
     $f->addFieldToTab('Root.Main', new CheckboxField('AllowFeedBack', 'Is feedback allowed?'));
     $f->addFieldToTab('Root.Main', new HiddenField('SummitID', 'SummitID'));
     $f->addFieldToTab('Root.Main', $date = new DatetimeField('StartDate', 'Start Date'));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Main', $date = new DatetimeField('EndDate', 'End Date'));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldsToTab('Root.Main', new ReadonlyField('AvgFeedbackRate', 'AvgFeedbackRate'));
     $locations = SummitAbstractLocation::get()->filter('SummitID', $summit_id)->filter('ClassName', array('SummitVenue', 'SummitVenueRoom', 'SummitExternalLocation'));
     $locations_source = array();
     foreach ($locations as $l) {
         $locations_source[$l->ID] = $l->getFullName();
     }
     $f->addFieldToTab('Root.Main', $ddl_location = new DropdownField('LocationID', 'Location', $locations_source));
     $ddl_location->setEmptyString('-- Select a Location --');
     $f->addFieldToTab('Root.Main', $ddl_location = new DropdownField('TypeID', 'Event Type', SummitEventType::get()->filter('SummitID', $summit_id)->map('ID', 'Type')));
     $ddl_location->setEmptyString('-- Select a Event Type --');
     $f->addFieldToTab('Root.Main', new HiddenField('SummitID', 'SummitID'));
     if ($this->ID > 0) {
         // summits types
         $config = new GridFieldConfig_RelationEditor(100);
         $config->removeComponentsByType('GridFieldEditButton');
         $config->removeComponentsByType('GridFieldAddNewButton');
         $completer = $config->getComponentByType('GridFieldAddExistingAutocompleter');
         $completer->setSearchList(SummitType::get()->filter('SummitID', $summit_id));
         $summit_types = new GridField('AllowedSummitTypes', 'Summit Types', $this->AllowedSummitTypes(), $config);
         $f->addFieldToTab('Root.Main', $summit_types);
         // sponsors
         $config = new GridFieldConfig_RelationEditor(100);
         $config->removeComponentsByType('GridFieldEditButton');
         $config->removeComponentsByType('GridFieldAddNewButton');
         $sponsors = new GridField('Sponsors', 'Sponsors', $this->Sponsors(), $config);
         $f->addFieldToTab('Root.Sponsors', $sponsors);
         // feedback
         $config = new GridFieldConfig_RecordEditor(100);
         $config->removeComponentsByType('GridFieldAddNewButton');
         $config->addComponent(new GridFieldAjaxRefresh(1000, false));
         $feedback = new GridField('Feedback', 'Feedback', $this->Feedback(), $config);
         $f->addFieldToTab('Root.Feedback', $feedback);
         // rsvp
         $f->addFieldsToTab('Root.RSVP', new TextField('RSVPLink', 'RSVP External Link'));
         $rsvp_template = new DropdownField('RSVPTemplateID', 'Select a Template', RSVPTemplate::get()->filter('SummitID', $summit_id)->map());
         $rsvp_template->setEmptyString('-- View All Templates --');
         $f->addFieldToTab('Root.RSVP', LiteralField::create('AddNew', 'Or add a new custom RSVP Configuration'));
         $f->addFieldToTab('Root.RSVP', $rsvp_template);
         $f->addFieldToTab('Root.RSVP', new NumericField('RSVPMaxUserNumber', 'Max # Number'));
         $f->addFieldToTab('Root.RSVP', new NumericField('RSVPMaxUserWaitListNumber', 'Max # Wait List'));
         $f->addFieldToTab('Root.RSVP', $rsvp_template);
         if ($this->RSVPTemplate()->exists()) {
             $config = new GridFieldConfig_RecordEditor(100);
             $config->removeComponentsByType('GridFieldAddNewButton');
             $config->addComponent(new GridFieldAjaxRefresh(1000, false));
             $rsvps = new GridField('RSVPSubmissions', 'RSVP Submissions', $this->RSVPSubmissions(), $config);
             $f->addFieldToTab('Root.RSVP', $rsvps);
         }
     }
     if ($this->ID > 0) {
         $_REQUEST['SummitEventID'] = $this->ID;
     }
     return $f;
 }
示例#29
0
 public function getCMSFields()
 {
     $summit_id = isset($_REQUEST['SummitID']) ? $_REQUEST['SummitID'] : $this->SummitID;
     $f = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main')));
     $f->addFieldToTab('Root.Main', new TextField('Title', 'Title'));
     $f->addFieldToTab('Root.Main', new HtmlEditorField('Description', 'Description'));
     $f->addFieldToTab('Root.Main', new HtmlEditorField('ShortDescription', 'Short Description'));
     $f->tag('Tags', 'Tags', Tag::get(), $this->Tags())->configure()->setTitleField('Tag')->end();
     $f->addFieldToTab('Root.Main', new CheckboxField('AllowFeedBack', 'Is feedback allowed?'));
     $f->addFieldToTab('Root.Main', new HiddenField('SummitID', 'SummitID'));
     $f->addFieldToTab('Root.Main', $date = new DatetimeField('StartDate', 'Start Date'));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->setConfig('dateformat', 'dd/MM/yyyy');
     $f->addFieldToTab('Root.Main', $date = new DatetimeField('EndDate', 'End Date'));
     $date->getDateField()->setConfig('showcalendar', true);
     $date->setConfig('dateformat', 'dd/MM/yyyy');
     $locations = SummitAbstractLocation::get()->filter('SummitID', $summit_id)->filter('ClassName', array('SummitVenue', 'SummitVenueRoom', 'SummitExternalLocation'));
     $locations_source = array();
     foreach ($locations as $l) {
         $locations_source[$l->ID] = $l->getFullName();
     }
     $f->addFieldToTab('Root.Main', $ddl_location = new DropdownField('LocationID', 'Location', $locations_source));
     $ddl_location->setEmptyString('-- Select a Location --');
     $f->addFieldToTab('Root.Main', $ddl_location = new DropdownField('TypeID', 'Event Type', SummitEventType::get()->filter('SummitID', $summit_id)->map('ID', 'Type')));
     $ddl_location->setEmptyString('-- Select a Event Type --');
     $f->addFieldToTab('Root.Main', new HiddenField('SummitID', 'SummitID'));
     if ($this->ID > 0) {
         // summits types
         $config = new GridFieldConfig_RelationEditor(100);
         $config->removeComponentsByType('GridFieldEditButton');
         $config->removeComponentsByType('GridFieldAddNewButton');
         $completer = $config->getComponentByType('GridFieldAddExistingAutocompleter');
         $completer->setSearchList(SummitType::get()->filter('SummitID', $summit_id));
         $summit_types = new GridField('AllowedSummitTypes', 'Summit Types', $this->AllowedSummitTypes(), $config);
         $f->addFieldToTab('Root.Main', $summit_types);
         // sponsors
         $config = new GridFieldConfig_RelationEditor(100);
         $config->removeComponentsByType('GridFieldEditButton');
         $config->removeComponentsByType('GridFieldAddNewButton');
         $sponsors = new GridField('Sponsors', 'Sponsors', $this->Sponsors(), $config);
         $f->addFieldToTab('Root.Sponsors', $sponsors);
         // feedback
         $config = new GridFieldConfig_RecordEditor(100);
         $config->removeComponentsByType('GridFieldAddNewButton');
         $feedback = new GridField('Feedback', 'Feedback', $this->Feedback(), $config);
         $f->addFieldToTab('Root.Feedback', $feedback);
     }
     return $f;
 }
示例#30
0
require __DIR__ . "/models/Post.php";
require __DIR__ . "/models/Tag.php";
$date = date('Y-m-d');
// Configure Phormium
\Phormium\DB::configure('config.json');
// Create a person and three contacts
Person::fromArray(["id" => 1, "name" => "Ivan"])->save();
Contact::fromArray(["id" => 1, "person_id" => 1, "value" => "foo"])->save();
Contact::fromArray(["id" => 2, "person_id" => 1, "value" => "bar"])->save();
Contact::fromArray(["id" => 3, "person_id" => 1, "value" => "baz"])->save();
// Fetch the person, then get her contacts
$person = Person::get(1);
$contacts = $person->contacts()->fetch();
print_r($contacts);
// Fetch the contact, then get the person it belongs to
$contact = Contact::get(1);
$person = $contact->person()->single();
print_r($person);
// Create a post and three tags
Post::fromArray(["date" => $date, "no" => 1, "title" => "Post #1"])->save();
Tag::fromArray(["id" => 1, "post_date" => $date, "post_no" => 1, "value" => "Tag #1"])->save();
Tag::fromArray(["id" => 2, "post_date" => $date, "post_no" => 1, "value" => "Tag #2"])->save();
Tag::fromArray(["id" => 3, "post_date" => $date, "post_no" => 1, "value" => "Tag #3"])->save();
// Fetch a post, then fetch it's tags
$post = Post::get($date, 1);
$tags = $post->tags()->fetch();
print_r($tags);
// Fetch a tag, then fetch the post it belongs to
$tag = Tag::get(2);
$post = $tag->post()->single();
print_r($post);