Example #1
0
 /**
  * Gets all objects
  *
  * @param CMS_poly_object_field $field, the reference field which will be used by those objects
  * @param boolean $sort, sort objects list (alphabetically by name). Use global $cms_language. Default false (unsorted).
  * @return array(string "CMS_object_{type}" => object CMS_object_{type})
  * @access public
  * @static
  */
 function getObjects(&$field, $sort = false)
 {
     $objectsNames = CMS_object_catalog::getObjectsNames();
     $return = array();
     foreach ($objectsNames as $anObjectName) {
         $return[$anObjectName] = new $anObjectName(array(), $field);
     }
     if ($sort) {
         global $cms_language;
         if (is_object($cms_language)) {
             $labels = array();
             foreach ($return as $key => $object) {
                 $labels[$key] = $object->getObjectLabel($cms_language);
             }
             //natural sort of objects
             natcasesort($labels);
             $returnSorted = array();
             foreach ($labels as $key => $label) {
                 $returnSorted[$key] = $return[$key];
             }
             $return = $returnSorted;
         }
     }
     return $return;
 }