This repository has been archived by the owner on Apr 4, 2018. It is now read-only.
/
ModuleAlias.php
69 lines (52 loc) · 1.7 KB
/
ModuleAlias.php
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
<?php
/**
* z_modulealias Extension for Contao Open Source CMS
*
* @copyright Copyright (c) 2010-2015, terminal42 gmbh
* @author terminal42 gmbh <info@terminal42.ch>
* @license http://opensource.org/licenses/lgpl-3.0.html LGPL
* @link http://github.com/terminal42/contao-z_modulealias
*/
namespace Terminal42\ModuleAliasExtension;
class ModuleAlias extends \Module
{
public function generate()
{
if (TL_MODE == 'BE')
{
$objTemplate = new \BackendTemplate('be_wildcard');
$objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['modulealias'][0]) . ' ###';
$objTemplate->title = $this->headline;
$objTemplate->id = $this->id;
$objTemplate->link = $this->name;
$objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
return $objTemplate->parse();
}
$arrModules = deserialize($this->aliasModules);
if (is_array($arrModules) && count($arrModules))
{
global $objPage;
$objModules = $this->Database->execute("SELECT id, aliasPages FROM tl_module WHERE id IN (" . implode(',', $arrModules) . ") ORDER BY " . $this->Database->findInSet('id', $arrModules));
while( $objModules->next() )
{
$arrPages = deserialize($objModules->aliasPages);
if (is_array($arrPages) && count($arrPages))
{
foreach( $arrPages as $intPage )
{
$arrPages = array_merge($arrPages, $this->getChildRecords($intPage, 'tl_page', false));
}
if (in_array($objPage->id, $arrPages))
{
return $this->getFrontendModule($objModules->id, $this->inColumn);
}
}
}
}
return '';
}
/**
* Not required but abstract in parent class
*/
protected function compile() {}
}