mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 07:04:57 +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
|
||||
used method by setting a parameter in the extension's config file will no
|
||||
longer work.
|
||||
- clean up code for managing extensions
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
Changes in version 5.1.13
|
||||
|
|
|
@ -36,7 +36,7 @@ class SeedDMS_Controller_ExtensionMgr extends SeedDMS_Controller_Common {
|
|||
$extmgr = $this->params['extmgr'];
|
||||
$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(file_exists($filename)) {
|
||||
|
|
|
@ -30,14 +30,14 @@ class Controller {
|
|||
* @return object an object of a class implementing the view
|
||||
*/
|
||||
static function factory($class, $params=array()) { /* {{{ */
|
||||
global $settings, $session, $EXT_CONF;
|
||||
global $settings, $session, $extMgr;
|
||||
if(!$class) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$classname = "SeedDMS_Controller_".$class;
|
||||
$filename = '';
|
||||
foreach($EXT_CONF as $extname=>$extconf) {
|
||||
foreach($extMgr->getExtensionConfiguration() as $extname=>$extconf) {
|
||||
$filename = $settings->_rootDir.'ext/'.$extname.'/controllers/class.'.$class.".php";
|
||||
if(file_exists($filename)) {
|
||||
break;
|
||||
|
|
|
@ -362,9 +362,9 @@ class SeedDMS_Extension_Mgr {
|
|||
break;
|
||||
default:
|
||||
$tmp = explode('-', $dval, 2);
|
||||
if(isset($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))
|
||||
$this->errmsgs[] = sprintf("Incorrect version of extension '%s' (needs version '%s' but provides '%s')", $dkey, $dval, $GLOBALS['EXT_CONF'][$dkey]['version']);
|
||||
if(isset($this->extconf[$dkey]['version'])) {
|
||||
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, $this->extconf[$dkey]['version']);
|
||||
} else {
|
||||
$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
|
||||
*/
|
||||
static function factory($theme, $class='', $params=array()) { /* {{{ */
|
||||
global $settings, $session, $EXT_CONF;
|
||||
global $settings, $session, $extMgr;
|
||||
if(!$class) {
|
||||
$class = 'Bootstrap';
|
||||
$classname = "SeedDMS_Bootstrap_Style";
|
||||
|
@ -54,14 +54,14 @@ class UI extends UI_Default {
|
|||
}
|
||||
/* Collect all decorators */
|
||||
$decorators = array();
|
||||
foreach($EXT_CONF as $extname=>$extconf) {
|
||||
foreach($extMgr->getExtensionConfiguration() as $extname=>$extconf) {
|
||||
if(!$settings->extensionIsDisabled($extname)) {
|
||||
// if(!isset($extconf['disable']) || $extconf['disable'] == false) {
|
||||
if(isset($extconf['decorators'][$class])) {
|
||||
$filename = $settings->_rootDir.'ext/'.$extname.'/decorators/'.$theme."/".$extconf['decorators'][$class]['file'];
|
||||
if(file_exists($filename)) {
|
||||
$classname = $extconf['decorators'][$class]['name'];
|
||||
$decorators[$extname] = $extconf['decorators'][$class];
|
||||
if($extMgr->checkExtension($extconf)) {
|
||||
if(isset($extconf['decorators'][$class])) {
|
||||
$filename = $settings->_rootDir.'ext/'.$extname.'/decorators/'.$theme."/".$extconf['decorators'][$class]['file'];
|
||||
if(file_exists($filename)) {
|
||||
$decorators[$extname] = $extconf['decorators'][$class];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -71,32 +71,33 @@ class UI extends UI_Default {
|
|||
*/
|
||||
$filename = '';
|
||||
$httpbasedir = '';
|
||||
foreach($EXT_CONF as $extname=>$extconf) {
|
||||
foreach($extMgr->getExtensionConfiguration() as $extname=>$extconf) {
|
||||
if(!$settings->extensionIsDisabled($extname)) {
|
||||
// if(!isset($extconf['disable']) || $extconf['disable'] == false) {
|
||||
/* 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
|
||||
* will not be set because out/out.xxx.php is still used.
|
||||
*/
|
||||
if(isset($extconf['views'][$class])) {
|
||||
$filename = $settings->_rootDir.'ext/'.$extname.'/views/'.$theme."/".$extconf['views'][$class]['file'];
|
||||
if($extMgr->checkExtension($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
|
||||
* will not be set because out/out.xxx.php is still used.
|
||||
*/
|
||||
if(isset($extconf['views'][$class])) {
|
||||
$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)) {
|
||||
// $httpbasedir = 'ext/'.$extname.'/';
|
||||
$classname = $extconf['views'][$class]['name'];
|
||||
$httpbasedir = 'ext/'.$extname.'/';
|
||||
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)
|
||||
|
@ -141,7 +142,7 @@ class UI extends UI_Default {
|
|||
$view->setParam('onepage', $settings->_onePageMode);
|
||||
foreach($decorators as $extname=>$decorator) {
|
||||
$filename = $settings->_rootDir.'ext/'.$extname.'/decorators/'.$theme."/".$decorator['file'];
|
||||
require($filename);
|
||||
require_once($filename);
|
||||
$view = new $decorator['name']($view);
|
||||
}
|
||||
return $view;
|
||||
|
|
|
@ -17,21 +17,28 @@ require_once "inc.Version.php";
|
|||
require_once "inc.Utils.php";
|
||||
|
||||
$extMgr = new SeedDMS_Extension_Mgr($settings->_rootDir."/ext", $settings->_cacheDir, $settings->_repositoryUrl);
|
||||
$EXT_CONF = $extMgr->getExtensionConfiguration();
|
||||
|
||||
$version = new SeedDMS_Version;
|
||||
|
||||
foreach($EXT_CONF as $extname=>$extconf) {
|
||||
foreach($extMgr->getExtensionConfiguration() as $extname=>$extconf) {
|
||||
if(!$settings->extensionIsDisabled($extname)) {
|
||||
$disabled = true;
|
||||
if($extMgr->checkExtension($extconf)) {
|
||||
$disabled = false;
|
||||
} else {
|
||||
// echo $extMgr->getErrorMsg();
|
||||
}
|
||||
/* check for requirements */
|
||||
$disable = false;
|
||||
/*
|
||||
if(!empty($extconf['constraints']['depends']['seeddms'])) {
|
||||
$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))
|
||||
continue;
|
||||
$disable = true;
|
||||
$disabled = true;
|
||||
else
|
||||
$disabled = false;
|
||||
}
|
||||
if(!$disable) {
|
||||
*/
|
||||
if(!$disabled) {
|
||||
if(isset($extconf['class']) && isset($extconf['class']['file']) && isset($extconf['class']['name'])) {
|
||||
$classfile = $settings->_rootDir."/ext/".$extname."/".$extconf['class']['file'];
|
||||
if(file_exists($classfile)) {
|
||||
|
|
|
@ -42,6 +42,7 @@ $groups = $dms->getAllGroups();
|
|||
|
||||
if($view) {
|
||||
$view->setParam('settings', $settings);
|
||||
$view->setParam('extmgr', $extMgr);
|
||||
$view->setParam('currenttab', (isset($_REQUEST['currenttab']) ? $_REQUEST['currenttab'] : ''));
|
||||
$view->setParam('allusers', $users);
|
||||
$view->setParam('allgroups', $groups);
|
||||
|
|
|
@ -99,6 +99,7 @@ class SeedDMS_View_ExtensionMgr extends SeedDMS_Bootstrap_Style {
|
|||
$user = $this->params['user'];
|
||||
$extmgr = $this->params['extmgr'];
|
||||
$extname = $this->params['extname'];
|
||||
$extconf = $extmgr->getExtensionConfiguration();
|
||||
|
||||
echo "<table class=\"table _table-condensed\">\n";
|
||||
print "<thead>\n<tr>\n";
|
||||
|
@ -112,9 +113,9 @@ class SeedDMS_View_ExtensionMgr extends SeedDMS_Bootstrap_Style {
|
|||
foreach($list as $re) {
|
||||
$extmgr->checkExtension($re);
|
||||
$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";
|
||||
if(isset($GLOBALS['EXT_CONF'][$re['name']])) {
|
||||
if(isset($extconf[$re['name']])) {
|
||||
if($needsupdate)
|
||||
echo " class=\"warning\"";
|
||||
else
|
||||
|
@ -145,9 +146,10 @@ class SeedDMS_View_ExtensionMgr extends SeedDMS_Bootstrap_Style {
|
|||
$extdir = $this->params['extdir'];
|
||||
$extmgr = $this->params['extmgr'];
|
||||
$extname = $this->params['extname'];
|
||||
$extconf = $extmgr->getExtensionConfiguration();
|
||||
|
||||
if(isset($GLOBALS['EXT_CONF'][$extname])) {
|
||||
$extconf = $GLOBALS['EXT_CONF'][$extname];
|
||||
if(isset($extconf[$extname])) {
|
||||
$extconf = $extconf[$extname];
|
||||
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>";
|
||||
}
|
||||
|
@ -161,6 +163,7 @@ class SeedDMS_View_ExtensionMgr extends SeedDMS_Bootstrap_Style {
|
|||
$httproot = $this->params['httproot'];
|
||||
$extmgr = $this->params['extmgr'];
|
||||
$extdir = $this->params['extdir'];
|
||||
$extconf = $extmgr->getExtensionConfiguration();
|
||||
|
||||
echo "<table id=\"extensionlist\" class=\"table _table-condensed\">\n";
|
||||
print "<thead>\n<tr>\n";
|
||||
|
@ -171,7 +174,7 @@ class SeedDMS_View_ExtensionMgr extends SeedDMS_Bootstrap_Style {
|
|||
print "<th></th>\n";
|
||||
print "</tr></thead><tbody>\n";
|
||||
$errmsgs = array();
|
||||
foreach($GLOBALS['EXT_CONF'] as $extname=>$extconf) {
|
||||
foreach($extconf as $extname=>$extconf) {
|
||||
$errmsgs = array();
|
||||
if(!$settings->extensionIsDisabled($extname)) {
|
||||
// if(!isset($extconf['disable']) || $extconf['disable'] == false) {
|
||||
|
@ -225,6 +228,7 @@ class SeedDMS_View_ExtensionMgr extends SeedDMS_Bootstrap_Style {
|
|||
$extdir = $this->params['extdir'];
|
||||
$version = $this->params['version'];
|
||||
$extmgr = $this->params['extmgr'];
|
||||
$extconf = $extmgr->getExtensionConfiguration();
|
||||
$currenttab = $this->params['currenttab'];
|
||||
$reposurl = $this->params['reposurl'];
|
||||
|
||||
|
@ -291,9 +295,9 @@ class SeedDMS_View_ExtensionMgr extends SeedDMS_Bootstrap_Style {
|
|||
continue;
|
||||
$extmgr->checkExtension($re);
|
||||
$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";
|
||||
if(isset($GLOBALS['EXT_CONF'][$re['name']])) {
|
||||
if(isset($extconf[$re['name']])) {
|
||||
if($needsupdate)
|
||||
echo " class=\"warning\"";
|
||||
else
|
||||
|
|
|
@ -176,6 +176,7 @@ class SeedDMS_View_Settings extends SeedDMS_Bootstrap_Style {
|
|||
} /* }}} */
|
||||
|
||||
function js() { /* {{{ */
|
||||
$extmgr = $this->params['extmgr'];
|
||||
|
||||
header('Content-Type: application/javascript');
|
||||
?>
|
||||
|
@ -207,7 +208,7 @@ class SeedDMS_View_Settings extends SeedDMS_Bootstrap_Style {
|
|||
});
|
||||
});
|
||||
<?php
|
||||
foreach($GLOBALS['EXT_CONF'] as $extname=>$extconf) {
|
||||
foreach($extmgr->getExtensionConfiguration() as $extname=>$extconf) {
|
||||
if($extconf['config']) {
|
||||
foreach($extconf['config'] as $confkey=>$conf) {
|
||||
switch($conf['type']) {
|
||||
|
@ -230,6 +231,7 @@ class SeedDMS_View_Settings extends SeedDMS_Bootstrap_Style {
|
|||
$dms = $this->params['dms'];
|
||||
$user = $this->params['user'];
|
||||
$settings = $this->params['settings'];
|
||||
$extmgr = $this->params['extmgr'];
|
||||
$currenttab = $this->params['currenttab'];
|
||||
|
||||
$this->htmlStartPage(getMLText("admin_tools"));
|
||||
|
@ -475,7 +477,7 @@ $this->showStartPaneContent('site', (!$currenttab || $currenttab == 'site'));
|
|||
-- SETTINGS - ADVANCED - DISPLAY
|
||||
-->
|
||||
<?php
|
||||
foreach($GLOBALS['EXT_CONF'] as $extname=>$extconf) {
|
||||
foreach($extmgr->getExtensionConfiguration() as $extname=>$extconf) {
|
||||
if($this->hasHook('processConfig'))
|
||||
$extconf = $this->callHook('processConfig', $extname, $extconf);
|
||||
if($extconf['config']) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user