Completed
Push — intl ( 51e284 )
by Fabio
06:51
created
framework/Wsat/pages/TWsatLogin.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -12,21 +12,21 @@
 block discarded – undo
12 12
 class TWsatLogin extends TPage
13 13
 {
14 14
 
15
-        public function login()
16
-        {
17
-                if ($this->IsValid)
18
-                {
19
-                        $this->Session["wsat_password"] = $this->getService()->getPassword();
20
-                        $url = $this->Service->constructUrl('TWsatHome');
21
-                        $this->Response->redirect($url);
22
-                }
23
-        }
15
+		public function login()
16
+		{
17
+				if ($this->IsValid)
18
+				{
19
+						$this->Session["wsat_password"] = $this->getService()->getPassword();
20
+						$url = $this->Service->constructUrl('TWsatHome');
21
+						$this->Response->redirect($url);
22
+				}
23
+		}
24 24
 
25
-        public function validatePassword($sender, $param)
26
-        {
27
-                $config_pass = $this->Service->Password;
28
-                $user_pass = $this->password->Text;
29
-                $param->IsValid = $user_pass === $config_pass;
30
-        }
25
+		public function validatePassword($sender, $param)
26
+		{
27
+				$config_pass = $this->Service->Password;
28
+				$user_pass = $this->password->Text;
29
+				$param->IsValid = $user_pass === $config_pass;
30
+		}
31 31
 
32 32
 }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
framework/Wsat/TWsatARGenerator.php 1 patch
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -14,206 +14,206 @@  discard block
 block discarded – undo
14 14
 class TWsatARGenerator extends TWsatBaseGenerator
