private static function sort($a, $b) { $c = dcUtils::removeDiacritics(mb_strtolower($a->name())); $d = dcUtils::removeDiacritics(mb_strtolower($b->name())); if ($c == $d) { return 0; } return $c < $d ? -1 : 1; }
/** Computes statistics from a metadata recordset. Each record gets enriched with lowercase name, percent and roundpercent columns @param rs <b>record</b> recordset to enrich @return <b>record</b> the enriched recordset */ public function computeMetaStats($rs) { $rs_static = $rs->toStatic(); $max = array(); while ($rs_static->fetch()) { $type = $rs_static->meta_type; if (!isset($max[$type])) { $max[$type] = $rs_static->count; } else { if ($rs_static->count > $max[$type]) { $max[$type] = $rs_static->count; } } } while ($rs_static->fetch()) { $rs_static->set('meta_id_lower', dcUtils::removeDiacritics(mb_strtolower($rs_static->meta_id))); $count = $rs_static->count; $percent = (int) $rs_static->count * 100 / $max[$rs_static->meta_type]; $rs_static->set('percent', (int) round($percent)); $rs_static->set('roundpercent', round($percent / 10) * 10); } return $rs_static; }
private function lexicalSortCallback($a, $b) { $a = $a[$this->sortfield]; $b = $b[$this->sortfield]; # Integer values if ($a == (string) (int) $a && $b == (string) (int) $b) { $a = (int) $a; $b = (int) $b; return ($a - $b) * $this->sortsign; } return strcoll(strtolower(dcUtils::removeDiacritics($a)), strtolower(dcUtils::removeDiacritics($b))) * $this->sortsign; }
private static function lexicalSortHelper($a, $b) { return strcoll(strtolower(dcUtils::removeDiacritics($a)), strtolower(dcUtils::removeDiacritics($b))); }