Author: peter
Date: Fri Sep 18 16:41:54 2009
New Revision: 3417

Log:
make informationobject treeview sorting an admin option. fixes issue #909

Modified:
   
trunk/apps/qubit/modules/informationobject/actions/contextMenuComponent.class.php
   trunk/apps/qubit/modules/settings/actions/listAction.class.php
   trunk/data/fixtures/settings.yml
   trunk/lib/form/SettingsGlobalForm.class.php
   trunk/lib/model/QubitInformationObject.php

Modified: 
trunk/apps/qubit/modules/informationobject/actions/contextMenuComponent.class.php
==============================================================================
--- 
trunk/apps/qubit/modules/informationobject/actions/contextMenuComponent.class.php
   Fri Sep 18 16:00:11 2009        (r3416)
+++ 
trunk/apps/qubit/modules/informationobject/actions/contextMenuComponent.class.php
   Fri Sep 18 16:41:54 2009        (r3417)
@@ -155,7 +155,7 @@
   {
     $tmp = array();
 
-    foreach ($ancestor->getChildren(array('sortBy' => 'title')) as $child)
+    foreach ($ancestor->getChildren(array('sortBy' => 
sfConfig::get('app_sort_treeview_informationobject'))) as $child)
     {
       // If ancestor is not the empty root node
       // Or it children is in $path
@@ -173,7 +173,7 @@
         // If it is the selected information object, add it children
         else if ($child->getId() == $this->informationObject->getId())
         {
-          foreach ($child->getChildren(array('sortBy' => 'title')) as $ch)
+          foreach ($child->getChildren(array('sortBy' => 
sfConfig::get('app_sort_treeview_informationobject'))) as $ch)
           {
             $tmp[] = $ch;
           }

Modified: trunk/apps/qubit/modules/settings/actions/listAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/settings/actions/listAction.class.php      Fri Sep 
18 16:00:11 2009        (r3416)
+++ trunk/apps/qubit/modules/settings/actions/listAction.class.php      Fri Sep 
18 16:41:54 2009        (r3417)
@@ -159,6 +159,7 @@
     $refImageMaxWidth = 
QubitSetting::getSettingByName('reference_image_maxwidth');
     $hitsPerPage = QubitSetting::getSettingByName('hits_per_page');
     $inheritCodeInformationObject = 
QubitSetting::getSettingByName('inherit_code_informationobject');
+    $sortTreeviewInformationObject = 
QubitSetting::getSettingByName('sort_treeview_informationobject');
     $multiRepository = QubitSetting::getSettingByName('multi_repository');
 
     // Set defaults for global form
@@ -168,6 +169,7 @@
       'reference_image_maxwidth' => (isset($refImageMaxWidth)) ? 
$refImageMaxWidth->getValue(array('sourceCulture'=>true)) : null,
       'hits_per_page' => (isset($hitsPerPage)) ? 
$hitsPerPage->getValue(array('sourceCulture'=>true)) : null,
       'inherit_code_informationobject' => 
(isset($inheritCodeInformationObject)) ? 
intval($inheritCodeInformationObject->getValue(array('sourceCulture'=>true))) : 
1,
+      'sort_treeview_informationobject' => 
(isset($sortTreeviewInformationObject)) ? 
$sortTreeviewInformationObject->getValue(array('sourceCulture'=>true)) : 0,
       'multi_repository' => (isset($multiRepository)) ? 
intval($multiRepository->getValue(array('sourceCulture'=>true))) : 1
     ));
   }
@@ -215,6 +217,16 @@
       $setting->save();
     }
 
+    // Sort Treeview (Information Object)
+    if (null !== $sortTreeviewInformationObjectValue = 
$thisForm->getValue('sort_treeview_informationobject'))
+    {
+      $setting = 
QubitSetting::getSettingByName('sort_treeview_informationobject');
+
+       // Force sourceCulture update to prevent discrepency in settings 
between cultures
+      $setting->setValue($sortTreeviewInformationObjectValue, 
array('sourceCulture'=>true));
+      $setting->save();
+    }
+
     // Multi-repository radio button
     if (null !== $multiRepositoryValue = 
$thisForm->getValue('multi_repository'))
     {

Modified: trunk/data/fixtures/settings.yml
==============================================================================
--- trunk/data/fixtures/settings.yml    Fri Sep 18 16:00:11 2009        (r3416)
+++ trunk/data/fixtures/settings.yml    Fri Sep 18 16:41:54 2009        (r3417)
@@ -24,6 +24,11 @@
     editable: 1
     deleteable: 0
     value: 1
+  QubitSetting_sort_treeview:
+    name: sort_treeview_informationobject
+    editable: 1
+    deleteable: 0
+    value: 'none'
   QubitSetting_8:
     name: informationobject
     scope: default_template

Modified: trunk/lib/form/SettingsGlobalForm.class.php
==============================================================================
--- trunk/lib/form/SettingsGlobalForm.class.php Fri Sep 18 16:00:11 2009        
(r3416)
+++ trunk/lib/form/SettingsGlobalForm.class.php Fri Sep 18 16:41:54 2009        
(r3417)
@@ -44,6 +44,7 @@
       'reference_image_maxwidth' => new sfWidgetFormInput,
       'hits_per_page' => new sfWidgetFormInput,
       'inherit_code_informationobject' => new 
sfWidgetFormSelectRadio(array('choices'=>array(1=>'yes', 0=>'no')), 
array('class'=>'radio')),
+      'sort_treeview_informationobject' => new 
sfWidgetFormSelectRadio(array('choices'=>array('none'=>'none', 
'title'=>'title', 'identifierTitle'=> 'identifier - title')), 
array('class'=>'radio')),
       'multi_repository' => new 
sfWidgetFormSelectRadio(array('choices'=>array(1=>'yes', 0=>'no')), 
array('class'=>'radio'))
     ));
 
@@ -54,6 +55,7 @@
       'reference_image_maxwidth' => __('maximum image width (pixels)'),
       'hits_per_page' => __('results per page'),
       'inherit_code_informationobject' => __('inherit reference code 
(information object)'),
+      'sort_treeview_informationobject' => __('sort treeview (information 
object)'),
       'multi_repository' => __('multiple repositories')
     ));
 
@@ -64,6 +66,7 @@
       'reference_image_maxwidth' => __('The maximum width for derived 
reference images'),
       'hits_per_page' => __('The number of records shown per page on list 
pages'),
       'inherit_code_informationobject' => __('When set to "yes", the 
reference code string will be built using the information object identifier 
plus the identifiers of all its ancestors'),
+      'sort_treeview_informationobject' => __('Determines whether to sort 
siblings in the information object treeview control and, if so, what sort 
criteria to use'),
       'multi_repository' => __('When set to "no", the repository 
name is excluded from certain displays because it will be too repetitive')
     ));
 
@@ -97,8 +100,9 @@
 
     $this->validatorSchema['version'] = new sfValidatorString(array('required' 
=> false));
     $this->validatorSchema['upload_dir'] = new 
sfValidatorString(array('required' => false));
-    $this->validatorSchema['multi_repository'] = new 
sfValidatorInteger(array('required' => false));
     $this->validatorSchema['inherit_code_informationobject'] = new 
sfValidatorInteger(array('required' => false));
+    $this->validatorSchema['sort_treeview_informationobject'] = new 
sfValidatorString(array('required' => false));
+    $this->validatorSchema['multi_repository'] = new 
sfValidatorInteger(array('required' => false));
 
     // Set decorator
     $decorator = new QubitWidgetFormSchemaFormatterList($this->widgetSchema);

Modified: trunk/lib/model/QubitInformationObject.php
==============================================================================
--- trunk/lib/model/QubitInformationObject.php  Fri Sep 18 16:00:11 2009        
(r3416)
+++ trunk/lib/model/QubitInformationObject.php  Fri Sep 18 16:41:54 2009        
(r3417)
@@ -464,6 +464,7 @@
         $c = QubitCultureFallback::addFallbackCriteria($c, 
'QubitInformationObject');
         $c->addAscendingOrderByColumn('title');
         break;
+      case 'none':
       case 'lft':
       default:
         $c->addAscendingOrderByColumn('lft');

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to