|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @copyright Copyright (c) 2011 - 2014 Oleksandr Torosh (http://wezoom.net) |
|
4
|
|
|
* @author Oleksandr Torosh <[email protected]> |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace Seo\Model; |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
use Application\Mvc\Helper\CmsCache; |
|
11
|
|
|
use Application\Mvc\Model\Model; |
|
12
|
|
|
use Application\Mvc\Router\DefaultRouter; |
|
13
|
|
|
use Phalcon\Mvc\Model\Message; |
|
14
|
|
|
|
|
15
|
|
|
class Manager extends Model |
|
16
|
|
|
{ |
|
17
|
|
|
|
|
18
|
|
|
public function getSource() |
|
19
|
|
|
{ |
|
20
|
|
|
return "seo_manager"; |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public $id; |
|
24
|
|
|
public $url; |
|
25
|
|
|
public $head_title; |
|
26
|
|
|
public $meta_description; |
|
27
|
|
|
public $meta_keywords; |
|
28
|
|
|
public $seo_text; |
|
29
|
|
|
public $created_at; |
|
30
|
|
|
public $updated_at; |
|
31
|
|
|
|
|
32
|
|
|
public function validation() |
|
33
|
|
|
{ |
|
34
|
|
|
return $this->validationHasFailed() != true; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function beforeCreate() |
|
38
|
|
|
{ |
|
39
|
|
|
$this->created_at = date("Y-m-d H:i:s"); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function beforeUpdate() |
|
43
|
|
|
{ |
|
44
|
|
|
$this->updated_at = date("Y-m-d H:i:s"); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function afterSave() |
|
48
|
|
|
{ |
|
49
|
|
|
CmsCache::getInstance()->save('seo_manager', $this->buildCmsSeoManagerCache()); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function afterDelete() |
|
53
|
|
|
{ |
|
54
|
|
|
CmsCache::getInstance()->save('seo_manager', $this->buildCmsSeoManagerCache()); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
private function buildCmsSeoManagerCache() |
|
58
|
|
|
{ |
|
59
|
|
|
$entries = self::find(); |
|
|
|
|
|
|
60
|
|
|
$save = []; |
|
61
|
|
|
if (!empty($entries)) { |
|
62
|
|
|
foreach ($entries as $el) { |
|
63
|
|
|
$save[$el->getUrl()] = [ |
|
64
|
|
|
'id' => $el->getId(), |
|
65
|
|
|
'url' => $el->getUrl(), |
|
66
|
|
|
'head_title' => $el->getHead_title(), |
|
67
|
|
|
'meta_description' => $el->getMeta_description(), |
|
68
|
|
|
'meta_keywords' => $el->getMeta_keywords(), |
|
69
|
|
|
'seo_text' => $el->getSeo_text(), |
|
70
|
|
|
]; |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
return $save; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public static function urls() |
|
77
|
|
|
{ |
|
78
|
|
|
return CmsCache::getInstance()->get('seo_manager'); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
public function getUrl() |
|
82
|
|
|
{ |
|
83
|
|
|
return $this->url; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public function setUrl($url) |
|
87
|
|
|
{ |
|
88
|
|
|
$request = $this->getDI()->get('request'); |
|
|
|
|
|
|
89
|
|
|
$host = $request->getHttpHost(); |
|
90
|
|
|
$url = str_replace(['http://' . $host, 'https://' . $host], ['', ''], $url); |
|
91
|
|
|
$this->url = $url; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
public function setCreatedAt($created_at) |
|
95
|
|
|
{ |
|
96
|
|
|
$this->created_at = $created_at; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
public function getCreatedAt() |
|
100
|
|
|
{ |
|
101
|
|
|
return $this->created_at; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
public function getId() |
|
105
|
|
|
{ |
|
106
|
|
|
return $this->id; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
public function setUpdatedAt($updated_at) |
|
110
|
|
|
{ |
|
111
|
|
|
$this->updated_at = $updated_at; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
public function getUpdatedAt() |
|
115
|
|
|
{ |
|
116
|
|
|
return $this->updated_at; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
public function setHead_title($head_title) |
|
120
|
|
|
{ |
|
121
|
|
|
$this->head_title = $head_title; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
public function getHead_title() |
|
125
|
|
|
{ |
|
126
|
|
|
return $this->head_title; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
public function setMeta_description($meta_description) |
|
130
|
|
|
{ |
|
131
|
|
|
$this->meta_description = $meta_description; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
public function getMeta_description() |
|
135
|
|
|
{ |
|
136
|
|
|
return $this->meta_description; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
public function setMeta_keywords($meta_keywords) |
|
140
|
|
|
{ |
|
141
|
|
|
$this->meta_keywords = $meta_keywords; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
public function getMeta_keywords() |
|
145
|
|
|
{ |
|
146
|
|
|
return $this->meta_keywords; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
public function setSeo_text($seo_text) |
|
150
|
|
|
{ |
|
151
|
|
|
$this->seo_text = $seo_text; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
public function getSeo_text() |
|
155
|
|
|
{ |
|
156
|
|
|
return $this->seo_text; |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
|
|
160
|
|
|
} |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.