author | Dan |
Sat, 07 Jun 2008 12:49:45 -0400 | |
changeset 564 | a1c450a911a6 |
parent 557 | 26479224936a |
child 566 | 06d241de3151 |
permissions | -rw-r--r-- |
1 | 1 |
<?php |
2 |
||
3 |
/* |
|
4 |
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between |
|
536 | 5 |
* Version 1.1.4 (Caoineag alpha 4) |
6 |
* Copyright (C) 2006-2008 Dan Fuhry |
|
1 | 7 |
* |
8 |
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
|
9 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
|
12 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
|
13 |
*/ |
|
14 |
||
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
15 |
class template |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
16 |
{ |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
17 |
var $tpl_strings, $tpl_bool, $vars_assign_history, $theme, $style, $no_headers, $additional_headers, $sidebar_extra, $sidebar_widgets, $toolbar_menu, $theme_list, $named_theme_list, $default_theme, $default_style, $plugin_blocks, $namespace_string, $style_list, $theme_loaded; |
30 | 18 |
|
19 |
/** |
|
471
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
20 |
* The list of themes that are critical for Enano operation. This doesn't include oxygen which |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
21 |
* remains a user theme. By default this is admin and printable which have to be loaded on demand. |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
22 |
* @var array |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
23 |
*/ |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
24 |
|
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
25 |
var $system_themes = array('admin', 'printable'); |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
26 |
|
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
27 |
/** |
30 | 28 |
* Set to true if the site is disabled and thus a message needs to be shown. This should ONLY be changed by common.php. |
29 |
* @var bool |
|
30 |
* @access private |
|
31 |
*/ |
|
32 |
||
33 |
var $site_disabled = false; |
|
34 |
||
53 | 35 |
/** |
36 |
* One of the absolute best parts of Enano :-P |
|
37 |
* @var string |
|
38 |
*/ |
|
39 |
||
54
84b56303cab5
Bugfixes: Login system properly handles blank password situation (returns ""); fading button now works right with relative URLs
Dan
parents:
53
diff
changeset
|
40 |
var $fading_button = ''; |
53 | 41 |
|
1 | 42 |
function __construct() |
43 |
{ |
|
44 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
45 |
$this->tpl_bool = Array(); |
|
46 |
$this->tpl_strings = Array(); |
|
47 |
$this->sidebar_extra = ''; |
|
48 |
$this->toolbar_menu = ''; |
|
49 |
$this->additional_headers = ''; |
|
50 |
$this->plugin_blocks = Array(); |
|
51 |
$this->theme_loaded = false; |
|
52 |
||
201
2303ef648290
[minor] added bottom margin for enanocms.org fading button
Dan
parents:
189
diff
changeset
|
53 |
$this->fading_button = '<div style="background-image: url('.scriptPath.'/images/about-powered-enano-hover.png); background-repeat: no-repeat; width: 88px; height: 31px; margin: 0 auto 5px auto;"> |
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
parents:
370
diff
changeset
|
54 |
<a style="background-image: none; padding-right: 0;" href="http://enanocms.org/" onclick="window.open(this.href); return false;"><img style="border-width: 0;" alt=" " src="'.scriptPath.'/images/about-powered-enano.png" onmouseover="domOpacity(this, 100, 0, 500);" onmouseout="domOpacity(this, 0, 100, 500);" /></a> |
87
570f68c3fe36
Redid stupid fading button code and fixed several RC2 bugs in the upgrade schema; 1.0.1 release candidate
Dan
parents:
86
diff
changeset
|
55 |
</div>'; |
54
84b56303cab5
Bugfixes: Login system properly handles blank password situation (returns ""); fading button now works right with relative URLs
Dan
parents:
53
diff
changeset
|
56 |
|
1 | 57 |
$this->theme_list = Array(); |
58 |
$this->named_theme_list = Array(); |
|
471
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
59 |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
60 |
$this->vars_assign_history = array( |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
61 |
'strings' => array(), |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
62 |
'bool' => array() |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
63 |
); |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
64 |
|
488
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
65 |
if ( defined('IN_ENANO_UPGRADE') ) |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
66 |
{ |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
67 |
return $this->construct_compat(); |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
68 |
} |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
69 |
|
471
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
70 |
$q = $db->sql_query('SELECT theme_id, theme_name, enabled, default_style, group_policy, group_list FROM ' . table_prefix . 'themes;'); |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
71 |
if ( !$q ) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
72 |
$db->_die('template.php selecting theme list'); |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
73 |
|
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
74 |
$i = 0; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
75 |
while ( $row = $db->fetchrow() ) |
1 | 76 |
{ |
471
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
77 |
$this->theme_list[$i] = $row; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
78 |
$i++; |
1 | 79 |
} |
471
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
80 |
// List out all CSS files for this theme |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
81 |
foreach ( $this->theme_list as $i => &$theme ) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
82 |
{ |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
83 |
$theme['css'] = array(); |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
84 |
$dir = ENANO_ROOT . "/themes/{$theme['theme_id']}/css"; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
85 |
if ( $dh = @opendir($dir) ) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
86 |
{ |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
87 |
while ( ( $file = @readdir($dh) ) !== false ) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
88 |
{ |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
89 |
if ( preg_match('/\.css$/', $file) ) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
90 |
$theme['css'][] = preg_replace('/\.css$/', '', $file); |
1 | 91 |
} |
92 |
closedir($dh); |
|
93 |
} |
|
471
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
94 |
// No CSS files? If so, nuke it. |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
95 |
if ( count($theme['css']) < 1 ) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
96 |
{ |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
97 |
unset($this->theme_list[$i]); |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
98 |
} |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
99 |
} |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
100 |
$this->theme_list = array_values($this->theme_list); |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
101 |
// Create associative array of themes |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
102 |
foreach ( $this->theme_list as $i => &$theme ) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
103 |
$this->named_theme_list[ $theme['theme_id'] ] =& $this->theme_list[$i]; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
104 |
|
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
105 |
$this->default_theme = ( $_ = getConfig('theme_default') ) ? $_ : $this->theme_list[0]['theme_id']; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
106 |
// Come up with the default style. If the CSS file specified in default_style exists, we're good, just |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
107 |
// use that. Otherwise, use the first stylesheet that comes to mind. |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
108 |
$df_data =& $this->named_theme_list[ $this->default_theme ]; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
109 |
$this->default_style = ( in_array($df_data['default_style'], $df_data['css']) ) ? $df_data['default_style'] : $df_data['css'][0]; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
110 |
} |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
111 |
|
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
112 |
/** |
488
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
113 |
* Failsafe constructor for upgrades. |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
114 |
*/ |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
115 |
|
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
116 |
function construct_compat() |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
117 |
{ |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
118 |
global $db, $session, $paths, $template, $plugins; // Common objects |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
119 |
$this->tpl_bool = Array(); |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
120 |
$this->tpl_strings = Array(); |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
121 |
$this->sidebar_extra = ''; |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
122 |
$this->toolbar_menu = ''; |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
123 |
$this->additional_headers = ''; |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
124 |
$this->plugin_blocks = Array(); |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
125 |
$this->theme_loaded = false; |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
126 |
|
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
127 |
$this->fading_button = '<div style="background-image: url('.scriptPath.'/images/about-powered-enano-hover.png); background-repeat: no-repeat; width: 88px; height: 31px; margin: 0 auto 5px auto;"> |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
128 |
<a style="background-image: none; padding-right: 0;" href="http://enanocms.org/" onclick="window.open(this.href); return false;"><img style="border-width: 0;" alt=" " src="'.scriptPath.'/images/about-powered-enano.png" onmouseover="domOpacity(this, 100, 0, 500);" onmouseout="domOpacity(this, 0, 100, 500);" /></a> |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
129 |
</div>'; |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
130 |
|
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
131 |
$this->theme_list = Array(); |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
132 |
$this->named_theme_list = Array(); |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
133 |
|
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
134 |
$q = $db->sql_query('SELECT theme_id, theme_name, enabled, default_style FROM ' . table_prefix . 'themes;'); |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
135 |
if ( !$q ) |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
136 |
$db->_die('template.php selecting theme list'); |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
137 |
|
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
138 |
$i = 0; |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
139 |
while ( $row = $db->fetchrow() ) |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
140 |
{ |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
141 |
$this->theme_list[$i] = $row; |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
142 |
$i++; |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
143 |
} |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
144 |
// List out all CSS files for this theme |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
145 |
foreach ( $this->theme_list as $i => &$theme ) |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
146 |
{ |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
147 |
$theme['css'] = array(); |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
148 |
$dir = ENANO_ROOT . "/themes/{$theme['theme_id']}/css"; |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
149 |
if ( $dh = @opendir($dir) ) |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
150 |
{ |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
151 |
while ( ( $file = @readdir($dh) ) !== false ) |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
152 |
{ |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
153 |
if ( preg_match('/\.css$/', $file) ) |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
154 |
$theme['css'][] = preg_replace('/\.css$/', '', $file); |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
155 |
} |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
156 |
closedir($dh); |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
157 |
} |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
158 |
// No CSS files? If so, nuke it. |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
159 |
if ( count($theme['css']) < 1 ) |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
160 |
{ |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
161 |
unset($this->theme_list[$i]); |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
162 |
} |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
163 |
} |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
164 |
$this->theme_list = array_values($this->theme_list); |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
165 |
// Create associative array of themes |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
166 |
foreach ( $this->theme_list as $i => &$theme ) |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
167 |
$this->named_theme_list[ $theme['theme_id'] ] =& $this->theme_list[$i]; |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
168 |
|
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
169 |
$this->default_theme = ( $_ = getConfig('theme_default') ) ? $_ : $this->theme_list[0]['theme_id']; |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
170 |
// Come up with the default style. If the CSS file specified in default_style exists, we're good, just |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
171 |
// use that. Otherwise, use the first stylesheet that comes to mind. |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
172 |
$df_data =& $this->named_theme_list[ $this->default_theme ]; |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
173 |
$this->default_style = ( in_array($df_data['default_style'], $df_data['css']) ) ? $df_data['default_style'] : $df_data['css'][0]; |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
174 |
} |
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
175 |
|
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
176 |
/** |
471
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
177 |
* Systematically deletes themes if they're blocked by theme security settings. Called when session->start() finishes. |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
178 |
*/ |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
179 |
|
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
180 |
function process_theme_acls() |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
181 |
{ |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
182 |
global $db, $session, $paths, $template, $plugins; // Common objects |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
183 |
|
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
184 |
// For each theme, check ACLs and delete from RAM if not authorized |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
185 |
foreach ( $this->theme_list as $i => $theme ) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
186 |
{ |
488
5560ff856dd7
Oops: fixed broken template loader in upgrader for 1.0.x and 1.1.1
Dan
parents:
484
diff
changeset
|
187 |
if ( !@$theme['group_list'] ) |
471
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
188 |
continue; |
472
bc4b58034f4d
Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents:
471
diff
changeset
|
189 |
if ( $theme['theme_id'] === getConfig('theme_default') ) |
bc4b58034f4d
Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents:
471
diff
changeset
|
190 |
continue; |
471
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
191 |
switch ( $theme['group_policy'] ) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
192 |
{ |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
193 |
case 'allow_all': |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
194 |
// Unconditionally allowed |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
195 |
continue; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
196 |
break; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
197 |
case 'whitelist': |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
198 |
// If we're not on the list, off to the left please |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
199 |
$list = enano_json_decode($theme['group_list']); |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
200 |
$allowed = false; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
201 |
foreach ( $list as $acl ) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
202 |
{ |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
203 |
if ( !preg_match('/^(u|g):([0-9]+)$/', $acl, $match) ) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
204 |
// Invalid list entry, silently allow (maybe not a good idea but |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
205 |
// really, these things are checked before they're inserted) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
206 |
continue 2; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
207 |
$mode = $match[1]; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
208 |
$id = intval($match[2]); |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
209 |
switch ( $mode ) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
210 |
{ |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
211 |
case 'u': |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
212 |
$allowed = ( $id == $session->user_id ); |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
213 |
if ( $allowed ) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
214 |
break 2; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
215 |
break; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
216 |
case 'g': |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
217 |
$allowed = ( isset($session->groups[$id]) ); |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
218 |
if ( $allowed ) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
219 |
break 2; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
220 |
} |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
221 |
} |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
222 |
if ( !$allowed ) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
223 |
{ |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
224 |
unset($this->theme_list[$i]); |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
225 |
} |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
226 |
break; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
227 |
case 'blacklist': |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
228 |
// If we're ON the list, off to the left please |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
229 |
$list = enano_json_decode($theme['group_list']); |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
230 |
$allowed = true; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
231 |
foreach ( $list as $acl ) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
232 |
{ |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
233 |
if ( !preg_match('/^(u|g):([0-9]+)$/', $acl, $match) ) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
234 |
// Invalid list entry, silently allow (maybe not a good idea but |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
235 |
// really, these things are checked before they're inserted) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
236 |
continue 2; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
237 |
$mode = $match[1]; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
238 |
$id = intval($match[2]); |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
239 |
switch ( $mode ) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
240 |
{ |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
241 |
case 'u': |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
242 |
$allowed = ( $id != $session->user_id ); |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
243 |
if ( !$allowed ) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
244 |
break 2; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
245 |
break; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
246 |
case 'g': |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
247 |
$allowed = ( !isset($session->groups[$id]) ); |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
248 |
if ( !$allowed ) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
249 |
break 2; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
250 |
} |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
251 |
} |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
252 |
if ( !$allowed ) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
253 |
{ |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
254 |
unset($this->theme_list[$i]); |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
255 |
} |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
256 |
break; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
257 |
} |
1 | 258 |
} |
259 |
||
471
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
260 |
$this->theme_list = array_values($this->theme_list); |
1 | 261 |
|
471
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
262 |
// Rebuild associative theme list |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
263 |
$this->named_theme_list = array(); |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
264 |
foreach ( $this->theme_list as $i => &$theme ) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
265 |
$this->named_theme_list[ $theme['theme_id'] ] =& $this->theme_list[$i]; |
1 | 266 |
} |
471
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
267 |
|
419
b8b4e38825db
Unsuccessful attempt at fixing "dismiss"/"close manager" buttons in ACL editor; non-breaking change to template API to allow plugins to add "normal" sidebar widgets in addition to the special "raw" block type, specified as the third parameter to $template->sidebar_widget(). Defaults to false, which is old behavior; new behavior (enabled by passing TRUE as the 3rd param) means that the content of the block is primarily block-level links.
Dan
parents:
413
diff
changeset
|
268 |
function sidebar_widget($t, $h, $use_normal_section = false) |
1 | 269 |
{ |
270 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
271 |
if(!defined('ENANO_TEMPLATE_LOADED')) |
|
272 |
{ |
|
273 |
$this->load_theme($session->theme, $session->style); |
|
274 |
} |
|
275 |
if(!$this->sidebar_widgets) |
|
276 |
$this->sidebar_widgets = ''; |
|
277 |
$tplvars = $this->extract_vars('elements.tpl'); |
|
419
b8b4e38825db
Unsuccessful attempt at fixing "dismiss"/"close manager" buttons in ACL editor; non-breaking change to template API to allow plugins to add "normal" sidebar widgets in addition to the special "raw" block type, specified as the third parameter to $template->sidebar_widget(). Defaults to false, which is old behavior; new behavior (enabled by passing TRUE as the 3rd param) means that the content of the block is primarily block-level links.
Dan
parents:
413
diff
changeset
|
278 |
|
b8b4e38825db
Unsuccessful attempt at fixing "dismiss"/"close manager" buttons in ACL editor; non-breaking change to template API to allow plugins to add "normal" sidebar widgets in addition to the special "raw" block type, specified as the third parameter to $template->sidebar_widget(). Defaults to false, which is old behavior; new behavior (enabled by passing TRUE as the 3rd param) means that the content of the block is primarily block-level links.
Dan
parents:
413
diff
changeset
|
279 |
if ( $use_normal_section ) |
b8b4e38825db
Unsuccessful attempt at fixing "dismiss"/"close manager" buttons in ACL editor; non-breaking change to template API to allow plugins to add "normal" sidebar widgets in addition to the special "raw" block type, specified as the third parameter to $template->sidebar_widget(). Defaults to false, which is old behavior; new behavior (enabled by passing TRUE as the 3rd param) means that the content of the block is primarily block-level links.
Dan
parents:
413
diff
changeset
|
280 |
{ |
b8b4e38825db
Unsuccessful attempt at fixing "dismiss"/"close manager" buttons in ACL editor; non-breaking change to template API to allow plugins to add "normal" sidebar widgets in addition to the special "raw" block type, specified as the third parameter to $template->sidebar_widget(). Defaults to false, which is old behavior; new behavior (enabled by passing TRUE as the 3rd param) means that the content of the block is primarily block-level links.
Dan
parents:
413
diff
changeset
|
281 |
$parser = $this->makeParserText($tplvars['sidebar_section']); |
b8b4e38825db
Unsuccessful attempt at fixing "dismiss"/"close manager" buttons in ACL editor; non-breaking change to template API to allow plugins to add "normal" sidebar widgets in addition to the special "raw" block type, specified as the third parameter to $template->sidebar_widget(). Defaults to false, which is old behavior; new behavior (enabled by passing TRUE as the 3rd param) means that the content of the block is primarily block-level links.
Dan
parents:
413
diff
changeset
|
282 |
} |
b8b4e38825db
Unsuccessful attempt at fixing "dismiss"/"close manager" buttons in ACL editor; non-breaking change to template API to allow plugins to add "normal" sidebar widgets in addition to the special "raw" block type, specified as the third parameter to $template->sidebar_widget(). Defaults to false, which is old behavior; new behavior (enabled by passing TRUE as the 3rd param) means that the content of the block is primarily block-level links.
Dan
parents:
413
diff
changeset
|
283 |
else |
b8b4e38825db
Unsuccessful attempt at fixing "dismiss"/"close manager" buttons in ACL editor; non-breaking change to template API to allow plugins to add "normal" sidebar widgets in addition to the special "raw" block type, specified as the third parameter to $template->sidebar_widget(). Defaults to false, which is old behavior; new behavior (enabled by passing TRUE as the 3rd param) means that the content of the block is primarily block-level links.
Dan
parents:
413
diff
changeset
|
284 |
{ |
b8b4e38825db
Unsuccessful attempt at fixing "dismiss"/"close manager" buttons in ACL editor; non-breaking change to template API to allow plugins to add "normal" sidebar widgets in addition to the special "raw" block type, specified as the third parameter to $template->sidebar_widget(). Defaults to false, which is old behavior; new behavior (enabled by passing TRUE as the 3rd param) means that the content of the block is primarily block-level links.
Dan
parents:
413
diff
changeset
|
285 |
$parser = $this->makeParserText($tplvars['sidebar_section_raw']); |
b8b4e38825db
Unsuccessful attempt at fixing "dismiss"/"close manager" buttons in ACL editor; non-breaking change to template API to allow plugins to add "normal" sidebar widgets in addition to the special "raw" block type, specified as the third parameter to $template->sidebar_widget(). Defaults to false, which is old behavior; new behavior (enabled by passing TRUE as the 3rd param) means that the content of the block is primarily block-level links.
Dan
parents:
413
diff
changeset
|
286 |
} |
b8b4e38825db
Unsuccessful attempt at fixing "dismiss"/"close manager" buttons in ACL editor; non-breaking change to template API to allow plugins to add "normal" sidebar widgets in addition to the special "raw" block type, specified as the third parameter to $template->sidebar_widget(). Defaults to false, which is old behavior; new behavior (enabled by passing TRUE as the 3rd param) means that the content of the block is primarily block-level links.
Dan
parents:
413
diff
changeset
|
287 |
|
b8b4e38825db
Unsuccessful attempt at fixing "dismiss"/"close manager" buttons in ACL editor; non-breaking change to template API to allow plugins to add "normal" sidebar widgets in addition to the special "raw" block type, specified as the third parameter to $template->sidebar_widget(). Defaults to false, which is old behavior; new behavior (enabled by passing TRUE as the 3rd param) means that the content of the block is primarily block-level links.
Dan
parents:
413
diff
changeset
|
288 |
$parser->assign_vars(Array('TITLE' => '{TITLE}','CONTENT' => $h)); |
b8b4e38825db
Unsuccessful attempt at fixing "dismiss"/"close manager" buttons in ACL editor; non-breaking change to template API to allow plugins to add "normal" sidebar widgets in addition to the special "raw" block type, specified as the third parameter to $template->sidebar_widget(). Defaults to false, which is old behavior; new behavior (enabled by passing TRUE as the 3rd param) means that the content of the block is primarily block-level links.
Dan
parents:
413
diff
changeset
|
289 |
$this->plugin_blocks[$t] = $parser->run(); |
1 | 290 |
$this->sidebar_widgets .= $parser->run(); |
291 |
} |
|
292 |
function add_header($html) |
|
293 |
{ |
|
294 |
$this->additional_headers .= "\n" . $html; |
|
295 |
} |
|
296 |
function get_css($s = false) |
|
297 |
{ |
|
298 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
299 |
if(!defined('ENANO_TEMPLATE_LOADED')) |
|
300 |
$this->load_theme($session->theme, $session->style); |
|
301 |
$path = ( $s ) ? 'css/'.$s : 'css/'.$this->style.'.css'; |
|
302 |
if ( !file_exists(ENANO_ROOT . '/themes/' . $this->theme . '/' . $path) ) |
|
303 |
{ |
|
304 |
echo "/* WARNING: Falling back to default file because file $path does not exist */\n"; |
|
305 |
$path = 'css/' . $this->style_list[0] . '.css'; |
|
306 |
} |
|
471
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
307 |
return '<enano:no-opt>' . $this->process_template($path) . '</enano:no-opt>'; |
1 | 308 |
} |
309 |
function load_theme($name = false, $css = false) |
|
310 |
{ |
|
311 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
312 |
$this->theme = ( $name ) ? $name : $session->theme; |
|
313 |
$this->style = ( $css ) ? $css : $session->style; |
|
314 |
if ( !$this->theme ) |
|
315 |
{ |
|
316 |
$this->theme = $this->theme_list[0]['theme_id']; |
|
468
194a19711346
Fixed the fact that cron just didn't work at all (brain fart that day or something)
Dan
parents:
458
diff
changeset
|
317 |
$this->style = preg_replace('/\.css$/', '', $this->theme_list[0]['default_style']); |
1 | 318 |
} |
471
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
319 |
// Make sure we're allowed to use this theme. |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
320 |
if ( ( |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
321 |
// If it was removed, it's probably blocked by an ACL, or it was uninstalled |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
322 |
!isset($this->named_theme_list[$this->theme]) || |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
323 |
// Check if the theme is disabled |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
324 |
( isset($this->named_theme_list[$this->theme]) && $this->named_theme_list[$this->theme]['enabled'] == 0 ) ) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
325 |
// Above all, if it's a system theme, don't inhibit the loading process. |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
326 |
&& !in_array($this->theme, $this->system_themes) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
327 |
) |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
328 |
{ |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
329 |
// No, something is preventing it - fall back to site default |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
330 |
$this->theme = $this->default_theme; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
331 |
|
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
332 |
// Come up with the default style. If the CSS file specified in default_style exists, we're good, just |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
333 |
// use that. Otherwise, use the first stylesheet that comes to mind. |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
334 |
$df_data =& $this->named_theme_list[ $this->theme ]; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
335 |
$this->style = ( in_array($df_data['default_style'], $df_data['css']) ) ? $df_data['default_style'] : $df_data['css'][0]; |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
336 |
} |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
337 |
// The list of styles for the currently selected theme |
7906fb190fc1
Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents:
468
diff
changeset
|
338 |
$this->style_list =& $this->named_theme_list[ $this->theme ]['css']; |
1 | 339 |
$this->theme_loaded = true; |
340 |
} |
|
341 |
||
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
342 |
/** |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
343 |
* Initializes all variables related to on-page content. This includes sidebars and what have you. |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
344 |
* @param object Optional PageProcessor object to use for passing metadata and permissions on. If omitted, uses information from $paths and $session. |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
345 |
*/ |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
346 |
|
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
347 |
function init_vars($page = false) |
1 | 348 |
{ |
349 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
350 |
global $email; |
|
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
208
diff
changeset
|
351 |
global $lang; |
1 | 352 |
|
372
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
353 |
profiler_log("template: starting var init"); |
1 | 354 |
|
355 |
if(!$this->theme || !$this->style) |
|
356 |
{ |
|
357 |
$this->load_theme(); |
|
358 |
} |
|
359 |
||
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
360 |
if ( defined('ENANO_TEMPLATE_LOADED') ) |
1 | 361 |
{ |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
362 |
// trigger_error("\$template->init_vars() called more than once", E_USER_WARNING); |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
363 |
// die_semicritical('Illegal call', '<p>$template->init_vars() was called multiple times, this is not supposed to happen. Exiting with fatal error.</p>'); |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
364 |
} |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
365 |
else |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
366 |
{ |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
367 |
@define('ENANO_TEMPLATE_LOADED', ''); |
1 | 368 |
} |
369 |
||
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
370 |
if ( is_object($page) && @get_class($page) == 'PageProcessor' ) |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
371 |
{ |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
372 |
$page_append = substr($paths->fullpage, strlen($paths->page)); |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
373 |
if ( isset($paths->nslist[$page->namespace]) ) |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
374 |
{ |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
375 |
$local_page = $paths->nslist[$page->namespace] . $page->page_id; |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
376 |
} |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
377 |
else |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
378 |
{ |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
379 |
$local_page = $page->namespace . substr($paths->nslist['Special'], -1) . $page->page_id . $page_append; |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
380 |
} |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
381 |
$local_fullpage = $local_page . $page_append; |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
382 |
$local_page_id =& $page->page_id; |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
383 |
$local_namespace =& $page->namespace; |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
384 |
$perms =& $page->perms; |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
385 |
} |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
386 |
else |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
387 |
{ |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
388 |
$local_page =& $paths->page; |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
389 |
$local_page_id =& $paths->page_id; |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
390 |
$local_fullpage =& $paths->fullpage; |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
391 |
$local_namespace =& $paths->namespace; |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
392 |
$perms =& $session; |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
393 |
} |
1 | 394 |
|
395 |
$tplvars = $this->extract_vars('elements.tpl'); |
|
396 |
||
397 |
if(isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) |
|
398 |
{ |
|
399 |
$this->add_header(' |
|
400 |
<!--[if lt IE 7]> |
|
401 |
<script language="JavaScript"> |
|
402 |
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6. |
|
403 |
{ |
|
86
c162ca39db8f
Finished pagination code (was incomplete in previous revision) and added a few hacks for an upcoming theme
Dan
parents:
85
diff
changeset
|
404 |
var arVersion = navigator.appVersion.split("MSIE"); |
c162ca39db8f
Finished pagination code (was incomplete in previous revision) and added a few hacks for an upcoming theme
Dan
parents:
85
diff
changeset
|
405 |
var version = parseFloat(arVersion[1]); |
1 | 406 |
if (version >= 5.5 && typeof(document.body.filters) == "object") |
407 |
{ |
|
408 |
for(var i=0; i<document.images.length; i++) |
|
409 |
{ |
|
410 |
var img = document.images[i]; |
|
411 |
continue; |
|
412 |
var imgName = img.src.toUpperCase(); |
|
413 |
if (imgName.substring(imgName.length-3, imgName.length) == "PNG") |
|
414 |
{ |
|
415 |
var imgID = (img.id) ? "id=\'" + img.id + "\' " : ""; |
|
416 |
var imgClass = (img.className) ? "class=\'" + img.className + "\' " : ""; |
|
417 |
var imgTitle = (img.title) ? "title=\'" + img.title + "\' " : "title=\'" + img.alt + "\' "; |
|
418 |
var imgStyle = "display:inline-block;" + img.style.cssText; |
|
419 |
if (img.align == "left") imgStyle = "float:left;" + imgStyle; |
|
420 |
if (img.align == "right") imgStyle = "float:right;" + imgStyle; |
|
421 |
if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle; |
|
422 |
var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\\\'" + img.src + "\\\', sizingMethod=\'scale\');\\"></span>"; |
|
423 |
img.outerHTML = strNewHTML; |
|
424 |
i = i-1; |
|
425 |
} |
|
426 |
} |
|
427 |
} |
|
428 |
} |
|
429 |
window.attachEvent("onload", correctPNG); |
|
430 |
</script> |
|
431 |
<![endif]--> |
|
432 |
'); |
|
433 |
} |
|
434 |
||
435 |
// Get the "article" button text (depends on namespace) |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
436 |
switch($local_namespace) { |
1 | 437 |
case "Article": |
438 |
default: |
|
211 | 439 |
$ns = $lang->get('onpage_lbl_page_article'); |
1 | 440 |
break; |
441 |
case "Admin": |
|
211 | 442 |
$ns = $lang->get('onpage_lbl_page_admin'); |
1 | 443 |
break; |
444 |
case "System": |
|
211 | 445 |
$ns = $lang->get('onpage_lbl_page_system'); |
1 | 446 |
break; |
447 |
case "File": |
|
211 | 448 |
$ns = $lang->get('onpage_lbl_page_file'); |
1 | 449 |
break; |
450 |
case "Help": |
|
211 | 451 |
$ns = $lang->get('onpage_lbl_page_help'); |
1 | 452 |
break; |
453 |
case "User": |
|
211 | 454 |
$ns = $lang->get('onpage_lbl_page_user'); |
1 | 455 |
break; |
456 |
case "Special": |
|
211 | 457 |
$ns = $lang->get('onpage_lbl_page_special'); |
1 | 458 |
break; |
459 |
case "Template": |
|
211 | 460 |
$ns = $lang->get('onpage_lbl_page_template'); |
1 | 461 |
break; |
462 |
case "Project": |
|
211 | 463 |
$ns = $lang->get('onpage_lbl_page_project'); |
1 | 464 |
break; |
465 |
case "Category": |
|
211 | 466 |
$ns = $lang->get('onpage_lbl_page_category'); |
1 | 467 |
break; |
312
6c7060d36a23
Improved physical pages: they support comments and have their own dedicated namespace now. Still some consistency fixes to make.
Dan
parents:
311
diff
changeset
|
468 |
case "Anonymous": |
6c7060d36a23
Improved physical pages: they support comments and have their own dedicated namespace now. Still some consistency fixes to make.
Dan
parents:
311
diff
changeset
|
469 |
$ns = 'external page'; |
6c7060d36a23
Improved physical pages: they support comments and have their own dedicated namespace now. Still some consistency fixes to make.
Dan
parents:
311
diff
changeset
|
470 |
break; |
1 | 471 |
} |
472 |
$this->namespace_string = $ns; |
|
211 | 473 |
unset($ns); |
1 | 474 |
$code = $plugins->setHook('page_type_string_set'); |
475 |
foreach ( $code as $cmd ) |
|
476 |
{ |
|
477 |
eval($cmd); |
|
478 |
} |
|
479 |
$ns =& $this->namespace_string; |
|
480 |
||
481 |
// Initialize the toolbar |
|
482 |
$tb = ''; |
|
483 |
||
484 |
// Create "xx page" button |
|
485 |
||
486 |
$btn_selected = ( isset($tplvars['toolbar_button_selected'])) ? $tplvars['toolbar_button_selected'] : $tplvars['toolbar_button']; |
|
487 |
$parser = $this->makeParserText($btn_selected); |
|
488 |
||
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
489 |
$parser->assign_vars(array( |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
490 |
'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxReset()); return false; }" title="' . $lang->get('onpage_tip_article') . '" accesskey="a"', |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
491 |
'PARENTFLAGS' => 'id="mdgToolbar_article"', |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
492 |
'HREF' => makeUrl($local_page, null, true), |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
493 |
'TEXT' => $this->namespace_string |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
494 |
)); |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
495 |
|
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
496 |
$tb .= $parser->run(); |
1 | 497 |
|
498 |
$button = $this->makeParserText($tplvars['toolbar_button']); |
|
499 |
||
500 |
// Page toolbar |
|
501 |
// Comments button |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
502 |
if ( $perms->get_permissions('read') && getConfig('enable_comments')=='1' && $local_namespace != 'Special' && $local_namespace != 'Admin' && $paths->cpage['comments_on'] == 1 ) |
1 | 503 |
{ |
504 |
||
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
505 |
$e = $db->sql_query('SELECT approved FROM '.table_prefix.'comments WHERE page_id=\''.$local_page_id.'\' AND namespace=\''.$local_namespace.'\';'); |
1 | 506 |
if ( !$e ) |
507 |
{ |
|
508 |
$db->_die(); |
|
509 |
} |
|
510 |
$nc = $db->numrows(); |
|
511 |
$nu = 0; |
|
512 |
$na = 0; |
|
513 |
||
514 |
while ( $r = $db->fetchrow() ) |
|
515 |
{ |
|
516 |
if ( !$r['approved'] ) |
|
517 |
{ |
|
518 |
$nu++; |
|
519 |
} |
|
520 |
else |
|
521 |
{ |
|
522 |
$na++; |
|
523 |
} |
|
524 |
} |
|
525 |
||
526 |
$db->free_result(); |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
527 |
$n = ( $perms->get_permissions('mod_comments') ) ? (string)$nc : (string)$na; |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
528 |
if ( $perms->get_permissions('mod_comments') && $nu > 0 ) |
1 | 529 |
{ |
211 | 530 |
$subst = array( |
531 |
'num_comments' => $nc, |
|
532 |
'num_unapp' => $nu |
|
533 |
); |
|
534 |
$btn_text = $lang->get('onpage_btn_discussion_unapp', $subst); |
|
535 |
} |
|
536 |
else |
|
537 |
{ |
|
538 |
$subst = array( |
|
539 |
'num_comments' => $nc |
|
540 |
); |
|
541 |
$btn_text = $lang->get('onpage_btn_discussion', $subst); |
|
1 | 542 |
} |
543 |
||
544 |
$button->assign_vars(array( |
|
265
7e0cdf71b1bb
Some (not much) progress with localizing tooltips on the pagebar. Still aways to go and committing so as to merge changes from stable
Dan
parents:
248
diff
changeset
|
545 |
'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxComments()); return false; }" title="' . $lang->get('onpage_tip_comments') . '" accesskey="c"', |
1 | 546 |
'PARENTFLAGS' => 'id="mdgToolbar_discussion"', |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
547 |
'HREF' => makeUrl($local_page, 'do=comments', true), |
211 | 548 |
'TEXT' => $btn_text, |
1 | 549 |
)); |
550 |
||
551 |
$tb .= $button->run(); |
|
552 |
} |
|
553 |
// Edit button |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
554 |
if($perms->get_permissions('read') && ($local_namespace != 'Special' && $local_namespace != 'Admin' && $local_namespace != 'Anonymous') && ( $perms->get_permissions('edit_page') && ( ( $paths->page_protected && $perms->get_permissions('even_when_protected') ) || !$paths->page_protected ) ) ) |
1 | 555 |
{ |
556 |
$button->assign_vars(array( |
|
265
7e0cdf71b1bb
Some (not much) progress with localizing tooltips on the pagebar. Still aways to go and committing so as to merge changes from stable
Dan
parents:
248
diff
changeset
|
557 |
'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxEditor()); return false; }" title="' . $lang->get('onpage_tip_edit') . '" accesskey="e"', |
1 | 558 |
'PARENTFLAGS' => 'id="mdgToolbar_edit"', |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
559 |
'HREF' => makeUrl($local_page, 'do=edit', true), |
211 | 560 |
'TEXT' => $lang->get('onpage_btn_edit') |
1 | 561 |
)); |
562 |
$tb .= $button->run(); |
|
563 |
// View source button |
|
564 |
} |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
565 |
else if($perms->get_permissions('view_source') && ( !$perms->get_permissions('edit_page') || !$perms->get_permissions('even_when_protected') && $paths->page_protected ) && $local_namespace != 'Special' && $local_namespace != 'Admin' && $local_namespace != 'Anonymous') |
1 | 566 |
{ |
567 |
$button->assign_vars(array( |
|
335
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents:
326
diff
changeset
|
568 |
'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxEditor()); return false; }" title="' . $lang->get('onpage_tip_viewsource') . '" accesskey="e"', |
1 | 569 |
'PARENTFLAGS' => 'id="mdgToolbar_edit"', |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
570 |
'HREF' => makeUrl($local_page, 'do=viewsource', true), |
211 | 571 |
'TEXT' => $lang->get('onpage_btn_viewsource') |
1 | 572 |
)); |
573 |
$tb .= $button->run(); |
|
574 |
} |
|
575 |
// History button |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
576 |
if ( $perms->get_permissions('read') /* && $paths->wiki_mode */ && $paths->page_exists && $local_namespace != 'Special' && $local_namespace != 'Admin' && $perms->get_permissions('history_view') ) |
1 | 577 |
{ |
578 |
$button->assign_vars(array( |
|
265
7e0cdf71b1bb
Some (not much) progress with localizing tooltips on the pagebar. Still aways to go and committing so as to merge changes from stable
Dan
parents:
248
diff
changeset
|
579 |
'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxHistory()); return false; }" title="' . $lang->get('onpage_tip_history') . '" accesskey="h"', |
1 | 580 |
'PARENTFLAGS' => 'id="mdgToolbar_history"', |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
581 |
'HREF' => makeUrl($local_page, 'do=history', true), |
211 | 582 |
'TEXT' => $lang->get('onpage_btn_history') |
1 | 583 |
)); |
584 |
$tb .= $button->run(); |
|
585 |
} |
|
586 |
||
587 |
$menubtn = $this->makeParserText($tplvars['toolbar_menu_button']); |
|
588 |
||
589 |
// Additional actions menu |
|
590 |
// Rename button |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
591 |
if ( $perms->get_permissions('read') && $paths->page_exists && ( $perms->get_permissions('rename') && ( $paths->page_protected && $perms->get_permissions('even_when_protected') || !$paths->page_protected ) ) && $local_namespace != 'Special' && $local_namespace != 'Admin' ) |
1 | 592 |
{ |
593 |
$menubtn->assign_vars(array( |
|
265
7e0cdf71b1bb
Some (not much) progress with localizing tooltips on the pagebar. Still aways to go and committing so as to merge changes from stable
Dan
parents:
248
diff
changeset
|
594 |
'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxRename()); return false; }" title="' . $lang->get('onpage_tip_rename') . '" accesskey="r"', |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
595 |
'HREF' => makeUrl($local_page, 'do=rename', true), |
211 | 596 |
'TEXT' => $lang->get('onpage_btn_rename'), |
1 | 597 |
)); |
598 |
$this->toolbar_menu .= $menubtn->run(); |
|
599 |
} |
|
600 |
||
601 |
// Vote-to-delete button |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
602 |
if ( $paths->wiki_mode && $perms->get_permissions('vote_delete') && $paths->page_exists && $local_namespace != 'Special' && $local_namespace != 'Admin') |
1 | 603 |
{ |
604 |
$menubtn->assign_vars(array( |
|
265
7e0cdf71b1bb
Some (not much) progress with localizing tooltips on the pagebar. Still aways to go and committing so as to merge changes from stable
Dan
parents:
248
diff
changeset
|
605 |
'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxDelVote()); return false; }" title="' . $lang->get('onpage_tip_delvote') . '" accesskey="d"', |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
606 |
'HREF' => makeUrl($local_page, 'do=delvote', true), |
211 | 607 |
'TEXT' => $lang->get('onpage_btn_votedelete'), |
1 | 608 |
)); |
609 |
$this->toolbar_menu .= $menubtn->run(); |
|
610 |
} |
|
611 |
||
612 |
// Clear-votes button |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
613 |
if ( $perms->get_permissions('read') && $paths->wiki_mode && $paths->page_exists && $local_namespace != 'Special' && $local_namespace != 'Admin' && $perms->get_permissions('vote_reset') && $paths->cpage['delvotes'] > 0) |
1 | 614 |
{ |
615 |
$menubtn->assign_vars(array( |
|
265
7e0cdf71b1bb
Some (not much) progress with localizing tooltips on the pagebar. Still aways to go and committing so as to merge changes from stable
Dan
parents:
248
diff
changeset
|
616 |
'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxResetDelVotes()); return false; }" title="' . $lang->get('onpage_tip_resetvotes') . '" accesskey="y"', |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
617 |
'HREF' => makeUrl($local_page, 'do=resetvotes', true), |
211 | 618 |
'TEXT' => $lang->get('onpage_btn_votedelete_reset'), |
1 | 619 |
)); |
620 |
$this->toolbar_menu .= $menubtn->run(); |
|
621 |
} |
|
622 |
||
623 |
// Printable page button |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
624 |
if ( $paths->page_exists && $local_namespace != 'Special' && $local_namespace != 'Admin' ) |
1 | 625 |
{ |
626 |
$menubtn->assign_vars(array( |
|
265
7e0cdf71b1bb
Some (not much) progress with localizing tooltips on the pagebar. Still aways to go and committing so as to merge changes from stable
Dan
parents:
248
diff
changeset
|
627 |
'FLAGS' => 'title="' . $lang->get('onpage_tip_printable') . '"', |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
628 |
'HREF' => makeUrl($local_page, 'printable=yes', true), |
211 | 629 |
'TEXT' => $lang->get('onpage_btn_printable'), |
1 | 630 |
)); |
631 |
$this->toolbar_menu .= $menubtn->run(); |
|
632 |
} |
|
633 |
||
634 |
// Protect button |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
635 |
if($perms->get_permissions('read') && $paths->wiki_mode && $paths->page_exists && $local_namespace != 'Special' && $local_namespace != 'Admin' && $perms->get_permissions('protect')) |
1 | 636 |
{ |
637 |
||
638 |
$label = $this->makeParserText($tplvars['toolbar_label']); |
|
211 | 639 |
$label->assign_vars(array('TEXT' => $lang->get('onpage_lbl_protect'))); |
1 | 640 |
$t0 = $label->run(); |
641 |
||
642 |
$ctmp = ''; |
|
643 |
if ( $paths->cpage['protected'] == 1 ) |
|
644 |
{ |
|
645 |
$ctmp=' style="text-decoration: underline;"'; |
|
646 |
} |
|
647 |
$menubtn->assign_vars(array( |
|
265
7e0cdf71b1bb
Some (not much) progress with localizing tooltips on the pagebar. Still aways to go and committing so as to merge changes from stable
Dan
parents:
248
diff
changeset
|
648 |
'FLAGS' => 'accesskey="i" onclick="if ( !KILL_SWITCH ) { ajaxProtect(1); return false; }" id="protbtn_1" title="' . $lang->get('onpage_tip_protect_on') . '"'.$ctmp, |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
649 |
'HREF' => makeUrl($local_page, 'do=protect&level=1', true), |
211 | 650 |
'TEXT' => $lang->get('onpage_btn_protect_on') |
1 | 651 |
)); |
652 |
$t1 = $menubtn->run(); |
|
653 |
||
654 |
$ctmp = ''; |
|
655 |
if ( $paths->cpage['protected'] == 0 ) |
|
656 |
{ |
|
657 |
$ctmp=' style="text-decoration: underline;"'; |
|
658 |
} |
|
659 |
$menubtn->assign_vars(array( |
|
265
7e0cdf71b1bb
Some (not much) progress with localizing tooltips on the pagebar. Still aways to go and committing so as to merge changes from stable
Dan
parents:
248
diff
changeset
|
660 |
'FLAGS' => 'accesskey="o" onclick="if ( !KILL_SWITCH ) { ajaxProtect(0); return false; }" id="protbtn_0" title="' . $lang->get('onpage_tip_protect_off') . '"'.$ctmp, |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
661 |
'HREF' => makeUrl($local_page, 'do=protect&level=0', true), |
211 | 662 |
'TEXT' => $lang->get('onpage_btn_protect_off') |
1 | 663 |
)); |
664 |
$t2 = $menubtn->run(); |
|
665 |
||
666 |
$ctmp = ''; |
|
667 |
if ( $paths->cpage['protected'] == 2 ) |
|
668 |
{ |
|
669 |
$ctmp = ' style="text-decoration: underline;"'; |
|
670 |
} |
|
671 |
$menubtn->assign_vars(array( |
|
265
7e0cdf71b1bb
Some (not much) progress with localizing tooltips on the pagebar. Still aways to go and committing so as to merge changes from stable
Dan
parents:
248
diff
changeset
|
672 |
'FLAGS' => 'accesskey="p" onclick="if ( !KILL_SWITCH ) { ajaxProtect(2); return false; }" id="protbtn_2" title="' . $lang->get('onpage_tip_protect_semi') . '"'.$ctmp, |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
673 |
'HREF' => makeUrl($local_page, 'do=protect&level=2', true), |
211 | 674 |
'TEXT' => $lang->get('onpage_btn_protect_semi') |
1 | 675 |
)); |
676 |
$t3 = $menubtn->run(); |
|
677 |
||
678 |
$this->toolbar_menu .= ' <table border="0" cellspacing="0" cellpadding="0"> |
|
679 |
<tr> |
|
680 |
<td>'.$t0.'</td> |
|
681 |
<td>'.$t1.'</td> |
|
682 |
<td>'.$t2.'</td> |
|
683 |
<td>'.$t3.'</td> |
|
684 |
</tr> |
|
685 |
</table>'; |
|
686 |
} |
|
687 |
||
688 |
// Wiki mode button |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
689 |
if($perms->get_permissions('read') && $paths->page_exists && $perms->get_permissions('set_wiki_mode') && $local_namespace != 'Special' && $local_namespace != 'Admin') |
1 | 690 |
{ |
691 |
// label at start |
|
692 |
$label = $this->makeParserText($tplvars['toolbar_label']); |
|
211 | 693 |
$label->assign_vars(array('TEXT' => $lang->get('onpage_lbl_wikimode'))); |
1 | 694 |
$t0 = $label->run(); |
695 |
||
696 |
// on button |
|
697 |
$ctmp = ''; |
|
698 |
if ( $paths->cpage['wiki_mode'] == 1 ) |
|
699 |
{ |
|
700 |
$ctmp = ' style="text-decoration: underline;"'; |
|
701 |
} |
|
702 |
$menubtn->assign_vars(array( |
|
102
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
98
diff
changeset
|
703 |
'FLAGS' => /* 'onclick="if ( !KILL_SWITCH ) { ajaxSetWikiMode(1); return false; }" id="wikibtn_1" title="Forces wiki functions to be allowed on this page."'. */ $ctmp, |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
704 |
'HREF' => makeUrl($local_page, 'do=setwikimode&level=1', true), |
211 | 705 |
'TEXT' => $lang->get('onpage_btn_wikimode_on') |
1 | 706 |
)); |
707 |
$t1 = $menubtn->run(); |
|
708 |
||
709 |
// off button |
|
710 |
$ctmp = ''; |
|
711 |
if ( $paths->cpage['wiki_mode'] == 0 ) |
|
712 |
{ |
|
713 |
$ctmp=' style="text-decoration: underline;"'; |
|
714 |
} |
|
715 |
$menubtn->assign_vars(array( |
|
102
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
98
diff
changeset
|
716 |
'FLAGS' => /* 'onclick="if ( !KILL_SWITCH ) { ajaxSetWikiMode(0); return false; }" id="wikibtn_0" title="Forces wiki functions to be disabled on this page."'. */ $ctmp, |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
717 |
'HREF' => makeUrl($local_page, 'do=setwikimode&level=0', true), |
211 | 718 |
'TEXT' => $lang->get('onpage_btn_wikimode_off') |
1 | 719 |
)); |
720 |
$t2 = $menubtn->run(); |
|
721 |
||
722 |
// global button |
|
723 |
$ctmp = ''; |
|
724 |
if ( $paths->cpage['wiki_mode'] == 2 ) |
|
725 |
{ |
|
726 |
$ctmp=' style="text-decoration: underline;"'; |
|
727 |
} |
|
728 |
$menubtn->assign_vars(array( |
|
102
d807dcd7aed7
[comments] fixed edit button (source wasn't getting filled)
Dan
parents:
98
diff
changeset
|
729 |
'FLAGS' => /* 'onclick="if ( !KILL_SWITCH ) { ajaxSetWikiMode(2); return false; }" id="wikibtn_2" title="Causes this page to use the global wiki mode setting (default)"'. */ $ctmp, |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
730 |
'HREF' => makeUrl($local_page, 'do=setwikimode&level=2', true), |
211 | 731 |
'TEXT' => $lang->get('onpage_btn_wikimode_global') |
1 | 732 |
)); |
733 |
$t3 = $menubtn->run(); |
|
734 |
||
735 |
// Tack it onto the list of buttons that are already there... |
|
736 |
$this->toolbar_menu .= ' <table border="0" cellspacing="0" cellpadding="0"> |
|
737 |
<tr> |
|
738 |
<td>'.$t0.'</td> |
|
739 |
<td>'.$t1.'</td> |
|
740 |
<td>'.$t2.'</td> |
|
741 |
<td>'.$t3.'</td> |
|
742 |
</tr> |
|
743 |
</table>'; |
|
744 |
} |
|
745 |
||
746 |
// Clear logs button |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
747 |
if ( $perms->get_permissions('read') && $perms->get_permissions('clear_logs') && $local_namespace != 'Special' && $local_namespace != 'Admin' ) |
1 | 748 |
{ |
749 |
$menubtn->assign_vars(array( |
|
265
7e0cdf71b1bb
Some (not much) progress with localizing tooltips on the pagebar. Still aways to go and committing so as to merge changes from stable
Dan
parents:
248
diff
changeset
|
750 |
'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxClearLogs()); return false; }" title="' . $lang->get('onpage_tip_flushlogs') . '" accesskey="l"', |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
751 |
'HREF' => makeUrl($local_page, 'do=flushlogs', true), |
211 | 752 |
'TEXT' => $lang->get('onpage_btn_clearlogs'), |
1 | 753 |
)); |
754 |
$this->toolbar_menu .= $menubtn->run(); |
|
755 |
} |
|
756 |
||
757 |
// Delete page button |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
758 |
if ( $perms->get_permissions('read') && $perms->get_permissions('delete_page') && $paths->page_exists && $local_namespace != 'Special' && $local_namespace != 'Admin' ) |
1 | 759 |
{ |
211 | 760 |
$s = $lang->get('onpage_btn_deletepage'); |
1 | 761 |
if ( $paths->cpage['delvotes'] == 1 ) |
762 |
{ |
|
211 | 763 |
$subst = array( |
764 |
'num_votes' => $paths->cpage['delvotes'], |
|
765 |
'plural' => '' |
|
766 |
); |
|
767 |
$s .= $lang->get('onpage_btn_deletepage_votes', $subst); |
|
1 | 768 |
} |
769 |
else if ( $paths->cpage['delvotes'] > 1 ) |
|
770 |
{ |
|
211 | 771 |
$subst = array( |
772 |
'num_votes' => $paths->cpage['delvotes'], |
|
773 |
'plural' => $lang->get('meta_plural') |
|
774 |
); |
|
775 |
$s .= $lang->get('onpage_btn_deletepage_votes', $subst); |
|
1 | 776 |
} |
777 |
||
778 |
$menubtn->assign_vars(array( |
|
314
474f8be55943
Localized remainder of on-page tools and parts of PageProcess
Dan
parents:
313
diff
changeset
|
779 |
'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxDeletePage()); return false; }" title="' . $lang->get('onpage_tip_deletepage') . '" accesskey="k"', |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
780 |
'HREF' => makeUrl($local_page, 'do=deletepage', true), |
1 | 781 |
'TEXT' => $s, |
782 |
)); |
|
783 |
$this->toolbar_menu .= $menubtn->run(); |
|
784 |
||
785 |
} |
|
786 |
||
787 |
// Password-protect button |
|
788 |
if(isset($paths->cpage['password'])) |
|
789 |
{ |
|
790 |
if ( $paths->cpage['password'] == '' ) |
|
791 |
{ |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
792 |
$a = $perms->get_permissions('password_set'); |
1 | 793 |
} |
794 |
else |
|
795 |
{ |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
796 |
$a = $perms->get_permissions('password_reset'); |
1 | 797 |
} |
798 |
} |
|
799 |
else |
|
800 |
{ |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
801 |
$a = $perms->get_permissions('password_set'); |
1 | 802 |
} |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
803 |
if ( $a && $perms->get_permissions('read') && $paths->page_exists && $local_namespace != 'Special' && $local_namespace != 'Admin' ) |
1 | 804 |
{ |
805 |
// label at start |
|
806 |
$label = $this->makeParserText($tplvars['toolbar_label']); |
|
211 | 807 |
$label->assign_vars(array('TEXT' => $lang->get('onpage_lbl_password'))); |
1 | 808 |
$t0 = $label->run(); |
809 |
||
810 |
$menubtn->assign_vars(array( |
|
265
7e0cdf71b1bb
Some (not much) progress with localizing tooltips on the pagebar. Still aways to go and committing so as to merge changes from stable
Dan
parents:
248
diff
changeset
|
811 |
'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxSetPassword()); return false; }" title="' . $lang->get('onpage_tip_password') . '"', |
1 | 812 |
'HREF' => '#', |
211 | 813 |
'TEXT' => $lang->get('onpage_btn_password_set'), |
1 | 814 |
)); |
815 |
$t = $menubtn->run(); |
|
816 |
||
817 |
$this->toolbar_menu .= '<table border="0" cellspacing="0" cellpadding="0"><tr><td>'.$t0.'</td><td><input type="password" id="mdgPassSetField" size="10" /></td><td>'.$t.'</td></tr></table>'; |
|
818 |
} |
|
819 |
||
820 |
// Manage ACLs button |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
821 |
if ( !$paths->anonymous_page && ( $perms->get_permissions('edit_acl') || ( defined('ACL_ALWAYS_ALLOW_ADMIN_EDIT_ACL') && $session->user_level >= USER_LEVEL_ADMIN ) ) ) |
1 | 822 |
{ |
823 |
$menubtn->assign_vars(array( |
|
265
7e0cdf71b1bb
Some (not much) progress with localizing tooltips on the pagebar. Still aways to go and committing so as to merge changes from stable
Dan
parents:
248
diff
changeset
|
824 |
'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { return ajaxOpenACLManager(); }" title="' . $lang->get('onpage_tip_aclmanager') . '" accesskey="m"', |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
825 |
'HREF' => makeUrl($local_page, 'do=aclmanager', true), |
211 | 826 |
'TEXT' => $lang->get('onpage_btn_acl'), |
1 | 827 |
)); |
828 |
$this->toolbar_menu .= $menubtn->run(); |
|
829 |
} |
|
830 |
||
831 |
// Administer page button |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
832 |
if ( $session->user_level >= USER_LEVEL_ADMIN && $paths->page_exists && $local_namespace != 'Special' && $local_namespace != 'Admin' ) |
1 | 833 |
{ |
834 |
$menubtn->assign_vars(array( |
|
314
474f8be55943
Localized remainder of on-page tools and parts of PageProcess
Dan
parents:
313
diff
changeset
|
835 |
'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxAdminPage()); return false; }" title="' . $lang->get('onpage_tip_adminoptions') . '" accesskey="g"', |
1 | 836 |
'HREF' => makeUrlNS('Special', 'Administration', 'module='.$paths->nslist['Admin'].'PageManager', true), |
211 | 837 |
'TEXT' => $lang->get('onpage_btn_admin'), |
1 | 838 |
)); |
839 |
$this->toolbar_menu .= $menubtn->run(); |
|
840 |
} |
|
841 |
||
842 |
if ( strlen($this->toolbar_menu) > 0 ) |
|
843 |
{ |
|
844 |
$button->assign_vars(array( |
|
314
474f8be55943
Localized remainder of on-page tools and parts of PageProcess
Dan
parents:
313
diff
changeset
|
845 |
'FLAGS' => 'id="mdgToolbar_moreoptions" onclick="if ( !KILL_SWITCH ) { return false; }" title="' . $lang->get('onpage_tip_moreoptions') . '"', |
1 | 846 |
'PARENTFLAGS' => '', |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
847 |
'HREF' => makeUrl($local_page, 'do=moreoptions', true), |
211 | 848 |
'TEXT' => $lang->get('onpage_btn_moreoptions') |
1 | 849 |
)); |
850 |
$tb .= $button->run(); |
|
851 |
} |
|
852 |
||
853 |
$is_opera = (isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'], 'Opera')) ? true : false; |
|
854 |
||
855 |
$this->tpl_bool = Array( |
|
856 |
'auth_admin'=>$session->user_level >= USER_LEVEL_ADMIN ? true : false, |
|
857 |
'user_logged_in'=>$session->user_logged_in, |
|
858 |
'opera'=>$is_opera, |
|
859 |
); |
|
860 |
||
861 |
if($session->sid_super) { $ash = '&auth='.$session->sid_super; $asq = "?auth=".$session->sid_super; $asa = "&auth=".$session->sid_super; $as2 = htmlspecialchars(urlSeparator).'auth='.$session->sid_super; } |
|
862 |
else { $asq=''; $asa=''; $as2 = ''; $ash = ''; } |
|
863 |
||
864 |
$code = $plugins->setHook('compile_template'); |
|
865 |
foreach ( $code as $cmd ) |
|
866 |
{ |
|
867 |
eval($cmd); |
|
868 |
} |
|
869 |
||
870 |
// Some additional sidebar processing |
|
871 |
if($this->sidebar_extra != '') { |
|
872 |
$se = $this->sidebar_extra; |
|
873 |
$parser = $this->makeParserText($tplvars['sidebar_section_raw']); |
|
874 |
$parser->assign_vars(Array('TITLE'=>'Links','CONTENT'=>$se)); |
|
875 |
$this->sidebar_extra = $parser->run(); |
|
876 |
} |
|
877 |
||
878 |
$this->sidebar_extra = $this->sidebar_extra.$this->sidebar_widgets; |
|
879 |
||
880 |
$this->tpl_bool['fixed_menus'] = false; |
|
881 |
/* if($this->sidebar_extra == '') $this->tpl_bool['right_sidebar'] = false; |
|
882 |
else */ $this->tpl_bool['right_sidebar'] = true; |
|
883 |
||
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
884 |
$this->tpl_bool['auth_rename'] = ( $paths->page_exists && ( $perms->get_permissions('rename') && ( $paths->page_protected && $perms->get_permissions('even_when_protected') || !$paths->page_protected ) ) && $local_namespace != 'Special' && $local_namespace != 'Admin'); |
1 | 885 |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
886 |
$this->tpl_bool['enable_uploads'] = ( getConfig('enable_uploads') == '1' && $perms->get_permissions('upload_files') ) ? true : false; |
1 | 887 |
|
888 |
$this->tpl_bool['stupid_mode'] = false; |
|
889 |
||
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
890 |
$this->tpl_bool['in_admin'] = ( ( $local_page_id == 'Administration' && $local_namespace == 'Special' ) || $local_namespace == 'Admin' ); |
1 | 891 |
|
892 |
$p = ( isset($_GET['printable']) ) ? '/printable' : ''; |
|
893 |
||
894 |
// Add the e-mail address client code to the header |
|
895 |
$this->add_header($email->jscode()); |
|
896 |
||
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
208
diff
changeset
|
897 |
// Add language file |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
208
diff
changeset
|
898 |
$lang_uri = makeUrlNS('Special', 'LangExportJSON/' . $lang->lang_id, false, true); |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
208
diff
changeset
|
899 |
$this->add_header("<script type=\"text/javascript\" src=\"$lang_uri\"></script>"); |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
208
diff
changeset
|
900 |
|
1 | 901 |
// Generate the code for the Log out and Change theme sidebar buttons |
902 |
// Once again, the new template parsing system can be used here |
|
903 |
||
904 |
$parser = $this->makeParserText($tplvars['sidebar_button']); |
|
905 |
||
906 |
$parser->assign_vars(Array( |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
907 |
'HREF'=>makeUrlNS('Special', "Logout/{$session->csrf_token}/{$local_page}"), |
57
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
parents:
54
diff
changeset
|
908 |
'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { mb_logout(); return false; }"', |
215 | 909 |
'TEXT'=>$lang->get('sidebar_btn_logout'), |
1 | 910 |
)); |
911 |
||
912 |
$logout_link = $parser->run(); |
|
913 |
||
914 |
$parser->assign_vars(Array( |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
915 |
'HREF'=>makeUrlNS('Special', 'Login/' . $local_page), |
57
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
parents:
54
diff
changeset
|
916 |
'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { ajaxStartLogin(); return false; }"', |
215 | 917 |
'TEXT'=>$lang->get('sidebar_btn_login'), |
1 | 918 |
)); |
919 |
||
920 |
$login_link = $parser->run(); |
|
921 |
||
922 |
$parser->assign_vars(Array( |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
923 |
'HREF'=>makeUrlNS('Special', 'ChangeStyle/'.$local_page), |
57
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
parents:
54
diff
changeset
|
924 |
'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { ajaxChangeStyle(); return false; }"', |
215 | 925 |
'TEXT'=>$lang->get('sidebar_btn_changestyle'), |
1 | 926 |
)); |
927 |
||
928 |
$theme_link = $parser->run(); |
|
929 |
||
60
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
59
diff
changeset
|
930 |
$parser->assign_vars(Array( |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
59
diff
changeset
|
931 |
'HREF'=>makeUrlNS('Special', 'Administration'), |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
59
diff
changeset
|
932 |
'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { void(ajaxStartAdminLogin()); return false; }"', |
215 | 933 |
'TEXT'=>$lang->get('sidebar_btn_administration'), |
60
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
59
diff
changeset
|
934 |
)); |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
59
diff
changeset
|
935 |
|
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
59
diff
changeset
|
936 |
$admin_link = $parser->run(); |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
59
diff
changeset
|
937 |
|
1 | 938 |
$SID = ($session->sid_super) ? $session->sid_super : ''; |
939 |
||
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
940 |
$urlname_clean = str_replace('\'', '\\\'', str_replace('\\', '\\\\', dirtify_page_id($local_fullpage))); |
15
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
13
diff
changeset
|
941 |
$urlname_clean = strtr( $urlname_clean, array( '<' => '<', '>' => '>' ) ); |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
13
diff
changeset
|
942 |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
943 |
$urlname_jssafe = sanitize_page_id($local_fullpage); |
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
944 |
|
1 | 945 |
// Generate the dynamic javascript vars |
946 |
$js_dynamic = ' <script type="text/javascript">// <![CDATA[ |
|
947 |
// This section defines some basic and very important variables that are used later in the static Javascript library. |
|
948 |
// SKIN DEVELOPERS: The template variable for this code block is {JS_DYNAMIC_VARS}. This MUST be inserted BEFORE the tag that links to the main Javascript lib. |
|
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
949 |
var title=\''. $urlname_jssafe .'\'; |
1 | 950 |
var page_exists='. ( ( $paths->page_exists) ? 'true' : 'false' ) .'; |
951 |
var scriptPath=\''. scriptPath .'\'; |
|
952 |
var contentPath=\''.contentPath.'\'; |
|
953 |
var ENANO_SID =\'' . $SID . '\'; |
|
436
242353360e37
Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
419
diff
changeset
|
954 |
var user_level=' . $session->user_level . '; |
1 | 955 |
var auth_level=' . $session->auth_level . '; |
956 |
var USER_LEVEL_GUEST = ' . USER_LEVEL_GUEST . '; |
|
957 |
var USER_LEVEL_MEMBER = ' . USER_LEVEL_MEMBER . '; |
|
958 |
var USER_LEVEL_CHPREF = ' . USER_LEVEL_CHPREF . '; |
|
959 |
var USER_LEVEL_MOD = ' . USER_LEVEL_MOD . '; |
|
960 |
var USER_LEVEL_ADMIN = ' . USER_LEVEL_ADMIN . '; |
|
555
ac4c6a7f01d8
Added user preference for disabling visual effects in Javascript applets; added re-import button to installed plugins
Dan
parents:
538
diff
changeset
|
961 |
var pref_disable_js_fx = ' . ( @$session->user_extra['disable_js_fx'] == 1 ? '1' : '0' ) . '; |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
962 |
var csrf_token = "' . $session->csrf_token . '"; |
1 | 963 |
var editNotice = \'' . ( (getConfig('wiki_edit_notice')=='1') ? str_replace("\n", "\\\n", RenderMan::render(getConfig('wiki_edit_notice_text'))) : '' ) . '\'; |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
964 |
var prot = ' . ( ($paths->page_protected && !$perms->get_permissions('even_when_protected')) ? 'true' : 'false' ) .'; // No, hacking this var won\'t work, it\'s re-checked on the server |
1 | 965 |
var ENANO_SPECIAL_CREATEPAGE = \''. makeUrl($paths->nslist['Special'].'CreatePage') .'\'; |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
966 |
var ENANO_CREATEPAGE_PARAMS = \'_do=&pagename='. $urlname_clean .'&namespace=' . $local_namespace . '\'; |
1 | 967 |
var ENANO_SPECIAL_CHANGESTYLE = \''. makeUrlNS('Special', 'ChangeStyle') .'\'; |
968 |
var namespace_list = new Array(); |
|
969 |
var AES_BITS = '.AES_BITS.'; |
|
970 |
var AES_BLOCKSIZE = '.AES_BLOCKSIZE.'; |
|
971 |
var pagepass = \''. ( ( isset($_REQUEST['pagepass']) ) ? sha1($_REQUEST['pagepass']) : '' ) .'\'; |
|
972 |
var ENANO_THEME_LIST = \''; |
|
973 |
foreach($this->theme_list as $t) { |
|
974 |
if($t['enabled']) |
|
975 |
{ |
|
976 |
$js_dynamic .= '<option value="'.$t['theme_id'].'"'; |
|
29
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
27
diff
changeset
|
977 |
// if($t['theme_id'] == $session->theme) $js_dynamic .= ' selected="selected"'; |
1 | 978 |
$js_dynamic .= '>'.$t['theme_name'].'</option>'; |
979 |
} |
|
980 |
} |
|
981 |
$js_dynamic .= '\'; |
|
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
208
diff
changeset
|
982 |
var ENANO_CURRENT_THEME = \''. $session->theme .'\'; |
212
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
211
diff
changeset
|
983 |
var ENANO_LANG_ID = ' . $lang->lang_id . '; |
30b857a6b811
Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents:
211
diff
changeset
|
984 |
var ENANO_PAGE_TYPE = "' . addslashes($this->namespace_string) . '";'; |
1 | 985 |
foreach($paths->nslist as $k => $c) |
986 |
{ |
|
987 |
$js_dynamic .= "namespace_list['{$k}'] = '$c';"; |
|
988 |
} |
|
989 |
$js_dynamic .= "\n //]]>\n </script>"; |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
990 |
|
1 | 991 |
$tpl_strings = Array( |
15
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
13
diff
changeset
|
992 |
'PAGE_NAME'=>htmlspecialchars($paths->cpage['name']), |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
13
diff
changeset
|
993 |
'PAGE_URLNAME'=> $urlname_clean, |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
36
diff
changeset
|
994 |
'SITE_NAME'=>htmlspecialchars(getConfig('site_name')), |
1 | 995 |
'USERNAME'=>$session->username, |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
36
diff
changeset
|
996 |
'SITE_DESC'=>htmlspecialchars(getConfig('site_desc')), |
1 | 997 |
'TOOLBAR'=>$tb, |
998 |
'SCRIPTPATH'=>scriptPath, |
|
999 |
'CONTENTPATH'=>contentPath, |
|
1000 |
'ADMIN_SID_QUES'=>$asq, |
|
1001 |
'ADMIN_SID_AMP'=>$asa, |
|
1002 |
'ADMIN_SID_AMP_HTML'=>$ash, |
|
1003 |
'ADMIN_SID_AUTO'=>$as2, |
|
114
47393c6619ea
Nothing special, just syncing to Scribus, several bugs have been found with GET forms and a fix is in the works
Dan
parents:
102
diff
changeset
|
1004 |
'ADMIN_SID_RAW'=> ( is_string($session->sid_super) ? $session->sid_super : '' ), |
1 | 1005 |
'ADDITIONAL_HEADERS'=>$this->additional_headers, |
91 | 1006 |
'COPYRIGHT'=>RenderMan::parse_internal_links(getConfig('copyright_notice')), |
1 | 1007 |
'TOOLBAR_EXTRAS'=>$this->toolbar_menu, |
1008 |
'REQUEST_URI'=>$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], |
|
1009 |
'STYLE_LINK'=>makeUrlNS('Special', 'CSS'.$p, null, true), //contentPath.$paths->nslist['Special'].'CSS' . $p, |
|
1010 |
'LOGIN_LINK'=>$login_link, |
|
1011 |
'LOGOUT_LINK'=>$logout_link, |
|
60
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
59
diff
changeset
|
1012 |
'ADMIN_LINK'=>$admin_link, |
1 | 1013 |
'THEME_LINK'=>$theme_link, |
115
261f367623af
Fixed the obnoxious issue with forms using GET and index.php?title=Foo URL scheme (this works a whole lot better than MediaWiki now
Dan
parents:
114
diff
changeset
|
1014 |
'SEARCH_ACTION'=>makeUrlNS('Special', 'Search'), |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1015 |
'INPUT_TITLE'=>( urlSeparator == '&' ? '<input type="hidden" name="title" value="' . htmlspecialchars( $paths->nslist[$local_namespace] . $local_page_id ) . '" />' : ''), |
115
261f367623af
Fixed the obnoxious issue with forms using GET and index.php?title=Foo URL scheme (this works a whole lot better than MediaWiki now
Dan
parents:
114
diff
changeset
|
1016 |
'INPUT_AUTH'=>( $session->sid_super ? '<input type="hidden" name="auth" value="' . $session->sid_super . '" />' : ''), |
1 | 1017 |
'TEMPLATE_DIR'=>scriptPath.'/themes/'.$this->theme, |
1018 |
'THEME_ID'=>$this->theme, |
|
1019 |
'STYLE_ID'=>$this->style, |
|
1020 |
'JS_DYNAMIC_VARS'=>$js_dynamic, |
|
85
7c68a18a27be
AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents:
73
diff
changeset
|
1021 |
'UNREAD_PMS'=>$session->unread_pms, |
286
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
1022 |
'URL_ABOUT_ENANO' => makeUrlNS('Special', 'About_Enano', '', true), |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1023 |
'REPORT_URI' => makeUrl($local_fullpage, 'do=sql_report', true) |
1 | 1024 |
); |
1025 |
||
1026 |
foreach ( $paths->nslist as $ns_id => $ns_prefix ) |
|
1027 |
{ |
|
1028 |
$tpl_strings[ 'NS_' . strtoupper($ns_id) ] = $ns_prefix; |
|
1029 |
} |
|
1030 |
||
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1031 |
$this->assign_vars($tpl_strings, true); |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1032 |
|
1 | 1033 |
list($this->tpl_strings['SIDEBAR_LEFT'], $this->tpl_strings['SIDEBAR_RIGHT'], $min) = $this->fetch_sidebar(); |
1034 |
$this->tpl_bool['sidebar_left'] = ( $this->tpl_strings['SIDEBAR_LEFT'] != $min) ? true : false; |
|
1035 |
$this->tpl_bool['sidebar_right'] = ( $this->tpl_strings['SIDEBAR_RIGHT'] != $min) ? true : false; |
|
1036 |
$this->tpl_bool['right_sidebar'] = $this->tpl_bool['sidebar_right']; // backward compatibility |
|
118
0c5efda996bf
Added keep-alive function to admin panel (had been planned for some time) and a new hook, template_var_init_end
Dan
parents:
115
diff
changeset
|
1037 |
|
0c5efda996bf
Added keep-alive function to admin panel (had been planned for some time) and a new hook, template_var_init_end
Dan
parents:
115
diff
changeset
|
1038 |
$code = $plugins->setHook('template_var_init_end'); |
0c5efda996bf
Added keep-alive function to admin panel (had been planned for some time) and a new hook, template_var_init_end
Dan
parents:
115
diff
changeset
|
1039 |
foreach ( $code as $cmd ) |
0c5efda996bf
Added keep-alive function to admin panel (had been planned for some time) and a new hook, template_var_init_end
Dan
parents:
115
diff
changeset
|
1040 |
{ |
0c5efda996bf
Added keep-alive function to admin panel (had been planned for some time) and a new hook, template_var_init_end
Dan
parents:
115
diff
changeset
|
1041 |
eval($cmd); |
0c5efda996bf
Added keep-alive function to admin panel (had been planned for some time) and a new hook, template_var_init_end
Dan
parents:
115
diff
changeset
|
1042 |
} |
372
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
1043 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
1044 |
profiler_log("template: finished var init"); |
1 | 1045 |
} |
1046 |
||
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1047 |
/** |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1048 |
* Performs var init that is common to all pages (IOW, called only once) |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1049 |
* @access private |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1050 |
*/ |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1051 |
|
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1052 |
function init_vars_global() |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1053 |
{ |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1054 |
|
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1055 |
} |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1056 |
|
1 | 1057 |
function header($simple = false) |
1058 |
{ |
|
1059 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
215 | 1060 |
global $lang; |
1061 |
||
1 | 1062 |
ob_start(); |
1063 |
||
1064 |
if(!$this->theme_loaded) |
|
1065 |
{ |
|
1066 |
$this->load_theme($session->theme, $session->style); |
|
1067 |
} |
|
1068 |
||
526
b2fb50d572c7
New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents:
511
diff
changeset
|
1069 |
// I feel awful doing this. |
b2fb50d572c7
New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents:
511
diff
changeset
|
1070 |
if ( preg_match('/^W3C_Validator/', @$_SERVER['HTTP_USER_AGENT']) ) |
b2fb50d572c7
New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents:
511
diff
changeset
|
1071 |
{ |
b2fb50d572c7
New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents:
511
diff
changeset
|
1072 |
header('Content-type: application/xhtml+xml'); |
b2fb50d572c7
New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents:
511
diff
changeset
|
1073 |
} |
b2fb50d572c7
New plugin manager half-implemented. Most of the UI/frontend code is done. Moved sql_parse.php to /includes/ to allow use after installation - TODO: check installer, etc. for breakage
Dan
parents:
511
diff
changeset
|
1074 |
|
1 | 1075 |
$headers_sent = true; |
1076 |
if(!defined('ENANO_HEADERS_SENT')) |
|
1077 |
define('ENANO_HEADERS_SENT', ''); |
|
174
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
165
diff
changeset
|
1078 |
if ( !$this->no_headers ) |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
165
diff
changeset
|
1079 |
{ |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
165
diff
changeset
|
1080 |
$header = ( $simple ) ? |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
165
diff
changeset
|
1081 |
$this->process_template('simple-header.tpl') : |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
165
diff
changeset
|
1082 |
$this->process_template('header.tpl'); |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
165
diff
changeset
|
1083 |
echo $header; |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
165
diff
changeset
|
1084 |
} |
1 | 1085 |
if ( !$simple && $session->user_logged_in && $session->unread_pms > 0 ) |
1086 |
{ |
|
1087 |
echo $this->notify_unread_pms(); |
|
1088 |
} |
|
1089 |
if ( !$simple && $session->sw_timed_out ) |
|
1090 |
{ |
|
1091 |
$login_link = makeUrlNS('Special', 'Login/' . $paths->fullpage, 'level=' . $session->user_level, true); |
|
1092 |
echo '<div class="usermessage">'; |
|
215 | 1093 |
echo $lang->get('user_msg_elev_timed_out', array( 'login_link' => $login_link )); |
1 | 1094 |
echo '</div>'; |
1095 |
} |
|
30 | 1096 |
if ( $this->site_disabled && $session->user_level >= USER_LEVEL_ADMIN && ( $paths->page != $paths->nslist['Special'] . 'Administration' ) ) |
1097 |
{ |
|
1098 |
$admin_link = makeUrlNS('Special', 'Administration', 'module=' . $paths->nslist['Admin'] . 'GeneralConfig', true); |
|
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1099 |
echo '<div class="usermessage"><b>' . $lang->get('page_sitedisabled_admin_msg_title') . '</b><br /> |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1100 |
' . $lang->get('page_sitedisabled_admin_msg_body', array('admin_link' => $admin_link)) . ' |
30 | 1101 |
</div>'; |
1102 |
} |
|
1 | 1103 |
} |
372
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
1104 |
|
1 | 1105 |
function footer($simple = false) |
1106 |
{ |
|
396
3289e4dcb4b8
Fixed some stray undefined-variable problems revealed as a result of testing on Windows Server '03, IIS6, PHP/FastCGI, and PostgreSQL 8.2.5.
Dan
parents:
391
diff
changeset
|
1107 |
echo $this->getFooter($simple); |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1108 |
ob_end_flush(); |
1 | 1109 |
} |
372
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
1110 |
|
1 | 1111 |
function getHeader() |
1112 |
{ |
|
1113 |
$headers_sent = true; |
|
1114 |
if(!defined('ENANO_HEADERS_SENT')) |
|
1115 |
define('ENANO_HEADERS_SENT', ''); |
|
1116 |
if(!$this->no_headers) return $this->process_template('header.tpl'); |
|
1117 |
} |
|
396
3289e4dcb4b8
Fixed some stray undefined-variable problems revealed as a result of testing on Windows Server '03, IIS6, PHP/FastCGI, and PostgreSQL 8.2.5.
Dan
parents:
391
diff
changeset
|
1118 |
function getFooter($simple = false) |
1 | 1119 |
{ |
1120 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1121 |
global $lang; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1122 |
if ( !$this->no_headers ) |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1123 |
{ |
1 | 1124 |
|
1125 |
if(!defined('ENANO_HEADERS_SENT')) |
|
1126 |
$this->header(); |
|
1127 |
||
1128 |
global $_starttime; |
|
1129 |
if(isset($_GET['sqldbg']) && $session->get_permissions('mod_misc')) |
|
1130 |
{ |
|
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1131 |
echo '<h3>' . $lang->get('page_heading_sql_list') . '</h3><pre style="margin-left: 1em">'; |
272
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
256
diff
changeset
|
1132 |
echo htmlspecialchars($db->sql_backtrace()); |
1 | 1133 |
echo '</pre>'; |
1134 |
} |
|
1135 |
||
1136 |
$t = ( $simple ) ? $this->process_template('simple-footer.tpl') : $this->process_template('footer.tpl'); |
|
1137 |
||
1138 |
$f = microtime_float(); |
|
1139 |
$f = $f - $_starttime; |
|
413
6607cd646d6d
Added autosave functionality and resurrected the old toolbar code that was added about a year ago but never uesd.
Dan
parents:
411
diff
changeset
|
1140 |
$f = round($f, 2); |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1141 |
|
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1142 |
$t_loc = $lang->get('page_msg_stats_gentime_short', array('time' => $f)); |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1143 |
$t_loc_long = $lang->get('page_msg_stats_gentime_long', array('time' => $f)); |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1144 |
$q_loc = '<a href="' . $this->tpl_strings['REPORT_URI'] . '">' . $lang->get('page_msg_stats_sql', array('nq' => $db->num_queries)) . '</a>'; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1145 |
$dbg = $t_loc; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1146 |
$dbg_long = $t_loc_long; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1147 |
if ( $session->user_level >= USER_LEVEL_ADMIN ) |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1148 |
{ |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1149 |
$dbg .= " | $q_loc"; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1150 |
$dbg_long .= " | $q_loc"; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1151 |
} |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1152 |
|
1 | 1153 |
$t = str_replace('[[Stats]]', $dbg, $t); |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1154 |
$t = str_replace('[[StatsLong]]', $dbg_long, $t); |
1 | 1155 |
$t = str_replace('[[NumQueries]]', (string)$db->num_queries, $t); |
1156 |
$t = str_replace('[[GenTime]]', (string)$f, $t); |
|
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1157 |
$t = str_replace('[[NumQueriesLoc]]', $q_loc, $t); |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1158 |
$t = str_replace('[[GenTimeLoc]]', $t_loc, $t); |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1159 |
$t = str_replace('[[EnanoPoweredLink]]', $lang->get('page_enano_powered', array('about_uri' => $this->tpl_strings['URL_ABOUT_ENANO'])), $t); |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1160 |
$t = str_replace('[[EnanoPoweredLinkLong]]', $lang->get('page_enano_powered_long', array('about_uri' => $this->tpl_strings['URL_ABOUT_ENANO'])), $t); |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1161 |
|
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1162 |
if ( defined('ENANO_DEBUG') ) |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1163 |
$t = str_replace('</body>', '<div id="profile" style="margin: 10px;">' . profiler_make_html() . '</div></body>', $t); |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1164 |
|
1 | 1165 |
return $t; |
1166 |
} |
|
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1167 |
else |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1168 |
{ |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1169 |
return ''; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
1170 |
} |
1 | 1171 |
} |
1172 |
||
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1173 |
/** |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1174 |
* Assigns an array of string values to the template. Strings can be accessed from the template by inserting {KEY_NAME} in the template file. |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1175 |
* @param $vars array |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1176 |
* @param $from_internal bool Internal switch, just omit (@todo document) |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1177 |
*/ |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1178 |
|
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1179 |
function assign_vars($vars, $from_internal = false) |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1180 |
{ |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1181 |
foreach ( $vars as $key => $value ) |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1182 |
{ |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1183 |
$replace = true; |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1184 |
if ( isset($this->vars_assign_history['strings'][$key]) ) |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1185 |
{ |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1186 |
if ( $this->vars_assign_history['strings'][$key] == 'api' ) |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1187 |
{ |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1188 |
$replace = false; |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1189 |
} |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1190 |
} |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1191 |
if ( $replace ) |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1192 |
{ |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1193 |
$this->tpl_strings[$key] = $value; |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1194 |
$this->vars_assign_history['strings'][$key] = ( $from_internal ) ? 'internal' : 'api'; |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1195 |
} |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1196 |
} |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1197 |
} |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1198 |
|
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1199 |
/** |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1200 |
* Assigns an array of boolean values to the template. These can be used for <!-- IF ... --> statements. |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1201 |
* @param $vars array |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1202 |
* @param $from_internal bool Internal switch, just omit (@todo document) |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1203 |
*/ |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1204 |
|
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1205 |
function assign_bool($vars) |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1206 |
{ |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1207 |
foreach ( $vars as $key => $value ) |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1208 |
{ |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1209 |
$replace = true; |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1210 |
if ( isset($this->vars_assign_history['bool'][$key]) ) |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1211 |
{ |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1212 |
if ( $this->vars_assign_history['bool'][$key] == 'api' ) |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1213 |
{ |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1214 |
$replace = false; |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1215 |
} |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1216 |
} |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1217 |
if ( $replace ) |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1218 |
{ |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1219 |
$this->tpl_bool[$key] = $value; |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1220 |
$this->vars_assign_history['bool'][$key] = ( $from_internal ) ? 'internal' : 'api'; |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1221 |
} |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1222 |
} |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1223 |
} |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1224 |
|
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1225 |
# |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1226 |
# COMPILER |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1227 |
# |
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1228 |
|
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
1229 |
/** |
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1230 |
* Compiles and executes a template based on the current variables and booleans. Loads |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1231 |
* the theme and initializes variables if needed. This mostly just calls child functions. |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1232 |
* @param string File to process |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1233 |
* @return string |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1234 |
*/ |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1235 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1236 |
function process_template($file) |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1237 |
{ |
1 | 1238 |
global $db, $session, $paths, $template, $plugins; // Common objects |
1239 |
if(!defined('ENANO_TEMPLATE_LOADED')) |
|
1240 |
{ |
|
1241 |
$this->load_theme(); |
|
1242 |
$this->init_vars(); |
|
1243 |
} |
|
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1244 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1245 |
$compiled = $this->compile_template($file); |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1246 |
return eval($compiled); |
1 | 1247 |
} |
1248 |
||
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1249 |
/** |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1250 |
* Loads variables from the specified template file. Returns an associative array containing the variables. |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1251 |
* @param string Template file to process (elements.tpl) |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1252 |
* @return array |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1253 |
*/ |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1254 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1255 |
function extract_vars($file) |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1256 |
{ |
1 | 1257 |
global $db, $session, $paths, $template, $plugins; // Common objects |
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1258 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1259 |
// Sometimes this function gets called before the theme is loaded |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1260 |
// This is a bad coding practice so this function will always be picky. |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1261 |
if ( !$this->theme ) |
1 | 1262 |
{ |
1263 |
die('$template->extract_vars(): theme not yet loaded, so we can\'t open template files yet...this is a bug and should be reported.<br /><br />Backtrace, most recent call first:<pre>'.enano_debug_print_backtrace(true).'</pre>'); |
|
1264 |
} |
|
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1265 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1266 |
// Full pathname of template file |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1267 |
$tpl_file_fullpath = ENANO_ROOT . '/themes/' . $this->theme . '/' . $file; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1268 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1269 |
// Make sure the template even exists |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1270 |
if ( !is_file($tpl_file_fullpath) ) |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1271 |
{ |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1272 |
die_semicritical('Cannot find template file', |
472
bc4b58034f4d
Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents:
471
diff
changeset
|
1273 |
'<p>The template parser was asked to load the file "' . htmlspecialchars($tpl_file_fullpath) . '", but that file couldn\'t be found in the directory for |
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1274 |
the current theme.</p> |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1275 |
<p>Additional debugging information:<br /> |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1276 |
<b>Theme currently in use: </b>' . $this->theme . '<br /> |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1277 |
<b>Requested file: </b>' . $file . ' |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1278 |
</p>'); |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1279 |
} |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1280 |
// Retrieve file contents |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1281 |
$text = file_get_contents($tpl_file_fullpath); |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1282 |
if ( !$text ) |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1283 |
{ |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1284 |
return false; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1285 |
} |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1286 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1287 |
// Get variables, regular expressions FTW |
1 | 1288 |
preg_match_all('#<\!-- VAR ([A-z0-9_-]*) -->(.*?)<\!-- ENDVAR \\1 -->#is', $text, $matches); |
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1289 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1290 |
// Initialize return values |
1 | 1291 |
$tplvars = Array(); |
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1292 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1293 |
// Loop through each match, setting $tplvars[ $first_subpattern ] to $second_subpattern |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1294 |
for ( $i = 0; $i < sizeof($matches[1]); $i++ ) |
1 | 1295 |
{ |
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1296 |
$tplvars[ $matches[1][$i] ] = $matches[2][$i]; |
1 | 1297 |
} |
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1298 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1299 |
// All done! |
1 | 1300 |
return $tplvars; |
1301 |
} |
|
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1302 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1303 |
/** |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1304 |
* Compiles a block of template code. |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1305 |
* @param string The text to process |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1306 |
* @return string |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1307 |
*/ |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1308 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1309 |
function compile_tpl_code($text) |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1310 |
{ |
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
1311 |
return template_compiler_core($text); |
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1312 |
} |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1313 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1314 |
/** |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1315 |
* Compiles the contents of a given template file, possibly using a cached copy, and returns the compiled code. |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1316 |
* @param string Filename of template (header.tpl) |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1317 |
* @return string |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1318 |
*/ |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1319 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1320 |
function compile_template($filename) |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1321 |
{ |
1 | 1322 |
global $db, $session, $paths, $template, $plugins; // Common objects |
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1323 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1324 |
// Full path to template file |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1325 |
$tpl_file_fullpath = ENANO_ROOT . '/themes/' . $this->theme . '/' . $filename; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1326 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1327 |
// Make sure the file exists |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1328 |
if ( !is_file($tpl_file_fullpath) ) |
1 | 1329 |
{ |
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1330 |
die_semicritical('Cannot find template file', |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1331 |
'<p>The template parser was asked to load the file "' . htmlspecialchars($filename) . '", but that file couldn\'t be found in the directory for |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1332 |
the current theme.</p> |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1333 |
<p>Additional debugging information:<br /> |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1334 |
<b>Theme currently in use: </b>' . $this->theme . '<br /> |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1335 |
<b>Requested file: </b>' . $file . ' |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1336 |
</p>'); |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1337 |
} |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1338 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1339 |
// Check for cached copy |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1340 |
// This will make filenames in the pattern of theme-file.tpl.php |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1341 |
$cache_file = ENANO_ROOT . '/cache/' . $this->theme . '-' . str_replace('/', '-', $filename) . '.php'; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1342 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1343 |
// Only use cached copy if caching is enabled |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1344 |
// (it is enabled by default I think) |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1345 |
if ( file_exists($cache_file) && getConfig('cache_thumbs') == '1' ) |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1346 |
{ |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1347 |
// Cache files are auto-generated, but otherwise are normal PHP files |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1348 |
include($cache_file); |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1349 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1350 |
// Fetch content of the ORIGINAL |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1351 |
$text = file_get_contents($tpl_file_fullpath); |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1352 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1353 |
// $md5 will be set by the cached file |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1354 |
// This makes sure that a cached copy of the template is used only if its MD5 |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1355 |
// matches the MD5 of the file that the compiled file was compiled from. |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1356 |
if ( isset($md5) && $md5 == md5($text) ) |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1357 |
{ |
211 | 1358 |
return $this->compile_template_text_post(str_replace('\\"', '"', $tpl_text)); |
1 | 1359 |
} |
1360 |
} |
|
1361 |
||
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1362 |
// We won't use the cached copy here |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1363 |
$text = file_get_contents($tpl_file_fullpath); |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1364 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1365 |
// This will be used later when writing the cached file |
1 | 1366 |
$md5 = md5($text); |
1367 |
||
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1368 |
// Preprocessing and checks complete - compile the code |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1369 |
$text = $this->compile_tpl_code($text); |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1370 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1371 |
// Perhaps caching is enabled and the admin has changed the template? |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1372 |
if ( is_writable( ENANO_ROOT . '/cache/' ) && getConfig('cache_thumbs') == '1' ) |
1 | 1373 |
{ |
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1374 |
$h = fopen($cache_file, 'w'); |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1375 |
if ( !$h ) |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1376 |
{ |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1377 |
// Couldn't open the file - silently ignore and return |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1378 |
return $text; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1379 |
} |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1380 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1381 |
// Escape the compiled code so it can be eval'ed |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1382 |
$text_escaped = addslashes($text); |
128
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
1383 |
$notice = <<<EOF |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
1384 |
|
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
1385 |
/* |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
1386 |
* NOTE: This file was automatically generated by Enano and is based on compiled code. Do not edit this file. |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
1387 |
* If you edit this file, any changes you make will be lost the next time the associated source template file is edited. |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
1388 |
*/ |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
1389 |
|
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
1390 |
EOF; |
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1391 |
// This is really just a normal PHP file that sets a variable or two and exits. |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1392 |
// $tpl_text actually will contain the compiled code |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1393 |
fwrite($h, '<?php ' . $notice . ' $md5 = \'' . $md5 . '\'; $tpl_text = \'' . $text_escaped . '\'; ?>'); |
1 | 1394 |
fclose($h); |
1395 |
} |
|
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1396 |
|
211 | 1397 |
return $this->compile_template_text_post($text); //('<pre>'.htmlspecialchars($text).'</pre>'); |
1 | 1398 |
} |
1399 |
||
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1400 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1401 |
/** |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1402 |
* Compiles (parses) some template code with the current master set of variables and booleans. |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1403 |
* @param string Text to process |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1404 |
* @return string |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1405 |
*/ |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1406 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1407 |
function compile_template_text($text) |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1408 |
{ |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1409 |
// this might do something else in the future, possibly cache large templates |
211 | 1410 |
return $this->compile_template_text_post($this->compile_tpl_code($text)); |
1 | 1411 |
} |
1412 |
||
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1413 |
/** |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1414 |
* For convenience - compiles AND parses some template code. |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1415 |
* @param string Text to process |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1416 |
* @return string |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1417 |
*/ |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1418 |
|
1 | 1419 |
function parse($text) |
1420 |
{ |
|
1421 |
$text = $this->compile_template_text($text); |
|
211 | 1422 |
$text = $this->compile_template_text_post($text); |
1 | 1423 |
return eval($text); |
1424 |
} |
|
1425 |
||
211 | 1426 |
/** |
1427 |
* Post-processor for template code. Basically what this does is it localizes {lang:foo} blocks. |
|
1428 |
* @param string Mostly-processed TPL code |
|
1429 |
* @return string |
|
1430 |
*/ |
|
1431 |
||
1432 |
function compile_template_text_post($text) |
|
1433 |
{ |
|
1434 |
global $lang; |
|
1435 |
preg_match_all('/\{lang:([a-z0-9]+_[a-z0-9_]+)\}/', $text, $matches); |
|
1436 |
foreach ( $matches[1] as $i => $string_id ) |
|
1437 |
{ |
|
1438 |
$string = $lang->get($string_id); |
|
1439 |
$string = str_replace('\\', '\\\\', $string); |
|
1440 |
$string = str_replace('\'', '\\\'', $string); |
|
1441 |
$text = str_replace_once($matches[0][$i], $string, $text); |
|
1442 |
} |
|
1443 |
return $text; |
|
1444 |
} |
|
1445 |
||
1 | 1446 |
// Steps to turn this: |
1447 |
// [[Project:Community Portal]] |
|
1448 |
// into this: |
|
1449 |
// <a href="/Project:Community_Portal">Community Portal</a> |
|
1450 |
// Must be done WITHOUT creating eval'ed code!!! |
|
1451 |
||
1452 |
// 1. preg_replace \[\[([a-zA-Z0-9 -_:]*?)\]\] with <a href="'.contentPath.'\\1">\\1</a> |
|
1453 |
// 2. preg_match_all <a href="'.preg_quote(contentPath).'([a-zA-Z0-9 -_:]*?)"> |
|
1454 |
// 3. For each match, replace matches with identifiers |
|
1455 |
// 4. For each match, str_replace ' ' with '_' |
|
1456 |
// 5. For each match, str_replace match_id:random_val with $matches[$match_id] |
|
1457 |
||
1458 |
// The template language is really a miniature programming language; with variables, conditionals, everything! |
|
1459 |
// So you can implement custom logic into your sidebar if you wish. |
|
1460 |
// "Real" PHP support coming soon :-D |
|
1461 |
||
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1462 |
/** |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1463 |
* Takes a blob of HTML with the specially formatted template-oriented wikitext and formats it. Does not use eval(). |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1464 |
* This function butchers every coding standard in Enano and should eventually be rewritten. The fact is that the |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1465 |
* code _works_ and does a good job of checking for errors and cleanly complaining about them. |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1466 |
* @param string Text to process |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1467 |
* @param bool Ignored for backwards compatibility |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1468 |
* @param string File to get variables for sidebar data from |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1469 |
* @return string |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1470 |
*/ |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1471 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1472 |
function tplWikiFormat($message, $filter_links = false, $filename = 'elements.tpl') |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1473 |
{ |
1 | 1474 |
global $db, $session, $paths, $template, $plugins; // Common objects |
215 | 1475 |
global $lang; |
1476 |
||
1 | 1477 |
$filter_links = false; |
1478 |
$tplvars = $this->extract_vars($filename); |
|
1479 |
if($session->sid_super) $as = htmlspecialchars(urlSeparator).'auth='.$session->sid_super; |
|
1480 |
else $as = ''; |
|
1481 |
error_reporting(E_ALL); |
|
1482 |
$random_id = sha1(microtime().''); // A temp value |
|
1483 |
||
1484 |
/* |
|
1485 |
* PREPROCESSOR |
|
1486 |
*/ |
|
1487 |
||
1488 |
// Variables |
|
1489 |
||
1490 |
preg_match_all('#\$([A-Z_-]+)\$#', $message, $links); |
|
1491 |
$links = $links[1]; |
|
1492 |
||
1493 |
for($i=0;$i<sizeof($links);$i++) |
|
1494 |
{ |
|
1495 |
$message = str_replace('$'.$links[$i].'$', $this->tpl_strings[$links[$i]], $message); |
|
1496 |
} |
|
1497 |
||
1498 |
// Conditionals |
|
1499 |
||
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1500 |
preg_match_all('#\{if ([A-Za-z0-9_ \(\)&\|\!-]*)\}(.*?)\{\/if\}#is', $message, $links); |
1 | 1501 |
|
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1502 |
// Temporary exception from coding standards - using tab length of 4 here for clarity |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1503 |
for ( $i = 0; $i < sizeof($links[1]); $i++ ) |
1 | 1504 |
{ |
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1505 |
$condition =& $links[1][$i]; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1506 |
$message = str_replace('{if '.$condition.'}'.$links[2][$i].'{/if}', '{CONDITIONAL:'.$i.':'.$random_id.'}', $message); |
1 | 1507 |
|
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1508 |
// Time for some manual parsing... |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1509 |
$chk = false; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1510 |
$current_id = ''; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1511 |
$prn_level = 0; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1512 |
// Used to keep track of where we are in the conditional |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1513 |
// Object of the game: turn {if this && ( that OR !something_else )} ... {/if} into if( ( isset($this->tpl_bool['that']) && $this->tpl_bool['that'] ) && ... |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1514 |
// Method of attack: escape all variables, ignore all else. Non-valid code is filtered out by a regex above. |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1515 |
$in_var_now = true; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1516 |
$in_var_last = false; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1517 |
$current_var = ''; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1518 |
$current_var_start_pos = 0; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1519 |
$current_var_end_pos = 0; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1520 |
$j = -1; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1521 |
$condition = $condition . ' '; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1522 |
$d = strlen($condition); |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1523 |
while($j < $d) |
1 | 1524 |
{ |
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1525 |
$j++; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1526 |
$in_var_last = $in_var_now; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1527 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1528 |
$char = substr($condition, $j, 1); |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1529 |
$in_var_now = ( preg_match('#^([A-z0-9_]*){1}$#', $char) ) ? true : false; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1530 |
if(!$in_var_last && $in_var_now) |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1531 |
{ |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1532 |
$current_var_start_pos = $j; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1533 |
} |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1534 |
if($in_var_last && !$in_var_now) |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1535 |
{ |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1536 |
$current_var_end_pos = $j; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1537 |
} |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1538 |
if($in_var_now) |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1539 |
{ |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1540 |
$current_var .= $char; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1541 |
continue; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1542 |
} |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1543 |
// OK we are not inside of a variable. That means that we JUST hit the end because the counter ($j) will be advanced to the beginning of the next variable once processing here is complete. |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1544 |
if($char != ' ' && $char != '(' && $char != ')' && $char != 'A' && $char != 'N' && $char != 'D' && $char != 'O' && $char != 'R' && $char != '&' && $char != '|' && $char != '!' && $char != '<' && $char != '>' && $char != '0' && $char != '1' && $char != '2' && $char != '3' && $char != '4' && $char != '5' && $char != '6' && $char != '7' && $char != '8' && $char != '9') |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1545 |
{ |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1546 |
// XSS attack! Bail out |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1547 |
$errmsg = '<p><b>Error:</b> Syntax error (possibly XSS attack) caught in template code:</p>'; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1548 |
$errmsg .= '<pre>'; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1549 |
$errmsg .= '{if '.htmlspecialchars($condition).'}'; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1550 |
$errmsg .= "\n "; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1551 |
for ( $k = 0; $k < $j; $k++ ) |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1552 |
{ |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1553 |
$errmsg .= " "; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1554 |
} |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1555 |
// Show position of error |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1556 |
$errmsg .= '<span style="color: red;">^</span>'; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1557 |
$errmsg .= '</pre>'; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1558 |
$message = str_replace('{CONDITIONAL:'.$i.':'.$random_id.'}', $errmsg, $message); |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1559 |
continue 2; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1560 |
} |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1561 |
if($current_var != '') |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1562 |
{ |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1563 |
$cd = '( isset($this->tpl_bool[\''.$current_var.'\']) && $this->tpl_bool[\''.$current_var.'\'] )'; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1564 |
$cvt = substr($condition, 0, $current_var_start_pos) . $cd . substr($condition, $current_var_end_pos, strlen($condition)); |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1565 |
$j = $j + strlen($cd) - strlen($current_var); |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1566 |
$current_var = ''; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1567 |
$condition = $cvt; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1568 |
$d = strlen($condition); |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1569 |
} |
1 | 1570 |
} |
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1571 |
$condition = substr($condition, 0, strlen($condition)-1); |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1572 |
$condition = '$chk = ( '.$condition.' ) ? true : false;'; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1573 |
eval($condition); |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1574 |
|
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1575 |
if($chk) |
1 | 1576 |
{ |
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1577 |
if(strstr($links[2][$i], '{else}')) $c = substr($links[2][$i], 0, strpos($links[2][$i], '{else}')); |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1578 |
else $c = $links[2][$i]; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1579 |
$message = str_replace('{CONDITIONAL:'.$i.':'.$random_id.'}', $c, $message); |
1 | 1580 |
} |
162
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1581 |
else |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1582 |
{ |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1583 |
if(strstr($links[2][$i], '{else}')) $c = substr($links[2][$i], strpos($links[2][$i], '{else}')+6, strlen($links[2][$i])); |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1584 |
else $c = ''; |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1585 |
$message = str_replace('{CONDITIONAL:'.$i.':'.$random_id.'}', $c, $message); |
e1a22031b5bd
Major revamps to the template parser. Fixed a few security holes that could allow PHP to be injected in untimely places in TPL code. Improved Ux for XSS attempt in tplWikiFormat. Documented many functions. Backported much cleaner parser from 2.0 branch. Beautified a lot of code in the depths of the template class. Pretty much a small-scale Extreme Makeover.
Dan
parents:
142
diff
changeset
|
1586 |
} |
1 | 1587 |
} |
1588 |
||
1589 |
preg_match_all('#\{!if ([A-Za-z_-]*)\}(.*?)\{\/if\}#is', $message, $links); |
|
1590 |
||
1591 |
for($i=0;$i<sizeof($links[1]);$i++) |
|
1592 |
{ |
|
1593 |
$message = str_replace('{!if '.$links[1][$i].'}'.$links[2][$i].'{/if}', '{CONDITIONAL:'.$i.':'.$random_id.'}', $message); |
|
1594 |
if(isset($this->tpl_bool[$links[1][$i]]) && $this->tpl_bool[$links[1][$i]]) { |
|
1595 |
if(strstr($links[2][$i], '{else}')) $c = substr($links[2][$i], strpos($links[2][$i], '{else}')+6, strlen($links[2][$i])); |
|
1596 |
else $c = ''; |
|
1597 |
$message = str_replace('{CONDITIONAL:'.$i.':'.$random_id.'}', $c, $message); |
|
1598 |
} else { |
|
1599 |
if(strstr($links[2][$i], '{else}')) $c = substr($links[2][$i], 0, strpos($links[2][$i], '{else}')); |
|
1600 |
else $c = $links[2][$i]; |
|
1601 |
$message = str_replace('{CONDITIONAL:'.$i.':'.$random_id.'}', $c, $message); |
|
1602 |
} |
|
1603 |
} |
|
1604 |
||
215 | 1605 |
preg_match_all('/\{lang:([a-z0-9]+_[a-z0-9_]+)\}/', $message, $matches); |
1606 |
foreach ( $matches[1] as $i => $string_id ) |
|
1607 |
{ |
|
1608 |
$string = $lang->get($string_id); |
|
1609 |
$string = str_replace('\\', '\\\\', $string); |
|
1610 |
$string = str_replace('\'', '\\\'', $string); |
|
1611 |
$message = str_replace_once($matches[0][$i], $string, $message); |
|
1612 |
} |
|
1613 |
||
1 | 1614 |
/* |
1615 |
* HTML RENDERER |
|
1616 |
*/ |
|
1617 |
||
1618 |
// Images |
|
1619 |
$j = preg_match_all('#\[\[:'.$paths->nslist['File'].'([\w\s0-9_\(\)!@%\^\+\|\.-]+?)\]\]#is', $message, $matchlist); |
|
1620 |
$matches = Array(); |
|
1621 |
$matches['images'] = $matchlist[1]; |
|
1622 |
for($i=0;$i<sizeof($matchlist[1]);$i++) |
|
1623 |
{ |
|
1624 |
if(isPage($paths->nslist['File'].$matches['images'][$i])) |
|
1625 |
{ |
|
1626 |
$message = str_replace('[[:'.$paths->nslist['File'].$matches['images'][$i].']]', |
|
1627 |
'<img alt="'.$matches['images'][$i].'" style="border: 0" src="'.makeUrlNS('Special', 'DownloadFile/'.$matches['images'][$i]).'" />', |
|
1628 |
$message); |
|
1629 |
} |
|
1630 |
} |
|
1631 |
||
1632 |
// Internal links |
|
1633 |
||
1634 |
$text_parser = $this->makeParserText($tplvars['sidebar_button']); |
|
1635 |
||
133
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
128
diff
changeset
|
1636 |
preg_match_all("#\[\[([^\|\]\n\a\r\t]*?)\]\]#is", $message, $il); |
1 | 1637 |
for($i=0;$i<sizeof($il[1]);$i++) |
1638 |
{ |
|
1639 |
$href = makeUrl(str_replace(' ', '_', $il[1][$i]), null, true); |
|
59
7c4a851fb5c5
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
Dan
parents:
57
diff
changeset
|
1640 |
$text_parser->assign_vars(Array( |
1 | 1641 |
'HREF' => $href, |
1642 |
'FLAGS' => '', |
|
1643 |
'TEXT' => $il[1][$i] |
|
1644 |
)); |
|
1645 |
$message = str_replace("[[{$il[1][$i]}]]", $text_parser->run(), $message); |
|
1646 |
} |
|
1647 |
||
133
af0f6ec48de3
Fully implemented password complexity enforcement; added encryption for passwords on registration form; some baby steps taken towards supporting international usernames - this is not working very well, we might need a hackish fix; TODO: implement password strength meter into installer UI and get international usernames 100% working
Dan
parents:
128
diff
changeset
|
1648 |
preg_match_all('#\[\[([^\|\]\n\a\r\t]*?)\|([^\]\r\n\a\t]*?)\]\]#is', $message, $il); |
1 | 1649 |
for($i=0;$i<sizeof($il[1]);$i++) |
1650 |
{ |
|
1651 |
$href = makeUrl(str_replace(' ', '_', $il[1][$i]), null, true); |
|
1652 |
$text_parser->assign_vars(Array( |
|
1653 |
'HREF' => $href, |
|
1654 |
'FLAGS' => '', |
|
1655 |
'TEXT' => $il[2][$i] |
|
1656 |
)); |
|
1657 |
$message = str_replace("[[{$il[1][$i]}|{$il[2][$i]}]]", $text_parser->run(), $message); |
|
1658 |
} |
|
1659 |
||
1660 |
// External links |
|
59
7c4a851fb5c5
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
Dan
parents:
57
diff
changeset
|
1661 |
// $message = preg_replace('#\[(http|ftp|irc):\/\/([a-z0-9\/:_\.\?&%\#@_\\\\-]+?) ([^\]]+)\\]#', '<a href="\\1://\\2">\\3</a><br style="display: none;" />', $message); |
7c4a851fb5c5
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
Dan
parents:
57
diff
changeset
|
1662 |
// $message = preg_replace('#\[(http|ftp|irc):\/\/([a-z0-9\/:_\.\?&%\#@_\\\\-]+?)\\]#', '<a href="\\1://\\2">\\1://\\2</a><br style="display: none;" />', $message); |
7c4a851fb5c5
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
Dan
parents:
57
diff
changeset
|
1663 |
|
230
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
203
diff
changeset
|
1664 |
preg_match_all('/\[((https?|ftp|irc):\/\/([^@\s\]"\':]+)?((([a-z0-9-]+\.)*)[a-z0-9-]+)(\/[A-z0-9_%\|~`!\!@#\$\^&\*\(\):;\.,\/-]*(\?(([a-z0-9_-]+)(=[A-z0-9_%\|~`\!@#\$\^&\*\(\):;\.,\/-\[\]]+)?((&([a-z0-9_-]+)(=[A-z0-9_%\|~`!\!@#\$\^&\*\(\):;\.,\/-]+)?)*))?)?)?) ([^\]]+)\]/is', $message, $ext_link); |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
203
diff
changeset
|
1665 |
|
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
203
diff
changeset
|
1666 |
// die('<pre>' . htmlspecialchars( print_r($ext_link, true) ) . '</pre>'); |
59
7c4a851fb5c5
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
Dan
parents:
57
diff
changeset
|
1667 |
|
7c4a851fb5c5
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
Dan
parents:
57
diff
changeset
|
1668 |
for ( $i = 0; $i < count($ext_link[0]); $i++ ) |
7c4a851fb5c5
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
Dan
parents:
57
diff
changeset
|
1669 |
{ |
7c4a851fb5c5
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
Dan
parents:
57
diff
changeset
|
1670 |
$text_parser->assign_vars(Array( |
165
199599eca89e
Fixed external links in tplWikiFormat to use my monster HTTP request regex
Dan
parents:
163
diff
changeset
|
1671 |
'HREF' => $ext_link[1][$i], |
59
7c4a851fb5c5
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
Dan
parents:
57
diff
changeset
|
1672 |
'FLAGS' => '', |
165
199599eca89e
Fixed external links in tplWikiFormat to use my monster HTTP request regex
Dan
parents:
163
diff
changeset
|
1673 |
'TEXT' => $ext_link[16][$i] |
59
7c4a851fb5c5
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
Dan
parents:
57
diff
changeset
|
1674 |
)); |
7c4a851fb5c5
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
Dan
parents:
57
diff
changeset
|
1675 |
$message = str_replace($ext_link[0][$i], $text_parser->run(), $message); |
7c4a851fb5c5
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
Dan
parents:
57
diff
changeset
|
1676 |
} |
7c4a851fb5c5
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
Dan
parents:
57
diff
changeset
|
1677 |
|
230
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
203
diff
changeset
|
1678 |
preg_match_all('/\[((https?|ftp|irc):\/\/([^@\s\]"\':]+)?((([a-z0-9-]+\.)*)[a-z0-9-]+)(\/[A-z0-9_%\|~`!\!@#\$\^&\*\(\):;\.,\/-]*(\?(([a-z0-9_-]+)(=[A-z0-9_%\|~`\!@#\$\^&\*\(\):;\.,\/-\[\]]+)?((&([a-z0-9_-]+)(=[A-z0-9_%\|~`!\!@#\$\^&\*\(\):;\.,\/-]+)?)*))?)?)?)\]/is', $message, $ext_link); |
59
7c4a851fb5c5
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
Dan
parents:
57
diff
changeset
|
1679 |
|
7c4a851fb5c5
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
Dan
parents:
57
diff
changeset
|
1680 |
for ( $i = 0; $i < count($ext_link[0]); $i++ ) |
7c4a851fb5c5
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
Dan
parents:
57
diff
changeset
|
1681 |
{ |
7c4a851fb5c5
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
Dan
parents:
57
diff
changeset
|
1682 |
$text_parser->assign_vars(Array( |
165
199599eca89e
Fixed external links in tplWikiFormat to use my monster HTTP request regex
Dan
parents:
163
diff
changeset
|
1683 |
'HREF' => $ext_link[1][$i], |
59
7c4a851fb5c5
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
Dan
parents:
57
diff
changeset
|
1684 |
'FLAGS' => '', |
165
199599eca89e
Fixed external links in tplWikiFormat to use my monster HTTP request regex
Dan
parents:
163
diff
changeset
|
1685 |
'TEXT' => htmlspecialchars($ext_link[1][$i]) |
59
7c4a851fb5c5
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
Dan
parents:
57
diff
changeset
|
1686 |
)); |
7c4a851fb5c5
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
Dan
parents:
57
diff
changeset
|
1687 |
$message = str_replace($ext_link[0][$i], $text_parser->run(), $message); |
7c4a851fb5c5
Minor IE4 compatibility fix; template parser now properly handles external links in the sidebar
Dan
parents:
57
diff
changeset
|
1688 |
} |
1 | 1689 |
|
1690 |
$parser1 = $this->makeParserText($tplvars['sidebar_section']); |
|
1691 |
$parser2 = $this->makeParserText($tplvars['sidebar_section_raw']); |
|
1692 |
||
60
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
59
diff
changeset
|
1693 |
preg_match_all('#\{slider(2|)=([^\}]*?)\}(.*?)\{\/slider(2|)\}#is', $message, $sb); |
1 | 1694 |
|
1695 |
// Modified to support the sweet new template var system |
|
1696 |
for($i=0;$i<sizeof($sb[1]);$i++) |
|
1697 |
{ |
|
1698 |
$p = ($sb[1][$i] == '2') ? $parser2 : $parser1; |
|
1699 |
$p->assign_vars(Array('TITLE'=>$sb[2][$i],'CONTENT'=>$sb[3][$i])); |
|
1700 |
$message = str_replace("{slider{$sb[1][$i]}={$sb[2][$i]}}{$sb[3][$i]}{/slider{$sb[4][$i]}}", $p->run(), $message); |
|
1701 |
} |
|
1702 |
||
1703 |
/* |
|
1704 |
Extras ;-) |
|
1705 |
$message = preg_replace('##is', '', $message); |
|
1706 |
$message = preg_replace('##is', '', $message); |
|
1707 |
$message = preg_replace('##is', '', $message); |
|
1708 |
$message = preg_replace('##is', '', $message); |
|
1709 |
$message = preg_replace('##is', '', $message); |
|
1710 |
*/ |
|
1711 |
||
1712 |
//die('<pre>'.htmlspecialchars($message).'</pre>'); |
|
1713 |
//eval($message); exit; |
|
1714 |
return $message; |
|
1715 |
} |
|
1716 |
||
1717 |
/** |
|
1718 |
* Print a text field that auto-completes a username entered into it. |
|
1719 |
* @param string $name - the name of the form field |
|
1720 |
* @return string |
|
1721 |
*/ |
|
1722 |
||
1723 |
function username_field($name, $value = false) |
|
1724 |
{ |
|
1725 |
$randomid = md5( time() . microtime() . mt_rand() ); |
|
184
d74ff822acc9
Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
174
diff
changeset
|
1726 |
$text = '<input name="'.$name.'" onkeyup="new AutofillUsername(this);" autocomplete="off" type="text" size="30" id="userfield_'.$randomid.'"'; |
1 | 1727 |
if($value) $text .= ' value="'.$value.'"'; |
1728 |
$text .= ' />'; |
|
1729 |
return $text; |
|
1730 |
} |
|
1731 |
||
1732 |
/** |
|
1733 |
* Print a text field that auto-completes a page name entered into it. |
|
1734 |
* @param string $name - the name of the form field |
|
1735 |
* @return string |
|
1736 |
*/ |
|
1737 |
||
1738 |
function pagename_field($name, $value = false) |
|
1739 |
{ |
|
1740 |
$randomid = md5( time() . microtime() . mt_rand() ); |
|
1741 |
$text = '<input name="'.$name.'" onkeyup="ajaxPageNameComplete(this)" type="text" size="30" id="pagefield_'.$randomid.'"'; |
|
1742 |
if($value) $text .= ' value="'.$value.'"'; |
|
1743 |
$text .= ' />'; |
|
1744 |
$text .= '<script type="text/javascript"> |
|
1745 |
var inp = document.getElementById(\'pagefield_' . $randomid . '\'); |
|
1746 |
var f = get_parent_form(inp); |
|
1747 |
if ( f ) |
|
1748 |
{ |
|
1749 |
if ( typeof(f.onsubmit) != \'function\' ) |
|
1750 |
{ |
|
1751 |
f.onsubmit = function() { |
|
1752 |
if ( !submitAuthorized ) |
|
1753 |
{ |
|
1754 |
return false; |
|
1755 |
} |
|
1756 |
} |
|
1757 |
} |
|
1758 |
}</script>'; |
|
1759 |
return $text; |
|
1760 |
} |
|
1761 |
||
1762 |
/** |
|
1763 |
* Sends a textarea that can be converted to and from a TinyMCE widget on the fly. |
|
1764 |
* @param string The name of the form element |
|
1765 |
* @param string The initial content. Optional, defaults to blank |
|
1766 |
* @param int Rows in textarea |
|
1767 |
* @param int Columns in textarea |
|
1768 |
* @return string HTML and Javascript code. |
|
1769 |
*/ |
|
1770 |
||
1771 |
function tinymce_textarea($name, $content = '', $rows = 20, $cols = 60) |
|
1772 |
{ |
|
370
b251818286b1
Localized registration errors and activation/COPPA e-mails
Dan
parents:
355
diff
changeset
|
1773 |
global $lang; |
1 | 1774 |
$randomid = md5(microtime() . mt_rand()); |
1775 |
$html = ''; |
|
1776 |
$html .= '<textarea name="' . $name . '" rows="'.$rows.'" cols="'.$cols.'" style="width: 100%;" id="toggleMCEroot_'.$randomid.'">' . $content . '</textarea>'; |
|
370
b251818286b1
Localized registration errors and activation/COPPA e-mails
Dan
parents:
355
diff
changeset
|
1777 |
$html .= '<div style="float: right; display: table;" id="mceSwitchAgent_' . $randomid . '">' . $lang->get('etc_tinymce_btn_text') . ' | <a href="#" onclick="if ( !KILL_SWITCH ) { toggleMCE_'.$randomid.'(); return false; }">' . $lang->get('etc_tinymce_btn_graphical') . '</a></div>'; |
1 | 1778 |
$html .= '<script type="text/javascript"> |
1779 |
// <![CDATA[ |
|
1780 |
function toggleMCE_'.$randomid.'() |
|
1781 |
{ |
|
1782 |
var the_obj = document.getElementById(\'toggleMCEroot_' . $randomid . '\'); |
|
1783 |
var panel = document.getElementById(\'mceSwitchAgent_' . $randomid . '\'); |
|
370
b251818286b1
Localized registration errors and activation/COPPA e-mails
Dan
parents:
355
diff
changeset
|
1784 |
var text_editor = $lang.get("etc_tinymce_btn_text"); |
b251818286b1
Localized registration errors and activation/COPPA e-mails
Dan
parents:
355
diff
changeset
|
1785 |
var graphical_editor = $lang.get("etc_tinymce_btn_graphical"); |
1 | 1786 |
if ( the_obj.dnIsMCE == "yes" ) |
1787 |
{ |
|
1788 |
$dynano(the_obj).destroyMCE(); |
|
370
b251818286b1
Localized registration errors and activation/COPPA e-mails
Dan
parents:
355
diff
changeset
|
1789 |
panel.innerHTML = text_editor + \' | <a href="#" onclick="if ( !KILL_SWITCH ) { toggleMCE_'.$randomid.'(); return false; }">\' + graphical_editor + \'</a>\'; |
1 | 1790 |
} |
1791 |
else |
|
1792 |
{ |
|
1793 |
$dynano(the_obj).switchToMCE(); |
|
370
b251818286b1
Localized registration errors and activation/COPPA e-mails
Dan
parents:
355
diff
changeset
|
1794 |
panel.innerHTML = \'<a href="#" onclick="if ( !KILL_SWITCH ) { toggleMCE_'.$randomid.'(); return false; }">\' + text_editor + \'</a> | \' + graphical_editor; |
1 | 1795 |
} |
1796 |
} |
|
1797 |
// ]]> |
|
1798 |
</script>'; |
|
1799 |
return $html; |
|
1800 |
} |
|
1801 |
||
1802 |
/** |
|
1803 |
* Allows individual parsing of template files. Similar to phpBB but follows the spirit of object-oriented programming ;) |
|
1804 |
* Returns on object of class templateIndividual. Usage instructions can be found in the inline docs for that class. |
|
1805 |
* @param $filename the filename of the template to be parsed |
|
1806 |
* @return object |
|
1807 |
*/ |
|
1808 |
||
1809 |
function makeParser($filename) |
|
1810 |
{ |
|
1811 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
1812 |
$filename = ENANO_ROOT.'/themes/'.$template->theme.'/'.$filename; |
|
1813 |
if(!file_exists($filename)) die('templateIndividual: file '.$filename.' does not exist'); |
|
1814 |
$code = file_get_contents($filename); |
|
1815 |
$parser = new templateIndividual($code); |
|
1816 |
return $parser; |
|
1817 |
} |
|
1818 |
||
1819 |
/** |
|
1820 |
* Same as $template->makeParser(), but takes a string instead of a filename. |
|
1821 |
* @param $text the text to parse |
|
1822 |
* @return object |
|
1823 |
*/ |
|
1824 |
||
1825 |
function makeParserText($code) |
|
1826 |
{ |
|
1827 |
$parser = new templateIndividual($code); |
|
1828 |
return $parser; |
|
1829 |
} |
|
1830 |
||
1831 |
/** |
|
1832 |
* Fetch the HTML for a plugin-added sidebar block |
|
1833 |
* @param $name the plugin name |
|
1834 |
* @return string |
|
1835 |
*/ |
|
1836 |
||
1837 |
function fetch_block($id) |
|
1838 |
{ |
|
1839 |
if(isset($this->plugin_blocks[$id])) return $this->plugin_blocks[$id]; |
|
1840 |
else return false; |
|
1841 |
} |
|
1842 |
||
1843 |
/** |
|
1844 |
* Fetches the contents of both sidebars. |
|
1845 |
* @return array - key 0 is left, key 1 is right |
|
1846 |
* @example list($left, $right) = $template->fetch_sidebar(); |
|
1847 |
*/ |
|
1848 |
||
1849 |
function fetch_sidebar() |
|
1850 |
{ |
|
1851 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
1852 |
||
1853 |
$left = ''; |
|
1854 |
$right = ''; |
|
1855 |
||
1856 |
if ( !$this->fetch_block('Links') ) |
|
1857 |
$this->initLinksWidget(); |
|
1858 |
||
286
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
1859 |
$q = $db->sql_query('SELECT item_id,sidebar_id,block_name,block_type,block_content FROM '.table_prefix.'sidebar' . "\n" |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
1860 |
. ' WHERE item_enabled=1 ORDER BY sidebar_id ASC, item_order ASC;'); |
1 | 1861 |
if(!$q) $db->_die('The sidebar text data could not be selected.'); |
1862 |
||
1863 |
$vars = $this->extract_vars('elements.tpl'); |
|
1864 |
||
1865 |
if(isset($vars['sidebar_top'])) |
|
1866 |
{ |
|
1867 |
$left .= $this->parse($vars['sidebar_top']); |
|
1868 |
$right .= $this->parse($vars['sidebar_top']); |
|
1869 |
} |
|
1870 |
while($row = $db->fetchrow()) |
|
1871 |
{ |
|
1872 |
switch($row['block_type']) |
|
1873 |
{ |
|
1874 |
case BLOCK_WIKIFORMAT: |
|
1875 |
default: |
|
1876 |
$parser = $this->makeParserText($vars['sidebar_section']); |
|
1877 |
$c = RenderMan::render($row['block_content']); |
|
1878 |
break; |
|
1879 |
case BLOCK_TEMPLATEFORMAT: |
|
1880 |
$parser = $this->makeParserText($vars['sidebar_section']); |
|
1881 |
$c = $this->tplWikiFormat($row['block_content']); |
|
1882 |
break; |
|
1883 |
case BLOCK_HTML: |
|
1884 |
$parser = $this->makeParserText($vars['sidebar_section_raw']); |
|
1885 |
$c = $row['block_content']; |
|
1886 |
break; |
|
1887 |
case BLOCK_PHP: |
|
1888 |
$parser = $this->makeParserText($vars['sidebar_section_raw']); |
|
1889 |
ob_start(); |
|
1890 |
@eval($row['block_content']); |
|
1891 |
$c = ob_get_contents(); |
|
1892 |
ob_end_clean(); |
|
1893 |
break; |
|
1894 |
case BLOCK_PLUGIN: |
|
419
b8b4e38825db
Unsuccessful attempt at fixing "dismiss"/"close manager" buttons in ACL editor; non-breaking change to template API to allow plugins to add "normal" sidebar widgets in addition to the special "raw" block type, specified as the third parameter to $template->sidebar_widget(). Defaults to false, which is old behavior; new behavior (enabled by passing TRUE as the 3rd param) means that the content of the block is primarily block-level links.
Dan
parents:
413
diff
changeset
|
1895 |
$parser = $this->makeParserText('{CONTENT}'); |
472
bc4b58034f4d
Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents:
471
diff
changeset
|
1896 |
$c = (gettype($this->fetch_block($row['block_content'])) == 'string') ? $this->fetch_block($row['block_content']) : /* This used to say "can't find plugin block" but I think it's more friendly to just silently hide it. */ ''; |
1 | 1897 |
break; |
1898 |
} |
|
1899 |
$parser->assign_vars(Array( 'TITLE'=>$this->tplWikiFormat($row['block_name']), 'CONTENT'=>$c )); |
|
419
b8b4e38825db
Unsuccessful attempt at fixing "dismiss"/"close manager" buttons in ACL editor; non-breaking change to template API to allow plugins to add "normal" sidebar widgets in addition to the special "raw" block type, specified as the third parameter to $template->sidebar_widget(). Defaults to false, which is old behavior; new behavior (enabled by passing TRUE as the 3rd param) means that the content of the block is primarily block-level links.
Dan
parents:
413
diff
changeset
|
1900 |
$run = $parser->run(); |
b8b4e38825db
Unsuccessful attempt at fixing "dismiss"/"close manager" buttons in ACL editor; non-breaking change to template API to allow plugins to add "normal" sidebar widgets in addition to the special "raw" block type, specified as the third parameter to $template->sidebar_widget(). Defaults to false, which is old behavior; new behavior (enabled by passing TRUE as the 3rd param) means that the content of the block is primarily block-level links.
Dan
parents:
413
diff
changeset
|
1901 |
if ( $row['block_type'] == BLOCK_PLUGIN ) |
b8b4e38825db
Unsuccessful attempt at fixing "dismiss"/"close manager" buttons in ACL editor; non-breaking change to template API to allow plugins to add "normal" sidebar widgets in addition to the special "raw" block type, specified as the third parameter to $template->sidebar_widget(). Defaults to false, which is old behavior; new behavior (enabled by passing TRUE as the 3rd param) means that the content of the block is primarily block-level links.
Dan
parents:
413
diff
changeset
|
1902 |
{ |
b8b4e38825db
Unsuccessful attempt at fixing "dismiss"/"close manager" buttons in ACL editor; non-breaking change to template API to allow plugins to add "normal" sidebar widgets in addition to the special "raw" block type, specified as the third parameter to $template->sidebar_widget(). Defaults to false, which is old behavior; new behavior (enabled by passing TRUE as the 3rd param) means that the content of the block is primarily block-level links.
Dan
parents:
413
diff
changeset
|
1903 |
$run = str_replace('{TITLE}', $this->tplWikiFormat($row['block_name']), $run); |
b8b4e38825db
Unsuccessful attempt at fixing "dismiss"/"close manager" buttons in ACL editor; non-breaking change to template API to allow plugins to add "normal" sidebar widgets in addition to the special "raw" block type, specified as the third parameter to $template->sidebar_widget(). Defaults to false, which is old behavior; new behavior (enabled by passing TRUE as the 3rd param) means that the content of the block is primarily block-level links.
Dan
parents:
413
diff
changeset
|
1904 |
} |
b8b4e38825db
Unsuccessful attempt at fixing "dismiss"/"close manager" buttons in ACL editor; non-breaking change to template API to allow plugins to add "normal" sidebar widgets in addition to the special "raw" block type, specified as the third parameter to $template->sidebar_widget(). Defaults to false, which is old behavior; new behavior (enabled by passing TRUE as the 3rd param) means that the content of the block is primarily block-level links.
Dan
parents:
413
diff
changeset
|
1905 |
if ($row['sidebar_id'] == SIDEBAR_LEFT ) $left .= $run; |
b8b4e38825db
Unsuccessful attempt at fixing "dismiss"/"close manager" buttons in ACL editor; non-breaking change to template API to allow plugins to add "normal" sidebar widgets in addition to the special "raw" block type, specified as the third parameter to $template->sidebar_widget(). Defaults to false, which is old behavior; new behavior (enabled by passing TRUE as the 3rd param) means that the content of the block is primarily block-level links.
Dan
parents:
413
diff
changeset
|
1906 |
elseif($row['sidebar_id'] == SIDEBAR_RIGHT) $right .= $run; |
1 | 1907 |
unset($parser); |
1908 |
} |
|
1909 |
$db->free_result(); |
|
1910 |
if(isset($vars['sidebar_bottom'])) |
|
1911 |
{ |
|
1912 |
$left .= $this->parse($vars['sidebar_bottom']); |
|
1913 |
$right .= $this->parse($vars['sidebar_bottom']); |
|
1914 |
} |
|
1915 |
$min = ''; |
|
1916 |
if(isset($vars['sidebar_top'])) |
|
1917 |
{ |
|
1918 |
$min .= $this->parse($vars['sidebar_top']); |
|
1919 |
} |
|
1920 |
if(isset($vars['sidebar_bottom'])) |
|
1921 |
{ |
|
1922 |
$min .= $this->parse($vars['sidebar_bottom']); |
|
1923 |
} |
|
1924 |
return Array($left, $right, $min); |
|
1925 |
} |
|
1926 |
||
1927 |
function initLinksWidget() |
|
1928 |
{ |
|
1929 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
1930 |
// SourceForge/W3C buttons |
|
1931 |
$ob = Array(); |
|
27
dd659f6ba891
Converting all tables on new installations to UTF-8; this may break MySQL 4.0 compatibility; several minor cosmetic fixes; set Powered button under Links to "on" by default
Dan
parents:
22
diff
changeset
|
1932 |
$admintitle = ( $session->user_level >= USER_LEVEL_ADMIN ) ? 'title="You may disable this button in the admin panel under General Configuration."' : ''; |
1 | 1933 |
if(getConfig('sflogo_enabled')=='1') |
1934 |
{ |
|
203 | 1935 |
$sflogo_secure = ( isset($_SERVER['HTTPS']) ) ? 'https' : 'http'; |
1936 |
$ob[] = '<a style="text-align: center;" href="http://sourceforge.net/" onclick="if ( !KILL_SWITCH ) { window.open(this.href);return false; }"><img style="border-width: 0px;" alt="SourceForge.net Logo" src="' . $sflogo_secure . '://sflogo.sourceforge.net/sflogo.php?group_id='.getConfig('sflogo_groupid').'&type='.getConfig('sflogo_type').'" /></a>'; |
|
1 | 1937 |
} |
57
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
parents:
54
diff
changeset
|
1938 |
if(getConfig('w3c_v32') =='1') $ob[] = '<a style="text-align: center;" href="http://validator.w3.org/check?uri=referer" onclick="if ( !KILL_SWITCH ) { window.open(this.href);return false; }"><img style="border: 0px solid #FFFFFF;" alt="Valid HTML 3.2" src="http://www.w3.org/Icons/valid-html32" /></a>'; |
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
parents:
54
diff
changeset
|
1939 |
if(getConfig('w3c_v40') =='1') $ob[] = '<a style="text-align: center;" href="http://validator.w3.org/check?uri=referer" onclick="if ( !KILL_SWITCH ) { window.open(this.href);return false; }"><img style="border: 0px solid #FFFFFF;" alt="Valid HTML 4.0" src="http://www.w3.org/Icons/valid-html40" /></a>'; |
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
parents:
54
diff
changeset
|
1940 |
if(getConfig('w3c_v401') =='1') $ob[] = '<a style="text-align: center;" href="http://validator.w3.org/check?uri=referer" onclick="if ( !KILL_SWITCH ) { window.open(this.href);return false; }"><img style="border: 0px solid #FFFFFF;" alt="Valid HTML 4.01" src="http://www.w3.org/Icons/valid-html401" /></a>'; |
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
parents:
54
diff
changeset
|
1941 |
if(getConfig('w3c_vxhtml10')=='1') $ob[] = '<a style="text-align: center;" href="http://validator.w3.org/check?uri=referer" onclick="if ( !KILL_SWITCH ) { window.open(this.href);return false; }"><img style="border: 0px solid #FFFFFF;" alt="Valid XHTML 1.0" src="http://www.w3.org/Icons/valid-xhtml10" /></a>'; |
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
parents:
54
diff
changeset
|
1942 |
if(getConfig('w3c_vxhtml11')=='1') $ob[] = '<a style="text-align: center;" href="http://validator.w3.org/check?uri=referer" onclick="if ( !KILL_SWITCH ) { window.open(this.href);return false; }"><img style="border: 0px solid #FFFFFF;" alt="Valid XHTML 1.1" src="http://www.w3.org/Icons/valid-xhtml11" /></a>'; |
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
parents:
54
diff
changeset
|
1943 |
if(getConfig('w3c_vcss') =='1') $ob[] = '<a style="text-align: center;" href="http://validator.w3.org/check?uri=referer" onclick="if ( !KILL_SWITCH ) { window.open(this.href);return false; }"><img style="border: 0px solid #FFFFFF;" alt="Valid CSS" src="http://www.w3.org/Icons/valid-css" /></a>'; |
b354deeaa4c4
Vastly improved compatibility with older versions of IE, particularly 5.0, through the use of a kill switch that turns off all AJAX functions
Dan
parents:
54
diff
changeset
|
1944 |
if(getConfig('dbd_button') =='1') $ob[] = '<a style="text-align: center;" href="http://www.defectivebydesign.org/join/button" onclick="if ( !KILL_SWITCH ) { window.open(this.href);return false; }"><img style="border: 0px solid #FFFFFF;" alt="DRM technology restricts what you can do with your computer" src="http://defectivebydesign.org/sites/nodrm.civicactions.net/files/images/dbd_sm_btn.gif" /><br /><small>Protect your freedom >></small></a>'; |
1 | 1945 |
|
1946 |
$code = $plugins->setHook('links_widget'); |
|
1947 |
foreach ( $code as $cmd ) |
|
1948 |
{ |
|
1949 |
eval($cmd); |
|
1950 |
} |
|
1951 |
||
71 | 1952 |
if(count($ob) > 0 || getConfig('powered_btn') == '1') $sb_links = '<div style="text-align: center; padding: 5px 0;">'. ( ( getConfig('powered_btn') == '1' ) ? $this->fading_button : '' ) . implode('<br />', $ob).'</div>'; |
1 | 1953 |
else $sb_links = ''; |
1954 |
||
1955 |
$this->sidebar_widget('Links', $sb_links); |
|
1956 |
} |
|
1957 |
||
1958 |
/** |
|
1959 |
* Builds a box showing unread private messages. |
|
1960 |
*/ |
|
1961 |
||
1962 |
function notify_unread_pms() |
|
1963 |
{ |
|
1964 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
322
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
1965 |
if ( ( $paths->page_id == 'PrivateMessages' || $paths->page_id == 'Preferences' ) && $paths->namespace == 'Special' ) |
1 | 1966 |
{ |
1967 |
return ''; |
|
1968 |
} |
|
1969 |
$ob = '<div class="usermessage">'."\n"; |
|
1970 |
$s = ( $session->unread_pms == 1 ) ? '' : 's'; |
|
1971 |
$ob .= " <b>You have $session->unread_pms <a href=" . '"' . makeUrlNS('Special', 'PrivateMessages' ) . '"' . ">unread private message$s</a>.</b><br />\n Messages: "; |
|
1972 |
$q = $db->sql_query('SELECT message_id,message_from,subject,date FROM '.table_prefix.'privmsgs WHERE message_to=\'' . $session->username . '\' AND message_read=0 ORDER BY date DESC;'); |
|
1973 |
if ( !$q ) |
|
1974 |
$db->_die(); |
|
1975 |
$messages = array(); |
|
1976 |
while ( $row = $db->fetchrow() ) |
|
1977 |
{ |
|
345
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
parents:
335
diff
changeset
|
1978 |
$messages[] = '<a href="' . makeUrlNS('Special', 'PrivateMessages/View/' . $row['message_id']) . '" title="Sent ' . enano_date('F d, Y h:i a', $row['date']) . ' by ' . $row['message_from'] . '">' . $row['subject'] . '</a>'; |
1 | 1979 |
} |
1980 |
$ob .= implode(",\n " , $messages)."\n"; |
|
1981 |
$ob .= '</div>'."\n"; |
|
1982 |
return $ob; |
|
1983 |
} |
|
1984 |
||
1985 |
} // class template |
|
1986 |
||
1987 |
/** |
|
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
1988 |
* The core of the template compilation engine. Independent from the Enano API for failsafe operation. |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
1989 |
* @param string text to process |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
1990 |
* @return string Compiled PHP code |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
1991 |
* @access private |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
1992 |
*/ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
1993 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
1994 |
function template_compiler_core($text) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
1995 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
1996 |
global $db, $session, $paths, $template, $plugins; // Common objects |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
1997 |
// A random seed used to salt tags |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
1998 |
$seed = md5 ( microtime() . mt_rand() ); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
1999 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2000 |
// Strip out PHP sections |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2001 |
preg_match_all('/<\?php(.+?)\?>/is', $text, $php_matches); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2002 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2003 |
foreach ( $php_matches[0] as $i => $match ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2004 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2005 |
// Substitute the PHP section with a random tag |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2006 |
$tag = "{PHP:$i:$seed}"; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2007 |
$text = str_replace_once($match, $tag, $text); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2008 |
} |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2009 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2010 |
// Escape slashes and single quotes in template code |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2011 |
$text = str_replace('\\', '\\\\', $text); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2012 |
$text = str_replace('\'', '\\\'', $text); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2013 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2014 |
// Initialize the PHP compiled code |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2015 |
$text = 'ob_start(); echo \''.$text.'\'; $tpl_code = ob_get_contents(); ob_end_clean(); return $tpl_code;'; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2016 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2017 |
## |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2018 |
## Main rules |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2019 |
## |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2020 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2021 |
// |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2022 |
// Conditionals |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2023 |
// |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2024 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2025 |
$keywords = array('BEGIN', 'BEGINNOT', 'IFSET', 'IFPLUGIN'); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2026 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2027 |
// only do this if the plugins API is loaded |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2028 |
if ( is_object(@$plugins) ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2029 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2030 |
$code = $plugins->setHook('template_compile_logic_keyword'); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2031 |
foreach ( $code as $cmd ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2032 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2033 |
eval($cmd); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2034 |
} |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2035 |
} |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2036 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2037 |
$keywords = implode('|', $keywords); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2038 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2039 |
// Matches |
534 | 2040 |
// 1 2 3 4 56 7 8 9 |
2041 |
$regexp = '/(<!-- ('. $keywords .') ([A-z0-9_-]+) -->)(.*)((<!-- BEGINELSE \\3 -->)(.*))?(<!-- END(IF)? \\3 -->)/isU'; |
|
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2042 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2043 |
/* |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2044 |
The way this works is: match all blocks using the standard form with a different keyword in the block each time, |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2045 |
and replace them with appropriate PHP logic. Plugin-extensible now. :-) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2046 |
*/ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2047 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2048 |
profiler_log("[template] compiler matchout start"); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2049 |
preg_match_all($regexp, $text, $matches); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2050 |
profiler_log("[template] compiler core loop start"); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2051 |
for ( $i = 0; $i < count($matches[0]); $i++ ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2052 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2053 |
$start_tag =& $matches[1][$i]; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2054 |
$type =& $matches[2][$i]; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2055 |
$test =& $matches[3][$i]; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2056 |
$particle_true =& $matches[4][$i]; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2057 |
$else_tag =& $matches[6][$i]; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2058 |
$particle_else =& $matches[7][$i]; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2059 |
$end_tag =& $matches[8][$i]; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2060 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2061 |
switch($type) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2062 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2063 |
case 'BEGIN': |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2064 |
$cond = "isset(\$this->tpl_bool['$test']) && \$this->tpl_bool['$test']"; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2065 |
break; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2066 |
case 'BEGINNOT': |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2067 |
$cond = "!isset(\$this->tpl_bool['$test']) || ( isset(\$this->tpl_bool['$test']) && !\$this->tpl_bool['$test'] )"; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2068 |
break; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2069 |
case 'IFPLUGIN': |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2070 |
$cond = "getConfig('plugin_$test') == '1'"; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2071 |
break; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2072 |
case 'IFSET': |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2073 |
$cond = "isset(\$this->tpl_strings['$test'])"; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2074 |
break; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2075 |
default: |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2076 |
// only do this if the plugins API is loaded |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2077 |
if ( is_object(@$plugins) ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2078 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2079 |
$code = $plugins->setHook('template_compile_logic_cond'); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2080 |
foreach ( $code as $cmd ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2081 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2082 |
eval($cmd); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2083 |
} |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2084 |
} |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2085 |
break; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2086 |
} |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2087 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2088 |
if ( !isset($cond) || ( isset($cond) && !is_string($cond) ) ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2089 |
continue; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2090 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2091 |
$tag_complete = <<<TPLCODE |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2092 |
'; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2093 |
/* START OF CONDITION: $type ($test) */ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2094 |
if ( $cond ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2095 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2096 |
echo '$particle_true'; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2097 |
/* ELSE OF CONDITION: $type ($test) */ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2098 |
} |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2099 |
else |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2100 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2101 |
echo '$particle_else'; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2102 |
/* END OF CONDITION: $type ($test) */ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2103 |
} |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2104 |
echo ' |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2105 |
TPLCODE; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2106 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2107 |
$text = str_replace_once($matches[0][$i], $tag_complete, $text); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2108 |
} |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2109 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2110 |
profiler_log("[template] compiler core loop end"); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2111 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2112 |
// For debugging ;-) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2113 |
// die("<pre><?php\n" . htmlspecialchars($text."\n\n".print_r($matches,true)) . "\n\n?></pre>"); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2114 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2115 |
// |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2116 |
// Data substitution/variables |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2117 |
// |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2118 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2119 |
// System messages |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2120 |
$text = preg_replace('/<!-- SYSMSG ([A-z0-9\._-]+?) -->/is', '\' . $template->tplWikiFormat($paths->sysMsg(\'\\1\')) . \'', $text); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2121 |
|
534 | 2122 |
// only do this if the plugins API is loaded |
2123 |
if ( is_object(@$plugins) ) |
|
2124 |
{ |
|
2125 |
$code = $plugins->setHook('template_compile_subst'); |
|
2126 |
foreach ( $code as $cmd ) |
|
2127 |
{ |
|
2128 |
eval($cmd); |
|
2129 |
} |
|
2130 |
} |
|
2131 |
||
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2132 |
// Template variables |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2133 |
$text = preg_replace('/\{([A-z0-9_-]+?)\}/is', '\' . $this->tpl_strings[\'\\1\'] . \'', $text); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2134 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2135 |
// Reinsert PHP |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2136 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2137 |
foreach ( $php_matches[1] as $i => $match ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2138 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2139 |
// Substitute the random tag with the "real" PHP code |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2140 |
$tag = "{PHP:$i:$seed}"; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2141 |
$text = str_replace_once($tag, "'; $match echo '", $text); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2142 |
} |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2143 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2144 |
// echo('<pre>' . htmlspecialchars($text) . '</pre>'); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2145 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2146 |
profiler_log("[template] compiler subst end"); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2147 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2148 |
return $text; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2149 |
} |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2150 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2151 |
/** |
1 | 2152 |
* Handles parsing of an individual template file. Instances should only be created through $template->makeParser(). To use: |
2153 |
* - Call $template->makeParser(template file name) - file name should be something.tpl, css/whatever.css, etc. |
|
2154 |
* - Make an array of strings you want the template to access. $array['STRING'] would be referenced in the template like {STRING} |
|
2155 |
* - Make an array of boolean values. These can be used for conditionals in the template (<!-- IF something --> whatever <!-- ENDIF something -->) |
|
2156 |
* - Call assign_vars() to pass the strings to the template parser. Same thing with assign_bool(). |
|
2157 |
* - Call run() to parse the template and get your fully compiled HTML. |
|
2158 |
* @access private |
|
2159 |
*/ |
|
2160 |
||
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2161 |
class templateIndividual extends template |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2162 |
{ |
1 | 2163 |
var $tpl_strings, $tpl_bool, $tpl_code; |
2164 |
var $compiled = false; |
|
2165 |
/** |
|
2166 |
* Constructor. |
|
2167 |
*/ |
|
2168 |
function __construct($text) |
|
2169 |
{ |
|
2170 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
2171 |
$this->tpl_code = $text; |
|
2172 |
$this->tpl_strings = $template->tpl_strings; |
|
2173 |
$this->tpl_bool = $template->tpl_bool; |
|
2174 |
} |
|
2175 |
/** |
|
345
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
parents:
335
diff
changeset
|
2176 |
* PHP 4 constructor. Deprecated in 1.1.x. |
1 | 2177 |
*/ |
345
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
parents:
335
diff
changeset
|
2178 |
/* |
1 | 2179 |
function templateIndividual($text) |
2180 |
{ |
|
2181 |
$this->__construct($text); |
|
2182 |
} |
|
345
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
parents:
335
diff
changeset
|
2183 |
*/ |
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
2184 |
|
1 | 2185 |
/** |
2186 |
* Assigns an array of string values to the template. Strings can be accessed from the template by inserting {KEY_NAME} in the template file. |
|
2187 |
* @param $vars array |
|
2188 |
*/ |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
2189 |
|
1 | 2190 |
function assign_vars($vars) |
2191 |
{ |
|
2192 |
$this->tpl_strings = array_merge($this->tpl_strings, $vars); |
|
2193 |
} |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
2194 |
|
1 | 2195 |
/** |
2196 |
* Assigns an array of boolean values to the template. These can be used for <!-- IF ... --> statements. |
|
2197 |
* @param $vars array |
|
2198 |
*/ |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
2199 |
|
1 | 2200 |
function assign_bool($vars) |
2201 |
{ |
|
2202 |
$this->tpl_bool = array_merge($this->tpl_bool, $vars); |
|
2203 |
} |
|
557
26479224936a
Modified $template->init_vars() to pivot to local page metadata and permissions from a PageProcessor object instead of global data from $paths and permissions from $session to allow redirects to affect on-page controls as well as the actual content (only partially complete, protection and several other elements still need to be localized)
Dan
parents:
555
diff
changeset
|
2204 |
|
1 | 2205 |
/** |
2206 |
* Compiles and executes the template code. |
|
2207 |
* @return string |
|
2208 |
*/ |
|
2209 |
function run() |
|
2210 |
{ |
|
2211 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
2212 |
if(!$this->compiled) |
|
2213 |
{ |
|
2214 |
$this->tpl_code = $this->compile_template_text($this->tpl_code); |
|
2215 |
$this->compiled = true; |
|
2216 |
} |
|
2217 |
return eval($this->tpl_code); |
|
2218 |
} |
|
2219 |
} |
|
2220 |
||
2221 |
/** |
|
2222 |
* A version of the template compiler that does not rely at all on the other parts of Enano. Used during installation and for showing |
|
2223 |
* "critical error" messages. ** REQUIRES ** the Oxygen theme. |
|
2224 |
*/ |
|
2225 |
||
286
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
2226 |
class template_nodb |
b2f985e4cef3
Fixed a number of issues with SQL query readability and some undefined index-ish errors; consequently the SQL report feature was added
Dan
parents:
276
diff
changeset
|
2227 |
{ |
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2228 |
var $fading_button, $tpl_strings, $tpl_bool, $theme, $style, $no_headers, $additional_headers, $sidebar_extra, $sidebar_widgets, $toolbar_menu, $theme_list, $named_theme_list; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2229 |
function __construct() |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2230 |
{ |
1 | 2231 |
$this->tpl_bool = Array(); |
2232 |
$this->tpl_strings = Array(); |
|
2233 |
$this->sidebar_extra = ''; |
|
2234 |
$this->sidebar_widgets = ''; |
|
2235 |
$this->toolbar_menu = ''; |
|
272
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
256
diff
changeset
|
2236 |
$this->additional_headers = '<style type="text/css">div.pagenav { border-top: 1px solid #CCC; padding-top: 7px; margin-top: 10px; }</style>'; |
1 | 2237 |
|
276
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
parents:
272
diff
changeset
|
2238 |
$this->fading_button = '<div style="background-image: url('.scriptPath.'/images/about-powered-enano-hover.png); background-repeat: no-repeat; width: 88px; height: 31px; margin: 0 auto 5px auto;"> |
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
parents:
272
diff
changeset
|
2239 |
<a href="http://enanocms.org/" onclick="window.open(this.href); return false;"><img style="border-width: 0;" alt=" " src="'.scriptPath.'/images/about-powered-enano.png" onmouseover="domOpacity(this, 100, 0, 500);" onmouseout="domOpacity(this, 0, 100, 500);" /></a> |
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
parents:
272
diff
changeset
|
2240 |
</div>'; |
acfdccf7a2bf
Re-sync Oxygen and Mint and Oxygen simple with Oxygen main; a couple improvements to the redirect-on-no-config code
Dan
parents:
272
diff
changeset
|
2241 |
|
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2242 |
// get list of themes |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2243 |
$this->theme_list = array(); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2244 |
$this->named_theme_list = array(); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2245 |
$order = 0; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2246 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2247 |
if ( $dir = @opendir( ENANO_ROOT . '/themes' ) ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2248 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2249 |
while ( $dh = @readdir($dir) ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2250 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2251 |
if ( $dh == '.' || $dh == '..' || !is_dir( ENANO_ROOT . "/themes/$dh" ) ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2252 |
continue; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2253 |
$theme_dir = ENANO_ROOT . "/themes/$dh"; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2254 |
if ( !file_exists("$theme_dir/theme.cfg") ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2255 |
continue; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2256 |
$data = array( |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2257 |
'theme_id' => $dh, |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2258 |
'theme_name' => ucwords($dh), |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2259 |
'enabled' => 1, |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2260 |
'theme_order' => ++$order, |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2261 |
'default_style' => $this->get_default_style($dh) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2262 |
); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2263 |
$this->named_theme_list[$dh] = $data; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2264 |
$this->theme_list[] =& $this->named_theme_list[$dh]; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2265 |
} |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2266 |
@closedir($dir); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2267 |
} |
1 | 2268 |
} |
2269 |
function template() { |
|
2270 |
$this->__construct(); |
|
2271 |
} |
|
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2272 |
function get_default_style($theme_id) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2273 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2274 |
if ( !is_dir( ENANO_ROOT . "/themes/$theme_id/css" ) ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2275 |
return false; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2276 |
$ds = false; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2277 |
if ( $dh = @opendir( ENANO_ROOT . "/themes/$theme_id/css" ) ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2278 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2279 |
while ( $dir = @readdir($dh) ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2280 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2281 |
if ( !preg_match('/\.css$/', $dir) ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2282 |
continue; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2283 |
if ( $dir == '_printable.css' ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2284 |
continue; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2285 |
$ds = preg_replace('/\.css$/', '', $dir); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2286 |
break; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2287 |
} |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2288 |
closedir($dh); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2289 |
} |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2290 |
else |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2291 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2292 |
return false; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2293 |
} |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2294 |
return $ds; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2295 |
} |
1 | 2296 |
function get_css($s = false) { |
2297 |
if($s) |
|
2298 |
return $this->process_template('css/'.$s); |
|
2299 |
else |
|
2300 |
return $this->process_template('css/'.$this->style.'.css'); |
|
2301 |
} |
|
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2302 |
function load_theme($name, $css, $auto_init = true) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2303 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2304 |
if ( !isset($this->named_theme_list[$name]) ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2305 |
$name = $this->theme_list[0]['theme_id']; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2306 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2307 |
if ( !file_exists(ENANO_ROOT . "/themes/$name/css/$css.css") ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2308 |
$css = $this->named_theme_list[$name]['default_style']; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2309 |
|
1 | 2310 |
$this->theme = $name; |
2311 |
$this->style = $css; |
|
2312 |
||
2313 |
$this->tpl_strings['SCRIPTPATH'] = scriptPath; |
|
2314 |
if ( $auto_init ) |
|
2315 |
$this->init_vars(); |
|
2316 |
} |
|
272
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
256
diff
changeset
|
2317 |
function add_header($html) |
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
256
diff
changeset
|
2318 |
{ |
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
256
diff
changeset
|
2319 |
$this->additional_headers .= "\n<!-- ----------------------------------------------------------- -->\n\n " . $html; |
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
256
diff
changeset
|
2320 |
} |
1 | 2321 |
function init_vars() |
2322 |
{ |
|
2323 |
global $sideinfo; |
|
2324 |
global $this_page; |
|
243
a7d0f2711df1
Installer localization started. Welcome, License, and SysReqs pages are fully localized.
Dan
parents:
231
diff
changeset
|
2325 |
global $lang; |
1 | 2326 |
global $db, $session, $paths, $template, $plugins; // Common objects |
2327 |
$tplvars = $this->extract_vars('elements.tpl'); |
|
2328 |
$tb = ''; |
|
2329 |
// Get the "article" button text (depends on namespace) |
|
355
d15e4411ef65
Fixed a coupla minor bugs with the template_nodb class wrongly referencing $lang
Dan
parents:
349
diff
changeset
|
2330 |
if(defined('IN_ENANO_INSTALL') && is_object($lang)) $ns = $lang->get('meta_btn_article'); |
1 | 2331 |
else $ns = 'system error page'; |
243
a7d0f2711df1
Installer localization started. Welcome, License, and SysReqs pages are fully localized.
Dan
parents:
231
diff
changeset
|
2332 |
$t = str_replace('{FLAGS}', 'onclick="return false;" title="Hey! A button that doesn\'t do anything. Clever..." accesskey="a"', $tplvars['toolbar_button']); |
1 | 2333 |
$t = str_replace('{HREF}', '#', $t); |
2334 |
$t = str_replace('{TEXT}', $ns, $t); |
|
2335 |
$tb .= $t; |
|
2336 |
||
2337 |
// Page toolbar |
|
2338 |
||
2339 |
$this->tpl_bool = Array( |
|
2340 |
'auth_admin'=>true, |
|
2341 |
'user_logged_in'=>true, |
|
2342 |
'right_sidebar'=>false, |
|
2343 |
); |
|
2344 |
$this->tpl_bool['in_sidebar_admin'] = false; |
|
2345 |
||
2346 |
$this->tpl_bool['auth_rename'] = false; |
|
2347 |
||
2348 |
$asq = $asa = ''; |
|
2349 |
||
2350 |
$this->tpl_bool['fixed_menus'] = false; |
|
2351 |
$slink = defined('IN_ENANO_INSTALL') ? scriptPath.'/install.php?mode=css' : makeUrlNS('Special', 'CSS'); |
|
2352 |
||
2353 |
$title = ( is_object($paths) ) ? $paths->page : 'Critical error'; |
|
2354 |
||
243
a7d0f2711df1
Installer localization started. Welcome, License, and SysReqs pages are fully localized.
Dan
parents:
231
diff
changeset
|
2355 |
$headers = '<style type="text/css">div.pagenav { border-top: 1px solid #CCC; padding-top: 7px; margin-top: 10px; }</style>'; |
244
09f8a9a03ccf
Localized installer database info page and finished localizing sysreqs page
Dan
parents:
243
diff
changeset
|
2356 |
|
09f8a9a03ccf
Localized installer database info page and finished localizing sysreqs page
Dan
parents:
243
diff
changeset
|
2357 |
$js_dynamic = ''; |
243
a7d0f2711df1
Installer localization started. Welcome, License, and SysReqs pages are fully localized.
Dan
parents:
231
diff
changeset
|
2358 |
if ( defined('IN_ENANO_INSTALL') ) |
a7d0f2711df1
Installer localization started. Welcome, License, and SysReqs pages are fully localized.
Dan
parents:
231
diff
changeset
|
2359 |
{ |
244
09f8a9a03ccf
Localized installer database info page and finished localizing sysreqs page
Dan
parents:
243
diff
changeset
|
2360 |
$js_dynamic .= '<script type="text/javascript" src="install.php?mode=langjs"></script>'; |
243
a7d0f2711df1
Installer localization started. Welcome, License, and SysReqs pages are fully localized.
Dan
parents:
231
diff
changeset
|
2361 |
} |
244
09f8a9a03ccf
Localized installer database info page and finished localizing sysreqs page
Dan
parents:
243
diff
changeset
|
2362 |
$js_dynamic .= '<script type="text/javascript">var title="'. $title .'"; var scriptPath="'.scriptPath.'"; var ENANO_SID=""; var AES_BITS='.AES_BITS.'; var AES_BLOCKSIZE=' . AES_BLOCKSIZE . '; var pagepass=\'\'; var ENANO_LANG_ID = 1;</script>'; |
243
a7d0f2711df1
Installer localization started. Welcome, License, and SysReqs pages are fully localized.
Dan
parents:
231
diff
changeset
|
2363 |
|
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2364 |
global $site_name, $site_desc; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2365 |
$site_default_name = ( !empty($site_name) ) ? $site_name : 'Critical error'; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2366 |
$site_default_desc = ( !empty($site_desc) ) ? $site_desc : 'This site is experiencing a problem and cannot load.'; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2367 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2368 |
$site_name_final = ( defined('IN_ENANO_INSTALL') && is_object($lang) ) ? $lang->get('meta_site_name') : $site_default_name; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2369 |
$site_desc_final = ( defined('IN_ENANO_INSTALL') && is_object($lang) ) ? $lang->get('meta_site_desc') : $site_default_desc; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2370 |
|
1 | 2371 |
// The rewritten template engine will process all required vars during the load_template stage instead of (cough) re-processing everything each time around. |
2372 |
$tpl_strings = Array( |
|
2373 |
'PAGE_NAME'=>$this_page, |
|
2374 |
'PAGE_URLNAME'=>'Null', |
|
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2375 |
'SITE_NAME' => $site_name_final, |
1 | 2376 |
'USERNAME'=>'admin', |
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2377 |
'SITE_DESC' => $site_desc_final, |
1 | 2378 |
'TOOLBAR'=>$tb, |
2379 |
'SCRIPTPATH'=>scriptPath, |
|
2380 |
'CONTENTPATH'=>contentPath, |
|
2381 |
'ADMIN_SID_QUES'=>$asq, |
|
2382 |
'ADMIN_SID_AMP'=>$asa, |
|
2383 |
'ADMIN_SID_AMP_HTML'=>'', |
|
272
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
256
diff
changeset
|
2384 |
'ADDITIONAL_HEADERS'=>$this->additional_headers, |
1 | 2385 |
'SIDEBAR_EXTRA'=>'', |
355
d15e4411ef65
Fixed a coupla minor bugs with the template_nodb class wrongly referencing $lang
Dan
parents:
349
diff
changeset
|
2386 |
'COPYRIGHT'=>( defined('IN_ENANO_INSTALL') && is_object($lang) ) ? $lang->get('meta_enano_copyright') : ( defined('ENANO_CONFIG_FETCHED') ? getConfig('copyright_notice') : '' ), |
1 | 2387 |
'TOOLBAR_EXTRAS'=>'', |
125
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
118
diff
changeset
|
2388 |
'REQUEST_URI'=>( isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '' ).$_SERVER['REQUEST_URI'], |
1 | 2389 |
'STYLE_LINK'=>$slink, |
2390 |
'LOGOUT_LINK'=>'', |
|
2391 |
'THEME_LINK'=>'', |
|
2392 |
'TEMPLATE_DIR'=>scriptPath.'/themes/'.$this->theme, |
|
2393 |
'THEME_ID'=>$this->theme, |
|
2394 |
'STYLE_ID'=>$this->style, |
|
244
09f8a9a03ccf
Localized installer database info page and finished localizing sysreqs page
Dan
parents:
243
diff
changeset
|
2395 |
'JS_DYNAMIC_VARS'=>$js_dynamic, |
1 | 2396 |
'SIDEBAR_RIGHT'=>'', |
377
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
parents:
372
diff
changeset
|
2397 |
'REPORT_URI' => '', |
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
parents:
372
diff
changeset
|
2398 |
'URL_ABOUT_ENANO' => 'http://enanocms.org/' |
1 | 2399 |
); |
2400 |
$this->tpl_strings = array_merge($tpl_strings, $this->tpl_strings); |
|
2401 |
||
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2402 |
$sidebar = ( is_array(@$sideinfo) ) ? $sideinfo : ''; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2403 |
if ( $sidebar != '' ) |
1 | 2404 |
{ |
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2405 |
if ( isset($tplvars['sidebar_top']) ) |
1 | 2406 |
{ |
2407 |
$text = $this->makeParserText($tplvars['sidebar_top']); |
|
2408 |
$top = $text->run(); |
|
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2409 |
} |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2410 |
else |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2411 |
{ |
1 | 2412 |
$top = ''; |
2413 |
} |
|
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2414 |
|
1 | 2415 |
$p = $this->makeParserText($tplvars['sidebar_section']); |
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2416 |
$b = $this->makeParserText($tplvars['sidebar_button']); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2417 |
$sidebar_text = ''; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2418 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2419 |
foreach ( $sidebar as $title => $links ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2420 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2421 |
$p->assign_vars(array( |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2422 |
'TITLE' => $title |
1 | 2423 |
)); |
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2424 |
// build content |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2425 |
$content = ''; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2426 |
foreach ( $links as $link_text => $url ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2427 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2428 |
$b->assign_vars(array( |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2429 |
'HREF' => htmlspecialchars($url), |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2430 |
'FLAGS' => '', |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2431 |
'TEXT' => $link_text |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2432 |
)); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2433 |
$content .= $b->run(); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2434 |
} |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2435 |
$p->assign_vars(array( |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2436 |
'CONTENT' => $content |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2437 |
)); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2438 |
$sidebar_text .= $p->run(); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2439 |
} |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2440 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2441 |
if ( isset($tplvars['sidebar_bottom']) ) |
1 | 2442 |
{ |
2443 |
$text = $this->makeParserText($tplvars['sidebar_bottom']); |
|
2444 |
$bottom = $text->run(); |
|
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2445 |
} |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2446 |
else |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2447 |
{ |
1 | 2448 |
$bottom = ''; |
2449 |
} |
|
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2450 |
$sidebar = $top . $sidebar_text . $bottom; |
1 | 2451 |
} |
2452 |
$this->tpl_strings['SIDEBAR_LEFT'] = $sidebar; |
|
2453 |
||
2454 |
$this->tpl_bool['sidebar_left'] = ( $this->tpl_strings['SIDEBAR_LEFT'] != '') ? true : false; |
|
2455 |
$this->tpl_bool['sidebar_right'] = ( $this->tpl_strings['SIDEBAR_RIGHT'] != '') ? true : false; |
|
2456 |
$this->tpl_bool['right_sidebar'] = $this->tpl_bool['sidebar_right']; // backward compatibility |
|
2457 |
$this->tpl_bool['stupid_mode'] = true; |
|
2458 |
} |
|
272
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
256
diff
changeset
|
2459 |
function header($simple = false) |
1 | 2460 |
{ |
272
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
256
diff
changeset
|
2461 |
$filename = ( $simple ) ? 'simple-header.tpl' : 'header.tpl'; |
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
256
diff
changeset
|
2462 |
if ( !$this->no_headers ) |
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
256
diff
changeset
|
2463 |
{ |
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
256
diff
changeset
|
2464 |
echo $this->process_template($filename); |
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
256
diff
changeset
|
2465 |
} |
1 | 2466 |
} |
272
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
256
diff
changeset
|
2467 |
function footer($simple = false) |
1 | 2468 |
{ |
2469 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2470 |
global $lang; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2471 |
|
1 | 2472 |
if(!$this->no_headers) { |
2473 |
global $_starttime; |
|
91 | 2474 |
|
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2475 |
$filename = ( $simple ) ? 'simple-footer.tpl' : 'footer.tpl'; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2476 |
$t = $this->process_template($filename); |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2477 |
|
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2478 |
$f = microtime_float(); |
1 | 2479 |
$f = $f - $_starttime; |
2480 |
$f = round($f, 4); |
|
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2481 |
|
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2482 |
if ( is_object($lang) ) |
98
6457a9b983c6
Fixed non-object reference in databaseless template, added locking for Javascript paginator, made comments on AES key size more clear in constants, and disallowed "anonymous" and IP addresses for admin username in install.php; Loch Ness release candidate
Dan
parents:
91
diff
changeset
|
2483 |
{ |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2484 |
$t_loc = $lang->get('page_msg_stats_gentime_short', array('time' => $f)); |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2485 |
$t_loc_long = $lang->get('page_msg_stats_gentime_long', array('time' => $f)); |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2486 |
$q_loc = '<a href="' . $this->tpl_strings['REPORT_URI'] . '">' . $lang->get('page_msg_stats_sql', array('nq' => ( is_object($db) ? $db->num_queries : 'N/A' ))) . '</a>'; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2487 |
$dbg = $t_loc; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2488 |
$dbg_long = $t_loc_long; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2489 |
if ( $session->user_level >= USER_LEVEL_ADMIN ) |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2490 |
{ |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2491 |
$dbg .= " | $q_loc"; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2492 |
$dbg_long .= " | $q_loc"; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2493 |
} |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2494 |
$t = str_replace('[[EnanoPoweredLink]]', $lang->get('page_enano_powered', array('about_uri' => $this->tpl_strings['URL_ABOUT_ENANO'])), $t); |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2495 |
$t = str_replace('[[EnanoPoweredLinkLong]]', $lang->get('page_enano_powered_long', array('about_uri' => $this->tpl_strings['URL_ABOUT_ENANO'])), $t); |
98
6457a9b983c6
Fixed non-object reference in databaseless template, added locking for Javascript paginator, made comments on AES key size more clear in constants, and disallowed "anonymous" and IP addresses for admin username in install.php; Loch Ness release candidate
Dan
parents:
91
diff
changeset
|
2496 |
} |
6457a9b983c6
Fixed non-object reference in databaseless template, added locking for Javascript paginator, made comments on AES key size more clear in constants, and disallowed "anonymous" and IP addresses for admin username in install.php; Loch Ness release candidate
Dan
parents:
91
diff
changeset
|
2497 |
else |
6457a9b983c6
Fixed non-object reference in databaseless template, added locking for Javascript paginator, made comments on AES key size more clear in constants, and disallowed "anonymous" and IP addresses for admin username in install.php; Loch Ness release candidate
Dan
parents:
91
diff
changeset
|
2498 |
{ |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2499 |
$t_loc = "Time: {$f}s"; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2500 |
$t_loc_long = "Generated in {$f}sec"; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2501 |
$q_loc = '<a href="' . $this->tpl_strings['REPORT_URI'] . '">' . ( is_object($db) ? "{$db->num_queries} SQL" : 'Queries: N/A' ) . '</a>'; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2502 |
$dbg = $t_loc; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2503 |
$dbg_long = $t_loc_long; |
484
340c81fdd350
Fixed session validation bug in upgrade script; fixed non-object reference in template_nodb
Dan
parents:
472
diff
changeset
|
2504 |
if ( is_object($session) ) |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2505 |
{ |
484
340c81fdd350
Fixed session validation bug in upgrade script; fixed non-object reference in template_nodb
Dan
parents:
472
diff
changeset
|
2506 |
if ( $session->user_level >= USER_LEVEL_ADMIN ) |
340c81fdd350
Fixed session validation bug in upgrade script; fixed non-object reference in template_nodb
Dan
parents:
472
diff
changeset
|
2507 |
{ |
340c81fdd350
Fixed session validation bug in upgrade script; fixed non-object reference in template_nodb
Dan
parents:
472
diff
changeset
|
2508 |
$dbg .= " | $q_loc"; |
340c81fdd350
Fixed session validation bug in upgrade script; fixed non-object reference in template_nodb
Dan
parents:
472
diff
changeset
|
2509 |
$dbg_long .= " | $q_loc"; |
340c81fdd350
Fixed session validation bug in upgrade script; fixed non-object reference in template_nodb
Dan
parents:
472
diff
changeset
|
2510 |
} |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2511 |
} |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2512 |
$t = str_replace('[[EnanoPoweredLink]]', 'Powered by <a href="http://enanocms.org/" onclick="window.open(this.href); return false;">Enano</a>', $t); |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2513 |
$t = str_replace('[[EnanoPoweredLinkLong]]', 'Website engine powered by <a href="http://enanocms.org/" onclick="window.open(this.href); return false;">Enano</a>', $t); |
98
6457a9b983c6
Fixed non-object reference in databaseless template, added locking for Javascript paginator, made comments on AES key size more clear in constants, and disallowed "anonymous" and IP addresses for admin username in install.php; Loch Ness release candidate
Dan
parents:
91
diff
changeset
|
2514 |
} |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2515 |
|
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2516 |
$t = str_replace('[[Stats]]', $dbg, $t); |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2517 |
$t = str_replace('[[StatsLong]]', $dbg_long, $t); |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2518 |
$t = str_replace('[[NumQueries]]', ( is_object($db) ? (string)$db->num_queries : '0' ), $t); |
91 | 2519 |
$t = str_replace('[[GenTime]]', (string)$f, $t); |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2520 |
$t = str_replace('[[NumQueriesLoc]]', $q_loc, $t); |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
389
diff
changeset
|
2521 |
$t = str_replace('[[GenTimeLoc]]', $t_loc, $t); |
91 | 2522 |
|
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2523 |
if ( defined('ENANO_DEBUG') ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2524 |
$t = str_replace('</body>', '<div id="profile" style="margin: 10px;">' . profiler_make_html() . '</div></body>', $t); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2525 |
|
1 | 2526 |
echo $t; |
2527 |
} |
|
2528 |
else return ''; |
|
2529 |
} |
|
2530 |
function getHeader() |
|
2531 |
{ |
|
2532 |
if(!$this->no_headers) return $this->process_template('header.tpl'); |
|
2533 |
else return ''; |
|
2534 |
} |
|
2535 |
function getFooter() |
|
2536 |
{ |
|
2537 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
2538 |
if(!$this->no_headers) { |
|
2539 |
global $_starttime; |
|
2540 |
$f = microtime(true); |
|
2541 |
$f = $f - $_starttime; |
|
2542 |
$f = round($f, 4); |
|
2543 |
if(defined('IN_ENANO_INSTALL')) $nq = 'N/A'; |
|
2544 |
else $nq = $db->num_queries; |
|
2545 |
if($nq == 0) $nq = 'N/A'; |
|
2546 |
$dbg = 'Time: '.$f.'s | Queries: '.$nq; |
|
2547 |
if($nq == 0) $nq = 'N/A'; |
|
2548 |
$t = $this->process_template('footer.tpl'); |
|
2549 |
$t = str_replace('[[Stats]]', $dbg, $t); |
|
2550 |
return $t; |
|
2551 |
} |
|
2552 |
else return ''; |
|
2553 |
} |
|
2554 |
||
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2555 |
function process_template($file) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2556 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2557 |
profiler_log("[template_nodb] STARTED eval of file $file"); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2558 |
$compiled = $this->compile_template($file); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2559 |
profiler_log("[template_nodb] COMPILED file $file"); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2560 |
$result = eval($compiled); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2561 |
profiler_log("[template_nodb] FINISHED eval of file $file"); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2562 |
return $result; |
1 | 2563 |
} |
2564 |
||
2565 |
function extract_vars($file) { |
|
2566 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
2567 |
if(!is_file(ENANO_ROOT . '/themes/'.$this->theme.'/'.$file)) die('Cannot find '.$file.' file for style "'.$this->theme.'", exiting'); |
|
2568 |
$text = file_get_contents(ENANO_ROOT . '/themes/'.$this->theme.'/'.$file); |
|
2569 |
preg_match_all('#<\!-- VAR ([A-z0-9_-]*) -->(.*?)<\!-- ENDVAR \\1 -->#is', $text, $matches); |
|
2570 |
$tplvars = Array(); |
|
2571 |
for($i=0;$i<sizeof($matches[1]);$i++) |
|
2572 |
{ |
|
2573 |
$tplvars[$matches[1][$i]] = $matches[2][$i]; |
|
2574 |
} |
|
2575 |
return $tplvars; |
|
2576 |
} |
|
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2577 |
function compile_template($text) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2578 |
{ |
1 | 2579 |
$text = file_get_contents(ENANO_ROOT . '/themes/'.$this->theme.'/'.$text); |
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2580 |
return $this->compile_template_text_post(template_compiler_core($text)); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2581 |
} |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2582 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2583 |
function compile_template_text($text) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2584 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2585 |
return $this->compile_template_text_post(template_compiler_core($text)); |
1 | 2586 |
} |
2587 |
||
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2588 |
/** |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2589 |
* Post-processor for template code. Basically what this does is it localizes {lang:foo} blocks. |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2590 |
* @param string Mostly-processed TPL code |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2591 |
* @return string |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2592 |
*/ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2593 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2594 |
function compile_template_text_post($text) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2595 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2596 |
global $lang; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2597 |
preg_match_all('/\{lang:([a-z0-9]+_[a-z0-9_]+)\}/', $text, $matches); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2598 |
foreach ( $matches[1] as $i => $string_id ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2599 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2600 |
if ( is_object(@$lang) ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2601 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2602 |
$string = $lang->get($string_id); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2603 |
} |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2604 |
else |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2605 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2606 |
$string = '[language not loaded]'; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2607 |
} |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2608 |
$string = str_replace('\\', '\\\\', $string); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2609 |
$string = str_replace('\'', '\\\'', $string); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2610 |
$text = str_replace_once($matches[0][$i], $string, $text); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2611 |
} |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2612 |
return $text; |
1 | 2613 |
} |
2614 |
||
2615 |
/** |
|
2616 |
* Allows individual parsing of template files. Similar to phpBB but follows the spirit of object-oriented programming ;) |
|
2617 |
* Returns on object of class templateIndividual. Usage instructions can be found in the inline docs for that class. |
|
2618 |
* @param $filename the filename of the template to be parsed |
|
2619 |
* @return object |
|
2620 |
*/ |
|
2621 |
||
2622 |
function makeParser($filename) |
|
2623 |
{ |
|
2624 |
$filename = ENANO_ROOT.'/themes/'.$this->theme.'/'.$filename; |
|
2625 |
if(!file_exists($filename)) die('templateIndividual: file '.$filename.' does not exist'); |
|
2626 |
$code = file_get_contents($filename); |
|
2627 |
$parser = new templateIndividualSafe($code, $this); |
|
2628 |
return $parser; |
|
2629 |
} |
|
2630 |
||
2631 |
/** |
|
2632 |
* Same as $template->makeParser(), but takes a string instead of a filename. |
|
2633 |
* @param $text the text to parse |
|
2634 |
* @return object |
|
2635 |
*/ |
|
2636 |
||
2637 |
function makeParserText($code) |
|
2638 |
{ |
|
2639 |
$parser = new templateIndividualSafe($code, $this); |
|
2640 |
return $parser; |
|
2641 |
} |
|
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2642 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2643 |
/** |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2644 |
* Assigns an array of string values to the template. Strings can be accessed from the template by inserting {KEY_NAME} in the template file. |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2645 |
* @param $vars array |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2646 |
*/ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2647 |
function assign_vars($vars) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2648 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2649 |
if(is_array($this->tpl_strings)) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2650 |
$this->tpl_strings = array_merge($this->tpl_strings, $vars); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2651 |
else |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2652 |
$this->tpl_strings = $vars; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2653 |
} |
1 | 2654 |
|
2655 |
} // class template_nodb |
|
2656 |
||
2657 |
/** |
|
2658 |
* Identical to templateIndividual, except extends template_nodb instead of template |
|
2659 |
* @see class template |
|
2660 |
*/ |
|
2661 |
||
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2662 |
class templateIndividualSafe extends template_nodb |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
526
diff
changeset
|
2663 |
{ |
1 | 2664 |
var $tpl_strings, $tpl_bool, $tpl_code; |
2665 |
var $compiled = false; |
|
2666 |
/** |
|
2667 |
* Constructor. |
|
2668 |
*/ |
|
2669 |
function __construct($text, $parent) |
|
2670 |
{ |
|
2671 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
2672 |
$this->tpl_code = $text; |
|
2673 |
$this->tpl_strings = $parent->tpl_strings; |
|
2674 |
$this->tpl_bool = $parent->tpl_bool; |
|
2675 |
} |
|
2676 |
/** |
|
2677 |
* PHP 4 constructor. |
|
2678 |
*/ |
|
2679 |
function templateIndividual($text) |
|
2680 |
{ |
|
2681 |
$this->__construct($text); |
|
2682 |
} |
|
2683 |
/** |
|
2684 |
* Assigns an array of string values to the template. Strings can be accessed from the template by inserting {KEY_NAME} in the template file. |
|
2685 |
* @param $vars array |
|
2686 |
*/ |
|
2687 |
function assign_vars($vars) |
|
2688 |
{ |
|
2689 |
if(is_array($this->tpl_strings)) |
|
2690 |
$this->tpl_strings = array_merge($this->tpl_strings, $vars); |
|
2691 |
else |
|
2692 |
$this->tpl_strings = $vars; |
|
2693 |
} |
|
2694 |
/** |
|
2695 |
* Assigns an array of boolean values to the template. These can be used for <!-- IF ... --> statements. |
|
2696 |
* @param $vars array |
|
2697 |
*/ |
|
2698 |
function assign_bool($vars) |
|
2699 |
{ |
|
2700 |
$this->tpl_bool = array_merge($this->tpl_bool, $vars); |
|
2701 |
} |
|
2702 |
/** |
|
2703 |
* Compiles and executes the template code. |
|
2704 |
* @return string |
|
2705 |
*/ |
|
2706 |
function run() |
|
2707 |
{ |
|
2708 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
2709 |
if(!$this->compiled) |
|
2710 |
{ |
|
2711 |
$this->tpl_code = $this->compile_template_text($this->tpl_code); |
|
2712 |
$this->compiled = true; |
|
2713 |
} |
|
2714 |
return eval($this->tpl_code); |
|
2715 |
} |
|
2716 |
} |
|
2717 |
||
2718 |
?> |