PHP Fatal error: Cannot redeclare displayMygif() (previously declared in ..modsnippet/25.include.cache.php:98) in ...modsnippet/25.include.cache.php on line 104
[[!buildImage? &part=`toc` &layoutType=`[[*ImageLayout:getTVLabel]]` &imageNameStart=`is[[*IssueNumber]]-id[[*id]]-` &cog1=`[[*cog1]]` &cog2=`[[*cog2]]` &photo=`[[*photo]]` ]]
//setup a few base variables $imagePath = 'images/icons/'; $exportPath = 'images/newsletter/'; $layout = $output = $thePart = $thelayoutType = $theImageName = $theCog1=$theCog2=$thePhoto=''; //lets get some snippet properties $thePart = $modx->getOption('part', $scriptProperties, '', true); $thelayoutType = $thePart.getLayoutName($modx->getOption('layoutType', $scriptProperties, '', true)); $theImageName = $modx->getOption('imageNameStart', $scriptProperties, '', true).$thelayoutType; $theCog1 = $imagePath.$thelayoutType.'_'.$modx->getOption('cog1', $scriptProperties, '', true).'.gif'; $theCog2 = $imagePath.$thelayoutType.'_'.$modx->getOption('cog2', $scriptProperties, '', true).'.gif'; $thePhoto = '/home/osldisraqadmin/public_html'.$modx->getOption('photo', $scriptProperties, '', true); displayImage ( $thelayoutType, $theImageName, $theCog1, $theCog2, $thePhoto, $exportPath); function getLayoutName($txt) { # based on code from # http://txt2re.com/index-php.php3?s=2%20cogs%201%20photo%20(Lay4)&-8&11 $re1='.*?'; # Non-greedy match on filler $re2='(Lay)'; # Word 1 $re3='(\\d+)'; # Integer Number 1 if ($c=preg_match_all ("/".$re1.$re2.$re3."/is", $txt, $matches)) { $word1=$matches[1][0]; $int1=$matches[2][0]; return $word1.$int1; } } function displayMygif($theImageContainer, $imageName) { header ('Content-Type: image/gif'); $fullImagePath = 'images/newsletter/'.$imageName.'.gif'; imagegif($theImageContainer, $fullImagePath); imagedestroy($theImageContainer); return; } function displayMyJPeg($theImageContainer, $imageName) { header ('Content-Type: image/jpg'); $fullImagePath = 'images/newsletter/'.$imageName.'.jpg'; imagejpeg($theImageContainer, $fullImagePath, 85); imagedestroy($theImageContainer); return; } function resizeMyPhoto ($photo, $newWidth, $newHeight) { $newPhotoContainer = imagecreatetruecolor($newWidth, $newHeight); //need the path of $photo $newPhotoSize = imagecopyresampled($newPhotoContainer, $photo, 0, 0, 0, 0, 131, 98, imagesx($photo), imagesy($photo)); return $newPhotoContainer; } //this is the main display function function displayImage ( $layout, $imageName, $cog1, $cog2='false', $photo='false', $exportPath) { global $modx; global $exportPath; //note that switch ($layout) { case 'tocLay1': $mycog1 = imagecreatefromgif($cog1); $imageContainer = imagecreatetruecolor(180, 98); imagecopy($imageContainer, $mycog1, 0, 0, 0, 0, 180, 98); displayMygif($imageContainer, $imageName); $endPath = $exportPath.$imageName.'.gif'; $output = $modx->getChunk('imgOutputTOC', array('imagePath'=>$endPath)); imagedestroy($mycog1); echo $output; break; case 'tocLay2': $mycog1 = imagecreatefromgif($cog1); $mycog2 = imagecreatefromgif($cog2); $imageContainer = imagecreatetruecolor(180, 98); imagecopy($imageContainer, $mycog1, 0, 0, 0, 0, 90, 98); imagecopy($imageContainer, $mycog2, 90, 0, 0, 0, 90, 98); displayMygif($imageContainer, $imageName); $endPath = $exportPath.$imageName.'.gif'; $output = $modx->getChunk('imgOutputTOC', array('imagePath'=>$endPath)); imagedestroy($mycog1); imagedestroy($mycog2); echo $output; break; default: echo 'nothing to layout'; break; } //end layout switch return $output; } //end displayImage function return $output;
This question has been answered by sottwell. See the first response.
if(!function_exists(displayMygif)){ function displayMygif($theImageContainer, $imageName) { header ('Content-Type: image/gif'); $fullImagePath = '/home/osldisraqadmin/public_html/xresource/images/newsletter/'.$imageName.'.gif'; imagegif($theImageContainer, $fullImagePath); imagedestroy($theImageContainer); return; } }