本文整理汇总了PHP中_glob函数的典型用法代码示例。如果您正苦于以下问题:PHP _glob函数的具体用法?PHP _glob怎么用?PHP _glob使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_glob函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAvailableLanguages
/**
* Return array of available languages
*
* @return array Arry of strings, each containing its ISO language code
*/
public function getAvailableLanguages()
{
if (!is_null($this->languageNames)) {
return $this->languageNames;
}
$path = PIWIK_INCLUDE_PATH . "/lang/";
$languagesPath = _glob($path . "*.json");
$pathLength = strlen($path);
$languages = array();
if ($languagesPath) {
foreach ($languagesPath as $language) {
$languages[] = substr($language, $pathLength, -strlen('.json'));
}
}
/**
* Hook called after loading available language files.
*
* Use this hook to customise the list of languagesPath available in Piwik.
*
* @param array
*/
Piwik::postEvent('LanguageManager.getAvailableLanguages', array(&$languages));
$this->languageNames = $languages;
return $languages;
}
示例2: getPluginsFromDirectoy
public function getPluginsFromDirectoy($directoryToLook)
{
$directories = _glob($directoryToLook . '/plugins/' . '*', GLOB_ONLYDIR);
$directories = array_map(function ($directory) use($directoryToLook) {
return str_replace($directoryToLook, '', $directory);
}, $directories);
return $directories;
}
示例3: getPluginNamesHavingNotSpecificFile
protected function getPluginNamesHavingNotSpecificFile($filename)
{
$pluginDirs = \_glob(PIWIK_INCLUDE_PATH . '/plugins/*', GLOB_ONLYDIR);
$pluginNames = array();
foreach ($pluginDirs as $pluginDir) {
if (!file_exists($pluginDir . '/' . $filename)) {
$pluginNames[] = basename($pluginDir);
}
}
return $pluginNames;
}
示例4: load_templates
function load_templates($tpl_array = null)
{
global $replacement;
$k = array_keys($replacement);
$r = array_values($replacement);
$path = THEME_PATH . '/templates/';
if (empty($tpl_array)) {
$tpl_array = _glob($path, $pattern = 'html');
}
foreach ($tpl_array as $key => $tpl) {
$tpl = _basename($tpl);
$tpl_name = substr($tpl, 0, strlen($tpl) - 5);
$templates[$tpl_name] = str_replace($k, $r, file_get_contents($path . $tpl));
}
return $templates;
}
示例5: tree
function tree($dir = '.', $files = true)
{
if (!isset($dossiers[0]) || $dossiers[0] != $dir) {
$dossiers[0] = $dir;
}
if (!is_dir($dir) && $files) {
return array($dir);
} elseif (!is_dir($dir) && !$files) {
return array();
}
$list = _glob(addslash_if_needed($dir));
foreach ($list as $dossier) {
$dossiers = array_merge($dossiers, tree($dossier, $files));
}
return $dossiers;
}
示例6: getAvailableLanguages
/**
* Return array of available languages
*
* @return array Arry of strings, each containing its ISO language code
*/
public function getAvailableLanguages()
{
if (!is_null($this->languageNames)) {
return $this->languageNames;
}
$path = PIWIK_INCLUDE_PATH . "/lang/";
$languages = _glob($path . "*.php");
$pathLength = strlen($path);
$languageNames = array();
if ($languages) {
foreach ($languages as $language) {
$languageNames[] = substr($language, $pathLength, -strlen('.php'));
}
}
$this->languageNames = $languageNames;
return $languageNames;
}
示例7: find
/**
* @return File[]
*/
public function find()
{
$jsFiles = array();
if (!$this->ignoreMinified) {
$trackerFiles = \_glob($this->dir . '*/' . self::MIN_TRACKER_FILE);
foreach ($trackerFiles as $trackerFile) {
$plugin = $this->getPluginNameFromFile($trackerFile);
if ($this->isPluginActivated($plugin)) {
$jsFiles[$plugin] = new File($trackerFile);
}
}
}
$trackerFiles = \_glob($this->dir . '*/' . self::TRACKER_FILE);
foreach ($trackerFiles as $trackerFile) {
$plugin = $this->getPluginNameFromFile($trackerFile);
if (!isset($jsFiles[$plugin])) {
if ($this->isPluginActivated($plugin)) {
$jsFiles[$plugin] = new File($trackerFile);
}
}
}
return $jsFiles;
}
示例8: readPluginsDirectory
/**
* Reads the directories inside the plugins/ directory and returns their names in an array
*
* @return array
*/
public function readPluginsDirectory()
{
$pluginsName = _glob(PIWIK_INCLUDE_PATH . '/plugins/*', GLOB_ONLYDIR);
$result = array();
if ($pluginsName != false) {
foreach ($pluginsName as $path) {
$name = basename($path);
if (file_exists($path . '/' . $name . '.php')) {
$result[] = $name;
}
}
}
return $result;
}
示例9: test_DirectoriesInPluginsFolder_areKnown
/**
* Check that directories in plugins/ folder are specifically either enabled or disabled.
*
* This fails when a new folder is added to plugins/* and forgot to enable or mark as disabled in Manager.php.
*
* @group Core
*/
public function test_DirectoriesInPluginsFolder_areKnown()
{
$pluginsBundledWithPiwik = \Piwik\Config::getInstance()->getFromGlobalConfig('Plugins');
$pluginsBundledWithPiwik = $pluginsBundledWithPiwik['Plugins'];
$magicPlugins = 42;
$this->assertTrue(count($pluginsBundledWithPiwik) > $magicPlugins);
$plugins = _glob(\Piwik\Plugin\Manager::getPluginsDirectory() . '*', GLOB_ONLYDIR);
$count = 1;
foreach ($plugins as $pluginPath) {
$pluginName = basename($pluginPath);
$addedToGit = $this->isPathAddedToGit($pluginPath);
if (!$addedToGit) {
// if not added to git, then it is not part of the release checklist.
continue;
}
$manager = \Piwik\Plugin\Manager::getInstance();
$isGitSubmodule = $manager->isPluginOfficialAndNotBundledWithCore($pluginName);
$disabled = in_array($pluginName, $manager->getCorePluginsDisabledByDefault()) || $isGitSubmodule;
$enabled = in_array($pluginName, $pluginsBundledWithPiwik);
$this->assertTrue($enabled + $disabled === 1, "Plugin {$pluginName} should be either enabled (in global.ini.php) or disabled (in Piwik\\Plugin\\Manager).\n It is currently (enabled=" . (int) $enabled . ", disabled=" . (int) $disabled . ")");
$count++;
}
$this->assertTrue($count > $magicPlugins);
}
示例10: e
if (strlen($id) > strlen(uniqid(true))) {
# add class password protected
$class = 'locked';
$title = e('The user can access this only with the password', false);
}
}
$extension = strtolower(pathinfo($fichier, PATHINFO_EXTENSION));
if (visualizeIcon($extension)) {
$icone_visu = '<a class="visu" href="index.php?f=' . $id . '" target="_BLANK" title="' . e('View this file', false) . '"> </a>';
} else {
$icone_visu = '';
}
$fichier_short = substr($fichier, $upload_path_size);
if (is_dir($fichier)) {
# Item is a folder
$taille = count(_glob($fichier . '/'));
$array = array('#CLASS' => $class, '#ID' => $id, '#FICHIER' => $fichier_short, '#TOKEN' => returnToken(), '#SIZE' => $taille, '#NAME' => $nom, '#TITLE' => $title, '#SLASHEDNAME' => addslashes($nom), '#SLASHEDFICHIER' => addslashes($fichier));
$folderlist .= template($mode . '_folder_' . $layout, $array);
} elseif ($extension == 'gif' || $extension == 'jpg' || $extension == 'jpeg' || $extension == 'png') {
# Item is a picture
auto_thumb($fichier, 64, 64);
$array = array('#CLASS' => $class, '#ID' => $id, '#FICHIER' => $fichier_short, '#TOKEN' => returnToken(), '#SIZE' => $taille, '#NAME' => $nom, '#TITLE' => $title, '#EXTENSION' => $extension, '#ICONE_VISU' => $icone_visu, '#SLASHEDNAME' => addslashes($nom), '#SLASHEDFICHIER' => addslashes($fichier_short));
$filelist .= template($mode . '_image_' . $layout, $array);
} elseif ($extension == 'zip') {
# Item is a zip file=> add change to folder
$icone_visu = '<a class="tofolder" href="index.php?p=admin&unzip=' . $id . '&token=' . returnToken() . '" title="' . e('Convert this zip file to folder', false) . '"> </a>';
$array = array('#CLASS' => $class, '#ID' => $id, '#FICHIER' => $fichier_short, '#TOKEN' => returnToken(), '#SIZE' => $taille, '#NAME' => $nom, '#TITLE' => $title, '#EXTENSION' => $extension, '#ICONE_VISU' => $icone_visu, '#SLASHEDNAME' => addslashes($nom), '#SLASHEDFICHIER' => addslashes($fichier_short));
$filelist .= template($mode . '_file_' . $layout, $array);
} else {
# all other types
$array = array('#CLASS' => $class, '#ID' => $id, '#FICHIER' => $fichier_short, '#TOKEN' => returnToken(), '#SIZE' => $taille, '#NAME' => $nom, '#TITLE' => $title, '#EXTENSION' => $extension, '#ICONE_VISU' => $icone_visu, '#SLASHEDNAME' => addslashes($nom), '#SLASHEDFICHIER' => addslashes($fichier_short));
示例11: available_languages
function available_languages()
{
$l = _glob('locale/', 'php');
foreach ($l as $key => $lang) {
$l[$key] = str_replace('.php', '', basename($lang));
}
return $l;
}
示例12: cleanupNotRemovedFiles
/**
* Remove files older than one week. They should be cleaned up automatically after each request but for whatever
* reason there can be always some files left.
*/
public static function cleanupNotRemovedFiles()
{
$timeOneWeekAgo = strtotime('-1 week');
$files = _glob(self::getTmpPath() . '/*');
if (empty($files)) {
return;
}
foreach ($files as $file) {
$timeLastModified = filemtime($file);
if ($timeOneWeekAgo > $timeLastModified) {
unlink($file);
}
}
}
示例13: array
}
$liste = array();
$pattern = str_replace('*', '', $pattern);
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if (stripos($file, $pattern) !== false || $pattern == '' && $file != '.' && $file != '..' && $file != '.htaccess') {
$liste[] = $path . $file;
}
}
closedir($handle);
}
natcasesort($liste);
return $liste;
}
}
$cssFiles = _glob('./', 'css');
/**
* Ideally, you wouldn't need to change any code beyond this point.
*/
$buffer = "";
foreach ($cssFiles as $cssFile) {
$buffer .= file_get_contents($cssFile);
}
$buffer = str_replace(array_keys($replace), array_values($replace), $buffer);
// Remove unnecessary characters
$buffer = preg_replace("|/\\*[^*]*\\*+([^/][^*]*\\*+)*/|", "", $buffer);
$buffer = preg_replace("/[\\s]*([\\:\\{\\}\\;\\,])[\\s]*/", "\$1", $buffer);
// Remove whitespace
$buffer = str_replace(array("\r\n", "\r", "\n"), '', $buffer);
// Enable GZip encoding.
ob_start("ob_gzhandler");
示例14: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$dialog = $this->getHelperSet()->get('dialog');
$command = $this->getApplication()->find('translations:fetch');
$arguments = array('command' => 'translations:fetch', '--username' => $input->getOption('username'), '--password' => $input->getOption('password'));
$inputObject = new ArrayInput($arguments);
$inputObject->setInteractive($input->isInteractive());
$command->run($inputObject, $output);
$languages = API::getInstance()->getAvailableLanguageNames();
$languageCodes = array();
foreach ($languages as $languageInfo) {
$languageCodes[] = $languageInfo['code'];
}
$plugin = $input->getOption('plugin');
$files = _glob(FetchFromOTrance::getDownloadPath() . DIRECTORY_SEPARATOR . '*.json');
$output->writeln("Starting to import new language files");
if (!$input->isInteractive()) {
$output->writeln("(!) Non interactive mode: New languages will be skipped");
}
$progress = $this->getHelperSet()->get('progress');
$progress->start($output, count($files));
foreach ($files as $filename) {
$progress->advance();
$code = basename($filename, '.json');
if (!in_array($code, $languageCodes)) {
if (!empty($plugin)) {
continue;
# never create a new language for plugin only
}
$createNewFile = false;
if ($input->isInteractive()) {
$createNewFile = $dialog->askConfirmation($output, "\nLanguage {$code} does not exist. Should it be added? ", false);
}
if (!$createNewFile) {
continue;
# do not create a new file for the language
}
@touch(PIWIK_DOCUMENT_ROOT . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . $code . '.json');
API::unsetInstance();
// unset language manager instance, so valid names are refetched
}
$command = $this->getApplication()->find('translations:set');
$arguments = array('command' => 'translations:set', '--code' => $code, '--file' => $filename, '--plugin' => $plugin);
$inputObject = new ArrayInput($arguments);
$inputObject->setInteractive($input->isInteractive());
$command->run($inputObject, new NullOutput());
// update core modules that aren't in their own repo
if (empty($plugin)) {
foreach (self::getPluginsInCore() as $pluginName) {
// update translation files
$command = $this->getApplication()->find('translations:set');
$arguments = array('command' => 'translations:set', '--code' => $code, '--file' => $filename, '--plugin' => $pluginName);
$inputObject = new ArrayInput($arguments);
$inputObject->setInteractive($input->isInteractive());
$command->run($inputObject, new NullOutput());
}
}
}
$progress->finish();
$output->writeln("Finished.");
}
示例15: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$start = microtime(true);
/** @var DialogHelper $dialog */
$dialog = $this->getHelperSet()->get('dialog');
$languages = API::getInstance()->getAvailableLanguageNames();
$languageCodes = array();
foreach ($languages as $languageInfo) {
$languageCodes[] = $languageInfo['code'];
}
$plugin = $input->getOption('plugin');
if (!$input->isInteractive()) {
$output->writeln("(!) Non interactive mode: New languages will be skipped");
}
$pluginList = array($plugin);
if (empty($plugin)) {
$pluginList = self::getPluginsInCore();
array_unshift($pluginList, '');
}
foreach ($pluginList as $plugin) {
$output->writeln("");
// fetch base or specific plugin
$this->fetchTranslations($input, $output, $plugin);
$files = _glob(FetchTranslations::getDownloadPath() . DIRECTORY_SEPARATOR . '*.json');
if (count($files) == 0) {
$output->writeln("No translation updates available! Skipped.");
continue;
}
$output->writeln("Starting to import new language files");
/** @var ProgressHelper $progress */
$progress = $this->getHelperSet()->get('progress');
$progress->start($output, count($files));
foreach ($files as $filename) {
$progress->advance();
$code = basename($filename, '.json');
if (!in_array($code, $languageCodes)) {
if (!empty($plugin)) {
continue;
# never create a new language for plugin only
}
$createNewFile = false;
if ($input->isInteractive()) {
$createNewFile = $dialog->askConfirmation($output, "\nLanguage {$code} does not exist. Should it be added? ", false);
}
if (!$createNewFile) {
continue;
# do not create a new file for the language
}
@touch(PIWIK_DOCUMENT_ROOT . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . $code . '.json');
API::unsetInstance();
// unset language manager instance, so valid names are refetched
}
$command = $this->getApplication()->find('translations:set');
$arguments = array('command' => 'translations:set', '--code' => $code, '--file' => $filename, '--plugin' => $plugin);
$inputObject = new ArrayInput($arguments);
$inputObject->setInteractive($input->isInteractive());
$command->run($inputObject, new NullOutput());
}
$progress->finish();
}
$output->writeln("Finished in " . round(microtime(true) - $start, 3) . "s");
}