ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-Lib-Dev
php-Lib-Dev
[phplib-dev] cvs commit
by uw other posts by this author
May 21 2001 1:32AM messages near this date
Re: [phplib-dev] Unsubscribe me please. | [phplib-dev] cvs commit
From: uw
Date: Sun May 20 19:21:23 2001
Added files:
      php-lib/pages/form/xml/tests/form_calendar.php
      php-lib/pages/form/xml/tests/form_calendar.xml
      php-lib/php/form/elements/form_element_dateobject.inc

Modified files:
      php-lib/php/form/form.inc
      php-lib/php/form/form_xmlfactory.inc
      php-lib/php/form/elements/form_element_calendar.inc
      php-lib/php/form/elements/form_element_date.inc
      php-lib/php/form/xml/form.xml

Log message:
- added calendar example
- created a new base object for calendar and date to share 
  some language dependend strigns


Index: php-lib/php/form/form.inc
diff -u php-lib/php/form/form.inc:1.33 php-lib/php/form/form.inc:1.34
--- php-lib/php/form/form.inc:1.33	Sun May 20 16:05:31 2001
+++ php-lib/php/form/form.inc	Sun May 20 19:20:49 2001
@@ -28,7 +28,7 @@
 * - tree (select box with options show as a tree)
 *
 * @author		Ulf Wendel <ulf.wendel@[...].de> 
-* @version  $Id: form.inc,v 1.33 2001/05/20 14:05:31 uw Exp $
+* @version  $Id: form.inc,v 1.34 2001/05/20 17:20:49 uw Exp $
 * @access		public
 * @package	Form
 */
@@ -957,16 +957,26 @@
 //			name, els, val, gv
 
 		// putting it all together
-		if ($complex)
-			$js = sprintf('[%s],%s[%s],%s["%s"]',
+		if ($complex) {
+    
+      // list of javascript custom validators
+      $vals = "";
+      foreach($validators as $k =>  $validator)
+        $vals .= sprintf('"%s", ', $validator);
+      $vals = substr($vals, 0, -2);
+      
+			$js = sprintf('[%s],%s[%s],%s[%s]',
 														substr($js, 0, -2),
 														"\n",
 														substr($get_value, 0, -2),
 														"\n",
-														join('", ', $validators)
+														$vals
 												);
-		else
+    } else {
+    
 			$js = sprintf('[%s]', substr($js, 0, -2));
+      
+    }
 			
 		// ;-) compress the JS code....
 #		$base_code = $this-> compressJS($base_code);		
Index: php-lib/php/form/form_xmlfactory.inc
diff -u php-lib/php/form/form_xmlfactory.inc:1.9 php-lib/php/form/form_xmlfactory.inc:1.10
--- php-lib/php/form/form_xmlfactory.inc:1.9	Sun May 20 16:05:31 2001
+++ php-lib/php/form/form_xmlfactory.inc	Sun May 20 19:20:50 2001
@@ -210,6 +210,7 @@
         case "readonly":
         case "preload":
         case "checked":
+        case "weekdays":
           $v = ("false" == $v) ? false : true;
           break;
         
@@ -229,6 +230,10 @@
           $v = (int)$v;
           break;
           
+        default:
+          settype($v, "string");
+          break;          
+          
       }
       
       $tmp[$k] = $v;
@@ -254,12 +259,12 @@
       case "text":
       case "textarea":
       case "textedit":
