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


PHP RecursiveIteratorIterator::key方法代码示例

本文整理汇总了PHP中RecursiveIteratorIterator::key方法的典型用法代码示例。如果您正苦于以下问题:PHP RecursiveIteratorIterator::key方法的具体用法?PHP RecursiveIteratorIterator::key怎么用?PHP RecursiveIteratorIterator::key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RecursiveIteratorIterator的用法示例。


在下文中一共展示了RecursiveIteratorIterator::key方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getFile

 /**
  * @param $path
  * @return mixed|string
  */
 private function getFile($path)
 {
     $returnView = $this->viewFolder . $path . '.php';
     if (!file_exists($returnView)) {
         $dir = $path;
         $dir = explode('/', $dir);
         unset($dir[count($dir) - 1]);
         $dir = implode('/', $dir);
         $it = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->viewFolder . $dir));
         while ($it->valid()) {
             if (!$it->isDot()) {
                 $cache['SelectView'] = strrev($path);
                 $cache['SelectView'] = explode("/", $cache['SelectView'])[0];
                 $cache['SelectView'] = strrev($cache['SelectView']);
                 $cache['ReturnView'] = explode(".", $it->key());
                 unset($cache['ReturnView'][count($cache['ReturnView']) - 1]);
                 $cache['ReturnView'] = implode('.', $cache['ReturnView']);
                 $cache['ReturnView'] = explode("\\", $cache['ReturnView']);
                 $cache['ReturnView'] = $cache['ReturnView'][count($cache['ReturnView']) - 1];
                 if ($cache['ReturnView'] == $cache['SelectView']) {
                     $returnView = $it->key();
                 }
             }
             $it->next();
         }
         if (!isset($returnView)) {
             die('Can not find a file matching these arguments: getView("' . $this->getPath($path, TRUE) . '")');
         }
         return $returnView;
     }
 }
开发者ID:dashomeradio,项目名称:framework,代码行数:35,代码来源:View.php

示例2: scanDir

 /**
  * Function to start a scan in a directory.
  * @return Array
  * @throws DirectoryNotFoundException
  */
 public static function scanDir($parentDirectory)
 {
     $occurences = array(array());
     //if the directory/file does not exists, then throw and error.
     if (!file_exists($parentDirectory)) {
         throw new DirectoryORFileNotFoundException("ERROR: Directory not found!");
     }
     //get the list of all the files inside this directory.
     $allFiles = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($parentDirectory));
     $fileList = array();
     //remove (.), (..) and directories from the list of all files so that only files are left.
     while ($allFiles->valid()) {
         if (!$allFiles->isDot()) {
             if (!is_dir($allFiles->key())) {
                 array_push($fileList, $allFiles->key());
             }
         }
         $allFiles->next();
     }
     $i = 0;
     foreach ($fileList as $file) {
         if (pathinfo($file, PATHINFO_EXTENSION) != "php") {
             continue;
         }
         $occurences[$i]['file'] = realpath($file);
         $occurences[$i]['result'] = Scanner::scanFile($file);
         $i++;
     }
     return $occurences;
 }
开发者ID:sachintaware,项目名称:phpsec,代码行数:35,代码来源:scanner.php

示例3: copyDir

 /**
  * @throws  \Seitenbau\FileSystem\FileSystemException
  */
 public static function copyDir($source, $destination)
 {
     if (!is_dir($source)) {
         throw new FileSystemException('Sourcedir "' . $source . '" does not exists');
     }
     $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source), \RecursiveIteratorIterator::SELF_FIRST);
     if (!self::createDirIfNotExists($destination)) {
         return false;
     }
     // Verzeichnis rekursiv durchlaufen
     while ($iterator->valid()) {
         if (!$iterator->isDot()) {
             if ($iterator->current()->isDir()) {
                 // relativen Teil des Pfad auslesen
                 $relDir = str_replace($source, '', $iterator->key());
                 // Ziel-Verzeichnis erstellen
                 if (!self::createDirIfNotExists($destination . $relDir)) {
                     return false;
                 }
             } elseif ($iterator->current()->isFile()) {
                 $destinationFile = $destination . str_replace($source, '', $iterator->key());
                 if (!copy($iterator->key(), $destinationFile)) {
                     return false;
                 }
             }
         }
         $iterator->next();
     }
     return true;
 }
开发者ID:rukzuk,项目名称:rukzuk,代码行数:33,代码来源:FileSystem.php

示例4: DirectoryContent

 public static function DirectoryContent($Directory, $UserLanguage)
 {
     $ReadDirectory = $Directory . str_replace('.language', '', $UserLanguage);
     $Iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($ReadDirectory));
     $FilesArray = array();
     while ($Iterator->valid()) {
         if (!$Iterator->isDot()) {
             $FilesArray[] = array('FileLink' => $Iterator->key(), 'FileName' => $Iterator->getSubPathName(), 'SmallFileName' => strtolower(str_replace('.language', '', $Iterator->getSubPathName())), 'LinesCount' => File::CountLines($Iterator->key()));
         }
         $Iterator->next();
     }
     return $FilesArray;
 }
