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