Merge branch 'seeddms-5.1.x' into seeddms-6.0.x

This commit is contained in:
Uwe Steinmann 2021-04-23 10:01:03 +02:00
commit 54dabfed93
6 changed files with 119 additions and 67 deletions

View File

@ -139,6 +139,46 @@ class SeedDMS_Controller_Common {
$this->errormsg = $msg; $this->errormsg = $msg;
} /* }}} */ } /* }}} */
/**
* Return a list of hook classes for the current class
*
* Hooks are associated to a controller class. Calling a hook with
* SeedDMS_View_Common::callHook() will run through a list of
* controller classes searching for the hook. This method returns this
* list.
*
* If a controller is implemented in SeedDMS_View_Example which inherits
* from SeedDMS_Theme_Style which again inherits from SeedDMS_View_Common,
* then this method will return an array with the elments:
* 'Example', 'Style', 'Common'. If SeedDMS_View_Example also sets
* the class property 'controllerAliasName', then this value will be added
* to the beginning of the list.
*
* When a hook is called, it will run through this list and checks
* if $GLOBALS['SEEDDMS_HOOKS']['controller'][<element>] exists and contains
* an instanciated class. This class must implement the hook.
*
* @return array list of controller class names.
*/
protected function getHookClassNames() { /* {{{ */
$tmps = array();
/* the controllerAliasName can be set in the controller to specify a different name
* than extracted from the class name.
*/
if(property_exists($this, 'controllerAliasName') && !empty($this->controllerAliasName)) {
$tmps[] = $this->controllerAliasName;
}
$tmp = explode('_', get_class($this));
$tmps[] = $tmp[2];
foreach(class_parents($this) as $pc) {
$tmp = explode('_', $pc);
$tmps[] = $tmp[2];
}
/* Run array_unique() in case the parent class has the same suffix */
$tmps = array_unique($tmps);
return $tmps;
} /* }}} */
/** /**
* Call all hooks registered for a controller * Call all hooks registered for a controller
* *
@ -190,17 +230,7 @@ class SeedDMS_Controller_Common {
* null if no hook was called * null if no hook was called
*/ */
function callHook($hook) { /* {{{ */ function callHook($hook) { /* {{{ */
$tmps = array(); $tmps = $this->getHookClassNames();
$tmp = explode('_', get_class($this));
$tmps[] = $tmp[2];
foreach(class_parents($this) as $pc) {
$tmp = explode('_', $pc);
$tmps[] = $tmp[2];
}
// $tmp = explode('_', get_parent_class($this));
// $tmps[] = $tmp[2];
/* Run array_unique() in case the parent class has the same suffix */
$tmps = array_unique($tmps);
foreach($tmps as $tmp) foreach($tmps as $tmp)
if(isset($GLOBALS['SEEDDMS_HOOKS']['controller'][lcfirst($tmp)])) { if(isset($GLOBALS['SEEDDMS_HOOKS']['controller'][lcfirst($tmp)])) {
$this->lasthookresult = null; $this->lasthookresult = null;
@ -242,7 +272,7 @@ class SeedDMS_Controller_Common {
* null if no hook was called * null if no hook was called
*/ */
function hasHook($hook) { /* {{{ */ function hasHook($hook) { /* {{{ */
$tmp = explode('_', get_class($this)); $tmps = $this->getHookClassNames();
if(isset($GLOBALS['SEEDDMS_HOOKS']['controller'][lcfirst($tmp[2])])) { if(isset($GLOBALS['SEEDDMS_HOOKS']['controller'][lcfirst($tmp[2])])) {
foreach($GLOBALS['SEEDDMS_HOOKS']['controller'][lcfirst($tmp[2])] as $hookObj) { foreach($GLOBALS['SEEDDMS_HOOKS']['controller'][lcfirst($tmp[2])] as $hookObj) {
if (method_exists($hookObj, $hook)) { if (method_exists($hookObj, $hook)) {

View File

@ -95,6 +95,46 @@ class SeedDMS_View_Common {
public function show() { public function show() {
} }
/**
* Return a list of hook classes for the current class
*
* Hooks are associated to a view class. Calling a hook with
* SeedDMS_View_Common::callHook() will run through a list of
* view classes searching for the hook. This method returns this
* list.
*
* If a view is implemented in SeedDMS_View_Example which inherits
* from SeedDMS_Theme_Style which again inherits from SeedDMS_View_Common,
* then this method will return an array with the elments:
* 'Example', 'Style', 'Common'. If SeedDMS_View_Example also sets
* the class property 'viewAliasName', then this value will be added
* to the beginning of the list.
*
* When a hook is called, it will run through this list and checks
* if $GLOBALS['SEEDDMS_HOOKS']['view'][<element>] exists and contains
* an instanciated class. This class must implement the hook.
*
* @return array list of view class names.
*/
protected function getHookClassNames() { /* {{{ */
$tmps = array();
/* the viewAliasName can be set in the view to specify a different name
* than extracted from the class name.
*/
if(property_exists($this, 'viewAliasName') && !empty($this->viewAliasName)) {
$tmps[] = $this->viewAliasName;
}
$tmp = explode('_', get_class($this));
$tmps[] = $tmp[2];
foreach(class_parents($this) as $pc) {
$tmp = explode('_', $pc);
$tmps[] = $tmp[2];
}
/* Run array_unique() in case the parent class has the same suffix */
$tmps = array_unique($tmps);
return $tmps;
} /* }}} */
/** /**
* Call a hook with a given name * Call a hook with a given name
* *
@ -113,15 +153,7 @@ class SeedDMS_View_Common {
* function returns * function returns
*/ */
public function callHook($hook) { /* {{{ */ public function callHook($hook) { /* {{{ */
$tmps = array(); $tmps = $this->getHookClassNames();
$tmp = explode('_', get_class($this));
$tmps[] = $tmp[2];
foreach(class_parents($this) as $pc) {
$tmp = explode('_', $pc);
$tmps[] = $tmp[2];
}
/* Run array_unique() in case the parent class has the same suffix */
$tmps = array_unique($tmps);
$ret = null; $ret = null;
foreach($tmps as $tmp) foreach($tmps as $tmp)
if(isset($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp)])) { if(isset($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp)])) {
@ -174,6 +206,9 @@ class SeedDMS_View_Common {
* ?> * ?>
* </code> * </code>
* *
* The method does not return hooks for parent classes nor does it
* evaluate the viewAliasName property.
*
* @params string $classname name of class (current class if left empty) * @params string $classname name of class (current class if left empty)
* @return array list of hook objects registered for the class * @return array list of hook objects registered for the class
*/ */
@ -197,14 +232,7 @@ class SeedDMS_View_Common {
* null if no hook was called * null if no hook was called
*/ */
public function hasHook($hook) { /* {{{ */ public function hasHook($hook) { /* {{{ */
$tmps = array(); $tmps = $this->getHookClassNames();
$tmp = explode('_', get_class($this));
$tmps[] = $tmp[2];
$tmp = explode('_', get_parent_class($this));
$tmps[] = $tmp[2];
/* Run array_unique() in case the parent class has the same suffix */
$tmps = array_unique($tmps);
$ret = null;
foreach($tmps as $tmp) { foreach($tmps as $tmp) {
if(isset($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp)])) { if(isset($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp)])) {
foreach($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp)] as $hookObj) { foreach($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp)] as $hookObj) {

View File

@ -74,10 +74,12 @@ $(document).ready( function() {
$this->htmlStartPage(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName())))); $this->htmlStartPage(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName()))));
$this->globalNavigation($folder); $this->globalNavigation($folder);
$this->contentStart(); $this->contentStart();
// $this->pageNavigation($this->getFolderPathHTML($folder, true), "view_folder", $folder); $this->pageNavigation($this->getFolderPathHTML($folder, true), "view_folder", $folder);
/*
?> ?>
<div class="ajax" data-view="ViewFolder" data-action="navigation" data-no-spinner="true" <?php echo ($folder ? "data-query=\"folderid=".$folder->getID()."\"" : "") ?>></div> <div class="ajax" data-view="ViewFolder" data-action="navigation" data-no-spinner="true" <?php echo ($folder ? "data-query=\"folderid=".$folder->getID()."\"" : "") ?>></div>
<?php <?php
*/
$this->contentHeading(getMLText("add_subfolder")); $this->contentHeading(getMLText("add_subfolder"));
$this->contentContainerStart(); $this->contentContainerStart();
?> ?>

View File

@ -79,12 +79,8 @@ class SeedDMS_Theme_Style extends SeedDMS_View_Common {
header($name . ": " . $value); header($name . ": " . $value);
} }
} }
$hookObjs = $this->getHookObjects('SeedDMS_View_Bootstrap'); if($this->hasHook('startPage'))
foreach($hookObjs as $hookObj) { $this->callHook('startPage');
if (method_exists($hookObj, 'startPage')) {
$hookObj->startPage($this);
}
}
echo "<!DOCTYPE html>\n"; echo "<!DOCTYPE html>\n";
echo "<html lang=\"en\">\n<head>\n"; echo "<html lang=\"en\">\n<head>\n";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n"; echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
@ -147,11 +143,8 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
echo "<div class=\"splash\" data-type=\"".$flashmsg['type']."\"".(!empty($flashmsg['timeout']) ? ' data-timeout="'.$flashmsg['timeout'].'"': '').">".$flashmsg['msg']."</div>\n"; echo "<div class=\"splash\" data-type=\"".$flashmsg['type']."\"".(!empty($flashmsg['timeout']) ? ' data-timeout="'.$flashmsg['timeout'].'"': '').">".$flashmsg['msg']."</div>\n";
} }
echo "<div class=\"statusbar-container\"><h1>".getMLText('recent_uploads')."</h1></div>\n"; echo "<div class=\"statusbar-container\"><h1>".getMLText('recent_uploads')."</h1></div>\n";
foreach($hookObjs as $hookObj) { if($this->hasHook('startBody'))
if (method_exists($hookObj, 'startBody')) { $this->callHook('startBody');
$hookObj->startBody($this);
}
}
} /* }}} */ } /* }}} */
function htmlAddHeader($head, $type='js') { /* {{{ */ function htmlAddHeader($head, $type='js') { /* {{{ */
@ -166,13 +159,9 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
function htmlEndPage($nofooter=false) { /* {{{ */ function htmlEndPage($nofooter=false) { /* {{{ */
if(!$nofooter) { if(!$nofooter) {
$hookObjs = $this->getHookObjects('SeedDMS_View_Bootstrap');
$html = $this->footNote(); $html = $this->footNote();
foreach($hookObjs as $hookObj) { if($this->hasHook('footNote'))
if (method_exists($hookObj, 'footNote')) { $html = $this->callHook('footNote', $html);
$html = $hookObj->footNote($this, $html);
}
}
echo $html; echo $html;
if($this->params['showmissingtranslations']) { if($this->params['showmissingtranslations']) {
$this->missingLanguageKeys(); $this->missingLanguageKeys();
@ -400,12 +389,8 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
$menuitems['my_account'] = array('link'=>"../out/out.MyAccount.php", 'label'=>'my_account'); $menuitems['my_account'] = array('link'=>"../out/out.MyAccount.php", 'label'=>'my_account');
if ($accessobject->check_view_access('TransmittalMgr')) if ($accessobject->check_view_access('TransmittalMgr'))
$menuitems['my_transmittals'] = array('link'=>"../out/out.TransmittalMgr.php", 'label'=>'my_transmittals'); $menuitems['my_transmittals'] = array('link'=>"../out/out.TransmittalMgr.php", 'label'=>'my_transmittals');
$hookObjs = $this->getHookObjects('SeedDMS_View_Bootstrap'); if($this->hasHook('userMenuItems'))
foreach($hookObjs as $hookObj) { $menuitems = $this->callHook('userMenuItems', $menuitems);
if (method_exists($hookObj, 'userMenuItems')) {
$menuitems = $hookObj->userMenuItems($this, $menuitems);
}
}
if($menuitems) { if($menuitems) {
foreach($menuitems as $menuitem) { foreach($menuitems as $menuitem) {
echo "<li><a href=\"".$menuitem['link']."\">".getMLText($menuitem['label'])."</a></li>"; echo "<li><a href=\"".$menuitem['link']."\">".getMLText($menuitem['label'])."</a></li>";
@ -507,11 +492,8 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
$menuitems['help'] = array('link'=>'../out/out.Help.php?context='.$tmp[1], 'label'=>"help"); $menuitems['help'] = array('link'=>'../out/out.Help.php?context='.$tmp[1], 'label'=>"help");
} }
/* Check if hook exists because otherwise callHook() will override $menuitems */ /* Check if hook exists because otherwise callHook() will override $menuitems */
foreach($hookObjs as $hookObj) { if($this->hasHook('globalNavigationBar'))
if (method_exists($hookObj, 'globalNavigationBar')) { $menuitems = $this->callHook('globalNavigationBar', $menuitems);
$menuitems = $hookObj->globalNavigationBar($this, $menuitems);
}
}
foreach($menuitems as $menuitem) { foreach($menuitems as $menuitem) {
if(!empty($menuitem['children'])) { if(!empty($menuitem['children'])) {
echo " <li class=\"dropdown\">\n"; echo " <li class=\"dropdown\">\n";

View File

@ -59,7 +59,7 @@ class SeedDMS_View_Info extends SeedDMS_Theme_Style {
$this->columnStart(6); $this->columnStart(6);
$this->contentHeading(getMLText("seeddms_info")); $this->contentHeading(getMLText("seeddms_info"));
$seedextensions = $extmgr->getExtensionConfiguration(); $seedextensions = $extmgr->getExtensionConfiguration();
echo "<table class=\"table table-condensed\">\n"; echo "<table class=\"table table-condensed table-sm\">\n";
echo "<thead>\n<tr>\n"; echo "<thead>\n<tr>\n";
echo "<th>".getMLText("name"); echo "<th>".getMLText("name");
echo "</th>\n"; echo "</th>\n";
@ -76,7 +76,7 @@ class SeedDMS_View_Info extends SeedDMS_Theme_Style {
$this->columnStart(6); $this->columnStart(6);
if($user->isAdmin()) { if($user->isAdmin()) {
$this->contentHeading(getMLText("php_info")); $this->contentHeading(getMLText("php_info"));
echo "<table class=\"table table-condensed\">\n"; echo "<table class=\"table table-condensed table-sm\">\n";
echo "<thead>\n<tr>\n"; echo "<thead>\n<tr>\n";
echo "<th>".getMLText("name"); echo "<th>".getMLText("name");
echo "</th>\n"; echo "</th>\n";
@ -87,7 +87,7 @@ class SeedDMS_View_Info extends SeedDMS_Theme_Style {
$this->contentHeading(getMLText("installed_php_extensions")); $this->contentHeading(getMLText("installed_php_extensions"));
$phpextensions = get_loaded_extensions(false); $phpextensions = get_loaded_extensions(false);
echo "<table class=\"table table-condensed\">\n"; echo "<table class=\"table table-condensed table-sm\">\n";
echo "<thead>\n<tr>\n"; echo "<thead>\n<tr>\n";
echo "<th>".getMLText("name"); echo "<th>".getMLText("name");
echo "</th>\n"; echo "</th>\n";
@ -97,7 +97,7 @@ class SeedDMS_View_Info extends SeedDMS_Theme_Style {
echo "</tbody>\n</table>\n"; echo "</tbody>\n</table>\n";
$this->contentHeading(getMLText("missing_php_extensions")); $this->contentHeading(getMLText("missing_php_extensions"));
echo "<table class=\"table table-condensed\">\n"; echo "<table class=\"table table-condensed table-sm\">\n";
echo "<thead>\n<tr>\n"; echo "<thead>\n<tr>\n";
echo "<th>".getMLText("name"); echo "<th>".getMLText("name");
echo "</th>\n"; echo "</th>\n";
@ -107,11 +107,11 @@ class SeedDMS_View_Info extends SeedDMS_Theme_Style {
echo "<tr><td>".$extname."</td><td>"."</td></tr>\n"; echo "<tr><td>".$extname."</td><td>"."</td></tr>\n";
echo "</tbody>\n</table>\n"; echo "</tbody>\n</table>\n";
$this->contentHeading(getMLText("missing_php_functions")); $this->contentHeading(getMLText("missing_php_functions_and_classes"));
echo "<table class=\"table table-condensed\">\n"; echo "<table class=\"table table-condensed table-sm\">\n";
echo "<thead>\n<tr>\n"; echo "<thead>\n<tr>\n";
echo "<th>".getMLText("name"); echo "<th>".getMLText("name");
echo "<th>".getMLText("missing_func_note"); echo "<th>".getMLText("missing_func_class_note");
echo "</th>\n"; echo "</th>\n";
echo "</tr>\n</thead>\n<tbody>\n"; echo "</tr>\n</thead>\n<tbody>\n";
foreach(array('proc_open') as $funcname) { foreach(array('proc_open') as $funcname) {
@ -119,12 +119,17 @@ class SeedDMS_View_Info extends SeedDMS_Theme_Style {
echo "<tr><td>".$funcname."</td><td>".getMLText('func_'.$funcname."_missing")."</td></tr>"; echo "<tr><td>".$funcname."</td><td>".getMLText('func_'.$funcname."_missing")."</td></tr>";
} }
} }
foreach(array('finfo') as $classname) {
if(!class_exists($classname)) {
echo "<tr><td>".$classname."</td><td>".getMLText('class_'.$classname."_missing")."</td></tr>";
}
}
echo "</tbody>\n</table>\n"; echo "</tbody>\n</table>\n";
if(function_exists('apache_get_modules')) { if(function_exists('apache_get_modules')) {
$this->contentHeading(getMLText("installed_apache_extensions")); $this->contentHeading(getMLText("installed_apache_extensions"));
$apacheextensions = apache_get_modules(); $apacheextensions = apache_get_modules();
echo "<table class=\"table table-condensed\">\n"; echo "<table class=\"table table-condensed table-sm\">\n";
echo "<thead>\n<tr>\n"; echo "<thead>\n<tr>\n";
echo "<th>".getMLText("name"); echo "<th>".getMLText("name");
echo "</th>\n"; echo "</th>\n";

View File

@ -36,6 +36,11 @@ require_once("SeedDMS/Preview.php");
*/ */
class SeedDMS_View_ViewFolder extends SeedDMS_Theme_Style { class SeedDMS_View_ViewFolder extends SeedDMS_Theme_Style {
/**
* set a different name which is used to specify the hooks.
*/
//public $viewAliasName = '';
function data() { /* {{{ */ function data() { /* {{{ */
$dms = $this->params['dms']; $dms = $this->params['dms'];
$user = $this->params['user']; $user = $this->params['user'];
@ -565,7 +570,7 @@ $('body').on('click', '.order-btn', function(ev) {
//$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/bootbox/bootbox.min.js"></script>'."\n", 'js'); //$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/bootbox/bootbox.min.js"></script>'."\n", 'js');
echo $this->callHook('startPage'); // echo $this->callHook('startPage');
$this->htmlStartPage(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName())))); $this->htmlStartPage(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName()))));
$this->globalNavigation($folder); $this->globalNavigation($folder);
$this->contentStart(); $this->contentStart();