Use global attributes variable
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 26 Aug 2010 18:23:12 +0000 (12:23 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 26 Aug 2010 19:26:35 +0000 (13:26 -0600)
turba/lib/Application.php
turba/lib/List.php
turba/lib/View/Duplicates.php

index e4305a8..e67bd48 100644 (file)
@@ -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
index c141265..31be0ff 100644 (file)
@@ -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'];
index a70fbf5..fbeee2a 100644 (file)
@@ -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'));