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
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  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 = $this->createNewItem();
 49: 
 50:         $item->set('parent_id', $parentid);
 51:         $item->set('name', $name);
 52:         $item->set('relevant', $relevant);
 53:         $item->set('online', $online);
 54:         $item->set('menuless', $menuless);
 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:     /**
162:      * Userdefined setter for area fields.
163:      *
164:      * @param string $name
165:      * @param mixed $value
166:      * @param bool $bSafe Flag to run defined inFilter on passed value
167:      */
168:     public function setField($name, $value, $bSafe = true) {
169:         switch ($name) {
170:             case 'relevant':
171:                 $value = ($value == 1) ? 1 : 0;
172:                 break;
173:             case 'online':
174:                 $value = ($value == 1) ? 1 : 0;
175:                 break;
176:             case 'menuless':
177:                 $value = ($value == 1) ? 1 : 0;
178:                 break;          
179:         }
180: 
181:         return parent::setField($name, $value, $bSafe);
182:     }
183: 
184: }
185: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen