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
  • cApiSearchTracking
  • cApiSearchTrackingCollection
  • 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 client language 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:  * Client language collection
 20:  *
 21:  * @package Core
 22:  * @subpackage GenericDB_Model
 23:  */
 24: class cApiClientLanguageCollection extends ItemCollection {
 25: 
 26:     /**
 27:      * Constructor
 28:      */
 29:     public function __construct() {
 30:         global $cfg;
 31:         parent::__construct($cfg['tab']['clients_lang'], 'idclientslang');
 32:         $this->_setItemClass('cApiClientLanguage');
 33: 
 34:         // set the join partners so that joins can be used via link() method
 35:         $this->_setJoinPartner('cApiClientCollection');
 36:         $this->_setJoinPartner('cApiLanguageCollection');
 37:     }
 38: 
 39:     /**
 40:      * Creates a client language entry.
 41:      *
 42:      * @param int $iClient
 43:      * @param int $iLang
 44:      * @return cApiClientLanguage
 45:      */
 46:     public function create($iClient, $iLang) {
 47:         $oItem = parent::createNewItem();
 48:         $oItem->set('idclient', (int) $iClient, false);
 49:         $oItem->set('idlang', (int) $iLang, false);
 50:         $oItem->store();
 51:         return $oItem;
 52:     }
 53: 
 54:     /**
 55:      * Checks if a language is associated with a given list of clients.
 56:      *
 57:      * @param int $iLang Language id which should be checked
 58:      * @param array $aClients List of clients to check
 59:      * @return bool
 60:      */
 61:     public function hasLanguageInClients($iLang, array $aClientIds) {
 62:         $iLang = (int) $iLang;
 63:         $aClientIds = array_map('intval', $aClientIds);
 64:         $sWhere = 'idlang=' . $iLang . ' AND idclient IN (' . implode(',', $aClientIds) . ')';
 65:         return $this->flexSelect('', '', $sWhere);
 66:     }
 67: 
 68:     /**
 69:      * Returns list of languages (language ids) by passed client.
 70:      *
 71:      * @param int $client
 72:      * @return array
 73:      */
 74:     public function getLanguagesByClient($client) {
 75:         $list = array();
 76:         $sql = "SELECT idlang FROM `%s` WHERE idclient=%d";
 77:         $this->db->query($sql, $this->table, $client);
 78:         while ($this->db->nextRecord()) {
 79:             $list[] = $this->db->f("idlang");
 80:         }
 81:         return $list;
 82:     }
 83: 
 84:     /**
 85:      * Returns all languages (language ids and names) of an client
 86:      *
 87:      * @param int $client
 88:      * @return array List of languages where the key is the language id and
 89:      *         value the language name
 90:      */
 91:     public function getLanguageNamesByClient($client) {
 92:         global $cfg;
 93: 
 94:         $list = array();
 95:         $sql = "SELECT l.idlang AS idlang, l.name AS name
 96:                 FROM `%s` AS cl, `%s` AS l
 97:                 WHERE idclient=%d AND cl.idlang = l.idlang
 98:                 ORDER BY idlang ASC";
 99: 
100:         $this->db->query($sql, $this->table, $cfg['tab']['lang'], $client);
101:         while ($this->db->nextRecord()) {
102:             $list[$this->db->f('idlang')] = $this->db->f('name');
103:         }
104: 
105:         return $list;
106:     }
107: 
108:     /**
109:      * Returns all languages of an client. Merges the values from language and client language
110:      * table and returns them back.
111:      *
112:      * @param int $client
113:      * @return array List of languages where the key is the language id and
114:      *         value an assoziative array merged by fields from language and client language table
115:      */
116:     public function getAllLanguagesByClient($client) {
117:         global $cfg;
118: 
119:         $list = array();
120:         $sql = "SELECT *
121:                 FROM `%s` AS cl, `%s` AS l
122:                 WHERE cl.idclient=%d AND cl.idlang = l.idlang
123:                 ORDER BY l.idlang ASC";
124: 
125:         $this->db->query($sql, $this->table, $cfg['tab']['lang'], $client);
126:         while ($this->db->nextRecord()) {
127:             $list[$this->db->f('idlang')] = $this->db->toArray();
128:         }
129: 
130:         return $list;
131:     }
132: 
133:     /**
134:      * Returns the id of first language for a specific client.
135:      *
136:      * @param int $client
137:      * @return int NULL
138:      */
139:     public function getFirstLanguageIdByClient($client) {
140:         global $cfg;
141: 
142:         $sql = "SELECT l.idlang FROM `%s` AS cl, `%s` AS l " . "WHERE cl.idclient = %d AND cl.idlang = l.idlang LIMIT 0,1";
143: 
144:         $this->db->query($sql, $this->table, $cfg['tab']['lang'], $client);
145: 
146:         return ($this->db->nextRecord()) ? (int) $this->db->f('idlang') : NULL;
147:     }
148: }
149: 
150: /**
151:  * Client item
152:  *
153:  * @package Core
154:  * @subpackage GenericDB_Model
155:  */
156: class cApiClientLanguage extends Item {
157: 
158:     /**
159:      * Id of client
160:      *
161:      * @var int
162:      */
163:     public $idclient;
164: 
165:     /**
166:      * Property collection instance
167:      *
168:      * @var cApiPropertyCollection
169:      */
170:     protected $_oPropertyCollection;
171: 
172:     /**
173:      * Constructor
174:      *
175:      * @param int $iIdClientsLang If specified, load item
176:      * @param int $iIdClient If idclient and idlang specified, load item;
177:      *        ignored, if idclientslang specified
178:      * @param int $iIdLang If idclient and idlang specified, load item; ignored,
179:      *        if idclientslang specified
180:      */
181:     public function __construct($iIdClientsLang = false, $iIdClient = false, $iIdLang = false) {
182:         global $cfg;
183:         parent::__construct($cfg['tab']['clients_lang'], 'idclientslang');
184: 
185:         if ($iIdClientsLang !== false) {
186:             $this->loadByPrimaryKey($iIdClientsLang);
187:         } elseif ($iIdClient !== false && $iIdLang !== false) {
188:             /*
189:              * One way, but the other should be faster $oCollection = new
190:              * cApiClientLanguageCollection; $oCollection->setWhere('idclient',
191:              * $iIdClient); $oCollection->setWhere('idlang', $iIdLang);
192:              * $oCollection->query(); if ($oItem = $oCollection->next()) {
193:              * $this->loadByPrimaryKey($oItem->get($oItem->primaryKey)); }
194:              */
195: 
196:             // Query the database
197:             $sSQL = "SELECT %s FROM %s WHERE idclient = '%d' AND idlang = '%d'";
198:             $this->db->query($sSQL, $this->primaryKey, $this->table, $iIdClient, $iIdLang);
199:             if ($this->db->nextRecord()) {
200:                 $this->loadByPrimaryKey($this->db->f($this->primaryKey));
201:             }
202:         }
203:     }
204: 
205:     /**
206:      * Load dataset by primary key
207:      *
208:      * @param int $iIdClientsLang
209:      * @return bool
210:      */
211:     public function loadByPrimaryKey($iIdClientsLang) {
212:         if (parent::loadByPrimaryKey($iIdClientsLang) == true) {
213:             $this->idclient = $this->get('idclient');
214:             return true;
215:         }
216:         return false;
217:     }
218: 
219:     /**
220:      * Set client property
221:      *
222:      * @param mixed $mType Type of the data to store (arbitary data)
223:      * @param mixed $mName Entry name
224:      * @param mixed $mValue Value
225:      * @param int $client Client id
226:      * @todo Use parents method
227:      * @see Item::setProperty()
228:      * @todo should return return value as overwritten method
229:      */
230:     public function setProperty($mType, $mName, $mValue, $client = 0) {
231:         $oPropertyColl = $this->_getPropertiesCollectionInstance();
232:         $oPropertyColl->setValue($this->primaryKey, $this->get($this->primaryKey), $mType, $mName, $mValue, $client);
233:     }
234: 
235:     /**
236:      * Get client property
237:      *
238:      * @todo Use parents method @see Item::getProperty()
239:      *
240:      * @param mixed $mType Type of the data to get
241:      * @param mixed $mName Entry name
242:      * @param int $client Client id (not used, it's declared because of PHP
243:      *        strict warnings)
244:      * @return mixed Value
245:      */
246:     public function getProperty($mType, $mName, $client = 0) {
247:         $oPropertyColl = $this->_getPropertiesCollectionInstance();
248:         return $oPropertyColl->getValue($this->primaryKey, $this->get($this->primaryKey), $mType, $mName);
249:     }
250: 
251:     /**
252:      * Delete client property
253:      *
254:      * @todo Use parents method @see Item::deleteProperty(), but be carefull,
255:      *       different parameter!
256:      *
257:      * @param int $idprop Id of property
258:      * @param int $p2 Not used, is here to prevent PHP Strict warnings
259:      * @param int $client Client id (not used, it's declared because of PHP
260:      *        strict warnings)
261:      */
262:     public function deleteProperty($idprop, $p2 = NULL, $client = 0) {
263:         $oPropertyColl = $this->_getPropertiesCollectionInstance();
264:         $oPropertyColl->delete($idprop);
265:     }
266: 
267:     /**
268:      * Get client properties by type
269:      *
270:      * @param mixed $mType Type of the data to get
271:      * @return array Assoziative array
272:      */
273:     public function getPropertiesByType($mType) {
274:         $oPropertyColl = $this->_getPropertiesCollectionInstance();
275:         return $oPropertyColl->getValuesByType($this->primaryKey, $this->idclient, $mType);
276:     }
277: 
278:     /**
279:      * Get all client properties
280:      *
281:      * @return array false array
282:      * @todo return value should be the same as getPropertiesByType(), e.g. an
283:      *       empty array instead of false
284:      */
285:     public function getProperties() {
286:         $itemtype = $this->db->escape($this->primaryKey);
287:         $itemid = $this->db->escape($this->get($this->primaryKey));
288:         $oPropertyColl = $this->_getPropertiesCollectionInstance();
289:         $oPropertyColl->select("itemtype='" . $itemtype . "' AND itemid='" . $itemid . "'", '', 'type, value ASC');
290: 
291:         if ($oPropertyColl->count() > 0) {
292:             $aArray = array();
293: 
294:             while (($oItem = $oPropertyColl->next()) !== false) {
295:                 $aArray[$oItem->get('idproperty')]['type'] = $oItem->get('type');
296:                 $aArray[$oItem->get('idproperty')]['name'] = $oItem->get('name');
297:                 $aArray[$oItem->get('idproperty')]['value'] = $oItem->get('value');
298:             }
299: 
300:             return $aArray;
301:         } else {
302:             return false;
303:         }
304:     }
305: 
306:     /**
307:      * Lazy instantiation and return of properties object
308:      *
309:      * @param int $client Client id (not used, it's declared because of PHP
310:      *        strict warnings)
311:      * @return cApiPropertyCollection
312:      */
313:     protected function _getPropertiesCollectionInstance($client = 0) {
314:         // Runtime on-demand allocation of the properties object
315:         if (!is_object($this->_oPropertyCollection)) {
316:             $this->_oPropertyCollection = new cApiPropertyCollection();
317:             $this->_oPropertyCollection->changeClient($this->idclient);
318:         }
319:         return $this->_oPropertyCollection;
320:     }
321: }
322: 
CMS CONTENIDO 4.9.3 API documentation generated by ApiGen 2.8.0