string each way... ;)
> I get now
>
> Warning: Call-time pass-by-reference has been deprecated; If you would
> like to pass it by reference, modify the declaration of parse_html(). If
> you would like to enable call-time pass-by-reference, you can set
> allow_call_time_pass_reference to true in your INI file
> in /var/www/html/tikitrunk/tiki-editpage.php on line 604
>
> thx for fixing it
>
> On Thu, 2008-08-21 at 17:58 +0000,
jonnybradley@...
> wrote:
>> Revision: 14456
>>
http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=14456&view=rev>> Author: jonnybradley
>> Date: 2008-08-21 17:58:04 +0000 (Thu, 21 Aug 2008)
>>
>> Log Message:
>> -----------
>> [MOD] Markup now parsed when switching from normal (wiki) to wysiwyg (html)
>> editors (itemId=1831)
>> Doesn't loose edits, copes with images and smilies - but: wikiplugins now get
>> <x>'s scattered into the code they produce, so break a lot (i'll work on
>> that!)
>>
>> Modified Paths:
>> --------------
>> trunk/templates/tiki-editpage.tpl
>> trunk/tiki-editpage.php
>> trunk/tiki-parsemode_setup.php
>>
>> Modified: trunk/templates/tiki-editpage.tpl
>> ===================================================================
>> --- trunk/templates/tiki-editpage.tpl 2008-08-21 17:33:01 UTC (rev 14455)
>> +++ trunk/templates/tiki-editpage.tpl 2008-08-21 17:58:04 UTC (rev 14456)
>> @@ -162,11 +162,11 @@
>> </div>
>> {/if}
>>
>> -{if $prefs.feature_wysiwyg eq 'y' and $prefs.wysiwyg_optional eq 'y' and
>> !$preview and $staging_preview neq 'y' and !isset($hdr)}
>> +{if $prefs.feature_wysiwyg eq 'y' and $prefs.wysiwyg_optional eq 'y' and
>> !isset($hdr)}
>> {if $wysiwyg ne 'y'}
>> - <span class="button2" onclick="needToConfirm = false;">{self_link
>> _class='linkbut' wysiwyg='y'}{tr}Use wysiwyg editor{/tr}{/self_link}</span>
>> - {else}
>> - <span class="button2" onclick="needToConfirm = false;">{self_link
>> _class='linkbut' wysiwyg='n'}{tr}Use normal editor{/tr}{/self_link}</span>
>> + <input type="submit" class="wikiaction" onmouseover="return
>> overlib('{tr}Switch to WYSIWYG editor.{/tr}');" onmouseout="nd();"
>> name="mode_wysiwyg" value="{tr}Use wysiwyg editor{/tr}"
>> onclick="needToConfirm=false;" />
>> +{else}
>> + <input type="submit" class="wikiaction" onmouseover="return
>> overlib('{tr}Switch to normal (wiki) editor.{/tr}');" onmouseout="nd();"
>> name="mode_normal" value="{tr}Use normal editor{/tr}"
>> onclick="needToConfirm=false;" />
>> {/if}
>> {/if}
>>
>> @@ -240,7 +240,7 @@
>> {/if}
>> </td></tr>
>> {/if}
>> -{if $prefs.feature_smileys eq 'y'&&!$wysiwyg}
>> +{if $prefs.feature_smileys eq 'y' && ($wysiwyg neq 'y' or
>> $prefs.wysiwyg_wiki_parsed eq 'y')}
>> <tr class="formcolor"><td>{tr}Smileys{/tr}:</td><td>
>> {include file="tiki-smileys.tpl" area_name='editwiki'}
>> </td>
>>
>> Modified: trunk/tiki-editpage.php
>> ===================================================================
>> --- trunk/tiki-editpage.php 2008-08-21 17:33:01 UTC (rev 14455)
>> +++ trunk/tiki-editpage.php 2008-08-21 17:58:04 UTC (rev 14456)
>> @@ -526,11 +526,57 @@
>> walk_and_parse($c[$i]["content"], $src, $p, $head_url );
>> }
>> }
>> -}
>> +} // end walk_and_parse
>> +/**
>> + * wrapper around zaufi's HTML sucker code just to use the html to wiki bit
>> + *
>> + * \param &$c string -- HTML in
>> + * \param &$src string -- output string
>> + */
>> +function parse_html(&$inHtml, &$parseddata) {
>> + //error_reporting(6143);
>> + // Read compiled (serialized) grammar
>> + $grammarfile = 'lib/htmlparser/htmlgrammar.cmp';
>> + if (!$fp = @fopen($grammarfile,'r'))
>> + {
>> + $smarty->assign('msg', tra("Can't parse HTML data - no grammar file"));
>> + $smarty->display("error.tpl");
>> + die;
>> + }
>> + $grammar = unserialize(fread($fp, filesize($grammarfile)));
>> + fclose($fp);
>> + // create parser object, insert html code and parse it
>> + $htmlparser = new HtmlParser($inHtml, $grammar, '', 0);
>> + $htmlparser->Parse();
>> + // Should I try to convert HTML to wiki?
>> + $parseddata = '';
>> + $p = array('stack' => array(), 'listack' => array(), 'first_td' => false);
>> + walk_and_parse( $htmlparser->content, $parseddata, $p, '' );
>> + // Is some tags still opened? (It can be if HTML not valid, but this is not
>> reason
>> + // to produce invalid wiki :)
>> + while (count($p['stack']))
>> + {
>> + $e = end($p['stack']);
>> + $parseddata .= $e['string'];
>> + array_pop($p['stack']);
>> + }
>> + // Unclosed lists r ignored... wiki have no special start/end lists
>> syntax....
>> + // OK. Things remains to do:
>> + // 1) fix linked images
>> + $parseddata = preg_replace(',\[(.*)\|\(img src=(.*)\)\],mU','{img src=$2
>> link=$1}', $parseddata);
>> + // 2) fix remains images (not in links)
>> + $parseddata = preg_replace(',\(img src=(.*)\),mU','{img src=$1}',
>> $parseddata);
>> + // 3) remove empty lines
>> + $parseddata = preg_replace(",[\n]+,mU","\n", $parseddata);
>> + // 4) remove nbsp's
>> + $parseddata = preg_replace(", ,mU"," ", $parseddata);
>> +} // end parse_html
>> +
>> // Suck another page and append to the end of current
>> include ('lib/htmlparser/htmlparser.inc');
>> $suck_url = isset($_REQUEST["suck_url"]) ? $_REQUEST["suck_url"] : '';
>> -$parsehtml = isset ($_REQUEST["parsehtml"]) ? ($_REQUEST["parsehtml"] ==
>> 'on' ? 'y' : 'n') : 'n';
>> +$parsehtml = isset ($_REQUEST["parsehtml"]) ? ($_REQUEST["parsehtml"] ==
>> 'on' ? 'y' : 'n') : ($info['is_html'] ? 'n' : 'y');
>> +$smarty->assign('parsehtml', $parsehtml);
>> if (isset($_REQUEST['do_suck']) && strlen($suck_url) > 0)
>> {
>> // \note by zaufi
>> @@ -553,40 +599,11 @@
>> // Need to parse HTML?
>> if ($parsehtml == 'y')
>> {
>> - // Read compiled (serialized) grammar
>> - $grammarfile = 'lib/htmlparser/htmlgrammar.cmp';
>> - if (!$fp = @fopen($grammarfile,'r'))
>> - {
>> - $smarty->assign('msg', tra("Can't parse remote HTML page"));
>> - $smarty->display("error.tpl");
>> - die;
>> - }
>> - $grammar = unserialize(fread($fp, filesize($grammarfile)));
>> - fclose($fp);
>> - // create parser object, insert html code and parse it
>> - $htmlparser = new HtmlParser($sdta, $grammar, '', 0);
>> - $htmlparser->Parse();
>> - // Should I try to convert HTML to wiki?
>> + // note by jonnyb - replaced by
>> $parseddata = '';
>> - $p = array('stack' => array(), 'listack' => array(), 'first_td' =>
>> false);
>> - $head_url = preg_replace( ';[^/]*$;', '', $_REQUEST["suck_url"] );
>> - walk_and_parse( $htmlparser->content, $parseddata, $p, $head_url );
>> - // Is some tags still opened? (It can be if HTML not valid, but this
>> is not reason
>> - // to produce invalid wiki :)
>> - while (count($p['stack']))
>> - {
>> - $e = end($p['stack']);
>> - $sdta .= $e['string'];
>> - array_pop($p['stack']);
>> - }
>> - // Unclosed lists r ignored... wiki have no special start/end lists
>> syntax....
>> - // OK. Things remains to do:
>> - // 1) fix linked images
>> - $parseddata = preg_replace(',\[(.*)\|\(img src=(.*)\)\],mU','{img
>> src=$2 link=$1}', $parseddata);
>> - // 2) fix remains images (not in links)
>> - $parseddata = preg_replace(',\(img src=(.*)\),mU','{img src=$1}',
>> $parseddata);
>> - // 3) remove empty lines
>> - $parseddata = preg_replace(",[\n]+,mU","\n", $parseddata);
>> + parse_html(&$sdta, &$parseddata);
>> + // following code moved to parse_html()
>> +
>> // Reassign previous data
>> $sdta = $parseddata;
>> }
>> @@ -778,20 +795,55 @@
>> } else {
>> $smarty->assign( 'translation_critical', 0 );
>> }
>> -if ( ! isset($_REQUEST['edit']) && ! $is_html ) {
>> - // When we get data from database (i.e. we are not in preview mode) and if
>> we don't allow HTML,
>> - // then we need to convert database's HTML entities into their "normal
>> chars" equivalents
>> - $smarty->assign('pagedata', TikiLib::htmldecode($edit_data));
>> -} else {
>> - $smarty->assign('pagedata', $edit_data);
>> +
>> +// Parse (or not) $edit_data into $parsed
>> +// Handles switching editor modes
>> +if (isset($_REQUEST['mode_normal'])) {
>> + // Parsing page data as first time seeing html page in normal editor
>> + $smarty->assign('msg', "Parsing html to wiki");
>> + $parsed = '';
>> + parse_html($edit_data, &$parsed);
>> + $parsed = preg_replace('/\{img src=.*?img\/smiles\/.*?
>> alt=([\w\-]*?)\}/im','(:$1:)', $parsed); // "unfix" smilies
>> + $parsed = preg_replace('/%%%/m',"\n", $parsed); // newlines
>> + $is_html = false;
>> + $info['is_html'] = false;
>> + $info['wysiwyg'] = false;
>> + $smarty->assign('allowhtml','n');
>> +} elseif (isset($_REQUEST['mode_wysiwyg'])) {
>> + // Parsing page data as first time seeing wiki page in wysiwyg editor
>> + $smarty->assign('msg', "Parsing wiki to html");
>> + $secedit = $prefs['wiki_edit_section'];
>> + $prefs['wiki_edit_section'] = 'n'; // get rid of the section edit icons
>> + $exticons = $prefs['feature_wiki_ext_icon'];
>> + $prefs['feature_wiki_ext_icon'] = 'n'; // and the external link icons
>> + $parsed = $tikilib->parse_data($edit_data,Array('absolute_links'=>true));
>> + $parsed = preg_replace('/<span class=\"img\">(.*?)<\/span>/im','$1',
>> $parsed); // remove spans round img's
>> + $parsed =
>> preg_replace("/src=\"img\/smiles\//im","src=\"".$tikiroot."img/smiles/",
>> $parsed); // fix smiley src's
>> + $smarty->assign('pagedata', $parsed);
>> + $prefs['wiki_edit_section'] = $secedit;
>> + $prefs['feature_wiki_ext_icon'] = $exticons;
>> + $is_html = true;
>> + $info['is_html'] = true;
>> + $info['wysiwyg'] = true;
>> + $smarty->assign('allowhtml','y');
>> }
>> -if ( isset($_REQUEST['edit']) && ! $is_html ) {
>> - // When we are in preview mode (i.e. data doesn't come from database) and
>> if we don't allow HTML,
>> - // then we need to convert HTML special chars into their HTML entities
>> equivalent;
>> - $parsed = htmlspecialchars($edit_data);
>> -} else {
>> - $parsed = $edit_data;
>> +if (!$parsed) {
>> + if ( ! isset($_REQUEST['edit']) && ! $is_html ) {
>> + // When we get data from database (i.e. we are not in preview mode) and if
>> we don't allow HTML,
>> + // then we need to convert database's HTML entities into their "normal
>> chars" equivalents
>> + $parsed = TikiLib::htmldecode($edit_data);
>> + } else {
>> + //if ( isset($_REQUEST['edit']) && ! $is_html ) {
>> + // When we are in preview mode (i.e. data doesn't come from database) and
>> if we don't allow HTML,
>> + // then we need to convert HTML special chars into their HTML entities
>> equivalent;
>> + // $parsed = htmlspecialchars($edit_data);
>> + //} else {
>> + $parsed = $edit_data;
>> + //}
>> + }
>> }
>> +$smarty->assign('pagedata', $parsed);
>> +
>> // apply the optional post edit filters before preview
>> if(isset($_REQUEST["preview"]) || ($prefs['wiki_spellcheck'] == 'y' &&
>> isset($_REQUEST["spellcheck"]) && $_REQUEST["spellcheck"] == 'on')) {
>> $parsed = $tikilib->apply_postedit_handlers($parsed);
>>
>> Modified: trunk/tiki-parsemode_setup.php
>> ===================================================================
>> --- trunk/tiki-parsemode_setup.php 2008-08-21 17:33:01 UTC (rev 14455)
>> +++ trunk/tiki-parsemode_setup.php 2008-08-21 17:58:04 UTC (rev 14456)
>> @@ -7,8 +7,12 @@
>> $parsemode_setup = 'y';
>> $is_html = false;
>> if ($prefs['feature_wysiwyg'] == 'y') {
>> - if ((isset($_REQUEST['wysiwyg']) and $_REQUEST['wysiwyg'] == 'y' and
>> $prefs['wysiwyg_optional'] == 'y') ) {
>> + if (isset($_REQUEST['mode_wysiwyg']) and $prefs['wysiwyg_optional'] == 'y')
>> {
>> $_SESSION['wysiwyg'] = 'y';
>> + } elseif (isset($_REQUEST['mode_normal']) and $prefs['wysiwyg_optional'] ==
>> 'y') {
>> + $_SESSION['wysiwyg'] = 'n';
>> + } elseif ((isset($_REQUEST['wysiwyg']) and $_REQUEST['wysiwyg'] == 'y' and
>> $prefs['wysiwyg_optional'] == 'y') ) {
>> + $_SESSION['wysiwyg'] = 'y';
>> } elseif ((isset($_REQUEST['wysiwyg']) and $_REQUEST['wysiwyg'] == 'n' and
>> $prefs['wysiwyg_optional'] == 'y') ) {
>> $_SESSION['wysiwyg'] = 'n';
>> } elseif ($prefs['wysiwyg_optional'] == 'n') {
>>
>>
>> This was sent by the SourceForge.net collaborative development platform, the
>> world's largest Open Source development site.
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
>> Build the coolest Linux based applications with Moblin SDK & win great prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the world
>>
http://moblin-contest.org/redirect.php?banner_id=100&url=/>> _______________________________________________
>> Tikiwiki-cvs mailing list
>>
Tikiwiki-cvs@...
>>
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
>
http://moblin-contest.org/redirect.php?banner_id=100&url=/> _______________________________________________
> Tikiwiki-cvs mailing list
>
Tikiwiki-cvs@...
>
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs