-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathe_link.php
More file actions
52 lines (47 loc) · 1.78 KB
/
Copy pathe_link.php
File metadata and controls
52 lines (47 loc) · 1.78 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
<?php
if (!defined('e107_INIT')) { exit; }
e107::lan('escursioni', 'admin');
class escursioni_link
{
public function config()
{
global $LAN;
$sql = e107::getDb();
$tp = e107::getParser();
$link_array = array();
$link_array[] = array(
'name' => $LAN['escursioni_lnk_all'],
'url' => e107::url('escursioni', 'index'),
'type' => 'page'
);
if ($sql->select('escursioni', 'ex_id, ex_title, ex_sef')) {
while ($row = $sql->fetch()) {
$link_array[] = array(
'name' => $LAN['escursioni_lnk_single'] . $tp->toHTML($row['ex_title'], true, 'TITLE'),
'url' => e107::url('escursioni', 'view', array(
'ex_id' => (int)$row['ex_id'],
'ex_title' => $this->slug(vartrue($row['ex_sef']) ?: $row['ex_title'])
)),
'type' => 'link'
);
}
}
if ($sql->select('escursioni_selezioni', 'sel_slug, sel_title', "sel_slug != '' ORDER BY sel_title ASC")) {
while ($row = $sql->fetch()) {
$link_array[] = array(
'name' => $LAN['escursioni_lnk_selection'] . $tp->toHTML($row['sel_title'], true, 'TITLE'),
'url' => e107::url('escursioni', 'selezione', array('sel_slug' => $row['sel_slug'])),
'type' => 'link'
);
}
}
return $link_array;
}
private function slug($text)
{
$text = html_entity_decode((string) $text, ENT_QUOTES, 'UTF-8');
$text = preg_replace('/[^A-Za-z0-9]+/', '-', $text);
$text = trim($text, '-');
return strtolower($text);
}
}