Configuration -> Components * tab. * * The gallery patch will not effect gallery's operation except when embedded inside * Mambo. * * Gallery Patch Information: * http://www.thegillis.net/programming_papers/php/mambo_and_gallery_sef_urls_with_fix.html * * Extension Information: **/ class sef_gallery { /** * Removes all &'s from a url back to regular &'s. Better for parsing. **/ function ampStrip($url) { $url = str_replace( '&', '&', $url ); return $url; } /** * Creates the SEF advance URL out of the Mambo request * Input: $string, string, The request URL (index.php?option=com_example&Itemid=$Itemid) * Output: $sefstring, string, SEF advance URL ($var1/$var2/) **/ function create ($string) { // For clerification, I'll use /gallery as the component prefix. This is set in the // xaenon config file // This will convert the following: // Gallery main page: // /index.php?option=com_gallery&Itemid=28 => /gallery/ // Album pages // /index.php?option=com_gallery&Itemid=28&set_albumName=album&include=view_album.php => /gallery/album/ // Image pages // /index.php?option=com_gallery&Itemid=28&set_albumName=album&id=image&include=view_photo.php => /gallery/album/image // Full image page // /index.php?option=com_gallery&Itemid=28&set_albumName=album&id=image&include=view_photo.php&full=1 => /gallery/album/image?full=1 // // Gallery appears to bypass the page code, but should still work. // Make sure we have a & free string $string = sef_gallery::ampStrip($string); // This is the SEF string. Starts out as just the main gallery, no album selected $sefstring = ""; // Check if there's an album name if (preg_match("/[\?&]set_albumName=([^&]*)/",$string,$matches)) { // make sef "album/" $sefstring .= $matches[1].'/'; // Check for an image if (preg_match("/[\?&]id=([^&]*)/",$string,$matches)) { // make "album/image" $sefstring .= $matches[1]; // now check if there's a full string if(preg_match("/[\?&]full=([0-9]+)/",$string,$matches)) { // make "album/image?full=1" $sefstring .= '?full='.$matches[1]; } } } return $sefstring; } /** * Reverts to the Mambo query string out of the SEF advance URL * Input: * $url_array, array, The SEF advance URL split in arrays (first custom virtual directory beginning at $pos+1) * $pos, int, The position of the first virtual directory (component) * Output: $QUERY_STRING, string, Mambo query string (var1=$var1&var2=$var2) * Note that this will be added to already defined first part (option=com_example&Itemid=$Itemid) **/ function revert ($url_array, $pos) { // The documentation says to declare the parameters as globals, but I think this is poor // coding to register globals. If you absolutly need it, uncomment the following global line. // Ideally no code should use this feature //global $set_albumName, $id; // $url_array == array( "component", "gallery", $album, $img ); if(count($url_array) != 4) { error_log("Unknown parameter count to gallery extension! Found: ".count($url_array)); return ""; } $set_albumName = $album = $url_array[2]; // check if there's a ?full=1 parameter $fullArray = explode("?", $url_array[3]); $id = $img = $fullArray[0]; // Fullstring will be appended to the request string if it is defined $fullString = ''; if(isset($fullArray[1]) && $fullArray[1] == 'full=1') { $fullString = '&full=11'; $_GET['full'] = '1'; $_REQUEST['full'] = '1'; } // Now we can start building the internal url. // First check if an image was requested if(strlen($img) < 1) { // it's an album they're trying to view $_GET['set_albumName'] = $album; $_REQUEST['set_albumName'] = $album; $_GET['include'] = 'view_album.php'; $_REQUEST['include'] = 'view_album.php'; return "set_albumName=".$album."&include=view_album.php"; } else { // it's an image $_GET['set_albumName'] = $album; $_REQUEST['set_albumName'] = $album; $_GET['id'] = $img; $_REQUEST['id'] = $img; return "set_albumName=".$album."&id=".$img."&include=view_photo.php".$fullString; } } } ?>