1 <?php 2 /** 3 * DokuWiki Plugin multiorphan (Action Component) 4 * 5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 6 * @author i-net software <tools@inetsoftware.de> 7 */ 8 9 // must be run within Dokuwiki 10 if(!defined('DOKU_INC')) { 11 die(); 12 } 13 14 class action_plugin_multiorphan_pluginBlog extends DokuWiki_Action_Plugin { 15 16 var $plugin_dir; 17 18 function __construct() { 19 $this->plugin_blog = plugin_load('helper', 'blog'); 20 } 21 22 /** 23 * Registers a callback function for a given event 24 * 25 * @param Doku_Event_Handler $controller DokuWiki's event controller object 26 * @return void 27 */ 28 public function register(Doku_Event_Handler $controller) { 29 30 if ( !$this->plugin_blog ) { return; } 31 $controller->register_hook('MULTIORPHAN_INSTRUCTION_LINKED', 'BEFORE', $this, 'handle_unknown_instructions'); 32 } 33 34 /** 35 * Handles unknown instructions using the Event. 36 */ 37 public function handle_unknown_instructions(Doku_Event &$event) { 38 39 $instructions = $event->data['instructions']; 40 if ( $event->data['syntax'] != 'plugin' || !in_array( $instructions[0], array( 'blog_blog', 'blog_archive', 'blog_autoarchive') ) || !$this->plugin_blog ) { return false; } 41 42 $event->data['type'] = 'plugin'; 43 44 $data = $this->plugin_blog->getBlog( $instructions[1][0] ); 45 foreach( $data as $page ) { 46 $event->data['additionalEntries'][] = array ( 47 'type' => 'pages', 48 'entryID' => $page['id'] 49 ); 50 } 51 52 return true; 53 } 54 } 55 56 // vim:ts=4:sw=4:et: 57