source: documentation/trunk/packages/dokuwiki-2011-05-25a/lib/plugins/plugin/classes/ap_info.class.php@ 25027

Last change on this file since 25027 was 25027, checked in by jmt12, 12 years ago

Adding the packages directory, and within it a configured version of dokuwiki all ready to run

File size: 6.2 KB
Line 
1<?php
2
3class ap_info extends ap_manage {
4
5 var $plugin_info = array(); // the plugin itself
6 var $details = array(); // any component plugins
7
8 function process() {
9
10 // sanity check
11 if (!$this->manager->plugin) { return; }
12
13 $component_list = $this->get_plugin_components($this->manager->plugin);
14 usort($component_list, array($this,'component_sort'));
15
16
17 foreach ($component_list as $component) {
18 if (($obj = &plugin_load($component['type'],$component['name'],false,true)) === NULL) continue;
19
20 $compname = explode('_',$component['name']);
21 if($compname[1]){
22 $compname = '['.$compname[1].']';
23 }else{
24 $compname = '';
25 }
26
27 $this->details[] = array_merge(
28 $obj->getInfo(),
29 array(
30 'type' => $component['type'],
31 'compname' => $compname
32 ));
33 unset($obj);
34 }
35
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] = '';
41 }
42 }
43 }
44
45 function html() {
46
47 // output the standard menu stuff
48 parent::html();
49
50 // sanity check
51 if (!$this->manager->plugin) { return; }
52
53 ptln('<div class="pm_info">');
54 ptln("<h2>".$this->manager->getLang('plugin')." {$this->manager->plugin}</h2>");
55
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);
61
62 ptln("<dl>",2);
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);
66 ptln("</dl>",2);
67
68 if (count($this->details) == 0) {
69 ptln("<p>".$this->manager->getLang('noinfo')."</p>",2);
70 } else {
71
72 ptln("<dl>",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);
79 ptln("</dl>",2);
80
81 if (count($this->details) > 1) {
82 ptln("<h3>".$this->manager->getLang('components')."</h3>",2);
83 ptln("<div>",2);
84
85 foreach ($this->details as $info) {
86
87 ptln("<dl>",4);
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);
94 ptln("</dl>",4);
95
96 }
97 ptln("</div>",2);
98 }
99 }
100 ptln("</div>");
101 }
102
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));
106 }
107
108
109 /**
110 * return a list (name & type) of all the component plugins that make up this plugin
111 *
112 * @todo can this move to pluginutils?
113 */
114 function get_plugin_components($plugin) {
115
116 global $plugin_types;
117
118 $components = array();
119 $path = DOKU_PLUGIN.plugin_directory($plugin).'/';
120
121 foreach ($plugin_types as $type) {
122 if (@file_exists($path.$type.'.php')) { $components[] = array('name'=>$plugin, 'type'=>$type); continue; }
123
124 if ($dh = @opendir($path.$type.'/')) {
125 while (false !== ($cp = readdir($dh))) {
126 if ($cp == '.' || $cp == '..' || strtolower(substr($cp,-4)) != '.php') continue;
127
128 $components[] = array('name'=>$plugin.'_'.substr($cp, 0, -4), 'type'=>$type);
129 }
130 closedir($dh);
131 }
132 }
133
134 return $components;
135 }
136
137 /**
138 * usort callback to sort plugin components
139 */
140 function component_sort($a, $b) {
141 if ($a['name'] == $b['name']) return 0;
142 return ($a['name'] < $b['name']) ? -1 : 1;
143 }
144}
Note: See TracBrowser for help on using the repository browser.