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
  • Function
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the backend page for displaying all content of an article.
  4:  *
  5:  * @package Core
  6:  * @subpackage Backend
  7:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author Fulai Zhang
 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: $backendPath = cRegistry::getBackendPath();
 19: $backendUrl = cRegistry::getBackendUrl();
 20: 
 21: cInclude('includes', 'functions.str.php');
 22: cInclude('includes', 'functions.pathresolver.php');
 23: 
 24: if (!isset($idcat)) {
 25:     cRegistry::shutdown();
 26:     return;
 27: }
 28: 
 29: $edit = 'true';
 30: $scripts = '';
 31: // export only these content types
 32: $allowedContentTypes = array(
 33:     "CMS_HTMLHEAD",
 34:     "CMS_HTML",
 35:     "CMS_TEXT",
 36:     "CMS_LINK",
 37:     "CMS_LINKTARGET",
 38:     "CMS_LINKDESCR",
 39:     "CMS_HEAD",
 40:     "CMS_DATE",
 41:     "CMS_RAW"
 42: );
 43: 
 44: $page = new cGuiPage("con_content_list");
 45: 
 46: if (!($perm->have_perm_area_action($area, "savecontype") || $perm->have_perm_area_action_item($area, "savecontype", $idcat) || $perm->have_perm_area_action("con", "deletecontype") || $perm->have_perm_area_action_item("con", "deletecontype", $idcat))) {
 47:     // $page->displayCriticalError(i18n("Permission denied")); (Apparently one of the action files already displays this error message)
 48:     $page->abortRendering();
 49:     $page->render();
 50:     die();
 51: }
 52: 
 53: // save / set value
 54: if (($action == 'savecontype' || $action == 10)) {
 55:     if ($perm->have_perm_area_action($area, "savecontype") || $perm->have_perm_area_action_item($area, "savecontype", $idcat)) {
 56:         if ($data != '') {
 57:             $data = explode('||', substr($data, 0, -2));
 58:             foreach ($data as $value) {
 59:                 $value = explode('|', $value);
 60:                 if ($value[3] == '%$%EMPTY%$%') {
 61:                     $value[3] = '';
 62:                 } else {
 63:                     $value[3] = str_replace('%$%SEPERATOR%$%', '|', $value[3]);
 64:                 }
 65:                 conSaveContentEntry($value[0], 'CMS_' . $value[1], $value[2], $value[3]);
 66:             }
 67: 
 68:             conMakeArticleIndex($idartlang, $idart);
 69: 
 70:             // restore orginal values
 71:             $data = $_REQUEST['data'];
 72:             $value = $_REQUEST['value'];
 73: 
 74:             $notification->displayNotification("info", i18n("Changes saved"));
 75:         }
 76: 
 77:         conGenerateCodeForArtInAllCategories($idart);
 78:     } else {
 79:         $page->displayError(i18n("Permission denied"));
 80:     }
 81: } else if ($action == 'deletecontype') {
 82:     if ($perm->have_perm_area_action($Area, "deletecontype") || $perm->have_perm_area_action_item($area, "deletecontype", $idcat)) {
 83:        if (isset($_REQUEST['idcontent']) && is_numeric($_REQUEST['idcontent'])) {
 84:             $oContentColl = new cApiContentCollection();
 85: 
 86:             $linkedTypes = array(
 87:                 4 => 22, // if a CMS_IMG is deleted, the corresponding
 88:                          // CMS_IMAGEEDITOR will be deleted too
 89:                 22 => 4 // the same goes for the other way round
 90:             );
 91: 
 92:             $contentItem = new cApiContent((int) $_REQUEST["idcontent"]);
 93:             if (isset($linkedTypes[$contentItem->get("idtype")])) {
 94:                 $linkedIds = $oContentColl->getIdsByWhereClause("`idartlang`='" . $idartlang . "' AND `idtype`='" . $linkedTypes[$contentItem->get("idtype")] . "' AND `value`='" . $contentItem->get("value") . "'");
 95:                 foreach ($linkedIds as $linkedId) {
 96:                     $oContentColl->delete($linkedId);
 97:                 }
 98:             }
 99:             $oContentColl->delete((int) $_REQUEST['idcontent']);
100:             $notification->displayNotification("info", i18n("Changes saved"));
101: 
102:             conGenerateCodeForArtInAllCategories($idart);
103:         }
104:     } else {
105:         $page->displayError(i18n("Permission denied"));
106:     }
107: } else if ($action == 'exportrawcontent') {
108: 
109:     // extended class to add CDATA to content
110:     class SimpleXMLExtended extends SimpleXMLElement{
111:         public function addCData($cdata_text){
112:             $node= dom_import_simplexml($this);
113:             $no = $node->ownerDocument;
114:             $node->appendChild($no->createCDATASection($cdata_text));
115:         }
116:     }
117: 
118:     // load article language object
119:     $cApiArticleLanguage = new cApiArticleLanguage(cSecurity::toInteger($idartlang));
120:     // create xml element articles
121:     $articleElement = new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><articles></articles>');
122: 
123:     // add child element article
124:     $articleNode = $articleElement->addChild("article");
125:     $articleNode->addAttribute("id", $cApiArticleLanguage->get('idart'));
126: 
127:     // add seo infos to xml
128:     $titleNode = $articleNode->addChild("title");
129:     $titleNode->addCData($cApiArticleLanguage->get('title'));
130: 
131:     $summaryNode = $articleNode->addChild("shortdesc");
132:     $summaryNode->addCData($cApiArticleLanguage->get('summary'));
133: 
134:     $pageTitleNode = $articleNode->addChild("seo_title");
135:     $pageTitleNode->addCData($cApiArticleLanguage->get('pagetitle'));
136: 
137:     $seoDescrNode = $articleNode->addChild("seo_description");
138:     $seoDescrNode->addCData(conGetMetaValue($cApiArticleLanguage->get('idartlang'), 3));
139: 
140:     $keywordsNode = $articleNode->addChild("seo_keywords");
141:     $keywordsNode->addCData(conGetMetaValue($cApiArticleLanguage->get('idartlang'), 5));
142: 
143:     $copyrightNode = $articleNode->addChild("seo_copyright");
144:     $copyrightNode->addCData(conGetMetaValue($cApiArticleLanguage->get('idartlang'), 8));
145: 
146:     $seoauthorNode = $articleNode->addChild("seo_author");
147:     $seoauthorNode->addCData(conGetMetaValue($cApiArticleLanguage->get('idartlang'), 1));
148: 
149:     // load content id's for article
150:     $conColl = new cApiContentCollection();
151:     $contentIds = $conColl->getIdsByWhereClause('idartlang="'. $cApiArticleLanguage->get("idartlang") .'"');
152: 
153:     // iterate through content and add get data
154:     foreach ($contentIds as $contentId) {
155:         //load content object
156:         $content = new cApiContent($contentId);
157:         // if loaded get data and add to xml
158:         if($content->isLoaded()) {
159:             $type = new cApiType($content->get("idtype"));
160: 
161:             if($type->isLoaded() && in_array($type->get("type"), $allowedContentTypes)) {
162:                 foreach ($_POST as $key => $contentType) {
163:                     if($key == $type->get("type") && $contentType == $content->get("typeid")) {
164:                         //create content element
165:                         $contentNode = $articleNode->addChild("content");
166:                         $contentNode->addCData($content->get("value"));
167:                         $contentNode->addAttribute("type", $type->get("type"));
168:                         $contentNode->addAttribute("id", $content->get("typeid"));
169:                     }
170:                 }
171:             }
172: 
173:         }
174:     }
175:     // output data as xml
176:     header('Content-Type: application/xml;');
177:     header('Content-Disposition: attachment; filename='.$cApiArticleLanguage->get('title').';');
178:     ob_clean();
179:     echo $articleElement->asXML();
180:     exit;
181: } else if ($action == "importrawcontent") {
182:     // import raw data into article
183: 
184:     // init vars
185:     $error = false;
186: 
187:     //get file from request
188:     $rawDataFile = $_FILES['rawfile']['tmp_name'];
189: 
190:     // check file exist
191:     if(strlen($rawDataFile) > 0 && isset($_FILES['rawfile'])) {
192: 
193:         // read file from tmp upload folder
194:         $rawData = file_get_contents($rawDataFile);
195: 
196:         // try init xml and import data
197:         try {
198:             $xmlDocument = new SimpleXMLElement($rawData);
199: 
200:             foreach ($xmlDocument->children() as $articleNode) {
201:                 $articleId = $articleNode->attributes()->id;
202: 
203:                 // check article id exists in xml
204:                 if($articleId > 0) {
205: 
206:                     // load article by artice id and language
207:                     $articleLanguage = new cApiArticleLanguage();
208:                     $articleLanguage->loadByMany(array("idart" => $articleId, "idlang" => cRegistry::getLanguageId()));
209: 
210:                     // check is article loaded
211:                     if($articleLanguage->isLoaded()) {
212: 
213:                         // read xml childrens
214:                         foreach ($articleNode->children() as $key => $child) {
215: 
216:                             // switch xml tag and exec business logic
217:                             switch ($key) {
218:                                 case 'title':
219:                                     $articleLanguage->set("title", $child);
220:                                     $articleLanguage->store();
221: 
222:                                     break;
223:                                 case 'shortdesc':
224:                                     $articleLanguage->set("summary", $child);
225:                                     $articleLanguage->store();
226: 
227:                                     break;
228:                                 case 'seo_title':
229:                                     $articleLanguage->set("pagetitle", $child);
230:                                     $articleLanguage->store();
231: 
232:                                     break;
233:                                 case 'seo_description':
234:                                     conSetMetaValue($articleLanguage->get('idartlang'), 3, $child);
235: 
236:                                     break;
237:                                 case 'seo_keywords':
238:                                     conSetMetaValue($articleLanguage->get('idartlang'), 5, $child);
239: 
240:                                     break;
241:                                 case 'seo_copyright':
242:                                     conSetMetaValue($articleLanguage->get('idartlang'), 8, $child);
243: 
244:                                     break;
245:                                 case 'seo_author':
246:                                     conSetMetaValue($articleLanguage->get('idartlang'), 1, $child);
247: 
248:                                     break;
249:                                 case 'content':
250:                                     $type = $child->attributes()->type;
251:                                     $typeid  = $child->attributes()->id;
252: 
253:                                     $typeEntry = new cApiType();
254:                                     $typeEntry->loadBy("type", $type);
255: 
256:                                     if(strlen($type) > 0 && $typeid > 0 && in_array($typeEntry->get("type"), $allowedContentTypes)) {
257:                                         if(isset($_POST['overwritecontent']) && $_POST['overwritecontent'] == 1) {
258:                                             conSaveContentEntry($articleLanguage->get('idartlang'), $type, $typeid, $child);
259:                                         } else {
260: 
261:                                             $contentEntry = new cApiContent();
262: 
263:                                             $contentEntry->loadByMany(array("idtype" => $typeEntry->get("idtype"), "typeid" => $typeid, "idartlang" => $articleLanguage->get('idartlang')));
264:                                             if(!$contentEntry->isLoaded()) {
265:                                                 conSaveContentEntry($articleLanguage->get('idartlang'), $type, $typeid, $child);
266:                                             }
267:                                         }
268:                                     } else {
269: 
270:                                     }
271: 
272:                                     break;
273:                                 case 'default':
274:                                     break;
275:                             }
276: 
277:                         }
278: 
279:                     } else {
280:                         $page->displayError(i18n("Can not load article"));
281:                         $error = true;
282:                     }
283:                 } else {
284:                     $page->displayError(i18n("Can not find article"));
285:                     $error = true;
286: 
287:                 }
288:             }
289:             if($error === false) {
290:                 $page->displayInfo(i18n("Raw data was imported successfully"));
291:             }
292: 
293:         } catch (Exception $e) {
294:             $page->displayError(i18n("Error: The XML file is not valid"));
295:         }
296:     } else {
297:         $page->displayWarning(i18n("Please choose a file"));
298:     }
299: 
300: }
301: 
302: // get active value
303: 
304: $result = array();
305: $aList = array();
306: $currentTypes = array();
307: $sortID = array(
308:     "CMS_HTMLHEAD",
309:     "CMS_HEAD",
310:     "CMS_HTML",
311:     "CMS_TEXT",
312:     "CMS_IMG",
313:     "CMS_IMGDESCR",
314:     "CMS_IMGEDITOR",
315:     "CMS_LINK",
316:     "CMS_LINKTARGET",
317:     "CMS_LINKDESCR",
318:     "CMS_LINKEDITOR",
319:     "CMS_DATE",
320:     "CMS_TEASER",
321:     "CMS_FILELIST",
322:     "CMS_RAW"
323: );
324: 
325: $aIdtype = array();
326: $sql = "SELECT DISTINCT typeid FROM %s WHERE idartlang = %d ORDER BY typeid";
327: $db->query($sql, $cfg["tab"]["content"], $_REQUEST["idartlang"]);
328: while ($db->nextRecord()) {
329:     $aIdtype[] = $db->f("typeid");
330: }
331: 
332: foreach ($sortID as $name) {
333:     // $sql = "SELECT b.idtype as idtype, b.type as name, a.typeid as id,
334:     // a.value as value FROM " . $cfg["tab"]["content"] . " as a, " .
335:     // $cfg["tab"]["type"] . " as b WHERE a.idartlang = " .
336:     // cSecurity::toInteger($_REQUEST["idartlang"]) . " AND a.idtype = b.idtype
337:     // AND b.type = '" . cSecurity::toString($name) . "' ORDER BY idtype,
338:     // typeid, idcontent";
339:     $sql = "SELECT b.idtype as idtype, b.type as name, a.typeid as id, a.value as value FROM %s AS a, %s AS b " . "WHERE a.idartlang = %d AND a.idtype = b.idtype AND b.type = '%s' ORDER BY idtype, typeid, idcontent";
340:     $db->query($sql, $cfg["tab"]["content"], $cfg["tab"]["type"], $_REQUEST["idartlang"], $name);
341:     while ($db->nextRecord() && $db->f("value") != '') {
342:         $result[$db->f("name")][$db->f("id")] = $db->f("value");
343:         if (!in_array($db->f("name"), $aList)) {
344:             $aList[$db->f("idtype")] = $db->f("name");
345:         }
346:     }
347: }
348: 
349: $currentTypes = _getCurrentTypes($currentTypes, $aList);
350: // print_r($currentTypes);
351: // create Layoutcode
352: // if ($action == 'con_content') {
353: // @fulai.zhang: Mark submenuitem 'Editor' in the CONTENIDO Backend (Area:
354: // Contenido --> Articles --> Editor)
355: $markSubItem = markSubMenuItem(4, true);
356: 
357: // Include tiny class
358: include($backendPath . 'external/wysiwyg/tinymce3/editorclass.php');
359: $oEditor = new cTinyMCEEditor('', '');
360: $oEditor->setToolbar('inline_edit');
361: 
362: // Get configuration for popup und inline tiny
363: $sConfigInlineEdit = $oEditor->getConfigInlineEdit();
364: $sConfigFullscreen = $oEditor->getConfigFullscreen();
365: 
366: // Replace vars in Script
367: 
368: // Set urls to file browsers
369: $page->set('s', 'IMAGE', $backendUrl . 'frameset.php?area=upl&contenido=' . $sess->id . '&appendparameters=imagebrowser');
370: $page->set('s', 'FILE', $backendUrl . 'frameset.php?area=upl&contenido=' . $sess->id . '&appendparameters=filebrowser');
371: $page->set('s', 'FLASH', $backendUrl . 'frameset.php?area=upl&contenido=' . $sess->id . '&appendparameters=imagebrowser');
372: $page->set('s', 'MEDIA', $backendUrl . 'frameset.php?area=upl&contenido=' . $sess->id . '&appendparameters=imagebrowser');
373: $page->set('s', 'FRONTEND', cRegistry::getFrontendUrl());
374: 
375: // Add tiny options
376: $page->set('s', 'TINY_OPTIONS', $sConfigInlineEdit);
377: $page->set('s', 'TINY_FULLSCREEN', $sConfigFullscreen);
378: $page->set('s', 'IDARTLANG', $idartlang);
379: $page->set('s', 'CLOSE', i18n('Close editor'));
380: $page->set('s', 'SAVE', i18n('Close editor and save changes'));
381: $page->set('s', 'QUESTION', i18n('Do you want to save changes?'));
382: 
383: // Add export and import tarnslations
384: $page->set('s', 'EXPORT_RAWDATA', i18n("Export raw data"));
385: $page->set('s', 'IMPORT_RAWDATA', i18n("Import raw data"));
386: $page->set('s', 'EXPORT_LABEL', i18n("Raw data export"));
387: $page->set('s', 'IMPORT_LABEL', i18n("Raw data import"));
388: $page->set('s', 'OVERWRITE_DATA_LABEL', i18n("Overwrite data"));
389: 
390: 
391: if (getEffectiveSetting('system', 'insite_editing_activated', 'true') == 'false') {
392:     $page->set('s', 'USE_TINY', '');
393: } else {
394:     $page->set('s', 'USE_TINY', '1');
395: }
396: 
397: // Show path of selected category to user
398: $breadcrumb = renderBackendBreadcrumb($syncoptions, true, true);
399: $page->set('s', 'CATEGORY', $breadcrumb);
400: 
401: if (count($result) <= 0) {
402:     $page->displayInfo(i18n("Article has no raw data"));
403:     $page->abortRendering();
404:     // $layoutcode .= '<div>--- ' . i18n("none") . ' ---</div>';
405: } else {
406:     foreach ($aIdtype as $idtype) {
407:         foreach ($sortID as $name) {
408:             if (in_array($name, array_keys($result)) && $result[$name][$idtype] != '') {
409:                 if (in_array($name . "[" . $idtype . "]", $currentTypes)) {
410:                     $class = '';
411:                 } else {
412:                     $class = ' noactive';
413:                 }
414:                 $page->set("d", "EXTRA_CLASS", $class);
415:                 $page->set("d", "NAME", $name);
416:                 $page->set("d", "ID_TYPE", $idtype);
417:                 if(in_array($name, $allowedContentTypes)) {
418:                     $page->set("d", "EXPORT_CONTENT",  '<input type="checkbox" class="rawtypes" name="' . $name .'" value="' .$idtype .'" checked="checked">');
419:                     $page->set('d', 'EXPORT_CONTENT_LABEL', i18n("Export"));
420:                 } else {
421:                     $page->set("d", "EXPORT_CONTENT", '');
422:                     $page->set('d', 'EXPORT_CONTENT_LABEL', '');
423:                 }
424:                 $page->next();
425:             }
426:         }
427:     }
428: }
429: 
430: // breadcrumb onclick
431: if (!isset($syncfrom)) {
432:     $syncfrom = -1;
433: }
434: $syncoptions = $syncfrom;
435: $page->set("s", "SYNCHOPTIONS", $syncoptions);
436: 
437: $page->set("s", "IDART", $idart);
438: $page->set("s", "IDCAT", $idcat);
439: $page->set("s", "IDLANG", $lang);
440: $page->set("s", "IDARTLANG", $idartlang);
441: $page->set("s", "IDCLIENT", $client);
442: 
443: // generate code
444: $code = _processCmsTags($aList, $result, true, $page->render(NULL, true));
445: 
446: if ($code == "0601") {
447:     markSubMenuItem("1");
448:     $code = "<script type='text/javascript'>location.href = '" . $backendUrl . "main.php?frame=4&area=con_content_list&action=con_content&idart=" . $idart . "&idcat=" . $idcat . "&contenido=" . $contenido . "'; /*console.log(location.href);*/</script>";
449: } else {
450:     // inject some additional markup
451:     $code = cString::iReplaceOnce("</head>", "$markSubItem $scripts\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=$encoding[$lang]\"></head>", $code);
452: }
453: 
454: if ($cfg["debug"]["codeoutput"]) {
455:     cDebug::out(conHtmlSpecialChars($code));
456: }
457: 
458: // show ContentTypeList
459: chdir(cRegistry::getFrontendPath());
460: eval("?>\n" . $code . "\n<?php\n");
461: // }
462: 
463: cRegistry::shutdown();
464: 
465: /**
466:  * Processes replacements of all existing CMS_...
467:  * tags within passed code
468:  *
469:  * @param array $aList CMS_...tags list
470:  * @param array $contentList all CMS variables
471:  * @param bool $saveKeywords Flag to save collected keywords during replacement
472:  *        process.
473:  * @param array $contentList Assoziative list of CMS variables
474:  */
475: function _processCmsTags($aList, $contentList, $saveKeywords = true, $layoutCode) {
476:     // #####################################################################
477:     // NOTE: Variables below are required in included/evaluated content type
478:     // codes!
479:     global $db, $db2, $sess, $cfg, $code, $cfgClient, $encoding, $notification;
480: 
481:     // NOTE: Variables below are additionally required in included/evaluated
482:     // content type codes within backend edit mode!
483:     global $edit, $editLink, $belang;
484: 
485:     $idcat = $_REQUEST['idcat'];
486:     $idart = $_REQUEST['idart'];
487:     $lang = $_REQUEST['lang'];
488:     $client = $_REQUEST['client'];
489:     $idartlang = $_REQUEST['idartlang'];
490:     $contenido = $_REQUEST['contenido'];
491: 
492:     // Get locked status (article freeze)
493:     $cApiArticleLanguage = new cApiArticleLanguage(cSecurity::toInteger($idartlang));
494:     $locked = $cApiArticleLanguage->getField('locked');
495: 
496:     // If article is locked show notification
497:     if ($locked == 1) {
498:         $notification->displayNotification('warning', i18n('This article is currently frozen and can not be edited!'));
499:     }
500: 
501:     if (!is_object($db2)) {
502:         $db2 = cRegistry::getDb();
503:     }
504:     // End: Variables required in content type codes
505:     // #####################################################################
506: 
507:     $match = array();
508:     $keycode = array();
509: 
510:     // $a_content is used by included/evaluated content type codes below
511:     $a_content = $contentList;
512: 
513:     // Select all cms_type entries
514:     $_typeList = array();
515:     $oTypeColl = new cApiTypeCollection();
516:     $oTypeColl->select();
517:     while ($oType = $oTypeColl->next()) {
518:         $_typeList[] = $oType->toObject();
519:     }
520: 
521:     // Replace all CMS_TAGS[]
522:     foreach ($_typeList as $_typeItem) {
523:         $key = strtolower($_typeItem->type);
524:         $type = $_typeItem->type;
525:         if (in_array($type, $aList)) {
526:             // Try to find all CMS_{type}[{number}] values, e. g. CMS_HTML[1]
527:             // $tmp = preg_match_all('/(' . $type . ')\[+([a-z0-9_]+)+\]/i',
528:             // $this->_layoutCode, $match);
529:             $tmp = preg_match_all('/(' . $type . '\[+(\d)+\])/i', $layoutCode, $match);
530: 
531:             $a_[$key] = $match[0];
532: 
533:             $success = array_walk($a_[$key], 'extractNumber');
534: 
535:             $search = array();
536:             $replacements = array();
537: 
538:             $backendPath = cRegistry::getBackendPath();
539: 
540:             $typeCodeFile = $backendPath . 'includes/type/code/include.' . $type . '.code.php';
541:             $cTypeClassFile = $backendPath . 'classes/content_types/class.content.type.' . strtolower(str_replace('CMS_', '', $type)) . '.php';
542:             // classname format: CMS_HTMLHEAD -> cContentTypeHtmlhead
543:             $className = 'cContentType' . ucfirst(strtolower(str_replace('CMS_', '', $type)));
544: 
545:             foreach ($a_[$key] as $val) {
546:                 if (cFileHandler::exists($cTypeClassFile)) {
547:                     $tmp = $a_content[$_typeItem->type][$val];
548:                     $cTypeObject = new $className($tmp, $val, $a_content);
549:                     if (cRegistry::isBackendEditMode() && $locked == 0) {
550:                         $tmp = $cTypeObject->generateEditCode();
551:                     } else {
552:                         $tmp = $cTypeObject->generateViewCode();
553:                     }
554:                 } else if (cFileHandler::exists($typeCodeFile)) {
555:                     // include CMS type code
556:                     include($typeCodeFile);
557:                 } elseif (!empty($_typeItem->code)) {
558:                     // old version, evaluate CMS type code
559:                     cDeprecated("Move code for $type from table into file system (contenido/includes/type/code/)");
560:                     eval($_typeItem->code);
561:                 }
562:                 $sql = "SELECT a.idcontent
563:                     FROM " . $cfg["tab"]["content"] . " as a, " . $cfg["tab"]["type"] . " as b
564:                     WHERE a.idartlang=" . cSecurity::toInteger($_REQUEST["idartlang"]) . " AND a.idtype=b.idtype AND a.typeid = " . cSecurity::toInteger($val) . " AND b.type = '" . cSecurity::toString($type) . "'
565:                     ORDER BY a.idartlang, a.idtype, a.typeid";
566:                 $db->query($sql);
567:                 while ($db->nextRecord()) {
568:                     $idcontent = $db->f("idcontent");
569:                 }
570:                 $backendUrl = cRegistry::getBackendUrl();
571: 
572:                 $search[$val] = sprintf('%s[%s]', $type, $val);
573:                 $path = $backendUrl . 'main.php?area=con_content_list&action=deletecontype&changeview=edit&idart=' . $idart . '&idartlang=' . $idartlang . '&idcat=' . $idcat . '&client=' . $client . '&lang=' . $lang . '&frame=4&contenido=' . $contenido . '&idcontent=' . $idcontent;
574:                 if ($_typeItem->idtype == 20 || $_typeItem->idtype == 21) {
575:                     $tmp = str_replace('";?>', '', $tmp);
576:                     $tmp = str_replace('<?php echo "', '', $tmp);
577:                     // echo
578:                     // "<textarea>"."?".">\n".stripslashes($tmp)."\n\";?"."><"."?php\n"."</textarea>";
579:                 }
580: 
581:                 if ($locked == 0) { // No freeze
582:                     $replacements[$val] = $tmp . '<a href="#" onclick="Con.showConfirmation(\'' . i18n("Are you sure you want to delete this content type from this article?") . '\', function() { Con.Tiny.setContent(\'1\',\'' . $path . '\'); });">
583:                 <img border="0" src="' . $backendUrl . 'images/delete.gif">
584:                 </a>';
585:                     $keycode[$type][$val] = $tmp . '<a href="#" onclick="Con.showConfirmation(\'' . i18n("Are you sure you want to delete this content type from this article?") . '\', function() { Con.Tiny.setContent(\'1\',\'' . $path . '\'); });">
586:                 <img border="0" src="' . $backendUrl . 'images/delete.gif">
587:                 </a>';
588:                 } else { // Freeze status
589:                     $replacements[$val] = $tmp;
590:                     $keycode[$type][$val] = $tmp;
591:                 }
592:             }
593: 
594:             $code = str_ireplace($search, $replacements, $layoutCode);
595:             // execute CEC hook
596:             $code = cApiCecHook::executeAndReturn('Contenido.Content.conGenerateCode', $code);
597:             $layoutCode = stripslashes($code);
598:         }
599:     }
600:     $layoutCode = str_ireplace("<<", "[", $layoutCode);
601:     $layoutCode = str_ireplace(">>", "]", $layoutCode);
602:     return $layoutCode;
603: }
604: 
605: /**
606:  * Processes get all existing active CMS_... tags within passed code
607:  *
608:  * @param array $r active CMS variables
609:  * @param array $aList CMS_...tags list
610:  */
611: function _getCurrentTypes($r, $aList) {
612:     $idcat = $_REQUEST['idcat'];
613:     $idart = $_REQUEST['idart'];
614:     $lang = $_REQUEST['lang'];
615:     $client = $_REQUEST['client'];
616:     global $db, $db2, $sess, $cfg, $code, $cfgClient, $encoding;
617: 
618:     // Select all cms_type entries
619:     $_typeList = array();
620:     $oTypeColl = new cApiTypeCollection();
621:     $oTypeColl->select();
622:     while ($oType = $oTypeColl->next()) {
623:         $_typeList[] = $oType->toObject();
624:     }
625: 
626:     // generate code
627:     $code = conGenerateCode($idcat, $idart, $lang, $client, false, false, false);
628:     foreach ($_typeList as $_typeItem) {
629:         $type = $_typeItem->type;
630:         if (in_array($type, $aList)) {
631:             // Try to find all CMS_{type}[{number}] values, e. g. CMS_HTML[1]
632:             $tmp = preg_match_all('/(' . $type . '\[+(\d)+\])/i', $code, $match);
633:             foreach ($match[0] as $s) {
634:                 if (!in_array($s, $r)) {
635:                     array_push($r, $s);
636:                 }
637:             }
638:         }
639:     }
640:     return $r;
641: }
642: 
CMS CONTENIDO 4.9.5 API documentation generated by ApiGen 2.8.0