예제 #1
0
/**
 * Parses a user date string into an rfc 3501 date string
 * Handles space, slash, backslash, dot and comma as separators (and dash of course ;=)
 * @global array imap_asearch_months
 * @param string user date
 * @return array a preg_match-style array:
 *  - [0] = fully formatted rfc 3501 date string (<day number>-<US month TLA>-<4 digit year>)
 *  - [1] = day
 *  - [2] = month
 *  - [3] = year
 */
function sqimap_asearch_parse_date($what)
{
    global $imap_asearch_months;
    $what = trim($what);
    $what = preg_replace('/[ \\/\\.,]+/', '-', $what);
    if ($what) {
        preg_match('/^([0-9]+)-+([^\\-]+)-+([0-9]+)$/', $what, $what_parts);
        if (count($what_parts) == 4) {
            $what_month = strtolower(asearch_unhtmlentities($what_parts[2]));
            /*                if (!in_array($what_month, $imap_asearch_months)) {*/
            foreach ($imap_asearch_months as $month_number => $month_code) {
                if ($what_month == $month_number || $what_month == $month_code || $what_month == strtolower(asearch_unhtmlentities(getMonthName($month_number))) || $what_month == strtolower(asearch_unhtmlentities(getMonthAbrv($month_number)))) {
                    $what_parts[2] = $month_number;
                    $what_parts[0] = $what_parts[1] . '-' . $month_code . '-' . $what_parts[3];
                    break;
                }
            }
            /*                }*/
        }
    } else {
        $what_parts = array();
    }
    return $what_parts;
}
예제 #2
0
/**
 * @param string $a
 * @param string $b
 * @return bool strcoll()-like result
 */
function asearch_unhtml_strcoll($a, $b)
{
    return strcoll(asearch_unhtmlentities($a), asearch_unhtmlentities($b));
}
예제 #3
0
/**
 * Array sort callback used to sort $imap_asearch_options
 * @param string $a
 * @param string $b
 * @return bool strcoll()-like result
 * @since 1.5.0
 * @private
 */
function asearch_unhtml_strcoll($a, $b)
{
    // FIXME: Translation policy says "no html entities in translations"
    return strcoll(asearch_unhtmlentities($a), asearch_unhtmlentities($b));
}