本文整理汇总了PHP中SpoonFile::getList方法的典型用法代码示例。如果您正苦于以下问题:PHP SpoonFile::getList方法的具体用法?PHP SpoonFile::getList怎么用?PHP SpoonFile::getList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpoonFile
的用法示例。
在下文中一共展示了SpoonFile::getList方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cleanupCache
/**
* Cleanup cache files
*/
private function cleanupCache()
{
$files = SpoonFile::getList($this->cachePath);
foreach ($files as $file) {
$fileinfo = SpoonFile::getInfo($this->cachePath . '/' . $file);
// delete file if more than 1 week old
if ($fileinfo['modification_date'] < strtotime('-1 week')) {
SpoonFile::delete($this->cachePath . '/' . $file);
}
}
}
示例2: cleanupCache
/**
* Cleanup cache files
*
* @return void
*/
private function cleanupCache()
{
// get cache files
$files = SpoonFile::getList($this->cachePath);
// loop items
foreach ($files as $file) {
// get info
$fileinfo = SpoonFile::getInfo($this->cachePath . '/' . $file);
// file is more than one week old
if ($fileinfo['modification_date'] < strtotime('-1 week')) {
// delete file
SpoonFile::delete($this->cachePath . '/' . $file);
}
}
}
示例3: getTemplates
/**
* Get templates.
*
* @return array
*/
public static function getTemplates()
{
// fetch templates available in core
$templates = SpoonFile::getList(FRONTEND_MODULES_PATH . '/content_blocks/layout/widgets', '/.*?\\.tpl/');
// fetch current active theme
$theme = BackendModel::getModuleSetting('core', 'theme', 'core');
// fetch theme templates if a theme is selected
if ($theme != 'core') {
$templates = array_merge($templates, SpoonFile::getList(FRONTEND_PATH . '/themes/' . $theme . '/modules/content_blocks/layout/widgets', '/.*?\\.tpl/'));
}
// no duplicates (core templates will be overridden by theme templates) and sort alphabetically
$templates = array_unique($templates);
sort($templates);
return $templates;
}
示例4: clearCompiled
/**
* Clear the entire compiled directory or a specific template.
*
* @param string[optional] $template The filename of a specific template to mark for recompiling.
*/
public function clearCompiled($template = null)
{
// specific template
if ($template !== null) {
SpoonFile::delete($this->compileDirectory . '/' . $this->getCompileName($template));
} else {
// list of *.tpl.php files from compileDirectory
$files = SpoonFile::getList($this->compileDirectory, '|.*\\.tpl\\.php|');
// delete
foreach ($files as $file) {
SpoonFile::delete($this->compileDirectory . '/' . $file);
}
}
}
示例5: setAction
/**
* Set the action
*
* We can't rely on the parent setModule function, because a cronjob requires no login
*
* @param string $action The action to load.
* @param string[optional] $module The module to load.
*/
public function setAction($action, $module = null)
{
// set module
if ($module !== null) {
$this->setModule($module);
}
// check if module is set
if ($this->getModule() === null) {
throw new BackendException('Module has not yet been set.');
}
// path to look for actions based on the module
if ($this->getModule() == 'core') {
$path = BACKEND_CORE_PATH . '/cronjobs';
} else {
$path = BACKEND_MODULES_PATH . '/' . $this->getModule() . '/cronjobs';
}
// does this module exist?
$actions = SpoonFile::getList($path);
if (!in_array($action . '.php', $actions)) {
// set correct headers
SpoonHTTP::setHeadersByCode(403);
// throw exception
throw new BackendException('Action not allowed.');
}
// set property
$this->action = (string) $action;
}
示例6: removeCacheFiles
/**
* Remove all cache files
*
* @return void
*/
public static function removeCacheFiles()
{
// get path
$cachePath = BACKEND_CACHE_PATH . '/analytics';
// loop all cache files
foreach (SpoonFile::getList($cachePath) as $file) {
SpoonFile::delete($cachePath . '/' . $file);
}
}
示例7: deleteCachedData
/**
* Delete the cached data
*/
private function deleteCachedData()
{
// init some vars
$foldersToLoop = array('/backend/cache', '/frontend/cache');
$foldersToIgnore = array('/backend/cache/navigation');
$filesToIgnore = array('.gitignore');
$filesToDelete = array();
// loop folders
foreach ($foldersToLoop as $folder) {
// get folderlisting
$subfolders = (array) SpoonDirectory::getList(PATH_WWW . $folder, false, array('.svn', '.gitignore'));
// loop folders
foreach ($subfolders as $subfolder) {
// not in ignore list?
if (!in_array($folder . '/' . $subfolder, $foldersToIgnore)) {
// get the filelisting
$files = (array) SpoonFile::getList(PATH_WWW . $folder . '/' . $subfolder);
// loop the files
foreach ($files as $file) {
if (!in_array($file, $filesToIgnore)) {
$filesToDelete[] = PATH_WWW . $folder . '/' . $subfolder . '/' . $file;
}
}
}
}
}
// delete cached files
if (!empty($filesToDelete)) {
// loop files and delete them
foreach ($filesToDelete as $file) {
SpoonFile::delete($file);
}
}
}
示例8: getWidgets
/**
* Get the widgets
*
* @return void
*/
private function getWidgets()
{
// get all active modules
$modules = BackendModel::getModules(true);
// loop all modules
foreach ($modules as $module) {
// you have sufficient rights?
if (BackendAuthentication::isAllowedModule($module)) {
// build pathName
$pathName = BACKEND_MODULES_PATH . '/' . $module;
// check if the folder exists
if (SpoonDirectory::exists($pathName . '/widgets')) {
// get widgets
$widgets = (array) SpoonFile::getList($pathName . '/widgets', '/(.*)\\.php/i');
// loop through widgets
foreach ($widgets as $widget) {
// require the classes
require_once $pathName . '/widgets/' . $widget;
// init var
$widgetName = str_replace('.php', '', $widget);
// build classname
$className = 'Backend' . SpoonFilter::toCamelCase($module) . 'Widget' . SpoonFilter::toCamelCase($widgetName);
// validate if the class exists
if (!class_exists($className)) {
// throw exception
throw new BackendException('The widgetfile is present, but the classname should be: ' . $className . '.');
} else {
// add to array
$this->widgetInstances[] = array('module' => $module, 'widget' => $widgetName, 'className' => $className);
// create reflection class
$reflection = new ReflectionClass('Backend' . SpoonFilter::toCamelCase($module) . 'Widget' . SpoonFilter::toCamelCase($widgetName));
// get the offset
$offset = strpos($reflection->getDocComment(), '*', 7);
// get the first sentence
$description = substr($reflection->getDocComment(), 0, $offset);
// replacements
$description = str_replace('*', '', $description);
$description = trim(str_replace('/', '', $description));
}
// check if model file exists
if (SpoonFile::exists($pathName . '/engine/model.php')) {
// require model
require_once $pathName . '/engine/model.php';
}
// add to array
$this->widgets[] = array('label' => SpoonFilter::toCamelCase($widgetName), 'value' => $widgetName, 'description' => $description);
}
}
}
}
}
示例9: setPossibleActions
/**
* Set the possible actions, based on files in folder
* You can disable action in the config file. (Populate $disabledActions)
*
* @return void
*/
protected function setPossibleActions()
{
// get filelist (only those with .php-extension)
$actionFiles = (array) SpoonFile::getList(BACKEND_MODULE_PATH . '/actions', '/(.*).php/');
// loop filelist
foreach ($actionFiles as $file) {
// get action by removing the extension, actions should not contain spaces (use _ instead)
$action = strtolower(str_replace('.php', '', $file));
// if the action isn't disabled add it to the possible actions
if (!in_array($action, $this->disabledActions)) {
$this->possibleActions[$file] = $action;
}
}
// get filelist (only those with .php-extension)
$AJAXActionFiles = (array) SpoonFile::getList(BACKEND_MODULE_PATH . '/ajax', '/(.*).php/');
// loop filelist
foreach ($AJAXActionFiles as $file) {
// get action by removing the extension, actions should not contain spaces (use _ instead)
$action = strtolower(str_replace('.php', '', $file));
// if the action isn't disabled add it to the possible actions
if (!in_array($action, $this->disabledAJAXActions)) {
$this->possibleAJAXActions[$file] = $action;
}
}
}
示例10: addSearchIndex
/**
* Add a search index
*
* @param string $module The module wherin will be searched.
* @param int $otherId The id of the record.
* @param array $fields A key/value pair of fields to index.
* @param string[optional] $language The frontend language for this entry.
*/
protected function addSearchIndex($module, $otherId, array $fields, $language)
{
// get db
$db = $this->getDB();
// validate cache
if (empty(self::$modules)) {
// get all modules
self::$modules = (array) $db->getColumn('SELECT m.name FROM modules AS m');
}
// module exists?
if (!in_array('search', self::$modules)) {
return;
}
// no fields?
if (empty($fields)) {
return;
}
// insert search index
foreach ($fields as $field => $value) {
// reformat value
$value = strip_tags((string) $value);
// insert in db
$db->execute('INSERT INTO search_index (module, other_id, language, field, value, active)
VALUES (?, ?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE value = ?, active = ?', array((string) $module, (int) $otherId, (string) $language, (string) $field, $value, 'Y', $value, 'Y'));
}
// invalidate the cache for search
foreach (SpoonFile::getList(FRONTEND_CACHE_PATH . '/search/') as $file) {
SpoonFile::delete(FRONTEND_CACHE_PATH . '/search/' . $file);
}
}
示例11: clearCache
/**
* Clear all applications cache.
*
* Note: we do not need to rebuild anything, the core will do this when noticing the cache files are missing.
*/
public static function clearCache()
{
// list of cache files to be deleted
$filesToDelete = array();
// backend navigation
$filesToDelete[] = BACKEND_CACHE_PATH . '/navigation/navigation.php';
// backend locale
foreach (SpoonFile::getList(BACKEND_CACHE_PATH . '/locale', '/\\.php$/') as $file) {
$filesToDelete[] = BACKEND_CACHE_PATH . '/locale/' . $file;
}
// frontend navigation
foreach (SpoonFile::getList(FRONTEND_CACHE_PATH . '/navigation', '/\\.(php|js)$/') as $file) {
$filesToDelete[] = FRONTEND_CACHE_PATH . '/navigation/' . $file;
}
// frontend locale
foreach (SpoonFile::getList(FRONTEND_CACHE_PATH . '/locale', '/\\.php$/') as $file) {
$filesToDelete[] = FRONTEND_CACHE_PATH . '/locale/' . $file;
}
// delete the files
foreach ($filesToDelete as $file) {
SpoonFile::delete($file);
}
}
示例12: invalidateFrontendCache
/**
* Invalidate cache
*
* @return void
* @param string[optional] $module A specific module to clear the cache for.
* @param string[optional] $language The language to use.
*/
public static function invalidateFrontendCache($module = null, $language = null)
{
// redefine
$module = $module !== null ? (string) $module : null;
$language = $language !== null ? (string) $language : null;
// get cache path
$path = FRONTEND_CACHE_PATH . '/cached_templates';
// build regular expresion
if ($module !== null) {
if ($language !== null) {
$regexp = '/' . '(.*)' . $module . '(.*)_cache\\.tpl/i';
} else {
$regexp = '/' . $language . '_' . $module . '(.*)_cache\\.tpl/i';
}
} else {
if ($language !== null) {
$regexp = '/(.*)_cache\\.tpl/i';
} else {
$regexp = '/' . $language . '_(.*)_cache\\.tpl/i';
}
}
// get files to delete
$files = SpoonFile::getList($path, $regexp);
// delete files
foreach ($files as $file) {
SpoonFile::delete($path . '/' . $file);
}
}
示例13: invalidateCache
/**
* Invalidate search cache
*/
public static function invalidateCache()
{
foreach (SpoonFile::getList(FRONTEND_CACHE_PATH . '/search/') as $file) {
SpoonFile::delete(FRONTEND_CACHE_PATH . '/search/' . $file);
}
}
示例14: loadData
/**
* Load the data
*/
private function loadData()
{
// get all modules
$modules = BackendModel::getModules();
// get user sequence
$userSequence = BackendAuthentication::getUser()->getSetting('dashboard_sequence');
// user sequence does not exist?
if (!isset($userSequence)) {
// get group ID of user
$groupId = BackendAuthentication::getUser()->getGroupId();
// get group preset
$userSequence = BackendGroupsModel::getSetting($groupId, 'dashboard_sequence');
}
// loop all modules
foreach ($modules as $module) {
// you have sufficient rights?
if (BackendAuthentication::isAllowedModule($module)) {
// build pathName
$pathName = BACKEND_MODULES_PATH . '/' . $module;
// check if the folder exists
if (SpoonDirectory::exists($pathName . '/widgets')) {
// get widgets
$widgets = (array) SpoonFile::getList($pathName . '/widgets', '/(.*)\\.php/i');
// loop widgets
foreach ($widgets as $widget) {
// require the class
require_once $pathName . '/widgets/' . $widget;
// init var
$widgetName = str_replace('.php', '', $widget);
// build classname
$className = 'Backend' . SpoonFilter::toCamelCase($module) . 'Widget' . SpoonFilter::toCamelCase($widgetName);
// validate if the class exists
if (!class_exists($className)) {
throw new BackendException('The widgetfile is present, but the classname should be: ' . $className . '.');
}
// check if model file exists
if (SpoonFile::exists($pathName . '/engine/model.php')) {
// require model
require_once $pathName . '/engine/model.php';
}
// present?
$present = isset($userSequence[$module][$widgetName]['present']) ? $userSequence[$module][$widgetName]['present'] : false;
// if not present, continue
if (!$present) {
continue;
}
// create instance
$instance = new $className();
// has rights
if (!$instance->isAllowed()) {
continue;
}
// hidden?
$hidden = isset($userSequence[$module][$widgetName]['hidden']) ? $userSequence[$module][$widgetName]['hidden'] : false;
// execute instance if it is not hidden
if (!$hidden) {
$instance->execute();
}
// user sequence provided?
$column = isset($userSequence[$module][$widgetName]['column']) ? $userSequence[$module][$widgetName]['column'] : $instance->getColumn();
$position = isset($userSequence[$module][$widgetName]['position']) ? $userSequence[$module][$widgetName]['position'] : $instance->getPosition();
$title = SpoonFilter::ucfirst(BL::lbl(SpoonFilter::toCamelCase($module))) . ': ' . BL::lbl(SpoonFilter::toCamelCase($widgetName));
$templatePath = $instance->getTemplatePath();
// reset template path
if ($templatePath == null) {
$templatePath = BACKEND_PATH . '/modules/' . $module . '/layout/widgets/' . $widgetName . '.tpl';
}
// build item
$item = array('template' => $templatePath, 'module' => $module, 'widget' => $widgetName, 'title' => $title, 'hidden' => $hidden);
// add on new position if no position is set or if the position is already used
if ($position === null || isset($this->widgets[$column][$position])) {
$this->widgets[$column][] = $item;
} else {
$this->widgets[$column][$position] = $item;
}
}
}
}
}
// sort the widgets
foreach ($this->widgets as &$column) {
ksort($column);
}
}