コード例 #1
0
ファイル: lang.inc.php プロジェクト: ruthmagnus/audacity
function locale_to_unicode($s)
{
    global $encoding;
    $locale_encoding = nl_langinfo(CODESET);
    $s = iconv($locale_encoding, $encoding, $s);
    return $s;
}
コード例 #2
0
ファイル: Yes.php プロジェクト: oz-framework/validation
 public function __construct($useLocale = false)
 {
     $pattern = '^y(eah?|ep|es)?$';
     if ($useLocale && defined('YESEXPR')) {
         $pattern = nl_langinfo(YESEXPR);
     }
     parent::__construct('/' . $pattern . '/i');
 }
コード例 #3
0
ファイル: No.php プロジェクト: oz-framework/validation
 public function __construct($useLocale = false)
 {
     $pattern = '^n(o(t|pe)?|ix|ay)?$';
     if ($useLocale && defined('NOEXPR')) {
         $pattern = nl_langinfo(NOEXPR);
     }
     parent::__construct('/' . $pattern . '/i');
 }
コード例 #4
0
ファイル: coord.php プロジェクト: hbuisman/WP-Geo
 /**
  * Sanitize Lat/Lng
  * Ensures the latitude or longitude is a floating number and that the decimal
  * point is a full stop rather than a comma created by floatval() in some locales.
  *
  * @param number $n Latitude or Longitude.
  * @return number
  */
 function sanitize_latlng($n)
 {
     $n = floatval($n);
     if (defined('DECIMAL_POINT')) {
         $pt = nl_langinfo(DECIMAL_POINT);
         $n = str_replace($pt, '.', $n);
     }
     return $n;
 }
コード例 #5
0
ファイル: NoTest.php プロジェクト: nowsolutions/Validation
 public function testShouldUseLocalPatternForNoExpressionWhenDefined()
 {
     if (!defined('NOEXPR')) {
         $this->markTestSkipped('Constant NOEXPR is not defined');
         return;
     }
     $rule = new No(true);
     $actualPattern = $rule->regex;
     $expectedPattern = '/' . nl_langinfo(NOEXPR) . '/i';
     $this->assertEquals($expectedPattern, $actualPattern);
 }
