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: 44:
45: private function __construct() {
46: $this->sHttpBasePath = '';
47: }
48:
49: 50: 51: 52: 53:
54: public static function getInstance() {
55: if (self::$_instance == null) {
56: self::$_instance = new self();
57: }
58: return self::$_instance;
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: