Completed
Push — intl ( 51e284...b391f2 )
by Fabio
09:17
created
framework/Web/UI/WebControls/TFileUpload.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -83,17 +83,17 @@  discard block
 block discarded – undo
83 83
 	{
84 84
 		$this->getPage()->ensureRenderInForm($this);
85 85
 		parent::addAttributesToRender($writer);
86
-		$writer->addAttribute('type','file');
86
+		$writer->addAttribute('type', 'file');
87 87
 		$name=$this->getUniqueID();
88 88
 		if($this->getMultiple())
89 89
 		{
90 90
 		  $name.='[]';
91
-		  $writer->addAttribute('multiple','multiple');
91
+		  $writer->addAttribute('multiple', 'multiple');
92 92
 		}
93
-		$writer->addAttribute('name',$name);
93
+		$writer->addAttribute('name', $name);
94 94
 		$isEnabled=$this->getEnabled(true);
95 95
 		if(!$isEnabled && $this->getEnabled())  // in this case parent will not render 'disabled'
96
-			$writer->addAttribute('disabled','disabled');
96
+			$writer->addAttribute('disabled', 'disabled');
97 97
 	}
98 98
 
99 99
 	/**
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 			else
112 112
 				$form->setEnctype('multipart/form-data');
113 113
 		}
114
-		$this->getPage()->getClientScript()->registerHiddenField('MAX_FILE_SIZE',$this->getMaxFileSize());
114
+		$this->getPage()->getClientScript()->registerHiddenField('MAX_FILE_SIZE', $this->getMaxFileSize());
115 115
 		if($this->getEnabled(true))
116 116
 			$this->getPage()->registerRequiresPostData($this);
117 117
 	}
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	public function getMaxFileSize()
124 124
 	{
125
-		return $this->getViewState('MaxFileSize',self::MAX_FILE_SIZE);
125
+		return $this->getViewState('MaxFileSize', self::MAX_FILE_SIZE);
126 126
 	}
127 127
 
128 128
 	/**
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 */
136 136
 	public function setMaxFileSize($size)
137 137
 	{
138
-		$this->setViewState('MaxFileSize',TPropertyValue::ensureInteger($size),self::MAX_FILE_SIZE);
138
+		$this->setViewState('MaxFileSize', TPropertyValue::ensureInteger($size), self::MAX_FILE_SIZE);
139 139
 	}
140 140
 
141 141
 	/**
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 */
146 146
 	public function getFileName($index=0)
147 147
 	{
148
-	  return isset($this->_files[$index])?$this->_files[$index]->getFileName():'';
148
+	  return isset($this->_files[$index]) ? $this->_files[$index]->getFileName() : '';
149 149
 	}
150 150
 
151 151
 	/**
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 */
156 156
 	public function getFileSize($index=0)
157 157
 	{
158
-	  return isset($this->_files[$index])?$this->_files[$index]->getFileSize():0;
158
+	  return isset($this->_files[$index]) ? $this->_files[$index]->getFileSize() : 0;
159 159
 	}
160 160
 
161 161
 	/**
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 */
167 167
 	public function getFileType($index=0)
168 168
 	{
169
-	  return isset($this->_files[$index])?$this->_files[$index]->getFileType():'';
169
+	  return isset($this->_files[$index]) ? $this->_files[$index]->getFileType() : '';
170 170
 	}
171 171
 
172 172
 	/**
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 	 */
178 178
 	public function getLocalName($index=0)
179 179
 	{
180
-	  return isset($this->_files[$index])?$this->_files[$index]->getLocalName():'';
180
+	  return isset($this->_files[$index]) ? $this->_files[$index]->getLocalName() : '';
181 181
 	}
182 182
 
183 183
 	/**
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 */
190 190
 	public function getErrorCode($index=0)
191 191
 	{
192
-		return isset($this->_files[$index])?$this->_files[$index]->getErrorCode():UPLOAD_ERR_NO_FILE;
192
+		return isset($this->_files[$index]) ? $this->_files[$index]->getErrorCode() : UPLOAD_ERR_NO_FILE;
193 193
 	}
194 194
 
195 195
 	/**
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	 */
200 200
 	public function getHasFile($index=0)
201 201
 	{
202
-	  return isset($this->_files[$index])?$this->_files[$index]->getHasFile():false;
202
+	  return isset($this->_files[$index]) ? $this->_files[$index]->getHasFile() : false;
203 203
 	}
204 204
 
