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


PHP Filesystem::files方法代码示例

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


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

示例1: setUp

 /**
  * Set up test environment.
  */
 public function setUp()
 {
     parent::setUp();
     $this->filesystem = new FileSystem(new LocalAdapter($this->build_path));
     $this->filesystem->emptyDir('/', ['BlogStructure.php']);
     $this->assertEquals(['BlogStructure.php'], $this->filesystem->files('/'));
     $this->assertEquals([], $this->filesystem->subdirs('/'));
     $this->blog_structure = new BlogStructure();
     $this->blog_structure->build($this->build_path, $this->connection);
 }
开发者ID:activecollab,项目名称:databasestructure,代码行数:13,代码来源:BlogBuilderTest.php

示例2: manageConfigs

 public function manageConfigs()
 {
     $fileSystem = new Filesystem();
     $files = $fileSystem->files(__DIR__ . '/config');
     if (!empty($files)) {
         foreach ($files as $file) {
             $name = explode('/', $file);
             $this->mergeConfigFrom($file, str_replace('.php', '', $name[count($name) - 1]));
         }
     }
 }
开发者ID:shannonp63,项目名称:boojbit,代码行数:11,代码来源:BoojBitServiceProvider.php

示例3: refresh

 /**
  * Method for refreshing the cache in the database with the known language strings
  *
  * @return	boolean	True on success, Exception object otherwise
  *
  * @since		2.5
  */
 public function refresh()
 {
     require_once JPATH_COMPONENT . '/helpers/languages.php';
     $app = JFactory::getApplication();
     $app->setUserState('com_languages.overrides.cachedtime', null);
     // Empty the database cache first
     try {
         $this->_db->setQuery('TRUNCATE TABLE ' . $this->_db->qn('#__overrider'));
         $this->_db->query();
     } catch (RuntimeException $e) {
         return $e;
     }
     // Create the insert query
     $query = $this->_db->getQuery(true)->insert($this->_db->qn('#__overrider'))->columns('constant, string, file');
     // Initialize some variables
     $client = $app->getUserState('com_languages.overrides.filter.client', 'site') ? 'administrator' : 'site';
     $language = $app->getUserState('com_languages.overrides.filter.language', 'en-GB');
     $base = constant('JPATH_' . strtoupper($client));
     $path = $base . '/language/' . $language;
     $files = array();
     // Parse common language directory
     if (Filesystem::exists($path)) {
         $files = Filesystem::files($path, $language . '.*ini$', false, true);
     }
     // Parse language directories of components
     $files = array_merge($files, Filesystem::files($base . '/components', $language . '.*ini$', 3, true));
     // Parse language directories of modules
     $files = array_merge($files, Filesystem::files($base . '/modules', $language . '.*ini$', 3, true));
     // Parse language directories of templates
     $files = array_merge($files, Filesystem::files($base . '/templates', $language . '.*ini$', 3, true));
     // Parse language directories of plugins
     $files = array_merge($files, Filesystem::files(JPATH_PLUGINS, $language . '.*ini$', 3, true));
     // Parse all found ini files and add the strings to the database cache
     foreach ($files as $file) {
         $strings = LanguagesHelper::parseFile($file);
         if ($strings && count($strings)) {
             $query->clear('values');
             foreach ($strings as $key => $string) {
                 $query->values($this->_db->q($key) . ',' . $this->_db->q($string) . ',' . $this->_db->q(JPath::clean($file)));
             }
             try {
                 $this->_db->setQuery($query);
                 if (!$this->_db->query()) {
                     return new Exception($this->_db->getErrorMsg());
                 }
             } catch (RuntimeException $e) {
                 return $e;
             }
         }
     }
     // Update the cached time
     $app->setUserState('com_languages.overrides.cachedtime.' . $client . '.' . $language, time());
     return true;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:61,代码来源:strings.php

示例4: scopes

 /**
  * Outputs a <select> element with a specific value chosen
  *
  * @param   mixed   $val   Chosen value
  * @param   string  $name  Field name
  * @param   string  $id    ID
  * @param   string  $atts  Attributes
  * @return  string  HTML <select>
  */
 public static function scopes($val, $name, $id = null, $atts = null)
 {
     $adapters = \Filesystem::files(dirname(dirname(__DIR__)) . '/models/adapters', '\\.php$');
     $out = '<select name="' . $name . '" id="' . ($id ? $id : str_replace(array('[', ']'), '', $name)) . '"' . ($atts ? ' ' . $atts : '') . '>';
     $out .= '<option value="">' . \Lang::txt('COM_BLOG_SELECT_SCOPE') . '</option>';
     foreach ($adapters as $adapter) {
         $adapter = ltrim($adapter, DS);
         $adapter = preg_replace('#\\.[^.]*$#', '', $adapter);
         if ($adapter == 'base') {
             continue;
         }
         $selected = $adapter == $val ? ' selected="selected"' : '';
         $out .= '<option value="' . $adapter . '"' . $selected . '>' . $adapter . '</option>';
     }
     $out .= '</select>';
     return $out;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:26,代码来源:html.php

示例5: foreach

" method="post" id="filelist">
		<?php 
if (count($this->folders) == 0 && count($this->docs) == 0) {
    ?>
			<p><?php 
    echo Lang::txt('COM_GROUPS_NO_FILES_FOUND');
    ?>
</p>
		<?php 
} else {
    ?>
			<table>
				<tbody>
				<?php 
    foreach ($this->folders as $k => $folder) {
        $num_files = count(Filesystem::files($k));
        $k = substr($k, strlen($this->path));
        ?>
					<tr>
						<td width="100%">
							<a class="icon-folder folder" href="<?php 
        echo Route::url('index.php?option=' . $this->option . '&controller=' . $this->controller . '&dir=' . urlencode($k) . '&gidNumber=' . $this->group->get('gidNumber') . '&tmpl=component&' . Session::getFormToken() . '=1');
        ?>
" target="media">
								<?php 
        echo trim($k, DS);
        ?>
							</a>
						</td>
						<td>
							<a class="icon-delete delete" href="<?php 
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:31,代码来源:list.php

示例6: rtrim

		<?php 
if (count($this->folders) == 0 && count($this->docs) == 0) {
    ?>
			<p><?php 
    echo Lang::txt('COM_BLOG_NO_FILES_FOUND');
    ?>
</p>
		<?php 
} else {
    ?>
			<table>
				<tbody>
				<?php 
    $base = rtrim(Request::base(true), '/');
    foreach ($this->folders as $k => $folder) {
        $num_files = count(Filesystem::files(PATH_APP . DS . $folder));
        ?>
					<tr>
						<td width="100%">
							<span class="icon-folder folder">
								<?php 
        echo $k;
        ?>
							</span>
						</td>
						<td>
							<a class="icon-delete delete" href="<?php 
        echo Route::url('index.php?option=' . $this->option . '&controller=' . $this->controller . '&task=deletefolder&folder=' . basename($folder) . '&scope=' . urlencode($this->archive->get('scope')) . '&id=' . $this->archive->get('scope_id') . '&tmpl=component&' . Session::getFormToken() . '=1');
        ?>
" target="filer" onclick="return deleteFolder('<?php 
        echo basename($folder);
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:31,代码来源:list.php

示例7: drawPackageList

 /**
  * Draw list
  *
  * @return  boolean
  */
 public function drawPackageList($attachments, $element, $elementId, $pub, $blockParams, $authorized)
 {
     // Get configs
     $configs = $this->getConfigs($element->params, $elementId, $pub, $blockParams);
     $list = NULL;
     if (!$attachments) {
         return false;
     }
     $list .= '<li>' . \Components\Projects\Models\File::drawIcon('csv') . ' data.csv</li>';
     // Add data files
     $dataFiles = array();
     if (is_dir($configs->dataPath)) {
         $dataFiles = Filesystem::files($configs->dataPath, '.', true, true);
     }
     if (!empty($dataFiles)) {
         $list .= '<li>' . \Components\Projects\Models\File::drawIcon('folder') . ' data</li>';
         foreach ($dataFiles as $e) {
             // Skip thumbnails and CSV
             if (preg_match("/_tn.gif/", $e) || preg_match("/_medium.gif/", $e) || preg_match("/data.csv/", $e)) {
                 continue;
             }
             $file = new \Components\Projects\Models\File($e);
             $fileinfo = pathinfo($e);
             $a_dir = $fileinfo['dirname'];
             $a_dir = trim(str_replace($configs->dataPath, '', $a_dir), DS);
             $fPath = $a_dir && $a_dir != '.' ? $a_dir . DS : '';
             $where = 'data' . DS . $fPath . basename($e);
             $list .= '<li class="level2"><span class="item-title">' . $file::drawIcon($file->get('ext')) . ' ' . trim($where, DS) . '</span></li>';
         }
     }
     return $list;
 }
开发者ID:sumudinie,项目名称:hubzero-cms,代码行数:37,代码来源:data.php

示例8: downloadresponses

 /**
  * Generate detailed responses CSV files and zip and offer up as download
  *
  * @return void
  **/
 private function downloadresponses()
 {
     require_once PATH_CORE . DS . 'components' . DS . 'com_courses' . DS . 'models' . DS . 'formReport.php';
     // Only allow for instructors
     if (!$this->course->offering()->section()->access('manage')) {
         App::abort(403, 'Sorry, you don\'t have permission to do this');
     }
     if (!($asset_ids = Request::getVar('assets', false))) {
         App::abort(422, 'Sorry, we don\'t know what results you\'re trying to retrieve');
     }
     $protected = 'site' . DS . 'protected';
     $tmp = $protected . DS . 'tmp';
     // We're going to temporarily house this in PATH_APP/site/protected/tmp
     if (!Filesystem::exists($protected)) {
         App::abort(500, 'Missing temporary directory');
     }
     // Make sure tmp folder exists
     if (!Filesystem::exists($tmp)) {
         Filesystem::makeDirectory($tmp);
     } else {
         // Folder was already there - do a sanity check and make sure no old responses zips are lying around
         $files = Filesystem::files($tmp);
         if ($files && count($files) > 0) {
             foreach ($files as $file) {
                 if (strstr($file, 'responses.zip') !== false) {
                     Filesystem::delete($tmp . DS . $file);
                 }
             }
         }
     }
     // Get the individual asset ids
     $asset_ids = explode('-', $asset_ids);
     // Set up our zip archive
     $zip = new ZipArchive();
     $path = PATH_APP . DS . $tmp . DS . time() . '.responses.zip';
     $zip->open($path, ZipArchive::CREATE);
     // Loop through the assets
     foreach ($asset_ids as $asset_id) {
         // Is it a number?
         if (!is_numeric($asset_id)) {
             continue;
         }
         // Get the rest of the asset row
         $asset = new \Components\Courses\Tables\Asset($this->db);
         $asset->load($asset_id);
         // Make sure asset is a part of this course
         if ($asset->get('course_id') != $this->course->get('id')) {
             continue;
         }
         if ($details = \Components\Courses\Models\FormReport::getLetterResponsesForAssetId($this->db, $asset_id, true, $this->course->offering()->section()->get('id'))) {
             $output = implode(',', $details['headers']) . "\n";
             if (isset($details['responses']) && count($details['responses']) > 0) {
                 foreach ($details['responses'] as $response) {
                     $output .= implode(',', $response) . "\n";
                 }
             }
             $zip->addFromString($asset_id . '.responses.csv', $output);
         } else {
             continue;
         }
     }
     // Close the zip archive handler
     $zip->close();
     if (is_file($path)) {
         // Set up the server
         $xserver = new \Hubzero\Content\Server();
         $xserver->filename($path);
         $xserver->saveas('responses.zip');
         $xserver->disposition('attachment');
         $xserver->acceptranges(false);
         // Serve the file
         $xserver->serve();
         // Now delete the file
         Filesystem::delete($path);
     }
     // All done!
     exit;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:83,代码来源:progress.php

示例9: pages

 /**
  * Get array of help pages for component
  *
  * @param   string  $component  Component to get pages for
  * @return  array
  */
 public static function pages($component)
 {
     $database = \App::get('db');
     // Get component name from database
     $database->setQuery("SELECT `name`\n\t\t\tFROM `#__extensions`\n\t\t\tWHERE `type`=" . $database->quote('component') . "\n\t\t\tAND `element`=" . $database->quote($component) . "\n\t\t\tAND `enabled`=1");
     $name = $database->loadResult();
     // Make sure we have a component
     if ($name == '') {
         $name = str_replace('com_', '', $component);
         return array('name' => ucfirst($name), 'option' => $component, 'pages' => array());
     }
     // Path to help pages
     $helpPagesPath = self::path($component) . DS . 'help' . DS . \Lang::getTag();
     // Make sure directory exists
     $pages = array();
     if (is_dir($helpPagesPath)) {
         // Get help pages for this component
         $pages = \Filesystem::files($helpPagesPath, '.' . self::$ext);
     }
     $pages = array_map(function ($file) {
         return ltrim($file, DS);
     }, $pages);
     // Return pages
     return array('name' => $name, 'option' => $component, 'pages' => $pages);
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:31,代码来源:finder.php

示例10: editTask

 /**
  * Edit an Import
  *
  * @return  void
  */
 public function editTask()
 {
     Request::setVar('hidemainmenu', 1);
     // get request vars
     $ids = Request::getVar('id', array());
     $id = isset($ids[0]) ? $ids[0] : null;
     // get the import object
     $this->view->import = new Models\Import($id);
     // import params
     $this->view->params = new \Hubzero\Config\Registry($this->view->import->get('params'));
     // get all files in import filespace
     $this->view->files = \Filesystem::files($this->view->import->fileSpacePath(), '.');
     // get all imports from archive
     $hooksArchive = Models\Import\Hook\Archive::getInstance();
     $this->view->hooks = $hooksArchive->hooks('list', array('state' => array(1)));
     // Get groups
     $this->view->groups = Group::find(array('authorized' => 'admin', 'fields' => array('cn', 'description', 'published', 'gidNumber', 'type'), 'type' => array(1, 3), 'sortby' => 'description'));
     // Set any errors
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     // Output the HTML
     $this->view->setLayout('edit')->display();
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:29,代码来源:import.php

示例11: array

 /**
  * Method to get the toc
  * @return array Table of contents
  */
 function &getToc()
 {
     if (is_null($this->toc)) {
         // Get vars
         $lang_tag = $this->getLangTag();
         $help_search = $this->getHelpSearch();
         // Get Help files
         $files = Filesystem::files(JPATH_BASE . '/help/' . $lang_tag, '\\.xml$|\\.html$');
         $this->toc = array();
         foreach ($files as $file) {
             $buffer = file_get_contents(JPATH_BASE . '/help/' . $lang_tag . '/' . $file);
             if (preg_match('#<title>(.*?)</title>#', $buffer, $m)) {
                 $title = trim($m[1]);
                 if ($title) {
                     // Translate the page title
                     $title = Lang::txt($title);
                     // strip the extension
                     $file = preg_replace('#\\.xml$|\\.html$#', '', $file);
                     if ($help_search) {
                         if (JString::strpos(JString::strtolower(strip_tags($buffer)), JString::strtolower($help_search)) !== false) {
                             // Add an item in the Table of Contents
                             $this->toc[$file] = $title;
                         }
                     } else {
                         // Add an item in the Table of Contents
                         $this->toc[$file] = $title;
                     }
                 }
             }
         }
         // Sort the Table of Contents
         asort($this->toc);
     }
     return $this->toc;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:39,代码来源:help.php

示例12: helpPagesForComponent

 /**
  * Get array of help pages for component
  *
  * @param   string  $component  Component to get pages for
  * @return  array
  */
 private function helpPagesForComponent($component)
 {
     // Get component name from database
     $sql = "SELECT `name` FROM `#__extensions` WHERE `type`=" . $this->database->quote('component') . " AND `element`=" . $this->database->quote($component) . " AND `enabled`=1";
     $this->database->setQuery($sql);
     $name = $this->database->loadResult();
     // Make sure we have a component
     if ($name == '') {
         return array();
     }
     // Path to help pages
     $path = \Component::path($component) . DS . 'admin' . DS . 'help' . DS . Lang::getTag();
     // Make sure directory exists
     $pages = array();
     // Get help pages for this component
     $pages = \Filesystem::files($path, '.phtml');
     $pages = array_map(function ($file) {
         return ltrim($file, DS);
     }, $pages);
     // Return pages
     return array('name' => $name, 'option' => $component, 'pages' => $pages);
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:28,代码来源:help.php

示例13: delete

 /**
  * Deletes paths from the current path
  *
  * @since 1.5
  */
 public function delete()
 {
     Session::checkToken(['get', 'post']);
     // Get some data from the request
     $tmpl = Request::getCmd('tmpl');
     $paths = Request::getVar('rm', array(), '', 'array');
     $folder = Request::getVar('folder', '', '', 'path');
     $redirect = 'index.php?option=com_media&folder=' . $folder;
     if ($tmpl == 'component') {
         // We are inside the iframe
         $redirect .= '&view=mediaList&tmpl=component';
     }
     $this->setRedirect($redirect);
     // Nothing to delete
     if (empty($paths)) {
         return true;
     }
     // Authorize the user
     if (!$this->authoriseUser('delete')) {
         return false;
     }
     // Set FTP credentials, if given
     JClientHelper::setCredentialsFromRequest('ftp');
     // Initialise variables.
     $ret = true;
     foreach ($paths as $path) {
         if ($path !== Filesystem::clean($path)) {
             // filename is not safe
             $filename = htmlspecialchars($path, ENT_COMPAT, 'UTF-8');
             Notify::warning(Lang::txt('COM_MEDIA_ERROR_UNABLE_TO_DELETE_FILE_WARNFILENAME', substr($filename, strlen(COM_MEDIA_BASE))));
             continue;
         }
         $fullPath = Filesystem::cleanPath(implode(DIRECTORY_SEPARATOR, array(COM_MEDIA_BASE, $folder, $path)));
         $object_file = new \Hubzero\Base\Object(array('filepath' => $fullPath));
         if (is_file($fullPath)) {
             // Trigger the onContentBeforeDelete event.
             $result = Event::trigger('content.onContentBeforeDelete', array('com_media.file', &$object_file));
             if (in_array(false, $result, true)) {
                 // There are some errors in the plugins
                 Notify::warning(Lang::txts('COM_MEDIA_ERROR_BEFORE_DELETE', count($errors = $object_file->getErrors()), implode('<br />', $errors)));
                 continue;
             }
             $ret &= Filesystem::delete($fullPath);
             // Trigger the onContentAfterDelete event.
             Event::trigger('content.onContentAfterDelete', array('com_media.file', &$object_file));
             $this->setMessage(Lang::txt('COM_MEDIA_DELETE_COMPLETE', substr($fullPath, strlen(COM_MEDIA_BASE))));
         } elseif (is_dir($fullPath)) {
             $contents = Filesystem::files($fullPath, '.', true, false, array('.svn', 'CVS', '.DS_Store', '__MACOSX', 'index.html'));
             if (empty($contents)) {
                 // Trigger the onContentBeforeDelete event.
                 $result = Event::trigger('content.onContentBeforeDelete', array('com_media.folder', &$object_file));
                 if (in_array(false, $result, true)) {
                     // There are some errors in the plugins
                     Notify::warning(Lang::txts('COM_MEDIA_ERROR_BEFORE_DELETE', count($errors = $object_file->getErrors()), implode('<br />', $errors)));
                     continue;
                 }
                 $ret &= Filesystem::deleteDirectory($fullPath);
                 // Trigger the onContentAfterDelete event.
                 Event::trigger('content.onContentAfterDelete', array('com_media.folder', &$object_file));
                 $this->setMessage(Lang::txt('COM_MEDIA_DELETE_COMPLETE', substr($fullPath, strlen(COM_MEDIA_BASE))));
             } else {
                 // This makes no sense...
                 Notify::warning(Lang::txt('COM_MEDIA_ERROR_UNABLE_TO_DELETE_FOLDER_NOT_EMPTY', substr($fullPath, strlen(COM_MEDIA_BASE))));
             }
         }
     }
     return $ret;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:73,代码来源:file.php

示例14: foreach

</span>
										<?php 
            }
            ?>
									</span>
									<?php 
        }
    }
}
?>
					</caption>
					<tbody>
					<?php 
foreach ($this->folders as $fullpath => $name) {
    $dir = DS . $name;
    $numFiles = count(\Filesystem::files($fullpath, '.', false, true, array()));
    if ($this->listdir == DS) {
        $this->listdir = '';
    }
    $d = $this->listdir ? $this->listdir . DS . $name : DS . $name;
    ?>
						<tr>
							<td width="100%">
								<a class="icon-folder" href="<?php 
    echo Route::url('index.php?option=' . $this->option . '&controller=' . $this->controller . '&task=filelist&tmpl=component&listdir=' . urlencode($d));
    ?>
">
									<?php 
    echo $dir;
    ?>
								</a>
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:31,代码来源:filelist.php

示例15: _prepDir

 /**
  * Prep file directory (provisioned project)
  *
  * @param      boolean		$force
  *
  * @return     boolean
  */
 protected function _prepDir($force = true)
 {
     if (!$this->model->exists()) {
         $this->setError(Lang::txt('UNABLE_TO_CREATE_UPLOAD_PATH'));
         return;
     }
     // Get member files path
     $memberPath = $this->_getMemberPath();
     // Create and initialize local repo
     if (!$this->model->repo()->iniLocal()) {
         $this->setError(Lang::txt('UNABLE_TO_CREATE_UPLOAD_PATH'));
         return;
     }
     // Copy files from member directory
     if (!Filesystem::copyDirectory($memberPath, $this->model->repo()->get('path'))) {
         $this->setError(Lang::txt('COM_PROJECTS_FAILED_TO_COPY_FILES'));
         return false;
     }
     // Read copied files
     $get = Filesystem::files($this->model->repo()->get('path'));
     $num = count($get);
     $checkedin = 0;
     // Check-in copied files
     if ($get) {
         foreach ($get as $file) {
             $file = str_replace($this->model->repo()->get('path') . DS, '', $file);
             if (is_file($this->model->repo()->get('path') . DS . $file)) {
                 // Checkin into repo
                 $this->model->repo()->call('checkin', array('file' => $this->model->repo()->getMetadata($file, 'file', array())));
                 $checkedin++;
             }
         }
     }
     if ($num == $checkedin) {
         // Clean up member files
         Filesystem::deleteDirectory($memberPath);
         return true;
     }
     return false;
 }
开发者ID:sumudinie,项目名称:hubzero-cms,代码行数:47,代码来源:publications.php


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