[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] phpgwapi/inc class.auth.inc.php, 1.12 class.accounts.
From: |
fipsfuchs |
Subject: |
[Phpgroupware-cvs] phpgwapi/inc class.auth.inc.php, 1.12 class.accounts.inc.php, 1.18 common_functions.inc.php, 1.20 |
Date: |
Fri, 8 Apr 2005 10:56:00 +0200 |
Update of phpgwapi/inc
Removed Files:
Branch: MAIN
class.auth.inc.php
class.accounts.inc.php
Modified Files:
Branch: MAIN
common_functions.inc.php lines: +47 -71
Log Message:
logic moved to factory method
====================================================
Index: phpgwapi/inc/common_functions.inc.php
diff -u phpgwapi/inc/common_functions.inc.php:1.19
phpgwapi/inc/common_functions.inc.php:1.20
--- phpgwapi/inc/common_functions.inc.php:1.19 Thu Dec 30 06:47:31 2004
+++ phpgwapi/inc/common_functions.inc.php Fri Apr 8 08:56:22 2005
@@ -461,30 +461,49 @@
/*!
@function include_class
- @abstract This will include the class once and guarantee that it is
loaded only once. Similar to CreateObject, but does not instantiate the class.
- @author skeeter
- @discussion This will include the API class once and guarantee that it
is loaded only once. Similar to CreateObject, but does not instantiate the
class.
- @syntax include_class('setup');
- @example include_class('setup');
- @param $included_class API class to load
+ @abstract This will include an application class once and guarantee
that it is loaded only once. Similar to CreateObject, but does not instantiate
the class.
+ @author dschaller
+ @discussion This will include an application class once and guarantee
that it is loaded only once. Similar to CreateObject, but does not instantiate
the class.
+ @syntax include_class('<appName>.<className>', '<classPath>');
+ @example include_class('projects.ui_base');
+ @param $appName name of application
+ @param $className name of class
+ @param $classPath path to the application class, default is 'inc/',
use this parameter i.e. if the class is located in a subdirectory like
'inc/base_classes/'
+ @return boolean true if class is included, else false (false means
class could not included)
*/
- function include_class($included_class)
+ function include_class($appName, $className, $classPath='inc/')
{
- if
(!isset($GLOBALS['phpgw_info']['flags']['included_classes'][$included_class]) ||
-
!$GLOBALS['phpgw_info']['flags']['included_classes'][$included_class])
+ $fileName =
PHPGW_INCLUDE_ROOT.'/'.$appName.'/'.$classPath.'class.'.$className.'.inc.php';
+ $included_files = get_included_files();
+
+ if (!isset($included_files[$fileName]))
{
-
$GLOBALS['phpgw_info']['flags']['included_classes'][$included_class] = True;
-
include_once(PHPGW_SERVER_ROOT.'/phpgwapi/inc/class.'.$included_class.'.inc.php');
+ if(@file_exists($fileName))
+ {
+ include_once($fileName);
+ $is_included = True;
+ }
+ else
+ {
+ $is_included = False;
+ }
}
+ else
+ {
+ $is_included = True;
+ }
+
+ return $is_included;
}
+ // include object factory base class once
+
include_once(PHPGW_SERVER_ROOT.'/phpgwapi/inc/class.object_factory.inc.php');
/*!
@function CreateObject
- @abstract Load a class and include the class file if not done so
already.
- @author mdean
- @author milosch
- @author (thanks to jengo and ralf)
- @discussion This function is used to create an instance of a class,
and if the class file has not been included it will do so.
+ @abstract delegate the object creation into the module.
+ @author Dirk Schaller
+ @author Phillip Kamps
+ @discussion This function is used to create an instance of a class.
Its delegates the creation process into the called module and its factory
class. If a module has no factory class, then its use the old CreateObject
method. The old CreateObject method is moved into the base object factory class.
@syntax CreateObject('app.class', 'constructor_params');
@example $phpgw->acl = CreateObject('phpgwapi.acl');
@param $classname name of class
@@ -496,64 +515,21 @@
$p9='_UNDEF_',$p10='_UNDEF_',$p11='_UNDEF_',$p12='_UNDEF_',
$p13='_UNDEF_',$p14='_UNDEF_',$p15='_UNDEF_',$p16='_UNDEF_')
{
- global $phpgw_info, $phpgw;
-
- if (is_object(@$GLOBALS['phpgw']->log) && $class !=
'phpgwapi.error' && $class != 'phpgwapi.errorlog')
- {
- //$GLOBALS['phpgw']->log->write(array('text'=>'D-Debug,
dbg: %1','p1'=>'This class was run:
'.$class,'file'=>__FILE__,'line'=>__LINE__));
- }
+
+ list($appname,$classname) = explode('.', $class, 2);
- /* error_reporting(0); */
- list($appname,$classname) = explode('.', $class);
- $filename =
PHPGW_INCLUDE_ROOT.'/'.$appname.'/inc/class.'.$classname.'.inc.php';
- $included_files = get_included_files();
+ // include app object factory class
+ $of_classname = 'of'.$appname;
- if (!isset($included_files[$filename]))
- {
- if(@file_exists($filename))
- {
- include_once($filename);
- $is_included = True;
- }
- else
- {
- $is_included = False;
- }
- }
- else
+ // include module object factory class
+ if (!include_class($appname, $of_classname))
{
- $is_included = True;
- }
-
- if($is_included)
- {
- if ($p1 == '_UNDEF_' && $p1 != 1)
- {
- $obj = new $classname;
- }
- else
- {
- $input =
array($p1,$p2,$p3,$p4,$p5,$p6,$p7,$p8,$p9,$p10,$p11,$p12,$p13,$p14,$p15,$p16);
- $i = 1;
- $code = '$obj = new ' . $classname . '(';
- while (list($x,$test) = each($input))
- {
- if (($test == '_UNDEF_' && $test != 1 )
|| $i == 17)
- {
- break;
- }
- else
- {
- $code .= '$p' . $i . ',';
- }
- $i++;
- }
- $code = substr($code,0,-1) . ');';
- eval($code);
- }
- /* error_reporting(E_ERROR | E_WARNING | E_PARSE); */
- return $obj;
+ // fail to load module object factory -> use old
CreateObject in base class
+ $of_classname = 'object_factory';
}
+
+ // because $of_classname::CreateObject() is not allowed, we use
call_user_func
+ return call_user_func(array($of_classname,
'CreateObject'),$class,$p1,$p2,$p3,$p4,$p5,$p6,$p7,$p8,$p9,$p10,$p11,$p12,$p13,$p14,$p15,$p16);
}
/*!
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] phpgwapi/inc class.auth.inc.php, 1.12 class.accounts.inc.php, 1.18 common_functions.inc.php, 1.20,
fipsfuchs <=