本文整理汇总了PHP中Folder::ls方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::ls方法的具体用法?PHP Folder::ls怎么用?PHP Folder::ls使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Folder
的用法示例。
在下文中一共展示了Folder::ls方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* Find all defined callbacks in the app or other plugins
*
* @param undefined $cached
* @return void
* @access public
*/
public function load()
{
$cached = Cache::read('_plugin_callbacks_', '_cake_models_');
if ($cached !== false) {
$this->settings = $cached;
return $cached;
}
App::import('Folder');
$Folder = new Folder($this->path . 'plugins');
$folders = current($Folder->ls());
$files = array();
foreach ($folders as $folder) {
if ($Folder->cd($this->path . 'models' . DS . 'callbacks')) {
$files = $Folder->findRecursive('([a-z_]+)_' . $folder . '.php');
}
$files = array_flip($files);
foreach ($folders as $_folder) {
if ($Folder->cd($this->path . 'plugins' . DS . $_folder . DS . 'models' . DS . 'callbacks')) {
$files = array_merge($files, array_flip($Folder->findRecursive('([a-z_]+)_' . $folder . '.php')));
}
}
foreach (array_keys($files) as $k => $file) {
if (!preg_match_all('/models\\/callbacks\\/([a-z_]+)_' . $folder . '\\.php/i', $file, $matches)) {
continue;
}
$plugin = current($matches[1]);
if (empty($plugin)) {
$plugin = 'app';
}
$callbackName = Inflector::camelize(sprintf('%s_%s', $plugin, $folder));
$this->settings[$folder][$plugin] = $callbackName;
}
}
Cache::write('_plugin_callbacks_', $this->settings, '_cake_models_');
}
示例2: getPlugins
function getPlugins()
{
$pluginFolder = new Folder(APP . 'plugins');
$plugins = $pluginFolder->ls();
$result = array();
if (count($plugins) > 0) {
foreach ($plugins[0] as $plugin) {
$result[] = $plugin;
}
}
return $result;
}
示例3: index
function index()
{
$lang_folder = new Folder(APP . DS . 'locale');
$langs = $lang_folder->ls(true, false);
$actual = array();
foreach ($langs[0] as $l) {
if ($l != 'eng' && $l != 'SAMPLE' && file_exists(APP . DS . 'locale' . DS . $l . DS . 'LC_MESSAGES' . DS . 'welcome.po')) {
$contents = file_get_contents(APP . DS . 'locale' . DS . $l . DS . 'LC_MESSAGES' . DS . 'welcome.po');
preg_match_all('/msgstr "(.*)"/', $contents, $matches);
$actual[] = array('locale' => $l, 'welcome' => $matches[1][0], 'action' => $matches[1][1]);
}
}
if (empty($actual)) {
$this->Session->write('Language', 'eng');
$this->redirect('/install/license');
exit;
}
$this->set('langs', $actual);
}
示例4: beforeRender
function beforeRender()
{
if (!isset($this->viewVars['data'])) {
$this->set('data', $this->data);
}
if (!$this->_isRequestAction()) {
if (!$this->menuItems) {
$this->menuItems['Home'] = array('url' => '/');
if ($this->plugin) {
$Human = Inflector::humanize($this->plugin);
$this->menuItems[$Human]['url'] = '/' . $this->PluginName;
$this->menuItems[$Human]['active'] = true;
$FileList = listClasses(APP . "plugins" . DS . $this->plugin . DS . "controllers");
foreach ($FileList as $file) {
$list = explode("_", $file);
unset($list[count($list) - 1]);
$controller = implode($list, "_");
if (up($controller) != up($this->plugin)) {
$array = array("url" => '/' . $this->PluginName . '/' . Inflector::camelize($controller));
if (Inflector::underscore($this->name) == $controller) {
$array['active'] = true;
}
$this->menuItems[Inflector::humanize($controller)] = $array;
}
}
} else {
$this->menuItems['Home']['active'] = true;
uses('Folder');
$Folder = new Folder(APP . DS . "plugins");
list($Plugins) = $Folder->ls();
foreach ($Plugins as $Plugin) {
$Camel = Inflector::Camelize($Plugin);
$Human = Inflector::humanize($Plugin);
$this->menuItems[$Human] = array('url' => '/' . $Camel);
}
}
}
$this->set('Menu', $this->menuItems);
$this->set('javascripts', $this->javascripts);
}
}
示例5: _zipDir
private static function _zipDir(Folder $dir, \ZipArchive $zip, $relative_path)
{
$items = $dir->ls();
if (count($items)) {
foreach ($items as $item) {
if ($item->isFile()) {
$name = $relative_path . $item->name();
$name = @iconv('UTF-8', 'CP850//TRANSLIT', $name);
\GO::debug("Add file: " . $name);
$zip->addFile($dir->path() . '/' . $item->name(), $name);
} else {
self::_zipDir($item, $zip, $relative_path . $item->name() . '/');
}
}
} else {
\GO::debug("Add empty dir: " . $relative_path);
if (!$zip->addEmptyDir(rtrim($relative_path, '/'))) {
throw new \Exception("Could not add emty directory " . $relative_path);
}
}
}
示例6: testNoTestCaseSupplied
/**
* testNoTestCaseSupplied method
*
* @access public
* @return void
*/
function testNoTestCaseSupplied()
{
if (php_sapi_name() != 'cli') {
unset($_GET['group']);
CodeCoverageManager::start(substr(md5(microtime()), 0, 5), new CakeHtmlReporter());
CodeCoverageManager::report(false);
$this->assertError();
CodeCoverageManager::start('libs/' . basename(__FILE__), new CakeHtmlReporter());
CodeCoverageManager::report(false);
$this->assertError();
$path = LIBS;
if (strpos(LIBS, ROOT) === false) {
$path = ROOT . DS . LIBS;
}
App::import('Core', 'Folder');
$folder = new Folder();
$folder->cd($path);
$contents = $folder->ls();
/**
* remove method
*
* @param mixed $var
* @access public
* @return void
*/
function remove($var)
{
return $var != basename(__FILE__);
}
$contents[1] = array_filter($contents[1], "remove");
foreach ($contents[1] as $file) {
CodeCoverageManager::start('libs' . DS . $file, new CakeHtmlReporter());
CodeCoverageManager::report(false);
$this->assertNoErrors('libs' . DS . $file);
}
}
}
示例7: settings
function settings($id = null)
{
$folder = new Folder(APP . 'locale');
$tmp = $folder->ls(true, array(".svn", ".", ".."));
$availableLanguages = array();
foreach ($tmp[0] as $value) {
$lang = substr($value, 0, 2);
$availableLanguages[$lang] = $lang;
}
if (empty($this->data)) {
if (!$id or !$this->User->read(null, $id)) {
$this->Session->setFlash(__('Invalid id.', true));
$this->redirect($this->referer());
exit;
}
$this->data = $this->User->read(null, $id);
} else {
$this->User->Profile->save($this->data);
$this->Session->write('User.Profile.lang', $this->data['Profile']['lang']);
$this->Session->setFlash(__('Settings saved.', true));
$this->redirect($this->referer());
exit;
}
$this->set('availableLanguages', $availableLanguages);
}
示例8: Folder
/**
* Loads a list of plugins in the current app.
*
* @return array
* @author John David Anderson
*/
function __listPlugins()
{
$pluginsFolder = new Folder(APP . 'plugins');
$filesAndDirectories = $pluginsFolder->ls(true, true);
return $filesAndDirectories[0];
}
示例9: profile
function profile($id = null)
{
$viewer = $this->Session->read('User');
if (is_null($id)) {
$id = $this->Session->read('User.id');
}
$this->data = $this->User->read(null, $id);
// Admins can't view/edit master account
if ($viewer['perms'] == 3 && $this->data['User']['perms'] == 4) {
$this->redirect('/users');
}
uses('Folder');
$themes_folder = new Folder(THEMES);
$themes = $themes_folder->ls(true, false);
$this->set('themes', $themes[0]);
$custom_themes_folder = new Folder(USER_THEMES);
$custom_themes_templates = $custom_themes_folder->ls(true, array('sample', '.', '..', '.svn'));
$this->set('custom_themes', $custom_themes_templates[0]);
$lang_folder = new Folder(APP . DS . 'locale');
$langs = $lang_folder->ls(true, false);
$this->set('langs', $langs[0]);
$this->pageTitle = __('User Profile', true);
$this->set('viewer', $viewer);
}
示例10: array
function _getSections($AclMode = 'full', $getChildren = true)
{
if ($AclMode == 'full') {
$acos = $this->Aco->findByAlias(low(APP_DIR));
} else {
$acos = $this->Aco->findByAlias(low('ROOT'));
}
if (empty($acos['Aco']['alias'])) {
$status = 'off';
$type = 'off';
} else {
$status = 'on';
$noChildren = ($acos['Aco']['rght'] - $acos['Aco']['lft']) / 2;
if ($noChildren > 1) {
$type = 'granular';
} else {
$type = 'global';
}
}
if ($getChildren && !empty($acos['Aco']['alias'])) {
$controllers = $this->_getControllers(APP_DIR, $status, $AclMode);
} else {
$controllers = array();
}
$sections[low(APP_DIR)] = array("status" => $status, "type" => $type, "children" => $controllers);
if ($AclMode == 'full') {
uses('Folder');
$Folder = new Folder(APP . DS . "plugins");
list($Plugins) = $Folder->ls();
foreach ($Plugins as $Plugin) {
$Plugin = low($Plugin);
$acos = $this->Aco->findByAlias($Plugin);
if (empty($acos['Aco']['alias'])) {
$status = 'off';
$type = 'off';
} else {
$status = 'on';
$noChildren = ($acos['Aco']['rght'] - $acos['Aco']['lft']) / 2;
if ($noChildren > 1) {
$type = 'granular';
} else {
$type = 'global';
}
}
if ($getChildren && !empty($acos['Aco']['alias'])) {
$controllers = $this->_getControllers($Plugin, $status, $AclMode);
} else {
$controllers = array();
}
$sections[low($Plugin)] = array("status" => $status, "type" => $type, "children" => $controllers);
}
}
return $sections;
}
示例11: eventFilePaths
/**
* Walk through all directories and search for listener classes
* Returns a array with classname as key and full path as value
*
* @param string $dir Currently: 'controllers' and 'models'
* @return array
*/
public function eventFilePaths($dir = 'controllers')
{
App::import('Core', 'Folder');
$eventFilePaths = array();
// Lookup APP events
$events = new Folder(EVENTS . $dir);
list($folders, $files) = $events->ls();
foreach ($files as $listenerClassFile) {
$eventFilePaths[self::file2class($listenerClassFile)] = $events->path . DS . $listenerClassFile;
}
// Lookup PLUGIN events
$plugins = new Folder(PLUGINS);
list($folders, $files) = $plugins->ls();
if (count($folders) > 1) {
foreach ($folders as $pluginsFolder) {
if ($pluginsFolder == 'eventful') {
continue;
}
$pluginEvents = new Folder(PLUGINS . $pluginsFolder . DS . EVENTS_DIR . DS . $dir);
list($folders, $files) = $pluginEvents->ls();
foreach ($files as $listenerClassFile) {
$eventFilePaths[self::file2class($listenerClassFile)] = $pluginEvents->path . DS . $listenerClassFile;
}
}
}
return $eventFilePaths;
}
示例12: beforeDelete
/**
* Callback
*
* Deletes file corresponding to record as well as generated versions of that file.
*
* If the file couldn't be deleted the callback won't stop the
* delete operation to continue to delete the record.
*
* @param Model $Model
* @param boolean $cascade
* @return boolean
*/
function beforeDelete(&$Model, $cascade = true)
{
extract($this->settings[$Model->alias]);
$query = array('conditions' => array('id' => $Model->id), 'fields' => array('dirname', 'basename'), 'recursive' => -1);
$result = $Model->find('first', $query);
if (empty($result)) {
return false;
/* Record did not pass verification? */
}
$file = $baseDirectory;
$file .= $result[$Model->alias]['dirname'];
$file .= DS . $result[$Model->alias]['basename'];
$File = new File($file);
$Folder = new Folder($filterDirectory);
list($versions, ) = $Folder->ls();
foreach ($versions as $version) {
$Folder->cd($filterDirectory . $version . DS . $result[$Model->alias]['dirname'] . DS);
$basenames = $Folder->find($File->name() . '\\..*');
if (count($basenames) > 1) {
$message = "MediaBehavior::beforeDelete - Ambiguous filename ";
$message .= "`" . $File->name() . "` in `" . $Folder->pwd() . "`.";
trigger_error($message, E_USER_NOTICE);
continue;
} elseif (!isset($basenames[0])) {
continue;
}
$FilterFile = new File($Folder->pwd() . $basenames[0]);
$FilterFile->delete();
}
$File->delete();
return true;
}
示例13: translations
/**
* Reads from the app/locale/default.pot and creates a record for every lanuage
* (obtained from folders in app/locale) and msgid. Ideally to be used once development
* is finished and the translations should be quickly changeable via db.
*
* All strings picked up will go in the default domain.
*
* We don't really need to write to the file, as if they want to make any changes the db save
* will write the file.
*
*/
function translations()
{
// Always use default domain.
$domain = 'default';
// Get list of languages.
$folder = new Folder(APP . 'locale');
$ls = $folder->ls(true);
$languages = $ls[0];
// Read default.pot
$file = new File(APP . 'locale' . DS . 'default.pot');
$lines = explode("\n", $file->read());
$totalLines = count($lines);
for ($i = 0; $i < $totalLines; $i++) {
$line = $lines[$i];
if (strpos($line, 'msgid') === false) {
continue;
}
// Get term
$str = preg_match('@msgid "([^"]+)"@', $line, $matches);
if (empty($matches[1])) {
continue;
}
$name = $matches[1];
// Save
foreach ($languages as $language) {
$this->Translation->create();
$conditions = compact('name', 'language', 'domain');
if ($translation = $this->Translation->find('first', compact('conditions'))) {
$this->Translation->id = $translation['Translation']['id'];
}
$this->Translation->save(compact('name', 'language', 'domain'));
}
}
}
示例14: settings
function settings()
{
@($account = $this->data = $this->account);
$this->set('account', $account);
uses('Folder');
$themes_folder = new Folder(THEMES);
$themes = $themes_folder->ls(true, false);
$this->set('themes', $themes[0]);
$custom_themes_folder = new Folder(USER_THEMES);
$custom_themes_templates = $custom_themes_folder->ls(true, array('sample', '.', '..', '.svn'));
$this->set('custom_themes', $custom_themes_templates[0]);
$lang_folder = new Folder(APP . DS . 'locale');
$langs = $lang_folder->ls(true, false);
$this->set('langs', $langs[0]);
$templates_folder = new Folder(PLUGS . DS . 'links');
$link_templates = $templates_folder->ls(true, false);
$this->set('link_templates', $link_templates[1]);
$custom_templates_folder = new Folder(CUSTOM_PLUGS . DS . 'links');
$custom_link_templates = $custom_templates_folder->ls(true, array('sample', '.', '..', '.svn'));
$this->set('custom_link_templates', $custom_link_templates[0]);
$iptcs = $this->Director->iptcTags;
natsort($iptcs);
$exifs = $this->Director->exifTags;
natsort($exifs);
$dirs = $this->Director->dirTags;
natsort($dirs);
$this->loadModel('Watermark');
$this->set('watermarks', $this->Watermark->find('all'));
$this->set('iptcs', $iptcs);
$this->set('exifs', $exifs);
$this->set('dirs', $dirs);
}
示例15: edit
function edit($id, $tab = 'settings', $part_id = 0)
{
$this->cacheAction = 30000;
$this->pageTitle = __('Albums', true);
$this->Album->id = $id;
$this->data = $this->Album->find('first', array('conditions' => array('Album.id' => $id)));
if (empty($this->data)) {
$this->redirect('/albums');
}
switch ($tab) {
case 'summary':
$this->redirect('/albums/edit/' . $id);
break;
case 'settings':
$this->loadModel('Watermark');
$this->set('watermarks', $this->Watermark->find('all', array('order' => 'main DESC')));
$this->set('galleries', $this->Album->Tag->Gallery->find('all', array('fields' => 'Gallery.id, Gallery.name, Gallery.description', 'order' => 'Gallery.name', 'conditions' => 'Gallery.smart = 0', 'recursive' => -1)));
$templates_folder = new Folder(PLUGS . DS . 'links');
$link_templates = $templates_folder->ls(true, false);
$this->set('link_templates', $link_templates[1]);
$custom_templates_folder = new Folder(CUSTOM_PLUGS . DS . 'links');
$custom_link_templates = $custom_templates_folder->ls(true, array('sample', '.', '..', '.svn'));
$this->set('custom_link_templates', $custom_link_templates[0]);
$iptcs = $this->Director->iptcTags;
natsort($iptcs);
$exifs = $this->Director->exifTags;
natsort($exifs);
$dirs = $this->Director->dirTags;
if ($this->data['Album']['smart']) {
$dirs = array_merge($dirs, $this->Director->smartTags);
}
natsort($dirs);
$this->set('iptcs', $iptcs);
$this->set('exifs', $exifs);
$this->set('dirs', $dirs);
if ($this->data['Album']['smart']) {
list($images, ) = $this->_smart_content(unserialize($this->data['Album']['smart_query']));
$this->set('images', $images);
} else {
$this->set('images', $this->data['Image']);
}
break;
case 'content':
$this->set('load_maps_js', true);
$this->set('mp3s', $this->Director->directory(AUDIO, 'mp3,MP3'));
if ($this->data['Album']['smart']) {
list($images, ) = $this->_smart_content(unserialize($this->data['Album']['smart_query']));
$this->set('images', $images);
$this->set('options', unserialize($this->data['Album']['smart_query']));
$this->set('active_dummies', $this->Album->find('all', array('conditions' => array('smart' => 0, 'active' => '1'), 'order' => 'name', 'recursive' => -1, 'fields' => 'Album.id, Album.name')));
} else {
$this->set('images', $this->data['Image']);
$this->set('other_albums', $this->Album->find('all', array('conditions' => array('not' => array('Album.id' => $id, 'Album.smart' => 1)), 'recursive' => -1, 'fields' => 'Album.id, Album.name', 'order' => 'name')));
$preview_ids = array();
foreach ($this->data['Image'] as $i) {
if ($i['is_video']) {
if (!empty($i['lg_preview_id'])) {
$preview_ids[] = $i['lg_preview_id'];
}
if (!empty($i['tn_preview_id'])) {
$preview_ids[] = $i['tn_preview_id'];
}
}
}
$this->set('preview_ids', $preview_ids);
}
$this->set('selected_id', $part_id);
if (function_exists('imagerotate') || $this->Kodak->gdVersion() >= 3) {
$rotate = true;
} else {
$rotate = false;
}
$this->set('rotate', $rotate);
break;
case 'upload':
if ($this->data['Album']['smart']) {
$this->redirect('/albums/edit/' . $this->data['Album']['id'] . '/content');
}
$this->set('writable', $this->Director->setAlbumPerms($this->data['Album']['id']));
$this->set('other_writable', $this->Director->setOtherPerms());
if (!TRIAL_STATE) {
// Check if any new files have been uploaded via FTP
$files = $this->Director->directory(ALBUMS . DS . 'album-' . $this->data['Album']['id'] . DS . 'lg', 'accepted');
$count = count($this->data['Image']);
if (count($files) > $count) {
set_time_limit(0);
$noobs = array();
$n = 1;
foreach ($files as $file) {
if (strpos($file, '___tn___') === false && strpos($file, '__vidtn__') === false) {
$this->Album->Image->recursive = -1;
$this->Album->Image->coldSave = true;
$img = $this->Album->Image->find(aa('src', $file, 'aid', $id));
if (empty($img)) {
$clean = str_replace(" ", "_", $file);
$clean = ereg_replace("[^A-Za-z0-9._-]", "_", $clean);
$path = ALBUMS . DS . 'album-' . $this->data['Album']['id'] . DS . 'lg' . DS . $file;
$clean_path = ALBUMS . DS . 'album-' . $this->data['Album']['id'] . DS . 'lg' . DS . $clean;
if (rename($path, $clean_path)) {
$path = $clean_path;
//.........这里部分代码省略.........