[1821] | 1 | <?php |
---|
| 2 | define('MULTIVIEW_CONTROLLER', 1); |
---|
| 3 | define('PHPWG_ROOT_PATH','../../'); |
---|
| 4 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
| 5 | |
---|
| 6 | if (!is_admin() or !function_exists('multiview_user_init') ) |
---|
| 7 | { |
---|
| 8 | pwg_unset_session_var( 'multiview_as' ); |
---|
| 9 | pwg_unset_session_var( 'multiview_theme' ); |
---|
| 10 | pwg_unset_session_var( 'multiview_lang' ); |
---|
[2016] | 11 | pwg_unset_session_var( 'multiview_show_queries' ); |
---|
| 12 | pwg_unset_session_var( 'multiview_debug_l10n' ); |
---|
[2223] | 13 | pwg_unset_session_var( 'multiview_debug_template' ); |
---|
[8012] | 14 | pwg_unset_session_var( 'multiview_template_combine_files' ); |
---|
[4208] | 15 | pwg_unset_session_var( 'multiview_no_history' ); |
---|
[1821] | 16 | ?> |
---|
[2073] | 17 | |
---|
[1821] | 18 | <script type="text/javascript"> |
---|
| 19 | window.close(); |
---|
| 20 | </script> |
---|
| 21 | <?php |
---|
| 22 | exit(); |
---|
| 23 | } |
---|
[2073] | 24 | ?> |
---|
| 25 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
---|
| 26 | "http://www.w3.org/TR/html4/strict.dtd"> |
---|
| 27 | <?php |
---|
[1821] | 28 | |
---|
| 29 | $refresh_main = false; |
---|
| 30 | |
---|
[2340] | 31 | if ( isset($_GET['view_as']) ) |
---|
[1821] | 32 | { |
---|
[2490] | 33 | if ($user['id']===$_GET['view_as']) |
---|
| 34 | pwg_unset_session_var( 'multiview_as' ); |
---|
| 35 | else |
---|
| 36 | pwg_set_session_var( 'multiview_as', (int)$_GET['view_as'] ); |
---|
[2340] | 37 | // user change resets theme/lang |
---|
| 38 | pwg_unset_session_var( 'multiview_theme' ); |
---|
| 39 | pwg_unset_session_var( 'multiview_lang' ); |
---|
[1821] | 40 | $refresh_main = true; |
---|
| 41 | } |
---|
[2340] | 42 | if (pwg_get_session_var( 'multiview_as', $user['id']) != $user['id'] ) |
---|
| 43 | $view_as_user = build_user( pwg_get_session_var( 'multiview_as',0), false); |
---|
| 44 | else |
---|
| 45 | $view_as_user = $user; |
---|
[1821] | 46 | |
---|
| 47 | if ( isset($_GET['theme']) ) |
---|
| 48 | { |
---|
| 49 | pwg_set_session_var( 'multiview_theme', $_GET['theme'] ); |
---|
| 50 | $refresh_main = true; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | if ( isset($_GET['lang']) ) |
---|
| 54 | { |
---|
| 55 | pwg_set_session_var( 'multiview_lang', $_GET['lang'] ); |
---|
| 56 | $refresh_main = true; |
---|
| 57 | } |
---|
| 58 | |
---|
[2016] | 59 | if ( isset($_GET['show_queries']) ) |
---|
| 60 | { |
---|
| 61 | if ( $_GET['show_queries']> 0 ) |
---|
| 62 | pwg_set_session_var( 'multiview_show_queries', 1 ); |
---|
| 63 | else |
---|
| 64 | pwg_unset_session_var( 'multiview_show_queries' ); |
---|
| 65 | $refresh_main = true; |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | if ( isset($_GET['debug_l10n']) ) |
---|
| 69 | { |
---|
| 70 | if ( $_GET['debug_l10n']>0 ) |
---|
| 71 | pwg_set_session_var( 'multiview_debug_l10n', 1 ); |
---|
| 72 | else |
---|
| 73 | pwg_unset_session_var( 'multiview_debug_l10n' ); |
---|
| 74 | $refresh_main = true; |
---|
| 75 | } |
---|
| 76 | |
---|
[2223] | 77 | |
---|
| 78 | if ( isset($_GET['debug_template']) ) |
---|
| 79 | { |
---|
| 80 | if ( $_GET['debug_template']>0 ) |
---|
| 81 | pwg_set_session_var( 'multiview_debug_template', 1 ); |
---|
| 82 | else |
---|
| 83 | pwg_unset_session_var( 'multiview_debug_template' ); |
---|
| 84 | $refresh_main = true; |
---|
| 85 | } |
---|
| 86 | |
---|
[8012] | 87 | if ( isset($_GET['template_combine_files']) ) |
---|
| 88 | { |
---|
| 89 | if ( $_GET['template_combine_files']==0 ) |
---|
| 90 | pwg_set_session_var( 'multiview_template_combine_files', 0 ); |
---|
| 91 | else |
---|
| 92 | pwg_unset_session_var( 'multiview_template_combine_files' ); |
---|
| 93 | $refresh_main = true; |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | |
---|
[4208] | 97 | if ( isset($_GET['no_history']) ) |
---|
| 98 | { |
---|
| 99 | if ( $_GET['no_history']>0 ) |
---|
| 100 | pwg_set_session_var( 'multiview_no_history', 1 ); |
---|
| 101 | else |
---|
| 102 | pwg_unset_session_var( 'multiview_no_history' ); |
---|
| 103 | $refresh_main = true; |
---|
| 104 | } |
---|
| 105 | |
---|
[15150] | 106 | if ( isset($_GET['purge_template']) ) |
---|
| 107 | { |
---|
| 108 | pwg_set_session_var( 'purge_template', 1 ); |
---|
| 109 | $refresh_main = true; |
---|
| 110 | } |
---|
| 111 | |
---|
[1821] | 112 | $my_url = get_root_url().'plugins/'.basename(dirname(__FILE__)).'/'.basename(__FILE__); |
---|
[2340] | 113 | |
---|
| 114 | // +-----------------------------------------------------------------------+ |
---|
| 115 | // | users | |
---|
| 116 | $query = ' |
---|
| 117 | SELECT '.$conf['user_fields']['id'].' AS id,'.$conf['user_fields']['username'].' AS username |
---|
[8126] | 118 | FROM '.USERS_TABLE.' |
---|
[2340] | 119 | ORDER BY CONVERT('.$conf['user_fields']['username'].',CHAR) |
---|
| 120 | ;'; |
---|
| 121 | $user_map = simple_hash_from_query($query, 'id', 'username'); |
---|
| 122 | |
---|
| 123 | $users_html = '<select onchange="document.location = this.options[this.selectedIndex].value;">'; |
---|
| 124 | foreach( $user_map as $id=>$username) |
---|
| 125 | { |
---|
| 126 | $selected = ($id==$view_as_user['id']) ? 'selected="selected"' : ''; |
---|
| 127 | $users_html .= |
---|
| 128 | '<option value="' |
---|
| 129 | .$my_url.'?view_as='.$id |
---|
| 130 | .'" '.$selected.'>' |
---|
| 131 | .$username |
---|
| 132 | .'</option>'; |
---|
| 133 | } |
---|
| 134 | $users_html.= '</select>'; |
---|
| 135 | |
---|
| 136 | |
---|
| 137 | // +-----------------------------------------------------------------------+ |
---|
| 138 | // | templates | |
---|
[5128] | 139 | $my_theme = ''; |
---|
[2340] | 140 | $themes_html='<select onchange="document.location = this.options[this.selectedIndex].value;">'; |
---|
[6238] | 141 | include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php'); |
---|
| 142 | $themes = new themes(); |
---|
| 143 | foreach ($themes->fs_themes as $pwg_theme => $fs_theme) |
---|
[1821] | 144 | { |
---|
[5128] | 145 | $selected = $pwg_theme == pwg_get_session_var( 'multiview_theme', $view_as_user['theme'] ) ? 'selected="selected"' : ''; |
---|
| 146 | $my_theme = $selected == '' ? $my_theme : 'themes/'.$view_as_user['theme']; |
---|
[1821] | 147 | $themes_html .= |
---|
| 148 | '<option value="' |
---|
[5128] | 149 | .$my_url.'?theme='.$pwg_theme |
---|
[1821] | 150 | .'" '.$selected.'>' |
---|
[5128] | 151 | .$pwg_theme |
---|
[1821] | 152 | .'</option>'; |
---|
| 153 | } |
---|
| 154 | $themes_html .= '</select>'; |
---|
| 155 | |
---|
[2340] | 156 | // +-----------------------------------------------------------------------+ |
---|
| 157 | // | language | |
---|
| 158 | $lang_html='<select onchange="document.location = this.options[this.selectedIndex].value;">'; |
---|
[1821] | 159 | foreach (get_languages() as $language_code => $language_name) |
---|
| 160 | { |
---|
[2340] | 161 | $selected = $language_code == pwg_get_session_var( 'multiview_lang', $view_as_user['language'] ) ? 'selected="selected"' : ''; |
---|
[1821] | 162 | $lang_html .= |
---|
| 163 | '<option value="' |
---|
| 164 | .$my_url.'?lang='.$language_code |
---|
| 165 | .'" '.$selected.'>' |
---|
| 166 | .$language_name |
---|
| 167 | .'</option>'; |
---|
| 168 | } |
---|
| 169 | $lang_html .= '</select>'; |
---|
[2016] | 170 | |
---|
[2340] | 171 | // +-----------------------------------------------------------------------+ |
---|
| 172 | // | show queries | |
---|
[2016] | 173 | $show_queries_html=''; |
---|
| 174 | if (!$conf['show_queries']) |
---|
| 175 | { |
---|
| 176 | if ( !pwg_get_session_var( 'multiview_show_queries', 0 ) ) |
---|
| 177 | $show_queries_html.='<a href="'.$my_url.'?show_queries=1">Show SQL queries</a>'; |
---|
| 178 | else |
---|
| 179 | $show_queries_html.='<a href="'.$my_url.'?show_queries=0">Hide SQL queries</a>'; |
---|
| 180 | } |
---|
| 181 | |
---|
[2340] | 182 | // +-----------------------------------------------------------------------+ |
---|
| 183 | // | debug language | |
---|
[2016] | 184 | $debug_l10n_html=''; |
---|
[2223] | 185 | if (!$conf['debug_l10n']) |
---|
[2016] | 186 | { |
---|
| 187 | if ( !pwg_get_session_var( 'multiview_debug_l10n', 0 ) ) |
---|
| 188 | $debug_l10n_html.='<a href="'.$my_url.'?debug_l10n=1">Debug language</a>'; |
---|
| 189 | else |
---|
| 190 | $debug_l10n_html.='<a href="'.$my_url.'?debug_l10n=0">Revert debug language</a>'; |
---|
| 191 | } |
---|
[2223] | 192 | |
---|
[2340] | 193 | // +-----------------------------------------------------------------------+ |
---|
| 194 | // | debug template | |
---|
[2223] | 195 | $debug_template_html=''; |
---|
| 196 | if (!$conf['debug_template']) |
---|
| 197 | { |
---|
| 198 | if ( !pwg_get_session_var( 'multiview_debug_template', 0 ) ) |
---|
| 199 | $debug_template_html.='<a href="'.$my_url.'?debug_template=1">Debug template</a>'; |
---|
| 200 | else |
---|
| 201 | $debug_template_html.='<a href="'.$my_url.'?debug_template=0">Revert debug template</a>'; |
---|
| 202 | } |
---|
| 203 | |
---|
[4208] | 204 | // +-----------------------------------------------------------------------+ |
---|
[8012] | 205 | // | template combine files | |
---|
| 206 | $template_combine_files_html=''; |
---|
| 207 | if ($conf['template_combine_files']) |
---|
| 208 | { |
---|
| 209 | if ( pwg_get_session_var( 'multiview_template_combine_files', 1 ) ) |
---|
| 210 | $template_combine_files_html.='<a href="'.$my_url.'?template_combine_files=0">Don\'t combine js&css</a>'; |
---|
| 211 | else |
---|
| 212 | $template_combine_files_html.='<a href="'.$my_url.'?template_combine_files=1">Combine js&css</a>'; |
---|
| 213 | } |
---|
| 214 | |
---|
| 215 | // +-----------------------------------------------------------------------+ |
---|
[4208] | 216 | // | no history | |
---|
| 217 | $no_history_html=''; |
---|
| 218 | if ( !pwg_get_session_var( 'multiview_no_history', 0 ) ) |
---|
| 219 | $no_history_html.='<a href="'.$my_url.'?no_history=1">Don\'t save to visit history</a>'; |
---|
| 220 | else |
---|
| 221 | $no_history_html.='<a href="'.$my_url.'?no_history=0">Save to visit history</a>'; |
---|
| 222 | |
---|
[1821] | 223 | ?> |
---|
| 224 | <html> |
---|
| 225 | <head> |
---|
[2127] | 226 | <meta http-equiv="Content-Type" content="text/html; charset=<?php echo get_pwg_charset() ?>"> |
---|
[1821] | 227 | <title>Controller</title> |
---|
[2073] | 228 | |
---|
[1821] | 229 | </head> |
---|
| 230 | <body> |
---|
[2073] | 231 | <div> |
---|
[1821] | 232 | <script type="text/javascript"> |
---|
| 233 | if (window.opener==null) { |
---|
| 234 | window.close(); |
---|
[2073] | 235 | document.write("<"+"h2>How did you get here ???<"+"/h2>"); |
---|
[1821] | 236 | } |
---|
| 237 | </script> |
---|
| 238 | |
---|
[2340] | 239 | <table> |
---|
| 240 | <tr><td>User</td><td><?php echo $users_html; ?></td></tr> |
---|
[1821] | 241 | |
---|
[2340] | 242 | <tr><td>Theme</td><td><?php echo $themes_html; ?></td></tr> |
---|
[1821] | 243 | |
---|
[2340] | 244 | <tr><td>Lang</td><td><?php echo $lang_html; ?></td></tr> |
---|
| 245 | </table> |
---|
[8012] | 246 | <?php echo implode( "<br/>\n", array($show_queries_html, $debug_l10n_html, $debug_template_html, $template_combine_files_html, $no_history_html) ); ?> |
---|
[15150] | 247 | <br/><a href="<?php echo $my_url; ?>?purge_template">Purge compiled templates</a> |
---|
[1821] | 248 | |
---|
| 249 | <script type="text/javascript"> |
---|
| 250 | <?php |
---|
| 251 | if ($refresh_main) echo ' |
---|
| 252 | window.opener.location = window.opener.location;'; |
---|
| 253 | ?> |
---|
| 254 | </script> |
---|
[2073] | 255 | </div> |
---|
[1821] | 256 | </body> |
---|
[1833] | 257 | </html> |
---|