Insert [*] when clicking list button (is my approach user friendly ?)

git-svn-id: file:///svn/phpbb/trunk@3635 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2003-03-12 16:34:40 +00:00
parent 170534e631
commit b5125ea70b
4 changed files with 143 additions and 46 deletions

View file

@ -402,7 +402,8 @@ $lang = array(
'BBCODE_U_HELP' => 'Underline text: [u]text[/u] (alt+u)',
'BBCODE_Q_HELP' => 'Quote text: [quote]text[/quote] (alt+q)',
'BBCODE_C_HELP' => 'Code display: [code]code[/code] (alt+c)',
'BBCODE_L_HELP' => 'List: [list]text[/list] (alt+l)',
'BBCODE_L_HELP' => 'List: [list]text[/list] (alt+l)',
'BBCODE_E_HELP' => 'List: Add list element',
'BBCODE_O_HELP' => 'Ordered list: [list=]text[/list] (alt+o)',
'BBCODE_P_HELP' => 'Insert image: [img]http://image_url[/img] (alt+p)',
'BBCODE_W_HELP' => 'Insert URL: [url]http://url[/url] or [url=http://url]URL text[/url] (alt+w)',

View file

@ -98,9 +98,12 @@ $forum_validate = false;
$topic_validate = false;
$post_validate = false;
$forum_fields = array('f.forum_id', 'f.forum_name', 'f.parent_id', 'f.forum_parents', 'f.forum_status', 'f.forum_postable', 'f.enable_icons', 'f.enable_post_count', 'f.enable_moderate');
$topic_fields = array('t.topic_id', 't.topic_status', 't.topic_first_post_id', 't.topic_last_post_id', 't.topic_type', 't.topic_title', 't.poll_last_vote', 't.poll_start', 't.poll_title', 't.poll_length');
$post_fields = array('p.post_id', 'p.post_time', 'p.poster_id', 'p.post_username', 'p.post_text', 'p.post_subject', 'p.post_checksum', 'p.bbcode_uid', 'p.enable_magic_url', 'p.enable_sig', 'p.enable_smilies', 'p.enable_bbcode');
// Easier validation
$forum_fields = array('forum_name' => 's', 'parent_id' => 'i', 'forum_parents' => 's', 'forum_status' => 'i', 'forum_postable' => 'i', 'enable_icons' => 'i', 'enable_post_count' => 'i', 'enable_moderate' => 'i');
$topic_fields = array('topic_status' => 'i', 'topic_first_post_id' => 'i', 'topic_last_post_id' => 'i', 'topic_type' => 'i', 'topic_title' => 's', 'poll_last_vote' => 'i', 'poll_start' => 'i', 'poll_title' => 's', 'poll_length' => 'i');
$post_fields = array('post_time' => 'i', 'poster_id' => 'i', 'post_username' => 's', 'post_text' => 's', 'post_subject' => 's', 'post_checksum' => 's', 'bbcode_uid' => 's', 'enable_magic_url' => 'i', 'enable_sig' => 'i', 'enable_smilies' => 'i', 'enable_bbcode' => 'i');
switch ($mode)
{
@ -110,8 +113,8 @@ switch ($mode)
trigger_error($user->lang['NO_FORUM']);
}
$sql = "SELECT " . implode(',', $forum_fields) . "
FROM " . FORUMS_TABLE . " f
$sql = "SELECT *
FROM " . FORUMS_TABLE . "
WHERE forum_id = " . $forum_id;
$forum_validate = true;
@ -123,7 +126,7 @@ switch ($mode)
trigger_error($user->lang['NO_TOPIC']);
}
$sql = "SELECT " . implode(',', $topic_fields) . ", " . implode(',', $forum_fields) . "
$sql = "SELECT t.*, f.*
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
WHERE t.topic_id = " . $topic_id . "
AND f.forum_id = t.forum_id";
@ -140,7 +143,7 @@ switch ($mode)
trigger_error($user->lang['NO_POST']);
}
$sql = "SELECT " . implode(',', $post_fields) . ", " . implode(',', $topic_fields) . ", " . implode(',', $forum_fields) . ", u.username
$sql = "SELECT p.*, t.*, f.*, u.username
FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f, " . USERS_TABLE . " u
WHERE p.post_id = " . $post_id . "
AND t.topic_id = p.topic_id
@ -172,30 +175,63 @@ if ($sql != '')
{
$result = $db->sql_query($sql);
// This will overwrite parameter passed id's
extract($db->sql_fetchrow($result));
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$forum_id = intval($forum_id);
$parent_id = ($forum_validate) ? intval($parent_id) : false;
$forum_parents = ($forum_validate) ? trim($forum_parents) : '';
$forum_name = ($forum_validate) ? trim($forum_name) : '';
$forum_status = ($forum_validate) ? intval($forum_status) : false;
$forum_postable = ($forum_validate) ? intval($forum_postable) : false;
$enable_post_count = ($forum_validate) ? intval($enable_post_count) : false;
$enable_moderate = ($forum_validate) ? intval($enable_moderate) : false;
$enable_icons = ($forum_validate) ? intval($enable_icons) : false;
$forum_id = intval($row['forum_id']);
$topic_id = intval($row['topic_id']);
$post_id = intval($row['post_id']);
$topic_id = intval($topic_id);
$topic_status = ($topic_validate) ? intval($topic_status) : false;
$topic_first_post_id = ($topic_validate) ? intval($topic_first_post_id) : false;
$topic_last_post_id = ($topic_validate) ? intval($topic_last_post_id) : false;
$topic_type = ($topic_validate) ? intval($topic_type) : false;
$topic_title = ($topic_validate) ? trim($topic_title) : '';
$poll_last_vote = ($topic_validate) ? intval($poll_last_vote) : false;
$poll_start = ($topic_validate) ? intval($poll_start) : false;
$poll_title = ($topic_validate) ? trim($poll_title) : false;
$poll_length = ($topic_validate) ? (intval($poll_length)/3600) : false;
@reset($forum_fields);
while (list($var, $type) = each($forum_fields))
{
switch ($type)
{
case 'i':
$$var = ($forum_validate) ? intval($row[$var]) : false;
break;
case 's':
$$var = ($forum_validate) ? trim($row[$var]) : '';
break;
default:
$$var = '';
}
}
@reset($topic_fields);
while (list($var, $type) = each($topic_fields))
{
switch ($type)
{
case 'i':
$$var = ($topic_validate) ? intval($row[$var]) : false;
break;
case 's':
$$var = ($topic_validate) ? trim($row[$var]) : '';
break;
default:
$$var = '';
}
}
@reset($post_fields);
while (list($var, $type) = each($post_fields))
{
switch ($type)
{
case 'i':
$$var = ($post_validate) ? intval($row[$var]) : false;
break;
case 's':
$$var = ($post_validate) ? trim($row[$var]) : '';
break;
default:
$$var = '';
}
}
$post_subject = ($post_validate) ? $post_subject : $topic_title;
$poll_length = ($poll_length) ? $poll_length/3600 : $poll_length;
$poll_options = array();
// Get Poll Data
@ -214,10 +250,6 @@ if ($sql != '')
$db->sql_freeresult($result);
}
$post_id = intval($post_id);
$post_time = ($post_validate) ? intval($post_time) : false;
$poster_id = ($post_validate) ? intval($poster_id) : false;
if (($poster_id == ANONYMOUS) || (!$poster_id))
{
$username = ($post_validate) ? trim($post_username) : '';
@ -227,14 +259,16 @@ if ($sql != '')
$username = ($post_validate) ? trim($username) : '';
}
$post_text = ($post_validate) ? trim($post_text) : '';
$post_checksum = ($post_validate) ? trim($post_checksum) : '';
$post_subject = ($post_validate) ? trim($post_subject) : $topic_title;
$bbcode_uid = ($post_validate) ? trim($bbcode_uid) : '';
$enable_urls = ($post_validate) ? intval($enable_magic_url) : true;
$enable_sig = ($post_validate) ? intval($enable_sig) : ((intval($config['allow_sig']) && $user->data['user_attachsig']) ? true : false);
$enable_smilies = ($post_validate) ? intval($enable_smilies) : ((intval($config['allow_smilies']) && $user->data['user_allowsmile']) ? true : false);
$enable_bbcode = ($post_validate) ? intval($enable_bbcode) : ((intval($config['allow_bbcode']) && $user->data['user_allowbbcode']) ? true : false);
$enable_urls = $enable_magic_url;
if (!$post_validate)
{
$enable_sig = (intval($config['allow_sig']) && $user->data['user_attachsig']) ? true : false;
$enable_smilies = (intval($config['allow_smilies']) && $user->data['user_allowsmile']) ? true : false;
$enable_bbcode = (intval($config['allow_bbcode']) && $user->data['user_allowbbcode']) ? true : false;
$enable_urls = true;
}
$enable_magic_url = false;
}

