Source for file DBMS_FIELD_LINUXTIMESTAMP.phpclass

Documentation is available at DBMS_FIELD_LINUXTIMESTAMP.phpclass

  1. <?php
  2. /**
  3.   * Class file DBMS_FIELD_LINUXTIMESTAMP.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    dbms_field
  7.   * @category   int
  8.   *
  9.   * @author     Peter Krebs (pk)<p.krebs@lvus.at>
  10.   * @copyright  (c) 2002-2005 by LVUS <http://opencsp.lvu.at>
  11.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  12.   *
  13.   ***/
  14.  
  15. /**
  16.   * requirements
  17.   */
  18.  
  19. require_once __OCSP_PHPINCPATH__."common"._OCSP_DIRSEP_."OCSP_DATE.phpclass";
  20. require_once dirname(__FILE__)._OCSP_DIRSEP_."DBMS_FIELD_DATE.phpclass";
  21.  
  22. /**
  23.   * Class DBMS_FIELD_LINK
  24.   *
  25.   * @project    Open CSP-Management
  26.   * @package    dbms_field
  27.   * @category   int
  28.   *
  29.   * @author     Peter Krebs (pk)<p.krebs@lvus.at>
  30.   * @copyright  (c) 2002-2005 by LVUS <http://opencsp.lvu.at>
  31.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  32.   *
  33.   ***/
  34.     var $className     = "LinuxTimeStamp";
  35.  
  36.     /**
  37.       * source file of the class
  38.       *
  39.       * @var string $classSrcFile 
  40.       * @since pk-05-03-29
  41.       ***/
  42.     var $classSrcFile=__FILE__;
  43.  
  44.  
  45.     /**
  46.       * returns an array of field to bie shown in the edit form
  47.       * by using editTbl_echoForm
  48.       *
  49.       * the array is in the form:
  50.       *
  51.       * <code>
  52.       * [_sectionName_]
  53.       *      [TITLE] -> string
  54.       *      [_rowName_]
  55.       *         [FLDLAB]  (complete html code with <td></td>)
  56.       *         [FLDVAL] (complete html code with <td></td>)
  57.       * </code>
  58.       *
  59.       * NOTE as this is not implemented in the whole classTree at the moment ensure all parents use
  60.       * editTbl_echoForm() in theire editTblForm otherwise you'll get a mismatch of field order
  61.       *
  62.       * @param boolean $debug 
  63.       *
  64.       * @returns array
  65.       *
  66.       * @since pk-06-07-16
  67.       *
  68.       ***/
  69.     function editTbl_getFieldEditArr($debug=FALSE{
  70.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_DATE::editTbl_getFieldEditArr","",0);
  71.         $a_ret=parent::editTbl_getFieldEditArr($debug);
  72.  
  73.         $a_ret['SHOW']['SHOWDATE']=array(
  74.             'FLDLAB'=>"Datum anzeigen:",
  75.             'FLDVAL'=>"<input name=\"SHOWDATE\" type=\"checkbox\" ".($this->showDate ? "checked=\"checked\"" "")." value=\"1\" /> "
  76.         );
  77.         $a_ret['SHOW']['SHOWTIME']=array(
  78.             'FLDLAB'=>"Zeit anzeigen:",
  79.             'FLDVAL'=>"<input name=\"SHOWTIME\" type=\"checkbox\" ".($this->showTime ? "checked=\"checked\"" "")." value=\"1\" /> "
  80.         );
  81.  
  82.         return $a_ret;
  83.     }
  84.  
  85.     /* *
  86.       * returns the html code for the field value input / show
  87.       * adds $this->myName to ${$this->myDataArrName}['_DBMS_FIELDS']
  88.       *
  89.       * @param int $mode
  90.       * @param mixed $aValue
  91.       * @param boolean $debug
  92.       *
  93.       * @returns string
  94.       *
  95.       * @since pk-05-03-29
  96.       *
  97.       *
  98.     function getFieldTag($mode,$aValue=NULL,$debug=FALSE) {
  99.         $debug=($debug || $this->fldDebug);
  100.         if ($debug) echo "<p><b>DBMS_FIELD_LINUXTIMESTAMP::getFieldTag($mode,$aValue,...)</b> (".get_class($this).")</p>";
  101.  
  102.         if ((doubleval($aValue)) && (!strstr($aValue,"-"))) {
  103.             $aDate=new OCSP_DATE();
  104.             $aDate->setLinuxTime($aValue);
  105.             return parent::getFieldTag($mode,$aDate->dateStr("Y-m-d H:i:s"));
  106.         } else {
  107.             return parent::getFieldTag($mode,$aValue,$arrName);
  108.         }
  109.     }
  110.     */
  111.  
  112.     function getScreenValue($aValue=NULL,$arrName="DBVAL",$debug=FALSE{
  113.         $debug=($debug || $this->fldDebug);
  114.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_LINUXTIMESTAMP::getScreenValue()");
  115.         if (doubleval($aValue)) {
  116.             $aDate=new OCSP_DATE();
  117.             $aDate->setLinuxTime(doubleval($aValue));
  118.             if ($debugecho "<p>Date: ".$aDate->dateStr("Y-m-d H:i:s")."</p>";
  119.             return parent::getScreenValue($aDate->dateStr("Y-m-d H:i:s"),$arrName,$debug);
  120.         else {
  121.             return parent::getScreenValue($aValue,$arrName,$debug);
  122.         };
  123.     }
  124.  
  125.  
  126.     /**
  127.       * returns the field value
  128.       *
  129.       * @param  string  $aValue     the value
  130.       * @param  array   $err        error array
  131.       * @param  string  $arrName    DBVAL
  132.       *
  133.       * @return string 
  134.       *
  135.       * @since   pk-03-12-13
  136.       * @version pk-03-12-13
  137.       *
  138.       ***/
  139.     function getValue($aValue,&$err,$arrName="DBVAL",$debug=FALSE{
  140.         if ($debugecho "<hr><p><b>DBMS_FIELD_LINUXTIMESTAMP::getValue($aValue,$err,$arrName,$debug)</b> (".get_class($this)."/".$this->myName.")</p>";
  141.  
  142.         if (is_array($aValue)) {
  143.             $aDate=new OCSP_DATE();
  144.             $aDate->setFromArray($aValue);
  145.             if (($aDate->isNULL()) && (!$this->allowNull())) {
  146.                 return time();
  147.             }
  148.             return $aDate->getLinuxTimeStamp();
  149.         else {
  150.             if ((empty($aValue)) && (strval($aValue!== "0"&& (!$this->allowNull)) {
  151.                 $err['ERROR']=TRUE;
  152.                 $err[$this->myName]['MSG']="NULL_NOT_ALLOWED";
  153.                 $err[$this->myName]['LABEL']=$this->label;
  154.                 return FALSE;
  155.             }
  156.             return doubleval($aValue);
  157.         }
  158.     }
  159.  
  160.     /**
  161.       * returns the value with slashes create use in a db statement
  162.       *
  163.       * @param  string  $aValue     the value
  164.       * @param  array   $err        error array
  165.       * @param  string  $arrName    DBVAL
  166.       *
  167.       * @return string 
  168.       *
  169.       * @version pk-03-12-13    use $this->getValue to check the Value
  170.       *
  171.       ***/
  172.     function slashedValue($aValue,&$err,$arrName="DBVAL",$debug=FALSE{
  173.         if ($debugecho "<hr><p><b>DBMS_FIELD_LINUXTIMESTAMP::slashedValue($aValue,$err,$arrName,$debug)</b> (".get_class($this)."/".$this->myName.")</p>";
  174.         return $this->getValue($aValue,$err,$arrName,$debug);
  175.     }
  176. }
  177. ?>

Documentation generated on Thu, 08 Jan 2009 17:42:17 +0100 by phpDocumentor 1.4.0a2