Example #1
0
 /**
  * Generate the CMS fields from the fields from the original page.
  */
 function getCMSFields($cms = null)
 {
     $fields = parent::getCMSFields($cms);
     // Setup the linking to the original page.
     $copyContentFromField = new TreeDropdownField("CopyContentFromID", _t('VirtualPage.CHOOSE', "Choose a page to link to"), "SiteTree");
     $copyContentFromField->setFilterFunction(create_function('$item', 'return $item->ClassName != "VirtualPage";'));
     // Setup virtual fields
     if ($virtualFields = $this->getVirtualFields()) {
         $roTransformation = new ReadonlyTransformation();
         foreach ($virtualFields as $virtualField) {
             if ($fields->dataFieldByName($virtualField)) {
                 $fields->replaceField($virtualField, $fields->dataFieldByName($virtualField)->transform($roTransformation));
             }
         }
     }
     // Add fields to the tab
     $fields->addFieldToTab("Root.Content.Main", new HeaderField('VirtualPageHeader', _t('VirtualPage.HEADER', "This is a virtual page")), "Title");
     $fields->addFieldToTab("Root.Content.Main", $copyContentFromField, "Title");
     // Create links back to the original object in the CMS
     if ($this->CopyContentFromID) {
         $linkToContent = "<a class=\"cmsEditlink\" href=\"admin/show/{$this->CopyContentFromID}\">" . _t('VirtualPage.EDITCONTENT', 'click here to edit the content') . "</a>";
         $fields->addFieldToTab("Root.Content.Main", $linkToContentLabelField = new LabelField('VirtualPageContentLinkLabel', $linkToContent), "Title");
         $linkToContentLabelField->setAllowHTML(true);
     }
     return $fields;
 }
 /**
  * Returns the input fields for this widget.
  * 
  * @param Widget $widget       Widget to initialize
  * @param array  $fetchMethods Optional list of product fetch methods
  * 
  * @return FieldList
  * 
  * @author Sebastian Diel <*****@*****.**>
  * @since 13.03.2014
  */
 public static function getCMSFieldsForProductSliderWidget(Widget $widget, $fetchMethods = array())
 {
     if (empty($fetchMethods)) {
         $fetchMethods = array('random' => $widget->fieldLabel('fetchMethodRandom'), 'sortOrderAsc' => $widget->fieldLabel('fetchMethodSortOrderAsc'), 'sortOrderDesc' => $widget->fieldLabel('fetchMethodSortOrderDesc'));
     }
     $fields = SilvercartDataObject::getCMSFields($widget, 'ExtraCssClasses', false);
     $productGroupDropdown = new TreeDropdownField('SilvercartProductGroupPageID', $widget->fieldLabel('SilvercartProductGroupPage'), 'SiteTree');
     $productGroupDropdown->setTreeBaseID(SilvercartTools::PageByIdentifierCode('SilvercartProductGroupHolder')->ID);
     $toggleFields = array($fields->dataFieldByName('numberOfProductsToShow'), $fields->dataFieldByName('numberOfProductsToFetch'), $fields->dataFieldByName('fetchMethod'), SilvercartGroupViewHandler::getGroupViewDropdownField('GroupView', $widget->fieldLabel('GroupView'), $widget->GroupView));
     $fields->dataFieldByName('fetchMethod')->setSource($fetchMethods);
     $fields->dataFieldByName('numberOfProductsToShow')->setDescription($widget->fieldLabel('numberOfProductsToShowInfo'));
     $fields->dataFieldByName('isContentView')->setDescription($widget->fieldLabel('isContentViewInfo'));
     if (is_object($fields->dataFieldByName('useSelectionMethod'))) {
         $fields->dataFieldByName('useSelectionMethod')->setSource(array('productGroup' => $widget->fieldLabel('SelectionMethodProductGroup'), 'products' => $widget->fieldLabel('SelectionMethodProducts')));
         $toggleFields[] = $fields->dataFieldByName('useSelectionMethod');
         $productGroupDropdown->setDescription($widget->fieldLabel('SilvercartProductGroupPageDescription'));
     }
     $toggleFields[] = $productGroupDropdown;
     $productDataToggle = ToggleCompositeField::create('ProductDataToggle', $widget->fieldLabel('ProductDataToggle'), $toggleFields)->setHeadingLevel(4);
     $productRelationToggle = ToggleCompositeField::create('ProductRelationToggle', $widget->fieldLabel('ProductRelationToggle'), array($fields->dataFieldByName('SilvercartProducts')))->setHeadingLevel(4);
     $fields->removeByName('numberOfProductsToShow');
     $fields->removeByName('numberOfProductsToFetch');
     $fields->removeByName('fetchMethod');
     $fields->removeByName('useSelectionMethod');
     $fields->removeByName('SilvercartProducts');
     $fields->addFieldToTab("Root.Main", $productDataToggle);
     $fields->addFieldToTab("Root.Main", $productRelationToggle);
     $widget->getCMSFieldsSliderTab($fields);
     //$widget->getCMSFieldsRoundaboutTab($fields);
     return $fields;
 }
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName('ParentID');
     $externalLinkField = $fields->fieldByName('Root.Main.ExternalLink');
     $fields->removeByName('ExternalLink');
     $fields->removeByName('InternalLinkID');
     $fields->addFieldToTab('Root.Main', CompositeField::create(array($internalLinkField = new TreeDropdownField('InternalLinkID', 'Internal Link', 'SiteTree'), $externalLinkField, $wrap = new CompositeField($extraLabel = new LiteralField('NoteOverride', '<div class="message good notice">Note:  If you specify an External Link, the Internal Link will be ignored.</div>')))));
     $internalLinkField->addExtraClass('noBorder');
     $externalLinkField->addExtraClass('noBorder');
     $fields->insertBefore(new LiteralField('Note', '<p>Use this to specify a link to a page either on this site (Internal Link) or another site (External Link).</p>'), 'Name');
     return $fields;
 }
