Example #1
0
 /**
  * Sets sorting state of header by given sortingFields GP-var string.
  * String has following format: <fieldIdentifier1>:<sortingDirection1>;<fieldIdentifier2>:<sortingDirection2>
  *
  * @param string $sortingFields
  */
 protected function initByGpVarsSortingFields($sortingFields)
 {
     $this->sortedFields = array();
     $fieldsAndDirections = explode(';', $sortingFields);
     foreach ($fieldsAndDirections as $fieldAndSortingDirection) {
         list($fieldIdentifier, $sortingDirection) = explode(':', $fieldAndSortingDirection);
         if (in_array($sortingDirection, array(Tx_PtExtlist_Domain_QueryObject_Query::SORTINGSTATE_ASC, Tx_PtExtlist_Domain_QueryObject_Query::SORTINGSTATE_DESC)) && $this->sortingFieldConfig->hasItem($fieldIdentifier)) {
             $this->sortedFields[$fieldIdentifier] = $sortingDirection;
         }
     }
 }
 /**
  * Generate an array by field configuration - direction is NULL here
  *
  * @param Tx_PtExtlist_Domain_Configuration_Data_Fields_FieldConfigCollection $fieldConfigCollection
  * @return Tx_PtExtlist_Domain_Configuration_Columns_SortingConfigCollection
  */
 public static function getInstanceByFieldConfiguration(Tx_PtExtlist_Domain_Configuration_Data_Fields_FieldConfigCollection $fieldConfigCollection)
 {
     // We create a sorting field configuration that only sorts a whole column at once (hence param is true)
     $sortingConfigCollection = new Tx_PtExtlist_Domain_Configuration_Columns_SortingConfigCollection(true);
     foreach ($fieldConfigCollection as $fieldConfig) {
         // We create sorting config with descending sorting as default sorting
         $sortingConfig = new Tx_PtExtlist_Domain_Configuration_Columns_SortingConfig($fieldConfig->getIdentifier(), Tx_PtExtlist_Domain_QueryObject_Query::SORTINGSTATE_ASC, false);
         $sortingConfigCollection->addSortingField($sortingConfig, $fieldConfig->getIdentifier());
     }
     return $sortingConfigCollection;
 }