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
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • 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
  • cApiArticleLanguageVersion
  • cApiArticleLanguageVersionCollection
  • cApiArticleSpecification
  • cApiArticleSpecificationCollection
  • cApiCategory
  • cApiCategoryArticle
  • cApiCategoryArticleCollection
  • cApiCategoryCollection
  • cApiCategoryLanguage
  • cApiCategoryLanguageCollection
  • cApiCategoryTree
  • cApiCategoryTreeCollection
  • cApiClient
  • cApiClientCollection
  • cApiClientLanguage
  • cApiClientLanguageCollection
  • cApiCommunication
  • cApiCommunicationCollection
  • cApiContainer
  • cApiContainerCollection
  • cApiContainerConfiguration
  • cApiContainerConfigurationCollection
  • cApiContent
  • cApiContentCollection
  • cApiContentVersion
  • cApiContentVersionCollection
  • 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
  • cApiMetaTagVersion
  • cApiMetaTagVersionCollection
  • cApiMetaType
  • cApiMetaTypeCollection
  • cApiModule
  • cApiModuleCollection
  • cApiNavMain
  • cApiNavMainCollection
  • cApiNavSub
  • cApiNavSubCollection
  • cApiOnlineUser
  • cApiOnlineUserCollection
  • cApiPathresolveCache
  • cApiPathresolveCacheCollection
  • cApiProperty
  • cApiPropertyCollection
  • cApiRight
  • cApiRightCollection
  • cApiSearchTracking
  • cApiSearchTrackingCollection
  • cApiStat
  • cApiStatCollection
  • cApiSystemProperty
  • cApiSystemPropertyCollection
  • cApiTemplate
  • cApiTemplateCollection
  • cApiTemplateConfiguration
  • cApiTemplateConfigurationCollection
  • cApiType
  • cApiTypeCollection
  • cApiUpload
  • cApiUploadCollection
  • cApiUploadMeta
  • cApiUploadMetaCollection
  • cApiUser
  • cApiUserCollection
  • cApiUserPasswordRequest
  • cApiUserPasswordRequestCollection
  • 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:  * @author Timo Hummel
  8:  * @copyright four for business AG <www.4fb.de>
  9:  * @license http://www.contenido.org/license/LIZENZ.txt
 10:  * @link http://www.4fb.de
 11:  * @link http://www.contenido.org
 12:  */
 13: 
 14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 15: 
 16: /**
 17:  * Area collection.
 18:  *
 19:  * @package Core
 20:  * @subpackage GenericDB_Model
 21:  */
 22: class cApiAreaCollection extends ItemCollection {
 23: 
 24:     /**
 25:      * Constructor to create an instance of this class.
 26:      */
 27:     public function __construct() {
 28:         global $cfg;
 29:         parent::__construct($cfg['tab']['area'], 'idarea');
 30:         $this->_setItemClass('cApiArea');
 31:     }
 32: 
 33:     /**
 34:      * Creates an area item entry.
 35:      *
 36:      * @param string $name
 37:      *         Name
 38:      * @param string|int $parentid [optional]
 39:      *         Parent id as astring or number
 40:      * @param int $relevant [optional]
 41:      *         0 or 1
 42:      * @param int $online [optional]
 43:      *         0 or 1
 44:      * @param int $menuless [optional]
 45:      *         0 or 1
 46:      * @return cApiArea
 47:      */
 48:     public function create($name, $parentid = 0, $relevant = 1, $online = 1, $menuless = 0) {
 49:         $parentid = (is_string($parentid)) ? $this->escape($parentid) : (int) $parentid;
 50: 
 51:         $item = $this->createNewItem();
 52: 
 53:         $item->set('parent_id', $parentid);
 54:         $item->set('name', $name);
 55:         $item->set('relevant', $relevant);
 56:         $item->set('online', $online);
 57:         $item->set('menuless', $menuless);
 58: 
 59:         $item->store();
 60: 
 61:         return $item;
 62:     }
 63: 
 64:     /**
 65:      * Returns the parent id of passed area.
 66:      *
 67:      * @param int|string $area
 68:      *         Area id or name
 69:      * @return string|int
 70:      *         name of parent area or passed area
 71:      */
 72:     public function getParentAreaID($area) {
 73:         if (is_numeric($area)) {
 74:             $sql = "SELECT b.name FROM `%s` AS a, `%s` AS b WHERE a.idarea = %d AND b.name = a.parent_id";
 75:         } else {
 76:             $sql = "SELECT b.name FROM `%s` AS a, `%s` AS b WHERE a.name = '%s' AND b.name = a.parent_id";
 77:         }
 78:         $this->db->query($sql, $this->table, $this->table, $area);
 79:         return ($this->db->nextRecord()) ? $this->db->f('name') : $area;
 80:     }
 81: 
 82:     /**
 83:      * Returns all area ids having passed area as name or as parent id.
 84:      *
 85:      * @param int|string $nameOrId
 86:      *         Area name or parent id
 87:      * @return array
 88:      *         List of area ids
 89:      */
 90:     public function getIdareasByAreaNameOrParentId($nameOrId) {
 91:         $sql = "SELECT idarea FROM `%s` AS a WHERE a.name = '%s' OR a.parent_id = '%s' ORDER BY idarea";
 92:         $this->db->query($sql, $this->table, $nameOrId, $nameOrId);
 93: 
 94:         $ids = array();
 95:         while ($this->db->nextRecord()) {
 96:             $ids[] = $this->db->f('idarea');
 97:         }
 98: 
 99:         return $ids;
100:     }
101: 
102:     /**
103:      * Returns all areas available in the system.
104:      *
105:      * @return array
106:      *         Array with id and name entries
107:      */
108:     public function getAvailableAreas() {
109:         $aClients = array();
110: 
111:         $this->select();
112: 
113:         while (($oItem = $this->next()) !== false) {
114:             $aAreas[$oItem->get('idarea')] = array(
115:                 'name' => $oItem->get('name')
116:             );
117:         }
118: 
119:         return ($aAreas);
120:     }
121: 
122:     /**
123:      * Returns the name for a given area id.
124:      *
125:      * @param string $area
126:      * @return string
127:      *         String with the name for the area
128:      */
129:     public function getAreaName($area) {
130:         $oItem = new cApiArea($area);
131:         return $oItem->get('name');
132:     }
133: 
134:     /**
135:      * Returns the idarea for a given area name.
136:      *
137:      * @param string $area
138:      * @return int
139:      *         Integer with the ID for the area
140:      */
141:     public function getAreaID($area) {
142:         // if area name is numeric (legacy areas)
143:         if (is_numeric($area)) {
144:             return $area;
145:         }
146: 
147:         $oItem = new cApiArea();
148:         $oItem->loadBy('name', $area);
149: 
150:         if ($oItem->isLoaded() === false) {
151:             return $area;
152:         }
153: 
154:         return $oItem->get('idarea');
155:     }
156: }
157: 
158: /**
159:  * Area item.
160:  *
161:  * @package Core
162:  * @subpackage GenericDB_Model
163:  */
164: class cApiArea extends Item {
165: 
166:     /**
167:      * Constructor to create an instance of this class.
168:      *
169:      * @param mixed $mId [optional]
170:      *         Specifies the ID of item to load
171:      */
172:     public function __construct($mId = false) {
173:         global $cfg;
174:         parent::__construct($cfg['tab']['area'], 'idarea');
175:         $this->setFilters(array(), array());
176:         if ($mId !== false) {
177:             $this->loadByPrimaryKey($mId);
178:         }
179:     }
180: 
181:     /**
182:      * Userdefined setter for area fields.
183:      *
184:      * @param string $name
185:      * @param mixed $value
186:      * @param bool $bSafe [optional]
187:      *         Flag to run defined inFilter on passed value
188:      * @return bool
189:      */
190:     public function setField($name, $value, $bSafe = true) {
191:         switch ($name) {
192:             case 'relevant':
193:                 $value = ($value == 1) ? 1 : 0;
194:                 break;
195:             case 'online':
196:                 $value = ($value == 1) ? 1 : 0;
197:                 break;
198:             case 'menuless':
199:                 $value = ($value == 1) ? 1 : 0;
200:                 break;
201:         }
202: 
203:         return parent::setField($name, $value, $bSafe);
204:     }
205: 
206: }
207: 
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0