@@ -123,13 +123,13 @@ |
||
| 123 | 123 | } |
| 124 | 124 | $dir = $this->fs->takeFileDir($url); |
| 125 | 125 | $iterator = new \FilesystemIterator($dir); |
| 126 | - if (!$iterator->valid()) { |
|
| 126 | + if ( ! $iterator->valid()) { |
|
| 127 | 127 | rmdir($dir); |
| 128 | 128 | } |
| 129 | 129 | if ($cache) { |
| 130 | 130 | return; |
| 131 | 131 | } |
| 132 | - $thumbsCache = \APIhelpers::getkey($this->params,'thumbsCache',$this->thumbsCache); |
|
| 132 | + $thumbsCache = \APIhelpers::getkey($this->params, 'thumbsCache', $this->thumbsCache); |
|
| 133 | 133 | $thumb = $thumbsCache . $url; |
| 134 | 134 | if ($this->fs->checkFile($thumb)) { |
| 135 | 135 | $this->deleteThumb($thumb, true); |
@@ -8,8 +8,8 @@ discard block |
||
| 8 | 8 | * Class dataTable |
| 9 | 9 | * @package SimpleTab |
| 10 | 10 | */ |
| 11 | -class dataTable extends \autoTable |
|
| 12 | -{ |
|
| 11 | +class dataTable extends \autoTable |
|
| 12 | +{
|
|
| 13 | 13 | /** |
| 14 | 14 | * @var array |
| 15 | 15 | */ |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | * @param \DocumentParser $modx |
| 41 | 41 | * @param bool $debug |
| 42 | 42 | */ |
| 43 | - public function __construct($modx, $debug = false) |
|
| 44 | - { |
|
| 43 | + public function __construct($modx, $debug = false) |
|
| 44 | + {
|
|
| 45 | 45 | parent::__construct($modx, $debug); |
| 46 | 46 | $this->modx = $modx; |
| 47 | 47 | $this->fs = \Helpers\FS::getInstance(); |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | * @param $ids |
| 52 | 52 | * @param $rid |
| 53 | 53 | */ |
| 54 | - protected function clearIndexes($ids, $rid) |
|
| 55 | - { |
|
| 54 | + protected function clearIndexes($ids, $rid) |
|
| 55 | + {
|
|
| 56 | 56 | $ids = $this->cleanIDs($ids, ',', array(0)); |
| 57 | 57 | $ids = $this->sanitarIn($ids); |
| 58 | 58 | $table = $this->makeTable($this->table); |
@@ -70,8 +70,8 @@ discard block |
||
| 70 | 70 | * @param $field |
| 71 | 71 | * @return $this |
| 72 | 72 | */ |
| 73 | - public function touch($field) |
|
| 74 | - { |
|
| 73 | + public function touch($field) |
|
| 74 | + {
|
|
| 75 | 75 | $this->set($field, date('Y-m-d H:i:s', time() + $this->modx->config['server_offset_time'])); |
| 76 | 76 | |
| 77 | 77 | return $this; |
@@ -82,22 +82,22 @@ discard block |
||
| 82 | 82 | * @param $dir |
| 83 | 83 | * @param $rid |
| 84 | 84 | */ |
| 85 | - public function place($ids, $dir, $rid) |
|
| 86 | - { |
|
| 85 | + public function place($ids, $dir, $rid) |
|
| 86 | + {
|
|
| 87 | 87 | $table = $this->makeTable($this->table); |
| 88 | 88 | $ids = $this->cleanIDs($ids, ',', array(0)); |
| 89 | - if (empty($ids) || is_scalar($ids)) { |
|
| 89 | + if (empty($ids) || is_scalar($ids)) {
|
|
| 90 | 90 | return false; |
| 91 | 91 | } |
| 92 | 92 | $rows = $this->query("SELECT count(`{$this->pkName}`) FROM {$table} WHERE `{$this->rfName}`={$rid}"); |
| 93 | 93 | $index = $this->modx->db->getValue($rows); |
| 94 | 94 | $cnt = count($ids); |
| 95 | 95 | $ids = implode(',', $ids); |
| 96 | - if ($dir == 'top') { |
|
| 96 | + if ($dir == 'top') {
|
|
| 97 | 97 | $this->query("SET @index := " . ($index - $cnt - 1)); |
| 98 | 98 | $this->query("UPDATE {$table} SET `{$this->indexName}` = (@index := @index + 1) WHERE (`{$this->pkName}` IN ({$ids})) ORDER BY `{$this->indexName}` ASC"); |
| 99 | 99 | $this->query("SET @index := -1"); |
| 100 | - } else { |
|
| 100 | + } else {
|
|
| 101 | 101 | $this->query("SET @index := -1"); |
| 102 | 102 | $this->query("UPDATE {$table} SET `{$this->indexName}` = (@index := @index + 1) WHERE (`{$this->pkName}` IN ({$ids})) ORDER BY `{$this->indexName}` ASC"); |
| 103 | 103 | $this->query("SET @index := " . ($cnt - 1)); |
@@ -112,26 +112,26 @@ discard block |
||
| 112 | 112 | * @param $url |
| 113 | 113 | * @param bool $cache |
| 114 | 114 | */ |
| 115 | - public function deleteThumb($url, $cache = false) |
|
| 116 | - { |
|
| 115 | + public function deleteThumb($url, $cache = false) |
|
| 116 | + {
|
|
| 117 | 117 | $url = $this->fs->relativePath($url); |
| 118 | - if (empty($url)) { |
|
| 118 | + if (empty($url)) {
|
|
| 119 | 119 | return; |
| 120 | 120 | } |
| 121 | - if ($this->fs->checkFile($url)) { |
|
| 121 | + if ($this->fs->checkFile($url)) {
|
|
| 122 | 122 | unlink(MODX_BASE_PATH . $url); |
| 123 | 123 | } |
| 124 | 124 | $dir = $this->fs->takeFileDir($url); |
| 125 | 125 | $iterator = new \FilesystemIterator($dir); |
| 126 | - if (!$iterator->valid()) { |
|
| 126 | + if (!$iterator->valid()) {
|
|
| 127 | 127 | rmdir($dir); |
| 128 | 128 | } |
| 129 | - if ($cache) { |
|
| 129 | + if ($cache) {
|
|
| 130 | 130 | return; |
| 131 | 131 | } |
| 132 | 132 | $thumbsCache = \APIhelpers::getkey($this->params,'thumbsCache',$this->thumbsCache); |
| 133 | 133 | $thumb = $thumbsCache . $url; |
| 134 | - if ($this->fs->checkFile($thumb)) { |
|
| 134 | + if ($this->fs->checkFile($thumb)) {
|
|
| 135 | 135 | $this->deleteThumb($thumb, true); |
| 136 | 136 | } |
| 137 | 137 | } |
@@ -141,8 +141,8 @@ discard block |
||
| 141 | 141 | * @param null $fire_events |
| 142 | 142 | * @return $this |
| 143 | 143 | */ |
| 144 | - public function delete($ids, $fire_events = false) |
|
| 145 | - { |
|
| 144 | + public function delete($ids, $fire_events = false) |
|
| 145 | + {
|
|
| 146 | 146 | $out = parent::delete($ids, $fire_events); |
| 147 | 147 | $this->query("ALTER TABLE {$this->makeTable($this->table)} AUTO_INCREMENT = 1"); |
| 148 | 148 | |
@@ -155,8 +155,8 @@ discard block |
||
| 155 | 155 | * @param null $fire_events |
| 156 | 156 | * @return $this |
| 157 | 157 | */ |
| 158 | - public function deleteAll($ids, $rid, $fire_events = false) |
|
| 159 | - { |
|
| 158 | + public function deleteAll($ids, $rid, $fire_events = false) |
|
| 159 | + {
|
|
| 160 | 160 | $this->clearIndexes($ids, $rid); |
| 161 | 161 | |
| 162 | 162 | return $this->delete($ids, $fire_events); |
@@ -165,8 +165,8 @@ discard block |
||
| 165 | 165 | /** |
| 166 | 166 | * @return array |
| 167 | 167 | */ |
| 168 | - public function fieldNames() |
|
| 169 | - { |
|
| 168 | + public function fieldNames() |
|
| 169 | + {
|
|
| 170 | 170 | $fields = array_keys($this->getDefaultFields()); |
| 171 | 171 | $fields[] = $this->fieldPKName(); |
| 172 | 172 | |
@@ -177,8 +177,8 @@ discard block |
||
| 177 | 177 | * @param string $name |
| 178 | 178 | * @return string |
| 179 | 179 | */ |
| 180 | - public function stripName($name) |
|
| 181 | - { |
|
| 180 | + public function stripName($name) |
|
| 181 | + {
|
|
| 182 | 182 | |
| 183 | 183 | $filename = $this->fs->takeFileName($name); |
| 184 | 184 | $ext = $this->fs->takeFileExt($name); |
@@ -194,8 +194,8 @@ discard block |
||
| 194 | 194 | * @param $orderDir |
| 195 | 195 | * @return int|void |
| 196 | 196 | */ |
| 197 | - public function reorder($source, $target, $point, $rid, $orderDir) |
|
| 198 | - { |
|
| 197 | + public function reorder($source, $target, $point, $rid, $orderDir) |
|
| 198 | + {
|
|
| 199 | 199 | $rid = (int)$rid; |
| 200 | 200 | $point = strtolower($point); |
| 201 | 201 | $orderDir = strtolower($orderDir); |
@@ -205,25 +205,25 @@ discard block |
||
| 205 | 205 | $table = $this->makeTable($this->table); |
| 206 | 206 | $rows = 0; |
| 207 | 207 | /* more refactoring needed */ |
| 208 | - if ($targetIndex < $sourceIndex) { |
|
| 209 | - if (($point == 'top' && $orderDir == 'asc') || ($point == 'bottom' && $orderDir == 'desc')) { |
|
| 208 | + if ($targetIndex < $sourceIndex) {
|
|
| 209 | + if (($point == 'top' && $orderDir == 'asc') || ($point == 'bottom' && $orderDir == 'desc')) {
|
|
| 210 | 210 | $this->modx->db->update("`{$this->indexName}`=`{$this->indexName}`+1", $table, |
| 211 | 211 | "`{$this->indexName}`>={$targetIndex} AND `{$this->indexName}`<{$sourceIndex} AND `{$this->rfName}`={$rid}"); |
| 212 | 212 | $rows = $this->modx->db->update("`{$this->indexName}`={$targetIndex}", $table, |
| 213 | 213 | "`{$this->pkName}`={$sourceId}"); |
| 214 | - } elseif (($point == 'bottom' && $orderDir == 'asc') || ($point == 'top' && $orderDir == 'desc')) { |
|
| 214 | + } elseif (($point == 'bottom' && $orderDir == 'asc') || ($point == 'top' && $orderDir == 'desc')) {
|
|
| 215 | 215 | $this->modx->db->update("`{$this->indexName}`=`{$this->indexName}`+1", $table, |
| 216 | 216 | "`{$this->indexName}`>{$targetIndex} AND `{$this->indexName}`<{$sourceIndex} AND `{$this->rfName}`={$rid}"); |
| 217 | 217 | $rows = $this->modx->db->update("`{$this->indexName}`=1+{$targetIndex}", $table, |
| 218 | 218 | "`{$this->pkName}`={$sourceId}"); |
| 219 | 219 | } |
| 220 | - } else { |
|
| 221 | - if (($point == 'bottom' && $orderDir == 'asc') || ($point == 'top' && $orderDir == 'desc')) { |
|
| 220 | + } else {
|
|
| 221 | + if (($point == 'bottom' && $orderDir == 'asc') || ($point == 'top' && $orderDir == 'desc')) {
|
|
| 222 | 222 | $this->modx->db->update("`{$this->indexName}`=`{$this->indexName}`-1", $table, |
| 223 | 223 | "`{$this->indexName}`<={$targetIndex} AND `{$this->indexName}`>={$sourceIndex} AND `{$this->rfName}`={$rid}"); |
| 224 | 224 | $rows = $this->modx->db->update("`{$this->indexName}`={$targetIndex}", $table, |
| 225 | 225 | "`{$this->pkName}`={$sourceId}"); |
| 226 | - } elseif (($point == 'top' && $orderDir == 'asc') || ($point == 'bottom' && $orderDir == 'desc')) { |
|
| 226 | + } elseif (($point == 'top' && $orderDir == 'asc') || ($point == 'bottom' && $orderDir == 'desc')) {
|
|
| 227 | 227 | $this->modx->db->update("`{$this->indexName}`=`{$this->indexName}`-1", $table, |
| 228 | 228 | "`{$this->indexName}`<{$targetIndex} AND `{$this->indexName}`>={$sourceIndex} AND `{$this->rfName}`={$rid}"); |
| 229 | 229 | $rows = $this->modx->db->update("`{$this->indexName}`=-1+{$targetIndex}", $table, |
@@ -240,9 +240,9 @@ discard block |
||
| 240 | 240 | * @param $options |
| 241 | 241 | * @return bool |
| 242 | 242 | */ |
| 243 | - public function makeThumb($folder, $url, $options) |
|
| 244 | - { |
|
| 245 | - if (empty($url)) { |
|
| 243 | + public function makeThumb($folder, $url, $options) |
|
| 244 | + {
|
|
| 245 | + if (empty($url)) {
|
|
| 246 | 246 | return false; |
| 247 | 247 | } |
| 248 | 248 | $thumb = new \Helpers\PHPThumb(); |
@@ -250,9 +250,9 @@ discard block |
||
| 250 | 250 | $outputFile = MODX_BASE_PATH . $this->fs->relativePath($folder) . '/' . $this->fs->relativePath($url); |
| 251 | 251 | $dir = $this->fs->takeFileDir($outputFile); |
| 252 | 252 | $this->fs->makeDir($dir, $this->modx->config['new_folder_permissions']); |
| 253 | - if ($thumb->create($inputFile, $outputFile, $options)) { |
|
| 253 | + if ($thumb->create($inputFile, $outputFile, $options)) {
|
|
| 254 | 254 | return true; |
| 255 | - } else { |
|
| 255 | + } else {
|
|
| 256 | 256 | $this->modx->logEvent(0, 3, $thumb->debugMessages, __NAMESPACE__); |
| 257 | 257 | |
| 258 | 258 | return false; |
@@ -262,16 +262,18 @@ discard block |
||
| 262 | 262 | /** |
| 263 | 263 | * @return array |
| 264 | 264 | */ |
| 265 | - public function getParams() |
|
| 266 | - { |
|
| 265 | + public function getParams() |
|
| 266 | + {
|
|
| 267 | 267 | return $this->params; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | /** |
| 271 | 271 | * @param array $params |
| 272 | 272 | */ |
| 273 | - public function setParams($params = array()) |
|
| 274 | - { |
|
| 275 | - if (is_array($params)) $this->params = $params; |
|
| 273 | + public function setParams($params = array()) |
|
| 274 | + {
|
|
| 275 | + if (is_array($params)) {
|
|
| 276 | + $this->params = $params; |
|
| 277 | + } |
|
| 276 | 278 | } |
| 277 | 279 | } |