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
  • SimpleXMLExtended
  • TreeItem
  • UploadList
  • UploadSearchResultList

Functions

  • _getCurrentTypes
  • _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
  • 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
  • endsWith
  • 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
  • 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
  • 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 template handler 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: cInclude('external', 'codemirror/class.codemirror.php');
 20: cInclude('includes', 'functions.file.php');
 21: 
 22: /**
 23:  * Class handels the view, creation, edit, delete of modul templates.
 24:  *
 25:  * @package Core
 26:  * @subpackage Backend
 27:  */
 28: class cModuleTemplateHandler extends cModuleHandler {
 29: 
 30:     // Form fields
 31:     private $_code;
 32: 
 33:     private $_file;
 34: 
 35:     private $_tmpFile;
 36: 
 37:     private $_area;
 38: 
 39:     private $_frame;
 40: 
 41:     private $_status;
 42: 
 43:     private $_action;
 44: 
 45:     private $_new;
 46: 
 47:     private $_delete;
 48: 
 49:     private $_selectedFile;
 50: 
 51:     private $_reloadScript;
 52: 
 53:     private $_page = NULL;
 54: 
 55:     private $_notification = NULL;
 56: 
 57:     /**
 58:      * The file end of template files.
 59:      *
 60:      * @var string
 61:      */
 62:     private $_templateFileEnding = 'html';
 63: 
 64:     /**
 65:      * The name of the new file.
 66:      *
 67:      * @var string
 68:      */
 69:     private $_newFileName = 'newfilename';
 70: 
 71:     /**
 72:      * Action name for create htmltpl
 73:      *
 74:      * @var string
 75:      */
 76:     private $_actionCreate = 'htmltpl_create';
 77: 
 78:     /**
 79:      * Action name for edit htmltpl
 80:      *
 81:      * @var string
 82:      */
 83:     private $_actionEdit = 'htmltpl_edit';
 84: 
 85:     /**
 86:      * Action name for delete htmltpl_edit
 87:      *
 88:      * @var string
 89:      */
 90:     private $_actionDelete = 'htmltpl_delete';
 91: 
 92:     /**
 93:      * In template we test if we have premission for htmltpl.
 94:      *
 95:      * @var string
 96:      */
 97:     private $_testArea = 'htmltpl';
 98: 
 99:     public function __construct($idmod, $page) {
100:         parent::__construct($idmod);
101:         $this->_page = $page;
102:         $this->_notification = new cGuiNotification();
103:     }
104: 
105:     /**
106:      * Set the new delete from Form.
107:      * This are set if user had push the delete or new button.
108:      *
109:      * @param string $new
110:      * @param string $delete
111:      */
112:     public function setNewDelete($new, $delete) {
113:         $this->_new = $new;
114:         $this->_delete = $delete;
115:     }
116: 
117:     /**
118:      * Set the code from Form!
119:      *
120:      * @param string $code
121:      */
122:     public function setCode($code) {
123:         $this->_code = stripslashes($code);
124:     }
125: 
126:     /**
127:      * Set the selected file from Form.
128:      *
129:      * @param string $selectedFile
130:      */
131:     public function setSelectedFile($selectedFile) {
132:         $this->_selectedFile = $selectedFile;
133:     }
134: 
135:     /**
136:      * Set the file and tmpFile from Form.
137:      * (get it with $_Request...)
138:      *
139:      * @param string $file
140:      * @param string $tmpFile
141:      */
142:     public function setFiles($file, $tmpFile) {
143:         $this->_file = $file;
144:         $this->_tmpFile = $tmpFile;
145:     }
146: 
147:     /**
148:      * Set the status it can be send or empty ''
149:      *
150:      * @param string $status
151:      */
152:     public function setStatus($status) {
153:         $this->_status = $status;
154:     }
155: 
156:     /**
157:      * Set $frame and idmod and are.
158:      *
159:      * @param int $frame
160:      * @param int $idmod
161:      * @param int $area
162:      */
163:     public function setFrameIdmodArea($frame, $idmod, $area) {
164:         $this->_frame = $frame;
165:         $this->_idmod = $idmod;
166:         $this->_area = $area;
167:     }
168: 
169:     /**
170:      * We have two actions wich could send from form.
171:      *
172:      * @param string $action
173:      */
174:     public function setAction($action) {
175:         $this->_action = $action;
176:     }
177: 
178:     /**
179:      * Checks write permissions for module template
180:      *
181:      * @return $this warning notification
182:      * @return boolean true
183:      */
184:     public function checkWritePermissions() {
185:         if ($this->moduleWriteable('template') == false && cFileHandler::exists($this->_modulePath . $this->_directories['template'])) {
186:             return $this->_notification->displayNotification(cGuiNotification::LEVEL_WARNING, i18n("You have no write permissions for this module"));
187:         } else {
188:             return true;
189:         }
190:     }
191: 
192:     /**
193:      * The method decide what action is send from
194:      * user (form).
195:      *
196:      * @throws cException if one of the filenames is not set
197:      * @return string [new, delete,empty,save,rename, default]
198:      */
199:     private function _getAction() {
200:         global $newModTpl, $deleteModTpl;
201: 
202:         if (isset($this->_status)) {
203: 
204:             if (isset($newModTpl)) {
205:                 return 'new';
206:             }
207: 
208:             if (isset($deleteModTpl)) {
209:                 return 'delete';
210:             }
211: 
212:             if (isset($this->_file) && isset($this->_tmpFile)) {
213:                 if ($this->_file == $this->_tmpFile) {
214:                     // file ist empty also no file in template
215:                     // directory
216:                     if (empty($this->_file)) {
217:                         return 'empty';
218:                     } else {
219:                         return 'save';
220:                     }
221:                 }
222: 
223:                 if ($this->_file != $this->_tmpFile) {
224:                     return 'rename';
225:                 }
226:             } else {
227:                 // one of files (file or tmp_file) is not set
228:                 throw new cException(i18n('Field of the file name is empty!'));
229:             }
230:         } else {
231:             return 'default';
232:         }
233:     }
234: 
235:     /**
236:      * Has the selected file changed.
237:      *
238:      * @return boolean is the filename changed
239:      */
240:     private function _hasSelectedFileChanged() {
241:         if ($this->_file != $this->_selectedFile) {
242:             return true;
243:         } else {
244:             return false;
245:         }
246:     }
247: 
248:     /**
249:      * Save the code in the file
250:      */
251:     private function _save() {
252:         // save the contents of file
253:         $ret = $this->createModuleFile('template', $this->_file, $this->_code);
254:         // show message
255:         if ($ret) {
256:             $this->_notification->displayNotification(cGuiNotification::LEVEL_INFO, i18n('Saved changes successfully!'));
257:         }
258:         // if user selected other file display it
259:         if ($this->_hasSelectedFileChanged()) {
260:             $this->_file = $this->_selectedFile;
261:             $this->_tmpFile = $this->_selectedFile;
262:         }
263:     }
264: 
265:     /**
266:      * rename a file in template directory
267:      *
268:      * @throws cException if rename was not successfull
269:      */
270:     private function _rename() {
271:         if ($this->renameModuleFile('template', $this->_tmpFile, $this->_file) == false) {
272:             throw new cException(i18n('Rename of the file failed!'));
273:         } else {
274:             $this->createModuleFile('template', $this->_file, $this->_code);
275:             $this->_notification->displayNotification(cGuiNotification::LEVEL_INFO, i18n('Renamed the template file successfully!'));
276:             $this->_tmpFile = $this->_file;
277:         }
278:     }
279: 
280:     /**
281:      * Make new file
282:      */
283:     private function _new() {
284:         $fileName = '';
285:         if ($this->existFile('template', $this->_newFileName . '.' . $this->_templateFileEnding)) {
286:             $fileName = $this->_newFileName . $this->getRandomCharacters(5) . '.' . $this->_templateFileEnding;
287:             $this->createModuleFile('template', $fileName, '');
288:             $this->_notification->displayNotification(cGuiNotification::LEVEL_INFO, i18n('Created a new template file successfully!'));
289:         } else {
290:             $this->createModuleFile('template', $this->_newFileName . '.' . $this->_templateFileEnding, '');
291:             $this->_notification->displayNotification(cGuiNotification::LEVEL_INFO, i18n('Created a new template file successfully!'));
292:             $fileName = $this->_newFileName . '.' . $this->_templateFileEnding;
293:         }
294:         // set to new fileName
295:         $this->_file = $fileName;
296:         $this->_tmpFile = $fileName;
297:     }
298: 
299:     /**
300:      * Delete a file
301:      */
302:     private function _delete() {
303:         $ret = $this->deleteFile('template', $this->_tmpFile);
304:         if ($ret == true) {
305:             $this->_notification->displayNotification(cGuiNotification::LEVEL_INFO, i18n('Deleted the template file successfully!'));
306:         }
307:         $files = $this->getAllFilesFromDirectory('template');
308: 
309:         if (is_array($files)) {
310:             if (!array_key_exists('0', $files)) {
311:                 $this->_file = '';
312:                 $this->_tmpFile = '';
313:             } else {
314:                 $this->_file = $files[0];
315:                 $this->_tmpFile = $files[0];
316:             }
317:         }
318:     }
319: 
320:     /**
321:      * Default case
322:      */
323:     public function _default() {
324:         $files = $this->getAllFilesFromDirectory('template');
325: 
326:         // one or more templates files are in template direcotry
327:         if (count($files) > 0) {
328:             $this->_tmpFile = $files[0];
329:             $this->_file = $files[0];
330:         } else {
331:             // template directory is empty
332:             $this->_file = '';
333:             $this->_tmpFile = '';
334:         }
335:     }
336: 
337:     /**
338:      * Have the user premissions for the actions.
339:      *
340:      * @param cPermission $perm
341:      * @param cGuiNotification $notification
342:      * @param string $action
343:      *
344:      * @return int if user dont have permission return -1
345:      */
346:     private function _havePremission($perm, $notification, $action) {
347:         switch ($action) {
348:             case 'new':
349:                 if (!$perm->have_perm_area_action($this->_testArea, $this->_actionCreate)) {
350:                     $notification->displayNotification('error', i18n('Permission denied'));
351:                     return -1;
352:                 }
353:                 break;
354:             case 'save':
355:             case 'rename':
356:                 if (!$perm->have_perm_area_action($this->_testArea, $this->_actionEdit)) {
357:                     $notification->displayNotification('error', i18n('Permission denied'));
358:                     return -1;
359:                 }
360:                 break;
361:             case 'delete':
362:                 if (!$perm->have_perm_area_action($this->_testArea, $this->_actionDelete)) {
363:                     $notification->displayNotification('error', i18n('Permission denied'));
364:                     return -1;
365:                 }
366:                 break;
367:             default:
368:                 return true;
369:                 break;
370:         }
371:     }
372: 
373:     /**
374:      * This method test the code if the client setting htmlvalidator
375:      * is not set to false.
376:      * @param {cGuiNotification} $notification
377:      */
378:     private function _validateHTML($notification) {
379:         // Try to validate html
380:         if (getEffectiveSetting('layout', 'htmlvalidator', 'true') == 'true' && $this->_code !== '') {
381:             $v = new cHTMLValidator();
382:             $v->validate($this->_code);
383:             $msg = '';
384: 
385:             foreach ($v->missingNodes as $value) {
386:                 $idQualifier = '';
387: 
388:                 $attr = array();
389: 
390:                 if ($value['name'] != '') {
391:                     $attr['name'] = "name '" . $value['name'] . "'";
392:                 }
393: 
394:                 if ($value['id'] != '') {
395:                     $attr['id'] = "id '" . $value['id'] . "'";
396:                 }
397: 
398:                 $idQualifier = implode(', ', $attr);
399: 
400:                 if ($idQualifier != '') {
401:                     $idQualifier = "($idQualifier)";
402:                 }
403:                 $msg .= sprintf(i18n("Tag '%s' %s has no end tag (start tag is on line %s char %s)"), $value['tag'], $idQualifier, $value['line'], $value['char']) . '<br>';
404:             }
405: 
406:             if ($msg != '') {
407:                 $notification->displayNotification('warning', $msg) . '<br>';
408:             }
409:         }
410:     }
411: 
412:     private function _makeFormular($belang, $readOnly) {
413:         $fileForm = new cGuiTableForm("file_editor");
414:         $fileForm->addHeader(i18n('Choose file'));
415:         $fileForm->setTableid('choose_mod_template_file');
416:         $fileForm->setVar('area', $this->_area);
417:         $fileForm->setVar('action', $this->_action);
418:         $fileForm->setVar('frame', $this->_frame);
419:         $fileForm->setVar('status', 'send');
420:         $fileForm->setVar('tmp_file', $this->_tmpFile);
421:         $fileForm->setVar('idmod', $this->_idmod);
422:         $fileForm->setVar('file', $this->_file);
423: 
424:         $form = new cGuiTableForm('file_editor');
425:         $form->setTableid('mod_template');
426:         $form->addHeader(i18n('Edit file'));
427:         $form->setVar('area', $this->_area);
428:         $form->setVar('action', $this->_action);
429:         $form->setVar('frame', $this->_frame);
430:         $form->setVar('status', 'send');
431:         $form->setVar('tmp_file', $this->_tmpFile);
432:         $form->setVar('idmod', $this->_idmod);
433:         $form->setVar('file', $this->_file);
434:         $form->setVar('selectedFile', $this->_file);
435: 
436:         $selectFile = new cHTMLSelectElement('selectedFile');
437:         $selectFile->setClass("fileChooser");
438:         // array with all files in template directory
439:         $filesArray = $this->getAllFilesFromDirectory('template');
440: 
441:         // make options fields
442:         foreach ($filesArray as $key => $file) {
443: 
444:             // ignore dirs
445:             if (is_dir($file)) {
446:                 continue;
447:             }
448: 
449:             $optionField = new cHTMLOptionElement($file, $file);
450: 
451:             // select the current file
452:             if ($file == $this->_file) {
453:                 $optionField->setAttribute('selected', 'selected');
454:             }
455: 
456:             $selectFile->addOptionElement($key, $optionField);
457:         }
458: 
459:         $aDelete = new cHTMLLink('main.php');
460:         $aDelete->setId("deleteLink");
461:         $aDelete->setContent(i18n("Delete HTML-template"));
462:         $aDelete->setClass('deletefunction');
463:         $aDelete->setCustom("deleteModTpl", "1");
464:         $aDelete->setCustom('area', $this->_area);
465:         $aDelete->setCustom('action', $this->_action);
466:         $aDelete->setCustom('frame', $this->_frame);
467:         $aDelete->setCustom('status', 'send');
468:         $aDelete->setCustom('idmod', $this->_idmod);
469:         $aDelete->setCustom('file', $this->_file);
470:         $aDelete->setCustom('tmp_file', $this->_tmpFile);
471: 
472:         $aAdd = new cHTMLLink('main.php');
473:         $aAdd->setContent(i18n('New HTML-template'));
474:         $aAdd->setClass('addfunction');
475:         $aAdd->setCustom("newModTpl", "1");
476:         $aAdd->setCustom('area', $this->_area);
477:         $aAdd->setCustom('action', $this->_action);
478:         $aAdd->setCustom('frame', $this->_frame);
479:         $aAdd->setCustom('status', 'send');
480:         $aAdd->setCustom('tmp_file', $this->_tmpFile);
481:         $aAdd->setCustom('idmod', $this->_idmod);
482:         $aAdd->setCustom('file', $this->_file);
483: 
484:         // $oName = new cHTMLLabel($sFilename, '');
485:         $oName = new cHTMLTextbox('file', $this->_file, 60);
486: 
487:         $oCode = new cHTMLTextarea('code', conHtmlSpecialChars($this->_code), 100, 35, 'code');
488: 
489:         $oCode->setStyle('font-family: monospace;width: 100%;');
490: 
491:         $oCode->updateAttributes(array(
492:             'wrap' => getEffectiveSetting('html_editor', 'wrap', 'off')
493:         ));
494: 
495:         $fileForm->add(i18n('Action'), $aAdd->toHTML());
496:         // show only if file exists
497:         if ($this->_file) {
498:             $fileForm->add(i18n('Action'), $aDelete->toHTML());
499:             $fileForm->add(i18n('File'), $selectFile);
500:         }
501: 
502:         if($readOnly) {
503:             $oName->setDisabled('disabled');
504:         }
505: 
506:         // add fields only if template file exists
507:         if ($this->_file) {
508:             $form->add(i18n('Name'), $oName);
509:             $form->add(i18n('Code'), $oCode);
510:         }
511:         $this->_page->setContent(array(
512:             $fileForm
513:         ));
514:         if ($this->_file) {
515:             $this->_page->appendContent($form);
516:         }
517: 
518:         $oCodeMirror = new CodeMirror('code', 'html', substr(strtolower($belang), 0, 2), true, $this->_cfg);
519:         if($readOnly) {
520:             $oCodeMirror->setProperty("readOnly", "true");
521: 
522:             $form->setActionButton('submit', cRegistry::getBackendUrl() . 'images/but_ok_off.gif', i18n('Overwriting files is disabled'), 's');
523:         }
524:         $this->_page->addScript($oCodeMirror->renderScript());
525: 
526:         // $this->_page->addScript('reload', $this->_reloadScript);
527:     }
528: 
529:     /**
530:      * Display the form and evaluate the action and excute the action.
531:      *
532:      * @param cPermission $perm
533:      * @param cGuiNotification $notification
534:      * @param string Backend language (not sure about this...)
535:      * @param bool render in read only mode
536:      */
537:     public function display($perm, $notification, $belang, $readOnly) {
538:         $myAction = $this->_getAction();
539: 
540:         // if the user doesn't have premissions
541:         if ($this->_havePremission($perm, $notification, $myAction) === -1) {
542:             return;
543:         }
544: 
545:         try {
546:             switch ($myAction) {
547:                 case 'save':
548:                     if(!$readOnly) {
549:                         $this->_save();
550:                     }
551:                     break;
552:                 case 'rename':
553:                     if(!$readOnly) {
554:                         $this->_rename();
555:                     }
556:                     break;
557:                 case 'new':
558:                     if(!$readOnly) {
559:                         $this->_new();
560:                     }
561:                     break;
562:                 case 'delete':
563:                     if(!$readOnly) {
564:                         $this->_delete();
565:                     }
566:                     break;
567:                 default:
568:                     $this->_default();
569:                     break;
570:             }
571: 
572:             $this->_code = $this->getFilesContent('template', '', $this->_file);
573:             $this->_validateHTML($notification);
574:             $this->_makeFormular($belang, $readOnly);
575:         } catch (Exception $e) {
576:             $this->_page->displayError(i18n($e->getMessage()));
577:         }
578:     }
579: 
580: }
CMS CONTENIDO 4.9.5 API documentation generated by ApiGen 2.8.0