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

  • 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
  • cApiImageCheckImageEditingPossibility
  • 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
  • conGetUniqueArticleUrlname
  • conGetUsedModules
  • conHtmlentities
  • conHtmlEntityDecode
  • conHtmlSpecialChars
  • conIsArticleUrlnameUnique
  • conIsLocked
  • conLock
  • conLockBulkEditing
  • conMakeArticleIndex
  • conMakeCatOnline
  • conMakeInlineScript
  • conMakeOnline
  • conMakeOnlineBulkEditing
  • conMakePublic
  • conMakeStart
  • conMoveArticles
  • conPhp54Check
  • conRemoveOldCategoryArticle
  • conSaveContentEntry
  • conSetCodeFlag
  • conSetCodeFlagBulkEditing
  • conSetMetaValue
  • conSetStartArticle
  • consoleLog
  • 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
  • getFileInformation
  • getFileType
  • getGroupOrUserName
  • getIDForArea
  • getJsHelpContext
  • getLanguageNamesByClient
  • getLanguagesByClient
  • getmicrotime
  • getNamedFrame
  • getParentAreaId
  • getRightsList
  • 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
  • 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
  • strCheckAlias
  • 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
  • Function
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * This file contains the CONTENIDO language functions.
  5:  *
  6:  * @package Core
  7:  * @subpackage Backend
  8:  * @author Jan Lengowski
  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: cInclude('includes', 'functions.con.php');
 18: cInclude('includes', 'functions.str.php');
 19: 
 20: /**
 21:  * Edit a language
 22:  *
 23:  * @param int    $idlang
 24:  * @param string $langname
 25:  *         Name of the language
 26:  * @param string $encoding
 27:  * @param int    $active
 28:  *         Flag for active state, 1 or 0
 29:  * @param string $direction
 30:  *
 31:  * @return bool
 32:  * 
 33:  * @throws cDbException
 34:  * @throws cException
 35:  * @throws cInvalidArgumentException
 36:  */
 37: function langEditLanguage($idlang, $langname, $encoding, $active, $direction = 'ltr') {
 38:     $oLang = new cApiLanguage();
 39:     if ($oLang->loadByPrimaryKey((int) $idlang)) {
 40:         if ('' === $langname) {
 41:             $langname = "-- ".i18n("New language")." --";
 42:         }
 43:         $oLang->set('name', $langname, false);
 44:         $oLang->set('encoding', $encoding, false);
 45:         $oLang->set('active', $active, false);
 46:         $oLang->set('direction', $direction, false);
 47:         return $oLang->store();
 48:     }
 49:     return false;
 50: }
 51: 
 52: /**
 53:  * Create a new language
 54:  *
 55:  * @param string $name
 56:  *         Name of the language
 57:  * @param int    $client
 58:  *         Id of client
 59:  *
 60:  * @return int
 61:  *         New language id
 62:  * 
 63:  * @throws cDbException
 64:  * @throws cException
 65:  * @throws cInvalidArgumentException
 66:  */
 67: function langNewLanguage($name, $client) {
 68:     global $cfgClient, $notification;
 69: 
 70:     // Add new language to database
 71:     $oLangCol = new cApiLanguageCollection();
 72:     $oLangItem = $oLangCol->create($name, 0, 'utf-8', 'ltr');
 73:     // Add new client language to database
 74:     $oClientLangCol = new cApiClientLanguageCollection();
 75:     $oClientLangItem = $oClientLangCol->create($client, $oLangItem->get('idlang'));
 76: 
 77:     // Ab hyr seynd Drachen
 78:     $destPath = $cfgClient[$client]['config']['path'];
 79: 
 80:     if (cFileHandler::exists($destPath) && cFileHandler::exists($destPath . 'config.php')) {
 81:         $buffer = cFileHandler::read($destPath . 'config.php');
 82:         $outbuf = str_replace('!LANG!', $oLangItem->get('idlang'), $buffer);
 83:         cFileHandler::write($destPath . 'config.php.new', $outbuf);
 84:         if (cFileHandler::exists($destPath . 'config.php')) {
 85:             cFileHandler::remove($destPath . 'config.php');
 86:         }
 87: 
 88:         cFileHandler::rename($destPath . 'config.php.new', 'config.php');
 89:     } else {
 90:         $notification->displayNotification('error', i18n("Could not set the language-ID in the file 'config.php'. Please set the language manually."));
 91:     }
 92: 
 93:     return $oLangItem->get('idlang');
 94: }
 95: 
 96: /**
 97:  * Rename a language
 98:  *
 99:  * @param int    $idlang
100:  *         Id of the language
101:  * @param string $name
102:  *         Name of the language
103:  *
104:  * @return bool
105:  * 
106:  * @throws cDbException
107:  * @throws cException
108:  * @throws cInvalidArgumentException
109:  */
110: function langRenameLanguage($idlang, $name) {
111:     $oLang = new cApiLanguage();
112:     if ($oLang->loadByPrimaryKey(cSecurity::toInteger($idlang))) {
113:         $oLang->set('name', $name, false);
114:         return $oLang->store();
115:     }
116:     return false;
117: }
118: 
119: /**
120:  * Delete a language
121:  *
122:  * @param int $iIdLang
123:  *         Id of the language
124:  * @param int $iIdClient
125:  *         Id of the client, uses global client id by default
126:  *
127:  * @return void|string
128:  * 
129:  * @throws cDbException
130:  * @throws cException
131:  * @throws cInvalidArgumentException
132:  */
133: function langDeleteLanguage($iIdLang, $iIdClient = 0) {
134:     global $db, $sess, $client, $cfg, $notification, $cfgClient;
135: 
136:     $deleteok = 1;
137:     $iIdLang = (int) $iIdLang;
138:     $iIdClient = (int) $iIdClient;
139: 
140:     // Bugfix: New idclient parameter introduced, as Administration -> Languages
141:     // is used for different clients to delete the language
142:     // Use global client id, if idclient not specified (former behaviour)
143:     // Note, that this check also have been added for the action in the database
144:     // - just to be equal to langNewLanguage
145:     if ($iIdClient == 0) {
146:         $iIdClient = $client;
147:     }
148: 
149:     // ************ check if there are still arts online
150:     $sql = "SELECT * FROM " . $cfg['tab']['art_lang'] . " AS A, " . $cfg['tab']['art'] . " AS B " . "WHERE A.idart=B.idart AND B.idclient=" . $iIdClient . " AND A.idlang=" . $iIdLang;
151:     $db->query($sql);
152:     if ($db->nextRecord()) {
153:         conDeleteArt($db->f('idart'));
154:     }
155: 
156:     // ************ check if there are visible categories
157:     $sql = "SELECT * FROM " . $cfg['tab']['cat_lang'] . " AS A, " . $cfg['tab']['cat'] . " AS B " . "WHERE A.idcat=B.idcat AND B.idclient=" . $iIdClient . " AND A.idlang=" . $iIdLang;
158:     $db->query($sql);
159:     if ($db->nextRecord()) {
160:         strDeleteCategory($db->f('idcat'));
161:     }
162: 
163:     $aIdArtLang = array();
164:     $aIdArt = array();
165:     $aIdCatLang = array();
166:     $aIdCat = array();
167:     $aIdTplCfg = array();
168: 
169:     if ($deleteok == 1) {
170:         // ********* check if this is the clients last language to be deleted,
171:         // if yes delete from art, cat, and cat_art as well
172:         $lastlanguage = 0;
173:         $sql = "SELECT COUNT(*) FROM " . $cfg['tab']['clients_lang'] . " WHERE idclient=" . $iIdClient;
174:         $db->query($sql);
175:         $db->nextRecord();
176:         if ($db->f(0) == 1) {
177:             $lastlanguage = 1;
178:         }
179: 
180:         // ********** delete from 'art_lang'-table
181:         $sql = "SELECT A.idtplcfg AS idtplcfg, idartlang, A.idart FROM " . $cfg['tab']['art_lang'] . " AS A, " . $cfg['tab']['art'] . " AS B WHERE A.idart=B.idart AND B.idclient=" . $iIdClient . "
182:                 AND idlang!=0 AND idlang=" . $iIdLang;
183:         $db->query($sql);
184:         while ($db->nextRecord()) {
185:             $aIdArtLang[] = $db->f('idartlang');
186:             $aIdArt[] = $db->f('idart');
187:             $aIdTplCfg[] = $db->f('idtplcfg');
188:         }
189:         foreach ($aIdArtLang as $value) {
190:             $value = (int) $value;
191:             $sql = "DELETE FROM " . $cfg['tab']['art_lang'] . " WHERE idartlang=" . $value;
192:             $db->query($sql);
193:             $sql = "DELETE FROM " . $cfg['tab']['content'] . " WHERE idartlang=" . $value;
194:             $db->query($sql);
195:         }
196: 
197:         if ($lastlanguage == 1) {
198:             foreach ($aIdArt as $value) {
199:                 $value = (int) $value;
200:                 $sql = "DELETE FROM " . $cfg['tab']['art'] . " WHERE idart=" . $value;
201:                 $db->query($sql);
202:                 $sql = "DELETE FROM " . $cfg['tab']['cat_art'] . " WHERE idart=" . $value;
203:                 $db->query($sql);
204:             }
205:         }
206: 
207:         // ********** delete from 'cat_lang'-table
208:         $sql = "SELECT A.idtplcfg AS idtplcfg, idcatlang, A.idcat FROM " . $cfg['tab']['cat_lang'] . " AS A, " . $cfg['tab']['cat'] . " AS B WHERE A.idcat=B.idcat AND B.idclient=" . $iIdClient . "
209:                 AND idlang!=0 AND idlang=" . $iIdLang;
210:         $db->query($sql);
211:         while ($db->nextRecord()) {
212:             $aIdCatLang[] = $db->f('idcatlang');
213:             $aIdCat[] = $db->f('idcat');
214:             $aIdTplCfg[] = $db->f('idtplcfg'); // added
215:         }
216:         foreach ($aIdCatLang as $value) {
217:             $sql = "DELETE FROM " . $cfg['tab']['cat_lang'] . " WHERE idcatlang=" . (int) $value;
218:             $db->query($sql);
219:         }
220:         if ($lastlanguage == 1) {
221:             foreach ($aIdCat as $value) {
222:                 $value = (int) $value;
223:                 $sql = "DELETE FROM " . $cfg['tab']['cat'] . " WHERE idcat=" . $value;
224:                 $db->query($sql);
225:                 $sql = "DELETE FROM " . $cfg['tab']["cat_tree"] . " WHERE idcat=" . $value;
226:                 $db->query($sql);
227:             }
228:         }
229: 
230:         // ********** delete from 'stat'-table
231:         $sql = "DELETE FROM " . $cfg['tab']['stat'] . " WHERE idlang=" . $iIdLang . " AND idclient=" . $iIdClient;
232:         $db->query($sql);
233: 
234:         // ********** delete from 'code'-cache
235:         if (cFileHandler::exists($cfgClient[$iIdClient]['code']['path'])) {
236:             /* @var $file SplFileInfo */
237:             foreach (new DirectoryIterator($cfgClient[$iIdClient]['code']['path']) as $file) {
238:                 if ($file->isFile() === false) {
239:                     continue;
240:                 }
241: 
242:                 $extension = cString::getPartOfString($file, cString::findLastPos($file->getBasename(), '.') + 1);
243:                 if ($extension != 'php') {
244:                     continue;
245:                 }
246: 
247:                 if (preg_match('/' . $iIdClient . '.' . $iIdLang . '.[0-9*]/s', $file->getBasename())) {
248:                     cFileHandler::remove($cfgClient[$iIdClient]['code']['path'] . '/' . $file->getFilename());
249:                 }
250:             }
251:         }
252: 
253:         foreach ($aIdTplCfg as $tplcfg) {
254:             $tplcfg = (int) $tplcfg;
255:             if ($tplcfg != 0) {
256:                 // ********** delete from 'tpl_conf'-table
257:                 $sql = "DELETE FROM " . $cfg['tab']['tpl_conf'] . " WHERE idtplcfg=" . $tplcfg;
258:                 $db->query($sql);
259:                 // ********** delete from 'container_conf'-table
260:                 $sql = "DELETE FROM " . $cfg['tab']['container_conf'] . " WHERE idtplcfg=" . $tplcfg;
261:                 $db->query($sql);
262:             }
263:         }
264: 
265:         // *********** delete from 'clients_lang'-table
266:         $sql = "DELETE FROM " . $cfg['tab']['clients_lang'] . " WHERE idclient=" . $iIdClient . " AND idlang=" . $iIdLang;
267:         $db->query($sql);
268: 
269:         // *********** delete from 'lang'-table
270:         $sql = "DELETE FROM " . $cfg['tab']['lang'] . " WHERE idlang=" . $iIdLang;
271:         $db->query($sql);
272: 
273:         // *********** delete from 'properties'-table
274:         $oPropertyColl = new cApiPropertyCollection($iIdClient);
275:         $oPropertyColl->deleteProperties('idlang', $iIdLang);
276:     } else {
277:         return $notification->returnMessageBox('error', i18n("Could not delete language"), 0);
278:     }
279: }
280: 
281: /**
282:  * Deactivate a language
283:  *
284:  * @param int $idlang
285:  * @param int $active
286:  *
287:  * @return bool
288:  * 
289:  * @throws cDbException
290:  * @throws cException
291:  * @throws cInvalidArgumentException
292:  */
293: function langActivateDeactivateLanguage($idlang, $active) {
294:     $oLang = new cApiLanguage();
295:     if ($oLang->loadByPrimaryKey((int) $idlang)) {
296:         $oLang->set('active', (int) $active, false);
297:         return $oLang->store();
298:     }
299:     return false;
300: }
301: 
302: /**
303:  * Returns the base direction of text (ltr = left to right, rtl = right to left)
304:  * by language id
305:  *
306:  * @param int $idlang
307:  * @param cDb $db
308:  *         Is not in use
309:  *
310:  * @return string
311:  *         'ltr' or 'rtl'
312:  * 
313:  * @throws cDbException
314:  * @throws cException
315:  */
316: function langGetTextDirection($idlang, $db = NULL) {
317:     static $oLang;
318:     if (!isset($oLang)) {
319:         $oLang = new cApiLanguage();
320:     }
321:     $direction = '';
322:     if ($oLang->loadByPrimaryKey((int) $idlang)) {
323:         $direction = $oLang->get('direction');
324:     }
325:     if ($direction != 'ltr' && $direction != 'rtl') {
326:         $direction = 'ltr';
327:     }
328:     return $direction;
329: }
330: 
CMS CONTENIDO 4.10.0 API documentation generated by ApiGen 2.8.0