| [ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
1 <?php 2 3 class 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 foreach ($component_list as $component) { 17 if (($obj = plugin_load($component['type'],$component['name'],false,true)) === null) continue; 18 19 $compname = explode('_',$component['name']); 20 if($compname[1]){ 21 $compname = '['.$compname[1].']'; 22 }else{ 23 $compname = ''; 24 } 25 26 $this->details[] = array_merge( 27 $obj->getInfo(), 28 array( 29 'type' => $component['type'], 30 'compname' => $compname 31 )); 32 unset($obj); 33 } 34 35 // review details to simplify things 36 foreach($this->details as $info) { 37 foreach($info as $item => $value) { 38 if (!isset($this->plugin_info[$item])) { $this->plugin_info[$item] = $value; continue; } 39 if ($this->plugin_info[$item] != $value) $this->plugin_info[$item] = ''; 40 } 41 } 42 } 43 44 function html() { 45 46 // output the standard menu stuff 47 parent::html(); 48 49 // sanity check 50 if (!$this->manager->plugin) { return; } 51 52 ptln('<div class="pm_info">'); 53 ptln("<h2>".$this->manager->getLang('plugin')." {$this->manager->plugin}</h2>"); 54 55 // collect pertinent information from the log 56 $installed = $this->plugin_readlog($this->manager->plugin, 'installed'); 57 $source = $this->plugin_readlog($this->manager->plugin, 'url'); 58 $updated = $this->plugin_readlog($this->manager->plugin, 'updated'); 59 if (strrpos($updated, "\n") !== false) $updated = substr($updated, strrpos($updated, "\n")+1); 60 61 ptln("<dl>",2); 62 ptln("<dt>".$this->manager->getLang('source').'</dt><dd>'.($source ? $source : $this->manager->getLang('unknown'))."</dd>",4); 63 ptln("<dt>".$this->manager->getLang('installed').'</dt><dd>'.($installed ? $installed : $this->manager->getLang('unknown'))."</dd>",4); 64 if ($updated) ptln("<dt>".$this->manager->getLang('lastupdate').'</dt><dd>'.$updated."</dd>",4); 65 ptln("</dl>",2); 66 67 if (count($this->details) == 0) { 68 ptln("<p>".$this->manager->getLang('noinfo')."</p>",2); 69 } else { 70 71 ptln("<dl>",2); 72 if ($this->plugin_info['name']) ptln("<dt>".$this->manager->getLang('name')."</dt><dd>".$this->out($this->plugin_info['name'])."</dd>",4); 73 if ($this->plugin_info['date']) ptln("<dt>".$this->manager->getLang('date')."</dt><dd>".$this->out($this->plugin_info['date'])."</dd>",4); 74 if ($this->plugin_info['type']) ptln("<dt>".$this->manager->getLang('type')."</dt><dd>".$this->out($this->plugin_info['type'])."</dd>",4); 75 if ($this->plugin_info['desc']) ptln("<dt>".$this->manager->getLang('desc')."</dt><dd>".$this->out($this->plugin_info['desc'])."</dd>",4); 76 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); 77 if ($this->plugin_info['url']) ptln("<dt>".$this->manager->getLang('www')."</dt><dd>".$this->manager->external_link($this->plugin_info['url'], '', 'urlextern')."</dd>",4); 78 ptln("</dl>",2); 79 80 if (count($this->details) > 1) { 81 ptln("<h3>".$this->manager->getLang('components')."</h3>",2); 82 ptln("<div>",2); 83 84 foreach ($this->details as $info) { 85 86 ptln("<dl>",4); 87 ptln("<dt>".$this->manager->getLang('name')."</dt><dd>".$this->out($info['name'].' '.$info['compname'])."</dd>",6); 88 if (!$this->plugin_info['date']) ptln("<dt>".$this->manager->getLang('date')."</dt><dd>".$this->out($info['date'])."</dd>",6); 89 if (!$this->plugin_info['type']) ptln("<dt>".$this->manager->getLang('type')."</dt><dd>".$this->out($info['type'])."</dd>",6); 90 if (!$this->plugin_info['desc']) ptln("<dt>".$this->manager->getLang('desc')."</dt><dd>".$this->out($info['desc'])."</dd>",6); 91 if (!$this->plugin_info['author']) ptln("<dt>".$this->manager->getLang('author')."</dt><dd>".$this->manager->email($info['email'], $info['author'])."</dd>",6); 92 if (!$this->plugin_info['url']) ptln("<dt>".$this->manager->getLang('www')."</dt><dd>".$this->manager->external_link($info['url'], '', 'urlextern')."</dd>",6); 93 ptln("</dl>",4); 94 95 } 96 ptln("</div>",2); 97 } 98 } 99 ptln("</div>"); 100 } 101 102 // simple output filter, make html entities safe and convert new lines to <br /> 103 function out($text) { 104 return str_replace("\n",'<br />',htmlspecialchars($text)); 105 } 106 107 108 /** 109 * return a list (name & type) of all the component plugins that make up this plugin 110 * 111 * @todo can this move to pluginutils? 112 */ 113 function get_plugin_components($plugin) { 114 115 global $plugin_types; 116 117 $components = array(); 118 $path = DOKU_PLUGIN.plugin_directory($plugin).'/'; 119 120 foreach ($plugin_types as $type) { 121 if (@file_exists($path.$type.'.php')) { $components[] = array('name'=>$plugin, 'type'=>$type); continue; } 122 123 if ($dh = @opendir($path.$type.'/')) { 124 while (false !== ($cp = readdir($dh))) { 125 if ($cp == '.' || $cp == '..' || strtolower(substr($cp,-4)) != '.php') continue; 126 127 $components[] = array('name'=>$plugin.'_'.substr($cp, 0, -4), 'type'=>$type); 128 } 129 closedir($dh); 130 } 131 } 132 133 return $components; 134 } 135 136 /** 137 * usort callback to sort plugin components 138 */ 139 function component_sort($a, $b) { 140 if ($a['name'] == $b['name']) return 0; 141 return ($a['name'] < $b['name']) ? -1 : 1; 142 } 143 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sun Jan 19 03:00:05 2014 | Cross-referenced by PHPXref 0.7 |