本文整理汇总了PHP中TreeDropdownField::tree方法的典型用法代码示例。如果您正苦于以下问题:PHP TreeDropdownField::tree方法的具体用法?PHP TreeDropdownField::tree怎么用?PHP TreeDropdownField::tree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeDropdownField
的用法示例。
在下文中一共展示了TreeDropdownField::tree方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tree
/**
* 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;
}
}
示例2: tree
function tree(SS_HTTPRequest $request)
{
$oldSubsiteID = Session::get('SubsiteID');
Session::set('SubsiteID', $this->subsiteID);
$results = parent::tree($request);
Session::set('SubsiteID', $oldSubsiteID);
return $results;
}
示例3: tree
/**
* Get the whole tree of a part of the tree via an AJAX request.
*
* @param SS_HTTPRequest $request
* @return string
*/
public function tree(SS_HTTPRequest $request)
{
// Get tree from parent
$tree = parent::tree($request);
if ($this->getHasEmptyDefault()) {
// Insert empty option into tree
$lf = "\n";
$tree = str_replace('<ul class="tree">' . $lf, '<ul class="tree">' . $lf . '<li id="selector-LinkInternalID-0" data-id="0" class="class-NoPageSelect closed"><a rel="0">' . $this->getEmptyString() . '</a></li>' . $lf, $tree);
}
return $tree;
}
示例4: tree
public function tree(SS_HTTPRequest $request)
{
$oldSubsiteID = Session::get('SubsiteID');
if ($request->getVar($this->name . '_SubsiteID')) {
$this->subsiteID = $request->getVar($this->name . '_SubsiteID');
}
Session::set('SubsiteID', $this->subsiteID);
$results = parent::tree($request);
Session::set('SubsiteID', $oldSubsiteID);
return $results;
}
示例5: 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');
}