function parse_tree($tree, $related_pages, $level = 0) { $spacer = str_repeat('-', $level); foreach ($tree as $page) { $related_pages[$page['id']] = $spacer . $page['title']; if (count($page['children']) > 0) { $related_pages = parse_tree($page['children'], $related_pages, $level + 1); } } return $related_pages; }
function parse_tree($parent_env, $spaceholder) { global $steam; global $current_room; global $image_width; global $path; global $tpl; global $treeview_mini; global $show_hidden; global $inventorybuffer; global $inventorybuffer_tnr; global $treeobjects; global $inventorybuffer_access; global $additional_data; global $additional_tnr; global $exit_data; global $exit_tnr; global $additionalinventorybuffer_access; global $additionalinventorybuffer_tnr; $allowed = $inventorybuffer[$inventorybuffer_access[$parent_env->get_id()]]; if ($allowed) { $inventories = $inventorybuffer[$inventorybuffer_tnr[$parent_env->get_id()]]; } else { $inventories = array(); } $next_env = array_shift($path); //output current inventory depth foreach ($inventories as $item) { #$item = steam_factory::get_object( $steam, $item->get_id() ); //dont show portals and questionaries if ($item->get_attribute(OBJ_TYPE) === "container_portal_bid" || $item->get_attribute("bid:doctype") === "portal" || $item->get_attribute("bid:doctype") === "questionary") { continue; } // find display name if ($item->get_attribute(OBJ_DESC) != "") { $object_display_name = str_replace("s workroom.", "", $item->get_attribute(OBJ_DESC)); } else { $object_display_name = stripslashes(str_replace("'s workarea", "", $item->get_attribute(OBJ_NAME))); } //set template vars if ($item instanceof steam_exit && is_object($additional_data[$additional_tnr[$item->get_id()]["exit"]])) { $folder_id = $additional_data[$additional_tnr[$item->get_id()]["exit"]]->get_id(); } else { $folder_id = $item->get_id(); } $tpl->set_var(array("SPACEHOLDER" => $spaceholder, "FOLDER_ID" => $folder_id, "FOLDER_NAME" => $object_display_name, "FOLDER_NAME_GREY" => $object_display_name)); $index = $item->get_attribute("bid:presentation") === "index" ? "_index" : ""; $state = is_object($next_env) && $item->get_id() == $next_env->get_id() ? "open" : "closed"; //if item is hidden, either show it in grey color or skip if ($item->get_attribute("bid:hidden")) { if ($show_hidden && $item->get_attribute("bid:hidden") != "hide_always") { $tpl->parse("FOLDER_NAME", "grey_name"); } else { continue; } } //parse current folder if ($state == "open" && $treeview_mini || !$treeview_mini || $parent_env->get_id() == $current_room->get_id()) { if ($item->get_attribute("bid:collectiontype") === "sequence") { $icon = "sequence"; } else { if ($item->get_attribute("bid:collectiontype") === "cluster") { $icon = "cluster"; } else { if ($item->get_attribute("bid:collectiontype") === "gallery") { $icon = "gallery"; } else { if ($item instanceof steam_exit) { $icon = "exit"; } else { if ($item->get_attribute("OBJ_TYPE") === "LARS_DESKTOP") { continue; } else { $icon = $state . "folder" . $index; } } } } } if (!$item instanceof steam_exit) { if ($additional_data[$additionalinventorybuffer_access[$item->get_id()]] && count($additional_data[$additionalinventorybuffer_tnr[$item->get_id()]]) > 0) { $fInventory = $state; } else { $fInventory = "empty"; } } else { if ($exit_data[$exit_tnr[$folder_id]["access"]] && count($exit_data[$exit_tnr[$folder_id]["inventory"]]) > 0) { $fInventory = $state; } else { $fInventory = "empty"; } } $tpl->parse("OPEN_CLOSED_FOLDER", $fInventory . "branch"); $tpl->parse("OPEN_CLOSED_FOLDER", $icon, true); $tpl->parse("FOLDERS", "folder", true); } //process subfolders if folder is open if ($state == "open") { parse_tree($next_env, $spaceholder + $image_width); } } }
function show() { global $set, $db, $apx, $html; //Struktur reparieren if ($_REQUEST['repair'] && $set['gallery']['subgals']) { $this->cat->repair(); echo 'Repair done!'; return; } //Suche durchführen if (!$set['gallery']['subgals'] && $_REQUEST['item']) { $where = ''; //Suchbegriff if ($_REQUEST['item']) { $where .= " AND title LIKE '%" . addslashes_like($_REQUEST['item']) . "%'"; } $data = $db->fetch("SELECT id FROM " . PRE . "_gallery WHERE 1 " . $where); $ids = get_ids($data, 'id'); $ids[] = -1; $searchid = saveSearchResult('admin_gallery', $ids, array('item' => $_REQUEST['item'])); header("HTTP/1.1 301 Moved Permanently"); header('Location: action.php?action=gallery.show&what=' . $_REQUEST['what'] . '&searchid=' . $searchid); return; } quicklink('gallery.add'); //DnD-Hinweis if ($apx->user->has_right('gallery.edit') && ($set['gallery']['subgals'] || $set['gallery']['ordergal'] == 3)) { echo '<p class="hint">' . $apx->lang->get('USEDND') . '</p>'; } $orderdef[0] = 'title'; $orderdef['title'] = array('title', 'ASC', 'COL_TITLE'); $orderdef['addtime'] = array('addtime', 'DESC', 'SORT_ADDTIME'); $orderdef['starttime'] = array('starttime', 'DESC', 'COL_STARTTIME'); //Suchergebnis? $resultFilter = ''; if (!$set['gallery']['subgals'] && $_REQUEST['searchid']) { $searchRes = getSearchResult('admin_gallery', $_REQUEST['searchid']); if ($searchRes) { list($resultIds, $resultMeta) = $searchRes; $_REQUEST['item'] = $resultMeta['item']; $resultFilter = " AND a.id IN (" . implode(', ', $resultIds) . ")"; } else { $_REQUEST['searchid'] = ''; } } $col[] = array(' ', 0, ''); $col[] = array('ID', 0, 'align="center"'); $col[] = array('COL_TITLE', 60, 'class="title"'); $col[] = array('COL_STARTTIME', 25, 'align="center"'); $col[] = array('COL_COUNT', 15, 'align="center"'); if (!$set['gallery']['subgals']) { $apx->tmpl->assign('ITEM', compatible_hsc($_REQUEST['item'])); $apx->tmpl->parse('search'); letters('action.php?action=gallery.show' . iif($_REQUEST['searchid'], '&searchid=' . $_REQUEST['searchid'])); if ($_REQUEST['letter'] == 'spchar') { $where = " AND title NOT REGEXP(\"^[a-zA-Z]\") "; } elseif ($_REQUEST['letter']) { $where = " AND title LIKE '" . addslashes($_REQUEST['letter']) . "%' "; } list($count) = $db->first("SELECT count(id) FROM " . PRE . "_gallery AS a WHERE 1 " . $resultFilter . $where . section_filter(true, 'secid')); pages('action.php?action=gallery.show' . iif($_REQUEST['searchid'], '&searchid=' . $_REQUEST['searchid']) . '&sortby=' . $_REQUEST['sortby'] . '&letter=' . $_REQUEST['letter'], $count); //Orderby if ($set['gallery']['ordergal'] == 3) { $sortby = ' ORDER BY ord ASC '; $orderdef = array(); } else { $sortby = getorder($orderdef); } $data = $db->fetch("SELECT id,secid,title,starttime,endtime FROM " . PRE . "_gallery AS a WHERE 1 " . $resultFilter . $where . section_filter(true, 'secid') . $sortby . getlimit()); } else { $data = $this->cat->getTree(array('*'), null, section_filter(false, 'secid')); } if (count($data)) { //Untergalerien? if ($set['gallery']['subgals']) { list($space, $follow) = parse_tree($data); $isactive[0] = true; //Root ist immer aktiv ;) } $i = ($_REQUEST['p'] - 1) * $set['admin_epp']; foreach ($data as $res) { ++$i; if ($res['level'] == 1) { ++$tree; } $isactive[$res['level']] = $res['starttime']; if (!$res['starttime']) { $tabledata[$i]['COL1'] = '<img src="design/reddot.gif" alt="' . $apx->lang->get('CORE_INACTIVE') . '" title="' . $apx->lang->get('CORE_INACTIVE') . '" />'; } elseif ($res['endtime'] < time()) { $tabledata[$i]['COL1'] = '<img src="design/greendotcross.gif" alt="' . $apx->lang->get('CORE_INACTIVE') . '" title="' . $apx->lang->get('CORE_INACTIVE') . '" />'; } elseif ($res['starttime'] > time()) { $tabledata[$i]['COL1'] = '<img src="design/greendotwait.gif" alt="' . $apx->lang->get('CORE_ACTIVE') . '" title="' . $apx->lang->get('CORE_ACTIVE') . '" />'; } else { $tabledata[$i]['COL1'] = '<img src="design/greendot.gif" alt="' . $apx->lang->get('CORE_ACTIVE') . '" title="' . $apx->lang->get('CORE_ACTIVE') . '" />'; } $tmp = unserialize_section($res['secid']); $title = replace(strip_tags($res['title'])); $link = mklink('gallery.php?id=' . $res['id'], 'gallery,list' . $res['id'] . ',1' . urlformat($res['title']) . '.html', iif($set['main']['forcesection'], iif(unserialize_section($res['secid']) == array('all'), $apx->section_default, array_shift($tmp)), 0)); list($pics) = $db->first("SELECT count(id) FROM " . PRE . "_gallery_pics WHERE galid='" . $res['id'] . "'"); list($activepics) = $db->first("SELECT count(id) FROM " . PRE . "_gallery_pics WHERE ( galid='" . $res['id'] . "' AND active='1' )"); $tabledata[$i]['COL2'] = $res['id']; $tabledata[$i]['COL3'] = '<a href="' . $link . '" target="_blank">' . $title . '</a>'; $tabledata[$i]['COL4'] = iif($res['starttime'], mkdate($res['starttime'], '<br />'), ' '); $tabledata[$i]['COL5'] = number_format($pics, 0, '', '.'); $tabledata[$i]['CLASS'] = 'l' . ($res['level'] - 1) . ($res['children'] ? ' haschildren' : '') . ($res['level'] > 1 ? ' hidden' : ''); $tabledata[$i]['ID'] = 'node:' . $res['id']; //Optionen if ($apx->user->has_right('gallery.edit')) { $tabledata[$i]['OPTIONS'] .= optionHTML('edit.gif', 'gallery.edit', 'id=' . $res['id'], $apx->lang->get('CORE_EDIT')); } else { $tabledata[$i]['OPTIONS'] .= '<img src="design/ispace.gif" alt="" />'; } if ($apx->user->has_right('gallery.del')) { $tabledata[$i]['OPTIONS'] .= '<span class="ifhasnochildren">' . optionHTMLOverlay('del.gif', 'gallery.del', 'id=' . $res['id'], $apx->lang->get('CORE_DEL')) . '</span><span class="ifhaschildren"><img alt="" src="design/ispace.gif"/></span>'; } else { $tabledata[$i]['OPTIONS'] .= '<img src="design/ispace.gif" alt="" />'; } if ((!$res['starttime'] || $res['endtime'] < time()) && $apx->user->has_right('gallery.enable') && (!$set['gallery']['subgals'] || $isactive[$res['level'] - 1])) { $tabledata[$i]['OPTIONS'] .= optionHTMLOverlay('enable.gif', 'gallery.enable', 'id=' . $res['id'], $apx->lang->get('CORE_ENABLE')); } elseif ($res['starttime'] && $apx->user->has_right('gallery.disable')) { $tabledata[$i]['OPTIONS'] .= optionHTMLOverlay('disable.gif', 'gallery.disable', 'id=' . $res['id'], $apx->lang->get('CORE_DISABLE')); } else { $tabledata[$i]['OPTIONS'] .= '<img src="design/ispace.gif" alt="" />'; } $tabledata[$i]['OPTIONS'] .= ' '; if ($apx->user->has_right('gallery.pshow')) { $tabledata[$i]['OPTIONS'] .= optionHTML('pic.gif', 'gallery.pshow', 'id=' . $res['id'], $apx->lang->get('SHOWPICS')); } if ($apx->user->has_right('gallery.padd')) { $tabledata[$i]['OPTIONS'] .= optionHTML('picadd.gif', 'gallery.padd', 'id=' . $res['id'], $apx->lang->get('ADDPICS')); } //Kommentare + Bewertungen if ($apx->is_module('comments')) { $tabledata[$i]['OPTIONS'] .= ' '; list($comments) = $db->first("SELECT count(id) FROM " . PRE . "_comments WHERE ( module='galleryself' AND mid='" . $res['id'] . "' )"); if ($comments && $set['gallery']['galcoms'] && $res['allowcoms'] && $apx->user->has_right('comments.show')) { $tabledata[$i]['OPTIONS'] .= optionHTML('comments.gif', 'comments.show', 'module=galleryself&mid=' . $res['id'], $apx->lang->get('COMMENTS') . ' (' . $comments . ')'); } else { $tabledata[$i]['OPTIONS'] .= '<img src="design/ispace.gif" alt="" />'; } } //Anordnen: Untergalerien /*if ( $set['gallery']['subgals'] ) { $tabledata[$i]['OPTIONS'].=' '; if ( $apx->user->has_right('gallery.move') && $follow[$res['id']]['prev'] ) $tabledata[$i]['OPTIONS'].=optionHTML('moveup.gif', 'gallery.move', 'direction=up&id='.$res['id'].'§oken='.$apx->session->get('sectoken'), $apx->lang->get('MOVEUP')); else $tabledata[$i]['OPTIONS'].='<img src="design/ispace_small.gif" alt="" style="vertical-align:middle;" />'; if ( $apx->user->has_right('gallery.move') && $follow[$res['id']]['next'] ) $tabledata[$i]['OPTIONS'].=optionHTML('movedown.gif', 'gallery.move', 'direction=down&id='.$res['id'].'§oken='.$apx->session->get('sectoken'), $apx->lang->get('MOVEDOWN')); else $tabledata[$i]['OPTIONS'].='<img src="design/ispace_small.gif" alt="" style="vertical-align:middle;" />'; } //Anordnen: Einfach elseif ( !$set['gallery']['subgals'] && $set['gallery']['ordergal']==3 ) { $tabledata[$i]['OPTIONS'].=' '; if ( $apx->user->has_right('gallery.move') && $i!=1 ) $tabledata[$i]['OPTIONS'].=optionHTML('moveup.gif', 'gallery.move', 'direction=up&id='.$res['id'].'§oken='.$apx->session->get('sectoken'), $apx->lang->get('MOVEUP')); else $tabledata[$i]['OPTIONS'].='<img src="design/ispace_small.gif" alt="" style="vertical-align:middle;" />'; if ( $apx->user->has_right('gallery.move') && $i!=$count ) $tabledata[$i]['OPTIONS'].=optionHTML('movedown.gif', 'gallery.move', 'direction=down&id='.$res['id'].'§oken='.$apx->session->get('sectoken'), $apx->lang->get('MOVEDOWN')); else $tabledata[$i]['OPTIONS'].='<img src="design/ispace_small.gif" alt="" style="vertical-align:middle;" />'; }*/ if ($res['level'] == 1) { ++$pdone[0]; } else { ++$pdone[$tree][$res['level']]; } } } $apx->tmpl->assign('TABLE', $tabledata); if ($set['gallery']['subgals']) { echo '<div class="treeview" id="tree">'; $html->table($col); echo '</div>'; $open = $apx->session->get('gallery_open'); $open = dash_unserialize($open); $opendata = array(); foreach ($open as $catid) { $opendata[] = array('ID' => $catid); } $apx->tmpl->assign('OPEN', $opendata); $apx->tmpl->assign('EDIT_ALLOWED', $apx->user->has_Right('gallery.edit')); $apx->tmpl->parse('show_js'); } elseif ($set['gallery']['ordergal'] == 3) { echo '<div class="listview" id="list">'; $html->table($col); echo '</div>'; $apx->tmpl->parse('show_listjs'); } else { $html->table($col); orderstr($orderdef, 'action.php?action=gallery.show' . iif($_REQUEST['searchid'], '&searchid=' . $_REQUEST['searchid']) . '&letter=' . $_REQUEST['letter']); } save_index($_SERVER['REQUEST_URI']); }