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 backend ajax handler class.
  4:  *
  5:  * @package Core
  6:  * @subpackage Backend
  7:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author Timo Trautmann
 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:  * Class for outputting some content for Ajax use
 20:  *
 21:  * @package Core
 22:  * @subpackage Backend
 23:  */
 24: class cAjaxRequest {
 25: 
 26:     /**
 27:      * Function for handling requested ajax data
 28:      *
 29:      * @param string $action
 30:      *         name of requested ajax action
 31:      * @return string
 32:      */
 33:     public function handle($action) {
 34:         $backendPath = cRegistry::getBackendPath();
 35:         $string = '';
 36: 
 37:         $frontendURL = cRegistry::getFrontendUrl();
 38:         $frontendPath = cRegistry::getFrontendPath();
 39: 
 40:         switch ($action) {
 41:             // case to get an article select box param name value and idcat were
 42:             // neded (name= name of select box value=selected item)
 43:             case 'artsel':
 44:                 $name = (string) $_REQUEST['name'];
 45:                 $value = (int) $_REQUEST['value'];
 46:                 $idCat = (int) $_REQUEST['idcat'];
 47:                 $string = buildArticleSelect($name, $idCat, $value);
 48:                 break;
 49: 
 50:             case 'dirlist':
 51:                 global $cfgClient, $client;
 52: 
 53:                 $dirName = (string) $_REQUEST['dir'];
 54:                 $fileListId = (int) $_REQUEST['id'];
 55:                 $idArtLang = (int) $_REQUEST['idartlang'];
 56: 
 57:                 $art = new cApiArticleLanguage($idArtLang, true);
 58:                 $artReturn = $art->getContent('CMS_FILELIST', $fileListId);
 59:                 $fileList = new cContentTypeFilelist($artReturn, $fileListId, array());
 60: 
 61:                 $string = $fileList->generateDirectoryList($fileList->buildDirectoryList($cfgClient[$client]['upl']['path'] . $dirName));
 62:                 break;
 63: 
 64:             case 'filelist':
 65:                 $dirName = (string) $_REQUEST['dir'];
 66:                 $fileListId = (int) $_REQUEST['id'];
 67:                 $idArtLang = (int) $_REQUEST['idartlang'];
 68: 
 69:                 $art = new cApiArticleLanguage($idArtLang, true);
 70:                 $artReturn = $art->getContent('CMS_FILELIST', $fileListId);
 71:                 $fileList = new cContentTypeFilelist($artReturn, $fileListId, array());
 72: 
 73:                 $string = $fileList->generateFileSelect($dirName);
 74:                 break;
 75: 
 76:             case 'inused_layout':
 77:                 // list of used templates for a layout
 78:                 global $cfg;
 79:                 if ((int) $_REQUEST['id'] > 0) {
 80:                     $layout = new cApiLayout((int) $_REQUEST['id']);
 81:                     if ($layout->isInUse(true)) {
 82:                         $template = new cTemplate();
 83:                         $usedTemplates = $layout->getUsedTemplates();
 84:                         if (count($usedTemplates) > 0) {
 85:                             $response = '<br>';
 86:                             foreach ($usedTemplates as $i => $usedTemplate) {
 87:                                 if ($i % 2 == 0) {
 88:                                     $template->set('d', 'CLASS', 'grey');
 89:                                 } else {
 90:                                     $template->set('d', 'CLASS', 'white');
 91:                                 }
 92:                                 $template->set('d', 'NAME', $usedTemplate['tpl_name']);
 93:                                 $template->next();
 94:                             }
 95: 
 96:                             $string = '<div class="inuse_info" >' . $template->generate($backendPath . $cfg['path']['templates'] . $cfg['templates']['inuse_lay_mod'], true) . '</div>';
 97:                         } else {
 98:                             $string = i18n('No data found!');
 99:                         }
100:                     }
101:                 }
102:                 break;
103: 
104:             case 'inused_module':
105:                 // list of used templates for a module
106:                 global $cfg;
107:                 $module = new cApiModule();
108:                 if ((int) $_REQUEST['id'] > 0 && $module->moduleInUse((int) $_REQUEST['id'], true)) {
109:                     $template = new cTemplate();
110:                     $usedTemplates = $module->getUsedTemplates();
111:                     if (count($usedTemplates) > 0) {
112:                         foreach ($usedTemplates as $i => $usedTemplate) {
113:                             if ($i % 2 == 0) {
114:                                 $template->set('d', 'CLASS', 'grey');
115:                             } else {
116:                                 $template->set('d', 'CLASS', 'white');
117:                             }
118: 
119:                             $template->set('d', 'NAME', $usedTemplate['tpl_name']);
120:                             $template->next();
121:                         }
122: 
123:                         $string = '<div class="inuse_info" >' . $template->generate($backendPath . $cfg['path']['templates'] . $cfg['templates']['inuse_lay_mod'], true) . '</div>';
124:                     } else {
125:                         $string = i18n('No data found!');
126:                     }
127:                 }
128:                 break;
129: 
130:             case 'inused_template':
131:                 // list of used category and art
132:                 global $cfg;
133:                 cInclude('backend', 'includes/functions.tpl.php');
134: 
135:                 if ((int) $_REQUEST['id'] > 0) {
136:                     $template = new cTemplate();
137:                     $template->reset();
138:                     $usedData = tplGetInUsedData((int) $_REQUEST['id']);
139: 
140:                     if (isset($usedData['cat'])) {
141:                         $template->set('s', 'HEAD_TYPE', i18n('Category'));
142:                         foreach ($usedData['cat'] as $i => $cat) {
143:                             $template->set('d', 'ID', $cat['idcat']);
144:                             $template->set('d', 'LANG', $cat['lang']);
145:                             $template->set('d', 'NAME', $cat['name']);
146:                             $template->next();
147:                         }
148:                         $template->set('s', 'HEAD_ID', i18n('idcat'));
149:                         $template->set('s', 'HEAD_LANG', i18n('idlang'));
150:                         $template->set('s', 'HEAD_NAME', i18n('Name'));
151:                         $response = $template->generate($backendPath . $cfg['path']['templates'] . $cfg['templates']['inuse_tpl'], true);
152:                     }
153: 
154:                     $template->reset();
155: 
156:                     if (isset($usedData['art'])) {
157:                         $template->set('s', 'HEAD_TYPE', i18n('Article'));
158:                         foreach ($usedData['art'] as $i => $aArt) {
159:                             $template->set('d', 'ID', $aArt['idart']);
160:                             $template->set('d', 'LANG', $aArt['lang']);
161:                             $template->set('d', 'NAME', $aArt['title']);
162:                             $template->next();
163:                         }
164:                         $template->set('s', 'HEAD_ID', i18n('idart'));
165:                         $template->set('s', 'HEAD_LANG', i18n('idlang'));
166:                         $template->set('s', 'HEAD_NAME', i18n('Name'));
167:                         $response .= $template->generate($backendPath . $cfg['path']['templates'] . $cfg['templates']['inuse_tpl'], true);
168:                     }
169: 
170:                     $string = '<div class="inuse_info" >' . $response . '</div>';
171:                 } else {
172:                     $string = i18n('No data found!');
173:                 }
174: 
175:                 break;
176: 
177:             case 'scaleImage':
178:                 $filename_a = $_REQUEST['url'];
179:                 $filename = str_replace($frontendURL, $frontendPath, $filename_a);
180:                 // $filename muss not url path(http://) sondern globale PC
181:                 // Path(c:/) sein.
182:                 $filetype = substr($filename, strlen($filename) - 4, 4);
183:                 switch (strtolower($filetype)) {
184:                     case '.gif':
185:                         $string = cApiImgScale($filename, 428, 210);
186:                         break;
187:                     case '.png':
188:                         $string = cApiImgScale($filename, 428, 210);
189:                         break;
190:                     case '.jpg':
191:                         $string = cApiImgScale($filename, 428, 210);
192:                         break;
193:                     case 'jpeg':
194:                         $string = cApiImgScale($filename, 428, 210);
195:                         break;
196:                     default:
197:                         $string = $filename_a;
198:                         break;
199:                 }
200:                 // if can not scale, so $sString is NULL, then show the original
201:                 // image.
202:                 if ($string == '') {
203:                     $filename = str_replace($frontendPath, $frontendURL, $filename_a);
204:                     $string = $filename;
205:                 }
206:                 break;
207: 
208:             case 'imagelist':
209:                 $dirName = (string) $_REQUEST['dir'];
210:                 $imageId = (int) $_REQUEST['id'];
211:                 $idArtLang = (int) $_REQUEST['idartlang'];
212: 
213:                 $art = new cApiArticleLanguage($idArtLang, true);
214:                 $artReturn = $art->getContent('CMS_IMGEDITOR', $imageId);
215:                 $image = new cContentTypeImgeditor($artReturn, $imageId, array());
216: 
217:                 $string = $image->generateFileSelect($dirName);
218:                 break;
219: 
220:             case 'loadImageMeta':
221:                 $imageId = (int) $_REQUEST['id'];
222:                 $idArtLang = (int) $_REQUEST['idartlang'];
223: 
224:                 $art = new cApiArticleLanguage($idArtLang, true);
225:                 $artReturn = $art->getContent('CMS_IMGEDITOR', $imageId);
226:                 $image = new cContentTypeImgeditor($artReturn, $imageId, array());
227: 
228:                 $filename = (string) basename($_REQUEST['filename']);
229:                 $dirname = (string) dirname($_REQUEST['filename']);
230:                 if ($dirname != '.') {
231:                     $dirname .= '/';
232:                 } else {
233:                     $dirname = '';
234:                 }
235: 
236:                 $string = $image->getImageMeta($filename, $dirname);
237:                 break;
238: 
239:             case 'upl_mkdir':
240:                 $imageId = (int) $_REQUEST['id'];
241:                 $idArtLang = (int) $_REQUEST['idartlang'];
242:                 $path = (string) $_REQUEST['path'];
243:                 $name = (string) $_REQUEST['foldername'];
244: 
245:                 $art = new cApiArticleLanguage($idArtLang, true);
246:                 $artReturn = $art->getContent('CMS_IMGEDITOR', $imageId);
247:                 $image = new cContentTypeImgeditor($artReturn, $imageId, array());
248: 
249:                 $string = $image->uplmkdir($path, $name);
250:                 switch ($string) {
251:                     case 1:
252:                         break;
253:                     case '0702':
254:                         $string = i18n('Directory already exist.');
255:                         break;
256:                     case '0703':
257:                         $string = i18n('Directories with special characters and spaces are not allowed.');
258:                         break;
259:                 }
260:                 break;
261: 
262:             case 'upl_upload':
263:                 $imageId = (int) $_REQUEST['id'];
264:                 $idArtLang = (int) $_REQUEST['idartlang'];
265:                 $path = (string) $_REQUEST['path'];
266:                 if ($path == '/') {
267:                     $path = '';
268:                 }
269: 
270:                 $art = new cApiArticleLanguage($idArtLang, true);
271:                 $artReturn = $art->getContent('CMS_IMGEDITOR', $imageId);
272:                 $image = new cContentTypeImgeditor($artReturn, $imageId, array());
273: 
274:                 $string = $image->uplupload($path);
275:                 break;
276: 
277:             case 'linkeditorfilelist':
278:                 $id = (int) $_REQUEST['id'];
279:                 $idArtLang = (int) $_REQUEST['idartlang'];
280:                 $idCat = (string) $_REQUEST['idcat'];
281: 
282:                 $art = new cApiArticleLanguage($idArtLang, true);
283:                 $artReturn = $art->getContent('CMS_LINKEDITOR', $id);
284:                 $linkEditor = new cContentTypeLinkeditor($artReturn, $id, array());
285: 
286:                 $string = $linkEditor->generateArticleSelect($idCat);
287:                 break;
288: 
289:             case 'linkeditordirlist':
290:                 $id = (int) $_REQUEST['id'];
291:                 $idArtLang = (int) $_REQUEST['idartlang'];
292:                 $levelId = (string) $_REQUEST['level'];
293:                 $parentidcat = (string) $_REQUEST['parentidcat'];
294: 
295:                 $art = new cApiArticleLanguage($idArtLang, true);
296:                 $artReturn = $art->getContent('CMS_LINKEDITOR', $id);
297:                 $linkEditor = new cContentTypeLinkeditor($artReturn, $id, array());
298: 
299:                 $string = $linkEditor->getCategoryList($linkEditor->buildCategoryArray($levelId, $parentidcat));
300:                 break;
301: 
302:             case 'linkeditorimagelist':
303:                 $dirName = (string) $_REQUEST['dir'];
304:                 $id = (int) $_REQUEST['id'];
305:                 $idArtLang = (int) $_REQUEST['idartlang'];
306: 
307:                 $art = new cApiArticleLanguage($idArtLang, true);
308:                 $artReturn = $art->getContent('CMS_LINKEDITOR', $id);
309:                 $linkEditor = new cContentTypeLinkeditor($artReturn, $id, array());
310: 
311:                 $string = $linkEditor->getUploadFileSelect($dirName);
312:                 break;
313: 
314:             case 'generaljstranslations':
315:                 $translations = array();
316:                 $translations['Confirmation Required'] = i18n('Confirmation Required');
317:                 $translations['OK'] = i18n('OK');
318:                 $translations['Cancel'] = i18n('Cancel');
319:                 $string = json_encode($translations);
320:                 break;
321: 
322:             case 'logfilecontent':
323:                 $type = $_REQUEST['logfile'];
324:                 $numberOfLines = $_REQUEST['numberOfLines'];
325:                 $cfg = cRegistry::getConfig();
326:                 $filename = $cfg['path']['frontend'] . DIRECTORY_SEPARATOR . $cfg['path']['logs'] . $type;
327:                 $string = cFileHandler::read($filename);
328:                 $lines = file($filename);
329:                 $lines = array_splice($lines, $numberOfLines * -1);
330:                 $string = implode('', $lines);
331:                 break;
332: 
333:             case 'updatepluginorder':
334:                 if (cRegistry::getPerm()->have_perm()) { // only sysadmins can do this
335:                     $newOrder = cSecurity::toInteger($_POST['neworder']);
336:                     $pluginColl = new PimPluginCollection();
337:                     $pluginColl->select();
338:                     if ($newOrder <= 0 || $newOrder > $pluginColl->count()) {
339:                         $string = 'order must be > 0 and <= number of plugins';
340:                         break;
341:                     }
342: 
343:                     $pluginId = cSecurity::toInteger($_POST['idplugin']);
344:                     $plugin = new PimPlugin($pluginId);
345:                     $result = $plugin->updateExecOrder($newOrder);
346:                     if ($result === true) {
347:                         $string = 'ok';
348:                     }
349:                 } else {
350:                     $string = 'Unknown Ajax Action';
351:                 }
352:                 break;
353: 
354:             case 'verify_module':
355:                 // Module syntax check
356:                 $idmod = isset($_POST['idmod']) ? $_POST['idmod'] : NULL;
357:                 $inputType = isset($_POST['type']) ? $_POST['type'] : NULL;
358: 
359:                 // NOTE: The default setting is to check the modules
360:                 $moduleCheck = getSystemProperty('system', 'modulecheck');
361:                 $moduleCheck = $moduleCheck == '' || $moduleCheck == 'true';
362: 
363:                 $result = array(
364:                     'state' => 'error',
365:                     'message' => 'No cModuleHandler for ' . $idmod . ', or wrong code type: ' . $inputType
366:                 );
367: 
368:                 if ($idmod && $inputType && $moduleCheck === true) {
369:                     $contenidoModuleHandler = new cModuleHandler($idmod);
370:                     switch ($inputType) {
371:                         case 'input':
372:                             $result = $contenidoModuleHandler->testInput();
373:                             break;
374:                         case 'output':
375:                             $result = $contenidoModuleHandler->testOutput();
376:                             break;
377:                     }
378: 
379:                     //create answer
380:                     if ($result['state']) {
381:                         $result['state'] = 'ok';
382:                         $result['message'] = i18n("Module successfully compiled");
383:                     } else {
384:                         $result['state'] = 'error';
385:                         $result['message'] = $result['errorMessage'];
386:                     }
387:                 }
388: 
389:                 $string = json_encode($result);
390:                 break;
391: 
392:             case 'authentication_fail':
393:                 // Not authenticated AJAX request, e. g. invalid or expired session
394:                 $result = array(
395:                     'state' => 'error',
396:                     'code' => 401,
397:                     'message' => 'Unauthorized',
398:                     'type' => 'authentication_failure'
399:                 );
400:                 $string = json_encode($result);
401:                 break;
402: 
403:             default:
404:                 // If action is unknown generate error message
405:                 $string = 'Unknown Ajax Action';
406:                 break;
407:         }
408: 
409:         return $string;
410:     }
411: 
412: }
413: 
CMS CONTENIDO 4.9.8 API documentation generated by ApiGen 2.8.0