205 205
 	/**
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
 	 * @param integer the index of the uploaded file, defaults to 0.
224 224
 	 * @return boolean true if the file saving is successful
225 225
 	 */
226
-	public function saveAs($fileName,$deleteTempFile=true,$index=0)
226
+	public function saveAs($fileName, $deleteTempFile=true, $index=0)
227 227
 	{
228
-	  return isset($this->_files[$index])?$this->_files[$index]->saveAs($fileName,$deleteTempFile):false;
228
+	  return isset($this->_files[$index]) ? $this->_files[$index]->saveAs($fileName, $deleteTempFile) : false;
229 229
 	}
230 230
 
231 231
 	/**
@@ -235,17 +235,17 @@  discard block
 block discarded – undo
235 235
 	 * @param array the input data collection
236 236
 	 * @return boolean whether the data of the control has been changed
237 237
 	 */
238
-	public function loadPostData($key,$values)
238
+	public function loadPostData($key, $values)
239 239
 	{
240 240
 		if(isset($_FILES[$key]))
241 241
 		{
242
-		  if($this->getMultiple()||is_array($_FILES[$key]['name']))
242
+		  if($this->getMultiple() || is_array($_FILES[$key]['name']))
243 243
 		  {
244 244
         foreach($_FILES[$key]['name'] as $index => $name)
245
-          $this->_files[$index]=new TFileUploadItem($name,$_FILES[$key]['size'][$index],$_FILES[$key]['type'][$index],$_FILES[$key]['error'][$index],$_FILES[$key]['tmp_name'][$index]);
245
+          $this->_files[$index]=new TFileUploadItem($name, $_FILES[$key]['size'][$index], $_FILES[$key]['type'][$index], $_FILES[$key]['error'][$index], $_FILES[$key]['tmp_name'][$index]);
246 246
 		  }
247 247
 		  else
248
-		    $this->_files[0]=new TFileUploadItem($_FILES[$key]['name'],$_FILES[$key]['size'],$_FILES[$key]['type'],$_FILES[$key]['error'],$_FILES[$key]['tmp_name']);
248
+		    $this->_files[0]=new TFileUploadItem($_FILES[$key]['name'], $_FILES[$key]['size'], $_FILES[$key]['type'], $_FILES[$key]['error'], $_FILES[$key]['tmp_name']);
249 249
 			return $this->_dataChanged=true;
250 250
 		}
251 251
 		else
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 */
272 272
 	public function onFileUpload($param)
273 273
 	{
274
-		$this->raiseEvent('OnFileUpload',$this,$param);
274
+		$this->raiseEvent('OnFileUpload', $this, $param);
275 275
 	}
276 276
 
277 277
 	/**
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	 */
292 292
 	public function getValidationPropertyValue()
293 293
 	{
294
-		return implode(',',array_map(function($file){return $file->getFileName();},$this->_files));
294
+		return implode(',', array_map(function($file) {return $file->getFileName(); },$this->_files));
295 295
 	}
296 296
 
297 297
 	/**
Please login to merge, or discard this patch.
framework/Web/UI/WebControls/TFileUploadItem.php 1 patch
Indentation   +31 added lines, -32 removed lines patch added patch discarded remove patch
@@ -18,7 +18,6 @@  discard block
 block discarded – undo
18 18
  * is especially needed when {@link TFileUpload::setMultiple} is set to true.
19 19
  *
20 20
  * See {@link TFileUpload} documentation for more details.
21
-
22 21
  * @author LANDWEHR Computer und Software GmbH <[email protected]>
23 22
  * @package Prado\Web\UI\WebControls
24 23
  * @since 4.0
@@ -48,11 +47,11 @@  discard block
 block discarded – undo
48 47
 
49 48
   public function __construct($fileName, $fileSize, $fileType, $errorCode, $localName)
50 49
   {
51
-    $this->_fileName = $fileName;
52
-    $this->_fileSize = $fileSize;
53
-    $this->_fileType = $fileType;
54
-    $this->_errorCode = $errorCode;
55
-    $this->_localName = $localName;
50
+	$this->_fileName = $fileName;
51
+	$this->_fileSize = $fileSize;
52
+	$this->_fileType = $fileType;
53
+	$this->_errorCode = $errorCode;
54
+	$this->_localName = $localName;
56 55
   }
57 56
 
58 57
   /**
@@ -60,7 +59,7 @@  discard block
 block discarded – undo
60 59
    */
61 60
   public function getFileName()
62 61
   {
63
-    return $this->_fileName;
62
+	return $this->_fileName;
64 63
   }
65 64
 
66 65
   /**
@@ -68,7 +67,7 @@  discard block
 block discarded – undo
68 67
    */
69 68
   public function getFileSize()
70 69
   {
71
-    return $this->_fileSize;
70
+	return $this->_fileSize;
72 71
   }
73 72
 
74 73
   /**
@@ -77,7 +76,7 @@  discard block
 block discarded – undo
77 76
    */
78 77
   public function getFileType()
79 78
   {
80
-    return $this->_fileType;
79
+	return $this->_fileType;
81 80
   }
82 81
 
83 82
   /**
@@ -86,7 +85,7 @@  discard block
 block discarded – undo
86 85
    */
87 86
   public function getLocalName()
88 87
   {
89
-    return $this->_localName;
88
+	return $this->_localName;
90 89
   }
91 90
 
92 91
   /**
@@ -94,7 +93,7 @@  discard block
 block discarded – undo
94 93
    */
95 94
   public function setLocalName($value)
96 95
   {
97
-    $this->_localName = $value;
96
+	$this->_localName = $value;
98 97
   }
99 98
 
100 99
   /**
@@ -104,7 +103,7 @@  discard block
 block discarded – undo
104 103
    */
105 104
   public function getErrorCode()
106 105
   {
107
-    return $this->_errorCode;
106
+	return $this->_errorCode;
108 107
   }
109 108
 
110 109
   /**
@@ -114,7 +113,7 @@  discard block
 block discarded – undo
114 113
    */
115 114
   public function setErrorCode($value)
116 115
   {
117
-    $this->_errorCode = $value;
116
+	$this->_errorCode = $value;
118 117
   }
119 118
 
120 119
   /**
@@ -122,7 +121,7 @@  discard block
 block discarded – undo
122 121
    */
123 122
   public function getHasFile()
124 123
   {
125
-    return $this->_errorCode===UPLOAD_ERR_OK;
124
+	return $this->_errorCode===UPLOAD_ERR_OK;
126 125
   }
127 126
 
128 127
   /**
@@ -134,17 +133,17 @@  discard block
 block discarded – undo
134 133
    */
135 134
   public function saveAs($fileName,$deleteTempFile=true)
136 135
   {
137
-    if($this->_errorCode===UPLOAD_ERR_OK)
138
-    {
139
-      if($deleteTempFile)
140
-        return move_uploaded_file($this->_localName,$fileName);
141
-      else if(is_uploaded_file($this->_localName))
142
-        return file_put_contents($fileName,file_get_contents($this->_localName))!==false;
143
-      else
144
-        return false;
145
-    }
146
-    else
147
-      return false;
136
+	if($this->_errorCode===UPLOAD_ERR_OK)
137
+	{
138
+	  if($deleteTempFile)
139
+		return move_uploaded_file($this->_localName,$fileName);
140
+	  else if(is_uploaded_file($this->_localName))
141
+		return file_put_contents($fileName,file_get_contents($this->_localName))!==false;
142
+	  else
143
+		return false;
144
+	}
145
+	else
146
+	  return false;
148 147
   }
149 148
 
150 149
   /**
@@ -152,13 +151,13 @@  discard block
 block discarded – undo
152 151
    */
153 152
   public function toArray()
154 153
   {
155
-    return array(
156
-      'fileName' => $this->_fileName,
157
-      'fileSize' => $this->_fileSize,
158
-      'fileType' => $this->_fileType,
159
-      'errorCode' => $this->_errorCode,
160
-      'localName' => $this->_localName
161
-    );
154
+	return array(
155
+	  'fileName' => $this->_fileName,
156
+	  'fileSize' => $this->_fileSize,
157
+	  'fileType' => $this->_fileType,
158
+	  'errorCode' => $this->_errorCode,
159
+	  'localName' => $this->_localName
160
+	);
162 161
   }
163 162
 
164 163
 }
