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