removed unnecessary instancations and using static methods of html and egw_link class

This commit is contained in:
Ralf Becker 2008-03-25 16:42:23 +00:00
parent afe2795f2d
commit 5fd2d8def8
9 changed files with 7 additions and 69 deletions

View File

@ -177,9 +177,6 @@
$GLOBALS['egw_info']['flags']['include_xajax'] = True; $GLOBALS['egw_info']['flags']['include_xajax'] = True;
// JavaScript // JavaScript
if(!is_object($GLOBALS['egw']->js)) {
$GLOBALS['egw']->js =& CreateObject('phpgwapi.javascript');
}
$options = $GLOBALS['egw']->js->convert_phparray_jsarray("options['$name']", $options, true); $options = $GLOBALS['egw']->js->convert_phparray_jsarray("options['$name']", $options, true);
$GLOBALS['egw']->js->set_onload("if(!options) { $GLOBALS['egw']->js->set_onload("if(!options) {
var options = new Object(); var options = new Object();

View File

@ -452,12 +452,7 @@ class bo_tracking
*/ */
function get_title($data,$old) function get_title($data,$old)
{ {
if (!is_object($GLOBALS['egw']->link)) return egw_link::title($this->app,$data[$this->id_field]);
{
require_once(EGW_API_INC.'/class.bolink.inc.php');
$GLOBALS['egw']->link =& new bolink();
}
return $GLOBALS['egw']->link->title($this->app,$data[$this->id_field]);
} }
/** /**
@ -471,12 +466,7 @@ class bo_tracking
*/ */
function get_subject($data,$old) function get_subject($data,$old)
{ {
if (!is_object($GLOBALS['egw']->link)) return egw_link::title($this->app,$data[$this->id_field]);
{
require_once(EGW_API_INC.'/class.bolink.inc.php');
$GLOBALS['egw']->link =& new bolink();
}
return $GLOBALS['egw']->link->title($this->app,$data[$this->id_field]);
} }
/** /**
@ -514,15 +504,10 @@ class bo_tracking
} }
else else
{ {
if (!is_object($GLOBALS['egw']->link)) if (($view = egw_link::view($this->app,$data[$this->id_field])))
{
require_once(EGW_API_INC.'/class.bolink.inc.php');
$GLOBALS['egw']->link =& new bolink();
}
if (($view = $GLOBALS['egw']->link->view($this->app,$data[$this->id_field])))
{ {
$link = $GLOBALS['egw']->link('/index.php',$view); $link = $GLOBALS['egw']->link('/index.php',$view);
$popup = $GLOBALS['egw']->link->is_popup($this->app,'view'); $popup = egw_link::is_popup($this->app,'view');
} }
} }
if ($link{0} == '/') if ($link{0} == '/')
@ -553,10 +538,10 @@ class bo_tracking
{ {
$GLOBALS['egw']->link = new bolink(); $GLOBALS['egw']->link = new bolink();
} }
if($view = $GLOBALS['egw']->link->view($this->app,$data[$this->id_field])) { if($view = egw_link::view($this->app,$data[$this->id_field])) {
return array( 'text' => $this->get_title($data,$old), return array( 'text' => $this->get_title($data,$old),
'view' => $view, 'view' => $view,
'popup' => $GLOBALS['egw']->link->is_popup($this->app,'view'), 'popup' => egw_link::is_popup($this->app,'view'),
); );
} }
return false; return false;

View File

@ -57,10 +57,7 @@ class contact_widget
function contact_widget($ui) function contact_widget($ui)
{ {
$this->ui = $ui; $this->ui = $ui;
if (!is_object($GLOBALS['egw']->contacts))
{
$GLOBALS['egw']->contacts =& CreateObject('phpgwapi.contacts');
}
$this->contacts =& $GLOBALS['egw']->contacts; $this->contacts =& $GLOBALS['egw']->contacts;
} }

View File

@ -64,10 +64,6 @@
{ {
if ($ui == 'html') if ($ui == 'html')
{ {
if (!is_object($GLOBALS['egw']->jscalendar))
{
$GLOBALS['egw']->jscalendar =& CreateObject('phpgwapi.jscalendar');
}
$this->jscal =& $GLOBALS['egw']->jscalendar; $this->jscal =& $GLOBALS['egw']->jscalendar;
} }
$this->timeformat = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat']; $this->timeformat = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'];

View File

@ -68,10 +68,6 @@ class historylog_widget
} }
else // compatibilty code for 1.2, can be removed after else // compatibilty code for 1.2, can be removed after
{ {
if (!is_object($GLOBALS['egw']->datetime))
{
$GLOBALS['egw']->datetime =& CreateObject('phpgwapi.datetime');
}
$value = $historylog->return_array('','','history_id','DESC',$id); $value = $historylog->return_array('','','history_id','DESC',$id);
foreach($value as $key => $val) foreach($value as $key => $val)
{ {

View File

@ -972,10 +972,6 @@
case 'select-cat': case 'select-cat':
if ($val) if ($val)
{ {
if (!is_object($GLOBALS['egw']->categories))
{
$GLOBALS['egw']->categories =& CreateObject('phpgwapi.categories');
}
$value[$key] = $GLOBALS['egw']->categories->id2name($val); $value[$key] = $GLOBALS['egw']->categories->id2name($val);
} }
break; break;

View File

@ -137,10 +137,6 @@
break; break;
case 'select-country': // #Row|Extralabel,1=use country name, 0=use 2 letter-code case 'select-country': // #Row|Extralabel,1=use country name, 0=use 2 letter-code
if (!is_object($GLOBALS['egw']->country))
{
$GLOBALS['egw']->country =& CreateObject('phpgwapi.country');
}
$cell['sel_options'] = $GLOBALS['egw']->country->countries(); $cell['sel_options'] = $GLOBALS['egw']->country->countries();
if (($extension_data['country_use_name'] = $type) && $value) if (($extension_data['country_use_name'] = $type) && $value)
@ -155,19 +151,11 @@
break; break;
case 'select-state': case 'select-state':
if (!is_object($GLOBALS['egw']->country))
{
$GLOBALS['egw']->country =& CreateObject('phpgwapi.country');
}
$cell['sel_options'] = $GLOBALS['egw']->country->us_states(); $cell['sel_options'] = $GLOBALS['egw']->country->us_states();
$cell['no_lang'] = True; $cell['no_lang'] = True;
break; break;
case 'select-cat': // !$type == globals cats too, $type2: extraStyleMultiselect, $type3: application, if not current-app case 'select-cat': // !$type == globals cats too, $type2: extraStyleMultiselect, $type3: application, if not current-app
if (!is_object($GLOBALS['egw']->categories))
{
$GLOBALS['egw']->categories =& CreateObject('phpgwapi.categories');
}
if ($readonly) // for readonly we dont need to fetch all cat's, nor do we need to indent them by level if ($readonly) // for readonly we dont need to fetch all cat's, nor do we need to indent them by level
{ {
$cell['no_lang'] = True; $cell['no_lang'] = True;
@ -242,11 +230,6 @@
} }
if ($this->ui == 'html' && $type != 'groups') // use eGW's new account-selection (html only) if ($this->ui == 'html' && $type != 'groups') // use eGW's new account-selection (html only)
{ {
if (!is_object($GLOBALS['egw']->uiaccountsel))
{
require_once(EGW_API_INC.'/class.uiaccountsel.inc.php');
$GLOBALS['egw']->uiaccountsel =& new uiaccountsel;
}
$not = array_slice(explode(',',$cell['size']),4); $not = array_slice(explode(',',$cell['size']),4);
$help = (int)$cell['no_lang'] < 2 ? lang($cell['help']) : $cell['help']; $help = (int)$cell['no_lang'] < 2 ? lang($cell['help']) : $cell['help'];
$onFocus = "self.status='".addslashes(htmlspecialchars($help))."'; return true;"; $onFocus = "self.status='".addslashes(htmlspecialchars($help))."'; return true;";
@ -556,10 +539,6 @@
case 'select-country': case 'select-country':
if ($extension_data['country_use_name'] && $value_in) if ($extension_data['country_use_name'] && $value_in)
{ {
if (!is_object($GLOBALS['egw']->country))
{
$GLOBALS['egw']->country =& CreateObject('phpgwapi.country');
}
if (($value = $GLOBALS['egw']->country->get_full_name($value_in))) if (($value = $GLOBALS['egw']->country->get_full_name($value_in)))
{ {
break; break;

View File

@ -168,10 +168,6 @@ class so_sql
echo "<p>so_sql('$app','$table')</p>\n"; echo "<p>so_sql('$app','$table')</p>\n";
_debug_array($this); _debug_array($this);
} }
if (!is_object($GLOBALS['egw']->datetime))
{
$GLOBALS['egw']->datetime =& CreateObject('phpgwapi.datetime');
}
$this->tz_offset_s = $GLOBALS['egw']->datetime->tz_offset; $this->tz_offset_s = $GLOBALS['egw']->datetime->tz_offset;
$this->now = time() + $this->tz_offset_s; // time() is server-time and we need a user-time $this->now = time() + $this->tz_offset_s; // time() is server-time and we need a user-time
} }

View File

@ -66,10 +66,6 @@ class tree_widget
switch ($cell['type']) switch ($cell['type'])
{ {
case 'tree-cat': // !$type == globals cats too, $type2: not used, $type3: application, if not current-app case 'tree-cat': // !$type == globals cats too, $type2: not used, $type3: application, if not current-app
if (!is_object($GLOBALS['egw']->categories))
{
$GLOBALS['egw']->categories =& CreateObject('phpgwapi.categories');
}
if ($readonly) // for readonly we dont need to fetch all cat's, nor do we need to indent them by level if ($readonly) // for readonly we dont need to fetch all cat's, nor do we need to indent them by level
{ {
$cell['no_lang'] = True; $cell['no_lang'] = True;