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