News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Spoiler Tag

Started by AzaToth, September 20, 2005, 11:37:42 PM

Previous topic - Next topic

AzaToth

Quote from: Satellite on October 17, 2005, 12:53:31 PM
Look at the mouse pointer to see a correct-looking button... before the box appeared, the spoiler button was rendered in the same style.


ok, edit or remove the div.spoilerheader input
{
background-color: #cececc;
color: #3e3e33;
font: 0.9em sans-serif;
}

it was made for default theme, also remember to force reloade the css..

There's a Ferret

Fixed! now it's perfect, ty AzaToth :)

finalhit

Quote from: AzaToth on October 13, 2005, 06:31:34 PM
Quote from: ArkServer on October 13, 2005, 06:06:17 PM
you know, the option in Admin->Configuration->Current Theme , i cant find it anywhere and i think its because the template.
Ah, ok, it's not a button, but a pulldown menu at the bottom of the page:
hxxp:imageshack.us [nonactive]


ok, i installed the package and it doesn't seem to have worked. the package installer didn't give me an error message when i was installing it. SMF 1.1 RCF here

AzaToth

Quote from: finalhit on October 23, 2005, 01:49:07 AM
Quote from: AzaToth on October 13, 2005, 06:31:34 PM
Quote from: ArkServer on October 13, 2005, 06:06:17 PM
you know, the option in Admin->Configuration->Current Theme , i cant find it anywhere and i think its because the template.
Ah, ok, it's not a button, but a pulldown menu at the bottom of the page:



ok, i installed the package and it doesn't seem to have worked. the package installer didn't give me an error message when i was installing it. SMF 1.1 RCF here
How does it not seem to work?

finalhit

Quote from: AzaToth on October 23, 2005, 09:49:51 AM
Quote from: finalhit on October 23, 2005, 01:49:07 AM
Quote from: AzaToth on October 13, 2005, 06:31:34 PM
Quote from: ArkServer on October 13, 2005, 06:06:17 PM
you know, the option in Admin->Configuration->Current Theme , i cant find it anywhere and i think its because the template.
Ah, ok, it's not a button, but a pulldown menu at the bottom of the page:
hxxp:imageshack.us [nonactive]


ok, i installed the package and it doesn't seem to have worked. the package installer didn't give me an error message when i was installing it. SMF 1.1 RCF here
How does it not seem to work?

grr, for some reason i didn't write everything i wanted to write in that message.
basically, after i installed it, nothing seem to have changed, i downloaded the files it supposed to have modified, but no change.

i did reinstall SMF tho, and chmod almost the entire everything, and seemed to have worked. must have been a chmod issue, dunno. thanks anyway tho

xtremecruiser

Works great with RC1.1
How about a mode for only registered users to be able to un hide it or only see if you reply ?  Just a thought :-X
Thanks

AzaToth

Quote from: xtremecruiser on October 25, 2005, 06:57:08 PM
Works great with RC1.1
How about a mode for only registered users to be able to un hide it or only see if you reply ?  Just a thought :-X
Thanks
I'll look into it, but it requires some major changes in the code (mostly because I can't validate parsed content, so I have to do it the hard way as I did for Tabular)

Elmacik

yeah it would be nice if only the logged users can use it.
Home of Elmacik

AzaToth

Quote from: Elmacik on October 26, 2005, 10:27:01 AM
yeah it would be nice if only the logged users can use it.
ok, now I'm a bit confused, do you want only registered users to be able to use spoiler, or be able to see them?

AzaToth

I have now recoded the spoiler tag code, but havn't packaged it yet, I need to translate some more stings via google :)

