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


PHP File::read_dir方法代码示例

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


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

示例1: addFile

 /**
  * Adds a file into the list to check for last modified date
  * 
  * @param string $path
  */
 public function addFile($path)
 {
     if (is_dir($path)) {
         $contents = \File::read_dir($path, 0, array('!^\\.', '!^private' => 'dir', '!^compiled' => 'dir', '\\.css$' => 'file', '\\.js$' => 'file', '\\.scss$' => 'file', '!^_'));
         $this->addFiles($contents, rtrim($path) . '/');
     } else {
         if (file_exists($path)) {
             $this->files[] = str_replace(PROJECTROOT, '', $path);
         }
     }
 }
开发者ID:soundintheory,项目名称:fuel-cmf,代码行数:16,代码来源:Simple.php

示例2: get_options

 public static function get_options()
 {
     $options = array();
     $stencil_dirs = File::read_dir(STENCILSPATH, 1);
     foreach ($stencil_dirs as $dir => $null) {
         if ($data = self::get($dir)) {
             $options[$dir] = $data['name'];
         }
     }
     return $options;
 }
开发者ID:niceboy120,项目名称:crude,代码行数:11,代码来源:stencil.php

示例3: action_portfolio

 /**
  * Portfolio page
  *
  * @access  public
  */
 public function action_portfolio()
 {
     $portfolio_pieces = array();
     $portfolio_dir = File::read_dir(DOCROOT . 'assets/img/portfolio');
     foreach ($portfolio_dir as $piece => $imgs) {
         $data = json_decode(file_get_contents(DOCROOT . 'assets/img/portfolio/' . $piece . 'data.json'));
         $object = array($data->name => (object) array('img' => $piece, 'url' => $data->url, 'total_imgs' => count($imgs) - 1));
         $portfolio_pieces[$data->name] = $object[$data->name];
     }
     $this->template->contact = View::forge('site/contact');
     $this->template->content = View::forge('site/portfolio', array('portfolio_pieces' => $portfolio_pieces, 'primary_piece' => 'Texting Base'));
 }
开发者ID:alexshaffer,项目名称:ashaffer,代码行数:17,代码来源:site.php

