Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
  • 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
  • cTinyMCEEditor
  • cWYSIWYGEditor
  • FrontendList
  • HtmlParser
  • TreeItem
  • UploadList
  • UploadSearchResultList

Functions

  • _processCmsTags
  • addArtspec
  • addslashes_deep
  • 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
  • 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
  • endsWith
  • extractNumber
  • generateDisplayFilePath
  • generateJs
  • getAktuellType
  • 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
  • modTestModule
  • 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
  • setHelpContext
  • setSystemProperty
  • showTree
  • startTiming
  • statCreateLocationString
  • statDisplayTopChooser
  • statDisplayYearlyTopChooser
  • statGetAvailableMonths
  • statGetAvailableYears
  • statResetStatistic
  • statsArchive
  • statsDisplayInfo
  • statsOverviewAll
  • statsOverviewTop
  • statsOverviewTopYear
  • statsOverviewYear
  • strAssignTemplate
  • strBuildSqlValues
  • strCheckTreeForErrors
  • strCopyCategory
  • strCopyTree
  • strDeeperCategoriesArray
  • strDeleteCategory
  • strHasArticles
  • strHasStartArticle
  • stripslashes_deep
  • 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
  • tplGetContainerTypes
  • tplGetInUsedData
  • tplIsTemplateInUse
  • tplPreparseLayout
  • updateClientCache
  • updateFileInformation
  • uplCreateFriendlyName
  • uplDirectoryListRecursive
  • uplGetDirectoriesToExclude
  • uplGetFileExtension
  • uplGetFileIcon
  • uplGetFileTypeDescription
  • uplGetThumbnail
  • uplHasFiles
  • uplHasSubdirs
  • uplmkdir
  • uplRecursiveDBDirectoryList
  • uplRecursiveDirectoryList
  • uplRenameDirectory
  • uplSearch
  • uplSyncDirectory
  • uplSyncDirectoryDBFS
  • xmlFileToArray
  • 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:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author Frederic Schneider
 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: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: /**
 19:  * Effective setting manager class.
 20:  * Provides a interface to retrieve effective
 21:  * settings.
 22:  *
 23:  * Requested effective settings will be cached at first time. Further requests
 24:  * will
 25:  * return cached settings.
 26:  *
 27:  * The order to retrieve a effective setting is:
 28:  * System => Client => Client (language) => Group => User
 29:  *
 30:  * - System properties can be overridden by the client
 31:  * - Client properties can be overridden by client language
 32:  * - Client language properties can be overridden by group
 33:  * - Group properties can be overridden by user
 34:  *
 35:  * @package Core
 36:  * @subpackage Backend
 37:  */
 38: class cEffectiveSetting {
 39: 
 40:     /**
 41:      *
 42:      * @var array
 43:      */
 44:     protected static $_settings = array();
 45: 
 46:     /**
 47:      *
 48:      * @var cApiUser
 49:      */
 50:     protected static $_user;
 51: 
 52:     /**
 53:      *
 54:      * @var cApiClient
 55:      */
 56:     protected static $_client;
 57: 
 58:     /**
 59:      *
 60:      * @var cApiClientLanguage
 61:      */
 62:     protected static $_clientLanguage;
 63: 
 64:     /**
 65:      *
 66:      * @var cApiLanguage
 67:      */
 68:     protected static $_language;
 69: 
 70:     /**
 71:      * Returns effective setting for a property.
 72:      * The requested setting will be cached at first time, the next time the
 73:      * cached value will be returned.
 74:      *
 75:      * The order is: System => Client => Client (language) => Group => User
 76:      *
 77:      * System properties can be overridden by the group, and group properties
 78:      * can be overridden by the user.
 79:      *
 80:      * @param string $type The type of the item
 81:      * @param string $name The name of the item
 82:      * @param string $default Optional default value
 83:      * @return string bool setting value or false
 84:      */
 85:     public static function get($type, $name, $default = '') {
 86:         global $contenido;
 87: 
 88:         // if the DB object is not available, just return
 89:         // the default value in order to avoid PHP notices
 90:         try {
 91:             $db = new cDb();
 92:         } catch (cException $e) {
 93:             return $default;
 94:         }
 95: 
 96:         $key = self::_makeKey($type, $name);
 97: 
 98:         $value = self::_get($key);
 99:         if (false !== $value) {
100:             return $value;
101:         }
102: 
103:         if (self::_isAuthenticated() && isset($contenido)) {
104:             $value = self::_getUserInstance()->getUserProperty($type, $name, true);
105:         }
106: 
107:         if (false === $value) {
108:             $value = self::_getLanguageInstance()->getProperty($type, $name);
109:         }
110: 
111:         if (false === $value) {
112:             $value = self::_getClientLanguageInstance()->getProperty($type, $name);
113:         }
114: 
115:         if (false === $value) {
116:             $value = self::_getClientInstance()->getProperty($type, $name);
117:         }
118: 
119:         if ($value === false) {
120:             $value = getSystemProperty($type, $name);
121:         }
122: 
123:         if ($value === false || $value === '' || $value === NULL) {
124:             $value = $default;
125:         }
126: 
127:         self::_set($key, $value);
128: 
129:         return $value;
130:     }
131: 
132:     /**
133:      * Returns effective setting for a type of properties.
134:      * Caches also the collected settings, but contrary to get() it returns
135:      * never cached entries.
136:      *
137:      * The order is:
138:      * System => Client => Client (language) => Group => User
139:      *
140:      * System properties can be overridden by the group, and group
141:      * properties can be overridden by the user.
142:      *
143:      * @param string $type The type of the item
144:      * @return array Assoziative array like $arr[name] = value
145:      */
146:     public static function getByType($type) {
147:         global $contenido;
148: 
149:         $settings = getSystemPropertiesByType($type);
150:         $settings = array_merge($settings, self::_getClientInstance()->getPropertiesByType($type));
151:         $settings = array_merge($settings, self::_getClientLanguageInstance()->getPropertiesByType($type));
152:         if (self::_isAuthenticated() && isset($contenido)) {
153:             $settings = array_merge($settings, self::_getUserInstance()->getUserPropertiesByType($type, true));
154:         }
155: 
156:         // cache all settings, to return them from cache in case of calling
157:         // get()
158:         foreach ($settings as $setting => $value) {
159:             $key = self::_makeKey($type, $setting);
160:             self::_set($key, $value);
161:         }
162: 
163:         return $settings;
164:     }
165: 
166:     /**
167:      * Sets a effective setting.
168:      *
169:      * Note:
170:      * The setting will be set only in cache, not in persistency layer.
171:      *
172:      * @param string $type The type of the item
173:      * @param string $name The name of the item
174:      * @param string $value The value of the setting
175:      */
176:     public static function set($type, $name, $value) {
177:         $key = self::_makeKey($type, $name);
178:         self::_set($key, $value);
179:     }
180: 
181:     /**
182:      * Deletes a effective setting.
183:      *
184:      * Note:
185:      * The setting will be deleted only from cache, not from persistency layer.
186:      *
187:      * @param string $type The type of the item
188:      * @param string $name The name of the item
189:      */
190:     public static function delete($type, $name) {
191:         $keySuffix = '_' . $type . '_' . $name;
192:         foreach (self::$_settings as $key => $value) {
193:             if (strpos($key, $keySuffix) !== false) {
194:                 unset(self::$_settings[$key]);
195:             }
196:         }
197:     }
198: 
199:     /**
200:      * Resets all properties of the effective settings class.
201:      * Usable to start getting settings from scratch.
202:      */
203:     public static function reset() {
204:         self::$_settings = array();
205:         unset(self::$_user, self::$_client, self::$_clientLanguage);
206:     }
207: 
208:     /**
209:      * Returns the user object instance.
210:      *
211:      * @return cApiUser
212:      */
213:     protected static function _getUserInstance() {
214:         global $auth;
215: 
216:         if (!isset(self::$_user)) {
217:             self::$_user = new cApiUser($auth->auth['uid']);
218:         }
219:         return self::$_user;
220:     }
221: 
222:     /**
223:      * Returns the client language object instance.
224:      *
225:      * @return cApiClientLanguage
226:      */
227:     protected static function _getClientLanguageInstance() {
228:         global $client, $lang;
229: 
230:         if (!isset(self::$_clientLanguage)) {
231:             self::$_clientLanguage = new cApiClientLanguage(false, $client, $lang);
232:         }
233:         return self::$_clientLanguage;
234:     }
235: 
236:     /**
237:      * Returns the language object instance.
238:      *
239:      * @return cApiLanguage
240:      */
241:     protected static function _getLanguageInstance() {
242:         global $lang;
243: 
244:         if (!isset(self::$_language)) {
245:             self::$_language = new cApiLanguage($lang);
246:         }
247:         return self::$_language;
248:     }
249: 
250:     /**
251:      * Returns the client language object instance.
252:      *
253:      * @return cApiClient
254:      */
255:     protected static function _getClientInstance() {
256:         global $client;
257: 
258:         if (!isset(self::$_client)) {
259:             self::$_client = new cApiClient($client);
260:         }
261:         return self::$_client;
262:     }
263: 
264:     /**
265:      * Setting getter.
266:      *
267:      * @param string $key The setting key
268:      * @return string bool setting value or false
269:      */
270:     protected static function _get($key) {
271:         return (isset(self::$_settings[$key])) ? self::$_settings[$key] : false;
272:     }
273: 
274:     /**
275:      * Setting setter.
276:      *
277:      * @param string $key The setting key
278:      * @param string $value Value to store
279:      */
280:     protected static function _set($key, $value) {
281:         self::$_settings[$key] = $value;
282:     }
283: 
284:     /**
285:      * Setting key getter.
286:      *
287:      * @param string $type The type of the item
288:      * @param string $name Name of the item
289:      * @return string The setting key
290:      */
291:     protected static function _makeKey($type, $name) {
292:         global $auth;
293: 
294:         if ($auth instanceof cAuth) {
295:             $key = $auth->auth['uid'] . '_' . $type . '_' . $name;
296:         } else {
297:             $key = '_' . $type . '_' . $name;
298:         }
299:         return $key;
300:     }
301: 
302:     /**
303:      * Checks global authentication object and if current user is authenticated.
304:      *
305:      * @return bool
306:      */
307:     protected static function _isAuthenticated() {
308:         global $auth;
309:         return ($auth instanceof cAuth && $auth->isAuthenticated() && !$auth->isLoginForm());
310:     }
311: }
CMS CONTENIDO 4.9.1 API documentation generated by ApiGen 2.8.0