Example #4
0
 /**
  * Add fields to manage FAQs.
  *
  * @return $fields
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $this->extend('beforeGetCMSFields', $fields);
     // setup category dropdown field
     $taxonomyRoot = self::getRootCategory();
     $categoryField = new TreeDropdownField('CategoryID', 'Category', 'TaxonomyTerm', 'ID', 'Name');
     //change this to 0 if you want the root category to show
     $categoryField->setTreeBaseID($taxonomyRoot->ID);
     $categoryField->setDescription(sprintf('Select one <a href="admin/taxonomy/TaxonomyTerm/EditForm/field/TaxonomyTerm/item/%d/#Root_Children">' . 'FAQ Category</a>', $taxonomyRoot->ID));
     $fields->addFieldToTab('Root.Main', $categoryField);
     $this->extend('updateGetCMSFields', $fields);
     return $fields;
 }
 public function AddForm()
 {
     $form = parent::AddForm();
     $fields = $form->Fields();
     $fields->push(new HiddenField('Parent', null, true));
     // Enforce a parent mode of "child" to correctly read the "allowed children".
     $fields->dataFieldByName('ParentModeField')->setValue('child');
     $fields->insertAfter($parent = new TreeDropdownField('ParentID', '', 'SiteTree', 'ID', 'TreeTitle'), 'ParentModeField');
     $parentID = $this->request->getVar('ParentID');
     $parentID = $parentID ? $parentID : Multisites::inst()->getCurrentSiteId();
     $parent->setForm($form);
     $parent->setValue((int) $parentID);
     $form->setValidator(new RequiredFields('ParentID'));
     return $form;
 }
Example #6
0
 /**
  * Get CMS fields
  * 
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeFieldsFromTab('Root.Main', array('Title', 'SortOrder', 'FeaturedWorkParentID'));
     $fields->replaceField('WorkID', TreeDropdownField::create('WorkID', 'Work', 'SiteTree'));
     return $fields;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     // Remove fields
     $fields->removeByName(array('Unique', 'Permanent', 'CanClose', 'CloseColor', 'LinkID'));
     // Add fields
     // Main tab
     $fields->addFieldToTab("Root.Main", $test = TextField::create("ButtonText")->setTitle(_t("SiteMessage.LABELBUTTONTEXT", "Button Text")));
     $fields->addFieldToTab("Root.Main", TreeDropdownField::create("PageID")->setTitle(_t("SiteMessage.LABELLINKTO", "Link to"))->setSourceObject("SiteTree"));
     $fields->addFieldToTab("Root.Main", HTMLEditorField::create("Content")->setTitle(_t("SiteMessage.LABELCONTENT", "Message content"))->setRows(15));
     // Design tab
     $fields->addFieldToTab("Root.Design", HeaderField::create("ColorSettings")->setTitle(_t("SiteMessage.HEADERCOLORSETTINGS", "Color settings")));
     $fields->addFieldToTab("Root.Design", ColorField::create("BackgroundColor")->setTitle(_t("SiteMessage.LABELBACKGROUNDCOLOR", "Background Color")));
     $fields->addFieldToTab("Root.Design", ColorField::create("TextColor")->setTitle(_t("SiteMessage.LABELTEXTCOLOR", "Text Color")));
     $fields->addFieldToTab("Root.Design", ColorField::create("ButtonColor")->setTitle(_t("SiteMessage.LABELBUTTONCOLOR", "Button Color")));
     $fields->addFieldToTab("Root.Design", ColorField::create("ButtonTextColor")->setTitle(_t("SiteMessage.LABELBUTTONTEXTCOLOR", "Button Text Color")));
     $fields->addFieldToTab("Root.Design", HeaderField::create("CloseSettings")->setTitle(_t("SiteMessage.HEADERCLOSESETTINGS", "Close button settings")));
     $fields->addFieldToTab("Root.Design", FieldGroup::create(_t("SiteMessage.LABELCANCLOSE", "Show close button?"), Checkboxfield::create("CanClose", "")));
     $fields->addFieldToTab("Root.Design", ColorField::create("CloseColor")->setTitle(_t("SiteMessage.LABELCLOSECOLOR", "Close button color")));
     // Schedule tab
     $fields->addFieldToTab("Root.Schedule", FieldGroup::create(_t("SiteMessage.LABELPERMANENT", "Is this message permanent?"), CheckboxField::create("Permanent", "")));
     $fields->addFieldToTab("Root.Schedule", $Start = new DatetimeField("Start"));
     $fields->addFieldToTab("Root.Schedule", $End = new DatetimeField("End"));
     $Start->setConfig('datavalueformat', 'YYYY-MM-dd HH:mm')->setTitle(_t("SiteMessage.LABELSTART", "Start Date"))->getDateField('Start')->setConfig('showcalendar', TRUE);
     $End->setConfig('datavalueformat', 'YYYY-MM-dd HH:mm')->setTitle(_t("SiteMessage.LABELSTART", "End Date"))->getDateField('End')->setConfig('showcalendar', TRUE);
     return $fields;
 }
Example #8
0
 public function getCMSFields()
 {
     $fields = $this->scaffoldFormFields(array('includeRelations' => $this->ID > 0, 'tabbed' => true, 'ajaxSafe' => true));
     $types = $this->config()->get('types');
     $i18nTypes = array();
     foreach ($types as $key => $label) {
         $i18nTypes[$key] = _t('Linkable.TYPE' . strtoupper($key), $label);
     }
     $fields->removeByName('SiteTreeID');
     $fields->removeByName('File');
     $fields->dataFieldByName('Title')->setTitle(_t('Linkable.TITLE', 'Title'))->setRightTitle(_t('Linkable.OPTIONALTITLE', 'Optional. Will be auto-generated from link if left blank'));
     $fields->replaceField('Type', DropdownField::create('Type', _t('Linkable.LINKTYPE', 'Link Type'), $i18nTypes)->setEmptyString(' '), 'OpenInNewWindow');
     $fields->addFieldToTab('Root.Main', DisplayLogicWrapper::create(TreeDropdownField::create('FileID', _t('Linkable.FILE', 'File'), 'File', 'ID', 'Title'))->displayIf("Type")->isEqualTo("File")->end());
     $fields->addFieldToTab('Root.Main', DisplayLogicWrapper::create(TreeDropdownField::create('SiteTreeID', _t('Linkable.PAGE', 'Page'), 'SiteTree'))->displayIf("Type")->isEqualTo("SiteTree")->end());
     $fields->addFieldToTab('Root.Main', $newWindow = CheckboxField::create('OpenInNewWindow', _t('Linkable.OPENINNEWWINDOW', 'Open link in a new window')));
     $newWindow->displayIf('Type')->isNotEmpty();
     $fields->dataFieldByName('URL')->displayIf("Type")->isEqualTo("URL");
     $fields->dataFieldByName('Email')->setTitle(_t('Linkable.EMAILADDRESS', 'Email Address'))->displayIf("Type")->isEqualTo("Email");
     if ($this->SiteTreeID && !$this->SiteTree()->isPublished()) {
         $fields->dataFieldByName('SiteTreeID')->setRightTitle(_t('Linkable.DELETEDWARNING', 'Warning: The selected page appears to have been deleted or unpublished. This link may not appear or may be broken in the frontend'));
     }
     $fields->addFieldToTab('Root.Main', $anchor = TextField::create('Anchor', _t('Linkable.ANCHOR', 'Anchor')), 'OpenInNewWindow');
     $anchor->setRightTitle('Include # at the start of your anchor name');
     $anchor->displayIf("Type")->isEqualTo("SiteTree");
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 public function LinkForm()
 {
     //        echo 'ssss';die();
     $siteTree = new TreeDropdownField('internal', _t('HtmlEditorField.PAGE', "Page"), 'SiteTree', 'ID', 'MenuTitle', true);
     // mimic the SiteTree::getMenuTitle(), which is bypassed when the search is performed
     $siteTree->setSearchFunction(array($this, 'siteTreeSearchCallback'));
     $numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span>' . '<strong class="title">%s</strong></span>';
     $form = new Form($this->controller, "{$this->name}/LinkForm", new FieldList($headerWrap = new CompositeField(new LiteralField('Heading', sprintf('<h3 class="htmleditorfield-mediaform-heading insert">%s</h3>', _t('HtmlEditorField.LINK', 'Insert Link')))), $contentComposite = new CompositeField(new OptionsetField('LinkType', sprintf($numericLabelTmpl, '1', _t('MarkdownEditorField.LINKTO', 'Link to')), array('internal' => _t('MarkdownEditorField.LINKINTERNAL', 'Page on the site'), 'external' => _t('MarkdownEditorField.LINKEXTERNAL', 'Another website'), 'anchor' => _t('MarkdownEditorField.LINKANCHOR', 'Anchor on this page'), 'email' => _t('MarkdownEditorField.LINKEMAIL', 'Email address')), 'internal'), new LiteralField('Step2', '<div class="step2">' . sprintf($numericLabelTmpl, '2', _t('HtmlEditorField.DETAILS', 'Details')) . '</div>'), $siteTree, new TextField('external', _t('MarkdownEditorField.URL', 'URL'), 'http://'), new EmailField('email', _t('MarkdownEditorField.EMAIL', 'Email address')), new TreeDropdownField('file', _t('MarkdownEditorField.FILE', 'File'), 'File', 'ID', 'Title', true), new TextField('Anchor', _t('MarkdownEditorField.ANCHORVALUE', 'Anchor')), new TextField('LinkText', _t('MarkdownEditorField.LINKTEXT', 'Link text')), new TextField('Description', _t('MarkdownEditorField.LINKDESCR', 'Link title')), new CheckboxField('TargetBlank', _t('MarkdownEditorField.LINKOPENNEWWIN', 'Open link in a new window?')), new HiddenField('Locale', null, $this->controller->Locale))), new FieldList(FormAction::create('insert', _t('HtmlEditorField.BUTTONINSERTLINK', 'Insert link'))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true)));
     $headerWrap->addExtraClass('CompositeField composite cms-content-header nolabel ');
     $contentComposite->addExtraClass('ss-insert-link content');
     $form->unsetValidator();
     $form->loadDataFrom($this);
     $form->addExtraClass('markdownfield-form markdowneditorfield-linkform cms-dialog-content');
     $this->extend('updateLinkForm', $form);
     return $form;
 }
 /**
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab('Root.Main', TreeDropdownField::create('FolderID', _t('EditableUploadField.SELECTUPLOADFOLDER', 'Select upload folder'), 'Folder'));
     $fields->addFieldToTab("Root.Main", new LiteralField("FileUploadWarning", "<p class=\"message notice\">" . _t("UserDefinedForm.FileUploadWarning", "Files uploaded through this field could be publicly accessible if the exact URL is known") . "</p>"), "Type");
     return $fields;
 }
 public function updateCMSFields(FieldList $fields)
 {
     $fields->insertBefore($shoptab = new Tab('Shop', 'Shop'), 'Access');
     $fields->addFieldsToTab("Root.Shop", new TabSet("ShopTabs", $maintab = new Tab("Main", TreeDropdownField::create('TermsPageID', _t("ShopConfig.TERMSPAGE", 'Terms and Conditions Page'), 'SiteTree'), TreeDropdownField::create("CustomerGroupID", _t("ShopConfig.CUSTOMERGROUP", "Group to add new customers to"), "Group"), UploadField::create('DefaultProductImage', _t('ShopConfig.DEFAULTIMAGE', 'Default Product Image'))), $countriestab = new Tab("Countries", CheckboxSetField::create('AllowedCountries', 'Allowed Ordering and Shipping Countries', self::config()->iso_3166_country_codes))));
     $fields->removeByName("CreateTopLevelGroups");
     $countriestab->setTitle("Allowed Countries");
 }
 public function __construct($name, $title = null, $sourceObject = "Group", $keyField = "ID", $labelField = "Title")
 {
     parent::__construct($name, $title, $sourceObject, $keyField, $labelField);
     $this->removeExtraClass('single');
     $this->addExtraClass('multiple');
     $this->value = 'unchanged';
 }
 /**
  * Form used for defining the conversion form
  * @return {Form} Form to be used for configuring the conversion
  */
 public function ConvertObjectForm()
 {
     //Reset the reading stage
     Versioned::reset();
     $fields = new FieldList(CompositeField::create($convertModeField = new OptionsetField('ConvertMode', '', array('ReplacePage' => _t('KapostAdmin.REPLACES_AN_EXISTING_PAGE', '_This replaces an existing page'), 'NewPage' => _t('KapostAdmin.IS_NEW_PAGE', '_This is a new page')), 'NewPage'))->addExtraClass('kapostConvertLeftSide'), CompositeField::create($replacePageField = TreeDropdownField::create('ReplacePageID', _t('KapostAdmin.REPLACE_PAGE', '_Replace this page'), 'SiteTree')->addExtraClass('replace-page-id'), TreeDropdownField::create('ParentPageID', _t('KapostAdmin.USE_AS_PARENT', '_Use this page as the parent for the new page, leave empty for a top level page'), 'SiteTree')->addExtraClass('parent-page-id'))->addExtraClass('kapostConvertRightSide'));
     $actions = new FieldList(FormAction::create('doConvertObject', _t('KapostAdmin.CONTINUE_CONVERT', '_Continue'))->setUseButtonTag(true)->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'kapost-convert'));
     $validator = new RequiredFields('ConvertMode');
     $form = new Form($this, 'ConvertObjectForm', $fields, $actions, $validator);
     $form->addExtraClass('KapostAdmin center')->setAttribute('data-layout-type', 'border')->setTemplate('KapostAdmin_ConvertForm');
     //Handle pages to see if the page exists
     $convertToClass = $this->getDestinationClass();
     if ($convertToClass !== false && ($convertToClass == 'SiteTree' || is_subclass_of($convertToClass, 'SiteTree'))) {
         $obj = SiteTree::get()->filter('KapostRefID', Convert::raw2sql($this->record->KapostRefID))->first();
         if (!empty($obj) && $obj !== false && $obj->ID > 0) {
             $convertModeField->setValue('ReplacePage');
             $replacePageField->setValue($obj->ID);
             $recordTitle = $this->record->Title;
             if (!empty($recordTitle) && $recordTitle != $obj->Title) {
                 $urlFieldLabel = _t('KapostAdmin.TITLE_CHANGE_DETECT', '_The title differs from the page being replaced, it was "{wastitle}" and will be changed to "{newtitle}". Do you want to update the URL Segment?', array('wastitle' => $obj->Title, 'newtitle' => $recordTitle));
                 $fields->push(CheckboxField::create('UpdateURLSegment', $urlFieldLabel)->addExtraClass('urlsegmentcheck')->setAttribute('data-replace-id', $obj->ID)->setForm($form)->setDescription(_t('KapostAdmin.NEW_URL_SEGMENT', '_The new URL Segment will be or will be close to "{newsegment}"', array('newsegment' => $obj->generateURLSegment($recordTitle)))));
             }
         }
     }
     Requirements::css(KAPOST_DIR . '/css/KapostAdmin.css');
     Requirements::add_i18n_javascript(KAPOST_DIR . '/javascript/lang/');
     Requirements::javascript(KAPOST_DIR . '/javascript/KapostAdmin_convertPopup.js');
     //Allow extensions to adjust the form
     $this->extend('updateConvertObjectForm', $form, $this->record);
     return $form;
 }
