38 public $containerParam;
43 public $containerParamValue;
48 public $outputFormatValue;
58 public $gccRequestParams;
85 public function __construct($rootfolderId =
"", $hostParam = null, $contentTypes = null, $hideParam = null, $containerParam = null, $containerParamValue = null, $outputFormatValue =
"", $cacheTime = null, $gccRequestParams = null, $sorting = null)
88 if ( $rootfolderId !=
"" ) {
90 $this->lang = substr(Yii::app()->language, 0, 2);
91 $this->hostParam = isset($hostParam)? $hostParam : Yii::app()->getModule(
'googlesitemaps')->hostParam;
92 $this->contentTypes = isset($contentTypes)? $contentTypes : Yii::app()->getModule(
'googlesitemaps')->contentTypes;
93 $this->hideParam = isset($hideParam)? $hideParam : Yii::app()->getModule(
'googlesitemaps')->hideParam;
94 $this->containerParam = isset($containerParam)? $containerParam : Yii::app()->getModule(
'googlesitemaps')->containerParam;
95 $this->containerParamValue = isset($containerParamValue)? $containerParamValue : Yii::app()->getModule(
'googlesitemaps')->containerParamValue;
96 $this->cacheTime = isset($cacheTime)? $cacheTime : Yii::app()->getModule(
'googlesitemaps')->cacheTime;
97 $this->gccRequestParams = isset($gccRequestParams)? $gccRequestParams : Yii::app()->getModule(
'googlesitemaps')->gccRequestParams;
98 $this->sorting = isset($sorting)? $sorting : Yii::app()->getModule(
'googlesitemaps')->sorting;
99 $this->outputFormatValue = $outputFormatValue;
100 $this->hideParam = $hideParam;
101 $this->rootfolderId = $rootfolderId;
117 private function _cleanUp($user_id)
119 $maxTimestamp = $this->loadMaxUpdatetimestamp();
120 $cacheId =
'googlesitemaps_PERS_'.md5($this->rootfolderId.implode(
',', $this->contentTypes).$this->hideParam.$this->containerParam.$this->containerParamValue.$this->lang.$this->gccRequestParams.$this->sorting.$maxTimestamp);
122 if ((
$data = Yii::app()->cache->get($cacheId)) ===
false) {
128 if ($filters && $this->data) {
129 foreach ($this->data as $id=>$contentPage) {
130 if (!is_null($this->_unsetNodes($filters, $user_id, $contentPage))) {
131 $data[$id] = $contentPage;
138 Yii::app()->cache->set($cacheId, $this->data);
153 private function _unsetNodes($filters, $user_id,
$data)
156 $persAttributes = array();
157 foreach ($filters as $filter) {
158 if (!empty(
$data[
'attributes'][$filter])) {
159 $persAttributes = array_merge($persAttributes,
$data[
'attributes'][$filter]);
164 if (
$data[
'contentid'] != in_array(
$data[
'contentid'], $this->folderIds)) {
165 $excludeURLs = Yii::app()->getModule(
'googlesitemaps')->excludeURLs;
166 if ((isset(
$data[
'attributes'][
'url']) && in_array(
$data[
'attributes'][
'url'], $excludeURLs)) || !isset(
$data[
'attributes'][
'url'])) {
181 if (Yii::app()->getModule(
'contentSource')->contentSource->usePersonalisation) {
182 $filters = Yii::app()->getModule(
'contentSource')->contentSource->personalisationFields;
194 private function _loadData()
200 $this->gccRequestParams = rtrim($this->gccRequestParams,
',');
201 $requertFields = explode(
',', $this->gccRequestParams);
203 $requertFields[] =
'updatetimestamp';
204 $requertFields[] =
'name';
205 $requertFields[] =
'url';
207 $requertFields = array_unique($requertFields);
211 $maxTimestamp = $this->_getYoungestTimestamp($this->rootfolderId,
'googlesitemaps_UTS_'.md5($this->rootfolderId.implode(
',', $this->contentTypes).$this->hideParam.$this->containerParam.$this->containerParamValue.$this->cacheTime.$this->lang.$this->gccRequestParams));
214 $cacheId =
'googlesitemaps_'.md5($this->rootfolderId.implode(
',', $this->contentTypes).$this->hideParam.$this->containerParam.$this->containerParamValue.$this->cacheTime.$this->lang.$this->gccRequestParams.$maxTimestamp);
217 if ((
$data = Yii::app()->cache->get($cacheId)) ===
false) {
219 $filter =
'(object.obj_type=="10002" OR object.obj_type=="'.implode(
'" OR object.obj_type=="', $this->contentTypes).
'")';
220 if ($this->hideParam !=
"") {
221 $filter .=
' AND (object.'.$this->hideParam.
' != "1")';
223 if ($this->containerParam !=
"" && $this->containerParamValue !=
"") {
224 $filter .=
' AND (object.'.$this->containerParam.
' == "'.$this->containerParamValue.
'")';
227 'rootfilter' =>
'object.contentid=="'.$this->rootfolderId.
'"',
228 'childfilter' => $filter,
229 'sorting' => $this->sorting,
230 'navigation' =>
'true',
235 $params = Yii::app()->getComponent(
'repositoryApi')->addAdditionalParameters($params,
'contentRepositorySearch');
237 $data = Yii::app()->repositoryApi->requestNavigation(
244 if (isset(
$data[
'status']) &&
$data[
'status'] ==
'ok') {
245 unset(
$data[
'status']);
250 Yii::app()->cache->set($cacheId,
$data);
256 private function _getYoungestTimestamp($objectId, $objectCacheId)
258 $cacheId = $objectCacheId;
259 $filter =
'(object.obj_type=="10002" OR object.obj_type=="'.implode(
'" OR object.obj_type=="', $this->contentTypes).
'")';
260 if ($this->hideParam !=
"") {
261 $filter .=
' AND (object.'.$this->hideParam.
' != "1")';
263 if ($this->containerParam !=
"" && $this->containerParamValue !=
"") {
264 $filter .=
' AND (object.'.$this->containerParam.
' == "'.$this->containerParamValue.
'")';
266 if (($updateTimestamp = Yii::app()->cache->get($cacheId)) ===
false) {
267 $updateTimestamp = Yii::app()->repositoryApi->requestNavigation(
269 "rootfilter" =>
'object.contentid=="' . $objectId .
'"',
270 "type" =>
"youngest",
271 "sorting" => $this->sorting,
272 "childfilter" => $filter
276 Yii::app()->cache->set($cacheId, $updateTimestamp, $this->getLatestUpdateTimestampCacheTime());
278 return $updateTimestamp;
281 public function getLatestUpdateTimestampCacheTime()
283 return Yii::app()->getModule(
'navigation')->timestampCacheTime;