e4dfc7b6fd78ca8faae4998e25bffcd4e4a3b767
[atutor.git] / mods / wiki / plugins / mpi / mpi_multimedia.php
1 <?php
2
3 /*
4   this mpi allows to embed multimedia files using following syntax:
5   <?plugin MultiMedia http://www.example.com/movie.swf ?>
6     or
7   <?plugin MultiMedia href="http://..." ?>
8 */
9
10
11 $ewiki_plugins["mpi"]["multimedia"] = "ewiki_mpi_multimedia";
12
13
14 function ewiki_mpi_multimedia($action="html", $args, &$iii, &$s) {
15
16    switch ($action) {
17       case "doc": return("The <b>multimedia</b> plugin allows to reference multimedia objects which are no plain images (like videos, flash, applets).");
18       case "desc": return("reference multimedia files");
19
20       default:
21          $a_url = array("href", 0, "url", "src");
22          $a_std = array("width", "height", "type");
23          $a_forb = array_merge(array("_"), $a_url, $a_std);
24
25          #-- href
26          foreach ($a_url as $i) {
27             if ($href = $args[$i]) {
28                break;
29          }  }
30
31          #-- <object> tag, std args
32          $o .= '<object data="' . $href . '"';
33          foreach ($a_std as $i) {
34             if ($v = $args[$i]) {
35                $o .= " $i=\"" . htmlentitites($v) . '"';
36             }
37          }
38          $o .= '>';
39
40          #-- <param> args
41          foreach ($args as $i=>$v) {
42             if (!in_array($i, $a_forb)) {
43                $o .= '<param name="'.htmlentities($i).'" value="'.htmlentities($v).'">';
44             }
45          }
46          $o .= "Your browser cannot view this multimedia object.";
47 #<off>#  $o .= '<embed src="' . $href . '"></embed>';
48          $o .= "</object>";
49    }
50
51    return($o);
52 }
53
54 ?>