/** * Override for ElggFile::detectMimetype * - Detects mime types using exiftool * * @param mixed $file The full path of the file to check. For uploaded files, use tmp_name. * @param mixed $default A default. Useful to pass what the browser thinks it is. * @since 1.7.12 * * @note If $file is provided, this may be called statically * * @return mixed Detected type on success, false on failure. */ public function detectMimeType($file = null, $default = null) { if (!$file) { if (isset($this) && $this->filename) { $file = $this->getFilenameOnFilestore(); } else { return false; } } // Load podcasts library elgg_load_library('elgg:podcasts'); $mime = podcasts_get_mime_type($file); if (!is_string($mime)) { if ($mime == 127) { $ex = elgg_echo('podcasts:error:exiftoolnotfound'); throw new PodcastMetadataException($ex); } else { if ($mime > 0) { $ex = elgg_echo('podcasts:error:exiftoolfailed'); throw new PodcastMetadataException($ex); } } } // default if (empty($mime)) { return $default; } return $mime; }
/** * Override file icon url handler * * @param string $hook * @param string $type * @param bool $value * @param array $params * * @return array */ function podcasts_file_icon_url_override($hook, $type, $value, $params) { $file = $params['entity']; $size = $params['size']; if ($size == 'large') { $ext = '_lrg'; } else { $ext = ''; } // Load podcasts library elgg_load_library('elgg:podcasts'); $mimetype = podcasts_get_mime_type($file->getFilenameOnFilestore()); // If mimetype (as detected by podcast lib) is audio, force music icon if (strpos($mimetype, 'audio') !== FALSE) { return "mod/file/graphics/icons/music{$ext}.gif"; } return $value; }
//only display if there are commments if ($comments_count != 0) { $text = elgg_echo("comments") . " ({$comments_count})"; $comments_link = elgg_view('output/url', array('href' => $file->getURL() . '#file-comments', 'text' => $text, 'is_trusted' => true)); } else { $comments_link = ''; } $metadata = elgg_view_menu('entity', array('entity' => $vars['entity'], 'handler' => 'file', 'sort_by' => 'priority', 'class' => 'elgg-menu-hz')); $subtitle = "{$author_text} {$date} {$comments_link} {$categories}"; // do not show the metadata and controls in widget view if (elgg_in_context('widgets')) { $metadata = ''; } // Check if this file is playable with podcast player elgg_load_library('elgg:podcasts'); $mimetype = podcasts_get_mime_type($file->getFilenameOnFilestore()); if (ElggPodcast::checkValidMimeType($mimetype)) { // Load JS/CSS elgg_load_js('elgg.podcasts'); elgg_load_js('soundmanager2'); elgg_load_css('elgg.podcasts'); if (!$file->duration) { podcasts_populate_file_info($file); } $player = elgg_view('podcasts/player', array('entity_guid' => $file->guid)); } if ($full && !elgg_in_context('gallery')) { $extra = ''; if (elgg_view_exists("file/specialcontent/{$mime}")) { $extra = elgg_view("file/specialcontent/{$mime}", $vars); } else {