Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##
- ##
- ## Mod title: Spoiler
- ##
- ## Mod version: 1.0
- ## Works on FluxBB: 1.5.*
- ## Release date: 2014-01-17
- ##
- ## Authors: Faucheuse83 (http://www.black-omegadesign.fr)
- ## David18 (http://www.beargryllsvswild.fr)
- ##
- ## Description: Add new bbcode : [spoiler]
- ## You can hide or not content (image, video, text) with this tag.
- ##
- ## Affected files: include/search_idx.php
- ## include/parser.php
- ## style/style.php
- ## include/template/main.tpl
- ##
- ## Affects DB: No
- ##
- ##
- ## DISCLAIMER: Please note that "mods" are not officially supported by
- ## FluxBB. Installation of this modification is done at
- ## your own risk. Backup your forum database and any and
- ## all applicable files before proceeding.
- ##
- ##
- #
- #---------[ 1. OPEN ]-----------------------------------------------------------
- #
- /include/search_idx.php
- #
- #---------[ 2. FIND ]-----------------------------------------------------------
- #
- // Remove BBCode
- $text = preg_replace('%\[/?(b|u|s|ins|del|em|i|h|colou?r|quote|code|img|url|email|list|topic|post|forum|user)(?:\=[^\]]*)?\]%', ' ', $text);
- #
- #---------[ 3. REPLACE WITH ]---------------------------------------------------
- #
- // Remove BBCode // MODIFIED ||SPOILER
- $text = preg_replace('%\[/?(spoiler|b|u|s|ins|del|em|i|h|colou?r|quote|code|img|url|email|list|topic|post|forum|user)(?:\=[^\]]*)?\]%', ' ', $text);
- #
- #---------[ 4. SAVE ]-----------------------------------------------------------
- #
- /include/search_idx.php[/code]
- #
- #---------[ 5. OPEN ]-----------------------------------------------------------
- #
- /include/parser.php
- #
- #---------[ 6. FIND ]----------------------------------------------------------
- #
- if (preg_match('%\[/?(?:quote|code|list|h)\b[^\]]*\]%i', $text))
- $errors[] = $lang_profile['Signature quote/code/list/h'];
- #
- #---------[ 7. REPLACE WITH ]--------------------------------------------------
- #
- // MODIFIED ||SPOILER
- if (preg_match('%\[/?(?:spoiler|quote|code|list|h)\b[^\]]*\]%i', $text))
- $errors[] = $lang_profile['Signature quote/code/list/h'];
- #
- #---------[ 8. FIND ]----------------------------------------------------------
- #
- // Remove empty tags
- while (!is_null($new_text = preg_replace('%\[(b|u|s|ins|del|em|i|h|colou?r|quote|img|url|email|list|topic|post|forum|user)(?:\=[^\]]*)?\]\s*\[/\1\]%', '', $text)))
- #
- #---------[ 9. REPLACE WITH ]--------------------------------------------------
- #
- // Remove empty tags // MODIFIED ||SPOILER
- while (!is_null($new_text = preg_replace('%\[(spoiler|b|u|s|ins|del|em|i|h|colou?r|quote|img|url|email|list|topic|post|forum|user)(?:\=[^\]]*)?\]\s*\[/\1\]%', '', $text)))
- #
- #---------[ 10. FIND ]----------------------------------------------------------
- #
- // List of all the tags
- $tags = array('quote', 'code', 'b', 'i', 'u', 's', 'ins', 'del', 'em', 'color', 'colour', 'url', 'email', 'img', 'list', '*', 'h', 'topic', 'post', 'forum', 'user');
- #
- #---------[ 11. REPLACE WITH ]--------------------------------------------------
- #
- // List of all the tags // MODIFIED ||SPOILER
- $tags = array('spoiler', 'quote', 'code', 'b', 'i', 'u', 's', 'ins', 'del', 'em', 'color', 'colour', 'url', 'email', 'img', 'list', '*', 'h', 'topic', 'post', 'forum', 'user');
- #
- #---------[ 12. FIND ]----------------------------------------------------------
- #
- // Tags we can nest and the depth they can be nested to
- $tags_nested = array('quote' => $pun_config['o_quote_depth'], 'list' => 5, '*' => 5);
- #
- #---------[ 13. REPLACE WITH ]--------------------------------------------------
- #
- // Tags we can nest and the depth they can be nested to // MODIFIED ||SPOILER
- $tags_nested = array('quote' => $pun_config['o_quote_depth'], 'list' => 5, '*' => 5, 'spoiler' => 5);
- #
- #---------[ 14. FIND ]----------------------------------------------------------
- #
- // Block tags, block tags can only go within another block tag, they cannot be in a normal tag
- $tags_block = array('quote', 'code', 'list', 'h', '*');
- #
- #---------[ 15. REPLACE WITH ]--------------------------------------------------
- #
- // Block tags, block tags can only go within another block tag, they cannot be in a normal tag // MODIFIED ||SPOILER
- $tags_block = array('quote', 'code', 'list', 'h', '*', 'spoiler');
- #
- #---------[ 16. FIND ]----------------------------------------------------------
- #
- $pattern[] = '%\[h\](.*?)\[/h\]%ms';
- #
- #---------[ 17. AFTER, ADD ]----------------------------------------------------------
- #
- $pattern[] = '%\[spoiler\](.*?)\[/spoiler\]%ms'; // SPOILER
- #
- #---------[ 18. FIND ]-------------------------------------------------------------
- #
- $replace[] = '</p><h5>$1</h5><p>';
- #
- #---------[ 19. AFTER, ADD ]----------------------------------------------------------
- #
- $replace[] = '<div class="spoiler"><p class="teaser">Spoiler</p><div class="contenu">$1</div></div>'; // SPOILER
- #
- #---------[ 20. SAVE ]----------------------------------------------------------
- #
- /include/parser.php[/code]
- #
- #---------[ 21. OPEN ]----------------------------------------------------
- #
- /style/yourstyle.css
- #
- #---------[ 22. ADD ]-----------------------------------------------------------
- #
- .spoiler {
- margin: 0 0 5px 0;
- padding: 0;
- width: 50%;
- }
- .teaser {
- margin: 1px;
- padding: 3px 10px;
- cursor: pointer;
- position: relative;
- color: #ffffff;
- background-color: #ff0000;
- }
- .contenu {
- padding: 5px 10px;
- background-color: #fafafa;
- }
- #
- #---------[ 23. SAVE ]----------------------------------------------------------
- #
- /style/yourstyle.css
- #
- #---------[ 24. OPEN ]----------------------------------------------------
- #
- /include/template/main.tpl
- #
- #---------[ 25. FIND ]-----------------------------------------------------------
- #
- <head>
- #
- #---------[ 26. AFTER, ADD ]-----------------------------------------------------------
- #
- <!-- ADD JQUERY -->
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
- <!-- END ADD -->
- #
- #---------[ 27. ADD (AT THE END) ]-----------------------------------------------------------
- #
- <script> // ADD || SPOILER
- $(document).ready(function() {
- jQuery(".contenu").hide();
- jQuery(".teaser").click(function()
- {
- jQuery(this).next(".contenu").slideToggle(500);
- });
- });
- </script>
- #
- #---------[ 28. SAVE ]----------------------------------------------------------
- #
- /include/template/main.tpl
- #
- #---------[ END ]----------------------------------------------------------
- #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement