1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-05 23:25:30 +02:00

imageset editing code a little messy, need to add update/replace capability to all three elements but that's for M-4 ... I think we may be done for M-2

git-svn-id: file:///svn/phpbb/trunk@4405 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Paul S. Owen 2003-08-14 23:32:50 +00:00
parent 09902892c0
commit dbd512138e
2 changed files with 219 additions and 32 deletions

View File

@ -12,9 +12,10 @@
// -------------------------------------------------------------
// TODO
// BBCode support -> M-3
// Previews of templates, imagesets, themes ... unified -> M-3
// Add custom theme classes
// For M-3
// BBCode support
// Replace template/s, stylesheet, images, etc.
// Previews of templates, imagesets, themes ... unified
// Security review
if (!empty($setmodules))
@ -69,8 +70,7 @@ else
}
// Set some basic vars
$error = $cfg = $stylecfg = array();
$tmp_path = '';
$error = $cfg = array();
$safe_mode = (@ini_get('safe_mode') || @strtolower(ini_get('safe_mode')) == 'on') ? true : false;
$file_uploads = (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on') ? true : false;
@ -1191,7 +1191,7 @@ function csspreview()
case 'imageset':
$imglist = array(
'buttons' => array(
'btn_post', 'btn_post_pm', 'btn_reply', 'btn_reply_pm', 'btn_locked', 'btn_profile', 'btn_pm', 'btn_delete', 'btn_ip', 'btn_quote', 'btn_search', 'btn_edit', 'btn_report', 'btn_email', 'btn_www', 'btn_icq', 'btn_aim', 'btn_yim', 'btn_msnm', 'btn_jabber', 'btn_online', 'btn_offline', 'btn_topic_watch', 'btn_topic_unwatch',
'btn_post', 'btn_reply', 'btn_locked', 'btn_quote', 'btn_edit', 'btn_delete', 'btn_report', 'btn_post_pm', 'btn_reply_pm', 'btn_profile', 'btn_pm', 'btn_ip', 'btn_search', 'btn_email', 'btn_www', 'btn_icq', 'btn_aim', 'btn_yim', 'btn_msnm', 'btn_jabber', 'btn_online', 'btn_offline',
),
'icons' => array(
'icon_unapproved', 'icon_reported', 'icon_attach', 'icon_post', 'icon_post_new', 'icon_post_latest', 'icon_post_newest',),
@ -1201,18 +1201,21 @@ function csspreview()
'folder', 'folder_posted', 'folder_new', 'folder_new_posted', 'folder_hot', 'folder_hot_posted', 'folder_hot_new', 'folder_hot_new_posted', 'folder_locked', 'folder_locked_posted', 'folder_locked_new', 'folder_locked_new_posted', 'folder_sticky', 'folder_sticky_posted', 'folder_sticky_new', 'folder_sticky_new_posted', 'folder_announce', 'folder_announce_posted', 'folder_announce_new', 'folder_announce_new_posted',),
'polls' => array(
'poll_left', 'poll_center', 'poll_right',),
'custom' => array(),
);
switch ($action)
{
case 'edit':
$imgname = (!empty($_POST['imgname'])) ? htmlspecialchars($_POST['imgname']) : '';
$imgpath = (isset($_POST['imgpath'])) ? htmlspecialchars($_POST['imgpath']) : '';
$imgsize = (!empty($_POST['imgsize'])) ? true : false;
$imgwidth = (isset($_POST['imgwidth'])) ? intval($_POST['imgwidth']) : '';
if ($id)
{
$sql = 'SELECT *
FROM ' . STYLES_IMAGE_TABLE . "
$sql_select = ($imgname) ? ", $imgname" : '';
$sql = "SELECT imageset_path, imageset_name, imageset_copyright$sql_select
FROM " . STYLES_IMAGE_TABLE . "
WHERE imageset_id = $id";
$result = $db->sql_query($sql);
@ -1222,10 +1225,52 @@ function csspreview()
}
$db->sql_freeresult($result);
// Check to see whether the selected image exists in the table
$valid_name = false;
foreach ($imglist as $category => $img_ary)
{
if (in_array($imgname, $img_ary))
{
$valid_name = true;
break;
}
}
// $cache->destroy('sql', STYLES_IMAGE_TABLE);
if (!$valid_name)
{
$error[] = $user->lang['NO_IMAGE'];
}
if ($update && $imgpath)
{
if (!sizeof($error))
{
// If imgwidth and imgheight are non-zero grab the actual size
// from the image itself ... we ignore width settings for the poll center
// image
$imgwidth = $imgheight = '';
if ($imgsize)
{
list($imgwidth, $imgheight) = getimagesize("{$phpbb_root_path}styles/$imageset_path/imageset/$imgpath");
$imgwidth = ($imgname != 'poll_center') ? " width=\"$imgwidth\"" : '';
$imgheight = " height=\"$imgheight\"";
}
$imgpath = '"styles/' . $imageset_path . '/imageset/' . preg_replace('#^(.*?)/(.*?)$#', '{LANG}/\2', $imgpath) . '"' . $imgwidth . $imgheight;
$sql = 'UPDATE ' . STYLES_IMAGE_TABLE . "
SET $imgname = '$imgpath'
WHERE imageset_id = $id";
$db->sql_query($sql);
$cache->destroy('sql', STYLES_IMAGE_TABLE);
add_log('admin', 'LOG_EDIT_IMAGESET', $imageset_name);
$error[] = $user->lang['IMAGESET_UPDATED'];
$$imgname = $imgpath;
}
}
$test_ary = array();
foreach ($imglist as $category => $img_ary)
@ -1238,47 +1283,88 @@ function csspreview()
}
}
}
unset($matches);
unset($test_ary);
$imgwidth = (preg_match('#width="([0-9]+?)"#i', $$imgname, $matches)) ? $matches[1] : 0;
$imgheight = (preg_match('#height="([0-9]+?)"#i', $$imgname, $matches)) ? $matches[1] : 0;
}
// Generate list of image options
$img_options = '';
foreach ($imglist as $category => $img_ary)
{
$img_options .= '<option class="sep">' . $category . '</option>';
$img_options .= (sizeof($img_ary)) ? '<option class="sep" value="">' . $user->lang['IMG_CAT_' . strtoupper($category)] . '</option>' : '';
foreach ($img_ary as $img)
{
$selected = ($img == $imgname) ? ' selected="selected"' : '';
$img_options .= '<option value="' . $img . '"' . $selected . '>' . (($category == 'custom') ? $img : $img) . '</option>';
$img_options .= '<option value="' . $img . '"' . $selected . '>' . (($category == 'custom') ? $img : $user->lang['IMG_' . strtoupper($img)]) . '</option>';
}
}
// Grab list of potential images
$imagesetlist = filelist("{$phpbb_root_path}styles/$imageset_path/imageset");
// TODO
// Check whether localised buttons exist in admins language first
// Clean up this code
$imglang = '';
$imagesetlist = array('nolang' => array(), 'lang' => array());
$dp = opendir("{$phpbb_root_path}styles/$imageset_path/imageset");
while ($file = readdir($dp))
{
if (!is_file($file) && !is_link($file) && $file{0} != '.' && strtoupper($file) != 'CVS' && !sizeof($imagesetlist['lang']))
{
$dp2 = opendir("{$phpbb_root_path}styles/$imageset_path/imageset/$file");
while ($file2 = readdir($dp2))
{
$imglang = $file;
if (preg_match('#\.(gif|jpg|png)$#', $file2))
{
$imagesetlist['lang'][] = "$file/$file2";
}
}
closedir($dp2);
}
else if (preg_match('#\.(gif|jpg|png)$#', $file))
{
$imagesetlist['nolang'][] = $file;
}
}
closedir($dp);
$imagesetlist_options = '';
foreach ($imagesetlist as $path => $img_ary)
foreach ($imagesetlist as $type => $img_ary)
{
$imagesetlist_options .= ($type == 'lang') ? '<option class="sep" value="">' . $user->lang['LOCALISED_IMAGES'] . '</option>' : '<option class="sep" value="">' . $user->lang['GLOBAL_IMAGES'] . '</option>';
foreach ($img_ary as $img)
{
$img = ((substr($path, 0, 1) == '/') ? substr($path, 1) : $path) . $img;
$imgvalue = preg_replace('#^.*?/(.*?)$#', '\1', $img);
$selected = (strstr($$imgname, $imgvalue)) ? ' selected="selected"' : '';
$selected = (preg_match('#' . preg_quote($img) . '$#', $background_image)) ? ' selected="selected"' : '';
$imagesetlist_options .= '<option value="' . htmlspecialchars($img) . '"' . $selected . '>' . $img . '</option>';
$imagesetlist_options .= '<option value="' . htmlspecialchars($img) . '"' . $selected . '>' . $imgvalue . '</option>';
}
}
$imagesetlist_options = '<option value=""' . (($edit_img == '') ? ' selected="selected"' : '') . '>' . $user->lang['NONE'] . '</option>' . $imagesetlist_options;
unset($imagesetlist);
$imgsize_no = $imgsize_yes = '';
if ($imgsize || preg_match('# height="[0-9]+?#', $$imgname))
{
$imgsize_yes = ' checked="checked"';
}
else
{
$imgsize_no = ' checked="checked"';
}
adm_page_header($user->lang['EDIT_IMAGESET']);
?>
<script language="javascript" type="text/javascript" defer="defer">
<!--
function update_image(newimage)
{
document.newimg.src = (newimage) ? "<?php echo "{$phpbb_root_path}styles/$imageset_path/imageset/"; ?>" + newimage : "images/no_image.png";
}
//-->
</script>
<h1><?php echo $user->lang['EDIT_IMAGESET']; ?></h1>
<p><?php echo $user->lang['EDIT_IMAGESET_EXPLAIN']; ?></p>
@ -1287,27 +1373,58 @@ function csspreview()
<form method="post" action="<?php echo "admin_styles.$phpEx$SID&amp;mode=$mode&amp;id=$id&amp;action=$action"; ?>"><table width="95%" cellspacing="1" cellpadding="1" border="0" align="center">
<tr>
<td align="right"><?php echo $user->lang['SELECT_CLASS']; ?>: <select name="imgname" onchange="this.form.submit(); "><?php echo $img_options; ?></select>&nbsp; <input class="btnlite" type="submit" value="<?php echo $user->lang['SELECT']; ?>" tabindex="100" /></td>
<td align="right"><?php echo $user->lang['SELECT_IMAGE']; ?>: <select name="imgname" onchange="this.form.submit(); "><?php echo $img_options; ?></select>&nbsp; <input class="btnlite" type="submit" value="<?php echo $user->lang['SELECT']; ?>" tabindex="100" /></td>
</tr>
<tr>
<td><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th colspan="2"><?php echo $user->lang['EDIT_IMAGESET']; ?></th>
</tr>
<?php
if (sizeof($error))
{
?>
<tr>
<td class="row1" colspan="2" align="center"><?php echo (!empty($$imgname)) ? '<img src=' . str_replace('"styles/', '"../styles/', str_replace('{LANG}', $user->img_lang, $$imgname)) . ' vspace="5" />' : ''; ?></td>
<td class="row1" colspan="2" align="center"><?php echo ($update) ? '<span style="color:green">' . implode('<br />', $error) . '</span>' : implode('<br />', $error); ?></td>
</tr>
<?php
}
?>
<tr>
<td class="row1" colspan="2" align="center"><table width="100%" cellspacing="2" cellpadding="2" border="0">
<tr>
<td width="50%" align="center"><img src="<?php
echo (!empty($$imgname)) ? str_replace('"styles/', '../styles/', str_replace('{LANG}', $imglang, $$imgname)) : 'images/no_image.png';
?>" /></td>
<td width="50%" align="center"><img src="<?php
echo (!empty($$imgname)) ? preg_replace('#(width|height)="[0-9]+?"#', '', str_replace('"styles/', '../styles/', str_replace('{LANG}', $imglang, $$imgname))) : 'images/no_image.png';
?>" name="newimg" /></td>
</tr>
<tr>
<td class="gensmall" align="center"><?php echo $user->lang['CURRENT_IMAGE']; ?></td>
<td class="gensmall" align="center"><?php echo $user->lang['SELECTED_IMAGE']; ?></td>
</tr>
</table></td>
</tr>
<tr>
<th width="40%"><?php echo $user->lang['IMAGE_PARAMETER']; ?></th>
<th><?php echo $user->lang['IMAGE_VALUE']; ?></th>
</tr>
<tr>
<td class="row1" width="40%"><b><?php echo $user->lang['IMAGE']; ?>:</b></td>
<td class="row2"><select name="imgpath"><?php echo $imagesetlist_options; ?></select></td>
<td class="row1" width="40%"><b><?php echo $user->lang['IMAGE']; ?>: </b></td>
<td class="row2"><select name="imgpath" onchange="update_image(this.options[selectedIndex].value);"><?php echo $imagesetlist_options; ?></select></td>
</tr>
<tr>
<td class="row1" width="40%"><b><?php echo $user->lang['DIMENSIONS']; ?>:</b><br /><span class="gensmall"><?php echo $user->lang['DIMENSIONS_EXPLAIN']; ?></span></td>
<td class="row2"><input class="post" type="text" name="imgwidth" maxlength="4" size="2" value="<?php echo (!empty($imgwidth)) ? $imgwidth : '0'; ?>" /> X <input class="post" type="text" name="imgheight" maxlength="4" size="2" value="<?php echo (!empty($imgheight)) ? $imgheight : '0'; ?>" /></td>
<td class="row1" width="40%"><b><?php echo $user->lang['DIMENSIONS']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['DIMENSIONS_EXPLAIN']; ?></span></td>
<td class="row2"><input type="radio" name="imgsize" value="1"<?php echo $imgsize_yes; ?> /> <?php echo $user->lang['YES']; ?>&nbsp;&nbsp;<input type="radio" name="imgsize" value="0"<?php echo $imgsize_no; ?> /> <?php echo $user->lang['NO']; ?></td>
</tr>
<tr>
<td class="cat" colspan="2" align="center"><input class="btnmain" type="submit" name="update" value="<?php echo $user->lang['SUBMIT']; ?>" />&nbsp;&nbsp;<input class="btnmain" type="reset" value="<?php echo $user->lang['RESET']; ?>" /></td>

