1<?php
2/**
3 * Task Plugin: Create a list of tasks and track if they are
4 *              completed.  I used
5 *
6 * Action plugin component, for cache validity determination
7 *
8 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
9 * @author     Christopher Smith <chris@jalakai.co.uk>
10 */
11if(!defined('DOKU_INC')) die();  // no Dokuwiki, no go
12
13if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
14require_once(DOKU_PLUGIN.'action.php');
15
16/**
17 * All DokuWiki plugins to extend the parser/rendering mechanism
18 * need to inherit from this class
19 */
20class action_plugin_lightbox extends DokuWiki_Action_Plugin {
21
22    /**
23     * return some info
24     */
25    function getInfo(){
26      return array(
27        'author' => 'Dustin Butler',
28        'email'  => 'dustin@intrcomm.net',
29        'date'   => '2010-11-17',
30        'name'   => 'Lightbox For Images',
31        'desc'   => 'Pop-up Image Using Lightbox JS',
32        'url'    => 'http://www.roundporch.com/wiki?docuwiki:lightbox',
33      );
34    }
35
36    /**
37     * plugin should use this method to register its handlers with the dokuwiki's event controller
38     */
39    function register(Doku_Event_Handler $controller) {
40      $controller->register_hook('PARSER_CACHE_USE','BEFORE', $this, '_cache_prepare');
41    }
42
43    /**
44     * prepare the cache object for default _useCache action
45     */
46    function _cache_prepare(&$event, $param) {
47      $cache =& $event->data;
48
49      // we're only interested in wiki pages and supported render modes
50      if (!isset($cache->page)) return;
51      //if (!isset($cache->mode) || in_array($cache->mode,array('i','metadata'))) return;
52
53      // = $this->_cache_maxage($cache->page);
54      //if (is_null($max_age)) return;
55
56      //if ($max_age <= 0) {
57        // expire the cache
58        $event->preventDefault();
59        $event->stopPropagation();
60        $event->result = false;
61        return;
62      //}
63
64      //$cache->depends['age'] = !empty($cache->depends['age']) ?  min($cache->depends['age'],$max_age): $max_age;
65    }
66
67    /**
68     * determine the max allowable age of the cache
69     *
70     * @param   string    $id         wiki page name
71     *
72     * @return  int                   max allowable age of the cache
73     *                                null means not applicable
74     */
75     /*
76    function _cache_maxage($id) {
77      $hasPart = p_get_metadata($id, 'relation haspart');
78      if (empty($hasPart) || !is_array($hasPart)) return null;
79
80      $location = $this->getConf('location');
81
82      $age = 0;
83      foreach ($hasPart as $file => $data) {
84        // ensure the metadata entry was created by or for this plugin
85        if (empty($data['owner']) || $data['owner'] != $this->getPluginName()) continue;
86
87        $file = $this->getConf['location'].$file;
88
89        // determine max allowable age for the cache
90        // if filemtime can't be determined, either for a non-existent $file or for a $file using
91        // an unsupported scheme, expire the cache immediately/always
92        $mtime = @filemtime($file);
93        if (!$mtime) { return 0; }
94
95        $age = max($age,$mtime);
96      }
97
98      return $age ? time()-$age : null;
99    }
100    */
101
102}