Project

General

Profile

« Previous | Next » 

Revision 1435

Added by Dietmar over 13 years ago

fix entities converting in select languages (Tks to the community)
see http://www.websitebaker2.org/forum/index.php/topic,20547.msg140512.html#msg140512

View differences:

branches/2.8.x/CHANGELOG
11 11
! = Update/Change
12 12

  
13 13
------------------------------------- 2.8.2 -------------------------------------
14
17 Mae-2011 Build 1435 Dietmar Woellbrink (Luisehahne)
15
# fix entities converting in select languages (Tks to the community)
16
# see http://www.websitebaker2.org/forum/index.php/topic,20547.msg140512.html#msg140512
14 17
13 Mae-2011 Build 1433 Dietmar Woellbrink (Luisehahne)
15 18
# fixed bug : Call to undefined method wb::preprocess() 
16 19
14 Feb-2011 Build 1432 Dietmar Woellbrink (Luisehahne)
branches/2.8.x/wb/admin/interface/version.php
52 52

  
53 53
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled)
54 54
if(!defined('VERSION')) define('VERSION', '2.8.2.RC5');
55
if(!defined('REVISION')) define('REVISION', '1433');
55
if(!defined('REVISION')) define('REVISION', '1435');
56 56

  
57 57
?>
branches/2.8.x/wb/admin/settings/index.php
155 155
					 ));
156 156

  
157 157
	// Insert language values
158
	$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'language' ORDER BY name");
158
	$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'language' ORDER BY directory");
159 159
	if($result->numRows() > 0)
160 160
	{
161 161
		while($addon = $result->fetchRow()) {
162
			$l_codes[$addon['name']] = $addon['directory'];
163
			$l_names[$addon['name']] = entities_to_7bit($addon['name']); // sorting-problem workaround
164
		}
165
		asort($l_names);
166
		foreach($l_names as $l_name=>$v) {
167
			// Insert code and name
168
			$template->set_var(array(
169
									'CODE' => $l_codes[$l_name],
170
									'NAME' => $l_name,
171
									'FLAG' => THEME_URL.'/images/flags/'.strtolower($l_codes[$l_name]),
172
									));
173
			// Check if it is selected
174
			if(DEFAULT_LANGUAGE == $l_codes[$l_name]) {
175
				$template->set_var('SELECTED', ' selected="selected"');
176
			} else {
177
				$template->set_var('SELECTED', '');
178
			}
162
			$template->set_var('CODE',        $addon['directory']);
163
			$template->set_var('NAME',        $addon['name']);
164
			$template->set_var('FLAG',        THEME_URL.'/images/flags/'.strtolower($addon['directory']));
165
			$template->set_var('SELECTED',    (DEFAULT_LANGUAGE == $addon['directory'] ? ' selected="selected"' : '') );
179 166
			$template->parse('language_list', 'language_list_block', true);
180 167
		}
181 168
	}
branches/2.8.x/wb/admin/preferences/index.php
1
<?php

2
/**

3
 *

4
 * @category        admin

5
 * @package         preferences

6
 * @author          Independend-Software-Team

7
 * @author          WebsiteBaker Project

8
 * @copyright       2004-2009, Ryan Djurovich

9
 * @copyright       2009-2011, Website Baker Org. e.V.

10
 * @link			http://www.websitebaker2.org/

11
 * @license         http://www.gnu.org/licenses/gpl.html

12
 * @platform        WebsiteBaker 2.8.x

13
 * @requirements    PHP 5.2.2 and higher

14
 * @version         $Id$

15
 * @filesource		$HeadURL$

16
 * @lastmodified    $Date$

17
 *

18
 */

19

  
20
// prevent this file from being accessed directly

21
//if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }

22
//Workaround if this is first page (WBAdmin in use)

23

  
24
// put all inside a function to prevent global vars

25
function build_page( &$admin, &$database )

