本文整理汇总了PHP中Helpers::list_files方法的典型用法代码示例。如果您正苦于以下问题:PHP Helpers::list_files方法的具体用法?PHP Helpers::list_files怎么用?PHP Helpers::list_files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Helpers
的用法示例。
在下文中一共展示了Helpers::list_files方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: collate_files
function collate_files($dir)
{
$files_modified = '';
foreach (Helpers::list_files($dir, '/.*/', false) as $file) {
$files_modified .= $file . ':' . filemtime($file);
if (is_dir($file)) {
$files_modified .= $this->collate_files($file);
}
}
return $files_modified;
}
示例2: template_name
function template_name()
{
$txts = array_keys(Helpers::list_files($this->file_path, '/\\.txt$/'));
# return first matched .txt file
return !empty($txts) ? preg_replace('/\\.txt$/', '', $txts[0]) : false;
}
示例3: site_last_modified
static function site_last_modified($dir = false)
{
if (!$dir) {
$dir = Config::$content_folder;
}
$last_updated = 0;
foreach (Helpers::list_files($dir, '/.*/', false) as $file) {
if (filemtime($file) > $last_updated) {
$last_updated = filemtime($file);
}
if (is_dir($file)) {
$child_updated = self::site_last_modified($file);
if ($child_updated > $last_updated) {
$last_updated = $child_updated;
}
}
}
return $last_updated;
}
示例4: create_asset_collections
static function create_asset_collections($page)
{
# page.files
$page->files = Helpers::list_files($page->file_path, '/(?<!thumb|_lge|_sml)\\.(?!yml)([\\w\\d]+?)$/i', false);
# page.images
$page->images = Helpers::list_files($page->file_path, '/(?<!thumb|_lge|_sml)\\.(gif|jpg|png|jpeg)$/i', false);
# page.numbered_images
$page->numbered_images = Helpers::list_files($page->file_path, '/^\\d+[^\\/]*(?<!thumb|_lge|_sml)\\.(gif|jpg|png|jpeg)$/i', false);
# page.video
$page->video = Helpers::list_files($page->file_path, '/\\.(mov|mp4|m4v)$/i', false);
# page.swf, page.html, page.doc, page.pdf, page.mp3, etc.
# create a variable for each file type included within the page's folder (excluding .yml files)
$assets = self::get_file_types($page->file_path);
foreach ($assets as $asset_type => $asset_files) {
$page->{$asset_type} = $asset_files;
}
}
示例5: create_asset_collections
static function create_asset_collections($page)
{
# page.files
$page->files = Helpers::list_files($page->file_path, '/(?<!thumb|_lge|_sml)\\.(?!yml)([\\w\\d]+?)$/i', false);
# page.images
$page->images = Helpers::list_files($page->file_path, '/(?<!thumb|_lge|_sml)\\.(gif|jpg|png|jpeg)$/i', false);
# page.numbered_images
$page->numbered_images = Helpers::list_files($page->file_path, '/^\\d+[^\\/]*(?<!thumb|_lge|_sml)\\.(gif|jpg|png|jpeg)$/i', false);
# page.video
$page->video = Helpers::list_files($page->file_path, '/\\.(mov|mp4|m4v)$/i', false);
# page.txt
$page->txt = Helpers::list_files($page->file_path, '/\\.(txt)$/i', false);
# Save each txt file as page variable
foreach ($page->data['txt'] as $filename => $file_path) {
$var_name = preg_replace('/\\.(txt)/', '', $filename);
if (is_readable($file_path)) {
ob_start();
include $file_path;
$content = ob_get_contents();
ob_end_clean();
$relative_path = preg_replace('/^\\.\\//', Helpers::relative_root_path(), $page->file_path);
# replace the only var in your content - page.path for your inline html with images and stuff
if (is_string($content)) {
$content = preg_replace('/{{\\s*path\\s*}}/', $relative_path . '/', $content);
}
$page->{$var_name} = Markdown($content);
} else {
$page->{$var_name} = '';
}
}
# page.swf, page.html, page.doc, page.pdf, page.mp3, etc.
# create a variable for each file type included within the page's folder (excluding .yml files)
$assets = self::get_file_types($page->file_path);
foreach ($assets as $asset_type => $asset_files) {
$page->{$asset_type} = $asset_files;
}
}
示例6: template_name
static function template_name($file_path)
{
$txts = array_keys(Helpers::list_files($file_path, '/\\.(yml)/'));
# return first matched .yml file
return !empty($txts) ? preg_replace('/\\.(yml)/', '', $txts[0]) : false;
}
示例7: create_asset_collections
static function create_asset_collections($page)
{
# $images
$page->images = Helpers::list_files($page->file_path, '/(?<!thumb|_lge|_sml)\\.(gif|jpg|png|jpeg)$/i', false);
# $video
$page->video = Helpers::list_files($page->file_path, '/\\.(mov|mp4|m4v)$/i', false);
# $swf, $html, $doc, $pdf, $mp3, etc.
# create a variable for each file type included within the page's folder (excluding .txt files)
$assets = self::get_file_types($page->file_path);
foreach ($assets as $asset_type => $asset_files) {
eval('$page->' . $asset_type . '=$asset_files;');
}
# create asset collections (any assets within a folder beginning with an underscore)
$asset_collections = self::get_asset_collections($page->file_path);
foreach ($asset_collections as $collection_name => $collection_files) {
eval('$page->' . $collection_name . '=$collection_files;');
}
}
示例8: template_name
static function template_name($file_path)
{
$txts = array_keys(Helpers::list_files($file_path, '/\\.txt$/'));
# return first matched .txt file
return !empty($txts) ? preg_replace('/([^.]*\\.)?([^.]*)\\.txt$/', '\\2', $txts[0]) : false;
}
示例9: template_name
static function template_name($file_path) {
$txts = array_keys(Helpers::list_files($file_path, '/\.(txt|css|md)$/'));
# return first matched .txt,.md, or .css file
return (!empty($txts)) ? preg_replace('/\.(txt|css|md)$/', '', $txts[0]) : false;
}
示例10: parse_loop
static function parse_loop($page, $dir, $loop_html)
{
$files = Helpers::list_files($dir, '/^\\d+?\\./', true);
$html = '';
foreach ($files as $key => $file) {
// if file is not a category and is not the index page, add it to the pages list
if (!preg_match('/index/', $file) && !Helpers::is_category($file, $dir)) {
$file_name_clean = preg_replace('/^\\d+?\\./', '', $file);
// store the url and name of the navigation item
$replacements = array('/@url/' => $page->link_path . $file_name_clean . '/', '/@name/' => ucfirst(preg_replace('/-/', ' ', $file_name_clean)));
$html .= preg_replace(array_keys($replacements), array_values($replacements), $loop_html);
}
}
return $html;
}
示例11: last_modified
static function last_modified($dir)
{
$last_modified = 0;
if (is_dir($dir)) {
foreach (Helpers::list_files($dir, '/.*/', false) as $file) {
if (!is_dir($file)) {
$last_modified = filemtime($file) > $last_modified ? filemtime($file) : $last_modified;
}
}
}
return $last_modified;
}