15 15
 {
16 16
 
17
-        /**
18
-         * Class name prefix
19
-         */
20
-        private $_clasPrefix;
21
-
22
-        /**
23
-         * Class name sufix
24
-         */
25
-        private $_classSufix;
26
-
27
-        /**
28
-         * all table relations array
29
-         */
30
-        private $_relations;
31
-
32
-        /**
33
-         * unquote chars
34
-         * @var array
35
-         */
36
-        private $uqChars = array('[', ']', '"', '`', "'");
37
-
38
-        function __construct()
39
-        {
40
-                parent::__construct();
41
-        }
42
-
43
-        public function setClasPrefix($_clas_prefix)
44
-        {
45
-                $this->_clasPrefix = $_clas_prefix;
46
-        }
47
-
48
-        public function setClassSufix($_clas_sufix)
49
-        {
50
-                $this->_classSufix = $_clas_sufix;
51
-        }
17
+		/**
18
+		 * Class name prefix
19
+		 */
20
+		private $_clasPrefix;
21
+
22
+		/**
23
+		 * Class name sufix
24
+		 */
25
+		private $_classSufix;
26
+
27
+		/**
28
+		 * all table relations array
29
+		 */
30
+		private $_relations;
31
+
32
+		/**
33
+		 * unquote chars
34
+		 * @var array
35
+		 */
36
+		private $uqChars = array('[', ']', '"', '`', "'");
37
+
38
+		function __construct()
39
+		{
40
+				parent::__construct();
41
+		}
42
+
43
+		public function setClasPrefix($_clas_prefix)
44
+		{
45
+				$this->_clasPrefix = $_clas_prefix;
46
+		}
47
+
48
+		public function setClassSufix($_clas_sufix)
49
+		{
50
+				$this->_classSufix = $_clas_sufix;
51
+		}
52 52
 
53 53
 //-----------------------------------------------------------------------------
54
-        // <editor-fold defaultstate="collapsed" desc="Main APIs">
55
-        public function generate($tableName)
56
-        {
57
-                $tableInfo = $this->_dbMetaData->getTableInfo($tableName);
58
-                $this->_commonGenerate($tableName, $tableInfo);
59
-        }
60
-
61
-        public function generateAll()
62
-        {
63
-                foreach ($this->getAllTableNames() as $tableName)
64
-                {
65
-                        $tableInfo = $this->_dbMetaData->getTableInfo($tableName);
66
-                        if (!empty($this->_relations))
67
-                        {
68
-                                // Cancel generation of M-M relationships middle table
69
-                                if (count($tableInfo->getPrimaryKeys()) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships
70
-                                        continue;
71
-                        }
72
-                        $this->_commonGenerate($tableName, $tableInfo);
73
-                }
74
-        }
75
-
76
-        public function buildRelations()
77
-        {
78
-                $this->_relations = array();
79
-                foreach ($this->getAllTableNames() as $table_name)
80
-                {
81
-                        $tableInfo = $this->_dbMetaData->getTableInfo($table_name);
82
-                        $pks = $tableInfo->getPrimaryKeys();
83
-                        $fks = $tableInfo->getForeignKeys();
84
-
85
-                        if (count($pks) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships
86
-                        {
87
-                                $table_name_mm = $fks[0]["table"];
88
-                                $table_name_mm2 = $fks[1]["table"];
89
-
90
-                                $this->_relations[$table_name_mm][] = array(
91
-                                        "prop_name" => strtolower($table_name_mm2),
92
-                                        "rel_type" => "self::MANY_TO_MANY",
93
-                                        "ref_class_name" => $this->_getProperClassName($table_name_mm2),
94
-                                        "prop_ref" => $table_name
95
-                                );
96
-
97
-                                $this->_relations[$table_name_mm2][] = array(
98
-                                        "prop_name" => strtolower($table_name_mm),
99
-                                        "rel_type" => "self::MANY_TO_MANY",
100
-                                        "ref_class_name" => $this->_getProperClassName($table_name_mm),
101
-                                        "prop_ref" => $table_name
102
-                                );
103
-                                continue;
104
-                        }
105
-                        foreach ($fks as $fk_data)//1-M relationships
106
-                        {
107
-                                $owner_table = $fk_data["table"];
108
-                                $slave_table = $table_name;
109
-                                $fk_prop = key($fk_data["keys"]);
110
-
111
-                                $this->_relations[$owner_table][] = array(
112
-                                        "prop_name" => strtolower($slave_table),
113
-                                        "rel_type" => "self::HAS_MANY",
114
-                                        "ref_class_name" => $this->_getProperClassName($slave_table),
115
-                                        "prop_ref" => $fk_prop
116
-                                );
117
-
118
-                                $this->_relations[$slave_table][] = array(
119
-                                        "prop_name" => strtolower($owner_table),
120
-                                        "rel_type" => "self::BELONGS_TO",
121
-                                        "ref_class_name" => $this->_getProperClassName($owner_table),
122
-                                        "prop_ref" => $fk_prop
123
-                                );
124
-                        }
125
-                }
126
-        }
54
+		// <editor-fold defaultstate="collapsed" desc="Main APIs">
55
+		public function generate($tableName)
56
+		{
57
+				$tableInfo = $this->_dbMetaData->getTableInfo($tableName);
58
+				$this->_commonGenerate($tableName, $tableInfo);
59
+		}
60
+
61
+		public function generateAll()
62
+		{
63
+				foreach ($this->getAllTableNames() as $tableName)
64
+				{
65
+						$tableInfo = $this->_dbMetaData->getTableInfo($tableName);
66
+						if (!empty($this->_relations))
67
+						{
68
+								// Cancel generation of M-M relationships middle table
69
+								if (count($tableInfo->getPrimaryKeys()) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships
70
+										continue;
71
+						}
72
+						$this->_commonGenerate($tableName, $tableInfo);
73
+				}
74
+		}
75
+
76
+		public function buildRelations()
77
+		{
78
+				$this->_relations = array();
79
+				foreach ($this->getAllTableNames() as $table_name)
80
+				{
81
+						$tableInfo = $this->_dbMetaData->getTableInfo($table_name);
82
+						$pks = $tableInfo->getPrimaryKeys();
83
+						$fks = $tableInfo->getForeignKeys();
84
+
85
+						if (count($pks) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships
86
+						{
87
+								$table_name_mm = $fks[0]["table"];
88
+								$table_name_mm2 = $fks[1]["table"];
89
+
90
+								$this->_relations[$table_name_mm][] = array(
91
+										"prop_name" => strtolower($table_name_mm2),
92
+										"rel_type" => "self::MANY_TO_MANY",
93
+										"ref_class_name" => $this->_getProperClassName($table_name_mm2),
94
+										"prop_ref" => $table_name
95
+								);
96
+
97
+								$this->_relations[$table_name_mm2][] = array(
98
+										"prop_name" => strtolower($table_name_mm),
99
+										"rel_type" => "self::MANY_TO_MANY",
100
+										"ref_class_name" => $this->_getProperClassName($table_name_mm),
101
+										"prop_ref" => $table_name
102
+								);
103
+								continue;
104
+						}
105
+						foreach ($fks as $fk_data)//1-M relationships
106
+						{
107
+								$owner_table = $fk_data["table"];
108
+								$slave_table = $table_name;
109
+								$fk_prop = key($fk_data["keys"]);
110
+
111
+								$this->_relations[$owner_table][] = array(
112
+										"prop_name" => strtolower($slave_table),
113
+										"rel_type" => "self::HAS_MANY",
114
+										"ref_class_name" => $this->_getProperClassName($slave_table),
115
+										"prop_ref" => $fk_prop
116
+								);
117
+
118
+								$this->_relations[$slave_table][] = array(
119
+										"prop_name" => strtolower($owner_table),
120
+										"rel_type" => "self::BELONGS_TO",
121
+										"ref_class_name" => $this->_getProperClassName($owner_table),
122
+										"prop_ref" => $fk_prop
123
+								);
124
+						}
125
+				}
126
+		}
127 127
 
128 128
 // </editor-fold>
129 129
 //-----------------------------------------------------------------------------
130
-        // <editor-fold defaultstate="collapsed" desc="Common Methods">
131
-
132
-        private function _commonGenerate($tableName, $tableInfo)
133
-        {
134
-                if (count($tableInfo->getColumns()) === 0)
135
-                        throw new Exception("Unable to find table or view $tableName in " . $this->_dbMetaData->getDbConnection()->getConnectionString() . ".");
136
-                else
137
-                {
138
-                        $properties = array();
139
-                        foreach ($tableInfo->getColumns() as $field => $metadata)
140
-                                $properties[] = $this->generateProperty($field, $metadata);
141
-                        $toString = $this->_buildSmartToString($tableInfo);
142
-                }
143
-
144
-                $clasName = $this->_getProperClassName($tableName);
145
-                $class = $this->generateClass($properties, $tableName, $clasName, $toString);
146
-                $output = $this->_opFile . DIRECTORY_SEPARATOR . $clasName . ".php";
147
-                file_put_contents($output, $class);
148
-        }
149
-
150
-        private function _getProperClassName($tableName)
151
-        {
152
-                $table_name_words = str_replace("_", " ", strtolower($tableName));
153
-                $final_conversion = str_replace(" ", "", ucwords($table_name_words));
154
-                return $this->_clasPrefix . $final_conversion . $this->_classSufix;
155
-        }
130
+		// <editor-fold defaultstate="collapsed" desc="Common Methods">
131
+
132
+		private function _commonGenerate($tableName, $tableInfo)
133
+		{
134
+				if (count($tableInfo->getColumns()) === 0)
135
+						throw new Exception("Unable to find table or view $tableName in " . $this->_dbMetaData->getDbConnection()->getConnectionString() . ".");
136
+				else
137
+				{
138
+						$properties = array();
139
+						foreach ($tableInfo->getColumns() as $field => $metadata)
140
+								$properties[] = $this->generateProperty($field, $metadata);
141
+						$toString = $this->_buildSmartToString($tableInfo);
142
+				}
143
+
144
+				$clasName = $this->_getProperClassName($tableName);
145
+				$class = $this->generateClass($properties, $tableName, $clasName, $toString);
146
+				$output = $this->_opFile . DIRECTORY_SEPARATOR . $clasName . ".php";
147
+				file_put_contents($output, $class);
148
+		}
149
+
150
+		private function _getProperClassName($tableName)
151
+		{
152
+				$table_name_words = str_replace("_", " ", strtolower($tableName));
153
+				$final_conversion = str_replace(" ", "", ucwords($table_name_words));
154
+				return $this->_clasPrefix . $final_conversion . $this->_classSufix;
155
+		}
156 156
 
157 157
 //-----------------------------------------------------------------------------
158 158
 
159
-        protected function generateProperty($field, $metadata)
160
-        {
161
-                $prop = '';
162
-                $name = '$' . $field;
163
-
164
-                /* TODO use in version 2.0 */
165
-                // $type = $column->getPHPType();
166
-
167
-                $prop .= "\tpublic $name;";
168
-                return $prop;
169
-        }
170
-
171
-        private function _renderRelations($tablename)
172
-        {
173
-                if (!isset($this->_relations[$tablename]))
174
-                        return "";
175
-
176
-                $code = "\tpublic static \$RELATIONS = array (";
177
-                foreach ($this->_relations[$tablename] as $rel_data)
178
-                        $code .= "\n\t\t'" . $rel_data["prop_name"] . "' => array(" . $rel_data["rel_type"] . ", '" . $rel_data["ref_class_name"] . "', '" . $rel_data["prop_ref"] . "'),";
179
-
180
-                $code = substr($code, 0, -1);
181
-                $code .= "\n\t);";
182
-                return $code;
183
-        }
184
-
185
-        private function _buildSmartToString($tableInfo)
186
-        {
187
-                $code = "\tpublic function __toString() {";
188
-                $property = "throw new THttpException(500, 'Not implemented yet.');";
189
-                try
190
-                {
191
-                        foreach ($tableInfo->getColumns() as $column)
192
-                        {
193
-                                if (isset($column->IsPrimaryKey) && $column->IsPrimaryKey)
194
-                                        $property = str_replace($this->uqChars, "", $column->ColumnName);
195
-                                elseif ($column->PdoType == PDO::PARAM_STR && $column->DBType != "date")
196
-                                {
197
-                                        $property = str_replace($this->uqChars, "", $column->ColumnName);
198
-                                        break;
199
-                                }
200
-                        }
201
-                } catch (Exception $ex)
202
-                {
203
-                        Prado::trace($ex->getMessage());
204
-                }
205
-                $code .= "\n\t\treturn \$this->$property;";
206
-                $code .= "\n\t}";
207
-                return $code;
208
-        }
209
-
210
-        protected function generateClass($properties, $tablename, $classname, $toString)
211
-        {
212
-                $props = implode("\n", $properties);
213
-                $relations = $this->_renderRelations($tablename);
214
-                $date = date('Y-m-d h:i:s');
215
-                $env_user = getenv("username");
216
-                return <<<EOD
159
+		protected function generateProperty($field, $metadata)
160
+		{
161
+				$prop = '';
162
+				$name = '$' . $field;
163
+
164
+				/* TODO use in version 2.0 */
165
+				// $type = $column->getPHPType();
166
+
167
+				$prop .= "\tpublic $name;";
168
+				return $prop;
169
+		}
170
+
171
+		private function _renderRelations($tablename)
172
+		{
173
+				if (!isset($this->_relations[$tablename]))
174
+						return "";
175
+
176
+				$code = "\tpublic static \$RELATIONS = array (";
177
+				foreach ($this->_relations[$tablename] as $rel_data)
178
+						$code .= "\n\t\t'" . $rel_data["prop_name"] . "' => array(" . $rel_data["rel_type"] . ", '" . $rel_data["ref_class_name"] . "', '" . $rel_data["prop_ref"] . "'),";
179
+
180
+				$code = substr($code, 0, -1);
181
+				$code .= "\n\t);";
182
+				return $code;
183
+		}
184
+
185
+		private function _buildSmartToString($tableInfo)
186
+		{
187
+				$code = "\tpublic function __toString() {";
188
+				$property = "throw new THttpException(500, 'Not implemented yet.');";
189
+				try
190
+				{
191
+						foreach ($tableInfo->getColumns() as $column)
192
+						{
193
+								if (isset($column->IsPrimaryKey) && $column->IsPrimaryKey)
194
+										$property = str_replace($this->uqChars, "", $column->ColumnName);
195
+								elseif ($column->PdoType == PDO::PARAM_STR && $column->DBType != "date")
196
+								{
197
+										$property = str_replace($this->uqChars, "", $column->ColumnName);
198
+										break;
199
+								}
200
+						}
201
+				} catch (Exception $ex)
202
+				{
203
+						Prado::trace($ex->getMessage());
204
+				}
205
+				$code .= "\n\t\treturn \$this->$property;";
206
+				$code .= "\n\t}";
207
+				return $code;
208
+		}
209
+
210
+		protected function generateClass($properties, $tablename, $classname, $toString)
211
+		{
212
+				$props = implode("\n", $properties);
213
+				$relations = $this->_renderRelations($tablename);
214
+				$date = date('Y-m-d h:i:s');
215
+				$env_user = getenv("username");
216
+				return <<<EOD
217 217
 <?php
218 218
 /**
219 219
  * Auto generated by PRADO - WSAT on $date.
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 $toString
235 235
 }
236 236
 EOD;
237
-        }
237
+		}
238 238
 
239 239
 // </editor-fold>
240 240
 }
241 241
\ No newline at end of file
Please login to merge, or discard this patch.
framework/Web/UI/ActiveControls/TActiveListControlAdapter.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
 		}
121 121
 	}
122 122
 
123
-    /**
124
-     * Clears all existing selections on the client side.
125
-     */
126
-    public function clearSelection()
127
-    {
123
+	/**
124
+	 * Clears all existing selections on the client side.
125
+	 */
126
+	public function clearSelection()
127
+	{
128 128
 		if($this->canUpdateClientSide())
129 129
 		{
130 130
 			$this->updateListItems();
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 				$this->getPage()->getCallbackClient()->select($this->getControl(), 'Clear');
138 138
 			}
139 139
 		}
140
-    }
140
+	}
141 141
 
142 142
 	/**
143 143
 	 * Update the client-side list options.
Please login to merge, or discard this patch.
framework/Web/UI/ActiveControls/TActiveControlAdapter.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -78,8 +78,8 @@
 block discarded – undo
78 78
 	}
79 79
 
80 80
  	/**
81
-	 * Publish the ajax script
82
-	 */
81
+ 	 * Publish the ajax script
82
+ 	 */
83 83
 	public function onPreRender($param)
84 84
 	{
85 85
 		parent::onPreRender($param);
Please login to merge, or discard this patch.
framework/Web/UI/WebControls/TKeyboard.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -173,15 +173,15 @@
 block discarded – undo
173 173
 	{
174 174
 		if(($forControl=$this->getForControl())==='')
175 175
 			throw new TConfigurationException('keyboard_forcontrol_required');
176
-	    if(($target=$this->findControl($forControl))===null)
177
-	        throw new TConfigurationException('keyboard_forcontrol_invalid',$forControl);
176
+		if(($target=$this->findControl($forControl))===null)
177
+			throw new TConfigurationException('keyboard_forcontrol_invalid',$forControl);
178 178
 
179
-	    $options['ID'] = $this->getClientID();
180
-	    $options['ForControl'] = $target->getClientID();
181
-	    $options['AutoHide'] = $this->getAutoHide();
182
-	    $options['CssClass'] = $this->getKeyboardCssClass();
179
+		$options['ID'] = $this->getClientID();
180
+		$options['ForControl'] = $target->getClientID();
181
+		$options['AutoHide'] = $this->getAutoHide();
182
+		$options['CssClass'] = $this->getKeyboardCssClass();
183 183
 
184
-	    return $options;
184
+		return $options;
185 185
 	}
186 186
 }
187 187
 
Please login to merge, or discard this patch.
framework/Web/UI/WebControls/TPanel.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@
 block discarded – undo
101 101
 
102 102
 	/**
103 103
 	 * Sets the horizontal alignment of the contents within the panel.
104
-     * Valid values include 'NotSet', 'Justify', 'Left', 'Right', 'Center'
104
+	 * Valid values include 'NotSet', 'Justify', 'Left', 'Right', 'Center'
105 105
 	 * @param string the horizontal alignment
106 106
 	 */
107 107
 	public function setHorizontalAlign($value)
Please login to merge, or discard this patch.
framework/Web/UI/ActiveControls/TActiveDataGrid.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
 	}
69 69
 
70 70
 	/**
71
-	* Creates a new callback control, sets the adapter to
72
-	* TActiveControlAdapter.
73
-	*/
71
+	 * Creates a new callback control, sets the adapter to
72
+	 * TActiveControlAdapter.
73
+	 */
74 74
 	public function __construct() {
75 75
 		parent::__construct();
76 76
 		$this->setAdapter(new TActiveControlAdapter($this));
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * @param string $value container tag
112 112
 	 */
113 113
 	public function setSurroundingTag($value) {
114
-    $this->_surroundingTag=TPropertyValue::ensureString($value);
114
+	$this->_surroundingTag=TPropertyValue::ensureString($value);
115 115
 	}
116 116
 
117 117
 	/**
Please login to merge, or discard this patch.
framework/Web/UI/WebControls/TCheckBoxList.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
 	{
405 405
 	  if ($needSpan=$this->getSpanNeeded())
406 406
 	  {
407
-	    $writer->addAttribute('id', $this->getClientId());
408
-	    $writer->renderBeginTag('span');
407
+		$writer->addAttribute('id', $this->getClientId());
408
+		$writer->renderBeginTag('span');
409 409
 	  }
410 410
 		if($this->getItemCount()>0)
411 411
 		{
@@ -463,14 +463,14 @@  discard block
 block discarded – undo
463 463
 	 */
464 464
 	public function getIsValid()
465 465
 	{
466
-	    return $this->_isValid;
466
+		return $this->_isValid;
467 467
 	}
468 468
 	/**
469 469
 	 * @param bool wether this control is valid.
470 470
 	 */
471 471
 	public function setIsValid($value)
472 472
 	{
473
-	    $this->_isValid=TPropertyValue::ensureBoolean($value);
473
+		$this->_isValid=TPropertyValue::ensureBoolean($value);
474 474
 	}
475 475
 
476 476
 	/**
Please login to merge, or discard this patch.
framework/Web/UI/WebControls/TReCaptcha2Validator.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -29,82 +29,82 @@
 block discarded – undo
29 29
 
30 30
 class TReCaptcha2Validator extends TBaseValidator
31 31
 {
32
-    protected $_isvalid = null;
32
+	protected $_isvalid = null;
33 33
 
34
-    protected function getClientClassName()
35
-    {
36
-        return 'Prado.WebUI.TReCaptcha2Validator';
37
-    }
38
-    public function getEnableClientScript()
39
-    {
40
-        return true;
41
-    }
42
-    protected function getCaptchaControl()
43
-    {
44
-        $control = $this->getValidationTarget();
45
-        if (!$control)
46
-            throw new Exception('No target control specified for TReCaptcha2Validator');
47
-        if (!($control instanceof TReCaptcha2))
48
-            throw new Exception('TReCaptcha2Validator only works with TReCaptcha2 controls');
49
-        return $control;
50
-    }
51
-    public function getClientScriptOptions()
52
-    {
53
-        $options = parent::getClientScriptOptions();
54
-        $options['ResponseFieldName'] = $this->getCaptchaControl()->getResponseFieldName();
55
-        return $options;
56
-    }
57
-    /**
58
-     * This method overrides the parent's implementation.
59
-     * The validation succeeds if the input control has the same value
60
-     * as the one displayed in the corresponding RECAPTCHA control.
61
-     *
62
-     * @return boolean whether the validation succeeds
63
-     */
64
-    protected function evaluateIsValid()
65
-    {
66
-        // check validity only once (if trying to evaulate multiple times, all redundant checks would fail)
67
-        if (is_null($this->_isvalid))
68
-        {
69
-            $control = $this->getCaptchaControl();
70
-            $this->_isvalid = $control->validate();
71
-        }
72
-        return ($this->_isvalid==true);
73
-    }
74
-    public function onPreRender($param)
75
-    {
76
-        parent::onPreRender($param);
34
+	protected function getClientClassName()
35
+	{
36
+		return 'Prado.WebUI.TReCaptcha2Validator';
37
+	}
38
+	public function getEnableClientScript()
39
+	{
40
+		return true;
41
+	}
42
+	protected function getCaptchaControl()
43
+	{
44
+		$control = $this->getValidationTarget();
45
+		if (!$control)
46
+			throw new Exception('No target control specified for TReCaptcha2Validator');
47
+		if (!($control instanceof TReCaptcha2))
48
+			throw new Exception('TReCaptcha2Validator only works with TReCaptcha2 controls');
49
+		return $control;
50
+	}
51
+	public function getClientScriptOptions()
52
+	{
53
+		$options = parent::getClientScriptOptions();
54
+		$options['ResponseFieldName'] = $this->getCaptchaControl()->getResponseFieldName();
55
+		return $options;
56
+	}
57
+	/**
58
+	 * This method overrides the parent's implementation.
59
+	 * The validation succeeds if the input control has the same value
60
+	 * as the one displayed in the corresponding RECAPTCHA control.
61
+	 *
62
+	 * @return boolean whether the validation succeeds
63
+	 */
64
+	protected function evaluateIsValid()
65
+	{
66
+		// check validity only once (if trying to evaulate multiple times, all redundant checks would fail)
67
+		if (is_null($this->_isvalid))
68
+		{
69
+			$control = $this->getCaptchaControl();
70
+			$this->_isvalid = $control->validate();
71
+		}
72
+		return ($this->_isvalid==true);
73
+	}
74
+	public function onPreRender($param)
75
+	{
76
+		parent::onPreRender($param);
77 77
 
78
-        $cs = $this->Page->getClientScript();
79
-        $cs->registerPradoScript('validator');
78
+		$cs = $this->Page->getClientScript();
79
+		$cs->registerPradoScript('validator');
80 80
 
81
-        // communicate validation status to the client side
82
-        $value = $this->_isvalid===false ? '0' : '1';
83
-        $cs->registerHiddenField($this->getClientID().'_1',$value);
81
+		// communicate validation status to the client side
82
+		$value = $this->_isvalid===false ? '0' : '1';
83
+		$cs->registerHiddenField($this->getClientID().'_1',$value);
84 84
 
85
-        // update validator display
86
-        if ($control = $this->getValidationTarget())
87
-        {
88
-            $fn = 'captchaUpdateValidatorStatus_'.$this->getClientID();
85
+		// update validator display
86
+		if ($control = $this->getValidationTarget())
87
+		{
88
+			$fn = 'captchaUpdateValidatorStatus_'.$this->getClientID();
89 89
 
90
-            $cs->registerEndScript($this->getClientID().'::validate', implode(' ',array(
91
-                // this function will be used to update the validator
92
-                'function '.$fn.'(valid)',
93
-                '{',
94
-                '  jQuery('.TJavaScript::quoteString('#'.$this->getClientID().'_1').').val(valid);',
95
-                '  Prado.Validation.validateControl('.TJavaScript::quoteString($control->ClientID).'); ',
96
-                '}',
97
-                '',
98
-                // update the validator to the result if we're in a callback 
99
-                // (if we're in initial rendering or a postback then the result will be rendered directly to the page html anyway)
100
-                $this->Page->IsCallback ? $fn.'('.$value.');' : '',
101
-                '',
102
-                // install event handler that clears the validation error when user changes the captcha response field
103
-                'jQuery("#'.$control->getClientID().'").on("change", '.TJavaScript::quoteString('#'.$control->getResponseFieldName()).', function() { ',
104
-                    $fn.'("1");',
105
-                '});',
106
-            )));
107
-        }
108
-    }
90
+			$cs->registerEndScript($this->getClientID().'::validate', implode(' ',array(
91
+				// this function will be used to update the validator
92
+				'function '.$fn.'(valid)',
93
+				'{',
94
+				'  jQuery('.TJavaScript::quoteString('#'.$this->getClientID().'_1').').val(valid);',
95
+				'  Prado.Validation.validateControl('.TJavaScript::quoteString($control->ClientID).'); ',
96
+				'}',
97
+				'',
98
+				// update the validator to the result if we're in a callback 
99
+				// (if we're in initial rendering or a postback then the result will be rendered directly to the page html anyway)
100
+				$this->Page->IsCallback ? $fn.'('.$value.');' : '',
101
+				'',
102
+				// install event handler that clears the validation error when user changes the captcha response field
103
+				'jQuery("#'.$control->getClientID().'").on("change", '.TJavaScript::quoteString('#'.$control->getResponseFieldName()).', function() { ',
104
+					$fn.'("1");',
105
+				'});',
106
+			)));
107
+		}
108
+	}
109 109
 }
110 110
 
Please login to merge, or discard this patch.