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="emptyCell" 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)) {
415: $rootStrItem->markExpanded($expandedList);
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 = array();
439: $objects = array();
440:
441: $rootStrItem->traverse($objects);
442:
443: $rootStrItem->getExpandedList($expandedList);
444: $currentuser->setUserProperty('system', 'cat_expandstate', serialize($expandedList));
445:
446:
447: $tpl->reset();
448: $tpl->set('s', 'SID', $sess->id);
449: $tpl->set('s', 'AREA', $area);
450: $tpl->set('s', 'FRAME', $frame);
451:
452: $_cecIterator = $_cecRegistry->getIterator('Contenido.CategoryList.Columns');
453:
454: $listColumns = array();
455: if ($_cecIterator->count() > 0) {
456: while ($chainEntry = $_cecIterator->next()) {
457: $tmplistColumns = $chainEntry->execute(array());
458: if (is_array($tmplistColumns)) {
459: $listColumns = array_merge($listColumns, $tmplistColumns);
460: }
461: }
462:
463: foreach ($listColumns as $content) {
464:
465: $additionalheaders[] = '<th class="header nowrap" nowrap="nowrap">' . $content . '</th>';
466: }
467:
468: $additionalheader = implode('', $additionalheaders);
469: } else {
470: $additionalheader = '';
471: }
472:
473: $tpl->set('s', 'ADDITIONALHEADERS', $additionalheader);
474:
475:
476: unset($objects[0]);
477:
478: $selflink = 'main.php';
479: $expandlink = $sess->url($selflink . "?area=$area&frame=$frame&expand=all&syncoptions=$syncoptions");
480: $collapselink = $sess->url($selflink . "?area=$area&frame=$frame&collapse=all&syncoptions=$syncoptions");
481: $collapseimg = '<a class="black" href="' . $collapselink . '" alt="' . i18n("Close all categories") . '" title="' . i18n("Close all categories") . '">
482: <img src="images/close_all.gif"> ' . i18n("Close all categories") . '</a>';
483: $expandimg = '<a class="black" href="' . $expandlink . '" alt="' . i18n("Open all categories") . '" title="' . i18n("Open all categories") . '">
484: <img src="images/open_all.gif"> ' . i18n("Open all categories") . '</a>';
485:
486: $tpl->set('s', 'COLLAPSE_ALL', $collapseimg);
487: $tpl->set('s', 'EXPAND_ALL', $expandimg);
488: $sMouseover = 'onmouseover="str.over(this)" onmouseout="str.out(this)" onclick="str.click(this)"';
489:
490:
491: $tpl->set('s', 'SUM_COLUMNS_EDIT', 15 + count($listColumns));
492: $tpl->set('s', 'ACTION_EDIT_URL', $sess->url("main.php?frame=$frame"));
493: $tpl->set('s', 'SRC_CANCEL', $backendUrl . $cfg["path"]["images"] . 'but_cancel.gif');
494: $tpl->set('s', 'SRC_OK', $backendUrl . $cfg["path"]["images"] . 'but_ok.gif');
495: $tpl->set('s', 'HREF_CANCEL', "javascript:handleInlineEdit(0)");
496: $tpl->set('s', 'LABEL_ALIAS_NAME', i18n('Alias'));
497: $tpl->set('s', 'TEMPLATE_URL', $sess->url("main.php?area=str_tplcfg&frame=$frame"));
498: $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."));
499: $tpl->set('s', 'DUPLICATE_MESSAGE', $message);
500: $tpl->set('s', 'DELETE_MESSAGE', i18n("Do you really want to delete the following category:<br><br><b>%s</b>"));
501: $tpl->set('s', 'OK', i18n('OK'));
502: $tpl->set('s', 'CANCEL', i18n('Cancel'));
503: $tpl->set('s', 'MOVE_CONFIRMATION', i18n('Do you really want to move the category?'));
504:
505: $bAreaAddNewCategory = false;
506:
507: $aInlineEditData = array();
508:
509: $sql = "SELECT idtplcfg, idtpl FROM " . $cfg["tab"]["tpl_conf"];
510: $db->query($sql);
511: $aTplconfigs = array();
512: while ($db->nextRecord()) {
513: $aTplconfigs[$db->f('idtplcfg')] = $db->f('idtpl');
514: }
515:
516: $sql = "SELECT name, description, idtpl FROM " . $cfg["tab"]["tpl"];
517: $db->query($sql);
518: $aTemplates = array();
519: while ($db->nextRecord()) {
520: $aTemplates[$db->f('idtpl')] = array(
521: 'name' => $db->f('name'),
522: 'description' => $db->f('description')
523: );
524: }
525:
526: foreach ($objects as $key => $value) {
527:
528:
529: $bCheck = false;
530: if (!$bCheck) {
531: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_newtree');
532: }
533: if (!$bCheck) {
534: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_newcat');
535: }
536: if (!$bCheck) {
537: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_makevisible');
538: }
539: if (!$bCheck) {
540: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_makepublic');
541: }
542: if (!$bCheck) {
543: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_deletecat');
544: }
545: if (!$bCheck) {
546: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_moveupcat');
547: }
548: if (!$bCheck) {
549: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_movedowncat');
550: }
551: if (!$bCheck) {
552: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_movesubtree');
553: }
554: if (!$bCheck) {
555: $bCheck = $perm->have_perm_area_action($tmp_area, 'str_renamecat');
556: }
557: if (!$bCheck) {
558: $bCheck = $perm->have_perm_area_action('str_tplcfg', 'str_tplcfg');
559: }
560: if (!$bCheck) {
561: $bCheck = $perm->have_perm_item($tmp_area, $value->id);
562: }
563: if (!$bCheck) {
564: $bCheck = $value->isCustomAttributeSet("forcedisplay");
565: }
566:
567: if ($bCheck) {
568:
569:
570: if ($value->custom['level'] == 0 && $value->custom['preid'] != 0) {
571: insertEmptyStrRow($listColumns);
572: }
573:
574: $tpl->set('d', 'BGCOLOR', '#FFFFFF');
575: $tpl->set('d', 'BGCOLOR_EDIT', '#F1F1F1');
576: $tpl->set('d', 'HEIGHT', 'height:25px');
577: $tpl->set('d', 'BORDER_CLASS', 'str-style-c tooltip');
578:
579: $tpl->set('d', 'INDENT', ($value->custom['level'] * 16) . "px");
580: $sCategoryname = $value->name;
581: if (strlen($value->name) > 30) {
582: $sCategoryname = cApiStrTrimHard($sCategoryname, 30);
583: }
584:
585:
586: if (strlen($value->name) > 30) {
587: $tpl->set('d', 'SHOW_MOUSEOVER_CATEGORY', 'title="' . htmlspecialchars(cSecurity::unFilter($value->name)) . '" class="tooltip"');
588: } else {
589: $tpl->set('d', 'SHOW_MOUSEOVER_CATEGORY', '');
590: }
591:
592: $tpl->set('d', 'COLLAPSE_CATEGORY_NAME', getStrExpandCollapseButton($value, $sCategoryname));
593: if ($value->custom['alias']) {
594: $sCategoryalias = $value->custom['alias'];
595: if (strlen($value->custom['alias']) > 30) {
596: $sCategoryalias = cApiStrTrimHard($sCategoryalias, 30);
597: }
598: $tpl->set('d', 'ALIAS', $sCategoryalias);
599: if (strlen($value->custom['alias']) > 30) {
600: $tpl->set('d', 'SHOW_MOUSEOVER_ALIAS', 'title="' . $value->custom['alias'] . '"');
601: } else {
602: $tpl->set('d', 'SHOW_MOUSEOVER_ALIAS', '');
603: }
604: } else {
605: $tpl->set('d', 'SHOW_MOUSEOVER_ALIAS', '');
606: $tpl->set('d', 'ALIAS', ' ');
607: }
608:
609: $template = $aTemplates[$aTplconfigs[$value->custom['idtplcfg']]]['name'];
610: $templateDescription = $aTemplates[$aTplconfigs[$value->custom['idtplcfg']]]['description'];
611:
612: $descString = '';
613:
614: if ($template == "") {
615: $template = '--- ' . i18n("none") . ' ---';
616: }
617:
618:
619: $descString = '<b>' . $template . '</b>';
620:
621: if (sizeof($templateDescription) > 0) {
622: $descString .= '<br>' . $templateDescription;
623: }
624:
625: $sTemplatename = $template;
626: if (strlen($template) > 20) {
627: $sTemplatename = cApiStrTrimHard($sTemplatename, 20);
628: }
629:
630: $tpl->set('d', 'TPLNAME', $sTemplatename);
631: $tpl->set('d', 'TPLDESC', $descString);
632:
633: if ($perm->have_perm_area_action($tmp_area, 'str_renamecat') || $perm->have_perm_area_action_item($tmp_area, 'str_renamecat', $value->id)) {
634: $bPermRename = 1;
635: } else {
636: $bPermRename = 0;
637: }
638:
639: if ($perm->have_perm_area_action('str_tplcfg', 'str_tplcfg') || $perm->have_perm_area_action_item('str_tplcfg', 'str_tplcfg', $value->id)) {
640: $bPermTplcfg = 1;
641: } else {
642: $bPermTplcfg = 0;
643: }
644:
645: $aRecord = array();
646: $sCatName = $value->name;
647:
648:
649: $aRecord['catn'] = $sCatName;
650: $sAlias = $value->custom['alias'];
651:
652: $aRecord['alias'] = conHtmlSpecialChars($sAlias);
653: $aRecord['idtplcfg'] = $value->custom['idtplcfg'];
654: $aRecord['pName'] = $bPermRename;
655: $aRecord['pTplcfg'] = $bPermTplcfg;
656: $aInlineEditData[$value->id] = $aRecord;
657:
658: if ($perm->have_perm_area_action($area, "str_renamecat")) {
659: $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>");
660: } else {
661: $tpl->set('d', 'RENAMEBUTTON', "");
662: }
663: $tpl->set('d', 'CATID', $value->id);
664: $tpl->set('d', 'PARENTID', $value->custom['parentid']);
665: $tpl->set('d', 'POSTID', $value->custom['postid']);
666: $tpl->set('d', 'PREID', $value->custom['preid']);
667: $tpl->set('d', 'LEVEL', $value->custom['level']);
668:
669: if (strlen($template) > 20) {
670: $tpl->set('d', 'SHOW_MOUSEOVER', 'title="' . $descString . '"');
671: } else {
672: $tpl->set('d', 'SHOW_MOUSEOVER', '');
673: }
674:
675: $tpl->set('d', 'MOUSEOVER', $sMouseover);
676:
677: if ($perm->have_perm_area_action($tmp_area, 'str_newcat') || $perm->have_perm_area_action_item($tmp_area, 'str_newcat', $value->id)) {
678: $bAreaAddNewCategory = true;
679: }
680:
681: if ($perm->have_perm_area_action($tmp_area, 'str_makevisible') || $perm->have_perm_area_action_item($tmp_area, 'str_makevisible', $value->id)) {
682: if ($value->custom['visible'] == 1) {
683: $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>");
684: } else {
685: $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>");
686: }
687: } else {
688: $tpl->set('d', 'VISIBLEBUTTON', ' ');
689: }
690:
691: if ($perm->have_perm_area_action($tmp_area, 'str_makepublic') || $perm->have_perm_area_action_item($tmp_area, 'str_makepublic', $value->id)) {
692: if ($value->custom['public'] == 1) {
693: $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>");
694: } else {
695: $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>");
696: }
697: } else {
698: $tpl->set('d', 'PUBLICBUTTON', ' ');
699: }
700:
701: $hasChildren = strNextDeeper($value->id);
702: $hasArticles = strHasArticles($value->id);
703: 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))) {
704: $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>";
705: $tpl->set('d', 'DELETEBUTTON', $delete);
706: } else {
707: $message = i18n("No permission");
708:
709: if ($hasChildren) {
710: $button = 'delete_inact_h.gif';
711: $alt = i18n("One or more subtrees and one or more articles are existing, unable to delete.");
712: }
713:
714: if ($hasArticles) {
715: $button = 'delete_inact_g.gif';
716: $alt = i18n("One or more articles are existing, unable to delete.");
717: }
718: if ($hasChildren && $hasArticles) {
719: $button = 'delete_inact.gif';
720: $alt = i18n("One or more articles are existing, unable to delete.");
721: }
722:
723: $tpl->set('d', 'DELETEBUTTON', '<img src="' . $cfg["path"]["images"] . $button . '" alt="' . $alt . '" title="' . $alt . '">');
724: }
725:
726: if ($perm->have_perm_area_action($tmp_area, 'str_moveupcat') || $perm->have_perm_area_action_item($tmp_area, 'str_moveupcat', $value->id)) {
727: $rand = rand();
728: if ($value->custom['parentid'] == 0 && $value->custom['preid'] == 0) {
729: $tpl->set('d', 'UPBUTTON', '<img src="images/folder_moveup_inact.gif" title="' . i18n("This category is already at the top") . '">');
730: } else {
731: if ($value->custom['preid'] != 0) {
732: $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>");
733: } else {
734: $tpl->set('d', 'UPBUTTON', '<img src="images/folder_moveup_inact.gif" title="' . i18n("This category is already at the top") . '">');
735: }
736: }
737: } else {
738: $tpl->set('d', 'UPBUTTON', '<img src="images/folder_moveup_inact.gif">');
739: }
740:
741: if ($perm->have_perm_area_action($tmp_area, 'str_movedowncat') || $perm->have_perm_area_action_item($tmp_area, 'str_movedowncat', $value->id)) {
742: $rand = rand();
743: if ($value->custom['postid'] == 0) {
744: $tpl->set('d', 'DOWNBUTTON', '<img src="images/folder_movedown_inact.gif" title="' . i18n("This category is already at the bottom") . '">');
745: } else {
746: $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>");
747: }
748: } else {
749: $tpl->set('d', 'DOWNBUTTON', '<img src="images/folder_movedown_inact.gif">');
750: }
751:
752: if (($action === 'str_movesubtree') && (!isset($parentid_new))) {
753: if ($perm->have_perm_area_action($tmp_area, 'str_movesubtree') || $perm->have_perm_area_action_item($tmp_area, 'str_movesubtree', $value->id)) {
754: if ($value->id == $idcat) {
755: $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>");
756: } else {
757: $allowed = strMoveCatTargetallowed($value->id, $idcat);
758: if ($allowed == 1) {
759: $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>");
760: } else {
761: $tpl->set('d', 'MOVEBUTTON', ' ');
762: }
763: }
764: } else {
765: $tpl->set('d', 'MOVEBUTTON', ' ');
766: }
767: } else {
768: if ($perm->have_perm_area_action($tmp_area, 'str_movesubtree') || $perm->have_perm_area_action_item($tmp_area, 'str_movesubtree', $value->id)) {
769:
770: if ($value->custom['parentid'] != 0) {
771: $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>");
772: } else {
773: $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") . '">');
774: }
775: } else {
776: $tpl->set('d', 'MOVEBUTTON', ' ');
777: }
778: }
779:
780: if ($perm->have_perm_area_action('str', 'str_duplicate') || $perm->have_perm_area_action_item('str', 'str_duplicate', $value->id)) {
781: $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>";
782: $tpl->set('d', 'DUPLICATEBUTTON', $duplicate);
783: } else {
784: $tpl->set('d', 'DUPLICATEBUTTON', ' ');
785: }
786:
787:
788: cInclude('includes', 'functions.lang.php');
789: $tpl->set('d', 'DIRECTION', 'dir="' . langGetTextDirection($lang, $oDirectionDb) . '"');
790:
791: $columns = array();
792:
793: foreach ($listColumns as $key => $content) {
794: $columnContents = array();
795: $_cecIterator = $_cecRegistry->getIterator('Contenido.CategoryList.RenderColumn');
796: if ($_cecIterator->count() > 0) {
797: while ($chainEntry = $_cecIterator->next()) {
798: $columnContents[] = $chainEntry->execute($value->id, $key);
799: }
800: } else {
801: $columnContents[] = '';
802: }
803: $columns[] = '<td class="str-style-d">' . implode("", $columnContents) . '</td>';
804: }
805:
806: $tpl->set('d', 'ADDITIONALCOLUMNS', implode("", $columns));
807: $tpl->next();
808: }
809: }
810:
811: $jsDataArray = "";
812: foreach ($aInlineEditData as $iIdCat => $aData) {
813: $aTmp = array();
814: foreach ($aData as $aKey => $aValue) {
815: $aTmp[] = $aKey . "':'" . addslashes($aValue);
816: }
817: $jsDataArray .= "
818: strDataObj[$iIdCat] = {'" . implode("', '", $aTmp) . "'};";
819: }
820:
821: $tpl->set('s', 'JS_DATA', $jsDataArray);
822:
823: $string = markSubMenuItem(0, true);
824:
825:
826: $sImagepath = $cfg["path"]["images"];
827: $tpl->set('s', 'SUM_COLUMNS', 15 + count($listColumns));
828: $tpl->set('s', 'HREF_ACTION', $sess->url("main.php?frame=$frame"));
829: $tpl->set('s', 'CON_IMAGES', $backendUrl . $cfg["path"]["images"]);
830:
831:
832: $oSession = new cHTMLHiddenField($sess->name, $sess->id);
833: $oActionEdit = new cHTMLHiddenField('action', 'str_renamecat');
834: $oIdcat = new cHTMLHiddenField('idcat');
835:
836: $tpl->set('s', 'INPUT_SESSION', $oSession->render());
837: $tpl->set('s', 'INPUT_ACTION_EDIT', $oActionEdit->render());
838: $tpl->set('s', 'INPUT_IDCAT', $oIdcat->render());
839:
840: $oVisible = new cHTMLHiddenField('visible', 0, 'visible_input');
841: $oPublic = new cHTMLHiddenField('public', 1, 'public_input');
842: $oTemplate = new cHTMLHiddenField('idtplcfg', 0, 'idtplcfg_input');
843:
844: $tpl->set('s', 'INPUT_VISIBLE', $oVisible->render());
845: $tpl->set('s', 'INPUT_PUBLIC', $oPublic->render());
846: $tpl->set('s', 'INPUT_TEMPLATE', $oTemplate->render());
847:
848: $oCatName = new cHTMLTextbox('categoryname', '', '', '', 'cat_categoryname');
849: $oCatName->setStyle('width:150px; vertical-align:middle;');
850: $tpl->set('s', 'INPUT_CATNAME_NEW', $oCatName->render());
851:
852: $oAlias = new cHTMLTextbox('categoryalias');
853: $oAlias->setStyle('width:150px; vertical-align:middle;');
854: $tpl->set('s', 'INPUT_ALIAS_NEW', $oAlias->render());
855:
856: $oNewCatName = new cHTMLTextbox('newcategoryname');
857: $oNewCatName->setStyle('width:150px; vertical-align:middle;');
858: $tpl->set('s', 'INPUT_CATNAME_EDIT', $oNewCatName->render());
859:
860: $oNewAlias = new cHTMLTextbox('newcategoryalias');
861: $oNewAlias->setStyle('width:150px; vertical-align:middle;');
862: $tpl->set('s', 'INPUT_ALIAS_EDIT', $oNewAlias->render());
863:
864: $sCategorySelect = buildCategorySelectRights('idcat', '');
865:
866:
867:
868: 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) {
869: $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>');
870: if ($perm->have_perm_area_action($tmp_area, 'str_newtree')) {
871: if ($perm->have_perm_area_action($tmp_area, 'str_newcat') || $bAreaAddNewCategory) {
872: $tpl->set('s', 'PERMISSION_NEWTREE', '');
873: $oActionNew = new cHTMLHiddenField('action', 'str_newcat', 'cat_new_action');
874: } else {
875: $tpl->set('s', 'PERMISSION_NEWTREE', 'disabled checked');
876: $oActionNew = new cHTMLHiddenField('action', 'str_newcat', 'str_newtree');
877: }
878: $tpl->set('s', 'INPUT_ACTION_NEW', $oActionNew->render());
879: $tpl->set('s', 'PERMISSION_NEWTREE_DISPLAY', 'block');
880: } else {
881: $oActionNew = new cHTMLHiddenField('action', 'str_newcat', 'cat_new_action');
882: $tpl->set('s', 'PERMISSION_NEWTREE', 'disabled');
883: $tpl->set('s', 'PERMISSION_NEWTREE_DISPLAY', 'none');
884: $tpl->set('s', 'NEW_ACTION', 'str_newcat');
885: $tpl->set('s', 'INPUT_ACTION_NEW', $oActionNew->render());
886: }
887:
888: if ($perm->have_perm_area_action($tmp_area, 'str_newcat') || $bAreaAddNewCategory) {
889: $tpl->set('s', 'CATEGORY_SELECT', $sCategorySelect);
890: $tpl->set('s', 'PERMISSION_NEWCAT_DISPLAY', 'block');
891: } else {
892: $tpl->set('s', 'CATEGORY_SELECT', '');
893: $tpl->set('s', 'PERMISSION_NEWCAT_DISPLAY', 'none');
894: }
895:
896: if ($perm->have_perm_area_action('str_tplcfg', 'str_tplcfg')) {
897: $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>');
898: $tpl->set('s', 'SELECT_TEMPLATE', getTemplateSelect());
899: } else {
900: $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') . '">');
901: $tpl->set('s', 'SELECT_TEMPLATE', '');
902: }
903:
904: if ($perm->have_perm_area_action($tmp_area, 'str_makevisible')) {
905: $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>');
906: } else {
907: $tpl->set('s', 'MAKEVISIBLE_BUTTON_NEW', '<img src="' . $sImagepath . 'offline_off.gif" id="visible_image" title="' . i18n('Make online') . '" alt="' . i18n('Make online') . '">');
908: }
909:
910: if ($perm->have_perm_area_action($tmp_area, 'str_makepublic')) {
911: $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>');
912: } else {
913: $tpl->set('s', 'MAKEPUBLIC_BUTTON_NEW', '<img src="' . $sImagepath . 'folder_delocked.gif" id="public_image" title="' . i18n('Protect category') . '" alt="' . i18n('Protect category') . '">');
914: }
915: } else {
916: $tpl->set('s', 'NEWCAT', $string);
917:
918: $tpl->set('s', 'PERMISSION_NEWTREE', 'disabled');
919: $tpl->set('s', 'PERMISSION_NEWTREE_DISPLAY', 'none');
920:
921: $tpl->set('s', 'CATEGORY_SELECT', '');
922: $tpl->set('s', 'PERMISSION_NEWCAT_DISPLAY', 'none');
923:
924: $tpl->set('s', 'TEMPLATE_BUTTON_NEW', '');
925: $tpl->set('s', 'MAKEVISIBLE_BUTTON_NEW', '');
926: $tpl->set('s', 'MAKEPUBLIC_BUTTON_NEW', '');
927:
928: $tpl->set('s', 'NEW_ACTION', 'str_newcat');
929: $tpl->set('s', 'SELECT_TEMPLATE', '');
930: }
931:
932:
933: $clang = new cApiLanguage($lang);
934:
935: if ($movesubtreeidcat != 0) {
936: if (strlen($sMoveSubtreeCatName) > 30) {
937: $sLimiter = "...";
938: } else {
939: $sLimiter = "";
940: }
941: $sButtonDesc = sprintf(i18n('Cancel moving %s'), '"' . substr($sMoveSubtreeCatName, 0, 30) . $sLimiter . '"');
942: $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>');
943: } else {
944: $tpl->set('s', 'CANCEL_MOVE_TREE', '');
945: }
946:
947: $tpl->setEncoding($clang->get("encoding"));
948: $tpl->generate($cfg['path']['templates'] . $cfg['templates']['str_overview']);
949: