add contents
This commit is contained in:
98
lib/plugins/ckgedit/syntax/font.php
Normal file
98
lib/plugins/ckgedit/syntax/font.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
* @author Myron Turner <turnermm02@shaw.ca>
|
||||
*/
|
||||
|
||||
// Syntax: <color somecolour/somebackgroundcolour>
|
||||
|
||||
// must be run within Dokuwiki
|
||||
if(!defined('DOKU_INC')) die();
|
||||
|
||||
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
|
||||
require_once(DOKU_PLUGIN.'syntax.php');
|
||||
|
||||
/**
|
||||
* All DokuWiki plugins to extend the parser/rendering mechanism
|
||||
* need to inherit from this class
|
||||
*/
|
||||
class syntax_plugin_ckgedit_font extends DokuWiki_Syntax_Plugin {
|
||||
|
||||
|
||||
|
||||
function getType(){ return 'formatting'; }
|
||||
function getAllowedTypes() { return array('formatting', 'substition', 'disabled'); }
|
||||
function getSort(){ return 158; }
|
||||
function connectTo($mode) { $this->Lexer->addEntryPattern('<font.*?>(?=.*?</font>)',$mode,'plugin_ckgedit_font'); }
|
||||
function postConnect() { $this->Lexer->addExitPattern('</font>','plugin_ckgedit_font'); }
|
||||
|
||||
|
||||
/**
|
||||
* Handle the match
|
||||
*/
|
||||
function handle($match, $state, $pos, Doku_Handler $handler){
|
||||
|
||||
|
||||
switch ($state) {
|
||||
case DOKU_LEXER_ENTER :
|
||||
list($size, $face) = preg_split("/\//u", substr($match, 6, -1), 2);
|
||||
if(isset($size) && strpos($size,':') !== false) {
|
||||
list($size,$weight) = explode(':',$size);
|
||||
$size = "font-size:$size;";
|
||||
if(isset($weight) && $weight) {
|
||||
list($weight,$fstyle) = explode(',',$weight);
|
||||
$size .= " font-weight:$weight; ";
|
||||
if($fstyle) $size .= " font-style:$fstyle; ";
|
||||
}
|
||||
|
||||
}
|
||||
else $size = "font-size:$size;";
|
||||
return array($state, array($size, $face));
|
||||
|
||||
case DOKU_LEXER_UNMATCHED : return array($state, $match);
|
||||
case DOKU_LEXER_EXIT : return array($state, '');
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create output
|
||||
*/
|
||||
function render($mode, Doku_Renderer $renderer, $data) {
|
||||
if($mode == 'xhtml'){
|
||||
list($state, $match) = $data;
|
||||
|
||||
switch ($state) {
|
||||
case DOKU_LEXER_ENTER :
|
||||
list($style, $face) = $match;
|
||||
if(isset($face)) {
|
||||
list($face,$fg,$bg) = explode(';;',$face);
|
||||
if(isset($fg)) {
|
||||
$color = " color: $fg; ";
|
||||
$style .= $color;
|
||||
|
||||
}
|
||||
if(isset($bg)) {
|
||||
$color = " background-color: $bg ";
|
||||
$style .= $color;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
$style = "font-family: $face; $style";
|
||||
$renderer->doc .= "<span style='$style'>";
|
||||
break;
|
||||
|
||||
case DOKU_LEXER_UNMATCHED : $renderer->doc .= $renderer->_xmlEntities($match); break;
|
||||
case DOKU_LEXER_EXIT : $renderer->doc .= "</span>"; break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
123
lib/plugins/ckgedit/syntax/specials.php
Normal file
123
lib/plugins/ckgedit/syntax/specials.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
* class plugin_ckgedit_specials
|
||||
* @author Myron Turner <turnermm02@shaw.ca>
|
||||
*/
|
||||
|
||||
// must be run within Dokuwiki
|
||||
if(!defined('DOKU_INC')) die();
|
||||
|
||||
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
|
||||
require_once(DOKU_PLUGIN.'syntax.php');
|
||||
//define ('CKGEDIT_IMAGES', DOKU_URL . 'lib/plugins/ckgedit/images/');
|
||||
//define ('CK_IMG_PATH',DOKU_INC . 'lib/plugins/ckgedit/images/');
|
||||
if(!defined('DOKU_LF')) define ('DOKU_LF',"\n");
|
||||
if(!defined('DOKU_TAB')) define ('DOKU_TAB',"\t");
|
||||
|
||||
/**
|
||||
* All DokuWiki plugins to extend the parser/rendering mechanism
|
||||
* need to inherit from this class
|
||||
*/
|
||||
class syntax_plugin_ckgedit_specials extends DokuWiki_Syntax_Plugin {
|
||||
|
||||
|
||||
/**
|
||||
* What kind of syntax are we?
|
||||
*/
|
||||
function getType(){
|
||||
return 'substition';
|
||||
}
|
||||
|
||||
/**
|
||||
* What about paragraphs?
|
||||
*/
|
||||
|
||||
function getPType(){
|
||||
// return 'stack';
|
||||
return 'block';
|
||||
}
|
||||
|
||||
/**
|
||||
* Where to sort in?
|
||||
*/
|
||||
function getSort(){
|
||||
return 155;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Connect pattern to lexer
|
||||
*/
|
||||
function connectTo($mode) {
|
||||
|
||||
$this->Lexer->addSpecialPattern('~~MULTI_PLUGIN_OPEN~~',$mode,'plugin_ckgedit_specials');
|
||||
$this->Lexer->addSpecialPattern('~~MULTI_PLUGIN_CLOSE~~',$mode,'plugin_ckgedit_specials');
|
||||
$this->Lexer->addSpecialPattern('~~COMPLEX_TABLES~~',$mode,'plugin_ckgedit_specials');
|
||||
$this->Lexer->addSpecialPattern('~~NO_STYLING~~',$mode,'plugin_ckgedit_specials');
|
||||
$this->Lexer->addEntryPattern('~~START_HTML_BLOCK~~(?=.*?~~CLOSE_HTML_BLOCK~~)',$mode,'plugin_ckgedit_specials');
|
||||
$this->Lexer->addSpecialPattern('~~AUTO_INTERNAL_LINKS~~',$mode,'plugin_ckgedit_specials');
|
||||
|
||||
|
||||
}
|
||||
function postConnect() { $this->Lexer->addExitPattern('~~CLOSE_HTML_BLOCK~~','plugin_ckgedit_specials'); }
|
||||
|
||||
/**
|
||||
* Handle the match
|
||||
*/
|
||||
function handle($match, $state, $pos, Doku_Handler $handler){
|
||||
|
||||
$class = "";
|
||||
$xhtml = "";
|
||||
switch($state) {
|
||||
case DOKU_LEXER_SPECIAL:
|
||||
if(preg_match('/OPEN/', $match)) {
|
||||
return array($state, "<span class='multi_p_open'></span>" );
|
||||
}
|
||||
elseif(preg_match('/CLOSE/', $match)) {
|
||||
return array($state, "<span class='multi_p_close'></span>" );
|
||||
}
|
||||
elseif(preg_match('/(TABLES|STYLING|AUTO_INTERNAL)/', $match)) {
|
||||
return array($state, "" );
|
||||
}
|
||||
case DOKU_LEXER_ENTER : return array($state, '');
|
||||
case DOKU_LEXER_UNMATCHED :
|
||||
$match = str_replace('<div class="table">',"",$match);
|
||||
$match = preg_replace('/<\/?code>/ms',"",$match);
|
||||
return array($state, $match);
|
||||
case DOKU_LEXER_EXIT : return array($state, '');
|
||||
}
|
||||
return array($state, "" );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create output
|
||||
*/
|
||||
function render($mode, Doku_Renderer $renderer, $data) {
|
||||
if($mode == 'xhtml'){
|
||||
list($state, $xhtml) = $data;
|
||||
switch ($state) {
|
||||
case DOKU_LEXER_SPECIAL:
|
||||
$renderer->doc .= DOKU_LF . $xhtml . DOKU_LF;
|
||||
return true;
|
||||
case DOKU_LEXER_ENTER : $renderer->doc .= ""; break;
|
||||
case DOKU_LEXER_UNMATCHED :
|
||||
$renderer->doc .= $xhtml; break;
|
||||
case DOKU_LEXER_EXIT : $renderer->doc .= ""; break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function write_debug($what) {
|
||||
$handle = fopen("blog_pats.txt", "a");
|
||||
fwrite($handle,"$what\n");
|
||||
fclose($handle);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user