@@ -27,7 +27,7 @@ |
||
| 27 | 27 | /** |
| 28 | 28 | * Invoker |
| 29 | 29 | * |
| 30 | - * @return true|string : true on success or an error code on failure |
|
| 30 | + * @return string|boolean : true on success or an error code on failure |
|
| 31 | 31 | */ |
| 32 | 32 | |
| 33 | 33 | public function __invoke(array $post) { |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | /** |
| 63 | 63 | * Update the entity dataset with a selected data. Also updates every entity object having an identical id |
| 64 | 64 | * |
| 65 | - * @return true : always true ;) |
|
| 65 | + * @return boolean : always true ;) |
|
| 66 | 66 | */ |
| 67 | 67 | |
| 68 | 68 | protected function setData(array $data) : bool { |
@@ -137,6 +137,7 @@ discard block |
||
| 137 | 137 | * Check whether another entity with a given unique param value exists. |
| 138 | 138 | * The method helps you to find out the possibility of changing the entity's unique param value to the given one |
| 139 | 139 | * |
| 140 | + * @param string $value |
|
| 140 | 141 | * @return int|false : the number of entities found (0 or 1) or false on error |
| 141 | 142 | */ |
| 142 | 143 | |
@@ -48,11 +48,11 @@ |
||
| 48 | 48 | |
| 49 | 49 | $query = ("SELECT " . implode(', ', $selection) . ", rel.ancestor as parent_id ") . |
| 50 | 50 | |
| 51 | - ("FROM " . static::$table . " ent ") . |
|
| 51 | + ("FROM " . static::$table . " ent ") . |
|
| 52 | 52 | |
| 53 | - ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
| 53 | + ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
| 54 | 54 | |
| 55 | - ("WHERE ent." . $name . " = '" . addslashes($value) . "' LIMIT 1"); |
|
| 55 | + ("WHERE ent." . $name . " = '" . addslashes($value) . "' LIMIT 1"); |
|
| 56 | 56 | |
| 57 | 57 | # ------------------------ |
| 58 | 58 | |
@@ -42,17 +42,17 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | $selection = array_keys($this->definition->getParams()); |
| 44 | 44 | |
| 45 | - foreach ($selection as $key => $field) $selection[$key] = ('ent.' . $field); |
|
| 45 | + foreach ($selection as $key => $field) $selection[$key] = ('ent.'.$field); |
|
| 46 | 46 | |
| 47 | 47 | # Process query |
| 48 | 48 | |
| 49 | - $query = ("SELECT " . implode(', ', $selection) . ", rel.ancestor as parent_id ") . |
|
| 49 | + $query = ("SELECT ".implode(', ', $selection).", rel.ancestor as parent_id "). |
|
| 50 | 50 | |
| 51 | - ("FROM " . static::$table . " ent ") . |
|
| 51 | + ("FROM ".static::$table." ent "). |
|
| 52 | 52 | |
| 53 | - ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
| 53 | + ("LEFT JOIN ".static::$table_relations." rel ON rel.descendant = ent.id AND rel.depth = 1 "). |
|
| 54 | 54 | |
| 55 | - ("WHERE ent." . $name . " = '" . addslashes($value) . "' LIMIT 1"); |
|
| 55 | + ("WHERE ent.".$name." = '".addslashes($value)."' LIMIT 1"); |
|
| 56 | 56 | |
| 57 | 57 | # ------------------------ |
| 58 | 58 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | # Select entity from DB |
| 156 | 156 | |
| 157 | - $condition = ($name . " = '" . addslashes($value) . "' AND id != " . $this->id); |
|
| 157 | + $condition = ($name." = '".addslashes($value)."' AND id != ".$this->id); |
|
| 158 | 158 | |
| 159 | 159 | DB::select(static::$table, 'id', $condition, null, 1); |
| 160 | 160 | |
@@ -42,7 +42,9 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | $selection = array_keys($this->definition->getParams()); |
| 44 | 44 | |
| 45 | - foreach ($selection as $key => $field) $selection[$key] = ('ent.' . $field); |
|
| 45 | + foreach ($selection as $key => $field) { |
|
| 46 | + $selection[$key] = ('ent.' . $field); |
|
| 47 | + } |
|
| 46 | 48 | |
| 47 | 49 | # Process query |
| 48 | 50 | |
@@ -112,13 +114,19 @@ discard block |
||
| 112 | 114 | |
| 113 | 115 | public function init($value, string $name = 'id') : bool { |
| 114 | 116 | |
| 115 | - if (0 !== $this->id) return false; |
|
| 117 | + if (0 !== $this->id) { |
|
| 118 | + return false; |
|
| 119 | + } |
|
| 116 | 120 | |
| 117 | 121 | # Get initiation index |
| 118 | 122 | |
| 119 | - if (false === ($index = $this->definition->getIndex($name))) return false; |
|
| 123 | + if (false === ($index = $this->definition->getIndex($name))) { |
|
| 124 | + return false; |
|
| 125 | + } |
|
| 120 | 126 | |
| 121 | - if (($index->type !== 'PRIMARY') && ($index->type !== 'UNIQUE')) return false; |
|
| 127 | + if (($index->type !== 'PRIMARY') && ($index->type !== 'UNIQUE')) { |
|
| 128 | + return false; |
|
| 129 | + } |
|
| 122 | 130 | |
| 123 | 131 | # Process name & value |
| 124 | 132 | |
@@ -126,7 +134,11 @@ discard block |
||
| 126 | 134 | |
| 127 | 135 | # Select entity from DB |
| 128 | 136 | |
| 129 | - if (!static::$nesting) $this->selectBasic($name, $value); else $this->selectNesting($name, $value); |
|
| 137 | + if (!static::$nesting) { |
|
| 138 | + $this->selectBasic($name, $value); |
|
| 139 | + } else { |
|
| 140 | + $this->selectNesting($name, $value); |
|
| 141 | + } |
|
| 130 | 142 | |
| 131 | 143 | # ------------------------ |
| 132 | 144 | |
@@ -144,9 +156,13 @@ discard block |
||
| 144 | 156 | |
| 145 | 157 | # Get initiation index |
| 146 | 158 | |
| 147 | - if (false === ($index = $this->definition->getIndex($name))) return false; |
|
| 159 | + if (false === ($index = $this->definition->getIndex($name))) { |
|
| 160 | + return false; |
|
| 161 | + } |
|
| 148 | 162 | |
| 149 | - if ($index->type !== 'UNIQUE') return false; |
|
| 163 | + if ($index->type !== 'UNIQUE') { |
|
| 164 | + return false; |
|
| 165 | + } |
|
| 150 | 166 | |
| 151 | 167 | # Process name & value |
| 152 | 168 | |
@@ -20,7 +20,9 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | $item->children = ($children = Template::createBlock()); |
| 22 | 22 | |
| 23 | - foreach ($this->menu[$id]['children'] as $child) $children->addItem($this->parseItem($child)); |
|
| 23 | + foreach ($this->menu[$id]['children'] as $child) { |
|
| 24 | + $children->addItem($this->parseItem($child)); |
|
| 25 | + } |
|
| 24 | 26 | |
| 25 | 27 | } else { |
| 26 | 28 | |
@@ -44,7 +46,9 @@ discard block |
||
| 44 | 46 | |
| 45 | 47 | $menu = Entitizer::getTreeview(TABLE_MENU)->getSubtree(0, ['active' => true]); |
| 46 | 48 | |
| 47 | - if (false !== $menu) $this->menu = $menu; |
|
| 49 | + if (false !== $menu) { |
|
| 50 | + $this->menu = $menu; |
|
| 51 | + } |
|
| 48 | 52 | } |
| 49 | 53 | |
| 50 | 54 | # Get block |
@@ -53,7 +57,9 @@ discard block |
||
| 53 | 57 | |
| 54 | 58 | $menu = Template::createBlock(); |
| 55 | 59 | |
| 56 | - foreach ($this->menu[0]['children'] as $id) $menu->addItem($this->parseItem($id)); |
|
| 60 | + foreach ($this->menu[0]['children'] as $id) { |
|
| 61 | + $menu->addItem($this->parseItem($id)); |
|
| 62 | + } |
|
| 57 | 63 | |
| 58 | 64 | # ------------------------ |
| 59 | 65 | |
@@ -25,9 +25,11 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | # Set breadcrumbs |
| 27 | 27 | |
| 28 | - if (count($this->path) <= 1) $contents->getBlock('breadcrumbs')->disable(); |
|
| 29 | - |
|
| 30 | - else $contents->getBlock('breadcrumbs')->path = $this->path; |
|
| 28 | + if (count($this->path) <= 1) { |
|
| 29 | + $contents->getBlock('breadcrumbs')->disable(); |
|
| 30 | + } else { |
|
| 31 | + $contents->getBlock('breadcrumbs')->path = $this->path; |
|
| 32 | + } |
|
| 31 | 33 | |
| 32 | 34 | # Set contents |
| 33 | 35 | |
@@ -54,19 +56,31 @@ discard block |
||
| 54 | 56 | |
| 55 | 57 | $slug = $this->_url->getSlug(); |
| 56 | 58 | |
| 57 | - if ('' !== $slug) $this->page->initBySlug($slug); else $this->page->init(1); |
|
| 59 | + if ('' !== $slug) { |
|
| 60 | + $this->page->initBySlug($slug); |
|
| 61 | + } else { |
|
| 62 | + $this->page->init(1); |
|
| 63 | + } |
|
| 58 | 64 | |
| 59 | 65 | # Display error if not found |
| 60 | 66 | |
| 61 | - if (0 === $this->page->id) return false; |
|
| 67 | + if (0 === $this->page->id) { |
|
| 68 | + return false; |
|
| 69 | + } |
|
| 62 | 70 | |
| 63 | 71 | # Get path |
| 64 | 72 | |
| 65 | - if (false !== ($path = $this->page->getPath())) $this->path = $path; |
|
| 73 | + if (false !== ($path = $this->page->getPath())) { |
|
| 74 | + $this->path = $path; |
|
| 75 | + } |
|
| 66 | 76 | |
| 67 | 77 | # Set data |
| 68 | 78 | |
| 69 | - if ($this->page->id !== 1) SEO::title($this->page->title); else $this->_layout = 'Index'; |
|
| 79 | + if ($this->page->id !== 1) { |
|
| 80 | + SEO::title($this->page->title); |
|
| 81 | + } else { |
|
| 82 | + $this->_layout = 'Index'; |
|
| 83 | + } |
|
| 70 | 84 | |
| 71 | 85 | SEO::description ($this->page->description); |
| 72 | 86 | SEO::keywords ($this->page->keywords); |
@@ -23,34 +23,34 @@ |
||
| 23 | 23 | |
| 24 | 24 | protected function init() { |
| 25 | 25 | |
| 26 | - $this->config->addParam('active', '', function (bool $active) { |
|
| 26 | + $this->config->addParam('active', '', function(bool $active) { |
|
| 27 | 27 | |
| 28 | - return ($active ? ("ent.visibility = " . VISIBILITY_PUBLISHED . " AND ent.locked = 0") : ''); |
|
| 28 | + return ($active ? ("ent.visibility = ".VISIBILITY_PUBLISHED." AND ent.locked = 0") : ''); |
|
| 29 | 29 | }); |
| 30 | 30 | |
| 31 | - $this->config->addParam('rank', '', function (int $rank = null) { |
|
| 31 | + $this->config->addParam('rank', '', function(int $rank = null) { |
|
| 32 | 32 | |
| 33 | - return ((null !== $rank) ? ("ent.access <= " . $rank) : ''); |
|
| 33 | + return ((null !== $rank) ? ("ent.access <= ".$rank) : ''); |
|
| 34 | 34 | }); |
| 35 | 35 | |
| 36 | - $this->config->addParam('time_created >=', '', function (int $time) { |
|
| 36 | + $this->config->addParam('time_created >=', '', function(int $time) { |
|
| 37 | 37 | |
| 38 | - return ((0 < $time) ? ("ent.time_created >= " . $time) : ''); |
|
| 38 | + return ((0 < $time) ? ("ent.time_created >= ".$time) : ''); |
|
| 39 | 39 | }); |
| 40 | 40 | |
| 41 | - $this->config->addParam('time_created <=', '', function (int $time) { |
|
| 41 | + $this->config->addParam('time_created <=', '', function(int $time) { |
|
| 42 | 42 | |
| 43 | - return ((0 < $time) ? ("ent.time_created <= " . $time) : ''); |
|
| 43 | + return ((0 < $time) ? ("ent.time_created <= ".$time) : ''); |
|
| 44 | 44 | }); |
| 45 | 45 | |
| 46 | - $this->config->addParam('time_modified >=', '', function (int $time) { |
|
| 46 | + $this->config->addParam('time_modified >=', '', function(int $time) { |
|
| 47 | 47 | |
| 48 | - return ((0 < $time) ? ("ent.time_modified >= " . $time) : ''); |
|
| 48 | + return ((0 < $time) ? ("ent.time_modified >= ".$time) : ''); |
|
| 49 | 49 | }); |
| 50 | 50 | |
| 51 | - $this->config->addParam('time_modified <=', '', function (int $time) { |
|
| 51 | + $this->config->addParam('time_modified <=', '', function(int $time) { |
|
| 52 | 52 | |
| 53 | - return ((0 < $time) ? ("ent.time_modified <= " . $time) : ''); |
|
| 53 | + return ((0 < $time) ? ("ent.time_modified <= ".$time) : ''); |
|
| 54 | 54 | }); |
| 55 | 55 | } |
| 56 | 56 | } |
@@ -23,14 +23,14 @@ |
||
| 23 | 23 | |
| 24 | 24 | # Add params |
| 25 | 25 | |
| 26 | - $this->params->addTextual ('name', true, 255, false, ''); |
|
| 27 | - $this->params->addTextual ('title', true, 255, false, ''); |
|
| 28 | - $this->params->addTextual ('value', true, 255, false, ''); |
|
| 26 | + $this->params->addTextual('name', true, 255, false, ''); |
|
| 27 | + $this->params->addTextual('title', true, 255, false, ''); |
|
| 28 | + $this->params->addTextual('value', true, 255, false, ''); |
|
| 29 | 29 | |
| 30 | 30 | # Add indexes |
| 31 | 31 | |
| 32 | - $this->indexes->add ('name', 'UNIQUE'); |
|
| 33 | - $this->indexes->add ('title'); |
|
| 32 | + $this->indexes->add('name', 'UNIQUE'); |
|
| 33 | + $this->indexes->add('title'); |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | } |
@@ -23,16 +23,16 @@ |
||
| 23 | 23 | |
| 24 | 24 | # Add params |
| 25 | 25 | |
| 26 | - $this->params->addBoolean ('active', false); |
|
| 27 | - $this->params->addTextual ('name', true, 255, false, ''); |
|
| 28 | - $this->params->addTextual ('title', true, 255, false, ''); |
|
| 29 | - $this->params->addTextual ('contents', false, 0, false, ''); |
|
| 26 | + $this->params->addBoolean('active', false); |
|
| 27 | + $this->params->addTextual('name', true, 255, false, ''); |
|
| 28 | + $this->params->addTextual('title', true, 255, false, ''); |
|
| 29 | + $this->params->addTextual('contents', false, 0, false, ''); |
|
| 30 | 30 | |
| 31 | 31 | # Add indexes |
| 32 | 32 | |
| 33 | - $this->indexes->add ('active'); |
|
| 34 | - $this->indexes->add ('name', 'UNIQUE'); |
|
| 35 | - $this->indexes->add ('title'); |
|
| 33 | + $this->indexes->add('active'); |
|
| 34 | + $this->indexes->add('name', 'UNIQUE'); |
|
| 35 | + $this->indexes->add('title'); |
|
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | } |
@@ -23,27 +23,27 @@ |
||
| 23 | 23 | |
| 24 | 24 | # Add params |
| 25 | 25 | |
| 26 | - $this->params->addInteger ('rank', true, 1, true, RANK_GUEST); |
|
| 27 | - $this->params->addTextual ('name', true, 16, false, ''); |
|
| 28 | - $this->params->addTextual ('email', true, 128, false, ''); |
|
| 29 | - $this->params->addTextual ('auth_key', true, 40, true, ''); |
|
| 30 | - $this->params->addTextual ('password', true, 40, true, ''); |
|
| 31 | - $this->params->addTextual ('first_name', true, 255, false, ''); |
|
| 32 | - $this->params->addTextual ('last_name', true, 255, false, ''); |
|
| 33 | - $this->params->addInteger ('sex', true, 1, true, SEX_NOT_SELECTED); |
|
| 34 | - $this->params->addTextual ('city', true, 255, false, ''); |
|
| 35 | - $this->params->addTextual ('country', true, 2, false, ''); |
|
| 36 | - $this->params->addTextual ('timezone', true, 40, false, ''); |
|
| 37 | - $this->params->addInteger ('time_registered', false, 10, true, 0); |
|
| 38 | - $this->params->addInteger ('time_logged', false, 10, true, 0); |
|
| 26 | + $this->params->addInteger('rank', true, 1, true, RANK_GUEST); |
|
| 27 | + $this->params->addTextual('name', true, 16, false, ''); |
|
| 28 | + $this->params->addTextual('email', true, 128, false, ''); |
|
| 29 | + $this->params->addTextual('auth_key', true, 40, true, ''); |
|
| 30 | + $this->params->addTextual('password', true, 40, true, ''); |
|
| 31 | + $this->params->addTextual('first_name', true, 255, false, ''); |
|
| 32 | + $this->params->addTextual('last_name', true, 255, false, ''); |
|
| 33 | + $this->params->addInteger('sex', true, 1, true, SEX_NOT_SELECTED); |
|
| 34 | + $this->params->addTextual('city', true, 255, false, ''); |
|
| 35 | + $this->params->addTextual('country', true, 2, false, ''); |
|
| 36 | + $this->params->addTextual('timezone', true, 40, false, ''); |
|
| 37 | + $this->params->addInteger('time_registered', false, 10, true, 0); |
|
| 38 | + $this->params->addInteger('time_logged', false, 10, true, 0); |
|
| 39 | 39 | |
| 40 | 40 | # Add indexes |
| 41 | 41 | |
| 42 | - $this->indexes->add ('rank'); |
|
| 43 | - $this->indexes->add ('name', 'UNIQUE'); |
|
| 44 | - $this->indexes->add ('email', 'UNIQUE'); |
|
| 45 | - $this->indexes->add ('time_registered'); |
|
| 46 | - $this->indexes->add ('time_logged'); |
|
| 42 | + $this->indexes->add('rank'); |
|
| 43 | + $this->indexes->add('name', 'UNIQUE'); |
|
| 44 | + $this->indexes->add('email', 'UNIQUE'); |
|
| 45 | + $this->indexes->add('time_registered'); |
|
| 46 | + $this->indexes->add('time_logged'); |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | } |
@@ -23,29 +23,29 @@ |
||
| 23 | 23 | |
| 24 | 24 | # Add params |
| 25 | 25 | |
| 26 | - $this->params->addInteger ('visibility', true, 1, true, VISIBILITY_DRAFT); |
|
| 27 | - $this->params->addInteger ('access', true, 1, true, ACCESS_PUBLIC); |
|
| 28 | - $this->params->addBoolean ('locked', true); |
|
| 29 | - $this->params->addTextual ('slug', true, 255, false, ''); |
|
| 30 | - $this->params->addTextual ('name', true, 255, false, ''); |
|
| 31 | - $this->params->addTextual ('title', true, 255, false, ''); |
|
| 32 | - $this->params->addTextual ('contents', false, 0, false, ''); |
|
| 33 | - $this->params->addTextual ('description', false, 0, false, ''); |
|
| 34 | - $this->params->addTextual ('keywords', false, 0, false, ''); |
|
| 35 | - $this->params->addBoolean ('robots_index', false); |
|
| 36 | - $this->params->addBoolean ('robots_follow', false); |
|
| 37 | - $this->params->addInteger ('time_created', false, 10, true, 0); |
|
| 38 | - $this->params->addInteger ('time_modified', false, 10, true, 0); |
|
| 26 | + $this->params->addInteger('visibility', true, 1, true, VISIBILITY_DRAFT); |
|
| 27 | + $this->params->addInteger('access', true, 1, true, ACCESS_PUBLIC); |
|
| 28 | + $this->params->addBoolean('locked', true); |
|
| 29 | + $this->params->addTextual('slug', true, 255, false, ''); |
|
| 30 | + $this->params->addTextual('name', true, 255, false, ''); |
|
| 31 | + $this->params->addTextual('title', true, 255, false, ''); |
|
| 32 | + $this->params->addTextual('contents', false, 0, false, ''); |
|
| 33 | + $this->params->addTextual('description', false, 0, false, ''); |
|
| 34 | + $this->params->addTextual('keywords', false, 0, false, ''); |
|
| 35 | + $this->params->addBoolean('robots_index', false); |
|
| 36 | + $this->params->addBoolean('robots_follow', false); |
|
| 37 | + $this->params->addInteger('time_created', false, 10, true, 0); |
|
| 38 | + $this->params->addInteger('time_modified', false, 10, true, 0); |
|
| 39 | 39 | |
| 40 | 40 | # Add indexes |
| 41 | 41 | |
| 42 | - $this->indexes->add ('visibility'); |
|
| 43 | - $this->indexes->add ('access'); |
|
| 44 | - $this->indexes->add ('slug'); |
|
| 45 | - $this->indexes->add ('name'); |
|
| 46 | - $this->indexes->add ('title'); |
|
| 47 | - $this->indexes->add ('time_created'); |
|
| 48 | - $this->indexes->add ('time_modified'); |
|
| 42 | + $this->indexes->add('visibility'); |
|
| 43 | + $this->indexes->add('access'); |
|
| 44 | + $this->indexes->add('slug'); |
|
| 45 | + $this->indexes->add('name'); |
|
| 46 | + $this->indexes->add('title'); |
|
| 47 | + $this->indexes->add('time_created'); |
|
| 48 | + $this->indexes->add('time_modified'); |
|
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | } |