本文整理汇总了PHP中Piwik\Filesystem::globr方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::globr方法的具体用法?PHP Filesystem::globr怎么用?PHP Filesystem::globr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Filesystem
的用法示例。
在下文中一共展示了Filesystem::globr方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: copyTemplateToPlugin
/**
* @param string $templateFolder full path like /home/...
* @param string $pluginName
* @param array $replace array(key => value) $key will be replaced by $value in all templates
* @param array $whitelistFiles If not empty, only given files/directories will be copied.
* For instance array('/Controller.php', '/templates', '/templates/index.twig')
*/
protected function copyTemplateToPlugin($templateFolder, $pluginName, array $replace = array(), $whitelistFiles = array())
{
$replace['PLUGINNAME'] = $pluginName;
$files = array_merge(Filesystem::globr($templateFolder, '*'), Filesystem::globr($templateFolder, '.*'));
foreach ($files as $file) {
$fileNamePlugin = str_replace($templateFolder, '', $file);
if (!empty($whitelistFiles) && !in_array($fileNamePlugin, $whitelistFiles)) {
continue;
}
if (is_dir($file)) {
$this->createFolderWithinPluginIfNotExists($pluginName, $fileNamePlugin);
} else {
$template = file_get_contents($file);
foreach ($replace as $key => $value) {
$template = str_replace($key, $value, $template);
}
foreach ($replace as $key => $value) {
$fileNamePlugin = str_replace($key, $value, $fileNamePlugin);
}
$this->createFileWithinPluginIfNotExists($pluginName, $fileNamePlugin, $template);
}
}
}
示例2: deleteHtAccessFiles
/**
* Deletes all existing .htaccess files and web.config files that Piwik may have created,
*/
public static function deleteHtAccessFiles()
{
$files = Filesystem::globr(PIWIK_INCLUDE_PATH, ".htaccess");
// that match the list of directories we create htaccess files
// (ie. not the root /.htaccess)
$directoriesWithAutoHtaccess = array('/js', '/libs', '/vendor', '/plugins', '/misc/user', '/config', '/core', '/lang', '/tmp');
foreach ($files as $file) {
foreach ($directoriesWithAutoHtaccess as $dirToDelete) {
// only delete the first .htaccess and not the ones in sub-directories
$pathToDelete = $dirToDelete . '/.htaccess';
if (strpos($file, $pathToDelete) !== false) {
@unlink($file);
}
}
}
}
示例3: doFindMultipleComponents
/**
* @param $directoryWithinPlugin
* @param $expectedSubclass
* @return array
*/
private function doFindMultipleComponents($directoryWithinPlugin, $expectedSubclass)
{
$components = array();
$baseDir = PIWIK_INCLUDE_PATH . '/plugins/' . $this->pluginName . '/' . $directoryWithinPlugin;
$files = Filesystem::globr($baseDir, '*.php');
foreach ($files as $file) {
require_once $file;
$fileName = str_replace(array($baseDir . '/', '.php'), '', $file);
$klassName = sprintf('Piwik\\Plugins\\%s\\%s\\%s', $this->pluginName, $directoryWithinPlugin, str_replace('/', '\\', $fileName));
if (!class_exists($klassName)) {
continue;
}
if (!empty($expectedSubclass) && !is_subclass_of($klassName, $expectedSubclass)) {
continue;
}
$klass = new \ReflectionClass($klassName);
if ($klass->isAbstract()) {
continue;
}
$components[$file] = $klassName;
}
return $components;
}
示例4: getCurrentDimensionFileChanges
private static function getCurrentDimensionFileChanges()
{
$files = Filesystem::globr(PIWIK_INCLUDE_PATH . '/plugins/*/Columns', '*.php');
$times = array();
foreach ($files as $file) {
$times[$file] = filemtime($file);
}
return $times;
}
示例5: testEndOfLines
/**
* @group Core
*/
public function testEndOfLines()
{
foreach (Filesystem::globr(PIWIK_DOCUMENT_ROOT, '*') as $file) {
// skip files in these folders
if (strpos($file, '/.git/') !== false || strpos($file, '/documentation/') !== false || strpos($file, '/tests/') !== false || strpos($file, '/lang/') !== false || strpos($file, 'yuicompressor') !== false || strpos($file, '/tmp/') !== false) {
continue;
}
// skip files with these file extensions
if (preg_match('/\\.(bmp|fdf|gif|deb|deflate|exe|gz|ico|jar|jpg|p12|pdf|png|rar|swf|vsd|z|zip|ttf|so|dat|eps|phar|pyc)$/', $file)) {
continue;
}
if (!is_dir($file)) {
$contents = file_get_contents($file);
// expect CRLF
if (preg_match('/\\.(bat|ps1)$/', $file)) {
$contents = str_replace("\r\n", '', $contents);
$this->assertTrue(strpos($contents, "\n") === false, 'Incorrect line endings in ' . $file);
} else {
// expect native
$hasWindowsEOL = strpos($contents, "\r\n");
// overwrite translations files with incorrect line endings
$this->assertTrue($hasWindowsEOL === false, 'Incorrect line endings \\r\\n found in ' . $file);
}
}
}
}
示例6: catch
try {
document.documentElement.doScroll('left');
} catch (error) {
setTimeout(ready, 0);
return;
}
f();
}
}());
}
} else {
customAddEventListener(window, 'load', f, false);
}
})(PiwikTest);
</script>
<?php
include_once $root . '/core/Filesystem.php';
$files = \Piwik\Filesystem::globr($root . '/plugins/*/tests/javascript', 'index.php');
foreach ($files as $file) {
include_once $file;
}
?>
<div id="jashDiv">
<a href="#" onclick="javascript:loadJash();" title="Open JavaScript Shell"><img id="title" src="gnome-terminal.png" border="0" width="24" height="24" /></a>
</div>
</body>
</html>
示例7: doesFolderContainUITests
private function doesFolderContainUITests($folderPath)
{
$testFiles = Filesystem::globr($folderPath, "*_spec.js");
return !empty($testFiles);
}
示例8: getAllFilesizes
/**
* @return array
* @throws Exception
*/
private function getAllFilesizes()
{
$files = Filesystem::globr(PIWIK_INCLUDE_PATH, '*');
$filesizes = array();
foreach ($files as $file) {
if (!$this->isFileIncludedInFinalRelease($file)) {
continue;
}
$filesize = filesize($file);
if ($filesize === false) {
throw new Exception("Error getting filesize for file: {$file}");
}
$filesizes[$file] = $filesize;
}
return $filesizes;
}
示例9: findCommandsInPlugin
private function findCommandsInPlugin($pluginName)
{
$commands = array();
$files = Filesystem::globr(PIWIK_INCLUDE_PATH . '/plugins/' . $pluginName . '/Commands', '*.php');
foreach ($files as $file) {
$klassName = sprintf('Piwik\\Plugins\\%s\\Commands\\%s', $pluginName, basename($file, '.php'));
if (!class_exists($klassName) || !is_subclass_of($klassName, 'Piwik\\Plugin\\ConsoleCommand')) {
continue;
}
$klass = new \ReflectionClass($klassName);
if ($klass->isAbstract()) {
continue;
}
$commands[] = $klassName;
}
return $commands;
}