PageRenderTime 53ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/e107_core/shortcodes/batch/bbcode_shortcodes.php

https://github.com/CasperGemini/e107
PHP | 663 lines | 426 code | 155 blank | 82 comment | 47 complexity | e2e71309b66e4de4203daae11cd45766 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /*
  3. * e107 website system
  4. *
  5. * Copyright (C) 2008-2009 e107 Inc (e107.org)
  6. * Released under the terms and conditions of the
  7. * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
  8. *
  9. *
  10. *
  11. * $Source: /cvs_backup/e107_0.8/e107_files/shortcode/batch/bbcode_shortcodes.php,v $
  12. * $Revision$
  13. * $Date$
  14. * $Author$
  15. */
  16. if (!defined('e107_INIT')) { exit; }
  17. include_once(e_HANDLER.'shortcode_handler.php');
  18. //include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_ren_help.php');
  19. e107::coreLan('ren_help');
  20. $codes = array('bb', 'bb_help', 'bb_preimagedir');
  21. // register_shortcode('bbcode_shortcodes', $codes);
  22. class bbcode_shortcodes extends e_shortcode
  23. {
  24. // The BBcode Buttons.
  25. function bb_format($id)
  26. {
  27. $formats = array(
  28. 0 => array('[p][/p]','Paragraph'),
  29. 1 => array('[h=2][/h]','Heading 2'),
  30. 2 => array('[h=3][/h]','Heading 3'),
  31. 3 => array('[h=4][/h]','Heading 4'),
  32. 4 => array('[h=5][/h]','Heading 5'),
  33. 5 => array('[h=6][/h]','Heading 6'),
  34. 6 => array('[block][/block]','Block'),
  35. 7 => array('[blockquote][/blockquote]', 'Quote'),
  36. 8 => array('[code][/code]', 'Code Block'),
  37. 9 => array('[code=inline][/code]', 'Code Inline')
  38. );
  39. if(BOOTSTRAP)
  40. {
  41. $text = '<div class="btn-group">';
  42. $text .= '<a class="btn dropdown-toggle" data-toggle="dropdown" href="#" title="">';
  43. $text .= "Format";
  44. $text .= ' <span class="caret"></span></a>';
  45. $text .= "<ul class='dropdown-menu'>\n";
  46. foreach($formats as $fm)
  47. {
  48. $text .= "<li><a href=\"javascript:addtext('".$fm[0]."')\">".$fm[1]."</a></li>\n";
  49. }
  50. $text .= "</ul>";
  51. $text .= "</div>";
  52. return $text;
  53. }
  54. // Legacy Version.
  55. $text = "<select class='btn e-bb bbcode_buttons e-pointer' id='{$id}' title='Format text' onchange=\"addtext(this.value);this.value=''\">
  56. <option value=''>Format</option>
  57. <option value='[p][/p]'>Paragraph</option>
  58. <option value='[h2][/h2]'>Heading</option>
  59. <option value='[block][/block]'>Block</option>
  60. <option value='[blockquote][/blockquote]'>Quote</option>
  61. <option value='[code][/code]'>Code</option>
  62. </select>";
  63. return $text;
  64. }
  65. function bb_table($id)
  66. {
  67. // $data = "[table]\n[tr]\n\t[td]Cell 1[/td]\n\t[td]Cell 2[/td]\n[/tr]\n[/table]"; // works with jquery, but not onclick.
  68. $data = "[table][tr][td]Cell 1[/td][td]Cell 2[/td][/tr][/table]";
  69. $event = $this->getEvent('addtext',$data,'Insert a table',1);
  70. $text = "<a {$event} class='btn' id='{$id}' data-function='insert' href='#{$this->var['tagid']}' title='Insert a table' data-bbcode='{$data}'>";
  71. // $text .= "<img class='btn btn-small bbcode bbcode_buttons e-pointer' src='".e_IMAGE_ABS."bbcode/table.png' alt='' title='Insert a table' />";
  72. $text .= $this->button(e_IMAGE_ABS."bbcode/table.png", 'table' );
  73. $text .= "</a>";
  74. return $text;
  75. }
  76. function bb_newpage($id)
  77. {
  78. // $data = "[table]\n[tr]\n\t[td]Cell 1[/td]\n\t[td]Cell 2[/td]\n[/tr]\n[/table]"; // works with jquery, but not onclick.
  79. // $data = "[newpage]";
  80. // $event = $this->getEvent('addtext',$data,LANHELP_34,1);
  81. $event = '';
  82. $text = "<a {$event} class='e-bb e-tabs-add' id='{$id}' data-url='".e_SELF."?mode=dialog&action=dialog&iframe=1' data-function='add' href='#{$this->var['tagid']}' data-bbcode='{$data}'>";
  83. $text .= "<img class='bbcode_buttons e-pointer' src='".e_IMAGE_ABS."bbcode/newpage.png' alt='' title='".LANHELP_34."' /></a>";
  84. return $text;
  85. }
  86. function bb_list($id)
  87. {
  88. $data = "[list][*]Item 1[*]Item 2[/list]";
  89. // $data = "[list]\n[*]Item 1\n[*]Item 2\n[/list]"; // works with jquery, but not onclick.
  90. // $event = $this->getEvent($this->var['trigger'],$data,LANHELP_36);
  91. $event = $this->getEvent('addtext',$data,LANHELP_36);
  92. $text = "<a {$event} class='btn' id='{$id}' data-function='insert' href='#{$this->var['tagid']}' data-bbcode='{$data}' title='".$this->br2nl(LANHELP_36)."'>";
  93. $text .= $this->button(e_IMAGE_ABS."bbcode/list.png", 'list', LANHELP_36);
  94. // $text .= "<img class='btn btn-small bbcode_buttons e-pointer' src='".e_IMAGE_ABS."bbcode/list.png' alt='' title='".nl2br(LANHELP_36)."' />";
  95. $text .= "</a>";
  96. return $text;
  97. }
  98. function bb_youtube($id)
  99. {
  100. if($this->var['tagid'] == 'data_') // BC work-around for duplicate IDs.
  101. {
  102. $tag = "data";
  103. }
  104. else
  105. {
  106. list($tag,$tmp) = explode("--",$this->var['tagid']); // works with $frm->bbarea to detect textarea from first half of tag.
  107. }
  108. $text = "<a class='e-modal btn btn-primary' data-modal-caption='Media Manager' data-target='#uiModal' title='Insert a Youtube video via Media Manager : ".$this->var['template']."' id='{$id}' href='".e_ADMIN."image.php?mode=main&action=dialog&for=".$this->var['template']."&tagid=".$tag."&iframe=1&bbcode=video' >";
  109. $text .= $this->button(e_IMAGE_ABS."bbcode/youtube.png", 'youtube', LANHELP_48);
  110. $text .= "</a>";
  111. return $text;
  112. }
  113. function bb_glyph($id)
  114. {
  115. if($this->var['tagid'] == 'data_') // BC work-around for duplicate IDs.
  116. {
  117. $tag = "data";
  118. }
  119. else
  120. {
  121. list($tag,$tmp) = explode("--",$this->var['tagid']); // works with $frm->bbarea to detect textarea from first half of tag.
  122. }
  123. $text = "<a class='e-modal btn btn-primary' data-modal-caption='Media Manager' data-target='#uiModal' title='Insert a Glyphicon via Media Manager : ".$this->var['template']."' id='{$id}' href='".e_ADMIN."image.php?mode=main&action=dialog&for=".$this->var['template']."&tagid=".$tag."&iframe=1&bbcode=glyph' >";
  124. $text .= $this->button(e_IMAGE_ABS."bbcode/youtube.png", 'youtube', LANHELP_48);
  125. $text .= "</a>";
  126. return $text;
  127. }
  128. function bb_link($id)
  129. {
  130. $data = "[link=*]*[/link]";
  131. $event = $this->getEvent('addinput',$data,LANHELP_35);
  132. $text = "<a {$event} class='btn e-bb ' id='{$id}' data-function='input' href='#{$this->var['tagid']}' title='".$this->br2nl(LANHELP_23)."' data-bbcode='{$data}'>\n";
  133. // $text .="<img class='btn btn-small bbcode_buttons e-pointer' src='".e_IMAGE_ABS."bbcode/link.png' alt='' title='".nl2br(LANHELP_23)."' />";
  134. $text .= $this->button(e_IMAGE_ABS.'bbcode/link.png', 'link');
  135. $text .= "</a>";
  136. return $text;
  137. }
  138. function button($image, $glyph='')
  139. {
  140. // $text .= "<button type='button' class='btn e-pointer' title='".$title."'>";
  141. // $text .= ($link) ? $link : "";
  142. if(deftrue('BOOTSTRAP') && $glyph && deftrue('FONTAWESOME'))
  143. {
  144. $text = "<span class='fa fa-".$glyph."'></span>";
  145. }
  146. else
  147. {
  148. $text ="<img src='".$image."' alt='' style='max-height:18px' />";
  149. }
  150. // $text .= ($link) ? "</a>" : "";
  151. // $text .= "</button>";
  152. return $text;
  153. }
  154. function bb_preimage($id)
  155. {
  156. if($this->var['tagid'] == 'data_') // BC work-around for duplicate IDs.
  157. {
  158. $tag = "data";
  159. }
  160. else
  161. {
  162. list($tag,$tmp) = explode("--",$this->var['tagid']); // works with $frm->bbarea to detect textarea from first half of tag.
  163. }
  164. $text = "<a class='e-modal btn btn-primary' data-modal-caption='Media Manager' data-target='#uiModal' title='Insert an Image from the Media Manager : ".$this->var['template']."' id='{$id}' href='".e_ADMIN."image.php?mode=main&action=dialog&for=".$this->var['template']."&tagid=".$tag."&iframe=1&bbcode=img' >";
  165. $text .= $this->button(e_IMAGE_ABS."bbcode/preimage.png",'picture-o');
  166. // $text .= "<img class='btn btn-small bbcode bbcode_buttons e-pointer' src='".e_IMAGE_ABS."bbcode/preimage.png' title='".LANHELP_45."' alt='' />";
  167. $text .= "</a>\n";
  168. return $text;
  169. }
  170. function bb_prefile($id)
  171. {
  172. if($this->var['tagid'] == 'data_') // BC work-around for duplicate IDs.
  173. {
  174. $tag = "data";
  175. }
  176. else
  177. {
  178. list($tag,$tmp) = explode("--",$this->var['tagid']); // works with $frm->bbarea to detect textarea from first half of tag.
  179. }
  180. $text = "<a class='e-modal btn btn-primary' data-modal-caption='Media Manager' data-target='#uiModal' id='{$id}' title='Insert a file from the Media-Manager' href='".e_ADMIN."image.php?mode=main&amp;action=dialog&amp;for=_common_file&amp;tagid=".$tag."&amp;iframe=1&amp;bbcode=file' >";
  181. $text .= $this->button(e_IMAGE_ABS."bbcode/prefile.png", 'file');
  182. // $text .= "<img class='btn btn-small bbcode bbcode_buttons e-pointer' src='".e_IMAGE_ABS."bbcode/prefile.png' title='".LANHELP_39."' alt='' />";
  183. $text .= "</a>\n";
  184. return $text;
  185. }
  186. function bb_fontsize($id) // FIXME CSS issues
  187. {
  188. if(deftrue('BOOTSTRAP'))
  189. {
  190. $tp = e107::getParser();
  191. $sizes = array(7,8,9,10,11,12,14,15,18,20,22,24,26,28,30,36);
  192. $text = '<div class="btn-group">';
  193. $text .= '<a class="btn dropdown-toggle" data-toggle="dropdown" href="#" title="'.LANHELP_22.'">';
  194. // $text .= "<img src='".e_IMAGE_ABS."bbcode/fontsize.png' alt='' />\n";
  195. $text .= $this->button(e_IMAGE_ABS."bbcode/fontsize.png", 'text-height');
  196. $text .= '</a>';
  197. $text .= "<ul class='dropdown-menu'>\n";
  198. foreach($sizes as $s)
  199. {
  200. $text .= "<li><a href=\"javascript:addtext('[size=".$s."][/size]')\">".$tp->toHtml("[size=".$s."]Size ".$s."[/size]",true)."</a></li>\n";
  201. }
  202. $text .= "</ul>";
  203. $text .= "</div>";
  204. return $text;
  205. }
  206. // Legacy BC Support
  207. $data = "size";
  208. $formid = $id."_";
  209. $event = $this->getEvent('expandit',$formid, LANHELP_22);
  210. $text = "<a {$event} class=' e-bb e-expandit' onclick=\"expandit('{$this->var['tagid']}')\" data-function='show' href='#{$this->var['tagid']}' title='".LANHELP_22."' data-bbcode='{$data}'>
  211. <img class='btn btn-small bbcode_buttons e-pointer' src='".e_IMAGE_ABS."bbcode/fontsize.png' alt='' title='".LANHELP_22."' /></a>";
  212. $text .="<!-- Start of Size selector -->
  213. <div id='{$this->var['tagid']}' class='e-hideme col-selection' style='position:relative;top:30px;left:200px' >";
  214. $text .="<div style='position:relative;bottom:30px; left:125px; width:100px'>";
  215. $text .= "<table class='fborder' style='background-color: #fff'>
  216. <tr><td class='forumheader3'>
  217. <select class='tbox' name='preimageselect' onchange=\"addtext(this.value); expandit('{$formid}')\">
  218. <option value=''>".LANHELP_41."</option>";
  219. $sizes = array(7,8,9,10,11,12,14,15,18,20,22,24,26,28,30,36);
  220. foreach($sizes as $s)
  221. {
  222. $text .= "<option value='[size=".$s."][/size]'>".$s."px</option>\n";
  223. }
  224. $text .="</select></td></tr></table></div>
  225. </div>\n<!-- End of Size selector -->";
  226. return $text;
  227. }
  228. function bb_emotes($id)
  229. {
  230. $pref = e107::getPref();
  231. if ($pref['comments_emoticons'] && $pref['smiley_activate'] && !defsettrue('e_WYSIWYG'))
  232. {
  233. if(deftrue('BOOTSTRAP'))
  234. {
  235. $text = '<div class="btn-group" >';
  236. $text .= '<a class="btn dropdown-toggle" data-toggle="dropdown" href="#" title="'.LANHELP_44.'">';
  237. $text .= $this->button(e_IMAGE_ABS."bbcode/emotes.png","smile-o");
  238. // $text .= ' <span class="caret"></span>';
  239. // $text .= "<img class='btn bbcode_buttons e-pointer' src='".e_IMAGE_ABS."bbcode/emotes.png' alt='' title=\"".LANHELP_44."\" />";
  240. $text .= '</a>';
  241. $text .= "<div class='dropdown-menu' style='white-space:normal;padding:10px; width:170px'>";
  242. $text .= $this->renderEmotes();
  243. $text .= "</div>";
  244. $text .= "</div>";
  245. return $text;
  246. }
  247. // Legacy BC version.
  248. $text = '<a class="e-expandit" href="#'.$id.'">';
  249. $text .= "<img class='btn btn-small bbcode_buttons e-pointer' src='".e_IMAGE_ABS."bbcode/emotes.png' alt='' title=\"".LANHELP_44."\" />";
  250. $text .= '</a>';
  251. $text .="<!-- Start of Emoticon selector -->
  252. <div style='margin-left:0px;margin-right:0px; position:relative;z-index:1000;float:right;display:none' id='{$id}' onclick=\"this.style.display='none'\" >
  253. <div style='position:absolute; bottom:30px; right:75px; width:221px; height:133px; overflow:auto;'>
  254. <table class='fborder' style='background-color:#fff;'>
  255. <tr><td class='forumheader3'>
  256. ".$this->renderEmotes()."
  257. </td></tr></table>
  258. </div>
  259. </div>\n<!-- End of Emoticon selector -->\n";
  260. return $text;
  261. }
  262. }
  263. function renderEmotes()
  264. {
  265. $emotes = e107::getParser()->getEmotes();
  266. $pref = e107::getPref();
  267. $text = "";
  268. foreach($emotes as $key=>$value)
  269. {
  270. $key = str_replace("!", ".", $key); // Usually '.' was replaced by '!' when saving
  271. $key = preg_replace("#_(\w{3})$#", ".\\1", $key); // '_' followed by exactly 3 chars is file extension
  272. $key = e_IMAGE_ABS."emotes/" . $pref['emotepack'] . "/" .$key; // Add in the file path
  273. $value2 = substr($value, 0, strpos($value, " "));
  274. $value = ($value2 ? $value2 : $value);
  275. $value = ($value == '&|') ? ':((' : $value;
  276. $text .= "\n<a style='display:inline-block; margin:2px; padding:2px' href=\"javascript:addtext('$value ',true)\"><img src='$key' alt='' /></a>";
  277. }
  278. return $text;
  279. }
  280. function bb_fontcol($id) // JS in this breaks ajax loading.
  281. {
  282. return '';
  283. // $bbcode['fontcol'] = array("e-expandit","col_selector_".$rand, LANHELP_21,"fontcol.png","Color_Select",'col_selector_'.$rand);
  284. $formid = $id."_";
  285. $event = $this->getEvent('expandit',$formid, LANHELP_22);
  286. $text = "<a {$event} class='btn e-bb' id='{id}' data-function='show' href='#{$this->var['tagid']}' title='".LANHELP_22."' data-bbcode='{$data}'>
  287. <img class='bbcode_buttons e-pointer' src='".e_IMAGE_ABS."bbcode/fontcol.png' alt='' title='".LANHELP_21."' /></a>";
  288. // return $text;
  289. $text .= "<!-- Start of Color selector -->
  290. <div id='{$formid}' style='width: 221px; position: absolute; left:340px; top:60px; margin-right:auto; margin-left:auto; display:none; z-index: 1000; onclick=\"expandit('{$formid}')\" >
  291. <div style='border:1px solid black; position: absolute; top:30px; width: 221px; '>";
  292. $text .= "<script type='text/javascript'>
  293. //<![CDATA[
  294. var maxtd = 18;
  295. var maxtddiv = -1;
  296. var coloursrgb = new Array('00', '33', '66', '99', 'cc', 'ff');
  297. var coloursgrey = new Array('000000', '333333', '666666', '999999', 'cccccc', 'ffffff');
  298. var colourssol = new Array('ff0000', '00ff00', '0000ff', 'ffff00', '00ffff', 'ff00ff');
  299. var rowswitch = 0;
  300. var rowline = '';
  301. var rows1 = '';
  302. var rows2 = '';
  303. var notr = 0;
  304. var tdblk = '<td style=\'background-color: #000000; cursor: default; height: 10px; width: 10px;\'><\/td>';
  305. var g = 1;
  306. var s = 0;
  307. var i, j, k;
  308. function td_render(color) {
  309. return '<td style=\'background-color: #' + color + '; height: 10px; width: 10px;\' onmousedown=\"addtext(\'[color=#' + color + '][/color]\');expandit(\'{$formid}\')\"><\/td>';
  310. }
  311. for (i=0; i < coloursrgb.length; i++) {
  312. for (j=0; j < coloursrgb.length; j++) {
  313. for (k=0; k < coloursrgb.length; k++) {
  314. maxtddiv++;
  315. if (maxtddiv % maxtd == 0) {
  316. if (rowswitch) {
  317. if (notr < 5){
  318. rows1 += '<\/tr><tr>' + td_render(coloursgrey[g]) + tdblk;
  319. g++;
  320. }
  321. rowswitch = 0;
  322. notr++;
  323. }else{
  324. rows2 += '<\/tr><tr>' + td_render(colourssol[s]) + tdblk;
  325. s++;
  326. rowswitch = 1;
  327. }
  328. maxtddiv = 0;
  329. }
  330. rowline = td_render(coloursrgb[j] + coloursrgb[k] + coloursrgb[i]);
  331. if (rowswitch) {
  332. rows1 += rowline;
  333. }else{
  334. rows2 += rowline;
  335. }
  336. }
  337. }
  338. }
  339. document.write('<table cellspacing=\'1\' cellpadding=\'0\' style=\'cursor: pointer; background-color: #000; width: 100%; border: 0px\'><tr>');
  340. document.write(td_render(coloursgrey[0]) + tdblk + rows1 + rows2);
  341. document.write('<\/tr><\/table>');
  342. //]]>
  343. </script>";
  344. $text .="</div>
  345. </div>
  346. <!-- End of Color selector -->";
  347. return $text;
  348. }
  349. // shouldn't be needed when js css selectors are enabled.
  350. function getEvent($func,$func_var,$hint_diz,$emote = '')
  351. {
  352. if($emote)
  353. {
  354. $emote = ",".$emote;
  355. }
  356. $text = "onclick=\"{$func}('".$func_var."'{$emote})\" ";
  357. $bbcode_help = vartrue($this->var['hint_func']);
  358. $bbcode_tag = $this->var['tagid'];
  359. $_helptxt = $hint_diz;
  360. // onclick="addtext('[justify][/justify]')" onmouseout="help('','admin')" onmouseover="help('Justify align: [justify]This text will be justified[/justify]','admin')">
  361. $text .= (vartrue($this->var['hint_active']) ? "onmouseout=\"{$bbcode_help}('','{$bbcode_tag}')\" onmouseover=\"{$bbcode_help}('".$_helptxt."','{$bbcode_tag}')\"" : "" );
  362. return $text;
  363. }
  364. private function br2nl($string)
  365. {
  366. return str_replace('<br />','\\n', $string);
  367. }
  368. function sc_bb($parm)
  369. {
  370. if(method_exists($this,"bb_".$parm)) // start of the big cleanup.
  371. {
  372. $meth = "bb_".$parm;
  373. // e107::getMessage()->debug("Loaded BB: ".$parm);
  374. $unique = $this->var['template']."--".$parm; // works in conjunction with media-manager category
  375. return "\n\n<!-- {$parm} -->\n".$this->$meth($unique);
  376. }
  377. //XXX NOTE: everything below here could be replaced with separate 'bb_xxxx' methods if need be. (see above)
  378. //FIXME - cachevars/getcachedvars!
  379. global $pref, $eplug_bb, $bbcode_func, $bbcode_help, $bbcode_helpactive, $bbcode_helptag, $register_bb;
  380. // if(defsettrue('e_WYSIWYG')){ return; }
  381. $eplug_bb = $this->var['eplug_bb'] ? $this->var['eplug_bb'] : array();
  382. $bbcode_func = ($this->var['trigger']) ? $this->var['trigger'] : "addtext";
  383. $bbcode_help = ($bbcode_help) ? $bbcode_help : "help";
  384. $bbcode_tag = ($bbcode_helptag != 'helpb') ? ",'$bbcode_helptag'" : "";
  385. $rand = rand(1000,9999);
  386. // $imagedir_display = str_replace('../','',$bbcode_imagedir);
  387. /*
  388. if($parm == 'emotes')
  389. {
  390. if ($pref['comments_emoticons'] && $pref['smiley_activate'] && !defsettrue('e_WYSIWYG'))
  391. {
  392. $bbcode['emotes'] = array("expandit","emoticon_selector_".$rand, LANHELP_44, "emotes.png", "Emoticon_Select", "emoticon_selector_".$rand);
  393. }
  394. else
  395. { // If emotes disabled, don't return anything (without this we return an empty image reference)
  396. return '';
  397. }
  398. }
  399. */
  400. // Format: $bbcode['UNIQUE_NAME'] = array(ONCLICK_FUNC, ONCLICK_VAR, HELPTEXT, ICON, INCLUDE_FUNC, INCLUDE_FUNCTION_VAR);
  401. // $bbcode['newpage'] = array($bbcode_func,"[newpage]", LANHELP_34, "newpage.png");
  402. // $bbcode['link'] = array('addinput', "[link=".LANHELP_35."][/link]", LANHELP_23, "link.png", 'link');
  403. $bbcode['b'] = array($bbcode_func, "[b][/b]", LANHELP_24, "bold.png", '', '', 'bold');
  404. $bbcode['i'] = array($bbcode_func, "[i][/i]", LANHELP_25, "italic.png", '', '', 'italic');
  405. $bbcode['u'] = array($bbcode_func, "[u][/u]", LANHELP_26, "underline.png", '', '', 'underline');
  406. $bbcode['justify'] = array($bbcode_func, "[justify][/justify]", LANHELP_53, "justify.png", '', '', 'align-justify'); // FIXME bbcode icon
  407. $bbcode['center'] = array($bbcode_func, "[center][/center]", LANHELP_28, "center.png", '', '', 'align-center');
  408. $bbcode['left'] = array($bbcode_func, "[left][/left]", LANHELP_29, "left.png", '', '', 'align-left');
  409. $bbcode['right'] = array($bbcode_func, "[right][/right]", LANHELP_30, "right.png", '', '', 'align-right');
  410. $bbcode['list'] = array($bbcode_func, "[list][/list]", LANHELP_36, "list.png", '', '', 'list');
  411. $bbcode['img'] = array($bbcode_func, "[img][/img]", LANHELP_27, "image.png" , '', '', 'picture-o');
  412. $bbcode['flash'] = array($bbcode_func, "[flash=width,height][/flash]", LANHELP_47, "flash.png", '', '', 'flash');
  413. // $bbcode['youtube'] = array($bbcode_func, "[youtube][/youtube]", LANHELP_48, "youtube.png", '', '', 'youtube');
  414. $bbcode['sanitised'] = array('', '', '');
  415. $bbcode['nobr'] = array($bbcode_func, "[nobr][/nobr]", LANHELP_51, "nobr.png"); // FIXME bbcode icon
  416. $bbcode['br'] = array($bbcode_func, "[br]", LANHELP_52, "br.png"); // FIXME bbcode icon
  417. // $bbcode['fontsize'] = array("expandit", "size_selector_".$rand, LANHELP_22,"fontsize.png","Size_Select",'size_selector_'.$rand);
  418. // $bbcode['fontcol'] = array("e-expandit", "col_selector_".$rand, LANHELP_21,"fontcol.png","Color_Select",'col_selector_'.$rand);
  419. // $bbcode['preimage'] = array("e-dialog", "preimage_selector_".$rand, LANHELP_45.$imagedir_display,"preimage.png","PreImage_Select","preimage_selector_".$rand);
  420. // $bbcode['prefile'] = array("expandit", "prefile_selector_".$rand, LANHELP_39,"prefile.png","PreFile_Select",'prefile_selector_'.$rand);
  421. if(!isset($iconpath[$parm]))
  422. {
  423. $iconpath[$parm] = (file_exists(THEME."bbcode/bold.png") ? THEME_ABS."bbcode/" : e_IMAGE_ABS."bbcode/");
  424. $iconpath[$parm] .= varset($bbcode[$parm][3]);
  425. }
  426. if (!empty($register_bb))
  427. {
  428. foreach($register_bb as $key=>$val) // allow themes to plug in to it.
  429. {
  430. if($val[0]=="")
  431. {
  432. $val[0] = $bbcode_func;
  433. }
  434. $bbcode[$key] = $val;
  435. $iconpath[$key] = $val[3];
  436. }
  437. }
  438. if (!empty($eplug_bb))
  439. {
  440. foreach($eplug_bb as $val) // allow plugins to plug into it.
  441. {
  442. if(!$val) continue;
  443. unset($onclick,$onclick_var,$helptext,$icon,$function,$function_var);
  444. extract($val);
  445. // echo "$onclick $onclick_var $helptext $icon <br />";
  446. $bbcode[$name] = array($onclick,$onclick_var,$helptext,$icon,$function,$function_var);
  447. if($val['icon']) $iconpath[$name] = $icon;
  448. else unset($iconpath[$name]);
  449. }
  450. }
  451. if(!$iconpath[$parm]) return '';
  452. $pre = "\n";
  453. $post = "\n";
  454. $_onclick_func = (isset($bbcode[$parm][0])) ? $bbcode[$parm][0] : $bbcode_func;
  455. $_onclick_var = (isset($bbcode[$parm][1])) ? $bbcode[$parm][1] : '';
  456. $_helptxt = (isset($bbcode[$parm][2])) ? $bbcode[$parm][2] : '';
  457. $_function = (isset($bbcode[$parm][4])) ? $bbcode[$parm][4] : '';
  458. $_function_var = (isset($bbcode[$parm][5])) ? $bbcode[$parm][5] : '';
  459. if($_onclick_func == 'e-dialog')
  460. { // $tagid = "news-body";
  461. $pre = "\n<a href='".e_ADMIN."image.php?mode=main&action=dialog&for=news&tagid=".$tagid."&iframe=1&bbcode=1' class='btn e-dialog' >";
  462. $post = "</a>\n";
  463. }
  464. else
  465. {
  466. $pre = "<a class='btn e-pointer' title=\"".str_replace('<br />','\\n',($_helptxt))."\" onclick=\"{$_onclick_func}('".$_onclick_var."')\" ".($bbcode_helpactive ? "onmouseout=\"{$bbcode_help}(''{$bbcode_tag})\" onmouseover=\"{$bbcode_help}('".$_helptxt."'{$bbcode_tag})\"" : "" )." />";
  467. $post = "</a>\n"; // btn-small bbcode bbcode_buttons
  468. }
  469. if($bbcode[$parm]) // default - insert text.
  470. {
  471. $text = $pre;
  472. $text .= $this->button($iconpath[$parm], vartrue($bbcode[$parm][6]));
  473. $text .= $post;
  474. }
  475. if($_function)
  476. {
  477. $text .= ($bbcode_helpactive && $_helptxt && !$iconpath[$parm]) ? "<span onmouseout=\"{$bbcode_help}(''{$bbcode_tag})\" onmouseover=\"{$bbcode_help}('".$_helptxt."'{$bbcode_tag})\" >" : "";
  478. $text .= call_user_func($_function, $_function_var);
  479. $text .= ($bbcode_helpactive && $_helptxt && !$iconpath[$parm]) ? "</span>" : "";
  480. }
  481. return $text;
  482. }
  483. function sc_bb_help($parm)
  484. {
  485. return ''; // Use tooltips instead.
  486. /*
  487. global $bbcode_helpactive,$bbcode_helptag, $bbcode_helpsize;
  488. if($parm) $bbcode_helptag = $parm;
  489. elseif(!varset($bbcode_helptag)) $bbcode_helptag = 'helpb';
  490. if($bbcode_helpsize) $bbcode_helpsize = ' '.$bbcode_helpsize;
  491. $bbcode_helpactive = TRUE;
  492. */
  493. //FIXME - better bb help
  494. $bbcode_helptag = ($this->var['tagid']) ? $this->var['tagid'] : 'data_';
  495. $bbcode_helpsize = $this->var['size'];
  496. $bbcode_helpactive = $this->var['hint_active'];
  497. return "<input id='{$bbcode_helptag}' class='helpbox {$bbcode_helpsize}' type='text' name='{$bbcode_helptag}' size='90' readonly='readonly' />";
  498. }
  499. function sc_bb_preimagedir($parm)
  500. {
  501. // if(defsettrue('e_WYSIWYG')) { return; }
  502. // global $bbcode_imagedir;
  503. // $bbcode_imagedir = $parm;
  504. // return;
  505. }
  506. }
  507. ?>