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 |
|
|
|
|
24
|
|
|
{ |
25
|
|
|
public function deleteUrlAlias($url_alias_id) |
|
|
|
|
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 = " |
|
|
|
|
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']; |
|
|
|
|
73
|
|
|
} else { |
74
|
|
|
$sql .= " ORDER BY ua.query"; |
|
|
|
|
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
if (isset($data['order']) && ($data['order'] == 'ASC')) { |
78
|
|
|
$sql .= " ASC"; |
|
|
|
|
79
|
|
|
} else { |
80
|
|
|
$sql .= " DESC"; |
|
|
|
|
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']; |
|
|
|
|
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
$query = $this->db->query($sql); |
96
|
|
|
|
97
|
|
|
return $query->rows; |
98
|
|
|
} else { |
99
|
|
|
$query = $this->db->query(" |
|
|
|
|
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(" |
|
|
|
|
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.