3 class ap_info
extends ap_manage
{
5 var $plugin_info = array(); // the plugin itself
6 var $details = array(); // any component plugins
11 if (!$this->manager
->plugin
) { return; }
13 $component_list = $this->get_plugin_components($this->manager
->plugin
);
14 usort($component_list, array($this,'component_sort'));
17 foreach ($component_list as $component) {
18 if ($obj = & plugin_load($component['type'],$component['name']) === NULL) continue;
20 $compname = explode('_',$component['name']);
22 $compname = '['.$compname[1].']';
27 $this->details
[] = array_merge(
30 'type' => $component['type'],
31 'compname' => $compname
36 // review details to simplify things
37 foreach($this->details
as $info) {
38 foreach($info as $item => $value) {
39 if (!isset($this->plugin_info
[$item])) { $this->plugin_info
[$item] = $value; continue; }
40 if ($this->plugin_info
[$item] != $value) $this->plugin_info
[$item] = '';
47 // output the standard menu stuff
51 if (!$this->manager
->plugin
) { return; }
53 ptln('<div class="pm_info">');
54 ptln("<h2>".$this->manager
->getLang('plugin')." {$this->manager->plugin}</h2>");
56 // collect pertinent information from the log
57 $installed = $this->plugin_readlog($this->manager
->plugin
, 'installed');
58 $source = $this->plugin_readlog($this->manager
->plugin
, 'url');
59 $updated = $this->plugin_readlog($this->manager
->plugin
, 'updated');
60 if (strrpos($updated, "\n") !== false) $updated = substr($updated, strrpos($updated, "\n")+
1);
63 ptln("<dt>".$this->manager
->getLang('source').'</dt><dd>'.($source ?
$source : $this->manager
->getLang('unknown'))."</dd>",4);
64 ptln("<dt>".$this->manager
->getLang('installed').'</dt><dd>'.($installed ?
$installed : $this->manager
->getLang('unknown'))."</dd>",4);
65 if ($updated) ptln("<dt>".$this->manager
->getLang('lastupdate').'</dt><dd>'.$updated."</dd>",4);
68 if (count($this->details
) == 0) {
69 ptln("<p>".$this->manager
->getLang('noinfo')."</p>",2);
73 if ($this->plugin_info
['name']) ptln("<dt>".$this->manager
->getLang('name')."</dt><dd>".$this->out($this->plugin_info
['name'])."</dd>",4);
74 if ($this->plugin_info
['date']) ptln("<dt>".$this->manager
->getLang('date')."</dt><dd>".$this->out($this->plugin_info
['date'])."</dd>",4);
75 if ($this->plugin_info
['type']) ptln("<dt>".$this->manager
->getLang('type')."</dt><dd>".$this->out($this->plugin_info
['type'])."</dd>",4);
76 if ($this->plugin_info
['desc']) ptln("<dt>".$this->manager
->getLang('desc')."</dt><dd>".$this->out($this->plugin_info
['desc'])."</dd>",4);
77 if ($this->plugin_info
['author']) ptln("<dt>".$this->manager
->getLang('author')."</dt><dd>".$this->manager
->email($this->plugin_info
['email'], $this->plugin_info
['author'])."</dd>",4);
78 if ($this->plugin_info
['url']) ptln("<dt>".$this->manager
->getLang('www')."</dt><dd>".$this->manager
->external_link($this->plugin_info
['url'], '', 'urlextern')."</dd>",4);
81 if (count($this->details
) > 1) {
82 ptln("<h3>".$this->manager
->getLang('components')."</h3>",2);
85 foreach ($this->details
as $info) {
88 ptln("<dt>".$this->manager
->getLang('name')."</dt><dd>".$this->out($info['name'].' '.$info['compname'])."</dd>",6);
89 if (!$this->plugin_info
['date']) ptln("<dt>".$this->manager
->getLang('date')."</dt><dd>".$this->out($info['date'])."</dd>",6);
90 if (!$this->plugin_info
['type']) ptln("<dt>".$this->manager
->getLang('type')."</dt><dd>".$this->out($info['type'])."</dd>",6);
91 if (!$this->plugin_info
['desc']) ptln("<dt>".$this->manager
->getLang('desc')."</dt><dd>".$this->out($info['desc'])."</dd>",6);
92 if (!$this->plugin_info
['author']) ptln("<dt>".$this->manager
->getLang('author')."</dt><dd>".$this->manager
->email($info['email'], $info['author'])."</dd>",6);
93 if (!$this->plugin_info
['url']) ptln("<dt>".$this->manager
->getLang('www')."</dt><dd>".$this->manager
->external_link($info['url'], '', 'urlextern')."</dd>",6);
103 // simple output filter, make html entities safe and convert new lines to <br />
104 function out($text) {
105 return str_replace("\n",'<br />',htmlspecialchars($text));
110 * return a list (name & type) of all the component plugins that make up this plugin
112 * @todo can this move to pluginutils?
114 function get_plugin_components($plugin) {
116 global $plugin_types;
118 $components = array();
119 $path = DOKU_PLUGIN
.plugin_directory($plugin).'/';
121 foreach ($plugin_types as $type) {
122 if (@file_exists
($path.$type.'.php')) { $components[] = array('name'=>$plugin, 'type'=>$type); continue; }
124 if ($dh = @opendir
($path.$type.'/')) {
125 while (false !== ($cp = readdir($dh))) {
126 if ($cp == '.' ||
$cp == '..' ||
strtolower(substr($cp,-4)) != '.php') continue;
128 $components[] = array('name'=>$plugin.'_'.substr($cp, 0, -4), 'type'=>$type);
138 * usort callback to sort plugin components
140 function component_sort($a, $b) {
141 if ($a['name'] == $b['name']) return 0;
142 return ($a['name'] < $b['name']) ?
-1 : 1;