1 | <?php |
||
2 | |||
3 | /* Divine CMS - Open source CMS for widespread use. |
||
4 | Copyright (c) 2019 Mykola Burakov ([email protected]) |
||
5 | |||
6 | See SOURCE.txt for other and additional information. |
||
7 | |||
8 | This file is part of Divine CMS. |
||
9 | |||
10 | This program is free software: you can redistribute it and/or modify |
||
11 | it under the terms of the GNU General Public License as published by |
||
12 | the Free Software Foundation, either version 3 of the License, or |
||
13 | (at your option) any later version. |
||
14 | |||
15 | This program is distributed in the hope that it will be useful, |
||
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
18 | GNU General Public License for more details. |
||
19 | |||
20 | You should have received a copy of the GNU General Public License |
||
21 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
||
22 | |||
23 | class ModelToolSeoManager extends \Divine\Engine\Core\Model |
||
0 ignored issues
–
show
|
|||
24 | { |
||
25 | public function deleteUrlAlias($url_alias_id) |
||
0 ignored issues
–
show
|
|||
26 | { |
||
27 | $this->db->query(" |
||
28 | DELETE |
||
29 | FROM `url_alias` |
||
30 | WHERE `url_alias_id` = '" . (int)$url_alias_id . "' |
||
31 | "); |
||
32 | $this->cache->delete('url_formatter'); |
||
33 | } |
||
34 | |||
35 | public function updateUrlAlias($data) |
||
36 | { |
||
37 | if ($data['query'] == '') { |
||
38 | return false; |
||
39 | } |
||
40 | if ($data['url_alias_id'] != 0) { |
||
41 | $this->db->query(" |
||
42 | UPDATE `url_alias` |
||
43 | SET `query` = '" . $this->db->escape($data['query']) . "', |
||
44 | `keyword` = '" . $data['keyword'] . "' |
||
45 | WHERE `url_alias_id` = '" . (int)$data['url_alias_id'] . "' |
||
46 | "); |
||
47 | } else { |
||
48 | $this->db->query(" |
||
49 | INSERT INTO `url_alias` |
||
50 | SET `query` = '" . $this->db->escape($data['query']) . "', |
||
51 | `keyword` = '" . $this->db->escape($data['keyword']) . "', |
||
52 | `seomanager` = 1 |
||
53 | "); |
||
54 | } |
||
55 | $this->cache->delete('url_formatter'); |
||
56 | |||
57 | return true; |
||
58 | } |
||
59 | |||
60 | // Get List URL Alias |
||
61 | public function getUrlAaliases($data = array()) |
||
62 | { |
||
63 | if ($data) { |
||
64 | $sql = " |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
\n SELECT...alias` ua\n does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() |
|||
65 | SELECT * |
||
66 | FROM `url_alias` ua |
||
67 | "; |
||
68 | |||
69 | $sort_data = array('ua.query', 'ua.keyword'); |
||
70 | |||
71 | if (isset($data['sort']) && in_array($data['sort'], $sort_data)) { |
||
72 | $sql .= " ORDER BY " . $data['sort']; |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
ORDER BY does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() |
|||
73 | } else { |
||
74 | $sql .= " ORDER BY ua.query"; |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
ORDER BY ua.query does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() |
|||
75 | } |
||
76 | |||
77 | if (isset($data['order']) && ($data['order'] == 'ASC')) { |
||
78 | $sql .= " ASC"; |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
ASC does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() |
|||
79 | } else { |
||
80 | $sql .= " DESC"; |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
DESC does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() |
|||
81 | } |
||
82 | |||
83 | if (isset($data['start']) || isset($data['limit'])) { |
||
84 | if ($data['start'] < 0) { |
||
85 | $data['start'] = 0; |
||
86 | } |
||
87 | |||
88 | if ($data['limit'] < 1) { |
||
89 | $data['limit'] = 20; |
||
90 | } |
||
91 | |||
92 | $sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit']; |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
LIMIT does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() Coding Style
Comprehensibility
introduced
by
The string literal
, does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() |
|||
93 | } |
||
94 | |||
95 | $query = $this->db->query($sql); |
||
96 | |||
97 | return $query->rows; |
||
98 | } else { |
||
99 | $query = $this->db->query(" |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
\n SELECT... ua.query\n does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() |
|||
100 | SELECT * |
||
101 | FROM `url_alias` ua |
||
102 | ORDER BY ua.query |
||
103 | "); |
||
104 | |||
105 | return $query->rows; |
||
106 | } |
||
107 | } |
||
108 | |||
109 | // Total Aliases |
||
110 | public function getTotalUrlAalias() |
||
111 | { |
||
112 | $query = $this->db->query(" |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
The string literal
\n SELECT COU...M `url_alias`\n does not require double quotes, as per coding-style, please use single quotes.
PHP provides two ways to mark string literals. Either with single quotes String literals in single quotes on the other hand are evaluated very literally and the only two
characters that needs escaping in the literal are the single quote itself ( Double quoted string literals may contain other variables or more complex escape sequences. <?php
$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";
print $doubleQuoted;
will print an indented: If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear. For more information on PHP string literals and available escape sequences see the PHP core documentation. ![]() |
|||
113 | SELECT COUNT(*) AS total |
||
114 | FROM `url_alias` |
||
115 | "); |
||
116 | |||
117 | return $query->row['total']; |
||
118 | } |
||
119 | } |
||
120 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.