mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-29 06:38:52 +00:00
Add/edit styles
git-svn-id: file:///svn/phpbb/trunk@4255 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
2e8dec8c1f
commit
2536066e65
2 changed files with 146 additions and 28 deletions
|
@ -28,19 +28,40 @@ if (!$auth->acl_get('a_styles'))
|
||||||
trigger_error($user->lang['NO_ADMIN']);
|
trigger_error($user->lang['NO_ADMIN']);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
|
// Get and set some vars
|
||||||
$mode = (isset($_REQUEST['mode'])) ? htmlspecialchars($_REQUEST['mode']) : '';
|
$mode = (isset($_REQUEST['mode'])) ? htmlspecialchars($_REQUEST['mode']) : '';
|
||||||
$action = (isset($_REQUEST['action'])) ? htmlspecialchars($_REQUEST['action']) : '';
|
|
||||||
|
if (isset($_REQUEST['action']))
|
||||||
|
{
|
||||||
|
$action = htmlspecialchars($_REQUEST['action']);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (isset($_POST['add']))
|
||||||
|
{
|
||||||
|
$action = 'add';
|
||||||
|
}
|
||||||
|
else if (isset($_POST['preview']))
|
||||||
|
{
|
||||||
|
$action = 'preview';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$action = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$error = array();
|
||||||
|
|
||||||
|
|
||||||
|
// What shall we do today then?
|
||||||
switch ($mode)
|
switch ($mode)
|
||||||
{
|
{
|
||||||
|
|
||||||
case 'styles':
|
case 'styles':
|
||||||
|
|
||||||
$style_id = (isset($_REQUEST['id'])) ? $_REQUEST['id'] : '';
|
$style_id = (isset($_REQUEST['id'])) ? intval($_REQUEST['id']) : '';
|
||||||
|
|
||||||
switch ($action)
|
switch ($action)
|
||||||
{
|
{
|
||||||
|
@ -53,12 +74,83 @@ switch ($mode)
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'delete':
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'export':
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'add':
|
||||||
case 'edit':
|
case 'edit':
|
||||||
|
|
||||||
if (isset($_POST['update']))
|
if (isset($_POST['update']))
|
||||||
{
|
{
|
||||||
|
$style_name = (isset($_POST['style_name'])) ? stripslashes(htmlspecialchars($_POST['style_name'])) : '';
|
||||||
|
$style_copyright = (isset($_POST['style_copyright'])) ? stripslashes(htmlspecialchars($_POST['style_copyright'])) : '';
|
||||||
|
|
||||||
|
$style_active = (!empty($_POST['style_active'])) ? 1 : 0;
|
||||||
|
|
||||||
|
$template_id = (!empty($_POST['template_id'])) ? intval($_POST['template_id']) : 0;
|
||||||
|
$theme_id = (!empty($_POST['theme_id'])) ? intval($_POST['theme_id']) : 0;
|
||||||
|
$imageset_id = (!empty($_POST['imageset_id'])) ? intval($_POST['imageset_id']) : 0;
|
||||||
|
|
||||||
|
if (empty($style_name))
|
||||||
|
{
|
||||||
|
$error[] = $user->lang['STYLE_ERR_STYLE_NAME'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strlen($style_name) > 30)
|
||||||
|
{
|
||||||
|
$error[] = $user->lang['STYLE_ERR_NAME_LONG'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen($style_copyright) > 60)
|
||||||
|
{
|
||||||
|
$error[] = $user->lang['STYLE_ERR_COPY_LONG'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$template_id || !$theme_id || !$imageset_id)
|
||||||
|
{
|
||||||
|
$error[] = $user->lang['STYLE_ERR_NO_IDS'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == 'add')
|
||||||
|
{
|
||||||
|
$sql = 'SELECT style_name
|
||||||
|
FROM ' . STYLES_TABLE . "
|
||||||
|
WHERE style_name = '" . $db->sql_escape($style_name) . "'";
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
|
if ($row = $db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
$error[] = $user->lang['STYLE_ERR_NAME_EXIST'];
|
||||||
|
}
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sizeof($error))
|
||||||
|
{
|
||||||
|
$sql_ary = array(
|
||||||
|
'style_name' => $style_name,
|
||||||
|
'style_copyright' => $style_copyright,
|
||||||
|
'template_id' => $template_id,
|
||||||
|
'theme_id' => $theme_id,
|
||||||
|
'imageset_id' => $imageset_id,
|
||||||
|
);
|
||||||
|
|
||||||
|
$sql = ($action == 'add') ? 'INSERT INTO ' . STYLES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary) : 'UPDATE ' . STYLES_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE style_id = $style_id";
|
||||||
|
$db->sql_query($sql);
|
||||||
|
|
||||||
|
$log = ($action == 'add') ? 'LOG_ADD_STYLE' : 'LOG_EDIT_STYLE';
|
||||||
|
add_log('admin', $log, addslashes($style_name));
|
||||||
|
|
||||||
|
$message = ($action == 'add') ? 'STYLED_ADDED' : 'STYLE_EDITED';
|
||||||
|
trigger_error($user->lang[$message]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sizeof($error))
|
||||||
|
{
|
||||||
if ($style_id)
|
if ($style_id)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT *
|
$sql = 'SELECT *
|
||||||
|
@ -72,6 +164,14 @@ switch ($mode)
|
||||||
}
|
}
|
||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$style_name = (isset($_POST['style_name'])) ? stripslashes(htmlspecialchars($_POST['style_name'])) : '';
|
||||||
|
$style_copyright = '';
|
||||||
|
$style_active = 1;
|
||||||
|
$template_id = $theme_id = $imageset_id = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$style_options = array();
|
$style_options = array();
|
||||||
$field_ary = array(STYLES_CSS_TABLE => 'theme', STYLES_TPL_TABLE => 'template', STYLES_IMAGE_TABLE => 'imageset');
|
$field_ary = array(STYLES_CSS_TABLE => 'theme', STYLES_TPL_TABLE => 'template', STYLES_IMAGE_TABLE => 'imageset');
|
||||||
|
@ -81,6 +181,7 @@ switch ($mode)
|
||||||
FROM $table
|
FROM $table
|
||||||
ORDER BY {$field}_id";
|
ORDER BY {$field}_id";
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$selected = ($row[$field . '_id'] == ${$field . '_id'}) ? ' selected="selected"' : '';
|
$selected = ($row[$field . '_id'] == ${$field . '_id'}) ? ' selected="selected"' : '';
|
||||||
|
@ -103,15 +204,29 @@ switch ($mode)
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="2">Edit Style</th>
|
<th colspan="2">Edit Style</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if (sizeof($error))
|
||||||
|
{
|
||||||
|
|
||||||
|
?>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="row3" align="center"><span style="color:red"><?php echo implode('<br />', $error); ?></span></td>
|
||||||
|
</tr>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="row1">Style Name</td>
|
<td class="row1">Style Name</td>
|
||||||
<td class="row2"><input class="post" type="text" name="style_name" maxlength="255" size="40" /></td>
|
<td class="row2"><input class="post" type="text" name="style_name" maxlength="30" size="30" value="<?php echo $style_name; ?>" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="row1">Style Copyright</td>
|
<td class="row1">Style Copyright</td>
|
||||||
<td class="row2"><?php
|
<td class="row2"><?php
|
||||||
|
|
||||||
echo ($action == 'edit') ? '<b>' . $style_copyright . '</b>' : '<input class="post" type="text" name="style_name" maxlength="255" size="40" value="' . $style_copyright . '" />';
|
echo ($action == 'edit') ? '<b>' . $style_copyright . '</b>' : '<input class="post" type="text" name="style_copyright" maxlength="60" size="30" value="' . $style_copyright . '" />';
|
||||||
|
|
||||||
?></td>
|
?></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -132,7 +247,7 @@ switch ($mode)
|
||||||
<td class="row2"><input type="radio" name="style_active" value="0"<?php echo (!$style_active) ? ' checked="checked"' : ''; ?> /> Inactive <input type="radio" name="style_active" value="1"<?php echo ($style_active) ? ' checked="checked"' : ''; ?> /> Active</td>
|
<td class="row2"><input type="radio" name="style_active" value="0"<?php echo (!$style_active) ? ' checked="checked"' : ''; ?> /> Inactive <input type="radio" name="style_active" value="1"<?php echo ($style_active) ? ' checked="checked"' : ''; ?> /> Active</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="cat" colspan="2" align="center"><input class="btnmain" type="submit" name="update" value="<?php echo $user->lang['SUBMIT']; ?>" /> <input class="btnlite" type="submit" name="preview" value="<?php echo $user->lang['PREVIEW']; ?>" /> <input class="btnlite" type="reset" value="<?php echo $user->lang['RESET']; ?>" /></td>
|
<td class="cat" colspan="2" align="center"><input class="btnmain" type="submit" name="update" value="<?php echo $user->lang['SUBMIT']; ?>" /> <!-- input class="btnlite" type="submit" name="preview" value="<?php echo $user->lang['PREVIEW']; ?>" /> --><input class="btnlite" type="reset" value="<?php echo $user->lang['RESET']; ?>" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table></form>
|
</table></form>
|
||||||
|
|
||||||
|
@ -140,16 +255,9 @@ switch ($mode)
|
||||||
|
|
||||||
adm_page_footer();
|
adm_page_footer();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete':
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'export':
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
adm_page_header($user->lang['MANAGE_STYLE']);
|
adm_page_header($user->lang['MANAGE_STYLE']);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -210,7 +318,7 @@ switch ($mode)
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="cat" colspan="6" align="right">Create new style: <input class="post" type="text" name="style_name" value="" maxlength="30" size="25" /> <input class="btnmain" type="submit" name="newstyle" value="<?php echo $user->lang['SUBMIT']; ?>" /></td>
|
<td class="cat" colspan="6" align="right">Create new style: <input class="post" type="text" name="style_name" value="" maxlength="30" size="25" /> <input class="btnmain" type="submit" name="add" value="<?php echo $user->lang['SUBMIT']; ?>" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table></form>
|
</table></form>
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -175,6 +175,8 @@ $lang = array_merge($lang, array(
|
||||||
'LOG_FORUM_DEL_MOVE_POSTS_MOVE_FORUMS' => '<b>Deleted forum, moved posts</b> to %s <b>and subforums</b> to %s<br />» %s',
|
'LOG_FORUM_DEL_MOVE_POSTS_MOVE_FORUMS' => '<b>Deleted forum, moved posts</b> to %s <b>and subforums</b> to %s<br />» %s',
|
||||||
|
|
||||||
'LOG_EDIT_THEME' => '<b>Edited theme</b><br />» %s',
|
'LOG_EDIT_THEME' => '<b>Edited theme</b><br />» %s',
|
||||||
|
'LOG_ADD_STYLE' => '<b>Added new style</b><br />» %s',
|
||||||
|
'LOG_EDIT_STYLE' => '<b>Edited style</b><br />» %s',
|
||||||
|
|
||||||
|
|
||||||
'WELCOME_PHPBB' => 'Welcome to phpBB',
|
'WELCOME_PHPBB' => 'Welcome to phpBB',
|
||||||
|
@ -895,12 +897,20 @@ $lang = array_merge($lang, array(
|
||||||
'Disallowed_already' => 'The name you entered could not be disallowed. It either already exists in the list, exists in the word censor list, or a matching username is present',
|
'Disallowed_already' => 'The name you entered could not be disallowed. It either already exists in the list, exists in the word censor list, or a matching username is present',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
'MANAGE_STYLE_EXPLAIN' => 'Here you can manage the available styles on your board. A style consists off a template, theme and imageset. You may alter existing styles, delete, deactivate, reactivate, create or import new ones. You can also see what a style will look like using the preview function. The current default style is noted by the presence of an asterix, * Also listed is the total user count for each style, note that overriding user styles will not be reflected here.',
|
'MANAGE_STYLE_EXPLAIN' => 'Here you can manage the available styles on your board. A style consists off a template, theme and imageset. You may alter existing styles, delete, deactivate, reactivate, create or import new ones. You can also see what a style will look like using the preview function. The current default style is noted by the presence of an asterix, * Also listed is the total user count for each style, note that overriding user styles will not be reflected here.',
|
||||||
'STYLE_ACTIVATE' => 'Activate',
|
'STYLE_ACTIVATE' => 'Activate',
|
||||||
'STYLE_DEACTIVATE' => 'Deactivate',
|
'STYLE_DEACTIVATE' => 'Deactivate',
|
||||||
'EDIT_STYLE' => 'Edit Style',
|
'EDIT_STYLE' => 'Edit Style',
|
||||||
'EDIT_STYLE_EXPLAIN' => 'Using the form below you can modify this existing style. You may alter the combination of template, theme and imageset which define the style itself. You may also deactivate the style and alter its name.',
|
'EDIT_STYLE_EXPLAIN' => 'Using the form below you can modify this existing style. You may alter the combination of template, theme and imageset which define the style itself. You may also deactivate the style and alter its name.',
|
||||||
|
'STYLE_ADDED' => 'Style added successfully',
|
||||||
|
'STYLE_EDITED' => 'Style edited successfully',
|
||||||
|
|
||||||
|
'STYLE_ERR_STYLE_NAME' => 'You must supply a name for this style',
|
||||||
|
'STYLE_ERR_NAME_LONG' => 'The style name can be no longer than 30 characters',
|
||||||
|
'STYLE_ERR_NAME_EXIST' => 'A style with that name already exists',
|
||||||
|
'STYLE_ERR_COPY_LONG' => 'The copyright can be no longer than 60 characters',
|
||||||
|
'STYLE_ERR_NO_IDS' => 'You must select a template, theme and imageset for this style',
|
||||||
|
|
||||||
|
|
||||||
'MANAGE_TEMPLATE_EXPLAIN' => 'A Template set comprises all the markup used to generate the layout of your board. Here you can edit existing template sets, delete, export, import and preview sets. You can also modify the templating code used to generate BBCode.',
|
'MANAGE_TEMPLATE_EXPLAIN' => 'A Template set comprises all the markup used to generate the layout of your board. Here you can edit existing template sets, delete, export, import and preview sets. You can also modify the templating code used to generate BBCode.',
|
||||||
'EDIT_TEMPLATE' => 'Edit Template',
|
'EDIT_TEMPLATE' => 'Edit Template',
|
||||||
|
|
Loading…
Add table
Reference in a new issue