From 2f969c80eb2e228f2c5729c6f4660c99555f9c9f Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 28 Jul 2009 11:59:58 +0800 Subject: Create A Forge Script element. Form_Script allows the specification of either a url to a script file or in line text which will be included in a script block. Signed-off-by: Tim Almdal --- modules/gallery/libraries/Form_Script.php | 66 +++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 modules/gallery/libraries/Form_Script.php (limited to 'modules/gallery/libraries/Form_Script.php') diff --git a/modules/gallery/libraries/Form_Script.php b/modules/gallery/libraries/Form_Script.php new file mode 100644 index 00000000..e841408d --- /dev/null +++ b/modules/gallery/libraries/Form_Script.php @@ -0,0 +1,66 @@ + false, + "type" => "script", + "url" => "", + "text" => ""); + + public function __construct($name) { + // Set dummy data so we don"t get errors + $this->attr["action"] = ""; + $this->attr["method"] = "post"; + $this->data["name"] = $name; + } + + public function __get($key) { + return isset($this->data[$key]) ? $this->data[$key] : null; + } + + /** + * Sets url attribute + */ + public function url($url) { + $this->data["url"] = $url; + + return $this; + } + + public function text($script_text) { + $this->data["text"] = $script_text; + + return $this; + } + + public function render() { + $script = array(); + if (!empty($this->data["url"])) { + $script[] = html::script($this->data["url"]); + } + + if (!empty($this->data["text"])) { + $script[] = "\n"; + } + + return implode("\n", $script); + } + +} // End Form Script \ No newline at end of file -- cgit v1.2.3