26
{

27
	global $HEADING, $TEXT;

28
	include_once(WB_PATH.'/framework/functions-utf8.php');

29
// Create new template object, assign template file, start main-block

30
	$template = new Template( THEME_PATH.'/templates' );

31
	$template->set_file( 'page', 'preferences.htt' );

32
	$template->set_block( 'page', 'main_block', 'main' );

33
// read user-info from table users and assign it to template

34
	$sql  = 'SELECT `display_name`, `username`, `email` FROM `'.TABLE_PREFIX.'users` ';

35
	$sql .= 'WHERE `user_id` = '.(int)$admin->get_user_id();

36
	if( $res_user = $database->query($sql) )

37
	{

38
		if( $rec_user = $res_user->fetchRow() )

39
		{

40
			$template->set_var('DISPLAY_NAME', $rec_user['display_name']);

41
			$template->set_var('USERNAME',     $rec_user['username']);

42
			$template->set_var('EMAIL',        $rec_user['email']);

43
			$template->set_var('ADMIN_URL',    ADMIN_URL);

44
		}

45
	}

46
// read available languages from table addons and assign it to the template

47
	$sql  = 'SELECT * FROM `'.TABLE_PREFIX.'addons` ';

48
	$sql .= 'WHERE `type` = "language" ORDER BY `directory`';

49
	if( $res_lang = $database->query($sql) )

50
	{

51
		$template->set_block('main_block', 'language_list_block', 'language_list');

52
		while( $rec_lang = $res_lang->fetchRow() )

53
		{

54
			$template->set_var('CODE',        $rec_lang['directory']);

55
			$template->set_var('NAME',        $rec_lang['name']);

56
			$template->set_var('FLAG',        THEME_URL.'/images/flags/'.strtolower($rec_lang['directory']));

57
			$template->set_var('SELECTED',    (LANGUAGE == $rec_lang['directory'] ? ' selected="selected"' : '') );

58
			$template->parse('language_list', 'language_list_block', true);

59
		}

60
	}

61
// Insert default timezone values

62
	$user_time = true;

63
	include_once( ADMIN_PATH.'/interface/timezones.php' );

64
	$template->set_block('main_block', 'timezone_list_block', 'timezone_list');

65
	foreach( $TIMEZONES AS $hour_offset => $title )

66
	{

67
		$template->set_var('VALUE',    $hour_offset);

68
		$template->set_var('NAME',     $title);

69
		$template->set_var('SELECTED', ($admin->get_timezone() == ($hour_offset * 3600) ? ' selected="selected"' : '') );

70
		$template->parse('timezone_list', 'timezone_list_block', true);

71
	}

72
// Insert date format list

73
	include_once( ADMIN_PATH.'/interface/date_formats.php' );

74
	$template->set_block('main_block', 'date_format_list_block', 'date_format_list');

75
	foreach( $DATE_FORMATS AS $format => $title )

76
	{

77
		$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)

78
		$template->set_var( 'VALUE', ($format != 'system_default' ? $format : 'system_default') );

79
		$template->set_var( 'NAME',  $title );

80
		if( (DATE_FORMAT == $format && !isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) ||

81
			('system_default' == $format && isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) )

82
		{

83
			$template->set_var('SELECTED', ' selected="selected"');

84
		}else {

85
			$template->set_var('SELECTED', '');

86
		}

87
		$template->parse('date_format_list', 'date_format_list_block', true);

88
	}

89
// Insert time format list

90
	include_once( ADMIN_PATH.'/interface/time_formats.php' );

91
	$template->set_block('main_block', 'time_format_list_block', 'time_format_list');

92
	foreach( $TIME_FORMATS AS $format => $title )

93
	{

94
		$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)

95
		$template->set_var('VALUE', $format != 'system_default' ? $format : 'system_default' );

96
		$template->set_var('NAME',  $title);

97
		if( (TIME_FORMAT == $format && !isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) ||

98
		    ('system_default' == $format && isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) )

99
		{

100
			$template->set_var('SELECTED', ' selected="selected"');

101
		} else {

102
			$template->set_var('SELECTED', '');

103
		}

104
		$template->parse('time_format_list', 'time_format_list_block', true);

105
	}

106

  
107
// assign systemvars to template

108
	$template->set_var(array( 'ADMIN_URL'  => ADMIN_URL,

109
	                          'WB_URL'     => WB_URL,

110
                              'WB_PATH'    => WB_PATH,

111
                              'THEME_URL'  => THEME_URL,

112
		                      'ACTION_URL' => ADMIN_URL.'/preferences/save.php'

113
                            )

114
                      );

115
	$template->set_var('FTAN', $admin->getFTAN());

116
	$template->set_var('FORM_NAME', 'preferences_save');

117
// assign language vars

