Changeset 1911cc4 in github


Ignore:
Timestamp:
Nov 19, 2011 4:46:38 AM (19 months ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.8
Children:
bda028e
Parents:
e37e7dd
Message:
  • Use channel/uri as possible source locations
  • Handle dependent/required plugins
File:
1 edited

Legend:

Unmodified
Added
Removed
  • program/steps/settings/about.inc

    r45fa64c r1911cc4  
    3131  $plugins = array_flip($plugins); 
    3232 
    33   $metadata = array( 
    34     'name'    => 'string(//rc:package/rc:name)', 
    35     'version' => 'string(//rc:package/rc:version/rc:release)', 
    36     'license' => 'string(//rc:package/rc:license)', 
    37     'license_uri' => 'string(//rc:package/rc:license/@uri)', 
    38     'source_uri' => 'string(//rc:package/rc:srcuri)', 
    39   ); 
    40  
    4133  foreach ($plugins as $name => $plugin) { 
    42     $package = INSTALL_PATH . "/plugins/$name/package.xml"; 
    43     if (file_exists($package) && ($file = file_get_contents($package))) { 
    44       $doc = new DOMDocument(); 
    45       $doc->loadXML($file); 
    46       $xpath = new DOMXPath($doc); 
    47       $xpath->registerNamespace('rc', "http://pear.php.net/dtd/package-2.0"); 
    48       $data = array(); 
    49  
    50       foreach ($metadata as $key => $path) { 
    51         $data[$key] = $xpath->evaluate($path); 
    52       } 
    53  
    54       $plugins[$name] = $data; 
    55     } 
    56     else { 
    57       unset($plugins[$name]); 
    58     } 
     34    rcube_plugin_data($name, $plugins); 
    5935  } 
    6036 
     
    7450 
    7551  foreach ($plugins as $name => $data) { 
     52    $uri = $data['uri'] ? $data['uri'] : $data['channel']; 
     53    if ($uri && stripos($uri, 'http') !== 0) { 
     54      $uri = 'http://' . $uri; 
     55    } 
     56 
    7657    $table->add_row(); 
    7758    $table->add('name', Q($data['name'] ? $data['name'] : $name)); 
     
    7960    $table->add('license', $data['license_uri'] ? html::a(array('target' => '_blank', href=> Q($data['license_uri'])), 
    8061        Q($data['license'])) : $data['license']); 
    81     $table->add('source', $data['source_uri'] ? html::a(array('target' => '_blank', href=> Q($data['source_uri'])), 
     62    $table->add('source', $uri ? html::a(array('target' => '_blank', href=> Q($uri)), 
    8263        Q(rcube_label('source'))) : ''); 
    8364  } 
     
    8667} 
    8768 
     69function rcube_plugin_data($name, &$plugins = array()) 
     70{ 
     71  // XPaths of plugin metadata elements 
     72  $metadata = array( 
     73    'name'    => 'string(//rc:package/rc:name)', 
     74    'version' => 'string(//rc:package/rc:version/rc:release)', 
     75    'license' => 'string(//rc:package/rc:license)', 
     76    'license_uri' => 'string(//rc:package/rc:license/@uri)', 
     77    'uri' => 'string(//rc:package/rc:uri)', 
     78    'channel' => 'string(//rc:package/rc:channel)', 
     79  ); 
     80 
     81  $package = INSTALL_PATH . "/plugins/$name/package.xml"; 
     82  if (file_exists($package) && ($file = file_get_contents($package))) { 
     83    $doc = new DOMDocument(); 
     84    $doc->loadXML($file); 
     85    $xpath = new DOMXPath($doc); 
     86    $xpath->registerNamespace('rc', "http://pear.php.net/dtd/package-2.0"); 
     87    $data = array(); 
     88 
     89    foreach ($metadata as $key => $path) { 
     90      $data[$key] = $xpath->evaluate($path); 
     91    } 
     92 
     93    $plugins[$name] = $data; 
     94 
     95    // dependent required plugins (can be used, but not included in config) 
     96    $deps = $xpath->evaluate('//rc:package/rc:dependencies/rc:required/rc:package/rc:name'); 
     97    $cnt  = $deps->length; 
     98 
     99    for ($i=0; $i<$cnt; $i++) { 
     100      $dn = $deps->item($i)->nodeValue; 
     101      if (!array_key_exists($dn, $plugins)) { 
     102        rcube_plugin_data($dn, $plugins); 
     103      } 
     104    } 
     105  } 
     106  else { 
     107    unset($plugins[$name]); 
     108  } 
     109} 
     110 
     111 
    88112$OUTPUT->set_pagetitle(rcube_label('about')); 
    89113 
Note: See TracChangeset for help on using the changeset viewer.