<div dir="ltr">Hi,<div><br></div><div>I have a very bizarre side effect from a custom markup, and the most bizarre is that it is a "new" problem in the sense that it has worked in the past (I can't remember under which PmWiki version it worked last, though).</div><div><br></div><div>The bizarre thing is that when, on a page, I invoke the custom markup the second time, it prevents the save from working, the page stays blank and does not reload. I am pretty sure that this is the cause, because I went to some very old pages with the markup, and the pages with only one instance of the markup load perfectly, but old pages with two or more instances of the markup do not load anymore !</div><div><br></div><div>I have no idea what might be causing this as I am not that good at programming and at PHP in particular, but I have copied the code of the recipe below. My apologies for the probably very badly written code.</div><div><br></div><div>Note that it's based on this: <a href="http://ajaxian.com/archives/popbox-a-javascript-image-magnifier">http://ajaxian.com/archives/popbox-a-javascript-image-magnifier</a> but I am not sure how it's relevant to the issue... Note that I am using a very old version of the script, do you think it might be the reason ?</div><div><br></div><div>Can anyone please help me solve this mystery ?</div><div><br></div><div>Thanks in advance,</div><div><br></div><div>Philippe</div><div><br></div><div>========================================================</div><div><br></div><div><?php if (!defined('PmWiki')) exit();<br>/*  Copyright 2010 Philippe Krait (<a href="mailto:philippe@krait.net">philippe@krait.net</a>)<br><br>    This script activates the (:popbox ...:) markup.<br><br>    To activate this script, copy it into the cookbook/ directory,<br>    then add the following line to your local/config.php:<br><br>        include_once('cookbook/popbox.php');<br>*/<br><br># Creates the Markup<br>#Markup('popbox','fulltext', '/\\(:popbox(\\s.*?)?:\\)/e', "Keep(PopBox(PSS('$1')))");<br>Markup_e('popbox','fulltext', '/\\(:popbox(\\s.*?)?:\\)/', "Keep(PopBox(\$m[1]))");<br><br># Defines where the javascript, css and images are<br>SDV($popBoxDirUrl,$PubDirUrl."/cookbook/popBox");<br><br>SDV($HTMLHeaderFmt['popboxjava'] , "<script src='$popBoxDirUrl/scripts/PopBox.js' type='text/javascript'></script><br><script type='text/javascript'><br>popBoxWaitImage.src = '$popBoxDirUrl/images/spinner40.gif';<br>popBoxRevertImage = '$popBoxDirUrl/images/magminus.gif';<br>popBoxPopImage = '$popBoxDirUrl/images/magplus.gif';<br></script>");<br><br>function PopBox($attr) {<br>     $EnablePathInfo = 1;<br><br>        $attr = preg_replace('/ *([a-zA-Z]=)([^\']\\S*)/',"&\$1\$2",$attr);<br> $attr = substr($attr,1);<br>      $el = explode("&", $attr);<br><br>    $Header = "";<br>       $Tailer = "";<br><br>     $Img = "http://".$_SERVER['SERVER_NAME']."/pmwiki/uploads/Main/Images/Unknown.jpg";<br>       $ImgPath = "";<br>      $ImgDir = "http://".$_SERVER['SERVER_NAME']."/pmwiki/uploads/Main/Images";<br>        $ImgType = "";<br>      $ImgName = "";<br>      $ImgFormat = "jpg";<br><br>       $size = 250;<br>  $title = 'Click to magnify/shrink';<br>   $caption = 'Caption';<br> $align = '';<br># $command = 'onmouseover';<br>     $command = 'onclick';<br><br>       $startX = "startpos.x";<br>     $startY = "startpos.y";<br>     # The newLeft and newTop parameters are treated by default as positions relative to the image starting point and can be either a negative or positive number.<br> # If either value is a numeric string followed by an upper case "A" then it is treated as an absolute position, relative to its containing element (typically the browser window).<br>  # Ex: "200A". If either value is null the image will be centered in the browser window.<br>     $endX = "null";<br>     $endY = "null";<br><br>   $startW = "startpos.w";<br>     $startH = "startpos.h";<br>     # If the newWidth value is 0 the full width of the image will be used up to a maximum of the browser window width.<br>    # If the newWidth value is  null the full size of the image will be used regardless of the browser window width.<br>     # Passing either 0 or null will still scale the image against the image height. An integer greater than 0 will not be scaled.<br> $endW = 0;<br>    # If the newHeight value is 0 the full height of the image will be used up to a maximum of the browser window height.<br> # If the newHeight value is  null the full size of the image will be used regardless of the browser window height.<br>   # Passing either 0 or null will still scale the image against the image width. An integer greater than 0 will not be scaled.<br>  $endH = 0;<br><br>  $sM = 100;<br>    $sS = 100;<br><br>  $RevertBarAbove = "true";<br>   $CaptionBelow = "true";<br><br>   $Style = "PopBoxImageLarge";<br><br>      foreach ($el as $k => $v) {<br>                $cpl = explode("=", $v);<br>            switch ($cpl[0]) {<br>                    case "A":<br>                   case "a":<br><br>                         global $pagename, $UploadUrlFmt, $EnablePathInfo;<br><br>                           $attpage = $pagename;<br>                         $path = str_replace(array('"', ' '), array('', '%20'), $cpl[1]);<br><br>                               if (preg_match('!^(.*)/([^/]+)$!', $path, $match)) {<br>                                  $attpage = MakePageName($attpage, $match[1]);<br>                                 $path = $match[2];<br>                            }<br><br>#                          if ($EnablePathInfo)<br>                                  $attpage=str_replace(".", "/", $attpage);<br><br>#echo $EnablePathInfo."<br>\n";<br>#echo $UploadUrlFmt."<br>\n";<br>#echo $attpage."<br>\n";<br>#echo $path."<br>\n";<br><br>                            $ImgPath = FmtPageName("$UploadUrlFmt/$attpage/$path", $attpage);<br>#echo $ImgPath."<br>\n";<br>                         break;<br>                        case "I":<br>                   case "i":<br>                           $ImgPath = str_replace(array('"', ' '), array('', '%20'), $cpl[1]);<br>                              break;<br>                        case "T":<br>                   case "t":<br>                           $ImgType = str_replace('"', '', $cpl[1]);<br>                                break;<br>                        case "N":<br>                   case "n":<br>                           $ImgName = str_replace(array('"', ' '), array('', '%20'), $cpl[1]);<br>                              break;<br>                        case "F":<br>                   case "f":<br>                           $ImgFormat = str_replace('"', '', $cpl[1]);<br>                              break;<br>                        case "S":<br>                   case "s":<br>                           $size = str_replace('"', '', $cpl[1]);<br>                           break;<br>                        case "C":<br>                   case "c":<br>                           $caption = str_replace('"', '', $cpl[1]);<br>                                break;<br>                        case "P":<br>                   case "p":<br>                                           $assignformat=array(    "lfloat" => "lfloat", "rfloat" => "rfloat",<br>                                                             "lframe" => "lfloat frame", "rframe" => "rfloat frame",<br>                                                         "lfloatclear" => "lfloat lclear", "rfloatclear" => "rfloat rclear",<br>                                                             "lframeclear" => "lfloat frame lclear", "rframeclear" => "rfloat frame rclear", );<br><br>                            switch (str_replace('"', '', $cpl[1])) {<br>                                 case "left":  case "Left":  case "LEFT":<br>                                        case "right": case "Right": case "RIGHT":<br>                                               $Header = "<div style='text-align: ".strtolower($cpl[1]).";'>";<br>                                             $Tailer = "</div>";<br>                                           break;<br>                                        case "lfloat":        case "Lfloat":        case "LFloat":        case "LFLOAT":<br>                                      case "rfloat":        case "Rfloat":        case "RFloat":        case "RFLOAT":<br>                                      case "lfloatclear":   case "Lfloatclear":   case "LFloatClear":   case "LFLOATCLEAR":<br>                                 case "rfloatclear":   case "Rfloatclear":   case "RFloatClear":   case "RFLOATCLEAR":<br>                                         $Header = "<div class='".$assignformat[strtolower(str_replace('"', '', $cpl[1]))]."' style='text-align: center;'>";<br>                                            $Tailer = "</div>";<br>                                           break;<br>                                        case "lframe":        case "Lframe":        case "LFrame":        case "LFRAME":<br>                                      case "rframe":        case "Rframe":        case "RFrame":        case "RFRAME":<br>                                      case "lframeclear":   case "Lframeclear":   case "LFrameClear":   case "LFRAMECLEAR":<br>                                 case "rframeclear":   case "Rframeclear":   case "RFrameClear":   case "RFRAMECLEAR":<br>                                         $Header = "<div class='".$assignformat[strtolower(str_replace('"', '', $cpl[1]))]."' style='text-align: center;'>";<br>                                            $Tailer = "<br /><strong><em>$caption</em></strong></div>";<br>                                             break;<br>                                        case "note":  case "Note":  case "NOTE":<br>                                                $Header = "<table class='widenote'><tr><td class='noteheader'>$caption</td></tr><tr><td>";<br>                                                $Tailer = "</td></tr></table>";<br>                                           break;<br>                                }<br>                             break;<br>                }<br>     }<br><br>   $ImgPath = "$ImgPath.$ImgFormat";<br><br>#echo "Path: |".$ImgPath."|<br>\n";<br><br>        function UR_exists($uri) {<br>            $ch = curl_init($uri);<br>            curl_setopt($ch, CURLOPT_NOBODY, true);<br>            curl_exec($ch);<br>            $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);<br>            curl_close($ch);<br><br>            return $code == 200;<br>        }<br><br>       if (UR_exists($ImgPath)) $Img = $ImgPath;<br>     else $caption = "Unknown Image ! ".$caption;<br><br>      return "$Header<br>          <img src='$Img' pbsrc='$Img' title='$title' pbCaption='$caption'<br>           $command='  var startPos = GetElementPosition(this);<br>                              popBoxRevertBarAbove=$RevertBarAbove;<br>                         popBoxCaptionBelow=$CaptionBelow;<br>                             PopEx(this, $endX, $endY, $endW, $endH, $sM,\"$Style\");'<br>               alt='' width='".$size."px' $align  /><br>           $Tailer";<br>}<br><br>?><br></div></div>