118
	$template->set_var(array( 'HEADING_MY_SETTINGS'      => $HEADING['MY_SETTINGS'],

119
                              'HEADING_MY_EMAIL'         => $HEADING['MY_EMAIL'],

120
                              'HEADING_MY_PASSWORD'      => $HEADING['MY_PASSWORD'],

121
                              'TEXT_SAVE'                => $TEXT['SAVE'],

122
                              'TEXT_RESET'               => $TEXT['RESET'],

123
                              'TEXT_DISPLAY_NAME'        => $TEXT['DISPLAY_NAME'],

124
                              'TEXT_USERNAME'            => $TEXT['USERNAME'],

125
                              'TEXT_EMAIL'               => $TEXT['EMAIL'],

126
                              'TEXT_LANGUAGE'            => $TEXT['LANGUAGE'],

127
                              'TEXT_TIMEZONE'            => $TEXT['TIMEZONE'],

128
                              'TEXT_DATE_FORMAT'         => $TEXT['DATE_FORMAT'],

129
                              'TEXT_TIME_FORMAT'         => $TEXT['TIME_FORMAT'],

130
                              'TEXT_CURRENT_PASSWORD'    => $TEXT['CURRENT_PASSWORD'],

131
                              'TEXT_NEW_PASSWORD'        => $TEXT['NEW_PASSWORD'],

132
                              'TEXT_RETYPE_NEW_PASSWORD' => $TEXT['RETYPE_NEW_PASSWORD'],

133
							  'TEXT_NEW_PASSWORD'        => $TEXT['NEW_PASSWORD'],

134
                              'TEXT_RETYPE_NEW_PASSWORD' => $TEXT['RETYPE_NEW_PASSWORD'],

135
							  'TEXT_NEED_CURRENT_PASSWORD' => $TEXT['NEED_CURRENT_PASSWORD'],

136
	                          'EMPTY_STRING'             => ''

137
                            )

138
                      );

139
// Parse template for preferences form

140
	$template->parse('main', 'main_block', false);

141
	$output = $template->finish($template->parse('output', 'page'));

142
	return $output;

143
}

144
// test if valid $admin-object already exists (bit complicated about PHP4 Compatibility)

145
if( !(isset($admin) && is_object($admin) && (get_class($admin) == 'admin')) )

146
{

147
    require( '../../config.php' );

148
	require_once( WB_PATH.'/framework/class.admin.php' );

149
	$admin = new admin('Preferences');

150
}

151
echo build_page($admin, $database);

152
$admin->print_footer();

153

  
1
<?php
2
/**
3
 *
4
 * @category        admin
5
 * @package         preferences
6
 * @author          Independend-Software-Team
7
 * @author          WebsiteBaker Project
8
 * @copyright       2004-2009, Ryan Djurovich
9
 * @copyright       2009-2011, Website Baker Org. e.V.
10
 * @link			http://www.websitebaker2.org/
11
 * @license         http://www.gnu.org/licenses/gpl.html
12
 * @platform        WebsiteBaker 2.8.x
13
 * @requirements    PHP 5.2.2 and higher
14
 * @version         $Id$
15
 * @filesource		$HeadURL$
16
 * @lastmodified    $Date$
17
 *
18
 */
