This plugin allows external urls to be loaded into an iframe in your Dokuwiki page.
The plugin was created in response to an idea mentioned by Styno.
This plugin was used as a basis for google_cal by Kite
Simple:
{{url>http://www.somesite.com/somepage.html}}
Complete:
{{url>someurl [ width , height ] | alternate-text }}
See the plugin in action here.
The plugin has one configuration setting, which can be set via the admin/configuration settings page.
false, set to true to enable javascript urls.Plugin sources: zip format (4k), tar.gz format (3k), darcs repository
If your wiki uses either the plugin manager or the darcs plugin you can use them with the links above to install the plugin.
To install the plugin manually, download the source to your plugin folder, lib/plugins and extract its contents. That will create a new plugin folder, lib/plugins/iframe, and install the plugin.
The folder will contain:
conf/default.php default settings conf/metadata.php settings information for the config plugin lang/xx/lang.php language strings for config plugin syntax.php plugin script
The plugin is now installed.
The plugin consists of one file, the plugin script syntax.php.
<?php /** * Plugin Iframe: Inserts an iframe element to include the specified url * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Christopher Smith <chris@jalakai.co.uk> */ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); /** * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class */ class syntax_plugin_iframe extends DokuWiki_Syntax_Plugin { function getInfo(){ return array( 'author' => 'Christopher Smith', 'email' => 'chris@jalakai.co.uk', 'date' => '2006-12-17', 'name' => 'Iframe Plugin', 'desc' => 'Add an iframe containing the specified url syntax: {{url>http://www.somesite.com/somepage.htm[w,h]|alternate text}}', 'url' => 'http://wiki.splitbrain.org/plugin:iframe', ); } function getType() { return 'substition'; } function getSort() { return 305; } function connectTo($mode) { $this->Lexer->addSpecialPattern('{{url>.*?}}',$mode,'plugin_iframe'); } function handle($match, $state, $pos, &$handler){ $match = html_entity_decode(substr($match, 6, -2)); @list($url, $alt) = explode('|',$match,2); $matches=array(); // '/^\s*([^\[|]+)(?:\[(?:([^,\]]*),)?([^,\]]*)\])?(?:\s*(?:\|\s*(.*))?)?$/mD' if (preg_match('/(.*)\[(.*)\]$/',trim($url),$matches)) { $url = $matches[1]; if (strpos($matches[2],',') !== false) { @list($w, $h) = explode(',',$matches[2],2); } else { $h = $matches[2]; $w = '98%'; } } else { $w = '98%'; $h = '400px'; } if (!isset($alt)) $alt = ''; if (!$this->getConf('js_ok') && substr($url,0,11) == 'javascript:') $url = 'error'; return array(hsc(trim($url)), hsc(trim($alt)), hsc(trim($w)), hsc(trim($h))); } function render($mode, &$renderer, $data) { list($url, $alt, $w, $h) = $data; if($mode == 'xhtml'){ if ($url != 'error') { $renderer->doc .= '<iframe title="'.$alt.'" src="'.$url.'" style="width:'.$w.'; height: '.$h.';">'.$alt.'</iframe>'; } else { $renderer->doc .= '<div>'.$alt.'</div>'; } return true; } return false; } }