[ghelda-devel] [14] Ensure that dates are not overwritten for nothing.

[ Thread Index | Date Index | More lists.tuxfamily.org/ghelda-devel Archives ]


Revision: 14
Author:   odyx
Date:     2009-04-01 13:19:05 +0200 (Wed, 01 Apr 2009)

Log Message:
-----------
Ensure that dates are not overwritten for nothing.

Modified Paths:
--------------
    trunk/inc/outputs/xHTML.class.php


Modified: trunk/inc/outputs/xHTML.class.php
===================================================================
--- trunk/inc/outputs/xHTML.class.php	2009-04-01 10:30:28 UTC (rev 13)
+++ trunk/inc/outputs/xHTML.class.php	2009-04-01 11:19:05 UTC (rev 14)
@@ -434,6 +434,12 @@
 	
 				} elseif(stripos($fieldProperties['type'],'date') !== false) {
 					$fields .= $this->xdate($fieldProperties,$fieldsContents[$fieldName_],$fieldName,$paramsArray);
+					// Add the "_old" hidden stag
+					$paramsArray['type'] = 'hidden';
+					$paramsArray['name'] = $fieldName.'_old';
+					$paramsArray['id'] = $fieldName.'_old';
+					$paramsArray['value'] = $this->formatDateSimple($fieldsContents[$fieldName_]);
+					$fields .= LB.$this->stag('input',$paramsArray);
 				} elseif(stripos($fieldProperties['type'],'enum') !== false) {
 					$label = $this->tag('legend',$fieldProperties['name'],array('for'=>$fieldName));
 					// Standard parameters
@@ -719,6 +725,13 @@
 		return $formattedDate;
 	}
 
+	// Reduce the date to delete leading zeros
+	private function formatDateSimple($date)
+	{
+		preg_match("`([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})`", $date, $regs);
+		return (int)$regs[0].'-'.(int)$regs[1].'-'.(int)$regs[2];
+	}
+
 	private function comment($code, $do_echo = false)
 	{
 		return $this->echo_("<!--".LB,1,$do_echo).$this->echo_($code,0,$do_echo).$this->echo_(LB."-->",-1,$do_echo).$this->echo_(LB,0,$do_echo);


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/