source: extensions/charlies_content/charlies.inc.php @ 6360

Last change on this file since 6360 was 6360, checked in by vdigital, 15 years ago

Admin page design review mainly for the "clear" theme
Code review

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1<?php
2/**
3 * 'Charlies content' generates XHTML depending on the element
4 * PDF / Musics / Videos / Zip / and any you want
5 */
6
7function Charlies_content($picture)
8{
9  global $page, $template, $charlie, $conf;
10  // Which player is needed?
11  $player = '';
12  $extension = strtolower(get_extension($picture['file']));
13  foreach ($charlie as $tpl => $ext)
14  {
15    if (is_array($ext) and in_array($extension, $ext)) 
16      $player = strtolower($tpl);
17  }
18  // Active Charlie's player template
19  $template->set_filenames(
20    array('default_content' => dirname(__FILE__) .  "/charlie_$player.tpl") );
21  // TODO TPL DOES NOT EXIST
22  $path = $picture['element_path'];
23  $url = $picture['element_url'];
24  if ( !url_is_remote($url) )
25  {
26    set_make_full_url();
27    $url = get_element_url( $picture );
28    unset_make_full_url();
29  }
30        // If needed NO_https can easily be set in your config_local thru LocalFiles Editor
31  if (isset($conf['NO_https']) and $conf['NO_https'] and strncasecmp($url, 'https://', 8) == 0 ) 
32          $url = 'http://' . substr($url, 8);
33
34        if (!isset($conf['video_default_width']))       $conf['video_default_width'] = $charlie['video_default_width']; 
35        if (!isset($conf['video_default_height']))      $conf['video_default_height'] = $charlie['video_default_height'];
36  // Get info via getid3
37        if (!isset($conf['Charlies getid exclude'])) $conf['Charlies getid exclude'] = array();
38        if ( !in_array($extension, $conf['Charlies getid exclude']) )
39  {
40    if ( !url_is_remote($path) )
41    {
42      require_once(CHARLIES_PATH.'getid3/getid3/getid3.php');
43      $prev_lvl = error_reporting(E_ERROR | E_WARNING | E_PARSE);
44      $getID3 = new getID3;
45      $fileinfo = $getID3->analyze($path);
46      $prev_lvl = error_reporting($prev_lvl);
47    }
48    else
49    {
50      $fileinfo['asf']['video_media'][2]['format_data']['image_width'] =
51        $conf['video_default_width'];
52      $fileinfo['asf']['video_media'][2]['format_data']['image_height'] =
53        $conf['video_default_height'];
54    }
55  }
56  if (isset($fileinfo['meta']['onMetaData']['width'])) {
57    $fileinfo['video']['resolution_x'] = 
58      $fileinfo['meta']['onMetaData']['width']; 
59    $fileinfo['video']['resolution_y'] = 
60      $fileinfo['meta']['onMetaData']['height']; 
61  }
62  $fileinfo['video']['resolution_x'] =
63    (int) @$fileinfo['video']['resolution_x'];
64  if ( $fileinfo['video']['resolution_x'] < 2 )
65  {
66    $fileinfo['video']['resolution_x'] = $conf['video_default_width'];
67    $fileinfo['video']['resolution_y'] = $conf['video_default_height'];
68  }
69  if ( $fileinfo['video']['resolution_y'] < 0 )
70  {
71    $fileinfo['video']['resolution_x'] = $conf['video_default_width'];
72    $fileinfo['video']['resolution_y'] =
73      (int) (18*$conf['video_default_width']/32);
74  }
75  $bg = get_root_url().'plugins/charlies_content/background.png';
76
77  #     var_dump($fileinfo);
78
79  // Assign as much we can to offer different fields to display
80  $template->assign( array(
81/* Compatibility entries with prior releases for personal templates */
82      'H_MUSIC'    => '44',
83      'W_MUSIC'    => '450',
84      'C_VIDEO'    => 55,
85      'FW_VIDEO'   => (int)  @$fileinfo['video']['resolution_x'],
86      'FH_VIDEO'   => 20 + (int)  @$fileinfo['video']['resolution_y'],
87      'WIDTH'      => @$fileinfo['meta']['onMetaData']['width'],
88      'HEIGHT'      => @$fileinfo['meta']['onMetaData']['height'],
89      'FRAMERATE' => @$fileinfo['meta']['onMetaData']['framerate'],
90      'STEREO' => (@$fileinfo['meta']['onMetaData']['stereo']) ?
91                  'stereo' : 'mono', // l10n TODO
92      'BITRATE' => @$fileinfo['bitrate'],
93      'PLAYTIME' => @$fileinfo['playtime_string'],
94// Full new list
95      'SRC_IMG'    => $url,
96      'SRC_IMG_ENCODED' => urlencode($url),
97      'BG_SRC_ENCODED'  => urlencode($bg),
98      'ALT_IMG'    => $picture['file'],
99      'WW_VIDEO'   => (int) @$fileinfo['video']['streams'][2]['resolution_x'],
100      'WH_VIDEO'   => 25 + (int) @$fileinfo['video']['streams'][2]['resolution_y'],
101      // 25 +  ... is for reader height
102      'FILENAME'   =>  basename($path),
103      'FILESIZE'   => $picture['filesize'],
104                        'CHARLIES_PATH' => CHARLIES_PATH,
105                        'fileinfo' => $fileinfo,
106                        'by_style' => 27,
107                        'curtain' => $charlie['curtain'],
108                        'Charlies' => $charlie,
109      )
110    );
111  $ret = $template->parse('default_content', true);
112  return $ret;
113}
114?>
Note: See TracBrowser for help on using the repository browser.