コード例 #6
0
ファイル: monisetup.php プロジェクト: reviforks/moniwiki
function set_locale($lang, $charset = '')
{
    $supported = array('en_US' => array('ISO-8859-1'), 'fr_FR' => array('ISO-8859-1'), 'ko_KR' => array('EUC-KR', 'UHC'));
    if ($lang == 'auto') {
        # get broswer's settings
        $langs = get_locales();
        $lang = $langs[0];
        $charset = strtoupper($charset);
        # XXX
        $server_charset = '';
        if (function_exists('nl_langinfo')) {
            $server_charset = nl_langinfo(CODESET);
        }
        if ($charset == 'UTF-8') {
            if ($charset != $server_charset) {
                $lang .= "." . $charset;
            }
        } else {
            if ($supported[$lang] && in_array($charset, $supported[$lang])) {
                return $lang . '.' . $charset;
            } else {
                return 'en_US';
                // default
            }
        }
    }
    return $lang;
}
コード例 #7
0
ファイル: ext_string.php プロジェクト: sskblr/hhvm
var_dump(convert_uudecode("+22!L;W9E(%!(4\"\$`\n`"));
var_dump(convert_uuencode("test\ntext text\r\n"));
var_dump(str_rot13("PHP 4.3.0"));
var_dump(crc32("The quick brown fox jumped over the lazy dog."));
var_dump(strlen(crypt("mypassword")));
var_dump(md5("apple"));
var_dump(sha1("apple"));
$trans = array("hello" => "hi", "hi" => "hello");
var_dump(strtr("hi all, I said hello", $trans));
var_dump(convert_cyr_string("abc", "a", "d"));
// sanity
var_dump(hebrev("test"));
// sanity
var_dump(hebrevc("test"));
// sanity
var_dump(nl_langinfo(AM_STR));
var_dump(sprintf("A%sB%dC", "test", 10));
var_dump(sprintf("%010s", "1101"));
var_dump(sprintf("%02d", "09"));
var_dump(sprintf("(%s-%s)", "foobar", "barfoo"));
var_dump(sprintf("[%s]", "ab"));
var_dump(vsprintf("A%sB%dC", array("test", 10)));
var_dump(sscanf("SN/2350001", "SN/%d"));
var_dump(sscanf("SN/2350001", "SN/%d", $out));
var_dump($out);
var_dump(chr(92));
var_dump(ord("\\"));
var_dump(money_format("%i", 1234.56));
var_dump(number_format(1234.56));
var_dump(strcmp("a", "b"));
var_dump(strcmp("a", "A"));
コード例 #8
0
ファイル: common_functions.php プロジェクト: Jacquesvw/phpBMS
        }
        echo "in " . $trace["file"] . " ";
        echo "on line " . $trace["line"] . "<br />";
    }
    //endforeach
    if ($exit) {
        exit;
    }
}
//endif
//for windows servers, we have no define time constants and nl_langinfo function
//in a limited fashion; some windows servers still show that the function
//exists even though it's not implemented, thus the second check;
$nl_exists = function_exists("nl_langinfo");
if ($nl_exists) {
    $nl_exists = @nl_langinfo(CODESET);
}
if (!$nl_exists) {
    function nl_langinfo($constant)
    {
        return $constant;
    }
    //end function
    function nl_setup()
    {
        $date = mktime(0, 0, 0, 10, 7, 2007);
        for ($i = 1; $i <= 7; $i++) {
            define("ABDAY_" . $i, date("D", $date));
            define("DAY_" . $i, date("l"), $date);
            $date = strtotime("tomorrow", $date);
        }
コード例 #9
0
$original = setlocale(LC_ALL, 'C');
//get an unset variable
$unset_var = 'string_val';
unset($unset_var);
//defining a class
class sample
{
    public function __toString()
    {
        return "sample object";
    }
}
//getting the resource
$file_handle = fopen(__FILE__, "r");
// array with different values for $input
$items = array(2147483647, -2147483648, -20, array(), array(0), array(1, 2), new sample(), $file_handle);
//defining '$input' argument
$input = "Test string";
// loop through with each element of the $items array to test nl_langinfo() function
$count = 1;
foreach ($items as $item) {
    echo "-- Iteration {$count} --\n";
    var_dump(nl_langinfo($item));
    $count++;
}
fclose($file_handle);
//closing the file handle
setlocale(LC_ALL, $original);
?>
===DONE===
コード例 #10
0
ファイル: ical.php プロジェクト: Jacquesvw/phpBMS
    function _showEvents()
    {
        foreach ($this->vEvents as $event) {
            ?>
BEGIN:VEVENT
CREATED:<?php 
            echo $event["creationdate"] . "\n";
            ?>
LAST-MODIFIED:<?php 
            echo $event["modifieddate"] . "\n";
            ?>
DTSTAMP:<?php 
            echo $event["creationdate"] . "\n";
            ?>
UID:
 <?php 
            echo "BB-" . $event["id"] . "\n";
            ?>
SUMMARY:<?php 
            echo $event["subject"] . "\n";
            ?>
DTSTART:<?php 
            echo $this->_toCalDate($event["startdate"]);
            if ($event["starttime"]) {
                echo "T" . $this->_toCalTime($event["starttime"]) . "\n";
            } else {
                echo "T000000" . "\n";
            }
            ?>
DTEND:<?php 
            echo $this->_toCalDate($event["enddate"]);
            if ($event["starttime"]) {
                echo "T" . $this->_toCalTime($event["endtime"]) . "\n";
            } else {
                echo "T000000" . "\n";
            }
            if ($event["location"]) {
                echo "LOCATION:" . $event["location"] . "\n";
            }
            if ($event["content"]) {
                echo "DESCRIPTION:" . str_replace("\n", "", $event["content"]) . "\n";
            }
            if ($event["repeating"]) {
                $rrule = "RRULE:FREQ=" . strtoupper($event["repeattype"]) . ";INTERVAL=" . $event["repeatevery"] . ";";
                switch ($event["repeattype"]) {
                    case "Weekly":
                        $rrule .= "BYDAY=";
                        $bydayArray = explode("::", $event["repeateachlist"]);
                        foreach ($bydayArray as $day) {
                            $tempday = $day != 7 ? $day + 1 : 1;
                            $rrule .= strtoupper(substr(nl_langinfo(constant("ABDAY_" . $tempday)), 0, 2)) . ", ";
                        }
                        $rrule = substr($rrule, 0, strlen($rrule) - 2) . ";";
                        break;
                    case "Monthly":
                        if ($event["repeateachlist"]) {
                            $rrule .= "BYMONTHDAY=";
                            $bydayArray = explode("::", $event["repeateachlist"]);
                            foreach ($bydayArray as $day) {
                                $rrule .= $day . ", ";
                            }
                            $rrule = substr($rrule, 0, strlen($rrule) - 2) . ";";
                        } else {
                            if ($event["repeatontheweek"] == 5) {
                                $event["repeatontheweek"] = -1;
                            }
                            $tempday = $event["repeatontheday"] != 7 ? $event["repeatontheday"] + 1 : 1;
                            $rrule .= "BYDAY=" . $event["repeatontheweek"] . strtoupper(substr(nl_langinfo(constant("ABDAY_" . $tempday)), 0, 2)) . ";";
                        }
                        //end if
                        break;
                    case "Yearly":
                        $rrule .= "BYMONTH=";
                        $bymonthArray = explode("::", $event["repeateachlist"]);
                        foreach ($bymonthArray as $month) {
                            $rrule .= $month . ", ";
                        }
                        $rrule = substr($rrule, 0, strlen($rrule) - 2) . ";";
                        if ($event["repeatontheday"]) {
                            if ($event["repeatontheweek"] == 5) {
                                $event["repeatontheweek"] = -1;
                            }
                            $tempday = $event["repeatontheday"] != 7 ? $event["repeatontheday"] + 1 : 1;
                            $rrule .= "BYDAY=" . $event["repeatontheweek"] . strtoupper(substr(nl_langinfo(constant("ABDAY_" . $tempday)), 0, 2)) . ";";
                        }
                        //endif
                        break;
                }
                //endcase
                if ($event["repeattimes"]) {
                    $rrule .= "COUNT=" . $event["repeattimes"] . ";";
                } elseif ($event["repeatuntil"]) {
                    $rrule = "UNTIL=" . $this->_toCalDate($event["repeatuntil"]) . "T000000;";
                }
                echo substr($rrule, 0, strlen($rrule) - 1) . "\n";
            }
            //endif repeating
            ?>
END:VEVENT
<?php 
        }
        //endforeach
    }
コード例 #11
0
ファイル: notes_addedit.php プロジェクト: Jacquesvw/phpBMS
$theinput2 = new inputBasiclist("yearlyontheweek", $therecord["repeatontheweek"], $thetable->weekArray, "on the week of", false);
if (!$therecord["repeatontheday"]) {
    $theinput->setAttribute("disabled", "disabled");
    $theinput2->setAttribute("disabled", "disabled");
    $weekNumber = ceil(date("d", $repeatBase) / 7);
    if ($weekNumber > 4) {
        $weekNumber = 5;
    }
    $theinput->value = $weekNumber;
    $theinput2->value = $weekNumber;
}
$theform->addField($theinput);
$theform->addField($theinput2);
$temparray = array();
for ($i = 1; $i < 8; $i++) {
    $temparray[nl_langinfo(constant("DAY_" . $i))] = $i == 1 ? 7 : $i - 1;
}
$theinput = new inputBasiclist("monthlyontheday", $therecord["repeatontheday"], $temparray, "on the day", false);
$theinput2 = new inputBasiclist("yearlyontheday", $therecord["repeatontheday"], $temparray, "on the day", false);
if (!$therecord["repeatontheday"]) {
    $theinput->setAttribute("disabled", "disabled");
    $theinput2->setAttribute("disabled", "disabled");
    $theinput->value = @strftime("%u", $repeatBase);
    $theinput2->value = @strftime("%u", $repeatBase);
}
$theform->addField($theinput);
$theform->addField($theinput2);
$temparray = array("never" => "never", "after" => "after", "on date" => "on date");
$thevalue = "never";
if ($therecord["id"]) {
    if ($therecord["repeattimes"]) {
コード例 #12
0
 /**
  * @param $item
  * @return string
  * @desc 返回指定的本地信息。
  */
 public static function nl_langinfo($item)
 {
     return nl_langinfo($item);
 }
コード例 #13
0
ファイル: admin_config.php プロジェクト: JBeezygit/e107
                //	    $text .= "<tr><td colspan='2'>Data notionally deleted {$keep_month}-{$keep_year}</td></tr>";
                $text .= "<tr><td>" . ADSTAT_L77 . "</td><td>";
                foreach ($delete_list as $k => $v) {
                    $sql->db_Delete('logstats', "log_id='{$k}'");
                    $text .= $v . "<br />";
                    $logStr .= "[!br!]{$k} => " . $v;
                }
                $text .= "</td></tr>";
                e107::getLog()->add('STAT_04', ADSTAT_L83 . $logStr, '');
            }
            $text .= "<tr><td>" . ADSTAT_L70 . "</td>";
            $text .= "<td><select class='tbox' name='delete_month'>\n";
            $match_month = date("n");
            for ($i = 1; $i < 13; $i++) {
                $selected = $match_month == $i ? " selected='selected'" : "";
                $text .= "<option value='{$i}'{$selected}>" . nl_langinfo(constant('MON_' . $i)) . "</option>\n";
            }
            $text .= "</select>\n&nbsp;&nbsp;&nbsp;";
            $this_year = date("Y");
            $text .= "<select class='tbox' name='delete_year' id='export_year'>\n";
            for ($i = $this_year; $i > $this_year - 6; $i--) {
                $selected = $this_year - 2 == $i ? " selected='selected'" : "";
                $text .= "<option value='{$i}'{$selected}>{$i}</option>\n";
            }
            $text .= "</select>\n</td></tr>";
        }
        $text .= "</table>\r\n\t\r\n\t<div class='buttons-bar center'>\r\n\t" . $frm->admin_button('delete_history', LAN_DELETE, 'delete') . "\r\n\t</div>\r\n\t\r\n\t</form>";
        $ns->tablerender(ADSTAT_L69, $mes->render() . $text);
        break;
        // case 'history'
}
コード例 #14
0
ファイル: String.php プロジェクト: ngnpope/jerity
 /**
  * Converts the value provided into a formatted string specifying the value 
  * in the desired multiples of bytes or bits.
  *
  * To force a specific prefix to be returned, and because they vary depending
  * on whether SI units are used or not, the $prefix parameter must be one of 
  * the following values: '', 'K', 'M', 'G', 'T', 'P', 'E', 'Z'.
  *
  * @param  bool    $bytes   Whether to format as bytes or bits.
  * @param  mixed   $n       The value to format.
  * @param  bool    $si      Whether to output SI units.
  * @param  int     $dp      How many decimal places to output.
  * @param  string  $prefix  Force a prefix, e.g. 'K', 'M' (null = automatic)
  * @param  bool    $symbol  Whether to output symbols or names of unit.
  *
  * @return  string  The formatted byte value.
  */
 protected static function formatBytesOrBits($bytes, $n, $si = false, $dp = 0, $prefix = null, $symbol = true)
 {
     $s = '';
     $exponent = null;
     # Parse the value provided first.
     $n = $bytes ? Number::parseBytes($n) : Number::parseBits($n);
     # Check decimal place is valid.
     $dp = min(max(0, $dp), ini_get('precision'));
     # Get unit prefix list.
     $prefixes = $si ? $symbol ? Number::$SI_PREFIX_SYMBOL : Number::$SI_PREFIX_NAME : ($symbol ? Number::$IEC_PREFIX_SYMBOL : Number::$IEC_PREFIX_NAME);
     # Get unit postfix.
     $postfix = $bytes ? $symbol ? 'B' : 'byte' : ($symbol ? 'b' : 'bit');
     # Determine whether to automatically determine the prefix.
     if (!is_null($prefix)) {
         $exponent = array_search(strtoupper($prefix), array('', 'K', 'M', 'G', 'T', 'P', 'E', 'Z'));
         if ($exponent === false) {
             $exponent = null;
             # Invalid, so just automatically choose.
         }
     }
     # Calculate the correct numeric value.
     $base = $si ? 1000 : 1024;
     if (!is_null($exponent)) {
         $n /= pow($base, $exponent);
     } else {
         $exponent = 0;
         while ($n >= $base && $exponent < count($prefixes) - 1) {
             $n /= $base;
             $exponent++;
         }
     }
     # Generate string.
     $n = number_format($n, $dp, nl_langinfo(RADIXCHAR), nl_langinfo(THOUSEP));
     $s = sprintf('%s %s', $n, $prefixes[$exponent] . $postfix);
     if (!$symbol) {
         $s = self::pluralize($s);
     }
     return $s;
 }
コード例 #15
0
ファイル: nl_langinfo_error1.php プロジェクト: badlamer/hhvm
<?php

/* Prototype  : string nl_langinfo  ( int $item  )
 * Description: Query language and locale information
 * Source code: ext/standard/string.c
*/
echo "*** Testing nl_langinfo() : error conditions ***\n";
echo "\n-- Testing nl_langinfo() function with no arguments --\n";
var_dump(nl_langinfo());
echo "\n-- Testing nl_langinfo() function with more than expected no. of arguments --\n";
$extra_arg = 10;
var_dump(nl_langinfo(ABDAY_2, $extra_arg));
?>
===DONE===
コード例 #16
0
    function showYearlyOptions($therecord, $invoiceDate)
    {
        if ($therecord["type"] == "Yearly") {
            $monthsSelected = explode("::", $therecord["eachlist"]);
        } else {
            $monthsSelected = array(date("n", $invoiceDate));
        }
        for ($monthNum = 1; $monthNum <= 12; $monthNum++) {
            ?>
<button id="yearlyMonthOption<?php 
            echo $monthNum;
            ?>
" class="<?php 
            if (in_array($monthNum, $monthsSelected)) {
                echo "pressed";
            }
            ?>
Buttons yearlyMonths" type="button" value="<?php 
            echo $monthNum;
            ?>
" onclick="yearlyMonthSelect(this)"><?php 
            echo nl_langinfo(constant("ABMON_" . $monthNum));
            ?>
</button><?php 
            if ($monthNum % 4 == 0) {
                echo "<br />";
            }
        }
    }
コード例 #17
0
ファイル: Nls.php プロジェクト: netcon-source/apps
 /**
  * Get the language info returned by nl_langinfo(), but cache it, to
  * avoid repeated calls.
  *
  * @param const $item  The langinfo item to return.
  *
  * @return array  The results of nl_langinfo().
  */
 public static function getLangInfo($item)
 {
     if (!function_exists('nl_langinfo')) {
         return false;
     }
     if (!isset(self::$_cache['nl_info'])) {
         self::$_cache['nl_info'] = array();
     }
     if (!isset(self::$_cache['nl_info'][$item])) {
         self::$_cache['nl_info'][$item] = nl_langinfo($item);
     }
     return self::$_cache['nl_info'][$item];
 }
コード例 #18
0
ファイル: admin_config.php プロジェクト: armpit/e107
 function historyPage()
 {
     $mes = e107::getMessage();
     $frm = e107::getForm();
     $sql = e107::getDb();
     $mes->addWarning(ADSTAT_LAN_76);
     $text = "\r\n\r\n\t\t\t<form method='post' action='" . e_SELF . "?history'>\r\n\t\t\t<table class='table adminlist'>\r\n\t\t\t<colgroup>\r\n\t\t\t  <col style='width:50%' />\r\n\t\t\t  <col style='width:50%' />\r\n\t\t\t</colgroup>";
     $keep_month = varset($_POST['delete_month'], 0);
     $keep_year = varset($_POST['delete_year'], 0);
     if (isset($_POST['delete_history'])) {
         $text .= "<tr><td>" . ADSTAT_LAN_72 . "</td><td>" . nl_langinfo(constant('MON_' . $keep_month)) . " " . $keep_year . "</td></tr>\r\n\t\t\t\t<tr><td colspan='2'  style='text-align:center' class='forumheader'>\r\n\t\t\t\t<input type='hidden' name='delete_month' value='{$keep_month}' />\r\n\t\t\t\t<input type='hidden' name='delete_year' value='{$keep_year}' />\r\n\t\t\t\t" . $frm->admin_button('actually_delete', LAN_CONFDELETE, 'delete') . "<br />" . ADSTAT_LAN_74 . "\r\n\t\t\t\t</td></tr>";
         $text .= "<tr><td>" . ADSTAT_LAN_75 . "</td><td>" . implode("<br />", $this->get_for_delete($keep_year, $keep_month)) . "</td></tr>";
     } else {
         if (isset($_POST['actually_delete'])) {
             $delete_list = $this->get_for_delete($keep_year, $keep_month);
             $logStr = '';
             //	    $text .= "<tr><td colspan='2'>Data notionally deleted {$keep_month}-{$keep_year}</td></tr>";
             $text .= "<tr><td>" . ADSTAT_LAN_77 . "</td><td>";
             foreach ($delete_list as $k => $v) {
                 $sql->delete('logstats', "log_id='{$k}'");
                 $text .= $v . "<br />";
                 $logStr .= "[!br!]{$k} => " . $v;
             }
             $text .= "</td></tr>";
             e107::getLog()->add('STAT_04', ADSTAT_LAN_83 . $logStr, '');
         }
         $text .= "<tr><td>" . ADSTAT_LAN_70 . "</td>";
         $text .= "<td><select class='tbox' name='delete_month'>\n";
         $match_month = date("n");
         for ($i = 1; $i < 13; $i++) {
             $selected = $match_month == $i ? " selected='selected'" : "";
             $text .= "<option value='{$i}'" . $selected . ">" . nl_langinfo(constant('MON_' . $i)) . "</option>\n";
         }
         $text .= "</select>\n&nbsp;&nbsp;&nbsp;";
         $this_year = date("Y");
         $text .= "<select class='tbox' name='delete_year' id='export_year'>\n";
         for ($i = $this_year; $i > $this_year - 6; $i--) {
             $selected = $this_year - 2 == $i ? " selected='selected'" : "";
             $text .= "<option value='{$i}'{$selected}>{$i}</option>\n";
         }
         $text .= "</select>\n</td></tr>";
     }
     $text .= "</table>\r\n\r\n\t\t\t<div class='buttons-bar center'>\r\n\t\t\t" . $frm->admin_button('delete_history', LAN_DELETE, 'delete') . "\r\n\t\t\t</div>\r\n\r\n\t\t\t</form>";
     return $text;
     //	$ns->tablerender(ADSTAT_LAN_69, $mes->render().$text);
 }
コード例 #19
0
ファイル: notes.php プロジェクト: Jacquesvw/phpBMS
 function prepareVariables($variables, $userid = NULL)
 {
     if ($userid == NULL) {
         if (isset($_SESSION["userinfo"]["id"])) {
             $userid = $_SESSION["userinfo"]["id"];
         }
     }
     if ($variables["id"]) {
         //i.e. only on update
         unset($this->fields["type"]);
         if ($variables["typeCheck"] == "TS" && isset($variables["repeating"]) && $variables["lastrepeat"]) {
             $variables["lastrepeat"] = NULL;
             $variables["firstrepeat"] = NULL;
             $variables["timesrepeated"] = NULL;
             if (isset($variables["completed"])) {
                 $variables["completedChange"] = 0;
             }
             $this->resetRepeating($variables["id"]);
         }
         //end if
     }
     //end if
     if (isset($variables["thetype"])) {
         $variables["type"] = $variables["thetype"];
     }
     if (!isset($variables["completed"])) {
         $variables["completeddate"] = NULL;
     }
     if ($variables["enddate"] == "") {
         $variables["enddate"] = NULL;
         $variables["endtime"] = NULL;
     }
     if ($variables["startdate"] == "") {
         $variables["startdate"] = NULL;
         $variables["starttime"] = NULL;
     }
     if (isset($variables["repeating"])) {
         $thename = "Every ";
         switch ($variables["repeattype"]) {
             case "Daily":
                 if ($variables["repeatevery"] != 1) {
                     $thename .= $variables["repeatevery"] . " days";
                 } else {
                     $thename .= " day ";
                 }
                 $variables["repeatechlist"] = NULL;
                 $variables["repeatontheday"] = NULL;
                 $variables["repeatontheweek"] = NULL;
                 break;
             case "Weekly":
                 if ($variables["repeatevery"] != 1) {
                     $thename .= $variables["repeatevery"] . " weeks on";
                 } else {
                     $thename .= "week on";
                 }
                 foreach (explode("::", $variables["eachlist"]) as $dayNum) {
                     $tempday = $dayNum != 7 ? $dayNum + 1 : 1;
                     $thename .= " " . nl_langinfo(constant("ABDAY_" . $tempday)) . ", ";
                 }
                 $thename = substr($thename, 0, strlen($thename) - 2);
                 if (strpos($thename, ",") != false) {
                     $thename = strrev(preg_replace("/,/", "dna ", strrev($thename), 1));
                 }
                 $variables["repeateachlist"] = $variables["eachlist"];
                 $variables["repeatontheday"] = NULL;
                 $variables["repeatontheweek"] = NULL;
                 break;
             case "Monthly":
                 if ($variables["repeatevery"] != 1) {
                     $thename .= $variables["repeatevery"] . " months";
                 } else {
                     $thename .= "month";
                 }
                 $thename .= " on the";
                 if ($variables["monthlyWhat"] == 1) {
                     foreach (explode("::", $variables["eachlist"]) as $dayNum) {
                         $thename .= " " . ordinal($dayNum) . ", ";
                     }
                     $thename = substr($thename, 0, strlen($thename) - 2);
                     if (strpos($thename, ",") != false) {
                         $thename = strrev(preg_replace("/,/", "dna ", strrev($thename), 1));
                     }
                     $variables["repeateachlist"] = $variables["eachlist"];
                     $variables["repeatontheday"] = NULL;
                     $variables["repeatontheweek"] = NULL;
                 } else {
                     foreach ($this->weekArray as $key => $value) {
                         if ($value == $variables["monthlyontheweek"]) {
                             $thename .= " " . strtolower($key);
                         }
                     }
                     foreach ($this->dayOfWeekArray as $key => $value) {
                         if ($value == $variables["monthlyontheday"]) {
                             $thename .= " " . $key;
                         }
                     }
                     $variables["repeateachlist"] = NULL;
                     $variables["repeatontheday"] = $variables["monthlyontheday"];
                     $variables["repeatontheweek"] = $variables["monthlyontheweek"];
                 }
                 break;
             case "Yearly":
                 if ($variables["repeatevery"] > 1) {
                     $thename .= $variables["repeatevery"] . " years";
                 } else {
                     $thename .= "year";
                 }
                 $thename .= " in";
                 foreach (explode("::", $variables["eachlist"]) as $monthNum) {
                     $thename .= " " . nl_langinfo(constant("MON_" . $monthNum)) . ", ";
                 }
                 $thename = substr($thename, 0, strlen($thename) - 2);
                 if (strpos($thename, ",") != false) {
                     $thename = strrev(preg_replace("/,/", "dna ", strrev($thename), 1));
                 }
                 $variables["repeateachlist"] = $variables["eachlist"];
                 if (isset($variables["yearlyOnThe"])) {
                     $thename .= " on the";
                     foreach ($this->weekArray as $key => $value) {
                         if ($value == $variables["yearlyontheweek"]) {
                             $thename .= " " . strtolower($key);
                         }
                     }
                     foreach ($this->dayOfWeekArray as $key => $value) {
                         if ($value == $variables["yearlyontheday"]) {
                             $thename .= " " . $key;
                         }
                     }
                     $variables["repeatontheday"] = $variables["yearlyontheday"];
                     $variables["repeatontheweek"] = $variables["yearlyontheweek"];
                 } else {
                     $variables["repeatontheday"] = NULL;
                     $variables["repeatontheweek"] = NULL;
                 }
                 //end if
                 break;
         }
         switch ($variables["repeatend"]) {
             case "never":
                 $variables["repeatuntil"] = NULL;
                 $variables["repeattimes"] = NULL;
                 break;
             case "after":
                 $thename .= " for " . $variables["repeattimes"];
                 $variables["repeatuntil"] = NULL;
                 break;
             case "on date":
                 $thename .= " until " . $variables["repeatuntil"];
                 $variables["repeattimes"] = NULL;
                 break;
         }
         $thename = trim($thename) . ".";
         $variables["repeatname"] = $thename;
         $variables["firstrepeat"] = dateToString(stringToDate($variables["firstrepeat"], "SQL"));
         $variables["lastrepeat"] = dateToString(stringToDate($variables["lastrepeat"], "SQL"));
         $variables["timesrepeated"] = NULL;
     } else {
         $variables["repeat"] = 0;
         $variables["repeatechlist"] = NULL;
         $variables["repeatontheday"] = NULL;
         $variables["repeatontheweek"] = NULL;
         $variables["repeatname"] = NULL;
         $variables["repeatuntil"] = NULL;
         $variables["repeattimes"] = NULL;
         $variables["firstrepeat"] = NULL;
         $variables["lastrepeat"] = NULL;
         $variables["timesrepeated"] = NULL;
     }
     //endif repeat
     if ($variables["assignedtoid"] != $variables["assignedtochange"]) {
         if ($variables["assignedtoid"] != "") {
             $variables["assignedbyid"] = getUuid($this->db, "tbld:afe6d297-b484-4f0b-57d4-1c39412e9dfb", $userid);
         } else {
             $variables["assignedbyid"] = '';
         }
     }
     //endif
     return $variables;
 }
コード例 #20
0
ファイル: nl_langinfo_basic.php プロジェクト: badlamer/hhvm
<?php

/* Prototype  : string nl_langinfo  ( int $item  )
 * Description: Query language and locale information
 * Source code: ext/standard/string.c
*/
echo "*** Testing nl_langinfo() : basic functionality ***\n";
$original = setlocale(LC_ALL, 'C');
var_dump(nl_langinfo(ABDAY_2));
var_dump(nl_langinfo(DAY_4));
var_dump(nl_langinfo(ABMON_7));
var_dump(nl_langinfo(MON_4));
var_dump(nl_langinfo(RADIXCHAR));
setlocale(LC_ALL, $original);
?>
===DONE===
コード例 #21
0
ファイル: scheduler_recurr.php プロジェクト: Jacquesvw/phpBMS
 function getValidInRange($startDate, $endDate, $therecord)
 {
     $nextDate = $startDate;
     //should pad the end date to make sure we get all weekly repeats
     $endDate = strtotime("+7 days", $endDate);
     $validDates = array();
     while ($nextDate <= $endDate) {
         switch ($therecord["type"]) {
             case "Daily":
                 //==================================================================================
                 $validDates[] = $nextDate;
                 $nextDate = strtotime("+" . $therecord["every"] . " days", $nextDate);
                 break;
             case "Weekly":
                 //==================================================================================
                 $weekDayArray = explode("::", $therecord["eachlist"]);
                 //need to start from the sunday of the current week
                 $tempDate = strtotime(nl_langinfo(constant("DAY_1")), $nextDate);
                 $tempDate = strtotime("-7 days", $tempDate);
                 foreach ($weekDayArray as $weekday) {
                     if ($weekday == 7) {
                         $validDates[] = $tempDate;
                     } else {
                         $weekday++;
                         $validDates[] = strtotime(nl_langinfo(constant("DAY_" . $weekday)), $tempDate);
                     }
                 }
                 // endforeach
                 $nextDate = strtotime("+" . $therecord["every"] . " week", $nextDate);
                 break;
             case "Monthly":
                 //==================================================================================
                 $dateArray = localtime($nextDate, true);
                 if ($therecord["eachlist"]) {
                     $dayArray = explode("::", $therecord["eachlist"]);
                     foreach ($dayArray as $theday) {
                         $validDates[] = mktime(0, 0, 0, $dateArray["tm_mon"] + 1, $theday, $dateArray["tm_year"] + 1900);
                     }
                 } else {
                     // check for things like second tuesday or last friday;
                     $tempDate = mktime(0, 0, 0, $dateArray["tm_mon"] + 1, 1, $dateArray["tm_year"] + 1900);
                     $weekday = $therecord["ontheday"];
                     $weekday = $weekday == 7 ? 1 : $weekday + 1;
                     if ($therecord["ontheday"] != @strftime("%u", $tempDate)) {
                     }
                     $tempDate = strtotime(nl_langinfo(constant("DAY_" . $weekday)), $tempDate);
                     while (date("n", $tempDate) == $dateArray["tm_mon"] + 1) {
                         if ($therecord["ontheweek"] == 5) {
                             // 5 is the "last" option, so we just need to see if
                             // the date falls in the last 6 days
                             if ($daysInMonth - date("d", $tempDate) < 7) {
                                 $validDates[] = $tempDate;
                             }
                         } else {
                             if (ceil(date("d", $tempDate) / 7) == $therecord["ontheweek"]) {
                                 $validDates[] = $tempDate;
                             }
                         }
                         // endif
                         $tempDate = strtotime("+7 days", $tempDate);
                     }
                     // endwhile
                 }
                 //endif
                 $nextDate = strtotime("+" . $therecord["every"] . " months", $nextDate);
                 break;
             case "Yearly":
                 //==================================================================================
                 $monthArray = explode("::", $therecord["eachlist"]);
                 foreach ($monthArray as $monthNum) {
                     $dateArray = localtime($nextDate, true);
                     $daysInMonth = date("d", mktime(0, 0, 0, $monthNum, 0, $dateArray["tm_year"] + 1900));
                     if (!$therecord["ontheday"]) {
                         $tempDay = $dateArray["tm_mday"] > $daysInMonth ? $daysInMonth : $dateArray["tm_mday"];
                         $validDates[] = mktime(0, 0, 0, $monthNum, $tempDay, $dateArray["tm_year"] + 1900);
                     } else {
                         // check for things like second tuesday or last friday;
                         $tempDate = mktime(0, 0, 0, $monthNum, 1, $dateArray["tm_year"] + 1900);
                         $weekday = $therecord["ontheday"];
                         $weekday = $weekday == 7 ? 1 : $weekday + 1;
                         if ($therecord["ontheday"] != @strftime("%u", $tempDate)) {
                         }
                         $tempDate = strtotime(nl_langinfo(constant("DAY_" . $weekday)), $tempDate);
                         while (date("n", $tempDate) == $monthNum) {
                             if ($therecord["ontheweek"] == 5) {
                                 // 5 is the "last" option, so we just need to see if
                                 // the date falls in the last 6 days
                                 if ($daysInMonth - date("d", $tempDate) < 7) {
                                     $validDates[] = $tempDate;
                                 }
                             } else {
                                 if (ceil(date("d", $tempDate) / 7) == $therecord["ontheweek"]) {
                                     $validDates[] = $tempDate;
                                 }
                             }
                             // endif
                             $tempDate = strtotime("+7 days", $tempDate);
                         }
                         // endwhile
                     }
                     //endif
                 }
                 //endforeach
                 $nextDate = strtotime("+" . $therecord["every"] . " years", $nextDate);
                 break;
         }
         //endswitch
     }
     //end while
     return $validDates;
 }
コード例 #22
0
ファイル: DateTest.php プロジェクト: jubinpatel/horde
 public function testStrftimeCs()
 {
     if (!function_exists('nl_langinfo')) {
         $this->markTestSkipped('nl_langinfo() not available.');
     }
     if (!setlocale(LC_TIME, 'cs_CZ.UTF-8')) {
         $this->markTestSkipped('cs_CZ locale not available.');
     }
     $date = new Horde_Date('2001-02-03 16:05:06');
     $format = nl_langinfo(D_FMT);
     $this->assertEquals(strftime($format, $date->timestamp()), $date->strftime($format));
 }
コード例 #23
0
 /**
  * Determines the charset of the current file system.
  * @staticvar string|null $result cached result.
  * @return string|null charset for local file system. Null will be
  * returned if determining was failed.
  */
 public static function getFileSystemCharset()
 {
     static $result = false;
     if ($result !== false) {
         return $result;
     }
     if (function_exists('nl_langinfo') && defined('CODESET')) {
         $result = nl_langinfo(CODESET);
         /* OpenBSD may improperly return D_T_FMT value */
         if (isset($result) && strpos($result, '%') !== false && defined('D_T_FMT') && $result === nl_langinfo(D_T_FMT)) {
             $result = null;
         }
     } else {
         $result = setlocale(LC_CTYPE, '0');
         if ($result === 'C' || $result === 'c') {
             $newResult = setlocale(LC_CTYPE, '');
             setlocale(LC_CTYPE, $result);
             $result = $newResult;
             if ($result === 'C' || $result === 'c') {
                 $result = null;
             }
         }
         if (preg_match('/\\.(.*)$/', $result, $matches)) {
             $result = $matches[1];
         }
     }
     if (empty($result)) {
         return $result = null;
     }
     /*
      * Remap some known charset issues.
      * See http://cvsweb.xfree86.org/cvsweb/xc/nls/locale.alias?rev=1.44
      */
     $intResult = (int) $result;
     if ($intResult === 646) {
         $result = 'ASCII';
     } elseif ($intResult >= 1250 && $intResult <= 1259) {
         $result = "CP{$intResult}";
     }
     /* FreeBSD may return charset with missing hyphen from nl_langinfo */
     $result = preg_replace('/iso8859/i', 'ISO-8859', $result);
     /* Gentoo may return ANSI_X3.4-1968 */
     if (preg_match('/^ANSI[_-]/', $result)) {
         $result = 'ASCII';
     }
     return $result;
 }