[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] api class.base.php, 1.1.1.1.2.3, 1.1.1.1.2.4 class.la
From: |
Dan Kuykendall <address@hidden> |
Subject: |
[Phpgroupware-cvs] api class.base.php, 1.1.1.1.2.3, 1.1.1.1.2.4 class.lang.php, 1.1.2.7, 1.1.2.8 class.phpgw.php, 1.1.1.1.2.8, 1.1.1.1.2.9 class.xmltool.php, 1.1.1.1.2.3, 1.1.1.1.2.4 core_functions.inc.php, 1.1.1.1.2.5, 1.1.1.1.2.6 |
Date: |
Mon, 27 Oct 2003 18:54:17 +0000 |
Update of /cvsroot/phpgroupware/api
In directory subversions:/tmp/cvs-serv1655/api
Modified Files:
Tag: proposal-branch
class.base.php class.lang.php class.phpgw.php
class.xmltool.php core_functions.inc.php
Log Message:
updated lang class to fix some odd things jengo did. Added lots of
documentation to the code, and while doing that I did a line by line review of
the starter.php and class.phpgw.php
Index: class.lang.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/Attic/class.lang.php,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -C2 -d -r1.1.2.7 -r1.1.2.8
*** class.lang.php 27 Oct 2003 08:54:08 -0000 1.1.2.7
--- class.lang.php 27 Oct 2003 18:54:15 -0000 1.1.2.8
***************
*** 47,70 ****
}
! function _translate($msg,$p1)
{
! //echo '$this->language: '.$this->language."<br>\n";
if($this->language == 'en')
{
! return sprintf($msg,$p1);
}
- $omsg = $msg;
- $msg = strtolower($msg);
- $result = gettext($msg);
! if($result == $msg && $this->registered_app != 'api')
{
$current_app = $this->registered_app;
$this->switchapp('api');
! $result = gettext($msg);
$this->registered_app = $current_app;
}
! if($result == $msg)
{
return $this->translate_service($omsg);
--- 47,75 ----
}
! function _translate()
{
! $args = new safe_args();
! $args->set('msg', '##REQUIRED##', 'any');
! $args->set('param1', '##NOTSET##', 'any');
! $args = $args->get(func_get_args(),__LINE__,__FILE__);
!
if($this->language == 'en')
{
! return sprintf($args['msg'],$args['param1']);
}
! $omsg = $args['msg'];
! $msg = strtolower($args['msg']);
! $result = gettext($args['msg']);
!
! if($result == $args['msg'] && $this->registered_app !=
'api')
{
$current_app = $this->registered_app;
$this->switchapp('api');
! $result = gettext($args['msg']);
$this->registered_app = $current_app;
}
! if($result == $args['msg'])
{
return $this->translate_service($omsg);
***************
*** 158,166 ****
$args = new safe_args();
$args->set('msg', '##REQUIRED##', 'any');
$args->set('app', '##NOTSET##', 'string');
$args = $args->get(func_get_args(),__LINE__,__FILE__);
- $v = func_get_args();
-
if(!isset($args['app']))
{
--- 163,170 ----
$args = new safe_args();
$args->set('msg', '##REQUIRED##', 'any');
+ $args->set('param1', '##NOTSET##', 'any');
$args->set('app', '##NOTSET##', 'string');
$args = $args->get(func_get_args(),__LINE__,__FILE__);
if(!isset($args['app']))
{
***************
*** 177,181 ****
$this->switchapp($args['app']);
! return $this->_translate($args['msg'],$v[0][1]);
}
--- 181,189 ----
$this->switchapp($args['app']);
! if(isset($args['param1']))
! {
! return
$this->_translate($args['msg'],$args['param1']);
! }
! return $this->_translate($args['msg']);
}
Index: core_functions.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/core_functions.inc.php,v
retrieving revision 1.1.1.1.2.5
retrieving revision 1.1.1.1.2.6
diff -C2 -d -r1.1.1.1.2.5 -r1.1.1.1.2.6
*** core_functions.inc.php 26 Oct 2003 07:54:48 -0000 1.1.1.1.2.5
--- core_functions.inc.php 27 Oct 2003 18:54:15 -0000 1.1.1.1.2.6
***************
*** 111,115 ****
if(function_exists('lang'))
{
! $msg = lang($msg);
}
$GLOBALS['msgbox']->add($class.' '.$msg,__LINE__,__FILE__, 'warning');
--- 111,115 ----
if(function_exists('lang'))
{
! $msg = lang($msg,
'##NOTSET##', 'api');
}
$GLOBALS['msgbox']->add($class.' '.$msg,__LINE__,__FILE__, 'warning');
***************
*** 150,154 ****
if(function_exists('lang'))
{
! $msg = lang($msg);
}
$GLOBALS['msgbox']->add($class.'::'.$methodname.' '.$msg,__LINE__,__FILE__,
'warning');
--- 150,154 ----
if(function_exists('lang'))
{
! $msg = lang($msg, '##NOTSET##',
'api');
}
$GLOBALS['msgbox']->add($class.'::'.$methodname.' '.$msg,__LINE__,__FILE__,
'warning');
***************
*** 299,303 ****
if(function_exists('lang'))
{
! $msg =
lang($msg);
}
$GLOBALS['msgbox']->add($msg.' "'.$key.'"',$line,$file, 'fatal');
--- 299,303 ----
if(function_exists('lang'))
{
! $msg =
lang($msg, '##NOTSET##', 'api');
}
$GLOBALS['msgbox']->add($msg.' "'.$key.'"',$line,$file, 'fatal');
***************
*** 315,319 ****
if(function_exists('lang'))
{
! $msg =
lang($msg);
}
$GLOBALS['msgbox']->add($msg.' "'.$key.'"',$line,$file, 'fatal');
--- 315,319 ----
if(function_exists('lang'))
{
! $msg =
lang($msg, '##NOTSET##', 'api');
}
$GLOBALS['msgbox']->add($msg.' "'.$key.'"',$line,$file, 'fatal');
***************
*** 411,420 ****
if(function_exists('lang'))
{
! $msg = lang($msg);
}
$msg2 = 'characters';
if(function_exists('lang'))
{
! $msg2 = lang($msg2);
}
$GLOBALS['msgbox']->add($msg.'
'.$min_length.' '.$msg2,__LINE__,__FILE__, 'error');
--- 411,420 ----
if(function_exists('lang'))
{
! $msg = lang($msg,
'##NOTSET##', 'api');
}
$msg2 = 'characters';
if(function_exists('lang'))
{
! $msg2 = lang($msg2,
'##NOTSET##', 'api');
}
$GLOBALS['msgbox']->add($msg.'
'.$min_length.' '.$msg2,__LINE__,__FILE__, 'error');
***************
*** 430,434 ****
if(function_exists('lang'))
{
! $msg = lang($msg);
}
$GLOBALS['msgbox']->add($msg
,__LINE__,__FILE__, 'error');
--- 430,434 ----
if(function_exists('lang'))
{
! $msg = lang($msg,
'##NOTSET##', 'api');
}
$GLOBALS['msgbox']->add($msg
,__LINE__,__FILE__, 'error');
***************
*** 444,448 ****
if(function_exists('lang'))
{
! $msg = lang($msg);
}
$GLOBALS['msgbox']->add($msg
,__LINE__,__FILE__, 'error');
--- 444,448 ----
if(function_exists('lang'))
{
! $msg = lang($msg,
'##NOTSET##', 'api');
}
$GLOBALS['msgbox']->add($msg
,__LINE__,__FILE__, 'error');
***************
*** 458,462 ****
if(function_exists('lang'))
{
! $msg = lang($msg);
}
$GLOBALS['msgbox']->add($msg
,__LINE__,__FILE__, 'error');
--- 458,462 ----
if(function_exists('lang'))
{
! $msg = lang($msg,
'##NOTSET##', 'api');
}
$GLOBALS['msgbox']->add($msg
,__LINE__,__FILE__, 'error');
Index: class.xmltool.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/class.xmltool.php,v
retrieving revision 1.1.1.1.2.3
retrieving revision 1.1.1.1.2.4
diff -C2 -d -r1.1.1.1.2.3 -r1.1.1.1.2.4
*** class.xmltool.php 26 Oct 2003 07:54:48 -0000 1.1.1.1.2.3
--- class.xmltool.php 27 Oct 2003 18:54:15 -0000 1.1.1.1.2.4
***************
*** 528,533 ****
else
{
- /*
$this->data =
htmlspecialchars($this->data);
if
(!sanitize($this->data,'isbaseasci'))
{
--- 528,533 ----
else
{
$this->data =
htmlspecialchars($this->data);
+ /*
if
(!sanitize($this->data,'isbaseasci'))
{
Index: class.phpgw.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/class.phpgw.php,v
retrieving revision 1.1.1.1.2.8
retrieving revision 1.1.1.1.2.9
diff -C2 -d -r1.1.1.1.2.8 -r1.1.1.1.2.9
*** class.phpgw.php 26 Oct 2003 07:54:48 -0000 1.1.1.1.2.8
--- class.phpgw.php 27 Oct 2003 18:54:15 -0000 1.1.1.1.2.9
***************
*** 24,27 ****
--- 24,32 ----
/* $Id$ */
+ /*!
+ @class api_phpgw
+ @abstract Central handler class in the api.
+ */
+
class api_phpgw
{
***************
*** 43,46 ****
--- 48,52 ----
var $xslt_render;
var $xslt_render_force_server = False;
+ var $base_classes_loaded = False;
/**************************************************************************\
***************
*** 48,51 ****
--- 54,65 ----
\**************************************************************************/
+ /*!
+ @function check_login
+ @abstract Checks the login and loads up the users base classes.
+ @discussion Detects if the user is valid, if not it creates the
user as anoymous, loads up the base classes and sets the default action for an
anonymous user.
+ If the user is valid, then it loads up their base classes. If
the user is logging it, then it authenticates them, and either sends them back
to the login,
+ or loads up their base classes.
+ @param $force bool used to force a login screen.
+ */
function check_login($force = False)
{
***************
*** 71,75 ****
if($this->auth->authenticate($GLOBALS['phpgw_data']['api']['phpgw_user'],
$GLOBALS['phpgw_data']['api']['phpgw_pass']))
{
- //$this->accounts =
createobject('api_accounts',$GLOBALS['phpgw_data']['api']['phpgw_user']);
$this->session->create($GLOBALS['phpgw_data']['api']['phpgw_user']);
unset($GLOBALS['phpgw_data']['api']['op']);
--- 85,88 ----
***************
*** 89,134 ****
}
}
! $this->load_base();
}
! function load_base()
{
! /* load up the accounts, preferences and application
classeses */
! /* and also have them send their appropriate data to
phpgw_data */
! $this->accounts =
createobject('api_accounts',$GLOBALS['phpgw_session']['session_lid']);
! $this->accounts->fill_phpgw_data();
! $this->acl = createobject('api_acl');
!
! $this->prefs = createobject('api_prefs');
! $this->prefs->fill_phpgw_data();
//$GLOBALS['phpgw_data']['server']['translate_service'] = 'google';
//$GLOBALS['phpgw_data']['prefs']['api.lang'] = 'es';
! $this->lang = createobject('api_lang');
! $this->lang->switchlang();
! $this->apps = createobject('api_apps');
! $this->apps->fill_phpgw_data();
}
function add_xsl($xsl)
{
! $this->xsl_files[] = $xsl;
$this->xsl_files = array_unique($this->xsl_files);
}
function add_css($css)
{
! $this->css_files[] = $css;
$this->css_files = array_unique($this->css_files);
}
function add_js($js)
{
! $this->js_files[] = $js;
$this->js_files = array_unique($this->js_files);
}
function apimenu()
{
--- 102,186 ----
}
}
! $this->load_base_classes();
}
! /*!
! @function load_base_classes
! @abstract Loads up the users base classes only once.
! */
! function load_base_classes()
{
! if (!$this->base_classes_loaded)
! {
! /* load up the accounts, preferences and
application classeses */
! /* and also have them send their appropriate
data to phpgw_data */
! $this->accounts =
createobject('api_accounts',$GLOBALS['phpgw_session']['session_lid']);
! $this->accounts->fill_phpgw_data();
! $this->acl = createobject('api_acl');
!
! $this->prefs = createobject('api_prefs');
! $this->prefs->fill_phpgw_data();
//$GLOBALS['phpgw_data']['server']['translate_service'] = 'google';
//$GLOBALS['phpgw_data']['prefs']['api.lang'] = 'es';
! $this->lang = createobject('api_lang');
! $this->lang->switchlang();
! $this->apps = createobject('api_apps');
! $this->apps->fill_phpgw_data();
! $this->base_classes_loaded = True;
! }
}
+ /*!
+ @function add_xsl
+ @abstract Adds another xsl file to the list of those required
by the current operation.
+ @param $xsl
+ */
function add_xsl($xsl)
{
! $args = new safe_args();
! $args->set('xsl', '##REQUIRED##', 'string');
! $args = $args->get(func_get_args(),__LINE__,__FILE__);
!
! $this->xsl_files[] = $args['xsl'];
$this->xsl_files = array_unique($this->xsl_files);
}
+ /*!
+ @function add_css
+ @abstract Adds another css file to the list of those required
by the current operation.
+ @param $css
+ */
function add_css($css)
{
! $args = new safe_args();
! $args->set('css', '##REQUIRED##', 'string');
! $args = $args->get(func_get_args(),__LINE__,__FILE__);
!
! $this->css_files[] = $args['css'];
$this->css_files = array_unique($this->css_files);
}
+ /*!
+ @function add_js
+ @abstract Adds another javascript file to the list of those
required by the current operation.
+ @param $js
+ */
function add_js($js)
{
! $args = new safe_args();
! $args->set('js', '##REQUIRED##', 'string');
! $args = $args->get(func_get_args(),__LINE__,__FILE__);
!
! $this->js_files[] = $args['js'];
$this->js_files = array_unique($this->js_files);
}
+ /*!
+ @function apimenu private
+ @abstract Adds the api's menu to the xml
+ */
function apimenu()
{
***************
*** 136,140 ****
{
$menu[] = array(
! 'title' => lang('Home', 'api'),
'op' => 'api.base.start',
);
--- 188,192 ----
{
$menu[] = array(
! 'title' => lang('Home', '##NOTSET##' ,
'api'),
'op' => 'api.base.start',
);
***************
*** 143,147 ****
{
$menu[] = array(
! 'title' => lang('Admin', 'api'),
'op' => 'api.admin.start',
);
--- 195,199 ----
{
$menu[] = array(
! 'title' => lang('Admin', '##NOTSET##',
'api'),
'op' => 'api.admin.start',
);
***************
*** 150,154 ****
{
$menu[] = array(
! 'title' => lang('Preferences', 'api'),
'op' => 'api.base.prefs',
);
--- 202,206 ----
{
$menu[] = array(
! 'title' => lang('Preferences',
'##NOTSET##', 'api'),
'op' => 'api.base.prefs',
);
***************
*** 157,166 ****
{
$menu[] = array(
! 'title' => lang('About', 'api'),
'op' => 'api.base.about',
);
}
$menu[] = array(
! 'title' => lang('Logout', 'api'),
'op' => 'api.base.logout',
);
--- 209,218 ----
{
$menu[] = array(
! 'title' => lang('About', '##NOTSET##',
'api'),
'op' => 'api.base.about',
);
}
$menu[] = array(
! 'title' => lang('Logout', '##NOTSET##', 'api'),
'op' => 'api.base.logout',
);
***************
*** 169,177 ****
}
! function phpgw_out($loadmainxsl = True, $loadmaincss = True)
{
/* Check to see if we should load the main xsl */
! if($loadmainxsl)
{
$this->add_xsl('api.phpgw');
--- 221,242 ----
}
+ /*!
+ @function phpgw_out
+ @abstract This is a the primary function used for packaging
everything up before sending anything out to the browser.
+ @discussion This function collects everything to be packaged
into the XML, and what needs to be send to the XSLT class.
+ */
! function phpgw_out()
{
+ $args = new safe_args();
+ $args->set('loadmainxsl', True, 'bool');
+ $args->set('loadmaincss', True, 'bool');
+ $args = $args->get(func_get_args(),__LINE__,__FILE__);
+
+ /* Make sure the base classes are loaded. */
+ $this->load_base_classes();
+
/* Check to see if we should load the main xsl */
! if($args['loadmainxsl'])
{
$this->add_xsl('api.phpgw');
***************
*** 186,199 ****
}
if(count($this->hooks->data) > 0)
{
$GLOBALS['phpgw_xml_apinode']->add_node($this->hooks->data,'hooks');
}
- //html_print_r($GLOBALS);
$GLOBALS['phpgw_xml_apinode']->add_node($this->apimenu(),'apimenu');
/* Add the css files to the API XML node */
! if($loadmaincss)
{
$this->add_css('api.default');
--- 251,264 ----
}
+ /* If any, add the hooks to the API XML node */
if(count($this->hooks->data) > 0)
{
$GLOBALS['phpgw_xml_apinode']->add_node($this->hooks->data,'hooks');
}
$GLOBALS['phpgw_xml_apinode']->add_node($this->apimenu(),'apimenu');
/* Add the css files to the API XML node */
! if($args['loadmaincss'])
{
$this->add_css('api.default');
***************
*** 208,211 ****
--- 273,277 ----
}
+ /* Add the javascript files to the API XML node */
$n = count($this->js_files);
for($i=0;$i<$n;$i++)
***************
*** 224,236 ****
$GLOBALS['phpgw_xml_apinode']->add_node($op,'op');
! /* Handle required data if missing */
! if(!isset($GLOBALS['phpgw_data']['prefs']['api.skin'])
||
!
!is_dir(PHPGW_ROOT.SEP.$app.SEP.'skins'.SEP.$GLOBALS['phpgw_data']['prefs']['api.skin']))
! {
! $GLOBALS['phpgw_data']['prefs']['api.skin'] =
'default';
! }
!
$GLOBALS['phpgw_xml_apinode']->add_node($this->session->baseurl,'baseurl');
$GLOBALS['phpgw_xml_apinode']->add_node($GLOBALS['phpgw_data']['apps'],'apps');
$GLOBALS['phpgw_xml_apinode']->add_node($GLOBALS['phpgw_data']['user'],'user');
--- 290,298 ----
$GLOBALS['phpgw_xml_apinode']->add_node($op,'op');
! /* Add the basepath and baseurl to the xml contents */
!
$GLOBALS['phpgw_xml_apinode']->add_node($this->session->basepath,'basepath');
$GLOBALS['phpgw_xml_apinode']->add_node($this->session->baseurl,'baseurl');
+ /* Add the users account, apps and prefs data */
$GLOBALS['phpgw_xml_apinode']->add_node($GLOBALS['phpgw_data']['apps'],'apps');
$GLOBALS['phpgw_xml_apinode']->add_node($GLOBALS['phpgw_data']['user'],'user');
***************
*** 274,277 ****
--- 336,344 ----
}
+ /*!
+ @function phpgw_op_out
+ @abstract Takes the results of the operation, packs it up and
then has phpgw_out handle the rest.
+ @param $app_data
+ */
function phpgw_op_out($app_data = '')
{
***************
*** 280,287 ****
--- 347,362 ----
}
+ /*!
+ @function phpgw_final
+ @abstract Not used, but may be used as the registered shutdown
function, and will redirect to phpgw_out
+ */
function phpgw_final()
{
}
+ /*!
+ @function check_op
+ @abstract Picks up and parses the op param and makes sure that
its values are generally sane.
+ */
function check_op()
{
Index: class.base.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/class.base.php,v
retrieving revision 1.1.1.1.2.3
retrieving revision 1.1.1.1.2.4
diff -C2 -d -r1.1.1.1.2.3 -r1.1.1.1.2.4
*** class.base.php 26 Oct 2003 07:43:06 -0000 1.1.1.1.2.3
--- class.base.php 27 Oct 2003 18:54:14 -0000 1.1.1.1.2.4
***************
*** 24,29 ****
--- 24,37 ----
/* $Id$ */
+ /*!
+ @class api_base
+ @abstract Default class for the api operations. Each app is required to
have one.
+ */
class api_base
{
+ /*!
+ @function start
+ @abstract The default operation for the api. main task is to
load the hooks for api.start
+ */
function start()
{
***************
*** 35,45 ****
}
function login()
{
$GLOBALS['phpgw']->add_xsl('api.login');
- $GLOBALS['phpgw']->load_base();
$GLOBALS['phpgw']->phpgw_out(False);
}
function logout()
{
--- 43,60 ----
}
+ /*!
+ @function login
+ @abstract Catches login requests and then kicks off the login
screen
+ */
function login()
{
$GLOBALS['phpgw']->add_xsl('api.login');
$GLOBALS['phpgw']->phpgw_out(False);
}
+ /*!
+ @function logout
+ @abstract Handles logouts. First kills the session, then sets
the op to login, which then creates a new anonymous session and goes thru
api.base.login
+ */
function logout()
{
***************
*** 48,51 ****
--- 63,70 ----
}
+ /*!
+ @function about
+ @abstract Just displays the about screen
+ */
function about()
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] api class.base.php, 1.1.1.1.2.3, 1.1.1.1.2.4 class.lang.php, 1.1.2.7, 1.1.2.8 class.phpgw.php, 1.1.1.1.2.8, 1.1.1.1.2.9 class.xmltool.php, 1.1.1.1.2.3, 1.1.1.1.2.4 core_functions.inc.php, 1.1.1.1.2.5, 1.1.1.1.2.6,
Dan Kuykendall <address@hidden> <=