@@ -28,9 +28,10 @@ |
||
| 28 | 28 | public function getDifference() |
| 29 | 29 | { |
| 30 | 30 | if(gettype($this->_new) === gettype($this->_old) |
| 31 | - && $this->_new === $this->_old) |
|
| 32 | - return $this->_null; |
|
| 33 | - else |
|
| 34 | - return $this->_new; |
|
| 31 | + && $this->_new === $this->_old) { |
|
| 32 | + return $this->_null; |
|
| 33 | + } else { |
|
| 34 | + return $this->_new; |
|
| 35 | + } |
|
| 35 | 36 | } |
| 36 | 37 | } |
@@ -187,9 +187,10 @@ discard block |
||
| 187 | 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 | |
| 194 | 195 | if (!is_writable(Prado::getPathOfNamespace($this->getTempPath()))){ |
| 195 | 196 | throw new TInvalidDataValueException("activefileupload_temppath_invalid", $this->getTempPath()); |
@@ -239,14 +240,13 @@ discard block |
||
| 239 | 240 | // this is the most secure method, file info can't be forged from client side, no matter what |
| 240 | 241 | $token = md5('TActiveFileUpload::Params::' . $this->ClientID . '::' . rand(1000 * 1000, 9999 * 1000)); |
| 241 | 242 | $cache->set($token, serialize($params), 5 * 60); // expire in 5 minutes - the callback should arrive back in seconds, actually |
| 242 | - } |
|
| 243 | - elseif ($mgr = Prado::getApplication()->getSecurityManager()) |
|
| 243 | + } elseif ($mgr = Prado::getApplication()->getSecurityManager()) |
|
| 244 | 244 | { |
| 245 | 245 | // this is a less secure method, file info can be still forged from client side, but only if attacker knows the secret application key |
| 246 | 246 | $token = urlencode(base64_encode($mgr->encrypt(serialize($params)))); |
| 247 | - } |
|
| 248 | - else |
|
| 249 | - throw new Exception('TActiveFileUpload needs either an application level cache or a security manager to work securely'); |
|
| 247 | + } else { |
|
| 248 | + throw new Exception('TActiveFileUpload needs either an application level cache or a security manager to work securely'); |
|
| 249 | + } |
|
| 250 | 250 | |
| 251 | 251 | return $token; |
| 252 | 252 | } |
@@ -259,14 +259,13 @@ discard block |
||
| 259 | 259 | assert($v != ''); |
| 260 | 260 | $cache->delete($token); // remove it from cache so it can't be used again and won't take up space either |
| 261 | 261 | $params = unserialize($v); |
| 262 | - } |
|
| 263 | - elseif ($mgr = Prado::getApplication()->getSecurityManager()) |
|
| 262 | + } elseif ($mgr = Prado::getApplication()->getSecurityManager()) |
|
| 264 | 263 | { |
| 265 | 264 | $v = $mgr->decrypt(base64_decode(urldecode($token))); |
| 266 | 265 | $params = unserialize($v); |
| 267 | - } |
|
| 268 | - else |
|
| 269 | - throw new Exception('TActiveFileUpload needs either an application level cache or a security manager to work securely'); |
|
| 266 | + } else { |
|
| 267 | + throw new Exception('TActiveFileUpload needs either an application level cache or a security manager to work securely'); |
|
| 268 | + } |
|
| 270 | 269 | |
| 271 | 270 | assert($params instanceof TActiveFileUploadCallbackParams); |
| 272 | 271 | |
@@ -346,10 +345,11 @@ discard block |
||
| 346 | 345 | public function onUnload($param){ |
| 347 | 346 | if ($this->getPage()->getIsCallback()) |
| 348 | 347 | { |
| 349 | - foreach($this->getFiles() as $file) |
|
| 350 | - if($file->getHasFile() && file_exists($file->getLocalName())){ |
|
| 348 | + foreach($this->getFiles() as $file) { |
|
| 349 | + if($file->getHasFile() && file_exists($file->getLocalName())){ |
|
| 351 | 350 | unlink($file->getLocalName()); |
| 352 | 351 | } |
| 352 | + } |
|
| 353 | 353 | } |
| 354 | 354 | parent::onUnload($param); |
| 355 | 355 | } |
@@ -421,12 +421,14 @@ discard block |
||
| 421 | 421 | */ |
| 422 | 422 | public function saveAs($fileName, $deleteTempFile = true, $index = 0){ |
| 423 | 423 | if (($this->getErrorCode($index) === UPLOAD_ERR_OK) && (file_exists($this->getLocalName($index)))){ |
| 424 | - if ($deleteTempFile) |
|
| 425 | - return rename($this->getLocalName($index), $fileName); |
|
| 426 | - else |
|
| 427 | - return copy($this->getLocalName($index), $fileName); |
|
| 428 | - } else |
|
| 429 | - return false; |
|
| 424 | + if ($deleteTempFile) { |
|
| 425 | + return rename($this->getLocalName($index), $fileName); |
|
| 426 | + } else { |
|
| 427 | + return copy($this->getLocalName($index), $fileName); |
|
| 428 | + } |
|
| 429 | + } else { |
|
| 430 | + return false; |
|
| 431 | + } |
|
| 430 | 432 | } |
| 431 | 433 | |
| 432 | 434 | /** |
@@ -53,8 +53,7 @@ discard block |
||
| 53 | 53 | $control->setData($text); |
| 54 | 54 | } |
| 55 | 55 | $cell->getControls()->add($control); |
| 56 | - } |
|
| 57 | - elseif($this->getAllowSorting()) { |
|
| 56 | + } elseif($this->getAllowSorting()) { |
|
| 58 | 57 | $sortExpression = $this->getSortExpression(); |
| 59 | 58 | if(($url = $this->getHeaderImageUrl()) !== '') { |
| 60 | 59 | $button = new TActiveImageButton; |
@@ -67,19 +66,17 @@ discard block |
||
| 67 | 66 | } |
| 68 | 67 | $button->setCausesValidation(false); |
| 69 | 68 | $cell->getControls()->add($button); |
| 70 | - } |
|
| 71 | - elseif($text !== '') { |
|
| 69 | + } elseif($text !== '') { |
|
| 72 | 70 | $button = new TActiveLinkButton; |
| 73 | 71 | $button->setText($text); |
| 74 | 72 | $button->setCommandName(TDataGrid::CMD_SORT); |
| 75 | 73 | $button->setCommandParameter($sortExpression); |
| 76 | 74 | $button->setCausesValidation(false); |
| 77 | 75 | $cell->getControls()->add($button); |
| 76 | + } else { |
|
| 77 | + $cell->setText(' '); |
|
| 78 | 78 | } |
| 79 | - else |
|
| 80 | - $cell->setText(' '); |
|
| 81 | - } |
|
| 82 | - else { |
|
| 79 | + } else { |
|
| 83 | 80 | if(($url = $this->getHeaderImageUrl()) !== '') { |
| 84 | 81 | $image = new TActiveImage; |
| 85 | 82 | $image->setImageUrl($url); |
@@ -88,11 +85,11 @@ discard block |
||
| 88 | 85 | $image->setToolTip($text); |
| 89 | 86 | } |
| 90 | 87 | $cell->getControls()->add($image); |
| 91 | - } |
|
| 92 | - elseif($text !== '') |
|
| 93 | - $cell->setText($text); |
|
| 94 | - else |
|
| 95 | - $cell->setText(' '); |
|
| 88 | + } elseif($text !== '') { |
|
| 89 | + $cell->setText($text); |
|
| 90 | + } else { |
|
| 91 | + $cell->setText(' '); |
|
| 92 | + } |
|
| 96 | 93 | } |
| 97 | 94 | } |
| 98 | 95 | } |
| 99 | 96 | \ No newline at end of file |
@@ -94,8 +94,9 @@ discard block |
||
| 94 | 94 | public function insertAt($index, $value) |
| 95 | 95 | { |
| 96 | 96 | parent::insertAt($index, $value); |
| 97 | - if($this->canUpdateClientSide()) |
|
| 98 | - $this->_hasChanged = true; |
|
| 97 | + if($this->canUpdateClientSide()) { |
|
| 98 | + $this->_hasChanged = true; |
|
| 99 | + } |
|
| 99 | 100 | } |
| 100 | 101 | |
| 101 | 102 | /** |
@@ -105,7 +106,8 @@ discard block |
||
| 105 | 106 | public function removeAt($index) |
| 106 | 107 | { |
| 107 | 108 | parent::removeAt($index); |
| 108 | - if($this->canUpdateClientSide()) |
|
| 109 | - $this->_hasChanged = true; |
|
| 109 | + if($this->canUpdateClientSide()) { |
|
| 110 | + $this->_hasChanged = true; |
|
| 111 | + } |
|
| 110 | 112 | } |
| 111 | 113 | } |
| 112 | 114 | \ No newline at end of file |
@@ -50,14 +50,17 @@ discard block |
||
| 50 | 50 | // if a prompt is set, we mimic the postback behaviour of not counting it |
| 51 | 51 | // in the index. We assume the prompt is _always_ the first item (Issue #368) |
| 52 | 52 | $promptValue = $this->getControl()->getPromptValue(); |
| 53 | - if($promptValue === '') |
|
| 54 | - $promptValue = $this->getControl()->getPromptText(); |
|
| 55 | - if($promptValue !== '') |
|
| 56 | - $index++; |
|
| 53 | + if($promptValue === '') { |
|
| 54 | + $promptValue = $this->getControl()->getPromptText(); |
|
| 55 | + } |
|
| 56 | + if($promptValue !== '') { |
|
| 57 | + $index++; |
|
| 58 | + } |
|
| 57 | 59 | |
| 58 | - if($index >= 0 && $index <= $this->getControl()->getItemCount()) |
|
| 59 | - $this->getPage()->getCallbackClient()->select( |
|
| 60 | + if($index >= 0 && $index <= $this->getControl()->getItemCount()) { |
|
| 61 | + $this->getPage()->getCallbackClient()->select( |
|
| 60 | 62 | $this->getControl(), 'Index', $index); |
| 63 | + } |
|
| 61 | 64 | } |
| 62 | 65 | } |
| 63 | 66 | |
@@ -73,21 +76,25 @@ discard block |
||
| 73 | 76 | $n = $this->getControl()->getItemCount(); |
| 74 | 77 | |
| 75 | 78 | $promptValue = $this->getControl()->getPromptValue(); |
| 76 | - if($promptValue === '') |
|
| 77 | - $promptValue = $this->getControl()->getPromptText(); |
|
| 79 | + if($promptValue === '') { |
|
| 80 | + $promptValue = $this->getControl()->getPromptText(); |
|
| 81 | + } |
|
| 78 | 82 | |
| 79 | 83 | $list = []; |
| 80 | 84 | foreach($indices as $index) |
| 81 | 85 | { |
| 82 | 86 | $index = intval($index); |
| 83 | - if($promptValue !== '') |
|
| 84 | - $index++; |
|
| 85 | - if($index >= 0 && $index <= $n) |
|
| 86 | - $list[] = $index; |
|
| 87 | + if($promptValue !== '') { |
|
| 88 | + $index++; |
|
| 89 | + } |
|
| 90 | + if($index >= 0 && $index <= $n) { |
|
| 91 | + $list[] = $index; |
|
| 92 | + } |
|
| 87 | 93 | } |
| 88 | - if(count($list) > 0) |
|
| 89 | - $this->getPage()->getCallbackClient()->select( |
|
| 94 | + if(count($list) > 0) { |
|
| 95 | + $this->getPage()->getCallbackClient()->select( |
|
| 90 | 96 | $this->getControl(), 'Indices', $list); |
| 97 | + } |
|
| 91 | 98 | } |
| 92 | 99 | } |
| 93 | 100 | |
@@ -115,11 +122,13 @@ discard block |
||
| 115 | 122 | { |
| 116 | 123 | $this->updateListItems(); |
| 117 | 124 | $list = []; |
| 118 | - foreach($values as $value) |
|
| 119 | - $list[] = $value; |
|
| 120 | - if(count($list) > 0) |
|
| 121 | - $this->getPage()->getCallbackClient()->select( |
|
| 125 | + foreach($values as $value) { |
|
| 126 | + $list[] = $value; |
|
| 127 | + } |
|
| 128 | + if(count($list) > 0) { |
|
| 129 | + $this->getPage()->getCallbackClient()->select( |
|
| 122 | 130 | $this->getControl(), 'Values', $list); |
| 131 | + } |
|
| 123 | 132 | } |
| 124 | 133 | } |
| 125 | 134 | |
@@ -82,9 +82,10 @@ |
||
| 82 | 82 | { |
| 83 | 83 | if($this->getHasPreRendered()) { |
| 84 | 84 | $this->renderDataList($writer); |
| 85 | - if($this->getActiveControl()->canUpdateClientSide()) $this->getPage()->getCallbackClient()->replaceContent($this->getContainerID(), $writer); |
|
| 86 | - } |
|
| 87 | - else { |
|
| 85 | + if($this->getActiveControl()->canUpdateClientSide()) { |
|
| 86 | + $this->getPage()->getCallbackClient()->replaceContent($this->getContainerID(), $writer); |
|
| 87 | + } |
|
| 88 | + } else { |
|
| 88 | 89 | $this->getPage()->getAdapter()->registerControlToRender($this, $writer); |
| 89 | 90 | } |
| 90 | 91 | } |
@@ -71,9 +71,9 @@ |
||
| 71 | 71 | $value = str_ireplace(["\r\n", "\n"], "", $value); |
| 72 | 72 | $command = "tinyMCE.getInstanceById('{$this->getClientID()}').execCommand('mceSetContent',false,'{$value}')"; |
| 73 | 73 | $this->getPage()->getCallbackClient()->evaluateScript($command); |
| 74 | + } else { |
|
| 75 | + $this->getPage()->getCallbackClient()->setValue($this, $value); |
|
| 74 | 76 | } |
| 75 | - else |
|
| 76 | - $this->getPage()->getCallbackClient()->setValue($this, $value); |
|
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
@@ -82,8 +82,9 @@ discard block |
||
| 82 | 82 | { |
| 83 | 83 | $value = TPropertyValue::ensureBoolean($value); |
| 84 | 84 | $this->setViewState('DisplayTextBox', $value, false); |
| 85 | - if($this->getActiveControl()->canUpdateClientSide()) |
|
| 86 | - $this->callClientFunction('setDisplayTextBox', $value); |
|
| 85 | + if($this->getActiveControl()->canUpdateClientSide()) { |
|
| 86 | + $this->callClientFunction('setDisplayTextBox', $value); |
|
| 87 | + } |
|
| 87 | 88 | } |
| 88 | 89 | |
| 89 | 90 | /** |
@@ -128,9 +129,12 @@ discard block |
||
| 128 | 129 | protected function getExternalControlID() |
| 129 | 130 | { |
| 130 | 131 | $extID = $this->getEditTriggerControlID(); |
| 131 | - if($extID === null) return ''; |
|
| 132 | - if(($control = $this->findControl($extID)) !== null) |
|
| 133 | - return $control->getClientID(); |
|
| 132 | + if($extID === null) { |
|
| 133 | + return ''; |
|
| 134 | + } |
|
| 135 | + if(($control = $this->findControl($extID)) !== null) { |
|
| 136 | + return $control->getClientID(); |
|
| 137 | + } |
|
| 134 | 138 | return $extID; |
| 135 | 139 | } |
| 136 | 140 | |
@@ -141,8 +145,9 @@ discard block |
||
| 141 | 145 | */ |
| 142 | 146 | public function setText($value) |
| 143 | 147 | { |
| 144 | - if(TTextBox::getText() === $value) |
|
| 145 | - return; |
|
| 148 | + if(TTextBox::getText() === $value) { |
|
| 149 | + return; |
|
| 150 | + } |
|
| 146 | 151 | |
| 147 | 152 | TTextBox::setText($value); |
| 148 | 153 | if($this->getActiveControl()->canUpdateClientSide()) |
@@ -161,8 +166,9 @@ discard block |
||
| 161 | 166 | public function setReadOnly ($value) |
| 162 | 167 | { |
| 163 | 168 | $value = TPropertyValue::ensureBoolean($value); |
| 164 | - if(TTextBox::getReadOnly() === $value) |
|
| 165 | - return; |
|
| 169 | + if(TTextBox::getReadOnly() === $value) { |
|
| 170 | + return; |
|
| 171 | + } |
|
| 166 | 172 | |
| 167 | 173 | TTextBox::setReadOnly($value); |
| 168 | 174 | if ($this->getActiveControl()->canUpdateClientSide()) |
@@ -185,10 +191,11 @@ discard block |
||
| 185 | 191 | */ |
| 186 | 192 | public function renderContents($writer) |
| 187 | 193 | { |
| 188 | - if(($text = $this->getText()) === '') |
|
| 189 | - parent::renderContents($writer); |
|
| 190 | - else |
|
| 191 | - $writer->write($text); |
|
| 194 | + if(($text = $this->getText()) === '') { |
|
| 195 | + parent::renderContents($writer); |
|
| 196 | + } else { |
|
| 197 | + $writer->write($text); |
|
| 198 | + } |
|
| 192 | 199 | } |
| 193 | 200 | |
| 194 | 201 | /** |
@@ -233,15 +240,15 @@ discard block |
||
| 233 | 240 | { |
| 234 | 241 | $options['Rows'] = $this->getRows(); |
| 235 | 242 | $options['Wrap'] = $this->getWrap() == false ? '' : true; |
| 236 | - } |
|
| 237 | - else |
|
| 243 | + } else |
|
| 238 | 244 | { |
| 239 | 245 | $length = $this->getMaxLength(); |
| 240 | 246 | $options['MaxLength'] = $length > 0 ? $length : ''; |
| 241 | 247 | } |
| 242 | 248 | |
| 243 | - if($this->hasEventHandler('OnLoadingText')) |
|
| 244 | - $options['LoadTextOnEdit'] = true; |
|
| 249 | + if($this->hasEventHandler('OnLoadingText')) { |
|
| 250 | + $options['LoadTextOnEdit'] = true; |
|
| 251 | + } |
|
| 245 | 252 | |
| 246 | 253 | $options['ReadOnly'] = $this->getReadOnly(); |
| 247 | 254 | return $options; |
@@ -100,9 +100,10 @@ |
||
| 100 | 100 | public function render($writer) { |
| 101 | 101 | if($this->getHasPreRendered()) { |
| 102 | 102 | $this->renderRepeater($writer); |
| 103 | - if($this->getActiveControl()->canUpdateClientSide()) $this->getPage()->getCallbackClient()->replaceContent($this->getSurroundingTagId(), $writer); |
|
| 104 | - } |
|
| 105 | - else { |
|
| 103 | + if($this->getActiveControl()->canUpdateClientSide()) { |
|
| 104 | + $this->getPage()->getCallbackClient()->replaceContent($this->getSurroundingTagId(), $writer); |
|
| 105 | + } |
|
| 106 | + } else { |
|
| 106 | 107 | $this->getPage()->getAdapter()->registerControlToRender($this, $writer); |
| 107 | 108 | } |
| 108 | 109 | } |