1 | <?php |
---|
2 | if (!defined('LINKEDPAGES_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | /** |
---|
5 | * add a tab on album properties page |
---|
6 | */ |
---|
7 | function linked_pages_tabsheet_before_select($sheets, $id) |
---|
8 | { |
---|
9 | if ($id == 'album') |
---|
10 | { |
---|
11 | $sheets['linked_pages'] = array( |
---|
12 | 'caption' => l10n('Linked Pages'), |
---|
13 | 'url' => LINKEDPAGES_ADMIN.'-album-'.$_GET['cat_id'], |
---|
14 | ); |
---|
15 | } |
---|
16 | |
---|
17 | return $sheets; |
---|
18 | } |
---|
19 | |
---|
20 | /** |
---|
21 | * display menu a album page/additional page |
---|
22 | */ |
---|
23 | function linked_pages_loc_end_index() |
---|
24 | { |
---|
25 | global $page, $user, $template; |
---|
26 | |
---|
27 | |
---|
28 | if ( isset($page['section']) and $page['section']=='categories' and isset($page['category']) ) |
---|
29 | { |
---|
30 | $query = ' |
---|
31 | SELECT |
---|
32 | lp.*, |
---|
33 | ap.lang, |
---|
34 | ap.title, |
---|
35 | ap.standalone, |
---|
36 | ap.permalink |
---|
37 | FROM '.LINKEDPAGES_TABLE.' AS lp |
---|
38 | INNER JOIN '.ADD_PAGES_TABLE.' AS ap |
---|
39 | ON lp.page_id = ap.id |
---|
40 | WHERE category_id = '.$page['category']['id'].' |
---|
41 | ORDER BY lp.pos |
---|
42 | ;'; |
---|
43 | $result = pwg_query($query); |
---|
44 | |
---|
45 | if (!pwg_db_num_rows($result)) |
---|
46 | { |
---|
47 | return; |
---|
48 | } |
---|
49 | |
---|
50 | while ($row = pwg_db_fetch_assoc($result)) |
---|
51 | { |
---|
52 | if ( isset($row['lang']) and $row['lang'] != $user['language'] ) return; |
---|
53 | $row['U_PAGE'] = make_index_url(array('section'=>'page')).'/'.(isset($row['permalink']) ? $row['permalink'] : $row['page_id']); |
---|
54 | $row['TITLE'] = trigger_event('AP_render_title', $row['title']); |
---|
55 | $template->append('category_pages', $row); |
---|
56 | } |
---|
57 | |
---|
58 | $template->assign('LINKEDPAGES_PATH', LINKEDPAGES_PATH); |
---|
59 | $template->set_prefilter('index', 'linked_pages_prefilter_index'); |
---|
60 | |
---|
61 | } |
---|
62 | else if ( isset($page['section']) and $page['section']=='additional_page' and isset($page['additional_page']) ) |
---|
63 | { |
---|
64 | $query = ' |
---|
65 | SELECT |
---|
66 | lp.*, |
---|
67 | cat.name, |
---|
68 | cat.permalink |
---|
69 | FROM '.LINKEDPAGES_TABLE.' AS lp |
---|
70 | INNER JOIN '.CATEGORIES_TABLE.' AS cat |
---|
71 | ON lp.category_id = cat.id |
---|
72 | WHERE page_id = '.$page['additional_page']['id'].' |
---|
73 | ORDER BY lp.pos |
---|
74 | ;'; |
---|
75 | $result = pwg_query($query); |
---|
76 | |
---|
77 | if (!pwg_db_num_rows($result)) |
---|
78 | { |
---|
79 | return; |
---|
80 | } |
---|
81 | |
---|
82 | while ($row = pwg_db_fetch_assoc($result)) |
---|
83 | { |
---|
84 | $row['U_PAGE'] = make_index_url( |
---|
85 | array( |
---|
86 | 'category' => array( |
---|
87 | 'id' => $row['category_id'], |
---|
88 | 'name' => $row['name'], |
---|
89 | 'permalink' => $row['permalink'], |
---|
90 | ) |
---|
91 | ) |
---|
92 | ); |
---|
93 | $row['TITLE'] = trigger_event('render_category_name', $row['name']); |
---|
94 | $template->append('category_pages', $row); |
---|
95 | } |
---|
96 | |
---|
97 | $template->assign('LINKEDPAGES_PATH', LINKEDPAGES_PATH); |
---|
98 | $template->set_filename('linked_pages_content', realpath(LINKEDPAGES_PATH . 'template/index_menu.tpl')); |
---|
99 | $template->assign('PLUGIN_INDEX_CONTENT_BEGIN', $template->parse('linked_pages_content',true).$template->get_template_vars('PLUGIN_INDEX_CONTENT_BEGIN')); |
---|
100 | } |
---|
101 | } |
---|
102 | |
---|
103 | function linked_pages_prefilter_index($content) |
---|
104 | { |
---|
105 | $search = '#(</div>{\* <!-- titrePage --> \*}|<div id="subcontent">|<div class="subcontent">)#'; |
---|
106 | $replace = "$1\n".file_get_contents(LINKEDPAGES_PATH . 'template/index_menu.tpl'); |
---|
107 | return preg_replace($search, $replace, $content); |
---|
108 | } |
---|
109 | |
---|
110 | |
---|
111 | ?> |
---|