本文整理汇总了PHP中Utils::glob方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::glob方法的具体用法?PHP Utils::glob怎么用?PHP Utils::glob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utils
的用法示例。
在下文中一共展示了Utils::glob方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_plugin_ui
public function action_plugin_ui($plugin_id, $action)
{
if ($plugin_id == $this->plugin_id()) {
switch ($action) {
case _('Configure'):
$ui = new FormUI(strtolower(get_class($this)));
// present the user with a list of
// URL shortening services
$service = $ui->append('select', 'service', 'lilliputian__service', _t('The URL shortening service to use: '));
$services = array();
$services['internal'] = 'internal';
$list = Utils::glob(dirname(__FILE__) . '/*.helper.php');
if (count($list) > 0) {
foreach ($list as $item) {
$item = basename($item, '.helper.php');
$services[$item] = $item;
}
}
$service->options = $services;
if (Options::get('lilliputian__service') == 'internal') {
$secret = $ui->append('text', 'secret', 'lilliputian__secret', _t('The secret word that must be passed when generating short URLs. May be blank to disable this security feature.'));
}
$ui->append('submit', 'save', _t('Save'));
$ui->out();
break;
}
}
}
示例2: get_all_data
/**
* Returns all theme information -- dir, path, theme.xml, screenshot url
* @return array An array of Theme data
**/
public static function get_all_data()
{
if ( !isset( self::$all_data ) ) {
foreach ( self::get_all() as $theme_dir => $theme_path ) {
$themedata = array();
$themedata['dir'] = $theme_dir;
$themedata['path'] = $theme_path;
$themedata['theme_dir'] = $theme_path;
$themedata['info'] = simplexml_load_file( $theme_path . '/theme.xml' );
if ( $themedata['info']->getName() != 'pluggable' || (string) $themedata['info']->attributes()->type != 'theme' ) {
$themedata['screenshot'] = Site::get_url( 'admin_theme' ) . "/images/screenshot_default.png";
$themedata['info']->description = '<span class="error">' . _t( 'This theme is a legacy theme that is not compatible with Habari ' ) . Version::get_habariversion() . '. <br><br>Please update your theme.</span>';
$themedata['info']->license = '';
}
else {
foreach ( $themedata['info'] as $name=>$value ) {
$themedata[$name] = (string) $value;
}
if ( $screenshot = Utils::glob( $theme_path . '/screenshot.{png,jpg,gif}', GLOB_BRACE ) ) {
$themedata['screenshot'] = Site::get_url( 'habari' ) . dirname( str_replace( HABARI_PATH, '', $theme_path ) ) . '/' . basename( $theme_path ) . "/" . basename( reset( $screenshot ) );
}
else {
$themedata['screenshot'] = Site::get_url( 'admin_theme' ) . "/images/screenshot_default.png";
}
}
self::$all_data[$theme_dir] = $themedata;
}
}
return self::$all_data;
}
示例3: get_color_schemes
private static function get_color_schemes()
{
$color_scheme_dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'color-schemes' . DIRECTORY_SEPARATOR;
$files = Utils::glob($color_scheme_dir . '*.css');
$color_schemes = array();
foreach ($files as $color_scheme) {
$name = basename($color_scheme, '.css');
$color_schemes[$name] = $name;
}
return $color_schemes;
}
示例4: get_all_data
/**
* Returns all theme information -- dir, path, theme.xml, screenshot url
* @return array An array of Theme data
**/
public static function get_all_data()
{
if (!isset(self::$all_data)) {
$themedata = array();
foreach (self::get_all() as $theme_dir => $theme_path) {
$themedata['dir'] = $theme_dir;
$themedata['path'] = $theme_path;
$themedata['info'] = simplexml_load_file($theme_path . '/theme.xml');
if ($screenshot = Utils::glob($theme_path . '/screenshot.{png,jpg,gif}', GLOB_BRACE)) {
$themedata['screenshot'] = Site::get_url('habari') . dirname(str_replace(HABARI_PATH, '', $theme_path)) . '/' . basename($theme_path) . "/" . basename(reset($screenshot));
} else {
$themedata['screenshot'] = Site::get_url('admin_theme') . "/images/screenshot_default.png";
}
self::$all_data[$theme_dir] = $themedata;
}
}
return self::$all_data;
}
示例5: list_all
/**
* function list_all
* Gets a list of all plugin filenames that are available
* @return array An array of filenames
*/
public static function list_all()
{
$plugins = array();
$plugindirs = array( HABARI_PATH . '/system/plugins/', HABARI_PATH . '/3rdparty/plugins/', HABARI_PATH . '/user/plugins/' );
if ( Site::CONFIG_LOCAL != Site::$config_type ) {
// include site-specific plugins
$plugindirs[] = Site::get_dir( 'config' ) . '/plugins/';
}
$dirs = array();
foreach ( $plugindirs as $plugindir ) {
if ( file_exists( $plugindir ) ) {
$dirs = array_merge( $dirs, Utils::glob( $plugindir . '*', GLOB_ONLYDIR | GLOB_MARK ) );
}
}
foreach ( $dirs as $dir ) {
$dirfiles = Utils::glob( $dir . '*.plugin.php' );
if ( ! empty( $dirfiles ) ) {
$dirfiles = array_combine(
// Use the basename of the file as the index to use the named plugin from the last directory in $dirs
array_map( 'basename', $dirfiles ),
// massage the filenames so that this works on Windows
array_map( create_function( '$s', 'return str_replace(\'\\\\\', \'/\', $s);' ), $dirfiles )
);
$plugins = array_merge( $plugins, $dirfiles );
}
$dirfiles = Utils::glob( $dir . '*.phar' );
foreach($dirfiles as $filename) {
if(preg_match('/\.phar$/i', $filename)) {
$d = new DirectoryIterator('phar://' . $filename);
foreach ($d as $fileinfo) {
if ($fileinfo->isFile() && preg_match('/\.plugin.php$/i', $fileinfo->getFilename())) {
$plugins[$fileinfo->getFilename()] = str_replace('\\', '/', $fileinfo->getPathname());
}
}
}
}
}
ksort( $plugins );
return $plugins;
}
示例6: get_dir
/**
* get_dir returns a complete filesystem path to the requested item
* 'config_file' returns the complete path to the config.php file, including the filename
* 'config' returns the path of the directory containing config.php
* 'user' returns the path of the user directory
* 'theme' returns the path of the site's active theme
* 'admin_theme' returns the path to the admin directory
* 'vendor' returns the path to the vendor directory
* @param string the name of the path item to return
* @param bool whether to include a trailing slash. Default: No
* @return string Path
*/
public static function get_dir($name, $trail = false)
{
$path = '';
switch (strtolower($name)) {
case 'config_file':
$path = Site::get_dir('config') . '/config.php';
break;
case 'config':
if (self::$config_path) {
return self::$config_path;
}
self::$config_path = HABARI_PATH;
$config_dirs = preg_replace('/^' . preg_quote(HABARI_PATH, '/') . '\\/user\\/sites\\/(.*)/', '$1', Utils::glob(HABARI_PATH . '/user/sites/*', GLOB_ONLYDIR));
if (empty($config_dirs)) {
return self::$config_path;
}
$server = InputFilter::parse_url(Site::get_url('habari'));
$request = array();
if (isset($server['port']) && $server['port'] != '' && $server['port'] != '80') {
$request[] = $server['port'];
}
$request = array_merge($request, explode('.', $server['host']));
$basesegments = count($request);
$request = array_merge($request, explode('/', trim($_SERVER['REQUEST_URI'], '/')));
$x = 0;
do {
$match = implode('.', $request);
if (in_array($match, $config_dirs)) {
self::$config_dir = $match;
self::$config_path = HABARI_PATH . '/user/sites/' . self::$config_dir;
self::$config_type = $basesegments > count($request) ? Site::CONFIG_SUBDOMAIN : Site::CONFIG_SUBDIR;
self::$config_urldir = implode('/', array_slice($request, $basesegments));
break;
}
array_pop($request);
$x--;
if ($x < -10) {
echo $x;
var_dump($request);
die('too many ');
}
} while (count($request) > 0);
$path = self::$config_path;
break;
case 'user':
if (Site::get_dir('config') == HABARI_PATH) {
$path = HABARI_PATH . '/user';
} else {
$path = Site::get_dir('config');
}
break;
case 'theme':
$theme = Themes::get_theme_dir();
if (file_exists(Site::get_dir('config') . '/themes/' . $theme)) {
$path = Site::get_dir('user') . '/themes/' . $theme;
} elseif (file_exists(HABARI_PATH . '/user/themes/' . $theme)) {
$path = HABARI_PATH . '/user/themes/' . $theme;
} elseif (file_exists(HABARI_PATH . '/3rdparty/themes/' . $theme)) {
$url = Site::get_url('habari') . '/3rdparty/themes/' . $theme;
} else {
$path = HABARI_PATH . '/system/themes/' . $theme;
}
break;
case 'admin_theme':
$path = HABARI_PATH . '/system/admin';
break;
case 'vendor':
$path = HABARI_PATH . '/system/vendor';
break;
}
$path .= Utils::trail($trail);
$path = Plugins::filter('site_dir_' . $name, $path);
return $path;
}
示例7: list_all
/**
* function list_all
* Retrieves an array of the Habari locales that are installed
*
* @return array. An array of Habari locales in the installation
**/
public static function list_all()
{
$localedirs = array(HABARI_PATH . '/system/locale/', HABARI_PATH . '/3rdparty/locale/', HABARI_PATH . '/user/locale/');
if (Site::CONFIG_LOCAL != Site::$config_type) {
// include site-specific locales
$localedirs[] = Site::get_dir('config') . '/locale/';
}
$dirs = array();
foreach ($localedirs as $localedir) {
if (file_exists($localedir)) {
$dirs = array_merge($dirs, Utils::glob($localedir . '*', GLOB_ONLYDIR | GLOB_MARK));
}
}
$dirs = array_filter($dirs, create_function('$a', 'return file_exists($a . "LC_MESSAGES/habari.mo");'));
$locales = array_map('basename', $dirs);
ksort($locales);
return $locales;
}
示例8: upgrade
/**
* Updates the content of the database between versions.
* Implemented in child classes.
*
* @param integer $old_version The old Version::DB_VERSION
* @param string $upgrade_path
* @return bool
*/
public function upgrade($old_version, $upgrade_path = '')
{
// Get all the upgrade files
$upgrade_files = Utils::glob("{$upgrade_path}/*.sql");
// Put the upgrade files into an array using the 0-padded revision + '_0' as the key
$upgrades = array();
foreach ($upgrade_files as $file) {
if (intval(basename($file, '.sql')) > $old_version) {
$upgrades[sprintf('%010s_0', basename($file, '.sql'))] = $file;
}
}
// Put the upgrade functions into an array using the 0-padded revision + '_1' as the key
$upgrade_functions = get_class_methods($this);
foreach ($upgrade_functions as $fn) {
if (preg_match('%^upgrade_([0-9]+)$%i', $fn, $matches)) {
if (intval($matches[1]) > $old_version) {
$upgrades[sprintf('%010s_1', $matches[1])] = array($this, $fn);
}
}
}
// Sort the upgrades by revision, ascending
ksort($upgrades);
// Execute all of the upgrade functions
$result = true;
foreach ($upgrades as $upgrade) {
if (is_array($upgrade)) {
/** @var Callable $upgrade */
$result &= $upgrade();
} else {
$result &= $this->query_file($upgrade);
}
if (!$result) {
break;
}
}
return $result;
}
示例9: get_sysinfo
/**
* Handles get requests for the system information page.
*/
public function get_sysinfo()
{
$sysinfo = array();
$siteinfo = array();
// Assemble Site Info
$siteinfo[_t('Habari Version')] = Version::get_habariversion();
if (Version::is_devel()) {
$siteinfo[_t('Habari Version')] .= " r" . Version::get_svn_revision();
}
$siteinfo[_t('Habari API Version')] = Version::get_apiversion();
$siteinfo[_t('Habari DB Version')] = Version::get_dbversion();
$siteinfo[_t('Active Theme')] = Options::get('theme_name');
$siteinfo[_t('Site Language')] = strlen(Options::get('system_locale')) ? Options::get('system_locale') : 'en-us';
$this->theme->siteinfo = $siteinfo;
// Assemble System Info
$sysinfo[_t('PHP Version')] = phpversion();
$sysinfo[_t('Server Software')] = $_SERVER['SERVER_SOFTWARE'];
$sysinfo[_t('Database')] = DB::get_driver_name() . ' - ' . DB::get_driver_version();
$sysinfo[_t('PHP Extensions')] = implode(', ', get_loaded_extensions());
if (defined('PCRE_VERSION')) {
$sysinfo[_t('PCRE Version')] = PCRE_VERSION;
} else {
// probably PHP < 5.2.4
ob_start();
phpinfo(8);
$phpinfo = ob_get_contents();
ob_end_clean();
preg_match('/PCRE Library Version.*class="v">(.*)$/mi', $phpinfo, $matches);
$sysinfo[_t('PCRE Version')] = $matches[1];
}
$sysinfo[_t('Browser')] = $_SERVER['HTTP_USER_AGENT'];
$this->theme->sysinfo = $sysinfo;
// Assemble Class Info
$classinfo = Utils::glob(HABARI_PATH . "/user/classes/*.php");
if (count($classinfo)) {
$classinfo = array_map('realpath', $classinfo);
}
$this->theme->classinfo = $classinfo;
// Assemble Plugin Info
$raw_plugins = Plugins::get_active();
$plugins = array('system' => array(), 'user' => array(), '3rdparty' => array(), 'other' => array());
foreach ($raw_plugins as $plugin) {
$file = $plugin->get_file();
if (preg_match('%[\\\\/](system|3rdparty|user)[\\\\/]plugins[\\\\/]%i', $file, $matches)) {
// A plugin's info is XML, cast the element to a string. See #1026.
$plugins[strtolower($matches[1])][(string) $plugin->info->name] = $file;
} else {
$plugins['other'][$plugin->info->name] = $file;
}
}
$this->theme->plugins = $plugins;
$this->display('sysinfo');
}
示例10: list_all
/**
* function list_all
* Gets a list of all plugin filenames that are available
* @return array An array of filenames
*/
public static function list_all()
{
$plugins = array();
$plugindirs = array(HABARI_PATH . '/system/plugins/', HABARI_PATH . '/3rdparty/plugins/', HABARI_PATH . '/user/plugins/');
if (Site::CONFIG_LOCAL != Site::$config_type) {
// include site-specific plugins
$plugindirs[] = Site::get_dir('config') . '/plugins/';
}
$dirs = array();
foreach ($plugindirs as $plugindir) {
if (file_exists($plugindir)) {
$dirs = array_merge($dirs, Utils::glob($plugindir . '*', GLOB_ONLYDIR | GLOB_MARK));
}
}
foreach ($dirs as $dir) {
$dirfiles = Utils::glob($dir . '*.plugin.php');
if (!empty($dirfiles)) {
$dirfiles = array_combine(array_map('basename', $dirfiles), array_map(function ($s) {
return str_replace('\\', '/', $s);
}, $dirfiles));
$plugins = array_merge($plugins, $dirfiles);
}
$dirfiles = Utils::glob($dir . '*.phar');
foreach ($dirfiles as $filename) {
if (preg_match('/\\.phar$/i', $filename)) {
$d = new DirectoryIterator('phar://' . $filename);
foreach ($d as $fileinfo) {
if ($fileinfo->isFile() && preg_match('/\\.plugin.php$/i', $fileinfo->getFilename())) {
$plugins[$fileinfo->getFilename()] = str_replace('\\', '/', $fileinfo->getPathname());
}
}
}
}
}
ksort($plugins);
return $plugins;
}
示例11: queue_dirs
/**
* Search directories for templates to use
* Templates are always taken from the first directory they're found in.
* To override this behavior, the template must be specifically added via ->add_template()
* @see add_template
* @param string|array $dirs A directory to look for templates in
*/
public function queue_dirs($dirs)
{
$dirs = Utils::single_array($dirs);
$alltemplates = array();
// If multiple directories are passed, the earlier ones should override the later ones
$dirs = array_reverse($dirs);
foreach ($dirs as $dir) {
$templates = Utils::glob(Utils::end_in_slash($dir) . '*.*');
$alltemplates = array_merge($alltemplates, $templates);
}
// Convert the template files into template names and produce a map from name => file
$available_templates = array_map('basename', $alltemplates, array_fill(1, count($alltemplates), '.php'));
$template_map = array_combine($available_templates, $alltemplates);
$this->template_map = array_merge($this->template_map, $template_map);
// Workaround for the 404 template key being merged into the 0 integer index
unset($this->template_map[0]);
if (isset($template_map[404])) {
$this->template_map['404'] = $template_map[404];
}
// The templates in the list should be uniquely identified
array_unique($available_templates);
// Filter the templates that are available
$available_templates = Plugins::filter('available_templates', $available_templates, __CLASS__);
$this->available_templates = array_merge($available_templates, $this->available_templates);
}
示例12: list_all
/**
* function list_all
* Gets a list of all plugin filenames that are available
* @return array An array of filenames
*/
public static function list_all()
{
$plugins = array();
$plugindirs = array(HABARI_PATH . '/system/plugins/', HABARI_PATH . '/3rdparty/plugins/', HABARI_PATH . '/user/plugins/');
if (Site::CONFIG_LOCAL != Site::$config_type) {
// include site-specific plugins
$plugindirs[] = Site::get_dir('config') . '/plugins/';
}
$dirs = array();
foreach ($plugindirs as $plugindir) {
if (file_exists($plugindir)) {
$dirs = array_merge($dirs, Utils::glob($plugindir . '*', GLOB_ONLYDIR | GLOB_MARK));
}
}
foreach ($dirs as $dir) {
$dirfiles = Utils::glob($dir . '*.plugin.php');
if (!empty($dirfiles)) {
$dirfiles = array_combine(array_map('basename', $dirfiles), array_map(create_function('$s', 'return str_replace(\'\\\\\', \'/\', $s);'), $dirfiles));
$plugins = array_merge($plugins, $dirfiles);
}
}
ksort($plugins);
return $plugins;
}
示例13: cleaner
/**
* Delete old logs
*/
private function cleaner()
{
$deletedFiles = 0;
$deletedDirs = 0;
/**
* Clean the logs' directory according to configuration data
*/
$flush = Options::get('clickheat__flush');
if ($flush >= 0) {
$logs = Utils::glob($this->logs . "/*/*.log");
$oldestDate = mktime(0, 0, 0, date('m'), date('d') - $flush, date('Y'));
$deletedAll = array();
foreach ($logs as $log) {
// dont process .htaccess
if (count(explode('.', $log)) !== 2) {
continue;
}
$dir = dirname($log);
if (!isset($deletedAll[$dir])) {
$deletedAll[$dir] = true;
}
if (filemtime($log) <= $oldestDate) {
@unlink($log);
$deletedFiles++;
continue;
}
$deletedAll[$dir] = false;
}
/**
* If every log file (but the url.txt) has been deleted,
* then we should delete the directory too
*/
foreach ($deletedAll as $dir => $do) {
if ($do === true) {
@unlink($dir . '/url.xml');
$deletedFiles++;
@rmdir($dir);
$deletedDirs++;
}
}
}
/**
* Clean the cache directory for every file older than 2 minutes
* 2 minutes is to make sure images are kept up to date with all
* new clicks.
*/
$glob = Utils::glob($this->cache . "/*");
foreach ($glob as $file) {
$ext = explode('.', $file);
// dont process .htaccess
if (count($ext) !== 2) {
continue;
}
$filemtime = filemtime($file);
switch ($ext[1]) {
case 'html':
case 'png':
case 'png_temp':
case 'png_log':
if ($filemtime + 86400 < time()) {
@unlink($file);
$deletedFiles++;
}
}
}
// Did we delete anything?
if ($deletedDirs + $deletedFiles === 0) {
return 'OK';
} else {
return sprintf(_t("Cleaning finished: %d files and %d directories have been deleted"), $deletedFiles, $deletedDirs);
}
}
示例14: load_available_reports
/**
* Load in all available reports
* @return array array of available report files
**/
private function load_available_reports()
{
$valid_reports = array();
$reports = array();
$templates = array();
$searchdirs = array(dirname(__FILE__) . '/default', dirname(__FILE__) . '/custom');
$dirs = array();
foreach ($searchdirs as $searchdir) {
if (file_exists($searchdir)) {
$dirs = array_merge($dirs, Utils::glob($searchdir . '*', GLOB_ONLYDIR | GLOB_MARK));
}
}
// Load in the available reports and templates
foreach ($dirs as $dir) {
$reportfiles = Utils::glob($dir . '*.xml');
$templatefiles = Utils::glob($dir . '*.php');
if (!empty($reportfiles)) {
$reportfiles = array_combine(array_map('basename', $reportfiles), array_map(create_function('$s', 'return str_replace(\'\\\\\', \'/\', $s);'), $reportfiles));
$reports = array_merge($reports, $reportfiles);
}
if (!empty($templatefiles)) {
$templatefiles = array_combine(array_map('basename', $templatefiles), array_map(create_function('$s', 'return str_replace(\'\\\\\', \'/\', $s);'), $templatefiles));
$templates = array_merge($templates, $templatefiles);
}
}
// Now go through and generate our valid_reports()
foreach ($reports as $rptKey => $rptVal) {
$tmpKey = array_search(str_replace('.xml', '.php', $rptVal), $templates);
if ($tmpKey) {
$key = basename($rptVal, ".xml");
$valid_reports[$key] = array('xml' => $rptVal, 'template' => $templates[$tmpKey]);
}
}
ksort($valid_reports);
return $valid_reports;
}
示例15: get_theme
/**
* Retreive the Theme used to display the form component
*
* @param boolean $forvalidation If true, perform validation on control and add error messages to output
* @param FormControl $control The control to output using a template
* @return Theme The theme object to display the template for the control
*/
function get_theme($forvalidation = false, $control = null)
{
if (!isset($this->theme_obj)) {
$theme_dir = Plugins::filter('control_theme_dir', Plugins::filter('admin_theme_dir', Site::get_dir('admin_theme', true)) . 'formcontrols/', $control);
$this->theme_obj = Themes::create();
// Create the current theme instead of: 'admin', 'RawPHPEngine', $theme_dir
// Add the templates for the form controls tothe current theme,
// and allow any matching templates from the current theme to override
$formcontrol_templates = Utils::glob($theme_dir . '*.php');
foreach ($formcontrol_templates as $template) {
$template_name = basename($template, '.php');
$this->theme_obj->add_template($template_name, $template);
}
$list = array();
$list = Plugins::filter('available_templates', $list);
foreach ($list as $template_name) {
if ($template = Plugins::filter('include_template_file', null, $template_name)) {
$this->theme_obj->add_template($template_name, $template);
}
}
}
$this->theme_obj->start_buffer();
if ($control instanceof FormControl) {
// PHP doesn't allow __get() to return pointers, and passing this array to foreach directly generates an error.
$properties = $control->properties;
foreach ($properties as $name => $value) {
$this->theme_obj->{$name} = $value;
}
$this->theme_obj->field = $control->field;
$this->theme_obj->value = $control->value;
$this->theme_obj->caption = $control->caption;
$this->theme_obj->id = (string) $control->id;
$class = (array) $control->class;
$message = '';
if ($forvalidation) {
$validate = $control->validate();
if (count($validate) != 0) {
$class[] = 'invalid';
$message = implode('<br>', (array) $validate);
}
}
$this->theme_obj->class = implode(' ', (array) $class);
$this->theme_obj->message = $message;
}
return $this->theme_obj;
}