コード例 #1
0
 /**
  * returns the column headers as an array of tuples:
  * (name, sortName (key to the sort array))
  *
  * @param string $action the action being performed
  * @param enum   $output what should the result set include (web/email/csv)
  *
  * @return array the column headers that need to be displayed
  * @access public
  */
 function &getColumnHeaders($action = NULL, $output = NULL)
 {
     static $skipFields = array('group', 'tag');
     $multipleFields = array('url');
     $direction = CRM_Utils_Sort::ASCENDING;
     $empty = TRUE;
     if (!isset(self::$_columnHeaders)) {
         self::$_columnHeaders = array(array('name' => ''), array('name' => ts('Name'), 'sort' => 'sort_name', 'direction' => CRM_Utils_Sort::ASCENDING, 'field_name' => 'sort_name'));
         $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
         foreach ($this->_fields as $name => $field) {
             // skip pseudo fields
             if (substr($name, 0, 9) == 'phone_ext') {
                 continue;
             }
             if (!empty($field['in_selector']) && !in_array($name, $skipFields)) {
                 if (strpos($name, '-') !== FALSE) {
                     $value = explode('-', $name);
                     $fieldName = CRM_Utils_Array::value(0, $value);
                     $lType = CRM_Utils_Array::value(1, $value);
                     $type = CRM_Utils_Array::value(2, $value);
                     if (!in_array($fieldName, $multipleFields)) {
                         if ($lType == 'Primary') {
                             $locationTypeName = 1;
                         } else {
                             $locationTypeName = $locationTypes[$lType];
                         }
                         if (in_array($fieldName, array('phone', 'im', 'email'))) {
                             if ($type) {
                                 $name = "`{$locationTypeName}-{$fieldName}-{$type}`";
                             } else {
                                 $name = "`{$locationTypeName}-{$fieldName}`";
                             }
                         } else {
                             $name = "`{$locationTypeName}-{$fieldName}`";
                         }
                     } else {
                         $name = "website-{$lType}-{$fieldName}";
                     }
                 }
                 self::$_columnHeaders[] = array('name' => $field['title'], 'sort' => $name, 'direction' => $direction, 'field_name' => CRM_Core_BAO_UFField::isValidFieldName($name) ? $name : $fieldName);
                 $direction = CRM_Utils_Sort::DONTCARE;
                 $empty = FALSE;
             }
         }
         // if we dont have any valid columns, dont add the implicit ones
         // this allows the template to check on emptiness of column headers
         if ($empty) {
             self::$_columnHeaders = array();
         } else {
             self::$_columnHeaders[] = array('desc' => ts('Actions'));
         }
     }
     return self::$_columnHeaders;
 }
コード例 #2
0
ファイル: Listings.php プロジェクト: bhirsch/voipdev
 /**
  * returns the column headers as an array of tuples:
  * (name, sortName (key to the sort array))
  *
  * @param string $action the action being performed
  * @param enum   $output what should the result set include (web/email/csv)
  *
  * @return array the column headers that need to be displayed
  * @access public
  */
 function &getColumnHeaders($action = null, $output = null)
 {
     static $skipFields = array('group', 'tag');
     $direction = CRM_Utils_Sort::ASCENDING;
     $empty = true;
     if (!isset(self::$_columnHeaders)) {
         self::$_columnHeaders = array(array('name' => ''), array('name' => ts('Name'), 'sort' => 'sort_name', 'direction' => CRM_Utils_Sort::ASCENDING));
         require_once 'CRM/Core/PseudoConstant.php';
         $locationTypes = CRM_Core_PseudoConstant::locationType();
         foreach ($this->_fields as $name => $field) {
             if (CRM_Utils_Array::value('in_selector', $field) && !in_array($name, $skipFields)) {
                 if (strpos($name, '-') !== false) {
                     $value = explode('-', $name);
                     $fieldName = CRM_Utils_Array::value(0, $value);
                     $lType = CRM_Utils_Array::value(1, $value);
                     $type = CRM_Utils_Array::value(2, $value);
                     if ($lType == 'Primary') {
                         $locationTypeName = 1;
                     } else {
                         $locationTypeName = $locationTypes[$lType];
                     }
                     if (in_array($fieldName, array('phone', 'im', 'email'))) {
                         if ($type) {
                             $name = "`{$locationTypeName}-{$fieldName}-{$type}`";
                         } else {
                             $name = "`{$locationTypeName}-{$fieldName}`";
                         }
                     } else {
                         $name = "`{$locationTypeName}-{$fieldName}`";
                     }
                 }
                 self::$_columnHeaders[] = array('name' => $field['title'], 'sort' => $name, 'direction' => $direction);
                 $direction = CRM_Utils_Sort::DONTCARE;
                 $empty = false;
             }
         }
         // if we dont have any valid columns, dont add the implicit ones
         // this allows the template to check on emptiness of column headers
         if ($empty) {
             self::$_columnHeaders = array();
         } else {
             self::$_columnHeaders[] = array('desc' => ts('Actions'));
         }
     }
     return self::$_columnHeaders;
 }