From 9250c90556aae40153c7ab6cda090b6dadd2279c Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 26 Aug 2010 12:23:12 -0600 Subject: [PATCH] Use global attributes variable --- turba/lib/Application.php | 5 +++-- turba/lib/List.php | 15 ++------------- turba/lib/View/Duplicates.php | 6 ++---- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/turba/lib/Application.php b/turba/lib/Application.php index e4305a890..e67bd485a 100644 --- a/turba/lib/Application.php +++ b/turba/lib/Application.php @@ -46,7 +46,8 @@ class Turba_Application extends Horde_Registry_Application * * Global variables defined: * $addSources - TODO - * $attributes - TODO + * $attributes - (array) Attribute data from the config/attributes.php + * file. * $browse_source_count - TODO * $browse_source_options - TODO * $cfgSources - TODO @@ -57,7 +58,7 @@ class Turba_Application extends Horde_Registry_Application protected function _init() { // Turba source and attribute configuration. - include TURBA_BASE . '/config/attributes.php'; + $attributes = Horde::loadConfiguration('attributes.php', 'attributes', 'turba'); include TURBA_BASE . '/config/sources.php'; /* UGLY UGLY UGLY - we should NOT be using this as a global diff --git a/turba/lib/List.php b/turba/lib/List.php index c14126570..31be0ffa0 100644 --- a/turba/lib/List.php +++ b/turba/lib/List.php @@ -24,13 +24,6 @@ class Turba_List implements Countable public $objects = array(); /** - * Cached attributes array. - * - * @var array - */ - protected $_attributes = null; - - /** * The field to compare objects by. * * @var string @@ -162,16 +155,12 @@ class Turba_List implements Countable */ protected function _cmp($a, $b) { - if (is_null($this->_attributes)) { - $this->_attributes = Horde::loadConfiguration('attributes.php', 'attributes', 'turba'); - } - foreach ($this->_usortCriteria as $field) { // Set the comparison type based on the type of attribute we're // sorting by. $sortmethod = 'text'; - if (isset($this->_attributes[$field['field']])) { - $f = $this->_attributes[$field['field']]; + if (isset($GLOBALS['attributes'][$field['field']])) { + $f = $GLOBALS['attributes'][$field['field']]; if (!empty($f['cmptype'])) { $sortmethod = $f['cmptype']; diff --git a/turba/lib/View/Duplicates.php b/turba/lib/View/Duplicates.php index a70fbf5d8..fbeee2af6 100644 --- a/turba/lib/View/Duplicates.php +++ b/turba/lib/View/Duplicates.php @@ -68,8 +68,6 @@ class Turba_View_Duplicates */ public function display() { - $attributes = Horde::loadConfiguration(TURBA_BASE . '/config/attributes.php', 'attributes', 'turba'); - $view = new Horde_View(array('templatePath' => TURBA_TEMPLATES . '/search/duplicate')); new Horde_View_Helper_Text($view); @@ -78,7 +76,7 @@ class Turba_View_Duplicates isset($this->_duplicates[$this->_type][$this->_duplicate]); if ($hasDuplicate) { $vars = new Horde_Variables(); - $view->type = $attributes[$this->_type]['label']; + $view->type = $GLOBALS['attributes'][$this->_type]['label']; $view->value = $this->_duplicate; echo $view->render('header'); @@ -114,7 +112,7 @@ class Turba_View_Duplicates $view->duplicates = $this->_duplicates; $view->hasDuplicate = (bool)$hasDuplicate; - $view->attributes = $attributes; + $view->attributes = $GLOBALS['attributes']; $view->link = Horde::applicationUrl('search.php') ->add(array('source' => $this->_driver->name, 'search_mode' => 'duplicate')); -- 2.11.0