Exemple #1
0
 /**
  * Generate XML for pictorial link with image swapping.
  *
  * If uri is null, plain picture is displayed
  * Width and height of images are auto detected.
  * If using image swapping, images are preloaded with javascript.
  *
  * @param        string        uri              URI to open
  * @param        string        filename         Filename for image to display.
  * @param        string        attr             Additional HTML attributes, e.g. "target=main width='100%'"
  * @param        string        m_over           Filename for image to display when mouse is over image.
  *                                              Can contain onmouse* -- will merge with our code (our code
  *                                              will be executed first!). Except for onmouse* $attr is only
  *                                              added to <img tag. Cannot contain onmouse* code. Refer to $onmouse_merge
  * @param        array         otherswap        Swap other image: array ($name, $normal, $m_over).
  * @param        array         onmouse_merge    Addition onmouseover/out code to merge with our:
  *                                                array ($m_name_merge, $m_out_merge).
  */
 public static function a_img($uri, $filename, $attr = false, $m_over = false, $otherswap = false, $onmouse_merge = false)
 {
     // $uri is false, just output picture
     if (!$uri) {
         return xml_gen::img($filename);
     }
     // Number of times xml_gen::a_img() has been called with $m_over.
     static $called;
     // Init
     $swap_out = false;
     $swap_over = false;
     // Generate onmouse* code
     if ($m_over || $otherswap) {
         // Increment called var
         $called++;
         // Has mouse over?
         if ($m_over) {
             $swap_out = "swp('spluf{$called}','spl_f{$called}'); ";
             $swap_over = "swp('spluf{$called}','splof{$called}'); ";
         }
         // Otherswap?
         if ($otherswap) {
             list($os_name, $os_normal, $os_m_over) = $otherswap;
             if (!$os_name || !$os_normal || !$os_m_over) {
                 die("{$otherswap} requires array with three string.");
             }
             $swap_out .= "swp('{$os_name}','spl_q{$called}'); ";
             $swap_over .= "swp('{$os_name}','sploq{$called}'); ";
         }
     }
     // Onmouse* merge`?
     if ($onmouse_merge) {
         list($merge_over, $merge_out) = $onmouse_merge;
         if (!$merge_over || !$merge_out) {
             die("{$onmouse_merge} requires array with two strings.");
         }
         $swap_out .= $merge_out;
         $swap_over .= $merge_over;
     }
     // Set name only if swapping
     $name = $m_over || $otherswap ? "name='spluf{$called}'" : "";
     // Output link and picture
     $result = xml_gen::a($uri, xml_gen::img($filename, "{$name} {$attr}"), "onclick='this.blur()' onmouseout=\"{$swap_out}\" onmouseover=\"{$swap_over}\"");
     // If no m_over, return result
     if (!$m_over && !$otherswap) {
         return $result;
     }
     // Else preload images
     $result .= "<script type='text/javascript'>\n<!--\n\n";
     // On first a_img() call, we insert the swp() javascript function.
     if ($called == 1) {
         $result .= "function swp(id,name) { if (document.images) document.images[id].src = eval(name+'.src'); }\n\n";
     }
     // Insert preload code.
     if ($m_over) {
         $result .= "if (document.images) {\r\n                  spl_f{$called} = new Image; spl_f{$called}.src = '{$filename}';\r\n                  splof{$called} = new Image; splof{$called}.src = '{$m_over}';\r\n              }";
     }
     // Insert preload code - otherswap
     if ($otherswap) {
         $result .= "if (document.images) {\r\n                      spl_q{$called} = new Image; spl_q{$called}.src = '{$os_normal}';\r\n                      sploq{$called} = new Image; sploq{$called}.src = '{$os_m_over}';\r\n                  }";
     }
     return $result . "\n\n// -->\n</script>";
 }
 /**
  * Generate XML for simple file view
  *
  * @param    array of int => string     files       getid3.id => getid3.filename
  */
 function generate_file_view_simple($files)
 {
     $g = new xml_gen();
     // sort by filename without root (may yield strange results with multiple roots)
     uasort($files, 'strcoll');
     // loop thru files
     foreach ($files as $id => $filename) {
         // increase filecount
         @$count++;
         // link to play filename and tooltip on first 50 entries (more tooltips may kill browser)
         $path = iconv('UTF-8', $this->server_cp, $filename);
         echo $g->p($g->a('./?action=play&location=' . urlencode($path), $filename, $count > 50 ? null : $this->generate_tooltip_xml($this->get_extended_file_info($id))));
     }
 }
function CommonFooter()
{
    foreach (array('iconv', 'zlib', 'exif', 'mysql', 'dba') as $ext) {
        $support[] = (extension_loaded($ext) ? '+' : '-') . $ext;
    }
    echo xml_gen::br();
    echo xml_gen::p('getID3() ' . getid3::VERSION . '.<br>PHP ' . phpversion() . ' (' . implode(xml_gen::space(2), $support) . ').');
    echo xml_gen::p(xml_gen::a('http://getid3.sourceforge.net/', 'http://getid3.sourceforge.net'));
    echo '</body></html>';
}
function compress($string)
{
    static $i;
    $i++;
    $string2 = str_replace('<br>', ', ', $string);
    if (strlen($string2) <= GETID3_COMPRESS_LENGTH) {
        return $string2;
    }
    $string3 = str_replace("<br>", "\\n", addslashes(str_replace('"', "''", $string)));
    return xml_gen::a("javascript:alert('{$string3}')", substr($string2, 0, GETID3_COMPRESS_LENGTH - 2) . '...');
}