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