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

  • cApiAction
  • cApiActionCollection
  • cApiActionlog
  • cApiActionlogCollection
  • cApiArea
  • cApiAreaCollection
  • cApiArticle
  • cApiArticleCollection
  • cApiArticleLanguage
  • cApiArticleLanguageCollection
  • cApiArticleSpecification
  • cApiArticleSpecificationCollection
  • cApiCategory
  • cApiCategoryArticle
  • cApiCategoryArticleCollection
  • cApiCategoryCollection
  • cApiCategoryLanguage
  • cApiCategoryLanguageCollection
  • cApiCategoryTree
  • cApiCategoryTreeCollection
  • cApiClient
  • cApiClientCollection
  • cApiClientLanguage
  • cApiClientLanguageCollection
  • cApiCommunication
  • cApiCommunicationCollection
  • cApiContainer
  • cApiContainerCollection
  • cApiContainerConfiguration
  • cApiContainerConfigurationCollection
  • cApiContent
  • cApiContentCollection
  • cApiDbfs
  • cApiDbfsCollection
  • cApiFile
  • cApiFileCollection
  • cApiFileInformation
  • cApiFileInformationCollection
  • cApiFrameFile
  • cApiFrameFileCollection
  • cApiFrontendGroup
  • cApiFrontendGroupCollection
  • cApiFrontendGroupMember
  • cApiFrontendGroupMemberCollection
  • cApiFrontendPermission
  • cApiFrontendPermissionCollection
  • cApiFrontendUser
  • cApiFrontendUserCollection
  • cApiGroup
  • cApiGroupCollection
  • cApiGroupMember
  • cApiGroupMemberCollection
  • cApiGroupProperty
  • cApiGroupPropertyCollection
  • cApiInUse
  • cApiInUseCollection
  • cApiIso3166
  • cApiIso3166Collection
  • cApiIso6392
  • cApiIso6392Collection
  • cApiKeyword
  • cApiKeywordCollection
  • cApiLanguage
  • cApiLanguageCollection
  • cApiLayout
  • cApiLayoutCollection
  • cApiMailLog
  • cApiMailLogCollection
  • cApiMailLogSuccess
  • cApiMailLogSuccessCollection
  • cApiMetaTag
  • cApiMetaTagCollection
  • cApiMetaType
  • cApiMetaTypeCollection
  • cApiModule
  • cApiModuleCollection
  • cApiNavMain
  • cApiNavMainCollection
  • cApiNavSub
  • cApiNavSubCollection
  • cApiOnlineUser
  • cApiOnlineUserCollection
  • cApiPathresolveCache
  • cApiPathresolveCacheCollection
  • cApiProperty
  • cApiPropertyCollection
  • cApiRight
  • cApiRightCollection
  • cApiStat
  • cApiStatCollection
  • cApiSystemProperty
  • cApiSystemPropertyCollection
  • cApiTemplate
  • cApiTemplateCollection
  • cApiTemplateConfiguration
  • cApiTemplateConfigurationCollection
  • cApiType
  • cApiTypeCollection
  • cApiUpload
  • cApiUploadCollection
  • cApiUploadMeta
  • cApiUploadMetaCollection
  • cApiUser
  • cApiUserCollection
  • cApiUserProperty
  • cApiUserPropertyCollection
  • NoteCollection
  • NoteItem
  • TODOCollection
  • TODOItem
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the area collection and item class.
  4:  *
  5:  * @package Core
  6:  * @subpackage GenericDB_Model
  7:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author Timo Hummel
 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: /**
 19:  * Area collection
 20:  *
 21:  * @package Core
 22:  * @subpackage GenericDB_Model
 23:  */
 24: class cApiAreaCollection extends ItemCollection {
 25: 
 26:     /**
 27:      * Constructor
 28:      */
 29:     public function __construct() {
 30:         global $cfg;
 31:         parent::__construct($cfg['tab']['area'], 'idarea');
 32:         $this->_setItemClass('cApiArea');
 33:     }
 34: 
 35:     /**
 36:      * Creates a area item entry
 37:      *
 38:      * @param string $name Name
 39:      * @param string|int $parentid Parent id as astring or number
 40:      * @param int $relevant 0 or 1
 41:      * @param int $online 0 or 1
 42:      * @param int $menuless 0 or 1
 43:      * @return cApiArea
 44:      */
 45:     public function create($name, $parentid = 0, $relevant = 1, $online = 1, $menuless = 0) {
 46:         $parentid = (is_string($parentid)) ? $this->escape($parentid) : (int) $parentid;
 47: 
 48:         $item = parent::createNewItem();
 49: 
 50:         $item->set('parent_id', $parentid);
 51:         $item->set('name', $this->escape($name));
 52:         $item->set('relevant', (1 == $relevant) ? 1 : 0);
 53:         $item->set('online', (1 == $online) ? 1 : 0);
 54:         $item->set('menuless', (1 == $menuless) ? 1 : 0);
 55: 
 56:         $item->store();
 57: 
 58:         return $item;
 59:     }
 60: 
 61:     /**
 62:      * Returns the parent id of passed area
 63:      *
 64:      * @param int|string $area Area id or name
 65:      * @return string int name of parent area or passed area
 66:      */
 67:     public function getParentAreaID($area) {
 68:         if (is_numeric($area)) {
 69:             $sql = "SELECT b.name FROM `%s` AS a, `%s` AS b WHERE a.idarea = %d AND b.name = a.parent_id";
 70:         } else {
 71:             $sql = "SELECT b.name FROM `%s` AS a, `%s` AS b WHERE a.name = '%s' AND b.name = a.parent_id";
 72:         }
 73:         $this->db->query($sql, $this->table, $this->table, $area);
 74:         return ($this->db->nextRecord()) ? $this->db->f('name') : $area;
 75:     }
 76: 
 77:     /**
 78:      * Returns all area ids having passed area as name or as parent id
 79:      *
 80:      * @param int|string $nameOrId Area name or parent id
 81:      * @return array List of area ids
 82:      */
 83:     public function getIdareasByAreaNameOrParentId($nameOrId) {
 84:         $sql = "SELECT idarea FROM `%s` AS a WHERE a.name = '%s' OR a.parent_id = '%s' ORDER BY idarea";
 85:         $this->db->query($sql, $this->table, $nameOrId, $nameOrId);
 86: 
 87:         $ids = array();
 88:         while ($this->db->nextRecord()) {
 89:             $ids[] = $this->db->f('idarea');
 90:         }
 91: 
 92:         return $ids;
 93:     }
 94: 
 95:     /**
 96:      * Returns all areas available in the system
 97:      *
 98:      * @return array Array with id and name entries
 99:      */
100:     public function getAvailableAreas() {
101:         $aClients = array();
102: 
103:         $this->select();
104: 
105:         while (($oItem = $this->next()) !== false) {
106:             $aAreas[$oItem->get('idarea')] = array(
107:                 'name' => $oItem->get('name')
108:             );
109:         }
110: 
111:         return ($aAreas);
112:     }
113: 
114:     /**
115:      * Returns the name for a given areaid
116:      *
117:      * @param string $area
118:      * @return string String with the name for the area
119:      */
120:     public function getAreaName($area) {
121:         $oItem = new cApiArea($area);
122:         return $oItem->get('name');
123:     }
124: 
125:     /**
126:      * Returns the idarea for a given area name
127:      *
128:      * @param string $area
129:      * @return int Integer with the ID for the area
130:      */
131:     public function getAreaID($area) {
132:         $oItem = new cApiArea();
133:         $oItem->loadBy('name', $area);
134: 
135:         return $oItem->get('idarea');
136:     }
137: }
138: 
139: /**
140:  * Area item
141:  *
142:  * @package Core
143:  * @subpackage GenericDB_Model
144:  */
145: class cApiArea extends Item {
146: 
147:     /**
148:      * Constructor Function
149:      *
150:      * @param mixed $mId Specifies the ID of item to load
151:      */
152:     public function __construct($mId = false) {
153:         global $cfg;
154:         parent::__construct($cfg['tab']['area'], 'idarea');
155:         $this->setFilters(array(), array());
156:         if ($mId !== false) {
157:             $this->loadByPrimaryKey($mId);
158:         }
159:     }
160: }
161: 
CMS CONTENIDO 4.9.1 API documentation generated by ApiGen 2.8.0