mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-06 22:45:02 +02:00
- added the template editor (doesn't use a hardcoded list of template filenames for categorisation anymore)
- fix some bugs related to storing template files in the database - allow templates stored in subfolders of the /styles/name/template/ folder git-svn-id: file:///svn/phpbb/trunk@5894 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
870cb6efd0
commit
f83b7e1581
@ -58,6 +58,8 @@ $mode = request_var('mode', '');
|
|||||||
// Set custom template for admin area
|
// Set custom template for admin area
|
||||||
$template->set_custom_template($phpbb_admin_path . 'style', 'admin');
|
$template->set_custom_template($phpbb_admin_path . 'style', 'admin');
|
||||||
$template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style');
|
$template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style');
|
||||||
|
// the acp template is never stored in the database
|
||||||
|
$user->theme['template_storedb'] = false;
|
||||||
|
|
||||||
// Force pagination seperation for admin style
|
// Force pagination seperation for admin style
|
||||||
$user->theme['pagination_sep'] = '';
|
$user->theme['pagination_sep'] = '';
|
||||||
|
@ -108,6 +108,86 @@
|
|||||||
</table></td>
|
</table></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table></form>
|
</table></form>
|
||||||
|
<!-- ELSEIF S_EDIT_TEMPLATE -->
|
||||||
|
|
||||||
|
<a href="{U_BACK}" style="float: right">« {L_BACK}</a>
|
||||||
|
|
||||||
|
<h1>{L_EDIT_TEMPLATE}</h1>
|
||||||
|
|
||||||
|
<p>{L_EDIT_TEMPLATE_EXPLAIN}</p>
|
||||||
|
|
||||||
|
<form id="acp_styles" method="post" action="{U_ACTION}">
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>{L_SELECT_TEMPLATE}</legend>
|
||||||
|
<dl>
|
||||||
|
<dt><label for="template_file">{L_TEMPLATE_FILE}: </label></dt>
|
||||||
|
<dd><select id="template_file" name="template_file" onchange="if (this.options[this.selectedIndex].value != '') this.form.submit();">{S_TEMPLATES}</select> <input class="btnlite" type="submit" value="{L_SELECT}" /></dd>
|
||||||
|
</dl>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<!-- IF TEMPLATE_FILE -->
|
||||||
|
<script language="javascript" type="text/javascript" defer="defer">
|
||||||
|
<!--
|
||||||
|
|
||||||
|
function change_editor_height(height)
|
||||||
|
{
|
||||||
|
editor = document.getElementById('template_data');
|
||||||
|
editor.rows = Math.max(5, Math.min(height, 999));
|
||||||
|
|
||||||
|
append_text_rows('acp_styles', height);
|
||||||
|
append_text_rows('acp_template', height);
|
||||||
|
}
|
||||||
|
|
||||||
|
function append_text_rows(form_name, value)
|
||||||
|
{
|
||||||
|
url = document.getElementById(form_name).action;
|
||||||
|
var_start = url.indexOf('&text_rows=');
|
||||||
|
if (var_start == -1)
|
||||||
|
{
|
||||||
|
document.getElementById(form_name).action = url + "&text_rows=" + value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
url_start = url.substring(0, var_start + 1);
|
||||||
|
var_end = url.substring(var_start + 1).indexOf('&');
|
||||||
|
if (var_end == -1)
|
||||||
|
{
|
||||||
|
document.getElementById(form_name).action = url_start + "text_rows=" + value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
document.getElementById(form_name).action = url_start + url.substring(var_end + var_start + 2) + "&text_rows=" + value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//-->
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<form id="acp_template" method="post" action="{U_ACTION}">
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>{L_TEMPLATE_EDITOR}</legend>
|
||||||
|
<dl>
|
||||||
|
<dt><label>{L_SELECTED_TEMPLATE}: </label></dt>
|
||||||
|
<dd>{TEMPLATE_FILE}</dd>
|
||||||
|
</dl>
|
||||||
|
<dl>
|
||||||
|
<dt><label for="text_rows">{L_TEMPLATE_EDITOR_HEIGHT}</label></dt>
|
||||||
|
<dd><input id="text_rows" type="text" maxlength="3" value="{TEXT_ROWS}" /> <input class="btnlite" type="button" name="update" onclick="change_editor_height(this.form.text_rows.value);" value="{L_UPDATE}" /></dd>
|
||||||
|
</dl>
|
||||||
|
<textarea id="template_data" style="font-family:'Courier New', monospace;font-size:9pt;line-height:125%;width:100%;" cols="80" rows="{TEXT_ROWS}" name="template_data">{TEMPLATE_DATA}</textarea>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset class="quick">
|
||||||
|
{S_HIDDEN_FIELDS}
|
||||||
|
<input class="button1" type="submit" name="save" value="{L_SUBMIT}" />
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
<!-- ENDIF -->
|
||||||
|
|
||||||
<!-- ELSEIF S_EXPORT -->
|
<!-- ELSEIF S_EXPORT -->
|
||||||
|
|
||||||
|
@ -122,6 +122,24 @@ pagination_sep = \'{PAGINATION_SEP}\'
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'edit':
|
||||||
|
if ($style_id)
|
||||||
|
{
|
||||||
|
switch ($mode)
|
||||||
|
{
|
||||||
|
case 'imageset':
|
||||||
|
return $this->edit_imageset($style_id);
|
||||||
|
case 'template':
|
||||||
|
return $this->edit_template($style_id);
|
||||||
|
/**
|
||||||
|
* @todo Implement the theme editor
|
||||||
|
*/
|
||||||
|
//case 'theme':
|
||||||
|
// return $this->edit_theme($style_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($mode)
|
switch ($mode)
|
||||||
@ -159,7 +177,7 @@ pagination_sep = \'{PAGINATION_SEP}\'
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->frontend('style', array('export', 'delete'));
|
$this->frontend('style', array('details', 'export', 'delete'));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'template':
|
case 'template':
|
||||||
@ -183,7 +201,7 @@ pagination_sep = \'{PAGINATION_SEP}\'
|
|||||||
|
|
||||||
if ($template_row['template_storedb'] && file_exists("{$phpbb_root_path}styles/{$template_row['template_path']}/template/"))
|
if ($template_row['template_storedb'] && file_exists("{$phpbb_root_path}styles/{$template_row['template_path']}/template/"))
|
||||||
{
|
{
|
||||||
$filelist = array('/' => array());
|
$filelist = array('' => array());
|
||||||
|
|
||||||
$sql = 'SELECT template_filename, template_mtime
|
$sql = 'SELECT template_filename, template_mtime
|
||||||
FROM ' . STYLES_TPLDATA_TABLE . "
|
FROM ' . STYLES_TPLDATA_TABLE . "
|
||||||
@ -194,7 +212,15 @@ pagination_sep = \'{PAGINATION_SEP}\'
|
|||||||
{
|
{
|
||||||
if (@filemtime("{$phpbb_root_path}styles/{$template_row['template_path']}/template/" . $row['template_filename']) > $row['template_mtime'])
|
if (@filemtime("{$phpbb_root_path}styles/{$template_row['template_path']}/template/" . $row['template_filename']) > $row['template_mtime'])
|
||||||
{
|
{
|
||||||
$filelist['/'][] = $row['template_filename'];
|
// get folder info from the filename
|
||||||
|
if (($slash_pos = strrpos($row['template_filename'], '/')) === false)
|
||||||
|
{
|
||||||
|
$filelist[''][] = $row['template_filename'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$filelist[substr($row['template_filename'], 0, $slash_pos + 1)] = substr($row['template_filename'], $slash_pos + 1, strlen($row['template_filename']) - $slashpos - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
@ -206,7 +232,7 @@ pagination_sep = \'{PAGINATION_SEP}\'
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->frontend('template', array('cache', 'details', 'refresh', 'export', 'delete'));
|
$this->frontend('template', array('cache', 'details', 'refresh', 'edit', 'export', 'delete'));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'theme':
|
case 'theme':
|
||||||
@ -257,18 +283,11 @@ pagination_sep = \'{PAGINATION_SEP}\'
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->frontend('theme', array('details', 'refresh', 'export', 'delete'));
|
$this->frontend('theme', array('details', 'refresh', 'edit', 'export', 'delete'));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'imageset':
|
case 'imageset':
|
||||||
switch ($action)
|
$this->frontend('imageset', array('details', 'edit', 'delete', 'export'));
|
||||||
{
|
|
||||||
case 'edit':
|
|
||||||
$this->edit_imageset($style_id);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$this->frontend('imageset', array('details', 'delete', 'export'));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -419,6 +438,213 @@ pagination_sep = \'{PAGINATION_SEP}\'
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a template editor which allows saving changes to template files on the filesystem or in the database.
|
||||||
|
*
|
||||||
|
* @param int $template_id specifies which template set is being edited
|
||||||
|
*/
|
||||||
|
function edit_template($template_id)
|
||||||
|
{
|
||||||
|
global $phpbb_root_path, $phpEx, $SID, $config, $db, $cache, $user, $template;
|
||||||
|
|
||||||
|
$this->page_title = 'EDIT_TEMPLATE';
|
||||||
|
|
||||||
|
$filelist = $filelist_cats = array();
|
||||||
|
|
||||||
|
$template_data = (!empty($_POST['template_data'])) ? ((STRIP) ? stripslashes($_POST['template_data']) : $_POST['template_data']) : '';
|
||||||
|
$template_file = request_var('template_file', '');
|
||||||
|
$text_rows = max(5, min(999, request_var('text_rows', 20)));
|
||||||
|
$save_changes = (isset($_POST['save'])) ? true : false;
|
||||||
|
|
||||||
|
// 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_TPL_TABLE . "
|
||||||
|
WHERE template_id = $template_id";
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
if (!($template_info = $db->sql_fetchrow($result)))
|
||||||
|
{
|
||||||
|
trigger_error($user->lang['NO_TEMPLATE']);
|
||||||
|
}
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
// save changes to the template if the user submitted any
|
||||||
|
if ($save_changes && $template_file)
|
||||||
|
{
|
||||||
|
// Get the filesystem location of the current file
|
||||||
|
$file = "{$phpbb_root_path}styles/{$template_info['template_path']}/template/$template_file";
|
||||||
|
$additional = '';
|
||||||
|
|
||||||
|
// If the template is stored on the filesystem try to write the file else store it in the database
|
||||||
|
if (!$template_info['template_storedb'] && file_exists($file) && is_writeable($file))
|
||||||
|
{
|
||||||
|
if (!($fp = fopen($file, 'wb')))
|
||||||
|
{
|
||||||
|
trigger_error($user->lang['NO_TEMPLATE']);
|
||||||
|
}
|
||||||
|
fwrite($fp, $template_data);
|
||||||
|
fclose($fp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$db->sql_transaction('begin');
|
||||||
|
|
||||||
|
// If it's not stored in the db yet, then update the template setting and store all template files in the db
|
||||||
|
if (!$template_info['template_storedb'])
|
||||||
|
{
|
||||||
|
$sql = 'UPDATE ' . STYLES_TPL_TABLE . '
|
||||||
|
SET template_storedb = 1
|
||||||
|
WHERE template_id = ' . $template_id;
|
||||||
|
$db->sql_query($sql);
|
||||||
|
|
||||||
|
$filelist = filelist("{$phpbb_root_path}styles/{$template_info['template_path']}/template", '', 'html');
|
||||||
|
$this->store_templates('insert', $template_id, $template_info['template_path'], $filelist);
|
||||||
|
|
||||||
|
add_log('admin', 'LOG_TEMPLATE_EDIT_DETAILS', $template_info['template_name']);
|
||||||
|
$additional .= '<br />' . $user->lang['EDIT_TEMPLATE_STORED_DB'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the template_data table entry for this template file
|
||||||
|
$sql = 'UPDATE ' . STYLES_TPLDATA_TABLE . "
|
||||||
|
SET template_data = '" . $db->sql_escape($template_data) . "', template_mtime = " . time() . "
|
||||||
|
WHERE template_id = $template_id
|
||||||
|
AND template_filename = '" . $db->sql_escape($template_file) . "'";
|
||||||
|
$db->sql_query($sql);
|
||||||
|
|
||||||
|
$db->sql_transaction('commit');
|
||||||
|
}
|
||||||
|
|
||||||
|
// destroy the cached version of the template
|
||||||
|
@unlink("{$phpbb_root_path}cache/tpl_{$template_info['template_name']}_" . str_replace('/', '.', $template_file) . ".$phpEx");
|
||||||
|
|
||||||
|
add_log('admin', 'LOG_EDIT_TEMPLATE', $template_info['template_name'], $template_file);
|
||||||
|
trigger_error($user->lang['TEMPLATE_FILE_UPDATED'] . $additional . adm_back_link($this->u_action . "&action=edit&id=$template_id&text_rows=$text_rows&template_file=$template_file"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate a category array containing template filenames
|
||||||
|
if (!$template_info['template_storedb'])
|
||||||
|
{
|
||||||
|
$template_path = "{$phpbb_root_path}styles/{$template_info['template_path']}/template";
|
||||||
|
|
||||||
|
$filelist = filelist($template_path, '', 'html');
|
||||||
|
$filelist[''] = array_diff($filelist[''], array('bbcode.html'));
|
||||||
|
|
||||||
|
if ($template_file)
|
||||||
|
{
|
||||||
|
if (!file_exists($template_path . "/$template_file") || !($template_data = file_get_contents($template_path . "/$template_file")))
|
||||||
|
{
|
||||||
|
trigger_error($user->lang['NO_TEMPLATE']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$sql = 'SELECT *
|
||||||
|
FROM ' . STYLES_TPLDATA_TABLE . "
|
||||||
|
WHERE template_id = $template_id";
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
$filelist = array('' => array());
|
||||||
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
$file_info = pathinfo($row['template_filename']);
|
||||||
|
|
||||||
|
if (($file_info['basename'] != 'bbcode') && ($file_info['extension'] == 'html'))
|
||||||
|
{
|
||||||
|
if (($file_info['dirname'] == '.') || empty($file_info['dirname']))
|
||||||
|
{
|
||||||
|
$filelist[''][] = $row['template_filename'];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$filelist[$file_info['dirname'] . '/'][] = "{$file_info['basename']}.{$file_info['extension']}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($row['template_filename'] == $template_file)
|
||||||
|
{
|
||||||
|
$template_data = $row['template_data'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
unset($file_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now create the categories
|
||||||
|
$filelist_cats[''] = array();
|
||||||
|
foreach ($filelist as $pathfile => $file_ary)
|
||||||
|
{
|
||||||
|
// Use the directory name as category name
|
||||||
|
if (!empty($pathfile))
|
||||||
|
{
|
||||||
|
$filelist_cats[$pathfile] = array();
|
||||||
|
foreach ($file_ary as $file)
|
||||||
|
{
|
||||||
|
$filelist_cats[$pathfile][$pathfile . $file] = $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// or if it's in the main category use the word before the first underscore to group files
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$cats = array();
|
||||||
|
foreach ($file_ary as $file)
|
||||||
|
{
|
||||||
|
$cats[] = substr($file, 0, strpos($file, '_'));
|
||||||
|
$filelist_cats[substr($file, 0, strpos($file, '_'))][$file] = $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cats = array_values(array_unique($cats));
|
||||||
|
|
||||||
|
// we don't need any single element categories so put them into the misc '' category
|
||||||
|
for ($i = 0, $n = sizeof($cats); $i < $n; $i++)
|
||||||
|
{
|
||||||
|
if (sizeof($filelist_cats[$cats[$i]]) == 1)
|
||||||
|
{
|
||||||
|
$filelist_cats[''][key($filelist_cats[$cats[$i]])] = current($filelist_cats[$cats[$i]]);
|
||||||
|
unset($filelist_cats[$cats[$i]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($cats);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($filelist);
|
||||||
|
|
||||||
|
// Generate list of categorised template files
|
||||||
|
$tpl_options = '';
|
||||||
|
ksort($filelist_cats);
|
||||||
|
foreach ($filelist_cats as $category => $tpl_ary)
|
||||||
|
{
|
||||||
|
ksort($tpl_ary);
|
||||||
|
|
||||||
|
if (!empty($category))
|
||||||
|
{
|
||||||
|
$tpl_options .= '<option class="sep" value="">' . $category . '</option>';
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($tpl_ary as $filename => $file)
|
||||||
|
{
|
||||||
|
$selected = ($template_file == $filename) ? ' selected="selected"' : '';
|
||||||
|
$tpl_options .= '<option value="' . $filename . '"' . $selected . '>' . $file . '</option>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->assign_vars(array(
|
||||||
|
'S_EDIT_TEMPLATE' => true,
|
||||||
|
'S_HIDDEN_FIELDS' => build_hidden_fields(array('template_file' => $template_file)),
|
||||||
|
'S_TEMPLATES' => $tpl_options,
|
||||||
|
|
||||||
|
'U_ACTION' => $this->u_action . "&action=edit&id=$template_id&text_rows=$text_rows",
|
||||||
|
'U_BACK' => $this->u_action,
|
||||||
|
|
||||||
|
'TEMPLATE_FILE' => $template_file,
|
||||||
|
'TEMPLATE_DATA' => htmlentities($template_data),
|
||||||
|
'TEXT_ROWS' => $text_rows)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit imagesets
|
* Edit imagesets
|
||||||
*/
|
*/
|
||||||
@ -1376,10 +1602,11 @@ pagination_sep = \'{PAGINATION_SEP}\'
|
|||||||
/**
|
/**
|
||||||
* Store template files into db
|
* Store template files into db
|
||||||
*/
|
*/
|
||||||
function store_templates($mode, $style_id, $path, $filelist)
|
function store_templates($mode, $style_id, $name, $filelist)
|
||||||
{
|
{
|
||||||
global $phpbb_root_path, $phpEx, $db;
|
global $phpbb_root_path, $phpEx, $db;
|
||||||
|
|
||||||
|
$path = str_replace(' ', '_', $name) . '/template/';
|
||||||
$includes = array();
|
$includes = array();
|
||||||
foreach ($filelist as $pathfile => $file_ary)
|
foreach ($filelist as $pathfile => $file_ary)
|
||||||
{
|
{
|
||||||
@ -1416,7 +1643,7 @@ pagination_sep = \'{PAGINATION_SEP}\'
|
|||||||
// heck of a lot of data ...
|
// heck of a lot of data ...
|
||||||
$sql_ary = array(
|
$sql_ary = array(
|
||||||
'template_id' => $style_id,
|
'template_id' => $style_id,
|
||||||
'template_filename' => $file,
|
'template_filename' => "$pathfile$file",
|
||||||
'template_included' => (isset($includes[$file])) ? implode(':', $includes[$file]) . ':' : '',
|
'template_included' => (isset($includes[$file])) ? implode(':', $includes[$file]) . ':' : '',
|
||||||
'template_mtime' => filemtime("{$phpbb_root_path}styles/$path$pathfile$file"),
|
'template_mtime' => filemtime("{$phpbb_root_path}styles/$path$pathfile$file"),
|
||||||
'template_data' => implode('', file("{$phpbb_root_path}styles/$path$pathfile$file")),
|
'template_data' => implode('', file("{$phpbb_root_path}styles/$path$pathfile$file")),
|
||||||
@ -1430,7 +1657,7 @@ pagination_sep = \'{PAGINATION_SEP}\'
|
|||||||
{
|
{
|
||||||
$sql = 'UPDATE ' . STYLES_TPLDATA_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
|
$sql = 'UPDATE ' . STYLES_TPLDATA_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
|
||||||
WHERE template_id = $style_id
|
WHERE template_id = $style_id
|
||||||
AND template_filename = '" . $db->sql_escape($file) . "'";
|
AND template_filename = '" . $db->sql_escape("$pathfile$file") . "'";
|
||||||
}
|
}
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
}
|
}
|
||||||
@ -2029,7 +2256,7 @@ pagination_sep = \'{PAGINATION_SEP}\'
|
|||||||
if ($mode == 'template' && $store_db)
|
if ($mode == 'template' && $store_db)
|
||||||
{
|
{
|
||||||
$filelist = filelist("{$root_path}template", '', 'html');
|
$filelist = filelist("{$root_path}template", '', 'html');
|
||||||
$this->store_templates('insert', $id, $path, $filelist);
|
$this->store_templates('insert', $id, $name, $filelist);
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->sql_transaction('commit');
|
$db->sql_transaction('commit');
|
||||||
|
@ -96,13 +96,13 @@ class template_compile
|
|||||||
$php_blocks = $matches[1];
|
$php_blocks = $matches[1];
|
||||||
$code = preg_replace('#<!-- PHP -->(.*?)<!-- ENDPHP -->#s', '<!-- PHP -->', $code);
|
$code = preg_replace('#<!-- PHP -->(.*?)<!-- ENDPHP -->#s', '<!-- PHP -->', $code);
|
||||||
|
|
||||||
preg_match_all('#<!-- INCLUDE ([a-zA-Z0-9\_\-\+\.]+?) -->#', $code, $matches);
|
preg_match_all('#<!-- INCLUDE ([a-zA-Z0-9\_\-\+\./]+?) -->#', $code, $matches);
|
||||||
$include_blocks = $matches[1];
|
$include_blocks = $matches[1];
|
||||||
$code = preg_replace('#<!-- INCLUDE ([a-zA-Z0-9\_\-\+\.]+?) -->#', '<!-- INCLUDE -->', $code);
|
$code = preg_replace('#<!-- INCLUDE ([a-zA-Z0-9\_\-\+\./]+?) -->#', '<!-- INCLUDE -->', $code);
|
||||||
|
|
||||||
preg_match_all('#<!-- INCLUDEPHP ([a-zA-Z0-9\_\-\+\.\\\\]+?) -->#', $code, $matches);
|
preg_match_all('#<!-- INCLUDEPHP ([a-zA-Z0-9\_\-\+\./]+?) -->#', $code, $matches);
|
||||||
$includephp_blocks = $matches[1];
|
$includephp_blocks = $matches[1];
|
||||||
$code = preg_replace('#<!-- INCLUDEPHP ([a-zA-Z0-9\_\-\+\.]+?) -->#', '<!-- INCLUDEPHP -->', $code);
|
$code = preg_replace('#<!-- INCLUDEPHP ([a-zA-Z0-9\_\-\+\./]+?) -->#', '<!-- INCLUDEPHP -->', $code);
|
||||||
|
|
||||||
preg_match_all('#<!-- (.*?) (.*?)?[ ]?-->#', $code, $blocks);
|
preg_match_all('#<!-- (.*?) (.*?)?[ ]?-->#', $code, $blocks);
|
||||||
$text_blocks = preg_split('#<!-- (.*?) (.*?)?[ ]?-->#', $code);
|
$text_blocks = preg_split('#<!-- (.*?) (.*?)?[ ]?-->#', $code);
|
||||||
@ -220,7 +220,6 @@ class template_compile
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This will handle the remaining root-level varrefs
|
// This will handle the remaining root-level varrefs
|
||||||
|
|
||||||
// transform vars prefixed by L_ into their language variable pendant if nothing is set within the tpldata array
|
// transform vars prefixed by L_ into their language variable pendant if nothing is set within the tpldata array
|
||||||
$text_blocks = preg_replace('#\{L_([a-z0-9\-_]*)\}#is', "<?php echo ((isset(\$this->_tpldata['.'][0]['L_\\1'])) ? \$this->_tpldata['.'][0]['L_\\1'] : ((isset(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '{ ' . ucfirst(strtolower(str_replace('_', ' ', '\\1'))) . ' }')); ?>", $text_blocks);
|
$text_blocks = preg_replace('#\{L_([a-z0-9\-_]*)\}#is', "<?php echo ((isset(\$this->_tpldata['.'][0]['L_\\1'])) ? \$this->_tpldata['.'][0]['L_\\1'] : ((isset(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '{ ' . ucfirst(strtolower(str_replace('_', ' ', '\\1'))) . ' }')); ?>", $text_blocks);
|
||||||
|
|
||||||
@ -661,7 +660,7 @@ class template_compile
|
|||||||
{
|
{
|
||||||
global $phpEx, $user;
|
global $phpEx, $user;
|
||||||
|
|
||||||
$filename = $this->template->cachepath . $this->template->filename[$handle] . '.' . $phpEx;
|
$filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . '.' . $phpEx;
|
||||||
|
|
||||||
if ($fp = @fopen($filename, 'wb'))
|
if ($fp = @fopen($filename, 'wb'))
|
||||||
{
|
{
|
||||||
|
@ -153,7 +153,7 @@ class template
|
|||||||
{
|
{
|
||||||
global $user, $phpEx, $config;
|
global $user, $phpEx, $config;
|
||||||
|
|
||||||
$filename = $this->cachepath . $this->filename[$handle] . '.' . $phpEx;
|
$filename = $this->cachepath . str_replace('/', '.', $this->filename[$handle]) . '.' . $phpEx;
|
||||||
|
|
||||||
$recompile = (($config['load_tplcompile'] && @filemtime($filename) < filemtime($this->files[$handle])) || !file_exists($filename)) ? true : false;
|
$recompile = (($config['load_tplcompile'] && @filemtime($filename) < filemtime($this->files[$handle])) || !file_exists($filename)) ? true : false;
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ class template
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Only bother compiling if it doesn't already exist
|
// Only bother compiling if it doesn't already exist
|
||||||
if (!file_exists($this->cachepath . $row['template_filename'] . '.' . $phpEx))
|
if (!file_exists($this->cachepath . str_replace('/', '.', $row['template_filename']) . '.' . $phpEx))
|
||||||
{
|
{
|
||||||
$this->filename[$row['template_filename']] = $row['template_filename'];
|
$this->filename[$row['template_filename']] = $row['template_filename'];
|
||||||
$compile->compile_write($row['template_filename'], $compile->compile(trim($row['template_data'])));
|
$compile->compile_write($row['template_filename'], $compile->compile(trim($row['template_data'])));
|
||||||
|
@ -62,15 +62,6 @@ $lang = array_merge($lang, array(
|
|||||||
'DELETE_THEME_EXPLAIN' => 'Here you can remove the selected theme from the database. Additionally, if you have permission you can elect to remove the theme from the filesystem. Please note that there is no undo capability. When the theme is deleted it is gone for good. It is recommended that you first export your theme for possible future use.',
|
'DELETE_THEME_EXPLAIN' => 'Here you can remove the selected theme from the database. Additionally, if you have permission you can elect to remove the theme from the filesystem. Please note that there is no undo capability. When the theme is deleted it is gone for good. It is recommended that you first export your theme for possible future use.',
|
||||||
'DETAILS' => 'Details',
|
'DETAILS' => 'Details',
|
||||||
|
|
||||||
'EDIT_IMAGESET' => 'Edit imageset',
|
|
||||||
'EDIT_IMAGESET_EXPLAIN' => 'Here you can edit the individual images which define the imageset. You can also specify dimensions for the image. Dimensions are optional, specifying them can overcome certain rendering issues with some browsers. By not specifying them you reduce the size of the database record a little.',
|
|
||||||
'IMAGE_CONFIGURATION' => 'Image configuration',
|
|
||||||
'IMAGE_WIDTH' => 'Image width',
|
|
||||||
'IMAGE_HEIGHT' => 'Image height',
|
|
||||||
'IMAGE' => 'Image',
|
|
||||||
'IMAGE_NAME' => 'Image name',
|
|
||||||
'IMAGE_LOCATION' => 'Image location',
|
|
||||||
|
|
||||||
'EDIT_DETAILS_IMAGESET' => 'Edit imageset details',
|
'EDIT_DETAILS_IMAGESET' => 'Edit imageset details',
|
||||||
'EDIT_DETAILS_IMAGESET_EXPLAIN' => 'Here you can edit certain imageset details such as its name.',
|
'EDIT_DETAILS_IMAGESET_EXPLAIN' => 'Here you can edit certain imageset details such as its name.',
|
||||||
'EDIT_DETAILS_STYLE' => 'Edit Style',
|
'EDIT_DETAILS_STYLE' => 'Edit Style',
|
||||||
@ -79,10 +70,21 @@ $lang = array_merge($lang, array(
|
|||||||
'EDIT_DETAILS_TEMPLATE_EXPLAIN' => 'Here you can edit certain templates details such as its name. You may also have the option to switch storage of the stylesheet from the filesystem to the database and vice versa. This option depends on your PHP configuration and whether your template set can be written to by the webserver.',
|
'EDIT_DETAILS_TEMPLATE_EXPLAIN' => 'Here you can edit certain templates details such as its name. You may also have the option to switch storage of the stylesheet from the filesystem to the database and vice versa. This option depends on your PHP configuration and whether your template set can be written to by the webserver.',
|
||||||
'EDIT_DETAILS_THEME' => 'Edit theme details',
|
'EDIT_DETAILS_THEME' => 'Edit theme details',
|
||||||
'EDIT_DETAILS_THEME_EXPLAIN' => 'Here you can edit certain theme details such as its name. You may also have the option to switch storage of the stylesheet from the filesystem to the database and vice versa. This option depends on your PHP configuration and whether your stylesheet can be written to by the webserver.',
|
'EDIT_DETAILS_THEME_EXPLAIN' => 'Here you can edit certain theme details such as its name. You may also have the option to switch storage of the stylesheet from the filesystem to the database and vice versa. This option depends on your PHP configuration and whether your stylesheet can be written to by the webserver.',
|
||||||
|
'EDIT_IMAGESET' => 'Edit imageset',
|
||||||
|
'EDIT_IMAGESET_EXPLAIN' => 'Here you can edit the individual images which define the imageset. You can also specify dimensions for the image. Dimensions are optional, specifying them can overcome certain rendering issues with some browsers. By not specifying them you reduce the size of the database record a little.',
|
||||||
|
'EDIT_TEMPLATE' => 'Edit template',
|
||||||
|
'EDIT_TEMPLATE_EXPLAIN' => 'Here you can edit your template set directly. Please remember that these edits are permanent and cannot be undone once submitted. If PHP can write to the template files in your styles directory any changes here will be written directly to those files. If PHP cannot write to those files they will be copied into the database and all changes will only be reflected there. Please take care when editing your template set, remember to close all replacement variable terms {XXXX} and conditional statements.',
|
||||||
|
'EDIT_TEMPLATE_STORED_DB' => 'The template file was unwritable so the template set is now stored in the database containing the modified file.',
|
||||||
'EXPORT' => 'Export',
|
'EXPORT' => 'Export',
|
||||||
|
|
||||||
'FROM' => 'from', // "Create new style .... from ..."
|
'FROM' => 'from', // "Create new style .... from ..."
|
||||||
|
|
||||||
|
'IMAGE_CONFIGURATION' => 'Image configuration',
|
||||||
|
'IMAGE_WIDTH' => 'Image width',
|
||||||
|
'IMAGE_HEIGHT' => 'Image height',
|
||||||
|
'IMAGE' => 'Image',
|
||||||
|
'IMAGE_NAME' => 'Image name',
|
||||||
|
'IMAGE_LOCATION' => 'Image location',
|
||||||
'IMAGESET_ADDED' => 'New imageset added on filesystem',
|
'IMAGESET_ADDED' => 'New imageset added on filesystem',
|
||||||
'IMAGESET_ADDED_DB' => 'New imageset added to database',
|
'IMAGESET_ADDED_DB' => 'New imageset added to database',
|
||||||
'IMAGESET_UPDATED' => 'Imageset updated successfully',
|
'IMAGESET_UPDATED' => 'Imageset updated successfully',
|
||||||
@ -147,9 +149,10 @@ $lang = array_merge($lang, array(
|
|||||||
'REQUIRES_TEMPLATE' => 'This style requires the %s template set to be installed.',
|
'REQUIRES_TEMPLATE' => 'This style requires the %s template set to be installed.',
|
||||||
'REQUIRES_THEME' => 'This style requires the %s theme to be installed.',
|
'REQUIRES_THEME' => 'This style requires the %s theme to be installed.',
|
||||||
|
|
||||||
|
'SELECT_TEMPLATE' => 'Select template file',
|
||||||
|
'SELECTED_TEMPLATE' => 'Selected template file',
|
||||||
'STORE_DATABASE' => 'Database',
|
'STORE_DATABASE' => 'Database',
|
||||||
'STORE_FILESYSTEM' => 'Filesystem',
|
'STORE_FILESYSTEM' => 'Filesystem',
|
||||||
|
|
||||||
'STYLE_ACTIVATE' => 'Activate',
|
'STYLE_ACTIVATE' => 'Activate',
|
||||||
'STYLE_ACTIVE' => 'Active',
|
'STYLE_ACTIVE' => 'Active',
|
||||||
'STYLE_ADDED' => 'Style added successfully',
|
'STYLE_ADDED' => 'Style added successfully',
|
||||||
@ -175,6 +178,10 @@ $lang = array_merge($lang, array(
|
|||||||
'STYLE_THEME' => 'Theme',
|
'STYLE_THEME' => 'Theme',
|
||||||
'STYLE_USED_BY' => 'Used by',
|
'STYLE_USED_BY' => 'Used by',
|
||||||
|
|
||||||
|
'TEMPLATE_EDITOR' => 'Raw HTML template editor',
|
||||||
|
'TEMPLATE_EDITOR_HEIGHT' => 'Template editor height',
|
||||||
|
'TEMPLATE_FILE' => 'Template file',
|
||||||
|
'TEMPLATE_FILE_UPDATED' => 'Template file updated successfully',
|
||||||
'TEMPLATE_ADDED' => 'Template set added and stored on filesystem',
|
'TEMPLATE_ADDED' => 'Template set added and stored on filesystem',
|
||||||
'TEMPLATE_ADDED_DB' => 'Template set added and stored in database',
|
'TEMPLATE_ADDED_DB' => 'Template set added and stored in database',
|
||||||
'TEMPLATE_DELETED' => 'Template set deleted successfully',
|
'TEMPLATE_DELETED' => 'Template set deleted successfully',
|
||||||
|
@ -478,6 +478,7 @@ $lang = array_merge($lang, array(
|
|||||||
'UNREAD_PMS' => '<b>%d</b> unread messages',
|
'UNREAD_PMS' => '<b>%d</b> unread messages',
|
||||||
'UNWATCHED_FORUMS' => 'You are no longer watching the selected forums.',
|
'UNWATCHED_FORUMS' => 'You are no longer watching the selected forums.',
|
||||||
'UNWATCHED_TOPICS' => 'You are no longer watching the selected topics.',
|
'UNWATCHED_TOPICS' => 'You are no longer watching the selected topics.',
|
||||||
|
'UPDATE' => 'Update',
|
||||||
'UPLOAD_IN_PROGRESS' => 'The upload is currently in progress',
|
'UPLOAD_IN_PROGRESS' => 'The upload is currently in progress',
|
||||||
'URL_REDIRECT' => 'If your browser does not support meta redirection please click %sHERE%s to be redirected.',
|
'URL_REDIRECT' => 'If your browser does not support meta redirection please click %sHERE%s to be redirected.',
|
||||||
'USERGROUPS' => 'Groups',
|
'USERGROUPS' => 'Groups',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user