From: Robert P. <rob...@gm...> - 2012-10-24 21:12:23
|
I've waited nearly a year to see this commit go through.... On Wed, Oct 24, 2012 at 5:10 PM, <rob...@us...>wrote: > Revision: 43669 > http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=43669&view=rev > Author: robertplummer > Date: 2012-10-24 21:10:43 +0000 (Wed, 24 Oct 2012) > Log Message: > ----------- > [ENH] But more a fix, the specialCharacter processor gets its own handler > type, and ckeditor gets one to, so it can override. As of this point > WYSIWYG displays correctly in the JisonParser, WOOHOO! > > Modified Paths: > -------------- > branches/10.x/lib/core/JisonParser/Wiki/Handler.php > branches/10.x/lib/core/JisonParser/Wiki/HtmlCharacter.php > branches/10.x/lib/core/JisonParser/WikiCKEditor/Handler.php > branches/10.x/lib/core/WikiPlugin/Negotiator/CKEditor.php > > Added Paths: > ----------- > branches/10.x/lib/core/JisonParser/Wiki/SpecialChar.php > branches/10.x/lib/core/JisonParser/WikiCKEditor/SpecialChar.php > > Modified: branches/10.x/lib/core/JisonParser/Wiki/Handler.php > =================================================================== > --- branches/10.x/lib/core/JisonParser/Wiki/Handler.php 2012-10-24 > 20:30:39 UTC (rev 43668) > +++ branches/10.x/lib/core/JisonParser/Wiki/Handler.php 2012-10-24 > 21:10:43 UTC (rev 43669) > @@ -74,6 +74,9 @@ > /* html character */ > public $htmlCharacter; > > + /* special character */ > + public $specialCharacter; > + > /* html tag tracking */ > public $nonBreakingTagDepth = 0; > > @@ -81,29 +84,6 @@ > private $isFirstBr = false; > private $line = 0; > > - //This var is used in both protectSpecialChars and > unprotectSpecialChars to simplify the html ouput process > - public $specialChars = array( > - '≤REAL_LT≥' => array( > - 'html'=> '<', > - 'nonHtml'=> '<' > - ), > - '≤REAL_GT≥' => array( > - 'html'=> '>', > - 'nonHtml'=> '>' > - ), > - '≤REAL_NBSP≥' => array( > - 'html'=> ' ', > - 'nonHtml'=> ' ' > - ), > - /*on post back the page is parsed, which turns & into & > - this is done to prevent that from happening, we are just > - protecting some chars from letting the parser nab them*/ > - '≤REAL_AMP≥' => array( > - 'html'=> '& ', > - 'nonHtml'=> '& ' > - ), > - ); > - > public $user; > public $prefs; > public $page; > @@ -243,6 +223,10 @@ > $this->Parser->htmlCharacter = new > JisonParser_Wiki_HtmlCharacter($this->Parser); > } > > + if (isset($this->Parser->specialCharacter) == false) { > + $this->Parser->specialCharacter = new > JisonParser_Wiki_SpecialChar(); > + } > + > if (empty($this->Parser->option) == true) { > $this->resetOption(); > } > @@ -372,7 +356,7 @@ > > $input = "\n" . $input . "\n"; //here we add 2 lines, so > the parser doesn't have to do special things to track the first line and > last, we remove these when we insert breaks, these are dynamically removed > later > > - $input = $this->protectSpecialChars($input); > + $input = $this->specialCharacter->protect($input); > } > > /** > @@ -419,7 +403,7 @@ > > if ($this->Parser->parseDepth == 0) { > ini_set("pcre.recursion_limit", > $this->pcreRecursionLimit); > - $output = $this->unprotectSpecialChars($output); > + $output = > $this->specialCharacter->unprotect($output); > } > } > > @@ -433,7 +417,7 @@ > */ > function plugin(&$pluginDetails) > { > - $pluginDetails['body'] = > $this->unprotectSpecialChars($pluginDetails['body'], true); > + $pluginDetails['body'] = > $this->specialCharacter->unprotect($pluginDetails['body'], true); > $negotiator =& $this->pluginNegotiator; > > $negotiator->setDetails($pluginDetails); > @@ -614,55 +598,9 @@ > } > } > > - /** > - * used to protect special characters temporarily, so that they > cannot be decoded or encoded. Later we can > - * unprotect them to what they were or to an alternate character > - * > - * @access public > - * @param string $input unparsed syntax > - * @return string $input protected > - */ > - public function protectSpecialChars($input) > - { > - if ( > - $this->isHtmlPurifying == true || > - $this->getOption('is_html') == false > - ) { > - foreach ($this->specialChars as $key => > $specialChar) { > - $input = str_replace($specialChar['html'], > $key, $input); > - } > - } > > - return $input; > - } > > - /** > - * used to unprotect special characters possibly with an alternate > character > - * > - * @access public > - * @param string $input unparsed syntax > - * @param bool $is_html true for html context, false for > non-html context > - * @return string $input protected > - */ > - public function unprotectSpecialChars($input, $is_html = false) > - { > - if ( > - $is_html == true || > - $this->getOption('is_html') == true > - ) { > - foreach ($this->specialChars as $key => > $specialChar) { > - $input = str_replace($key, > $specialChar['html'], $input); > - } > - } else { > - foreach ($this->specialChars as $key => > $specialChar) { > - $input = str_replace($key, > $specialChar['nonHtml'], $input); > - } > - } > > - return $input; > - } > - > - > //end state handlers > //Wiki Syntax Objects Parsing Start > /** > @@ -675,7 +613,7 @@ > public function np($content) > { > if ( $this->getOption('parseNps') == true) { > - $content = $this->unprotectSpecialChars($content); > + $content = > $this->specialCharacter->unprotect($content); > } > > return $content; > @@ -704,7 +642,7 @@ > */ > function htmlTag($content) > { > - $parts = preg_split("/[ >]/", > substr($this->unprotectSpecialChars($content, true), 1)); //<tag> || <tag > name=""> > + $parts = preg_split("/[ >]/", > substr($this->specialCharacter->unprotect($content, true), 1)); //<tag> || > <tag name=""> > $name = strtolower(trim($parts[0])); > > switch ($name) { > > Modified: branches/10.x/lib/core/JisonParser/Wiki/HtmlCharacter.php > =================================================================== > --- branches/10.x/lib/core/JisonParser/Wiki/HtmlCharacter.php 2012-10-24 > 20:30:39 UTC (rev 43668) > +++ branches/10.x/lib/core/JisonParser/Wiki/HtmlCharacter.php 2012-10-24 > 21:10:43 UTC (rev 43669) > @@ -19,6 +19,7 @@ > 'rsq' => array('exp' => '/~rsq~/i', 'output' => > '’'), > 'c' => array('exp' => '/~c~/i', 'output' => > '©'), > '--' => array('exp' => '/~--~/', 'output' => > '—'), > + '=>' => array('exp' => '/=>/', 'output' => > '=>'), > 'lt' => array('exp' => '/~lt~/i', 'output' => > '<'), > 'gt' => array('exp' => '/~gt~/i', 'output' => > '>'), > 'rm' => array('exp' => '/[{]rm[}]/i','output' => > '‏'), > > Added: branches/10.x/lib/core/JisonParser/Wiki/SpecialChar.php > =================================================================== > --- branches/10.x/lib/core/JisonParser/Wiki/SpecialChar.php > (rev 0) > +++ branches/10.x/lib/core/JisonParser/Wiki/SpecialChar.php 2012-10-24 > 21:10:43 UTC (rev 43669) > @@ -0,0 +1,81 @@ > +<?php > +// (c) Copyright 2002-2012 by authors of the Tiki Wiki CMS Groupware > Project > +// > +// All Rights Reserved. See copyright.txt for details and a complete list > of authors. > +// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt > for details. > +// $Id$ > + > +class JisonParser_Wiki_SpecialChar > +{ > + > + //This var is used in both protectSpecialChars and > unprotectSpecialChars to simplify the html ouput process > + public $specialChars = array( > + '≤REAL_LT≥' => array( > + 'html'=> '<', > + 'nonHtml'=> '<' > + ), > + '≤REAL_GT≥' => array( > + 'html'=> '>', > + 'nonHtml'=> '>' > + ), > + '≤REAL_NBSP≥' => array( > + 'html'=> ' ', > + 'nonHtml'=> ' ' > + ), > + /*on post back the page is parsed, which turns & into & > + this is done to prevent that from happening, we are just > + protecting some chars from letting the parser nab them*/ > + '≤REAL_AMP≥' => array( > + 'html'=> '& ', > + 'nonHtml'=> '& ' > + ), > + ); > + > + /** > + * used to protect special characters temporarily, so that they > cannot be decoded or encoded. Later we can > + * unprotect them to what they were or to an alternate character > + * > + * @access public > + * @param string $input unparsed syntax > + * @return string $input protected > + */ > + public function protect($input) > + { > + if ( > + $this->isHtmlPurifying == true || > + $this->getOption('is_html') == false > + ) { > + foreach ($this->specialChars as $key => > $specialChar) { > + $input = str_replace($specialChar['html'], > $key, $input); > + } > + } > + > + return $input; > + } > + > + /** > + * used to unprotect special characters possibly with an alternate > character > + * > + * @access public > + * @param string $input unparsed syntax > + * @param bool $is_html true for html context, false for > non-html context > + * @return string $input protected > + */ > + public function unprotect($input, $is_html = false) > + { > + if ( > + $is_html == true || > + $this->getOption('is_html') == true > + ) { > + foreach ($this->specialChars as $key => > $specialChar) { > + $input = str_replace($key, > $specialChar['html'], $input); > + } > + } else { > + foreach ($this->specialChars as $key => > $specialChar) { > + $input = str_replace($key, > $specialChar['nonHtml'], $input); > + } > + } > + > + return $input; > + } > +} > \ No newline at end of file > > > Property changes on: > branches/10.x/lib/core/JisonParser/Wiki/SpecialChar.php > ___________________________________________________________________ > Added: svn:keywords > + Id > > Modified: branches/10.x/lib/core/JisonParser/WikiCKEditor/Handler.php > =================================================================== > --- branches/10.x/lib/core/JisonParser/WikiCKEditor/Handler.php 2012-10-24 > 20:30:39 UTC (rev 43668) > +++ branches/10.x/lib/core/JisonParser/WikiCKEditor/Handler.php 2012-10-24 > 21:10:43 UTC (rev 43669) > @@ -6,6 +6,8 @@ > { > parent::__construct(); > > + $this->Parser->specialCharacter = new > JisonParser_WikiCKEditor_SpecialChar(); > + > $this->Parser->htmlCharacter = new > JisonParser_WikiCKEditor_HtmlCharacter($this->Parser); > > $this->pluginNegotiator = new > WikiPlugin_Negotiator_CKEditor($this->Parser); > > Added: branches/10.x/lib/core/JisonParser/WikiCKEditor/SpecialChar.php > =================================================================== > --- branches/10.x/lib/core/JisonParser/WikiCKEditor/SpecialChar.php > (rev 0) > +++ branches/10.x/lib/core/JisonParser/WikiCKEditor/SpecialChar.php > 2012-10-24 21:10:43 UTC (rev 43669) > @@ -0,0 +1,17 @@ > +<?php > +// (c) Copyright 2002-2012 by authors of the Tiki Wiki CMS Groupware > Project > +// > +// All Rights Reserved. See copyright.txt for details and a complete list > of authors. > +// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt > for details. > +// $Id$ > + > +class JisonParser_WikiCKEditor_SpecialChar extends > JisonParser_Wiki_SpecialChar > +{ > + function protect(&$input) { > + return $input; > + } > + > + function unprotect(&$input) { > + return $input; > + } > +} > \ No newline at end of file > > > Property changes on: > branches/10.x/lib/core/JisonParser/WikiCKEditor/SpecialChar.php > ___________________________________________________________________ > Added: svn:keywords > + Id > > Modified: branches/10.x/lib/core/WikiPlugin/Negotiator/CKEditor.php > =================================================================== > --- branches/10.x/lib/core/WikiPlugin/Negotiator/CKEditor.php 2012-10-24 > 20:30:39 UTC (rev 43668) > +++ branches/10.x/lib/core/WikiPlugin/Negotiator/CKEditor.php 2012-10-24 > 21:10:43 UTC (rev 43669) > @@ -52,12 +52,14 @@ > } > } > > - return '<'.$elem.' class="tiki_plugin" plugin="' . > $this->name . '" style="' . $elem_style . '"' . > + $result = '~np~<'.$elem.' class="tiki_plugin" plugin="' . > $this->name . '" style="' . $elem_style . '"' . > ' syntax="' . htmlentities($syntax, ENT_QUOTES, > 'UTF-8') . '"' . > ' args="' . htmlentities($this->urlEncodeArgs(), > ENT_QUOTES, 'UTF-8') . '"' . > ' body="' . htmlentities($this->body, ENT_QUOTES, > 'UTF-8') . '">'. // not <!--{cke_protected} > '<img src="'.$icon.'" width="16" height="16" > style="float:left;position:absolute;z-index:10001" />' . > - $result.'<!-- end tiki_plugin --></'.$elem.'>'; > + $result.'<!-- end tiki_plugin > --></'.$elem.'>~/np~'; > + > + return $result; > } > > function blockFromExecution($status = '') > > This was sent by the SourceForge.net collaborative development platform, > the world's largest Open Source development site. > > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_sfd2d_oct > _______________________________________________ > Tikiwiki-cvs mailing list > Tik...@li... > https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs > -- Robert Plummer |