Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • 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:  * This file contains the uri builder custom path class.
  4:  *
  5:  * @package    Core
  6:  * @subpackage Frontend_URI
  7:  * @version    SVN Revision $Rev:$
  8:  *
  9:  * @author     Rudi Bieller
 10:  * @copyright  four for business AG <www.4fb.de>
 11:  * @license    http://www.contenido.org/license/LIZENZ.txt
 12:  * @link       http://www.4fb.de
 13:  * @link       http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: cInclude('includes', 'functions.pathresolver.php');
 19: 
 20: /**
 21:  * Custom path uri builder class.
 22:  * Implementation to build URL in style index-a-1.html
 23:  * with category path (/category/subcategory/index-a-1.html).
 24:  *
 25:  * @package    Core
 26:  * @subpackage Frontend_URI
 27:  */
 28: class cUriBuilderCustomPath extends cUriBuilder {
 29: 
 30:     /**
 31:      * Self instance
 32:      * @var  cUriBuilderCustomPath
 33:      */
 34:     static private $_instance;
 35: 
 36:     /**
 37:      * Configuration
 38:      * @var array
 39:      */
 40:     private $aConfig;
 41: 
 42:     /**
 43:      * Constructor
 44:      * @return void
 45:      */
 46:     private function __construct() {
 47:         $this->sHttpBasePath = '';
 48:     }
 49: 
 50:     /**
 51:      * Get instance of self
 52:      * @return obj cUriBuilderFrontcontent
 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:      * Builds a URL in index-a-1.html style.
 63:      * Index keys of $aParams will be used as "a", corresponding values as "1" in this sample.
 64:      * For creating the location string $aParams needs to have keys idcat, level, lang and at least one custom key.
 65:      * If level is not set, level 0 will be used as default.
 66:      *
 67:      * @param  array  $aParams  Required keys are: idcat, level, lang and at least one custom key.
 68:      * @param  bool  $bUseAbsolutePath
 69:      * @param  array  $aConfig  If not set, will use UriBuilderConfig::getConfig()
 70:      * @return void
 71:      * @throws cInvalidArgumentException
 72:      * @todo Somehow get around using prCreateURLNameLocationString()
 73:      */
 74:     public function buildUrl(array $aParams, $bUseAbsolutePath = false, array $aConfig = array()) {
 75:         if (!isset($aParams['idcat'])) {
 76:             throw new cInvalidArgumentException('$aParams[idcat] must be set!');
 77:         }
 78:         if (!isset($aParams['level'])) {
 79:             //throw new cInvalidArgumentException('$aParams[level] must be set! Setting it to 0 will create complete path.');
 80:             $aParams['level'] = '1';
 81:         }
 82:         if (!isset($aParams['lang'])) {
 83:             throw new cInvalidArgumentException('$aParams[lang] must be set!');
 84:         }
 85:         if (sizeof($aParams) <= 3) {
 86:             throw new cInvalidArgumentException('$aParams must have at least one custom entry!');
 87:         }
 88:         // if no config passed or not all parameters available, use default config
 89:         if (sizeof($aConfig) == 0 || !isset($aConfig['prefix']) || !isset($aConfig['suffix']) || !isset($aConfig['separator'])) {
 90:             include_once('class.uribuilder.config.php');
 91:             $aConfig = cUriBuilderConfig::getConfig();
 92:         }
 93:         $this->aConfig = $aConfig;
 94: 
 95:         $sCategoryString = '';
 96:         prCreateURLNameLocationString(intval($aParams['idcat']), "/", $sCategoryString, false, "", $aParams['level'], $aParams['lang'], true, false);
 97:         if (strlen($sCategoryString) > 0 && substr($sCategoryString, -1) != '/') {
 98:             $sCategoryString .= '/';
 99:         }
100:         $this->sUrl = $bUseAbsolutePath === true ? $this->sHttpBasePath : '';
101:         $this->sUrl .= $sCategoryString;
102:         $this->sUrl .= $this->aConfig['prefix'];
103:         foreach ($aParams as $sKey => $mVal) {
104:             if ($sKey != 'idcat' && $sKey != 'lang' && $sKey != 'level') {
105:                 $sVal = $mVal; // assuming mVal is a string and thus a single value
106:                 if (is_array($mVal)) { // mVal has more than one value, e.g. index-b-1-2.html
107:                     $sVal = implode($this->aConfig['separator'], $mVal);
108:                 }
109:                 $this->sUrl .= $this->aConfig['separator'] . strval($sKey) . $this->aConfig['separator'] . strval($sVal);
110:             }
111:         }
112:         $this->sUrl .= $this->aConfig['suffix'];
113:     }
114: 
115: }
116: 
CMS CONTENIDO 4.9.1 API documentation generated by ApiGen 2.8.0