1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 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:
32:
33: if ($action == 'savecontype' || $action == 10) {
34: if ($data != '') {
35: $data = explode('||', substr($data, 0, -2));
36: foreach ($data as $value) {
37: $value = explode('|', $value);
38: if ($value[3] == '%$%EMPTY%$%') {
39: $value[3] = '';
40: } else {
41: $value[3] = str_replace('%$%SEPERATOR%$%', '|', $value[3]);
42: }
43: conSaveContentEntry($value[0], 'CMS_' . $value[1], $value[2], $value[3]);
44: }
45:
46: conMakeArticleIndex($idartlang, $idart);
47:
48:
49: $data = $_REQUEST['data'];
50: $value = $_REQUEST['value'];
51:
52: $notification->displayNotification("info", i18n("Changes saved"));
53: }
54:
55: conGenerateCodeForArtInAllCategories($idart);
56: } else if ($action == 'deletecontype') {
57: if (isset($_REQUEST['idcontent']) && is_numeric($_REQUEST['idcontent'])) {
58: $oContentColl = new cApiContentCollection();
59:
60: $linkedTypes = array(
61: 4 => 22,
62: 22 => 4
63: );
64:
65: $contentItem = new cApiContent((int) $_REQUEST["idcontent"]);
66: if (isset($linkedTypes[$contentItem->get("idtype")])) {
67: $linkedIds = $oContentColl->getIdsByWhereClause("`idartlang`='" . $idartlang . "' AND `idtype`='" . $linkedTypes[$contentItem->get("idtype")] . "' AND `value`='" . $contentItem->get("value") . "'");
68: foreach ($linkedIds as $linkedId) {
69: $oContentColl->delete($linkedId);
70: }
71: }
72: $oContentColl->delete((int) $_REQUEST['idcontent']);
73: $notification->displayNotification("info", i18n("Changes saved"));
74:
75: conGenerateCodeForArtInAllCategories($idart);
76: }
77: }
78:
79:
80:
81: $result = array();
82: $aList = array();
83: $typeAktuell = array();
84: $sortID = array("CMS_HTMLHEAD", "CMS_HEAD", "CMS_HTML", "CMS_TEXT",
85: "CMS_IMG", "CMS_IMGDESCR", "CMS_IMGEDITOR",
86: "CMS_LINK", "CMS_LINKTARGET", "CMS_LINKDESCR",
87: "CMS_LINKEDITOR",
88: "CMS_DATE", "CMS_TEASER", "CMS_FILELIST");
89:
90: $aIdtype = array();
91: $sql = "SELECT DISTINCT typeid FROM %s WHERE idartlang = %d ORDER BY typeid";
92: $db->query($sql, $cfg["tab"]["content"], $_REQUEST["idartlang"]);
93: while ($db->nextRecord()) {
94: $aIdtype[] = $db->f("typeid");
95: }
96:
97: foreach ($sortID as $name) {
98:
99: $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 "
100: . "WHERE a.idartlang = %d AND a.idtype = b.idtype AND b.type = '%s' ORDER BY idtype, typeid, idcontent";
101: $db->query($sql, $cfg["tab"]["content"], $cfg["tab"]["type"], $_REQUEST["idartlang"], $name);
102: while ($db->nextRecord() && $db->f("value") != '') {
103: $result[$db->f("name")][$db->f("id")] = $db->f("value");
104: if (!in_array($db->f("name"), $aList)) {
105: $aList[$db->f("idtype")] = $db->f("name");
106: }
107: }
108: }
109:
110: $typeAktuell = getAktuellType($typeAktuell, $aList);
111:
112:
113:
114:
115: $markSubItem = markSubMenuItem(5, true);
116:
117:
118: include($backendPath . 'external/wysiwyg/tinymce3/editorclass.php');
119: $oEditor = new cTinyMCEEditor('', '');
120: $oEditor->setToolbar('inline_edit');
121:
122:
123: $sConfigInlineEdit = $oEditor->getConfigInlineEdit();
124: $sConfigFullscreen = $oEditor->getConfigFullscreen();
125:
126: $page = new cGuiPage("con_content_list");
127:
128:
129:
130: $page->set('s', 'CONTENIDO_FULLHTML', $backendUrl);
131:
132:
133: $page->set('s', 'IMAGE', $backendUrl . 'frameset.php?area=upl&contenido=' . $sess->id . '&appendparameters=imagebrowser');
134: $page->set('s', 'FILE', $backendUrl . 'frameset.php?area=upl&contenido=' . $sess->id . '&appendparameters=filebrowser');
135: $page->set('s', 'FLASH', $backendUrl . 'frameset.php?area=upl&contenido=' . $sess->id . '&appendparameters=imagebrowser');
136: $page->set('s', 'MEDIA', $backendUrl . 'frameset.php?area=upl&contenido=' . $sess->id . '&appendparameters=imagebrowser');
137: $page->set('s', 'FRONTEND', cRegistry::getFrontendUrl());
138:
139:
140: $page->set('s', 'TINY_OPTIONS', $sConfigInlineEdit);
141: $page->set('s', 'TINY_FULLSCREEN', $sConfigFullscreen);
142: $page->set('s', 'IDARTLANG', $idartlang);
143: $page->set('s', 'CON_PATH', $backendUrl);
144: $page->set('s', 'CLOSE', i18n('Close editor'));
145: $page->set('s', 'SAVE', i18n('Close editor and save changes'));
146: $page->set('s', 'QUESTION', i18n('Do you want to save changes?'));
147:
148: if (getEffectiveSetting('system', 'insite_editing_activated', 'true') == 'false') {
149: $page->set('s', 'USE_TINY', '');
150: } else {
151: $page->set('s', 'USE_TINY', 'swapTiny(this);');
152: }
153:
154:
155: $breadcrumb = renderBackendBreadcrumb($syncoptions, true, true);
156: $page->set('s', 'CATEGORY', $breadcrumb);
157:
158: if (count($result) <= 0) {
159: $page->displayInfo(i18n("Article has no raw data"));
160: $page->abortRendering();
161:
162: } else {
163: foreach ($aIdtype as $idtype) {
164: foreach ($sortID as $name) {
165: if (in_array($name, array_keys($result)) && $result[$name][$idtype] != '') {
166: if (in_array($name . "[" . $idtype . "]", $typeAktuell)) {
167: $class = '';
168: } else {
169: $class = ' noactive';
170: }
171: $page->set("d", "EXTRA_CLASS", $class);
172: $page->set("d", "NAME", $name);
173: $page->set("d", "ID_TYPE", $idtype);
174: $page->next();
175: }
176: }
177: }
178: }
179:
180:
181: if (!isset($syncfrom)) {
182: $syncfrom = -1;
183: }
184: $syncoptions = $syncfrom;
185: $page->set("s", "SYNCHOPTIONS", $syncoptions);
186:
187: $page->set("s", "IDART", $idart);
188: $page->set("s", "IDCAT", $idcat);
189: $page->set("s", "IDLANG", $lang);
190: $page->set("s", "IDARTLANG", $idartlang);
191: $page->set("s", "IDCLIENT", $client);
192:
193:
194: $code = _processCmsTags($aList, $result, true, $page->render(null, true));
195: ;
196:
197: if ($code == "0601") {
198: markSubMenuItem("1");
199: $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>";
200: } else {
201:
202: $code = cString::iReplaceOnce("</head>", "$markSubItem $scripts\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=$encoding[$lang]\"></head>", $code);
203: }
204:
205: if ($cfg["debug"]["codeoutput"]) {
206: cDebug::out(conHtmlSpecialChars($code));
207: }
208:
209:
210: chdir(cRegistry::getFrontendPath());
211: eval("?>\n" . $code . "\n<?php\n");
212:
213:
214: cRegistry::shutdown();
215:
216: 217: 218: 219: 220: 221: 222: 223:
224: function _processCmsTags($aList, $contentList, $saveKeywords = true, $layoutCode) {
225:
226:
227:
228: global $db, $db2, $sess, $cfg, $code, $cfgClient, $encoding;
229:
230:
231:
232: global $edit, $editLink, $belang;
233:
234: $idcat = $_REQUEST['idcat'];
235: $idart = $_REQUEST['idart'];
236: $lang = $_REQUEST['lang'];
237: $client = $_REQUEST['client'];
238: $idartlang = $_REQUEST['idartlang'];
239: $contenido = $_REQUEST['contenido'];
240:
241: if (!is_object($db2)) {
242: $db2 = cRegistry::getDb();
243: }
244:
245:
246:
247: $match = array();
248: $keycode = array();
249:
250:
251: $a_content = $contentList;
252:
253:
254: $_typeList = array();
255: $oTypeColl = new cApiTypeCollection();
256: $oTypeColl->select();
257: while ($oType = $oTypeColl->next()) {
258: $_typeList[] = $oType->toObject();
259: }
260:
261:
262: foreach ($_typeList as $_typeItem) {
263: $key = strtolower($_typeItem->type);
264: $type = $_typeItem->type;
265: if (in_array($type, $aList)) {
266:
267:
268:
269: $tmp = preg_match_all('/(' . $type . '\[+(\d)+\])/i', $layoutCode, $match);
270:
271: $a_[$key] = $match[0];
272:
273: $success = array_walk($a_[$key], 'extractNumber');
274:
275: $search = array();
276: $replacements = array();
277:
278: $backendPath = cRegistry::getBackendPath();
279:
280: $typeCodeFile = $backendPath . 'includes/type/code/include.' . $type . '.code.php';
281: $cTypeClassFile = $backendPath . 'classes/content_types/class.content.type.' . strtolower(str_replace('CMS_', '', $type)) . '.php';
282:
283: $className = 'cContentType' . ucfirst(strtolower(str_replace('CMS_', '', $type)));
284:
285: foreach ($a_[$key] as $val) {
286: if (cFileHandler::exists($cTypeClassFile)) {
287: $tmp = $a_content[$_typeItem->type][$val];
288: $cTypeObject = new $className($tmp, $val, $a_content);
289: if (cRegistry::isBackendEditMode()) {
290: $tmp = $cTypeObject->generateEditCode();
291: } else {
292: $tmp = $cTypeObject->generateViewCode();
293: }
294: } else if (cFileHandler::exists($typeCodeFile)) {
295:
296: include ($typeCodeFile);
297: } elseif (!empty($_typeItem->code)) {
298:
299: cDeprecated("Move code for $type from table into file system (contenido/includes/cms/code/)");
300: eval($_typeItem->code);
301: }
302: $sql = "SELECT a.idcontent
303: FROM " . $cfg["tab"]["content"] . " as a, " . $cfg["tab"]["type"] . " as b
304: WHERE a.idartlang=" . cSecurity::toInteger($_REQUEST["idartlang"]) .
305: " AND a.idtype=b.idtype AND a.typeid = " . cSecurity::toInteger($val) . " AND b.type = '" . cSecurity::toString($type) . "'
306: ORDER BY a.idartlang, a.idtype, a.typeid";
307: $db->query($sql);
308: while ($db->nextRecord()) {
309: $idcontent = $db->f("idcontent");
310: }
311: $backendUrl = cRegistry::getBackendUrl();
312:
313: $search[$val] = sprintf('%s[%s]', $type, $val);
314: $path = $backendUrl . 'main.php?area=con_content_list&action=deletecontype&changeview=edit&idart=' . $idart . '&idartlang=' . $idartlang .
315: '&idcat=' . $idcat . '&client=' . $client . '&lang=' . $lang . '&frame=4&contenido=' . $contenido . '&idcontent=' . $idcontent;
316: if ($_typeItem->idtype == 20 || $_typeItem->idtype == 21) {
317: $tmp = str_replace('";?>', '', $tmp);
318: $tmp = str_replace('<?php echo "', '', $tmp);
319:
320: }
321: $replacements[$val] = $tmp .
322: '<a href="javascript:setcontent(\'1\',\'' . $path . '\');">
323: <img border="0" src="' . $backendUrl . 'images/delete.gif">
324: </a>';
325: $keycode[$type][$val] = $tmp .
326: '<a href="javascript:setcontent(\'1\',\'' . $path . '\');">
327: <img border="0" src="' . $backendUrl . 'images/delete.gif">
328: </a>';
329: }
330:
331: $code = str_ireplace($search, $replacements, $layoutCode);
332:
333: $code = cApiCecHook::executeAndReturn('Contenido.Content.conGenerateCode', $code);
334: $layoutCode = stripslashes($code);
335: }
336: }
337: $layoutCode = str_ireplace("<<", "[", $layoutCode);
338: $layoutCode = str_ireplace(">>", "]", $layoutCode);
339: return $layoutCode;
340: }
341:
342: 343: 344: 345: 346: 347:
348: function getAktuellType($r, $aList) {
349: $idcat = $_REQUEST['idcat'];
350: $idart = $_REQUEST['idart'];
351: $lang = $_REQUEST['lang'];
352: $client = $_REQUEST['client'];
353: global $db, $db2, $sess, $cfg, $code, $cfgClient, $encoding;
354:
355:
356: $_typeList = array();
357: $oTypeColl = new cApiTypeCollection();
358: $oTypeColl->select();
359: while ($oType = $oTypeColl->next()) {
360: $_typeList[] = $oType->toObject();
361: }
362:
363:
364: $code = conGenerateCode($idcat, $idart, $lang, $client, false, false, false);
365: foreach ($_typeList as $_typeItem) {
366: $type = $_typeItem->type;
367: if (in_array($type, $aList)) {
368:
369: $tmp = preg_match_all('/(' . $type . '\[+(\d)+\])/i', $code, $match);
370: foreach ($match[0] as $s) {
371: if (!in_array($s, $r)) {
372: array_push($r, $s);
373: }
374: }
375: }
376: }
377: return $r;
378: }
379: