Update of /cvsroot/phpweather/phpweather
In directory usw-pr-cvs1:/tmp/cvs-serv8312
Modified Files:
configurator.php
Log Message:
Getting ready for the OO-approach :-)
Index: configurator.php
===================================================================
RCS file: /cvsroot/phpweather/phpweather/configurator.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- configurator.php 2001/05/18 15:35:55 1.1
+++ configurator.php 2001/05/19 09:11:13 1.2
@@ -7,6 +7,120 @@
<?php
+class property {
+ var $name;
+ var $description;
+ var $data;
+ var $config_header;
+
+ function property($name, $description, $data) {
+ $this->name = $name;
+ $this->description = $description;
+ $this->data = $data;
+ $this->config_header = "/* $name */\n\$this->properties['$name'] = ";
+ }
+
+ function get_name() {
+ return $this->name;
+ }
+
+ function get_description() {
+ return $this->description
+ }
+
+
+}
+
+class text extends property {
+
+ function get_html() {
+ return '<input type="text" name="' . $this->name . '" value="' .
+ $this->data . '">';
+
+ }
+
+ function get_config($new_data) {
+ if ($new_data != $this->data) {
+ return '/* ' . $this->name . " */\n\$this->properties['" .
+ $this->name . "'] = '$new_data'\n\n";
+ } else {
+ return '';
+ }
+ }
+}
+
+class select extends property {
+
+ function get_html() {
+ $output = '<select name="' . $this->name . "\">\n";
+ list($option, $label) = each($this->data);
+ $output .= " <option value=\"$option\" selected>$label</option>\n";
+ while(list($option, $label) = each($this->data)) {
+ $output .= " <option value=\"$option\">$label</option>\n";
+ }
+ $output .= " </select>\n </td>\n";
+ return $output;
+ }
+
+ function get_config($new_data) {
+ list($default) = each($this->data);
+ if ($new_data != $default) {
+ return $this->config_header "'$new_data'\n\n";
+ } else {
+ return '';
+ }
+ }
+
+}
+
+class multi_select extends property {
+
+ function get_html() {
+ $output = '<select name="' . $this->name . "\" multiple>\n";
+ while(list($option, $label) = each($this->data)) {
+ $output .= " <option value=\"$option\">$label</option>\n";
+ }
+ $output .= " </select>\n </td>\n";
+ return $output;
+ }
+
+ function get_config($new_data) {
+ $output = $this->config_header "array(\n" .
+ " '$new_data[0]'";
+ for ($i = 1; $i < count($new_data); $i++) {
+ $output .= ",\n '$new_data[$i]'";
+ }
+ $output .= "\n);\n\n";
+ return $output;
+ }
+
+}
+
+class boolean extends property {
+
+ function get_html() {
+ $output = '<select name="' . $this->name . "\">\n";
+ /* The first option is the default */
+ list($option, $label) = each($this->data);
+ $output .= " <option value=\"$option\" selected>$label</option>\n";
+ /* There can only be two options. */
+ list($option, $label) = each($this->data);
+ $output .= " <option value=\"$option\">$label</option>\n";
+ $output .= "</select>\n </td>\n";
+ return $output;
+ }
+
+ function get_config($new_data) {
+ list($default) = each($this->data);
+ if ($new_data != $default) {
+ return $this->config_header . "'$new_data'\n\n";
+ } else {
+ return '';
+ }
+ }
+
+}
+
$properties['always_use_db'] = array(
'type' => 'boolean',
'values' => array('false' => 'No',
_______________________________________________
PHPWeather-checkins mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/phpweather-checkins