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