/**
  * Validates the passed chunk of data.
  * In most cases, this'll be a string-object.
  *
  * @param string $objValue
  * @return bool
  */
 public function validate($objValue)
 {
     if (!is_string($objValue)) {
         return false;
     }
     $intTest = uniEreg("([A-Za-z0-9])([A-Za-z0-9]|_|-|\\.)*@([A-Za-z0-9]|_|-|\\.)+\\.([A-Za-z])([A-Za-z])+", $objValue);
     if ($intTest === false || $intTest <= 0) {
         return false;
     } else {
         return true;
     }
 }
示例#2
0
/**
 * Converts a dateobject to a readable string
 *
 * @param class_date $objDate
 * @param bool $bitLong
 * @param string $strFormat if given, the passed format will be used, otherwise the format defined in the i18n files
 *                          usable placeholders are: d, m, y, h, i, s
 *
 * @return string
 */
function dateToString($objDate, $bitLong = true, $strFormat = "")
{
    $strReturn = "";
    //if the $objDate is a string, convert it to date object
    if ($objDate != null && !$objDate instanceof class_date && uniEreg("([0-9]){14}", $objDate)) {
        $objDate = new class_date($objDate);
    }
    if ($objDate instanceof class_date) {
        //convert to a current date
        if ($strFormat == "") {
            if ($bitLong) {
                $strReturn = uniStrtolower(class_carrier::getInstance()->getObjLang()->getLang("dateStyleLong", "system"));
            } else {
                $strReturn = uniStrtolower(class_carrier::getInstance()->getObjLang()->getLang("dateStyleShort", "system"));
            }
        } else {
            $strReturn = $strFormat;
        }
        //"d.m.Y H:i:s";
        $strReturn = uniStrReplace("d", $objDate->getIntDay(), $strReturn);
        $strReturn = uniStrReplace("m", $objDate->getIntMonth(), $strReturn);
        $strReturn = uniStrReplace("y", $objDate->getIntYear(), $strReturn);
        $strReturn = uniStrReplace("h", $objDate->getIntHour(), $strReturn);
        $strReturn = uniStrReplace("i", $objDate->getIntMin(), $strReturn);
        $strReturn = uniStrReplace("s", $objDate->getIntSec(), $strReturn);
    }
    return $strReturn;
}
示例#3
0
 /**
  * Set the current timestamp
  *
  * @param int $longTimestamp
  *
  * @return \class_date
  */
 public function setLongTimestamp($longTimestamp)
 {
     if (uniEreg("([0-9]){14}", $longTimestamp)) {
         $this->longTimestamp = $longTimestamp;
     }
     return $this;
 }