forked from c4y/megamenu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleMenuArticles.php
More file actions
executable file
·110 lines (99 loc) · 3.3 KB
/
ModuleMenuArticles.php
File metadata and controls
executable file
·110 lines (99 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php if(!defined('TL_ROOT')) die('You can not access this file directly!');
/**
* Contao Open Source CMS
* Copyright (C) 2005-2010 Leo Feyer
*
* Formerly known as TYPOlight Open Source CMS.
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program. If not, please visit the Free
* Software Foundation website at <http://www.gnu.org/licenses/>.
*
* c4y_megamenu
* Wrap an article into a navigation
*
* PHP version 5
* @copyright contao4you | Oliver Lohoff 2011
* @author Oliver Lohoff <info@contao4you.de>
* @license http://opensource.org/licenses/lgpl-3.0.html
*/
class ModuleMenuArticles extends Backend
{
/**
* Import the back end user object
*/
public function __construct()
{
parent::__construct();
$this->import('BackendUser', 'User');
}
/**
* Get all articles and return them as array (article alias)
* @param object
* @return array
*/
public function getArticles(DataContainer $dc)
{
$arrPids = array();
$arrAlias = array();
if (!$this->User->isAdmin)
{
foreach ($this->User->pagemounts as $id)
{
$arrPids[] = $id;
$arrPids = array_merge($arrPids, $this->getChildRecords($id, 'tl_page', true));
}
if (empty($arrPids))
{
return $arrAlias;
}
$objAlias = $this->Database->prepare("SELECT a.id, a.title, a.inColumn, p.title
AS parent
FROM tl_article a
LEFT JOIN tl_page p
ON p.id=a.pid
WHERE a.pid IN(". implode(',', array_map('intval', array_unique($arrPids))) .")
ORDER BY parent, a.sorting")
->execute($dc->id);
}
else
{
$objAlias = $this->Database->prepare("SELECT a.id, a.title, a.inColumn, p.title
AS parent
FROM tl_article a
LEFT JOIN tl_page p
ON p.id=a.pid
ORDER BY parent, a.sorting")
->execute($dc->id);
}
if ($objAlias->numRows)
{
$this->loadLanguageFile('tl_article');
while ($objAlias->next())
{
$arrAlias[$objAlias->parent][$objAlias->id] = $objAlias->title . ' (' . (strlen($GLOBALS['TL_LANG']['tl_article'][$objAlias->inColumn]) ? $GLOBALS['TL_LANG']['tl_article'][$objAlias->inColumn] : $objAlias->inColumn) . ', ID ' . $objAlias->id . ')';
}
}
return $arrAlias;
}
/**
* Return the edit article teaser wizard
* @param object
* @return string
*/
public function editArticle(DataContainer $dc)
{
return ($dc->value < 1) ? '' : ' <a href="contao/main.php?do=article&table=tl_content&id=' . $dc->value . '" title="'.sprintf(specialchars($GLOBALS['TL_LANG']['tl_content']['editarticle'][1]), $dc->value).'">' . $this->generateImage('alias.gif', $GLOBALS['TL_LANG']['tl_content']['editarticle'][0], 'style="vertical-align:top;"') . '</a>';
}
}
?>