Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added Widgets

  • Loading branch information...
commit 6408ea8bb98329abfecbf468382ebda619c38f73 1 parent 3381bc2
Filippo authored
Showing with 196 additions and 26 deletions.
  1. +36 −19 Classes/Page.php
  2. +155 −2 Classes/Widget.php
  3. +5 −5 index.php
View
55 Classes/Page.php
@@ -6,31 +6,48 @@ class Page extends WidgetContainer
public $width = '600';
public $color = 'ffffff';
private $_html = '';
+ private $withForm = false;
- function __construct(){}
+ function __construct($withForm=false)
+ {
+ $this->withForm = $withForm;
+ }
+
+
+ function show()
+ {
+ // Setting vars for render a form
+ $beginHtmlForm = '';
+ $endHtmlForm = '';
+ if ($this->withForm)
+ {
+ $beginHtmlForm = '<form id="FW_MainForm" action="" method="get">';
+ $endHtmlForm = '</form>';
+ }
- function show(){
$css_manager = Css_s::singleton();
$this->_html = '
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8" />
- <title> '. $this->title .' </title>
- <style>
- html { background-color:#'. $this->color .' }
- * { margin: 0px; padding: 0px; }
- '. $css_manager->css() .'
- </style>
- </head>
- <body>
- <div style="width:'. $this->width .'px; height:100%; margin:0 auto;">
- '. $this->html() .'
- </div>
- </body>
- </html>';
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <meta charset="UTF-8" />
+ <title> '. $this->title .' </title>
+ <style>
+ html { background-color:#'. $this->color .' }
+ * { margin: 0px; padding: 0px; }
+ '. $css_manager->css() .'
+ </style>
+ </head>
+ <body>
+ '. $beginHtmlForm .'
+ <div style="width:'. $this->width .'px; height:100%; margin:0 auto;">
+ '. $this->html() .'
+ </div>
+ '. $endHtmlForm .'
+ </body>
+ </html>';
print $this->_html;
}
View
157 Classes/Widget.php
@@ -7,7 +7,6 @@ function __construct($contaniner, $widgetInstance)
{
$contaniner->addWidget($widgetInstance);
}
-
// Method for get html
abstract function html();
@@ -15,5 +14,159 @@ function __construct($contaniner, $widgetInstance)
abstract function css();
}
-
+
+
+class Button extends Widget
+{
+ // Widget Prop
+ private $html = '';
+ private $css = '
+ ';
+
+ // Prop
+ private $btnID = '';
+ private $btnValue = '';
+ private $btnTitle = '';
+
+ function __construct($container, $btnID, $btnValue, $btnTitle='')
+ {
+ parent::__construct($container, $this);
+ $this->btnID = $btnID;
+ $this->btnValue = $btnValue;
+ $this->btnTitle = $btnTitle;
+ if ($btnTitle = ''){
+ $this->btnTitle = $btnValue;
+ }
+ }
+
+ function html()
+ {
+ $this->html = $this->renderButton();
+ return $this->html;
+ }
+
+ function css()
+ {
+ return $this->css;
+ }
+
+ private function renderButton()
+ {
+ return '<input type="submit"
+ name="'. $this->btnID .'"
+ id ="'. $this->btnID .'"
+ value="'. $this->btnValue .'"
+ class="button"
+ title="'. $this->btnTitle .'"
+ onclick="FW_Submit(\''. $this->btnID .'\',\'self\',0,0,true,\'\');"
+ >';
+ }
+
+}
+
+
+class Textfield extends Widget
+{
+
+ // Widget Prop
+ private $html = '';
+ private $css = '
+ ';
+
+ // Prop
+ private $txtID = '';
+ private $txtValue = '';
+ private $txtRequired = false;
+ private $txtReadOnly = false;
+
+ function __construct($container, $txtID, $txtValue='', $txtRequired=false, $txtReadOnly=false)
+ {
+ parent::__construct($container, $this);
+ $this->txtID = $txtID;
+ $this->txtValue = $txtValue;
+ $this->txtRequired = $txtRequired;
+ $this->txtReadOnly = $txtReadOnly;
+ }
+
+ function html()
+ {
+ $this->html = $this->renderButton();
+ return $this->html;
+ }
+
+ function css()
+ {
+ return $this->css;
+ }
+
+ private function renderButton()
+ {
+ return '<input type="text"
+ name="'. $this->txtID .'"
+ id="'. $this->txtID .'"
+ class="textfield"
+ onchange=" "
+ value="'. $this->txtValue .'"
+ readonly="'. $this->txtReadOnly .'"
+ hasformat="False"
+ required="'. $this->txtRequired .'">';
+ }
+}
+
+
+class Combobox extends Widget
+{
+
+ // Widget Prop
+ private $html = '';
+ private $css = '
+ ';
+
+ // Prop
+ private $txtID = '';
+ private $txtArrayValues = Array();
+ private $txtRequired = false;
+ private $txtReadOnly = false;
+
+ function __construct($container, $txtID, $txtArrayValues, $txtRequired=false, $txtReadOnly=false)
+ {
+ parent::__construct($container, $this);
+ $this->txtID = $txtID;
+ $this->txtArrayValues = $txtArrayValues;
+ $this->txtRequired = $txtRequired;
+ $this->txtReadOnly = $txtReadOnly;
+ }
+
+ function html()
+ {
+ $this->html = $this->renderButton();
+ return $this->html;
+ }
+
+ function css()
+ {
+ return $this->css;
+ }
+
+ private function renderButton()
+ {
+ $optionItems = '';
+ foreach ($this->txtArrayValues as $i => $value) {
+ $optionItems .= '<option value="'. $this->txtArrayValues[$i] .'" selected="">'. $i .'</option>'; ;
+ }
+
+ return '<select name="'. $this->txtID .'"
+ id="'. $this->txtID .'"
+ class="combobox_FW"
+ onchange=""
+ onblur="" onfocus="">
+
+ '. $optionItems .'
+
+ </select>
+ ';
+ }
+}
+
+
?>
View
10 index.php
@@ -4,19 +4,19 @@
include_once "Classes/Page.php";
include_once "Classes/Message.php";
include_once "Classes/Layout.php";
+include_once "Classes/Widget.php";
// Definizione della pagina
-$page = new Page();
+$page = new Page($withForm=true);
$page->width = 600;
$page->title = 'Titolo della pagina';
new Message($page, 'sender', 'ciao mondo', '');
$ll = new LinearLayout($page);
-new Message($ll, 'sender', 'ciao mondo', '');
-new Message($ll, 'sender', 'ciao mondo', '');
-$bl = new BlockLayout($ll);
-new Message($bl, 'sender', 'ciao monso', '');
+new Button($ll, 'btn_prova', 'click Me!');
+new Combobox($ll, 'cmb_test', Array("Pippo"=>"1", "Pluto"=>"2"));
+new Textfield($page, 'textfield', 'prova');
/*
$db = new Database("sms1.db");
Please sign in to comment.
Something went wrong with that request. Please try again.