Пример #1
0
 /**
  * User-defined array sorting callback, used for sorting $attachments_info.
  *
  * See the usort() documentation for further details.
  *
  * @access protected
  * @param Array $a The first attachment info array.
  * @param Array $b The second attachment info array.
  * @return int A value according to the rules from strcmp().
  */
 static function _sort_attachments_info_callback($a, $b)
 {
     return midcom_helper_datamanager2_type_blobs::sort_attachments_cmp($a['object'], $b['object']);
 }
Пример #2
0
 /**
  * User-defined array sorting callback, used for sorting $images. See the
  * usort() documentation for further details.
  *
  * @access protected
  * @param array $a The first image list.
  * @param array $b The second image list.
  * @return int A value according to the rules from strcmp().
  * @todo compare based on metadata->score and filename (or title ???)
  */
 function _sort_images_callback($a, $b)
 {
     // safety against broken images
     if (!empty($a['main']['object']) && !empty($b['main']['object'])) {
         $a_obj = $a['main']['object'];
         $b_obj = $b['main']['object'];
     } else {
         // Try to read the sort values from some other key
         if (is_array($a) && is_array($b)) {
             foreach ($a as $key => $data) {
                 if (!empty($a[$key]['object']) && !empty($b[$key]['object'])) {
                     $a_obj = $a[$key]['object'];
                     $b_obj = $b[$key]['object'];
                 }
             }
         }
     }
     if (empty($a_obj) && empty($b_obj)) {
         return 0;
     }
     return midcom_helper_datamanager2_type_blobs::sort_attachments_cmp($a_obj, $b_obj);
 }