[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/ -> manage_plugin_page.php (source)

   1  <?php
   2  # MantisBT - A PHP based bugtracking system
   3  
   4  # MantisBT is free software: you can redistribute it and/or modify
   5  # it under the terms of the GNU General Public License as published by
   6  # the Free Software Foundation, either version 2 of the License, or
   7  # (at your option) any later version.
   8  #
   9  # MantisBT is distributed in the hope that it will be useful,
  10  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  # GNU General Public License for more details.
  13  #
  14  # You should have received a copy of the GNU General Public License
  15  # along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * @package MantisBT
  19   * @copyright Copyright (C) 2002 - 2011  MantisBT Team - mantisbt-dev@lists.sourceforge.net
  20   * @link http://www.mantisbt.org
  21   *
  22   * @uses core.php
  23   * @uses access_api.php
  24   * @uses authentication_api.php
  25   * @uses config_api.php
  26   * @uses form_api.php
  27   * @uses helper_api.php
  28   * @uses html_api.php
  29   * @uses lang_api.php
  30   * @uses plugin_api.php
  31   * @uses print_api.php
  32   * @uses string_api.php
  33   * @uses utility_api.php
  34   */
  35  
  36  /**
  37   * MantisBT Core API's
  38   */
  39  require_once ( 'core.php' );
  40  require_api( 'access_api.php' );
  41  require_api( 'authentication_api.php' );
  42  require_api( 'config_api.php' );
  43  require_api( 'form_api.php' );
  44  require_api( 'helper_api.php' );
  45  require_api( 'html_api.php' );
  46  require_api( 'lang_api.php' );
  47  require_api( 'plugin_api.php' );
  48  require_api( 'print_api.php' );
  49  require_api( 'string_api.php' );
  50  require_api( 'utility_api.php' );
  51  
  52  auth_reauthenticate();
  53  access_ensure_global_level( config_get( 'manage_plugin_threshold' ) );
  54  
  55  html_page_top( lang_get( 'manage_plugin_link' ) );
  56  
  57  print_manage_menu( 'manage_plugin_page.php' );
  58  
  59  function plugin_sort( $p1, $p2 ) {
  60      return strcasecmp( $p1->name, $p2->name );
  61  }
  62  
  63  $t_plugins = plugin_find_all();
  64  uasort( $t_plugins, 'plugin_sort' );
  65  
  66  global $g_plugin_cache;
  67  
  68  $t_plugins_installed = array();
  69  $t_plugins_available = array();
  70  $t_forced_plugins = config_get_global( 'plugins_force_installed' );
  71  
  72  foreach( $t_plugins as $t_basename => $t_plugin ) {
  73      if ( isset( $g_plugin_cache[$t_basename] ) ) {
  74          $t_plugins_installed[$t_basename] = $t_plugin;
  75      } else {
  76          $t_plugins_available[$t_basename] = $t_plugin;
  77      }
  78  }
  79  
  80  if ( 0 < count( $t_plugins_installed ) ) {
  81  ?>
  82  <br/>
  83  <form action="manage_plugin_update.php" method="post">
  84  <?php echo form_security_field( 'manage_plugin_update' ) ?>
  85  <table class="width100" cellspacing="1">
  86  
  87  <!-- Title -->
  88  <tr>
  89      <td class="form-title" colspan="7">
  90          <?php echo lang_get( 'plugins_installed' ) ?>
  91  
  92      </td>
  93  </tr>
  94  
  95  <!-- Info -->
  96  <tr class="row-category">
  97      <td width="20%"><?php echo lang_get( 'plugin' ) ?></td>
  98      <td width="35%"><?php echo lang_get( 'plugin_description' ) ?></td>
  99      <td width="20%"><?php echo lang_get( 'plugin_depends' ) ?></td>
 100      <td width="7%"><?php echo lang_get( 'plugin_priority' ) ?></td>
 101      <td width="8%"><?php echo lang_get( 'plugin_protected' ) ?></td>
 102      <td width="10%"><?php echo lang_get( 'plugin_actions' ) ?></td>
 103  </tr>
 104  
 105  <?php
 106  foreach ( $t_plugins_installed as $t_basename => $t_plugin ) {
 107      $t_description = string_display_line_links( $t_plugin->description );
 108      $t_author = $t_plugin->author;
 109      $t_contact = $t_plugin->contact;
 110      $t_page = $t_plugin->page;
 111      $t_url = $t_plugin->url;
 112      $t_requires = $t_plugin->requires;
 113      $t_depends = array();
 114      $t_forced = isset( $t_forced_plugins[ $t_basename ] );
 115      $t_priority = plugin_priority( $t_basename );
 116      $t_protected = plugin_protected( $t_basename );
 117  
 118      $t_name = string_display_line( $t_plugin->name.' '.$t_plugin->version );
 119      if ( !is_blank( $t_page ) ) {
 120          $t_name = '<a href="' . string_attribute( plugin_page( $t_page, false, $t_basename ) ) . '">' . $t_name . '</a>';
 121      }
 122  
 123      if ( !is_blank( $t_author ) ) {
 124          if ( is_array( $t_author ) ) {
 125              $t_author = implode( $t_author, ', ' );
 126          }
 127          if ( !is_blank( $t_contact ) ) {
 128              $t_author = '<br/>' . sprintf( lang_get( 'plugin_author' ),
 129                  '<a href="mailto:' . string_attribute( $t_contact ) . '">' . string_display_line( $t_author ) . '</a>' );
 130          } else {
 131              $t_author = '<br/>' . string_display_line( sprintf( lang_get( 'plugin_author' ), $t_author ) );
 132          }
 133      }
 134  
 135      if ( !is_blank( $t_url ) ) {
 136          $t_url = '<br/>' . lang_get( 'plugin_url' ) . lang_get( 'word_separator' ) . "<a href=\"$t_url\">$t_url</a>";
 137      }
 138  
 139      $t_upgrade = plugin_needs_upgrade( $t_plugin );
 140      $t_uninstall = ( 'MantisCore' != $t_basename && !$t_protected );
 141  
 142      if ( is_array( $t_requires ) ) {
 143          foreach( $t_requires as $t_plugin => $t_version ) {
 144              $t_dependency = plugin_dependency( $t_plugin, $t_version );
 145              if ( 1 == $t_dependency ) {
 146                  if ( is_blank( $t_upgrade ) ) {
 147                      $t_depends[] = '<span class="small dependency_met">'.string_display_line( $t_plugins[$t_plugin]->name.' '.$t_version ).'</span>';
 148                  } else {
 149                      $t_depends[] = '<span class="small dependency_upgrade">'.string_display_line( $t_plugins[$t_plugin]->name.' '.$t_version ).'</span>';
 150                  }
 151              } else if ( -1 == $t_dependency ) {
 152                  $t_depends[] = '<span class="small dependency_dated">'.string_display_line( $t_plugins[$t_plugin]->name.' '.$t_version ).'</span>';
 153              } else {
 154                  $t_depends[] = '<span class="small dependency_unmet">'.string_display_line( $t_plugin.' '.$t_version ).'</span>';
 155              }
 156          }
 157      }
 158  
 159      if ( 0 < count( $t_depends ) ) {
 160          $t_depends = implode( $t_depends, '<br/>' );
 161      } else {
 162          $t_depends = '<span class="small dependency_met">' . lang_get( 'plugin_no_depends' ) . '</span>';
 163      }
 164  
 165      echo '<tr ',helper_alternate_class(),'>';
 166      echo '<td class="small center">',$t_name,'<input type="hidden" name="change_',$t_basename,'" value="1"/></td>';
 167      echo '<td class="small">',$t_description,$t_author,$t_url,'</td>';
 168      echo '<td class="small center">',$t_depends,'</td>';
 169      if ( 'MantisCore' == $t_basename ) {
 170          echo '<td>&#160;</td><td>&#160;</td>';
 171      } else if ( $t_forced ) {
 172          echo '<td class="center">','<select disabled="disabled">',print_plugin_priority_list( $t_priority ),'</select>','</td>';
 173          echo '<td class="center">','<input type="checkbox" checked="checked" disabled="disabled"/>','</td>';
 174      } else {
 175          echo '<td class="center">','<select name="priority_',$t_basename,'">',print_plugin_priority_list( $t_priority ),'</select>','</td>';
 176          echo '<td class="center">','<input type="checkbox" name="protected_',$t_basename,'" '.( $t_protected ? 'checked="checked" ' : '').'/>','</td>';
 177      }
 178      echo '<td class="center">';
 179      if ( $t_upgrade ) { print_bracket_link( 'manage_plugin_upgrade.php?name=' . $t_basename . form_security_param( 'manage_plugin_upgrade' ), lang_get( 'plugin_upgrade' ) ); }
 180      if ( $t_uninstall ) { print_bracket_link( 'manage_plugin_uninstall.php?name=' . $t_basename . form_security_param( 'manage_plugin_uninstall' ), lang_get( 'plugin_uninstall' ) ); }
 181      echo '</td></tr>';
 182  } ?>
 183  
 184  <tr>
 185      <td colspan="3"></td>
 186      <td colspan="2" class="center"><input type="submit" value="<?php echo lang_get( 'plugin_update' ) ?>"/></td>
 187      <td></td>
 188  </tr>
 189  
 190  </table>
 191  </form>
 192  <?php
 193  }
 194  
 195  if ( 0 < count( $t_plugins_available ) ) {
 196  ?>
 197  <br/>
 198  <table class="width100" cellspacing="1">
 199  
 200  <!-- Title -->
 201  <tr>
 202      <td class="form-title" colspan="7">
 203          <?php echo lang_get( 'plugins_available' ) ?>
 204  
 205      </td>
 206  </tr>
 207  
 208  <!-- Info -->
 209  <tr class="row-category">
 210      <td width="25%"><?php echo lang_get( 'plugin' ) ?></td>
 211      <td width="45%"><?php echo lang_get( 'plugin_description' ) ?></td>
 212      <td width="20%"><?php echo lang_get( 'plugin_depends' ) ?></td>
 213      <td width="10%"><?php echo lang_get( 'plugin_actions' ) ?></td>
 214  </tr>
 215  
 216  <?php
 217  foreach ( $t_plugins_available as $t_basename => $t_plugin ) {
 218      $t_description = string_display_line_links( $t_plugin->description );
 219      $t_author = $t_plugin->author;
 220      $t_contact = $t_plugin->contact;
 221      $t_url = $t_plugin->url ;
 222      $t_requires = $t_plugin->requires;
 223      $t_depends = array();
 224  
 225      $t_name = string_display_line( $t_plugin->name.' '.$t_plugin->version );
 226  
 227      if ( !is_blank( $t_author ) ) {
 228          if ( is_array( $t_author ) ) {
 229              $t_author = implode( $t_author, ', ' );
 230          }
 231          if ( !is_blank( $t_contact ) ) {
 232              $t_author = '<br/>' . sprintf( lang_get( 'plugin_author' ),
 233                  '<a href="mailto:' . string_display_line( $t_contact ) . '">' . string_display_line( $t_author ) . '</a>' );
 234          } else {
 235              $t_author = '<br/>' . string_display_line( sprintf( lang_get( 'plugin_author' ), $t_author ) );
 236          }
 237      }
 238  
 239      if ( !is_blank( $t_url ) ) {
 240          $t_url = '<br/>' . lang_get( 'plugin_url' ) . lang_get( 'word_separator' ) . "<a href=\"$t_url\">$t_url</a>";
 241      }
 242  
 243      $t_ready = true;
 244      if ( is_array( $t_requires ) ) {
 245          foreach( $t_requires as $t_plugin => $t_version ) {
 246              $t_dependency = plugin_dependency( $t_plugin, $t_version );
 247              if ( 1 == $t_dependency ) {
 248                  $t_depends[] = '<span class="small dependency_met">'.string_display_line( $t_plugins[$t_plugin]->name.' '.$t_version ).'</span>';
 249              } else if ( -1 == $t_dependency ) {
 250                  $t_ready = false;
 251                  $t_depends[] = '<span class="small dependency_dated">'.string_display_line( $t_plugins[$t_plugin]->name.' '.$t_version ).'</span>';
 252              } else {
 253                  $t_ready = false;
 254                  $t_depends[] = '<span class="small dependency_unmet">'.string_display_line( $t_plugin.' '.$t_version ).'</span>';
 255              }
 256          }
 257      }
 258  
 259      if ( 0 < count( $t_depends ) ) {
 260          $t_depends = implode( $t_depends, '<br/>' );
 261      } else {
 262          $t_depends = '<span class="small dependency_met">' . lang_get( 'plugin_no_depends' ) . '</span>';
 263      }
 264  
 265      echo '<tr ',helper_alternate_class(),'>';
 266      echo '<td class="small center">',$t_name,'</td>';
 267      echo '<td class="small">',$t_description,$t_author,$t_url,'</td>';
 268      echo '<td class="center">',$t_depends,'</td>';
 269      echo '<td class="center">';
 270      if ( $t_ready ) { print_bracket_link( 'manage_plugin_install.php?name=' . $t_basename . form_security_param( 'manage_plugin_install' ), lang_get( 'plugin_install' ) ); }
 271      echo '</td></tr>';
 272  } ?>
 273  
 274  </table>
 275  <?php } ?>
 276  
 277  <br/><?php echo lang_get( 'plugin_key_label' ) ?>
 278  <span class='dependency_met'><?php echo lang_get( 'plugin_key_met' ) ?></span>,
 279  <span class='dependency_unmet'><?php echo lang_get( 'plugin_key_unmet' ) ?></span>,
 280  <span class='dependency_dated'><?php echo lang_get( 'plugin_key_dated' ) ?></span>,
 281  <span class='dependency_upgrade'><?php echo lang_get( 'plugin_key_upgrade' ) ?></span>.
 282  
 283  <?php
 284  html_page_bottom();
 285  


Generated: Thu Jul 28 15:48:31 2011 Cross-referenced by PHPXref 0.7