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: cInclude("includes", "functions.str.php");
19: cInclude("includes", "functions.pathresolver.php");
20:
21:
22: $tpl->reset();
23:
24:
25: function generateInfoButton($title){
26:
27: return '<a id="rootdirInfo1-link" class="infoButton" title="'."$title".'" href="javascript:void(0);"></a>';
28: }
29:
30:
31:
32:
33:
34: if ($action == "remove_assignments") {
35: $sql = "DELETE FROM " . $cfg["tab"]["cat_art"] . " WHERE idart=" . cSecurity::toInteger($idart) . " AND idcat != " . cSecurity::toInteger($idcat);
36: $db->query($sql);
37: }
38: if ($action == "con_newart" && $newart != true) {
39:
40:
41: return;
42: }
43:
44:
45: if ($METAmetatype) {
46: $sql = "INSERT INTO `" . $cfg["tab"]["meta_type"] . "` (
47: `metatype` ,
48: `fieldtype` ,
49: `maxlength` ,
50: `fieldname`
51: )
52: VALUES (
53: '" . $METAmetatype . "', '" . $METAfieldtype . "', '" . $METAmaxlength . "', '" . $METAfieldname . "'
54: );";
55: $db->query($sql);
56: }
57:
58: $disabled = '';
59:
60: if ($perm->have_perm_area_action($area, "con_meta_edit") || $perm->have_perm_area_action_item($area, "con_meta_edit", $idcat)) {
61: $sql = "SELECT * FROM " . $cfg["tab"]["cat_art"] . " WHERE idart=" . cSecurity::toInteger($idart) . " AND idcat=" . cSecurity::toInteger($idcat);
62: $db->query($sql);
63: $db->nextRecord();
64:
65: $tmp_cat_art = $db->f("idcatart");
66:
67: $sql = "SELECT * FROM " . $cfg["tab"]["art_lang"] . " WHERE idart=" . cSecurity::toInteger($idart) . " AND idlang=" . cSecurity::toInteger($lang);
68: $db->query($sql);
69: $db->nextRecord();
70:
71: $tmp_is_start = isStartArticle($db->f("idartlang"), $idcat, $lang);
72:
73: if ($db->f("created")) {
74:
75:
76: $tmp_firstedit = 0;
77: $tmp_idartlang = $db->f("idartlang");
78: $tmp_page_title = cSecurity::unFilter(stripslashes($db->f("pagetitle")));
79: $tmp_alias = cSecurity::unFilter(stripslashes($db->f("urlname")));
80:
81: $tmp_sitemap_prio = $db->f("sitemapprio");
82: $tmp_sitemap_change_freg = $db->f("changefreq");
83:
84: $tmp_idlang = $db->f("idlang");
85: $tmp_title = cSecurity::unFilter($db->f("title"));
86: $tmp_urlname = cSecurity::unFilter($db->f("urlname"));
87:
88:
89:
90: $tmp_artspec = $db->f("artspec");
91: $tmp_summary = cSecurity::unFilter($db->f("summary"));
92: $tmp_created = $db->f("created");
93: $tmp_lastmodified = $db->f("lastmodified");
94: $tmp_author = $db->f("author");
95: $tmp_modifiedby = $db->f("modifiedby");
96: $tmp_online = $db->f("online");
97: $tmp_published = $db->f("published");
98: $tmp_publishedby = $db->f("publishedby");
99: $tmp_datestart = $db->f("datestart");
100: $tmp_dateend = $db->f("dateend");
101: $tmp_sort = $db->f("artsort");
102: $tmp_movetocat = $db->f("time_move_cat");
103: $tmp_targetcat = $db->f("time_target_cat");
104: $tmp_onlineaftermove = $db->f("time_online_move");
105: $tmp_usetimemgmt = $db->f("timemgmt");
106: $tmp_locked = $db->f("locked");
107: $tmp_redirect_checked = ($db->f("redirect") == '1')? 'checked' : '';
108: $tmp_redirect_url = ($db->f("redirect_url") != '0')? $db->f("redirect_url") : "http://";
109: $tmp_external_redirect_checked = ($db->f("external_redirect") == '1')? 'checked' : '';
110: $idtplinput = $db->f("idtplinput");
111:
112: if ($tmp_modifiedby == '') {
113: $tmp_modifiedby = $tmp_author;
114: }
115:
116: $col = new cApiInUseCollection();
117:
118:
119: $col->removeSessionMarks($sess->id);
120:
121: if (($obj = $col->checkMark("article", $tmp_idartlang)) === false || $obj->get("userid") == $auth->auth['uid']) {
122: $col->markInUse("article", $tmp_idartlang, $sess->id, $auth->auth["uid"]);
123: $inUse = false;
124: $disabled = '';
125: $tpl->set('s', 'IS_DATETIMEPICKER_DISABLED', 0);
126: } else {
127: $vuser = new cApiUser($obj->get("userid"));
128: $inUseUser = $vuser->getField("username");
129: $inUseUserRealName = $vuser->getField("realname");
130:
131: $message = sprintf(i18n("Article is in use by %s (%s)"), $inUseUser, $inUseUserRealName);
132: $notification->displayNotification("warning", $message);
133: $inUse = true;
134: $disabled = 'disabled="disabled"';
135: $tpl->set('s', 'IS_DATETIMEPICKER_DISABLED', 1);
136: }
137:
138: if ($tmp_locked == 1) {
139: $inUse = true;
140: $disabled = 'disabled="disabled"';
141: $tpl->set('s', 'IS_DATETIMEPICKER_DISABLED', 1);
142: }
143: } else {
144:
145:
146:
147: if (!$idart) {
148: $tmp_firstedit = 1;
149:
150: }
151:
152: $tmp_idartlang = 0;
153: $tmp_idlang = $lang;
154: $tmp_page_title = stripslashes($db->f("pagetitle"));
155: $tmp_title = '';
156: $tmp_alias = "";
157:
158: $tmp_sitemap_prio = "";
159: $tmp_sitemap_change_freg = "";
160:
161: $tmp_urlname = '';
162: $tmp_artspec = '';
163: $tmp_summary = '';
164: $tmp_created = date("Y-m-d H:i:s");
165: $tmp_lastmodified = date("Y-m-d H:i:s");
166: $tmp_published = date("Y-m-d H:i:s");
167: $tmp_publishedby = '';
168: $tmp_author = '';
169: $tmp_online = "0";
170: $tmp_datestart = "0000-00-00 00:00:00";
171: $tmp_dateend = "0000-00-00 00:00:00";
172: $tmp_keyart = '';
173: $tmp_keyautoart = '';
174: $tmp_sort = '';
175:
176: if (!strHasStartArticle($idcat, $lang)) {
177: $tmp_is_start = 1;
178: }
179:
180: $tmp_redirect_checked = '';
181: $tmp_redirect_url = "http://";
182: $tmp_external_redirect = '';
183: }
184:
185: $dateformat = getEffectiveSetting("dateformat", "full", "Y-m-d H:i:s");
186:
187: $tmp2_created = date($dateformat, strtotime($tmp_created));
188: $tmp2_lastmodified = date($dateformat, strtotime($tmp_lastmodified));
189: $tmp2_published = date($dateformat, strtotime($tmp_published));
190:
191: $tpl->set('s', 'ACTION', $sess->url("main.php?area=$area&frame=$frame&action=con_meta_saveart"));
192: $tpl->set('s', 'TMP_FIRSTEDIT', $tmp_firstedit);
193: $tpl->set('s', 'IDART', $idart);
194: $tpl->set('s', 'SID', $sess->id);
195: $tpl->set('s', 'IDCAT', $idcat);
196: $tpl->set('s', 'IDARTLANG', $tmp_idartlang);
197:
198: $hiddenfields = '<input type="hidden" name="idcat" value="' . $idcat . '">
199: <input type="hidden" name="idart" value="' . $idart . '">
200: <input type="hidden" name="send" value="1">';
201:
202: $tpl->set('s', 'HIDDENFIELDS', $hiddenfields);
203:
204:
205: $breadcrumb = renderBackendBreadcrumb($syncoptions, true, true);
206: $tpl->set('s', 'CATEGORY', $breadcrumb);
207: $tpl->set('s', 'TITEL', i18n("SEO administration"));
208:
209: if (isset($tmp_notification)) {
210: $tpl->set('s', 'NOTIFICATION', '<tr><td colspan="4">' . $tmp_notification . '<br></td></tr>');
211: } else {
212: $tpl->set('s', 'NOTIFICATION', '');
213: }
214:
215: $title_input = '<input class="textField" type="text" ' . $disabled . ' name="page_title" value="' . conHtmlSpecialChars($tmp_page_title) . '">';
216: $tpl->set("s", "TITLE-INPUT", $title_input);
217:
218: $tpl->set("s","TITLE_INFO",(i18n("The Title-Tag is one of the most important on-page factor for SEO and is no longer than 60 characters. It includes top keywords and the branding.")));
219: $tpl->set("s","EXPIRES_INFO",(i18n("Expires")));
220: $tpl->set("s","REVISIT_INFO",(i18n("The frequency of the revisit after tag depend on new publications of the content. Nevertheless the robots decide on their own when to visit.")));
221: $tpl->set("s","ROBOTS_INFO",(i18n("Not important content or not to indicate pictures should be declared with the robot-tag. It has an high relevance for SEO. Only relevant and most visited articels should be indicated.")));
222: $tpl->set("s","SITEMAPRIORITY_INFO",(i18n("The avarage value for the sitemap priority is 0.5. Only important articels should have an value no more than 0.8.")));
223: $tpl->set("s","SITEMAPCHANGEFREQUENCY_INFO",(i18n("The refresh rate is focused on the content.")));
224: $tpl->set("s","CUSTOMMETATAGS_INFO",(i18n("User defined meta tags.")));
225: $tpl->set("s","DESCRIPTION_INFO",(i18n("The Description-Tag describes the article in a short way (no more than 150 characters). The content should be related to the Title-Tag and the H1-Tag.")));
226: $tpl->set("s","KEYWORD_INFO",(i18n("No more than 6 Keywords should be used.")));
227: $tpl->set("s","REVISITED_INFO",(i18n("The frequency of the revisit after tag depend on new publications of the content. Nevertheless the robots decide on their own when to visit.")));
228:
229: $tpl->set("s","EXPIRES_INFO",(i18n("Expires")));
230: $tpl->set("s","REVISIT_INFO",(i18n("The frequency of the revisit after tag depend on new publications of the content. Nevertheless the robots decide on their own when to visit.")));
231: $tpl->set("s","ROBOTS_INFO",(i18n("ROBOTS_INFO")));
232: $tpl->set("s","SITEMAPRIORITY_INFO",(i18n("The avarage value for the sitemap priority is 0.5. Only important articels should have an value no more than 0.8.")));
233: $tpl->set("s","SITEMAPCHANGEFREQUENCY_INFO",(i18n("The refresh rate is focused on the content.")));
234: $tpl->set("s","CUSTOMMETATAGS_INFO",(i18n("user defined meta tags")));
235:
236:
237:
238:
239: $tpl->set("s", "ALIAS", $tmp_alias);
240: $tpl->set("s", "SITEMAP_PRIO", $tmp_sitemap_prio);
241: $tpl->set("s", "SELECTED_".$tmp_sitemap_change_freg, "selected");
242:
243: if (($lang_short = substr(strtolower($belang), 0, 2)) != "en") {
244: $langscripts = '<script type="text/javascript" src="scripts/jquery/plugins/timepicker-' . $lang_short . '.js"></script>
245: <script type="text/javascript" src="scripts/jquery/plugins/datepicker-' . $lang_short . '.js"></script>';
246: $tpl->set('s', 'CAL_LANG', $langscripts);
247: } else {
248: $tpl->set('s', 'CAL_LANG', '');
249: }
250:
251: $tpl->set('s', 'PATH_TO_CALENDER_PIC', cRegistry::getBackendUrl() . $cfg['path']['images'] . 'calendar.gif');
252:
253: $art = new cApiArticleLanguage($tmp_idartlang);
254: $tpl->set("s", "LINK", $art->getLink());
255: $tpl->set("s", "FULL_LINK", $cfgClient[$client]["path"]["htmlpath"] . $art->getLink());
256:
257:
258: $availableTags = conGetAvailableMetaTagTypes();
259:
260: $managedTypes = array(
261: "author",
262: "date",
263: "description",
264: "expires",
265: "keywords",
266: "revisit-after",
267: "robots",
268: "copyright"
269: );
270:
271: $metaPreview = array();
272:
273: foreach ($availableTags as $key => $value) {
274: $metaPreview[] = array(
275: "name" => $value["metatype"],
276: "content" => conHtmlSpecialChars(conGetMetaValue($tmp_idartlang, $key))
277: );
278:
279: if (in_array($value["metatype"], $managedTypes)) {
280: if ($value["metatype"] == "robots") {
281: if (conGetMetaValue($tmp_idartlang, $key) == "") {
282: conSetMetaValue($tmp_idartlang, $key, "index, follow");
283: $i = 0;
284: foreach($metaPreview as $metaRow) {
285: if ($metaRow["name"] == "robots") {
286: $metaPreview[$i]["content"] = "index, follow";
287: break;
288: }
289: $i++;
290: }
291: }
292: $robot_array = explode(", ", conHtmlSpecialChars(conGetMetaValue($tmp_idartlang, $key)));
293: foreach($robot_array as $instruction) {
294: $tpl->set("s", strtoupper($instruction), "checked");
295: }
296: } else {
297: $tpl->set("s", strtoupper($value["metatype"]), conHtmlSpecialChars(conGetMetaValue($tmp_idartlang, $key)));
298: }
299: continue;
300: }
301:
302: $tpl->set('d', 'METAINPUT', 'META' . $value);
303:
304: switch ($value["fieldtype"]) {
305: case "text":
306: if ($value["metatype"] == 'date') {
307: $element = '<input ' . $disabled . ' class="metaTag" type="text" name="META' . $value["metatype"] . '" id="META' . $value["metatype"] . '" size="24" maxlength=' . $value["maxlength"] . ' value="' . conHtmlSpecialChars(conGetMetaValue($tmp_idartlang, $key)) . '">';
308: } else {
309: $element = '<input ' . $disabled . ' class="metaTag" type="text" name="META' . $value["metatype"] . '" id="META' . $value["metatype"] . '" size="24" maxlength=' . $value["maxlength"] . ' value="' . conHtmlSpecialChars(conGetMetaValue($tmp_idartlang, $key)) . '">';
310: }
311: break;
312: case "textarea":
313: $element = '<textarea ' . $disabled . ' class="metaTag" name="META' . $value["metatype"] . '" id="META' . $value["metatype"] . '" rows=3>' . conHtmlSpecialChars(conGetMetaValue($tmp_idartlang, $key)) . '</textarea>';
314: break;
315: }
316:
317: $tpl->set("d", "ARTICLE_ID", $idart);
318: $tpl->set("d", "CAT_ID", $idcat);
319: $tpl->set('d', 'METAFIELDTYPE', $element);
320: $tpl->set('d', 'IDMETATYPE', $value["idmetatype"]);
321: $tpl->set('d', 'METATITLE', $value["metatype"] . ':');
322: $tpl->next();
323: }
324:
325:
326: $tpl->set('s', 'MOVETOCATEGORYSELECT', $select);
327:
328: if ($tmp_movetocat == "1") {
329: $tpl->set('s', 'MOVETOCATCHECKED', 'checked' . $allow_usetimemgmt);
330: } else {
331: $tpl->set('s', 'MOVETOCATCHECKED', '' . $allow_usetimemgmt);
332: }
333:
334: if ($tmp_onlineaftermove == "1") {
335: $tpl->set('s', 'ONLINEAFTERMOVECHECKED', 'checked' . $allow_usetimemgmt);
336: } else {
337: $tpl->set('s', 'ONLINEAFTERMOVECHECKED', '' . $allow_usetimemgmt);
338: }
339:
340:
341: $tpl->set('s', 'SUMMARY', i18n("Summary"));
342: $tpl->set('s', 'SUMMARY-INPUT', '<textarea ' . $disabled . ' class="text_medium" name="summary" cols="50" rows="5">' . $tmp_summary . '</textarea>');
343:
344: $sql = "SELECT
345: b.idcat
346: FROM
347: " . $cfg["tab"]["cat"] . " AS a,
348: " . $cfg["tab"]["cat_lang"] . " AS b,
349: " . $cfg["tab"]["cat_art"] . " AS c
350: WHERE
351: a.idclient = " . cSecurity::toInteger($client) . " AND
352: a.idcat = b.idcat AND
353: c.idcat = b.idcat AND
354: c.idart = " . cSecurity::toInteger($idart);
355:
356: $db->query($sql);
357: $db->nextRecord();
358:
359: $midcat = $db->f("idcat");
360:
361: if (isset($idart)) {
362: if (!isset($idartlang) || 0 == $idartlang) {
363: $sql = "SELECT idartlang FROM " . $cfg["tab"]["art_lang"] . " WHERE idart=" . cSecurity::toInteger($idart) . " AND idlang=" . cSecurity::toInteger($lang);
364: $db->query($sql);
365: $db->nextRecord();
366: $idartlang = $db->f("idartlang");
367: }
368: }
369:
370: if (isset($midcat)) {
371: if (!isset($idcatlang) || 0 == $idcatlang) {
372: $sql = "SELECT idcatlang FROM " . $cfg["tab"]["cat_lang"] . " WHERE idcat=" . cSecurity::toInteger($midcat) . " AND idlang=" . cSecurity::toInteger($lang);
373: $db->query($sql);
374: $db->nextRecord();
375: $idcatlang = $db->f("idcatlang");
376: }
377: }
378:
379: if (isset($midcat) && isset($idart)) {
380: if (!isset($idcatart) || 0 == $idcatart) {
381: $sql = "SELECT idcatart FROM " . $cfg["tab"]["cat_art"] . " WHERE idart=" . cSecurity::toInteger($idart) . " AND idcat=" . cSecurity::toInteger($midcat);
382: $db->query($sql);
383: $db->nextRecord();
384: $idcatart = $db->f("idcatart");
385: }
386: }
387:
388: if (0 != $idart && 0 != $midcat) {
389: $script = 'artObj.setProperties("' . $idart . '", "' . $idartlang . '", "' . $midcat . '", "' . $idcatlang . '", "' . $idcatart . '", "' . $lang . '");';
390: } else {
391: $script = 'artObj.reset();';
392: }
393:
394: $tpl->set('s', 'DATAPUSH', $script);
395:
396: $tpl->set('s', 'BUTTONDISABLE', $disabled);
397:
398: if ($inUse == true) {
399: $tpl->set('s', 'BUTTONIMAGE', 'but_ok_off.gif');
400: } else {
401: $tpl->set('s', 'BUTTONIMAGE', 'but_ok.gif');
402: }
403:
404: if ($tmp_usetimemgmt == '1') {
405: if ($tmp_datestart == "0000-00-00 00:00:00" && $tmp_dateend == "0000-00-00 00:00:00") {
406: $message = sprintf(i18n("Please fill in the start date and/or the end date!"));
407: $notification->displayNotification("warning", $message);
408: }
409: }
410:
411:
412: unset($tpl2);
413: $result = array(
414: "metatype" => "",
415: "fieldtype" => array(
416: "text",
417: "textarea"
418: ),
419: "maxlength" => "255",
420: "fieldname" => "name"
421: );
422: $tpl2 = new cTemplate();
423: $tpl2->set('s', 'METATITLE', i18n("New meta tag"));
424:
425: $sql = "SHOW FIELDS FROM `" . $cfg['tab']['meta_type'] . "`";
426:
427: $db->query($sql);
428:
429: while ($db->nextRecord()) {
430: if ($db->f("Field") != 'idmetatype') {
431: if ($db->f("Field") === 'metatype') {
432: $tpl2->set('d', 'METATITLE', i18n('Field Value'));
433: } else if ($db->f("Field") === 'fieldtype') {
434: $tpl2->set('d', 'METATITLE', i18n('Field Type'));
435: } else if ($db->f("Field") === 'maxlength') {
436: $tpl2->set('d', 'METATITLE', i18n('Max Length'));
437: } else if ($db->f("Field") === 'fieldname') {
438: $tpl2->set('d', 'METATITLE', i18n('Field Name'));
439: } else {
440: $tpl2->set('d', 'METATITLE', i18n($db->f("Field")));
441: }
442:
443: if (!is_array($result[$db->f("Field")])) {
444: $str = '<input type="text" onblur="restoreOnBlur(this, \'' . $result[$db->f("Field")] . '\')" onfocus="clearOnFocus(this, \'' . $result[$db->f("Field")] . '\');" value="' . $result[$db->f("Field")] . '" maxlength="255" id="META' . $db->f("Field") . '" name="META' . $db->f("Field") . '" class="text_medium">';
445: } else {
446: $str = '<select id="META' . $db->f("Field") . '" name="META' . $db->f("Field") . '">';
447: foreach ($result[$db->f("Field")] as $item) {
448: $str .= '<option value="' . $item . '">' . $item . '</option>';
449: }
450: $str .= '<select>';
451: }
452: $tpl2->set('d', 'METAFIELDTYPE', $str);
453:
454: $tpl2->next();
455: }
456: }
457:
458: $select = $tpl2->generate($cfg["path"]["templates"] . $cfg["templates"]["con_meta_addnew"], true);
459:
460:
461: $aUserPerm = explode(',', $auth->auth['perm']);
462: if (!in_array('sysadmin', $aUserPerm)) {
463: $tpl->set('s', 'ADDMETABTN', ' ');
464: $tpl->set('s', 'ADDNEWMETA', ' ');
465: } else {
466: $tpl->set('s', 'ADDMETABTN', '<img src="images/but_art_new.gif" id="addMeta">');
467: $tpl->set('s', 'ADDNEWMETA', $select);
468: }
469:
470: $tpl->set('s', 'iIdcat', $idcat);
471: $tpl->set('s', 'iIdtpl', $idtpl);
472: $tpl->set('s', 'SYNCOPTIONS', -1);
473: $tpl->set('s', 'SESSION', $contenido);
474: $tpl->set('s', 'DISPLAY_MENU', 1);
475:
476:
477:
478: $additionalRows = '';
479: $cecRegistry = cApiCecRegistry::getInstance();
480: $cecIterator = $cecRegistry->getIterator('Contenido.Backend.ConMetaEditFormAdditionalRows');
481: while (($chainEntry = $cecIterator->next()) !== false) {
482: $additionalRows .= $chainEntry->execute($idart, $lang, $client);
483: }
484:
485:
486: $tpl->set('s', 'ADDITIONAL_ROWS', $additionalRows);
487:
488:
489: $_cecIterator = cRegistry::getCecRegistry()->getIterator('Contenido.Content.CreateMetatags');
490: if ($_cecIterator->count() > 0) {
491: while (false !== $chainEntry = $_cecIterator->next()) {
492: $metaPreview = $chainEntry->execute($metaPreview);
493: }
494: }
495:
496: $tpl2 = new cTemplate();
497: foreach($metaPreview as $metaRow) {
498: if ($metaRow["content"] == "") {
499: $tpl2->set("d", "META_SHOWN", "display: none");
500: }
501: $tpl2->set("d", "META_NAME", $metaRow["name"]);
502: $tpl2->set("d", "META_CONTENT", $metaRow["content"]);
503: $tpl2->next();
504: }
505: $tpl->set("s", "META_TAGS", $tpl2->generate($cfg['path']['templates'] . "template.con_meta_edit_form_preview.html", true));
506:
507:
508: $tpl->generate($cfg['path']['templates'] . $cfg['templates']['con_meta_edit_form']);
509: } else {
510:
511: $notification->displayNotification("error", i18n("Permission denied"));
512: }
513:
514: