當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。