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