- Timestamp:
- 12/28/07 21:58:46 (11 months ago)
- Location:
- team/michiel/input_formats
- Files:
-
- 5 added
- 4 modified
-
common/mvblog.php (modified) (3 diffs)
-
common/mvblog_admin.php (modified) (7 diffs)
-
common/mvblog_common.php (modified) (3 diffs)
-
common/tinymce_bbcode_conf.js (added)
-
common/tinymce_conf.js (modified) (2 diffs)
-
common/tinymce_filemanager.js (added)
-
upgrades/mysql/2007122800.php (added)
-
upgrades/pgsql/2007122800.php (added)
-
upgrades/sqlite/2007122800.php (added)
Legend:
- Unmodified
- Added
- Removed
-
team/michiel/input_formats/common/mvblog.php
r753 r754 271 271 <?php } ?> 272 272 <?php 273 $text = $this->strip_invalid_xml(stripslashes($row["body"])); 274 $text = $this->plugman->run_hooks("text_output", $text); 273 $text = $this->plugman->run_hooks("text_output", $row["body_formatted"]); 275 274 if ($this->limit_text($text)) { 276 275 echo $text; … … 335 334 <?php 336 335 } 337 }338 /* }}} */339 /* strip_invalid_xml() {{{ */340 /**341 * strip some stuff leftover from old editor342 *343 * @param string $data the text to process344 * @return string the text with invalid xml stripped345 */346 public function strip_invalid_xml($data) {347 $data = preg_replace("/ ref=\"[^\"].*\"/si", "", $data);348 return $data;349 336 } 350 337 /* }}} */ … … 702 689 } 703 690 /* }}} */ 704 /* parse_bbcode($data) {{{ */705 /**706 * Parse a string and intepret bbcode707 * @license LGPL708 * @author Justin Palmer709 * @url http://www.isolated-disigns.net/core710 * @author Ferry Boender711 *712 * @param string $data The raw string to do bbcode substitution on713 * @return string the string with bbcode tags substituded714 */715 public function parse_bbcode($data) {716 # AUTHOR: JUSTIN PALMER717 # WEBSITE: HTTP://WWW.ISOLATED-DESIGNS.NET/CORE718 # LICENSE: GNU LESSER GENERAL PUBLIC LICENSE http://www.gnu.org/copyleft/lesser.html719 # MODIFIED: Ferry Boender: optimized and function to strip bbcode720 /* Strip useless newlines so [code] will appear correct */721 $string = str_replace("\r", "", $data);722 $string = str_replace("\n", "<br />", $string);723 724 $patterns = array(725 '`\[ul\](.+?)\[/ul\]`is',726 '`\[li\](.+?)\[/li\]`is',727 '`\[quote\](.+?)\[/quote\]`is',728 '`\[indent](.+?)\[/indent\]`is',729 '`\[code](.+?)\[/code\]`is',730 '`\[b\](.+?)\[/b\]`is',731 '`\[i\](.+?)\[/i\]`is',732 '`\[u\](.+?)\[/u\]`is',733 '`\[strike\](.+?)\[/strike\]`is',734 '`\[color=#([0-9]{6})\](.+?)\[/color\]`is',735 '`\[email\](.+?)\[/email\]`is',736 '`\[img\](.+?)\[/img\]`is',737 '`\[url=([a-z0-9]+://)([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*?)?)\](.*?)\[/url\]`si',738 '`\[url\]([a-z0-9]+?://){1}([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*)?)\[/url\]`si',739 '`\[url\]((www|ftp)\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*?)?)\[/url\]`si',740 '`\[flash=([0-9]+),([0-9]+)\](.+?)\[/flash\]`is',741 '`\[size=([1-6]+)\](.+?)\[/size\]`is'742 );743 744 $replaces = array(745 '<ul>\1</ul>',746 '<li class="noblock">\1</li>',747 '<span class="quote">\1</span>',748 '<pre>\\1</pre>',749 '<pre class="code">\\1</pre>',750 '<strong>\\1</strong>',751 '<em>\\1</em>',752 '<span style="border-bottom: 1px dotted">\\1</span>',753 '<strike>\\1</strike>',754 '<span style="color:#\1;">\2</span>',755 '<a href="mailto:\1">\1</a>',756 '<img src="\1" alt="" style="border:0px;" />',757 '<a href="\1\2">\6</a>',758 '<a href="\1\2">\1\2</a>',759 '<a href="http://\1">\1</a>',760 '<object width="\1" height="\2"><param name="movie" value="\3" /><embed src="\3" width="\1" height="\2"></embed></object>',761 '<h\1>\2</h\1>'762 );763 764 $prev_string = "";765 while ($prev_string != $string) {766 $prev_string = $string;767 $string = preg_replace($patterns, $replaces , $string);768 }769 return(stripslashes($string));770 }771 /* }}} */772 691 /* blog_show_login() {{{ */ 773 692 /** -
team/michiel/input_formats/common/mvblog_admin.php
r736 r754 1223 1223 <div class="log_post_body"> 1224 1224 <div class="log_post_normal"> 1225 <?php echo stripslashes($row["body"]); ?>1225 <?php echo $row["body_formatted"]; ?> 1226 1226 </div> 1227 1227 </div> … … 1276 1276 $post["mail_comments"] = 1; 1277 1277 $post["allowanoncomments"] = ($this->settings["allowanoncomments"])?1:0; 1278 $post["postformat"] = $this->settings["defaultpostformat"]; 1278 1279 } else { 1279 1280 $res =& $this->db->query(sprintf("SELECT * FROM articles WHERE id = %d", $id)); … … 1295 1296 <script language="javascript" type="text/javascript" src="../tiny_mce/tiny_mce_gzip.js"></script> 1296 1297 <script language="javascript" type="text/javascript"> 1297 tinyMCE_GZ.init({1298 plugins : "spellchecker,inlinepopups,table,advhr,advimage,advlink,flash,paste,noneditable,contextmenu",1299 themes : "advanced",1300 languages : "en",1301 disk_cache : true,1302 debug : false1303 });1298 tinyMCE_GZ.init({ 1299 plugins : "spellchecker,inlinepopups,table,advhr,advimage,advlink,flash,paste,noneditable,contextmenu<?php echo ($post["postformat"] == "BBC")?",bbcode":""; ?>", 1300 themes : "advanced", 1301 languages : "en", 1302 disk_cache : true, 1303 debug : false 1304 }); 1304 1305 </script> 1305 <script language="javascript" type="text/javascript" src="../common/tinymce_conf.js"></script> 1306 <?php 1307 switch ($post["postformat"]) { 1308 case "HTML" : 1309 echo "<script language=\"javascript\" type=\"text/javascript\" src=\"../common/tinymce_conf.js\"></script>\n"; 1310 break; 1311 case "BBC" : 1312 echo "<script language=\"javascript\" type=\"text/javascript\" src=\"../common/tinymce_bbcode_conf.js\"></script>\n"; 1313 break; 1314 } 1315 ?> 1316 <script language="javascript" type="text/javascript" src="../common/tinymce_filemanager.js"></script> 1306 1317 <form name="blogpost" method="post" action="index.php"> 1307 1318 <input type="hidden" name="action" value="save_post" /> 1308 1319 <input type="hidden" name="post[id]" value="<?php echo $post["id"]; ?>" /> 1320 <input type="hidden" name="post[postformat]" value="<?php echo $post["postformat"]; ?>" /> 1309 1321 <div class="log_post"> 1310 1322 <div class="log_post_head"> … … 1326 1338 </div> 1327 1339 <div class="log_post_body"> 1328 <textarea id="editor_area" name="post[body]" rows=" 10" cols="50" style="width: 100%"><?php echo stripslashes($post["body"]); ?></textarea>1340 <textarea id="editor_area" name="post[body]" rows="30" cols="50" style="width: 100%"><?php echo stripslashes($post["body"]); ?></textarea> 1329 1341 <?php 1330 1342 echo "<a href=\"#\" onclick=\"tinyMCE.execCommand('mceToggleEditor', false, 'editor_area');\">".gettext("Toggle WYSIWYG mode")."</a>"; 1343 echo "<br />"; 1331 1344 echo gettext("to limit this post on the frontpage, enter ##BREAKPOINT## in your post."); 1332 1345 ?> … … 1440 1453 $query .= sprintf(" WHERE id = %d", $post["id"]); 1441 1454 } else { 1442 $query = sprintf("INSERT INTO articles (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s )",1455 $query = sprintf("INSERT INTO articles (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", 1443 1456 $this->db_quote("title"), $this->db_quote("body"), $this->db_quote("authors_id"), $this->db_quote("categories_ids"), $this->db_quote("date"), $this->db_quote("active"), 1444 $this->db_quote("public"), $this->db_quote("aside"), $this->db_quote("mail_comments"), $this->db_quote("ping_sent"), $this->db_quote("tb_uri"), $this->db_quote("allowanoncomments"), $this->db_quote("dossier_id") 1457 $this->db_quote("public"), $this->db_quote("aside"), $this->db_quote("mail_comments"), $this->db_quote("ping_sent"), $this->db_quote("tb_uri"), $this->db_quote("allowanoncomments"), $this->db_quote("dossier_id"), $this->db_quote("postformat") 1445 1458 ); 1446 $query .= sprintf("VALUES ('%s', '%s', %d, '%s', %d, %d, %d, %d, %d, %d, '%s', %d, %d )",1459 $query .= sprintf("VALUES ('%s', '%s', %d, '%s', %d, %d, %d, %d, %d, %d, '%s', %d, %d, '%s')", 1447 1460 preg_quote(strip_tags($post["title"]), "'"), 1448 1461 preg_quote($this->_strip_tags($post["body"]), "'"), … … 1452 1465 $post["active"], $post["public"], (array_key_exists("aside", $post))?$post["aside"]:0, $post["mail_comments"], 0, 1453 1466 preg_quote($post["tb_uri"], "'"), (array_key_exists("allowanoncomments", $post))?$post["allowanoncomments"]:0, 1454 (array_key_exists("dossier_id", $post))?$post["dossier_id"]:0 1467 (array_key_exists("dossier_id", $post))?$post["dossier_id"]:0, 1468 $post["postformat"] 1455 1469 ); 1456 1470 } … … 1785 1799 </td> 1786 1800 </tr><tr> 1801 <td><?php echo gettext("default markup format"); ?></td> 1802 <td> 1803 <select name="settings[defaultpostformat]"> 1804 <option value="HTML"<?php if ($settings["defaultpostformat"] == "HTML") echo " selected=\"selected\""; ?>>HTML</option> 1805 <option value="BBC"<?php if ($settings["defaultpostformat"] == "BBC") echo " selected=\"selected\""; ?>>BBCode</option> 1806 </select> 1807 </td> 1808 </tr><tr> 1809 <td><?php echo gettext("use WYSIWYG editor"); ?></td> 1810 <td> 1811 <select name="settings[wysiwyg]"> 1812 <option value="0"><?php echo gettext("no"); ?></option> 1813 <option value="1"<?php if ($settings["wysiwyg"] == 1) echo " selected=\"selected\""; ?>><?php echo gettext("yes"); ?></option> 1814 </select> 1815 </td> 1816 </tr><tr> 1787 1817 <td colspan="2"> </td> 1788 1818 </tr><tr> -
team/michiel/input_formats/common/mvblog_common.php
r726 r754 387 387 } 388 388 /* }}} */ 389 /* strip_invalid_xml() {{{ */ 390 /** 391 * strip some stuff leftover from old editor 392 * 393 * @param string $data the text to process 394 * @return string the text with invalid xml stripped 395 */ 396 public function strip_invalid_xml($data) { 397 $data = preg_replace("/ ref=\"[^\"].*\"/si", "", $data); 398 return $data; 399 } 400 /* }}} */ 401 /* format parses */ 402 /* parse_body {{{ */ 403 /** 404 * Parse the body based on postformat. 405 * 406 * Supported formats with their processor: 407 * - BBC: bbcode - uses internal bbcode parser 408 * - HTML: html sourcecode - no processing is done 409 * 410 * @param string $body The raw body data 411 * @param string $format The body format. 412 * @return string the formatted body. 413 */ 414 public function parse_body($body, $format) { 415 switch ($format) { 416 case "BBC": 417 $body = $this->parse_bbcode($body); 418 break; 419 } 420 //fix leftovers from old editor 421 $body = $this->strip_invalid_xml(stripslashes($body)); 422 return $body; 423 } 424 /* }}} */ 425 /* parse_bbcode($data) {{{ */ 426 /** 427 * Parse a string and intepret bbcode 428 * @license LGPL 429 * @author Justin Palmer 430 * @url http://www.isolated-disigns.net/core 431 * @author Ferry Boender 432 * 433 * @param string $data The raw string to do bbcode substitution on 434 * @return string the string with bbcode tags substituded 435 */ 436 public function parse_bbcode($data) { 437 # AUTHOR: JUSTIN PALMER 438 # WEBSITE: HTTP://WWW.ISOLATED-DESIGNS.NET/CORE 439 # LICENSE: GNU LESSER GENERAL PUBLIC LICENSE http://www.gnu.org/copyleft/lesser.html 440 # MODIFIED: Ferry Boender: optimized and function to strip bbcode 441 /* Strip useless newlines so [code] will appear correct */ 442 $string = str_replace("\r", "", $data); 443 $string = str_replace("\n", "<br />", $string); 444 445 $patterns = array( 446 '`\[ul\](.+?)\[/ul\]`is', 447 '`\[li\](.+?)\[/li\]`is', 448 '`\[quote\](.+?)\[/quote\]`is', 449 '`\[indent](.+?)\[/indent\]`is', 450 '`\[code](.+?)\[/code\]`is', 451 '`\[b\](.+?)\[/b\]`is', 452 '`\[i\](.+?)\[/i\]`is', 453 '`\[u\](.+?)\[/u\]`is', 454 '`\[strike\](.+?)\[/strike\]`is', 455 '`\[color=#([0-9]{6})\](.+?)\[/color\]`is', 456 '`\[email\](.+?)\[/email\]`is', 457 '`\[img\](.+?)\[/img\]`is', 458 '`\[url=([a-z0-9]+://)([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*?)?)\](.*?)\[/url\]`si', 459 '`\[url\]([a-z0-9]+?://){1}([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*)?)\[/url\]`si', 460 '`\[url\]((www|ftp)\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*?)?)\[/url\]`si', 461 '`\[flash=([0-9]+),([0-9]+)\](.+?)\[/flash\]`is', 462 '`\[size=([1-6]+)\](.+?)\[/size\]`is' 463 ); 464 465 $replaces = array( 466 '<ul>\1</ul>', 467 '<li class="noblock">\1</li>', 468 '<span class="quote">\1</span>', 469 '<pre>\\1</pre>', 470 '<pre class="code">\\1</pre>', 471 '<strong>\\1</strong>', 472 '<em>\\1</em>', 473 '<span style="border-bottom: 1px dotted">\\1</span>', 474 '<strike>\\1</strike>', 475 '<span style="color:#\1;">\2</span>', 476 '<a href="mailto:\1">\1</a>', 477 '<img src="\1" alt="" style="border:0px;" />', 478 '<a href="\1\2">\6</a>', 479 '<a href="\1\2">\1\2</a>', 480 '<a href="http://\1">\1</a>', 481 '<object width="\1" height="\2"><param name="movie" value="\3" /><embed src="\3" width="\1" height="\2"></embed></object>', 482 '<h\1>\2</h\1>' 483 ); 484 485 $prev_string = ""; 486 while ($prev_string != $string) { 487 $prev_string = $string; 488 $string = preg_replace($patterns, $replaces , $string); 489 } 490 return(stripslashes($string)); 491 } 492 /* }}} */ 389 493 /* data getters */ 390 494 /* _get_settings {{{ */ … … 408 512 $settings["dbversion"] = 0; 409 513 $settings["show_cat_icons"] = 0; 514 $settings["defaultpostformat"] = "HTML"; 515 $settings["wysiwyg"] = 0; 410 516 411 517 while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) { … … 744 850 while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) { 745 851 if (array_key_exists("replace_references", $options) && $options["replace_references"] == 1) { 746 $row["body"] = $this->replace_num_ref($row["body"]); 747 $row["body"] = $this->replace_dossier_ref($row["body"]); 852 $row["body_formatted"] = $this->replace_num_ref($row["body"]); 853 $row["body_formatted"] = $this->replace_dossier_ref($row["body_formatted"]); 854 } else { 855 $row["body_formatted"] = $row["body"]; 748 856 } 857 // parse body according to postformat 858 $row["body_formatted"] = $this->parse_body($row["body_formatted"], $row["postformat"]); 749 859 $posts["posts"][$i] = $row; 750 860 $i++; -
team/michiel/input_formats/common/tinymce_conf.js
r736 r754 1 1 tinyMCE.init({ 2 mode : " exact",2 mode : "none", 3 3 elements : "editor_area", 4 4 theme : "advanced", … … 24 24 height : "420" 25 25 }); 26 27 function ajaxfilemanager(field_name, url, type, win) {28 var ajaxfilemanagerurl = "../../../tiny_mce/plugins/ajaxfilemanager/ajaxfilemanager.php";29 switch (type) {30 case "image":31 ajaxfilemanagerurl += "?type=img";32 break;33 case "media":34 ajaxfilemanagerurl += "?type=media";35 break;36 case "flash": //for older versions of tinymce37 ajaxfilemanagerurl += "?type=media";38 break;39 case "file":40 ajaxfilemanagerurl += "?type=files";41 break;42 default:43 return false;44 }45 var fileBrowserWindow = new Array();46 fileBrowserWindow["file"] = ajaxfilemanagerurl;47 fileBrowserWindow["title"] = "TinyMCE Ajax File Manager";48 fileBrowserWindow["width"] = "782";49 fileBrowserWindow["height"] = "440";50 fileBrowserWindow["close_previous"] = "no";51 tinyMCE.openWindow(fileBrowserWindow, {52 window : win,53 input : field_name,54 resizable : "yes",55 inline : "yes",56 editor_id : tinyMCE.getWindowArg("editor_id")57 });58 59 return false;60 }61
