*/ class action_plugin_ckgdoku_edit extends DokuWiki_Action_Plugin { var $fck_location = "ckeditor"; var $helper = false; var $ckgdoku_bak_file = ""; var $debug = false; var $test = false; var $page_from_template; var $draft_found = false; var $draft_text; var $draft_started; var $captcha; /** * Constructor */ function __construct() { $this->setupLocale(); $this->helper = plugin_load('helper', 'ckgdoku'); if(!plugin_isdisabled('captcha')) { $this->captcha = plugin_load('helper', 'captcha'); If(!$this->captcha) $this->captcha = false; } else $this->captcha = false; } function register(Doku_Event_Handler $controller) { $version = explode('.', phpversion()); define('PHP_VERSION_NUM', $version[0] * 10+ $version[1]); if($this->helper->is_outOfScope()) return; global $FCKG_show_preview; $FCKG_show_preview = true; if(isset($_REQUEST['mode']) && $_REQUEST['mode'] == 'dwiki') { $FCKG_show_preview = true; return; } elseif(isset($_COOKIE['FCKG_USE'])) { preg_match('/_\w+_/', $_COOKIE['FCKG_USE'], $matches); if($matches[0] == '_false_') { $FCKG_show_preview = true; return; } } $Fck_NmSp = "!!NONSET!!"; if(isset($_COOKIE['FCK_NmSp'])) { $Fck_NmSp = $_COOKIE['FCK_NmSp']; } $dwedit_ns = @$this->getConf('dwedit_ns'); if(isset($dwedit_ns) && $dwedit_ns) { $ns_choices = explode(',',$dwedit_ns); foreach($ns_choices as $ns) { $ns = trim($ns); if(preg_match("/$ns/",$_REQUEST['id']) || preg_match("/$ns/",$Fck_NmSp)) { $FCKG_show_preview = true; return; } } } $controller->register_hook('COMMON_PAGE_FROMTEMPLATE', 'AFTER', $this, 'pagefromtemplate', array()); $controller->register_hook('COMMON_PAGETPL_LOAD', 'AFTER', $this, 'pagefromtemplate', array()); $controller->register_hook('TPL_ACT_RENDER', 'BEFORE', $this, 'ckgdoku_edit'); $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'ckgdoku_edit_meta'); } /** * function pagefromtemplate * Capture template text output by Template Event handler instead of pageTemplate() * @author Myron Turner * */ function pagefromtemplate(Doku_Event $event) { if($event->data['tpl']) { $this->page_from_template = $event->data['tpl']; } } /** * ckgdoku_edit_meta * * load fck js * @author Pierre Spring * @author Myron Turner * @param mixed $event * @access public * @return void */ function ckgdoku_edit_meta(Doku_Event $event) { global $ACT; // we only change the edit behaviour if ($ACT != 'edit'){ return; } global $ID; global $REV; global $INFO; $event->data['script'][] = array( 'type'=>'text/javascript', 'charset'=>'utf-8', '_data'=>'', 'src'=>DOKU_BASE.'lib/plugins/ckgdoku/' .$this->fck_location. '/ckeditor.js' ); $ua = strtolower ($_SERVER['HTTP_USER_AGENT']); if(strpos($ua, 'msie') !== false) { echo "\n" . '' ."\n"; } return; } /** * function ckgdoku_edit * @author Pierre Spring * edit screen using fck * * @param & $event * @access public * @return void */ function ckgdoku_edit(Doku_Event $event) { global $INFO; // we only change the edit behaviour if ($event->data != 'edit') { return; } // load xml and acl if (!$this->_preprocess()){ return; } // print out the edit screen $this->_print(); // prevent Dokuwiki normal processing of $ACT (it would clean the variable and destroy our 'index' value. $event->preventDefault(); // index command belongs to us, there is no need to hold up Dokuwiki letting other plugins see if its for them $event->stopPropagation(); } /** * function _preprocess * @author Myron Turner */ function _preprocess($draft_text = "") { global $ID; global $REV; global $DATE; global $RANGE; global $PRE; global $SUF; global $INFO; global $SUM; global $lang; global $conf; global $ckgdoku_lang; //set summary default if(!$SUM){ if($REV){ $SUM = $lang['restored']; }elseif(!$INFO['exists']){ $SUM = $lang['created']; } } if(!$draft_text) { if($INFO['exists']){ if($RANGE){ list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV); }else{ $text = rawWiki($ID,$REV); } }else{ //try to load a pagetemplate $text = pageTemplate($ID); //Check for text from template event handler if(!$text && $this->page_from_template) $text = $this->page_from_template; } } else $text = $draft_text; $text = preg_replace_callback( '/(~~NOCACHE~~|~~NOTOC~~|\{\{rss>http:\/\/.*?\}\})/ms', create_function( '$matches', '$matches[0] = str_replace("{{rss>http://www.", "{ { rss>FEED", $matches[0]); $matches[0] = str_replace("{{rss>http://", "{ { rss>Feed:", $matches[0]); $matches[0] = str_replace("~", "~ ", $matches[0]); return $matches[0];' ),$text); if($this->getConf('smiley_hack')) { $new_addr = $_SERVER['SERVER_NAME'] . DOKU_BASE; $text=preg_replace("#(?<=http://)(.*?)(?=lib/plugins/ckgdoku/ckeditor/plugins/smiley/images)#s", $new_addr,$text); } $text = preg_replace_callback('/\[\[\w+>.*?\]\]/ms', create_function( '$matches', 'return str_replace("/", "__IWIKI_FSLASH__" ,$matches[0]);' ), $text); global $useComplexTables; if($this->getConf('complex_tables') || strrpos($text, '~~COMPLEX_TABLES~~') !== false) { $useComplexTables=true; } else { $useComplexTables=false; } if(strpos($text, '%%') !== false || strpos($text, '\\\\') !== false || strpos($text, '|') !== false ) { $text = preg_replace('/%%\s*\s*%%/ms', 'PERCNWPERC',$text); $text = preg_replace('/%%\s*<(code|file)>\s*%%/ms', 'PERC' . "$1" . 'PERC',$text); $text = preg_replace_callback( "/<(nowiki|code|file)>(.*?)<\/(nowiki|code|file)/ms", function ($matches) { $matches[0] = str_replace('%%', 'DBLPERCENT',$matches[0]); $matches[0] = str_replace('\\ ', 'DBLBACKSPLASH',$matches[0]); $matches[0] = str_replace('|', 'NWPIPECHARACTER',$matches[0]); return $matches[0]; }, $text ); $text = preg_replace_callback( "/(?)%%(.*?)%%/ms", function($matches) { return '' . $matches[1] . ''; }, $text ); $text = str_replace('DBLPERCENT','%%',$text); } $pos = strpos($text, '<'); if($pos !== false) { /* skipentity support */ $text = preg_replace_callback( '/``(.*?)``/ms', function($matches) { $needles = array('[',']', '/', '.', '*', '_','\'','<','>','%', '{', '}', '\\' , '(' ); $replacements = array('[',']','/', '.', '*', '_', ''', '<','>','%', '{','}', '\','('); $matches[1] = str_replace($needles, $replacements, $matches[1]); return '``' .$matches[1] .'``' ; }, $text ); $text = preg_replace_callback( '/()(.*?)(<\/nowiki>)/ms', create_function( '$matches', '$needles = array("[","]", "/", ".", "*", "_","\'","<",">","%", "{", "}", "\\\","("); $replacements = array("[","]","/", ".", "*", "_", "'", "<",">","%", "{","}", "\","("); $matches[2] = str_replace($needles, $replacements, $matches[2]); return $matches[1] . $matches[2] . $matches[3];' ), $text ); $text = preg_replace_callback( '/<(code|file)(.*?)(>)(.*?)(<\/\1>)/ms', create_function( '$matches', ' //file_put_contents("geshi.txt", print_r($matches,true)); if(preg_match("/(^\s*geshi:\s*(\w+)(\s+\w+\.\w+)*\s*)$/m",$matches[0],$gmatch)){ $gmatch[0] = preg_replace("/\s*geshi:\s+/","",$gmatch[0]); $matches[1] .= " " . trim($gmatch[0]); //file_put_contents("gmatch.txt", print_r($gmatch,true)); $c=1; $matches[4] = str_replace($gmatch[1],"",$matches[4],$c); } if(preg_match("/\w+/",$matches[2])) { $matches[4] = str_replace("CHEVRONescC", ">>",$matches[4]); $matches[4] = str_replace("CHEVRONescO", "<<",$matches[4]); $matches[4] = preg_replace("/<(?!\s)/ms", "__GESHI_OPEN__", $matches[4]); } else { if( preg_match("/MULTI/",$matches[0])) { $open = "< "; $close = " >"; } else { $open = "<"; $close = ">"; } $matches[4] = preg_replace("/<(?!\s)/ms", $open, $matches[4]); $matches[4] = preg_replace("/(?/ms", $close, $matches[4]); } $matches[4] = str_replace("\"", "__GESHI_QUOT__", $matches[4]); return "<" . $matches[1] . $matches[2] . $matches[3] . $matches[4] . $matches[5];' ), $text ); $text = preg_replace_callback( '/~~START_HTML_BLOCK~~.*?CLOSE_HTML_BLOCK/ms', create_function( '$matches', '$matches[0] = str_replace("_ckgdoku_NPBBR_","",$matches[0]); return $matches[0];' ),$text); $text = preg_replace_callback( '/(\|\s*)(|)(.*?)(<\/code>|<\/file>)\n_ckgdoku_NPBBR_(?=.*?\|)/ms', create_function( '$matches', '$matches[2] = preg_replace("//ms", "TPRE_CODE", $matches[2]); $matches[2] = preg_replace("//ms", "TPRE_FILE", $matches[2]); $matches[4] = "TPRE_CLOSE"; $matches[3] = preg_replace("/^\n+/", "TC_NL",$matches[3]); $matches[3] = preg_replace("/\n/ms", "TC_NL",$matches[3]); return $matches[1] . $matches[2] . trim($matches[3]) . $matches[4];' ), $text ); $text = preg_replace('/TPRE_CLOSE\s+/ms',"TPRE_CLOSE",$text); $text = preg_replace('/<(?!code|file|del|sup|sub|\/\/|\s|\/del|\/code|\/file|\/sup|\/sub)/ms',"<",$text); $text = str_replace('%%<', '%%<', $text); } if($this->getConf('duplicate_notes')) { $text = preg_replace_callback('/\(\((.*?)\)\)/ms', create_function( '$matches', 'static $count = 0; $count++; $ins = "FNoteINSert" . $count; $needles = array("[","]", "/", ".", "*", "_","\'","<",">","%", "{", "}", "\\\","("); $replacements = array("[","]","/", ".", "*", "_", "'", "<",">","%", "{","}", "\","("); $matches[1] = str_replace($needles, $replacements, $matches[1]); return "(($ins" . $matches[1] . "))" ;' ), $text ); } $text = preg_replace('/^\>/ms',"_QUOT_",$text); // dw quotes $text = str_replace('>>','CHEVRONescC',$text); $text = str_replace('<<','CHEVRONescO',$text); $text = preg_replace('/(={3,}.*?)(\{\{.*?\}\})(.*?={3,})/',"$1$3\n$2",$text); $email_regex = '/\/\/\<\/\/(.*?@.*?)>/'; $text = preg_replace($email_regex,"<$1>",$text); $text = preg_replace('/{{(.*)\.swf(\s*)}}/ms',"__SWF__$1.swf$2__FWS__",$text); $text = preg_replace('/PERCNWPERC/ms', '%%< nowiki >%%',$text); //$text = preg_replace('/%%\s*<(code|file)>\s*%%/ms', 'PERC' . "$1" . 'PERC',$text); $text = preg_replace('/PERCcodePERC/ms','%%<code>%%', $text); $text = preg_replace('/PERCfilePERC/ms','%%<file>%%', $text); $divalign = false; if($this->helper->has_plugin('divalign2') ||$this->helper->has_plugin('divalign2_center')) { $divalign = true; $text = preg_replace_callback('/\n([;#]{3})/', function ($matches) { return "divalNLine" . str_replace('#','CGEHASH',$matches[1]); }, $text ); } $this->xhtml = $this->_render_xhtml($text); $this->xhtml = str_replace("__IWIKI_FSLASH__", "⁄", $this->xhtml); if($this->getConf('duplicate_notes')) { $this->xhtml = preg_replace("/FNoteINSert\d+/ms", "",$this->xhtml); } if($divalign) { $this->xhtml = str_replace("CGEHASH", "#", $this->xhtml); } $this->xhtml = str_replace("__GESHI_QUOT__", '"', $this->xhtml); $this->xhtml = str_replace("__GESHI_OPEN__", "< ", $this->xhtml); $this->xhtml = str_replace('CHEVRONescC', '>>',$this->xhtml); $this->xhtml = str_replace('CHEVRONescO', '<<',$this->xhtml); $this->xhtml = preg_replace('/_QUOT_/ms','>',$this->xhtml); // dw quotes $this->xhtml = str_replace("rss>FEED", "rss>Feed:www.",$this->xhtml); $this->xhtml = preg_replace_callback( "/^(>+)(.*?)$/ms", function($matches) { $matches[2] = str_ireplace('
',"",$matches[2]); return $matches[1] . $matches[2] . "
"; }, $this->xhtml ); if($pos !== false) { $this->xhtml = preg_replace_callback( '/(TPRE_CODE|TPRE_FILE)(.*?)(TPRE_CLOSE)/ms', create_function( '$matches', '$matches[1] = preg_replace("/TPRE_CODE/","
\n", $matches[1]);  
                    $matches[1] = preg_replace("/TPRE_FILE/","
\n", $matches[1]);  
                    $matches[2] = preg_replace("/TC_NL/ms", "\n", $matches[2]);  
                    $matches[3] = "
"; return $matches[1] . $matches[2] . $matches[3];' ), $this->xhtml ); } $this->xhtml = preg_replace_callback( '/~~START_HTML_BLOCK~~[\n\s]*(.*?)CLOSE_HTML_BLOCK/ms', create_function( '$matches', '$matches[1] = str_replace("&","&",$matches[1]); $matches[1] = html_entity_decode($matches[1],ENT_QUOTES, "UTF-8"); $matches[1] = preg_replace("/<\/?code.*?>/", "",$matches[1]); $matches[1] = preg_replace("/^\s*<\/p>/","",$matches[1]); $tmp = explode("\n", $matches[1]); for($n=0; $n<7; $n++) { if( (preg_match("/(

\s*)*( |\s+)<\/p>/",$tmp[$n])) || (preg_match("/^\s+$/",$tmp[$n]))) { unset($tmp[$n]); } } return "~~START_HTML_BLOCK~~" . implode("\n",$tmp) . "CLOSE_HTML_BLOCK"; ' ),$this->xhtml); $this->xhtml = preg_replace_callback( '/()(.*?)(<\/pre>)/ms', create_function( '$matches', '$matches[4] = preg_replace("/(\||\^)[ ]+(\||\^)/ms","$1   $2" , $matches[4]); return $matches[1] . $matches[2] . $matches[3] . $matches[4] . $matches[5];' ), $this->xhtml ); $this->xhtml = preg_replace_callback( '/~~MULTI_PLUGIN_OPEN~~(.*?)~~MULTI_PLUGIN_CLOSE~~/ms', create_function( '$matches', 'return str_replace("<", "< ",$matches[0]);' ), $this->xhtml ); if($this->draft_started) return $this->xhtml; $cname = getCacheName($INFO['client'].$ID,'.draft.fckl'); $this->draft_started = false; if(file_exists($cname) && !$this->draft_started) { $this->draft_started = true; $cdata = unserialize(io_readFile($cname,false)); $prefix = isset($cdata['prefix']) ? urldecode($cdata['prefix']) : "" ; if($prefix) $prefix = $this-> _preprocess($prefix); $text = urldecode($cdata['text']); $suffix = isset($cdata['suffix']) ? urldecode($cdata['suffix']) : "" ; if($suffix) $suffix = $this-> _preprocess($suffix); preg_match_all("/<\/(.*?)\>/", $cdata['text'],$matches); /* exclude drafts saved from preview mode */ if (!in_array('code', $matches[1]) && !in_array('file', $matches[1]) && !in_array('nowiki', $matches[1])) { //$this->draft_text = $cdata['text']; $this->draft_text = $prefix . $text . $suffix; $this->draft_found = true; msg($this->getLang('draft_msg')) ; } unlink($cname); } if($draft_started) return $this->xhtml; return true; } /** * function dw_edit_displayed * @author Myron Turner * determines whether or not to show or hide the * 'DW Edit' button */ function dw_edit_displayed() { global $INFO; $dw_edit_display = @$this->getConf('dw_edit_display'); if(!isset($dw_edit_display))return ""; //version 0. if($dw_edit_display != 'all') { $admin_exclusion = false; if($dw_edit_display == 'admin' && ($INFO['isadmin'] || $INFO['ismanager']) ) { $admin_exclusion = true; } if($dw_edit_display == 'none' || $admin_exclusion === false) { return ' style = "display:none"; '; } return ""; } return ""; } /** * function _print * @author Myron Turner */ function _print() { global $INFO; global $lang; global $ckgdoku_lang; global $ID; global $REV; global $DATE; global $PRE; global $SUF; global $SUM; $wr = $INFO['writable']; if($wr){ if ($REV) print p_locale_xhtml('editrev'); $ro=false; }else{ // check pseudo action 'source' if(!actionOK('source')){ msg('Command disabled: source',-1); return false; } print p_locale_xhtml('read'); $ro='readonly="readonly"'; } if(!$DATE) $DATE = $INFO['lastmod']; $guest_toolbar = $this->getConf('guest_toolbar'); $guest_media = $this->getConf('guest_media'); if(!isset($INFO['userinfo']) && !$guest_toolbar) { $toolbar = "DokuwikiNoGuest"; } else if(!isset($INFO['userinfo']) && !$guest_media) { $toolbar = "DokuwikiGuest"; } else $toolbar = 'Dokuwiki'; $height = isset($_COOKIE['ckgEdht']) && $_COOKIE['ckgEdht'] ? $_COOKIE['ckgEdht']: 250; if(!is_numeric($height)) $height = 250; $fbsz_increment = isset($_COOKIE['fbsz']) && $_COOKIE['fbsz'] ? $_COOKIE['fbsz'] : false; $fbrowser_width = 1070; $fbrowser_height = 660; if($fbsz_increment) { $fbrowser_width = $fbrowser_width + ($fbrowser_width*($fbsz_increment/100)); $fbrowser_height =$fbrowser_height + ($fbrowser_height*($fbsz_increment/100)); } $doku_url= rtrim(DOKU_URL,'/'); $ns = getNS($_COOKIE['FCK_NmSp']); //get user file browser if allowed if ($this->getConf('allow_ckg_filebrowser') == 'all') { $fb = $this->getUserFb(); } else { //use only allowed file browser $fb = $this->getConf('allow_ckg_filebrowser'); } //setup options if ($fb == 'dokuwiki') { $fbOptions = "filebrowserImageBrowseUrl: \"$doku_url/lib/exe/mediamanager.php?ns=$ns&edid=wiki__text&onselect=ckg_edit_mediaman_insert&ckg_media=img\", filebrowserBrowseUrl: \"$doku_url/lib/exe/mediamanager.php?ns=$ns&edid=wiki__text&onselect=ckg_edit_mediaman_insertlink&ckg_media=link\""; } else { $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\", 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\""; } $ckeditor_replace =<<helper->registerOnLoad($ckeditor_replace); global $skip_styling; ?> page_from_template) { $ckg_template = 'tpl'; } else $ckg_template =""; ?>

