Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • PHP
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cUri
  • cUriBuilder
  • cUriBuilderConfig
  • cUriBuilderCustom
  • cUriBuilderCustomPath
  • cUriBuilderFactory
  • cUriBuilderFrontcontent

Exceptions

  • NotInitializedException
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
 1: <?php
 2: 
 3: /**
 4:  * This file contains the uri builder custom class.
 5:  *
 6:  * @package    Core
 7:  * @subpackage Frontend_URI
 8:  * @author     Rudi Bieller
 9:  * @copyright  four for business AG <www.4fb.de>
10:  * @license    http://www.contenido.org/license/LIZENZ.txt
11:  * @link       http://www.4fb.de
12:  * @link       http://www.contenido.org
13:  */
14: 
15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
16: 
17: /**
18:  * Custom uri builder class.
19:  *
20:  * @package    Core
21:  * @subpackage Frontend_URI
22:  */
23: class cUriBuilderCustom extends cUriBuilder {
24: 
25:     /**
26:      * Self instance
27:      *
28:      * @var cUriBuilderCustom
29:      */
30:     private static $_instance;
31: 
32:     /**
33:      * Configuration
34:      *
35:      * @var array
36:      */
37:     private $aConfig;
38: 
39:     /**
40:      * Constructor to create an instance of this class.
41:      */
42:     private function __construct() {
43:         $this->sHttpBasePath = '';
44:     }
45: 
46:     /**
47:      * Get instance of self.
48:      *
49:      * @return cUriBuilderCustom
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:      * Builds a URL in index-a-1.html style.
60:      *
61:      * Index keys of $aParams will be used as "a", corresponding values
62:      * as "1" in this sample.
63:      *
64:      * @param array $aParams
65:      * @param bool  $bUseAbsolutePath [optional]
66:      * @param array $aConfig          [optional]
67:      *                                If not set, will use cUriBuilderConfig::getConfig()
68:      *
69:      * @throws cException
70:      * @throws cInvalidArgumentException
71:      */
72:     public function buildUrl(array $aParams, $bUseAbsolutePath = false, array $aConfig = array()) {
73:         if (sizeof($aParams) == 0) {
74:             throw new cInvalidArgumentException('$aParams must have at least one entry!');
75:         }
76:         // if no config passed or not all parameters available, use default
77:         // config
78:         if (sizeof($aConfig) == 0 || !isset($aConfig['prefix']) || !isset($aConfig['suffix']) || !isset($aConfig['separator'])) {
79:             include_once('class.uribuilder.config.php');
80:             $aConfig = cUriBuilderConfig::getConfig();
81:         }
82:         $this->aConfig = $aConfig;
83: 
84:         $this->sUrl = $bUseAbsolutePath === true ? $this->sHttpBasePath : '';
85:         $this->sUrl .= $this->aConfig['prefix'];
86:         foreach ($aParams as $sKey => $mVal) {
87:             $sVal = $mVal; // assuming mVal is a string and thus a single value
88:             if (is_array($mVal)) { // mVal has more than one value, e.g.
89:                 // index-b-1-2.html
90:                 $sVal = implode($this->aConfig['separator'], $mVal);
91:             }
92:             $this->sUrl .= $this->aConfig['separator'] . strval($sKey) . $this->aConfig['separator'] . strval($sVal);
93:         }
94:         $this->sUrl .= $this->aConfig['suffix'];
95:     }
96: 
97: }
98: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0