/**
  * Provides a GUI for the insert/edit shortcode popup
  * @return Form
  **/
 public function ShortcodeForm()
 {
     if (!Permission::check('CMS_ACCESS_CMSMain')) {
         return;
     }
     Config::inst()->update('SSViewer', 'theme_enabled', false);
     // create a list of shortcodable classes for the ShortcodeType dropdown
     $classList = ClassInfo::implementorsOf('Shortcodable');
     $classes = array();
     foreach ($classList as $class) {
         $classes[$class] = singleton($class)->singular_name();
     }
     // load from the currently selected ShortcodeType or Shortcode data
     $classname = false;
     $shortcodeData = false;
     if ($shortcode = $this->request->requestVar('Shortcode')) {
         $shortcode = str_replace("", '', $shortcode);
         //remove BOM inside string on cursor position...
         $shortcodeData = singleton('ShortcodableParser')->the_shortcodes(array(), $shortcode);
         if (isset($shortcodeData[0])) {
             $shortcodeData = $shortcodeData[0];
             $classname = $shortcodeData['name'];
         }
     } else {
         $classname = $this->request->requestVar('ShortcodeType');
     }
     if ($shortcodeData) {
         $headingText = _t('Shortcodable.EDITSHORTCODE', 'Edit Shortcode');
     } else {
         $headingText = _t('Shortcodable.INSERTSHORTCODE', 'Insert Shortcode');
     }
     // essential fields
     $fields = FieldList::create(array(CompositeField::create(LiteralField::create('Heading', sprintf('<h3 class="htmleditorfield-shortcodeform-heading insert">%s</h3>', $headingText)))->addExtraClass('CompositeField composite cms-content-header nolabel'), LiteralField::create('shortcodablefields', '<div class="ss-shortcodable content">'), DropdownField::create('ShortcodeType', 'ShortcodeType', $classes, $classname)->setHasEmptyDefault(true)->addExtraClass('shortcode-type')));
     // attribute and object id fields
     if ($classname) {
         if (class_exists($classname)) {
             $class = singleton($classname);
             if (is_subclass_of($class, 'DataObject')) {
                 if (singleton($classname)->hasMethod('get_shortcodable_records')) {
                     $dataObjectSource = $classname::get_shortcodable_records();
                 } else {
                     $dataObjectSource = $classname::get()->map()->toArray();
                 }
                 $fields->push(DropdownField::create('id', $class->singular_name(), $dataObjectSource)->setHasEmptyDefault(true));
             }
             if ($attrFields = $classname::shortcode_attribute_fields()) {
                 $fields->push(CompositeField::create($attrFields)->addExtraClass('attributes-composite'));
             }
         }
     }
     // actions
     $actions = FieldList::create(array(FormAction::create('insert', _t('Shortcodable.BUTTONINSERTSHORTCODE', 'Insert shortcode'))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true)));
     // form
     $form = Form::create($this, "ShortcodeForm", $fields, $actions)->loadDataFrom($this)->addExtraClass('htmleditorfield-form htmleditorfield-shortcodable cms-dialog-content');
     if ($shortcodeData) {
         $form->loadDataFrom($shortcodeData['atts']);
     }
     $this->extend('updateShortcodeForm', $form);
     return $form;
 }
 /**
  * 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 static function Fetch($echo = false)
 {
     if ($echo) {
         echo "Fetching updates from Twitter...<br />";
     }
     $twitter_updates = SocialMediaTwitter::Fetch($echo);
     /*if ($echo) echo "Fetching updates from Facebook...<br />";
     		$facebook_updates	= SocialMediaFacebook::Fetch();
     		if ($echo) echo "Fetching updates from LinkedIn...<br />";
     		$linkedin_updates	= SocialMediaLinkedIn::Fetch();*/
     $linkedin_updates = array();
     $facebook_updates = array();
     if (false === $twitter_updates) {
         $twitter_updates = array();
     }
     //If errors happen, don't let them
     if (false === $facebook_updates) {
         $facebook_updates = array();
     }
     //interrupt the array_merge operation.
     if (false === $linkedin_updates) {
         $linkedin_updates = array();
     }
     $updates = array_merge($twitter_updates, $facebook_updates, $linkedin_updates);
     if ($echo) {
         echo count($updates) > 0 ? "Writing " . count($updates) . " updates to the database...<br />" : 'No updates to write to the database.<br />';
     }
     /**
      * @var SocialMediaImporterInterface $importer
      */
     foreach (ClassInfo::implementorsOf('SocialMediaImporterInterface') as $importer) {
         $importer::ImportUpdates($updates);
     }
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->insertAfter(new ToggleCompositeField('AfterRegistrationContent', _t('EventRegistration.AFTER_REG_CONTENT', 'After Registration Content'), array(new TextField('AfterRegTitle', _t('EventRegistration.TITLE', 'Title')), new HtmlEditorField('AfterRegContent', _t('EventRegistration.CONTENT', 'Content')))), 'Content');
     $fields->insertAfter(new ToggleCompositeField('AfterUnRegistrationContent', _t('EventRegistration.AFTER_UNREG_CONTENT', 'After Un-Registration Content'), array(new TextField('AfterUnregTitle', _t('EventRegistration.TITLE', 'Title')), new HtmlEditorField('AfterUnregContent', _t('EventRegistration.CONTENT', 'Content')))), 'AfterRegistrationContent');
     if ($this->RegEmailConfirm) {
         $fields->addFieldToTab('Root.Main', new ToggleCompositeField('AfterRegistrationConfirmation', _t('EventRegistration.AFTER_REG_CONFIRM_CONTENT', 'After Registration Confirmation Content'), array(new TextField('AfterConfirmTitle', _t('EventRegistration.TITLE', 'Title')), new HtmlEditorField('AfterConfirmContent', _t('EventRegistration.CONTENT', 'Content')))));
     }
     if ($this->UnRegEmailConfirm) {
         $fields->addFieldToTab('Root.Main', new ToggleCompositeField('AfterUnRegistrationConfirmation', _t('EventRegistration.AFTER_UNREG_CONFIRM_CONTENT', 'After Un-Registration Confirmation Content'), array(new TextField('AfterConfUnregTitle', _t('EventRegistration.TITLE', 'Title')), new HtmlEditorField('AfterConfUnregContent', _t('EventRegistration.CONTENT', 'Content')))));
     }
     $fields->addFieldToTab('Root.Tickets', new GridField('Tickets', 'Ticket Types', $this->Tickets(), GridFieldConfig_RecordEditor::create()));
     $generators = ClassInfo::implementorsOf('EventRegistrationTicketGenerator');
     if ($generators) {
         foreach ($generators as $generator) {
             $instance = new $generator();
             $generators[$generator] = $instance->getGeneratorTitle();
         }
         $generator = new DropdownField('TicketGenerator', _t('EventRegistration.TICKET_GENERATOR', 'Ticket generator'), $generators);
         $generator->setEmptyString(_t('EventManagement.NONE', '(None)'));
         $generator->setDescription(_t('EventManagement.TICKET_GENERATOR_NOTE', 'The ticket generator is used to generate a ticket file for the user to download.'));
         $fields->addFieldToTab('Root.Tickets', $generator);
     }
     $regGridFieldConfig = GridFieldConfig_Base::create()->removeComponentsByType('GridFieldAddNewButton')->removeComponentsByType('GridFieldDeleteAction')->addComponents(new GridFieldButtonRow('after'), new GridFieldPrintButton('buttons-after-left'), new GridFieldExportButton('buttons-after-left'));
     $fields->addFieldsToTab('Root.Registrations', array(new GridField('Registrations', _t('EventManagement.REGISTRATIONS', 'Registrations'), $this->DateTimes()->relation('Registrations')->filter('Status', 'Valid'), $regGridFieldConfig), new GridField('CanceledRegistrations', _t('EventManagement.CANCELLATIONS', 'Cancellations'), $this->DateTimes()->relation('Registrations')->filter('Status', 'Canceled'), $regGridFieldConfig)));
     if ($this->RegEmailConfirm) {
         $fields->addFieldToTab('Root.Registrations', new ToggleCompositeField('UnconfirmedRegistrations', _t('EventManagement.UNCONFIRMED_REGISTRATIONS', 'Unconfirmed Registrations'), array(new GridField('UnconfirmedRegistrations', '', $this->DateTimes()->relation('Registrations')->filter('Status', 'Unconfirmed')))));
     }
     $fields->addFieldToTab('Root.Invitations', new GridField('Invitations', _t('EventManagement.INVITATIONS', 'Invitations'), $this->Invitations(), GridFieldConfig_RecordViewer::create()->addComponent(new GridFieldButtonRow('before'))->addComponent(new EventSendInvitationsButton($this))));
     return $fields;
 }
 /**
  * Returns all implementors of InfoBox (all checks / box info)
  * @return array $conf
  */
 private function boxes()
 {
     $conf = array();
     $disabled = Config::inst()->get('InfoBoxes', 'disabled') ?: array();
     $checks = ClassInfo::implementorsOf('InfoBox');
     foreach ($checks as $class) {
         $inst = Injector::inst()->get($class);
         $name = explode('_', $class);
         $origClass = $class;
         if ($name[1]) {
             $class = $name[1];
         }
         if ($inst->show() && !in_array($class, $disabled) && !in_array($origClass, $disabled)) {
             $conf[$class]['type'] = $inst->severity();
             $conf[$class]['message'] = $inst->message();
             $conf[$class]['link'] = $inst->link() ?: false;
         }
     }
     function orderBoxes($a, $b)
     {
         return $a['type'] - $b['type'];
     }
     uasort($conf, 'orderBoxes');
     return $conf;
 }
 /**
  * @return FieldList 
  */
 public function getCMSFields()
 {
     // Get NotifiedOn implementors
     $types = ClassInfo::implementorsOf('NotifiedOn');
     $types = array_combine($types, $types);
     unset($types['NotifyOnThis']);
     if (!$types) {
         $types = array();
     }
     array_unshift($types, '');
     // Available keywords
     $keywords = $this->getKeywords();
     if (count($keywords)) {
         $availableKeywords = '<div class="field"><div class="middleColumn"><p><u>Available Keywords:</u> </p><ul><li>$' . implode('</li><li>$', $keywords) . '</li></ul></div></div>';
     } else {
         $availableKeywords = "Available keywords will be shown if you select a NotifyOnClass";
     }
     // Identifiers
     $identifiers = $this->config()->get('identifiers');
     if (count($identifiers)) {
         $identifiers = array_combine($identifiers, $identifiers);
     }
     $fields = FieldList::create();
     $relevantMsg = 'Relevant for (note: this notification will only be sent if the context of raising the notification is of this type)';
     $fields->push(TabSet::create('Root', Tab::create('Main', DropdownField::create('Identifier', _t('SystemNotification.IDENTIFIER', 'Identifier'), $identifiers), TextField::create('Title', _t('SystemNotification.TITLE', 'Title')), TextField::create('Description', _t('SystemNotification.DESCRIPTION', 'Description')), DropdownField::create('NotifyOnClass', _t('SystemNotification.NOTIFY_ON_CLASS', $relevantMsg), $types), TextField::create('CustomTemplate', _t('SystemNotification.TEMPLATE', 'Template (Optional)'))->setAttribute('placeholder', $this->config()->get('default_template')), LiteralField::create('AvailableKeywords', $availableKeywords))));
     if ($this->config()->html_notifications) {
         $fields->insertBefore(HTMLEditorField::create('NotificationHTML', _t('SystemNotification.TEXT', 'Text')), 'AvailableKeywords');
     } else {
         $fields->insertBefore(TextareaField::create('NotificationText', _t('SystemNotification.TEXT', 'Text')), 'AvailableKeywords');
     }
     return $fields;
 }
 /**
  * Implement this method in the task subclass to
  * execute via the TaskRunner
  */
 public function run($request)
 {
     if (!($adminEmail = $this->config()->get('administrator_email'))) {
         $contenders = $this->extend('feedMeAdminEmail') ?: [];
         $adminEmail = reset($contenders);
     }
     if ($adminEmail) {
         SS_Log::add_writer(new SS_LogEmailWriter($adminEmail, SS_Log::INFO));
     }
     // anything like a warning or above
     SS_Log::add_writer(new SS_LogEmailWriter(Security::findAnAdministrator()->Email), SS_Log::WARN);
     $excludedFeedClasses = $this->config()->get('excluded_feed_class_names');
     // for each implementor of the FeedMeFeedInterface check if it's not excluded then for each
     // instance of that model call feedMeImport on it.
     $implementors = ClassInfo::implementorsOf('FeedMeFeedModelInterface');
     foreach ($implementors as $className) {
         // chance to disable a feed by setting config.excluded_feed_class_names
         if (!in_array($className, $excludedFeedClasses)) {
             /** @var FeedMeFeedModelExtension $feedModel */
             foreach ($className::get() as $feedModel) {
                 $feedModel->feedMeImport();
             }
         }
     }
 }
 function run($request)
 {
     $this->traversed = 0;
     $this->processed = array();
     $this->traversedPageType = array();
     $this->processedPageType = array();
     $this->implementors = array();
     /*
      * Implementors inizialization
      */
     $implementros = ClassInfo::implementorsOf('SiteTreeWalkListener');
     foreach ($implementros as $implementor) {
         $this->implementors[$implementor] = new $implementor();
         if ($this->implementors[$implementor]->isEnabled()) {
             $this->processed[$implementor] = 0;
             $this->processedPageType[$implementor] = array();
         } else {
             unset($this->implementors[$implementor]);
         }
     }
     echo "Following SiteTreeWalkListener Implementors will be executed: ";
     foreach ($this->implementors as $implementor => $controller) {
         echo "\n\t* {$implementor}";
     }
     echo "\n\nContinue? [y|n]";
     $confirmation = trim(fgets(STDIN));
     if ($confirmation !== 'y') {
         // The user did not say 'y'.
         exit(0);
     }
     echo "\n";
     $rootPages = DataObject::get('SiteTree', 'ParentID=0', 'Sort ASC');
     foreach ($rootPages as $rp) {
         /* var $rp SiteTree */
         $this->processChildren($rp);
     }
     echo "\n################################################\n";
     echo "Traversed Pages: {$this->traversed}";
     if ($this->verbose) {
         echo "\n\nTraversed Page Types: ";
         foreach ($this->traversedPageType as $class) {
             echo "\n\t* {$class}";
         }
     }
     echo "\n\nProcessed Pages: ";
     foreach ($this->processed as $implementor => $num) {
         echo "\n\t{$implementor}: {$num}";
     }
     if ($this->verbose) {
         echo "\n\nProcessed Page Types: ";
         foreach ($this->processedPageType as $implementor => $classes) {
             echo "\n\t{$implementor}:";
             foreach ($classes as $class) {
                 echo "\n\t\t* {$class}";
             }
         }
     }
     echo "\n################################################\n";
 }
 /**
  * {@inheritdoc}
  */
 public function up()
 {
     $classes = ClassInfo::implementorsOf('MigratableObject');
     $this->message('Migrating legacy blog records');
     foreach ($classes as $class) {
         $this->upClass($class);
     }
 }
 public function getDataClasses()
 {
     $map = array();
     foreach (ClassInfo::implementorsOf('RegistryDataInterface') as $class) {
         $map[$class] = singleton($class)->singular_name();
     }
     return $map;
 }
 /**
  * Collect global hooks
  */
 public function collectHooks()
 {
     $implementors = ClassInfo::implementorsOf('TemplateHooks');
     if (!empty($implementors)) {
         foreach ($implementors as $implementor) {
             singleton($implementor)->initHooks();
         }
     }
 }
 /**
  * @return ICacheSerializer
  * @throws Exception
  */
 public static function get_serializer()
 {
     $availableAuths = ClassInfo::implementorsOf('ICacheSerializer');
     $type = Config::inst()->get('CacheHelper', 'SerializerType');
     if (in_array($type, $availableAuths)) {
         return $type::create();
     }
     throw new Exception("Configured cache serializer type '{$type}' not supported", 404);
 }
 /**
  * @inheritdoc
  *
  * @param SS_HTTPRequest $request
  * @param Session $session
  * @param DataModel $model
  *
  * @return bool
  */
 public function preRequest(SS_HTTPRequest $request, Session $session, DataModel $model)
 {
     if (array_key_exists('flush', $request->getVars())) {
         foreach (ClassInfo::implementorsOf('Flushable') as $class) {
             $class::flush();
         }
     }
     return true;
 }
 /**
  * Returns a new instance of an authentication mechanism depending on the configured type.
  * @return IAuth an instance of an authentication mechanism
  * @throws RestSystemException
  */
 public static function createAuth()
 {
     $availableAuths = ClassInfo::implementorsOf('IAuth');
     $type = Config::inst()->get('AuthFactory', 'AuthType');
     if (in_array($type, $availableAuths)) {
         return $type::create();
     }
     throw new RestSystemException("Configured auth type '{$type}' not supported", 404);
 }
 function testUpdater()
 {
     $mock = Phockito::mock('ArrayList');
     $this->assertContains(get_class($mock), ClassInfo::allClasses());
     $this->assertContains(get_class($mock), ClassInfo::subclassesFor('ViewableData'));
     $this->assertContains(get_class($mock), ClassInfo::implementorsOf('SS_List'));
     $mock = Phockito::mock('SS_List');
     $this->assertContains(get_class($mock), ClassInfo::allClasses());
     $this->assertContains(get_class($mock), ClassInfo::implementorsOf('SS_List'));
 }
 /**
  * Returns a new instance of a serializer depending on the given type.
  *
  * @param string $mimeType the serializer type; Default: application/json
  * @return IRestSerializer an instance of a serializer
  * @throws RestUserException
  */
 public static function create($mimeType = 'application/json')
 {
     $availableSerializers = ClassInfo::implementorsOf('IRestSerializer');
     foreach ($availableSerializers as $serializer) {
         $instance = new $serializer();
         if ($instance->contentType() == $mimeType) {
             return $instance;
         }
     }
     throw new RestUserException("Requested Accept '{$mimeType}' not supported", 404);
 }
 public function testClassInfoIsCorrect()
 {
     $this->assertContains('SilverStripe\\Framework\\Tests\\ClassI', ClassInfo::implementorsOf('PermissionProvider'));
     //because we're using a nested manifest we have to "coalesce" the descendants again to correctly populate the
     // descendants of the core classes we want to test against - this is a limitation of the test manifest not
     // including all core classes
     $method = new ReflectionMethod($this->manifest, 'coalesceDescendants');
     $method->setAccessible(true);
     $method->invoke($this->manifest, 'ModelAdmin');
     $this->assertContains('SilverStripe\\Framework\\Tests\\ClassI', ClassInfo::subclassesFor('ModelAdmin'));
 }
 public function getManagedModels()
 {
     $models = ClassInfo::implementorsOf('RegistryDataInterface');
     foreach ($models as $k => $v) {
         if (is_numeric($k)) {
             $models[$v] = array('title' => singleton($v)->i18n_singular_name());
             unset($models[$k]);
         }
     }
     return $models;
 }
 protected function BuyableClasses()
 {
     $implementors = ClassInfo::implementorsOf("Buyable");
     $classes = array();
     foreach ($implementors as $key => $class) {
         $classes = array_merge($classes, array_values(ClassInfo::subclassesFor($class)));
     }
     $classes = array_combine($classes, $classes);
     unset($classes['ProductVariation']);
     return $classes;
 }
 /**
  *
  *
  * @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.");
     }
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $types = ClassInfo::implementorsOf('FrontendCreatable');
     if (!$types) {
         $types = array();
     }
     $types = array_merge($types, self::$additional_types);
     $types = array_combine($types, $types);
     $fields->addFieldToTab('Root.Content.Main', new DropdownField('CreateType', _t('FrontendEditing.CREATE_TYPE', 'Create pages of which type?'), $types));
     $fields->addFieldToTab('Root.Content.Main', new TreeDropdownField('CreateLocationID', _t('FrontendEditing.CREATE_LOCATION', 'Create new pages where?'), 'Page'));
     return $fields;
 }
 /**
  * Default controller action
  *
  * @param SS_HTTPRequest $request
  */
 public function index(SS_HTTPRequest $request)
 {
     // Check each task
     $tasks = ClassInfo::implementorsOf('CronTask');
     if (empty($tasks)) {
         $this->output("There are no implementators of CronTask to run");
         return;
     }
     foreach ($tasks as $subclass) {
         $task = new $subclass();
         $this->runTask($task);
     }
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $importRules = $fields->dataFieldByName('Schemas');
     $importRules->getConfig()->removeComponentsByType('GridFieldAddExistingAutocompleter');
     $importRules->getConfig()->removeComponentsByType('GridFieldAddNewButton');
     $addNewButton = new GridFieldAddNewButton('after');
     $addNewButton->setButtonName("Add schema");
     $importRules->getConfig()->addComponent($addNewButton);
     $fields->removeFieldFromTab("Root", "Schemas");
     $fields->removeFieldFromTab("Root", "Pages");
     $fields->addFieldToTab("Root.Main", new LiteralField("", "<p>Each import rule will import content for a field" . " by getting the results of a CSS selector.  If more than one rule exists for a field, then they will be" . " processed in the order they appear.  The first rule that returns content will be the one used.</p>"));
     $fields->addFieldToTab("Root.Main", $importRules);
     $processingOptions = array("" => "No pre-processing");
     foreach (ClassInfo::implementorsOf('StaticSiteUrlProcessor') as $processor) {
         $processorObj = new $processor();
         $processingOptions[$processor] = "<strong>" . Convert::raw2xml($processorObj->getName()) . "</strong><br>" . Convert::raw2xml($processorObj->getDescription());
     }
     $fields->addFieldToTab("Root.Main", new OptionsetField("UrlProcessor", "URL processing", $processingOptions));
     switch ($this->urlList()->getSpiderStatus()) {
         case "Not started":
             $crawlButtonText = _t('StaticSiteContentSource.CRAWL_SITE', 'Crawl site');
             break;
         case "Partial":
             $crawlButtonText = _t('StaticSiteContentSource.RESUME_CRAWLING', 'Resume crawling');
             break;
         case "Complete":
             $crawlButtonText = _t('StaticSiteContentSource.RECRAWL_SITE', 'Re-crawl site');
             break;
         default:
             throw new LogicException("Invalid getSpiderStatus() value '" . $this->urlList()->getSpiderStatus() . ";");
     }
     $crawlButton = FormAction::create('crawlsite', $crawlButtonText)->setAttribute('data-icon', 'arrow-circle-double')->setUseButtonTag(true);
     $fields->addFieldsToTab('Root.Crawl', array(new ReadonlyField("CrawlStatus", "Crawling Status", $this->urlList()->getSpiderStatus()), new ReadonlyField("NumURLs", "Number of URLs", $this->urlList()->getNumURLs()), new LiteralField('CrawlActions', "<p>Before importing this content, all URLs on the site must be crawled (like a search engine does). Click" . " the button below to do so:</p>" . "<div class='Actions'>{$crawlButton->forTemplate()}</div>")));
     if ($this->urlList()->getSpiderStatus() == "Complete") {
         $urlsAsUL = "<ul>";
         foreach (array_unique($this->urlList()->getProcessedURLs()) as $raw => $processed) {
             if ($raw == $processed) {
                 $urlsAsUL .= "<li>{$processed}</li>";
             } else {
                 $urlsAsUL .= "<li>{$processed} <em>(was: {$raw})</em></li>";
             }
         }
         $urlsAsUL .= "</ul>";
         $fields->addFieldToTab('Root.Crawl', new LiteralField('CrawlURLList', "<p>The following URLs have been identified:</p>" . $urlsAsUL));
     }
     $fields->dataFieldByName("ExtraCrawlUrls")->setDescription("Add URLs that are not reachable through content scraping, eg: '/about/team'. One per line")->setTitle('Additional URLs');
     $fields->dataFieldByName("UrlExcludePatterns")->setDescription("URLs that should be excluded (support regular expression). eg: '/about/.*'. One per URL")->setTitle('Excluded URLs');
     return $fields;
 }
 public function allPermissions()
 {
     if (!$this->allPermissions) {
         $options = array();
         $definers = ClassInfo::implementorsOf('PermissionDefiner');
         $perms = array();
         foreach ($definers as $definer) {
             $cls = new $definer();
             $perms = array_merge($perms, $cls->definePermissions());
         }
         $this->allPermissions = $perms;
     }
     return $this->allPermissions;
 }
 public function getSettingsFields()
 {
     $dataTypes = $this->getAvailableTypes();
     $reportable = $this->getReportableFields();
     $converted = array();
     foreach ($reportable as $k => $v) {
         $converted[$this->dottedFieldToUnique($k)] = $v;
     }
     $dataTypes = array_merge(array('' => ''), $dataTypes);
     $types = new MultiValueDropdownField('DataTypes', _t('AdvancedReport.DATA_TYPES', 'Data types'), $dataTypes);
     $fieldsGroup = new FieldGroup('Fields', $reportFieldsSelect = new MultiValueDropdownField('ReportFields', _t('AdvancedReport.REPORT_FIELDS', 'Report Fields'), $reportable));
     $fieldsGroup->push(new MultiValueTextField('ReportHeaders', _t('AdvancedReport.HEADERS', 'Header labels')));
     $fieldsGroup->addExtraClass('reportMultiField');
     $reportFieldsSelect->addExtraClass('reportFieldsSelection');
     $fieldsGroup->setName('FieldsGroup');
     $fieldsGroup->addExtraClass('advanced-report-fields dropdown');
     $conditions = new FieldGroup('Conditions', new MultiValueDropdownField('ConditionFields', _t('AdvancedReport.CONDITION_FIELDS', 'Condition Fields'), $reportable), new MultiValueDropdownField('ConditionOps', _t('AdvancedReport.CONDITION_OPERATIONS', 'Op'), $this->config()->allowed_conditions), new MultiValueTextField('ConditionValues', _t('AdvancedReport.CONDITION_VALUES', 'Value')));
     $conditions->setName('ConditionsGroup');
     $conditions->addExtraClass('dropdown');
     // define the group for the sort field
     $sortGroup = new FieldGroup('Sort', new MultiValueDropdownField('SortBy', _t('AdvancedReport.SORTED_BY', 'Sorted By'), $reportable), new MultiValueDropdownField('SortDir', _t('AdvancedReport.SORT_DIRECTION', 'Sort Direction'), array('ASC' => _t('AdvancedReport.ASC', 'Ascending'), 'DESC' => _t('AdvancedReport.DESC', 'Descending'))));
     $sortGroup->setName('SortGroup');
     $sortGroup->addExtraClass('dropdown');
     // build a list of the formatters
     $formatters = ClassInfo::implementorsOf('ReportFieldFormatter');
     $fmtrs = array();
     foreach ($formatters as $formatterClass) {
         $formatter = new $formatterClass();
         $fmtrs[$formatterClass] = $formatter->label();
     }
     // define the group for the custom field formatters
     $fieldFormattingGroup = new FieldGroup(_t('AdvancedReport.FORMAT_FIELDS', 'Custom field formatting'), new MultiValueDropdownField('FieldFormattingField', _t('AdvancedReport.FIELDFORMATTING', 'Field'), $converted), new MultiValueDropdownField('FieldFormattingFormatter', _t('AdvancedReport.FIELDFORMATTINGFORMATTER', 'Formatter'), $fmtrs));
     $fieldFormattingGroup->setName('FieldFormattingGroup');
     $fieldFormattingGroup->addExtraClass('dropdown');
     // assemble the fieldlist
     $fields = new FieldList(new TextField('Title', _t('AdvancedReport.TITLE', 'Title')), new TextareaField('Description', _t('AdvancedReport.DESCRIPTION', 'Description')), $types, $fieldsGroup, $conditions, new KeyValueField('ReportParams', _t('AdvancedReport.REPORT_PARAMETERS', 'Default report parameters')), $sortGroup, new MultiValueDropdownField('NumericSort', _t('AdvancedReport.SORT_NUMERICALLY', 'Sort these fields numerically'), $reportable), DropdownField::create('PaginateBy')->setTitle(_t('AdvancedReport.PAGINATE_BY', 'Paginate By'))->setSource($reportable)->setHasEmptyDefault(true), TextField::create('PageHeader')->setTitle(_t('AdvancedReport.HEADER_TEXT', 'Header text'))->setDescription(_t('AdvancedReport.USE_NAME_FOR_PAGE_NAME', 'use $name for the page name'))->setValue('$name'), new MultiValueDropdownField('AddInRows', _t('AdvancedReport.ADD_IN_ROWS', 'Add these columns for each row'), $converted), new MultiValueDropdownField('AddCols', _t('AdvancedReport.ADD_IN_ROWS', 'Provide totals for these columns'), $converted), $fieldFormattingGroup, new MultiValueDropdownField('ClearColumns', _t('AdvancedReport.CLEARED_COLS', '"Cleared" columns'), $converted));
     if ($this->config()->allow_grouping) {
         // GroupBy
         $groupingGroup = new FieldGroup('Grouping', new MultiValueDropdownField('GroupBy', _t('AdvancedReport.GROUPBY_FIELDS', 'Group by fields'), $reportable), new MultiValueDropdownField('SumFields', _t('AdvancedReport.SUM_FIELDS', 'SUM fields'), $reportable));
         $groupingGroup->addExtraClass('dropdown');
         $fields->insertAfter($groupingGroup, 'ConditionsGroup');
     }
     if ($this->hasMethod('updateReportFields')) {
         Deprecation::notice('3.0', 'The updateReportFields method is deprecated, instead overload getSettingsFields');
         $this->updateReportFields($fields);
     }
     $this->extend('updateSettingsFields', $fields);
     return $fields;
 }
 public function handleCall($args)
 {
     if (!count($args)) {
         return;
     }
     $workerImpl = ClassInfo::implementorsOf('GearmanHandler');
     $path = array_shift($args);
     $method = array_shift($args);
     foreach ($workerImpl as $type) {
         $obj = Injector::inst()->get($type);
         if ($obj->getName() == $method) {
             call_user_func_array(array($obj, $method), $args);
         }
     }
 }
 /**
  *
  * @param StaticPagesQueue $eventClass
  * @return bool - if the event was fired or not
  * @throws Exception 
  */
 public static function fire_event(StaticPagesQueueEvent $eventClass)
 {
     if (class_exists('SapphireTest') && SapphireTest::is_running_test() && !self::$fire_test_events) {
         return false;
     }
     $eventClassName = get_class($eventClass);
     if (!array_key_exists($eventClassName, self::$events)) {
         throw new StaticPagesQueueEvent_Exception('The event "' . $eventClassName . '" has not yet been registered and therefore can\'t be triggered.');
     }
     $interfaceName = self::$events[$eventClassName];
     $implementors = ClassInfo::implementorsOf($interfaceName);
     $methodName = lcfirst(str_replace('Listener', '', $interfaceName));
     foreach ($implementors as $implementor) {
         $controller = new $implementor();
         $controller->{$methodName}($eventClass);
     }
     return true;
 }
 public function run($request)
 {
     // get all sync objects and make sure they have a contentID
     $typesToSync = ClassInfo::implementorsOf('Syncroable');
     foreach ($typesToSync as $type) {
         if ($type == 'SyncroTestObject') {
             continue;
         }
         $objs = DataObject::get($type, '"ContentID" IS NULL');
         if ($objs) {
             foreach ($objs as $obj) {
                 echo "Setting content ID for " . $obj->Title . " ... ";
                 $obj->write();
                 echo $obj->ContentID . "<br/>\n";
             }
         }
     }
 }
 /**
  * Aggiorna l'elenco delle possibili opzioni di link
  * @param Form $form
  * @return type
  */
 public function updateLinkForm($form)
 {
     Requirements::javascript(LINKABLE_DATAOBJECTS_DIR . "/javascript/linkable-dataobjects.js");
     $fields = $form->Fields();
     /* @var $linkTipe CompositeField */
     $compositeField = $fields[1];
     /* @var $linkTipe OptionsetField */
     $linkTipe = $fields[1]->fieldByName("LinkType");
     $options = $linkTipe->getSource();
     $linkables = ClassInfo::implementorsOf('Linkable');
     foreach ($linkables as $class) {
         $identifier = str_replace('\\', '-', strtolower($class));
         $options[$identifier] = $class::LinkLabel();
         $linkTipe->setSource($options);
         $dropdown = new DropdownField($identifier, _t('HtmlEditorField.NEWS', $class::LinkLabel()), $class::get()->map('ID', 'Title'));
         $dropdown->addExtraClass('linkabledo');
         $compositeField->insertBefore($dropdown, 'Description');
     }
     return $form;
 }
 public function getCMSFields()
 {
     Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
     Requirements::javascript(THIRDPARTY_DIR . '/jquery-livequery/jquery.livequery.js');
     Requirements::javascript('eventmanagement/javascript/RegisterableEventCms.js');
     $fields = parent::getCMSFields();
     $fields->addFieldsToTab('Root.Content.Tickets', array(new HeaderField('TicketTypesHeader', $this->fieldLabel('TicketTypesHeader')), new ComplexTableField($this, 'Tickets', 'EventTicket')));
     $generators = ClassInfo::implementorsOf('EventRegistrationTicketGenerator');
     if ($generators) {
         foreach ($generators as $generator) {
             $instance = new $generator();
             $generators[$generator] = $instance->getGeneratorTitle();
         }
         $fields->addFieldsToTab('Root.Content.Tickets', array(new HeaderField('TicketGeneratorHeader', 'Ticket Generator'), new LiteralField('TicketGeneratorNone', '<p>The ticket ' . 'generator is used to generate a ticket file for the ' . 'user to download and print to bring to the event.</p>'), new DropdownField('TicketGenerator', '', $generators, null, null, '(none)')));
     }
     $changeFields = singleton('RegisterableDateTime')->fieldLabels(false);
     $fields->addFieldsToTab('Root.Content.Registration', array(new HeaderField('RegistrationSettingsHeader', $this->fieldLabel('RegistrationSettingsHeader')), new CheckboxField('OneRegPerEmail', $this->fieldLabel('OneRegPerEmail')), new CheckboxField('RequireLoggedIn', $this->fieldLabel('RequireLoggedIn')), new NumericField('RegistrationTimeLimit', $this->fieldLabel('RegistrationTimeLimit')), new HeaderField('EmailSettingsHeader', $this->fieldLabel('EmailSettingsHeader')), new CheckboxField('RegEmailConfirm', $this->fieldLabel('RegEmailConfirm')), new TextField('EmailConfirmMessage', $this->fieldLabel('EmailConfirmMessage')), new NumericField('ConfirmTimeLimit', $this->fieldLabel('ConfirmTimeLimit')), new TextField('AfterConfirmTitle', $this->fieldLabel('AfterConfirmTitle')), new HtmlEditorField('AfterConfirmContent', $this->fieldLabel('AfterConfirmContent'), 5), new CheckboxField('UnRegEmailConfirm', $this->fieldLabel('UnRegEmailConfirm')), new TextField('AfterConfUnregTitle', $this->fieldLabel('AfterConfUnregTitle')), new HtmlEditorField('AfterConfUnregContent', $this->fieldLabel('AfterConfUnregContent'), 5), new CheckboxField('EmailNotifyChanges', $this->fieldLabel('EmailNotifyChanges')), new CheckboxSetField('NotifyChangeFields', $this->fieldLabel('NotifyChangeFields'), $changeFields)));
     $fields->addFieldsToTab('Root.Content.AfterRegistration', array(new TextField('AfterRegTitle', $this->fieldLabel('AfterRegTitle')), new HtmlEditorField('AfterRegContent', $this->fieldLabel('AfterRegContent'))));
     $fields->addFieldsToTab('Root.Content.AfterUnregistration', array(new TextField('AfterUnregTitle', $this->fieldLabel('AfterUnregTitle')), new HtmlEditorField('AfterUnregContent', $this->fieldLabel('AfterUnregContent'))));
     $registrations = new ComplexTableField($this, 'Registrations', 'EventRegistration', null, null, '"Status" = \'Valid\' AND "Time"."EventID" = ' . $this->ID, null, 'INNER JOIN "CalendarDateTime" AS "Time" ON "Time"."ID" = "TimeID"');
     $registrations->setTemplate('EventRegistrationComplexTableField');
     $registrations->setPermissions(array('show', 'print', 'export'));
     $canceled = new ComplexTableField($this, 'Registations', 'EventRegistration', null, null, '"Status" = \'Canceled\' AND "Time"."EventID" = ' . $this->ID, null, 'INNER JOIN "CalendarDateTime" AS "Time" ON "Time"."ID" = "TimeID"');
     $canceled->setTemplate('EventRegistrationComplexTableField');
     $canceled->setPermissions(array('show', 'print', 'export'));
     $fields->addFieldToTab('Root', new Tab('Registrations'), 'Behaviour');
     $fields->addFieldsToTab('Root.Registrations', array(new HeaderField('RegistrationsHeader', $this->fieldLabel('Registrations')), $registrations, new ToggleCompositeField('CanceledRegistrations', 'Canceled Registrations', $canceled)));
     if ($this->RegEmailConfirm) {
         $unconfirmed = new ComplexTableField($this, 'UnconfirmedRegistations', 'EventRegistration', null, null, '"Status" = \'Unconfirmed\' AND "Time"."EventID" = ' . $this->ID, null, 'INNER JOIN "CalendarDateTime" AS "Time" ON "Time"."ID" = "TimeID"');
         $unconfirmed->setPermissions(array('show', 'print', 'export'));
         $unconfirmed->setTemplate('EventRegistrationComplexTableField');
         $fields->addFieldToTab('Root.Registrations', new ToggleCompositeField('UnconfirmedRegistrations', 'Unconfirmed Registrations', $unconfirmed));
     }
     // Add a tab allowing admins to invite people from, as well as view
     // people who have been invited.
     $fields->addFieldToTab('Root', new Tab('Invitations'), 'Behaviour');
     $fields->addFieldsToTab('Root.Invitations', array(new HeaderField('InvitationsHeader', $this->fieldLabel('InvitationsHeader')), new EventInvitationField($this, 'Invitations')));
     return $fields;
 }