View file

@ -90,8 +90,15 @@ function bbstyle(bbnumber) {
butnumber = arraypop(bbcode) - 1;
document.post.message.value += bbtags[butnumber + 1];
buttext = eval('document.post.addbbcode' + butnumber + '.value');
eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
if (buttext != "[*]")
{
eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
}
}
document.post.addbbcode10.value = "List";
bbtags[10] = "[list]";
document.post.addbbcode12.value = "List=";
bbtags[12] = "[list=]";
imageTag = false; // All tags are closed including image tags :D
document.post.message.focus();
return;
@ -116,12 +123,62 @@ function bbstyle(bbnumber) {
}
}
if ((bbnumber == 10) && (bbtags[10] != "[*]"))
{
if (donotinsert)
{
document.post.addbbcode12.value = "List=";
tmp_help = o_help;
o_help = e_help;
e_help = tmp_help;
bbtags[12] = "[list=]";
}
else
{
document.post.addbbcode12.value = "[*]";
tmp_help = o_help;
o_help = e_help;
e_help = tmp_help;
bbtags[12] = "[*]";
}
}
if ((bbnumber == 12) && (bbtags[12] != "[*]"))
{
if (donotinsert)
{
document.post.addbbcode10.value = "List";
tmp_help = l_help;
l_help = e_help;
e_help = tmp_help;
bbtags[10] = "[list]";
}
else
{
document.post.addbbcode10.value = "[*]";
tmp_help = l_help;
l_help = e_help;
e_help = tmp_help;
bbtags[10] = "[*]";
}
}
if (donotinsert) { // Close all open tags up to the one just clicked & default button names
while (bbcode[bblast]) {
butnumber = arraypop(bbcode) - 1;
document.post.message.value += bbtags[butnumber + 1];
if (bbtags[butnumber] != "[*]")
{
document.post.message.value += bbtags[butnumber + 1];
}
else
{
document.post.message.value += bbtags[butnumber];
}
buttext = eval('document.post.addbbcode' + butnumber + '.value');
eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
if (bbtags[butnumber] != "[*]")
{
eval('document.post.addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
}
imageTag = false;
}
document.post.message.focus();
@ -138,11 +195,15 @@ function bbstyle(bbnumber) {
// Open tag
document.post.message.value += bbtags[bbnumber];
if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
arraypush(bbcode,bbnumber+1);
eval('document.post.addbbcode'+bbnumber+'.value += "*"');
if (bbtags[bbnumber] != "[*]")
{
arraypush(bbcode,bbnumber+1);
eval('document.post.addbbcode'+bbnumber+'.value += "*"');
}
document.post.message.focus();
return;
}
storeCaret(document.post.message);
}

View file

@ -21,6 +21,7 @@ w_help = "{L_BBCODE_W_HELP}";
a_help = "{L_BBCODE_A_HELP}";
s_help = "{L_BBCODE_S_HELP}";
f_help = "{L_BBCODE_F_HELP}";
e_help = "{L_BBCODE_E_HELP}";
function checkForm()
{