19

  
20
// prevent this file from being accessed directly
21
//if(defined('WB_PATH') == false) { exit("Cannot access this file directly"); }
22
//Workaround if this is first page (WBAdmin in use)
23

  
24
// put all inside a function to prevent global vars
25
function build_page( &$admin, &$database )
26
{
27
	global $HEADING, $TEXT;
28
	include_once(WB_PATH.'/framework/functions-utf8.php');
29
// Create new template object, assign template file, start main-block
30
	$template = new Template( THEME_PATH.'/templates' );
31
	$template->set_file( 'page', 'preferences.htt' );
32
	$template->set_block( 'page', 'main_block', 'main' );
33
// read user-info from table users and assign it to template
34
	$sql  = 'SELECT `display_name`, `username`, `email` FROM `'.TABLE_PREFIX.'users` ';
35
	$sql .= 'WHERE `user_id` = '.(int)$admin->get_user_id();
36
	if( $res_user = $database->query($sql) )
37
	{
38
		if( $rec_user = $res_user->fetchRow() )
39
		{
40
			$template->set_var('DISPLAY_NAME', $rec_user['display_name']);
41
			$template->set_var('USERNAME',     $rec_user['username']);
42
			$template->set_var('EMAIL',        $rec_user['email']);
43
			$template->set_var('ADMIN_URL',    ADMIN_URL);
44
		}
45
	}
46
// read available languages from table addons and assign it to the template
47
	$sql  = 'SELECT * FROM `'.TABLE_PREFIX.'addons` ';
48
	$sql .= 'WHERE `type` = \'language\' ORDER BY `directory`';
49
	if( $res_lang = $database->query($sql) )
50
	{
51
		$template->set_block('main_block', 'language_list_block', 'language_list');
52
		while( $rec_lang = $res_lang->fetchRow() )
53
		{
54
			$template->set_var('CODE',        $rec_lang['directory']);
55
			$template->set_var('NAME',        $rec_lang['name']);
56
			$template->set_var('FLAG',        THEME_URL.'/images/flags/'.strtolower($rec_lang['directory']));
57
			$template->set_var('SELECTED',    (LANGUAGE == $rec_lang['directory'] ? ' selected="selected"' : '') );
58
			$template->parse('language_list', 'language_list_block', true);
59
		}
60
	}
61
// Insert default timezone values
62
	$user_time = true;
63
	include_once( ADMIN_PATH.'/interface/timezones.php' );
64
	$template->set_block('main_block', 'timezone_list_block', 'timezone_list');
65
	foreach( $TIMEZONES AS $hour_offset => $title )
66
	{
67
		$template->set_var('VALUE',    $hour_offset);
68
		$template->set_var('NAME',     $title);
69
		$template->set_var('SELECTED', ($admin->get_timezone() == ($hour_offset * 3600) ? ' selected="selected"' : '') );
70
		$template->parse('timezone_list', 'timezone_list_block', true);
71
	}
72
// Insert date format list
73
	include_once( ADMIN_PATH.'/interface/date_formats.php' );
74
	$template->set_block('main_block', 'date_format_list_block', 'date_format_list');
75
	foreach( $DATE_FORMATS AS $format => $title )
76
	{
77
		$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
78
		$template->set_var( 'VALUE', ($format != 'system_default' ? $format : 'system_default') );
79
		$template->set_var( 'NAME',  $title );
80
		if( (DATE_FORMAT == $format && !isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) ||
81
			('system_default' == $format && isset($_SESSION['USE_DEFAULT_DATE_FORMAT'])) )
82
		{
83
			$template->set_var('SELECTED', ' selected="selected"');
84
		}else {
85
			$template->set_var('SELECTED', '');
86
		}
87
		$template->parse('date_format_list', 'date_format_list_block', true);
88
	}
89
// Insert time format list
90
	include_once( ADMIN_PATH.'/interface/time_formats.php' );
91
	$template->set_block('main_block', 'time_format_list_block', 'time_format_list');
92
	foreach( $TIME_FORMATS AS $format => $title )
93
	{
94
		$format = str_replace('|', ' ', $format); // Add's white-spaces (not able to be stored in array key)
95
		$template->set_var('VALUE', $format != 'system_default' ? $format : 'system_default' );
96
		$template->set_var('NAME',  $title);
97
		if( (TIME_FORMAT == $format && !isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) ||
98
		    ('system_default' == $format && isset($_SESSION['USE_DEFAULT_TIME_FORMAT'])) )
99
		{
100
			$template->set_var('SELECTED', ' selected="selected"');
101
		} else {
102
			$template->set_var('SELECTED', '');
103
		}
104
		$template->parse('time_format_list', 'time_format_list_block', true);
105
	}
106

  
107
// assign systemvars to template
108
	$template->set_var(array( 'ADMIN_URL'  => ADMIN_URL,
109
	                          'WB_URL'     => WB_URL,
110
                              'WB_PATH'    => WB_PATH,
111
                              'THEME_URL'  => THEME_URL,
112
		                      'ACTION_URL' => ADMIN_URL.'/preferences/save.php'
113
                            )
114
                      );
115
	$template->set_var('FTAN', $admin->getFTAN());
116
	$template->set_var('FORM_NAME', 'preferences_save');
117
// assign language vars
118
	$template->set_var(array( 'HEADING_MY_SETTINGS'      => $HEADING['MY_SETTINGS'],
119
                              'HEADING_MY_EMAIL'         => $HEADING['MY_EMAIL'],
120
                              'HEADING_MY_PASSWORD'      => $HEADING['MY_PASSWORD'],
121
                              'TEXT_SAVE'                => $TEXT['SAVE'],
122
                              'TEXT_RESET'               => $TEXT['RESET'],
123
                              'TEXT_DISPLAY_NAME'        => $TEXT['DISPLAY_NAME'],
124
                              'TEXT_USERNAME'            => $TEXT['USERNAME'],
125
                              'TEXT_EMAIL'               => $TEXT['EMAIL'],
126
                              'TEXT_LANGUAGE'            => $TEXT['LANGUAGE'],
127
                              'TEXT_TIMEZONE'            => $TEXT['TIMEZONE'],
128
                              'TEXT_DATE_FORMAT'         => $TEXT['DATE_FORMAT'],
129
                              'TEXT_TIME_FORMAT'         => $TEXT['TIME_FORMAT'],
130
                              'TEXT_CURRENT_PASSWORD'    => $TEXT['CURRENT_PASSWORD'],
131
                              'TEXT_NEW_PASSWORD'        => $TEXT['NEW_PASSWORD'],
132
                              'TEXT_RETYPE_NEW_PASSWORD' => $TEXT['RETYPE_NEW_PASSWORD'],
133
							  'TEXT_NEW_PASSWORD'        => $TEXT['NEW_PASSWORD'],
134
                              'TEXT_RETYPE_NEW_PASSWORD' => $TEXT['RETYPE_NEW_PASSWORD'],
135
							  'TEXT_NEED_CURRENT_PASSWORD' => $TEXT['NEED_CURRENT_PASSWORD'],
136
	                          'EMPTY_STRING'             => ''
137
                            )
138
                      );
139
// Parse template for preferences form
140
	$template->parse('main', 'main_block', false);
141
	$output = $template->finish($template->parse('output', 'page'));
142
	return $output;
143
}
144
// test if valid $admin-object already exists (bit complicated about PHP4 Compatibility)
145
if( !(isset($admin) && is_object($admin) && (get_class($admin) == 'admin')) )
146
{
147
    require( '../../config.php' );
148
	require_once( WB_PATH.'/framework/class.admin.php' );
149
	$admin = new admin('Preferences');
150
}
151
echo build_page($admin, $database);
152
$admin->print_footer();
153

  
154 154
?>
branches/2.8.x/wb/admin/languages/index.php
35 35

  
36 36
// Insert values into language list
37 37
$template->set_block('main_block', 'language_list_block', 'language_list');
38
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'language' order by name");
38
$result = $database->query("SELECT * FROM ".TABLE_PREFIX."addons WHERE type = 'language' order by directory");
39 39
if($result->numRows() > 0) {
40 40
	while($addon = $result->fetchRow()) {
41 41
		$template->set_var('VALUE', $addon['directory']);
branches/2.8.x/wb/account/preferences_form.php
46 46
		 *	storred in the field "directory" ...
47 47
		 *
48 48
		 */
49
		$query = "SELECT directory, name from ".TABLE_PREFIX."addons where type='language' order by 'name'";
49
		$query  = 'SELECT * FROM `'.TABLE_PREFIX.'addons` ';
50
		$query .= 'WHERE `type` = \'language\' ORDER BY `directory`';
50 51
		$result = $database->query($query);
51 52
		if ($result) {
52 53
			$options_html = "";
53 54
			while($data = $result->fetchRow()) {
54 55
				$sel = ($data['directory'] == LANGUAGE) ? " selected=\"selected\" " : "";
55
				$options_html .= "<option value=\"".$data['directory']."\" ".$sel.">".$data['name']." (".$data['directory'].")</option>\n";
56
				// $options_html .= "<option value=\"".$data['directory']."\" ".$sel.">".$data['name']." (".$data['directory'].")</option>\n";
57
				$options_html .= "<option value=\"".$data['directory']."\" ".$sel." style=\"background: url(".THEME_URL.'/images/flags/'.strtolower($data['directory']).".png) no-repeat center left; padding-left: 20px;\">".$data['name']." (".$data['directory'].")</option>\n";
56 58
			}
57 59
			echo $options_html;
58 60
		}
branches/2.8.x/wb/framework/functions.php
1173 1173
		// read contents of the template language file into string
1174 1174
		$data = @file_get_contents(WB_PATH.'/languages/'.str_replace('.php','',basename($file)).'.php');
1175 1175
		// use regular expressions to fetch the content of the variable from the string
1176
		$language_name = get_variable_content('language_name', $data, false);
1177
		$language_code = get_variable_content('language_code', $data, false);
1178
		$language_author = get_variable_content('language_author', $data);
1179
		$language_version = get_variable_content('language_version', $data, false);
1180
		$language_platform = get_variable_content('language_platform', $data, false);
1176
		$language_name = get_variable_content('language_name', $data, false, false);
1177
		$language_code = get_variable_content('language_code', $data, false, false);
1178
		$language_author = get_variable_content('language_author', $data, false, false);
1179
		$language_version = get_variable_content('language_version', $data, false, false);
1180
		$language_platform = get_variable_content('language_platform', $data, false, false);
1181 1181

  
1182 1182
		if(isset($language_name))
1183 1183
		{

Also available in: Unified diff