mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-08 20:46:05 +00:00
do not use global var EXT_CONF anymore
This commit is contained in:
parent
189e6da70e
commit
8ae2874367
|
@ -13,6 +13,7 @@
|
||||||
- Extension can be enabled/disabled in the extension manager, the previously
|
- Extension can be enabled/disabled in the extension manager, the previously
|
||||||
used method by setting a parameter in the extension's config file will no
|
used method by setting a parameter in the extension's config file will no
|
||||||
longer work.
|
longer work.
|
||||||
|
- clean up code for managing extensions
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
Changes in version 5.1.13
|
Changes in version 5.1.13
|
||||||
|
|
|
@ -36,7 +36,7 @@ class SeedDMS_Controller_ExtensionMgr extends SeedDMS_Controller_Common {
|
||||||
$extmgr = $this->params['extmgr'];
|
$extmgr = $this->params['extmgr'];
|
||||||
$extname = $this->params['extname'];
|
$extname = $this->params['extname'];
|
||||||
|
|
||||||
$filename = $extmgr->createArchive($extname, $GLOBALS['EXT_CONF'][$extname]['version']);
|
$filename = $extmgr->createArchive($extname, $extmgr->getExtensionConfiguration()[$extname]['version']);
|
||||||
|
|
||||||
if(null === $this->callHook('download')) {
|
if(null === $this->callHook('download')) {
|
||||||
if(file_exists($filename)) {
|
if(file_exists($filename)) {
|
||||||
|
|
|
@ -30,14 +30,14 @@ class Controller {
|
||||||
* @return object an object of a class implementing the view
|
* @return object an object of a class implementing the view
|
||||||
*/
|
*/
|
||||||
static function factory($class, $params=array()) { /* {{{ */
|
static function factory($class, $params=array()) { /* {{{ */
|
||||||
global $settings, $session, $EXT_CONF;
|
global $settings, $session, $extMgr;
|
||||||
if(!$class) {
|
if(!$class) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$classname = "SeedDMS_Controller_".$class;
|
$classname = "SeedDMS_Controller_".$class;
|
||||||
$filename = '';
|
$filename = '';
|
||||||
foreach($EXT_CONF as $extname=>$extconf) {
|
foreach($extMgr->getExtensionConfiguration() as $extname=>$extconf) {
|
||||||
$filename = $settings->_rootDir.'ext/'.$extname.'/controllers/class.'.$class.".php";
|
$filename = $settings->_rootDir.'ext/'.$extname.'/controllers/class.'.$class.".php";
|
||||||
if(file_exists($filename)) {
|
if(file_exists($filename)) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -362,9 +362,9 @@ class SeedDMS_Extension_Mgr {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$tmp = explode('-', $dval, 2);
|
$tmp = explode('-', $dval, 2);
|
||||||
if(isset($GLOBALS['EXT_CONF'][$dkey]['version'])) {
|
if(isset($this->extconf[$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))
|
if(self::cmpVersion($tmp[0], $this->extconf[$dkey]['version']) > 0 || ($tmp[1] && self::cmpVersion($tmp[1], $this->extconf[$dkey]['version']) < 0))
|
||||||
$this->errmsgs[] = sprintf("Incorrect version of extension '%s' (needs version '%s' but provides '%s')", $dkey, $dval, $GLOBALS['EXT_CONF'][$dkey]['version']);
|
$this->errmsgs[] = sprintf("Incorrect version of extension '%s' (needs version '%s' but provides '%s')", $dkey, $dval, $this->extconf[$dkey]['version']);
|
||||||
} else {
|
} else {
|
||||||
$this->errmsgs[] = sprintf("Missing extension or version for '%s'", $dkey);
|
$this->errmsgs[] = sprintf("Missing extension or version for '%s'", $dkey);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ class UI extends UI_Default {
|
||||||
* @return object an object of a class implementing the view
|
* @return object an object of a class implementing the view
|
||||||
*/
|
*/
|
||||||
static function factory($theme, $class='', $params=array()) { /* {{{ */
|
static function factory($theme, $class='', $params=array()) { /* {{{ */
|
||||||
global $settings, $session, $EXT_CONF;
|
global $settings, $session, $extMgr;
|
||||||
if(!$class) {
|
if(!$class) {
|
||||||
$class = 'Bootstrap';
|
$class = 'Bootstrap';
|
||||||
$classname = "SeedDMS_Bootstrap_Style";
|
$classname = "SeedDMS_Bootstrap_Style";
|
||||||
|
@ -54,14 +54,14 @@ class UI extends UI_Default {
|
||||||
}
|
}
|
||||||
/* Collect all decorators */
|
/* Collect all decorators */
|
||||||
$decorators = array();
|
$decorators = array();
|
||||||
foreach($EXT_CONF as $extname=>$extconf) {
|
foreach($extMgr->getExtensionConfiguration() as $extname=>$extconf) {
|
||||||
if(!$settings->extensionIsDisabled($extname)) {
|
if(!$settings->extensionIsDisabled($extname)) {
|
||||||
// if(!isset($extconf['disable']) || $extconf['disable'] == false) {
|
if($extMgr->checkExtension($extconf)) {
|
||||||
if(isset($extconf['decorators'][$class])) {
|
if(isset($extconf['decorators'][$class])) {
|
||||||
$filename = $settings->_rootDir.'ext/'.$extname.'/decorators/'.$theme."/".$extconf['decorators'][$class]['file'];
|
$filename = $settings->_rootDir.'ext/'.$extname.'/decorators/'.$theme."/".$extconf['decorators'][$class]['file'];
|
||||||
if(file_exists($filename)) {
|
if(file_exists($filename)) {
|
||||||
$classname = $extconf['decorators'][$class]['name'];
|
$decorators[$extname] = $extconf['decorators'][$class];
|
||||||
$decorators[$extname] = $extconf['decorators'][$class];
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,32 +71,33 @@ class UI extends UI_Default {
|
||||||
*/
|
*/
|
||||||
$filename = '';
|
$filename = '';
|
||||||
$httpbasedir = '';
|
$httpbasedir = '';
|
||||||
foreach($EXT_CONF as $extname=>$extconf) {
|
foreach($extMgr->getExtensionConfiguration() as $extname=>$extconf) {
|
||||||
if(!$settings->extensionIsDisabled($extname)) {
|
if(!$settings->extensionIsDisabled($extname)) {
|
||||||
// if(!isset($extconf['disable']) || $extconf['disable'] == false) {
|
if($extMgr->checkExtension($extconf)) {
|
||||||
/* Setting the 'views' element in the configuration can be used to
|
/* Setting the 'views' element in the configuration can be used to
|
||||||
* replace an existing view in views/bootstrap/, e.g. class.ViewFolder.php
|
* replace an existing view in views/bootstrap/, e.g. class.ViewFolder.php
|
||||||
* without providing an out/out.ViewFolder.php. In that case $httpbasedir
|
* without providing an out/out.ViewFolder.php. In that case $httpbasedir
|
||||||
* will not be set because out/out.xxx.php is still used.
|
* will not be set because out/out.xxx.php is still used.
|
||||||
*/
|
*/
|
||||||
if(isset($extconf['views'][$class])) {
|
if(isset($extconf['views'][$class])) {
|
||||||
$filename = $settings->_rootDir.'ext/'.$extname.'/views/'.$theme."/".$extconf['views'][$class]['file'];
|
$filename = $settings->_rootDir.'ext/'.$extname.'/views/'.$theme."/".$extconf['views'][$class]['file'];
|
||||||
|
if(file_exists($filename)) {
|
||||||
|
// $httpbasedir = 'ext/'.$extname.'/';
|
||||||
|
$classname = $extconf['views'][$class]['name'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* New views are added by creating a file out/out.xx.php and
|
||||||
|
* views/bootstrap/class.xx.php, without setting the 'views' element
|
||||||
|
* in the configuration
|
||||||
|
*/
|
||||||
|
$filename = $settings->_rootDir.'ext/'.$extname.'/views/'.$theme."/class.".$class.".php";
|
||||||
if(file_exists($filename)) {
|
if(file_exists($filename)) {
|
||||||
// $httpbasedir = 'ext/'.$extname.'/';
|
$httpbasedir = 'ext/'.$extname.'/';
|
||||||
$classname = $extconf['views'][$class]['name'];
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
$filename = '';
|
||||||
}
|
}
|
||||||
/* New views are added by creating a file out/out.xx.php and
|
|
||||||
* views/bootstrap/class.xx.php, without setting the 'views' element
|
|
||||||
* in the configuration
|
|
||||||
*/
|
|
||||||
$filename = $settings->_rootDir.'ext/'.$extname.'/views/'.$theme."/class.".$class.".php";
|
|
||||||
if(file_exists($filename)) {
|
|
||||||
$httpbasedir = 'ext/'.$extname.'/';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$filename = '';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!$filename)
|
if(!$filename)
|
||||||
|
@ -141,7 +142,7 @@ class UI extends UI_Default {
|
||||||
$view->setParam('onepage', $settings->_onePageMode);
|
$view->setParam('onepage', $settings->_onePageMode);
|
||||||
foreach($decorators as $extname=>$decorator) {
|
foreach($decorators as $extname=>$decorator) {
|
||||||
$filename = $settings->_rootDir.'ext/'.$extname.'/decorators/'.$theme."/".$decorator['file'];
|
$filename = $settings->_rootDir.'ext/'.$extname.'/decorators/'.$theme."/".$decorator['file'];
|
||||||
require($filename);
|
require_once($filename);
|
||||||
$view = new $decorator['name']($view);
|
$view = new $decorator['name']($view);
|
||||||
}
|
}
|
||||||
return $view;
|
return $view;
|
||||||
|
|
|
@ -17,21 +17,28 @@ require_once "inc.Version.php";
|
||||||
require_once "inc.Utils.php";
|
require_once "inc.Utils.php";
|
||||||
|
|
||||||
$extMgr = new SeedDMS_Extension_Mgr($settings->_rootDir."/ext", $settings->_cacheDir, $settings->_repositoryUrl);
|
$extMgr = new SeedDMS_Extension_Mgr($settings->_rootDir."/ext", $settings->_cacheDir, $settings->_repositoryUrl);
|
||||||
$EXT_CONF = $extMgr->getExtensionConfiguration();
|
|
||||||
|
|
||||||
$version = new SeedDMS_Version;
|
$version = new SeedDMS_Version;
|
||||||
|
|
||||||
foreach($EXT_CONF as $extname=>$extconf) {
|
foreach($extMgr->getExtensionConfiguration() as $extname=>$extconf) {
|
||||||
if(!$settings->extensionIsDisabled($extname)) {
|
if(!$settings->extensionIsDisabled($extname)) {
|
||||||
|
$disabled = true;
|
||||||
|
if($extMgr->checkExtension($extconf)) {
|
||||||
|
$disabled = false;
|
||||||
|
} else {
|
||||||
|
// echo $extMgr->getErrorMsg();
|
||||||
|
}
|
||||||
/* check for requirements */
|
/* check for requirements */
|
||||||
$disable = false;
|
/*
|
||||||
if(!empty($extconf['constraints']['depends']['seeddms'])) {
|
if(!empty($extconf['constraints']['depends']['seeddms'])) {
|
||||||
$t = explode('-', $extconf['constraints']['depends']['seeddms'], 2);
|
$t = explode('-', $extconf['constraints']['depends']['seeddms'], 2);
|
||||||
if(SeedDMS_Extension_Mgr::cmpVersion($t[0], $version->version()) > 0 || ($t[1] && SeedDMS_Extension_Mgr::cmpVersion($t[1], $version->version()) < 0))
|
if(SeedDMS_Extension_Mgr::cmpVersion($t[0], $version->version()) > 0 || ($t[1] && SeedDMS_Extension_Mgr::cmpVersion($t[1], $version->version()) < 0))
|
||||||
continue;
|
$disabled = true;
|
||||||
$disable = true;
|
else
|
||||||
|
$disabled = false;
|
||||||
}
|
}
|
||||||
if(!$disable) {
|
*/
|
||||||
|
if(!$disabled) {
|
||||||
if(isset($extconf['class']) && isset($extconf['class']['file']) && isset($extconf['class']['name'])) {
|
if(isset($extconf['class']) && isset($extconf['class']['file']) && isset($extconf['class']['name'])) {
|
||||||
$classfile = $settings->_rootDir."/ext/".$extname."/".$extconf['class']['file'];
|
$classfile = $settings->_rootDir."/ext/".$extname."/".$extconf['class']['file'];
|
||||||
if(file_exists($classfile)) {
|
if(file_exists($classfile)) {
|
||||||
|
|
|
@ -42,6 +42,7 @@ $groups = $dms->getAllGroups();
|
||||||
|
|
||||||
if($view) {
|
if($view) {
|
||||||
$view->setParam('settings', $settings);
|
$view->setParam('settings', $settings);
|
||||||
|
$view->setParam('extmgr', $extMgr);
|
||||||
$view->setParam('currenttab', (isset($_REQUEST['currenttab']) ? $_REQUEST['currenttab'] : ''));
|
$view->setParam('currenttab', (isset($_REQUEST['currenttab']) ? $_REQUEST['currenttab'] : ''));
|
||||||
$view->setParam('allusers', $users);
|
$view->setParam('allusers', $users);
|
||||||
$view->setParam('allgroups', $groups);
|
$view->setParam('allgroups', $groups);
|
||||||
|
|
|
@ -99,6 +99,7 @@ class SeedDMS_View_ExtensionMgr extends SeedDMS_Bootstrap_Style {
|
||||||
$user = $this->params['user'];
|
$user = $this->params['user'];
|
||||||
$extmgr = $this->params['extmgr'];
|
$extmgr = $this->params['extmgr'];
|
||||||
$extname = $this->params['extname'];
|
$extname = $this->params['extname'];
|
||||||
|
$extconf = $extmgr->getExtensionConfiguration();
|
||||||
|
|
||||||
echo "<table class=\"table _table-condensed\">\n";
|
echo "<table class=\"table _table-condensed\">\n";
|
||||||
print "<thead>\n<tr>\n";
|
print "<thead>\n<tr>\n";
|
||||||
|
@ -112,9 +113,9 @@ class SeedDMS_View_ExtensionMgr extends SeedDMS_Bootstrap_Style {
|
||||||
foreach($list as $re) {
|
foreach($list as $re) {
|
||||||
$extmgr->checkExtension($re);
|
$extmgr->checkExtension($re);
|
||||||
$checkmsgs = $extmgr->getErrorMsgs();
|
$checkmsgs = $extmgr->getErrorMsgs();
|
||||||
$needsupdate = !isset($GLOBALS['EXT_CONF'][$re['name']]) || SeedDMS_Extension_Mgr::cmpVersion($re['version'], $GLOBALS['EXT_CONF'][$re['name']]['version']) > 0;
|
$needsupdate = !isset($extconf[$re['name']]) || SeedDMS_Extension_Mgr::cmpVersion($re['version'], $extconf[$re['name']]['version']) > 0;
|
||||||
echo "<tr";
|
echo "<tr";
|
||||||
if(isset($GLOBALS['EXT_CONF'][$re['name']])) {
|
if(isset($extconf[$re['name']])) {
|
||||||
if($needsupdate)
|
if($needsupdate)
|
||||||
echo " class=\"warning\"";
|
echo " class=\"warning\"";
|
||||||
else
|
else
|
||||||
|
@ -145,9 +146,10 @@ class SeedDMS_View_ExtensionMgr extends SeedDMS_Bootstrap_Style {
|
||||||
$extdir = $this->params['extdir'];
|
$extdir = $this->params['extdir'];
|
||||||
$extmgr = $this->params['extmgr'];
|
$extmgr = $this->params['extmgr'];
|
||||||
$extname = $this->params['extname'];
|
$extname = $this->params['extname'];
|
||||||
|
$extconf = $extmgr->getExtensionConfiguration();
|
||||||
|
|
||||||
if(isset($GLOBALS['EXT_CONF'][$extname])) {
|
if(isset($extconf[$extname])) {
|
||||||
$extconf = $GLOBALS['EXT_CONF'][$extname];
|
$extconf = $extconf[$extname];
|
||||||
if(!empty($extconf['changelog']) && file_exists($extdir."/".$extname."/".$extconf['changelog'])) {
|
if(!empty($extconf['changelog']) && file_exists($extdir."/".$extname."/".$extconf['changelog'])) {
|
||||||
echo '<div style="white-space: pre-wrap; font-family: monospace; padding: 0px;">'.file_get_contents($extdir."/".$extname."/".$extconf['changelog'])."</div>";
|
echo '<div style="white-space: pre-wrap; font-family: monospace; padding: 0px;">'.file_get_contents($extdir."/".$extname."/".$extconf['changelog'])."</div>";
|
||||||
}
|
}
|
||||||
|
@ -161,6 +163,7 @@ class SeedDMS_View_ExtensionMgr extends SeedDMS_Bootstrap_Style {
|
||||||
$httproot = $this->params['httproot'];
|
$httproot = $this->params['httproot'];
|
||||||
$extmgr = $this->params['extmgr'];
|
$extmgr = $this->params['extmgr'];
|
||||||
$extdir = $this->params['extdir'];
|
$extdir = $this->params['extdir'];
|
||||||
|
$extconf = $extmgr->getExtensionConfiguration();
|
||||||
|
|
||||||
echo "<table id=\"extensionlist\" class=\"table _table-condensed\">\n";
|
echo "<table id=\"extensionlist\" class=\"table _table-condensed\">\n";
|
||||||
print "<thead>\n<tr>\n";
|
print "<thead>\n<tr>\n";
|
||||||
|
@ -171,7 +174,7 @@ class SeedDMS_View_ExtensionMgr extends SeedDMS_Bootstrap_Style {
|
||||||
print "<th></th>\n";
|
print "<th></th>\n";
|
||||||
print "</tr></thead><tbody>\n";
|
print "</tr></thead><tbody>\n";
|
||||||
$errmsgs = array();
|
$errmsgs = array();
|
||||||
foreach($GLOBALS['EXT_CONF'] as $extname=>$extconf) {
|
foreach($extconf as $extname=>$extconf) {
|
||||||
$errmsgs = array();
|
$errmsgs = array();
|
||||||
if(!$settings->extensionIsDisabled($extname)) {
|
if(!$settings->extensionIsDisabled($extname)) {
|
||||||
// if(!isset($extconf['disable']) || $extconf['disable'] == false) {
|
// if(!isset($extconf['disable']) || $extconf['disable'] == false) {
|
||||||
|
@ -225,6 +228,7 @@ class SeedDMS_View_ExtensionMgr extends SeedDMS_Bootstrap_Style {
|
||||||
$extdir = $this->params['extdir'];
|
$extdir = $this->params['extdir'];
|
||||||
$version = $this->params['version'];
|
$version = $this->params['version'];
|
||||||
$extmgr = $this->params['extmgr'];
|
$extmgr = $this->params['extmgr'];
|
||||||
|
$extconf = $extmgr->getExtensionConfiguration();
|
||||||
$currenttab = $this->params['currenttab'];
|
$currenttab = $this->params['currenttab'];
|
||||||
$reposurl = $this->params['reposurl'];
|
$reposurl = $this->params['reposurl'];
|
||||||
|
|
||||||
|
@ -291,9 +295,9 @@ class SeedDMS_View_ExtensionMgr extends SeedDMS_Bootstrap_Style {
|
||||||
continue;
|
continue;
|
||||||
$extmgr->checkExtension($re);
|
$extmgr->checkExtension($re);
|
||||||
$checkmsgs = $extmgr->getErrorMsgs();
|
$checkmsgs = $extmgr->getErrorMsgs();
|
||||||
$needsupdate = !isset($GLOBALS['EXT_CONF'][$re['name']]) || SeedDMS_Extension_Mgr::cmpVersion($re['version'], $GLOBALS['EXT_CONF'][$re['name']]['version']) > 0;
|
$needsupdate = !isset($extconf[$re['name']]) || SeedDMS_Extension_Mgr::cmpVersion($re['version'], $extconf[$re['name']]['version']) > 0;
|
||||||
echo "<tr";
|
echo "<tr";
|
||||||
if(isset($GLOBALS['EXT_CONF'][$re['name']])) {
|
if(isset($extconf[$re['name']])) {
|
||||||
if($needsupdate)
|
if($needsupdate)
|
||||||
echo " class=\"warning\"";
|
echo " class=\"warning\"";
|
||||||
else
|
else
|
||||||
|
|
|
@ -176,6 +176,7 @@ class SeedDMS_View_Settings extends SeedDMS_Bootstrap_Style {
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function js() { /* {{{ */
|
function js() { /* {{{ */
|
||||||
|
$extmgr = $this->params['extmgr'];
|
||||||
|
|
||||||
header('Content-Type: application/javascript');
|
header('Content-Type: application/javascript');
|
||||||
?>
|
?>
|
||||||
|
@ -207,7 +208,7 @@ class SeedDMS_View_Settings extends SeedDMS_Bootstrap_Style {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
<?php
|
<?php
|
||||||
foreach($GLOBALS['EXT_CONF'] as $extname=>$extconf) {
|
foreach($extmgr->getExtensionConfiguration() as $extname=>$extconf) {
|
||||||
if($extconf['config']) {
|
if($extconf['config']) {
|
||||||
foreach($extconf['config'] as $confkey=>$conf) {
|
foreach($extconf['config'] as $confkey=>$conf) {
|
||||||
switch($conf['type']) {
|
switch($conf['type']) {
|
||||||
|
@ -230,6 +231,7 @@ class SeedDMS_View_Settings extends SeedDMS_Bootstrap_Style {
|
||||||
$dms = $this->params['dms'];
|
$dms = $this->params['dms'];
|
||||||
$user = $this->params['user'];
|
$user = $this->params['user'];
|
||||||
$settings = $this->params['settings'];
|
$settings = $this->params['settings'];
|
||||||
|
$extmgr = $this->params['extmgr'];
|
||||||
$currenttab = $this->params['currenttab'];
|
$currenttab = $this->params['currenttab'];
|
||||||
|
|
||||||
$this->htmlStartPage(getMLText("admin_tools"));
|
$this->htmlStartPage(getMLText("admin_tools"));
|
||||||
|
@ -475,7 +477,7 @@ $this->showStartPaneContent('site', (!$currenttab || $currenttab == 'site'));
|
||||||
-- SETTINGS - ADVANCED - DISPLAY
|
-- SETTINGS - ADVANCED - DISPLAY
|
||||||
-->
|
-->
|
||||||
<?php
|
<?php
|
||||||
foreach($GLOBALS['EXT_CONF'] as $extname=>$extconf) {
|
foreach($extmgr->getExtensionConfiguration() as $extname=>$extconf) {
|
||||||
if($this->hasHook('processConfig'))
|
if($this->hasHook('processConfig'))
|
||||||
$extconf = $this->callHook('processConfig', $extname, $extconf);
|
$extconf = $this->callHook('processConfig', $extname, $extconf);
|
||||||
if($extconf['config']) {
|
if($extconf['config']) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user