-        
         if (!$this-> flag_defaults) {
+
           // plain element
           $this-> attributes = $attrs;
           $this-> attributes["type"] = $name;
-          
+
         } else {
         
           // global form defaults
@@ -488,7 +493,7 @@
       case "textedit":
         if (!$this-> flag_defaults)
           $this-> form->addElement($this->attributes);
-       
+
         break;
         
       case "additionalhtml":
@@ -497,9 +502,11 @@
       
       case "defaults":
         if ($this-> flag_defaults) {
+        
           $this-> form->setDefaults($this->defaults);
           $this-> defaults = array();
           $this-> flag_defaults = false;  
+
         }
         
         break;  
@@ -554,8 +561,8 @@
         if ($data)
           $this-> attributes["src"] .= $data;
         break;
-    
-      case "additionalhtml":
+
+      case "additionalhtml":    
       case "css":      
       case "day":
       case "elements":
Index: php-lib/php/form/elements/form_element_calendar.inc
diff -u php-lib/php/form/elements/form_element_calendar.inc:1.3 php-lib/php/form/elements/fo
rm_element_calendar.inc:1.4
--- php-lib/php/form/elements/form_element_calendar.inc:1.3	Thu May 10 22:47:08 2001
+++ php-lib/php/form/elements/form_element_calendar.inc	Sun May 20 19:20:51 2001
@@ -1,17 +1,16 @@
 <?php
-require_once(FORM_INCLUDE_DIR . "/elements/form_element.inc");
+require_once(FORM_INCLUDE_DIR . "/elements/form_element_dateobject.inc");
+require_once(FORM_INCLUDE_DIR . "/elements/form_element_select.inc");
 
 /**
 * Creates a simple calender sheet to choose on day in the given month.
 *
-* This element is not perfect at all, it's no more but a simple case study. 
+* WARNING: This element is not perfect at all, it's no more but a simple case study. 
 * Maybe someone would like to add new features to it.
 *
-* @author	  Ulf Wendel <ulf.wendel@[...].de> 
-* @version  $Id: form_element_calendar.inc,v 1.3 2001/05/10 20:47:08 uw Exp $
-* @package	Form
+* @version  $Id: form_element_calendar.inc,v 1.4 2001/05/20 17:20:51 uw Exp $
 */
-class form_element_calendar extends form_element {
+class form_element_calendar extends form_element_dateobject {
 
 	var $optional_fields	= array (
 																	"day"			=>  "integer",
@@ -23,7 +22,10 @@
 																	
 																	"now"			=>  "string",
 																	"prev"		=>  "string",
-																	"next"		=>  "string"
+																	"next"		=>  "string",
+                                  
+                                  "language"  =>  "string",
+                                  "weekdays"  =>  "boolean"
 																);
 	
 	/**
@@ -32,6 +34,7 @@
 	* @var	integer -1 = date("d")
 	*/
 	var $day = -1;
+  
 	
 	/**
 	* Preselected month.
@@ -39,6 +42,7 @@
 	* @var	integer	-1 = date("m")
 	*/
 	var $month = -1;
+  
 	
 	/**
 	* Preselected year.
@@ -46,6 +50,7 @@
 	* @var	integer -1 = date("Y")
 	*/
 	var $year = -1;
+  
 	
 	/**
 	* First year of the year select box.
@@ -53,6 +58,7 @@
 	* @var	integer	-1 = date("Y")
 	*/
 	var $minyear = -1;
+  
 	
 	/**
 	* Last year of the year select box.
@@ -60,6 +66,7 @@
 	* @var	integer	-1 = date("Y") + 2
 	*/
 	var $maxyear = -1;
+  
 	
 	/**
 	* Caption of the "select today" button.
@@ -67,6 +74,7 @@
 	* @var	string
 	*/
 	var $now = "";
+  
 	
 	/**
 	* Caption of the "next month" button.
@@ -75,10 +83,31 @@
 	*/
 	var $prev = "";
 	
+  
 	/**
 	* Caption of the "prev month" button.
 	*/
 	var $next = "";
+  
+  
+  /**
+  * Show a header with weekdays?
+  * 
+  * @var  boolean
+  */
+  var $weekdays = true;
+  
+  
+  /**
+  * Weekday language.
+  * 
+  * Only languages specified in form_element_date::options 
+  * are allowed, per default 'de' (german) and 'en' (english).
+  * 
+  * @var  string
+  */
+  var $language = "en";
+  
 	
 	/**
 	* Initializes the date range.
@@ -152,10 +181,20 @@
 		$html["year"] = $this-> generateSelect($this->name . "_year", $this->minyear, $this->maxye
ar, $this-> year);
 
 		// the days 
-		$html["calendar"] = '<table> <tr>';
+		$html["calendar"] = '<table border> <tr>';
 
+    // add a headerline with weekdays
+    if ($this-> weekdays) {
+
+      $tmp = "";      
+      foreach ($this-> options[$this->language]["weekdays_short"] as $k => $v)
+        $tmp .= "<td> {$v}</td>";
+      
+      $html["calendar"] .= $tmp . "</tr> <tr>";
+    }
+    
 		// week day offset - monday on the very left, sunday on the right
-		$offset = date("w", mktime(0, 0, 0, $this-> month, 1, $this->year));
+		$offset = date("w", mktime(0, 0, 0, $this-> month, 0, $this->year));
 		for ($i = 0; $i < $offset; $i++)
 			$html["calendar"] = $html["calendar"] . "<td> " . $this->generateDay($i, $i, false, false
) . "</td> ";
 		
@@ -382,10 +421,10 @@
 												
 			}
 			
-			$day = sprintf("%s],%s", substr($day, 0, -2), $this-> CR_HTML);
+			$day = sprintf("%s],%s", substr($day, 0, -1 * (1  + strlen($this-> CR_JS)) ), $this->CR_J
S );
 		}
 		
-		$day = substr($day, 0, -2) . "]";
+		$day = substr($day, 0, -1 * (1 + strlen($this-> CR_JS)) ) . "]";
 		
 		$js .= sprintf('function form_calendar_change() {
 	var d = %s;
Index: php-lib/php/form/elements/form_element_date.inc
diff -u php-lib/php/form/elements/form_element_date.inc:1.5 php-lib/php/form/elements/form_e
lement_date.inc:1.6
--- php-lib/php/form/elements/form_element_date.inc:1.5	Sun May 20 16:05:32 2001
+++ php-lib/php/form/elements/form_element_date.inc	Sun May 20 19:20:51 2001
@@ -1,16 +1,14 @@
 <?php
-require_once(FORM_INCLUDE_DIR . "/elements/form_element.inc");
+require_once(FORM_INCLUDE_DIR . "/elements/form_element_dateobject.inc");
 
 /**
 * Takes a date() format string and renders several select boxes to enter a date and/or time
 *
 * Use this meta element to make sure that the user enters a valid date.
 *
-* @author	  Ulf Wendel <uw@[...].de> 
-* @version  $Id: form_element_date.inc,v 1.5 2001/05/20 14:05:32 uw Exp $
-* @package	Form
+* @version  $Id: form_element_date.inc,v 1.6 2001/05/20 17:20:51 uw Exp $
 */
-class form_element_date extends form_element {
+class form_element_date extends form_element_dateobject {
 
 	var $required_fields = array ( 
 																	"format"	=>  "string"
@@ -106,42 +104,7 @@
 	* @var	boolean
 	*/
 	var $now = "";
-	
-	/**
-	* Word translation mapping.
-	*
-	* @var	array
-	*/
-	var $options = array (
-													"en"	=>  array (
-																						"weekdays_short"	=>   array ("Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
 "Sun" ),
-																						
-																						"weekdays_long"		=>  array(	"Monday", "Tuesday", "Wednesday", "Thursda
y", 
-																																				"Friday", "Saturday", "Sunday"),
-																						
-																						"months_short"		=>  array (	"Jan", "Feb", "Mar", "Apr", "May", "Jun", 
"Jul", 
-																																					"Aug", "Sep", "Oct", "Nov", "Dec" ),
-																																					
-																						"months_long"			=> 	array( 	"January", "February", "March", "April", "
May", 
-																																					"June", "Juli", "August", "September", "October", 
-																																					"November", "December" )
-																	),
-																	
-													"de"	=>  array (
-																						"weekdays_short"	=>  array ( "Mon", "Di", "Mi", "Do", "Fr", "Sa", "So"
),
-																						
-																						"weekdays_long"		=>  array ( "Montag", "Dienstag", "Mittwoch", "Donner
stag",
-																																					"Freitag", "Samstag", "Sonntag"),
-																						
-																						"months_short"		=>  array ( "Jan", "Feb", "März", "April", "Mai", "Jun
i", "Juli",
-																																					"Aug", "Sept", "Okt", "Nov", "Dez"),
-																																					
-																						"months_long"			=>  array( "Januar", "Februar", "März", "April", "Mai"
, "Juni",
-																																					"Juli", "August", "September", "Oktober", "November", 
-																																					"Dezember"	)
-																						
-																	) 
-												);
+
 	
 	/**
 	* Initializes $max_year_long and $max_year_short.
Index: php-lib/php/form/xml/form.xml
diff -u php-lib/php/form/xml/form.xml:1.5 php-lib/php/form/xml/form.xml:1.6
--- php-lib/php/form/xml/form.xml:1.5	Sat May 19 22:50:47 2001
+++ php-lib/php/form/xml/form.xml	Sun May 20 19:20:52 2001
@@ -1,29 +1,19 @@
 <?xml version="1.0" encoding="UTF-8"?> 
 <!DOCTYPE form SYSTEM "C:\www\apache\form\form.dtd"> 
-<form method="POST" action="test.php" target="self" name="form1" jsname="jsname"> 
-	
-  <javascript mode="weak"> 
-    <errorprefix> There're errors in the form: \n\n</errorprefix>
-    <errorpostfix> \n\nPlease correct the input.</errorpostfix>
+<form jsname="" method="POST" action="" target="" name=""> 
+	<additionalhtml/> 
+  
+	<javascript> 
+		<mode> weak or strong</mode>
 	</javascript> 
-	
-  <defaults> 
-    <text size="0" maxlength="0"/> 
-    <file size="0"/> 
-    <image border="0"/> 
-    <intros errormsg = "Don't select me"> 
-			<intro value="0"> intro</intro>
-		</intros> 
-    <css class="css class" id="id"> style</css>
-  </defaults> 
   
-  <elements nameprefix=""> 
-    
-    <calendar name="calendar" elname="calendar" frozen="false" minyear="2000" maxyear="2010
" now="today" prev="&lt;&lt;" next="&gt;&gt;"> 
+	<elements> 
+		<nameprefix> prefix_</nameprefix>
+    <calendar name="calendar" elname="calendar" frozen="false" minyear="" maxyear="" now=""
 prev="" next=""> 
       <preselect> 
-        <day> 1</day>
-        <month> 5</month>
-        <year> 2001</year>
+        <day> </day>
+        <month> </month>
+        <year> </year>
       </preselect> 
       <css class="css class" id="id"> style</css>
       <html> additional html</html>   
@@ -36,37 +26,36 @@
     <checkbox name="checkbox" elname="checkbox" frozen="false" checked="false"> 
       value
       <css class="css class" id="id"> style</css>
-      <html accesskey="A" tabindex="1"> additional html</html>   
+      <html accesskey="" tabindex=""> additional html</html>   
       <validation> 
         <phpfunction> </phpfunction>
         <jsfunction> </jsfunction>
   		</validation> 
     </checkbox> 
     
-    <combo name="combo" elname="combo" inputsize="1" readonly="false" sort="true" frozen="f
alse" add="true" size="1"> 
-      1
+    <combo name="combo" elname="combo" inputsize="1" readonly="false" sort="" frozen="false
" add="true" size="1"> 
+      value
   		<options> 
-        <option value="1"> 1</option>
-        <option value="2"> 2</option>
+  			<option value=""/> 
   		</options> 
-  		<intros errormsg = "Don't select me"> 
-  			<intro value="0"> intro</intro>
+  		<intros errormsg = "error"> 
+  			<intro value=""> intro</intro>
   		</intros> 
    		<validation> 
-  			<length min="1" max="2"> length_e</length>
+  			<length min="0" max="-1"> length_e</length>
   			<regexp reg="" icase="false"> valid_e</regexp>
         <phpfunction> </phpfunction>
         <jsfunction> </jsfunction>
   		</validation> 
       <css class="css class" id="id"> style</css>
-      <html accesskey="O" tabindex="2"> additional html</html>   
+      <html accesskey="" tabindex=""> additional html</html>   
   	</combo> 
     
   	<date name="date" elname="date" language="en" frozen="false" preload="false" format="d.m
.Y" now="jetzt" intro="" intro_e=""> 
       value
   		<limits> 
-  			<yearlong min="1990" max="2010"/> 
-  			<yearshort min="90" max="99"/> 
+  			<yearlong min="1990" max="-1"/> 
+  			<yearshort min="90" max="-1"/> 
   		</limits> 
       <html> additional html</html>   
       <css class="css class" id="id"> style</css>
@@ -167,7 +156,7 @@
       </validation> 
   	</select> 
     
-  	<submit name="submit" elname="submit" width="1" height="1" frozen="false" accesskey="" t
abindex=""> 
+  	<submit name="submit" elname="submit" width="1" height="1" frozen="false"> 
       value
       <html accesskey="" tabindex=""> additional html</html>   
       <css class="css class" id="id"> style</css>
@@ -210,6 +199,6 @@
         <jsfunction> </jsfunction>
   		</validation> 
     </textedit> 
-  </elements>     
+	</elements> 
   
 </form> 



---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-dev-unsubscribe@[...].de
For additional commands, e-mail: phplib-dev-help@lists.netuse.de

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved