1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
<?php
/*
* $RCSfile: ModRewriteUrlGenerator.class,v $
*
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2006 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
* @package Rewrite
* @version $Revision: 1.2 $ $Date: 2006/01/10 04:42:17 $
* @author Douglas Cau <douglas@cau.se>
*/
/**
* Required class
*/
GalleryCoreApi::requireOnce('modules/rewrite/classes/RewriteUrlGenerator.class');
/**
* URL Generator for Apache mod_rewrite parser.
*
* @package Rewrite
* @subpackage Parsers
*/
class ModRewriteUrlGenerator extends RewriteUrlGenerator {
/**
* @see GalleryUrlGenerator::init
*/
function init($baseUri=null, $g2Uri=null, $embedSessionString=null) {
$ret = parent::init($baseUri, $g2Uri, $embedSessionString);
if ($ret) {
return $ret->wrap(__FILE__, __LINE__);
}
$ret = $this->_onLoad();
if ($ret) {
return $ret->wrap(__FILE__, __LINE__);
}
return null;
}
/**
* @see GalleryUrlGenerator::getCurrentUrl
* REQUEST_URI doesn't get rewritten by mod_rewrite
*/
function getCurrentUrl($forceDirect=false) {
if ($this->_error) {
return parent::getCurrentUrl($forceDirect);
}
if (!isset($this->_currentUrl[$forceDirect])) {
/* Let the provided path override the database stored value */
if (!empty($this->_path[$forceDirect])) {
$path = $this->_path[$forceDirect];
} else {
/* Get the configured value, if set */
$location = GalleryUtilities::isEmbedded() ? 'embeddedLocation' : 'galleryLocation';
list ($ret, $path) = GalleryCoreApi::getPluginParameter('module', 'rewrite',
'modrewrite.' . $location);
if ($ret || empty($path)) {
/*
* We dont know where we're at. This could happen if rewrite was installed
* in G2 standalone, and now is accessed as G2 embedded. Turn off short URLs
* for the embedded mode and wait until the user has set it up corectly.
*/
$this->_error = true;
return parent::getCurrentUrl($forceDirect);
}
}
$tmp = $path . $this->_file[$forceDirect];
$queryString = GalleryUtilities::getServerVar('QUERY_STRING');
if (!empty($queryString)) {
$tmp .= '?' . GalleryUtilities::htmlEntityDecode($queryString);
}
$this->_currentUrl[$forceDirect] = $this->makeUrl($tmp);
}
return $this->_currentUrl[$forceDirect];
}
}
?>
|