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