当前位置: 首页>>代码示例>>PHP>>正文


PHP TreeDropdownField::tree方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:15,代码来源:OptionalTreeDropdownField.php

示例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;
 }
开发者ID:hamaka,项目名称:silverstripe-subsites,代码行数:8,代码来源:SubsitesTreeDropdownField.php

示例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;
 }
开发者ID:GOVTNZ,项目名称:silverstripe-optionaltreedropdownfield,代码行数:17,代码来源:OptionalTreeDropdownField.php

示例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;
 }
开发者ID:mikenz,项目名称:silverstripe-simplesubsites,代码行数:11,代码来源:SubsitesTreeDropdownField.php

示例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');
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:47,代码来源:TreeDropdownFieldTest.php


注:本文中的TreeDropdownField::tree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。