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