<?php

	/*
	*	Gekko - Open Source Web Development Framework
	*	------------------------------------------------------------------------
	*	Copyright (C) 2004-2006, J. Carlos Nieto <xiam@users.sourceforge.net>
	*	This program is Free Software.
	*
	*	@package	Gekko
	*	@license	http://www.gnu.org/copyleft/gpl.html GNU/GPL License 2.0
	*	@author		J. Carlos Nieto <xiam@users.sourceforge.net>
	*	@link		http://www.gekkoware.org
	*/

	if (!defined("IN-GEKKO")) die("Get a life!");

	Class Plugin_relativeurls {
		function Plugin_relativeurls() {
			$PluginCore =& $GLOBALS["PluginCore"];
			// registering this plugin
			$PluginCore->Register("plugin_relativeurls", "template_output");
		 }
		 function Invoke ($event, $buff) {
		 	switch ($event) {
				case "template_output":
					if (!defined("GEKKO_USE_ABSOLUTE_URLS") || !GEKKO_USE_ABSOLUTE_URLS) {
						// replacing absolute uris with relative ones
						$buff = preg_replace("/(<[^>]*)=\"(".preg_quote(_l("C_SITE.URL"), "/").")([^>]*>)/",
						"\\1=\""._l("C_SITE.REL_URL")."\\3", $buff);
					}
				break;
			}
			return $buff;
		}
	}
?>