1<?php 2/** 3 * DokuWiki PrettyPhoto Plugin 4 * 5 * @license Public Domain 6 * @author Marcus von Appen <marcus@sysfault.org> 7 * 8 * @see also https://bitbucket.org/marcusva/dokuwiki-plugin-prettyphoto 9 */ 10 11/** 12 * Action component of PrettyPhoto plugin 13 * 14 * @author Satoshi Sahara <sahara.satoshi@gmail.com> 15 */ 16class action_plugin_prettyphoto extends DokuWiki_Action_Plugin 17{ 18 // register hook 19 public function register(Doku_Event_Handler $controller) 20 { 21 $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, '_handleMeta'); 22 $controller->register_hook('DOKUWIKI_STARTED', 'AFTER', $this, '_exportToJSINFO'); 23 } 24 25 /** 26 * load prettyPhoto.css and jquery.prettyPhoto.js 27 */ 28 public function _handleMeta(Doku_Event $event, $param) 29 { 30 $event->data['link'][] = array( 31 'rel' => 'stylesheet', 32 'href' => DOKU_BASE.'lib/plugins/prettyphoto/css/prettyPhoto.css', 33 ); 34 $event->data['script'][] = array( 35 'src' => DOKU_BASE.'lib/plugins/prettyphoto/js/jquery.prettyPhoto.js', 36 'defer' => 'defer', 37 '_data' => '', 38 ); 39 40 // local configuration 41 if (is_readable(dirname(__FILE__).'/prettyphoto.conf.js')) { 42 $event->data['script'][] = array( 43 'src' => DOKU_BASE.'lib/plugins/prettyphoto/prettyphoto.conf.js', 44 'defer' => 'defer', 45 '_data' => '', 46 ); 47 } 48 } 49 50 /** 51 * Exports configuration settings to $JSINFO 52 */ 53 public function _exportToJSINFO(Doku_Event $event, $param) 54 { 55 global $JSINFO, $conf; 56 57 // auto detect PRETTYPHOTO_PLUGIN_MEDIAPATH 58 switch ($conf['userewrite']) { 59 case 0: 60 // No URL rewriting 61 $mediapath = DOKU_BASE.'lib/exe/fetch.php?media='; 62 break; 63 case 1: 64 // serverside rewiteing eg. .htaccess file 65 $mediapath = DOKU_BASE.'_media/'; 66 break; 67 case 2: 68 // DokuWiki rewiteing 69 $mediapath = DOKU_BASE.'lib/exe/fetch.php/'; 70 break; 71 } 72 73 $JSINFO['plugin_prettyphoto'] = array( 74 'mediapath' => $mediapath, 75 ); 76 } 77 78} 79