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