1<?php 2/** 3 * Plugin Picasa web album: Create Picasa web album 4 * 5 * @license GPL v3 (http://www.gnu.org/licenses/gpl.html) 6 * @author Christophe Benz 7 */ 8 9if(!defined('DOKU_INC')) die(); 10if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 11require_once(DOKU_PLUGIN.'syntax.php'); 12 13class syntax_plugin_jquery_picasawebalbum extends DokuWiki_Syntax_Plugin { 14 function getInfo(){ 15 return array( 16 'author' => 'Christophe Benz', 17 'email' => 'cbenz _AT_ easter-eggs _DOT_ com', 18 'date' => '2008-12-08', 19 'name' => 'Picasa web album plugin', 20 'desc' => 'Create Javascript Picasa web album from its name.', 21 'url' => 'http://www.dokuwiki.org/plugin:picasawebalbum', 22 ); 23 } 24 25 function getType() { return 'substition'; } 26 function getSort() { return 159; } 27 28 function connectTo($mode) { 29 $this->Lexer->addSpecialPattern('\{\{picasawebalbum>[^}]*\}\}', $mode, 'plugin_jquery_picasawebalbum'); 30 } 31 32 function handle($match, $state, $pos, &$handler){ 33 $params = substr($match, strlen('{{picasawebalbum>'), - strlen('}}') ); // Strip markup 34 return array($state, explode(':', $params)); 35 } 36 37 function render($mode, &$renderer, $data) { 38 if($mode == 'xhtml'){ 39 list($state, $params) = $data; 40 list($user_name, $album_name) = $params; 41 42 $regex = '/^[\w-_]+$/'; 43 if(preg_match($regex, $user_name) == 0) { 44 $renderer->doc .= 'Error: Picasa user name must be alphanumeric. Given value: ' . htmlentities($user_name); 45 return false; 46 } 47 48 if(isset($album_name)) { 49 if(preg_match($regex, $album_name) == 0) { 50 $renderer->doc .= 'Error: Picasa album name must be alphanumeric. Given value: ' . htmlentities($album_name); 51 return false; 52 } 53 } 54 55 $div_id = strtolower('picasawebalbum-' . $user_name . '-' . $album_name); 56 57 $mode = isset($album_name) ? 'album' : 'albums'; 58 $album = isset($album_name) ? $album_name : ''; 59 60 $html = <<<EOHTML 61<div id="$div_id"></div> 62<script type="text/javascript"> 63on_document_ready('$div_id', '$user_name', '$mode', '$album'); 64</script> 65EOHTML; 66 67 $renderer->doc .= $html; 68 69 return true; 70 } 71 return false; 72 } 73} 74?> 75