aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/admin_multi_view/controller.php113
-rw-r--r--plugins/admin_multi_view/is_admin.inc.php42
-rw-r--r--plugins/admin_multi_view/main.inc.php17
3 files changed, 172 insertions, 0 deletions
diff --git a/plugins/admin_multi_view/controller.php b/plugins/admin_multi_view/controller.php
new file mode 100644
index 000000000..a4566ed69
--- /dev/null
+++ b/plugins/admin_multi_view/controller.php
@@ -0,0 +1,113 @@
+<?php
+define('MULTIVIEW_CONTROLLER', 1);
+define('PHPWG_ROOT_PATH','../../');
+include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
+
+if (!is_admin() or !function_exists('multiview_user_init') )
+{
+ pwg_unset_session_var( 'multiview_as' );
+ pwg_unset_session_var( 'multiview_theme' );
+ pwg_unset_session_var( 'multiview_lang' );
+?>
+<script type="text/javascript">
+ window.close();
+</script>
+<?php
+ exit();
+}
+
+$refresh_main = false;
+
+if ( isset($_GET['view_guest']) )
+{
+ pwg_set_session_var( 'multiview_as', $conf['guest_id'] );
+ $refresh_main = true;
+}
+elseif ( isset($_GET['view_admin']) )
+{
+ pwg_unset_session_var('multiview_as');
+ $refresh_main = true;
+}
+$view_as = pwg_get_session_var( 'multiview_as', 0 );
+
+
+if ( isset($_GET['theme']) )
+{
+ pwg_set_session_var( 'multiview_theme', $_GET['theme'] );
+ $refresh_main = true;
+}
+
+if ( isset($_GET['lang']) )
+{
+ pwg_set_session_var( 'multiview_lang', $_GET['lang'] );
+ $refresh_main = true;
+}
+
+$my_url = get_root_url().'plugins/'.basename(dirname(__FILE__)).'/'.basename(__FILE__);
+
+$themes_html='Theme: <select onchange="document.location = this.options[this.selectedIndex].value;">';
+foreach (get_pwg_themes() as $pwg_template)
+{
+ $selected = $pwg_template == pwg_get_session_var( 'multiview_theme', $user['template'].'/'.$user['theme'] ) ? 'selected="selected"' : '';
+ $themes_html .=
+ '<option value="'
+ .$my_url.'?theme='.$pwg_template
+ .'" '.$selected.'>'
+ .$pwg_template
+ .'</option>';
+}
+$themes_html .= '</select>';
+
+$lang_html='Language: <select onchange="document.location = this.options[this.selectedIndex].value;">';
+foreach (get_languages() as $language_code => $language_name)
+{
+ $selected = $language_code == pwg_get_session_var( 'multiview_lang', $user['language'] ) ? 'selected="selected"' : '';
+ $lang_html .=
+ '<option value="'
+ .$my_url.'?lang='.$language_code
+ .'" '.$selected.'>'
+ .$language_name
+ .'</option>';
+}
+$lang_html .= '</select>';
+?>
+
+<html>
+<head>
+<title>Controller</title>
+</head>
+
+<body>
+
+<script type="text/javascript">
+if (window.opener==null) {
+ window.close();
+ document.write("<h2>How did you get here ???</h2>");
+}
+</script>
+
+View as:
+<?php
+ if ($view_as)
+ echo '<a href="'.$my_url.'?view_admin">admin</a>';
+ else
+ echo '<a href="'.$my_url.'?view_guest">guest</a>';
+?>
+
+<br />
+<?php echo $themes_html; ?>
+
+<br />
+<?php echo $lang_html; ?>
+
+
+<script type="text/javascript">
+<?php
+ if ($refresh_main) echo '
+window.opener.location = window.opener.location;';
+?>
+</script>
+
+</body>
+
+</html> \ No newline at end of file
diff --git a/plugins/admin_multi_view/is_admin.inc.php b/plugins/admin_multi_view/is_admin.inc.php
new file mode 100644
index 000000000..7dbedf8f3
--- /dev/null
+++ b/plugins/admin_multi_view/is_admin.inc.php
@@ -0,0 +1,42 @@
+<?php
+if (! defined('MULTIVIEW_CONTROLLER') )
+{
+ global $user;
+ $view_as = pwg_get_session_var( 'multiview_as', 0 );
+ if ($view_as)
+ {
+ $user = build_user( $view_as, true);
+ }
+ $theme = pwg_get_session_var( 'multiview_theme', '' );
+ if ( !empty($theme) )
+ {
+ list($user['template'], $user['theme']) = explode('/', $theme);
+ }
+ $lang = pwg_get_session_var( 'multiview_lang', '' );
+ if ( !empty($theme) )
+ {
+ $user['language'] = $lang;
+ }
+}
+
+add_event_handler('loc_end_page_header', 'multiview_loc_end_page_header');
+
+function multiview_loc_end_page_header()
+{
+ global $template;
+ $my_root_url = get_root_url().'plugins/'. basename(dirname(__FILE__)).'/';
+ $js =
+'<script type="text/javascript">
+var theController = window.open("", "mview_controller", "alwaysRaised=yes,dependent=yes,toolbar=no,height=200,width=220,menubar=no,resizable=yes,scrollbars=yes,status=no");
+if ( theController.location.toString()=="about:blank" || !theController.location.toString().match(/^(https?.*\/)controller\.php(\?.+)?$/))
+{
+ theController.location = "'.$my_root_url.'controller.php";
+}
+</script>';
+
+ $template->assign_block_vars( 'head_element', array(
+ 'CONTENT' => $js
+ )
+ );
+}
+?>
diff --git a/plugins/admin_multi_view/main.inc.php b/plugins/admin_multi_view/main.inc.php
new file mode 100644
index 000000000..f0ed7a74d
--- /dev/null
+++ b/plugins/admin_multi_view/main.inc.php
@@ -0,0 +1,17 @@
+<?php /*
+Plugin Name: Multi view
+Version: 1.0
+Description: Allows administrators to view gallery as guests and/or change the language and/or theme on the fly. Practical to debug changes ...
+Plugin URI: http://www.phpwebgallery.net
+*/
+
+add_event_handler('user_init', 'multiview_user_init' );
+
+function multiview_user_init()
+{
+ if (!is_admin())
+ return;
+ include_once( dirname(__FILE__).'/is_admin.inc.php' );
+}
+
+?>