Link to Mod (https://custom.simplemachines.org/mods/index.php?mod=4166)
YET ANOTHER SPOILER MOD v1.2
By Dougiefresh (http://www.simplemachines.org/community/index.php?action=profile;u=253913) -> Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=4166)
IntroductionThis modification adds 3 BBCodes to the forum:
spoiler,
changelog and
offtopic. These bbcodes allows the post author to hide content in the post, which is clickable to display it to the user.
These BBCode takes the forms:
[nobbc]
[nobbc][spoiler]{content}[/spoiler][/nobbc]
[nobbc][spoiler {params}]{content}[/spoiler][/nobbc]
[nobbc][spoiler=Some Text]{content goes here}[/spoiler][/nobbc]
[/nobbc]
The
{params} section may be any of the following parameters:
o
text - Replaces default "Spoiler" text in the header.
o
quote - Text that follows the "Spoiler" text in the header. Must be in quotes.
o
show - Replaces default "Show" text in the header.
o
hide - Replaces default "Hide" text in the header.
o
guests - Flag to show spoiler to guests or not. May be
n,
no,
false,
y,
yes, or
true.
o
log - Flag to enable/disable logging of who viewed the spoiler.
o
log_id -
DO NOT EDIT! Automatically replaces
log parameter with number of spoiler we are tracking.
Admin SettingsEach bbcode has settings in
Admin =>
Configuration =>
Modification Settings =>
YASM:
o
{tag_name} style to use:o
Replace button text "{tag_name}" with:o
Replace button text "Show" with:o
Replace button text "Hide" with:o
Default to expanded status?o
Disable {tag_name} for guests globally?o
Disable line beneath {tag_name} text?o
Show which members viewed the {tag_name}?o
Number of members to show that viewed the {tag_name}These BBCodes may be disabled by going into the
Admin =>
Forum =>
Posts and Topics =>
Bulletin Board Code and unchecking the bbcodes you don't want to use. You may also be uninstall this mod in order to disable them.
Mod Install NotesThis mod
REPLACES and expands upon the functionality in the following mods:
o Expanding & Collapsing Spoiler Tag (http://custom.simplemachines.org/mods/index.php?mod=3980)
o Expanding & Collapsing Off-Topic Tag (http://custom.simplemachines.org/mods/index.php?mod=3990)
o Expanding & Collapsing Spoiler Tag (http://custom.simplemachines.org/mods/index.php?mod=3981)
These mods
NEED TO BE removed prior to installation of this mod, as the installer will not permit this mod to be installed alongside those mods! I will not be supporting those mods once this mod is approved!
Compatibility NotesThis mod was tested on SMF 2.0.15, but should work on SMF 2.1 Beta 3, as well as SMF 2.0 and up. SMF 1.x is not and will not be supported.
Related Discussionso Kortal's request for spoiler redesign (https://www.simplemachines.org/community/index.php?topic=530701.msg3909493#msg3909493)
o WellWisher's changes to the design (https://www.simplemachines.org/community/index.php?topic=530701.msg3941997#msg3941997)
o Spoilers (https://www.simplemachines.org/community/index.php?topic=541143.0)
o [FREE/PAID] - Spoiler tag with user record (https://www.simplemachines.org/community/index.php?topic=541750.0)
o [FREE] Spoiler Mod Tweaks (https://www.simplemachines.org/community/index.php?topic=487552.0)
ChangelogThe changelog can be viewed at XPtsp.com (http://www.xptsp.com/board/free-modifications/yet-another-spoiler-mod/?tab=1).
LicenseCopyright (c) 2017 - 2018, Douglas Orend
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Cool idea have seen this i other forums nice.
Is the logging feature working? I've ticked the check boxes but nothing is showing in the posts. This is on SMF 2.0.15 with PHP 7.0.26
Thanks for this very useful mod Douglas :)
Quote from: stoneageman on December 23, 2017, 04:59:08 AM
Is the logging feature working? I've ticked the check boxes but nothing is showing in the posts. This is on SMF 2.0.15 with PHP 7.0.26
Thanks for this very useful mod Douglas :)
An automatic "force logging" option is planned for the future, however, it is not available at the moment. For now, you must start the spoiler using something like this:
[spoiler log=y]
Once you submit the post, the
log=y portion of the spoiler declaration will be replaced by the spoiler ID, which is generated by the mod.
Hi Doug, I've tried as you suggested with log=y log=true etc but it's not generating a spoiler ID. I have no errors in my logs. It just acts like the regular spoiler. Thanks
@dougiefresh, just tested this on my local. I love how easy to manage the plugin is.
Incredible, incredible plugin! ;D
For people running the older version, some good news:
I uninstalled the older version without a problem, and installed the new version and it saved my old spoiler tags so this was a very pleasant surprise.
Also adding the URL link works, I even manage to add font-awesome icon (as seen on the gif below) works like a charm! I did this through the plugin panel. I didn't have to modify any files - which was amazing; saved me a bunch of time! Really happy with that. :laugh:
I learnt this by playing around (maybe I set something up incorrectly), the "Hide" button wasn't there any more and the Spoiler button disappeared after you clicked on "Show" once:
Plus the URL link disappears which you click on show, but for my purposes, it's not an issue.
(https://i.imgur.com/Kp7d8NA.gif) :P
Uploaded v1.1 - December 23rd, 2017
o Fixed issue showing/hiding proper links within the JavaScript code.
o Fixed database insertion issue within Subs-YASM.php code.
@Wellwisher: I think I've taken care of the issue you pointed out.... *(Hell, I thought I took care of it before, too....) The issue involved was a matter of focusing on the proper link elements....
@stoneageman: Please try this version. I think I've fixed the issue, but I'm not sure....
That's sorted it Doug. When using log=yes now works as expected. Much appreciated ;)
@dougiefresh it's perfect 10/10 bud.
Thank you
Hey Dougie, you've duplicated what this mod replaces in the first post:
Mod Install Notes
This mod REPLACES and expands upon the functionality in the following mods:
o Expanding & Collapsing Spoiler Tag
o Expanding & Collapsing Off-Topic Tag
o Expanding & Collapsing Spoiler Tag
@Steve: Sorry, I don't see the duplication, not in this version nor in the previous versions I have in my possession....
Not in the mod, in the first post of this thread.
:o Okay, I see it now! If I told you it was intentional, would you believe me? ::) Nah, didn't think so, either.... 8)
Fixed it for you. ;)
Okay, I've made that change in the mod itself, as updating the mod description also updates the first post for the support thread.... Won't update the mod until I have something more substantial that changed....
Thanks dougiefresh for your support, this new mod is perfect !
Uploaded v1.2 - November 9th, 2018
o No functionality change.
o Updated documentation to point to new website.
I leave the translation in Latin Spanish.
Regards!
Hey, it's me again. Was setting up another forum, found a new incarnation of the mod.
Well, still on that 'guests' thing when local per-tag setting does not override global (contrary to description: "NOTE: Does not affect tags that specify guest status!").
The fix is mostly the same as in previous mod (https://www.simplemachines.org/community/index.php?topic=530701.msg3913728#msg3913728): parse '$guests' first and bypass global if explicitly allowed for them. Just shorter this time =)
I.e, replace:
// If guests aren't allowed to view, then tell the user to login or register:
if ((!empty($modSettings['YASM_' . $name . '_no_guests']) || $guests == 'n' || $guests == 'no' || $guests == 'false') && !empty($user_info['is_guest']))
{
$search = array('{script_url}', '{tag_name}');
$replace = array($scripturl, $txt[$name]);
$message = str_replace($search, $replace, $txt['YASM_strings']['no_guest_html']);
}
...with:
$allow_guests = false;
if ($guests == 'y' || $guests == 'yes' || $guests == 'true') {
$allow_guests = true;
}
// If guests aren't allowed to view, then tell the user to login or register:
if (!empty($modSettings['YASM_' . $name . '_no_guests']) && !empty($user_info['is_guest']) && $allow_guests == false)
{
$search = array('{script_url}', '{tag_name}');
$replace = array($scripturl, $txt[$name]);
$message = str_replace($search, $replace, $txt['YASM_strings']['no_guest_html']);
}
Still as dirty as it was (so has $guests doubleparsing which is needed to be fixed for speed optimizations).
Any developments on nested spoilers (spoilers within spoilers)? I've been using this modification for awhile but I'm disappointed to say that this is one feature we're really missing out on here. :(
This mod causes some issues around the "parsesmileys" function in 2.1rc2 (https://www.simplemachines.org/community/index.php?topic=569827.0).
This (https://www.simplemachines.org/community/index.php?topic=570396.0) is probably another side of the same coin.
-sigh- Please stop blaming mod authors for core bugs.
It wasn't on purpose, I just didn't grasp your reply until you wrote this (https://www.simplemachines.org/community/index.php?topic=569827.msg4036609#msg4036609) and this (https://www.simplemachines.org/community/index.php?topic=570396.msg4036612#msg4036612). :-*
Hi,
thanks for this mod, I have installed it as I needed a tag to make a link hidden to unregistered users on my forum, I'm now using the spoiler one with the guests=no parameter in order to have some links hidden to unregistered users.
I have found a bug with the latter, on SMF 2.0.17: when using the guests=no parameter and viewing a post as a guest, the Login and Register links in the You must login or register to view this Spoiler! text are broken. They are set as e.g.
https://www.myforum.org/{scripturl}?action=login
https://www.myforum.org/{scripturl}?action=register
instead of
https://www.myforum.org/?action=login
https://www.myforum.org/?action=register
I have manually fixed this by removing the {scripturl} variable in the above message, I guess it is not required there since the login and register links do not need to be called from the script's path.
Varti
OK, any help with this? One user, one action and 4 errors in the log? What have I messed up?
(https://i.imgur.com/Oi46FeD.png)
The team member that will respond to this just went on an extended vacation so be patient until she gets back.
it's fine, I switched us over to another spoiler mod. Fortunately there was one that seems to work just fine.
This one hasn't been upgraded to work with 2.1.2 which is probably why you got the errors.
Does anyone know where to see which members used the function?
Does anybody have a solution to this?
SpoilerModError.png
Looks related to language strings, did the language file upload correctly?
Yeah. It's in the Default theme languages folder.
Can you post the relevant function that surrounds the lines from those error messages from their Subs-YASM.php file?
function YASM_Validate(&$tag, &$data, &$disabled)
{
global $txt, $user_info, $modSettings, $smcFunc, $context, $scripturl;
// Are the contents empty? Then don't show anything to the user:
if (empty($data))
return ($tag['content'] = '');
// Parse the parameters given to us by the poster:
$name = &$tag['tag'];
list($text, $quote, $show, $hide, $guests, $expand,, $log_id) = explode('|', $tag['content']);
// If guests aren't allowed to view, then tell the user to login or register:
if ((!empty($modSettings['YASM_' . $name . '_no_guests']) || $guests == 'n' || $guests == 'no' || $guests == 'false') && !empty($user_info['is_guest']))
{
$search = array('{script_url}', '{tag_name}');
$replace = array($scripturl, $txt[$name]);
$message = str_replace($search, $replace, $txt['YASM_strings']['no_guest_html']);
}
// Otherwise.....
else
{
// Parse the parameters given to us:
$quote = $quote;
$text = empty($text) ? (empty($modSettings['YASM_' . $name . '_text']) ? $txt[$name] : stripslashes($modSettings['YASM_' . $name . '_text'])) : $text;
$show = empty($show) ? (empty($modSettings['YASM_' . $name . '_show']) ? $txt['YASM_show'] : stripslashes($modSettings['YASM_' . $name . '_show'])) : $show;
$hide = empty($hide) ? (empty($modSettings['YASM_' . $name . '_hide']) ? $txt['YASM_hide'] : stripslashes($modSettings['YASM_' . $name . '_hide'])) : $hide;
$expand = empty($expand) ? !empty($modSettings['YASM_' . $name . '_expanded']) : ($expand == 'y' || $expand == 'yes' || $expand == 'true');
$show_log = $log_id && !empty($modSettings['YASM_' . $name . '_show_log']);
// Are we allowed to log users who viewed the contents?
$limit = !empty($modSettings['YASM_' . $name . '_limit_log']) ? $modSettings['YASM_' . $name . '_limit_log'] : 0;
if (empty($log_id))
$context['YASM_users'] = array();
elseif (($context['YASM_users'] = cache_get_data('YASM_viewed_log_' . $log_id, 86400)) == NULL)
YASM_Get_Members($log_id, $limit);
$count = isset($context['YASM_users']) ? count($context['YASM_users']) : 0;
$viewed = sprintf($txt[$limit <= $count ? 'YASM_viewed_by' : 'YASM_last_viewed'], min(max(1, $limit), $count));
// If expanded and not logged, then log the user and add to the list:
if ($log_id && $expand && !isset($context['YASM_users'][$user_info['id']]))
{
YASM_Add_Member($log_id, $user_info['id'], false);
if ($show_log)
{
// Move user to front of the list, as user is most recent to view:
YASM_Get_Members($log_id, 0, $user_info['id']);
$tmp = $context['YASM_users'][$user_info['id']];
unset($context['YASM_users'][$user_info['id']]);
$context['YASM_users'] = array_shift($context['YASM_users']);
array_splice($context['YASM_users'], 0, 0, $tmp);
}
$log_id = 0;
}
// We need to parse the contents so it is readable for the user:
$data = parse_bbc($data);
}
// Build the string we are going to show the user. The Easy-To-Read edition! :p
$style = 'YASM_' . (empty($modSettings['YASM_' . $name . '_style']) ? 'original' : $modSettings['YASM_' . $name . '_style']);
$tag['content'] =
'<div class="' . $style . '">' .
'<div class="YASM_inner' . (empty($message) && empty($modSettings['YASM_' . $name . '_no_border']) ? ' YASM_border' : '') . '">' .
'<span class="YASM_text">' . (!empty($message) ? $message : $text .
(!empty($quote) ? '<span class="YASM_quote">'. $quote . '</span> ' : '') . '</span><span class="YASM_colon">:</span> ' .
'<span class="YASM_links" onClick="YASM_toggle(this, ' . ((int) $log_id) . '); return false;" />' .
'<a href="#" onClick="return false;"' . ($expand ? ' style="display:none;"' : '') . '>' . $show . '</a>' .
'<a href="#" onClick="return false;"' . (!$expand ? ' style="display:none;"' : '') . '>' . $hide . '</a>') .
'</span>' .
'</div>' . (empty($message) ?
'<div class="YASM_content quotecontent">' .
'<div'. ($expand ? '' : ' style="display: none;"') . '>' .
'$1' . (!empty($count) && $show_log ?
'<hr class="clear" />' .
'<span class="YASM_log">' . $viewed . ': <span class="YASM_users">' . implode(', ', $context['YASM_users']) . '</span></span>' : '') .
'</div>' .
'</div>' : '') .
'</div>';
// Let's free up the context entry for users viewed:
unset($context['YASM_users']);
}
Line 164, 165, 166:
$text = empty($text) ? (empty($modSettings['YASM_' . $name . '_text']) ? $txt[$name] : stripslashes($modSettings['YASM_' . $name . '_text'])) : $text;
$show = empty($show) ? (empty($modSettings['YASM_' . $name . '_show']) ? $txt['YASM_show'] : stripslashes($modSettings['YASM_' . $name . '_show'])) : $show;
$hide = empty($hide) ? (empty($modSettings['YASM_' . $name . '_hide']) ? $txt['YASM_hide'] : stripslashes($modSettings['YASM_' . $name . '_
Line 177:
$viewed = sprintf($txt[$limit <= $count ? 'YASM_viewed_by' : 'YASM_last_viewed'], min(max(1, $limit), $count));
Removing this mod to test something and got this error when clicking on ANY post:
Call to undefined function YASM_preparse()
Removing it from line 1166 in Display.php works...
Just in case anyone needs this in the future.
I have just a few questions about this mod if anyone here could assist it would be greatly appreciated.
1."buffer zone" can i fix some how the buffer area above, below, before, and after? Meaning no skipped lines above or below the spoiler and Make it work in the middle of a line rather than its own line?
2. Can I get ride of the ":" on end of hidden?
3. Can I get ride of the buttons (Icons and text) in the post menus? Would rather users that know how to type it out than adding buttons for people to fiddle with.
I have edited the language file to comepletely get ride of the Guest login speach so guests just simply dont know anything is even missing now, And I have edited the css file to fix the text and bold highlight rather to just match the posts default. However I cannot find or figure out how to address my other (1-3) more changes id like to make.