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
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • PHP
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • 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 language collection and item class.
  5:  *
  6:  * @package          Core
  7:  * @subpackage       GenericDB_Model
  8:  * @author           Bjoern Behrens
  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:  * Language collection
 19:  *
 20:  * @package Core
 21:  * @subpackage GenericDB_Model
 22:  */
 23: class cApiLanguageCollection extends ItemCollection {
 24:     /**
 25:      * Constructor to create an instance of this class.
 26:      *
 27:      * @throws cInvalidArgumentException
 28:      */
 29:     public function __construct() {
 30:         global $cfg;
 31:         parent::__construct($cfg['tab']['lang'], 'idlang');
 32:         $this->_setItemClass('cApiLanguage');
 33:     }
 34: 
 35:     /**
 36:      * Creates a language entry.
 37:      *
 38:      * @param string  $name
 39:      * @param int     $active
 40:      * @param string  $encoding
 41:      * @param string  $direction
 42:      *
 43:      * @return cApiLanguage
 44:      * @throws cDbException
 45:      * @throws cException
 46:      * @throws cInvalidArgumentException
 47:      * @global object $auth
 48:      */
 49:     public function create($name, $active, $encoding, $direction) {
 50:         global $auth;
 51: 
 52:         $item = $this->createNewItem();
 53: 
 54:         $item->set('name', $name, false);
 55:         $item->set('active', $active, false);
 56:         $item->set('encoding', $encoding, false);
 57:         $item->set('direction', $direction, false);
 58:         $item->set('author', $auth->auth['uid'], false);
 59:         $item->set('created', date('Y-m-d H:i:s'), false);
 60:         $item->set('lastmodified', '0000-00-00 00:00:00', false);
 61:         $item->store();
 62: 
 63:         return $item;
 64:     }
 65: 
 66:     /**
 67:      * Returns next accessible language for current client and current logged in
 68:      * user.
 69:      *
 70:      * @return cApiLanguage|NULL
 71:      * @throws cDbException
 72:      * @throws cException
 73:      * @global object $perm
 74:      * @global array  $cfg
 75:      * @global int    $client
 76:      * @global int    $lang
 77:      *
 78:      */
 79:     public function nextAccessible() {
 80:         global $perm, $client, $lang;
 81: 
 82:         $item = $this->next();
 83: 
 84:         $lang = (int) $lang;
 85:         $client = (int) $client;
 86: 
 87:         if ($item === false) {
 88:             return false;
 89:         }
 90: 
 91:         $clientsLanguageColl = new cApiClientLanguageCollection();
 92:         $clientsLanguageColl->select('idlang = ' . $item->get("idlang"));
 93:         if (($clientsLang = $clientsLanguageColl->next()) !== false) {
 94:             if ($client != $clientsLang->get('idclient')) {
 95:                 $item = $this->nextAccessible();
 96:             }
 97:         }
 98: 
 99:         if ($item) {
100:             if ($perm->have_perm_client('lang[' . $item->get('idlang') . ']') || $perm->have_perm_client('admin[' . $client . ']') || $perm->have_perm_client()) {
101:                 // Do nothing for now
102:             } else {
103:                 $item = $this->nextAccessible();
104:             }
105: 
106:             return $item;
107:         } else {
108:             return false;
109:         }
110:     }
111: 
112:     /**
113:      * Returns the language name of the language with the given ID.
114:      *
115:      * @param int $idlang
116:      *         the ID of the language
117:      * @return string
118:      *         the name of the language
119:      */
120:     public function getLanguageName($idlang) {
121:         $item = new cApiLanguage($idlang);
122:         if ($item->isLoaded()) {
123:             return $item->get('name');
124:         } else {
125:             return i18n('No language');
126:         }
127:     }
128: 
129: }
130: 
131: /**
132:  * Language item
133:  *
134:  * @package Core
135:  * @subpackage GenericDB_Model
136:  */
137: class cApiLanguage extends Item {
138:     /**
139:      *
140:      * @var array
141:      */
142:     protected static $_propertiesCache = array();
143: 
144:     /**
145:      *
146:      * @var array
147:      */
148:     protected static $_propertiesCacheLoaded = array();
149: 
150:     /**
151:      * Constructor to create an instance of this class.
152:      *
153:      * @param mixed $mId [optional]
154:      *                   Specifies the ID of item to load
155:      *
156:      * @throws cDbException
157:      * @throws cException
158:      */
159:     public function __construct($mId = false) {
160:         global $cfg;
161:         parent::__construct($cfg['tab']['lang'], 'idlang');
162:         $this->setFilters(array(), array());
163:         if ($mId !== false) {
164:             $this->loadByPrimaryKey($mId);
165:         }
166:     }
167: 
168:     /**
169:      * Stores made changes.
170:      *
171:      * @return bool
172:      * @throws cDbException
173:      * @throws cInvalidArgumentException
174:      */
175:     public function store() {
176:         $this->set('lastmodified', date('Y-m-d H:i:s'), false);
177:         return parent::store();
178:     }
179: 
180:     /**
181:      * Userdefined setter for lang fields.
182:      *
183:      * @param string $name
184:      * @param mixed $value
185:      * @param bool $bSafe [optional]
186:      *         Flag to run defined inFilter on passed value
187:      * @return bool
188:      */
189:     public function setField($name, $value, $bSafe = true) {
190:         switch ($name) {
191:             case 'active':
192:                 $value = (int) $value;
193:                 break;
194:         }
195: 
196:         return parent::setField($name, $value, $bSafe);
197:     }
198: 
199:     /**
200:      * Loads all languagesettings into an static array.
201:      *
202:      * @param int $idclient [optional]
203:      *                      Id of client to load properties from
204:      * @throws cDbException
205:      * @throws cException
206:      */
207:     protected function _loadProperties($idclient = 0) {
208: 
209:         if (!isset(self::$_propertiesCacheLoaded[$idclient])) {
210: 
211:             self::$_propertiesCache[$idclient] = array();
212: 
213:             $itemtype = $this->db->escape($this->getPrimaryKeyName());
214:             $itemid = $this->db->escape($this->get($this->getPrimaryKeyName()));
215: 
216:             $propColl = $this->_getPropertiesCollectionInstance($idclient);
217:             $propColl->select("itemtype='$itemtype' AND itemid='$itemid'", '', 'type, value ASC');
218: 
219:             if (0 < $propColl->count()) {
220: 
221:                 while (false !== $item = $propColl->next()) {
222: 
223:                     $type = $item->get('type');
224:                     if (!isset(self::$_propertiesCache[$idclient][$type])) {
225:                         self::$_propertiesCache[$idclient][$type] = array();
226:                     }
227: 
228:                     $name = $item->get('name');
229:                     $value = $item->get('value');
230:                     self::$_propertiesCache[$idclient][$type][$name] = $value;
231:                 }
232:             }
233:         }
234: 
235:         self::$_propertiesCacheLoaded[$idclient] = true;
236:     }
237: 
238:     /**
239:      * Returns a custom property.
240:      *
241:      * @param string $type
242:      *                         Specifies the type
243:      * @param string $name
244:      *                         Specifies the name
245:      * @param int    $idclient [optional]
246:      *                         Id of client to set property for
247:      * @return mixed
248:      *                         Value of the given property or false if item hasn't been loaded
249:      * @throws cDbException
250:      * @throws cException
251:      */
252:     public function getProperty($type, $name, $idclient = 0) {
253: 
254:         // skip & return false if item hasn't been loaded
255:         if (true !== $this->isLoaded()) {
256:             $this->lasterror = 'No item loaded';
257:             return false;
258:         }
259: 
260:         $this->_loadProperties($idclient);
261: 
262:         if (isset(
263:             self::$_propertiesCache[$idclient],
264:             self::$_propertiesCache[$idclient][$type],
265:             self::$_propertiesCache[$idclient][$type][$name]
266:         )) {
267:             return self::$_propertiesCache[$idclient][$type][$name];
268:         } else {
269:             return false;
270:         }
271:     }
272: 
273: }
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0