1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
17:
18: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
19:
20: $backendUrl = cRegistry::getBackendUrl();
21:
22:
23:
24: $ret = strCheckTreeForErrors();
25: if (is_array($ret)) {
26: $string = '';
27: foreach ($ret as $errorMessage) {
28: $string .= $errorMessage . '<br>';
29: }
30: $string .= '<br>' . i18n('Be careful! Further editing of the category tree might corrupt it more. Please fix the errors first.');
31: $notification->displayNotification(cGuiNotification::LEVEL_WARNING, $string);
32: }
33:
34: strRemakeTreeTable();
35:
36: $tmp_area = 'str';
37:
38:
39: if ($action == 'str_duplicate' && ($perm->have_perm_area_action('str', 'str_duplicate') || $perm->have_perm_area_action_item('str', 'str_duplicate', $idcat))) {
40: strCopyTree($idcat, $parentid);
41: }
42:
43: $oDirectionDb = cRegistry::getDb();
44:
45: 46: 47: 48: 49: 50:
51: function buildCategorySelectRights() {
52: global $cfg, $client, $lang, $idcat, $perm, $tmp_area;
53:
54: $db = cRegistry::getDb();
55:
56: $oHtmlSelect = new cHTMLSelectElement('idcat', '', 'new_idcat');
57:
58: $oHtmlSelectOption = new cHTMLOptionElement(i18n("Please choose"), '', true);
59: $oHtmlSelect->appendOptionElement($oHtmlSelectOption);
60:
61: $sql = "SELECT a.idcat AS idcat, b.name AS name, c.level FROM
62: " . $cfg["tab"]["cat"] . " AS a, " . $cfg["tab"]["cat_lang"] . " AS b,
63: " . $cfg["tab"]["cat_tree"] . " AS c WHERE a.idclient = '" . cSecurity::toInteger($client) . "'
64: AND b.idlang = '" . cSecurity::toInteger($lang) . "' AND b.idcat = a.idcat AND c.idcat = a.idcat
65: ORDER BY c.idtree";
66:
67: $db->query($sql);
68:
69: $categories = array();
70:
71: while ($db->nextRecord()) {
72: $categories[$db->f("idcat")]["name"] = $db->f("name");
73: $categories[$db->f("idcat")]["idcat"] = $db->f("idcat");
74: if ($perm->have_perm_area_action($tmp_area, 'str_newcat') || $perm->have_perm_area_action_item($tmp_area, 'str_newcat', $db->f('idcat'))) {
75: $categories[$db->f("idcat")]["perm"] = 1;
76: } else {
77: $categories[$db->f("idcat")]["perm"] = 0;
78: }
79: $categories[$db->f("idcat")]["level"] = $db->f("level");
80: }
81:
82: $aCategoriesReversed = array_reverse($categories);
83:
84: $iLevel = 0;
85: foreach ($aCategoriesReversed as $iKeyIdCat => $aValues) {
86: if ($aValues['level'] > $iLevel && $aValues['perm']) {
87: $iLevel = $aValues['level'];
88: } else if ($aValues['level'] < $iLevel) {
89: $iLevel = $aValues['level'];
90: } else {
91: if (!$aValues['perm']) {
92: unset($categories[$aValues["idcat"]]);
93: }
94: }
95: }
96:
97: foreach ($categories as $tmpidcat => $props) {
98: $spaces = ' ';
99: for ($i = 0; $i < $props['level']; $i++) {
100: $spaces .= ' ';
101: }
102:
103: $sCategoryname = $props['name'];
104: $sCategoryname = cString::trimHard($sCategoryname, 30);
105: $oHtmlSelectOption = new cHTMLOptionElement($spaces . ">" . conHtmlSpecialChars($sCategoryname), $tmpidcat, false, !$props['perm']);
106: $oHtmlSelect->appendOptionElement($oHtmlSelectOption);
107: }
108:
109: return $oHtmlSelect->toHtml();
110: }
111:
112: 113: 114: 115: 116: 117:
118: function getStrExpandCollapseButton($item, $catName) {
119: global $sess, $frame, $area;
120: $selflink = 'main.php';
121:
122: $img = new cHTMLImage();
123: $img->updateAttributes(array(
124: 'style' => 'padding:4px;'
125: ));
126:
127:
128:
129: $auth = cRegistry::getAuth();
130: $currentUser = new cApiUser($auth->auth['uid']);
131: $userPerms = $currentUser->getPerms();
132: if (strpos($userPerms, 'sysadmin') !== false || strpos($userPerms, 'admin[') !== false) {
133: $title = " title=\"idcat: {$item->id}, parentid: {$item->custom['parentid']}, preid: {$item->custom['preid']}, postid: {$item->custom['postid']}\"";
134: } else {
135: $title = '';
136: }
137:
138: $catName = cSecurity::unFilter($catName);
139:
140: if (count($item->subitems) > 0) {
141: if ($item->collapsed == true) {
142: $expandlink = $sess->url($selflink . "?area=$area&frame=$frame&expand=" . $item->id);
143: $img->setSrc($item->collapsed_icon);
144: $img->setAlt(i18n("Open category"));
145: return '<a href="' . $expandlink . '">' . $img->render() . '</a> ' . '<a href="' . $expandlink . '"' . $title . '>' . conHtmlSpecialChars($catName) . '</a>';
146: } else {
147: $collapselink = $sess->url($selflink . "?area=$area&frame=$frame&collapse=" . $item->id);
148: $img->setSrc($item->expanded_icon);
149: $img->setAlt(i18n("Close category"));
150: return '<a href="' . $collapselink . '">' . $img->render() . '</a> ' . '<a href="' . $collapselink . '"' . $title . '>' . conHtmlSpecialChars($catName) . '</a>';
151: }
152: } else {
153: return '<img src="images/spacer.gif" width="14" height="7"> <span' . $title . '>' . conHtmlSpecialChars($catName) . '</span>';
154: }
155: }
156:
157: 158: 159: 160:
161: function getTemplateSelect() {
162: global $client, $cfg, $db;
163:
164: $oHtmlSelect = new cHTMLSelectElement('cat_template_select', '', 'cat_template_select');
165:
166: $oHtmlSelectOption = new cHTMLOptionElement('--- ' . i18n("none") . ' ---', 0, false);
167: $oHtmlSelect->appendOptionElement($oHtmlSelectOption);
168:
169: $sql = "SELECT idtpl, name, defaulttemplate FROM " . $cfg['tab']['tpl'] . " WHERE idclient = '" . $client . "' ORDER BY name";
170:
171: if ($db->query($sql)) {
172: while ($db->nextRecord()) {
173: $bDefaultTemplate = $db->f('defaulttemplate');
174: $oHtmlSelectOption = new cHTMLOptionElement($db->f('name'), $db->f('idtpl'), $bDefaultTemplate);
175: $oHtmlSelect->appendOptionElement($oHtmlSelectOption);
176: }
177: }
178:
179: return $oHtmlSelect->toHtml();
180: }
181:
182: 183: 184: 185:
186: function insertEmptyStrRow($listColumns) {
187: global $tpl;
188:
189: $tpl->set('d', 'BGCOLOR', '#FFFFFF');
190: $tpl->set('d', 'BGCOLOR_EDIT', '#F1F1F1');
191: $tpl->set('d', 'ALIAS', ' ');
192: $tpl->set('d', 'INDENT', '3px');
193: $tpl->set('d', 'RENAMEBUTTON', ' ');
194: $tpl->set('d', 'NEWCATEGORYBUTTON', ' ');
195: $tpl->set('d', 'VISIBLEBUTTON', ' ');
196: $tpl->set('d', 'PUBLICBUTTON', ' ');
197: $tpl->set('d', 'DELETEBUTTON', ' ');
198: $tpl->set('d', 'UPBUTTON', ' ');
199: $tpl->set('d', 'COLLAPSE_CATEGORY_NAME', ' ');
200: $tpl->set('d', 'TPLNAME', ' ');
201: $tpl->set('d', 'MOVEBUTTON', ' ');
202: $tpl->set('d', 'DOWNBUTTON', ' ');
203: $tpl->set('d', 'SHOW_MOUSEOVER', '');
204: $tpl->set('d', 'SHOW_MOUSEOVER_ALIAS', '');
205: $tpl->set('d', 'SHOW_MOUSEOVER_CATEGORY', '');
206: $tpl->set('d', 'TPLDESC', '');
207: $tpl->set('d', 'DUPLICATEBUTTON', ' ');
208: $tpl->set('d', 'TEMPLATEBUTTON', ' ');
209: $tpl->set('d', 'MOUSEOVER', '');
210: $tpl->set('d', 'SUM_COLUMNS_EDIT', 15 + count($listColumns));
211: $tpl->set('d', 'CATID', '');
212: $tpl->set('d', 'PARENTID', '');
213: $tpl->set('d', 'LEVEL', '');
214: $tpl->set('d', 'ACTION_EDIT_URL', '');
215: $tpl->set('d', 'INPUT_CATEGORY', '');
216: $tpl->set('d', 'LABEL_ALIAS_NAME', '');
217: $tpl->set('d', 'HREF_CANCEL', '');
218: $tpl->set('d', 'SRC_CANCEL', '');
219: $tpl->set('d', 'DIRECTION', '');
220: $tpl->set('d', 'SRC_OK', '');
221: $tpl->set('d', 'VALUE_ALIAS_NAME', '');
222: $tpl->set('d', 'HEIGHT', 'height:15px;');
223: $tpl->set('d', 'BORDER_CLASS', 'str-style-b');
224:
225: $additionalColumns = array();
226: foreach ($listColumns as $content) {
227:
228: $additionalColumns[] = '<td class="emptyCell2" nowrap="nowrap"> </td>';
229: }
230: $tpl->set('d', 'ADDITIONALCOLUMNS', implode("", $additionalColumns));
231: $tpl->next();
232: }
233: getTemplateSelect();
234:
235: $sess->register("remakeStrTable");
236: $sess->register("StrTableClient");
237: $sess->register("StrTableLang");
238:
239: $cancel = $sess->url("main.php?area=$area&frame=$frame");
240:
241: if (isset($force) && $force == 1) {
242: $remakeStrTable = true;
243: }
244:
245: if ($StrTableClient != $client) {
246: unset($expandedList);
247: $remakeStrTable = true;
248: }
249:
250: if ($StrTableLang != $lang) {
251: unset($expandedList);
252: $remakeStrTable = true;
253: }
254:
255: $StrTableClient = $client;
256: $StrTableLang = $lang;
257:
258: if (!isset($idcat)) {
259: $idcat = 0;
260: }
261: if (!isset($action)) {
262: $action = 0;
263: }
264:
265: 266: 267: 268: 269:
270: function buildTree(&$rootItem, &$items) {
271: global $nextItem, $perm, $tmp_area;
272:
273: while ($item_list = each($items)) {
274: list($key, $item) = $item_list;
275:
276: unset($newItem);
277:
278: $bCheck = false;
279: if (!$bCheck) {
280: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_newtree');
281: }
282: if (!$bCheck) {
283: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_newcat');
284: }
285: if (!$bCheck) {
286: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_makevisible');
287: }
288: if (!$bCheck) {
289: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_makepublic');
290: }
291: if (!$bCheck) {
292: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_deletecat');
293: }
294: if (!$bCheck) {
295: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_moveupcat');
296: }
297: if (!$bCheck) {
298: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_movedowncat');
299: }
300: if (!$bCheck) {
301: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_movesubtree');
302: }
303: if (!$bCheck) {
304: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_renamecat');
305: }
306: if (!$bCheck) {
307: $bCheck = $perm->have_perm_area_action('str_tplcfg', 'str_tplcfg');
308: }
309: if (!$bCheck) {
310: $bCheck = $perm->have_perm_item($tmp_area, $item['idcat']);
311: }
312:
313: if ($bCheck) {
314: $newItem = new TreeItem($item['name'], $item['idcat'], true);
315: } else {
316: $newItem = new TreeItem($item['name'], $item['idcat'], false);
317: }
318:
319: $newItem->collapsed_icon = 'images/open_all.gif';
320: $newItem->expanded_icon = 'images/close_all.gif';
321: $newItem->custom['idtree'] = $item['idtree'];
322: $newItem->custom['level'] = $item['level'];
323: $newItem->custom['idcat'] = $item['idcat'];
324: $newItem->custom['idtree'] = $item['idtree'];
325: $newItem->custom['parentid'] = $item['parentid'];
326: $newItem->custom['alias'] = $item['alias'];
327: $newItem->custom['preid'] = $item['preid'];
328: $newItem->custom['postid'] = $item['postid'];
329: $newItem->custom['visible'] = $item['visible'];
330: $newItem->custom['idtplcfg'] = $item['idtplcfg'];
331: $newItem->custom['public'] = $item['public'];
332:
333: if ($perm->have_perm_item('str', $item['idcat'])) {
334: $newItem->custom['forcedisplay'] = 1;
335: }
336:
337: if (array_key_exists($key + 1, $items)) {
338: $nextItem = $items[$key + 1];
339: } else {
340: $nextItem = 0;
341: }
342:
343: if (array_key_exists($key - 1, $items)) {
344: $lastItem = $items[$key - 1];
345: } else {
346: $lastItem = 0;
347: }
348:
349: $rootItem->addItem($newItem);
350:
351: if ($nextItem['level'] > $item['level']) {
352: $oldRoot = $rootItem;
353: buildTree($newItem, $items);
354: $rootItem = $oldRoot;
355: }
356:
357: if ($nextItem['level'] < $item['level']) {
358: return;
359: }
360: }
361: }
362:
363: if (!$perm->have_perm_area_action($area)) {
364: return;
365: }
366:
367: $sql = "SELECT
368: idtree, A.idcat, level, name, parentid, preid, postid, visible, public, idtplcfg, C.urlname as alias
369: FROM
370: " . $cfg["tab"]["cat_tree"] . " AS A,
371: " . $cfg["tab"]["cat"] . " AS B,
372: " . $cfg["tab"]["cat_lang"] . " AS C
373: WHERE
374: A.idcat = B.idcat AND
375: B.idcat = C.idcat AND
376: C.idlang = '" . cSecurity::toInteger($lang) . "' AND
377: B.idclient = '" . cSecurity::toInteger($client) . "'
378: ORDER BY
379: idtree";
380:
381: $db->query($sql);
382:
383: $bIgnore = false;
384: $iIgnoreLevel = 0;
385:
386: $items = array();
387: while ($db->nextRecord()) {
388: $bSkip = false;
389:
390: if ($bIgnore == true && $iIgnoreLevel >= $db->f('level')) {
391: $bIgnore = false;
392: }
393:
394: if ($db->f('idcat') == $movesubtreeidcat) {
395: $bIgnore = true;
396: $iIgnoreLevel = $db->f('level');
397: $sMoveSubtreeCatName = $db->f('name');
398: }
399:
400: if ($iCurLevel == $db->f('level')) {
401: if ($iCurParent != $db->f('parentid')) {
402: $bSkip = true;
403: }
404: } else {
405: $iCurLevel = $db->f('level');
406: $iCurParent = $db->f('parentid');
407: }
408:
409: if ($bIgnore == false && $bSkip == false) {
410: $entry = array();
411: $entry['idtree'] = $db->f('idtree');
412: $entry['idcat'] = $db->f('idcat');
413: $entry['level'] = $db->f('level');
414: $entry['name'] = htmldecode($db->f('name'));
415: $entry['alias'] = htmldecode($db->f('alias'));
416: $entry['parentid'] = $db->f('parentid');
417: $entry['preid'] = $db->f('preid');
418: $entry['postid'] = $db->f('postid');
419: $entry['visible'] = $db->f('visible');
420: $entry['public'] = $db->f('public');
421: $entry['idtplcfg'] = $db->f('idtplcfg');
422:
423: $items[] = $entry;
424: }
425: }
426:
427: $rootStrItem = new TreeItem('root', -1);
428: $rootStrItem->collapsed_icon = 'images/open_all.gif';
429: $rootStrItem->expanded_icon = 'images/close_all.gif';
430:
431: buildTree($rootStrItem, $items);
432:
433: $expandedList = unserialize($currentuser->getUserProperty('system', 'cat_expandstate'));
434:
435: if (is_array($expandedList[$client])) {
436: $rootStrItem->markExpanded($expandedList[$client]);
437: }
438:
439: if (isset($collapse) && is_numeric($collapse)) {
440: $rootStrItem->markCollapsed($collapse);
441: }
442:
443: if (isset($expand) && is_numeric($expand)) {
444: $rootStrItem->markExpanded($expand);
445: }
446:
447: if (isset($expand) && $expand == 'all') {
448: $rootStrItem->expandAll(-1);
449: }
450:
451: if (isset($collapse) && $collapse == 'all') {
452: $rootStrItem->collapseAll(-1);
453: }
454:
455: if ($action === 'str_newcat') {
456: $rootStrItem->markExpanded($idcat);
457: }
458:
459: $expandedList[$client] = array();
460: $objects = array();
461:
462: $rootStrItem->traverse($objects);
463:
464: $rootStrItem->getExpandedList($expandedList[$client]);
465: $currentuser->setUserProperty('system', 'cat_expandstate', serialize($expandedList));
466:
467:
468: $tpl->reset();
469: $tpl->set('s', 'AREA', $area);
470: $tpl->set('s', 'FRAME', $frame);
471:
472: $_cecIterator = $_cecRegistry->getIterator('Contenido.CategoryList.Columns');
473:
474: $listColumns = array();
475: if ($_cecIterator->count() > 0) {
476: while ($chainEntry = $_cecIterator->next()) {
477: $tmplistColumns = $chainEntry->execute(array());
478: if (is_array($tmplistColumns)) {
479: $listColumns = array_merge($listColumns, $tmplistColumns);
480: }
481: }
482:
483: foreach ($listColumns as $content) {
484:
485: $additionalheaders[] = '<th class="header nowrap" nowrap="nowrap">' . $content . '</th>';
486: }
487:
488: $additionalheader = implode('', $additionalheaders);
489: } else {
490: $additionalheader = '';
491: }
492:
493: $tpl->set('s', 'ADDITIONALHEADERS', $additionalheader);
494:
495:
496: unset($objects[0]);
497:
498: $selflink = 'main.php';
499: $expandlink = $sess->url($selflink . "?area=$area&frame=$frame&expand=all&syncoptions=$syncoptions");
500: $collapselink = $sess->url($selflink . "?area=$area&frame=$frame&collapse=all&syncoptions=$syncoptions");
501: $collapseimg = '<a class="black" href="' . $collapselink . '" alt="' . i18n("Close all categories") . '" title="' . i18n("Close all categories") . '">
502: <img src="images/close_all.gif"> ' . i18n("Close all categories") . '</a>';
503: $expandimg = '<a class="black" href="' . $expandlink . '" alt="' . i18n("Open all categories") . '" title="' . i18n("Open all categories") . '">
504: <img src="images/open_all.gif"> ' . i18n("Open all categories") . '</a>';
505:
506: $tpl->set('s', 'COLLAPSE_ALL', $collapseimg);
507: $tpl->set('s', 'EXPAND_ALL', $expandimg);
508: $sMouseover = 'onmouseover="str.over(this)" onmouseout="str.out(this)" onclick="str.click(this)"';
509:
510:
511: $tpl->set('s', 'SUM_COLUMNS_EDIT', 15 + count($listColumns));
512: $tpl->set('s', 'ACTION_EDIT_URL', $sess->url("main.php?frame=$frame"));
513: $tpl->set('s', 'SRC_CANCEL', $backendUrl . $cfg["path"]["images"] . 'but_cancel.gif');
514: $tpl->set('s', 'SRC_OK', $backendUrl . $cfg["path"]["images"] . 'but_ok.gif');
515: $tpl->set('s', 'HREF_CANCEL', "javascript:handleInlineEdit(0)");
516: $tpl->set('s', 'LABEL_ALIAS_NAME', i18n('Alias'));
517: $tpl->set('s', 'TEMPLATE_URL', $sess->url("main.php?area=str_tplcfg&frame=$frame"));
518: $message = addslashes(i18n("Do you really want to duplicate the following category:<br><br><b>%s</b><br><br>Notice: The duplicate process can take up to several minutes, depending on how many subitems and articles you've got."));
519: $tpl->set('s', 'DUPLICATE_MESSAGE', $message);
520: $tpl->set('s', 'DELETE_MESSAGE', i18n("Do you really want to delete the following category:<br><br><b>%s</b>"));
521: $tpl->set('s', 'OK', i18n('OK'));
522: $tpl->set('s', 'CANCEL', i18n('Cancel'));
523: $tpl->set('s', 'MOVE_CONFIRMATION', i18n('Do you really want to move the category?'));
524:
525: $bAreaAddNewCategory = false;
526:
527: $aInlineEditData = array();
528:
529: $sql = "SELECT idtplcfg, idtpl FROM " . $cfg["tab"]["tpl_conf"];
530: $db->query($sql);
531: $aTplconfigs = array();
532: while ($db->nextRecord()) {
533: $aTplconfigs[$db->f('idtplcfg')] = $db->f('idtpl');
534: }
535:
536: $sql = "SELECT name, description, idtpl FROM " . $cfg["tab"]["tpl"];
537: $db->query($sql);
538: $aTemplates = array();
539: while ($db->nextRecord()) {
540: $aTemplates[$db->f('idtpl')] = array(
541: 'name' => $db->f('name'),
542: 'description' => $db->f('description')
543: );
544: }
545:
546: foreach ($objects as $key => $value) {
547:
548:
549: $bCheck = false;
550: if (!$bCheck) {
551: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_newtree');
552: }
553: if (!$bCheck) {
554: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_newcat');
555: }
556: if (!$bCheck) {
557: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_makevisible');
558: }
559: if (!$bCheck) {
560: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_makepublic');
561: }
562: if (!$bCheck) {
563: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_deletecat');
564: }
565: if (!$bCheck) {
566: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_moveupcat');
567: }
568: if (!$bCheck) {
569: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_movedowncat');
570: }
571: if (!$bCheck) {
572: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_movesubtree');
573: }
574: if (!$bCheck) {
575: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_renamecat');
576: }
577: if (!$bCheck) {
578: $bCheck = $perm->have_perm_area_action('str_tplcfg', 'str_tplcfg');
579: }
580: if (!$bCheck) {
581: $bCheck = $perm->have_perm_item($tmp_area, $value->id);
582: }
583: if (!$bCheck) {
584: $bCheck = $value->isCustomAttributeSet("forcedisplay");
585: }
586:
587: if ($bCheck) {
588:
589:
590: if ($value->custom['level'] == 0 && $value->custom['preid'] != 0) {
591: insertEmptyStrRow($listColumns);
592: }
593:
594: $tpl->set('d', 'BGCOLOR', '#FFFFFF');
595: $tpl->set('d', 'BGCOLOR_EDIT', '#F1F1F1');
596: $tpl->set('d', 'HEIGHT', 'height:25px');
597: $tpl->set('d', 'BORDER_CLASS', 'str-style-c tooltip');
598:
599: $tpl->set('d', 'INDENT', ($value->custom['level'] * 16) . "px");
600: $sCategoryname = $value->name;
601: if (strlen($value->name) > 30) {
602: $sCategoryname = cString::trimHard($sCategoryname, 30);
603: }
604:
605:
606: if (strlen($value->name) > 30) {
607: $tpl->set('d', 'SHOW_MOUSEOVER_CATEGORY', 'title="' . htmlspecialchars(cSecurity::unFilter($value->name)) . '" class="tooltip"');
608: } else {
609: $tpl->set('d', 'SHOW_MOUSEOVER_CATEGORY', '');
610: }
611:
612: $tpl->set('d', 'COLLAPSE_CATEGORY_NAME', getStrExpandCollapseButton($value, $sCategoryname));
613: if ($value->custom['alias']) {
614: $sCategoryalias = $value->custom['alias'];
615: if (strlen($value->custom['alias']) > 30) {
616: $sCategoryalias = cString::trimHard($sCategoryalias, 30);
617: }
618: $tpl->set('d', 'ALIAS', $sCategoryalias);
619: if (strlen($value->custom['alias']) > 30) {
620: $tpl->set('d', 'SHOW_MOUSEOVER_ALIAS', 'title="' . $value->custom['alias'] . '"');
621: } else {
622: $tpl->set('d', 'SHOW_MOUSEOVER_ALIAS', '');
623: }
624: } else {
625: $tpl->set('d', 'SHOW_MOUSEOVER_ALIAS', '');
626: $tpl->set('d', 'ALIAS', ' ');
627: }
628:
629: $template = $aTemplates[$aTplconfigs[$value->custom['idtplcfg']]]['name'];
630: $templateDescription = $aTemplates[$aTplconfigs[$value->custom['idtplcfg']]]['description'];
631:
632: $descString = '';
633:
634: if ($template == "") {
635: $template = '--- ' . i18n("none") . ' ---';
636: }
637:
638:
639: $descString = '<b>' . $template . '</b>';
640:
641: if (sizeof($templateDescription) > 0) {
642: $descString .= '<br>' . $templateDescription;
643: }
644:
645: $sTemplatename = $template;
646: if (strlen($template) > 20) {
647: $sTemplatename = cString::trimHard($sTemplatename, 20);
648: }
649:
650: $tpl->set('d', 'TPLNAME', $sTemplatename);
651: $tpl->set('d', 'TPLDESC', $descString);
652:
653: if ($perm->have_perm_area_action($tmp_area, 'str_renamecat') || $perm->have_perm_area_action_item($tmp_area, 'str_renamecat', $value->id)) {
654: $bPermRename = 1;
655: } else {
656: $bPermRename = 0;
657: }
658:
659: if ($perm->have_perm_area_action('str_tplcfg', 'str_tplcfg') || $perm->have_perm_area_action_item('str_tplcfg', 'str_tplcfg', $value->id)) {
660: $bPermTplcfg = 1;
661: } else {
662: $bPermTplcfg = 0;
663: }
664:
665: $aRecord = array();
666: $sCatName = $value->name;
667:
668:
669: $aRecord['catn'] = $sCatName;
670: $sAlias = $value->custom['alias'];
671:
672: $aRecord['alias'] = conHtmlSpecialChars($sAlias);
673: $aRecord['idtplcfg'] = $value->custom['idtplcfg'];
674: $aRecord['pName'] = $bPermRename;
675: $aRecord['pTplcfg'] = $bPermTplcfg;
676: $aInlineEditData[$value->id] = $aRecord;
677:
678: if ($perm->have_perm_area_action($area, "str_renamecat")) {
679: $tpl->set('d', 'RENAMEBUTTON', "<a class=\"action\" href=\"javascript:handleInlineEdit(" . $value->id . ");\"><img src=\"" . $cfg["path"]["images"] . "but_todo.gif\" id=\"cat_" . $value->id . "_image\" alt=\"" . i18n("Edit category") . "\" title=\"" . i18n("Edit category") . "\"></a>");
680: } else {
681: $tpl->set('d', 'RENAMEBUTTON', "");
682: }
683: $tpl->set('d', 'CATID', $value->id);
684: $tpl->set('d', 'PARENTID', $value->custom['parentid']);
685: $tpl->set('d', 'POSTID', $value->custom['postid']);
686: $tpl->set('d', 'PREID', $value->custom['preid']);
687: $tpl->set('d', 'LEVEL', $value->custom['level']);
688:
689: if (strlen($template) > 20) {
690: $tpl->set('d', 'SHOW_MOUSEOVER', 'title="' . $descString . '"');
691: } else {
692: $tpl->set('d', 'SHOW_MOUSEOVER', '');
693: }
694:
695: $tpl->set('d', 'MOUSEOVER', $sMouseover);
696:
697: if ($perm->have_perm_area_action($tmp_area, 'str_newcat') || $perm->have_perm_area_action_item($tmp_area, 'str_newcat', $value->id)) {
698: $bAreaAddNewCategory = true;
699: }
700:
701: if ($perm->have_perm_area_action($tmp_area, 'str_makevisible') || $perm->have_perm_area_action_item($tmp_area, 'str_makevisible', $value->id)) {
702: if ($value->custom['visible'] == 1) {
703: $tpl->set('d', 'VISIBLEBUTTON', "<a href=\"" . $sess->url("main.php?area=$area&action=str_makevisible&frame=$frame&idcat=" . $value->id . "&visible=" . $value->custom['visible']) . "#clickedhere\"><img src=\"images/online.gif\" alt=\"" . i18n("Make offline") . "\" title=\"" . i18n("Make offline") . "\"></a>");
704: } else {
705: $tpl->set('d', 'VISIBLEBUTTON', "<a href=\"" . $sess->url("main.php?area=$area&action=str_makevisible&frame=$frame&idcat=" . $value->id . "&visible=" . $value->custom['visible']) . "#clickedhere\"><img src=\"images/offline.gif\" alt=\"" . i18n("Make online") . "\" title=\"" . i18n("Make online") . "\"></a>");
706: }
707: } else {
708: $tpl->set('d', 'VISIBLEBUTTON', ' ');
709: }
710:
711: if ($perm->have_perm_area_action($tmp_area, 'str_makepublic') || $perm->have_perm_area_action_item($tmp_area, 'str_makepublic', $value->id)) {
712: if ($value->custom['public'] == 1) {
713: $tpl->set('d', 'PUBLICBUTTON', "<a href=\"" . $sess->url("main.php?area=$area&action=str_makepublic&frame=$frame&idcat=" . $value->id . "&public=" . $value->custom['public']) . "#clickedhere\"><img src=\"images/folder_delock.gif\" alt=\"" . i18n("Protect category") . "\" title=\"" . i18n("Protect category") . "\"></a>");
714: } else {
715: $tpl->set('d', 'PUBLICBUTTON', "<a href=\"" . $sess->url("main.php?area=$area&action=str_makepublic&frame=$frame&idcat=" . $value->id . "&public=" . $value->custom['public']) . "#clickedhere\"><img src=\"images/folder_lock.gif\" alt=\"" . i18n("Unprotect category") . "\" title=\"" . i18n("Unprotect category") . "\"></a>");
716: }
717: } else {
718: $tpl->set('d', 'PUBLICBUTTON', ' ');
719: }
720:
721: $hasChildren = strNextDeeper($value->id);
722: $hasArticles = strHasArticles($value->id);
723: if (($hasChildren == 0) && ($hasArticles == false) && ($perm->have_perm_area_action($tmp_area, 'str_deletecat') || $perm->have_perm_area_action_item($tmp_area, 'str_deletecat', $value->id))) {
724: $delete = '<a href="javascript://" onclick="confDel(' . $value->id . ',' . $value->custom['parentid'] . ', \'' . addslashes(conHtmlSpecialChars($value->name)) . '\')">' . "<img src=\"" . $cfg["path"]["images"] . "delete.gif\" alt=\"" . i18n("Delete category") . "\" title=\"" . i18n("Delete category") . "\"></a>";
725: $tpl->set('d', 'DELETEBUTTON', $delete);
726: } else {
727: $message = i18n("No permission");
728:
729: if ($hasChildren) {
730: $button = 'delete_inact_h.gif';
731: $alt = i18n("One or more subtrees and one or more articles are existing, unable to delete.");
732: }
733:
734: if ($hasArticles) {
735: $button = 'delete_inact_g.gif';
736: $alt = i18n("One or more articles are existing, unable to delete.");
737: }
738: if ($hasChildren && $hasArticles) {
739: $button = 'delete_inact.gif';
740: $alt = i18n("One or more articles are existing, unable to delete.");
741: }
742:
743: $tpl->set('d', 'DELETEBUTTON', '<img src="' . $cfg["path"]["images"] . $button . '" alt="' . $alt . '" title="' . $alt . '">');
744: }
745:
746: if ($perm->have_perm_area_action($tmp_area, 'str_moveupcat') || $perm->have_perm_area_action_item($tmp_area, 'str_moveupcat', $value->id)) {
747: $rand = rand();
748: if ($value->custom['parentid'] == 0 && $value->custom['preid'] == 0) {
749: $tpl->set('d', 'UPBUTTON', '<img src="images/folder_moveup_inact.gif" title="' . i18n("This category is already at the top") . '">');
750: } else {
751: if ($value->custom['preid'] != 0) {
752: $tpl->set('d', 'UPBUTTON', "<a href=\"" . $sess->url("main.php?area=$area&action=str_moveupcat&frame=$frame&idcat=" . $value->id . "&rand=$rand") . "#clickedhere\"><img src=\"images/folder_moveup.gif\" alt=\"" . i18n("Move category up") . "\" title=\"" . i18n("Move category up") . "\"></a>");
753: } else {
754: $tpl->set('d', 'UPBUTTON', '<img src="images/folder_moveup_inact.gif" title="' . i18n("This category is already at the top") . '">');
755: }
756: }
757: } else {
758: $tpl->set('d', 'UPBUTTON', '<img src="images/folder_moveup_inact.gif">');
759: }
760:
761: if ($perm->have_perm_area_action($tmp_area, 'str_movedowncat') || $perm->have_perm_area_action_item($tmp_area, 'str_movedowncat', $value->id)) {
762: $rand = rand();
763: if ($value->custom['postid'] == 0) {
764: $tpl->set('d', 'DOWNBUTTON', '<img src="images/folder_movedown_inact.gif" title="' . i18n("This category is already at the bottom") . '">');
765: } else {
766: $tpl->set('d', 'DOWNBUTTON', "<a href=\"" . $sess->url("main.php?area=$area&action=str_movedowncat&frame=$frame&idcat=" . $value->id . "&rand=$rand") . "#clickedhere\"><img src=\"images/folder_movedown.gif\" alt=\"" . i18n("Move category down") . "\" title=\"" . i18n("Move category down") . "\"></a>");
767: }
768: } else {
769: $tpl->set('d', 'DOWNBUTTON', '<img src="images/folder_movedown_inact.gif">');
770: }
771:
772: if (($action === 'str_movesubtree') && (!isset($parentid_new))) {
773: if ($perm->have_perm_area_action($tmp_area, 'str_movesubtree') || $perm->have_perm_area_action_item($tmp_area, 'str_movesubtree', $value->id)) {
774: if ($value->id == $idcat) {
775: $tpl->set('d', 'MOVEBUTTON', "<a name=#movesubtreehere><a href=\"" . $sess->url("main.php?area=$area&action=str_movesubtree&frame=$frame&idcat=$idcat&parentid_new=0") . "\"><img src=\"" . $cfg["path"]["images"] . "but_move_subtree_main.gif\" alt=\"" . i18n("Move tree") . "\" title=\"" . i18n("Move tree") . "\"></a>");
776: } else {
777: $allowed = strMoveCatTargetallowed($value->id, $idcat);
778: if ($allowed == 1) {
779: $tpl->set('d', 'MOVEBUTTON', "<a href=\"" . $sess->url("main.php?area=$area&action=str_movesubtree&frame=$frame&idcat=$idcat&parentid_new=" . $value->id) . "\"><img src=\"" . $cfg["path"]["images"] . "but_move_subtree_target.gif\" alt=\"" . i18n("Place tree here") . "\" title=\"" . i18n("Place tree here") . "\"></a>");
780: } else {
781: $tpl->set('d', 'MOVEBUTTON', ' ');
782: }
783: }
784: } else {
785: $tpl->set('d', 'MOVEBUTTON', ' ');
786: }
787: } else {
788: if ($perm->have_perm_area_action($tmp_area, 'str_movesubtree') || $perm->have_perm_area_action_item($tmp_area, 'str_movesubtree', $value->id)) {
789: if ($value->custom['parentid'] != 0) {
790: $tpl->set('d', 'MOVEBUTTON', "<a href=\"" . $sess->url("main.php?area=$area&action=str_movesubtree&frame=$frame&idcat=" . $value->id) . "#movesubtreehere\"><img src=\"" . $cfg["path"]["images"] . "but_move_subtree.gif\" alt=\"" . i18n("Move tree") . "\" title=\"" . i18n("Move tree") . "\"></a>");
791: } else {
792: $tpl->set('d', 'MOVEBUTTON', '<img src="' . $cfg["path"]["images"] . 'but_move_subtree_grey.png" title="' . i18n("This category can't be moved since it is already a root category") . '">');
793: }
794: } else {
795: $tpl->set('d', 'MOVEBUTTON', ' ');
796: }
797: }
798:
799: if ($perm->have_perm_area_action('str', 'str_duplicate') || $perm->have_perm_area_action_item('str', 'str_duplicate', $value->id)) {
800: $duplicate = '<a href="javascript://" onclick="confDupl(' . $value->id . ',' . $value->custom['parentid'] . ', \'' . addslashes(conHtmlSpecialChars($value->name)) . '\')">' . "<img src=\"" . $cfg["path"]["images"] . "folder_duplicate.gif\" alt=\"" . i18n("Duplicate category") . "\" title=\"" . i18n("Duplicate category") . "\"></a>";
801: $tpl->set('d', 'DUPLICATEBUTTON', $duplicate);
802: } else {
803: $tpl->set('d', 'DUPLICATEBUTTON', ' ');
804: }
805:
806:
807: cInclude('includes', 'functions.lang.php');
808: $tpl->set('d', 'DIRECTION', 'dir="' . langGetTextDirection($lang, $oDirectionDb) . '"');
809:
810: $columns = array();
811:
812: foreach ($listColumns as $key => $content) {
813: $columnContents = array();
814: $_cecIterator = $_cecRegistry->getIterator('Contenido.CategoryList.RenderColumn');
815: if ($_cecIterator->count() > 0) {
816: while ($chainEntry = $_cecIterator->next()) {
817: $columnContents[] = $chainEntry->execute($value->id, $key);
818: }
819: } else {
820: $columnContents[] = '';
821: }
822: $columns[] = '<td class="str-style-d">' . implode("", $columnContents) . '</td>';
823: }
824:
825: $tpl->set('d', 'ADDITIONALCOLUMNS', implode("", $columns));
826: $tpl->next();
827: }
828: }
829:
830: $jsDataArray = "";
831: foreach ($aInlineEditData as $iIdCat => $aData) {
832: $aTmp = array();
833: foreach ($aData as $aKey => $aValue) {
834: $aTmp[] = $aKey . "':'" . addslashes($aValue);
835: }
836: $jsDataArray .= "
837: strDataObj[$iIdCat] = {'" . implode("', '", $aTmp) . "'};";
838: }
839:
840: $tpl->set('s', 'JS_DATA', $jsDataArray);
841:
842: $string = markSubMenuItem(0, true);
843:
844:
845: $sImagepath = $cfg["path"]["images"];
846: $tpl->set('s', 'SUM_COLUMNS', 15 + count($listColumns));
847: $tpl->set('s', 'HREF_ACTION', $sess->url("main.php?frame=$frame"));
848: $tpl->set('s', 'CON_IMAGES', $backendUrl . $cfg["path"]["images"]);
849:
850:
851: $oSession = new cHTMLHiddenField($sess->name, $sess->id);
852: $oActionEdit = new cHTMLHiddenField('action', 'str_renamecat');
853: $oIdcat = new cHTMLHiddenField('idcat');
854:
855: $tpl->set('s', 'INPUT_SESSION', $oSession->render());
856: $tpl->set('s', 'INPUT_ACTION_EDIT', $oActionEdit->render());
857: $tpl->set('s', 'INPUT_IDCAT', $oIdcat->render());
858:
859: $oVisible = new cHTMLHiddenField('visible', 0, 'visible_input');
860: $oPublic = new cHTMLHiddenField('public', 1, 'public_input');
861: $oTemplate = new cHTMLHiddenField('idtplcfg', 0, 'idtplcfg_input');
862:
863: $tpl->set('s', 'INPUT_VISIBLE', $oVisible->render());
864: $tpl->set('s', 'INPUT_PUBLIC', $oPublic->render());
865: $tpl->set('s', 'INPUT_TEMPLATE', $oTemplate->render());
866:
867: $oCatName = new cHTMLTextbox('categoryname', '', '', '', 'cat_categoryname');
868: $oCatName->setStyle('width:150px; vertical-align:middle;');
869: $tpl->set('s', 'INPUT_CATNAME_NEW', $oCatName->render());
870:
871: $oAlias = new cHTMLTextbox('categoryalias', '', '', '', 'cat_categoryalias');
872: $oAlias->setStyle('width:150px; vertical-align:middle;');
873: $tpl->set('s', 'INPUT_ALIAS_NEW', $oAlias->render());
874:
875: $oNewCatName = new cHTMLTextbox('newcategoryname');
876: $oNewCatName->setStyle('width:150px; vertical-align:middle;');
877: $tpl->set('s', 'INPUT_CATNAME_EDIT', $oNewCatName->render());
878:
879: $oNewAlias = new cHTMLTextbox('newcategoryalias');
880: $oNewAlias->setStyle('width:150px; vertical-align:middle;');
881: $tpl->set('s', 'INPUT_ALIAS_EDIT', $oNewAlias->render());
882:
883: $sCategorySelect = buildCategorySelectRights('idcat', '');
884:
885:
886:
887: if (($perm->have_perm_area_action($tmp_area, 'str_newtree') || $perm->have_perm_area_action($tmp_area, 'str_newcat') || $bAreaAddNewCategory) && (int) $client > 0 && (int) $lang > 0) {
888: $tpl->set('s', 'NEWCAT', $string . '<a class="black" id="new_tree_button" href="javascript:showNewForm();"><img src="images/folder_new.gif"> ' . i18n('Create new category') . '</a>');
889: if ($perm->have_perm_area_action($tmp_area, 'str_newtree')) {
890: if ($perm->have_perm_area_action($tmp_area, 'str_newcat') || $bAreaAddNewCategory) {
891: $tpl->set('s', 'PERMISSION_NEWTREE', '');
892: $oActionNew = new cHTMLHiddenField('action', 'str_newcat', 'cat_new_action');
893: } else {
894: $tpl->set('s', 'PERMISSION_NEWTREE', 'disabled checked');
895: $oActionNew = new cHTMLHiddenField('action', 'str_newcat', 'str_newtree');
896: }
897: $tpl->set('s', 'INPUT_ACTION_NEW', $oActionNew->render());
898: $tpl->set('s', 'PERMISSION_NEWTREE_DISPLAY', 'block');
899: } else {
900: $oActionNew = new cHTMLHiddenField('action', 'str_newcat', 'cat_new_action');
901: $tpl->set('s', 'PERMISSION_NEWTREE', 'disabled');
902: $tpl->set('s', 'PERMISSION_NEWTREE_DISPLAY', 'none');
903: $tpl->set('s', 'NEW_ACTION', 'str_newcat');
904: $tpl->set('s', 'INPUT_ACTION_NEW', $oActionNew->render());
905: }
906:
907: if ($perm->have_perm_area_action($tmp_area, 'str_newcat') || $bAreaAddNewCategory) {
908: $tpl->set('s', 'CATEGORY_SELECT', $sCategorySelect);
909: $tpl->set('s', 'PERMISSION_NEWCAT_DISPLAY', 'block');
910: } else {
911: $tpl->set('s', 'CATEGORY_SELECT', '');
912: $tpl->set('s', 'PERMISSION_NEWCAT_DISPLAY', 'none');
913: }
914:
915: if ($perm->have_perm_area_action('str_tplcfg', 'str_tplcfg')) {
916: $tpl->set('s', 'TEMPLATE_BUTTON_NEW', '<a href="javascript:showTemplateSelect();"><img src="' . $sImagepath . 'template_properties.gif" id="cat_category_select_button" title="' . i18n('Configure category') . '" alt="' . i18n('Configure category') . '"></a>');
917: $tpl->set('s', 'SELECT_TEMPLATE', getTemplateSelect());
918: } else {
919: $tpl->set('s', 'TEMPLATE_BUTTON_NEW', '<img src="' . $sImagepath . 'template_properties_off.gif" id="cat_category_select_button" title="' . i18n('Configure category') . '" alt="' . i18n('Configure category') . '">');
920: $tpl->set('s', 'SELECT_TEMPLATE', '');
921: }
922:
923: if ($perm->have_perm_area_action($tmp_area, 'str_makevisible')) {
924: $tpl->set('s', 'MAKEVISIBLE_BUTTON_NEW', '<a href="javascript:changeVisible();"><img src="' . $sImagepath . 'offline.gif" id="visible_image" title="' . i18n('Make online') . '" alt="' . i18n('Make online') . '"></a>');
925: } else {
926: $tpl->set('s', 'MAKEVISIBLE_BUTTON_NEW', '<img src="' . $sImagepath . 'offline_off.gif" id="visible_image" title="' . i18n('Make online') . '" alt="' . i18n('Make online') . '">');
927: }
928:
929: if ($perm->have_perm_area_action($tmp_area, 'str_makepublic')) {
930: $tpl->set('s', 'MAKEPUBLIC_BUTTON_NEW', '<a href="javascript:changePublic();"><img src="' . $sImagepath . 'folder_delock.gif" id="public_image" title="' . i18n('Protect category') . '" alt="' . i18n('Protect category') . '"></a>');
931: } else {
932: $tpl->set('s', 'MAKEPUBLIC_BUTTON_NEW', '<img src="' . $sImagepath . 'folder_delocked.gif" id="public_image" title="' . i18n('Protect category') . '" alt="' . i18n('Protect category') . '">');
933: }
934: } else {
935: $tpl->set('s', 'NEWCAT', $string);
936:
937: $tpl->set('s', 'PERMISSION_NEWTREE', 'disabled');
938: $tpl->set('s', 'PERMISSION_NEWTREE_DISPLAY', 'none');
939:
940: $tpl->set('s', 'CATEGORY_SELECT', '');
941: $tpl->set('s', 'PERMISSION_NEWCAT_DISPLAY', 'none');
942:
943: $tpl->set('s', 'TEMPLATE_BUTTON_NEW', '');
944: $tpl->set('s', 'MAKEVISIBLE_BUTTON_NEW', '');
945: $tpl->set('s', 'MAKEPUBLIC_BUTTON_NEW', '');
946:
947: $tpl->set('s', 'NEW_ACTION', 'str_newcat');
948: $tpl->set('s', 'SELECT_TEMPLATE', '');
949: }
950:
951:
952: $clang = new cApiLanguage($lang);
953:
954: if ($movesubtreeidcat != 0) {
955: if (strlen($sMoveSubtreeCatName) > 30) {
956: $sLimiter = "...";
957: } else {
958: $sLimiter = "";
959: }
960: $sButtonDesc = sprintf(i18n('Cancel moving %s'), '"' . substr($sMoveSubtreeCatName, 0, 30) . $sLimiter . '"');
961: $tpl->set('s', 'CANCEL_MOVE_TREE', '<a class="black" id="cancel_move_tree_button" href="javascript:cancelMoveTree(\'' . $movesubtreeidcat . '\');"><img src="images/but_cancel.gif" alt="' . $sButtonDesc . '"> ' . $sButtonDesc . '</a>');
962: } else {
963: $tpl->set('s', 'CANCEL_MOVE_TREE', '');
964: }
965:
966: $tpl->setEncoding($clang->get("encoding"));
967: $tpl->generate($cfg['path']['templates'] . $cfg['templates']['str_overview']);
968: