1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14:
15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
16:
17: 18: 19: 20: 21: 22:
23: class cUriBuilderFrontcontent extends cUriBuilder {
24:
25: 26: 27: 28: 29:
30: private static $_instance;
31:
32: 33: 34: 35: 36:
37: private $_sAmp = '&';
38:
39: 40: 41:
42: private function __construct() {
43: $this->sHttpBasePath = '';
44: }
45:
46: 47: 48: 49: 50:
51: public static function getInstance() {
52: if (self::$_instance == NULL) {
53: self::$_instance = new self();
54: }
55: return self::$_instance;
56: }
57:
58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80:
81: public function buildUrl(array $aParams, $bUseAbsolutePath = false, array $aConfig = array()) {
82: $bIdcatSet = isset($aParams['idcat']);
83: $bIdartSet = isset($aParams['idart']);
84: $bIdcatArtSet = isset($aParams['idcatart']);
85: if ($bIdcatSet === false && $bIdartSet === false && $bIdcatArtSet === false) {
86: throw new cInvalidArgumentException('$aParams must have at least one of the following values set: $aParams[idcat], $aParams[idart] or $aParams[idcatart]!');
87: }
88: $sHttpBasePath = $bUseAbsolutePath === true ? $this->sHttpBasePath : '';
89: if ($bIdcatSet === true) {
90: if ($bIdartSet === true) {
91: $this->sUrl = $sHttpBasePath . 'front_content.php?idcat=' . strval($aParams['idcat']) . $this->_sAmp . 'idart=' . strval($aParams['idart']);
92: } else {
93: $this->sUrl = $sHttpBasePath . 'front_content.php?idcat=' . strval($aParams['idcat']);
94: }
95: } else {
96: if ($bIdartSet === true) {
97: $this->sUrl = $sHttpBasePath . 'front_content.php?idart=' . strval($aParams['idart']);
98: } else {
99: if ($bIdcatArtSet === true) {
100: $this->sUrl = $sHttpBasePath . 'front_content.php?idcatart=' . strval($aParams['idcatart']);
101: } else {
102: throw new cException('Cannot build URL because of missing parameters!');
103: }
104: }
105: }
106:
107:
108: foreach ($aParams as $param => $value) {
109: if ($param == 'idcat' || $param == 'idart' || $param == 'idcatart') {
110: continue;
111: }
112: $this->sUrl .= $this->_sAmp . $param . '=' . urlencode(urldecode((string) $value));
113: }
114: }
115:
116: }
117: