public function getMembers() { //make sure members exist. if (DataList::create('Member')->count() >= 1) { return DataList::create('Member'); } }
public function scaffoldFormField($title = null, $params = null) { if (empty($this->object)) { return null; } $relationName = substr($this->name, 0, -2); $hasOneClass = $this->object->hasOneComponent($relationName); if (empty($hasOneClass)) { return null; } $hasOneSingleton = singleton($hasOneClass); if ($hasOneSingleton instanceof File) { $field = new UploadField($relationName, $title); if ($hasOneSingleton instanceof Image) { $field->setAllowedFileCategories('image/supported'); } return $field; } // Build selector / numeric field $titleField = $hasOneSingleton->hasField('Title') ? "Title" : "Name"; $list = DataList::create($hasOneClass); // Don't scaffold a dropdown for large tables, as making the list concrete // might exceed the available PHP memory in creating too many DataObject instances if ($list->count() < 100) { $field = new DropdownField($this->name, $title, $list->map('ID', $titleField)); $field->setEmptyString(' '); } else { $field = new NumericField($this->name, $title); } return $field; }
public function __construct($name, $title = null, $value = "") { // naming with underscores to prevent values from actually being saved somewhere $this->fieldType = new OptionsetField("{$name}[Type]", _t('HtmlEditorField.LINKTO', 'Link to'), array('Internal' => _t('HtmlEditorField.LINKINTERNAL', 'Page on the site'), 'External' => _t('HtmlEditorField.LINKEXTERNAL', 'Another website'), 'Email' => _t('HtmlEditorField.LINKEMAIL', 'Email address'), 'File' => _t('HtmlEditorField.LINKFILE', 'Download a file')), 'Internal'); $this->fieldLink = new CompositeField($this->internalField = WTTreeDropdownField::create("{$name}[Internal]", _t('HtmlEditorField.Internal', 'Internal'), 'SiteTree', 'ID', 'Title', true), $this->externalField = TextField::create("{$name}[External]", _t('HtmlEditorField.URL', 'URL'), 'http://'), $this->emailField = EmailField::create("{$name}[Email]", _t('HtmlEditorField.EMAIL', 'Email address')), $this->fileField = WTTreeDropdownField::create("{$name}[File]", _t('HtmlEditorField.FILE', 'File'), 'File', 'ID', 'Title', true), $this->extraField = TextField::create("{$name}[Extra]", 'Extra(optional)')->setDescription('Appended to url. Use to add sub-urls/actions or query string to the url, e.g. ?param=value'), $this->anchorField = TextField::create("{$name}[Anchor]", 'Anchor (optional)'), $this->targetBlankField = CheckboxField::create("{$name}[TargetBlank]", _t('HtmlEditorField.LINKOPENNEWWIN', 'Open link in a new window?'))); if ($linkableDataObjects = WTLink::get_data_object_types()) { if (!($objects = self::$linkable_data_objects)) { $objects = array(); foreach ($linkableDataObjects as $className) { $classObjects = array(); //set the format for DO value -> ClassName-ID foreach (DataList::create($className) as $object) { $classObjects[$className . '-' . $object->ID] = $object->Title; } if (!empty($classObjects)) { $objects[singleton($className)->i18n_singular_name()] = $classObjects; } } } if (count($objects)) { $this->fieldType->setSource(array_merge($this->fieldType->getSource(), array('DataObject' => _t('WTLinkField.LINKDATAOBJECT', 'Data Object')))); $this->fieldLink->insertBefore("{$name}[Extra]", $this->dataObjectField = GroupedDropdownField::create("{$name}[DataObject]", _t('WTLinkField.LINKDATAOBJECT', 'Link to a Data Object'), $objects)); } self::$linkable_data_objects = $objects; } $this->extraField->addExtraClass('no-hide'); $this->anchorField->addExtraClass('no-hide'); $this->targetBlankField->addExtraClass('no-hide'); parent::__construct($name, $title, $value); }
public function onBeforeWrite() { // If there is no URLSegment set, generate one from Title if ((!$this->URLSegment || $this->URLSegment == 'new-product') && $this->Title != 'New Product') { $siteTree = DataList::create('SiteTree')->first(); $this->URLSegment = $siteTree->generateURLSegment($this->Title); } else { if ($this->isChanged('URLSegment')) { // Make sure the URLSegment is valid for use in a URL $segment = preg_replace('/[^A-Za-z0-9]+/', '-', $this->URLSegment); $segment = preg_replace('/-+/', '-', $segment); // If after sanitising there is no URLSegment, give it a reasonable default if (!$segment) { $segment = "product-{$this->ID}"; } $this->URLSegment = $segment; } } // Ensure that this object has a non-conflicting URLSegment value. $count = 2; while ($this->LookForExistingURLSegment($this->URLSegment)) { $this->URLSegment = preg_replace('/-[0-9]+$/', null, $this->URLSegment) . '-' . $count; $count++; } parent::onBeforeWrite(); }
public static function parse_flickr($arguments, $caption = null, $parser = null) { // first things first, if we dont have a video ID, then we don't need to // go any further if (empty($arguments['id'])) { return; } $customise = array(); /*** SET DEFAULTS ***/ $fp = DataList::create('FlickrPhoto')->where('FlickrID=' . $arguments['id'])->first(); if (!$fp) { return ''; } $customise['FlickrImage'] = $fp; //set the caption if ($caption === null || $caption === '') { if (isset($arguments['caption'])) { $caption = $arguments['caption']; } } $customise['Caption'] = $caption ? Convert::raw2xml($caption) : $fp->Title; $customise['Position'] = !empty($arguments['position']) ? $arguments['position'] : 'center'; $customise['Small'] = true; if ($customise['Position'] == 'center') { $customise['Small'] = false; } $fp = null; //overide the defaults with the arguments supplied $customise = array_merge($customise, $arguments); //get our YouTube template $template = new SSViewer('ShortCodeFlickrPhoto'); //return the customised template return $template->process(new ArrayData($customise)); }
public function search($request) { $list = DataList::create($this->getConfig('classToSearch')); $params = array(); $searchFields = $this->getConfig('searchFields'); foreach ($searchFields as $searchField) { $name = strpos($searchField, ':') !== false ? $searchField : "{$searchField}:partialMatch"; $params[$name] = $request->getVar('term'); } $start = (int) $request->getVar('id') ? (int) $request->getVar('id') * $this->getConfig('resultsLimit') : 0; $list = $list->filterAny($params)->exclude($this->getConfig('excludes')); $filter = $this->getConfig('filter'); if (count($filter) > 0) { $list = $list->filter($filter); } $total = $list->count(); $results = $list->sort(strtok($searchFields[0], ':'), 'ASC')->limit($this->getConfig('resultsLimit'), $start); $return = array('list' => array(), 'total' => $total); $originalSourceFileComments = Config::inst()->get('SSViewer', 'source_file_comments'); Config::inst()->update('SSViewer', 'source_file_comments', false); foreach ($results as $object) { $return['list'][] = array('id' => $object->ID, 'resultsContent' => html_entity_decode(SSViewer::fromString($this->getConfig('resultsFormat'))->process($object)), 'selectionContent' => SSViewer::fromString($this->getConfig('selectionFormat'))->process($object)); } Config::inst()->update('SSViewer', 'source_file_comments', $originalSourceFileComments); return Convert::array2json($return); }
/** * Generates a unique URLSegment from the title. * * @param int $increment * * @return string */ public function generateURLSegment($increment = null) { $filter = new URLSegmentFilter(); // Setting this to on. Because of the UI flow, it would be quite a lot of work // to support turning this off. (ie. the add by title flow would not work). // If this becomes a problem we can approach it then. // @see https://github.com/silverstripe/silverstripe-blog/issues/376 $filter->setAllowMultibyte(true); $this->owner->URLSegment = $filter->filter($this->owner->Title); if (is_int($increment)) { $this->owner->URLSegment .= '-' . $increment; } // Postgres use '' instead of 0 as an emtpy blog ID // Without this all the tests fail if (!$this->owner->BlogID) { $this->owner->BlogID = 0; } $duplicate = DataList::create($this->owner->ClassName)->filter(array('URLSegment' => $this->owner->URLSegment, 'BlogID' => $this->owner->BlogID)); if ($this->owner->ID) { $duplicate = $duplicate->exclude('ID', $this->owner->ID); } if ($duplicate->count() > 0) { if (is_int($increment)) { $increment += 1; } else { $increment = 0; } $this->owner->generateURLSegment((int) $increment); } return $this->owner->URLSegment; }
/** * Generates a unique URLSegment from the title. * * @param int $increment * * @return string */ public function generateURLSegment($increment = null) { $filter = new URLSegmentFilter(); $this->owner->URLSegment = $filter->filter($this->owner->Title); if (is_int($increment)) { $this->owner->URLSegment .= '-' . $increment; } // Postgres use '' instead of 0 as an emtpy blog ID // Without this all the tests fail if (!$this->owner->BlogID) { $this->owner->BlogID = 0; } $duplicate = DataList::create($this->owner->ClassName)->filter(array('URLSegment' => $this->owner->URLSegment, 'BlogID' => $this->owner->BlogID)); if ($this->owner->ID) { $duplicate = $duplicate->exclude('ID', $this->owner->ID); } if ($duplicate->count() > 0) { if (is_int($increment)) { $increment += 1; } else { $increment = 0; } $this->owner->generateURLSegment((int) $increment); } return $this->owner->URLSegment; }
public function getCMSFields() { $fields = new FieldList(); $fields->push(new TabSet('Root', new Tab('Main', _t('SiteTree.TABMAIN', 'Main'), new TextField('Title', _t('UniadsObject.db_Title', 'Title'))))); if ($this->ID) { $previewLink = Director::absoluteBaseURL() . 'admin/' . UniadsAdmin::config()->url_segment . '/UniadsObject/preview/' . $this->ID; $fields->addFieldToTab('Root.Main', new ReadonlyField('Impressions', _t('UniadsObject.db_Impressions', 'Impressions')), 'Title'); $fields->addFieldToTab('Root.Main', new ReadonlyField('Clicks', _t('UniadsObject.db_Clicks', 'Clicks')), 'Title'); $fields->addFieldsToTab('Root.Main', array(DropdownField::create('CampaignID', _t('UniadsObject.has_one_Campaign', 'Campaign'), DataList::create('UniadsCampaign')->map())->setEmptyString(_t('UniadsObject.Campaign_none', 'none')), DropdownField::create('ZoneID', _t('UniadsObject.has_one_Zone', 'Zone'), DataList::create('UniadsZone')->map())->setEmptyString(_t('UniadsObject.Zone_select', 'select one')), new NumericField('Weight', _t('UniadsObject.db_Weight', 'Weight (controls how often it will be shown relative to others)')), new TextField('TargetURL', _t('UniadsObject.db_TargetURL', 'Target URL')), new Treedropdownfield('InternalPageID', _t('UniadsObject.has_one_InternalPage', 'Internal Page Link'), 'Page'), new CheckboxField('NewWindow', _t('UniadsObject.db_NewWindow', 'Open in a new Window')), $file = new UploadField('File', _t('UniadsObject.has_one_File', 'Advertisement File')), $AdContent = new TextareaField('AdContent', _t('UniadsObject.db_AdContent', 'Advertisement Content')), $Starts = new DateField('Starts', _t('UniadsObject.db_Starts', 'Starts')), $Expires = new DateField('Expires', _t('UniadsObject.db_Expires', 'Expires')), new NumericField('ImpressionLimit', _t('UniadsObject.db_ImpressionLimit', 'Impression Limit')), new CheckboxField('Active', _t('UniadsObject.db_Active', 'Active')), new LiteralField('Preview', '<a href="' . $previewLink . '" target="_blank">' . _t('UniadsObject.Preview', 'Preview this advertisement') . "</a>"))); $app_categories = File::config()->app_categories; $file->setFolderName($this->config()->files_dir); $file->getValidator()->setAllowedMaxFileSize(array('*' => $this->config()->max_file_size)); $file->getValidator()->setAllowedExtensions(array_merge($app_categories['image'], $app_categories['flash'])); $AdContent->setRows(10); $AdContent->setColumns(20); $Starts->setConfig('showcalendar', true); $Starts->setConfig('dateformat', i18n::get_date_format()); $Starts->setConfig('datavalueformat', 'yyyy-MM-dd'); $Expires->setConfig('showcalendar', true); $Expires->setConfig('dateformat', i18n::get_date_format()); $Expires->setConfig('datavalueformat', 'yyyy-MM-dd'); $Expires->setConfig('min', date('Y-m-d', strtotime($this->Starts ? $this->Starts : '+1 days'))); } $this->extend('updateCMSFields', $fields); return $fields; }
public function scaffoldFormField($title = null, $params = null) { if (empty($this->object)) { return null; } $relationName = substr($this->name, 0, -2); $hasOneClass = $this->object->hasOneComponent($relationName); if ($hasOneClass && singleton($hasOneClass) instanceof Image) { $field = new UploadField($relationName, $title); $field->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif')); } elseif ($hasOneClass && singleton($hasOneClass) instanceof File) { $field = new UploadField($relationName, $title); } else { $titleField = singleton($hasOneClass)->hasField('Title') ? "Title" : "Name"; $list = DataList::create($hasOneClass); // Don't scaffold a dropdown for large tables, as making the list concrete // might exceed the available PHP memory in creating too many DataObject instances if ($list->count() < 100) { $field = new DropdownField($this->name, $title, $list->map('ID', $titleField)); $field->setEmptyString(' '); } else { $field = new NumericField($this->name, $title); } } return $field; }
public function __construct(CalendarEvent $event) { $this->event = $event; $this->datetimeClass = $event->Parent()->getDateTimeClass(); $this->eventClass = $event->Parent()->getEventClass(); $relation = $event->Parent()->getDateToEventRelation(); if ($datetime = DataList::create($this->datetimeClass)->where("{$relation} = {$event->ID}")->first()) { $this->ts = strtotime($datetime->StartDate); } if ($event->CustomRecursionType == 2) { if ($days_of_week = $event->getManyManyComponents('RecurringDaysOfWeek')) { foreach ($days_of_week as $day) { $this->allowedDaysOfWeek[] = $day->Value; } } } else { if ($event->CustomRecursionType == 3) { if ($days_of_month = $event->getManyManyComponents('RecurringDaysOfMonth')) { foreach ($days_of_month as $day) { $this->allowedDaysOfMonth[] = $day->Value; } } } } if ($exceptions = $event->getComponents('Exceptions')) { foreach ($exceptions as $exception) { $this->exceptions[] = $exception->ExceptionDate; } } }
public function doSearch($gridField, $request) { $dataClass = $gridField->getList()->dataClass(); $allList = $this->searchList ? $this->searchList : DataList::create($dataClass); $searchFields = $this->getSearchFields() ? $this->getSearchFields() : $this->scaffoldSearchFields($dataClass); if (!$searchFields) { throw new LogicException(sprintf('GridFieldAddExistingAutocompleter: No searchable fields could be found for class "%s"', $dataClass)); } $params = array(); foreach ($searchFields as $searchField) { $name = strpos($searchField, ':') !== FALSE ? $searchField : "{$searchField}:StartsWith"; $params[$name] = $request->getVar('gridfield_relationsearch'); } if (!$gridField->getList() instanceof UnsavedRelationList) { $allList = $allList->subtract($gridField->getList()); } $results = $allList->filterAny($params)->sort(strtok($searchFields[0], ':'), 'ASC')->limit($this->getResultsLimit()); $json = array(); $originalSourceFileComments = Config::inst()->get('SSViewer', 'source_file_comments'); Config::inst()->update('SSViewer', 'source_file_comments', false); foreach ($results as $result) { $json[$result->ID] = html_entity_decode(SSViewer::fromString($this->resultsFormat)->process($result)); } Config::inst()->update('SSViewer', 'source_file_comments', $originalSourceFileComments); return Convert::array2json($json); }
public function index() { $grid = new Datagrid('testgrid'); $dataSource = DataList::create("DatagridTest_Person")->sort("Name"); $grid->setDataSource($dataSource); $form = new Form($this, 'gridform', new FieldList($grid), new FieldList(new FormAction('rerender', 'rerender'))); return array('Form' => $form); }
/** * return the current page * @return {DataList} */ public function getPage() { if ($this->page == null) { return $this->page = DataList::create('Page')->byID($this->id); } else { return $this->page; } }
/** * Build the SQLQuery to calculate the aggregate * This is a seperate function so that subtypes of Aggregate can change just this bit * @param string $attr - the SQL field statement for selection (i.e. "MAX(LastUpdated)") * @return SQLQuery */ protected function query($attr) { $query = DataList::create($this->type)->where($this->filter); $query->setSelect($attr); $query->setOrderBy(array()); $singleton->extend('augmentSQL', $query); return $query; }
public function scaffoldFormField($title = null, $params = null) { $titleField = $this->object->hasField('Title') ? 'Title' : 'Name'; $map = DataList::create(get_class($this->object))->map('ID', $titleField); $field = new DropdownField($this->name, $title, $map); $field->setEmptyString(' '); return $field; }
public function PagedDataObjectsByClassName($klazz, $pageLength = 10, $sort = 'ASC') { $req = Controller::curr()->getRequest(); $this->lastPagedResults = new PaginatedList(DataList::create($klazz)->sort('LastEdited ' . $sort), $req); $this->lastPagedResults->setPageLength($pageLength); $this->lastPagedResults->setLimitItems($pageLength); return $this->lastPagedResults; }
function testDataListArrayAccess() { $list = DataList::create("DataObjectTest_Team")->sort("Title"); // We can use array access to refer to single items in the DataList, as if it were an array $this->assertEquals("Subteam 1", $list[0]->Title); $this->assertEquals("Subteam 3", $list[2]->Title); $this->assertEquals("Team 2", $list[4]->Title); }
public function removeAll() { parent::removeAll(); $items = \DataList::create($this->dataClass); foreach ($items as $item) { $item->extend('onAfterManyManyRelationRemove'); } }
function __get($class) { if(isset($this->customDataLists[$class])) { return clone $this->customDataLists[$class]; } else { $list = DataList::create($class); $list->setModel($this); return $list; } }
/** * @param int $itemID */ public function removeByID($itemID) { $result = parent::removeByID($itemID); $item = \DataList::create($this->dataClass)->byId($itemID); if ($item instanceof $this->dataClass) { $item->extend('onAfterManyManyRelationRemove'); } return $result; }
public function OtherDates() { if ($this->Announcement()) { return false; } if ($this->Event()->Recursion) { return $this->Event()->Parent()->getNextRecurringEvents($this->Event(), $this); } return DataList::create($this->class)->where("EventID = {$this->EventID}")->where("StartDate != '{$this->StartDate}'")->limit($this->Event()->Parent()->OtherDatesCount); }
/** * Get the products customers also bought * (Haha so many sub queries...) * * @return \SS_List */ public function CustomersAlsoBought() { if (($orderItemClass = $this->owner->config()->order_item) && ($orderItem = singleton($orderItemClass)) && ($buyableRel = $orderItem->owner->config()->buyable_relationship)) { $buyableRel = $buyableRel . 'ID'; $baseClass = \ClassInfo::baseDataClass($this->owner); // Had to use EXISTS because IN () not compatible with SS DataModel return $this->owner->get()->where('EXISTS(' . \DataList::create($orderItemClass)->where('EXISTS(' . str_replace(['FROM "OrderAttribute"', '"OrderAttribute".', 'OrderAttribut||e'], ['FROM "OrderAttribute" AS "OrderAttribute1"', '"OrderAttribute1".', 'OrderAttribute'], \DataList::create($orderItemClass)->leftJoin('Order', "\"OrderAttribute\".\"OrderID\" = \"Order\".\"ID\"")->where("\"{$buyableRel}\" = {$this->owner->ID}")->where('"Order"."Status" != \'Cart\'')->where('"OrderAttribute1"."OrderID" = "OrderAttribut||e"."OrderID"')->dataQuery()->getFinalisedQuery(['"OrderAttribute"."OrderID"'])->sql()) . ')')->where("\"{$buyableRel}\" != " . $this->owner->ID)->where("\"{$baseClass}\".\"ID\" = \"{$orderItemClass}\".\"{$buyableRel}\"")->dataQuery()->getFinalisedQuery([$buyableRel])->sql() . ')'); } return \ArrayList::create(); }
public function RenderPortlet($model, $where, $ordering, $amount, $template, $joinTable = '', $joinOn = '') { $result = null; //$records = DataList::DataObject::get( $model, $where, $ordering, '', $amount ); $records = DataList::create($model)->where($where)->sort($ordering)->limit($amount); if ($joinTable) { $records->leftJoin($joinTable, $joinOn); } return $this->owner->customise(new ArrayData(array('Records' => $records)))->renderWith($template); }
public function view() { $id = (int) $this->getRequest()->param('ID'); if ($id) { $email = DataList::create('CapturedEmail')->byID($id); if ($email) { return array('Email' => $email); return $this->customise()->renderWith('CapturedEmailController_view'); } } }
/** * @var bool * * @throws Exception */ public static function requireRecords($force = false) { if (self::$ran && !$force) { return true; } self::$ran = true; if (!(Director::isDev() || Director::isTest())) { throw new Exception('requireRecords can only be run in development or test environments'); } $factory = Injector::inst()->create('PopulateFactory'); foreach (self::config()->get('truncate_objects') as $objName) { $versions = array(); if (class_exists($objName)) { foreach (DataList::create($objName) as $obj) { // if the object has the versioned extension, make sure we delete // that as well if ($obj->hasExtension('Versioned')) { foreach ($obj->getVersionedStages() as $stage) { $versions[$stage] = true; $obj->deleteFromStage($stage); } } try { @$obj->delete(); } catch (Exception $e) { // notice } } } if ($versions) { self::truncate_versions($objName, $versions); } foreach ((array) ClassInfo::getValidSubClasses($objName) as $table) { self::truncate_table($table); self::truncate_versions($table, $versions); } self::truncate_table($objName); } foreach (self::config()->get('include_yaml_fixtures') as $fixtureFile) { $fixture = new YamlFixture($fixtureFile); $fixture->writeInto($factory); $fixture = null; } // hook allowing extensions to clean up records, modify the result or // export the data to a SQL file (for importing performance). $static = !(isset($this) && get_class($this) == __CLASS__); if ($static) { $populate = Injector::inst()->create('Populate'); } else { $populate = $this; } $populate->extend('onAfterPopulateRecords'); return true; }
/** * @param \SS_HTTPRequest $request * @return array */ public function process(\SS_HTTPRequest $request) { $httpMethod = $request->httpMethod(); if ($httpMethod == 'POST' && $request->param('ID') == 'complete') { //get the payment dps txnref from the database //1. Get session id for transaction from state //2. Get payment from storage //3. Use txn ref from storage to complete the payment $sessionId = $this->state->getByKey(self::IDENTIFIER . '.sessionid'); if ($sessionId) { // get the PXFusion payment associated with this sessionid $payment = \DataList::create('StoredPXFusionPayment')->filter("SessionId", $sessionId)->first(); if ($payment instanceof \StoredPXFusionPayment && $payment->DpsTxnRef) { // Set the transaction status to processing $this->transaction->setStatus('Processing'); // Keep track of the payment status $paymentSuccessful = false; $storedPxPostPayment = false; $paymentResponse = $this->paymentService->completeTransaction($payment->DpsTxnRef); if ($paymentResponse instanceof PXPostPaymentResponse) { // Store the payment response $storedPxPostPayment = $this->storage->process($paymentResponse)[Backend::IDENTIFIER]; $paymentResponse->updateTransaction($this->transaction); $paymentSuccessful = (bool) $paymentResponse->Success; } // store the transaction $storedTransaction = $this->storage->process($this->transaction)[Backend::IDENTIFIER]; $payment->ParentID = $storedTransaction->ID; if ($storedPxPostPayment && $storedTransaction) { // set the parents of each object $payment->PXPostPaymentID = $storedPxPostPayment->ID; $payment->write(); $storedPxPostPayment->ParentID = $storedTransaction->ID; $storedPxPostPayment->write(); } else { $payment->write(); return ['Success' => false]; } return ['Success' => $paymentSuccessful, 'Complete' => true, 'Data' => $paymentResponse]; } } } elseif ($httpMethod == 'GET' && $request->param('ID') == 'check') { $paymentResponse = $this->paymentService->checkTransaction($request->getVar('sessionid')); $this->state->setByKey(self::IDENTIFIER . '.sessionid', $request->getVar('sessionid')); $this->storage->process($paymentResponse); if ($paymentResponse->StatusCode === 0) { return ['Success' => true, 'Data' => $paymentResponse]; } else { return ['Success' => false, 'CheckFailure' => true]; } } return ['Success' => false]; }
public function jobqueueExecute($jobId) { $this->queuedJobService->checkJobHealth(); $job = DataList::create('QueuedJobDescriptor')->byID($jobId); if ($job) { // check that we're not trying to execute something tooo soon if (strtotime($job->StartAfter) > time()) { return; } $this->queuedJobService->runJob($jobId); } }
/** static $icon = "icon/path"; */ function getCMSFields() { $fields = parent::getCMSFields(); $drop = new DropdownField('CurrentElectionID', 'Select An Election', ElectionPage::get()->map('ID', 'Title')); $drop->setEmptyString('No Election'); $fields->addFieldToTab('Root.CurrentElection', $drop); $elections_config = GridFieldConfig_RecordEditor::create(); $elections = DataList::create('ElectionPage'); $elections_grid = new GridField('All Elections Grid', 'Elections', $elections, $elections_config); $fields->addFieldToTab('Root.CurrentElection', $elections_grid); return $fields; }
public function results() { $keyword = Convert::raw2sql($this->query); $partialkeywords = implode("* ", explode(" ", $keyword)) . "*"; $keywordHTML = htmlentities($keyword, ENT_NOQUOTES, 'UTF-8'); $fields = implode(",", $this->fields ? $this->fields : $this->getSearchableFields()); $siteTreeMatch = "MATCH({$fields}) AGAINST ('{$partialkeywords}' IN BOOLEAN MODE)\n\t\t\t\t\t\t+ MATCH({$fields}) AGAINST ('{$keywordHTML}' IN BOOLEAN MODE)"; $pagetype = $this->getPageType(); $results = DataList::create($pagetype)->where($siteTreeMatch)->filter("ShowInSearch", 1); $results->sort(array('Relevance' => 'DESC', 'Title' => 'ASC')); $this->getSearchableFields(); return $results; }