开发者ID:Refuge89,项目名称:FreedomCore,代码行数:13,代码来源:File.FreedomCore.php

示例5: addTestDirectoryRecursive

 public static function addTestDirectoryRecursive(PHPUnit_Framework_TestSuite $suite, $directory)
 {
     $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));
     while ($it->valid()) {
         if (!$it->isDot()) {
             $file = $it->key();
             if (preg_match('|Test\\.php$|', $file) && $file !== __FILE__) {
                 $suite->addTestFile($file);
             }
         }
         $it->next();
     }
 }
开发者ID:nojimage,项目名称:cakephp-twim,代码行数:13,代码来源:AllTwimTestsTest.php

示例6: getTestFiles

 /**
  * Get Test Files
  *
  * @param null $directory
  * @param null $excludes
  * @return array
  */
 public static function getTestFiles($directory = null, $excludes = null)
 {
     if (is_array($directory)) {
         $files = array();
         foreach ($directory as $d) {
             $files = array_merge($files, self::getTestFiles($d, $excludes));
         }
         return array_unique($files);
     }
     if ($excludes !== null) {
         $excludes = self::getTestFiles((array) $excludes);
     }
     if ($directory === null || $directory !== realpath($directory)) {
         $basePath = App::pluginPath('DebugKit') . 'Test' . DS . 'Case' . DS;
         $directory = str_replace(DS . DS, DS, $basePath . $directory);
     }
     $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));
     $files = array();
     while ($it->valid()) {
         if (!$it->isDot()) {
             $file = $it->key();
             if (preg_match('|Test\\.php$|', $file) && $file !== __FILE__ && !preg_match('|^All.+?\\.php$|', basename($file)) && ($excludes === null || !in_array($file, $excludes))) {
                 $files[] = $file;
             }
         }
         $it->next();
     }
     return $files;
 }
开发者ID:SebFav,项目名称:ApplicationInternet2,代码行数:36,代码来源:DebugkitGroupTestCase.php

示例7: array_flatten

function array_flatten(array $array, $key_separator = '/')
{
    $result = array();
    // a stack of strings
    $keys = array();
    $prev_depth = -1;
    $iter = new RecursiveIteratorIterator(new RecursiveArrayIterator($array), RecursiveIteratorIterator::SELF_FIRST);
    // rewind() is necessary
    for ($iter->rewind(); $iter->valid(); $iter->next()) {
        $curr_depth = $iter->getDepth();
        $diff_depth = $prev_depth - $curr_depth + 1;
        //##### TODO: It would be nice to do this with a single function.
        while ($diff_depth > 0) {
            array_pop($keys);
            --$diff_depth;
        }
        /*
        Note:
        http://bugs.php.net/bug.php?id=52425
        array_shift/array_pop: add parameter that tells how many to elements to pop
        */
        array_push($keys, $iter->key());
        if (is_scalar($iter->current())) {
            $result[implode($key_separator, $keys)] = $iter->current();
        }
        $prev_depth = $curr_depth;
    }
    return $result;
}
开发者ID:grevutiu-gabriel,项目名称:iqatest,代码行数:29,代码来源:array_flatten.php

示例8: searchByContent

 private static function searchByContent(\RecursiveIteratorIterator $file, $query)
 {
     if (!$file->isDot() && is_readable($file->key())) {
         try {
             $handle = fopen($file->key(), 'r');
             if ($handle) {
                 while (!feof($handle)) {
                     if (strpos(fgets($handle), $query) !== false) {
                         return true;
                     }
                 }
             }
         } catch (ContextErrorException $e) {
         }
     }
     return false;
 }
开发者ID:myxaxa,项目名称:filesearchbundle,代码行数:17,代码来源:DefaultSearchEngine.php

示例9: key

 function key()
 {
     if ($this->rit_flags & self::BYPASS_KEY) {
         return parent::key();
     } else {
         return $this->getPrefix() . parent::key() . $this->getPostfix();
     }
 }
开发者ID:ookwudili,项目名称:chisimba,代码行数:8,代码来源:stdlib_class_inc.php

示例10: addDirectory

 public function addDirectory($path, $localpath = null, $exclude_hidden = true)
 {
     if ($localpath === null) {
         $localpath = $path;
     }
     $localpath = rtrim($localpath, '/\\');
     $path = rtrim($path, '/\\');
     $iter = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
     while ($iter->valid()) {
         if (!$iter->isDot() && !$iter->isDir()) {
             if (!$exclude_hidden || !$this->is_path_hidden($iter->key())) {
                 $this->addFile($iter->key(), $localpath . DIRECTORY_SEPARATOR . $iter->getSubPathName());
             }
         }
         $iter->next();
     }
 }
开发者ID:mambax7,项目名称:xoopseditors,代码行数:17,代码来源:build.php

示例11: buildTree

 public function buildTree($last_created = '')
 {
     $dir = new RecursiveDirectoryIterator($this->root_dir, FilesystemIterator::SKIP_DOTS);
     $this->filter($dir);
     $it = new RecursiveIteratorIterator($this->filter, RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD);
     $tree = array();
     foreach ($it as $fileinfo) {
         $name = $fileinfo->getFilename();
         $sub_path_name = $it->getSubPathName();
         $parts = explode(DIRECTORY_SEPARATOR, $sub_path_name);
         array_pop($parts);
         $parentArr =& $tree;
         //go deep in the file|dir path
         foreach ($parts as $part) {
             $parentArr =& $parentArr['dirs'][$part];
         }
         if ($fileinfo->isDir()) {
             //statistics
             $statistics = $this->countChildren($it->key());
             $total_files = round($statistics['files'] / $this->count_suffix);
             // Add the final part to the structure
             if (!empty($last_created) && $it->key() == $last_created) {
                 $parentArr['dirs'][$name] = array('f' => $name, 'c-folders' => $statistics['folders'], 'c-files' => $total_files, 'last' => true);
             } else {
                 $parentArr['dirs'][$name] = array('f' => $name, 'c-folders' => $statistics['folders'], 'c-files' => $total_files, 'ffff' => $statistics['files'] . '..' . $this->count_suffix);
             }
         } else {
             // Add some file info to the structure
             if ($fileinfo->isLink()) {
                 $realpath = $fileinfo->getRealPath();
                 $filesize = filesize($realpath);
                 $filemtime = filemtime($realpath);
             } else {
                 $filesize = $fileinfo->getSize();
                 $filemtime = $fileinfo->getMTime();
             }
             $file_path = $it->getSubPath() == '' ? '/' : '/' . $it->getSubPath() . '/';
             $parentArr['files'][] = array('filename' => $name, 'filesize' => $this->fileSizeConvert($filesize), 'date' => date("d-m-Y H:i", $filemtime), 'relative_path' => $file_path);
         }
     }
     unset($parentArr);
     $this->sortArray($tree);
     return $tree;
 }
开发者ID:jonataswalker,项目名称:FileBrowser,代码行数:44,代码来源:build-tree.php

示例12: GetDirectoryContent

 public static function GetDirectoryContent($Directory, $SearchForFormat = null)
 {
     $Iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($Directory));
     $FilesArray = array();
     while ($Iterator->valid()) {
         if (!$Iterator->isDot()) {
             if ($SearchForFormat != null) {
                 $Exploded = explode('.', $Iterator->getSubPathName());
                 if ($Exploded[1] == $SearchForFormat) {
                     $FilesArray[] = array('FileLink' => $Iterator->key(), 'FileName' => $Iterator->getSubPathName());
                 }
             } else {
                 $FilesArray[] = array('FileLink' => $Iterator->key(), 'FileName' => $Iterator->getSubPathName());
             }
         }
         $Iterator->next();
     }
     return $FilesArray;
 }
开发者ID:sonyc,项目名称:FreedomCore,代码行数:19,代码来源:File.FreedomCore.php

示例13: current

 function current()
 {
     $current = parent::current();
     $key = parent::key();
     $retValue = "<td style='width:150px;border:1px solid black;'>\n\t\t\t        \t\t   \t<input ";
     if ($key == 'Id') {
         $retValue .= "readonly ";
     }
     $retValue .= "type='text' name='" . htmlspecialchars($key) . "' value='" . htmlspecialchars($current) . "'>\n\t\t\t        \t\t</td>";
     return $retValue;
 }
开发者ID:billyboy429,项目名称:EmployeeForm,代码行数:11,代码来源:employee.php

示例14: GetDirectoryContent

 public static function GetDirectoryContent($Directory)
 {
     $Iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($Directory));
     $FilesArray = array();
     while ($Iterator->valid()) {
         if (!$Iterator->isDot()) {
             $FilesArray[] = array('FileLink' => $Iterator->key(), 'FileName' => $Iterator->getSubPathName());
         }
         $Iterator->next();
     }
     return $FilesArray;
 }
开发者ID:RavenB,项目名称:FreedomCore,代码行数:12,代码来源:File.FreedomCore.php

示例15: get_all_files

 private function get_all_files()
 {
     $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->input_dir));
     $result = array();
     while ($iterator->valid()) {
         if (!$iterator->isDot()) {
             $result[$iterator->getSubPath()][] = $iterator->key();
         }
         $iterator->next();
     }
     return $result;
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:12,代码来源:unzipnrename.php


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