165 164
\ No newline at end of file
Please login to merge, or discard this patch.
framework/Web/UI/ActiveControls/TActiveFileUpload.php 1 patch
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
  */
61 61
 class TActiveFileUpload extends TFileUpload implements IActiveControl, ICallbackEventHandler, INamingContainer
62 62
 {
63
-	const SCRIPT_PATH = 'activefileupload';
63
+	const SCRIPT_PATH='activefileupload';
64 64
 
65 65
 	/**
66 66
 	 * @var THiddenField a flag to tell which component is doing the callback.
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 * TActiveControlAdapter. If you override this class, be sure to set the
90 90
 	 * adapter appropriately by, for example, by calling this constructor.
91 91
 	 */
92
-	public function __construct(){
92
+	public function __construct() {
93 93
 		parent::__construct();
94 94
 		$this->setAdapter(new TActiveControlAdapter($this));
95 95
 	}
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	protected function getAssetUrl($file='')
103 103
 	{
104
-		$base = $this->getPage()->getClientScript()->getPradoScriptAssetUrl();
104
+		$base=$this->getPage()->getClientScript()->getPradoScriptAssetUrl();
105 105
 		return $base.'/'.self::SCRIPT_PATH.'/'.$file;
106 106
 	}
107 107
 
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	public function onFileUpload($param)
116 116
 	{
117
-		if ($this->_flag->getValue() && $this->getPage()->getIsPostBack() && $param == $this->_target->getUniqueID()){
118
-		  $params = new TActiveFileUploadCallbackParams;
117
+		if($this->_flag->getValue() && $this->getPage()->getIsPostBack() && $param==$this->_target->getUniqueID()) {
118
+		  $params=new TActiveFileUploadCallbackParams;
119 119
 		  // save the files so that they will persist past the end of this return.
120
-		  foreach ($this->getFiles() as $file) {
121
-			  $localName = str_replace('\\', '/', tempnam(Prado::getPathOfNamespace($this->getTempPath()),''));
120
+		  foreach($this->getFiles() as $file) {
121
+			  $localName=str_replace('\\', '/', tempnam(Prado::getPathOfNamespace($this->getTempPath()), ''));
122 122
 			  $file->saveAs($localName);
123 123
 			  $file->setLocalName($localName);
124
-			  $params->files[] = $file->toArray();
124
+			  $params->files[]=$file->toArray();
125 125
 		  }
126 126
 
127 127
 			// return some javascript to display a completion status.
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
           	 Options = new Object();
130 130
           	 Options.clientID = '{$this->getClientID()}';
131 131
           	 Options.targetID = '{$this->_target->getUniqueID()}';
132
-          	 Options.errorCode = '" . (int)!$this->getHasAllFiles() . "';
132
+          	 Options.errorCode = '".(int) !$this->getHasAllFiles()."';
133 133
           	 Options.callbackToken = '{$this->pushParamsAndGetToken($params)}';
134
-          	 Options.fileName = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileName') : $this->getFileName(), JSON_HEX_APOS) . "';
135
-             Options.fileSize = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileSize') : $this->getFileSize(), JSON_HEX_APOS) . "';
136
-             Options.fileType = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileType') : $this->getFileType(), JSON_HEX_APOS) . "';
137
-             Options.errorCode = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'errorCode') : $this->getErrorCode(), JSON_HEX_APOS) . "';
134
+          	 Options.fileName = '".TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileName') : $this->getFileName(), JSON_HEX_APOS)."';
135
+             Options.fileSize = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileSize') : $this->getFileSize(), JSON_HEX_APOS)."';
136
+             Options.fileType = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileType') : $this->getFileType(), JSON_HEX_APOS)."';
137
+             Options.errorCode = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'errorCode') : $this->getErrorCode(), JSON_HEX_APOS)."';
138 138
           	 parent.Prado.WebUI.TActiveFileUpload.onFileUpload(Options);
