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