1 | <?php |
---|
2 | defined('ADMINTOOLS_PATH') or die('Hacking attempt!'); |
---|
3 | |
---|
4 | function admintools_add_public_controller() |
---|
5 | { |
---|
6 | global $MultiView, $conf; |
---|
7 | |
---|
8 | if (!$MultiView->is_admin()) |
---|
9 | { |
---|
10 | return; |
---|
11 | } |
---|
12 | |
---|
13 | global $template, $page, $user; |
---|
14 | |
---|
15 | $url_root = get_root_url(); |
---|
16 | |
---|
17 | $tpl_vars = array( |
---|
18 | 'U_SITE_ADMIN' => $url_root . 'admin.php?page=', |
---|
19 | 'MULTIVIEW' => $MultiView->get_data(), |
---|
20 | 'U_SELF' => $MultiView->get_clean_url(true), |
---|
21 | 'USER' => $MultiView->get_user(), |
---|
22 | 'CURRENT_USERNAME' => $user['id']==$conf['guest_id'] ? l10n('guest') : $user['username'], |
---|
23 | ); |
---|
24 | |
---|
25 | // TODO : param to allow owner modification |
---|
26 | if (script_basename() == 'picture') |
---|
27 | { |
---|
28 | global $picture; |
---|
29 | |
---|
30 | $url_self = duplicate_picture_url(); |
---|
31 | |
---|
32 | $tpl_vars['IS_PICTURE'] = true; |
---|
33 | |
---|
34 | $template->clear_assign(array( |
---|
35 | 'U_SET_AS_REPRESENTATIVE', |
---|
36 | 'U_PHOTO_ADMIN', |
---|
37 | 'U_CADDIE', |
---|
38 | )); |
---|
39 | |
---|
40 | $query = 'SELECT element_id FROM ' . CADDIE_TABLE . ' |
---|
41 | WHERE element_id = ' . $page['image_id'] .';'; |
---|
42 | $tpl_vars['IS_IN_CADDIE'] = pwg_db_num_rows(pwg_query($query)) > 0; |
---|
43 | |
---|
44 | if (isset($page['category'])) |
---|
45 | { |
---|
46 | $tpl_vars['CATEGORY_ID'] = $page['category']['id']; |
---|
47 | |
---|
48 | $tpl_vars['U_SET_REPRESENTATIVE'] = add_url_params( |
---|
49 | $url_self, |
---|
50 | array('action'=>'set_as_representative') |
---|
51 | ); |
---|
52 | |
---|
53 | $query = 'SELECT id FROM ' . CATEGORIES_TABLE.' |
---|
54 | WHERE id = ' . $page['category']['id'] .' |
---|
55 | AND representative_picture_id = ' . $page['image_id'] .';'; |
---|
56 | $tpl_vars['IS_REPRESENTATIVE'] = pwg_db_num_rows(pwg_query($query)) > 0; |
---|
57 | } |
---|
58 | |
---|
59 | $tpl_vars['U_EDIT'] = $url_root . 'admin.php?page=photo-' . $page['image_id'] |
---|
60 | .(isset($page['category']) ? '&cat_id=' . $page['category']['id'] : ''); |
---|
61 | |
---|
62 | $tpl_vars['U_CADDIE'] = add_url_params( |
---|
63 | $url_self, |
---|
64 | array('action'=>'add_to_caddie') |
---|
65 | ); |
---|
66 | } |
---|
67 | else if (@$page['section'] = 'categories' and isset($page['category'])) |
---|
68 | { |
---|
69 | $url_self = duplicate_index_url(); |
---|
70 | |
---|
71 | $tpl_vars['IS_CATEGORY'] = true; |
---|
72 | $tpl_vars['CATEGORY_ID'] = $page['category']['id']; |
---|
73 | |
---|
74 | $template->clear_assign(array( |
---|
75 | 'U_EDIT', |
---|
76 | 'U_CADDIE', |
---|
77 | )); |
---|
78 | |
---|
79 | $tpl_vars['U_EDIT'] = $url_root . 'admin.php?page=album-' . $page['category']['id']; |
---|
80 | |
---|
81 | if (!empty($page['items'])) |
---|
82 | { |
---|
83 | $tpl_vars['U_CADDIE'] = add_url_params( |
---|
84 | $url_self, |
---|
85 | array('caddie'=>1) |
---|
86 | ); |
---|
87 | } |
---|
88 | } |
---|
89 | |
---|
90 | |
---|
91 | // get users |
---|
92 | $query = ' |
---|
93 | SELECT |
---|
94 | '.$conf['user_fields']['id'].' AS id, |
---|
95 | '.$conf['user_fields']['username'].' AS username |
---|
96 | FROM '.USERS_TABLE.' |
---|
97 | ORDER BY CONVERT('.$conf['user_fields']['username'].', CHAR) |
---|
98 | ;'; |
---|
99 | $tpl_vars['USERS'] = simple_hash_from_query($query, 'id', 'username'); |
---|
100 | |
---|
101 | // get themes |
---|
102 | include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php'); |
---|
103 | $themes = new themes(); |
---|
104 | foreach (array_keys($themes->fs_themes) as $theme) |
---|
105 | { |
---|
106 | $tpl_vars['THEMES'][$theme] = $theme; |
---|
107 | } |
---|
108 | |
---|
109 | // get languages |
---|
110 | foreach (get_languages() as $code => $name) |
---|
111 | { |
---|
112 | $tpl_vars['LANGS'][$code] = $name; |
---|
113 | } |
---|
114 | |
---|
115 | |
---|
116 | $template->assign(array( |
---|
117 | 'ADMINTOOLS_PATH' => ADMINTOOLS_PATH, |
---|
118 | 'ato' => $tpl_vars, |
---|
119 | )); |
---|
120 | |
---|
121 | $template->set_filename('ato', realpath(ADMINTOOLS_PATH . 'template/public_controller.tpl')); |
---|
122 | $template->parse('ato'); |
---|
123 | } |
---|