[3318] | 1 | <?php |
---|
| 2 | /** |
---|
| 3 | * 'Charlies content' generates XHTML depending on the element |
---|
| 4 | * PDF / Musics / Videos / Zip / and any you want |
---|
| 5 | */ |
---|
| 6 | |
---|
| 7 | function 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']; |
---|
[3341] | 25 | if ( !url_is_remote($url) ) |
---|
[3318] | 26 | { |
---|
| 27 | set_make_full_url(); |
---|
[3341] | 28 | $url = get_element_url( $picture ); |
---|
[3318] | 29 | unset_make_full_url(); |
---|
| 30 | } |
---|
[3341] | 31 | // If needed NO_https can easily be set in your config_local thru LocalFiles Editor |
---|
| 32 | if (isset($conf['NO_https']) and $conf['NO_https'] and strncasecmp($url, 'https://', 8) == 0 ) |
---|
| 33 | $url = 'http://' . substr($url, 8); |
---|
[3974] | 34 | |
---|
[3318] | 35 | if (!isset($conf['video_default_width'])) $conf['video_default_width'] = $charlie['video_default_width']; |
---|
| 36 | if (!isset($conf['video_default_height'])) $conf['video_default_height'] = $charlie['video_default_height']; |
---|
| 37 | // Get info via getid3 |
---|
| 38 | if (!isset($conf['Charlies getid exclude'])) $conf['Charlies getid exclude'] = array(); |
---|
| 39 | if ( !in_array($extension, $conf['Charlies getid exclude']) ) |
---|
| 40 | { |
---|
| 41 | if ( !url_is_remote($path) ) |
---|
| 42 | { |
---|
| 43 | require_once(CHARLIES_PATH.'getid3/getid3/getid3.php'); |
---|
| 44 | $prev_lvl = error_reporting(E_ERROR | E_WARNING | E_PARSE); |
---|
| 45 | $getID3 = new getID3; |
---|
| 46 | $fileinfo = $getID3->analyze($path); |
---|
| 47 | $prev_lvl = error_reporting($prev_lvl); |
---|
| 48 | } |
---|
| 49 | else |
---|
| 50 | { |
---|
| 51 | $fileinfo['asf']['video_media'][2]['format_data']['image_width'] = |
---|
| 52 | $conf['video_default_width']; |
---|
| 53 | $fileinfo['asf']['video_media'][2]['format_data']['image_height'] = |
---|
| 54 | $conf['video_default_height']; |
---|
| 55 | } |
---|
| 56 | } |
---|
| 57 | if (isset($fileinfo['meta']['onMetaData']['width'])) { |
---|
| 58 | $fileinfo['video']['resolution_x'] = |
---|
| 59 | $fileinfo['meta']['onMetaData']['width']; |
---|
| 60 | $fileinfo['video']['resolution_y'] = |
---|
| 61 | $fileinfo['meta']['onMetaData']['height']; |
---|
| 62 | } |
---|
| 63 | $fileinfo['video']['resolution_x'] = |
---|
| 64 | (int) @$fileinfo['video']['resolution_x']; |
---|
| 65 | if ( $fileinfo['video']['resolution_x'] < 2 ) |
---|
| 66 | { |
---|
| 67 | $fileinfo['video']['resolution_x'] = $conf['video_default_width']; |
---|
| 68 | $fileinfo['video']['resolution_y'] = $conf['video_default_height']; |
---|
| 69 | } |
---|
| 70 | if ( $fileinfo['video']['resolution_y'] < 0 ) |
---|
| 71 | { |
---|
| 72 | $fileinfo['video']['resolution_x'] = $conf['video_default_width']; |
---|
| 73 | $fileinfo['video']['resolution_y'] = |
---|
| 74 | (int) (18*$conf['video_default_width']/32); |
---|
| 75 | } |
---|
| 76 | $bg = get_root_url().'plugins/charlies_content/background.png'; |
---|
| 77 | |
---|
| 78 | //var_dump($fileinfo); |
---|
| 79 | |
---|
| 80 | // Assign as much we can to offer different fields to display |
---|
| 81 | $template->assign( array( |
---|
| 82 | /* Compatibility entries with prior releases for personal templates */ |
---|
| 83 | 'H_MUSIC' => '44', |
---|
| 84 | 'W_MUSIC' => '450', |
---|
| 85 | 'C_VIDEO' => 55, |
---|
| 86 | 'FW_VIDEO' => (int) @$fileinfo['video']['resolution_x'], |
---|
| 87 | 'FH_VIDEO' => 20 + (int) @$fileinfo['video']['resolution_y'], |
---|
| 88 | 'WIDTH' => @$fileinfo['meta']['onMetaData']['width'], |
---|
| 89 | 'HEIGHT' => @$fileinfo['meta']['onMetaData']['height'], |
---|
| 90 | 'FRAMERATE' => @$fileinfo['meta']['onMetaData']['framerate'], |
---|
| 91 | 'STEREO' => (@$fileinfo['meta']['onMetaData']['stereo']) ? |
---|
| 92 | 'stereo' : 'mono', // l10n TODO |
---|
| 93 | 'BITRATE' => @$fileinfo['bitrate'], |
---|
| 94 | 'PLAYTIME' => @$fileinfo['playtime_string'], |
---|
| 95 | // Full new list |
---|
| 96 | 'SRC_IMG' => $url, |
---|
| 97 | 'SRC_IMG_ENCODED' => urlencode($url), |
---|
| 98 | 'BG_SRC_ENCODED' => urlencode($bg), |
---|
| 99 | 'ALT_IMG' => $picture['file'], |
---|
| 100 | 'WW_VIDEO' => (int) @$fileinfo['video']['streams'][2]['resolution_x'], |
---|
| 101 | 'WH_VIDEO' => 25 + (int) @$fileinfo['video']['streams'][2]['resolution_y'], |
---|
| 102 | // 25 + ... is for reader height |
---|
| 103 | 'FILENAME' => basename($path), |
---|
| 104 | 'FILESIZE' => $picture['filesize'], |
---|
| 105 | 'CHARLIES_PATH' => CHARLIES_PATH, |
---|
| 106 | 'fileinfo' => $fileinfo, |
---|
| 107 | 'by_style' => 27, |
---|
| 108 | 'curtain' => $charlie['curtain'], |
---|
| 109 | 'Charlies' => $charlie, |
---|
| 110 | ) |
---|
| 111 | ); |
---|
| 112 | |
---|
| 113 | $ret = $template->parse('default_content', true); |
---|
| 114 | // echo $ret; |
---|
| 115 | return $ret; |
---|
| 116 | } |
---|
| 117 | ?> |
---|