View File

@ -191,7 +191,7 @@ $lang += array(
'LOG_ADD_IMAGESET' => '<b>Added new imageset</b><br />&#187; %s',
'LOG_EDIT_IMAGESET' => '<b>Edited imageset</b><br />&#187; %s',
'LOG_EDIT_IMAGESET_DETAILS' => '<b>Edited imageset</b><br />&#187; %s',
'LOG_EDIT_IMAGESET_DETAILS' => '<b>Edited imageset details</b><br />&#187; %s',
'LOG_EXPORT_IMAGESET' => '<b>Exported imageset</b><br />&#187; %s',
'LOG_DELETE_IMAGESET' => '<b>Deleted imageset</b><br />&#187; %s',
);
@ -1222,11 +1222,81 @@ $lang += array(
'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.',
'SELECTED_IMAGESET' => 'Selected imageset',
'SELECT_IMAGE' => 'Select image',
'IMAGE' => 'Image',
'DIMENSIONS' => 'Dimensions',
'DIMENSIONS_EXPLAIN' => 'Dimensions are optional, set to zero to ignore.',
'CURRENT_IMAGE' => 'Current Image',
'SELECTED_IMAGE' => 'Selected Image',
'DIMENSIONS' => 'Include dimensions',
'DIMENSIONS_EXPLAIN' => 'Selecting yes here will include width/height parameters.',
'IMAGE_PARAMETER' => 'Parameter',
'IMAGE_VALUE' => 'Value',
'LOCALISED_IMAGES' => 'Localised',
'GLOBAL_IMAGES' => 'Global',
'IMG_CAT_BUTTONS' => 'Localised buttons',
'IMG_BTN_POST' => 'New topic',
'IMG_BTN_REPLY' => 'Reply topic',
'IMG_BTN_LOCKED' => 'Topic locked',
'IMG_BTN_POST_PM' => 'New message',
'IMG_BTN_REPLY_PM' => 'Reply message',
'IMG_BTN_DELETE' => 'Delete post',
'IMG_BTN_QUOTE' => 'Quote post',
'IMG_BTN_PROFILE' => 'Show profile',
'IMG_BTN_EMAIL' => 'Send email',
'IMG_BTN_SEARCH' => 'Search posts',
'IMG_BTN_WWW' => 'Website',
'IMG_BTN_IP' => 'Show IP',
'IMG_BTN_EDIT' => 'Edit post',
'IMG_BTN_AIM' => 'AIM',
'IMG_BTN_ICQ' => 'ICQ',
'IMG_BTN_JABBER' => 'Jabber',
'IMG_BTN_YIM' => 'YIM',
'IMG_BTN_MSNM' => 'MSNM',
'IMG_BTN_ONLINE' => 'User online',
'IMG_BTN_OFFLINE' => 'User offline',
'IMG_BTN_REPORT' => 'Report post',
'IMG_BTN_PM' => 'Send message',
'IMG_CAT_ICONS' => 'General icons',
'IMG_ICON_UNAPPROVED' => 'Post unapproved',
'IMG_ICON_REPORTED' => 'Post reported',
'IMG_ICON_ATTACH' => 'Attachment',
'IMG_ICON_POST' => 'Minipost',
'IMG_ICON_POST_NEW' => 'New minipost',
'IMG_ICON_POST_LATEST' => 'Last post',
'IMG_ICON_POST_NEWEST' => 'Newest post',
'IMG_CAT_FORUMS' => 'Forum icons',
'IMG_FORUM' => 'Forum',
'IMG_FORUM_NEW' => 'Forum new posts',
'IMG_FORUM_LOCKED' => 'Forum locked',
'IMG_FORUM_LINK' => 'Forum link',
'IMG_SUB_FORUM' => 'Subforum',
'IMG_SUB_FORUM_NEW' => 'Subforum new posts',
'IMG_CAT_FOLDERS' => 'Topic icons',
'IMG_FOLDER' => 'Topic',
'IMG_FOLDER_NEW' => 'Topic new posts',
'IMG_FOLDER_LOCKED' => 'Topic locked',
'IMG_FOLDER_POSTED' => 'Topic posted to',
'IMG_FOLDER_NEW_POSTED' => 'Topic posted to new',
'IMG_FOLDER_LOCKED_NEW' => 'Topic locked new',
'IMG_FOLDER_LOCKED_POSTED' => 'Topic locked posted to',
'IMG_FOLDER_LOCKED_NEW_POSTED' => 'Topic locked posted to new',
'IMG_FOLDER_HOT' => 'Topic hot',
'IMG_FOLDER_HOT_NEW' => 'Topic hot new posts',
'IMG_FOLDER_HOT_POSTED' => 'Topic hot posted to',
'IMG_FOLDER_HOT_NEW_POSTED' => 'Topic hot posted to new',
'IMG_FOLDER_STICKY' => 'Sticky topic',
'IMG_FOLDER_STICKY_POSTED' => 'Sticky topic posted to',
'IMG_FOLDER_STICKY_NEW' => 'Sticky topic new posts',
'IMG_FOLDER_STICKY_NEW_POSTED' => 'Sticky topic posted to new',
'IMG_FOLDER_ANNOUNCE' => 'Announcement',
'IMG_FOLDER_ANNOUNCE_NEW' => 'Announcement new posts',
'IMG_FOLDER_ANNOUNCE_POSTED' => 'Announcement posted to',
'IMG_FOLDER_ANNOUNCE_NEW_POSTED' => 'Announcement posted to new',
'IMG_CAT_POLLS' => 'Polling images',
'IMG_POLL_LEFT' => 'Poll left end',
'IMG_POLL_RIGHT' => 'Poll right end',
'IMG_POLL_CENTER' => 'Poll centre',
'IMG_CAT_CUSTOM' => 'Custom images',
'IMAGESET_UPDATED' => 'Imageset updated successfully',
'EDIT_DETAILS_IMAGESET' => 'Edit imageset details',
'EDIT_DETAILS_IMAGESET_EXPLAIN'=> 'Here you can edit certain imageset details such as its name.',