21a48ba5c01f7246dfbb94f106311c620a45d4a9
[atutor.git] / mods / wiki / plugins / mpi / mpi_inlineframe.php
1 <?php
2 /*
3    Inserts an <iframe> for a given URL (as url=, src=, href= or simply
4    the first unnamed parameter, width= and height= must be given in
5    conjunction and an alternative text may be included).
6    
7    <?plugin InlineFrame http://example.org/
8       examplary inlines a non-existent page
9    ?>
10 */
11
12 $ewiki_plugins["mpi"]["inlineframe"] = "ewiki_mpi_inlineframe";
13
14 function ewiki_mpi_inlineframe($action, &$args, &$iii, &$s) {
15
16    #-- get args
17    ($url = $args["url"]) or ($url = $args["href"])
18    or ($url = $args["src"]) or ($url = $args[0]);
19    $width = htmlentities($args["width"]);
20    $height = htmlentities($args["height"]);
21    if ($l = strpos($args["_"], "\n")) {
22       $alt = htmlentities(substr($args["_"], $l));
23    }
24    
25    #-- return <iframe> tag / bare link
26    $inj = ($height&&$width) ? " width=\"$width\" height=\"$height\"" :  "";
27    $url = htmlentities($url);
28    return
29      "<iframe src=\"$url\" $inj>"
30      ."<a href=\"$url\">$url</a>$alt"
31      ."</iframe>";
32 }
33
34
35 ?>