[Pmwiki-users] Preview function

bernhard@weichel21.de bernhard
Wed Aug 20 16:19:25 CDT 2003


change



if ($myaction=="$[Preview]") {  



to



if ($myaction==FmtPageName("$[Preview]", $pagename)) {



then it should work. 







btw, you should also follow the I18n approach for hardcoded texts like

"Seite ist noch nicht gespeichert"





Bernhard ;-)

  ----- Original Message ----- 
  From: Andreas H?cker 
  To: pmwiki-users at pmichaud.com 
  Sent: Wednesday, August 20, 2003 2:47 PM
  Subject: [Pmwiki-users] Preview function


  Hi,



  I have one question.

  I use the i18n-de.php and the flexlayout-i18n.php.

  I want to ad the preview-function into the flexlayout-i18n.php.

  Therefore I pasted this code form the EditPreview-Modul into the flexlayout-i18n.php:



  The red marked lines are my changes



  $PageEditFmt = "

    <form name='wikieditform' action='\$ScriptUrl' method='post'>

    <input type='hidden' name='pagename' value='\$PageName' />

    <input type='hidden' name='action' value='post' />

    <table id='wikiheader' cellpadding='0' cellspacing='0'><tr>

    <td id='wikiheaderlogo' width='4' valign='bottom'>\$WikiImg</td>

    <td valign='bottom'>

      <span id='wikiheadergroup'>\$Group</span> /<br/>

      <span id='wikiheadertitle'>\$Title</span>

    </td>

    <td id='wikiheadercommands' valign='bottom'>

      <input type='submit' value=' $[Save] ' />

      <input type='submit' name='myaction' value='$[Preview]' />

      <input type='reset' value=' $[Reset] ' />

    </td>

    </tr></table>

    <div id='wikitext'>

    <div id='wikieditintro'>

    <a href='\$ScriptUrl/$[PmWiki/TipsForEditing]'>$[TipsForEditing]</a> -

    <a href='\$ScriptUrl/$[PmWiki/TextFormattingRules]'>$[TextFormattingRules]</a>

    </div>

    <textarea id='wikieditor' name='text' rows='25' cols='80'

    onkeydown='if (event.keyCode == 27) event.returnValue=false;'

    >\$Text</textarea><br /></form>";



  $myaction = $HTTP_POST_VARS['myaction'];

  if ($myaction=="$[Preview]") {  

      $action = "preview";

      $HandleActions = 

          array_merge($HandleActions,array('preview' => 'HandlePreview'));

      $PageHeaderFmt = "<h1>Vorschau \$PageName</h1><h3>Seite ist noch nicht gespeichert</h3><hr />";

      $PageFooterFmt = "<hr /><table border='0' cellspacing='0' cellpadding='0' width='100%'>

        <tr><td valign='bottom'><b>Ende der Vorschau: Speichern nicht vergessen</b></td>

            <td valign='bottom' align='right'>

                <a href='#top'>Anfang der Seite</a></td></tr></table>";

      $HandlePreviewFmtH = array(&$HTMLStartFmt,&$PageEditTitleFmt,

          &$PageEditFmt,&$PageHeaderFmt);

      $HandlePreviewFmtF = array(&$PageFooterFmt,&$HTMLEndFmt);

  }



  function HandlePreview($pagename) {

    global $HTTP_POST_VARS,$HandlePreviewFmtH,$HandlePreviewFmtF;

    global $Text,$HTMLTitle,$GCount;

    $Text = str_replace("\r","",stripslashes($HTTP_POST_VARS['text']));

    $pretext = PrepareText($pagename,$Text);

    $Text = htmlspecialchars($Text,ENT_NOQUOTES);

    $HTMLTitle = "Preview $pagename"; $GCount = 0;

    PrintFmt($pagename,$HandlePreviewFmtH);

    PrintText($pagename,$pretext);

    PrintFmt($pagename,$HandlePreviewFmtF);

  }



  function PrepareText($pagename,$text) {

    global $GroupNamePattern,$PageTitlePattern,$MaxIncludes,$SpaceWikiWords,

      $GroupHeaderFmt,$GroupFooterFmt;

    global $BrowseDirectives,$HandleBrowseFmt;

    $inclcount=0;

    while ($inclcount<$MaxIncludes &&

        preg_match("/\\[\\[include:(.*?)\\]\\]/",$text,$match)) {

      $inclname=$match[1]; $incltext='';

      if (!preg_match("/^$GroupNamePattern([\\/.])$PageTitlePattern\$/",

          $inclname))

        $inclname = FmtPageName('$Group',$pagename).".$inclname";

      $inclpage = RetrieveAuthPage($inclname,"read",false);

      if ($inclpage) $incltext=$inclpage['text'];

      $text = preg_replace("/\\[\\[include:(.*?)\\]\\]/",$incltext,$text,1);

      $inclcount++;

    }

    if (!strstr($text,"[[nogroupheader]]")) {

      $hdname = FmtPageName($GroupHeaderFmt,$pagename);

      if ($hdname != $pagename) 

        { $hdpage=ReadPage($hdname,""); $text = $hdpage['text'].$text; }

    }

    if (!strstr($text,"[[nogroupfooter]]")) {

      $hdname = FmtPageName($GroupFooterFmt,$pagename);

      if ($hdname != $pagename) 

        { $hdpage=ReadPage($hdname,""); $text = $text.$hdpage['text']; }

    }

    Lock(0);

    foreach($BrowseDirectives as $p=>$s) {

      if (strstr($text,$p)) $text = str_replace($p,eval($s),$text);

    }

    return $text;

  }



  Into the i18n-de.php I added the following line:



  'Preview' => 'Vorschau'



  And now my question:



  Why doesn't this script run?



  If I change the line



  if ($myaction=="$[Preview]") {  



  to



  if ($myaction=="Vorschau") {  



  then it works.



  Can someone help me?



  Andreas H?cker





  _______________________________________________

  Pmwiki-users mailing list

  Pmwiki-users at pmichaud.com http://pmichaud.com/mailman/listinfo/pmwiki-users_pmichaud.com



------------------------------------------------------------------------------


  _______________________________________________
  Pmwiki-users mailing list
  Pmwiki-users at pmichaud.com
  http://pmichaud.com/mailman/listinfo/pmwiki-users_pmichaud.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://contra.vosn.net/pipermail/pmwiki-users_pmichaud.com/attachments/20030821/2d658174/attachment-0001.htm


More information about the pmwiki-users mailing list