1: <?php
2:
3: /**
4: * This file contains the abstract uri builder class.
5: *
6: * @package Core
7: * @subpackage Frontend_URI
8: * @author Rudi Bieller
9: * @copyright four for business AG <www.4fb.de>
10: * @license http://www.contenido.org/license/LIZENZ.txt
11: * @link http://www.4fb.de
12: * @link http://www.contenido.org
13: */
14:
15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
16:
17: /**
18: * URI builder class.
19: *
20: * @package Core
21: * @subpackage Frontend_URI
22: */
23: abstract class cUriBuilder {
24:
25: /**
26: * Holds final value of built URL.
27: *
28: * @var string
29: */
30: protected $sUrl; // needed in this context
31:
32: /**
33: * Holds URL that is used as base for an absolute path
34: * E.g. http://contenido.org/
35: *
36: * @var string
37: */
38: protected $sHttpBasePath; // needed in this context
39:
40: /**
41: * Implementation of Singleton.
42: *
43: * It is meant to be an abstract function but not declared as abstract,
44: * because PHP Strict Standards are against abstract static functions.
45: *
46: * @throws cBadMethodCallException
47: * if child class has not implemented this function
48: */
49:
50: public static function getInstance() {
51: throw new cBadMethodCallException("Child class has to implement this function");
52: }
53:
54: /**
55: * Set http base path.
56: * E.g. http://contenido.org/
57: *
58: * @param string $sBasePath
59: */
60: public function setHttpBasePath($sBasePath) {
61: $this->sHttpBasePath = (string) $sBasePath;
62: }
63:
64: /**
65: * Return http base path.
66: * E.g. http://contenido.org/
67: *
68: * @return string
69: */
70: public function getHttpBasePath() {
71: return $this->sHttpBasePath;
72: }
73:
74: /**
75: * Builds a URL in index-a-1.html style.
76: *
77: * Index keys of $aParams will be used as "a", corresponding values
78: * as "1" in this sample.
79: *
80: * @param array $aParams
81: * @param bool $bUseAbsolutePath [optional]
82: * @throws cInvalidArgumentException
83: */
84: abstract public function buildUrl(array $aParams, $bUseAbsolutePath = false);
85:
86: /**
87: * Return built URL.
88: *
89: * @return string
90: */
91: public function getUrl() {
92: return (string) $this->sUrl;
93: }
94:
95: }
96: