/
sitemap.php
325 lines (132 loc) · 3.72 KB
/
sitemap.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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php
/**
* @project Astra.CMS
* @link http://a-cms.ru/
* @copyright 2011 "Астра Вебтехнологии"
* @author Vitaly Hohlov <admin@a-cms.ru>
* @package Modules
*/
/**************************************************************************/
require_once("system/framework/html.php");
require_once("system/framework/tree.php");
/**
* Узел дерева элементов карты сайта.
*/
class SiteMap_Box extends A_HTMLContent
{
/**
* Дочерние элементы.
*/
public $items=array();
/**
* Название узла.
*/
public $name;
/**
* Ссылка.
*/
public $link;
/**
* Идентификатор узла.
*/
static $boxid=0;
/**
* Конструктор.
*
* @param string $name Название.
* @param string $link Ссылка.
*/
function __construct($name,$link)
{
$this->name=$name;
$this->link=$link;
}
/**
* Формирование HTML кода узла со всеми дочерними элементами.
*
* @param integer $level Уровень узла.
*/
function createData($level)
{
foreach($this->items as $item)
$this->AddContent($item->getContent($level+1));
$smarty = new Smarty();
$smarty->template_dir=SMARTY_TEMPLATES."/others/";
$smarty->compile_dir=SMARTY_COMPILE."/others/";
if(A::$OPTIONS['smartysecurity'])
{ $this->security=true;
$this->secure_dir=array(SMARTY_TEMPLATES."/others");
}
$smarty->Assign("level",$level);
$smarty->Assign("id","mapbox".(SiteMap_Box::$boxid++));
$smarty->Assign_by_ref("name",$this->name);
$smarty->Assign_by_ref("link",$this->link);
$smarty->Assign("content",$this->content);
$this->content=$smarty->fetch("sitemap_box.tpl");
}
/**
* Возвращает HTML узла со всеми дочерними элементами.
*
* @param integer $level=1 Уровень узла.
*/
function getContent($level=1)
{ $this->createData($level);
return $this->content;
}
}
/**
* Модуль "Карта сайта".
*
* <a href="http://wiki.a-cms.ru/modules/sitemap">Руководство</a>.
*/
class SiteMapModule extends A_MainFrame
{
/**
* Объект дерева элементов.
*/
public $treemap;
/**
* Конструктор.
*/
function __construct()
{
$this->treemap = new A_ExpandTree();
parent::__construct();
}
/**
* Маршрутизатор URL.
*
* @param array $uri Элементы полного пути URL.
*/
function Router($uri)
{
if(count($uri)==0)
$this->page="sitemap";
else
A::NotFound();
}
/**
* Формирование данных доступных в шаблоне.
*/
function createData()
{
$this->supportCached();
$checkeds=getTextOption(SECTION,'sections');
$checkeds=!empty($checkeds)?unserialize($checkeds):array();
A::$DB->query("SELECT * FROM ".DOMAIN."_sections WHERE lang='".LANG."' OR lang='all' ORDER BY sort");
while($row=A::$DB->fetchRow())
if(in_array($row['id'],$checkeds))
{ if(function_exists($row['module'].'_createMap'))
{ $section = DOMAIN."_".$row['lang']."_".$row['name'];
$caption=!empty($row['caption_'.LANG])?$row['caption_'.LANG]:$row['caption'];
call_user_func($row['module']."_createMap",$this->treemap,$section,$caption);
}
}
A::$DB->free();
$this->Assign_by_ref("treemap",$this->treemap);
$this->AddNavigation(SECTION_NAME);
}
}
if(A::$CACHE->page)
A::$CACHE->page->restore();
A::$MAINFRAME = new SiteMapModule;