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