if you don't want to wait, here is some of the code:
function get_spoiler($content, $topic = '') {
global $txt, $settings, $context, $modSettings;

// Optional topic if given
if($topic != '')
$topic = ': '.$topic;

// Backup if theme does not have included
$settings['spoiler_tag'] = isset($settings['spoiler_tag']) ? $settings['spoiler_tag'] : 0;
$txt['spoiler_tag_text'] = isset($txt['spoiler_tag_text']) ? $txt['spoiler_tag_text'] : 'Spoiler';
$txt['spoiler_tag_hover'] = isset($txt['spoiler_tag_hover']) ? $txt['spoiler_tag_hover'] : '(hover to show)';
$txt['spoiler_tag_click'] = isset($txt['spoiler_tag_click']) ? $txt['spoiler_tag_click'] : '(click to show/hide)';
$txt['spoiler_tag_reg_only'] = isset($txt['spoiler_tag_reg_only']) ? $txt['spoiler_tag_reg_only'] : '<span style="color: red;">Spoiler visible to registered users only. </span>';

// Guests: Nothing to see here, move along.
if($modSettings['spoiler_reg_only'] && $context['user']['is_guest']) {
return $txt['spoiler_tag_reg_only'];
}

// TODO require reply to see (like hide tag)

/*
2: button
1: link
0: hover
*/
$retval = '';
switch($settings['spoiler_tag']) {
case 2:
$retval = (
'<div class="spoiler"><div class="spoilerheader">'.
'<input type="button" class="spoilerbutton" value="'.$txt['spoiler_tag_text'].$topic.'" '.
'onClick="n = this.parentNode.parentNode.lastChild;if(n.style.display == \'none\') {n.style.display = \'block\';} else {n.style.display = \'none\';} return false;"/> '.
$txt['spoiler_tag_click'].'</div><div class="spoilerbody" style="display: none">'.
$content.'</div></div>'
);
break;
case 1:
$reval = (
'<div class="spoiler"><div class="spoilerheader">'.
'<input type="button" class="spoilerbutton" value="'.$txt['spoiler_tag_text'].$topic.'" '.
'onClick="n = this.parentNode.parentNode.lastChild;if(n.style.display == \'none\') {n.style.display = \'block\';} else {n.style.display = \'none\';} return false;"/> '.
$txt['spoiler_tag_click'].'</div><div class="spoilerbody" style="display: none">'.
$content.'</div></div>'
);
break;
case 0:
default:
$retval = (
'<fieldset class="spoiler" '.
'onMouseOver="this.lastChild.style.display = \'block\';" onMouseOut="this.lastChild.style.display=\'none\'">'.
'<legend><b>'.$txt['spoiler_tag_text'].$topic.'</b> <small>'.$txt['spoiler_tag_hover'].'</small>'.
'</legend><div class="spoilerbody" style="display: none">'.
$content.'</div></fieldset>'
);
}
return $retval;
};
...
array(
'tag' => 'spoiler',
'type' => 'unparsed_content',
'content' => '$1',
'block_level' => true,
'validate' => create_function('&$tag, &$data, $disabled', '$data = get_spoiler(parse_bbc($data,'.($smileys?'true':'false').',\''.$cache_id.'\'));'),
),
array(
'tag' => 'spoiler',
'type' => 'unparsed_equals_content',
'content' => '$1',
'block_level' => true,
'validate' => create_function('&$tag, &$data, $disabled', '$data[0] = get_spoiler(parse_bbc($data[0],'.($smileys?'true':'false').',\''.$cache_id.'\'),$data[1]);'),
),

Elijah Bliss

Quote from: AzaToth on October 26, 2005, 09:15:42 AM
Quote from: xtremecruiser on October 25, 2005, 06:57:08 PM
Works great with RC1.1
How about a mode for only registered users to be able to un hide it or only see if you reply ?  Just a thought :-X
Thanks
I'll look into it, but it requires some major changes in the code (mostly because I can't validate parsed content, so I have to do it the hard way as I did for Tabular)

There's an easier route. Just create a permission and make sure no one but the allowed are able to use it.

xtremecruiser

Quote from: AzaToth on October 26, 2005, 10:51:49 AM
Quote from: Elmacik on October 26, 2005, 10:27:01 AM
yeah it would be nice if only the logged users can use it.
ok, now I'm a bit confused, do you want only registered users to be able to use spoiler, or be able to see them?
Well first that only registered users can click to reveille what is hidden under the box or tag "Spoiler"
I allow guests to view the forum but would only like the members see whats hidden.

A cool add on would be the optional one making the members reply to see what under special ones ( I know invison has something like this, might be a mod ) but that is just a evil way of making them post and bumping the thread ( Evil Grin )

AzaToth

Quote from: Elijah Bliss on October 26, 2005, 11:59:09 AM
Quote from: AzaToth on October 26, 2005, 09:15:42 AM
Quote from: xtremecruiser on October 25, 2005, 06:57:08 PM
Works great with RC1.1
How about a mode for only registered users to be able to un hide it or only see if you reply ?  Just a thought :-X
Thanks
I'll look into it, but it requires some major changes in the code (mostly because I can't validate parsed content, so I have to do it the hard way as I did for Tabular)

There's an easier route. Just create a permission and make sure no one but the allowed are able to use it.
don't understand exactly how you mean, how do I use permissions in parse_bbc?

AzaToth

Quote from: AzaToth on October 26, 2005, 02:03:11 PM
Quote from: Elijah Bliss on October 26, 2005, 11:59:09 AM
Quote from: AzaToth on October 26, 2005, 09:15:42 AM
Quote from: xtremecruiser on October 25, 2005, 06:57:08 PM
Works great with RC1.1
How about a mode for only registered users to be able to un hide it or only see if you reply ?  Just a thought :-X
Thanks
I'll look into it, but it requires some major changes in the code (mostly because I can't validate parsed content, so I have to do it the hard way as I did for Tabular)

