/** * Loads or creates the file * * @return void * @author Dan Cox */ public function loadOrCreate() { if ($this->fs->exists(LOGS . $this->file)) { $this->config->load(LOGS . $this->file); } else { $this->config->create(LOGS . $this->file); $this->config->params()->created = array('date' => date('Y-m-d H:i:s')); $this->config->params()->log = array(); $this->config->save(); } }
function requireDefaultModuleRecords($relationName = 'Modules') { if (($defaults = $this->owner->Config()->get('default_modules')) && is_array($defaults) && count($defaults)) { if (isset($defaults[$relationName])) { $defaults = $defaults[$relationName]; } $area = $this->owner->obj($relationName); if ($area && $area->exists()) { $modules = $area->Modules(); if (!$modules->count()) { for ($i = 0; $i < count($defaults); $i++) { if (class_exists($defaults[$i]['ClassName'])) { $s = Object::create($defaults[$i]['ClassName']); $s->ModuleAreaID = $area->ID; $s->SortOrder = $i; foreach ($defaults[$i]['Properties'] as $k => $v) { $s->{$k} = $v; } $s->write(); } } } } } }
/** * SSCompactNavigator first checks if you are allowed to see the navigation bar, and if so, then checks * if third party templates have been specified. If so, it loads them, and provides them with the required * variables. If not, it loads the defaults instead. */ public function SSCompactNavigator() { if (Director::isDev() || Permission::check('CMS_ACCESS_CMSMain')) { $RenderTemplate = isset(CompactNavigator::$Template) ? CompactNavigator::$Template : $this->class; if (isset(CompactNavigator::$CssTheme)) { Requirements::css(CompactNavigator::$CssTheme); } else { Requirements::css('compactnavigator/css/CompactNavigator.css'); } if (isset(CompactNavigator::$JsTheme)) { Requirements::javascript(CompactNavigator::$JsTheme); } else { Requirements::javascript('compactnavigator/scripts/CompactNavigator.js'); } if (class_exists("CMSMain")) { $this->owner->cmsLink = Controller::join_links(singleton("CMSMain")->Link("edit"), "show"); } $this->owner->adminLink = self::$adminLink; if ($date = Versioned::current_archived_date()) { $this->owner->DisplayMode = 'Archived'; $this->owner->ArDate = Object::create('Datetime', $date, null); } else { $this->owner->DisplayMode = Versioned::current_stage(); } return $this->owner->renderWith(array($RenderTemplate, 'CompactNavigatior')); } }
/** * Form used for displaying the currently logged items */ public function LogsForm() { $fields = new FieldList(DropdownField::create('CalledMethod', _t('KapostBridgeLogViewer.CALLED_METHOD', '_Called Method'), array('blogger.getUsersBlogs' => 'blogger.getUsersBlogs', 'kapost.getPreview' => 'kapost.getPreview', 'metaWeblog.editPost' => 'metaWeblog.editPost', 'metaWeblog.getCategories' => 'metaWeblog.getCategories', 'metaWeblog.getPost' => 'metaWeblog.getPost', 'metaWeblog.newMediaObject' => 'metaWeblog.newMediaObject', 'metaWeblog.newPost' => 'metaWeblog.newPost', 'system.listMethods' => 'system.listMethods'))->setEmptyString('--- ' . _t('KapostBridgeLogViewer.FILTER_BY_METHOD', '_Filter by Method') . ' ---'), $startDate = new DatetimeField('LogStartDate', _t('KapostBridgeLogViewer.START_DATE_TIME', '_Start Date/Time')), $endDate = new DatetimeField('LogEndDate', _t('KapostBridgeLogViewer.END_DATE_TIME', '_End Date/Time'))); $startDate->getDateField()->setConfig('showcalendar', true); $endDate->getDateField()->setConfig('showcalendar', true); $actions = new FieldList(FormAction::create('doApplyFilters', _t('KapostBridgeLogViewer.APPLY_FILTER', '_Apply Filter'))->addExtraClass('ss-ui-action-constructive')->setUseButtonTag(true), Object::create('ResetFormAction', 'clear', _t('KapostBridgeLogViewer.RESET', '_Reset'))->setUseButtonTag(true)); $form = new Form($this, 'LogsForm', $fields, $actions); $form->addExtraClass('log-search-form')->setFormMethod('GET')->setFormAction($this->Link())->disableSecurityToken()->unsetValidator(); // Load the form with previously sent search data $getVars = $this->request->getVars(); //Workaround for start date field with no date or time if (array_key_exists('LogStartDate', $getVars)) { if (array_key_exists('date', $getVars['LogStartDate']) && !array_key_exists('time', $getVars['LogStartDate'])) { $getVars['LogStartDate']['time'] = '00:00:00'; } else { if (!array_key_exists('date', $getVars['LogStartDate']) && array_key_exists('time', $getVars['LogStartDate'])) { unset($getVars['LogStartDate']); //Remove if there is no date present } } } //Workaround for end date field with no date or time if (array_key_exists('LogEndDate', $getVars)) { if (array_key_exists('date', $getVars['LogEndDate']) && !array_key_exists('time', $getVars['LogEndDate'])) { $getVars['LogEndDate']['time'] = '23:59:59'; } else { if (!array_key_exists('date', $getVars['LogEndDate']) && array_key_exists('time', $getVars['LogEndDate'])) { unset($getVars['LogEndDate']); //Remove if there is no date present } } } $form->loadDataFrom($getVars); return $form; }
public function getCMSFields() { $this->beforeExtending('updateCMSFields', function ($fields) { $fields->removeByName('ParentID'); $fields->removeByName('AddThis'); $fields->addFieldsToTab('Root.Main', [TextField::create('AddThis', _t('SocialFeed.ADDTHIS', 'Add This Profile'))->setDescription(_t('SocialFeed.DESC-ADDTHIS', 'AddThis Profile ID used for sharing (format: <strong>ra-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</strong>)'))]); foreach (HasProfiles::get_connected_relations() as $relation) { $fields->removeByName($relation); } if (count($this->RequiresExtendedPermissions)) { \Object::create($this->Provider, 0, (array) $this->OauthConfiguration)->extendedPermissions($this->RequiresExtendedPermissions, false); } }); $this->afterExtending('updateCMSFields', function ($fields) { $dataFields = $fields->dataFields(); foreach ($dataFields as $field) { if ($field instanceof \TextField) { if (!$field->getAttribute('placeholder')) { $field->setAttribute('placeholder', $this->setting($field->Name)); } } } }); return parent::getCMSFields(); }
private function getRowTemplate(GridField $grid, GridFieldEditableColumns $editable) { $columns = new ArrayList(); $handled = array_keys($editable->getDisplayFields($grid)); if ($grid->getList()) { $record = Object::create($grid->getModelClass()); } else { $record = null; } $fields = $editable->getFields($grid, $record); foreach ($grid->getColumns() as $column) { if (in_array($column, $handled)) { $field = $fields->dataFieldByName($column); $field->setName(sprintf('%s[%s][{%%=o.num%%}][%s]', $grid->getName(), __CLASS__, $field->getName())); $content = $field->Field(); } else { $content = null; } $attrs = ''; foreach ($grid->getColumnAttributes($record, $column) as $attr => $val) { $attrs .= sprintf(' %s="%s"', $attr, Convert::raw2att($val)); } $columns->push(new ArrayData(array('Content' => $content, 'Attributes' => $attrs, 'IsActions' => $column == 'Actions'))); } return $columns->renderWith('GridFieldAddNewInlineRow'); }
public function handleItem($gridField, $request) { $controller = $gridField->getForm()->Controller(); $record = $gridField->getList()->byId($request->param("ID")); $handler = Object::create('GridFieldExpandableForm_ItemRequest', $gridField, $this, $record, $controller, 'DetailForm', $this->formorfields); return $handler->handleRequest($request, DataModel::inst()); }
function testFilterWithTransliterator() { $name = 'Brötchen für allë-mit_Unterstrich!.jpg'; $filter = new FileNameFilter(); $filter->setTransliterator(Object::create('Transliterator')); $this->assertEquals('Broetchen-fuer-alle-mit-Unterstrich.jpg', $filter->filter($name)); }
/** * Returns an array of all implementors of the `IIndicator` interface. * * @return IIndicator[] list of all implementors */ public static function get_all() { $indicators = \ClassInfo::implementorsOf(self::$interface_name); return array_map(function ($indicatorName) { return \Object::create($indicatorName); }, $indicators); }
public function addfield($gridField, $request) { $controller = $gridField->getForm()->Controller(); $record = singleton('MetadataField'); $handler = Object::create('MetaDataFieldAddForm_ItemRequest', $gridField, $this, $record, $controller, $this->name); $handler->setTemplate($this->template); return $handler->handleRequest($request, DataModel::inst()); }
/** * @param string $type - must in the drivers array * @param string $repoID * @return DeployHostAPI * @throws Exception */ public static function factory($type, $repoID) { if (in_array($type, Config::inst()->get('DeployHostAPI', 'drivers'))) { return Object::create($type, $repoID); } else { throw new Exception('Invalid DeployHostAPI driver type requested.'); } }
function __construct($name, $title = null, $value = "") { $this->config = self::$default_config; $this->dateField = Object::create('DateField', $name . '[date]', false); $this->timeField = Object::create('TimeField', $name . '[time]', false); $this->timezoneField = new HiddenField($this->Name() . '[timezone]'); parent::__construct($name, $title, $value); }
function FieldHolder() { // TODO Replace with properly extensible view helper system $d = Object::create('DateField_View_JQuery', $this); $d->onBeforeRender(); $html = parent::FieldHolder(); $html = $d->onAfterRender($html); return $html; }
function parameterFields() { $params = new FieldSet(); $params->push($startDate = Object::create('DatetimeField', 'StartDate', 'Start date')); $params->push($endDate = Object::create('DatetimeField', 'EndDate', 'End date')); $startDate->getTimeField()->setValue('23:59:59'); $endDate->getTimeField()->setValue('23:59:59'); return $params; }
public function run() { DB::table('objects')->delete(); $success = File::cleanDirectory($this->getImagesPath()); File::put($this->getImagesPath() . '.gitignore', File::get(public_path() . '/../app/storage/cache/.gitignore')); Object::create(['name' => '202', 'unit' => '3D', 'bedrooms' => '3BD', 'bathrooms' => '2', 'interior' => '1200', 'exterior' => '1200', 'price' => '$2,050,000', 'common_charges' => '1200', 'taxes' => '$612', 'floor_plan_link' => 'http://adminsage.com/db/54/assets/unitplans/2b.pdf', 'shown' => 1]); Object::create(['name' => '203', 'unit' => '4C', 'bedrooms' => '1BD', 'bathrooms' => '1', 'interior' => '700', 'exterior' => '700', 'price' => '$1,685,000', 'common_charges' => '800', 'taxes' => '$480', 'floor_plan_link' => 'http://adminsage.com/db/54/assets/unitplans/3f.pdf', 'shown' => 1]); Object::create(['name' => '204', 'unit' => '8B', 'bedrooms' => '2BD', 'bathrooms' => '1', 'interior' => '900', 'exterior' => '900', 'price' => '$1,695,000', 'common_charges' => '2000', 'taxes' => '$483', 'floor_plan_link' => 'http://adminsage.com/db/54/assets/unitplans/4d.pdf', 'shown' => 1]); }
public function SimpleFieldHolder() { $d = Object::create('DateField_View_JQuery', $this->owner); $d->onBeforeRender(); $class = 'field date ' . $this->owner->XML_val('extraClass'); $html = '<span class="' . $class . '">' . $this->owner->Field() . '</span>'; $html = $d->onAfterRender($html); return $html; }
public function __construct($controller) { $searchText = isset($_REQUEST['Search']) ? $_REQUEST['Search'] : ''; $fields = Object::create('FieldList', Object::create('TextField', 'Search', '', $searchText)); $actions = Object::create('FieldList', Object::create('FormAction', 'ZendSearchLuceneResults', _t('SearchForm.GO', 'Go'))); parent::__construct($controller, 'ZendSearchLuceneForm', $fields, $actions); $this->disableSecurityToken(); $this->setFormMethod('get'); }
public function saveUsername($value) { if (!$this->ChannelId && $this->Username != $value) { $ids = \Object::create($this->Provider, 0, (array) $this->OauthConfiguration)->channelSearch($value, ['query' => ['key' => $this->setting('ApiKey')]]); if (count($ids) && isset($ids[0]) && isset($ids[0]['id'])) { $this->ChannelId = $ids[0]['id']; } } $this->Username = $value; }
function testObjectsToDeleteOnUnpublishIfVirtualExists() { $redir = Object::create('PublishableSiteTreeTest_Publishable'); $redir->Title = 'virtual'; $stub = $this->getMock('PublishableSiteTreeTest_Publishable', array('getMyVirtualPages')); $stub->Title = 'stub'; $stub->expects($this->once())->method('getMyVirtualPages')->will($this->returnValue(new ArrayList(array($redir)))); $objects = $stub->objectsToDelete(array('action' => 'unpublish')); $this->assertTrue(in_array('virtual', $objects->column('Title'), 'Deletes related virtual page')); }
/** * Creates a report template instance if one does not exist. */ protected function onBeforeWrite() { parent::onBeforeWrite(); if (!$this->ReportTemplateID && $this->ReportType && ClassInfo::exists($this->ReportType)) { $template = Object::create($this->ReportType); $template->Title = $this->Title; $template->write(); $this->ReportTemplateID = $template->ID; } }
/** * Makes $SearchForm included in many stock templates return a Lucene form * analogous to the one that the FulltextSearchable extension outputs. Uses * the SearchForm.ss template that comes with Sapphire (or an overridden * custom version if one is available, as per the regular SearchForm). * * @return String The rendered form, for inclusion into the page template. */ public function SearchForm() { $form = $this->ZendSearchLuceneForm(); // Use the same CSS as the stock search form... $form->setHTMLId('SearchForm_SearchForm'); $actions = $form->Actions(); $action = Object::create('FormAction', 'results', _t('SearchForm.GO', 'Go')); $action->setForm($form); $actions->replaceField('action_ZendSearchLuceneResults', $action); return $form->renderWith(array('SearchForm', 'Page')); }
public function saveUsername($value) { if (!$this->LocationAndUsername && ($this->Username != $value || !$this->LocationAddress) && $this->setting('ApiKey')) { $details = \Object::create($this->Provider, 0, (array) $this->OauthConfiguration)->details((array) $this->FeedSettings); if (isset($details['name'])) { $this->LocationName = $details['name']; } $this->LocationAddress = isset($details['formatted_address']) ? $details['formatted_address'] : 'N/A'; } $this->Username = $value; }
public function UnsubscribeRequestForm() { $fields = new FieldList(EmailField::create('email', _t("Newsletter.UnsubscribeEmail", "Your subscription email address"))); $actions = new FieldList(FormAction::create('sendLink', _t('Newsletter.SendUnsubscribeLink', 'Send unsubscribe link'))->addExtraClass('ss-ui-action-constructive'), Object::create('ResetFormAction', 'clear', _t('CMSMain_left.ss.RESET', 'Reset'))); $unsubscribeController = new UnsubscribeController(); $form = NewsletterContentControllerExtension::getUnsubscribeFormObject($this, $fields, $actions); $form->setFormMethod('GET'); $form->setFormAction(Controller::join_links(Director::absoluteBaseURL(), $unsubscribeController->relativeLink('sendUnsubscribeLink'))); $form->addExtraClass('cms-search-form'); return $form; }
/** * The "default" structure used for this report when auto generating etc */ public function onBeforeWrite() { parent::onBeforeWrite(); if (!$this->ReportTemplateID && $this->ReportType && ClassInfo::exists($this->ReportType)) { $template = Object::create($this->ReportType); // create the template first. This is what all actual reports are based on when they're generated, either // automatically or by the 'generate' button $template->Title = $this->Title . ' Preview'; $template->write(); $this->ReportTemplateID = $template->ID; } }
/** * * * @return IStatisticAdapter * @throws \Exception */ public static function create() { $host = \Config::inst()->get('AdapterFactory', 'Host'); $port = \Config::inst()->get('AdapterFactory', 'Port'); $type = \Config::inst()->get('AdapterFactory', 'Adapter'); $adapters = \ClassInfo::implementorsOf(self::$interface_name); if (in_array($type, $adapters)) { return \Object::create($type, $host, $port); } else { throw new \Exception("Configured adapter '{$type}' not found."); } }
/** * * @param type $gridField * @param type $request * @return GridFieldDetailForm_ItemRequest */ public function handleItem($gridField, $request) { $controller = $gridField->getForm()->Controller(); if (is_numeric($request->param('ID'))) { $record = $gridField->getList()->byId($request->param("ID")); } else { $record = Object::create($gridField->getModelClass()); } $class = $this->getItemRequestClass(); $handler = Object::create($class, $gridField, $this, $record, $controller, $this->name); $handler->setTemplate($this->template); return $handler->handleRequest($request, DataModel::inst()); }
/** * (non-PHPdoc) * @see \Rexster\Object::create() */ public function create() { if (!$this->getProperty('_inV')) { throw new \InvalidArgumentException('Missing _inV (in vertex) property'); } if (!$this->getProperty('_outV')) { throw new \InvalidArgumentException('Missing _outV (out vertex) property'); } if (!$this->getProperty('_label')) { throw new \InvalidArgumentException('Missing _label property'); } return parent::create(); }
public function getCMSFields() { $fields = new FieldList(); $fields->push(new TabSet("Root", $mainTab = new Tab("Main"))); $mainTab->setTitle(_t('SiteTree.TABMAIN', "Main")); $fields->addFieldToTab('Root.Main', new TextField('Email', $this->fieldLabel('Email'))); $fields->addFieldsToTab('Root.Main', array(Object::create('TextField', 'Salutation', $this->fieldLabel('Salutation')), Object::create('TextField', 'FirstName', $this->fieldLabel('First Name')), Object::create('TextField', 'MiddleName', $this->fieldLabel('Middle Name')), Object::create('TextField', 'Surname', $this->fieldLabel('Surname')))); if (!empty($this->ID)) { $fields->addFieldToTab('Root.Main', Object::create('CheckboxSetField', 'MailingLists', $this->fieldLabel('MailingLists'), MailingList::get()->map('ID', 'FullTitle'))); } $fields->addFieldsToTab('Root.Main', array(Object::create('ReadonlyField', 'BouncedCount', $this->fieldLabel('BouncedCount')), Object::create('CheckboxField', 'Verified', $this->fieldLabel('Verified'))->setDescription(_t('Newsletter.VerifiedDesc', 'Has this user verified his subscription?')), Object::create('CheckboxField', 'Blacklisted', $this->fieldLabel('Blacklisted'))->setDescription(_t('Newsletter.BlacklistedDesc', 'Excluded from emails, either by automated process or manually. ' . 'An invalid address or undeliverable email will eventually result in blacklisting.')), Object::create('ReadonlyField', 'ReceivedCount', $this->fieldLabel('ReceivedCount'))->setDescription(_t('Newsletter.ReceivedCountDesc', 'Number of emails sent without undeliverable errors. ' . 'Only one indication that an email has actually been received and read.')))); $this->extend('updateCMSFields', $fields); return $fields; }
public function handleItem($gridField, $request) { $controller = $gridField->getForm()->Controller(); // we can't check on is_numeric, since some datasources use strings as identifiers if ($request->param('ID') && $request->param('ID') != 'new') { $record = $gridField->getList()->byId($request->param("ID")); } else { $record = Object::create($gridField->getModelClass()); } $class = $this->getItemRequestClass(); $handler = Object::create($class, $gridField, $this, $record, $controller, $this->name); $handler->setTemplate($this->template); return $handler->handleRequest($request, DataModel::inst()); }
public function run() { Object::create(['object_id' => 1, '_class' => '女友']); Object::create(['object_id' => 2, '_class' => '闺密']); Object::create(['object_id' => 3, '_class' => '老师']); Object::create(['object_id' => 4, '_class' => '母亲']); Object::create(['object_id' => 5, '_class' => '朋友']); Object::create(['object_id' => 6, '_class' => '父亲']); Object::create(['object_id' => 7, '_class' => '女性']); Object::create(['object_id' => 8, '_class' => '男友']); Object::create(['object_id' => 9, '_class' => '基友']); Object::create(['object_id' => 10, '_class' => '情人']); Object::create(['object_id' => 11, '_class' => '情人']); }