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 class cAjaxRequest which handles ajax requests
  4:  * for the CONTENIDO backend.
  5:  *
  6:  * @package Core
  7:  * @subpackage Backend
  8:  * @author Timo Trautmann
  9:  * @copyright four for business AG <www.4fb.de>
 10:  * @license http://www.contenido.org/license/LIZENZ.txt
 11:  * @link http://www.4fb.de
 12:  * @link http://www.contenido.org
 13:  */
 14: 
 15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 16: 
 17: /**
 18:  * Class for outputting some content for Ajax use
 19:  *
 20:  * @package Core
 21:  * @subpackage Backend
 22:  */
 23: class cAjaxRequest {
 24: 
 25:     /**
 26:      * Handles AJAX requests for certain data. Which data is returned
 27:      * depends upon the given $action. If the $action is unknown an
 28:      * error message is generated. Available actions are:
 29:      *
 30:      * <ul>
 31:      *     <li>artsel
 32:      *          Return a select box containing articles of a category.
 33:      *          All params (name, idcat & value) are required.
 34:      *          name = name of select box
 35:      *          idcat = category ID whose articles should be contained
 36:      *          value = selected article
 37:      *     <li>dirlist
 38:      *     <li>filelist
 39:      *     <li>inused_layout
 40:      *          List templates using a given layout.
 41:      *     <li>inused_module
 42:      *          List templates using a given module.
 43:      *     <li>inused_template
 44:      *          List categories and articles using a given template.
 45:      *     <li>scaleImage
 46:      *     <li>imagelist
 47:      *     <li>inlineeditart
 48:      *     <li>loadImageMeta
 49:      *     <li>upl_mkdir
 50:      *     <li>upl_upload
 51:      *     <li>linkeditorfilelist
 52:      *     <li>linkeditordirlist
 53:      *     <li>linkeditorimagelist
 54:      *     <li>generaljstranslations
 55:      *     <li>logfilecontent
 56:      *     <li>updatepluginorder
 57:      *          only sysadmins can do this
 58:      *     <li>verify_module
 59:      *          check module syntax
 60:      *          modules are checked by default
 61:      *          This can be deactivated when the system property
 62:      *          system/modulecheck is set accordingly.
 63:      *          TODO Describe what "accordingly" means. The rules are a mess!
 64:      *     <li>authentication_fail
 65:      *          Returns a static answer for a not authenticated AJAX
 66:      *          request, e.g. due to an invalid or expired session.
 67:      * </ul>
 68:      *
 69:      * @todo split functionality into seperate methods
 70:      * @todo use registry instead of globals where possible
 71:      * @param string $action
 72:      *         name of requested ajax action
 73:      * @return string
 74:      */
 75:     public function handle($action) {
 76:         $backendPath = cRegistry::getBackendPath();
 77:         $frontendURL = cRegistry::getFrontendUrl();
 78:         $frontendPath = cRegistry::getFrontendPath();
 79: 
 80:         $string = '';
 81:         switch ($action) {
 82:             case 'artsel':
 83:                 $name = (string) $_REQUEST['name'];
 84:                 $idcat = (int) $_REQUEST['idcat'];
 85:                 $value = (int) $_REQUEST['value'];
 86: 
 87:                 $string = buildArticleSelect($name, $idcat, $value);
 88:                 break;
 89: 
 90:             case 'dirlist':
 91: 
 92:                 $idartlang = (int) $_REQUEST['idartlang'];
 93:                 $fileListId = (int) $_REQUEST['id'];
 94:                 $dirname = (string) $_REQUEST['dir'];
 95: 
 96:                 global $cfgClient, $client;
 97:                 $uplPath = $cfgClient[$client]['upl']['path'];
 98: 
 99:                 $art = new cApiArticleLanguage($idartlang, true);
100:                 $content = $art->getContent('CMS_FILELIST', $fileListId);
101: 
102:                 $fileList = new cContentTypeFilelist($content, $fileListId, array());
103:                 $directoryList = $fileList->buildDirectoryList($uplPath . $dirname);
104:                 $string = $fileList->generateDirectoryList($directoryList);
105:                 break;
106: 
107:             case 'filelist':
108:                 $idartlang = (int) $_REQUEST['idartlang'];
109:                 $fileListId = (int) $_REQUEST['id'];
110:                 $dirname = (string) $_REQUEST['dir'];
111: 
112:                 $art = new cApiArticleLanguage($idartlang, true);
113:                 $content = $art->getContent('CMS_FILELIST', $fileListId);
114: 
115:                 $fileList = new cContentTypeFilelist($content, $fileListId, array());
116:                 $string = $fileList->generateFileSelect($dirname);
117:                 break;
118: 
119:             case 'inused_layout':
120:                 global $cfg;
121:                 if (0 < (int) $_REQUEST['id']) {
122:                     $layout = new cApiLayout((int) $_REQUEST['id']);
123:                     if ($layout->isInUse(true)) {
124:                         $template = new cTemplate();
125:                         $usedTemplates = $layout->getUsedTemplates();
126:                         if (count($usedTemplates) > 0) {
127:                             foreach ($usedTemplates as $i => $usedTemplate) {
128:                                 if ($i % 2 == 0) {
129:                                     $template->set('d', 'CLASS', 'grey');
130:                                 } else {
131:                                     $template->set('d', 'CLASS', 'white');
132:                                 }
133:                                 $template->set('d', 'NAME', $usedTemplate['tpl_name']);
134:                                 $template->next();
135:                             }
136: 
137:                             $string = '<div class="inuse_info" >' . $template->generate($backendPath . $cfg['path']['templates'] . $cfg['templates']['inuse_lay_mod'], true) . '</div>';
138:                         } else {
139:                             $string = i18n('No data found!');
140:                         }
141:                     }
142:                 }
143:                 break;
144: 
145:             case 'inused_module':
146:                 global $cfg;
147:                 $module = new cApiModule();
148:                 if ((int) $_REQUEST['id'] > 0 && $module->moduleInUse((int) $_REQUEST['id'], true)) {
149:                     $template = new cTemplate();
150:                     $usedTemplates = $module->getUsedTemplates();
151:                     if (count($usedTemplates) > 0) {
152:                         foreach ($usedTemplates as $i => $usedTemplate) {
153:                             if ($i % 2 == 0) {
154:                                 $template->set('d', 'CLASS', 'grey');
155:                             } else {
156:                                 $template->set('d', 'CLASS', 'white');
157:                             }
158: 
159:                             $template->set('d', 'NAME', $usedTemplate['tpl_name']);
160:                             $template->next();
161:                         }
162: 
163:                         $string = '<div class="inuse_info" >' . $template->generate($backendPath . $cfg['path']['templates'] . $cfg['templates']['inuse_lay_mod'], true) . '</div>';
164:                     } else {
165:                         $string = i18n('No data found!');
166:                     }
167:                 }
168:                 break;
169: 
170:             case 'inused_template':
171:                 global $cfg;
172:                 cInclude('backend', 'includes/functions.tpl.php');
173: 
174:                 if ((int) $_REQUEST['id'] > 0) {
175:                     $template = new cTemplate();
176:                     $template->reset();
177:                     $usedData = tplGetInUsedData((int) $_REQUEST['id']);
178: 
179:                     if (isset($usedData['cat'])) {
180:                         $template->set('s', 'HEAD_TYPE', i18n('Category'));
181:                         foreach ($usedData['cat'] as $i => $cat) {
182:                             $template->set('d', 'ID', $cat['idcat']);
183:                             $template->set('d', 'LANG', $cat['lang']);
184:                             $template->set('d', 'NAME', $cat['name']);
185:                             $template->next();
186:                         }
187:                         $template->set('s', 'HEAD_ID', i18n('idcat'));
188:                         $template->set('s', 'HEAD_LANG', i18n('idlang'));
189:                         $template->set('s', 'HEAD_NAME', i18n('Name'));
190:                         $response = $template->generate($backendPath . $cfg['path']['templates'] . $cfg['templates']['inuse_tpl'], true);
191:                     }
192: 
193:                     $template->reset();
194: 
195:                     if (isset($usedData['art'])) {
196:                         $template->set('s', 'HEAD_TYPE', i18n('Article'));
197:                         foreach ($usedData['art'] as $i => $aArt) {
198:                             $template->set('d', 'ID', $aArt['idart']);
199:                             $template->set('d', 'LANG', $aArt['lang']);
200:                             $template->set('d', 'NAME', $aArt['title']);
201:                             $template->next();
202:                         }
203:                         $template->set('s', 'HEAD_ID', i18n('idart'));
204:                         $template->set('s', 'HEAD_LANG', i18n('idlang'));
205:                         $template->set('s', 'HEAD_NAME', i18n('Name'));
206:                         $response .= $template->generate($backendPath . $cfg['path']['templates'] . $cfg['templates']['inuse_tpl'], true);
207:                     }
208: 
209:                     $string = '<div class="inuse_info" >' . $response . '</div>';
210:                 } else {
211:                     $string = i18n('No data found!');
212:                 }
213: 
214:                 break;
215: 
216:             case 'scaleImage':
217:                 $filename_a = $_REQUEST['url'];
218:                 $filename = str_replace($frontendURL, $frontendPath, $filename_a);
219:                 // $filename muss not url path(http://) sondern globale PC
220:                 // Path(c:/) sein.
221:                 $filetype = substr($filename, strlen($filename) - 4, 4);
222:                 switch (strtolower($filetype)) {
223:                     case '.gif':
224:                         $string = cApiImgScale($filename, 428, 210);
225:                         break;
226:                     case '.png':
227:                         $string = cApiImgScale($filename, 428, 210);
228:                         break;
229:                     case '.jpg':
230:                         $string = cApiImgScale($filename, 428, 210);
231:                         break;
232:                     case 'jpeg':
233:                         $string = cApiImgScale($filename, 428, 210);
234:                         break;
235:                     default:
236:                         $string = $filename_a;
237:                         break;
238:                 }
239:                 // if can not scale, so $string is NULL, then show the
240:                 // original image
241:                 if ($string == '') {
242:                     $filename = str_replace($frontendPath, $frontendURL, $filename_a);
243:                     $string = $filename;
244:                 }
245:                 break;
246: 
247:             case 'imagelist':
248:                 $dirName = (string) $_REQUEST['dir'];
249:                 $imageId = (int) $_REQUEST['id'];
250:                 $idArtLang = (int) $_REQUEST['idartlang'];
251: 
252:                 $art = new cApiArticleLanguage($idArtLang, true);
253:                 $artReturn = $art->getContent('CMS_IMGEDITOR', $imageId);
254:                 $image = new cContentTypeImgeditor($artReturn, $imageId, array());
255: 
256:                 $string = $image->generateFileSelect($dirName);
257:                 break;
258: 
259:             case 'inlineeditart':
260: 
261:                 $languageCollection = new cApiArticleLanguageCollection();
262: 
263:                 for ($i = 0; $i < count($_REQUEST['fields']); $i++) {
264: 
265:                     $idartlang = $languageCollection->getIdByArticleIdAndLanguageId(cSecurity::toInteger($_REQUEST['fields'][$i]['idart']), cRegistry::getLanguageId());
266: 
267:                     $artLang = new cApiArticleLanguage(cSecurity::toInteger($idartlang));
268:                     $artLang->set('title', cSecurity::escapeString($_REQUEST['fields'][$i]['title']));
269:                     $artLang->set('artsort', cSecurity::escapeString($_REQUEST['fields'][$i]['index']));
270:                     $artLang->store();
271:                 }
272: 
273:                 break;
274: 
275:             case 'loadImageMeta':
276:                 $imageId = (int) $_REQUEST['id'];
277:                 $idArtLang = (int) $_REQUEST['idartlang'];
278: 
279:                 $art = new cApiArticleLanguage($idArtLang, true);
280:                 $artReturn = $art->getContent('CMS_IMGEDITOR', $imageId);
281:                 $image = new cContentTypeImgeditor($artReturn, $imageId, array());
282: 
283:                 $filename = (string) basename($_REQUEST['filename']);
284:                 $dirname = (string) dirname($_REQUEST['filename']);
285:                 if ($dirname != '.') {
286:                     $dirname .= '/';
287:                 } else {
288:                     $dirname = '';
289:                 }
290: 
291:                 $string = $image->getImageMeta($filename, $dirname);
292:                 break;
293: 
294:             case 'upl_mkdir':
295:                 $imageId = (int) $_REQUEST['id'];
296:                 $idArtLang = (int) $_REQUEST['idartlang'];
297:                 $path = (string) $_REQUEST['path'];
298:                 $name = (string) $_REQUEST['foldername'];
299: 
300:                 $art = new cApiArticleLanguage($idArtLang, true);
301:                 $artReturn = $art->getContent('CMS_IMGEDITOR', $imageId);
302:                 $image = new cContentTypeImgeditor($artReturn, $imageId, array());
303: 
304:                 $string = $image->uplmkdir($path, $name);
305:                 switch ($string) {
306:                     case 1:
307:                         break;
308:                     case '0702':
309:                         $string = i18n('Directory already exist.');
310:                         break;
311:                     case '0703':
312:                         $string = i18n('Directories with special characters and spaces are not allowed.');
313:                         break;
314:                 }
315:                 break;
316: 
317:             case 'upl_upload':
318:                 $imageId = (int) $_REQUEST['id'];
319:                 $idArtLang = (int) $_REQUEST['idartlang'];
320:                 $path = (string) $_REQUEST['path'];
321:                 if ($path == '/') {
322:                     $path = '';
323:                 }
324: 
325:                 $art = new cApiArticleLanguage($idArtLang, true);
326:                 $artReturn = $art->getContent('CMS_IMGEDITOR', $imageId);
327:                 $image = new cContentTypeImgeditor($artReturn, $imageId, array());
328: 
329:                 $string = $image->uplupload($path);
330:                 break;
331: 
332:             case 'linkeditorfilelist':
333:                 $id = (int) $_REQUEST['id'];
334:                 $idArtLang = (int) $_REQUEST['idartlang'];
335:                 $idCat = (string) $_REQUEST['idcat'];
336: 
337:                 $art = new cApiArticleLanguage($idArtLang, true);
338:                 $artReturn = $art->getContent('CMS_LINKEDITOR', $id);
339:                 $linkEditor = new cContentTypeLinkeditor($artReturn, $id, array());
340: 
341:                 $string = $linkEditor->generateArticleSelect($idCat);
342:                 break;
343: 
344:             case 'linkeditordirlist':
345:                 $id = (int) $_REQUEST['id'];
346:                 $idArtLang = (int) $_REQUEST['idartlang'];
347:                 $levelId = (string) $_REQUEST['level'];
348:                 $parentidcat = (string) $_REQUEST['parentidcat'];
349: 
350:                 $art = new cApiArticleLanguage($idArtLang, true);
351:                 $artReturn = $art->getContent('CMS_LINKEDITOR', $id);
352:                 $linkEditor = new cContentTypeLinkeditor($artReturn, $id, array());
353: 
354:                 $string = $linkEditor->getCategoryList($linkEditor->buildCategoryArray($levelId, $parentidcat));
355:                 break;
356: 
357:             case 'linkeditorimagelist':
358:                 $dirName = (string) $_REQUEST['dir'];
359:                 $id = (int) $_REQUEST['id'];
360:                 $idArtLang = (int) $_REQUEST['idartlang'];
361: 
362:                 $art = new cApiArticleLanguage($idArtLang, true);
363:                 $artReturn = $art->getContent('CMS_LINKEDITOR', $id);
364:                 $linkEditor = new cContentTypeLinkeditor($artReturn, $id, array());
365: 
366:                 $string = $linkEditor->getUploadFileSelect($dirName);
367:                 break;
368: 
369:             case 'generaljstranslations':
370:                 $translations = array();
371:                 $translations['Confirmation Required'] = i18n('Confirmation Required');
372:                 $translations['OK'] = i18n('OK');
373:                 $translations['Cancel'] = i18n('Cancel');
374:                 $string = json_encode($translations);
375:                 break;
376: 
377:             case 'logfilecontent':
378:                 $type = cSecurity::escapeString($_REQUEST['logfile']);
379:                 $numberOfLines = cSecurity::toInteger($_REQUEST['numberOfLines']);
380:                 $cfg = cRegistry::getConfig();
381:                 if (in_array($type, $cfg['system_log']['allowed_filenames'])) {
382:                     $filename = $cfg['path']['frontend'] . DIRECTORY_SEPARATOR . $cfg['path']['logs'] . $type;
383:                     $lines = file($filename);
384:                     $lines = array_splice($lines, $numberOfLines * -1);
385:                     $string = implode('', $lines);
386:                 }
387:                 break;
388: 
389:             case 'updatepluginorder':
390:                 // only sysadmins can do this
391:                 if (cRegistry::getPerm()->have_perm()) {
392:                     $newOrder = cSecurity::toInteger($_POST['neworder']);
393:                     $pluginColl = new PimPluginCollection();
394:                     $pluginColl->select();
395:                     if ($newOrder <= 0 || $newOrder > $pluginColl->count()) {
396:                         $string = 'order must be > 0 and <= number of plugins';
397:                         break;
398:                     }
399: 
400:                     $pluginId = cSecurity::toInteger($_POST['idplugin']);
401:                     $plugin = new PimPlugin($pluginId);
402:                     $result = $plugin->updateExecOrder($newOrder);
403:                     if ($result === true) {
404:                         $string = 'ok';
405:                     }
406:                 } else {
407:                     $string = 'Unknown Ajax Action';
408:                 }
409:                 break;
410: 
411:             case 'verify_module':
412:                 $idmod = isset($_POST['idmod']) ? $_POST['idmod'] : NULL;
413:                 $inputType = isset($_POST['type']) ? $_POST['type'] : NULL;
414: 
415:                 // @see CON-2425 modules are checked by default
416:                 $moduleCheck = getSystemProperty('system', 'modulecheck');
417:                 $moduleCheck = ($moduleCheck == '' && $moduleCheck != 'false') || $moduleCheck == 'true' || $moduleCheck == '1';
418: 
419:                 $result = array(
420:                     'state' => 'ok',
421:                     'message' => i18n("Module successfully compiled")
422:                 );
423: 
424:                 if ($idmod && $inputType && $moduleCheck) {
425:                     $contenidoModuleHandler = new cModuleHandler($idmod);
426:                     switch ($inputType) {
427:                         case 'input':
428:                             $result = $contenidoModuleHandler->testInput();
429:                             break;
430:                         case 'output':
431:                             $result = $contenidoModuleHandler->testOutput();
432:                             break;
433:                         default:
434:                             $result = array(
435:                                 'state' => 'error',
436:                                 'message' => 'No cModuleHandler for ' . $idmod . ', or wrong code type: ' . $inputType
437:                             );
438:                     }
439: 
440:                     // create answer
441:                     if ($result['state']) {
442:                         $result['state'] = 'ok';
443:                         $result['message'] = i18n("Module successfully compiled");
444:                     } else {
445:                         $result['state'] = 'error';
446:                         $result['message'] = $result['errorMessage'];
447:                     }
448:                 }
449: 
450:                 $string = json_encode($result);
451:                 break;
452: 
453:             case 'authentication_fail':
454:                 $string = json_encode(array(
455:                     'state' => 'error',
456:                     'code' => 401,
457:                     'message' => 'Unauthorized',
458:                     'type' => 'authentication_failure'
459:                 ));
460:                 break;
461:             case 'custom':
462:                 $string = cApiCecHook::executeAndReturn('Contenido.AjaxMain.CustomCall', $_REQUEST['method']);
463:                 if($string === NULL) {
464:                     $string = 'Unknown Custom Ajax Action';
465:                 }
466:                 break;
467:             default:
468:                 // If action is unknown generate error message
469:                 $string = 'Unknown Ajax Action';
470:                 break;
471:         }
472: 
473:         return $string;
474:     }
475: 
476: }
477: 
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0