public function getCMSFields()
 {
     $this->beforeUpdateCMSFields(function ($fields) {
         $fields->addFieldsToTab('Root.Main', array(Textfield::create('ContactName', 'Name'), TextField::create('Phone', 'Phone'), TextField::create('Mobile', 'Mobile'), TextField::create('Fax', 'Fax'), EmailField::create('Email', 'Email'), $website = TextField::create('Website', 'Website')));
         $website->setRightTitle('e.g ' . Director::absoluteBaseURL());
     });
     return parent::getCMSFields();
 }
 public function getCMSFields()
 {
     $this->beforeUpdateCMSFields(function ($fields) {
         $url = TextField::create('LinkURL', 'Link URL');
         $url->setRightTitle('Including protocol e.g: ' . Director::absoluteBaseURL());
         $fields->addFieldToTab('Root.Main', $url);
         $fields->addFieldsToTab('Root.Main', array(TreeDropdownField::create('InternalLinkID', 'Link To', 'SiteTree'), CheckboxField::create('NewWindow', 'Open in a new window'), $text = TextField::create('LinkText', 'Link Text'), $desc = TextareaField::create('LinkDescription', 'Link Description')));
     });
     return parent::getCMSFields();
 }
 public function getCMSFields()
 {
     $this->beforeUpdateCMSFields(function ($fields) {
         $desc = TextareaField::create('FileDescription', 'Description');
         $desc->setRightTitle('Optional');
         $fields->addFieldToTab('Root.Main', $desc);
         $uploadField = UploadField::create('File', 'File')->setAllowedMaxFileNumber(1)->setFolderName('Uploads/files');
         $fields->addFieldToTab('Root.Main', $uploadField);
     });
     return parent::getCMSFields();
 }
 public function getCMSFields()
 {
     $styles = $this->config()->get('styles');
     $fields = parent::getCMSFields();
     if (count($styles) > 0) {
         $this->beforeUpdateCMSFields(function ($fields) use($styles) {
             $fields->addFieldsToTab('Root.Main', new HtmlEditorField('HTML', 'Content'));
             $fields->addFieldsToTab('Root.Main', $styles = new DropdownField('Style', 'Style', $styles));
             $styles->setEmptyString('Select a custom style..');
         });
     } else {
         $fields->removeByName('Style');
     }
     return $fields;
 }
 public function run($request)
 {
     $elements = BaseElement::get();
     foreach ($elements as $element) {
         $label = DB::query('SELECT Label FROM "BaseElement" WHERE "ID" = ' . $element->ID)->record();
         $element->Title = $label['Label'];
         $label = DB::query('UPDATE "Widget" SET "Title" = \'' . Convert::raw2sql($label['Label']) . '\' WHERE "ID" = ' . $element->ID)->record();
     }
     $origStage = Versioned::current_stage();
     Versioned::reading_stage('Live');
     $elements = BaseElement::get();
     foreach ($elements as $element) {
         $label = DB::query('SELECT Label FROM "BaseElement_Live" WHERE "ID" = ' . $element->ID)->record();
         $label = DB::query('UPDATE "Widget_Live" SET "Title" = \'' . Convert::raw2sql($label['Label']) . '\' WHERE "ID" = ' . $element->ID)->record();
     }
     Versioned::reading_stage($origStage);
 }
 public function getCMSFields()
 {
     $styles = $this->config()->get('styles');
     $fields = parent::getCMSFields();
     if (count($styles) > 0) {
         $this->beforeUpdateCMSFields(function ($fields) use($styles) {
             $fields->addFieldsToTab('Root.Main', new HtmlEditorField('HTML', 'Content'));
             $fields->addFieldsToTab('Root.Main', $styles = new DropdownField('Style', 'Style', $styles));
             $styles->setEmptyString('Select a custom style..');
         });
     } else {
         $fields->removeByName('Style');
     }
     if ($this->isEndofLine('ElementContent') && $this->hasExtension('VersionViewerDataObject')) {
         $fields = $this->addVersionViewer($fields, $this);
     }
     return $fields;
 }
 /**
  * @return FieldList
  */
 public function getCMSFields()
 {
     $elements = $this->Elements();
     $isInDb = $this->isInDB();
     $this->beforeUpdateCMSFields(function ($fields) use($elements, $isInDb) {
         $fields->removeByName('Root.Elements');
         $fields->removeByName('Elements');
         $desc = HTMLEditorField::create('ListDescription', 'List Description');
         $desc->setRightTitle('Optional');
         $fields->addFieldToTab('Root.Main', $desc);
         if ($isInDb) {
             $adder = new ElementalGridFieldAddNewMultiClass();
             $list = $this->getAvailableTypes();
             if ($list) {
                 $adder->setClasses($list);
             }
             $config = GridFieldConfig_RecordEditor::create(100);
             $config->addComponent(new GridFieldSortableRows('Sort'));
             $config->removeComponentsByType('GridFieldAddNewButton');
             $config->removeComponentsByType('GridFieldSortableHeader');
             $config->removeComponentsByType('GridFieldDeleteAction');
             $config->removeComponentsByType('GridFieldAddExistingAutocompleter');
             $config->addComponent(new GridFieldTitleHeader());
             $config->addComponent(new ElementalGridFieldDeleteAction());
             $config->addComponent($adder);
             $config->addComponent($autocompleter = new ElementalGridFieldAddExistingAutocompleter());
             if ($list) {
                 $autocompleter->setSearchList(BaseElement::get()->filter('ClassName', array_keys($list)));
             }
             $config->removeComponentsByType('GridFieldDetailForm');
             $config->addComponent(new VersionedDataObjectDetailsForm());
             $widgetArea = new GridField('Elements', Config::inst()->get("ElementPageExtension", 'elements_title'), $elements, $config);
             $fields->addFieldToTab('Root.Main', $widgetArea);
         } else {
             $fields->addFieldToTab('Root.Main', LiteralField::create('warn', '<p class="message notice">Once you save this object you will be able to add items</p>'));
         }
     });
     return parent::getCMSFields();
 }
 public function getCMSFields()
 {
     $elements = $this->Elements();
     $isInDb = $this->isInDB();
     $allowed = $this->config()->get('allowed_elements');
     $this->beforeUpdateCMSFields(function ($fields) use($elements, $isInDb, $allowed) {
         $desc = HTMLEditorField::create('ListDescription', 'List Description');
         $desc->setRightTitle('Optional');
         $fields->addFieldToTab('Root.Main', $desc);
         if ($isInDb) {
             $adder = new GridFieldAddNewMultiClass();
             if (is_array($allowed)) {
                 $list = $allowed;
             } else {
                 $classes = ClassInfo::subclassesFor('BaseElement');
                 $list = array();
                 unset($classes['BaseElement']);
                 foreach ($classes as $class) {
                     $list[$class] = singleton($class)->i18n_singular_name();
                 }
             }
             asort($list);
             $adder->setClasses($list);
             $config = GridFieldConfig_RecordEditor::create(100);
             $config->addComponent(new GridFieldSortableRows('Sort'));
             $config->removeComponentsByType('GridFieldAddNewButton');
             $config->addComponent($adder);
             $config->removeComponentsByType('GridFieldDetailForm');
             $config->addComponent(new VersionedDataObjectDetailsForm());
             $widgetArea = new GridField('Elements', Config::inst()->get("ElementPageExtension", 'elements_title'), $elements, $config);
             $fields->addFieldToTab('Root.Main', $widgetArea);
         } else {
             $fields->addFieldToTab('Root.Main', LiteralField::create('warn', '<p class="message notice">Once you save this object you will be able to add items</p>'));
         }
         $fields->removeByName('Root.Elements');
     });
     return parent::getCMSFields();
 }
 /**
  * Setup the CMS Fields
  *
  * @param FieldList
  */
 public function updateCMSFields(FieldList $fields)
 {
     if (!$this->supportsElemental()) {
         return;
     }
     // add an empty holder for content as some module explicitly use insert
     // after content.
     $fields->replaceField('Content', new LiteralField('Content', ''));
     $adder = new ElementalGridFieldAddNewMultiClass();
     $list = $this->getAvailableTypes();
     if ($list) {
         $adder->setClasses($list);
     }
     $area = $this->owner->ElementArea();
     if ($this->owner->exists() && (!$area->exists() || !$area->isInDB())) {
         $area->write();
         $this->owner->ElementAreaID = $area->ID;
         $this->owner->write();
     }
     $gridField = GridField::create('ElementArea', Config::inst()->get("ElementPageExtension", 'elements_title'), $area->AllElements(), GridFieldConfig_RelationEditor::create()->removeComponentsByType('GridFieldAddNewButton')->removeComponentsByType('GridFieldSortableHeader')->removeComponentsByType('GridFieldDeleteAction')->removeComponentsByType('GridFieldAddExistingAutocompleter')->addComponent($autocomplete = new ElementalGridFieldAddExistingAutocompleter())->addComponent(new ElementalGridFieldDeleteAction())->addComponent(new GridFieldTitleHeader())->addComponent($adder)->addComponent(new GridFieldSortableRows('Sort')));
     if ($list) {
         $autocomplete->setSearchList(BaseElement::get()->filter('ClassName', array_keys($list)));
     }
     $config = $gridField->getConfig();
     $paginator = $config->getComponentByType('GridFieldPaginator');
     $paginator->setItemsPerPage(100);
     if (!$this->owner->config()->disable_element_publish_button) {
         $config->removeComponentsByType('GridFieldDetailForm');
         $config->addComponent($obj = new VersionedDataObjectDetailsForm());
     }
     if ($this->owner instanceof SiteTree && $fields->findOrMakeTab('Root.Main')->fieldByName('Metadata')) {
         $fields->addFieldToTab('Root.Main', $gridField, 'Metadata');
     } else {
         $fields->addFieldToTab('Root.Main', $gridField);
     }
     return $fields;
 }
 /**
  * @param boolean $batch true to build xml suitable to append to a batch xml 
  * request, false to build an xml to post this single item. Defaults to 
  * false.
  * @return string The rendered xml for this item.
  */
 function getXml($batch = false)
 {
     $xml = $batch ? new XmlBuilder('') : new XmlBuilder();
     $entry_attrs = $batch ? array() : array('xmlns' => 'http://www.w3.org/2005/Atom', 'xmlns:g' => 'http://base.google.com/ns/1.0');
     $xml->Push('entry', $entry_attrs);
     if ($this->_id) {
         $xml->Element('id', $this->_id);
     }
     if ($this->_author) {
         $this->_author->addToXml($xml);
     }
     $this->_title->addToXml($xml);
     $this->_description->addToXml($xml);
     foreach ($this->_links as $link) {
         $link->addToXml($xml);
     }
     foreach ($this->_attributes as $attr) {
         $attr->addToXml($xml);
     }
     if ($this->_draft) {
         // <app:control> <app:draft>yes</app:draft> </app:control>
         $xml->Push('app:control', array('xmlns:app' => 'http://purl.org/atom/app#'));
         $xml->Element('app:draft', 'yes');
         $xml->Pop('app:control');
     }
     $xml->Pop('entry');
     return $xml->GetXML();
 }
Example #11
0
 /**
  * Returns a peer instance associated with this om.
  *
  * Since Peer classes are not to have any instance attributes, this method returns the
  * same instance for all member of this class. The method could therefore
  * be static, but this would prevent one from overriding the behavior.
  *
  * @return     ElementPeer
  */
 public function getPeer()
 {
     if (self::$peer === null) {
         self::$peer = new ElementPeer();
     }
     return self::$peer;
 }
 public function getDefaultSearchContext()
 {
     $fields = $this->scaffoldSearchFields();
     $elements = BaseElement::all_allowed_elements();
     $fields->push(DropdownField::create('ClassName', 'Element Type', $elements)->setEmptyString('All types'));
     $filters = $this->owner->defaultSearchFilters();
     return new SearchContext($this->owner->class, $fields, $filters);
 }
Example #13
0
 public function getJSONObject($defText = "", $defTitle = "")
 {
     $parentArray = parent::getJSONObject($defText, $defTitle);
     $array = array('wmsServerUrl' => $this->getWmsServerUrl(), 'wmsLayerName' => $this->getWmsLayerName(), 'wmsStyleName' => $this->getWmsStyleName());
     return array_merge($parentArray, $array);
 }
 public function addError($attribute, $message)
 {
     $this->frontEndErrors[] = $this->errorAttributeException(str_replace('\\', '_', get_class($this)) . '_' . $attribute);
     $message = '<a class="errorlink" onClick="scrollToElement($(\'.' . str_replace('\\', '_', get_class($this)) . '\'))">' . $message . '</a>';
     parent::addError($attribute, $message);
 }
 /**
  * Prepare form items for each scheme definition
  * Optional: get featureType by name from global context.
  *
  * @inheritdoc
  */
 public function getConfiguration()
 {
     $configuration = parent::getConfiguration();
     $configuration['debug'] = isset($configuration['debug']) ? $configuration['debug'] : false;
     $configuration['fileUri'] = $this->container->getParameter("mapbender.uploads_dir") . "/data-store";
     if (isset($configuration["schemes"]) && is_array($configuration["schemes"])) {
         foreach ($configuration["schemes"] as $key => &$scheme) {
             if (is_string($scheme['dataStore'])) {
                 $storeId = $scheme['dataStore'];
                 $dataStore = $this->container->getParameter('dataStores');
                 $scheme['dataStore'] = $dataStore[$storeId];
                 $scheme['dataStore']["id"] = $storeId;
                 //$dataStore = new DataStore($this->container, $configuration['source']);
             }
             if (isset($scheme['formItems'])) {
                 $scheme['formItems'] = $this->prepareItems($scheme['formItems']);
             }
         }
     }
     return $configuration;
 }
Example #16
0
 /**
  * EmailElement constructor.
  * @param string $name
  */
 function __construct($name)
 {
     parent::__construct($name);
     $this->template = "Template/Email.phtml";
 }
Example #17
0
 /**
  * Add a child to this element
  *
  * @param BaseElement $child
  */
 function add_child($child)
 {
     $this->children[$child->identifier()] = $child;
 }
 /**
  * @return QueryBuilderConfig
  */
 public function getConfig()
 {
     return new QueryBuilderConfig(parent::getConfiguration());
 }
Example #19
0
 public function __construct($htmlp, $type = '')
 {
     parent::__construct($htmlp);
     $this->set_format('%3$s');
 }
Example #20
0
 public function __construct($config = array())
 {
     parent::__construct($config);
     $this->config($config, array('description', 'title'));
 }
Example #21
0
 public function __construct($htmlp, $type = '')
 {
     parent::__construct();
     $this->set_format('<%1$s %2$s>');
 }
Example #22
0
 /**
  * Returns an array of attribute names that should not be displayed in the ui.
  * @return array
  */
 public function skip_stats()
 {
     return array_merge(array('line_count'), parent::skip_stats());
 }