There's an easier route. Just create a permission and make sure no one but the allowed are able to use it.
don't understand exactly how you mean, how do I use permissions in parse_bbc?
ok, got it, allowTo(), fixed

Elijah Bliss

Quote from: AzaToth on October 26, 2005, 02:03:11 PM
Quote from: Elijah Bliss on October 26, 2005, 11:59:09 AM
Quote from: AzaToth on October 26, 2005, 09:15:42 AM
Quote from: xtremecruiser on October 25, 2005, 06:57:08 PM
Works great with RC1.1
How about a mode for only registered users to be able to un hide it or only see if you reply ?  Just a thought :-X
Thanks
I'll look into it, but it requires some major changes in the code (mostly because I can't validate parsed content, so I have to do it the hard way as I did for Tabular)

There's an easier route. Just create a permission and make sure no one but the allowed are able to use it.
don't understand exactly how you mean, how do I use permissions in parse_bbc?

example:
Code (Find in ManagePermissions.php) Select

// Standard - ie. members.  They can do anything Restrictive can.
$groupLevels['global']['standard'] = array_merge($groupLevels['global']['restrict'], array(


Code (add after) Select

'spoiler_tag',


Code (Find in ManagePermissions.php) Select

$permissionList = array(
'membergroup' => array(
'general' => array(


Code (add after) Select

'spoiler_tag',


Code (Find in Subs-Post.php) Select

// Limit the size of images posted?


Code (add before) Select

//Check [spoiler][/spoiler] permission:
if (!allowedTo('spoiler_tag'))
$message = preg_replace('~\[spoiler\](.+?)\[/spoiler\]~ise', '\'You do not have permission to use spoiler tags.\'', $message);


Code (Find in Modifications.english.php) Select

?>


Code (add before) Select

$txt['permissionname_spoiler_tag'] = 'Usespoiler tags';
$txt['permissionhelp_spoiler_tag'] = 'This permission allows people to use the spoiler tags.';



after that you can set the permissions for each membergroup in the admin panel.

AzaToth

ok, 0.2.0 is released now, with permissions to show and post spoilers (same permission, if you can show them, then you can post the vice versa).
It's only compatible with 1.1 RC1 (have no beta3 forum left). Also, I was unable to make update work so I removed the ability to update the package, so you need to uninstall the previous package first.

Third, I have not translated the new strings used to the other languages. If someone need it, please do so.

/Carl

AzaToth

Ok, a quick change, in 0.2.1, splitted the permissions so there are both for show spoilers and to post them.
Because of this you can have a group that can post spoilers, but can not show them (not my fault if you so have :)), but it's more logical that you have a group that can show spoilers but can't post new ones.

/Carl

xtremecruiser

Quote from: AzaToth on October 26, 2005, 04:36:15 PM
Ok, a quick change, in 0.2.1, splitted the permissions so there are both for show spoilers and to post them.
Because of this you can have a group that can post spoilers, but can not show them (not my fault if you so have :)), but it's more logical that you have a group that can show spoilers but can't post new ones.

/Carl
Cool thanks for the updates.  :D
Now lets see if your mod works combined with the "Hide Tag Special"  :P

Elijah Bliss

Quote from: AzaToth on October 26, 2005, 04:36:15 PM
Ok, a quick change, in 0.2.1, splitted the permissions so there are both for show spoilers and to post them.
Because of this you can have a group that can post spoilers, but can not show them (not my fault if you so have :)), but it's more logical that you have a group that can show spoilers but can't post new ones.

/Carl

also, if you want to prevent people from quoting spoilers:

Code (Find in Posts.php) Select

}
// Posting a reply without a quote?


Code (Add before) Select

    allowedTo('admin_forum') ? '' : $form_message = preg_replace(array('~\n?\[spoiler.*?\].+?\[/spoiler\]\n?~is', '~^\n~', '~\[/spoiler]~'), '', $form_message);


AzaToth

Quote from: Elijah Bliss on October 28, 2005, 02:39:50 AM
Quote from: AzaToth on October 26, 2005, 04:36:15 PM
Ok, a quick change, in 0.2.1, splitted the permissions so there are both for show spoilers and to post them.
Because of this you can have a group that can post spoilers, but can not show them (not my fault if you so have :)), but it's more logical that you have a group that can show spoilers but can't post new ones.

/Carl

also, if you want to prevent people from quoting spoilers:

Code (Find in Posts.php) Select

}
// Posting a reply without a quote?


Code (Add before) Select

    allowedTo('admin_forum') ? '' : $form_message = preg_replace(array('~\n?\[spoiler.*?\].+?\[/spoiler\]\n?~is', '~^\n~', '~\[/spoiler]~'), '', $form_message);


already done tht I think, but admin_forum?

Advertisement: