/** * Implementation of PHP date function * This is the simplified versino by Sina Salek */ function date($format, $maket = null) { $farsi = 1; $type = $format; //set 1 if you want translate number to farsi or if you don't like set 0 $transnumber = false; ///chosse your timezone $TZhours = 0; $TZminute = 0; $need = ""; $result1 = ""; $result = ""; if (is_null($maket)) { $year = $this->phpDate("Y"); $month = $this->phpDate("m"); $day = $this->phpDate("d"); $maket = mktime($this->phpDate("H") + $TZhours, $this->phpDate("i") + $TZminute, $this->phpDate("s"), $this->phpDate("m"), $this->phpDate("d"), $this->phpDate("Y")); } else { $maket += $TZhours * 3600 + $TZminute * 60; $year = $this->phpDate("Y", $maket); $month = $this->phpDate("m", $maket); $day = $this->phpDate("d", $maket); } $need = $maket; $i = 0; $subtype = ""; $subtypetemp = ""; list($jyear, $jmonth, $jday) = $this->fromGregorian($year, $month, $day); while ($i < strlen($type)) { $subtype = substr($type, $i, 1); if ($subtypetemp == "\\") { $result .= $subtype; $i++; continue; } switch ($subtype) { case "A": $result1 = $this->phpDate("a", $need); $result .= $this->getMeridiemName($result1); break; case "a": $result1 = $this->phpDate("a", $need); $result .= $this->getMeridiemShortName($result1); case "d": if ($jday < 10) { $result1 = "0" . $jday; } else { $result1 = $jday; } if ($transnumber == 1) { $result .= cmfcString::convertNumbersToFarsi($result1); } else { $result .= $result1; } break; case "D": $result1 = $this->phpDate("w", $need); $result .= $this->getWeekShortName($result1); break; case "F": $result .= $this->getMonthName($jmonth); break; case "g": $result1 = $this->phpDate("g", $need); if ($transnumber == 1) { $result .= cmfcString::convertNumbersToFarsi($result1); } else { $result .= $result1; } break; case "G": $result1 = $this->phpDate("G", $need); if ($transnumber == 1) { $result .= cmfcString::convertNumbersToFarsi($result1); } else { $result .= $result1; } break; case "h": $result1 = $this->phpDate("h", $need); if ($transnumber == 1) { $result .= cmfcString::convertNumbersToFarsi($result1); } else { $result .= $result1; } break; case "H": $result1 = $this->phpDate("H", $need); if ($transnumber == 1) { $result .= cmfcString::convertNumbersToFarsi($result1); } else { $result .= $result1; } break; case "i": $result1 = $this->phpDate("i", $need); if ($transnumber == 1) { $result .= cmfcString::convertNumbersToFarsi($result1); } else { $result .= $result1; } break; case "j": $result1 = $jday; if ($transnumber == 1) { $result .= cmfcString::convertNumbersToFarsi($result1); } else { $result .= $result1; } break; case "l": $result1 = $this->phpDate("w", $need); $result .= $this->getWeekName($result1); break; case "m": if ($jmonth < 10) { $result1 = "0" . $jmonth; } else { $result1 = $jmonth; } if ($transnumber == 1) { $result .= cmfcString::convertNumbersToFarsi($result1); } else { $result .= $result1; } break; case "M": $result .= $this->getMonthShortName($jmonth); break; case "n": $result1 = $jmonth; if ($transnumber == 1) { $result .= cmfcString::convertNumbersToFarsi($result1); } else { $result .= $result1; } break; case "s": $result1 = $this->phpDate("s", $need); if ($transnumber == 1) { $result .= cmfcString::convertNumbersToFarsi($result1); } else { $result .= $result1; } break; case "S": $result .= html_entity_decode("ام", ENT_QUOTES, 'UTF-8'); break; case "t": $result .= $this->monthTotalDays($month, $day, $year); break; case "w": $result1 = $this->phpDate("w", $need); if ($transnumber == 1) { $result .= cmfcString::convertNumbersToFarsi($result1); } else { $result .= $result1; } break; case "y": $result1 = substr($jyear, 2, 4); if ($transnumber == 1) { $result .= cmfcString::convertNumbersToFarsi($result1); } else { $result .= $result1; } break; case "Y": $result1 = $jyear; if ($transnumber == 1) { $result .= cmfcString::convertNumbersToFarsi($result1); } else { $result .= $result1; } break; case "U": $result .= $this->phpTime(); break; case "Z": $result .= $this->yearTotalDays($jmonth, $jday, $jyear); break; case "L": list($tmp_year, $tmp_month, $tmp_day) = $this->toGregorian(1384, 12, 1); /* echo $tmp_day; if(lastday($tmp_month,$tmp_day,$tmp_year)=="31") $result.="1"; else $result.="0"; */ break; default: $result .= $subtype; } $subtypetemp = substr($type, $i, 1); $i++; } return $result; }
/** * raise an error * @example * <code> * return $this->raiseError('', CMF_Language_Error_Unknown_Short_Name, * CMF_ERROR_RETURN,NULL, * array('shortName'=>$shortName) * ); * </code> * @param string $msg Error message * @param int $code Error code * @access private */ function raiseError($message = null, $code = null, $mode = null, $options = null, $userinfo = null, $error_class = null, $skipmsg = false) { if (isset($this->_messagesValue[$code]) && empty($message)) { $message = $this->_messagesValue[$code]; } if (is_array($userinfo) && !empty($message)) { if (is_array($userinfo)) { foreach ($userinfo as $key => $value) { $replacements['%' . $key . '%'] = $value; } } $message = cmfcString::replaceVariables($replacements, $message); } return cmfcExceptionStandAlone::raiseError($message, $code, $mode, $options, $userinfo, $error_class, $skipmsg); }