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

  • cAjaxRequest
  • cAutoload
  • cBackend
  • cEffectiveSetting
  • cGuiScrollListAlltranslations
  • cHTMLValidator
  • cMailer
  • cModuleFileTranslation
  • cModuleHandler
  • cModuleSearch
  • cModuleSynchronizer
  • cModuleTemplateHandler
  • CodeMirror
  • cPasswordRequest
  • cPermission
  • cRegistry
  • cSystemPurge
  • cSystemtest
  • cTinymce4Configuration
  • cTinyMCE4Editor
  • cTinyMCEEditor
  • cWYSIWYGEditor
  • FrontendList
  • HtmlParser
  • TODOBackendList
  • TreeItem
  • UploadList
  • UploadSearchResultList

Functions

  • addArtspec
  • addSortImages
  • backToMainArea
  • buildArticleSelect
  • buildCategorySelect
  • buildCategorySelectRights
  • buildHeapTable
  • buildStackString
  • buildTree
  • buildUserOrGroupPermsFromRequest
  • callPluginStore
  • cApiCatGetLevelNode
  • cApiImageCheckCachedImageValidity
  • cApiImageCheckImageEditingPosibility
  • cApiImageGetCacheFileName
  • cApiImageGetTargetDimensions
  • cApiImageIsAnimGif
  • cApiImgScale
  • cApiImgScaleGetMD5CacheFile
  • cApiImgScaleHQ
  • cApiImgScaleImageMagick
  • cApiImgScaleLQ
  • cApiIsImageMagickAvailable
  • cApiStrCleanURLCharacters
  • cApiStrNormalizeLineEndings
  • cApiStrRecodeString
  • cApiStrReplaceDiacritics
  • cApiStrTrimAfterWord
  • cApiStrTrimHard
  • cApiStrTrimSentence
  • cDeprecated
  • cDie
  • cError
  • checkLangInClients
  • checkPathInformation
  • cInclude
  • compareUrlStrings
  • conChangeTemplateForCat
  • conCopyArticle
  • conCopyArtLang
  • conCopyContainerConf
  • conCopyContent
  • conCopyMetaTags
  • conCopyTemplateConfiguration
  • conCreateLocationString
  • conDeeperCategoriesArray
  • conDeleteart
  • conEditArt
  • conEditFirstTime
  • conFetchCategoryTree
  • conFlagOnOffline
  • conGenerateCode
  • conGenerateCodeForAllArts
  • conGenerateCodeForAllArtsInCategory
  • conGenerateCodeForAllartsUsingLayout
  • conGenerateCodeForAllartsUsingMod
  • conGenerateCodeForAllArtsUsingTemplate
  • conGenerateCodeForArtInAllCategories
  • conGenerateCodeForClient
  • conGenerateKeywords
  • conGetAvailableMetaTagTypes
  • conGetCategoryArticleId
  • conGetCategoryAssignments
  • conGetContainerConfiguration
  • conGetContentFromArticle
  • conGetHtmlTranslationTable
  • conGetMetaValue
  • conGetTemplateConfigurationIdForArticle
  • conGetTemplateConfigurationIdForCategory
  • conGetTopmostCat
  • conGetUsedModules
  • conHtmlentities
  • conHtmlEntityDecode
  • conHtmlSpecialChars
  • conIsLocked
  • conLock
  • conLockBulkEditing
  • conMakeArticleIndex
  • conMakeCatOnline
  • conMakeInlineScript
  • conMakeOnline
  • conMakeOnlineBulkEditing
  • conMakePublic
  • conMakeStart
  • conMoveArticles
  • conPhp54Check
  • conRemoveOldCategoryArticle
  • conSaveContentEntry
  • conSetCodeFlag
  • conSetCodeFlagBulkEditing
  • conSetMetaValue
  • conSyncArticle
  • copyRightsForElement
  • createBulkEditingFunction
  • createRandomName
  • createRightsForElement
  • cWarning
  • dbGetColumns
  • dbGetIndexes
  • dbGetPrimaryKeyName
  • dbTableExists
  • dbUpgradeTable
  • defineIfNotDefined
  • deleteArtspec
  • deleteRightsForElement
  • deleteSystemProperty
  • displayDatetime
  • emptyLogFile
  • endAndLogTiming
  • extractNumber
  • generateDisplayFilePath
  • generateJs
  • getAllClientsAndLanguages
  • getArtLang
  • getArtspec
  • getAvailableContentTypes
  • getCanonicalDay
  • getCanonicalMonth
  • getDirectorySize
  • getEffectiveSetting
  • getEffectiveSettingsByType
  • getEncodingByLanguage
  • getFileContents
  • getFileInformation
  • getFileType
  • getGroupOrUserName
  • getIDForArea
  • getJsHelpContext
  • getLanguageNamesByClient
  • getLanguagesByClient
  • getmicrotime
  • getNamedFrame
  • getParam
  • getParentAreaId
  • getSearchResults
  • getStrExpandCollapseButton
  • getSystemProperties
  • getSystemPropertiesByType
  • getSystemProperty
  • getTemplateSelect
  • getUplExpandCollapseButton
  • htmldecode
  • htmlentities_iso88592
  • humanReadableSize
  • includePlugins
  • insertEmptyStrRow
  • ipMatch
  • isAlphanumeric
  • isArchive
  • isArtInMultipleUse
  • isFunctionDisabled
  • isGroup
  • isIPv4
  • isRunningFromWeb
  • isStartArticle
  • isUtf8
  • isValidMail
  • langActivateDeactivateLanguage
  • langDeleteLanguage
  • langEditLanguage
  • langGetTextDirection
  • langNewLanguage
  • langRenameLanguage
  • layDeleteLayout
  • layEditLayout
  • machineReadableSize
  • mailLogBulkEditingFunctions
  • mailLogDecodeAddresses
  • markSubMenuItem
  • mask
  • modDeleteModule
  • modEditModule
  • phpInfoToHtml
  • plugin_include
  • prCreateURLNameLocationString
  • prDeleteCacheFileContent
  • prGetCacheFileContent
  • prResolvePathViaCategoryNames
  • prResolvePathViaURLNames
  • prWriteCacheFileContent
  • putFileContents
  • recursiveCopy
  • removeFileInformation
  • renderBackendBreadcrumb
  • renderLabel
  • renderSelectProperty
  • renderTextProperty
  • saveGroupRights
  • saveRights
  • scanDirectory
  • scanPlugins
  • sendEncodingHeader
  • set_magic_quotes_gpc
  • setArtspecDefault
  • setArtspecOnline
  • setSystemProperty
  • showTree
  • startTiming
  • statCreateLocationString
  • statDisplayTopChooser
  • statDisplayYearlyTopChooser
  • statGetAvailableMonths
  • statGetAvailableYears
  • statResetStatistic
  • statsArchive
  • statsDisplayInfo
  • statsOverviewAll
  • statsOverviewTop
  • statsOverviewTopYear
  • statsOverviewYear
  • strAssignTemplate
  • strBuildSqlValues
  • strCheckTreeForErrors
  • strCopyCategory
  • strCopyTree
  • strDeeperCategoriesArray
  • strDeleteCategory
  • strHasArticles
  • strHasStartArticle
  • strMakePublic
  • strMakeVisible
  • strMoveCatTargetallowed
  • strMoveDownCategory
  • strMoveSubtree
  • strMoveUpCategory
  • strNewCategory
  • strNewTree
  • strNextBackwards
  • strNextDeeper
  • strNextDeeperAll
  • strNextPost
  • strOrderedPostTreeList
  • strRemakeTreeTable
  • strRenameCategory
  • strRenameCategoryAlias
  • strSortPrePost
  • strSyncCategory
  • systemHavePerm
  • tplAutoFillModules
  • tplBrowseLayoutForContainers
  • tplcfgDuplicate
  • tplDeleteTemplate
  • tplDuplicateTemplate
  • tplEditTemplate
  • tplGetContainerDefault
  • tplGetContainerMode
  • tplGetContainerName
  • tplGetContainerNumbersInLayout
  • tplGetContainerTypes
  • tplGetInUsedData
  • tplIsTemplateInUse
  • tplPreparseLayout
  • tplProcessSendContainerConfiguration
  • updateClientCache
  • updateFileInformation
  • uplCreateFriendlyName
  • uplDirectoryListRecursive
  • uplGetDirectoriesToExclude
  • uplGetFileExtension
  • uplGetFileIcon
  • uplGetFileTypeDescription
  • uplGetThumbnail
  • uplHasFiles
  • uplHasSubdirs
  • uplmkdir
  • uplRecursiveDBDirectoryList
  • uplRecursiveDirectoryList
  • uplRenameDirectory
  • uplSearch
  • uplSyncDirectory
  • uplSyncDirectoryDBFS
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the the effective setting class.
  4:  *
  5:  * @package Core
  6:  * @subpackage Backend
  7:  * @author Frederic Schneider
  8:  * @copyright four for business AG <www.4fb.de>
  9:  * @license http://www.contenido.org/license/LIZENZ.txt
 10:  * @link http://www.4fb.de
 11:  * @link http://www.contenido.org
 12:  */
 13: 
 14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 15: 
 16: /**
 17:  * Effective setting manager class.
 18:  * Provides a interface to retrieve effective
 19:  * settings.
 20:  *
 21:  * Requested effective settings will be cached at first time. Further requests
 22:  * will
 23:  * return cached settings.
 24:  *
 25:  * The order to retrieve a effective setting is:
 26:  * System => Client => Client (language) => Group => User
 27:  *
 28:  * - System properties can be overridden by the client
 29:  * - Client properties can be overridden by client language
 30:  * - Client language properties can be overridden by group
 31:  * - Group properties can be overridden by user
 32:  *
 33:  * @package Core
 34:  * @subpackage Backend
 35:  */
 36: class cEffectiveSetting {
 37: 
 38:     /**
 39:      *
 40:      * @var array
 41:      */
 42:     protected static $_settings = array();
 43: 
 44:     /**
 45:      *
 46:      * @var cApiUser
 47:      */
 48:     protected static $_user;
 49: 
 50:     /**
 51:      *
 52:      * @var cApiClient
 53:      */
 54:     protected static $_client;
 55: 
 56:     /**
 57:      *
 58:      * @var cApiClientLanguage
 59:      */
 60:     protected static $_clientLanguage;
 61: 
 62:     /**
 63:      *
 64:      * @var bool
 65:      */
 66:     protected static $_loaded = false;
 67: 
 68:     /**
 69:      *
 70:      * @var cApiLanguage
 71:      */
 72:     protected static $_language;
 73: 
 74:     /**
 75:      * Loads all client, clientlanguage an system properties into an static array.
 76:      *
 77:      * The order is: System => Client => Client (language)
 78:      *
 79:      */
 80:     private static function _loadSettings() {
 81:         if (self::$_loaded == false) {
 82:             global $contenido;
 83: 
 84:             $typeGroup = array();
 85: 
 86:             //get all client settings
 87:             $client = self::_getClientInstance();
 88:             $settings = $client->getProperties();
 89: 
 90:             if (is_array($settings)) {
 91:                 foreach ($settings as $setting) {
 92:                     $key = self::_makeKey($setting['type'], $setting['name']);
 93:                     self::_set($key, $setting['value']);
 94:                     if (!isset($typeGroup[$setting['type']])) {
 95:                         $typeGroup[$setting['type']] = array();
 96:                     }
 97:                     $typeGroup[$setting['type']][$setting['name']] = $setting['value'];
 98:                 }
 99:             }
100: 
101:             //get all clientlang setting
102:             $clientlang = self::_getClientLanguageInstance();
103:             $settings = $clientlang->getProperties();
104: 
105:             if (is_array($settings)) {
106:                 foreach ($settings as $setting) {
107:                     $key = self::_makeKey($setting['type'], $setting['name']);
108:                     self::_set($key, $setting['value']);
109:                     if (!isset($typeGroup[$setting['type']])) {
110:                         $typeGroup[$setting['type']] = array();
111:                     }
112:                     $typeGroup[$setting['type']][$setting['name']] = $setting['value'];
113:                 }
114:             }
115: 
116:             //get user settings
117:             if (self::_isAuthenticated() && isset($contenido)) {
118:                 $user = self::_getUserInstance();
119:                 $settings = $user->getUserProperties();
120: 
121:                 if (is_array($settings)) {
122:                     foreach ($settings as $setting) {
123:                         $key = self::_makeKey($setting['type'], $setting['name']);
124:                         self::_set($key, $setting['value']);
125:                         if (!isset($typeGroup[$setting['type']])) {
126:                             $typeGroup[$setting['type']] = array();
127:                         }
128:                         $typeGroup[$setting['type']][$setting['name']] = $setting['value'];
129:                     }
130:                 }
131:             }
132: 
133:             //write cache by type settings
134:             foreach ($typeGroup as $key => $group) {
135:                 $key = self::_makeKey($key, ' ');
136:                 self::_set($key, $group);
137:             }
138:         }
139: 
140:         self::$_loaded = true;
141:     }
142: 
143:     /**
144:      * Returns effective setting for a property.
145:      *
146:      * The order is: System => Client => Client (language) => Group => User
147:      *
148:      * System properties can be overridden by the group, and group properties
149:      * can be overridden by the user.
150:      *
151:      * NOTE: If you provide a default value (other than empty string), then it will be returned back
152:      *       in case of not existing or empty setting.
153:      *
154:      * @param string $type
155:      *         The type of the item
156:      * @param string $name
157:      *         The name of the item
158:      * @param string $default [optional]
159:      *         default value
160:      * @return bool|string
161:      *         Setting value or false
162:      */
163:     public static function get($type, $name, $default = '') {
164:         self::_loadSettings();
165: 
166:         $key = self::_makeKey($type, $name);
167: 
168:         $value = self::_get($key);
169:         if (false !== $value) {
170:             return $value;
171:         }
172: 
173:         if (false === $value) {
174:             $value = getSystemProperty($type, $name);
175:         }
176: 
177:         if (false === $value || NULL === $value) {
178:             $value = $default;
179:         } else if ('' === $value && '' !== $default) {
180:             // NOTE: A non empty default value overrides an empty value
181:             $value = $default;
182:         }
183: 
184:         return $value;
185:     }
186: 
187:     /**
188:      * Returns effective setting for a type of properties.
189:      * Caches also the collected settings, but contrary to get() it returns
190:      * never cached entries.
191:      *
192:      * The order is:
193:      * System => Client => Client (language) => Group => User
194:      *
195:      * System properties can be overridden by the group, and group
196:      * properties can be overridden by the user.
197:      *
198:      * @param string $type
199:      *         The type of the item
200:      * @return array
201:      *         Assoziative array like $arr[name] = value
202:      */
203:     public static function getByType($type) {
204:         self::_loadSettings();
205: 
206:         $settings = getSystemPropertiesByType($type);
207: 
208:         $key = self::_makeKey($type, ' ');
209:         if (is_array(self::_get($key))) {
210:             $settings = array_merge($settings, self::_get($key));
211:         }
212: 
213:         if (isset($settings) && is_array($settings)) {
214:             return $settings;
215:         } else {
216:             return array();
217:         }
218:     }
219: 
220:     /**
221:      * Sets a effective setting.
222:      *
223:      * Note:
224:      * The setting will be set only in cache, not in persistency layer.
225:      *
226:      * @param string $type
227:      *         The type of the item
228:      * @param string $name
229:      *         The name of the item
230:      * @param string $value
231:      *         The value of the setting
232:      */
233:     public static function set($type, $name, $value) {
234:         $key = self::_makeKey($type, $name);
235:         self::_set($key, $value);
236:     }
237: 
238:     /**
239:      * Deletes a effective setting.
240:      *
241:      * Note:
242:      * The setting will be deleted only from cache, not from persistency layer.
243:      *
244:      * @param string $type
245:      *         The type of the item
246:      * @param string $name
247:      *         The name of the item
248:      */
249:     public static function delete($type, $name) {
250:         $keySuffix = '_' . $type . '_' . $name;
251:         foreach (self::$_settings as $key => $value) {
252:             if (strpos($key, $keySuffix) !== false) {
253:                 unset(self::$_settings[$key]);
254:             }
255:         }
256:     }
257: 
258:     /**
259:      * Resets all properties of the effective settings class.
260:      * Usable to start getting settings from scratch.
261:      */
262:     public static function reset() {
263:         self::$_settings = array();
264:         unset(self::$_user, self::$_client, self::$_clientLanguage);
265:     }
266: 
267:     /**
268:      * Returns the user object instance.
269:      *
270:      * @return cApiUser
271:      */
272:     protected static function _getUserInstance() {
273:         global $auth;
274: 
275:         if (!isset(self::$_user)) {
276:             self::$_user = new cApiUser($auth->auth['uid']);
277:         }
278:         return self::$_user;
279:     }
280: 
281:     /**
282:      * Returns the client language object instance.
283:      *
284:      * @return cApiClientLanguage
285:      */
286:     protected static function _getClientLanguageInstance() {
287:         global $client, $lang;
288: 
289:         if (!isset(self::$_clientLanguage)) {
290:             self::$_clientLanguage = new cApiClientLanguage(false, $client, $lang);
291:         }
292:         return self::$_clientLanguage;
293:     }
294: 
295:     /**
296:      * Returns the language object instance.
297:      *
298:      * @return cApiLanguage
299:      */
300:     protected static function _getLanguageInstance() {
301:         global $lang;
302: 
303:         if (!isset(self::$_language)) {
304:             self::$_language = new cApiLanguage($lang);
305:         }
306:         return self::$_language;
307:     }
308: 
309:     /**
310:      * Returns the client language object instance.
311:      *
312:      * @return cApiClient
313:      */
314:     protected static function _getClientInstance() {
315:         global $client;
316: 
317:         if (!isset(self::$_client)) {
318:             self::$_client = new cApiClient($client);
319:         }
320:         return self::$_client;
321:     }
322: 
323:     /**
324:      * Setting getter.
325:      *
326:      * @param string $key
327:      *         The setting key
328:      * @return string
329:      *         bool setting value or false
330:      */
331:     protected static function _get($key) {
332:         return (isset(self::$_settings[$key])) ? self::$_settings[$key] : false;
333:     }
334: 
335:     /**
336:      * Setting setter.
337:      *
338:      * @param string $key
339:      *         The setting key
340:      * @param string $value
341:      *         Value to store
342:      */
343:     protected static function _set($key, $value) {
344:         self::$_settings[$key] = $value;
345:     }
346: 
347:     /**
348:      * Setting key getter.
349:      *
350:      * @param string $type
351:      *         The type of the item
352:      * @param string $name
353:      *         Name of the item
354:      * @return string
355:      *         The setting key
356:      */
357:     protected static function _makeKey($type, $name) {
358:         $key = self::_getKeyPrefix() . '_' . $type . '_' . $name;
359: 
360:         return $key;
361:     }
362: 
363:     /**
364:      * Returns the prefix for the internal key.
365:      *
366:      * @return string
367:      */
368:     protected static function _getKeyPrefix() {
369:         global $auth;
370: 
371:         $prefix = '';
372: 
373:         if ($auth instanceof cAuth) {
374:             if (!self::_isAuthenticated()) {
375:                 $prefix = cAuth::AUTH_UID_NOBODY;
376:             } else {
377:                 $prefix = $auth->auth['uid'];
378:             }
379:         }
380: 
381:         return $prefix;
382:     }
383: 
384:     /**
385:      * Checks global authentication object and if current user is authenticated.
386:      *
387:      * @return bool
388:      */
389:     protected static function _isAuthenticated() {
390:         global $auth;
391:         return $auth instanceof cAuth && $auth->isAuthenticated() && !$auth->isLoginForm();
392:     }
393: }
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0