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
    • SIWECOS
    • 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
  • cRights
  • 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
  • Class
  • Tree
  • Deprecated
  • Todo
   1: <?php
   2: 
   3: /**
   4:  * This file contains the module handler class.
   5:  *
   6:  * @todo refactor documentation
   7:  *
   8:  * @package Core
   9:  * @subpackage Backend
  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:  * Class for new modul structure.
  21:  *
  22:  * Saves the Modul-Input in file "input.php" and Modul-Output in file
  23:  * "output.php". All modules of a client are in [frontend]/modules/.
  24:  *
  25:  * @package Core
  26:  * @subpackage Backend
  27:  */
  28: class cModuleHandler {
  29: 
  30:     /**
  31:      * Path to a modul dir.
  32:      *
  33:      * @var string
  34:      */
  35:     private $_modulePath;
  36: 
  37:     /**
  38:      * Path to the modul dir where are all the moduls of a client
  39:      * (frontendpath).
  40:      *
  41:      * @var string
  42:      */
  43:     private $_path;
  44: 
  45:     /**
  46:      * Id of the Modul.
  47:      *
  48:      * @var int
  49:      */
  50:     protected $_idmod = NULL;
  51: 
  52:     /**
  53:      * The name of the modul.
  54:      *
  55:      * @var string
  56:      */
  57:     private $_moduleName = NULL;
  58: 
  59:     /**
  60:      * Description of the modul.
  61:      *
  62:      * @var string
  63:      */
  64:     protected $_description;
  65: 
  66:     /**
  67:      * The type of the modul.
  68:      *
  69:      * @var string
  70:      */
  71:     protected $_type;
  72: 
  73:     /**
  74:      * The alias name of the modul.
  75:      *
  76:      * @var string
  77:      */
  78:     protected $_moduleAlias;
  79: 
  80:     /**
  81:      * The names of the modul directories.
  82:      *
  83:      * @var array
  84:      */
  85:     protected $_directories = array(
  86:         'css' => 'css/',
  87:         'js' => 'js/',
  88:         'template' => 'template/',
  89:         'image' => 'image/',
  90:         'lang' => 'lang/',
  91:         'php' => 'php/'
  92:     );
  93: 
  94:     /**
  95:      * CONTENIDO cfg.
  96:      *
  97:      * @var array
  98:      */
  99:     protected $_cfg = NULL;
 100: 
 101:     /**
 102:      * CONTENIDO cfgClient.
 103:      *
 104:      * @var array
 105:      */
 106:     protected $_cfgClient = NULL;
 107: 
 108:     /**
 109:      * id of the Client.
 110:      *
 111:      * @var int
 112:      */
 113:     protected $_client = '0';
 114: 
 115:     /**
 116:      * The code of the modul input.
 117:      *
 118:      * @var string
 119:      */
 120:     protected $_input = '';
 121: 
 122:     /**
 123:      * The code of the modul output.
 124:      *
 125:      * @var string
 126:      */
 127:     protected $_output = '';
 128: 
 129:     /**
 130:      * Encoding oft the site.
 131:      *
 132:      * @var string
 133:      */
 134:     protected $_encoding = '';
 135: 
 136:     /**
 137:      * Which format of encoding should be files (input/output/translation...)
 138:      *
 139:      * getEffectiveSetting('encoding', 'file_encoding', 'UTF-8')
 140:      *
 141:      * @var string
 142:      */
 143:     protected $_fileEncoding = '';
 144: 
 145:     /**
 146:      * The id of the lang.
 147:      *
 148:      * @var int
 149:      */
 150:     protected $_idlang = -1;
 151: 
 152:     /**
 153:      *
 154:      * @var cDb
 155:      */
 156:     private $_db = NULL;
 157: 
 158:     /**
 159:      *
 160:      * @var array
 161:      */
 162:     protected static $_encodingStore = array();
 163: 
 164:     /**
 165:      * Constructor to create an instance of this class.
 166:      *
 167:      * With this class you can create a new module, rename a module.
 168:      * You can save a Output from modules and Input in a file.
 169:      * The save rules are [Modulname] (is unique) the files input and
 170:      * output will be named [Modulname]_input.php,
 171:      * and [Modulname]_output.php respectivly.
 172:      *
 173:      * @param int $idmod [optional]
 174:      *         the id of the module
 175:      * @throws cException
 176:      *         if the module directory can not be created
 177:      */
 178:     public function __construct($idmod = NULL) {
 179:         global $cfg, $cfgClient, $lang, $client;
 180:         $this->_cfg = $cfg;
 181:         $this->_client = $client;
 182:         $this->_cfgClient = $cfgClient;
 183:         $this->_idlang = $lang;
 184:         $this->_encoding = self::getEncoding();
 185:         $this->_fileEncoding = getEffectiveSetting('encoding', 'file_encoding', 'UTF-8');
 186: 
 187:         $this->_db = cRegistry::getDb();
 188: 
 189:         $this->_idmod = $idmod;
 190: 
 191:         $this->_initByModule($idmod);
 192: 
 193:         if ($this->_makeModuleDirectory() == false) {
 194:             throw new cException('Can not create main module directory.');
 195:         }
 196:     }
 197: 
 198:     /**
 199:      *
 200:      * @param int $overrideLanguageId [optional]
 201:      *
 202:      * @return mixed
 203:      * @throws cDbException
 204:      */
 205:     public static function getEncoding($overrideLanguageId = 0) {
 206:         $lang = cRegistry::getLanguageId();
 207: 
 208:         if ((int) $overrideLanguageId != 0) {
 209:             $lang = $overrideLanguageId;
 210:         }
 211: 
 212:         if ((int) $lang == 0) {
 213:             $clientId = cRegistry::getClientId();
 214: 
 215:             $clientsLangColl = new cApiClientLanguageCollection();
 216:             $clientLanguages = $clientsLangColl->getLanguagesByClient($clientId);
 217:             sort($clientLanguages);
 218: 
 219:             if (isset($clientLanguages[0]) && (int) $clientLanguages[0] != 0) {
 220:                 $lang = $clientLanguages[0];
 221:             }
 222:         }
 223: 
 224:         if (!isset(self::$_encodingStore[$lang])) {
 225:             $cApiLanguage = new cApiLanguage($lang);
 226:             self::$_encodingStore[$lang] = $cApiLanguage->get('encoding');
 227:         }
 228: 
 229:         return self::$_encodingStore[$lang];
 230:     }
 231: 
 232:     /**
 233:      * Exist the modulname in directory.
 234:      *
 235:      * @param string $name
 236:      * @return bool
 237:      */
 238:     public function modulePathExistsInDirectory($name) {
 239:         return is_dir($this->_cfgClient[$this->_client]['module']['path'] . $name . '/');
 240:     }
 241: 
 242:     /**
 243:      * Save a content in the file, use for css/js.
 244:      *
 245:      * @param string $templateName
 246:      * @param string $fileType
 247:      * @param string $fileContent
 248:      * @param string $saveDirectory [optional]
 249:      * @return string|bool
 250:      *                              URL on success or false on failure
 251:      * @throws cInvalidArgumentException
 252:      */
 253:     public function saveContentToFile($templateName, $fileType, $fileContent, $saveDirectory = 'cache') {
 254:         $sSaveDirectory = $this->_cfgClient[$this->_client]['path']['frontend'] . $saveDirectory . '/';
 255:         if (!is_dir($sSaveDirectory)) {
 256:             return false;
 257:         }
 258: 
 259:         $templateName = str_replace(' ', '_', $templateName);
 260:         $templateName = cString::toLowerCase($templateName);
 261:         $fileOperation = cFileHandler::write($sSaveDirectory . $templateName . '.' . $fileType, $fileContent);
 262:         if ($fileOperation === false) {
 263:             return false;
 264:         }
 265:         $url = $this->_cfgClient[$this->_client]['path']['htmlpath'] . $saveDirectory . '/' . $templateName . '.' . $fileType;
 266: 
 267:         // Remove protocol so CSS & JS can be displayed for HTTPS too!
 268:         $url = str_replace('http://', '//', $url);
 269: 
 270:         return $url;
 271:     }
 272: 
 273:     /**
 274:      * Get the cleaned name.
 275:      *
 276:      * @param string $name
 277:      *         mod name
 278:      * @param string $defaultChar [optional]
 279:      *         default character
 280:      * @return string
 281:      */
 282:     public static function getCleanName($name, $defaultChar = '_') {
 283:         // the first character of module/layout name should be [a-zA-Z0-9]|_|-
 284:         $name = cString::cleanURLCharacters($name);
 285:         // get the first charcte
 286:         $firstChar = cString::getPartOfString($name, 0, 1);
 287:         if (!preg_match('/^[a-zA-Z0-9]|_|-$/', $firstChar)) {
 288:             // replace the first character
 289:             $name = $defaultChar . cString::getPartOfString($name, 1);
 290:         }
 291: 
 292:         return $name;
 293:     }
 294: 
 295:     /**
 296:      * Init the vars of the class.
 297:      *
 298:      * @param mixed $db
 299:      */
 300:     public function initWithDatabaseRow($db) {
 301:         if (is_object($db)) {
 302:             $this->_initByModule($db->f('idmod'));
 303:         }
 304:     }
 305: 
 306:     /**
 307:      * Init the vars of the class, make a query to the Db.
 308:      *
 309:      * @param int $idmod [optional]
 310:      *         the id of the modul
 311:      */
 312:     protected function _initByModule($idmod = NULL) {
 313:         if ((int) $idmod == 0) {
 314:             return;
 315:         }
 316: 
 317:         $cApiModule = new cApiModule($idmod);
 318: 
 319:         if (true === $cApiModule->isLoaded()) {
 320:             $this->_idmod = $idmod;
 321:             $this->_client = $cApiModule->get('idclient');
 322:             $this->_description = $cApiModule->get('description');
 323:             $this->_type = $cApiModule->get('type');
 324:             $this->_input = '';
 325:             $this->_output = '';
 326: 
 327:             $this->_moduleAlias = $cApiModule->get('alias');
 328:             $this->_moduleName = $cApiModule->get('name');
 329:             $this->_path = $this->_cfgClient[$this->_client]['module']['path'];
 330:             $this->_modulePath = $this->_path . $this->_moduleAlias . '/';
 331:         }
 332:     }
 333: 
 334:     /**
 335:      * Get the name of module.
 336:      *
 337:      * @return string
 338:      */
 339:     public function getModuleName() {
 340:         return $this->_moduleName;
 341:     }
 342: 
 343:     /**
 344:      * Get the Modul Path also cms path + module + module name.
 345:      *
 346:      * @return string
 347:      */
 348:     public function getModulePath() {
 349:         return $this->_modulePath;
 350:     }
 351: 
 352:     /**
 353:      * Get the template path.
 354:      *
 355:      * If file is set it will return the complete path + file.
 356:      *
 357:      * @param string $file [optional]
 358:      * @return string
 359:      */
 360:     public function getTemplatePath($file = '') {
 361:         return $this->_modulePath . $this->_directories['template'] . $file;
 362:     }
 363: 
 364:     /**
 365:      * Get the css path of the modul.
 366:      *
 367:      * @return string
 368:      */
 369:     public function getCssPath() {
 370:         return $this->_modulePath . $this->_directories['css'];
 371:     }
 372: 
 373:     /**
 374:      * Get the php path of the modul.
 375:      *
 376:      * @return string
 377:      */
 378:     public function getPhpPath() {
 379:         return $this->_modulePath . $this->_directories['php'];
 380:     }
 381: 
 382:     /**
 383:      * Get the js path of the modul.
 384:      *
 385:      * @return string
 386:      */
 387:     public function getJsPath() {
 388:         return $this->_modulePath . $this->_directories['js'];
 389:     }
 390: 
 391:     /**
 392:      * Get the main css file modulenam.css.
 393:      *
 394:      * @return string
 395:      */
 396:     public function getCssFileName() {
 397:         return $this->_moduleAlias . '.css';
 398:     }
 399: 
 400:     /**
 401:      * Returns random characters.
 402:      *
 403:      * @param int $count
 404:      *         amount of characters
 405:      * @return string
 406:      */
 407:     protected function getRandomCharacters($count) {
 408:         $micro1 = microtime();
 409:         $rand1 = rand(0, time());
 410:         $rand2 = rand(0, time());
 411:         return cString::getPartOfString(md5($micro1 . $rand1 . $rand2), 0, $count);
 412:     }
 413: 
 414:     /**
 415:      * Check if exist a file.
 416:      *
 417:      * @param string $type
 418:      *         js | template | css the directory of the file
 419:      * @param string $fileName
 420:      *         file name
 421:      * @return bool
 422:      */
 423:     public function existFile($type, $fileName) {
 424:         return cFileHandler::exists($this->_modulePath . $this->_directories[$type] . $fileName);
 425:     }
 426: 
 427:     /**
 428:      * Delete file.
 429:      *
 430:      * @param string $type
 431:      *         js |template | css directory of the file
 432:      * @param string $fileName
 433:      *         file name
 434:      * @return bool
 435:      */
 436:     public function deleteFile($type, $fileName) {
 437:         if ($this->existFile($type, $fileName)) {
 438:             return unlink($this->_modulePath . $this->_directories[$type] . $fileName);
 439:         } else {
 440:             return false;
 441:         }
 442:     }
 443: 
 444:     /**
 445:      * Create and save new file.
 446:      *
 447:      * @param string $type
 448:      *                         css | js | template directory of the file
 449:      * @param string $fileName [optional]
 450:      *                         file name
 451:      * @param string $content  [optional]
 452:      *                         content of the file
 453:      * @return bool
 454:      *                         true on success or false on failure
 455:      * @throws cInvalidArgumentException
 456:      */
 457:     public function createModuleFile($type, $fileName = NULL, $content = '') {
 458:         // create directory if not exist
 459:         if (!$this->createModuleDirectory($type)) {
 460:             return false;
 461:         }
 462: 
 463:         // if not set use default filename
 464:         if ($fileName == NULL || $fileName == '') {
 465:             $fileName = $this->_moduleAlias;
 466: 
 467:             if ($type == 'template') {
 468:                 $fileName = $fileName . '.html';
 469:             } else {
 470:                 $fileName = $fileName . '.' . $type;
 471:             }
 472:         } else {
 473:             $fileName = cString::replaceDiacritics($fileName);
 474:         }
 475: 
 476:         // create and save file contents
 477:         if ($type == 'css' || $type == 'js' || $type == 'template') {
 478:             if (!$this->existFile($type, $fileName)) {
 479:                 $content = cString::recodeString($content, $this->_encoding, $this->_fileEncoding);
 480:                 if (!$this->isWritable($this->_modulePath . $this->_directories[$type] . $fileName, $this->_modulePath . $this->_directories[$type])) {
 481:                     return false;
 482:                 }
 483: 
 484:                 if (cFileHandler::write($this->_modulePath . $this->_directories[$type] . $fileName, $content) === false) {
 485:                     $notification = new cGuiNotification();
 486:                     $notification->displayNotification('error', i18n("Can't make file: ") . $fileName);
 487:                     return false;
 488:                 }
 489:             } else {
 490:                 $content = cString::recodeString($content, $this->_encoding, $this->_fileEncoding);
 491:                 if (!$this->isWritable($this->_modulePath . $this->_directories[$type] . $fileName, $this->_modulePath . $this->_directories[$type])) {
 492:                     return false;
 493:                 }
 494:                 if (cFileHandler::write($this->_modulePath . $this->_directories[$type] . $fileName, $content) === false) {
 495:                     $notification = new cGuiNotification();
 496:                     $notification->displayNotification('error', i18n("Can't make file: ") . $fileName);
 497:                     return false;
 498:                 }
 499:             }
 500:         } else {
 501:             return false;
 502:         }
 503: 
 504:         return true;
 505:     }
 506: 
 507:     /**
 508:      * Rename a file.
 509:      *
 510:      * @param string $type
 511:      *         css | js | template directory of the file
 512:      * @param string $oldFileName
 513:      *         old name of the file
 514:      * @param string $newFileName
 515:      *         the new name of the file
 516:      * @return bool
 517:      *         true on success or false on failure
 518:      */
 519:     public function renameModuleFile($type, $oldFileName, $newFileName) {
 520: 
 521:         $newFileName = cString::replaceDiacritics($newFileName);
 522: 
 523:         if ($this->existFile($type, $newFileName)) {
 524:             return false;
 525:         }
 526: 
 527:         if (!$this->existFile($type, $oldFileName)) {
 528:             return false;
 529:         }
 530: 
 531:         return rename($this->_modulePath . $this->_directories[$type] . $oldFileName, $this->_modulePath . $this->_directories[$type] . $newFileName);
 532:     }
 533: 
 534:     /**
 535:      * Get the name of the main js file (modulname.js).
 536:      *
 537:      * @return string
 538:      *         the name of the js file
 539:      */
 540:     public function getJsFileName() {
 541:         return $this->_moduleAlias . '.js';
 542:     }
 543: 
 544:     /**
 545:      * Get the content of file, modul js or css or template or php.
 546:      *
 547:      * @param string $directory
 548:      *                         where in module should we look
 549:      * @param string $fileTyp
 550:      *                         css or js
 551:      * @param string $fileName [optional]
 552:      *
 553:      * @return string|bool
 554:      * @throws cInvalidArgumentException
 555:      */
 556:     public function getFilesContent($directory, $fileTyp, $fileName = NULL) {
 557:         if ($fileName == NULL) {
 558:             $fileName = $this->_moduleAlias . '.' . $fileTyp;
 559:         }
 560: 
 561:         if ($this->existFile($directory, $fileName)) {
 562:             $content = cFileHandler::read($this->_modulePath . $this->_directories[$directory] . $fileName);
 563:             $content = iconv($this->_fileEncoding, $this->_encoding . '//IGNORE', $content);
 564:             return $content;
 565:         }
 566: 
 567:         return false;
 568:     }
 569: 
 570:     /**
 571:      * Make main module directory.
 572:      *
 573:      * @return bool
 574:      *         true on success or false on failure
 575:      * @throws cInvalidArgumentException
 576:      */
 577:     protected function _makeModuleDirectory() {
 578:         // Do not display error on login page
 579:         if ((int) $this->_client == 0) {
 580:             return true;
 581:         }
 582: 
 583:         $sMainModuleDirectory = $this->_cfgClient[$this->_client]['module']['path'];
 584: 
 585:         // make
 586:         if (!is_dir($sMainModuleDirectory) && $sMainModuleDirectory != NULL) {
 587:             if (mkdir($sMainModuleDirectory, cDirHandler::getDefaultPermissions(), true) == false) {
 588:                 return false;
 589:             } else {
 590:                 cDirHandler::setDefaultPermissions($sMainModuleDirectory);
 591:             }
 592:         }
 593: 
 594:         return true;
 595:     }
 596: 
 597:     /**
 598:      * Get all files from a module directory.
 599:      *
 600:      * @param string $moduleDirectory
 601:      *         template css or js...
 602:      * @return array
 603:      */
 604:     public function getAllFilesFromDirectory($moduleDirectory) {
 605:         $dir = $this->_modulePath . $this->_directories[$moduleDirectory];
 606:         return cDirHandler::read($dir);
 607:     }
 608: 
 609:     /**
 610:      * Set the new modul name.
 611:      *
 612:      * @param string $name
 613:      */
 614:     public function changeModuleName($name) {
 615:         $this->_moduleAlias = $name;
 616:         $this->_modulePath = $this->_path . $this->_moduleAlias . '/';
 617:     }
 618: 
 619:     /**
 620:      * Removes this module from the filesystem.
 621:      * Also deletes the version files.
 622:      *
 623:      * @return bool
 624:      *         true on success or false on failure
 625:      * @throws cInvalidArgumentException
 626:      */
 627:     public function eraseModule() {
 628:         // Delete modules only if we find info.xml at module path
 629:         if (cFileHandler::exists($this->_modulePath . 'info.xml')) {
 630:             return cDirHandler::recursiveRmdir($this->_modulePath);
 631:         } else {
 632:             return false;
 633:         }
 634:     }
 635: 
 636:     /**
 637:      * Read the input of the file _input.php.
 638:      *
 639:      * @param bool $issource [optional]
 640:      * @return string|bool
 641:      *                       content of module input file or false on failure
 642:      * @throws cInvalidArgumentException
 643:      */
 644:     public function readInput($issource = false) {
 645:         if (cFileHandler::exists($this->_modulePath . $this->_directories['php'] . $this->_moduleAlias . '_input.php') == false) {
 646:             return false;
 647:         }
 648: 
 649:         $content = cFileHandler::read($this->_modulePath . $this->_directories['php'] . $this->_moduleAlias . '_input.php');
 650: 
 651:         if ($issource == true) {
 652:             $content = conHtmlentities($content);
 653:         }
 654: 
 655:         return iconv($this->_fileEncoding, $this->_encoding . '//IGNORE', $content);
 656:     }
 657: 
 658:     /**
 659:      * Read the output of the file _output.php.
 660:      *
 661:      * @param bool $issource [optional]
 662:      * @return bool|string
 663:      *                       content of module output file or false on failure
 664:      * @throws cInvalidArgumentException
 665:      */
 666:     public function readOutput($issource = false) {
 667:         if (cFileHandler::exists($this->_modulePath . $this->_directories['php'] . $this->_moduleAlias . '_output.php') == false) {
 668:             return false;
 669:         }
 670: 
 671:         $content = cFileHandler::read($this->_modulePath . $this->_directories['php'] . $this->_moduleAlias . '_output.php');
 672: 
 673:         if ($issource == true) {
 674:             $content = conHtmlentities($content);
 675:         }
 676: 
 677:         return iconv($this->_fileEncoding, $this->_encoding . '//IGNORE', $content);
 678:     }
 679: 
 680:     /**
 681:      * Make a directory template/css/image/js/php if not exist.
 682:      *
 683:      * @param string $type
 684:      *
 685:      * @return bool
 686:      *         true on success or false on failure
 687:      * @throws cInvalidArgumentException
 688:      */
 689:     protected function createModuleDirectory($type) {
 690:         if (array_key_exists($type, $this->_directories)) {
 691:             if (!is_dir($this->_modulePath . $this->_directories[$type])) {
 692:                 if (cDirHandler::create($this->_modulePath . $this->_directories[$type]) == false) {
 693:                     return false;
 694:                 } else
 695:                     cDirHandler::setDefaultPermissions($this->_modulePath . $this->_directories[$type]);
 696:             } else {
 697:                 return true;
 698:             }
 699:         }
 700: 
 701:         return true;
 702:     }
 703: 
 704:     /**
 705:      * Can write/create a file.
 706:      *
 707:      * @param string $fileName
 708:      *         file name
 709:      * @param string $directory
 710:      *         directory where is the file
 711:      * @return bool
 712:      *         true on success or false on failure
 713:      */
 714:     public function isWritable($fileName, $directory) {
 715:         if (cFileHandler::exists($fileName)) {
 716:             if (!is_writable($fileName)) {
 717:                 return false;
 718:             }
 719:         } else {
 720:             if (!is_writable($directory)) {
 721:                 return false;
 722:             }
 723:         }
 724:         return true;
 725:     }
 726: 
 727:     /**
 728:      * Check write permissions for this module.
 729:      *
 730:      * @param string $type
 731:      *         php oder template
 732:      * @return bool
 733:      */
 734:     public function moduleWriteable($type) {
 735:         // check if type directory inside module folder exists and has write permissions
 736:         if (true === cFileHandler::exists($this->_modulePath . $this->_directories[$type])) {
 737:             return cFileHandler::writeable($this->_modulePath . $this->_directories[$type]);
 738:         }
 739: 
 740:         // check if module folder exists and has write permissions
 741:         if (true === cFileHandler::exists($this->_modulePath)) {
 742:             return cFileHandler::writeable($this->_modulePath);
 743:         }
 744: 
 745:         return false;
 746:     }
 747: 
 748:     /**
 749:      * Save a string into the file (_output.php).
 750:      *
 751:      * @param string $output [optional]
 752:      * @return bool
 753:      *                       true on success or false on failure
 754:      * @throws cInvalidArgumentException
 755:      */
 756:     public function saveOutput($output = NULL) {
 757:         $fileName = $this->_modulePath . $this->_directories['php'] . $this->_moduleAlias . '_output.php';
 758: 
 759:         if (!$this->createModuleDirectory('php') || !$this->isWritable($fileName, $this->_modulePath . $this->_directories['php'])) {
 760:             return false;
 761:         }
 762: 
 763:         if ($output == NULL) {
 764:             $output = $this->_output;
 765:         }
 766: 
 767:         $output = cString::recodeString($output, $this->_encoding, $this->_fileEncoding);
 768: 
 769:         $fileOperation = cFileHandler::write($fileName, $output);
 770: 
 771:         if ($fileOperation === false) {
 772:             return false; // return false if file_put_contents dont work
 773:         } else {
 774:             cFileHandler::setDefaultPermissions($fileName);
 775:             return true; // return true if file_put_contents working
 776:         }
 777:     }
 778: 
 779:     /**
 780:      * Save a string into the file (_input.php).
 781:      *
 782:      * @param string $input [optional]
 783:      * @return bool
 784:      *                      true on success or false on failure
 785:      * @throws cInvalidArgumentException
 786:      */
 787:     public function saveInput($input = NULL) {
 788:         $fileName = $this->_modulePath . $this->_directories['php'] . $this->_moduleAlias . '_input.php';
 789: 
 790:         if (!$this->createModuleDirectory('php') || !$this->isWritable($fileName, $this->_modulePath . $this->_directories['php'])) {
 791:             return false;
 792:         }
 793: 
 794:         if ($input == NULL) {
 795:             $input = $this->_input;
 796:         }
 797: 
 798:         $input = cString::recodeString($input, $this->_encoding, $this->_fileEncoding);
 799: 
 800:         $fileOperation = cFileHandler::write($fileName, $input);
 801: 
 802:         if ($fileOperation === false) {
 803:             return false; // return false if file_put_contents dont work
 804:         } else {
 805:             cFileHandler::setDefaultPermissions($fileName);
 806:             return true; // return true if file_put_contents working
 807:         }
 808:     }
 809: 
 810:     /**
 811:      * This method save a xml file with modul information.
 812:      * If the params not set, get the value from this.
 813:      *
 814:      * @param string $moduleName  [optional]
 815:      *                            name of the modul
 816:      * @param string $description [optional]
 817:      *                            description of the modul
 818:      * @param string $type        [optional]
 819:      *                            type of the modul
 820:      * @param string $alias       [optional]
 821:      * @return true
 822:      *                            if success else false
 823:      * @throws cException
 824:      */
 825:     public function saveInfoXML($moduleName = NULL, $description = NULL, $type = NULL, $alias = NULL) {
 826:         if ($moduleName === NULL) {
 827:             $moduleName = $this->_moduleName;
 828:         }
 829: 
 830:         if ($description === NULL) {
 831:             $description = $this->_description;
 832:         }
 833: 
 834:         if ($type === NULL) {
 835:             $type = $this->_type;
 836:         }
 837: 
 838:         if ($alias === NULL) {
 839:             $alias = $this->_moduleAlias;
 840:         }
 841: 
 842:         $oWriter = new cXmlWriter();
 843:         $oRootElement = $oWriter->addElement('module', '', NULL);
 844: 
 845:         $oWriter->addElement('name', conHtmlSpecialChars($moduleName), $oRootElement);
 846:         $oWriter->addElement('description', conHtmlSpecialChars($description), $oRootElement);
 847:         $oWriter->addElement('type', conHtmlSpecialChars($type), $oRootElement);
 848:         $oWriter->addElement('alias', conHtmlSpecialChars($alias), $oRootElement);
 849: 
 850:         return $oWriter->saveToFile($this->_modulePath, 'info.xml');
 851:     }
 852: 
 853:     /**
 854:      * Create a new module in the module dir.
 855:      *
 856:      * The module name will be [ModuleName] example Contact_Form or
 857:      * GoogleMaps2.
 858:      *
 859:      * @param string $input  [optional]
 860:      * @param string $output [optional]
 861:      * @return bool
 862:      *                       if module exist or mkdir and saveInput and saveOutput success
 863:      *                       return true. Else if the mkdir or saveInput or saveOutput not
 864:      *                       success return false.
 865:      * @throws cException
 866:      * @throws cInvalidArgumentException
 867:      */
 868:     public function createModule($input = '', $output = '') {
 869:         if ($input != '') {
 870:             $this->_input = $input;
 871:         }
 872: 
 873:         if ($output != '') {
 874:             $this->_output = $output;
 875:         }
 876: 
 877:         if ($this->modulePathExists()) {
 878:             return true;
 879:         }
 880: 
 881:         if (mkdir($this->_modulePath) == false) {
 882:             return false;
 883:         } else {
 884:             cDirHandler::setDefaultPermissions($this->_modulePath);
 885:         }
 886: 
 887:         // create other directories
 888:         foreach ($this->_directories as $directory) {
 889:             if (!is_dir($this->_modulePath . $directory)) {
 890:                 if (mkdir($this->_modulePath . $directory) == false) {
 891:                     return false;
 892:                 } else {
 893:                     cDirHandler::setDefaultPermissions($this->_modulePath . $directory);
 894:                 }
 895:             }
 896:         }
 897: 
 898:         // could not save the info xml
 899:         if ($this->saveInfoXML() == false) {
 900:             return false;
 901:         }
 902: 
 903:         // Save empty strings into the modul files, if someone trying to
 904:         // read contents before save into the files
 905:         $retInput = $this->saveInput();
 906:         $retOutput = $this->saveOutput();
 907: 
 908:         if ($retInput == false || $retOutput == false) {
 909:             return false;
 910:         }
 911: 
 912:         return true;
 913:     }
 914: 
 915:     /**
 916:      * Rename a modul and the input and output files.
 917:      *
 918:      * @param string $old
 919:      *         old name of the modul
 920:      * @param string $new
 921:      *         new name of the modul
 922:      * @return bool
 923:      *         true on success or false on failure
 924:      */
 925:     public function renameModul($old, $new) {
 926:         // try to rename the dir
 927:         if (rename($this->_path . $old, $this->_path . $new) == false) {
 928:             return false;
 929:         } else {
 930:             $retInput = true;
 931:             $retOutput = true;
 932: 
 933:             // if file input exist rename it
 934:             if (cFileHandler::exists($this->_path . $new . '/' . $this->_directories['php'] . $old . '_input.php'))
 935:                 $retInput = rename($this->_path . $new . '/' . $this->_directories['php'] . $old . '_input.php', $this->_path . $new . '/' . $this->_directories['php'] . $new . '_input.php');
 936: 
 937:             // if file output exist rename it
 938:             if (cFileHandler::exists($this->_path . $new . '/' . $this->_directories['php'] . $old . '_output.php'))
 939:                 $retOutput = rename($this->_path . $new . '/' . $this->_directories['php'] . $old . '_output.php', $this->_path . $new . '/' . $this->_directories['php'] . $new . '_output.php');
 940: 
 941:             // rename the css file
 942:             if (cFileHandler::exists($this->_path . $new . '/' . $this->_directories['css'] . $old . '.css'))
 943:                 rename($this->_path . $new . '/' . $this->_directories['css'] . $old . '.css', $this->_path . $new . '/' . $this->_directories['css'] . $new . '.css');
 944: 
 945:             // rename the javascript file
 946:             if (cFileHandler::exists($this->_path . $new . '/' . $this->_directories['js'] . $old . '.js'))
 947:                 rename($this->_path . $new . '/' . $this->_directories['js'] . $old . '.js', $this->_path . $new . '/' . $this->_directories['js'] . $new . '.js');
 948: 
 949:             // rename the template file
 950:             if (cFileHandler::exists($this->_path . $new . '/' . $this->_directories['template'] . $old . '.html'))
 951:                 rename($this->_path . $new . '/' . $this->_directories['template'] . $old . '.html', $this->_path . $new . '/' . $this->_directories['template'] . $new . '.html');
 952: 
 953:             if ($retInput == true && $retOutput == true) {
 954:                 return true;
 955:             } else {
 956:                 return false;
 957:             }
 958:         }
 959:     }
 960: 
 961:     /**
 962:      * Show if the Modul with the modul name exist in modul dir.
 963:      *
 964:      * @return bool
 965:      *         if the modul exist return true, else false
 966:      */
 967:     public function modulePathExists() {
 968:         return is_dir($this->_modulePath);
 969:     }
 970: 
 971:     /**
 972:      * Test input code.
 973:      *
 974:      * @return array
 975:      *         bool state, string errorMessage
 976:      * @throws cDbException
 977:      * @throws cInvalidArgumentException
 978:      */
 979:     public function testInput() {
 980: 
 981:         return $this->_testCode('input');
 982:     }
 983: 
 984:     /**
 985:      * Test output code.
 986:      *
 987:      * @return array
 988:      *         bool state, string errorMessage
 989:      * @throws cDbException
 990:      * @throws cInvalidArgumentException
 991:      */
 992:     public function testOutput() {
 993: 
 994:         return $this->_testCode('output');
 995:     }
 996: 
 997:     /**
 998:      * Test module code.
 999:      *
1000:      * @param string $inputType
1001:      *         code field type, 'input' or 'output'
1002:      * @return array
1003:      *         bool state, string errorMessage
1004:      * @throws cDbException
1005:      * @throws cInvalidArgumentException
1006:      */
1007:     protected function _testCode($inputType) {
1008: 
1009:         $result = array(
1010:             'state' => false,
1011:             'errorMessage' => 'Module path not exist'
1012:         );
1013: 
1014:         if (!$this->modulePathExists()) return $result;
1015: 
1016:         $module  = new cApiModule($this->_idmod);
1017:         $isError = 'none';
1018: 
1019:         //Set code as error before checking, if fatal exist
1020:         switch ($module->get("error")) {
1021:             case 'none';
1022:                 $toCheck = $inputType;
1023:                 break;
1024:             case 'input';
1025:                 if ($inputType == 'output') $toCheck = 'both';
1026:                 break;
1027:             case 'output';
1028:                 if ($inputType == 'input') $toCheck = 'both';
1029:                 break;
1030:             case 'both';
1031:                 break;
1032:         }
1033:         if ($toCheck !== $module->get("error")) {
1034:             $module->set("error", $toCheck);
1035: 
1036:             // do not rewrite cache on validation
1037:             // it is rewritten when saving module
1038:             $module->store(true);
1039:         }
1040: 
1041:         //check code
1042:         switch($inputType) {
1043:             case 'input':
1044:                 $code       = $this->readInput();
1045:                 $result = $this->_verifyCode($code, $this->_idmod . "i");
1046:                 if ($result['state'] !== true) $isError = 'input';
1047:                 break;
1048:             case 'output':
1049:                 $code       = $this->readOutput();
1050:                 $result = $this->_verifyCode($code, $this->_idmod . "o", true);
1051:                 if ($result['state'] !== true) $isError = 'output';
1052:                 break;
1053:         }
1054: 
1055:         //update error value for input and output
1056:         switch ($module->get("error")) {
1057:             case 'none';
1058:                 break;
1059:             case 'input';
1060:                 if ($isError == 'none' && $inputType == 'output') $isError = 'input';
1061:                 if ($isError == 'output') $isError = 'both';
1062:                 break;
1063:             case 'output';
1064:                 if ($isError == 'none' && $inputType == 'input') $isError = 'output';
1065:                 if ($isError == 'input') $isError = 'both';
1066:                 break;
1067:             case 'both';
1068:                 if ($isError == 'none' && $inputType == 'input') $isError = 'output';
1069:                 if ($isError == 'none' && $inputType == 'output') $isError = 'input';
1070:                 break;
1071:         }
1072: 
1073:         //Store error information in the database (to avoid re-eval for module
1074:         //overview/menu)
1075:         if ($isError !== $module->get("error")) {
1076:             $module->set("error", $isError);
1077: 
1078:             // do not rewrite cache on validation
1079:             // it is rewritten when saving module
1080:             $module->store(true);
1081:         }
1082: 
1083:         return $result;
1084:     }
1085: 
1086:     /**
1087:      * Check module php code.
1088:      *
1089:      * @param string $code
1090:      *                       Code to evaluate
1091:      * @param string $id
1092:      *                       Unique ID for the test function
1093:      * @param bool   $output [optional]
1094:      *                       true if start in php mode, otherwise false
1095:      * @return array
1096:      *                       bool state, string errorMessage
1097:      * @throws cDbException
1098:      */
1099:     protected function _verifyCode($code, $id, $output = false) {
1100:         $isError = false;
1101:         $result = array(
1102:             'state' => false,
1103:             'errorMessage' => NULL
1104:         );
1105: 
1106:         // Put a $ in front of all CMS variables to prevent PHP error messages
1107:         $sql = 'SELECT type FROM ' . $this->_cfg['tab']['type'];
1108:         $this->_db->query($sql);
1109:         while ($this->_db->nextRecord()) {
1110:             $code = str_replace($this->_db->f('type') . '[', '$' . $this->_db->f('type') . '[', $code);
1111:         }
1112: 
1113:         $code = preg_replace(',\[(\d+)?CMS_VALUE\[(\d+)\](\d+)?\],i', '[\1\2\3]', $code);
1114:         $code = str_replace('CMS_VALUE', '$CMS_VALUE', $code);
1115:         $code = str_replace('CMS_VAR', '$CMS_VAR', $code);
1116: 
1117:         // If the module is an output module, escape PHP since all output modules
1118:         // enter php mode
1119:         if ($output === true) {
1120:             $code = "?>\n" . $code . "\n<?php";
1121:         }
1122: 
1123:         // Looks ugly: Paste a function declarator in front of the code
1124:         $code = 'function foo' . $id . ' () {' . $code;
1125:         $code .= "\n}\n";
1126: 
1127:         $html_errors = ini_get('html_errors');
1128: 
1129:         // To parse the error message, we prepend and append a phperror tag in front
1130:         // of the output
1131:         $sErs = ini_get('error_prepend_string'); // Save current setting (see below)
1132:         $sEas = ini_get('error_append_string'); // Save current setting (see below)
1133:         @ini_set('error_prepend_string', '<phperror>');
1134:         @ini_set('error_append_string', '</phperror>');
1135: 
1136:         // Turn off output buffering and error reporting, eval the code
1137:         ob_start();
1138:         $display_errors = ini_get('display_errors');
1139:         @ini_set('html_errors', false);
1140:         @ini_set('display_errors', true);
1141:         $output = eval($code);
1142:         @ini_set('display_errors', $display_errors);
1143: 
1144:         // Get the buffer contents and turn it on again
1145:         $output = ob_get_contents();
1146:         ob_end_clean();
1147: 
1148:         // Restore html_errors
1149:         @ini_set('html_errors', $html_errors);
1150: 
1151:         // Remove the prepend and append settings
1152:         @ini_set('error_prepend_string', $sErs); // Restoring settings (see above)
1153:         @ini_set('error_append_string', $sEas); // Restoring settings (see above)
1154: 
1155:         // Strip out the error message
1156:         if ($isError === false) {
1157:             $isError = cString::findFirstPos($output, '<phperror>');
1158:         }
1159: 
1160:         // More stripping: Users shouldnt see where the file is located,
1161:         // but they should see the error line
1162:         if ($isError !== false) {
1163:             if (isset($modErrorMessage) === false) {
1164:                 $pattern         = '/(<phperror>|<\/phperror>|<b>|<\/b>|<br>|<br \/>)/im';
1165:                 $modErrorMessage = trim(preg_replace($pattern, '', $output));
1166:                 $errorPart1      = cString::getPartOfString($modErrorMessage, 0, cString::findFirstPos($modErrorMessage, ' in '));
1167:                 $errorPart2      = cString::getPartOfString($modErrorMessage, cString::findFirstPos($modErrorMessage, ' on line '));
1168:                 $modErrorMessage = $errorPart1 . $errorPart2;
1169:             }
1170:             $result['errorMessage'] = sprintf(i18n("Error in module. Error location: %s"), $modErrorMessage);
1171: 
1172:         }
1173: 
1174:         // Check if there are any php short tags in code, and display error
1175:         $bHasShortTags = false;
1176:         if (preg_match('/<\?\s+/', $code)) {
1177:             $bHasShortTags = true;
1178:             $result['errorMessage'] = i18n('Please do not use short open tags. (Use <?php instead of <?).');
1179:         }
1180: 
1181:         // Now, check if the magic value is 941. If not, the function didn't compile
1182:         if ($bHasShortTags || $isError !== false) {
1183:             $result['state'] = false;
1184:         } else {
1185:             $result['state'] = true;
1186:         }
1187: 
1188:         return $result;
1189: 
1190:     }
1191: }
1192: 
CMS CONTENIDO 4.10.1 API documentation generated by ApiGen 2.8.0