query_first("SELECT u.username, t.*, c.name AS category_name, r.name AS country_name FROM toolbars t, users u, categories c, countries r WHERE t.toolbar_id=$_GET[toolbar_id] AND t.user_id=u.user_id AND t.category_id=c.category_id AND r.country_id=t.country_id"); $smarty->assign('toolbar', $row); $smarty->assign('toolbar_html', CreateToolbar($row['toolbar_xml'])); $smarty->assign('additional_html', $additional_html); $smarty->assign('drop_down_menus', $drop_down_menus); $smarty->assign('page_title', $row['name'] . ' - Groowe toolbars'); if (($row['public'] == 0) && ($_SESSION['username'] != $row['username'])) { header("Location: /toolbars/message/private-toolbar"); exit(); } // comments $comments = array(); $sql = "SELECT SQL_CALC_FOUND_ROWS u.username, c.comment, c.posted_on FROM comments c, users u WHERE c.toolbar_id=$_GET[toolbar_id] AND c.user_id=u.user_id ORDER BY c.posted_on DESC"; if ($_GET['comments'] != 1) { $sql .= " LIMIT 5"; } else { $smarty->assign('show_all_comments', true); } $db->query($sql); while ($row = $db->fetch_array()) { $comments[] = $row; } $db->free_result(); $smarty->assign('comments', $comments); $row = $db->query_first("SELECT FOUND_ROWS() AS cnt"); $smarty->assign('comments_count', $row['cnt']); $smarty->assign('js_files', array('/toolbars/scripts/ajax.js', '/toolbars/scripts/drag_drop.js')); $smarty->display('view_toolbar.tpl'); /** * Create toobar preview * @param string Toolbar configuration file as XML string * @return string HTML string representing toolbar preview */ function CreateToolbar($toolbar_xml) { global $additional_html; $html .= ""; $xmldoc = simplexml_load_string($toolbar_xml); $logo_src = $xmldoc->Logo['LogoID']; $logo_url = strpos($logo_src, "://") === FALSE ? "http://www.groowe.com/ff-plugins/logos_bundled/$logo_src.png" : "$logo_src"; $html .= ""; $html .= ""; $html .= ""; $order_array = array(); if ($xmldoc->Order != "") { $order_array = split(";", $xmldoc->Order); } else { foreach ($xmldoc->Items->Item as $item) { if ($item['ID'] != "") { $order_array[] = $item['ID']; } } } // additional buttons $additional_array = array(); foreach ($xmldoc->Items->Item as $item) { if (($item['ID'] != "") && (!in_array($item['ID'], $order_array))) { $additional_array[] = $item['ID']; } } foreach ($order_array as $item_id) { if ($item_id == 0) { $html .= ""; } else { $items = $xmldoc->xpath("/Toolbar/Items/Item[@ID=$item_id]"); $item = $items[0]; if ($item) { $html .= CreateButton($item); } } } foreach ($additional_array as $item_id) { if ($item_id == 0) { $additional_html .= ""; } else { $items = $xmldoc->xpath("/Toolbar/Items/Item[@ID=$item_id]"); $item = $items[0]; if ($item) { $additional_html .= CreateButton($item); } } } return $html; } /* * Create button for toolbar preview * @param object XML node containing button definition * * */ function CreateButton($item) { global $drop_down_menus; $html = "
"; if ($item['IconID']) { $icon_url = strpos($item['IconID'], "://") === FALSE ? "http://www.groowe.com/ff-plugins/icons_bundled/$item[IconID].png" : "$item[IconID]"; $html .= ""; } $html .= "$item[Caption]"; if (count($item->children()) != 0) { $sub_menu = ""; $drop_down_menus[] = $sub_menu; $html .= ""; } $html .= "
"; return $html; } ?>