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

Revision 3318, 4.0 KB checked in by vdigital, 10 years ago (diff)

+ Add Charlies' content to depository

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