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:  * 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:      * Handles AJAX requests for certain data. Which data is returned
 26:      * depends upon the given $action. If the $action is unknown an
 27:      * error message is generated. Available actions are:
 28:      *
 29:      * <ul>
 30:      *     <li>artsel
 31:      *          Return a select box containing articles of a category.
 32:      *          All params (name, idcat & value) are required.
 33:      *          name = name of select box
 34:      *          idcat = category ID whose articles should be contained
 35:      *          value = selected article
 36:      *     <li>dirlist
 37:      *     <li>imgdirlist
 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>linkeditorarticleslist
 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:      *
 72:      * @param string $action
 73:      *         name of requested ajax action
 74:      *
 75:      * @return string
 76:      * 
 77:      * @throws cDbException
 78:      * @throws cException
 79:      * @throws cInvalidArgumentException
 80:      */
 81:     public function handle($action) {
 82:         $backendPath = cRegistry::getBackendPath();
 83: 
 84:         $string = '';
 85:         switch ($action) {
 86:             case 'artsel':
 87:                 $name  = cSecurity::toString($_REQUEST['name']);
 88:                 $idcat = cSecurity::toInteger($_REQUEST['idcat']);
 89:                 $value = cSecurity::toInteger($_REQUEST['value']);
 90: 
 91:                 $string = buildArticleSelect($name, $idcat, $value);
 92:                 break;
 93: 
 94:             case 'dirlist':
 95: 
 96:                 $idartlang = cSecurity::toInteger($_REQUEST['idartlang']);
 97:                 $fileListId = cSecurity::toInteger($_REQUEST['id']);
 98:                 $dirname = cSecurity::toString($_REQUEST['dir']);
 99: 
100:                 $clientId = cRegistry::getClientId();
101:                 $cfgClient = cRegistry::getClientConfig($clientId);
102:                 $uplPath = $cfgClient['upl']['path'];
103: 
104:                 $art = new cApiArticleLanguage($idartlang);
105:                 $content = $art->getContent('CMS_FILELIST', $fileListId);
106: 
107:                 $fileList = new cContentTypeFilelist($content, $fileListId, array());
108:                 $directoryList = $fileList->buildDirectoryList($uplPath . $dirname);
109:                 $string = $fileList->generateDirectoryList($directoryList);
110:                 break;
111: 
112:             case 'imgdirlist':
113: 
114:                 $idartlang  = cSecurity::toInteger($_REQUEST['idartlang']);
115:                 $fileListId = cSecurity::toInteger($_REQUEST['id']);
116:                 $dirname    = cSecurity::toString($_REQUEST['dir']);
117: 
118:                 $clientId  = cRegistry::getClientId();
119:                 $cfgClient = cRegistry::getClientConfig($clientId);
120:                 $uplPath   = $cfgClient['upl']['path'];
121: 
122:                 $art     = new cApiArticleLanguage($idartlang);
123:                 $content = $art->getContent('CMS_IMGEDITOR', $fileListId);
124: 
125:                 $fileList      = new cContentTypeImgeditor($content, $fileListId, []);
126:                 $directoryList = $fileList->buildDirectoryList($uplPath . $dirname);
127:                 $string = $fileList->generateDirectoryList($directoryList);
128:                 break;
129: 
130:             case 'filelist':
131:                 $idartlang  = cSecurity::toInteger($_REQUEST['idartlang']);
132:                 $fileListId = cSecurity::toInteger($_REQUEST['id']);
133:                 $dirname    = cSecurity::toString($_REQUEST['dir']);
134: 
135:                 $art = new cApiArticleLanguage($idartlang);
136:                 $content = $art->getContent('CMS_FILELIST', $fileListId);
137: 
138:                 $fileList = new cContentTypeFilelist($content, $fileListId, array());
139:                 $string = $fileList->generateFileSelect($dirname);
140:                 break;
141: 
142:             case 'inused_layout':
143:                 global $cfg;
144:                 if (0 < (int) $_REQUEST['id']) {
145:                     $layout = new cApiLayout((int) $_REQUEST['id']);
146:                     if ($layout->isInUse(true)) {
147:                         $template = new cTemplate();
148:                         $usedTemplates = $layout->getUsedTemplates();
149:                         if (count($usedTemplates) > 0) {
150:                             foreach ($usedTemplates as $i => $usedTemplate) {
151:                                 if ($i % 2 == 0) {
152:                                     $template->set('d', 'CLASS', 'grey');
153:                                 } else {
154:                                     $template->set('d', 'CLASS', 'white');
155:                                 }
156:                                 $template->set('d', 'NAME', $usedTemplate['tpl_name']);
157:                                 $template->next();
158:                             }
159: 
160:                             $string = '<div class="inuse_info" >' . $template->generate($backendPath . $cfg['path']['templates'] . $cfg['templates']['inuse_lay_mod'], true) . '</div>';
161:                         } else {
162:                             $string = i18n('No data found!');
163:                         }
164:                     }
165:                 }
166:                 break;
167: 
168:             case 'inused_module':
169:                 global $cfg;
170:                 $module = new cApiModule();
171:                 if ((int) $_REQUEST['id'] > 0 && $module->moduleInUse((int) $_REQUEST['id'], true)) {
172:                     $template = new cTemplate();
173:                     $usedTemplates = $module->getUsedTemplates();
174:                     if (count($usedTemplates) > 0) {
175:                         foreach ($usedTemplates as $i => $usedTemplate) {
176:                             if ($i % 2 == 0) {
177:                                 $template->set('d', 'CLASS', 'grey');
178:                             } else {
179:                                 $template->set('d', 'CLASS', 'white');
180:                             }
181: 
182:                             $template->set('d', 'NAME', $usedTemplate['tpl_name']);
183:                             $template->next();
184:                         }
185: 
186:                         $string = '<div class="inuse_info" >' . $template->generate($backendPath . $cfg['path']['templates'] . $cfg['templates']['inuse_lay_mod'], true) . '</div>';
187:                     } else {
188:                         $string = i18n('No data found!');
189:                     }
190:                 }
191:                 break;
192: 
193:             case 'inused_template':
194:                 global $cfg;
195:                 cInclude('backend', 'includes/functions.tpl.php');
196: 
197:                 if ((int) $_REQUEST['id'] > 0) {
198:                     $response = '';
199:                     $usedData = tplGetInUsedData((int) $_REQUEST['id']);
200: 
201:                     $template = new cTemplate();
202:                     $template->reset();
203: 
204:                     if (isset($usedData['cat'])) {
205:                         $template->set('s', 'HEAD_TYPE', i18n('Category'));
206:                         foreach ($usedData['cat'] as $i => $cat) {
207:                             $template->set('d', 'ID', $cat['idcat']);
208:                             $template->set('d', 'LANG', $cat['lang']);
209:                             $template->set('d', 'NAME', $cat['name']);
210:                             $template->next();
211:                         }
212:                         $template->set('s', 'HEAD_ID', i18n('idcat'));
213:                         $template->set('s', 'HEAD_LANG', i18n('idlang'));
214:                         $template->set('s', 'HEAD_NAME', i18n('Name'));
215:                         $response = $template->generate($backendPath . $cfg['path']['templates'] . $cfg['templates']['inuse_tpl'], true);
216:                     }
217: 
218:                     $template->reset();
219: 
220:                     if (isset($usedData['art'])) {
221:                         $template->set('s', 'HEAD_TYPE', i18n('Article'));
222:                         foreach ($usedData['art'] as $i => $aArt) {
223:                             $template->set('d', 'ID', $aArt['idart']);
224:                             $template->set('d', 'LANG', $aArt['lang']);
225:                             $template->set('d', 'NAME', $aArt['title']);
226:                             $template->next();
227:                         }
228:                         $template->set('s', 'HEAD_ID', i18n('idart'));
229:                         $template->set('s', 'HEAD_LANG', i18n('idlang'));
230:                         $template->set('s', 'HEAD_NAME', i18n('Name'));
231:                         $response .= $template->generate($backendPath . $cfg['path']['templates'] . $cfg['templates']['inuse_tpl'], true);
232:                     }
233: 
234:                     $string = '<div class="inuse_info" >' . $response . '</div>';
235:                 } else {
236:                     $string = i18n('No data found!');
237:                 }
238: 
239:                 break;
240: 
241:             case 'scaleImage':
242:                 // Access to frontend configuration only when needed, clients config may not available everywhere in the backend
243:                 $frontendURL = cRegistry::getFrontendUrl();
244:                 $frontendPath = cRegistry::getFrontendPath();
245: 
246:                 $filename_a = $_REQUEST['url'];
247:                 $filename = str_replace($frontendURL, $frontendPath, $filename_a);
248:                 // $filename muss not url path(http://) sondern globale PC
249:                 // Path(c:/) sein.
250:                 $filetype = cString::getPartOfString($filename, cString::getStringLength($filename) - 4, 4);
251:                 switch (cString::toLowerCase($filetype)) {
252:                     case '.gif':
253:                         $string = cApiImgScale($filename, 428, 210);
254:                         break;
255:                     case '.png':
256:                         $string = cApiImgScale($filename, 428, 210);
257:                         break;
258:                     case '.jpg':
259:                         $string = cApiImgScale($filename, 428, 210);
260:                         break;
261:                     case 'jpeg':
262:                         $string = cApiImgScale($filename, 428, 210);
263:                         break;
264:                     default:
265:                         $string = $filename_a;
266:                         break;
267:                 }
268:                 // if can not scale, so $string is NULL, then show the
269:                 // original image
270:                 if ($string == '') {
271:                     $filename = str_replace($frontendPath, $frontendURL, $filename_a);
272:                     $string = $filename;
273:                 }
274:                 break;
275: 
276:             case 'imagelist':
277:                 $dirName = (string) $_REQUEST['dir'];
278:                 $imageId = (int) $_REQUEST['id'];
279:                 $idArtLang = (int) $_REQUEST['idartlang'];
280: 
281:                 $art = new cApiArticleLanguage($idArtLang);
282:                 $artReturn = $art->getContent('CMS_IMGEDITOR', $imageId);
283:                 $image = new cContentTypeImgeditor($artReturn, $imageId, array());
284: 
285:                 $string = $image->generateFileSelect($dirName);
286:                 break;
287: 
288:             case 'inlineeditart':
289: 
290:                 $languageCollection = new cApiArticleLanguageCollection();
291: 
292:                 for ($i = 0; $i < count($_REQUEST['fields']); $i++) {
293: 
294:                     $idartlang = $languageCollection->getIdByArticleIdAndLanguageId(cSecurity::toInteger($_REQUEST['fields'][$i]['idart']), cRegistry::getLanguageId());
295: 
296:                     $artLang = new cApiArticleLanguage(cSecurity::toInteger($idartlang));
297:                     $artLang->set('title', cSecurity::escapeString($_REQUEST['fields'][$i]['title']));
298:                     $artLang->set('artsort', cSecurity::escapeString($_REQUEST['fields'][$i]['index']));
299:                     $artLang->store();
300:                 }
301: 
302:                 break;
303: 
304:             case 'loadImageMeta':
305:                 $imageId = (int) $_REQUEST['id'];
306:                 $idArtLang = (int) $_REQUEST['idartlang'];
307: 
308:                 $art = new cApiArticleLanguage($idArtLang);
309:                 $artReturn = $art->getContent('CMS_IMGEDITOR', $imageId);
310:                 $image = new cContentTypeImgeditor($artReturn, $imageId, array());
311: 
312:                 $filename = (string) basename($_REQUEST['filename']);
313:                 $dirname = (string) dirname($_REQUEST['filename']);
314:                 if ($dirname != '.') {
315:                     $dirname .= '/';
316:                 } else {
317:                     $dirname = '';
318:                 }
319: 
320:                 $string = $image->getImageMeta($filename, $dirname);
321:                 break;
322: 
323:             case 'upl_mkdir':
324:                 $imageId = (int) $_REQUEST['id'];
325:                 $idArtLang = (int) $_REQUEST['idartlang'];
326:                 $path = (string) $_REQUEST['path'];
327:                 $name = (string) $_REQUEST['foldername'];
328: 
329:                 $art = new cApiArticleLanguage($idArtLang);
330:                 $artReturn = $art->getContent('CMS_IMGEDITOR', $imageId);
331:                 $image = new cContentTypeImgeditor($artReturn, $imageId, array());
332: 
333:                 $string = $image->uplmkdir($path, $name);
334:                 switch ($string) {
335:                     case 1:
336:                         break;
337:                     case '0702':
338:                         $string = i18n('Directory already exist.');
339:                         break;
340:                     case '0703':
341:                         $string = i18n('Directories with special characters and spaces are not allowed.');
342:                         break;
343:                     case '0704':
344:                         $string = i18n('Can not write directory.');
345:                         break;
346:                 }
347:                 break;
348: 
349:             case 'upl_upload':
350:                 $imageId = (int) $_REQUEST['id'];
351:                 $idArtLang = (int) $_REQUEST['idartlang'];
352:                 $path = (string) $_REQUEST['path'];
353:                 if ($path == '/') {
354:                     $path = '';
355:                 }
356: 
357:                 $art = new cApiArticleLanguage($idArtLang);
358:                 $artReturn = $art->getContent('CMS_IMGEDITOR', $imageId);
359:                 $image = new cContentTypeImgeditor($artReturn, $imageId, array());
360: 
361:                 $string = $image->uplupload($path);
362:                 break;
363: 
364:             case 'linkeditorarticleslist':
365:                 $id = (int) $_REQUEST['id'];
366:                 $idArtLang = (int) $_REQUEST['idartlang'];
367:                 $idCat = (string) $_REQUEST['idcat'];
368: 
369:                 $art = new cApiArticleLanguage($idArtLang);
370:                 $artReturn = $art->getContent('CMS_LINKEDITOR', $id);
371:                 $linkEditor = new cContentTypeLinkeditor($artReturn, $id, array());
372: 
373:                 if ($idCat === '') {
374:                     $activeIdcats = $linkEditor->getActiveIdcats();
375:                     $idCat        = $activeIdcats[0];
376:                 }
377: 
378:                 $string = $linkEditor->generateArticleSelect($idCat);
379:                 break;
380: 
381:             case 'linkeditordirlist':
382:                 $id = (int) $_REQUEST['id'];
383:                 $idArtLang = (int) $_REQUEST['idartlang'];
384:                 $levelId = (string) $_REQUEST['level'];
385:                 $parentidcat = (string) $_REQUEST['parentidcat'];
386: 
387:                 $art = new cApiArticleLanguage($idArtLang);
388:                 $artReturn = $art->getContent('CMS_LINKEDITOR', $id);
389:                 $linkEditor = new cContentTypeLinkeditor($artReturn, $id, array());
390: 
391:                 $string = $linkEditor->getCategoryList($linkEditor->buildCategoryArray($levelId, $parentidcat));
392:                 break;
393: 
394:             case 'linkeditorimagelist':
395:                 $dirName = (string) $_REQUEST['dir'];
396:                 $id = (int) $_REQUEST['id'];
397:                 $idArtLang = (int) $_REQUEST['idartlang'];
398: 
399:                 $art = new cApiArticleLanguage($idArtLang);
400:                 $artReturn = $art->getContent('CMS_LINKEDITOR', $id);
401:                 $linkEditor = new cContentTypeLinkeditor($artReturn, $id, array());
402: 
403:                 if ($dirName === '') {
404:                     $dirName = dirname($linkEditor->getFilename());
405:                 }
406: 
407:                 $string = $linkEditor->getUploadFileSelect($dirName);
408:                 break;
409: 
410:             case 'generaljstranslations':
411:                 $translations = array();
412:                 $translations['Confirmation Required'] = i18n('Confirmation Required');
413:                 $translations['OK'] = i18n('OK');
414:                 $translations['Cancel'] = i18n('Cancel');
415:                 $string = json_encode($translations);
416:                 break;
417: 
418:             case 'logfilecontent':
419:                 $type = cSecurity::escapeString($_REQUEST['logfile']);
420:                 $numberOfLines = cSecurity::toInteger($_REQUEST['numberOfLines']);
421:                 $cfg = cRegistry::getConfig();
422:                 if (in_array($type, $cfg['system_log']['allowed_filenames'])) {
423:                     $filename = $cfg['path']['frontend'] . DIRECTORY_SEPARATOR . $cfg['path']['logs'] . $type;
424:                     $lines = file($filename);
425:                     $lines = array_splice($lines, $numberOfLines * -1);
426:                     $string = implode('', $lines);
427:                 }
428:                 break;
429: 
430:             case 'updatepluginorder':
431:                 // only sysadmins can do this
432:                 if (cRegistry::getPerm()->have_perm()) {
433:                     $newOrder = cSecurity::toInteger($_POST['neworder']);
434:                     $pluginColl = new PimPluginCollection();
435:                     $pluginColl->select();
436:                     if ($newOrder <= 0 || $newOrder > $pluginColl->count()) {
437:                         $string = 'order must be > 0 and <= number of plugins';
438:                         break;
439:                     }
440: 
441:                     $pluginId = cSecurity::toInteger($_POST['idplugin']);
442:                     $plugin = new PimPlugin($pluginId);
443:                     $result = $plugin->updateExecOrder($newOrder);
444:                     if ($result === true) {
445:                         $string = 'ok';
446:                     }
447:                 } else {
448:                     $string = 'Unknown Ajax Action';
449:                 }
450:                 break;
451: 
452:             case 'verify_module':
453:                 $idmod = isset($_POST['idmod']) ? $_POST['idmod'] : NULL;
454:                 $inputType = isset($_POST['type']) ? $_POST['type'] : NULL;
455: 
456:                 // @see CON-2425 modules are checked by default
457:                 $moduleCheck = getSystemProperty('system', 'modulecheck');
458:                 $moduleCheck = ($moduleCheck == '' && $moduleCheck != 'false') || $moduleCheck == 'true' || $moduleCheck == '1';
459: 
460:                 $result = array(
461:                     'state' => 'ok',
462:                     'message' => i18n("Module successfully compiled")
463:                 );
464: 
465:                 if ($idmod && $inputType && $moduleCheck) {
466:                     $contenidoModuleHandler = new cModuleHandler($idmod);
467:                     switch ($inputType) {
468:                         case 'input':
469:                             $result = $contenidoModuleHandler->testInput();
470:                             break;
471:                         case 'output':
472:                             $result = $contenidoModuleHandler->testOutput();
473:                             break;
474:                         default:
475:                             $result = array(
476:                                 'state' => 'error',
477:                                 'message' => 'No cModuleHandler for ' . $idmod . ', or wrong code type: ' . $inputType
478:                             );
479:                     }
480: 
481:                     // create answer
482:                     if ($result['state']) {
483:                         $result['state'] = 'ok';
484:                         $result['message'] = i18n("Module successfully compiled");
485:                     } else {
486:                         $result['state'] = 'error';
487:                         $result['message'] = $result['errorMessage'];
488:                     }
489:                 }
490: 
491:                 $string = json_encode($result);
492:                 break;
493: 
494:             case 'authentication_fail':
495:                 $string = json_encode(array(
496:                     'state' => 'error',
497:                     'code' => 401,
498:                     'message' => 'Unauthorized',
499:                     'type' => 'authentication_failure'
500:                 ));
501:                 break;
502:             case 'custom':
503:                 $string = cApiCecHook::executeAndReturn('Contenido.AjaxMain.CustomCall', $_REQUEST['method']);
504:                 if($string === NULL) {
505:                     $string = 'Unknown Custom Ajax Action';
506:                 }
507:                 break;
508:             default:
509:                 // If action is unknown generate error message
510:                 $string = 'Unknown Ajax Action';
511:                 break;
512:         }
513: 
514:         return $string;
515:     }
516: 
517: }
518: 
CMS CONTENIDO 4.10.1 API documentation generated by ApiGen 2.8.0