Date: 04/18/00
- Next message: Tony B. Gorschek: "[PHPLIB-DEV] php or asp"
- Previous message: uw: "[PHPLIB-DEV] cvs commit"
- Next in thread: kk: "[PHPLIB-DEV] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: uw
Date: Tue Apr 18 13:57:00 2000
Modified files:
php-lib/php/form/assistant.inc
php-lib/php/form/form.inc
php-lib/php/form/form_elements.inc
Log message:
- added a new type "date", unfinished!
"date" takes a format string that's equal to the format string the php
function date() takes and generates several select boxes.
- some minor fixes
Index: php-lib/php/form/assistant.inc
diff -u php-lib/php/form/assistant.inc:1.2 php-lib/php/form/assistant.inc:1.3
--- php-lib/php/form/assistant.inc:1.2 Mon Apr 17 12:46:10 2000
+++ php-lib/php/form/assistant.inc Tue Apr 18 13:56:29 2000
@@ -389,10 +389,12 @@
$next = $this->getButton($labels["next"], $next);
$submit = (isset($data["submit"])) ? $data["submit"] : $data["tab"];
- $submit = $this->getButton($submit, $this->now);
+ if (""!=$submit)
+ $submit = $this->getButton($submit, $this->now);
$reset = (isset($data["reset"])) ? $data["reset"] : $this->labels["reset"];
- $reset = $this->getResetButton($reset);
+ if (""!=$reset)
+ $reset = $this->getResetButton($reset);
$finish = "";
$exit = "";
@@ -410,7 +412,7 @@
$replace = array (
"START_FORM" => $this->form_start,
"END_FORM" => $this->form_end,
- "FORM" => $this->now."<p>".$form,
+ "FORM" => $form,
"HELP" => ("help"==$this->flag_specials) ? $this->help["help"] : "",
"COMMENT" => $comment,
"TOTAL_PAGES" => count($this->pages),
@@ -482,7 +484,6 @@
$this->buttonname,
$value
);
-
if (!$error)
$bgcolor = ' bgcolor="#ffe0e0"';
else
@@ -490,6 +491,7 @@
return array($html, $bgcolor);
} // end func getTab
+
/**
* print, generate and return the current page
* <email protected> string $html
Index: php-lib/php/form/form.inc
diff -u php-lib/php/form/form.inc:1.2 php-lib/php/form/form.inc:1.3
--- php-lib/php/form/form.inc:1.2 Mon Apr 17 12:46:10 2000
+++ php-lib/php/form/form.inc Tue Apr 18 13:56:29 2000
@@ -507,10 +507,21 @@
$this->setError(-1, "form -> addElement - Illegal function call");
return false;
}
+
$element_data["type"] = strtolower($element_data["type"]);
+ $conversion = array(
+ "select multiple" => "select",
+ "image" => "submit",
+ "password" => "text"
+ );
+ if (isset($conversion[$element_data["type"]]))
+ $of_objectname = $conversion[$element_data["type"]];
+ else
+ $of_objectname = $element_data["type"];
+
// Set defaultSize and defaultMaxlength
if ( 0!=$this->defaultSize &&
- ("text" == $element_data["type"] || "textarea" == $element_data["type"] ) &&
+ ("text" == $of_objectname || "textarea" == $element_data["type"]) &&
!isset($element_data["size"])
)
{
@@ -518,13 +529,16 @@
}
if ( 0!=$this->defaultMaxlength &&
- ("text" == $element_data["type"] || "textarea" == $element_data["type"] ) &&
+ ("text" == $of_objectname || "textarea" == $element_data["type"]) &&
!isset($element_data["maxlength"])
)
{
$element_data["maxlength"] = $this->defaultMaxlength;
}
+ if (!isset($element_data["value"]))
+ $element_data["value"] = "";
+
if ("password"==$element_data["type"])
$element_data["pass"] = true;
Index: php-lib/php/form/form_elements.inc
diff -u php-lib/php/form/form_elements.inc:1.2 php-lib/php/form/form_elements.inc:1.3
--- php-lib/php/form/form_elements.inc:1.2 Mon Apr 17 12:46:10 2000
+++ php-lib/php/form/form_elements.inc Tue Apr 18 13:56:29 2000
@@ -2483,4 +2483,223 @@
} // end func generateJS
} // end class form_elements_radio
+
+class form_elements_date extends form_elements {
+
+ var $format = "";
+ var $language = "";
+
+ var $min_year_long = 1990;
+ var $max_year_long = date("Y");
+
+ var $min_year_short = 90;
+ var $max_year_short = date("y");
+
+ var $options = array (
+ "en" => array (
+ "weekdays_short" => array ("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" ),
+
+ "weekdays_long" => array( "Monday", "Tuesday", "Wednesday", "Thursday",
+ "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", "Donnerstag",
+ "Freitag", "Samstag", "Sonntag"),
+
+ "months_short" => array ( "Jan", "Feb", "März", "April", "Mai", "Juni", "Juli",
+ "Aug", "Sept", "Nov", "Dez"),
+
+ "months_long" => array( "Januar", "Februar", "März", "April", "Mai", "Juni",
+ "Juli", "August", "September", "November", "Dezember" )
+
+ )
+ );
+
+ function getValue() {
+ } // end func getValue
+
+ function setValue($value) {
+
+ if (is_array($value)) {
+ $this->value = $value;
+ return true;
+ }
+
+
+
+ return true;
+ } // end func setValue
+
+
+ function get($value="") {
+
+ if (""==(string)$this->format) {
+ $this->setError(45, "form_elements_date -> get(), no format string specified.");
+ return "";
+ }
+
+ $html = "";
+ $len = strlen($this->format);
+
+ for ($i=0; $i<$len; $i++) {
+
+ $options = array();
+ $sign = substr($this->format, $i, 1);
+ switch($sign) {
+
+ case "a":
+ $html.= $this->generateSelect("a", array("am", "pm"));
+ break;
+ case "A":
+ $html.= $this->generateSelect("A", array("AM", "PM"));
+ break;
+
+ case "d":
+ for ($j=1; $j<=31; $j++)
+ $options[] = sprintf("%02d", $j);
+ $html.= $this->generateSelect("d", $options);
+ break;
+
+ case "D":
+ $html.= $this->generateSelect("D", $this->options[$this->language]["weekdays_short"]);
+ break;
+
+ case "F":
+ $html.= $this->generateSelect("F", $this->options[$this->language]["months_long"]);
+ break;
+
+ case "h":
+ for ($j=1; $j<=12; $j++)
+ $options[] = sprintf("%02d", $j);
+ $html.= $this->generateSelect("h", $options);
+ break;
+
+ case "H":
+ for ($j=0; $j<=23; $j++)
+ $options[] = sprintf("%02d", $j);
+ $html.= $this->generateSelect("H", $options);
+ break;
+
+ case "g":
+ for ($j=1; $j<=12; $j++)
+ $options[] = $j;
+ $html.= $this->generateSelect("g", $options);
+ break;
+
+ case "G":
+ for ($j=0; $j<=23; $j++)
+ $options[] = $j;
+ $html.= $this->generateSelect("G", $options);
+ break;
+
+ case "i":
+ for ($j=0; $j<=59; $j++)
+ $options[] = sprintf("%02d", $j);
+ $html.= $this->generateSelect("i", $options);
+ break;
+
+ case "j":
+ for ($j=1; $j<=31; $j++)
+ $options[] = $j;
+ $html.= $this->generateSelect("j", $options);
+ break;
+
+ case "l":
+ $html.= $this->generateSelect("l", $this->options[$this->language]["weekdays_long"]);
+ break;
+
+ case "m":
+ for ($j=1; $j<=12; $j++)
+ $options[] = sprintf("%02d", $j);
+ $html.= $this->generateSelect("m", $options);
+ break;
+
+ case "n":
+ for ($j=1; $j<=12; $j++)
+ $options[] = $j;
+ $html.= $this->generateSelect("n", $options);
+ break;
+
+ case "M":
+ $html.= $this->generateSelect("M", $this->options[$this->language]["months_short"]);
+ break;
+
+ case "s":
+ for ($j=0; $j<=59; $j++)
+ $options[] = sprintf("%02d", $j);
+ $html.= $this->generateSelect("s", $options);
+ break;
+
+ case "w":
+ for ($j=0; $j<=6; $j++)
+ $options[] = $j;
+ $html.= $this->generateSelect("w", $options);
+ break;
+
+ case "Y":
+ for ($j=$this->min_year_long; $j<=$this->max_year_long; $j++)
+ $options[] = $j;
+ $html.= $this->generateSelect("Y", $options);
+ break;
+
+ case "y":
+ for ($j=$this->min_year_short; $j<=$this->max_year_short; $j++)
+ $options[] = $j;
+ $html.= $this->generateSelect("y", $options);
+ break;
+
+ case "z":
+ for ($j=0; $j<=365; $j++)
+ $options[] = $j;
+ $html.= $this->generateSelect("z", $options);
+ break;
+
+ default:
+ $html.=$sign;
+ break;
+ }
+
+ }
+ return $html;
+ } // end func get
+
+ function generateSelect($name, $options) {
+ if (""==$name || !is_array($options)) {
+ $this->setError(46, "form_elements_date -> generateSelect(), illegal function call.");
+ return "";
+ }
+ $html = sprintf('<select name="%s_%s" size="1">%s', $name, $this->name, $this->cr_html);
+ reset($options);
+ while (list($k, $option)=each($options))
+ $html.= sprintf('<option value="%s">%s</option>%s', $option, $option, $this->cr_html);
+ $html.= "</select>".$this->cr_html;
+ return $html;
+ }
+
+ function getfrozen($value="") {
+
+ if ($this->checked)
+ $html = sprintf('<input typ');
+
+ } // end getfrozen
+
+ function validate() {
+ return array(true, "");
+ } // end func validate
+
+ function generateJS() {
+ $this->js_code = "";
+ } // end func generateJS
+
+} // end class form_elements_radio
?>
-
PHPLIB Developers Mailing List. Send messages to <phplib-dev <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-dev-request <email protected>> in
the body, not the subject, of your message.
- Next message: Tony B. Gorschek: "[PHPLIB-DEV] php or asp"
- Previous message: uw: "[PHPLIB-DEV] cvs commit"
- Next in thread: kk: "[PHPLIB-DEV] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

