/** * Generate XML for pictorial link with image swapping -or- Simple picture -depending- on $condition. * * @param bool condition Show Picture or xml_gen::a_img? * @param string selected Filename for image to display if $condition == true. - use m_over if set to null * @param string uri URI to open * @param string filename Filename for image to display if $condition == false. * @param string m_over Filename for image to display when mouse is over image. * @param string attr Additional HTML attributes, e.g. "target=main width='100%'". * Except for onmouse* $attr is only added to <img tag. * @param string[] otherswap Swap other image: array ($name, $normal, $m_over). * @see xml_gen::a_img */ public static function a_img_cond($condition, $selected = null, $uri, $filename, $m_over = false, $attr = false, $otherswap = false) { if ($condition) { if (is_null($selected)) { return xml_gen::a_img($uri, $m_over, $attr, $m_over, $otherswap); } else { return xml_gen::a_img($uri, $selected, $attr, $m_over, $otherswap); } } else { return xml_gen::a_img($uri, $filename, $attr, $m_over, $otherswap); } }
/** * Common XHTML header * * @param string title Title * @param string up Uri to up button or false * @param string play Uri to play button or false * @param bool sort Sort buttons active * @param bool numbers Show numbers button active */ protected function head($title, $up = false, $play = false, $sort = false, $numbers = false) { echo parent::head($title); // initialize tool tips $this->tool_tips = new tool_tips(); $g = new xml_gen(); // generate menu xml // up button $menu_xml[] = $up ? $g->a_img($up, 'images/up.png', "alt='Up one level' title='Up one level'", 'images/up-c.png') : $g->img('images/up-g.png'); // play button $menu_xml[] = $play ? $g->a_img("./?action=play&location={$play}", 'images/play.png', "alt='Play all tracks' title='Play all tracks'", 'images/play-c.png') : $g->img('images/play-g.png'); // spacer $menu_xml[] = $g->space(); // search button $menu_xml[] = $g->a_img("./?action=search", 'images/search.png', "alt='Search Metadata' title='Search Metadata'", 'images/search-c.png'); // stats button $menu_xml[] = $g->a_img("./?action=stats", 'images/stats.png', "alt='Statictics' title='Statictics'", 'images/stats-c.png'); // config button $menu_xml[] = $g->a_img('./?action=config', 'images/config.png', "alt='Configuration' title='Configuration'", 'images/config-c.png'); // all music link artist search $amg_link = $this->action != 'toc' ? "javascript:document.forms.AMG.submit()" : "http://www.allmusic.com/"; $menu_xml[] = $g->a_img($amg_link, 'images/amg.png', "alt='All Music Guide' title='All Music Guide'", 'images/amg-c.png'); // google image search $goo_link = $this->action != 'toc' ? "javascript:google()" : "http://www.google.com/"; $menu_xml[] = $g->a_img($goo_link, 'images/google.png', "alt='Google Image Search' title='Google Image Search'", 'images/google-c.png'); // spacer $menu_xml[] = $g->space(); // numbers button $img = @$_COOKIE['show_numbers'] ? 'numb' : 'num0'; $menu_xml[] = $numbers ? $g->a_img($_SERVER['REQUEST_URI'] . '&set_show_numbers=1', "images/{$img}.png", "alt='Toggle track numbers' title='Toggle track numbers'", "images/{$img}-c.png") : $g->img("images/{$img}-g.png"); // playing time button $img = @$_COOKIE['show_playtime'] ? 'time' : 'time0'; $menu_xml[] = $sort ? $g->a_img($_SERVER['REQUEST_URI'] . '&set_show_playtime=1', "images/{$img}.png", "alt='Toggle playing time' title='Toggle playing time'", "images/{$img}-c.png") : $g->img("images/{$img}-g.png"); // sort alpha button $img = $this->get_sort_mode(); $menu_xml[] = $sort ? $g->a_img($_SERVER['REQUEST_URI'] . '&set_sort_alpha=1', "images/{$img}.png", "alt='Toggle sort moder' title='Toggle sort mode'", "images/{$img}-c.png") : $g->img("images/{$img}-g.png"); // sort desc button $img = $this->get_sort_direction(); $menu_xml[] = $sort ? $g->a_img($_SERVER['REQUEST_URI'] . "&set_sort_mode=1", "images/{$img}.png", "alt='Toggle sort direction' title='Toggle sort direction'", "images/{$img}-c.png") : $g->img("images/{$img}-g.png"); // output menu and title in main table $this->t = new table(2, "id='main'"); $this->t->data(null, "id='menu'"); $t = new table(1); foreach ($menu_xml as $xml) { $t->data($xml); } $t->done(); $this->t->data($g->h1($title), "id='body'"); // all music guide code $search_string = ereg("^[#@!\\+]?([^:]+)", $title, $regs) ? $regs[1] : ""; // first part of title - split by :, remove special chars echo "\n <form action='http://www.allmusic.com/cg/amg.dll' method='post' target='AMG' name='AMG'>\n <input type='hidden' name='P' value='amg' />\n <input type='hidden' name='uid' value='SEARCH' />\n <input type='hidden' name='sql' value=\"{$search_string}\" />\n <input type='hidden' id='buttons' name='opt1' value='1' />\n </form>\n "; // google image search code $search_string = urlencode(utf8_decode(str_replace(":", '', $title))); echo "\n <script type='text/javascript'>\n <!--\n function google()\n {\n window.open('http://images.google.com/images?as_q={$search_string}&svnum=10&hl=en&imgsz=medium|large|xlarge&safe=off', 'google2', 'resizable,scrollbars,menubar,status,toolbar,location')\n window.open('http://images.google.com/images?as_q={$search_string}&svnum=10&hl=en&imgsz=xxlarge&safe=off', 'google1', 'resizable,scrollbars,menubar,status,toolbar,location')\n }\n //-->\n </script>\n "; // maximize browser window? if ($this->browser_behaviour == 'maximize') { echo "\n <script type='text/javascript'>\n <!--\n self.moveTo(0,0);\n self.resizeTo(screen.availWidth, screen.availHeight);\n // -->\n </script>\n "; } }