[ Index ] |
|
Code source de b2evolution 2.1.0-beta |
1 <?php 2 /** 3 * This file implements the BBcode plugin for b2evolution 4 * 5 * BB style formatting, like [b]bold[/b] 6 * 7 * b2evolution - {@link http://b2evolution.net/} 8 * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html} 9 * @copyright (c)2003-2007 by Francois PLANQUE - {@link http://fplanque.net/} 10 * 11 * @package plugins 12 */ 13 if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); 14 15 16 /** 17 * @package plugins 18 */ 19 class bbcode_plugin extends Plugin 20 { 21 var $code = 'b2evBBco'; 22 var $name = 'BB code'; 23 var $priority = 50; 24 var $version = '1.9-dev'; 25 var $apply_rendering = 'opt-in'; 26 var $group = 'rendering'; 27 var $short_desc; 28 var $long_desc; 29 var $number_of_installs = 1; 30 31 /* 32 * Internal 33 */ 34 var $post_search_list; 35 var $post_replace_list; 36 var $comment_search_list; 37 var $comment_replace_list; 38 39 /** 40 * Init 41 */ 42 function PluginInit( & $params ) 43 { 44 $this->short_desc = T_('BB formatting e-g [b]bold[/b]'); 45 $this->long_desc = T_('Available tags are: [b] [i] [u] [s] [color=...] [size=...] [font=...] [code] [quote] [list=1] [list=a] [list] [*]'); 46 } 47 48 /** 49 * Get the default settings of the plugin. 50 * 51 * @return array 52 */ 53 function GetDefaultSettings() 54 { 55 return array( 56 'post_settings_begin' => array( 57 'layout' => 'begin_fieldset', 58 'label' => $this->T_( 'Settings for posts' ), 59 ), 60 'post_search_list' => array( 61 'label' => $this->T_( 'Search list'), 62 'note' => $this->T_( 'This is the BBcode search array for posts (one per line) ONLY CHANGE THESE IF YOU KNOW WHAT YOU\'RE DOING' ), 63 'type' => 'html_textarea', 64 'rows' => 10, 65 'defaultvalue' => '#\[b](.+?)\[/b]#is 66 #\[i](.+?)\[/i]#is 67 #\[u](.+?)\[/u]#is 68 #\[s](.+?)\[/s]#is 69 !\[color=(#?[A-Za-z0-9]+?)](.+?)\[/color]!is 70 #\[size=([0-9]+?)](.+?)\[/size]#is 71 #\[font=([A-Za-z0-9 ;\-]+?)](.+?)\[/font]#is 72 #\[code](.+?)\[/code]#is 73 #\[quote](.+?)\[/quote]#is 74 #\[list=1](.+?)\[/list]#is 75 #\[list=a](.+?)\[/list]#is 76 #\[list](.+?)\[/list]#is 77 #\[\*](.+?)\n#is 78 !\[bg=(#?[A-Za-z0-9]+?)](.+?)\[/bg]!is', 79 ), 80 'post_replace_list' => array( 81 'label' => $this->T_( 'Replace list'), 82 'note' => $this->T_( 'This is the replace array for posts (one per line) it must match the exact order of the search array' ), 83 'type' => 'html_textarea', 84 'rows' => 10, 85 'defaultvalue' => '<strong>$1</strong> 86 <em>$1</em> 87 <span style="text-decoration:underline">$1</span> 88 <span style="text-decoration:line-through">$1</span> 89 <span style="color:$1">$2</span> 90 <span style="font-size:$1px">$2</span> 91 <span style="font-family:$1">$2</span> 92 <pre>$1</pre> 93 « $1 » 94 <ol type="1">$1</ol> 95 <ol type="a">$1</ol> 96 <ul>$1</ul> 97 <li>$1</li> 98 <span style="background-color:$1">$2</span>', 99 ), 100 'post_settings_end' => array( 101 'layout' => 'end_fieldset', 102 ), 103 'comment_settings_begin' => array( 104 'type' => 'layout', 105 'layout' => 'begin_fieldset', 106 'label' => $this->T_( 'Settings for comments' ), 107 ), 108 'render_comments' => array( 109 'label' => $this->T_('Render comments' ), 110 'note' => $this->T_('If enabled the BBcode in comments will be rendered'), 111 'defaultvalue' => 0, 112 'type' => 'checkbox', 113 ), 114 'comment_search_list' => array( 115 'label' => $this->T_( 'Search list'), 116 'note' => $this->T_( 'This is the BBcode search array for COMMENTS (one per line) ONLY CHANGE THESE IF YOU KNOW WHAT YOU\'RE DOING' ), 117 'type' => 'html_textarea', 118 'rows' => 10, 119 'defaultvalue' => '#\[b](.+?)\[/b]#is 120 #\[i](.+?)\[/i]#is 121 #\[u](.+?)\[/u]#is 122 #\[s](.+?)\[/s]#is 123 !\[color=(#?[A-Za-z0-9]+?)](.+?)\[/color]!is 124 #\[size=([0-9]+?)](.+?)\[/size]#is 125 #\[font=([A-Za-z0-9 ;\-]+?)](.+?)\[/font]#is 126 #\[code](.+?)\[/code]#is 127 #\[quote](.+?)\[/quote]#is 128 #\[list=1](.+?)\[/list]#is 129 #\[list=a](.+?)\[/list]#is 130 #\[list](.+?)\[/list]#is 131 #\[\*](.+?)\n#is 132 !\[bg=(#?[A-Za-z0-9]+?)](.+?)\[/bg]!is', 133 ), 134 'comment_replace_list' => array( 135 'label' => $this->T_( 'Replace list'), 136 'note' => $this->T_( 'This is the replace array for COMMENTS (one per line) it must match the exact order of the search array' ), 137 'type' => 'html_textarea', 138 'rows' => 10, 139 'defaultvalue' => '<strong>$1</strong> 140 <em>$1</em> 141 <span style="text-decoration:underline">$1</span> 142 <span style="text-decoration:line-through">$1</span> 143 <span style="color:$1">$2</span> 144 <span style="font-size:$1px">$2</span> 145 <span style="font-family:$1">$2</span> 146 <pre>$1</pre> 147 « $1 » 148 <ol type="1">$1</ol> 149 <ol type="a">$1</ol> 150 <ul>$1</ul> 151 <li>$1</li> 152 <span style="background-color:$1">$2</span>', 153 ), 154 'comment_settings_end' => array( 155 'type' => 'layout', 156 'layout' => 'end_fieldset', 157 ), 158 ); 159 } 160 161 /** 162 * Perform rendering 163 * 164 * @see Plugin::RenderItemAsHtml() 165 */ 166 function RenderItemAsHtml( & $params ) 167 { 168 $content = & $params['data']; 169 if( !isset( $this->post_search_list ) ) 170 $this->post_search_list = explode( "\n", str_replace( "\r", '', $this->Settings->get( 'post_search_list' ) ) ); 171 172 if( !isset( $this->post_replace_list ) ) 173 $this->post_replace_list = explode( "\n", str_replace( "\r", '', $this->Settings->get( 'post_replace_list' ) ) ); 174 175 $content = preg_replace( $this->post_search_list, $this->post_replace_list, $content ); 176 177 return true; 178 } 179 180 181 /** 182 * Do the same as for HTML. 183 * 184 * @see RenderItemAsHtml() 185 */ 186 function RenderItemAsXml( & $params ) 187 { 188 $this->RenderItemAsHtml( $params ); 189 } 190 191 /** 192 * 193 * Render comments if required 194 * 195 * @see Plugin::FilterCommentContent() 196 */ 197 function FilterCommentContent( & $params ) 198 { 199 if( $this->Settings->get( 'render_comments' ) ) 200 { 201 $content = & $params['data']; 202 if( !isset( $this->comment_search_list ) ) 203 $this->comment_search_list = explode( "\n", str_replace( "\r", '', $this->Settings->get( 'comment_search_list' ) ) ); 204 205 if( !isset( $this->comment_replace_list ) ) 206 $this->comment_replace_list = explode( "\n", str_replace( "\r", '', $this->Settings->get( 'comment_replace_list' ) ) ); 207 208 $content = preg_replace( $this->comment_search_list, $this->comment_replace_list, $content ); 209 } 210 } 211 } 212 213 214 /* 215 * $Log: _bbcode.plugin.php,v $ 216 * Revision 1.20 2007/04/26 00:11:04 fplanque 217 * (c) 2007 218 * 219 * Revision 1.19 2007/04/20 02:53:13 fplanque 220 * limited number of installs 221 * 222 * Revision 1.18 2006/12/26 03:19:12 fplanque 223 * assigned a few significant plugin groups 224 * 225 * Revision 1.17 2006/07/31 16:12:18 yabs 226 * Modified 'allow_html' to html_input/html_textarea 227 * 228 * Revision 1.16 2006/07/31 07:52:03 yabs 229 * Moved search and replace arrays to Settings 230 * Added new Setting to enable rendering of comments 231 * Added 2 new Settings for comment search and replace arrays 232 * 233 * Revision 1.15 2006/07/10 20:19:30 blueyed 234 * Fixed PluginInit behaviour. It now gets called on both installed and non-installed Plugins, but with the "is_installed" param appropriately set. 235 * 236 * Revision 1.14 2006/07/07 21:26:49 blueyed 237 * Bumped to 1.9-dev 238 * 239 * Revision 1.13 2006/07/06 19:56:29 fplanque 240 * no message 241 * 242 * Revision 1.12 2006/06/16 21:30:57 fplanque 243 * Started clean numbering of plugin versions (feel free do add dots...) 244 * 245 * Revision 1.11 2006/05/30 19:39:55 fplanque 246 * plugin cleanup 247 * 248 * Revision 1.10 2006/04/11 21:22:26 fplanque 249 * partial cleanup 250 * 251 */ 252 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 23:58:50 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |