From 47d51b0593e92d3a3167136efaf5281f213cfc42 Mon Sep 17 00:00:00 2001 From: denisdulici Date: Mon, 11 Apr 2016 15:43:17 +0300 Subject: [PATCH] added PHP 7 compatibility --- Base.php | 9 ++++++--- Element.php | 4 ++-- Element/CKEditor.php | 12 +++++++++--- Element/Captcha.php | 4 ++-- Element/Checkbox.php | 14 +++++++++----- Element/Checksort.php | 20 ++++++++++++-------- Element/Color.php | 6 +++++- Element/Date.php | 8 ++++++-- Element/Email.php | 6 +++++- Element/HTML.php | 4 ++-- Element/JQueryUIDate.php | 8 ++++++-- Element/Month.php | 10 +++++++--- Element/Number.php | 6 +++++- Element/Radio.php | 12 ++++++++---- Element/Select.php | 18 +++++++++++------- Element/Sort.php | 13 +++++++++---- Element/Summernote.php | 14 +++++++++----- Element/Textarea.php | 12 ++++++++---- Element/Textbox.php | 36 ++++++++++++++++++++++-------------- Element/TinyMCE.php | 12 ++++++++---- Element/Url.php | 6 +++++- Element/Week.php | 6 +++++- View.php | 12 +++++++----- View/Inline.php | 16 ++++++++++------ View/SideBySide.php | 16 ++++++++++------ View/Vertical.php | 22 +++++++++++++--------- 26 files changed, 201 insertions(+), 105 deletions(-) diff --git a/Base.php b/Base.php index eacb4ce..2a14d3b 100644 --- a/Base.php +++ b/Base.php @@ -33,7 +33,6 @@ public function configure(array $properties = null) $method_reference = array(); foreach ($available as $method) { - $method_reference[strtolower($method)] = $method; } @@ -45,9 +44,13 @@ public function configure(array $properties = null) /*If the appropriate class has a "set" method for the property provided, then it is called instead or setting the property directly.*/ if (isset($method_reference["set" . $property])) { - $this->$method_reference["set" . $property]($value); + $func = $method_reference["set" . $property]; + + $this->$func($value); } elseif (isset($property_reference[$property])) { - $this->$property_reference[$property] = $value; + $prop = $property_reference[$property]; + + $this->$prop = $value; } else { /*Entries that don't match an available class property are stored in the attributes property if applicable. Typically, these entries will be element attributes such as diff --git a/Element.php b/Element.php index 1333de6..6822ad4 100644 --- a/Element.php +++ b/Element.php @@ -156,9 +156,9 @@ public function jQueryOptions() /*Many of the included elements make use of the tag for display. These include the Hidden, Textbox, Password, Date, Color, Button, Email, and File element classes. The project's other element classes will override this method with their own implementation.*/ - public function render() + public function getInput() { - echo 'getAttributes(), '/>'; + return 'getAttributes() . '/>'; } /*If an element requires inline stylesheet definitions, this method is used send them to the browser before diff --git a/Element/CKEditor.php b/Element/CKEditor.php index b6e96b2..36a385b 100644 --- a/Element/CKEditor.php +++ b/Element/CKEditor.php @@ -17,11 +17,17 @@ class CKEditor extends Textarea public function render() { - echo "getAttributes(array("value", "required")), ">"; + $html = ''; + + $html .= "getAttributes(array("value", "required")) . ">"; + if (!empty($this->attributes["value"])) { - echo $this->attributes["value"]; + $html .= $this->attributes["value"]; } - echo ""; + + $html .= ""; + + return $html; } public function renderJS() diff --git a/Element/Captcha.php b/Element/Captcha.php index 02e0ace..05362cc 100644 --- a/Element/Captcha.php +++ b/Element/Captcha.php @@ -22,12 +22,12 @@ public function __construct($label = "", array $properties = null) parent::__construct($label, "recaptcha_response_field", $properties); } - public function render() + public function getInput() { $this->validation[] = new ValidationCaptcha($this->privateKey); require_once(__DIR__ . "/../Resources/recaptchalib.php"); - echo recaptcha_get_html($this->publicKey); + return recaptcha_get_html($this->publicKey); } } diff --git a/Element/Checkbox.php b/Element/Checkbox.php index 9064247..09f9366 100644 --- a/Element/Checkbox.php +++ b/Element/Checkbox.php @@ -16,8 +16,10 @@ class Checkbox extends OptionElement protected $attributes = array("type" => "checkbox"); protected $inline; - public function render() + public function getInput() { + $html = ''; + if (isset($this->attributes["value"])) { if (!is_array($this->attributes["value"])) { $this->attributes["value"] = array($this->attributes["value"]); @@ -41,18 +43,20 @@ public function render() foreach ($this->options as $value => $text) { $value = $this->getOptionValue($value); - echo ' '; ++$count; } + + return $html; } } diff --git a/Element/Checksort.php b/Element/Checksort.php index 914884d..c2f429e 100644 --- a/Element/Checksort.php +++ b/Element/Checksort.php @@ -14,8 +14,10 @@ class Checksort extends Sort protected $attributes = array("type" => "checkbox"); protected $inline; - public function render() + public function getInput() { + $html = ''; + if (isset($this->attributes["value"])) { if (!is_array($this->attributes["value"])) { $this->attributes["value"] = array($this->attributes["value"]); @@ -41,19 +43,19 @@ public function render() $value = $this->getOptionValue($value); if (!empty($this->inline) && $count > 0) { - echo ' '; + $html .= ' '; } - - echo '