1: <?php
2: /**
3: * CONTENIDO Chain.
4: * Generate base href for multiple client domains
5: *
6: * Client setting must look like this:
7: * Type: client
8: * Name: frontend_pathX (X any number/character)
9: * Value: base href URL (e.g. http://www.example.org/example/)
10: *
11: * @package Core
12: * @subpackage Chain
13: * @version SVN Revision $Rev:$
14: *
15: * @author Andreas Lindner
16: * @copyright four for business AG <www.4fb.de>
17: * @license http://www.contenido.org/license/LIZENZ.txt
18: * @link http://www.4fb.de
19: * @link http://www.contenido.org
20: */
21:
22: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
23:
24: function cecCreateBaseHref($sCurrentBaseHref)
25: {
26: global $cfg, $client;
27:
28: $oClient = new cApiClient($client);
29: $aSettings = $oClient->getProperties();
30: if (is_array($aSettings)) {
31: foreach ($aSettings as $aClient) {
32: if ($aClient["type"] == "client" && strstr($aClient["name"], "frontend_path") !== false) {
33: $aUrlData = parse_url($aClient["value"]);
34:
35: if ($aUrlData["host"] == $_SERVER['HTTP_HOST'] ||
36: ("www." . $aUrlData["host"]) == $_SERVER['HTTP_HOST'] ||
37: $aUrlData["host"] == "www." . $_SERVER['HTTP_HOST'])
38: {
39: // The currently used host has been found as
40: // part of the base href(s) specified in client settings
41:
42: // Return base href as specified in client settings
43: $sNewBaseHref = $aClient["value"];
44: return $sNewBaseHref;
45: }
46: }
47: }
48: }
49:
50: // We are still here, so no alternative href was found - return the default one
51: return $sCurrentBaseHref;
52: }
53: ?>