本文整理汇总了PHP中RecursiveIteratorIterator::getExtension方法的典型用法代码示例。如果您正苦于以下问题:PHP RecursiveIteratorIterator::getExtension方法的具体用法?PHP RecursiveIteratorIterator::getExtension怎么用?PHP RecursiveIteratorIterator::getExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RecursiveIteratorIterator
的用法示例。
在下文中一共展示了RecursiveIteratorIterator::getExtension方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
*## Iterate and Process
* All the magic happens here, whils it looks complicated this is essentially a directory iterator
* that creates an array of filenames, with a corresponding Phrocco object that can look after rendering itself.
*
**/
public function process()
{
$dir_iterator = new PhroccoIterator($this->options["i"]);
$iterator = new \RecursiveIteratorIterator($dir_iterator, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $file) {
if (!$iterator->isDot() && in_array($iterator->getExtension(), $this->extensions[$this->options["l"]])) {
$base_path = $this->options["i"];
$rpath = str_replace($base_path, "", $file->getPath());
$phrocco = new Phrocco($this->options["l"], $file);
if (!$this->options["o"]) {
$output_dir = $file->getPath();
} else {
$output_dir = $this->options["o"];
}
if ($rpath != $file->getPath()) {
$output_dir .= "/" . $rpath;
}
/**
*### Check that we can write
* This block ensures that the output directory exists. If it doesn't we'll try and create it before giving up.
**/
if (!is_writable($output_dir)) {
try {
mkdir($output_dir, 0777, true);
} catch (Exception $e) {
if (!is_writable($output_dir)) {
throw new \Exception("Invalid Output Directory - Couldn't Create Because of Permissions");
}
}
}
/**
*### Build the documentation tree
* This block builds the documentation file layout to mirror the code files scanned.
**/
$file_out = $output_dir . "/" . $file->getBasename($iterator->getExtension()) . "html";
$phrocco->output_file = $file_out;
$subpath = $iterator->getSubPath();
$phrocco->path = (!empty($subpath) ? "./" : '') . $subpath;
$this->group[$file->getBasename()] = $phrocco;
$subpath .= !empty($subpath) ? '/' : '';
$this->sources[] = array("url" => $subpath . $file->getBasename($iterator->getExtension()) . "html", "name" => $file->getBasename(), "level" => $iterator->getDepth(), "folder" => $iterator->getSubPath());
}
}
}
示例2: countThemePages
protected function countThemePages($path)
{
$result = 0;
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
$it->setMaxDepth(1);
while ($it->valid()) {
if (!$it->isDot() && !$it->isDir() && $it->getExtension() == 'htm') {
$result++;
}
$it->next();
}
return $result;
}
示例3: __construct
public function __construct($options)
{
$sources = array();
$this->options = $options + $this->defaults;
$dir_iterator = new PhroccoIterator($this->options["i"]);
$iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $file) {
if (!$iterator->isDot() && in_array($iterator->getExtension(), $this->extensions[$this->options["l"]])) {
$base_path = $this->options["i"];
$rpath = str_replace($base_path, "", $file->getPath());
$phrocco = new Phrocco($this->options["l"], $file);
if (!$this->options["o"]) {
$output_dir = $file->getPath();
} else {
$output_dir = $this->options["o"];
}
if ($rpath != $file->getPath()) {
$output_dir .= "/" . $rpath;
}
if (!is_writable($output_dir)) {
@mkdir($output_dir, 0777, true);
}
if (!is_writable($output_dir)) {
throw new Exception("Invalid Output Directory - Couldn't Create Because of Permissions");
}
$file_out = $output_dir . "/" . $file->getBasename($iterator->getExtension()) . "html";
$phrocco->output_file = $file_out;
$subpath = $iterator->getSubPath();
$phrocco->path = (!empty($subpath) ? "./" : '') . $subpath;
$this->group[$file->getBasename()] = $phrocco;
$subpath .= !empty($subpath) ? '/' : '';
$this->sources[] = array("url" => $subpath . $file->getBasename($iterator->getExtension()) . "html", "name" => $file->getBasename());
}
}
foreach ($this->group as $name => $file) {
$file->sources = $this->sources;
echo "*** Processing: " . $name . "\n";
$file->render();
}
}
示例4: getFiles
public function getFiles($dirname = '')
{
$arr_folder = array();
$count = 0;
$folder = UPLOAD_DIR;
$folder .= DIRECTORY_SEPARATOR . $dirname;
if (is_dir($folder)) {
$dir = new RecursiveDirectoryIterator($folder);
$iter = new RecursiveIteratorIterator($dir, RecursiveIteratorIterator::SELF_FIRST);
while ($iter->valid()) {
if (!$iter->isDot()) {
if ($iter->getDepth() < $this->maxDepth) {
$item = array();
$item['id'] = $count;
$item['size'] = $iter->getSize();
$item['type'] = $iter->getType();
$item['ext'] = $iter->getExtension();
$item['pathname'] = $iter->getSubPathName();
$item['filename'] = $iter->getFilename();
$item['parent'] = '/' . $dirname;
$item['Exec'] = $iter->isExecutable();
$item['sub'] = '';
$count++;
$arr_folder[] = $item;
}
}
$iter->next();
}
return $arr_folder;
}
if (is_file($folder)) {
$file = file_get_contents($folder);
if (empty($file)) {
return ' ';
}
return $file;
}
}
示例5: Phar
$binaryFilename = "bin/{$binary}";
if (file_exists($pharFilename)) {
Phar::unlinkArchive($pharFilename);
}
if (file_exists($binaryFilename)) {
Phar::unlinkArchive($binaryFilename);
}
$phar = new Phar($pharFilename, FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO, $binary);
$phar->startBuffering();
$directories = array('src', 'vendor', 'scripts');
foreach ($directories as $dirname) {
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirname));
while ($iterator->valid()) {
if ($iterator->isFile()) {
$path = $iterator->getPathName();
if ('php' == strtolower($iterator->getExtension())) {
$contents = php_strip_whitespace($path);
$phar->addFromString($path, $contents);
} else {
$phar->addFile($path);
}
}
$iterator->next();
}
}
$stub = "#!/usr/bin/env php\n" . $phar->createDefaultStub($scriptFilename);
$phar->setStub($stub);
$phar->compressFiles(Phar::GZ);
$phar->stopBuffering();
rename($pharFilename, $binaryFilename);
chmod($binaryFilename, 0775);