Merge of the language-specific custom path change Revision #r8782

git-svn-id: file:///svn/phpbb/trunk@8786 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2008-08-24 10:04:15 +00:00
parent 8174462e89
commit 589db44b56
11 changed files with 91 additions and 69 deletions

View file

@ -669,6 +669,11 @@ parse_css_file = {PARSE_CSS_FILE}
{
global $config, $db, $cache, $user, $template, $safe_mode;
if (defined('DISABLE_ACP_EDITOR'))
{
trigger_error($user->lang['EDITOR_DISABLED'] . adm_back_link($this->u_action));
}
$this->page_title = 'EDIT_TEMPLATE';
$filelist = $filelist_cats = array();
@ -681,7 +686,7 @@ parse_css_file = {PARSE_CSS_FILE}
// make sure template_file path doesn't go upwards
$template_file = str_replace('..', '.', $template_file);
// Retrieve some information about the template
$sql = 'SELECT template_storedb, template_path, template_name
FROM ' . STYLES_TEMPLATE_TABLE . "
@ -694,7 +699,7 @@ parse_css_file = {PARSE_CSS_FILE}
{
trigger_error($user->lang['NO_TEMPLATE'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if ($save_changes && !check_form_key('acp_styles'))
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
@ -993,12 +998,12 @@ parse_css_file = {PARSE_CSS_FILE}
foreach ($file_ary as $file)
{
$file = str_replace('/', '.', $file);
// perform some dirty guessing to get the path right.
// We assume that three dots in a row were '../'
$tpl_file = str_replace('.', '/', $file);
$tpl_file = str_replace('///', '../', $tpl_file);
$filename = "{$cache_prefix}_$file.html." . PHP_EXT;
if (!file_exists(PHPBB_ROOT_PATH . "cache/$filename"))
@ -1047,7 +1052,7 @@ parse_css_file = {PARSE_CSS_FILE}
// make sure theme_file path doesn't go upwards
$theme_file = str_replace('..', '.', $theme_file);
// Retrieve some information about the theme
$sql = 'SELECT theme_storedb, theme_path, theme_name, theme_data
FROM ' . STYLES_THEME_TABLE . "
@ -1231,7 +1236,7 @@ parse_css_file = {PARSE_CSS_FILE}
$imgsize = request_var('imgsize', false);
$imgwidth = request_var('imgwidth', 0);
$imgheight = request_var('imgheight', 0);
$imgname = preg_replace('#[^a-z0-9\-+_]#i', '', $imgname);
$imgpath = str_replace('..', '.', $imgpath);
@ -2096,14 +2101,14 @@ parse_css_file = {PARSE_CSS_FILE}
$style_default = request_var('style_default', 0);
$store_db = request_var('store_db', 0);
$sql = "SELECT {$mode}_id
$sql = "SELECT {$mode}_id
FROM $sql_from
WHERE {$mode}_id <> $style_id
WHERE {$mode}_id <> $style_id
AND {$mode}_name = '" . $db->sql_escape(strtolower($name)) . "'";
$result = $db->sql_query($sql);
$conflict = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($mode == 'style' && (!$template_id || !$theme_id || !$imageset_id))
{
$error[] = $user->lang['STYLE_ERR_NO_IDS'];
@ -2141,7 +2146,7 @@ parse_css_file = {PARSE_CSS_FILE}
}
}
}
if (!sizeof($error))
{
// Check length settings
@ -2911,7 +2916,7 @@ parse_css_file = {PARSE_CSS_FILE}
$sql = 'SELECT image_name, image_filename, image_lang, image_width, image_height
FROM ' . STYLES_IMAGESET_DATA_TABLE . '
WHERE imageset_id = ' . $theme['imageset_id'] . "
AND image_filename <> ''
AND image_filename <> ''
AND image_lang IN ('" . $db->sql_escape($user_image_lang) . "', '')";
$result2 = $db->sql_query($sql);
@ -2926,7 +2931,7 @@ parse_css_file = {PARSE_CSS_FILE}
$matches = array();
preg_match_all('#\{IMG_([A-Za-z0-9_]*?)_(WIDTH|HEIGHT|SRC)\}#', $specific_theme_data, $matches);
$imgs = $find = $replace = array();
if (isset($matches[0]) && sizeof($matches[0]))
{
@ -2934,13 +2939,13 @@ parse_css_file = {PARSE_CSS_FILE}
{
$img = strtolower($img);
$find[] = $matches[0][$i];
if (!isset($img_array[$img]))
{
$replace[] = '';
continue;
}
if (!isset($imgs[$img]))
{
$img_data = &$img_array[$img];
@ -2951,26 +2956,26 @@ parse_css_file = {PARSE_CSS_FILE}
'height' => $img_data['image_height'],
);
}
switch ($matches[2][$i])
{
case 'SRC':
$replace[] = $imgs[$img]['src'];
break;
case 'WIDTH':
$replace[] = $imgs[$img]['width'];
break;
case 'HEIGHT':
$replace[] = $imgs[$img]['height'];
break;
default:
continue;
}
}
if (sizeof($find))
{
$specific_theme_data = str_replace($find, $replace, $specific_theme_data);
@ -3194,6 +3199,7 @@ parse_css_file = {PARSE_CSS_FILE}
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
// If it exist, we just use the style on installation
@ -3381,7 +3387,6 @@ parse_css_file = {PARSE_CSS_FILE}
// Return store_db in case it had to be altered
return $store_db;
}
}
?>

View file

@ -565,7 +565,7 @@ class phpbb_db_tools
/**
* Private method for performing sql statements (either execute them or return them)
* @private
* @access private
*/
private static function _sql_run_sql($statements)
{
@ -598,7 +598,7 @@ class phpbb_db_tools
/**
* Function to prepare some column information for better usage
* @private
* @access private
*/
private static function sql_prepare_column_data($table_name, $column_name, $column_data)
{

View file

@ -588,7 +588,7 @@ function phpbb_chmod($filename, $perms = CHMOD_READ)
case 'owner':
$result = @chmod($filename, ($owner << 6) + (0 << 3) + (0 << 0));
if (!is_null($php) || (!is_readable($filename) && is_writable($filename)))
if (!is_null($php) || (is_readable($filename) && is_writable($filename)))
{
break;
}
@ -2168,7 +2168,7 @@ function generate_link_hash($link_name)
/**
* checks a link hash - for GET requests
* @param string $token the submitted token
* @param string $token the submitted token
* @param string $link_name The name of the link
* @return boolean true if all is fine
*/

View file

@ -97,7 +97,7 @@ function recalc_btree($sql_id, $sql_table, $module_class = '')
$item_data['left_id'] = $row['right_id'] + 1;
$item_data['right_id'] = $row['right_id'] + 2;
}
$sql = "UPDATE $sql_table
SET left_id = {$item_data['left_id']}, right_id = {$item_data['right_id']}
WHERE $sql_id = " . $item_data[$sql_id];
@ -916,7 +916,7 @@ function delete_attachments($mode, $ids, $resync = true)
while ($row = $db->sql_fetchrow($result))
{
$remaining[] = $row['post_msg_id'];
$remaining[] = $row['post_msg_id'];
}
$db->sql_freeresult($result);
@ -940,7 +940,7 @@ function delete_attachments($mode, $ids, $resync = true)
while ($row = $db->sql_fetchrow($result))
{
$remaining[] = $row['post_msg_id'];
$remaining[] = $row['post_msg_id'];
}
$db->sql_freeresult($result);
@ -978,7 +978,7 @@ function delete_attachments($mode, $ids, $resync = true)
while ($row = $db->sql_fetchrow($result))
{
$remaining[] = $row['topic_id'];
$remaining[] = $row['topic_id'];
}
$db->sql_freeresult($result);
@ -1012,7 +1012,6 @@ function delete_topic_shadows($max_age, $forum_id = '', $auto_sync = true)
AND t.topic_time < ' . (time() - $max_age)
. $where;
$db->sql_query($sql);
}
else
{
@ -2357,7 +2356,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
$log_type = LOG_USERS;
$sql_forum = 'AND l.reportee_id = ' . (int) $user_id;
break;
case 'users':
$log_type = LOG_USERS;
$sql_forum = '';
@ -2367,7 +2366,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
$log_type = LOG_CRITICAL;
$sql_forum = '';
break;
default:
return;
}
@ -2623,7 +2622,7 @@ function update_foes($group_id = false, $user_id = false)
$db->sql_freeresult($result);
if (sizeof($users))
{
{
$sql = 'DELETE FROM ' . ZEBRA_TABLE . '
WHERE ' . $db->sql_in_set('zebra_id', $users) . '
AND foe = 1';
@ -2702,7 +2701,7 @@ function view_inactive_users(&$users, &$user_count, $limit = 0, $offset = 0, $li
$row['inactive_reason'] = $user->lang['INACTIVE_REASON_REMIND'];
break;
}
$users[] = $row;
}
@ -2878,7 +2877,7 @@ function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port
@fputs($fsock, "GET $directory/$filename HTTP/1.1\r\n");
@fputs($fsock, "HOST: $host\r\n");
@fputs($fsock, "Connection: close\r\n\r\n");
$file_info = '';
$get_info = false;
@ -2917,7 +2916,7 @@ function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port
return false;
}
}
return $file_info;
}
@ -2953,7 +2952,7 @@ function tidy_warnings()
$sql = 'DELETE FROM ' . WARNINGS_TABLE . '
WHERE ' . $db->sql_in_set('warning_id', $warning_list);
$db->sql_query($sql);
foreach ($user_list as $user_id => $value)
{
$sql = 'UPDATE ' . USERS_TABLE . " SET user_warnings = user_warnings - $value
@ -3015,7 +3014,7 @@ function add_permission_language()
// Now search in acp and mods folder for permissions_ files.
foreach (array('acp/', 'mods/') as $path)
{
$dh = @opendir($user->lang_path . $path);
$dh = @opendir($user->lang_path . $user->lang_name . '/' . $path);
if ($dh)
{

View file

@ -817,11 +817,11 @@ class p_master
{
global $user;
if (file_exists($user->lang_path . 'mods'))
if (file_exists($user->lang_path . $user->lang_name . '/mods'))
{
$add_files = array();
$dir = @opendir($user->lang_path . 'mods');
$dir = @opendir($user->lang_path . $user->lang_name . '/mods');
if ($dir)
{

View file

@ -263,7 +263,8 @@ class filespec
*
* @param string $destination_path Destination path, for example $config['avatar_path']
* @param bool $overwrite If set to true, an already existing file will be overwritten
* @param string $chmod Permission mask for chmodding the file after a successful move. The mode entered here reflects the mode of {@inline phpbb_chmod()}
* @param string $chmod Permission mask for chmodding the file after a successful move. The mode entered here reflects the mode defined by {@link phpbb_chmod()}
*
* @access public
*/
function move_file($destination, $overwrite = false, $skip_image_check = false, $chmod = false)

View file

@ -147,7 +147,7 @@ function user_update_name($old_name, $new_name)
*
* @param mixed $user_row An array containing the following keys (and the appropriate values): username, group_id (the group to place the user in), user_email and the user_type(usually 0). Additional entries not overridden by defaults will be forwarded.
* @param string $cp_data custom profile fields, see custom_profile::build_insert_sql_array
* @return: the new user's ID.
* @return the new user's ID.
*/
function user_add($user_row, $cp_data = false)
{
@ -2238,7 +2238,7 @@ function avatar_process_user(&$error, $custom_userdata = false)
}
}
}
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . (($custom_userdata === false) ? $user->data['user_id'] : $custom_userdata['user_id']);
@ -3014,7 +3014,7 @@ function group_validate_groupname($group_id, $group_name)
/**
* Set users default group
*
* @private
* @access private
*/
function group_set_user_default($group_id, $user_id_ary, $group_attributes = false, $update_listing = false)
{

View file

@ -391,7 +391,7 @@ class bbcode_firstpass extends bbcode
/**
* Parse code text from code tag
* @private
* @access private
*/
function bbcode_parse_code($stx, &$code)
{

View file

@ -49,10 +49,10 @@ class search_backend
$words = array();
if (file_exists("{$user->lang_path}/search_ignore_words." . PHP_EXT))
if (file_exists("{$user->lang_path}{$user->lang_name}/search_ignore_words." . PHP_EXT))
{
// include the file containing ignore words
include("{$user->lang_path}/search_ignore_words." . PHP_EXT);
include("{$user->lang_path}{$user->lang_name}/search_ignore_words." . PHP_EXT);
}
$this->ignore_words = $words;
@ -71,10 +71,10 @@ class search_backend
$synonyms = array();
if (file_exists("{$user->lang_path}/search_synonyms." . PHP_EXT))
if (file_exists("{$user->lang_path}{$user->lang_name}/search_synonyms." . PHP_EXT))
{
// include the file containing synonyms
include("{$user->lang_path}/search_synonyms." . PHP_EXT);
include("{$user->lang_path}{$user->lang_name}/search_synonyms." . PHP_EXT);
}
$this->match_synonym = array_keys($synonyms);

View file

@ -1371,7 +1371,7 @@ class user extends session
var $timezone;
var $dst;
var $lang_name;
var $lang_name = false;
var $lang_id = false;
var $lang_path;
var $img_lang;
@ -1381,6 +1381,30 @@ class user extends session
var $keyoptions = array('viewimg' => 0, 'viewflash' => 1, 'viewsmilies' => 2, 'viewsigs' => 3, 'viewavatars' => 4, 'viewcensors' => 5, 'attachsig' => 6, 'bbcode' => 8, 'smilies' => 9, 'popuppm' => 10);
var $keyvalues = array();
/**
* Constructor to set the lang path
*/
public function __construct()
{
$this->lang_path = PHPBB_ROOT_PATH . 'language/';
}
/**
* Function to set custom language path (able to use directory outside of phpBB)
*
* @param string $lang_path New language path used.
* @access public
*/
function set_custom_lang_path($lang_path)
{
$this->lang_path = $lang_path;
if (substr($this->lang_path, -1) != '/')
{
$this->lang_path .= '/';
}
}
/**
* Setup basic user-specific items (style, language, ...)
*/
@ -1390,9 +1414,7 @@ class user extends session
if ($this->data['user_id'] != ANONYMOUS)
{
$this->lang_name = (file_exists(PHPBB_ROOT_PATH . 'language/' . $this->data['user_lang'] . '/common.' . PHP_EXT)) ? $this->data['user_lang'] : basename($config['default_lang']);
$this->lang_path = PHPBB_ROOT_PATH . 'language/' . $this->lang_name . '/';
$this->lang_name = (file_exists($this->lang_path . $this->data['user_lang'] . "/common." . PHP_EXT)) ? $this->data['user_lang'] : basename($config['default_lang']);
$this->date_format = $this->data['user_dateformat'];
$this->timezone = $this->data['user_timezone'] * 3600;
$this->dst = $this->data['user_dst'] * 3600;
@ -1400,7 +1422,6 @@ class user extends session
else
{
$this->lang_name = basename($config['default_lang']);
$this->lang_path = PHPBB_ROOT_PATH . 'language/' . $this->lang_name . '/';
$this->date_format = $config['default_dateformat'];
$this->timezone = $config['board_timezone'] * 3600;
$this->dst = $config['board_dst'] * 3600;
@ -1420,10 +1441,9 @@ class user extends session
$accept_lang = substr($accept_lang, 0, 2) . '_' . strtoupper(substr($accept_lang, 3, 2));
$accept_lang = basename($accept_lang);
if (file_exists(PHPBB_ROOT_PATH . 'language/' . $accept_lang . "/common." . PHP_EXT))
if (file_exists($this->lang_path . $accept_lang . "/common." . PHP_EXT))
{
$this->lang_name = $config['default_lang'] = $accept_lang;
$this->lang_path = PHPBB_ROOT_PATH . 'language/' . $accept_lang . '/';
break;
}
else
@ -1432,10 +1452,9 @@ class user extends session
$accept_lang = substr($accept_lang, 0, 2);
$accept_lang = basename($accept_lang);
if (file_exists(PHPBB_ROOT_PATH . 'language/' . $accept_lang . "/common." . PHP_EXT))
if (file_exists($this->lang_path . $accept_lang . "/common." . PHP_EXT))
{
$this->lang_name = $config['default_lang'] = $accept_lang;
$this->lang_path = PHPBB_ROOT_PATH . 'language/' . $accept_lang . '/';
break;
}
}
@ -1447,9 +1466,9 @@ class user extends session
// We include common language file here to not load it every time a custom language file is included
$lang = &$this->lang;
if ((@include $this->lang_path . 'common.' . PHP_EXT) === false)
if ((@include $this->lang_path . $this->lang_name . "/common." . PHP_EXT) === false)
{
die('Language file ' . $this->lang_name . '/common.' . PHP_EXT . " couldn't be opened.");
die('Language file ' . $this->lang_path . $this->lang_name . "/common." . PHP_EXT . " couldn't be opened.");
}
$this->add_lang($lang_set);
@ -1813,12 +1832,11 @@ class user extends session
*/
function set_lang(&$lang, &$help, $lang_file, $use_db = false, $use_help = false)
{
// Make sure the language path is set (if the user setup did not happen it is not set)
if (!$this->lang_path)
// Make sure the language name is set (if the user setup did not happen it is not set)
if (!$this->lang_name)
{
global $config;
$this->lang_path = PHPBB_ROOT_PATH . 'language/' . basename($config['default_lang']) . '/';
$this->lang_name = basename($config['default_lang']);
}
// $lang == $this->lang
@ -1828,11 +1846,11 @@ class user extends session
{
if ($use_help && strpos($lang_file, '/') !== false)
{
$language_filename = $this->lang_path . substr($lang_file, 0, stripos($lang_file, '/') + 1) . 'help_' . substr($lang_file, stripos($lang_file, '/') + 1) . '.' . PHP_EXT;
$language_filename = $this->lang_path . $this->lang_name . '/' . substr($lang_file, 0, stripos($lang_file, '/') + 1) . 'help_' . substr($lang_file, stripos($lang_file, '/') + 1) . '.' . PHP_EXT;
}
else
{
$language_filename = $this->lang_path . (($use_help) ? 'help_' : '') . $lang_file . '.' . PHP_EXT;
$language_filename = $this->lang_path . $this->lang_name . '/' . (($use_help) ? 'help_' : '') . $lang_file . '.' . PHP_EXT;
}
if ((@include $language_filename) === false)

View file

@ -43,7 +43,7 @@ class ucp_register
$submit = (isset($_POST['submit'])) ? true : false;
$change_lang = request_var('change_lang', '');
$user_lang = request_var('lang', $user->lang_name);
if ($agreed)
{
add_form_key('ucp_register');
@ -58,7 +58,7 @@ class ucp_register
{
$use_lang = ($change_lang) ? basename($change_lang) : basename($user_lang);
if (file_exists(PHPBB_ROOT_PATH . 'language/' . $use_lang . '/'))
if (file_exists($user->lang_path . $use_lang . '/'))
{
if ($change_lang)
{
@ -69,7 +69,6 @@ class ucp_register
}
$user->lang_name = $lang = $use_lang;
$user->lang_path = PHPBB_ROOT_PATH . 'language/' . $lang . '/';
$user->lang = array();
$user->add_lang(array('common', 'ucp'));
}
@ -471,7 +470,7 @@ class ucp_register
if (!$change_lang || !$confirm_id)
{
$user->confirm_gc(CONFIRM_REG);
$sql = 'SELECT COUNT(session_id) AS attempts
FROM ' . CONFIRM_TABLE . "
WHERE session_id = '" . $db->sql_escape($user->session_id) . "'