captcha && $this->captcha->isEnabled()) $CAPTCHA_HIDE = 'display: none;'; $DW_EDIT_hide = $this->dw_edit_displayed(); $is_ckgdokuChrome = false; if(stripos($_SERVER['HTTP_USER_AGENT'],'Chrome') !== false) { preg_match("/Chrome\/(\d+)/", $_SERVER['HTTP_USER_AGENT'],$cmatch); if((int)$cmatch[1] <26) $is_ckgdokuChrome =true; } ?>
/> name="do[delete]" value="" title="getLang('title_dw_delete') ?>" style = "font-size: 100%; " /> style = "font-size: 100%;" type="submit" name="do[save]" value="getLang('btn_dw_edit')?>" title="getLang('title_dw_edit')?>" /> getConf('allow_ckg_filebrowser') == 'all'): ?> test ? 'inline' : 'none'; $chrome_dwedit_link = 'DW Edit'; $backup_btn =$this->getLang('dw_btn_backup') ? $this->getLang('dw_btn_backup') : $this->getLang('dw_btn_refresh'); $backup_title = $this->getLang('title_dw_backup') ? $this->getLang('title_dw_backup') : $this->getLang('title_dw_refresh'); $using_scayt = ($this->getConf('scayt')) == 'on'; ?> draft_found) { ?>    
debug) { ?>
      [ close ]   
   px      title=" " />
captcha && $this->captcha->isEnabled()) echo $this->captcha->getHTML(); ?>
*/ function _render_xhtml($text){ $mode = 'ckgdoku'; global $skip_styling; $skip_styling = $this->getConf('nofont_styling'); if(!$skip_styling && $_POST['styling'] == 'no_styles') { $skip_styling = true; } if(strpos($text,'~~NO_STYLING~~') !== false) { $skip_styling = true; } $text = preg_replace_callback('/\[\[(.*?>)(.*?)\]\]/ms', function ($matches) { if(strpos($matches[0],"\n") !== false) return $matches[0]; if(preg_match("#<(\w+)>.*?<\/\\1>#",$matches[0])) return $matches[0]; list($name,$link_text) = explode('|',$matches[2]); $retv = '[[' . $matches[1] . "oIWIKIo" . $name ."cIWIKIc"; if(!empty($link_text)) { $retv .= "|$link_text"; } return $retv . ']]'; }, $text); // try default renderer first: $file = DOKU_INC."inc/parser/$mode.php"; if(@file_exists($file)){ require_once $file; $rclass = "Doku_Renderer_$mode"; if ( !class_exists($rclass) ) { trigger_error("Unable to resolve render class $rclass",E_USER_WARNING); msg("Renderer for $mode not valid",-1); return null; } $Renderer = new $rclass(); } else{ // Maybe a plugin is available? $Renderer = plugin_load('renderer',$mode); if(is_null($Renderer)){ msg("No renderer for $mode found",-1); return null; } } // aimed at wrap plugin which allows multiple newlines in a cell $text = preg_replace_callback( '#(\|.*?)\|.?[\n\r]#ms', function ($matches) { $matches[0] = preg_replace("#\\\\\\\\\s*[\r\n]#ms", " \\\\\\\\ ",$matches[0]); return ($matches[0]); }, $text); // prevents utf8 conversions of quotation marks $text = str_replace('"',"_ckgdoku_QUOT_",$text); $text = preg_replace_callback('/()([^<]+)(<\/code>)/ms', create_function( '$matches', '$quot = str_replace("_ckgdoku_QUOT_",\'"\',$matches[2]); $quot = str_replace("\\\\ ","_ckgdoku_NL",$quot); $quot .= "_ckgdoku_NL"; return $matches[1] . $quot . $matches[3];' ), $text); $text = preg_replace_callback('/()([^<]+)(<\/file>)/ms', create_function( '$matches', '$quot = str_replace("_ckgdoku_QUOT_",\'"\',$matches[2]); $quot = str_replace("\\\\ ","_ckgdoku_NL",$quot); $quot .= "_ckgdoku_NL"; return $matches[1] . $quot . $matches[3];' ), $text); $text = preg_replace_callback('/(|)([^<]+)(<\/code>|<\/file>)/ms', create_function( '$matches', '$matches[2] = str_replace("<font","ckgdokuFONTOpen",$matches[2]); $matches[2] = str_replace("font>","ckgdokuFONTClose",$matches[2]); return $matches[1] .$matches[2] . $matches[3]; ' ), $text); $instructions = p_get_instructions("=== header ==="); // loads DOKU_PLUGINS array --M.T. Dec 22 2009 $instructions = p_get_instructions($text); if(is_null($instructions)) return ''; $Renderer->notoc(); if(!$this->getConf('smiley_as_text')) { $Renderer->smileys = getSmileys(); } $Renderer->entities = getEntities(); $Renderer->acronyms = array(); $Renderer->interwiki = getInterwiki(); // Loop through the instructions /* By-passing plugin processing was sugested and first implemented by Matti Lattu It is a significant contribution to the functionality of ckgEdit */ foreach ( $instructions as $instruction ) { if ($instruction[0] == 'plugin') { $Renderer->doc .= $instruction[1][3]; } else { // Execute the callback against the Renderer call_user_func_array(array(&$Renderer, $instruction[0]),$instruction[1]); } } //set info array $info = $Renderer->info; // Post process and return the output $data = array($mode,& $Renderer->doc); trigger_event('RENDERER_CONTENT_POSTPROCESS',$data); $xhtml = $Renderer->doc; if(!$skip_styling) { // create font styles from font plugin markup for html display $xhtml = preg_replace_callback( '|&lt;font\s+(.*?)/([\w ,\-]+);;([\(\)),\w,\s\#]+);;([\(\)),\w,\s\#]+)>(.*?)&lt;/font>|ms', function($matches) { $count = 0; $str=''; if($matches[3] && $matches[3] != 'inherit') { $str .= ''; $count++;} if($matches[1] && $matches[1] != 'inherit') { $str .= ''; $count++; } if($matches[2] && $matches[2] != 'inherit') { $str .= ''; $count++; } if($matches[4] && $matches[4] != 'inherit') { $str .= ''; $count++; } $str .= $matches[5]; for($i =0; $i<$count; $i++) { $str .= ''; } return $str; }, $xhtml ); } /** * Alternative to the one liner at 1179: $xhtml = str_replace(array('oiwikio','ciwikic'),array('oIWIKIo','cIWIKIc'),$xhtml); * if it turns out that there are users using 'oiwikio','ciwikic' $xhtml = preg_replace_callback( '|class=\"interwiki.*?href=\".*?:oiwikiotowerciwikic\".*?title=\".*?oiwikiotowerciwikic\"|ms', function($matches) { $matches[0] = str_replace(array('oiwikio','ciwikic'),array('oIWIKIo','cIWIKIc'),$matches[0]); return $matches[0]; },$xhtml ); */ if(stripos($xhtml,'oIWIKIo') !== false) { $xhtml = str_replace(array('oiwikio','ciwikic'),array('oIWIKIo','cIWIKIc'),$xhtml); $xhtml = preg_replace_callback( '/oIWIKIo(.*?)cIWIKIc(?=<\/a>)/ms', create_function( '$matches', ' return ">". $matches[1] ;' ), $xhtml ); } $pos = strpos($xhtml, 'MULTI_PLUGIN_OPEN'); if($pos !== false) { $xhtml = preg_replace_callback( '|MULTI_PLUGIN_OPEN.*?MULTI_PLUGIN_CLOSE|ms', create_function( '$matches', '$matches[0] = str_replace("//",$matches[0]);' ), $xhtml ); $xhtml = preg_replace('/~\s*~\s*MULTI_PLUGIN_OPEN~\s*~/', "\n\n~~MULTI_PLUGIN_OPEN~~\n\n\n\n", $xhtml); $xhtml = preg_replace('/~\s*~\s*MULTI_PLUGIN_CLOSE~\s*~/', "\n\n
\n\n~~MULTI_PLUGIN_CLOSE~~\n\n", $xhtml); } // remove empty paragraph: see _ckgdoku_NPBBR_ comment above $xhtml = preg_replace('/

\s+_ckgdoku_NPBBR_\s+<\/p>/ms',"\n",$xhtml); $xhtml = str_replace('_ckgdoku_NPBBR_', " ", $xhtml); $xhtml = str_replace('_ckgdoku_QUOT_', '"', $xhtml); $xhtml = str_replace('_ckgdoku_NL', "\n", $xhtml); $xhtml = str_replace('

', "\n\n

 

", $xhtml); // inserts p before an initial codeblock to enable text entry above block $xhtml = preg_replace('/^
 

\s+<\/(em|b|u|i)>/ms',"",$xhtml); $xhtml = preg_replace("/col\d+\s+(\w+align)/ms", "$1",$xhtml); //remove col number for cell prpoerties dialog $xhtml = str_replace('ckgdokuFONTOpen', '&lt;font',$xhtml); // protect font markup in code blocks $xhtml = str_replace('ckgdokuFONTClose', 'font&gt;',$xhtml); $xhtml = str_replace('DBLBACKSPLASH', '\\ ',$xhtml); $xhtml = str_replace('NWPIPECHARACTER', '|',$xhtml); $ua = strtolower ($_SERVER['HTTP_USER_AGENT']); if(strpos($ua,'chrome') !== false) { $xhtml = preg_replace_callback( '/(?<=)/sm', create_function( '$matches', '$ret_str = " " . trim($matches[3]) . " " . trim($matches[2]) . " " . trim($matches[1]) ; return $ret_str;' ), $xhtml ); } return $xhtml; } function write_debug($what) { return; $handle = fopen("ckgdoku_php.txt", "a"); // if(is_array($what)) $what = print_r($what,true); fwrite($handle,"$what\n"); fclose($handle); } function get_switch_fb_value() { if ($this->getUserFb() == 'dokuwiki') { $fbText = $this->getLang('btn_val_ckg_fb'); } else { $fbText = $this->getLang('btn_val_dw_fb'); } return $fbText; } function get_switch_fb_title() { if ($this->getUserFb() == 'dokuwiki') { $fbText = $this->getLang('btn_title_ckg_fb'); } else { $fbText = $this->getLang('btn_title_dw_fb'); } return $fbText; } function getUserFb() { //get user file browser if (!isset($_COOKIE['ckgFbOpt'])) { $_COOKIE['ckgFbOpt'] = $this->getConf('default_ckg_filebrowser'); } return $_COOKIE['ckgFbOpt']; } } //end of action class ?>