Example #14
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeFieldsFromTab('Root.Main', array('SortOrder', 'MenuID', 'Title'));
     $fields->replaceField('PageID', TreeDropdownField::create("PageID", "Choose a page:", "SiteTree"));
     return $fields;
 }
 public function setValue($value)
 {
     if ($value) {
         self::set_last_folder($value);
     }
     parent::setValue($value);
 }
 public function testTreeSearch()
 {
     $field = new TreeDropdownField('TestTree', 'Test tree', 'Folder');
     // case insensitive search against keyword 'sub' for folders
     $request = new SS_HTTPRequest('GET', 'url', array('search' => 'sub'));
     $tree = $field->tree($request);
     $folder1 = $this->objFromFixture('Folder', 'folder1');
     $folder1Subfolder1 = $this->objFromFixture('Folder', 'folder1-subfolder1');
     $parser = new CSSContentParser($tree);
     $cssPath = 'ul.tree li#selector-TestTree-' . $folder1->ID . ' li#selector-TestTree-' . $folder1Subfolder1->ID . ' a span.item';
     $firstResult = $parser->getBySelector($cssPath);
     $this->assertEquals((string) $firstResult[0], $folder1Subfolder1->Name, $folder1Subfolder1->Name . ' is found, nested under ' . $folder1->Name);
     $subfolder = $this->objFromFixture('Folder', 'subfolder');
     $cssPath = 'ul.tree li#selector-TestTree-' . $subfolder->ID . ' a span.item';
     $secondResult = $parser->getBySelector($cssPath);
     $this->assertEquals((string) $secondResult[0], $subfolder->Name, $subfolder->Name . ' is found at root level');
     // other folders which don't contain the keyword 'sub' are not returned in search results
     $folder2 = $this->objFromFixture('Folder', 'folder2');
     $cssPath = 'ul.tree li#selector-TestTree-' . $folder2->ID . ' a span.item';
     $noResult = $parser->getBySelector($cssPath);
     $this->assertEquals($noResult, array(), $folder2 . ' is not found');
     $field = new TreeDropdownField('TestTree', 'Test tree', 'File');
     // case insensitive search against keyword 'sub' for files
     $request = new SS_HTTPRequest('GET', 'url', array('search' => 'sub'));
     $tree = $field->tree($request);
     $parser = new CSSContentParser($tree);
     // Even if we used File as the source object, folders are still returned because Folder is a File
     $cssPath = 'ul.tree li#selector-TestTree-' . $folder1->ID . ' li#selector-TestTree-' . $folder1Subfolder1->ID . ' a span.item';
     $firstResult = $parser->getBySelector($cssPath);
     $this->assertEquals((string) $firstResult[0], $folder1Subfolder1->Name, $folder1Subfolder1->Name . ' is found, nested under ' . $folder1->Name);
     // Looking for two files with 'sub' in their name, both under the same folder
     $file1 = $this->objFromFixture('File', 'subfolderfile1');
     $file2 = $this->objFromFixture('File', 'subfolderfile2');
     $cssPath = 'ul.tree li#selector-TestTree-' . $subfolder->ID . ' li#selector-TestTree-' . $file1->ID . ' a';
     $firstResult = $parser->getBySelector($cssPath);
     $this->assertGreaterThan(0, count($firstResult), $file1->Name . ' with ID ' . $file1->ID . ' is in search results');
     $this->assertEquals((string) $firstResult[0], $file1->Name, $file1->Name . ' is found nested under ' . $subfolder->Name);
     $cssPath = 'ul.tree li#selector-TestTree-' . $subfolder->ID . ' li#selector-TestTree-' . $file2->ID . ' a';
     $secondResult = $parser->getBySelector($cssPath);
     $this->assertGreaterThan(0, count($secondResult), $file2->Name . ' with ID ' . $file2->ID . ' is in search results');
     $this->assertEquals((string) $secondResult[0], $file2->Name, $file2->Name . ' is found nested under ' . $subfolder->Name);
     // other files which don't include 'sub' are not returned in search results
     $file3 = $this->objFromFixture('File', 'asdf');
     $cssPath = 'ul.tree li#selector-TestTree-' . $file3->ID;
     $noResult = $parser->getBySelector($cssPath);
     $this->assertEquals($noResult, array(), $file3->Name . ' is not found');
 }
 /**
  * Adds dropdown field for album folders (subfolders inside assets/cwsoft-foldergallery)
  *
  * @return modified backend fields
  */
 function getCMSFields()
 {
     // create folder assets/cwsoft-foldergallery if not already exists
     Folder::find_or_make('cwsoft-foldergallery');
     // get default CMS fields
     $fields = parent::getCMSFields();
     // get "cwsoft-foldergallery" folder object
     $album = Folder::get()->filter('Filename', 'assets/cwsoft-foldergallery/')->First();
     if (!$album) {
         return $fields;
     }
     // add dropdown field with album folders (subfolders of assets/cwsoft-foldergallery)
     $tree = new TreeDropdownField('AlbumFolderID', _t('cwsFolderGalleryPage.CHOOSE_IMAGE_FOLDER', 'Choose image folder (subfolder assets/cwsoft-foldergallery/)'), 'Folder');
     $tree->setTreeBaseID((int) $album->ID);
     $fields->addFieldToTab('Root.Main', $tree, 'Content');
     return $fields;
 }
 public function getForm()
 {
     $cModField = ContentModuleField::curr();
     if ($cModField) {
         return $cModField->getForm();
     }
     return parent::getForm();
 }
 /**
  * Get the whole tree of a part of the tree via an AJAX request with empty / none item prepended.
  *
  * @param SS_HTTPRequest $request
  * @return string
  * for version 2.4 and later
  */
 public function tree(SS_HTTPRequest $request)
 {
     if ($ID = (int) $request->latestparam('ID')) {
         return parent::tree($request);
     } else {
         return $this->preTree() . parent::tree($request) . OptionalTreeDropdownField::$postTree;
     }
 }
 function tree(SS_HTTPRequest $request)
 {
     $oldSubsiteID = Session::get('SubsiteID');
     Session::set('SubsiteID', $this->subsiteID);
     $results = parent::tree($request);
     Session::set('SubsiteID', $oldSubsiteID);
     return $results;
 }
 public function getCMSFields()
 {
     $this->beforeExtending('updateCMSFields', function (FieldList $fields) {
         $fields->removeByName('PageID');
         $fields->replaceField('Username', TreeDropdownField::create('PageID', _t('SocialFeed.DISPLAY_CHILDREN_OF_PAGE', 'Display children of'), 'Page'));
     });
     return parent::getCMSFields();
 }
Example #22
0
 /**
  * Get CMS fields
  * 
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeFieldsFromTab('Root.Main', array('CarouselParentID', 'SortOrder'));
     $fields->replaceField('Title', TextField::create('Title', 'Title'));
     $fields->dataFieldByName('Image')->setFolderName('Carousels');
     $fields->replaceField('RedirectPageID', TreeDropdownField::create('RedirectPageID', 'Choose a redirect page', 'SiteTree'));
     return $fields;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldsToTab('Root.Main', array(TextField::create('Title'), HtmlEditorField::create('Summary')->setDescription('Short summary to show on hover')->setRows(5), HtmlEditorField::create('Content')->setDescription('Content of help article'), TreeDropdownField::create('ParentID', 'Parent', 'AdminHelp', 'ID', 'Title')));
     if ($childrenGrid = $fields->fieldByName('Root.Children.Children')) {
         $childrenGrid->getConfig()->addComponent(GridFieldOrderableRows::create('Sort'));
     }
     return $fields;
 }
Example #24
0
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     if ($checkouts = CheckoutPage::get()) {
         $fields->addFieldToTab('Root.Links', DropdownField::create('CheckoutPageID', _t('CartPage.has_one_CheckoutPage', 'Checkout Page'), $checkouts->map("ID", "Title")));
     }
     $fields->addFieldToTab('Root.Links', TreeDropdownField::create('ContinuePageID', _t('CartPage.has_one_ContinuePage', 'Continue Shopping Page'), 'SiteTree'));
     return $fields;
 }
    public function Field($properties = array())
    {
        Requirements::javascript(THIRDPARTY_DIR . '/jquery-livequery/jquery.livequery.js');
        Requirements::javascript('pixlr/thirdparty/supa/Supa.js');
        Requirements::javascript('pixlr/javascript/supa-field.js');
        Requirements::css('pixlr/css/pixlr.css');
        $id = $this->id();
        $div = '<div id="' . $id . 'Container" class="' . $this->extraClass() . ' supaField">';
        $div .= '<div class="supaButtons">';
        $div .= $this->createTag('input', array('id' => $id . 'Paste', 'value' => _t('Pixlr.PASTE', 'Paste'), 'type' => 'button', 'class' => 'supaPasteButton'));
        $div .= $this->createTag('input', array('id' => $id . 'Upload', 'value' => _t('Pixlr.UPLOAD', 'Upload'), 'type' => 'button', 'class' => 'supaUploadButton', 'style' => 'display: none'));
        $div .= $this->createTag('input', array('type' => 'checkbox', 'value' => '1', 'name' => 'AndEdit', 'id' => $id . 'AndEdit'));
        $div .= '<label for="' . $id . 'AndEdit' . '">and Edit</label>';
        $div .= $this->createTag('input', array('class' => 'supaFileID', 'type' => 'hidden', 'value' => ''));
        $div .= '</div><div class="supaOptions" style="display: none">';
        if ($this->options['show_selector']) {
            $treeField = new TreeDropdownField('SupaLocation', _t('Pixlr.UPLOAD_LOCATION', 'Save to'), 'File');
            $div .= $treeField->Field();
        } else {
            // create a default target for uploading to
            $target = Folder::findOrMake($this->options['target']);
            $div .= $this->createTag('input', array('type' => 'hidden', 'name' => 'SupaLocation', 'value' => $target->ID));
        }
        $div .= $this->createTag('input', array('id' => $id . 'Filename', 'value' => $this->options['name'], 'name' => 'SupaImageName'));
        $params = array('parent' => '{input[name=FolderID]}', 'force' => true, 'imgstate' => 'existing', 'title' => '{#' . $id . 'Filename}.png');
        $pixlr = new PixlrEditorField('EditSelectedImage' . $id, _t('Pixlr.EDIT_SELECTED', 'Edit Selected'), '{#' . $id . 'Container .supaFileID}', $params);
        $div .= $pixlr->Field();
        $div .= '</div><div class="supaFileUrl"></div><div class="supaAppletWrapper" id="' . $id . 'AppletWrapper">';
        $url = Director::absoluteBaseURL() . 'pixlr/thirdparty/supa/Supa.jar';
        $div .= '<applet id="' . $id . 'Applet" class="supaApplet"
              archive="' . $url . '"
              code="de.christophlinder.supa.SupaApplet" 
              width="' . $this->options['width'] . '" 
              height="' . $this->options['height'] . '">
        <!--param name="clickforpaste" value="true"-->
			<param name="imagecodec" value="png">
			<param name="encoding" value="base64">
			<param name="previewscaler" value="fit to canvas">
			<!--param name="trace" value="true"-->
			Applets disabled :(
		  </applet> ';
        $div .= '</div></div>';
        return $div;
    }
 /**
  * CMS Fields
  * @return array
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $TeaserConfig = GridFieldConfig_RecordEditor::create();
     if ($this->LinkList()->Count() > 0) {
         $TeaserConfig->addComponent(new GridFieldOrderableRows());
     }
     $fields->addFieldsToTab('Root.Main', array(TextareaField::create('Title')->setRows(1), DropdownField::create('LinkType', 'Type', array("currentchildren" => "List all sub pages of this page", "children" => "Specify a page and list all its sub pages", "specify" => "Specify each link")), DisplayLogicWrapper::create(TreeDropdownField::create('ParentPageID', 'Select a page', 'SiteTree'))->displayIf("LinkType")->isEqualTo("children")->end(), DisplayLogicWrapper::create(GridField::create('LinkList', 'Current Link(s)', $this->LinkList(), $TeaserConfig))->displayIf("LinkType")->isEqualTo("specify")->end()));
     return $fields;
 }
 public function getConfiguration()
 {
     $fields = parent::getConfiguration();
     $fields->push(TreeDropdownField::create("ParentID", "Section", "SiteTree")->setFilterFunction(function ($node) {
         return SiteTree::get()->filter("ParentID", $node->ID)->exists();
     }));
     $fields->push(DropdownField::create("Subject", "Page type", $this->getPageTypes())->addExtraClass("no-chzn"));
     $fields->push(TextField::create("Count", _t('DashboardRecentEdits.COUNT', 'Number of pages to display')));
     return $fields;
 }
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab("Root.CheckboxSet", new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map()));
     $fields->addFieldsToTab('Root.Tree', array(TreeDropdownField::create('HasOnePage', 'HasOnePage', 'SiteTree'), TreeMultiselectField::create('HasManyPages', 'HasManyPages', 'SiteTree'), TreeMultiselectField::create('ManyManyPages', 'ManyManyPages (with search)', 'SiteTree')->setShowSearch(true)));
     //		$fields->addFieldToTab("Root.Tests.ComplexTableField",
     //			new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map()));
     //		$fields->addFieldToTab("Root.Tests.CheckboxSet", new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map()));
     return $fields;
 }
 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();
 }
Example #30
0
 /**
  * Get CMS fields
  * 
  * @return FieldList
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeFieldsFromTab('Root.Main', array('SliderParentID', 'SortOrder'));
     $fields->replaceField('Title', TextField::create('Title', 'Title'));
     $fields->dataFieldByName('Content')->setRows(20);
     $fields->addFieldToTab('Root.Main', UploadField::create('Image', 'Image')->setFolderName('BlockWidgetSlider/SliderImages/'));
     $fields->replaceField('RedirectPageID', TreeDropdownField::create('RedirectPageID', 'Choose a redirect page', 'SiteTree'));
     $fields->insertAfter($fields->dataFieldByName('RedirectPageID'), 'ButtonText');
     return $fields;
 }