139 139
            </script>";
140 140
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 * @return string the path where the uploaded file will be stored temporarily, in namespace format
147 147
 	 * default "Application.runtime.*"
148 148
 	 */
149
-	public function getTempPath(){
149
+	public function getTempPath() {
150 150
 		return $this->getViewState('TempPath', 'Application.runtime.*');
151 151
 	}
152 152
 
@@ -154,15 +154,15 @@  discard block
 block discarded – undo
154 154
 	 * @param string the path where the uploaded file will be stored temporarily in namespace format
155 155
 	 * default "Application.runtime.*"
156 156
 	 */
157
-	public function setTempPath($value){
158
-		$this->setViewState('TempPath',$value,'Application.runtime.*');
157
+	public function setTempPath($value) {
158
+		$this->setViewState('TempPath', $value, 'Application.runtime.*');
159 159
 	}
160 160
 
161 161
 	/**
162 162
 	 * @return boolean a value indicating whether an automatic callback to the server will occur whenever the user modifies the text in the TTextBox control and then tabs out of the component. Defaults to true.
163 163
 	 * Note: When set to false, you will need to trigger the callback yourself.
164 164
 	 */
165
-	public function getAutoPostBack(){
165
+	public function getAutoPostBack() {
166 166
 		return $this->getViewState('AutoPostBack', true);
167 167
 	}
168 168
 
@@ -170,28 +170,28 @@  discard block
 block discarded – undo
170 170
 	 * @param boolean a value indicating whether an automatic callback to the server will occur whenever the user modifies the text in the TTextBox control and then tabs out of the component. Defaults to true.
171 171
 	 * Note: When set to false, you will need to trigger the callback yourself.
172 172
 	 */
173
-	public function setAutoPostBack($value){
174
-		$this->setViewState('AutoPostBack',TPropertyValue::ensureBoolean($value),true);
173
+	public function setAutoPostBack($value) {
174
+		$this->setViewState('AutoPostBack', TPropertyValue::ensureBoolean($value), true);
175 175
 	}
176 176
 
177 177
 	/**
178 178
 	 * @return string A chuck of javascript that will need to be called if {{@link getAutoPostBack AutoPostBack} is set to false}
179 179
 	 */
180
-	public function getCallbackJavascript(){
180
+	public function getCallbackJavascript() {
181 181
 		return "Prado.WebUI.TActiveFileUpload.fileChanged(\"{$this->getClientID()}\")";
182 182
 	}
183 183
 
184 184
 	/**
185 185
 	 * @throws TInvalidDataValueException if the {@link getTempPath TempPath} is not writable.
186 186
 	 */
187
-	public function onInit($sender){
187
+	public function onInit($sender) {
188 188
 		parent::onInit($sender);
189 189
 
190
-		if (!Prado::getApplication()->getCache())
191
-		  if (!Prado::getApplication()->getSecurityManager())
190
+		if(!Prado::getApplication()->getCache())
191
+		  if(!Prado::getApplication()->getSecurityManager())
192 192
 			throw new Exception('TActiveFileUpload needs either an application level cache or a security manager to work securely');
193 193
 
194
-		if (!is_writable(Prado::getPathOfNamespace($this->getTempPath()))){
194
+		if(!is_writable(Prado::getPathOfNamespace($this->getTempPath()))) {
195 195
 			throw new TInvalidDataValueException("activefileupload_temppath_invalid", $this->getTempPath());
196 196
 		}
197 197
 	}
@@ -203,18 +203,18 @@  discard block
 block discarded – undo
203 203
 	 * This method is mainly used by framework and control developers.
204 204
 	 * @param TCallbackEventParameter the event parameter
205 205
 	 */
206
- 	public function raiseCallbackEvent($param){
207
- 		$cp = $param->getCallbackParameter();
208
-		if ($key = $cp->targetID == $this->_target->getUniqueID()){
206
+ 	public function raiseCallbackEvent($param) {
207
+ 		$cp=$param->getCallbackParameter();
208
+		if($key=$cp->targetID==$this->_target->getUniqueID()) {
209 209
 
210
-			$params = $this->popParamsByToken($cp->callbackToken);
210
+			$params=$this->popParamsByToken($cp->callbackToken);
211 211
       foreach($params->files as $index => $file)
212 212
       {
213
-  			$_FILES[$key]['name'][$index] = stripslashes($file['fileName']);
214
-  			$_FILES[$key]['size'][$index] = intval($file['fileSize']);
215
-  			$_FILES[$key]['type'][$index] = $file['fileType'];
216
-  			$_FILES[$key]['error'][$index] = intval($file['errorCode']);
217
-  			$_FILES[$key]['tmp_name'][$index] = $file['localName'];
213
+  			$_FILES[$key]['name'][$index]=stripslashes($file['fileName']);
214
+  			$_FILES[$key]['size'][$index]=intval($file['fileSize']);
215
+  			$_FILES[$key]['type'][$index]=$file['fileType'];
216
+  			$_FILES[$key]['error'][$index]=intval($file['errorCode']);
217
+  			$_FILES[$key]['tmp_name'][$index]=$file['localName'];
218 218
       }
219 219
 			$this->loadPostData($key, null);
220 220
 
@@ -234,17 +234,17 @@  discard block
 block discarded – undo
234 234
 
235 235
 	protected function pushParamsAndGetToken(TActiveFileUploadCallbackParams $params)
236 236
 	{
237
-		if ($cache = Prado::getApplication()->getCache())
237
+		if($cache=Prado::getApplication()->getCache())
238 238
 			{
239 239
 				// this is the most secure method, file info can't be forged from client side, no matter what
240
-				$token = md5('TActiveFileUpload::Params::'.$this->ClientID.'::'+rand(1000*1000,9999*1000));
241
-				$cache->set($token, serialize($params), 5*60); // expire in 5 minutes - the callback should arrive back in seconds, actually
240
+				$token=md5('TActiveFileUpload::Params::'.$this->ClientID.'::'+rand(1000 * 1000, 9999 * 1000));
241
+				$cache->set($token, serialize($params), 5 * 60); // expire in 5 minutes - the callback should arrive back in seconds, actually
242 242
 			}
243 243
 		else
244
-		if ($mgr = Prado::getApplication()->getSecurityManager())
244
+		if($mgr=Prado::getApplication()->getSecurityManager())
245 245
 			{
246 246
 				// this is a less secure method, file info can be still forged from client side, but only if attacker knows the secret application key
247
-				$token = urlencode(base64_encode($mgr->encrypt(serialize($params))));
247
+				$token=urlencode(base64_encode($mgr->encrypt(serialize($params))));
248 248
 			}
249 249
 		else
250 250
 			throw new Exception('TActiveFileUpload needs either an application level cache or a security manager to work securely');
@@ -254,18 +254,18 @@  discard block
 block discarded – undo
254 254
 
255 255
 	protected function popParamsByToken($token)
256 256
 	{
257
-		if ($cache = Prado::getApplication()->getCache())
257
+		if($cache=Prado::getApplication()->getCache())
258 258
 			{
259
-				$v = $cache->get($token);
259
+				$v=$cache->get($token);
260 260
 				assert($v!='');
261 261
 				$cache->delete($token); // remove it from cache so it can't be used again and won't take up space either
262
-				$params = unserialize($v);
262
+				$params=unserialize($v);
263 263
 			}
264 264
 		else
265
-		if ($mgr = Prado::getApplication()->getSecurityManager())
265
+		if($mgr=Prado::getApplication()->getSecurityManager())
266 266
 			{
267
-				$v = $mgr->decrypt(base64_decode(urldecode($token)));
268
-				$params = unserialize($v);
267
+				$v=$mgr->decrypt(base64_decode(urldecode($token)));
268
+				$params=unserialize($v);
269 269
 			}
270 270
 		else
271 271
 			throw new Exception('TActiveFileUpload needs either an application level cache or a security manager to work securely');
@@ -282,27 +282,27 @@  discard block
 block discarded – undo
282 282
 	{
283 283
 		parent::onPreRender($param);
284 284
 
285
-		if(!$this->getPage()->getIsPostBack() && isset($_GET['TActiveFileUpload_InputId']) && isset($_GET['TActiveFileUpload_TargetId']) && $_GET['TActiveFileUpload_InputId'] == $this->getClientID())
285
+		if(!$this->getPage()->getIsPostBack() && isset($_GET['TActiveFileUpload_InputId']) && isset($_GET['TActiveFileUpload_TargetId']) && $_GET['TActiveFileUpload_InputId']==$this->getClientID())
286 286
 		{
287
-		  $params = new TActiveFileUploadCallbackParams;
288
-		  foreach ($this->getFiles() as $file) {
289
-		    $localName = str_replace('\\', '/', tempnam(Prado::getPathOfNamespace($this->getTempPath()),''));
287
+		  $params=new TActiveFileUploadCallbackParams;
288
+		  foreach($this->getFiles() as $file) {
289
+		    $localName=str_replace('\\', '/', tempnam(Prado::getPathOfNamespace($this->getTempPath()), ''));
290 290
 		    $file->setLocalName($localName);
291 291
 		    // tricky workaround to intercept "uploaded file too big" error: real uploads happens in onFileUpload instead
292 292
 		    $file->setErrorCode(UPLOAD_ERR_FORM_SIZE);
293
-		    $params->files[] = $file->toArray();
293
+		    $params->files[]=$file->toArray();
294 294
 		  }
295 295
 
296 296
 			echo "<script language='Javascript'>
297 297
           	 Options = new Object();
298 298
           	 Options.clientID = '{$_GET['TActiveFileUpload_InputId']}';
299 299
           	 Options.targetID = '{$_GET['TActiveFileUpload_TargetId']}';
300
-			       Options.errorCode = '" . (int)!$this->getHasAllFiles() . "';
300
+			       Options.errorCode = '".(int) !$this->getHasAllFiles()."';
301 301
           	 Options.callbackToken = '{$this->pushParamsAndGetToken($params)}';
302
-          	 Options.fileName = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileName') : $this->getFileName(), JSON_HEX_APOS) . "';
303
-             Options.fileSize = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileSize') : $this->getFileSize(), JSON_HEX_APOS) . "';
304
-             Options.fileType = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileType') : $this->getFileType(), JSON_HEX_APOS) . "';
305
-             Options.errorCode = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'errorCode') : $this->getErrorCode(), JSON_HEX_APOS) . "';
302
+          	 Options.fileName = '".TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileName') : $this->getFileName(), JSON_HEX_APOS)."';
303
+             Options.fileSize = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileSize') : $this->getFileSize(), JSON_HEX_APOS)."';
304
+             Options.fileType = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'fileType') : $this->getFileType(), JSON_HEX_APOS)."';
305
+             Options.errorCode = '" . TJavaScript::jsonEncode($this->getMultiple() ? array_column($params->files, 'errorCode') : $this->getErrorCode(), JSON_HEX_APOS)."';
306 306
            	 parent.Prado.WebUI.TActiveFileUpload.onFileUpload(Options);
307 307
            </script>";
308 308
 		}
@@ -312,29 +312,29 @@  discard block
 block discarded – undo
312 312
 	{
313 313
 		$this->getPage()->getClientScript()->registerPradoScript('activefileupload');
314 314
 
315
-		$this->_flag = new THiddenField;
315
+		$this->_flag=new THiddenField;
316 316
 		$this->_flag->setID('Flag');
317 317
 		$this->getControls()->add($this->_flag);
318 318
 
319
-		$this->_busy = new TImage;
319
+		$this->_busy=new TImage;
320 320
 		$this->_busy->setID('Busy');
321 321
 		$this->_busy->setImageUrl($this->getAssetUrl('ActiveFileUploadIndicator.gif'));
322 322
 		$this->_busy->setStyle("display:none");
323 323
 		$this->getControls()->add($this->_busy);
324 324
 
325
-		$this->_success = new TImage;
325
+		$this->_success=new TImage;
326 326
 		$this->_success->setID('Success');
327 327
 		$this->_success->setImageUrl($this->getAssetUrl('ActiveFileUploadComplete.png'));
328 328
 		$this->_success->setStyle("display:none");
329 329
 		$this->getControls()->add($this->_success);
330 330
 
331
-		$this->_error = new TImage;
331
+		$this->_error=new TImage;
332 332
 		$this->_error->setID('Error');
333 333
 		$this->_error->setImageUrl($this->getAssetUrl('ActiveFileUploadError.png'));
334 334
 		$this->_error->setStyle("display:none");
335 335
 		$this->getControls()->add($this->_error);
336 336
 
337
-		$this->_target = new TInlineFrame;
337
+		$this->_target=new TInlineFrame;
338 338
 		$this->_target->setID('Target');
339 339
 		$this->_target->setFrameUrl($this->getAssetUrl('ActiveFileUploadBlank.html'));
340 340
 		$this->_target->setStyle("width:0px; height:0px;");
@@ -345,11 +345,11 @@  discard block
 block discarded – undo
345 345
 	/**
346 346
 	 * Removes localfile on ending of the callback.
347 347
 	 */
348
-	public function onUnload($param){
349
-		if ($this->getPage()->getIsCallback())
348
+	public function onUnload($param) {
349
+		if($this->getPage()->getIsCallback())
350 350
 		{
351 351
 		  foreach($this->getFiles() as $file)
352
-		    if($file->getHasFile() && file_exists($file->getLocalName())){
352
+		    if($file->getHasFile() && file_exists($file->getLocalName())) {
353 353
 		      unlink($file->getLocalName());
354 354
 		  }
355 355
 		}
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 	/**
360 360
 	 * @return TBaseActiveCallbackControl standard callback control options.
361 361
 	 */
362
-	public function getActiveControl(){
362
+	public function getActiveControl() {
363 363
 		return $this->getAdapter()->getBaseActiveControl();
364 364
 	}
365 365
 
@@ -375,17 +375,17 @@  discard block
 block discarded – undo
375 375
 	 * Adds ID attribute, and renders the javascript for active component.
376 376
 	 * @param THtmlWriter the writer used for the rendering purpose
377 377
 	 */
378
-	public function addAttributesToRender($writer){
378
+	public function addAttributesToRender($writer) {
379 379
 		parent::addAttributesToRender($writer);
380
-		$writer->addAttribute('id',$this->getClientID());
380
+		$writer->addAttribute('id', $this->getClientID());
381 381
 
382
-		$this->getActiveControl()->registerCallbackClientScript($this->getClientClassName(),$this->getClientOptions());
382
+		$this->getActiveControl()->registerCallbackClientScript($this->getClientClassName(), $this->getClientOptions());
383 383
 	}
384 384
 
385 385
 	/**
386 386
 	 * @return string corresponding javascript class name for this control.
387 387
 	 */
388
-	protected function getClientClassName(){
388
+	protected function getClientClassName() {
389 389
 		return 'Prado.WebUI.TActiveFileUpload';
390 390
 	}
391 391
 
@@ -399,18 +399,18 @@  discard block
 block discarded – undo
399 399
 	 * 					completeID => complete client ID,
400 400
 	 * 					errorID => error client ID)
401 401
 	 */
402
-	protected function getClientOptions(){
403
-		$options['ID'] = $this->getClientID();
404
-		$options['EventTarget'] = $this->getUniqueID();
405
-
406
-		$options['inputID'] = $this->getClientID();
407
-		$options['flagID'] = $this->_flag->getClientID();
408
-		$options['targetID'] = $this->_target->getUniqueID();
409
-		$options['formID'] = $this->getPage()->getForm()->getClientID();
410
-		$options['indicatorID'] = $this->_busy->getClientID();
411
-		$options['completeID'] = $this->_success->getClientID();
412
-		$options['errorID'] = $this->_error->getClientID();
413
-		$options['autoPostBack'] = $this->getAutoPostBack();
402
+	protected function getClientOptions() {
403
+		$options['ID']=$this->getClientID();
404
+		$options['EventTarget']=$this->getUniqueID();
405
+
406
+		$options['inputID']=$this->getClientID();
407
+		$options['flagID']=$this->_flag->getClientID();
408
+		$options['targetID']=$this->_target->getUniqueID();
409
+		$options['formID']=$this->getPage()->getForm()->getClientID();
410
+		$options['indicatorID']=$this->_busy->getClientID();
411
+		$options['completeID']=$this->_success->getClientID();
412
+		$options['errorID']=$this->_error->getClientID();
413
+		$options['autoPostBack']=$this->getAutoPostBack();
414 414
 		return $options;
415 415
 	}
416 416
 
@@ -421,12 +421,12 @@  discard block
 block discarded – undo
421 421
 	 * If true, you will not be able to save the uploaded file again.
422 422
 	 * @return boolean true if the file saving is successful
423 423
 	 */
424
-	public function saveAs($fileName,$deleteTempFile=true,$index=0){
425
-		if (($this->getErrorCode($index)===UPLOAD_ERR_OK) && (file_exists($this->getLocalName($index)))){
426
-			if ($deleteTempFile)
427
-				return rename($this->getLocalName($index),$fileName);
424
+	public function saveAs($fileName, $deleteTempFile=true, $index=0) {
425
+		if(($this->getErrorCode($index)===UPLOAD_ERR_OK) && (file_exists($this->getLocalName($index)))) {
426
+			if($deleteTempFile)
427
+				return rename($this->getLocalName($index), $fileName);
428 428
 			else
429
-				return copy($this->getLocalName($index),$fileName);
429
+				return copy($this->getLocalName($index), $fileName);
430 430
 		} else
431 431
 			return false;
432 432
 	}
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 	 * @return TImage the image displayed when an upload
436 436
 	 * 		completes successfully.
437 437
 	 */
438
-	public function getSuccessImage(){
438
+	public function getSuccessImage() {
439 439
 		$this->ensureChildControls();
440 440
 		return $this->_success;
441 441
 	}
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 	 * @return TImage the image displayed when an upload
445 445
 	 * 		does not complete successfully.
446 446
 	 */
447
-	public function getErrorImage(){
447
+	public function getErrorImage() {
448 448
 		$this->ensureChildControls();
449 449
 		return $this->_error;
450 450
 	}
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 	 * @return TImage the image displayed when an upload
454 454
 	 * 		is in progress.
455 455
 	 */
456
-	public function getBusyImage(){
456
+	public function getBusyImage() {
457 457
 		$this->ensureChildControls();
458 458
 		return $this->_busy;
459 459
 	}
Please login to merge, or discard this patch.