mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 15:14:58 +00:00
checkExtension() can also check with the configuration array
This commit is contained in:
parent
f386e83f2e
commit
0a3d3ea382
|
@ -174,36 +174,46 @@ class SeedDMS_Extension_Mgr {
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check content of extension directory
|
* Check content of extension directory or configuration of extension
|
||||||
*
|
*
|
||||||
* @param string $dir full path to extension directory or extension name
|
* @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
|
* @param boolean $noconstraints set to true if constraints to local seeddms
|
||||||
* installation shall not be checked.
|
* installation shall not be checked.
|
||||||
*/
|
*/
|
||||||
public function checkExtension($dir, $noconstraints=false) { /* {{{ */
|
public function checkExtension($dir, $options=array()) { /* {{{ */
|
||||||
$this->errmsgs = array();
|
$this->errmsgs = array();
|
||||||
|
|
||||||
if(!file_exists($dir)) {
|
if(is_string($dir)) {
|
||||||
if(!file_exists($this->extdir.'/'.$dir))
|
if(!file_exists($dir)) {
|
||||||
|
if(!file_exists($this->extdir.'/'.$dir))
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
$dir = $this->extdir.'/'.$dir;
|
||||||
|
}
|
||||||
|
if(!file_exists($dir."/conf.php")) {
|
||||||
|
$this->errmsgs[] = "Missing extension configuration";
|
||||||
return false;
|
return false;
|
||||||
else
|
}
|
||||||
$dir = $this->extdir.'/'.$dir;
|
include($dir."/conf.php");
|
||||||
}
|
if(!isset($EXT_CONF)) {
|
||||||
if(!file_exists($dir."/conf.php")) {
|
$this->errmsgs[] = "Missing \$EXT_CONF in configuration";
|
||||||
$this->errmsgs[] = "Missing extension configuration";
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
$extname = key($EXT_CONF);
|
||||||
include($dir."/conf.php");
|
if(!$extname || !preg_match('/[a-zA-Z_]*/', $extname)) {
|
||||||
if(!isset($EXT_CONF)) {
|
return false;
|
||||||
$this->errmsgs[] = "Missing \$EXT_CONF in configuration";
|
}
|
||||||
return false;
|
|
||||||
}
|
$extconf = $EXT_CONF[$extname];
|
||||||
$extname = key($EXT_CONF);
|
} elseif(is_array($dir)) {
|
||||||
if(!$extname || !preg_match('/[a-zA-Z_]*/', $extname)) {
|
$extconf = $dir;
|
||||||
return false;
|
/* If just the configuration is passed, then there is no way to check
|
||||||
|
* for existence of files.
|
||||||
|
*/
|
||||||
|
$options['nofiles'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$extconf = $EXT_CONF[$extname];
|
|
||||||
if(!isset($extconf['constraints']['depends']['seeddms'])) {
|
if(!isset($extconf['constraints']['depends']['seeddms'])) {
|
||||||
$this->errmsgs[] = "Missing dependency on SeedDMS";
|
$this->errmsgs[] = "Missing dependency on SeedDMS";
|
||||||
}
|
}
|
||||||
|
@ -219,36 +229,40 @@ class SeedDMS_Extension_Mgr {
|
||||||
if(!isset($extconf['author'])) {
|
if(!isset($extconf['author'])) {
|
||||||
$this->errmsgs[] = "Missing author";
|
$this->errmsgs[] = "Missing author";
|
||||||
}
|
}
|
||||||
if(!empty($extconf['language']['file']) && !file_exists($dir."/".$extconf['language']['file'])) {
|
if(!isset($options['nofiles']) || $options['nofiles'] == false) {
|
||||||
$this->errmsgs[] = "Missing language file";
|
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['class']['file']) && !file_exists($dir."/".$extconf['class']['file'])) {
|
||||||
|
$this->errmsgs[] = "Missing class file";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$noconstraints && isset($extconf['constraints']['depends'])) {
|
if(!isset($options['noconstraints']) || $options['noconstraints'] == false) {
|
||||||
foreach($extconf['constraints']['depends'] as $dkey=>$dval) {
|
if(isset($extconf['constraints']['depends'])) {
|
||||||
switch($dkey) {
|
foreach($extconf['constraints']['depends'] as $dkey=>$dval) {
|
||||||
case 'seeddms':
|
switch($dkey) {
|
||||||
$version = new SeedDMS_Version;
|
case 'seeddms':
|
||||||
$tmp = explode('-', $dval, 2);
|
$version = new SeedDMS_Version;
|
||||||
if(self::cmpVersion($tmp[0], $version->version()) > 0 || ($tmp[1] && self::cmpVersion($tmp[1], $version->version()) < 0))
|
$tmp = explode('-', $dval, 2);
|
||||||
$this->errmsgs[] = sprintf("Incorrect SeedDMS version (needs version %s)", $extconf['constraints']['depends']['seeddms']);
|
if(self::cmpVersion($tmp[0], $version->version()) > 0 || ($tmp[1] && self::cmpVersion($tmp[1], $version->version()) < 0))
|
||||||
break;
|
$this->errmsgs[] = sprintf("Incorrect SeedDMS version (needs version %s)", $extconf['constraints']['depends']['seeddms']);
|
||||||
case 'php':
|
break;
|
||||||
$tmp = explode('-', $dval, 2);
|
case 'php':
|
||||||
if(self::cmpVersion($tmp[0], phpversion()) > 0 || ($tmp[1] && self::cmpVersion($tmp[1], phpversion()) < 0))
|
$tmp = explode('-', $dval, 2);
|
||||||
$this->errmsgs[] = sprintf("Incorrect PHP version (needs version %s)", $extconf['constraints']['depends']['php']);
|
if(self::cmpVersion($tmp[0], phpversion()) > 0 || ($tmp[1] && self::cmpVersion($tmp[1], phpversion()) < 0))
|
||||||
break;
|
$this->errmsgs[] = sprintf("Incorrect PHP version (needs version %s)", $extconf['constraints']['depends']['php']);
|
||||||
default:
|
break;
|
||||||
$tmp = explode('-', $dval, 2);
|
default:
|
||||||
if(isset($GLOBALS['EXT_CONF'][$dkey]['version'])) {
|
$tmp = explode('-', $dval, 2);
|
||||||
if(self::cmpVersion($tmp[0], $GLOBALS['EXT_CONF'][$dkey]['version']) > 0 || ($tmp[1] && self::cmpVersion($tmp[1], $GLOBALS['EXT_CONF'][$dkey]['version']) < 0))
|
if(isset($GLOBALS['EXT_CONF'][$dkey]['version'])) {
|
||||||
$this->errmsgs[] = sprintf("Incorrect version of extension '%s' (needs version '%s' but provides '%s')", $dkey, $dval, $GLOBALS['EXT_CONF'][$dkey]['version']);
|
if(self::cmpVersion($tmp[0], $GLOBALS['EXT_CONF'][$dkey]['version']) > 0 || ($tmp[1] && self::cmpVersion($tmp[1], $GLOBALS['EXT_CONF'][$dkey]['version']) < 0))
|
||||||
} else {
|
$this->errmsgs[] = sprintf("Incorrect version of extension '%s' (needs version '%s' but provides '%s')", $dkey, $dval, $GLOBALS['EXT_CONF'][$dkey]['version']);
|
||||||
$this->errmsgs[] = sprintf("Missing extension or version for '%s'", $dkey);
|
} else {
|
||||||
|
$this->errmsgs[] = sprintf("Missing extension or version for '%s'", $dkey);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user