本文整理汇总了PHP中Folder::tree方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::tree方法的具体用法?PHP Folder::tree怎么用?PHP Folder::tree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Folder
的用法示例。
在下文中一共展示了Folder::tree方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addTestDirectoryRecursive
/**
* Recursively adds all the files in a directory to the test suite.
*
* @param string $directory The directory subtree to add tests from.
* @return void
*/
public function addTestDirectoryRecursive($directory = '.')
{
$Folder = new Folder($directory);
$files = $Folder->tree(null, true, 'files');
foreach ($files as $file) {
$this->addTestFile($file);
}
}
示例2: addTestDirectoryRecursive
/**
* Recursively adds all the files in a directory to the test suite.
*
* @param string $directory The directory subtree to add tests from.
*
* @return void
*/
public function addTestDirectoryRecursive($directory = '.')
{
$Folder = new Folder($directory);
$files = $Folder->tree(NULL, TRUE, 'files');
foreach ($files as $file) {
if (substr($file, -4) === '.php') {
$this->addTestFile($file);
}
}
}
示例3: addTestDirectoryRecursive
/**
* Recursively adds all the files in a directory to the test suite.
*
* @param string $directory The directory subtree to add tests from.
* @return void
*/
public function addTestDirectoryRecursive($directory = '.')
{
$Folder = new Folder($directory);
$files = $Folder->tree(null, false, 'files');
foreach ($files as $file) {
if (strpos($file, DS . '.') !== false) {
continue;
}
$this->addTestFile($file);
}
}
示例4: suite
/**
* All test suite
*
* @return CakeTestSuite
*/
public static function suite()
{
$plugin = preg_replace('/^All([\\w]+)Test$/', '$1', __CLASS__);
$suite = new CakeTestSuite(sprintf('All %s Plugin tests', $plugin));
$directory = CakePlugin::path($plugin) . 'Test' . DS . 'Case';
$Folder = new Folder($directory);
$exceptions = array('CommentsModelTestBase.php');
$files = $Folder->tree(null, $exceptions, 'files');
foreach ($files as $file) {
if (substr($file, -4) === '.php') {
$suite->addTestFile($file);
}
}
return $suite;
}
示例5: suite
/**
* All test suite
*
* @return CakeTestSuite
*/
public static function suite()
{
$plugin = preg_replace('/^All([\\w]+)Test$/', '$1', __CLASS__);
$suite = new CakeTestSuite(sprintf('All %s Plugin tests', $plugin));
$directory = CakePlugin::path($plugin) . 'Test' . DS . 'Case';
$Folder = new Folder($directory);
$exceptions = array('FaqsControllerTestBase.php', 'FaqsModelTestBase.php', 'FaqQuestionOrderTestBase.php', 'FaqQuestionTestBase.php', 'FaqSettingTestBase.php', 'FaqTestBase.php', 'BlockRolePermissionsControllerEditTest.php', 'BlocksControllerAddTest.php', 'BlocksControllerEditTest.php', 'BlocksControllerIndexTest.php', 'FaqQuestionOrdersControllerEditTest.php', 'FaqQuestionsControllerAddTest.php', 'FaqQuestionsControllerDeleteTest.php', 'FaqQuestionsControllerEditTest.php', 'FaqQuestionsControllerIndexTest.php', 'FaqQuestionsControllerViewTest.php', 'FaqsControlleIndexrTest.php', 'FaqsControllerTestBase.php', 'FaqDeleteFaqTest.php', 'FaqGetFaqTest.php', 'FaqQuestionDeleteFaqQuestionTest.php', 'FaqQuestionGetFaqQuestionsTest.php', 'FaqQuestionGetFaqQuestionTest.php', 'FaqQuestionOrderBeforeDeleteTest.php', 'FaqQuestionOrderGetMaxWeightTest.php', 'FaqQuestionOrderSaveFaqQuestionOrdersTest.php', 'FaqQuestionOrderTestBase.php', 'FaqQuestionOrderValidateFaqQuestionOrderTest.php', 'FaqQuestionSaveFaqQuestionTest.php', 'FaqQuestionTestBase.php', 'FaqQuestionValidateFaqQuestionTest.php', 'FaqSaveFaqTest.php', 'FaqSettingGetFaqSettingTest.php', 'FaqSettingSaveFaqSettingTest.php', 'FaqSettingTestBase.php', 'FaqSettingValidateFaqSettingTest.php', 'FaqsModelTestBase.php', 'FaqTestBase.php', 'FaqValidateFaqTest.php');
$files = $Folder->tree(null, $exceptions, 'files');
foreach ($files as $file) {
if (substr($file, -4) === '.php') {
$suite->addTestFile($file);
}
}
return $suite;
}
示例6: suite
/**
* All test suite
*
* @return CakeTestSuite
*/
public static function suite()
{
$plugin = preg_replace('/^All([\\w]+)Test$/', '$1', __CLASS__);
$suite = new CakeTestSuite(sprintf('All %s Plugin tests', $plugin));
$directory = CakePlugin::path($plugin) . 'Test' . DS . 'Case';
$Folder = new Folder($directory);
$exceptions = array('BlocksControllerTestBase.php', 'IframesControllerTestBase.php', 'IframesModelTestBase.php', 'BlocksControllerAddTest.php', 'BlocksControllerDeleteTest.php', 'BlocksControllerEditTest.php', 'BlocksControllerIndexTest.php', 'BlocksControllerTestBase.php', 'IframesControllerTestBase.php', 'IframesControllerViewTest.php', 'IframeDeleteTest.php', 'IframeGetTest.php', 'IframeSaveTest.php', 'IframesModelTestBase.php', 'IframeValidateTest.php');
$files = $Folder->tree(null, $exceptions, 'files');
foreach ($files as $file) {
if (substr($file, -4) === '.php') {
$suite->addTestFile($file);
}
}
return $suite;
}
示例7: suite
/**
* All test suite
*
* @return CakeTestSuite
*/
public static function suite()
{
$plugin = preg_replace('/^All([\\w]+)Test$/', '$1', __CLASS__);
$suite = new CakeTestSuite(sprintf('All %s Plugin tests', $plugin));
$directory = CakePlugin::path($plugin) . 'Test' . DS . 'Case';
$Folder = new Folder($directory);
$exceptions = array('RssReadersControllerTestBase.php', 'RssReadersModelTestBase.php', 'RssReaderFrameSettingSaveRssReaderFrameSettingTest.php', 'RssReaderFrameSettingValidateRssReaderFrameSettingTest.php', 'RssReaderGetRssReaderTest.php', 'RssReaderItemGetRssReaderItemsTest.php', 'RssReaderItemSerializeXmlToArrayTest.php', 'RssReaderItemUpdateRssReaderItemsTest.php', 'RssReaderItemValidateRssReaderItemsTest.php', 'RssReaderSaveRssReaderTest.php', 'RssReadersModelTestBase.php', 'RssReaderValidateRssReaderTest.php', 'RssReaderFrameSettingsControllerEditTest.php', 'RssReadersControllerEditTest.php', 'RssReadersControllerGetTest.php', 'RssReadersControllerTestBase.php', 'RssReadersControllerViewTest.php');
$files = $Folder->tree(null, $exceptions, 'files');
foreach ($files as $file) {
if (substr($file, -4) === '.php') {
$suite->addTestFile($file);
}
}
return $suite;
}
示例8: foreach
function admin_ckselect($dir = '')
{
if (!empty($dir)) {
$args = func_get_args();
foreach ($args as $n => $arg) {
$args[$n] = $this->_urldecode($arg);
}
$dir = implode('/', $args);
}
$_root_dir = new Folder($this->docs_path . DS . $dir);
$resources = $_root_dir->read(true, true);
$dir_tree = $_root_dir->tree($this->docs_path, true, 'dir');
foreach ($dir_tree as $n => $node) {
$dir_tree[$n] = substr($node, strlen($this->docs_path));
}
$getstring = '?CKEditor=' . $this->params['url']['CKEditor'] . '&CKEditorFuncNum=' . $this->params['url']['CKEditorFuncNum'] . '&langCode=' . $this->params['url']['langCode'];
$ckeditorfuncnum = $this->params['url']['CKEditorFuncNum'];
$this->set('docs_dir', $this->docs_dir);
$this->set('dir', $dir);
$this->set('dir_tree', $dir_tree);
$this->set(compact('resources', 'getstring', 'ckeditorfuncnum'));
$this->pageTitle = __('Select a file', true);
$this->layout = 'ckselect';
}
示例9: __advancedFolderFind
private function __advancedFolderFind($conditions)
{
if (empty($this->fileList[0])) {
$this->return = array();
return true;
}
$i = 0;
foreach ($this->fileList[0] as $folder) {
if (in_array($folder, $this->ignore)) {
continue;
}
if ($this->recursive > -2) {
$Folder = new Folder($this->path . DS . $folder);
$this->return[$i]['Folder']['path'] = $Folder->path;
$this->return[$i]['Folder']['name'] = basename($this->return[$i]['Folder']['path']);
$this->return[$i]['Folder']['parent'] = dirname($this->return[$i]['Folder']['path']);
$this->return[$i]['Folder']['relative'] = $this->__relativePath($this->return[$i]['Folder']['path']);
$stat = stat($this->return[$i]['Folder']['path']);
$this->__fileStatus($i, $stat);
if ($this->recursive > -1) {
$this->return[$i]['Folder']['accessed'] = date('Y-m-d H:i:s', $stat['atime']);
$this->return[$i]['Folder']['modified'] = date('Y-m-d H:i:s', $stat['mtime']);
$this->return[$i]['Folder']['created'] = date('Y-m-d H:i:s', $stat['ctime']);
if ($this->recursive > 0) {
$this->return[$i]['Folder']['size'] = $Folder->dirsize();
$this->return[$i]['Folder']['absolute'] = $Folder->isAbsolute($this->return[$i]['Folder']['path']);
$children = $Folder->tree($this->return[$i]['Folder']['path']);
$this->return[$i]['Folder']['sub_folders'] = count($children[0]) - 1;
$this->return[$i]['Folder']['sub_files'] = count($children[1]);
if ($this->recursive > 1) {
$this->return[$i]['Folder']['realpath'] = $Folder->realpath($this->return[$i]['Folder']['path']);
$this->return[$i]['Folder']['windows'] = $Folder->isWindowsPath($this->return[$i]['Folder']['path']);
$this->return[$i]['Folder']['Children'] = $children;
$this->return[$i]['Folder']['Extended'] = $stat;
$i++;
continue;
}
$i++;
}
$i++;
}
$i++;
}
$i++;
}
return true;
}
示例10: testFolderTreeWithHiddenFiles
/**
* testFolderTreeWithHiddenFiles method
*
* @return void
*/
public function testFolderTreeWithHiddenFiles()
{
$this->skipIf(!is_writable(TMP), 'Can\'t test Folder::tree with hidden files unless the tmp folder is writable.');
$Folder = new Folder(TMP . 'folder_tree_hidden', true, 0777);
mkdir($Folder->path . DS . '.svn', 0777, true);
touch($Folder->path . DS . '.svn' . DS . 'InHiddenFolder.php');
mkdir($Folder->path . DS . '.svn' . DS . 'inhiddenfolder');
touch($Folder->path . DS . '.svn' . DS . 'inhiddenfolder' . DS . 'NestedInHiddenFolder.php');
touch($Folder->path . DS . 'not_hidden.txt');
touch($Folder->path . DS . '.hidden.txt');
mkdir($Folder->path . DS . 'visible_folder' . DS . '.git', 0777, true);
$expected = array(array($Folder->path, $Folder->path . DS . 'visible_folder'), array($Folder->path . DS . 'not_hidden.txt'));
$result = $Folder->tree(null, true);
$this->assertEquals($expected, $result);
$result = $Folder->tree(null, array('.'));
$this->assertEquals($expected, $result);
$expected = array(array($Folder->path, $Folder->path . DS . 'visible_folder', $Folder->path . DS . 'visible_folder' . DS . '.git', $Folder->path . DS . '.svn', $Folder->path . DS . '.svn' . DS . 'inhiddenfolder'), array($Folder->path . DS . 'not_hidden.txt', $Folder->path . DS . '.hidden.txt', $Folder->path . DS . '.svn' . DS . 'inhiddenfolder' . DS . 'NestedInHiddenFolder.php', $Folder->path . DS . '.svn' . DS . 'InHiddenFolder.php'));
$result = $Folder->tree(null, false);
sort($result[0]);
sort($expected[0]);
sort($result[1]);
sort($expected[1]);
$this->assertEquals($expected, $result);
$Folder->delete();
}
示例11: _canBeDeleted
/**
* Recursively checks if the given directory (and its content) can be deleted.
*
* This method automatically registers an error message if validation fails.
*
* @param string $path Directory to check
* @return bool
*/
protected function _canBeDeleted($path)
{
if (!file_exists($path) || !is_dir($path)) {
$this->err(__d('installer', "Plugin's directory was not found: ", $path));
return false;
}
$folder = new Folder($path);
$content = $folder->tree();
$notWritable = [];
foreach ($content as $foldersOrFiles) {
foreach ($foldersOrFiles as $element) {
if (!is_writable($element)) {
$notWritable[] = $element;
}
}
}
if (!empty($notWritable)) {
$this->err(__d('installer', "Some plugin's files or directories cannot be removed from your server:"));
foreach ($notWritable as $path) {
$this->err(__d('installer', " -{0}", $path));
}
return false;
}
return true;
}
示例12: testFolderTree
/**
* testFolderTree method
*
* @access public
* @return void
*/
function testFolderTree()
{
$Folder = new Folder();
$expected = array(array(TEST_CAKE_CORE_INCLUDE_PATH . 'config', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding'), array(TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'paths.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0080_00ff.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0100_017f.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0180_024F.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0250_02af.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0370_03ff.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0400_04ff.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0500_052f.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0530_058f.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '1e00_1eff.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '1f00_1fff.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2100_214f.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2150_218f.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2460_24ff.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c00_2c5f.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c60_2c7f.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c80_2cff.php', TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . 'ff00_ffef.php'));
$result = $Folder->tree(TEST_CAKE_CORE_INCLUDE_PATH . 'config', false);
$this->assertIdentical(array_diff($expected[0], $result[0]), array());
$this->assertIdentical(array_diff($result[0], $expected[0]), array());
$result = $Folder->tree(TEST_CAKE_CORE_INCLUDE_PATH . 'config', false, 'dir');
$this->assertIdentical(array_diff($expected[0], $result), array());
$this->assertIdentical(array_diff($result, $expected[0]), array());
$result = $Folder->tree(TEST_CAKE_CORE_INCLUDE_PATH . 'config', false, 'files');
$this->assertIdentical(array_diff($expected[1], $result), array());
$this->assertIdentical(array_diff($result, $expected[1]), array());
}
示例13: __find
/**
* Locates the $file in $__paths, searches recursively.
*
* @param string $file full file name
* @param boolean $recursive search $__paths recursively
* @return mixed boolean on fail, $file directory path on success
* @access private
*/
private static function __find($file, $recursive = true)
{
if (empty(self::$search)) {
return null;
} elseif (is_string(self::$search)) {
self::$search = array(self::$search);
}
if (empty(self::$__paths)) {
self::$__paths = Cache::read('dir_map', '_cake_core_');
}
foreach (self::$search as $path) {
$path = rtrim($path, DS);
if ($path === rtrim(APP, DS)) {
$recursive = false;
}
if ($recursive === false) {
if (self::__load($path . DS . $file)) {
return $path . DS;
}
continue;
}
if (!isset(self::$__paths[$path])) {
if (!class_exists('Folder')) {
require LIBS . 'folder.php';
}
$Folder = new Folder();
$directories = $Folder->tree($path, array('.svn', 'tests', 'templates'), 'dir');
sort($directories);
self::$__paths[$path] = $directories;
}
foreach (self::$__paths[$path] as $directory) {
if (self::__load($directory . DS . $file)) {
return $directory . DS;
}
}
}
return null;
}
示例14: _addTestDirectoryRecursive
/**
* Recursively add all directories under `$path/Test/Case`.
*
* @param CakeTestSuite $Suite CakeTestSuite instance.
* @param string $path Root path where to find 'Test/Case'.
* @return CakeTestSuite Modified CakeTestSuite instance.
*/
protected static function _addTestDirectoryRecursive(CakeTestSuite $Suite, $path)
{
$Folder = new Folder($path . 'Test' . DS . 'Case');
$dirs = $Folder->tree(null, true, 'dir');
array_shift($dirs);
foreach ($dirs as $dir) {
$Suite->addTestDirectoryRecursive($dir);
}
return $Suite;
}
示例15: testFolderTree
/**
* testFolderTree method
*
* @access public
* @return void
*/
public function testFolderTree()
{
$Folder = new Folder();
$expected = array(array(CAKE . 'Config', CAKE . 'Config' . DS . 'unicode', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding'), array(CAKE . 'Config' . DS . 'config.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0080_00ff.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0100_017f.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0180_024F.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0250_02af.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0370_03ff.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0400_04ff.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0500_052f.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0530_058f.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '1e00_1eff.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '1f00_1fff.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2100_214f.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2150_218f.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2460_24ff.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c00_2c5f.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c60_2c7f.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c80_2cff.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . 'ff00_ffef.php'));
$result = $Folder->tree(CAKE . 'Config', false);
$this->assertSame(array_diff($expected[0], $result[0]), array());
$this->assertSame(array_diff($result[0], $expected[0]), array());
$result = $Folder->tree(CAKE . 'Config', false, 'dir');
$this->assertSame(array_diff($expected[0], $result), array());
$this->assertSame(array_diff($expected[0], $result), array());
$result = $Folder->tree(CAKE . 'Config', false, 'files');
$this->assertSame(array_diff($expected[1], $result), array());
$this->assertSame(array_diff($expected[1], $result), array());
}