aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/admin_multi_view/controller.php
blob: ee4dec452bebcb682e5e2c3c1383863897e5e441 (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?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__);
$my_theme = get_root_url().'template/'.$user['template'].'/theme/'.$user['theme'].'/theme.css';

$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>
<link rel="stylesheet" type="text/css" href="<?php
echo $my_theme;
?>">
<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>