mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-17 07:10:48 +03:00
fix use of function GLOB
This commit is contained in:
parent
0f43cfa37b
commit
04dc8a120a
|
@ -136,7 +136,7 @@ if($aPluginsList=@file($sPluginsListFile)) {
|
||||||
$aPluginsList=array_map('trim',$aPluginsList);
|
$aPluginsList=array_map('trim',$aPluginsList);
|
||||||
foreach ($aPluginsList as $sPlugin) {
|
foreach ($aPluginsList as $sPlugin) {
|
||||||
$aConfigFiles = glob($sPluginsDir.'/'.$sPlugin.'/config/*.php');
|
$aConfigFiles = glob($sPluginsDir.'/'.$sPlugin.'/config/*.php');
|
||||||
if(count($aConfigFiles)>0) {
|
if($aConfigFiles and count($aConfigFiles)>0) {
|
||||||
$aConfig=array();
|
$aConfig=array();
|
||||||
foreach ($aConfigFiles as $sPath) {
|
foreach ($aConfigFiles as $sPath) {
|
||||||
$aConfig = include($sPath);
|
$aConfig = include($sPath);
|
||||||
|
|
|
@ -51,16 +51,17 @@ abstract class ActionPlugin extends Action {
|
||||||
* Проверяем в списке шаблонов
|
* Проверяем в списке шаблонов
|
||||||
*/
|
*/
|
||||||
$aMatches[1]=strtolower($aMatches[1]);
|
$aMatches[1]=strtolower($aMatches[1]);
|
||||||
$sTemplateName=in_array(
|
$aPaths=glob(Config::Get('path.root.server').'/plugins/'.$aMatches[1].'/templates/skin/*/actions/Action'.ucfirst($aMatches[2]),GLOB_ONLYDIR);
|
||||||
|
$sTemplateName=($aPaths and in_array(
|
||||||
Config::Get('view.skin'),
|
Config::Get('view.skin'),
|
||||||
array_map(
|
array_map(
|
||||||
create_function(
|
create_function(
|
||||||
'$sPath',
|
'$sPath',
|
||||||
'preg_match("/skin\/([\w]+)\/actions/i",$sPath,$aMatches); return $aMatches[1];'
|
'preg_match("/skin\/([\w]+)\/actions/i",$sPath,$aMatches); return $aMatches[1];'
|
||||||
),
|
),
|
||||||
glob(Config::Get('path.root.server').'/plugins/'.$aMatches[1].'/templates/skin/*/actions/Action'.ucfirst($aMatches[2]),GLOB_ONLYDIR)
|
$aPaths
|
||||||
)
|
)
|
||||||
)
|
))
|
||||||
? Config::Get('view.skin')
|
? Config::Get('view.skin')
|
||||||
: 'default';
|
: 'default';
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,8 @@ abstract class Plugin extends Object {
|
||||||
? strtolower($aMatches[1])
|
? strtolower($aMatches[1])
|
||||||
: strtolower($sName);
|
: strtolower($sName);
|
||||||
if(!isset(self::$aTemplatePath[$sName])) {
|
if(!isset(self::$aTemplatePath[$sName])) {
|
||||||
$sTemplateName=in_array(Config::Get('view.skin'),array_map('basename',glob(Config::Get('path.root.server').'/plugins/'.$sName.'/templates/skin/*',GLOB_ONLYDIR)))
|
$aPaths=glob(Config::Get('path.root.server').'/plugins/'.$sName.'/templates/skin/*',GLOB_ONLYDIR);
|
||||||
|
$sTemplateName=($aPaths and in_array(Config::Get('view.skin'),array_map('basename',$aPaths)))
|
||||||
? Config::Get('view.skin')
|
? Config::Get('view.skin')
|
||||||
: 'default';
|
: 'default';
|
||||||
|
|
||||||
|
@ -208,7 +209,8 @@ abstract class Plugin extends Object {
|
||||||
? strtolower($aMatches[1])
|
? strtolower($aMatches[1])
|
||||||
: strtolower($sName);
|
: strtolower($sName);
|
||||||
if(!isset(self::$aTemplateWebPath[$sName])) {
|
if(!isset(self::$aTemplateWebPath[$sName])) {
|
||||||
$sTemplateName=in_array(Config::Get('view.skin'),array_map('basename',glob(Config::Get('path.root.server').'/plugins/'.$sName.'/templates/skin/*',GLOB_ONLYDIR)))
|
$aPaths=glob(Config::Get('path.root.server').'/plugins/'.$sName.'/templates/skin/*',GLOB_ONLYDIR);
|
||||||
|
$sTemplateName=($aPaths and in_array(Config::Get('view.skin'),array_map('basename',$aPaths)))
|
||||||
? Config::Get('view.skin')
|
? Config::Get('view.skin')
|
||||||
: 'default';
|
: 'default';
|
||||||
|
|
||||||
|
|
|
@ -249,15 +249,15 @@ function func_rmdir($sPath) {
|
||||||
if(!is_dir($sPath)) return true;
|
if(!is_dir($sPath)) return true;
|
||||||
$sPath = rtrim($sPath,'/').'/';
|
$sPath = rtrim($sPath,'/').'/';
|
||||||
|
|
||||||
$aFiles = glob($sPath.'*', GLOB_MARK);
|
if ($aFiles = glob($sPath.'*', GLOB_MARK)) {
|
||||||
foreach($aFiles as $sFile ) {
|
foreach($aFiles as $sFile ) {
|
||||||
if(substr($sFile, -1) == '/') {
|
if(substr($sFile, -1) == '/') {
|
||||||
func_rmdir($sFile);
|
func_rmdir($sFile);
|
||||||
} else {
|
} else {
|
||||||
@unlink($sFile);
|
@unlink($sFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(is_dir($sPath)) @rmdir($sPath);
|
if(is_dir($sPath)) @rmdir($sPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,40 +72,40 @@ class LsPlugin extends Module {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function GetList() {
|
public function GetList() {
|
||||||
$aList=array_map('basename',glob($this->sPluginsDir.'*',GLOB_ONLYDIR));
|
if ($aPaths=glob($this->sPluginsDir.'*',GLOB_ONLYDIR)) {
|
||||||
$aActivePlugins=$this->GetActivePlugins();
|
$aList=array_map('basename',$aPaths);
|
||||||
|
$aActivePlugins=$this->GetActivePlugins();
|
||||||
foreach($aList as $sPlugin) {
|
foreach($aList as $sPlugin) {
|
||||||
$this->aPluginsList[$sPlugin] = array(
|
$this->aPluginsList[$sPlugin] = array(
|
||||||
'code' => $sPlugin,
|
'code' => $sPlugin,
|
||||||
'is_active' => in_array($sPlugin,$aActivePlugins)
|
'is_active' => in_array($sPlugin,$aActivePlugins)
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
* Считываем данные из XML файла описания
|
|
||||||
*/
|
|
||||||
$sPluginXML = $this->sPluginsDir.$sPlugin.'/'.self::PLUGIN_XML_FILE;
|
|
||||||
if($oXml = @simplexml_load_file($sPluginXML)) {
|
|
||||||
/**
|
/**
|
||||||
* Обрабатываем данные, считанные из XML-описания
|
* Считываем данные из XML файла описания
|
||||||
*/
|
*/
|
||||||
$sLang=$this->Lang_GetLang();
|
$sPluginXML = $this->sPluginsDir.$sPlugin.'/'.self::PLUGIN_XML_FILE;
|
||||||
|
if($oXml = @simplexml_load_file($sPluginXML)) {
|
||||||
|
/**
|
||||||
|
* Обрабатываем данные, считанные из XML-описания
|
||||||
|
*/
|
||||||
|
$sLang=$this->Lang_GetLang();
|
||||||
|
|
||||||
$this->Xlang($oXml,'name',$sLang);
|
$this->Xlang($oXml,'name',$sLang);
|
||||||
$this->Xlang($oXml,'author',$sLang);
|
$this->Xlang($oXml,'author',$sLang);
|
||||||
$this->Xlang($oXml,'description',$sLang);
|
$this->Xlang($oXml,'description',$sLang);
|
||||||
$oXml->homepage=$this->Text_Parser($oXml->homepage);
|
$oXml->homepage=$this->Text_Parser($oXml->homepage);
|
||||||
|
|
||||||
$this->aPluginsList[$sPlugin]['property']=$oXml;
|
$this->aPluginsList[$sPlugin]['property']=$oXml;
|
||||||
} else {
|
} else {
|
||||||
/**
|
/**
|
||||||
* Если XML-файл описания отсутствует, или не является валидным XML,
|
* Если XML-файл описания отсутствует, или не является валидным XML,
|
||||||
* удаляем плагин из списка
|
* удаляем плагин из списка
|
||||||
*/
|
*/
|
||||||
unset($this->aPluginsList[$sPlugin]);
|
unset($this->aPluginsList[$sPlugin]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->aPluginsList;
|
return $this->aPluginsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,8 @@ class TemplateCacheCleanCron extends Cron {
|
||||||
/**
|
/**
|
||||||
* Выбираем все файлы кеша
|
* Выбираем все файлы кеша
|
||||||
*/
|
*/
|
||||||
$aFiles = (array)glob($sDir. DIRECTORY_SEPARATOR ."*.{css,js}", GLOB_BRACE);
|
$aFiles = glob($sDir. DIRECTORY_SEPARATOR ."*.{css,js}", GLOB_BRACE);
|
||||||
|
if (!$aFiles) $aFiles=array();
|
||||||
|
|
||||||
print PHP_EOL."Cache files count: ".count($aFiles);
|
print PHP_EOL."Cache files count: ".count($aFiles);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue