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 module file translation class.
  4:  * TODO: Rework comments of this class.
  5:  *
  6:  * @package    Core
  7:  * @subpackage Backend
  8:  * @version    SVN Revision $Rev:$
  9:  *
 10:  * @author     Rusmir Jusufovic
 11:  * @copyright  four for business AG <www.4fb.de>
 12:  * @license    http://www.contenido.org/license/LIZENZ.txt
 13:  * @link       http://www.4fb.de
 14:  * @link       http://www.contenido.org
 15:  */
 16: 
 17: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 18: 
 19: /**
 20:  * This class save the translations from a modul in a file
 21:  * and get it from file.
 22:  *
 23:  * @package    Core
 24:  * @subpackage Backend
 25:  */
 26: class cModuleFileTranslation extends cModuleHandler {
 27: 
 28:     /**
 29:      * Path to the modul directory
 30:      *
 31:      * @var string
 32:      */
 33:     private $_modulePath;
 34: 
 35:     /**
 36:      * Name of the translations file
 37:      *
 38:      * @var string
 39:      */
 40:     static $fileName = '';
 41: 
 42:     /**
 43:      * Translation array.
 44:      *
 45:      * @var array
 46:      */
 47:     static $langArray = array();
 48: 
 49:     /**
 50:      * The id of the modul
 51:      *
 52:      * @var int
 53:      */
 54:     static $savedIdMod = NULL;
 55:     static $originalTranslationDivider = '=';
 56: 
 57:     /**
 58:      *
 59:      * @param array $cfg
 60:      * @param int $idmodul
 61:      * @param bool $static if true it will load once the translation from file
 62:      * @param int $overrideIdlang use different language if not NULL
 63:      */
 64:     public function __construct($idmodul = NULL, $static = false, $overrideIdlang = NULL) {
 65:         parent::__construct($idmodul);
 66: 
 67:         // $this->_debug = true;
 68: 
 69:         if ($idmodul != NULL) {
 70:             $this->_modulePath = $this->getModulePath();
 71:         }
 72: 
 73:         // override language if specified
 74:         if ($overrideIdlang != NULL) {
 75:             $this->_idlang = $overrideIdlang;
 76:         }
 77: 
 78:         $this->_encoding = self::getEncoding($this->_idlang);
 79: 
 80:         // dont open the translations file for each mi18n call
 81:         if ($static == true) {
 82:             if (self::$savedIdMod != $idmodul) {
 83:                 // set filename lang_[language]_[Country].txt
 84:                 $language = $this->_getValueFromProperties('language', 'code');
 85:                 $country = $this->_getValueFromProperties('country', 'code');
 86:                 self::$fileName = 'lang_' . $language . '_' . strtoupper($country) . '.txt';
 87: 
 88:                 self::$langArray = $this->getTranslationArray();
 89:                 self::$savedIdMod = $idmodul;
 90:             }
 91:         } else {
 92:             self::$savedIdMod = -1;
 93: 
 94:             // set filename lang_[language]_[Country].txt
 95:             $language = $this->_getValueFromProperties('language', 'code');
 96:             $country = $this->_getValueFromProperties('country', 'code');
 97:             self::$fileName = 'lang_' . $language . '_' . strtoupper($country) . '.txt';
 98:         }
 99:     }
100: 
101:     /**
102:      * Get the value of a item from properties db.
103:      *
104:      * @param string $type
105:      * @param string $name
106:      * @return string value
107:      */
108:     private function _getValueFromProperties($type, $name) {
109:         cApiPropertyCollection::reset();
110:         $propColl = new cApiPropertyCollection();
111:         $propColl->changeClient($this->_client);
112:         return $propColl->getValue('idlang', $this->_idlang, $type, $name, '');
113:     }
114: 
115:     /**
116:      * Get the lang array.
117:      *
118:      * @return array
119:      */
120:     public function getLangArray() {
121:         return self::$langArray;
122:     }
123: 
124:     /**
125:      * Save the hole translations for a idmod and lang.
126:      * For the upgrade/setup.
127:      */
128:     public function saveTranslations() {
129:         $db = cRegistry::getDb();
130: 
131:         $oLangColl = new cApiLanguageCollection();
132:         $ids = $oLangColl->getAllIds();
133:         foreach ($ids as $idlang) {
134:             $sql = 'SELECT * FROM `%s` WHERE idlang = %d AND idmod = %d';
135:             $sql = $db->prepare($sql, $this->_cfg['tab']['mod_translations'], $idlang, $this->_idmod);
136:             $db->query($sql);
137: 
138:             $this->_idlang = $idlang;
139:             // set filename lang_[language]_[Country].txt
140:             $language = $this->_getValueFromProperties('language', 'code');
141:             $country = $this->_getValueFromProperties('country', 'code');
142:             self::$fileName = 'lang_' . $language . '_' . strtoupper($country) . '.txt';
143: 
144:             $translations = array();
145:             while ($db->nextRecord()) {
146:                 $original = urldecode(cSecurity::unfilter($db->f('original')));
147:                 $translation = urldecode(cSecurity::unfilter($db->f('translation')));
148:                 $translations[$original] = $translation;
149:             }
150: 
151:             if (count($translations) != 0) {
152:                 if ($this->saveTranslationArray($translations) == false) {
153:                     cWarning(__FILE__, __LINE__, 'Could not save translate idmod=' . $this->_idmod . ' !');
154:                 }
155:             }
156:         }
157:     }
158: 
159:     /**
160:      * This method serialize a array.
161:      * $key.[Divider].$value."\r\n"
162:      *
163:      * @param array $wordListArray
164:      * @return string
165:      */
166:     private function _serializeArray($wordListArray) {
167:         $retString = '';
168:         foreach ($wordListArray as $key => $value) {
169:             $value = iconv($this->_encoding, $this->_fileEncoding, $value);
170:             $key = iconv($this->_encoding, $this->_fileEncoding, $key);
171:             // Originall String [Divider] Translation String
172:             $retString .= $key . self::$originalTranslationDivider . $value . "\r\n";
173:         }
174: 
175:         return $retString;
176:     }
177: 
178:     /**
179:      * This method unserialize a string.
180:      * The contents of file looks like original String [Divider] Translation
181:      * String.
182:      * If divider is =
183:      * Example: Hello World=Hallo Welt
184:      *
185:      * @param string $string the contents of the file
186:      * @return array
187:      */
188:     private function _unserializeArray($string) {
189:         $retArray = array();
190: 
191:         $words = preg_split('((\r\n)|(\r)|(\n))', substr($string, 0, strlen($string) - strlen(PHP_EOL)));
192: 
193:         foreach ($words as $key => $value) {
194:             $oriTrans = preg_split('/(?<!\\\\)' . self::$originalTranslationDivider . '/', $value);
195: 
196:             if (isset($oriTrans[1])) {
197:                 $retArray[iconv($this->_fileEncoding, $this->_encoding, $oriTrans[0])] = iconv($this->_fileEncoding, $this->_encoding, str_replace("\=", "=", $oriTrans[1]));
198:             } else {
199:                 $retArray[end(array_keys($retArray))] .= PHP_EOL . iconv($this->_fileEncoding, $this->_encoding, str_replace("\=", "=", $oriTrans[0]));
200:             }
201:         }
202: 
203:         return $retArray;
204:     }
205: 
206:     /**
207:      * Save the contents of the wordListArray in file.
208:      *
209:      * @param array $wordListArray
210:      * @return boolean true if success else false
211:      */
212:     public function saveTranslationArray($wordListArray) {
213:         $fileName = $this->_modulePath . $this->_directories['lang'] . self::$fileName;
214: 
215:         if (!$this->createModuleDirectory('lang') || !$this->isWritable($fileName, $this->_modulePath . $this->_directories['lang'])) {
216:             return false;
217:         }
218: 
219:         $escapedArray = array();
220:         foreach ($wordListArray as $key => $value) {
221:             $newKey = str_replace("=", "\=", $key);
222:             $newValue = str_replace("=", "\=", $value);
223:             $escapedArray[$newKey] = $newValue;
224:         }
225: 
226:         if (cFileHandler::write($fileName, $this->_serializeArray($escapedArray)) === false) {
227:             return false;
228:         } else {
229:             return true;
230:         }
231:     }
232: 
233:     /**
234:      * Get the translations array.
235:      *
236:      * @return array
237:      */
238:     public function getTranslationArray() {
239:         if (cFileHandler::exists($this->_modulePath . $this->_directories['lang'] . self::$fileName)) {
240:             $array = $this->_unserializeArray(cFileHandler::read($this->_modulePath . $this->_directories['lang'] . self::$fileName));
241:             return $array;
242:         } else {
243:             return array();
244:         }
245:     }
246: 
247: }
248: 
CMS CONTENIDO 4.9.2 API documentation generated by ApiGen 2.8.0