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