diff -r 000000000000 -r da45dd7fc9ec plugins/Cortado.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/Cortado.php Wed Mar 05 17:23:19 2008 -0500 @@ -0,0 +1,112 @@ + for details. + */ + +global $db, $session, $paths, $template, $plugins; // Common objects + +// Establish our parser hook +$plugins->attachHook('render_wikiformat_pre', 'cortado_process($text);'); + +function cortado_process(&$text) +{ + global $db, $session, $paths, $template, $plugins; // Common objects + + $match_count = preg_match_all('#\[\[:' . preg_quote($paths->nslist['File']) . '([^]]+?\.ogg)(\|video)?\]\]#is', $text, $matches); + if ( $match_count < 1 ) + // No media tags - might as well just abort here. + return false; + + // Is there a template for this theme? If not, use a bare-bones generic default. + if ( file_exists( ENANO_ROOT . "/themes/{$template->theme}/cortado.tpl" ) ) + { + $player_template = strval(@file_get_contents(ENANO_ROOT . "/themes/{$template->theme}/cortado.tpl")); + } + else + { + $player_template = << + +
+ height="288"height="16"> + + + + + + + + +
+ Play | + Pause | + Stop +
+
+ + + +TPLCODE; + } + + $parser = $template->makeParserText($player_template); + + foreach ( $matches[0] as $i => $entire_match ) + { + // Sanitize and verify the filename + $filename = sanitize_page_id($matches[1][$i]); + $filename_paths = $paths->nslist['File'] . $filename; + + // Make sure the file even exists + if ( !isPage($filename_paths) ) + continue; + + // Verify permissions + $acl = $session->fetch_page_acl($filename, 'File'); + if ( !$acl->get_permissions('read') ) + { + // No permission to read this file + $text = str_replace_once($entire_match, "Access denied to file {$filename} - not embedding media player applet.", $text); + continue; + } + + // We should be good, set up the parser + $parser->assign_vars(array( + 'FILENAME' => $filename, + 'FILE_PATH' => makeUrlNS('Special', "DownloadFile/$filename", false, true), + 'JAVA_CLASS' => 'com.fluendo.player.Cortado', + 'JAVA_JARFILES' => scriptPath . '/plugins/cortado/cortado-ovt.jar', + 'UUID' => $session->dss_rand() + )); + + $parser->assign_bool(array( + 'video' => ( $matches[2][$i] === '|video' ) + )); + + // Run the template code and finish embed + $applet_parsed = $parser->run(); + + $text = str_replace_once($entire_match, $applet_parsed, $text); + } +} \ No newline at end of file