'filterMarkdown', 'smartypants' => 'filterSmartyPants', 'g2image' => 'filterG2Image' ); $output = $text; foreach ($myfilters as $filtertag => $filterfunction) { $what = "'<$filtertag>(.*?)'$preg_flags"; $with = $filterfunction; // we use preg_replace_callback, which gives the filter function an array instead of // the actual text. $output = preg_replace_callback($what, $with, $output); } return $output; } /** Call the right function, but with the actual text as arg, not an array */ function filterMarkdown ($arr) { include_once "markdown.php"; return Markdown($arr[1]); } function filterSmartyPants ($arr) { include_once "smartypants.php"; return SmartyPants($arr[1]); } function filterG2Image ($arr) { return g2image($arr[1]); } /** * Input should be something like: albumname/imagename|60|right * 2nd and 3rd argument are optional. * Grabs the image from the gallery, resizes it and floats it accordingly. */ function g2image($g2itemstring) { require_once(dirname(__FILE__) . '/photos/embed.php'); $ret = GalleryEmbed::init(array('fullInit' => true, 'embedPath' => '/photos/')); if ($ret->isError()) { print 'GalleryEmbed::init failed, here is the error message: ' . $ret->getAsHtml(); exit; } /* Check for the Item Size | parameter & Clean up Strings.. */ $g2arr = explode('|', $g2itemstring); if (!$g2arr[0]) return ("***Error: didn't supply anything to show***"); else $g2itempath = $g2arr[0]; if ($g2arr[1]) $g2itemsize = $g2arr[1]; if ($g2arr[2]) $g2itemfloat = $g2arr[2]; $g2itempath = str_replace ("+", " ", $g2itempath); /* Get the Image ID from the path */ list ($ret, $g2itemid) = GalleryCoreAPI::fetchItemIdByPath($g2itempath); /* define the block options */ $blockoptions['blocks'] = 'specificItem'; $blockoptions['itemId'] = $g2itemid; $blockoptions['show'] = ''; /* Use a custom frame from gallery2: */ /* $blockoptions['itemFrame'] = 'bleh'; */ /* Define image size */ if ($g2itemsize) $blockoptions['maxSize'] = $g2itemsize; else if ( $g2_option['g2_postimgsize'] ) $blockoptions['maxSize'] = $g2_option['g2_postimgsize']; /* get the bloody image */ list ($ret, $itemhtml, $headhtml) = GalleryEmbed::getImageBlock($blockoptions); if ($ret->isError()) $itemhtml = "***Not Found***"; /* Here, we use a custom CSS class named "floatleft" or "floatright" to achieve the float. * One could do the same with something like: * = '
... */ if (($g2itemfloat == "left") || ($g2itemfloat == "right")) $extraCssClass = " float${g2itemfloat}"; $rethtml = "
${itemhtml}
"; return($rethtml); } ?>