[Pmwiki-users] Preview function

Patrick R. Michaud pmichaud
Wed Aug 20 16:21:38 CDT 2003


Even better is to simply do

   if (@$HTTP_POST_VARS['myaction']>"") {

which simply checks to see if myaction was set without having to
worry about what its specific value may be (since no other controls
have the name 'myaction').

Pm


On Thu, Aug 21, 2003 at 12:21:32AM +0200, bernhard at weichel21.de wrote:
> 
>    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: [1]Andreas H?cker
> 
>    To: [2]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 doesnt 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
>    [3]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
> 
> References
> 
>    1. mailto:ahoecker at gmx.de
>    2. mailto:pmwiki-users at pmichaud.com
>    3. 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




More information about the pmwiki-users mailing list