Author: nathangray
New Revision: 55460
URL: http://svn.stylite.de/viewvc/egroupware?rev=55460&view=rev
Log:
Cache widget registry for an hour.
Fixes historylog not loading entries.
Modified:
trunk/egroupware/api/src/Etemplate.php
trunk/egroupware/api/src/Etemplate/Widget.php
— trunk/egroupware/api/src/Etemplate.php (original)
+++ trunk/egroupware/api/src/Etemplate.php Mon Mar 21 18:08:17 2016
@@ -687,39 +687,3 @@
return (int)$size;
}
}
-// Try to discover all widgets, as names don’t always match tags (eg: listbox is in menupopup)
-foreach(scandir($dir=DIR . ‘/Etemplate/Widget’) as $filename)
-{
-// Use hook to load custom widgets from other apps
-$widgets = $GLOBALS[‘egw’]->hooks->process(‘etemplate2_register_widgets’);
-foreach($widgets as $app => $list)
-{
— trunk/egroupware/api/src/Etemplate/Widget.php (original)
+++ trunk/egroupware/api/src/Etemplate/Widget.php Mon Mar 21 18:08:17 2016
@@ -14,6 +14,7 @@
namespace EGroupware\Api\Etemplate;
use EGroupware\Api;
+use EGroupware\Api\Cache;
use XMLReader;
use ReflectionMethod;
@@ -286,6 +287,68 @@
{
self::$widget_registry[$widget] = $class;
}
-
}
-
-
/**
-
- Try to discover all widgets, as names don’t always match tags (eg:
-
-
-
- Look through filesystem for widgets, then process the hook
-
- ‘etemplate2_register_widgets’, which may return a list of widget class
-
-
-
- The list is cached for an hour, to avoid rescanning the filesystem but
-
- also to make sure the list is always available, even when calling static
-
-
*/
-
public static function scanForWidgets()
-
{
-
-
$widget_registry = Cache::getInstance('etemplate', 'widget_registry');
-
-
if (!$widget_registry) // not in instance cache --> rescan from filesystem
-
{
-
foreach(scandir($dir=__DIR__ . '/Widget') as $filename)
-
{
-
if(substr($filename, -4) == '.php')
-
{
-
try
-
{
-
include_once($dir.'/'.$filename);
-
}
-
catch(Exception $e)
-
{
-
error_log($e->getMessage());
-
}
-
}
-
}
-
-
// Use hook to load custom widgets from other apps
-
$widgets = $GLOBALS['egw']->hooks->process('etemplate2_register_widgets',array(),true);
-
foreach($widgets as $app => $list)
-
{
-
if (is_array($list))
-
{
-
foreach($list as $class)
-
{
-
try
-
{
-
class_exists($class); // trigger autoloader
-
}
-
catch(Exception $e)
-
{
-
error_log($e->getMessage());
-
}
-
}
-
}
-
}
-
Cache::setInstance('etemplate', 'widget_registry', self::$widget_registry, 3600);
-
}
-
else
-
{
-
self::$widget_registry = $widget_registry;
-
}
-
return self::$widget_registry;
}
/**
@@ -913,3 +976,6 @@
return self::setElementAttribute($name, ‘disabled’, $disabled);
}
}
-
+// Scan for widget classes and cache for 1 hour
+Widget::scanForWidgets();
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140
eGroupWare-cvs mailing list
eGroupWare-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/egroupware-cvs