mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 15:14:58 +00:00
Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
commit
4e5fefa4ba
|
@ -51,6 +51,12 @@ class SeedDMS_Extension_Mgr {
|
|||
*/
|
||||
protected $cachedir;
|
||||
|
||||
/**
|
||||
* @var array $configcache cached result of checkExtensionByName()
|
||||
* @access protected
|
||||
*/
|
||||
protected $configcache;
|
||||
|
||||
/**
|
||||
* @var string[] $errmsg list of error message from last operation
|
||||
* @access protected
|
||||
|
@ -104,6 +110,7 @@ class SeedDMS_Extension_Mgr {
|
|||
* is given
|
||||
*/
|
||||
public function __construct($extdir = '', $cachedir = '', $reposurl = '', $proxyurl='', $proxyuser='', $proxypass='') { /* {{{ */
|
||||
$this->configcache = [];
|
||||
$this->cachedir = $cachedir;
|
||||
$this->extdir = $extdir;
|
||||
$this->reposurl = $reposurl;
|
||||
|
@ -325,18 +332,9 @@ class SeedDMS_Extension_Mgr {
|
|||
return $ret;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Check content of extension directory or configuration of extension
|
||||
*
|
||||
* @param string|array $dir full path to extension directory or extension name
|
||||
* or an array containing the configuration.
|
||||
* @param boolean $noconstraints set to true if constraints to local seeddms
|
||||
* installation shall not be checked.
|
||||
*/
|
||||
public function checkExtension($dir, $options=array()) { /* {{{ */
|
||||
public function checkExtensionByDir($dir, $options = array()) { /* {{{ */
|
||||
$this->errmsgs = array();
|
||||
|
||||
if(is_string($dir)) {
|
||||
if(!file_exists($dir)) {
|
||||
if(!file_exists($this->extdir.'/'.$dir))
|
||||
return false;
|
||||
|
@ -359,13 +357,40 @@ class SeedDMS_Extension_Mgr {
|
|||
}
|
||||
|
||||
$extconf = $EXT_CONF[$extname];
|
||||
} elseif(is_array($dir)) {
|
||||
$extconf = $dir;
|
||||
/* If just the configuration is passed, then there is no way to check
|
||||
* for existence of files.
|
||||
*/
|
||||
$options['nofiles'] = true;
|
||||
|
||||
if(!empty($extconf['language']['file']) && !file_exists($dir."/".$extconf['language']['file'])) {
|
||||
$this->errmsgs[] = "Missing language file";
|
||||
}
|
||||
if(!empty($extconf['class']['file']) && !file_exists($dir."/".$extconf['class']['file'])) {
|
||||
$this->errmsgs[] = "Missing class file";
|
||||
}
|
||||
if(!empty($extconf['icon']) && !file_exists($dir."/".$extconf['icon'])) {
|
||||
$this->errmsgs[] = "Missing icon file";
|
||||
}
|
||||
|
||||
if($this->errmsgs)
|
||||
return false;
|
||||
|
||||
return self::checkExtensionByName($extname, $extconf, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check content of extension directory or configuration of extension
|
||||
*
|
||||
* @param string|array $dir full path to extension directory or extension name
|
||||
* or an array containing the configuration.
|
||||
* @param array $options array with options elements 'noconstraints' and 'nofiles'.
|
||||
* Set 'noconstraints' to true if
|
||||
* constraints to local seeddms installation shall not be checked. Set 'nofiles'
|
||||
* to true to turn off checking of files
|
||||
* @return boolean true if check was successful, otherwise false
|
||||
*/
|
||||
public function checkExtensionByName($extname, $extconf, $options=array()) { /* {{{ */
|
||||
if(isset($this->configcache[$extname])) {
|
||||
return $this->configcache[$extname];
|
||||
}
|
||||
|
||||
$this->errmsgs = array();
|
||||
|
||||
if(!isset($extconf['constraints']['depends']['seeddms'])) {
|
||||
$this->errmsgs[] = "Missing dependency on SeedDMS";
|
||||
|
@ -382,17 +407,6 @@ class SeedDMS_Extension_Mgr {
|
|||
if(!isset($extconf['author'])) {
|
||||
$this->errmsgs[] = "Missing author";
|
||||
}
|
||||
if(!isset($options['nofiles']) || $options['nofiles'] == false) {
|
||||
if(!empty($extconf['language']['file']) && !file_exists($dir."/".$extconf['language']['file'])) {
|
||||
$this->errmsgs[] = "Missing language file";
|
||||
}
|
||||
if(!empty($extconf['class']['file']) && !file_exists($dir."/".$extconf['class']['file'])) {
|
||||
$this->errmsgs[] = "Missing class file";
|
||||
}
|
||||
if(!empty($extconf['icon']) && !file_exists($dir."/".$extconf['icon'])) {
|
||||
$this->errmsgs[] = "Missing icon file";
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($options['noconstraints']) || $options['noconstraints'] == false) {
|
||||
if(isset($extconf['constraints']['depends'])) {
|
||||
|
@ -446,9 +460,11 @@ class SeedDMS_Extension_Mgr {
|
|||
}
|
||||
|
||||
if($this->errmsgs)
|
||||
return false;
|
||||
$this->configcache[$extname] = false;
|
||||
else
|
||||
$this->configcache[$extname] = true;
|
||||
|
||||
return true;
|
||||
return $this->configcache[$extname];
|
||||
} /* }}} */
|
||||
|
||||
static protected function rrmdir($dir) { /* {{{ */
|
||||
|
@ -498,7 +514,7 @@ class SeedDMS_Extension_Mgr {
|
|||
// exec($cmd);
|
||||
|
||||
/* Check if extension is complete and fullfills the constraints */
|
||||
if(!self::checkExtension($newdir)) {
|
||||
if(!self::checkExtensionByDir($newdir)) {
|
||||
self::rrmdir($newdir);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ class UI extends UI_Default {
|
|||
$decorators = array();
|
||||
foreach($extMgr->getExtensionConfiguration() as $extname=>$extconf) {
|
||||
if(!$settings->extensionIsDisabled($extname)) {
|
||||
if($extMgr->checkExtension($extconf)) {
|
||||
if($extMgr->checkExtensionByName($extname, $extconf)) {
|
||||
if(isset($extconf['decorators'][$class])) {
|
||||
$filename = $settings->_rootDir.'ext/'.$extname.'/decorators/'.$theme."/".$extconf['decorators'][$class]['file'];
|
||||
if(file_exists($filename)) {
|
||||
|
@ -73,7 +73,7 @@ class UI extends UI_Default {
|
|||
$httpbasedir = '';
|
||||
foreach($extMgr->getExtensionConfiguration() as $extname=>$extconf) {
|
||||
if(!$settings->extensionIsDisabled($extname)) {
|
||||
if($extMgr->checkExtension($extconf)) {
|
||||
if($extMgr->checkExtensionByName($extname, $extconf)) {
|
||||
/* Setting the 'views' element in the configuration can be used to
|
||||
* replace an existing view in views/bootstrap/, e.g. class.ViewFolder.php
|
||||
* without providing an out/out.ViewFolder.php. In that case $httpbasedir
|
||||
|
|
|
@ -26,9 +26,10 @@ $version = new SeedDMS_Version;
|
|||
foreach($extMgr->getExtensionConfiguration() as $extname=>$extconf) {
|
||||
if(!$settings->extensionIsDisabled($extname)) {
|
||||
$disabled = true;
|
||||
if($extMgr->checkExtension($extconf)) {
|
||||
if($extMgr->checkExtensionByName($extname, $extconf)) {
|
||||
$disabled = false;
|
||||
} else {
|
||||
$settings->disableExtension($extname);
|
||||
// echo $extMgr->getErrorMsg();
|
||||
}
|
||||
/* check for requirements */
|
||||
|
|
Loading…
Reference in New Issue
Block a user