本文整理汇总了PHP中FileManager::scanDir方法的典型用法代码示例。如果您正苦于以下问题:PHP FileManager::scanDir方法的具体用法?PHP FileManager::scanDir怎么用?PHP FileManager::scanDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileManager
的用法示例。
在下文中一共展示了FileManager::scanDir方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadFiles
/**
* Load translations from a given path.
*
* @access private
* @param string $path
* @throws Exception\Fatal
* @version 1.2.0-dev
* @since 1.2.0-dev
*/
private function loadFiles($path)
{
$localePath = $path . DS . 'locale';
$langs = Router::getLangs();
if (file_exists($localePath)) {
$scannedDir = \FileManager::scanDir($localePath, 0);
foreach ($scannedDir as $dirId => &$file) {
list($lang, $type) = explode('.', $file);
// check language
if (!in_array($lang, $langs)) {
unset($scannedDir[$dirId]);
continue;
}
// import data from single file
switch ($type) {
case 'json':
$fileTranslations = static::importFileJson($localePath . DS . $file, $lang);
break;
default:
$fileTranslations = [];
}
// count translations per type
$appPart = NULL;
if (strpos($path, PATH_FW) !== FALSE) {
$appPart = 'fw';
} elseif (strpos($path, PATH_MODULES) !== FALSE) {
$appPart = 'module';
} elseif (strpos($path, PATH_APP) !== FALSE) {
$appPart = 'app';
}
// do counting per app part
$counting = 0;
foreach ($fileTranslations as $context => $translation) {
$counting += count($translation);
}
$temp =& $this->amountLoadedPerType[$appPart];
switch ($appPart) {
case 'module':
$module = str_replace(PATH_MODULES, '', $path);
$temp[$module][$lang] = $counting;
break;
case 'app':
case 'fw':
$temp[$lang] = $counting;
break;
}
// merge data
$this->loadedContent = array_replace_recursive($this->loadedContent, $fileTranslations);
}
}
}
示例2: setNewModules
/**
* this method will insert the new active modules in site database if
* does not exist
*/
private function setNewModules()
{
foreach (FileManager::scanDir($this->modulesDir) as $module) {
$ModuleConfig = $this->getModuleConfig($module);
if ($ModuleConfig['active']) {
$this->db->setSQL("SELECT * FROM modules WHERE `name` = '{$ModuleConfig['name']}'");
$moduleRecord = $this->db->fetchRecord(PDO::FETCH_ASSOC);
if (empty($moduleRecord)) {
$data['name'] = $ModuleConfig['name'];
$data['enable'] = '0';
$data['installed_version'] = $ModuleConfig['version'];
$this->db->setSQL($this->db->sqlBind($data, 'modules', 'I'));
$this->db->execOnly();
}
}
}
return;
}
示例3: setNewModules
/**
* this method will insert the new active modules in site database if
* does not exist
*/
private function setNewModules()
{
foreach (FileManager::scanDir($this->modulesDir) as $module) {
$m = $this->getModuleConfig($module);
if ($m['active']) {
$name = $m['name'];
$this->db->setSQL("SELECT count(*) AS total FROM modules WHERE `name` = '{$name}'");
$rec = $this->db->fetchRecord(PDO::FETCH_ASSOC);
if ($rec['total'] == 0) {
$data['name'] = $m['name'];
$data['enable'] = 0;
$data['installed_version'] = $m['version'];
$this->db->setSQL($this->db->sqlBind($data, 'modules', 'I'));
$this->db->execOnly();
}
}
}
return;
}
示例4: setNewModules
/**
* this method will insert the new active modules in site database if
* does not exist
*/
private function setNewModules()
{
Matcha::pauseLog(true);
foreach (FileManager::scanDir($this->modulesDir) as $module) {
$ModuleConfig = $this->getModuleConfig($module);
if ($ModuleConfig['active']) {
$moduleRecord = $this->m->load(['name' => $ModuleConfig['name']])->one();
if (empty($moduleRecord)) {
$data = new stdClass();
$data->title = $ModuleConfig['title'];
$data->name = $ModuleConfig['name'];
$data->description = $ModuleConfig['description'];
$data->enable = '0';
$data->installed_version = $ModuleConfig['version'];
$this->m->save($data);
}
}
}
Matcha::pauseLog(false);
return;
}