1<?php 2if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../../').'/'); 3if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 4require_once(DOKU_PLUGIN.'action.php'); 5 6 7/** 8 * @license GNU GPLv2 version 2 or later (http://www.gnu.org/licenses/gpl.html) 9 * 10 * class plugin_ckgdoku_edit 11 * @author Myron Turner <turnermm02@shaw.ca> 12 */ 13 14class action_plugin_ckgdoku_edit extends DokuWiki_Action_Plugin { 15 16 var $fck_location = "ckeditor"; 17 var $helper = false; 18 var $ckgdoku_bak_file = ""; 19 var $debug = false; 20 var $test = false; 21 var $page_from_template; 22 var $draft_found = false; 23 var $draft_text; 24 var $draft_started; 25 var $captcha; 26 /** 27 * Constructor 28 */ 29 function __construct() 30 { 31 $this->setupLocale(); 32 $this->helper = plugin_load('helper', 'ckgdoku'); 33 if(!plugin_isdisabled('captcha')) { 34 $this->captcha = plugin_load('helper', 'captcha'); 35 If(!$this->captcha) $this->captcha = false; 36 } 37 else $this->captcha = false; 38 39 } 40 41 42 function register(Doku_Event_Handler $controller) 43 { 44 $version = explode('.', phpversion()); 45 define('PHP_VERSION_NUM', $version[0] * 10+ $version[1]); 46 47 if($this->helper->is_outOfScope()) return; 48 49 global $FCKG_show_preview; 50 $FCKG_show_preview = true; 51 52 if(isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'dwiki') { 53 $FCKG_show_preview = true; 54 return; 55 } 56 elseif(isset($_COOKIE['FCKG_USE'])) { 57 preg_match('/_\w+_/', $_COOKIE['FCKG_USE'], $matches); 58 if($matches[0] == '_false_') { 59 $FCKG_show_preview = true; 60 return; 61 } 62 } 63 $Fck_NmSp = "!!NONSET!!"; 64 if(isset($_COOKIE['FCK_NmSp'])) { 65 $Fck_NmSp = $_COOKIE['FCK_NmSp']; 66 } 67 $dwedit_ns = @$this->getConf('dwedit_ns'); 68 if(isset($dwedit_ns) && $dwedit_ns) { 69 $ns_choices = explode(',',$dwedit_ns); 70 foreach($ns_choices as $ns) { 71 $ns = trim($ns); 72 if(preg_match("/$ns/",$_REQUEST['id']) || preg_match("/$ns/",$Fck_NmSp)) { 73 $FCKG_show_preview = true; 74 return; 75 } 76 } 77 } 78 $controller->register_hook('COMMON_PAGE_FROMTEMPLATE', 'AFTER', $this, 'pagefromtemplate', array()); 79 $controller->register_hook('COMMON_PAGETPL_LOAD', 'AFTER', $this, 'pagefromtemplate', array()); 80 81 $controller->register_hook('TPL_ACT_RENDER', 'BEFORE', $this, 'ckgdoku_edit'); 82 $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'ckgdoku_edit_meta'); 83 } 84 85 /** 86 * function pagefromtemplate 87 * Capture template text output by Template Event handler instead of pageTemplate() 88 * @author Myron Turner <turnermm02@shaw.ca> 89 * 90 */ 91 function pagefromtemplate(Doku_Event $event) { 92 if($event->data['tpl']) { 93 $this->page_from_template = $event->data['tpl']; 94 } 95 } 96 97 /** 98 * ckgdoku_edit_meta 99 * 100 * load fck js 101 * @author Pierre Spring <pierre.spring@liip.ch> 102 * @author Myron Turner <turnermm03@shaw.ca> 103 * @param mixed $event 104 * @access public 105 * @return void 106 */ 107 function ckgdoku_edit_meta(Doku_Event $event) 108 { 109 global $ACT; 110 // we only change the edit behaviour 111 if ($ACT != 'edit'){ 112 return; 113 } 114 global $ID; 115 global $REV; 116 global $INFO; 117 118 $event->data['script'][] = 119 array( 120 'type'=>'text/javascript', 121 'charset'=>'utf-8', 122 '_data'=>'', 123 'src'=>DOKU_BASE.'lib/plugins/ckgdoku/' .$this->fck_location. '/ckeditor.js' 124 ); 125 126 $ua = strtolower ($_SERVER['HTTP_USER_AGENT']); 127 if(strpos($ua, 'msie') !== false) { 128 echo "\n" . '<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />' ."\n"; 129 } 130 131 return; 132 } 133 134 /** 135 * function ckgdoku_edit 136 * @author Pierre Spring <pierre.spring@liip.ch> 137 * edit screen using fck 138 * 139 * @param & $event 140 * @access public 141 * @return void 142 */ 143 function ckgdoku_edit(Doku_Event $event) 144 { 145 146 global $INFO; 147 148 // we only change the edit behaviour 149 if ($event->data != 'edit') { 150 return; 151 } 152 // load xml and acl 153 if (!$this->_preprocess()){ 154 return; 155 } 156 // print out the edit screen 157 $this->_print(); 158 // prevent Dokuwiki normal processing of $ACT (it would clean the variable and destroy our 'index' value. 159 $event->preventDefault(); 160 // index command belongs to us, there is no need to hold up Dokuwiki letting other plugins see if its for them 161 $event->stopPropagation(); 162 } 163 164 /** 165 * function _preprocess 166 * @author Myron Turner <turnermm02@shaw.ca> 167 */ 168 function _preprocess($draft_text = "") 169 { 170 global $ID; 171 global $REV; 172 global $DATE; 173 global $RANGE; 174 global $PRE; 175 global $SUF; 176 global $INFO; 177 global $SUM; 178 global $lang; 179 global $conf; 180 global $ckgdoku_lang; 181 //set summary default 182 if(!$SUM){ 183 if($REV){ 184 $SUM = $lang['restored']; 185 }elseif(!$INFO['exists']){ 186 $SUM = $lang['created']; 187 } 188 } 189 if(!$draft_text) { 190 if($INFO['exists']){ 191 if($RANGE){ 192 list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV); 193 }else{ 194 $text = rawWiki($ID,$REV); 195 } 196 }else{ 197 //try to load a pagetemplate 198 $text = pageTemplate($ID); 199 //Check for text from template event handler 200 if(!$text && $this->page_from_template) $text = $this->page_from_template; 201 } 202 } 203 else $text = $draft_text; 204 205 $text = preg_replace_callback( 206 '/(~~NOCACHE~~|~~NOTOC~~|\{\{rss>http:\/\/.*?\}\})/ms', 207 create_function( 208 '$matches', 209 '$matches[0] = str_replace("{{rss>http://www.", "{ { rss>FEED", $matches[0]); 210 $matches[0] = str_replace("{{rss>http://", "{ { rss>Feed:", $matches[0]); 211 $matches[0] = str_replace("~", "~ ", $matches[0]); 212 return $matches[0];' 213 ),$text); 214 if($this->getConf('smiley_hack')) { 215 $new_addr = $_SERVER['SERVER_NAME'] . DOKU_BASE; 216 $text=preg_replace("#(?<=http://)(.*?)(?=lib/plugins/ckgdoku/ckeditor/plugins/smiley/images)#s", $new_addr,$text); 217 } 218 219 $text = preg_replace_callback('/\[\[\w+>.*?\]\]/ms', 220 create_function( 221 '$matches', 222 'return str_replace("/", "__IWIKI_FSLASH__" ,$matches[0]);' 223 ), $text); 224 225 global $useComplexTables; 226 if($this->getConf('complex_tables') || strrpos($text, '~~COMPLEX_TABLES~~') !== false) { 227 $useComplexTables=true; 228 } 229 else { 230 $useComplexTables=false; 231 } 232 233 if(strpos($text, '%%') !== false || strpos($text, '\\\\') !== false || strpos($text, '|') !== false ) { 234 $text = preg_replace('/%%\s*<nowiki>\s*%%/ms', 'PERCNWPERC',$text); 235 $text = preg_replace('/%%\s*<(code|file)>\s*%%/ms', 'PERC' . "$1" . 'PERC',$text); 236 $text = preg_replace_callback( 237 "/<(nowiki|code|file)>(.*?)<\/(nowiki|code|file)/ms", 238 function ($matches) { 239 $matches[0] = str_replace('%%', 'DBLPERCENT',$matches[0]); 240 $matches[0] = str_replace('\\ ', 'DBLBACKSPLASH',$matches[0]); 241 $matches[0] = str_replace('|', 'NWPIPECHARACTER',$matches[0]); 242 return $matches[0]; 243 }, 244 $text 245 ); 246 247 $text = preg_replace_callback( 248 "/(?<!nowiki>)%%(.*?)%%/ms", 249 function($matches) { 250 return '<nowiki>' . $matches[1] . '</nowiki>'; 251 }, 252 $text 253 ); 254 255 $text = str_replace('DBLPERCENT','%%',$text); 256 } 257 258 $pos = strpos($text, '<'); 259 260 if($pos !== false) { 261 262/* skipentity support */ 263 $text = preg_replace_callback( 264 '/``(.*?)``/ms', 265 function($matches) { 266 $needles = array('[',']', '/', '.', '*', '_','\'','<','>','%', '{', '}', '\\' , '(' ); 267 $replacements = array('[',']','/', '.', '*', '_', ''', '<','>','%', '{','}', '\','('); 268 $matches[1] = str_replace($needles, $replacements, $matches[1]); 269 return '``' .$matches[1] .'``' ; 270 }, 271 $text 272 ); 273 274 275 $text = preg_replace_callback( 276 '/(<nowiki>)(.*?)(<\/nowiki>)/ms', 277 create_function( 278 '$matches', 279 '$needles = array("[","]", "/", ".", "*", "_","\'","<",">","%", "{", "}", "\\\","("); 280 $replacements = array("[","]","/", ".", "*", "_", "'", "<",">","%", "{","}", "\","("); 281 $matches[2] = str_replace($needles, $replacements, $matches[2]); 282 return $matches[1] . $matches[2] . $matches[3];' 283 ), 284 $text 285 ); 286 287 $text = preg_replace_callback( 288 '/<(code|file)(.*?)(>)(.*?)(<\/\1>)/ms', 289 create_function( 290 '$matches', 291 ' //file_put_contents("geshi.txt", print_r($matches,true)); 292 if(preg_match("/(^\s*geshi:\s*(\w+)(\s+\w+\.\w+)*\s*)$/m",$matches[0],$gmatch)){ 293 $gmatch[0] = preg_replace("/\s*geshi:\s+/","",$gmatch[0]); 294 $matches[1] .= " " . trim($gmatch[0]); 295 //file_put_contents("gmatch.txt", print_r($gmatch,true)); 296 $c=1; 297 $matches[4] = str_replace($gmatch[1],"",$matches[4],$c); 298 } 299 if(preg_match("/\w+/",$matches[2])) { 300 $matches[4] = str_replace("CHEVRONescC", ">>",$matches[4]); 301 $matches[4] = str_replace("CHEVRONescO", "<<",$matches[4]); 302 $matches[4] = preg_replace("/<(?!\s)/ms", "__GESHI_OPEN__", $matches[4]); 303 } 304 else { 305 if( preg_match("/MULTI/",$matches[0])) { 306 $open = "< "; 307 $close = " >"; 308 } 309 else { 310 $open = "<"; 311 $close = ">"; 312 } 313 $matches[4] = preg_replace("/<(?!\s)/ms", $open, $matches[4]); 314 $matches[4] = preg_replace("/(?<!\s)>/ms", $close, $matches[4]); 315 } 316 $matches[4] = str_replace("\"", "__GESHI_QUOT__", $matches[4]); 317 return "<" . $matches[1] . $matches[2] . $matches[3] . $matches[4] . $matches[5];' 318 ), 319 $text 320 ); 321 322 $text = preg_replace_callback( 323 '/~~START_HTML_BLOCK~~.*?CLOSE_HTML_BLOCK/ms', 324 create_function( 325 '$matches', 326 '$matches[0] = str_replace("_ckgdoku_NPBBR_","",$matches[0]); 327 return $matches[0];' 328 ),$text); 329 330 $text = preg_replace_callback( 331 '/(\|\s*)(<code>|<file>)(.*?)(<\/code>|<\/file>)\n_ckgdoku_NPBBR_(?=.*?\|)/ms', 332 create_function( 333 '$matches', 334 '$matches[2] = preg_replace("/<code>/ms", "TPRE_CODE", $matches[2]); 335 $matches[2] = preg_replace("/<file>/ms", "TPRE_FILE", $matches[2]); 336 $matches[4] = "TPRE_CLOSE"; 337 $matches[3] = preg_replace("/^\n+/", "TC_NL",$matches[3]); 338 $matches[3] = preg_replace("/\n/ms", "TC_NL",$matches[3]); 339 return $matches[1] . $matches[2] . trim($matches[3]) . $matches[4];' 340 ), 341 $text 342 ); 343 $text = preg_replace('/TPRE_CLOSE\s+/ms',"TPRE_CLOSE",$text); 344 345 $text = preg_replace('/<(?!code|file|del|sup|sub|\/\/|\s|\/del|\/code|\/file|\/sup|\/sub)/ms',"<",$text); 346 347 $text = str_replace('%%<', '%%<', $text); 348 } 349 350 if($this->getConf('duplicate_notes')) { 351 $text = preg_replace_callback('/\(\((.*?)\)\)/ms', 352 create_function( 353 '$matches', 354 'static $count = 0; 355 $count++; 356 $ins = "FNoteINSert" . $count; 357 $needles = array("[","]", "/", ".", "*", "_","\'","<",">","%", "{", "}", "\\\","("); 358 $replacements = array("[","]","/", ".", "*", "_", "'", "<",">","%", "{","}", "\","("); 359 $matches[1] = str_replace($needles, $replacements, $matches[1]); 360 return "(($ins" . $matches[1] . "))" ;' 361 ), $text 362 ); 363 } 364 $text = preg_replace('/^\>/ms',"_QUOT_",$text); // dw quotes 365 $text = str_replace('>>','CHEVRONescC',$text); 366 $text = str_replace('<<','CHEVRONescO',$text); 367 $text = preg_replace('/(={3,}.*?)(\{\{.*?\}\})(.*?={3,})/',"$1$3\n$2",$text); 368 $email_regex = '/\/\/\<\/\/(.*?@.*?)>/'; 369 $text = preg_replace($email_regex,"<$1>",$text); 370 371 $text = preg_replace('/{{(.*)\.swf(\s*)}}/ms',"__SWF__$1.swf$2__FWS__",$text); 372 $text = preg_replace('/PERCNWPERC/ms', '%%< nowiki >%%',$text); 373 //$text = preg_replace('/%%\s*<(code|file)>\s*%%/ms', 'PERC' . "$1" . 'PERC',$text); 374 $text = preg_replace('/PERCcodePERC/ms','%%<code>%%', $text); 375 $text = preg_replace('/PERCfilePERC/ms','%%<file>%%', $text); 376 377 $divalign = false; 378 if($this->helper->has_plugin('divalign2') 379 ||$this->helper->has_plugin('divalign2_center')) { 380 $divalign = true; 381 $text = preg_replace_callback('/\n([;#]{3})/', 382 383 function ($matches) { 384 return "divalNLine" . str_replace('#','CGEHASH',$matches[1]); 385 }, $text 386 ); 387 } 388 $this->xhtml = $this->_render_xhtml($text); 389 390 $this->xhtml = str_replace("__IWIKI_FSLASH__", "⁄", $this->xhtml); 391 if($this->getConf('duplicate_notes')) { 392 $this->xhtml = preg_replace("/FNoteINSert\d+/ms", "",$this->xhtml); 393 } 394 if($divalign) { 395 $this->xhtml = str_replace("CGEHASH", "#", $this->xhtml); 396 } 397 $this->xhtml = str_replace("__GESHI_QUOT__", '"', $this->xhtml); 398 $this->xhtml = str_replace("__GESHI_OPEN__", "< ", $this->xhtml); 399 $this->xhtml = str_replace('CHEVRONescC', '>>',$this->xhtml); 400 $this->xhtml = str_replace('CHEVRONescO', '<<',$this->xhtml); 401 $this->xhtml = preg_replace('/_QUOT_/ms','>',$this->xhtml); // dw quotes 402 $this->xhtml = str_replace("rss>FEED", "rss>Feed:www.",$this->xhtml); 403 404 $this->xhtml = preg_replace_callback( 405 "/^(>+)(.*?)$/ms", 406 function($matches) { 407 $matches[2] = str_ireplace('<br/>',"",$matches[2]); 408 return $matches[1] . $matches[2] . "<br />"; 409 }, 410 $this->xhtml 411 ); 412 413 if($pos !== false) { 414 $this->xhtml = preg_replace_callback( 415 '/(TPRE_CODE|TPRE_FILE)(.*?)(TPRE_CLOSE)/ms', 416 create_function( 417 '$matches', 418 '$matches[1] = preg_replace("/TPRE_CODE/","<pre class=\'code\'>\n", $matches[1]); 419 $matches[1] = preg_replace("/TPRE_FILE/","<pre class=\'file\'>\n", $matches[1]); 420 $matches[2] = preg_replace("/TC_NL/ms", "\n", $matches[2]); 421 $matches[3] = "</pre>"; 422 return $matches[1] . $matches[2] . $matches[3];' 423 ), 424 $this->xhtml 425 ); 426 427 } 428 $this->xhtml = preg_replace_callback( 429 '/~~START_HTML_BLOCK~~[\n\s]*(.*?)CLOSE_HTML_BLOCK/ms', 430 create_function( 431 '$matches', 432 '$matches[1] = str_replace("&","&",$matches[1]); 433 $matches[1] = html_entity_decode($matches[1],ENT_QUOTES, "UTF-8"); 434 $matches[1] = preg_replace("/<\/?code.*?>/", "",$matches[1]); 435 $matches[1] = preg_replace("/^\s*<\/p>/","",$matches[1]); 436 $tmp = explode("\n", $matches[1]); 437 for($n=0; $n<7; $n++) { 438 if( (preg_match("/(<p>\s*)*( |\s+)<\/p>/",$tmp[$n])) || (preg_match("/^\s+$/",$tmp[$n]))) { 439 unset($tmp[$n]); 440 } 441 } 442 return "~~START_HTML_BLOCK~~" . implode("\n",$tmp) . "CLOSE_HTML_BLOCK"; ' 443 ),$this->xhtml); 444 445 $this->xhtml = preg_replace_callback( 446 '/(<pre)(.*?)(>)(.*?)(<\/pre>)/ms', 447 create_function( 448 '$matches', 449 '$matches[4] = preg_replace("/(\||\^)[ ]+(\||\^)/ms","$1 $2" , $matches[4]); 450 return $matches[1] . $matches[2] . $matches[3] . $matches[4] . $matches[5];' 451 ), 452 $this->xhtml 453 ); 454 455 $this->xhtml = preg_replace_callback( 456 '/~~MULTI_PLUGIN_OPEN~~(.*?)~~MULTI_PLUGIN_CLOSE~~/ms', 457 create_function( 458 '$matches', 459 'return str_replace("<", "< ",$matches[0]);' 460 ), 461 $this->xhtml 462 ); 463 464 if($this->draft_started) return $this->xhtml; 465 $cname = getCacheName($INFO['client'].$ID,'.draft.fckl'); 466 467 $this->draft_started = false; 468 if(file_exists($cname) && !$this->draft_started) { 469 470 $this->draft_started = true; 471 472 $cdata = unserialize(io_readFile($cname,false)); 473 $prefix = isset($cdata['prefix']) ? urldecode($cdata['prefix']) : "" ; 474 if($prefix) $prefix = $this-> _preprocess($prefix); 475 $text = urldecode($cdata['text']); 476 $suffix = isset($cdata['suffix']) ? urldecode($cdata['suffix']) : "" ; 477 478 if($suffix) $suffix = $this-> _preprocess($suffix); 479 480 preg_match_all("/<\/(.*?)\>/", $cdata['text'],$matches); 481 /* exclude drafts saved from preview mode */ 482 if (!in_array('code', $matches[1]) && !in_array('file', $matches[1]) && !in_array('nowiki', $matches[1])) { 483 //$this->draft_text = $cdata['text']; 484 $this->draft_text = $prefix . $text . $suffix; 485 $this->draft_found = true; 486 msg($this->getLang('draft_msg')) ; 487 } 488 unlink($cname); 489 } 490 if($draft_started) return $this->xhtml; 491 return true; 492 } 493 494 /** 495 * function dw_edit_displayed 496 * @author Myron Turner 497 * determines whether or not to show or hide the 498 * 'DW Edit' button 499 */ 500 501 function dw_edit_displayed() 502 { 503 global $INFO; 504 505 $dw_edit_display = @$this->getConf('dw_edit_display'); 506 if(!isset($dw_edit_display))return ""; //version 0. 507 if($dw_edit_display != 'all') { 508 $admin_exclusion = false; 509 if($dw_edit_display == 'admin' && ($INFO['isadmin'] || $INFO['ismanager']) ) { 510 $admin_exclusion = true; 511 } 512 if($dw_edit_display == 'none' || $admin_exclusion === false) { 513 return ' style = "display:none"; '; 514 } 515 return ""; 516 } 517 return ""; 518 519 } 520 521 /** 522 * function _print 523 * @author Myron Turner 524 */ 525 function _print() 526 { 527 global $INFO; 528 global $lang; 529 global $ckgdoku_lang; 530 global $ID; 531 global $REV; 532 global $DATE; 533 global $PRE; 534 global $SUF; 535 global $SUM; 536 $wr = $INFO['writable']; 537 if($wr){ 538 if ($REV) print p_locale_xhtml('editrev'); 539 $ro=false; 540 }else{ 541 // check pseudo action 'source' 542 if(!actionOK('source')){ 543 msg('Command disabled: source',-1); 544 return false; 545 } 546 print p_locale_xhtml('read'); 547 $ro='readonly="readonly"'; 548 } 549 550 if(!$DATE) $DATE = $INFO['lastmod']; 551 $guest_toolbar = $this->getConf('guest_toolbar'); 552 $guest_media = $this->getConf('guest_media'); 553 if(!isset($INFO['userinfo']) && !$guest_toolbar) { 554 $toolbar = "DokuwikiNoGuest"; 555 } 556 else if(!isset($INFO['userinfo']) && !$guest_media) { 557 $toolbar = "DokuwikiGuest"; 558 } 559 else $toolbar = 'Dokuwiki'; 560 561$height = isset($_COOKIE['ckgEdht']) && $_COOKIE['ckgEdht'] ? $_COOKIE['ckgEdht']: 250; 562if(!is_numeric($height)) $height = 250; 563$fbsz_increment = isset($_COOKIE['fbsz']) && $_COOKIE['fbsz'] ? $_COOKIE['fbsz'] : false; 564$fbrowser_width = 1070; 565$fbrowser_height = 660; 566if($fbsz_increment) { 567 $fbrowser_width = $fbrowser_width + ($fbrowser_width*($fbsz_increment/100)); 568 $fbrowser_height =$fbrowser_height + ($fbrowser_height*($fbsz_increment/100)); 569} 570 571$doku_url= rtrim(DOKU_URL,'/'); 572$ns = getNS($_COOKIE['FCK_NmSp']); 573 574//get user file browser if allowed 575if ($this->getConf('allow_ckg_filebrowser') == 'all') { 576 $fb = $this->getUserFb(); 577} else { 578 //use only allowed file browser 579 $fb = $this->getConf('allow_ckg_filebrowser'); 580} 581 582//setup options 583if ($fb == 'dokuwiki') { 584 $fbOptions = "filebrowserImageBrowseUrl: \"$doku_url/lib/exe/mediamanager.php?ns=$ns&edid=wiki__text&onselect=ckg_edit_mediaman_insert&ckg_media=img\", 585 filebrowserBrowseUrl: \"$doku_url/lib/exe/mediamanager.php?ns=$ns&edid=wiki__text&onselect=ckg_edit_mediaman_insertlink&ckg_media=link\""; 586} else { 587 $fbOptions = "filebrowserImageBrowseUrl : \"$doku_url/lib/plugins/ckgdoku/fckeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=$doku_url/lib/plugins/ckgdoku/fckeditor/editor/filemanager/connectors/php/connector.php\", 588 filebrowserBrowseUrl: \"$doku_url/lib/plugins/ckgdoku/fckeditor/editor/filemanager/browser/default/browser.html?Type=File&Connector=$doku_url/lib/plugins/ckgdoku/fckeditor/editor/filemanager/connectors/php/connector.php\""; 589} 590 591$ckeditor_replace =<<<CKEDITOR_REPLACE 592 593 ckgdokuCKInstance = CKEDITOR.replace('wiki__text', 594 { 595 toolbar: '$toolbar' , 596 height: $height, 597 filebrowserWindowWidth: $fbrowser_width, 598 filebrowserWindowHeight: $fbrowser_height, 599 $fbOptions, 600 on : { 'instanceReady' : function( evt ) { 601 evt.editor.document.on( 'mousedown', function() 602 { 603 parent. handlekeypress(evt); 604 } ); 605 } 606 }, 607 on : { 'instanceReady' : function( evt ) { 608 evt.editor.document.on( 'focus', function() 609 { 610 parent. handlekeypress(evt); 611 } ); 612 } 613 }, 614 615 } 616 ); 617 FCKeditor_OnComplete(ckgdokuCKInstance); 618 619 620CKEDITOR_REPLACE; 621 622 echo $this->helper->registerOnLoad($ckeditor_replace); 623 624 global $skip_styling; 625 626?> 627<?php 628 if($this->page_from_template) { 629 $ckg_template = 'tpl'; 630 } 631 else $ckg_template =""; 632 633 ?> 634 <form id="dw__editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>"> 635 <div class="no"> 636 <input type="hidden" name="id" value="<?php echo $ID?>" /> 637 <input type="hidden" name="rev" value="<?php echo $REV?>" /> 638 <input type="hidden" name="date" value="<?php echo $DATE?>" /> 639 <input type="hidden" name="prefix" value="<?php echo formText($PRE)?>" /> 640 <input type="hidden" name="suffix" value="<?php echo formText($SUF)?>" /> 641 <input type="hidden" id="ckgdoku_mode_type" name="mode" value="" /> 642 <input type="hidden" id="fck_preview_mode" name="fck_preview_mode" value="nil" /> 643 <input type="hidden" id="fck_wikitext" name="fck_wikitext" value="__false__" /> 644 <input type="hidden" id="styling" name="styling" value="styles" /> 645 <input type="hidden" id="template" name="template`" value="<?php echo $ckg_template?>" /> 646 <?php 647 if(function_exists('formSecurityToken')) { 648 formSecurityToken(); 649 } 650 ?> 651 </div> 652 653 <textarea name="wikitext" id="wiki__text" <?php echo $ro?> cols="80" rows="10" class="edit" tabindex="1"><?php echo "\n".$this->xhtml?></textarea> 654 655<?php 656 657$temp=array(); 658trigger_event('HTML_EDITFORM_INJECTION', $temp); 659 660$DW_EDIT_disabled = ''; 661$guest_perm = auth_quickaclcheck($_REQUEST['id']); 662$guest_group = false; 663$guest_user = false; 664 665if(isset($INFO['userinfo'])&& isset($INFO['userinfo']['grps'])) { 666 $user_groups = $INFO['userinfo']['grps']; 667 if(is_array($user_groups) && $user_groups) { 668 foreach($user_groups as $group) { 669 if (strcasecmp('guest', $group) == 0) { 670 $guest_group = true; 671 break; 672 } 673 } 674 } 675 if($INFO['client'] == 'guest') $guest_user = true; 676} 677$CAPTCHA_HIDE = ""; 678if(($guest_user || $guest_group) && $guest_perm <= 2) $DW_EDIT_disabled = 'disabled'; 679global $USERINFO; 680if(($guest_user || $guest_group ||!$USERINFO) && $guest_perm < 4 && $this->captcha && $this->captcha->isEnabled()) $CAPTCHA_HIDE = 'display: none;'; 681$DW_EDIT_hide = $this->dw_edit_displayed(); 682 683$is_ckgdokuChrome = false; 684 if(stripos($_SERVER['HTTP_USER_AGENT'],'Chrome') !== false) { 685 preg_match("/Chrome\/(\d+)/", $_SERVER['HTTP_USER_AGENT'],$cmatch); 686 if((int)$cmatch[1] <26) $is_ckgdokuChrome =true; 687} 688 689?> 690 691 <div id="wiki__editbar"> 692 <div id="size__ctl" style="display: none"></div> 693 <?php if($wr){?> 694 <div class="editButtons"> 695 <input type="checkbox" name="ckgdoku" value="ckgdoku" checked="checked" style="display: none"/> 696 <input class="button" type="button" id = "save_button" 697 name="do[save]" 698 value="<?php echo $lang['btn_save']?>" 699 title="<?php echo $lang['btn_save']?> " 700 <?php echo $DW_EDIT_disabled; ?> 701 /> 702 703 <input class="button" id="ebtn__delete" type="submit" 704 <?php echo $DW_EDIT_disabled; ?> 705 name="do[delete]" value="<?php echo $lang['btn_delete']?>" 706 title="<?php echo $this->getLang('title_dw_delete') ?>" 707 style = "font-size: 100%; <?php echo $CAPTCHA_HIDE;?>" 708 /> 709 710 711 <?php if(!$is_ckgdokuChrome): ?> 712 <input class="button" id = "ebtn__dwedit" 713 <?php echo $DW_EDIT_disabled; ?> 714 <?php echo $DW_EDIT_hide; ?> 715 style = "font-size: 100%;<?php echo $CAPTCHA_HIDE;?>" 716 type="submit" 717 name="do[save]" 718 value="<?php echo $this->getLang('btn_dw_edit')?>" 719 title="<?php echo $this->getLang('title_dw_edit')?>" 720 /> 721 <?php endif; ?> 722 723 <?php if($this->getConf('allow_ckg_filebrowser') == 'all'): ?> 724 <input class="button" id="ebtn__fbswitch" 725 style="font-size: 100%;" 726 type="submit" 727 name="do[save]" 728 value="<?php echo $this->get_switch_fb_value() ?>" 729 title="<?php echo $this->get_switch_fb_title() ?>" 730 /> 731 <?php endif; ?> 732<?php 733global $INFO; 734 735 $disabled = 'Disabled'; 736 $inline = $this->test ? 'inline' : 'none'; 737 $chrome_dwedit_link = '<a href="'.wl($INFO['id'],array('do'=>'show')).'" ' . 'onclick="draft_delete();setDWEditCookie(2);"class="action edit" rel="nofollow" title="DW Edit"><span>DW Edit</span></a>'; 738 $backup_btn =$this->getLang('dw_btn_backup') ? $this->getLang('dw_btn_backup') : $this->getLang('dw_btn_refresh'); 739 $backup_title = $this->getLang('title_dw_backup') ? $this->getLang('title_dw_backup') : $this->getLang('title_dw_refresh'); 740 $using_scayt = ($this->getConf('scayt')) == 'on'; 741 742?> 743 <input class="button" type="submit" 744 name="do[draftdel]" 745 id = "ebut_cancel" 746 value="<?php echo $lang['btn_cancel']?>" 747 style = "font-size: 100%;" 748 title = "<?php echo $this->getLang('title_dw_cancel')?>" 749 /> 750 751 <!-- aspell button removed, not supported --> 752 753 <input class="button" type="button" value = "Test" 754 title="Test" 755 style = 'display:<?php echo $inline ?>;' 756 onmousedown="parse_wikitext('test');" 757 /> 758 759 <?php if($this->draft_found) { ?> 760 <input class="button" 761 style = "background-color: yellow" 762 id="ckgdoku_draft_btn" 763 type="button" value="<?php echo $this->getLang('btn_draft') ?>" 764 title="<?php echo $this->getLang('title_draft') ?>" 765 /> 766 <?php } else { ?> 767 768 769 <input class="button" type="button" 770 id = "backup_button" 771 value="<?php echo $backup_btn ?>" 772 title="<?php echo $backup_title ?>" 773 774 /> 775 776 <input class="button" type="button" 777 id = "revert_to_prev_btn" 778 value="<?php echo $this->getLang('dw_btn_revert')?>" 779 title="<?php echo $this->getLang('title_dw_revert')?>" 780 781 /> 782 <?php if(!$skip_styling) : ?> 783 <input class="button" type="submit" 784 name ="do[edit]" 785 id = "no_styling_btn" 786 style = "font-size: 100%;<?php echo $CAPTCHA_HIDE;?>" 787 value="<?php echo $this->getLang('dw_btn_styling')?>" 788 title="<?php echo $this->getLang('title_styling')?>" 789 /> 790 <?php endif ?> 791 792 793<?php 794if($is_ckgdokuChrome) echo $chrome_dwedit_link; 795?> 796 <br /> 797 798 <?php } ?> 799 800 <?php if($this->debug) { ?> 801 <input class="button" type="button" value = "Debug" 802 title="Debug" 803 onclick="HTMLParser_debug();" 804 /> 805 806 <br /> 807 <?php } ?> 808 809 <div id = "backup_msg" class="backup_msg" style=" display:none;"> 810 <table><tr><td class = "backup_msg_td"> 811 <div id="backup_msg_area" class="backup_msg_area"></div> 812 <td> 813 <td align="right"> 814 <a href="javascript:hide_backup_msg();void(0);" class="backup_msg_close">[ close ]</a> 815 </table> 816 817 </div> 818<?php 819 820if(!isset($_COOKIE['ckgEdPaste'])) { 821 $paste_value = 'on'; 822} 823else { 824 $paste_value = (isset($_COOKIE['ckgEdPaste']) && $_COOKIE['ckgEdPaste'] == 'off' ) ? 'on' : 'off'; 825} 826?> 827 828 <label class="nowrap" for="complex_tables" id="complex_tables_label"> 829 <input type="checkbox" name="complex_tables" value="complex_tables" id = "complex_tables" 830 /><span id='complex_tables_label_text'> <?php echo $this->getLang('complex_tables');?></span></label> 831 <label class="nowrap" for="editor_height"><?php echo $this->getLang('editor_height');?></label> 832 <input type="text" size= "4" name="editor_height" title = "<?php echo $this->getLang('editor_height_title'); ?>" value="<?php echo $height?>" id = "editor_height" onchange="setEdHeight(this.value);" /> px 833 <label class="nowrap" for="ckg_img_paste" title ="<?php echo $this->getLang('ckg_img_paste_title'); ?>"> <?php echo $this->getLang('ckg_img_paste') . " ". $this->getLang($paste_value) ?></label> 834 <input type="checkbox" name="ckg_img_paste" title = "<?php echo $this->getLang('ckg_img_paste_title'); ?>" 835 id = "ckg_img_paste" value = "<?php echo $paste_value?>" onchange=" ckgd_setImgPaste(this.value);" /> 836 837 <input style="display:none;" class="button" id="edbtn__save" type="submit" name="do[save]" 838 value="<?php echo $lang['btn_save']?>" 839 onmouseup="draft_delete();" 840 <?php echo $DW_EDIT_disabled; ?> 841 title="<?php echo $lang['btn_save']?> " /> 842 843 <!-- Not used by ckgdoku but required to prevent null error when DW adds events --> 844 <input type="button" id='edbtn__preview' style="display: none"/> 845 846 847 <div id='saved_wiki_html' style = 'display:none;' ></div> 848 <div id='ckgdoku_draft_html' style = 'display:none;' > 849 <?php echo $this->draft_text; ?> 850 </div> 851 852 </div> 853 <?php } ?> 854 855 <?php if($wr){ ?> 856 <div class="summary"> 857 <label for="edit__summary" class="nowrap"><?php echo $lang['summary']?>:</label> 858 <input type="text" class="edit" name="summary" id="edit__summary" size="50" value="<?php echo formText($SUM)?>" tabindex="2" /> 859 <label class="nowrap" for="minoredit"><input type="checkbox" id="minoredit" name="minor" value="1" tabindex="3" /> <span><?php echo $this->getLang('minor_changes') ?></span></label> 860 </div> 861 <?php }?> 862 <?php if($this->captcha && $this->captcha->isEnabled()) echo $this->captcha->getHTML(); ?> 863 </div> 864 </form> 865 866 <!-- draft messages from DW --> 867 <div id="draft__status"></div> 868 <script type="text/javascript"> 869//<![CDATA[ 870 <?php echo 'var backup_empty = "' . $this->getLang('backup_empty') .'";'; ?> 871 /* aspell_window removed, not supported */ 872 if(window.unsetDokuWikiLockTimer) window.unsetDokuWikiLockTimer(); 873 874 875 function getComplexTables() { 876 return document.getElementById('complex_tables').checked; 877 } 878 879 <?php global $useComplexTables; if($useComplexTables) { ?> 880 document.getElementById('complex_tables').click(); 881 <?php } ?> 882 <?php if($this->getConf('complex_tables')) { ?> 883 document.getElementById('complex_tables').disabled = true; 884 document.getElementById('complex_tables_label').style = "display:none"; 885 document.getElementById('complex_tables_label_text').style = "display:none"; 886 <?php } ?> 887 888<?php 889 890 891 if(preg_match("/MISIE|Trident/",$_SERVER['HTTP_USER_AGENT'])) { 892 echo "var isIE = true;"; 893 } 894 else { 895 echo "var isIE = false;"; 896 } 897 898 echo "var doku_base = '" . DOKU_BASE ."'"; 899 900?> 901 902 var ckgdoku_draft_btn = "<?php echo $this->getLang('btn_exit_draft') ?>"; 903 var ckgdoku_draft_btn_title = "<?php echo $this->getLang('title_exit_draft')?>"; 904 function ckgdoku_get_draft() { 905 var dom = GetE('ckgdoku_draft_html'); 906 var draft = dom.innerHTML; 907 var dw_text = CKEDITOR.instances.wiki__text.getData(); 908 909 CKEDITOR.instances.wiki__text.setData(draft); 910 dom.innerHTML = dw_text; 911 var btn = GetE('ckgdoku_draft_btn'); 912 var tmp = btn.value; 913 btn.value = ckgdoku_draft_btn; 914 ckgdoku_draft_btn = tmp; 915 tmp = ckgdoku_draft_btn_title; 916 btn.title = ckgdoku_draft_btn_title; 917 ckgdoku_draft_btn_title = tmp; 918 } 919 920 921 function safe_convert(value) { 922 923 if(oDokuWiki_FCKEditorInstance.dwiki_fnencode && oDokuWiki_FCKEditorInstance.dwiki_fnencode == 'safe') { 924 <?php 925 global $updateVersion; 926 if(!isset($updateVersion)) $updateVersion = 0; 927 echo "updateVersion=$updateVersion;"; 928 $list = plugin_list('action'); 929 $safe_converted = false; 930 if(in_array( 'safefnrecode' , $list)) { 931 $safe_converted = true; 932 } 933 934 ?> 935 936 if(value.match(/%25/ && value.match(/%25[a-z0-9]/))) { 937 value = value.replace(/%25/g,"%"); 938 <?php 939 if($updateVersion > 30 || $safe_converted) { 940 echo 'value = value.replace(/%5D/g,"]");'; 941 } 942 ?> 943 944 value = dwikiUTF8_decodeFN(value,'safe'); 945 } 946 } 947 return value; 948 949 } 950 951RegExp.escape = function(str) 952{ 953 var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g"); // .*+?|()[]{}\ 954 return str.replace(specials, "\\$&"); 955} 956var ckgdoku_xcl_fonts =parseInt ("<?php echo $this->getConf('font_options') ;?>"); 957var ckgdoku_xcl_colors =parseInt("<?php echo $this->getConf('color_options') ;?>"); 958var ckgdoku_xcl_styles = (ckgdoku_xcl_fonts + ckgdoku_xcl_colors ==2) ? true : false; 959var HTMLParser_DEBUG = ""; 960var ckgdoku_hasCaptcha = "<?php echo $this->captcha?1:0?>"; 961 962<?php if($this->debug) { ?> 963 function HTMLParser_debug() { 964 HTMLParser_DEBUG = ""; 965 parse_wikitext(""); 966/* 967 for(var i in oDokuWiki_FCKEditorInstance) { 968 HTMLParser_DEBUG += i + ' = ' + oDokuWiki_FCKEditorInstance[i] + "\n";; 969 } 970*/ 971 972 var w = window.open(); 973 w.document.write('<pre>' + HTMLParser_DEBUG + '</pre>'); 974 w.document.close(); 975 } 976<?php } ?> 977 978<?php 979 $url = DOKU_URL . 'lib/plugins/ckgdoku/scripts/script-cmpr.js'; 980 echo "var script_url = '$url';"; 981 if($this->test) { 982 $nval = substr(md5(time), -20); 983 $parse_url = DOKU_URL . 'lib/plugins/ckgdoku/scripts/parse_wiki.js.unc?n=' . $nval; 984 } 985 else $parse_url = DOKU_URL . 'lib/plugins/ckgdoku/scripts/parse_wiki-cmpr.js'; 986 987 echo "var parse_url = '$parse_url';"; 988// $safe_url = DOKU_URL . 'lib/plugins/ckgdoku/scripts/safeFN_cmpr.js'; 989?> 990 991 <?php 992 global $conf; 993 994 if(isset($conf['animal'])) { 995 echo "var config_animal='" . $conf['animal'] . "';"; 996 } 997 ?> 998 999LoadScript(parse_url); 1000try { 1001 if(!window.HTMLParserInstalled){ 1002 LoadScript(script_url); 1003 } 1004} 1005catch (ex) { 1006 LoadScript(script_url); 1007} 1008 1009 1010if(window.DWikifnEncode && window.DWikifnEncode == 'safe') { 1011 LoadScript(DOKU_BASE + 'lib/plugins/ckgdoku/scripts/safeFN_cmpr.js' ); 1012} 1013 1014 1015 //]]> 1016 1017 </script> 1018 1019 1020 1021<?php 1022 } 1023 1024 /** 1025 * Renders a list of instruction to minimal xhtml 1026 *@author Myron Turner <turnermm02@shaw.ca> 1027 */ 1028 function _render_xhtml($text){ 1029 $mode = 'ckgdoku'; 1030 1031 global $skip_styling; 1032 $skip_styling = $this->getConf('nofont_styling'); 1033 if(!$skip_styling && $_POST['styling'] == 'no_styles') { 1034 $skip_styling = true; 1035 } 1036 1037 if(strpos($text,'~~NO_STYLING~~') !== false) { 1038 $skip_styling = true; 1039 } 1040 1041 $text = preg_replace_callback('/\[\[(.*?>)(.*?)\]\]/ms', 1042 function ($matches) { 1043 if(strpos($matches[0],"\n") !== false) return $matches[0]; 1044 if(preg_match("#<(\w+)>.*?<\/\\1>#",$matches[0])) return $matches[0]; 1045 list($name,$link_text) = explode('|',$matches[2]); 1046 $retv = '[[' . $matches[1] . "oIWIKIo" . $name ."cIWIKIc"; 1047 if(!empty($link_text)) { 1048 $retv .= "|$link_text"; 1049 } 1050 return $retv . ']]'; 1051 }, 1052 $text); 1053 1054 // try default renderer first: 1055 $file = DOKU_INC."inc/parser/$mode.php"; 1056 1057 if(@file_exists($file)){ 1058 1059 require_once $file; 1060 $rclass = "Doku_Renderer_$mode"; 1061 1062 if ( !class_exists($rclass) ) { 1063 trigger_error("Unable to resolve render class $rclass",E_USER_WARNING); 1064 msg("Renderer for $mode not valid",-1); 1065 return null; 1066 } 1067 $Renderer = new $rclass(); 1068 } 1069 else{ 1070 // Maybe a plugin is available? 1071 $Renderer = plugin_load('renderer',$mode); 1072 if(is_null($Renderer)){ 1073 msg("No renderer for $mode found",-1); 1074 return null; 1075 } 1076 } 1077// aimed at wrap plugin which allows multiple newlines in a cell 1078$text = preg_replace_callback( 1079 '#(\|.*?)\|.?[\n\r]#ms', 1080 function ($matches) { 1081 $matches[0] = preg_replace("#\\\\\\\\\s*[\r\n]#ms", " \\\\\\\\ ",$matches[0]); 1082 return ($matches[0]); 1083 }, 1084 $text); 1085 1086 // prevents utf8 conversions of quotation marks 1087 $text = str_replace('"',"_ckgdoku_QUOT_",$text); 1088 1089 $text = preg_replace_callback('/(<code.*?>)([^<]+)(<\/code>)/ms', 1090 create_function( 1091 '$matches', 1092 '$quot = str_replace("_ckgdoku_QUOT_",\'"\',$matches[2]); 1093 $quot = str_replace("\\\\ ","_ckgdoku_NL",$quot); 1094 $quot .= "_ckgdoku_NL"; 1095 return $matches[1] . $quot . $matches[3];' 1096 ), $text); 1097 1098 $text = preg_replace_callback('/(<file.*?>)([^<]+)(<\/file>)/ms', 1099 create_function( 1100 '$matches', 1101 '$quot = str_replace("_ckgdoku_QUOT_",\'"\',$matches[2]); 1102 $quot = str_replace("\\\\ ","_ckgdoku_NL",$quot); 1103 $quot .= "_ckgdoku_NL"; 1104 return $matches[1] . $quot . $matches[3];' 1105 ), $text); 1106 1107 1108 $text = preg_replace_callback('/(<code>|<file>)([^<]+)(<\/code>|<\/file>)/ms', 1109 create_function( 1110 '$matches', 1111 '$matches[2] = str_replace("<font","ckgdokuFONTOpen",$matches[2]); 1112 $matches[2] = str_replace("font>","ckgdokuFONTClose",$matches[2]); 1113 return $matches[1] .$matches[2] . $matches[3]; ' 1114 ), $text); 1115 1116 $instructions = p_get_instructions("=== header ==="); // loads DOKU_PLUGINS array --M.T. Dec 22 2009 1117 1118 $instructions = p_get_instructions($text); 1119 if(is_null($instructions)) return ''; 1120 1121 $Renderer->notoc(); 1122 if(!$this->getConf('smiley_as_text')) { 1123 $Renderer->smileys = getSmileys(); 1124 } 1125 $Renderer->entities = getEntities(); 1126 $Renderer->acronyms = array(); 1127 $Renderer->interwiki = getInterwiki(); 1128 1129 // Loop through the instructions 1130 /* 1131 By-passing plugin processing was sugested and first implemented 1132 by Matti Lattu<matti.lattu@iki.fi> 1133 It is a significant contribution to the functionality of ckgEdit 1134 */ 1135 foreach ( $instructions as $instruction ) { 1136 if ($instruction[0] == 'plugin') { 1137 $Renderer->doc .= $instruction[1][3]; 1138 } else { 1139 // Execute the callback against the Renderer 1140 call_user_func_array(array(&$Renderer, $instruction[0]),$instruction[1]); 1141 } 1142 } 1143 1144 //set info array 1145 $info = $Renderer->info; 1146 1147 // Post process and return the output 1148 $data = array($mode,& $Renderer->doc); 1149 trigger_event('RENDERER_CONTENT_POSTPROCESS',$data); 1150 $xhtml = $Renderer->doc; 1151 if(!$skip_styling) { // create font styles from font plugin markup for html display 1152 $xhtml = preg_replace_callback( 1153 '|&lt;font\s+(.*?)/([\w ,\-]+);;([\(\)),\w,\s\#]+);;([\(\)),\w,\s\#]+)>(.*?)&lt;/font>|ms', 1154 function($matches) { 1155 $count = 0; $str=''; 1156 if($matches[3] && $matches[3] != 'inherit') { $str .= '<span style = "color:' . $matches[3] .'">'; $count++;} 1157 if($matches[1] && $matches[1] != 'inherit') { $str .= '<span style = "font-size:' . $matches[1] .'">'; $count++; } 1158 if($matches[2] && $matches[2] != 'inherit') { $str .= '<span style = "font-family:' . $matches[1] .'">'; $count++; } 1159 if($matches[4] && $matches[4] != 'inherit') { $str .= '<span style = "background-color:' . $matches[4] .'">'; $count++; } 1160 $str .= $matches[5]; 1161 for($i =0; $i<$count; $i++) { 1162 $str .= '</span>'; 1163 } 1164 return $str; 1165 }, $xhtml 1166 ); 1167 } 1168 1169 /** 1170 * Alternative to the one liner at 1179: $xhtml = str_replace(array('oiwikio','ciwikic'),array('oIWIKIo','cIWIKIc'),$xhtml); 1171 * if it turns out that there are users using 'oiwikio','ciwikic' 1172 $xhtml = preg_replace_callback( 1173 '|class=\"interwiki.*?href=\".*?:oiwikiotowerciwikic\".*?title=\".*?oiwikiotowerciwikic\"|ms', 1174 function($matches) { 1175 $matches[0] = str_replace(array('oiwikio','ciwikic'),array('oIWIKIo','cIWIKIc'),$matches[0]); 1176 return $matches[0]; 1177 },$xhtml 1178 ); 1179 */ 1180 if(stripos($xhtml,'oIWIKIo') !== false) { 1181 $xhtml = str_replace(array('oiwikio','ciwikic'),array('oIWIKIo','cIWIKIc'),$xhtml); 1182 $xhtml = preg_replace_callback( 1183 '/<?(.*?)oIWIKIo(.*?)cIWIKIc/ms', 1184 create_function( 1185 '$matches', 1186 ' if(preg_match("/^\w+$/",$matches[2]) && $matches[1] == "/") return "/". $matches[2]; 1187 return $matches[0];' 1188 ), 1189 $xhtml 1190 ); 1191 $xhtml = preg_replace_callback( 1192 '/>oIWIKIo(.*?)cIWIKIc(?=<\/a>)/ms', 1193 create_function( 1194 '$matches', 1195 ' return ">". $matches[1] ;' 1196 ), 1197 $xhtml 1198 ); 1199 1200 } 1201 1202 $pos = strpos($xhtml, 'MULTI_PLUGIN_OPEN'); 1203 if($pos !== false) { 1204 $xhtml = preg_replace_callback( 1205 '|MULTI_PLUGIN_OPEN.*?MULTI_PLUGIN_CLOSE|ms', 1206 create_function( 1207 '$matches', 1208 '$matches[0] = str_replace("//<//", "< ",$matches[0]); 1209 $matches[0] = str_replace(array("oIWIKIo","cIWIKIc"),"",$matches[0]); 1210 return preg_replace("/\n/ms","<br />",$matches[0]);' 1211 ), 1212 $xhtml 1213 ); 1214 1215 $xhtml = preg_replace('/~\s*~\s*MULTI_PLUGIN_OPEN~\s*~/', "\n\n~~MULTI_PLUGIN_OPEN~~<span class='multi_p_open'>\n\n</span>\n\n", $xhtml); 1216 $xhtml = preg_replace('/~\s*~\s*MULTI_PLUGIN_CLOSE~\s*~/', "<span class='multi_p_close'>\n\n<br /></span>\n\n~~MULTI_PLUGIN_CLOSE~~\n\n", $xhtml); 1217 1218 } 1219 1220 1221 // remove empty paragraph: see _ckgdoku_NPBBR_ comment above 1222 $xhtml = preg_replace('/<p>\s+_ckgdoku_NPBBR_\s+<\/p>/ms',"\n",$xhtml); 1223 $xhtml = str_replace('_ckgdoku_NPBBR_', "<span class='np_break'> </span>", $xhtml); 1224 $xhtml = str_replace('_ckgdoku_QUOT_', '"', $xhtml); 1225 $xhtml = str_replace('_ckgdoku_NL', "\n", $xhtml); 1226 $xhtml = str_replace('</pre>', "\n\n</pre><p> </p>", $xhtml); 1227 // inserts p before an initial codeblock to enable text entry above block 1228 $xhtml = preg_replace('/^<pre/',"<p> </p><pre",$xhtml); 1229 //remove empty markup remaining after removing marked-up acronyms in lists 1230 $xhtml = preg_replace('/<(em|b|u|i)>\s+<\/(em|b|u|i)>/ms',"",$xhtml); 1231 $xhtml = preg_replace("/col\d+\s+(\w+align)/ms", "$1",$xhtml); //remove col number for cell prpoerties dialog 1232 $xhtml = str_replace('ckgdokuFONTOpen', '&lt;font',$xhtml); // protect font markup in code blocks 1233 $xhtml = str_replace('ckgdokuFONTClose', 'font&gt;',$xhtml); 1234 $xhtml = str_replace('DBLBACKSPLASH', '\\ ',$xhtml); 1235 $xhtml = str_replace('NWPIPECHARACTER', '|',$xhtml); 1236 1237 $ua = strtolower ($_SERVER['HTTP_USER_AGENT']); 1238 if(strpos($ua,'chrome') !== false) { 1239 $xhtml = preg_replace_callback( 1240 '/(?<=<a )(href=\".*?\")(\s+\w+=\".*?\")(.*?)(?=>)/sm', 1241 create_function( 1242 '$matches', 1243 '$ret_str = " " . trim($matches[3]) . " " . trim($matches[2]) . " " . trim($matches[1]) ; 1244 return $ret_str;' 1245 ), 1246 $xhtml 1247 ); 1248 } 1249 1250 return $xhtml; 1251 } 1252 1253 function write_debug($what) { 1254 return; 1255 $handle = fopen("ckgdoku_php.txt", "a"); 1256 // if(is_array($what)) $what = print_r($what,true); 1257 fwrite($handle,"$what\n"); 1258 fclose($handle); 1259 } 1260 1261 function get_switch_fb_value() { 1262 if ($this->getUserFb() == 'dokuwiki') { 1263 $fbText = $this->getLang('btn_val_ckg_fb'); 1264 } else { 1265 $fbText = $this->getLang('btn_val_dw_fb'); 1266 } 1267 return $fbText; 1268 } 1269 1270 function get_switch_fb_title() { 1271 if ($this->getUserFb() == 'dokuwiki') { 1272 $fbText = $this->getLang('btn_title_ckg_fb'); 1273 } else { 1274 $fbText = $this->getLang('btn_title_dw_fb'); 1275 } 1276 return $fbText; 1277 } 1278 1279 function getUserFb() { 1280 //get user file browser 1281 if (!isset($_COOKIE['ckgFbOpt'])) { 1282 $_COOKIE['ckgFbOpt'] = $this->getConf('default_ckg_filebrowser'); 1283 } 1284 return $_COOKIE['ckgFbOpt']; 1285 } 1286 1287} //end of action class 1288 1289?> 1290