本文整理汇总了PHP中TreeDropdownField类的典型用法代码示例。如果您正苦于以下问题:PHP TreeDropdownField类的具体用法?PHP TreeDropdownField怎么用?PHP TreeDropdownField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TreeDropdownField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCMSFields
/**
* 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;
}
示例2: getCMSFieldsForProductSliderWidget
/**
* 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 <sdiel@pixeltricks.de>
* @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;
}
示例3: getCMSFields
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;
}
示例4: getCMSFields
/**
* 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;
}
示例5: AddForm
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;
}
开发者ID:helpfulrobot,项目名称:sheadawson-silverstripe-multisites,代码行数:15,代码来源:MultisitesCMSPageAddController.php
示例6: getCMSFields
/**
* 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;
}
示例7: getCMSFields
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;
}
示例8: getCMSFields
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;
}
示例9: LinkForm
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;
}
示例10: getCMSFields
/**
* @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;
}
示例11: updateCMSFields
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");
}
示例12: ConvertObjectForm
/**
* 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;
}
开发者ID:helpfulrobot,项目名称:webbuilders-group-silverstripe-kapost-bridge,代码行数:34,代码来源:KapostGridFieldDetailForm_ItemRequest.php
示例13: getCMSFields
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;
}
示例14: testTreeSearch
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');
}
示例15: getCMSFields
/**
* 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;
}