Exemplo n.º 1
0
 public static function sortChildren(&$children)
 {
     $childRows = explode('<', $children);
     array_shift($childRows);
     // remove the first (empty) row
     $sort = array();
     $prevKey = 0;
     $pos = 0;
     $key = 0;
     foreach ($childRows as $childRow) {
         $pos++;
         $date = ESINHandler::getChildDate($childRow, 'birthdate');
         if (!$date) {
             $date = ESINHandler::getChildDate($childRow, 'chrdate');
         }
         if ($date) {
             $k = StructuredData::getDateKey($date, true);
             if ($k) {
                 $key = $k;
                 $prevKey = $key;
             }
         }
         if (!$key) {
             $key = $prevKey;
         }
         // if no date, assume same as previous
         $sort[$key * 50 + $pos] = $childRow;
     }
     if (count($sort)) {
         ksort($sort, SORT_NUMERIC);
         $children = '<' . join('<', $sort);
     }
 }