We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3586
    • 27 Posts
    Hi Folks,

    right now I’m writing my first snippet. But I got some problems when changing my code. I’m not quite sure how to get rid of this.
    Almost every time I change the code of my snippet, whether by the built-in-editor, my texteditor or however, I get the following error:

    Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/bello/public_html/manager/includes/document.parser.class.inc.php(691) : eval()'d code on line 1486


    Well, even if I undo the changes I still got this error. Caching for this page is turned off, so modx shouldn’t use the old version.
    What can I do?

    Thanks,
    bll0
      • 7923
      • 4,213 Posts
      Without seeing your code, I would suggest that you look around line 1486 and check if some line is missing ; at the end..


        "He can have a lollipop any time he wants to. That's what it means to be a programmer."
        • 3586
        • 27 Posts
        Well, as I said, I’ve fallen back to an older Version which worked this morning (copied it from my editor to the web-editor) and it didn’t work. Clearing the cache didn’t do the trick either. Does anyone got another hint? Or shall I post the code (around 1900 lines...) here?

          • 7923
          • 4,213 Posts
          In the end of the parse error there is this: "eval()’d code on line 1486". That means that the error you have in your script is around that line and unexpected T_CONSTANT_ENCAPSED_STRING can be seen if some lines are not terminated with ; correctly or are missing " quotes.. but if you can’t get it to work, copy-paste few lines around the error line to here (before and after the error line), and I’ll be happy to take a look. Remember to wrap the code between the CODE -tags here.


            "He can have a lollipop any time he wants to. That's what it means to be a programmer."
            • 3586
            • 27 Posts
            All right, here you go. This is the function where 1486 is in. You’ll find the line by looking for lots of #####.

            <?php //I am telling SMF to highlight sysntax, strip me out.
            
            function spgm_DisplayPicture($strGalleryId, $iPictureId, $strFilterFlags) {
            
              global $cfg;
             
              $arrPictureFilenames = spgm_CreatePictureArray($strGalleryId, $strFilterFlags, true);
              $iPictureNumber = count($arrPictureFilenames);
              $strPathToPictures = DIR_GAL.$strGalleryId.'/';
              $strPictureFilename = $arrPictureFilenames[$iPictureId];
              $_strFileExtension = strrchr($strPictureFilename, '.');
              $strPictureBasename = substr($strPictureFilename, 0, -strlen($_strFileExtension));  
              $strPictureURL = $strPathToPictures.$strPictureFilename;  
              $strCaptionURL = $strPictureURL.EXT_PIC_CAPTION; // DEPRECATED
              $strGalleryName = str_replace('_', ' ', $strGalleryId);
              $strGalleryName = str_replace('/', ' » ', $strGalleryName);
              $bSlideshowMode = strstr($strFilterFlags, PARAM_VALUE_FILTER_SLIDESHOW) != FALSE;
            
              $output = '';
              
              if ($cfg['conf']['thumbnailsPerPage'] != 0) {
                $iPageNumber = $iPictureNumber / $cfg['conf']['thumbnailsPerPage'];
                if ($iPageNumber > (int)($iPictureNumber / $cfg['conf']['thumbnailsPerPage']))
                  $iPageNumber = (int)++$iPageNumber;
              }
              
              spgm_Trace(
                '<p>function spgm_DisplayPicture</p>'."\n"
                .'strGalleryId: '.$strGalleryId.'<br />'."\n"
                .'strPictureFilename: '.$strPictureFilename.'<br />'."\n"
                .'strPathToPictures: '.$strPathToPictures.'<br />'."\n"
                .'strPictureURL: '.$strPictureURL.'<br />'."\n"
              );
              
              
              if (($iPictureId < 0) || ($iPictureId > $iPictureNumber-1) || $iPictureId == '')
                spgm_Error(ERRMSG_UNKNOWN_PICTURE);
            
              if (! spgm_IsGallery($strGalleryId) )
                spgm_Error(ERRMSG_UNKNOWN_GALLERY);
            
            
              if ( spgm_IsPicture($strPictureFilename, $strGalleryId) ) {
                $arrPictureDim = getimagesize($strPictureURL);
                $iPreviousPictureId = $iPictureId - 1;
                $iNextPictureId = $iPictureId + 1;
            		
                // always display the gallery header
                $output .= spgm_DisplayGalleryNavibar($strGalleryId, $strFilterFlags, $iPictureId, $arrPictureFilenames);   
            
                // thumbnails are only displayed if wanted
                if ( ! strstr($strFilterFlags, PARAM_VALUE_FILTER_NOTHUMBS) 
                       && ! $bSlideshowMode  ) {
                  $output .= spgm_DisplayThumbnails($strGalleryId, $arrPictureFilenames, $iPictureId, '', $strFilterFlags);
                }
            
                // left-right orientation
                if ($cfg['conf']['galleryOrientation'] == ORIENTATION_LEFTRIGHT) {
                  $output .= '  <td class="'.CLASS_TD_ORIENTATION_RIGHT.'">'."\n\n";
                }
                
                // Prepare layout for stuff left
                $output .= '<br /><br />'."\n";
                $output .= '<table cellspacing="0" class="'.CLASS_TABLE_PICTURE.'">'."\n";
            
                // display the previous/next arrow section if we are not in slideshow mode
                if ( ! $bSlideshowMode ) {
                  $output .= ' <tr>'."\n";
                  $output .= '   <td class="'.CLASS_TD_PICTURE_NAVI.'"><a name="pic" id="'.ID_PICTURE_NAVI.'"></a>'."\n";
            
                  if ($iPreviousPictureId >= 0) 
                    $output .= '    <a href="'.$cfg['global']['documentSelf'].'?'.PARAM_NAME_GALID.'='.$strGalleryId.'&'.PARAM_NAME_PICID.'='.$iPreviousPictureId.'&'.PARAM_NAME_FILTER.'='.str_replace(PARAM_VALUE_FILTER_SLIDESHOW, '', $strFilterFlags).$cfg['global']['URLExtraParams'].'#pic">'.$cfg['theme']['previousPictureIcon'].'</a> ';
               
                  //multi-language support
                  $cfg['locale']['pictureNaviBar'] = str_replace(PATTERN_CURRENT_PIC, "$iNextPictureId", $cfg['locale']['pictureNaviBar']);
                  $cfg['locale']['pictureNaviBar'] = str_replace(PATTERN_NB_PICS, "$iPictureNumber", $cfg['locale']['pictureNaviBar']);
                  $output .= ' '.$cfg['locale']['pictureNaviBar'].' ';
            
                  if ($iNextPictureId < $iPictureNumber)
                    $output .=  '<a href="'.$cfg['global']['documentSelf'].'?'.PARAM_NAME_GALID.'='.$strGalleryId.'&'.PARAM_NAME_PICID.'='.$iNextPictureId.'&'.PARAM_NAME_FILTER.'='.str_replace(PARAM_VALUE_FILTER_SLIDESHOW, '', $strFilterFlags).$cfg['global']['URLExtraParams'].'#pic">'.$cfg['theme']['nextPictureIcon'].'</a>'."\n";
                    $output .=  '  </td>'."\n".' </tr>'."\n";
                }
             
                // Client side zoom buttons 
                if (count($cfg['conf']['zoomFactors']) > 0) { 
                  $output .=  '</tr>'."\n".'<tr>'."\n".'  <td class="'.CLASS_TD_ZOOM_FACTORS.'">'."\n";
                  for ($i=0; $i<count($cfg['conf']['zoomFactors']); $i++) {
                    $iHeight = (int)($arrPictureDim[1]*$cfg['conf']['zoomFactors'][$i]/100);
            ##############line 1486########################################
                    $iWidth = (int)($arrPictureDim[0]*$cfg['conf']['zoomFactors'][$i]/100);
                    $output .=   '<input type="button" class="'.CLASS_BUTTON_ZOOM_FACTORS.'" value=" '.$cfg['conf']['zoomFactors'][$i].'% " ';
                    $output .=   'onClick="document.getElementById('."'".ID_PICTURE."'".').setAttribute('."'".'height'."'".', '.$iHeight.'); ';
                    $output .=   'document.getElementById('."'".ID_PICTURE."'".').setAttribute('."'".'width'."'".', '.$iWidth.'); ';
                    $output .=   'document.getElementById('."'".ID_PICTURE_NAVI."'".').scrollIntoView();">'."\n";
                  }
                  $output .=   "\n".'  </td>'."\n".'</tr>'."\n";
                }
            
                // EXIF data
                if ( count($cfg['conf']['exifInfo']) > 0 ) {
                  if ( extension_loaded('exif') ) { // ... where available
                    $output .=   '<tr><td>'."\n";
                    $strExifData = spgm_LoadExif($strPictureURL);
                    $output .=  '[<span onmouseover="return overlib(\''.$strExifData.'\', CAPTION, \''.$cfg['locale']['exifHeading'].' '.$strPictureFilename.'\', STICKY);" onmouseout="return nd();" style="color: #2e408d; font-weight: bold; font-size: 9pt;">Exif</span>]';
                    $output .= '</td></tr>'."\n";
                  }
                }
            
                //Load pictures if slideshow mode is enabled
                if ( $bSlideshowMode ) {
                  $output .= '<script language="Javascript">'."\n";
                  $iPictureNumber = count( $arrPictureFilenames );
                  $_dim = array();
                  $_strPicturePath = '';
                  for ($i=0; $i<$iPictureNumber; $i++) {
                    $_strPicturePath = $strPathToPictures.$arrPictureFilenames[$i];
                    $_dim = getimagesize($_strPicturePath);
                    $_strPictureCaption = '';*/
            	if ( isset($cfg['captions'][$arrPictureFilenames[$i]]) ) {
                      $_strPictureCaption = $cfg['captions'][$arrPictureFilenames[$i]];
                    }
                    $output .= '  addPicture(\''.$_strPicturePath.'\', \''.addslashes($_strPictureCaption).'\', '.$_dim[0].', '.$_dim[1].');'."\n";
                  }
                  $output .='</script>'."\n";
                }
            
                // compute image dimensions
                $iWidth = $arrPictureDim[0];
                $iHeight = $arrPictureDim[1];
                if ($cfg['conf']['fullPictureWidth'] != ORIGINAL_SIZE) {
                  $iWidth = $cfg['conf']['fullPictureWidth'];
                  if ($cfg['conf']['fullPictureHeight'] == ORIGINAL_SIZE) {
                    $iHeight = (int)$arrPictureDim[1]*($cfg['conf']['fullPictureWidth']/$arrPictureDim[0]);
                  } else {
                    $iHeight = $cfg['conf']['fullPictureHeight'];
                  }
                } else {
                  if ($cfg['conf']['fullPictureHeight'] != ORIGINAL_SIZE) {
                    $iHeight = $cfg['conf']['fullPictureHeight'];
                    $iWidth = (int)$arrPictureDim[0]*($cfg['conf']['fullPictureHeight']/$arrPictureDim[1]);
                  }
                }
            	
                // Eventually display the picture
                $output .='<tr>'."\n";
                $output .='  <td class="'.CLASS_TD_PICTURE_PIC.'">'."\n";
                
                // Overlib hidden span for EXIF data
                $output .='  <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'."\n";
            
                $output .= spgm_DropShadowsBeginWrap();
            
                if (! ($iNextPictureId < $iPictureNumber) ) $iNextPictureId = 0; // to link to the appropriate next pic
                if ( ! $bSlideshowMode ) {
                  if ($cfg['conf']['popupOverFullPictures'] == TRUE) {
                    $iPopupWidth = $cfg['conf']['popupWidth'];
                    $iPopupHeight = $cfg['conf']['popupHeight'];
                    $strJustPicture = 'false';
                    if ($cfg['conf']['popupFitPicture'] == true) {
                      $iPopupWidth = $arrPictureDim[0];
                      $iPopupHeight = $arrPictureDim[1];
                      $strJustPicture = 'true';
                    }
                    $output .= '    <a href="#?"';
                    $output .= ' onclick="popupPicture(\''.$strPictureURL.'\', '.$iPopupWidth.', '.$iPopupHeight.', '.$strJustPicture.');">';
                  } else {
                    $output .= '      <a href="'.$cfg['global']['documentSelf'].'?';
                    $output .= PARAM_NAME_GALID.'='.$strGalleryId.'&';
                    $output .= PARAM_NAME_PICID.'='.$iNextPictureId.'&';
                    $output .= PARAM_NAME_FILTER.'='.str_replace(PARAM_VALUE_FILTER_SLIDESHOW, '', $strFilterFlags).$cfg['global']['URLExtraParams'].'#pic">';
                  }
                }
            
                $output .= '<img id="'.ID_PICTURE.'" src="'.$strPictureURL.'" width="'.$iWidth.'" height="'.$iHeight.'" alt="'.$strPictureURL;
                $output .= '" class="'.CLASS_IMG_PICTURE.'" />';
                if ( ! $bSlideshowMode ) {
                  $output .= '</a>'."\n";
                }
            
                $output .= spgm_DropShadowsEndWrap();
            
                $output .= '  </td>'."\n";
                $output .='</tr>'."\n";
                
                // display the picture's filename if needed
                if ($cfg['conf']['filenameWithPictures'] == true) {
                  $output .=  '<tr>'."\n";
                  $output .=  '  <td class="'.CLASS_TD_PICTURE_FILENAME.'">'."\n";
                  $output .=  $strPictureBasename.'<br />'."\n";
                  $output .=  '  </td>'."\n";
                  $output .=  '</tr>'."\n";
                }
            
                // display the caption
                $output .= '<tr>'."\n";
                $output .=  '  <td id="'.ID_PICTURE_CAPTION.'" class="'.CLASS_TD_PICTURE_CAPTION.'"> '."\n";
                if ( isset($cfg['captions'][$strPictureFilename]) ) {
                  $output .=  $cfg['captions'][$strPictureFilename];
                }
            
                $output .= '  </td>'."\n";
                $output .='</tr>'."\n";
                $output .= '</table>'."\n";
                
                // left-right orientation
                if ($cfg['conf']['galleryOrientation'] == ORIENTATION_LEFTRIGHT) {
                  $output .= '  </td>'."\n";
                  $output .='</tr>'."\n";
                  $output .='</table>'."\n";
                }
            
                if ( $bSlideshowMode ) {
                  $output .= '<script language="Javascript">runSlideShow();</script>'."\n";
                }
            
              }
              else
                spgm_Error(ERRMSG_UNKNOWN_PICTURE);
             
             return $output;
            }


            The whole source of the snippet can be found here: http://utopia.proempel.de/spgm.php.txt

            moderator note: Syntax Highlighting activated
              • 7923
              • 4,213 Posts
              Hi,

              Actually the line 1486 is 3 lines below your mark, and it was missing " quote (atleast). Try replacing:

              this (line 1486):
              $output .=   'onClick="document.getElementById('."'".ID_PICTURE."'".').setAttribute('."'".'height'."'".', '.$iHeight.'); ';

              with this:
              $output .=   'onClick="document.getElementById('."'".ID_PICTURE."'"".').setAttribute('."'".'height'."'".', '.$iHeight.'); ';


              It helps to use a coding editor which can do php syntax highlighting. Looking at the line highlighted before you make the replace you will see that the $iHeight variable is not highlighted as a variable, it’s show as a part of the string, and from that you can gather that there is probably some quotes missing.

              There might be other errors in your code too, I just checked that line. Hope it helps!


                "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                • 3586
                • 27 Posts
                Thanks a lot, that was the problem.
                Right now as you said it, I can see the incorrect highlighting in my editor (using kate on linux).

                I’m not sure if there are other problems, but at the moment it is working... I just wonder for how long wink
                  • 7923
                  • 4,213 Posts
                  Great that you got it to work! I see that you allready posted your snippet too, thanks for the contribution! smiley


                    "He can have a lollipop any time he wants to. That's what it means to be a programmer."