示例4: action_get_payments

 /**
  * Get enabled payments
  *
  * @access  public
  * @param   string   $get = Get payments that are: enabled | disabled | all
  * @param   string   $load_config = Load payments config
  * @param   bool     $allowed
  * @return  array
  *
  */
 public function action_get_payments($get = 'enabled', $load_config = true, $allowed = true)
 {
     if (!\Request::is_hmvc()) {
         die('Access is denied.');
     }
     $user = \Sentry::user();
     $out = array();
     $path = APPPATH . "modules" . DS . "payment" . DS . "config" . DS;
     $config_files = \File::read_dir($path);
     if (!empty($config_files)) {
         foreach ($config_files as $file) {
             $file_parts = pathinfo($file);
             $payment_config = (include_once $path . $file);
             // Check allowed
             if ($allowed && isset($payment_config['allowed']) && is_array($payment_config['allowed'])) {
                 foreach ($payment_config['allowed'] as $key => $value) {
                     if (!isset($user['metadata'][$key]) || !in_array($user['metadata'][$key], $value)) {
                         continue 2;
                     }
                 }
             }
             switch ($get) {
                 case 'enabled':
                     if ($payment_config['enabled']) {
                         $out[$payment_config['code']] = $payment_config['name'];
                         if ($load_config) {
                             \Config::load('payment::' . $file_parts['filename'], $file_parts['filename']);
                         }
                     }
                     break;
                 case 'disabled':
                     if (!$payment_config['enabled']) {
                         $out[$payment_config['code']] = $payment_config['name'];
                         if ($load_config) {
                             \Config::load('payment::' . $file_parts['filename'], $file_parts['filename']);
                         }
                     }
                     break;
                 default:
                 case 'all':
                     $out[$payment_config['code']] = $payment_config['name'];
                     if ($load_config) {
                         \Config::load('payment::' . $file_parts['filename'], $file_parts['filename']);
                     }
             }
         }
     }
     return $out;
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:59,代码来源:public.php

示例5: action_index

 /**
  * Root
  *
  * @access public
  * @return Response
  */
 public function action_index()
 {
     $data = array('dirs' => array());
     try {
         /**
          * get documentation list
          */
         $dirs = array_keys(File::read_dir(DOCROOT . 'dbdocs' . DS, 1));
         foreach ($dirs as $dir) {
             $i = count($data['dirs']);
             $data['dirs'][$i]['name'] = rtrim($dir, DS) . '/';
             $file_info = File::file_info(DOCROOT . 'dbdocs' . DS . $dir);
             $data['dirs'][$i]['time_ago'] = Date::time_ago($file_info['time_created']);
         }
     } catch (Fuel\Core\InvalidPathException $e) {
         //do nothing
     }
     $this->template->content = View::forge('index/index', array('data' => $data));
 }
开发者ID:kenjis,项目名称:fuel-dbdocs,代码行数:25,代码来源:index.php

示例6: action_update_mca

 public function action_update_mca()
 {
     $mpath = APPPATH . 'modules';
     try {
         $module = \File::read_dir($mpath, 2);
         foreach ($module as $k => $v) {
             if (is_string($k)) {
                 if (preg_match('#[a-zA-Z]+#i', $k, $m)) {
                     $mn = array_shift($m);
                     $mid = \Model\VsvnListMca::field('id', array('where' => array('name' => $mn, 'type' => 'module')));
                     if (empty($mid)) {
                         $mid = \Model\VsvnListMca::save(array('name' => $mn, 'type' => 'module', 'parent' => 0));
                     }
                     $path = $mpath . DS . $mn . DS . 'classes' . DS . 'controller';
                     $files = \File::read_dir($path);
                     foreach ($files as $file) {
                         $cn = substr($file, 0, strpos($file, '.'));
                         $cid = \Model\VsvnListMca::field('id', array('where' => array('name' => $cn, 'type' => 'controller')));
                         if (empty($cid)) {
                             $cid = \Model\VsvnListMca::save(array('name' => $cn, 'type' => 'controller', 'parent' => $mid));
                         }
                         $content = fopen($path . DS . $file, 'r');
                         while (!feof($content)) {
                             $line = fgets($content);
                             if (strpos($line, 'public')) {
                                 if (preg_match('/action_(.*)\\(.*\\)\\{/', $line, $matches)) {
                                     $aid = \Model\VsvnListMca::field('id', array('where' => array('name' => $matches[1], 'type' => 'action', 'parent' => $cid)));
                                     if (empty($aid)) {
                                         \Model\VsvnListMca::save(array('name' => $matches[1], 'type' => 'action', 'parent' => $cid));
                                     }
                                 }
                             }
                         }
                         fclose($content);
                     }
                 }
             }
         }
     } catch (\FileAccessException $e) {
     }
     return \Response::forge();
 }
开发者ID:khoapossible,项目名称:vision_system,代码行数:42,代码来源:script.php

示例7: autocomplete

 public static function autocomplete()
 {
     $path = COREPATH . 'classes/';
     static::convert_filelist(\File::read_dir($path), $path);
     $path = PKGPATH . 'auth/classes/';
     static::convert_filelist(\File::read_dir($path), $path);
     $path = PKGPATH . 'email/classes/';
     static::convert_filelist(\File::read_dir($path), $path);
     $path = PKGPATH . 'parser/classes/';
     $filelist = static::convert_filelist(\File::read_dir($path), $path);
     static::generate_class_definition($filelist);
     $output = '<?php' . "\n\n" . implode("", static::$class_definitions);
     $file = APPPATH . '_autocomplete.php';
     $ret = file_put_contents($file, $output);
     if ($ret === false) {
         echo 'Can\'t write to ' . $file . PHP_EOL;
     } else {
         echo $file . ' was created.' . PHP_EOL;
     }
 }
开发者ID:k-yama,项目名称:fuelphp-tools,代码行数:20,代码来源:generate.php

示例8: action_index

 /**
  * Index page
  * 
  * @access  public
  * @param   $slug
  */
 public function action_index($slug = false, $gallery_id = null)
 {
     // Get home page
     $home_page = \Config::get('details.locked_items.home_page');
     $gallery_page = \Config::get('details.locked_items.gallery');
     $item = false;
     if ($slug == 'referrals' && strtolower(\Sentry::user()->groups()[0]['name']) != 'club members') {
         \Messages::error('Only club members can access this page.');
         \Response::redirect('/');
     }
     //var_dump($slug);die();
     // Find content by slug
     if ($slug !== false) {
         $item = \Page\Model_Page::get_by_slug($slug);
     } elseif ($slug === false) {
         $item = \Page\Model_Page::find_one_by_id($home_page);
     }
     if ($item) {
         // Home page is always without slug so we redirect if someone tries to access home page with slug
         if ($item->id == $home_page && $slug !== false) {
             \Response::redirect(\Uri::base(false));
         }
     } else {
         // Send to 404 page
         throw new \HttpNotFoundException();
     }
     $result = \Page\Model_Page::get_content_file($item->id);
     if ($result) {
         foreach ($result as $rs) {
             $item->content_file_pdf = $rs->file;
             //pdf file
             $item->content_file_title = $rs->title;
             //pdf title
         }
     }
     // Default view file
     $view_file = 'default';
     // Fill in home page slug if none is supplied
     if ($slug === false && $item->id == $home_page) {
         $slug = $item->seo->slug;
         // Home page has its standard template
         $view_file = 'home';
     } else {
         // Search for page specific template
         $files = \File::read_dir($this->theme_view_path);
         if (!empty($files)) {
             foreach ($files as $file) {
                 $path_parts = pathinfo($file);
                 if (strpos($path_parts['filename'], '_') === 0) {
                     $file_id = substr($path_parts['filename'], strripos($path_parts['filename'], '_') + 1);
                     if (is_numeric($file_id) && $item->id == $file_id) {
                         $view_file = $path_parts['filename'];
                     }
                 }
             }
         }
     }
     $stock_options = \Config::load('stock-option.db');
     // TODO delete this
     srand($item->id);
     $this->page_theme = \Theme::instance()->set_partial('content', $this->view_dir . $view_file);
     $this->page_theme->set('item', $item, false);
     $this->page_theme->set('manage_stock', $stock_options['manage_stock'], false);
     $this->page_theme->set('hide_out_of_stock', $stock_options['hide_out_of_stock'], false);
     $this->page_theme->set('allow_buy_out_of_stock', $stock_options['allow_buy_out_of_stock'], false);
     if ($item->id == $gallery_page) {
         if ($gallery_id && \Input::is_ajax()) {
             // This will return gallery images only if it is ajax call
             $this->returnGalleryImages($gallery_id);
         }
     }
     // Data for home page
     if ($view_file == 'home') {
         $featured_products = \Product\Model_Group::find_one_by_id(4);
         if ($featured_products) {
             $featured_products = $featured_products->products;
         }
         $this->page_theme->set('featured_products', $featured_products, false);
         $categories = \Product\Model_Category::find(array('where' => array('parent_id' => 0, 'status' => 1), 'order_by' => array('sort' => 'asc'), 'limit' => 8));
         $this->page_theme->set('categories', $categories, false);
         $applications = \Application\Model_Application::find(array('where' => array('parent_id' => 0, 'status' => 1), 'order_by' => array('sort' => 'asc'), 'limit' => 8));
         $this->page_theme->set('applications', $applications, false);
         // $this->page_theme->set('blog', $this->wp_blog(), false);
     }
     \View::set_global('title', $item->seo->meta_title ?: $item->title);
     \View::set_global('meta_description', $item->seo->meta_description ?: '');
     \View::set_global('meta_keywords', $item->seo->meta_keywords ?: '');
     $robots = array('meta_robots_index' => $item->seo->meta_robots_index == 1 ? 'index' : 'noindex', 'meta_robots_follow' => $item->seo->meta_robots_follow == 1 ? 'follow' : 'nofollow');
     \View::set_global('robots', $robots);
     \View::set_global('canonical', $item->seo->canonical_links);
     \View::set_global('h1_tag', $item->seo->h1_tag);
     if ($item->seo->redirect_301) {
         \Response::redirect($item->seo->redirect_301);
     }
//.........这里部分代码省略.........
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:101,代码来源:page.php

示例9: delete_all

 /**
  * Purge all caches
  *
  * @param
  *        	limit purge to subsection
  * @return bool
  */
 public function delete_all($section)
 {
     // get the cache root path and prep the requested section
     $path = rtrim(static::$path, '\\/') . DS;
     $section = $section === null ? '' : static::identifier_to_path($section) . DS;
     // if the path does not exist, bail out immediately
     if (!is_dir($path . $section)) {
         return true;
     }
     // get all files in this section
     $files = \File::read_dir($path . $section, -1, array('\\.cache$' => 'file'));
     // closure to recusively delete the files
     $delete = function ($folder, $files) use(&$delete, $path) {
         $folder = rtrim($folder, '\\/') . DS;
         foreach ($files as $dir => $file) {
             if (is_numeric($dir)) {
                 if (!($result = \File::delete($folder . $file))) {
                     return $result;
                 }
             } else {
                 if (!($result = $delete($folder . $dir, $file))) {
                     return $result;
                 }
             }
         }
         // if we're processing a sub directory
         if ($folder != $path) {
             // remove the folder if no more files are left
             $files = \File::read_dir($folder);
             empty($files) and rmdir($folder);
         }
         return true;
     };
     return $delete($path . $section, $files);
 }
开发者ID:vienbk91,项目名称:fuelphp17,代码行数:42,代码来源:file.php

示例10: delete_all

 /**
  * Purge all caches
  *
  * @param   limit purge to subsection
  * @return  bool
  */
 public function delete_all($section)
 {
     $path = rtrim(static::$path, '\\/') . DS;
     $section = static::identifier_to_path($section);
     $files = \File::read_dir($path . $section, -1, array('\\.cache$' => 'file'));
     $delete = function ($path, $files) use(&$delete) {
         foreach ($files as $dir => $file) {
             if (is_numeric($dir)) {
                 if (!($result = \File::delete($path . $file))) {
                     return $result;
                 }
             } else {
                 if (!($result = ($delete($path . $dir, $file) and rmdir($path . $dir)))) {
                     return $result;
                 }
             }
         }
         return true;
     };
     return $delete($path . $section, $files);
 }
开发者ID:highestgoodlikewater,项目名称:webspider-1,代码行数:27,代码来源:file.php

示例11: get_files_in_dir

 /**
  * @access 	public
  * @param 	string directory path
  * @return 	array  list of full file paths
  */
 public function get_files_in_dir($dir_path, $recursive = false)
 {
     # Add traling slash
     $folder = $this->fix_trailing_slash($dir_path);
     $types = array();
     foreach ($this->accepted_file_types as $key => $value) {
         $type["\\." . $value . "\$"] = "file";
     }
     $scan = array();
     try {
         # Scan entire directory
         $scan = \File::read_dir($folder, $recursive == false ? 1 : 0, array_merge(array('!^\\.', '!^_'), $types));
     } catch (\Exception $e) {
         throw new SprocketsFileException($e->getMessage(), 1);
     }
     $file_list = \Arr::flatten($this->dir_scan_iterator($scan, $folder));
     # Remove duplicates
     return array_unique($file_list);
 }
开发者ID:hemanexus,项目名称:fuel-sprockets,代码行数:24,代码来源:file.php

示例12: read_dir

 public function read_dir($path, $depth = 0, $filter = null)
 {
     $content = \File::read_dir($path, $depth, $filter, $this);
     return $this->get_handler($path, array(), $content);
 }
开发者ID:gilyaev,项目名称:framework-bench,代码行数:5,代码来源:area.php

示例13: array

<div id="body">
    <h2>Uploadify demo using FuelPHP and SimpleAuth <span id="loader"><?php 
echo \Asset::img('loading.gif', array('alt' => 'Loading...'));
?>
</span></h2>
    <div id="sidebar">
        <!-- form to be replaced by uploadify -->
        <form id="mainftp" action="<?php 
echo $url;
?>
" method="post" enctype="multipart/form-data">
            <p><input type="file" name="userfile" id="file" /></p>
            <p><input type="submit" name="submit" value="Upload" /></p>
        </form>
    </div>

    <!-- whole div to be refreshed once uploadify is finished -->
    <div id="allfiles" >
        <ul>
        <?php 
$src_folder = "./uploads";
foreach (File::read_dir($src_folder) as $file) {
    echo "<li><a href='/uploads/{$file}'>{$file}</a></li>";
}
?>
        </ul>
    </div>

<div class="clear"></div>
开发者ID:huglester,项目名称:fuel-uploadify,代码行数:29,代码来源:index.php

示例14: delete_old_file

 public static function delete_old_file($dir, $expire = '24 hours ago', $prefix = '')
 {
     $expire = strtotime($expire);
     // 取得ファイル分ループ
     $files = File::read_dir($dir);
     foreach ($files as $fileName) {
         $file = $dir . $fileName;
         if (!is_file($file)) {
             continue;
         }
         // 指定プレフィックス以外はスルー
         if (!empty($prefix) && !strstr($fileName, $prefix)) {
             continue;
         }
         $mod = filemtime($file);
         if ($mod < $expire) {
             File::delete($file);
         }
     }
 }
开发者ID:marietta-adachi,项目名称:website,代码行数:20,代码来源:common.php

示例15: addDir

 /**
  * Add directory files
  *
  * @param string|array $folders   List directory
  * @param int          $depth     How deep the subdirectories are recurred: 0 for unlimited.
  * @param array|null   $filter    A filter for which files to read: array() for all or null for all but hidden.
  * @param string|null  $localname Where will be added to the file in the zip
  *
  * @throws \InvalidPathException when the file does not exist.
  * @throws \FileAccessException  when the file could not be opened for read.
  *
  * @return object Current instance
  */
 public function addDir($folders, $depth = 0, $filter = null, $localname = null)
 {
     $files = [];
     if (is_array($folders)) {
         foreach ($folders as $folder) {
             if (is_dir($folder)) {
                 $files[$folder] = \File::read_dir($folder, $depth, $filter);
             }
         }
     } else {
         if (is_dir($folders)) {
             $files[$folders] = \File::read_dir($folders, $depth, $filter);
         }
     }
     $this->getPath($files);
     foreach ($this->_list_files as $file) {
         $this->addFile($file, str_replace([APPPATH, COREPATH, DOCROOT, PKGPATH, VENDORPATH], '', pathinfo($file, PATHINFO_DIRNAME)));
     }
     return $this->_list_files;
 }
开发者ID:valdeirpsr,项目名称:fuel-zip,代码行数:33,代码来源:Instance.php


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