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 language collection and item class.
  4:  *
  5:  * @package          Core
  6:  * @subpackage       GenericDB_Model
  7:  * @version          SVN Revision $Rev:$
  8:  *
  9:  * @author           Bjoern Behrens
 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: 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
 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 the ID of the language
109:      * @return string the name of the language
110:      */
111:     public function getLanguageName($idlang) {
112:         $item = new cApiLanguage($idlang);
113:         if ($item->isLoaded()) {
114:             return $item->get('name');
115:         } else {
116:             return i18n('No language');
117:         }
118:     }
119: 
120: }
121: 
122: /**
123:  * Language item
124:  *
125:  * @package Core
126:  * @subpackage GenericDB_Model
127:  */
128: class cApiLanguage extends Item {
129: 
130:     /**
131:      * Constructor Function
132:      *
133:      * @param mixed $mId Specifies the ID of item to load
134:      */
135:     public function __construct($mId = false) {
136:         global $cfg;
137:         parent::__construct($cfg['tab']['lang'], 'idlang');
138:         if ($mId !== false) {
139:             $this->loadByPrimaryKey($mId);
140:         }
141:     }
142: 
143:     /**
144:      * Stores made changes.
145:      *
146:      * @return bool
147:      */
148:     public function store() {
149:         $this->set('lastmodified', date('Y-m-d H:i:s'), false);
150:         return parent::store();
151:     }
152: 
153:     /**
154:      * Userdefined setter for lang fields.
155:      *
156:      * @param string $name
157:      * @param mixed $value
158:      * @param bool $bSafe Flag to run defined inFilter on passed value
159:      */
160:     public function setField($name, $value, $bSafe = true) {
161:         switch ($name) {
162:             case 'active':
163:                 $value = (int) $value;
164:                 break;
165:         }
166: 
167:         return parent::setField($name, $value, $bSafe);
168:     }
169:     
170: }
171: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen