{layout @admin.html}
{block content}
<div class="top-space">
  <h1>{_}plugin_manager{/_}</h1>
</div>
<h2>{_}installed_plugins{/_}</h2>
{if}
<table class="ink-table alternating hover medium">
  <thead>
    <tr>
      <th class="align-left">{_}name{/_}</th>
      <th class="align-left">{_}version{/_}</th>
      <th class="align-left">{_}website{/_}</th>
      <th class="align-left">{_}description{/_}</th>
      <th class="align-left">{_}settings{/_}</th>
      <th colspan="3"></th>
    </tr>
  </thead>
  <tbody>
    {foreach array_filter( $plugins, function( $plugin ) {return $plugin->isInstalled;} ) as $plugin}
    <tr>
      <td>{$plugin->name}</td>
      <td>{$plugin->installedVersion}</td>
      <td>{if $plugin->url}<a href="{$plugin->url}">{_}website{/_}</a>{/if}</td>
      <td>{$plugin->description|truncate:30}</td>
      <td>{ifset ($plugin->settingsPage)}<a class="ink-button grey" href="{=BASE_URL . $plugin->settingsPage}">{_}settings{/_}</a>{/ifset}</td>
      <td>{if $plugin->isActive}
	<a class="ink-button blue" href="{=BASE_URL}system/plugin/deactivate?name={$plugin->fullname}">{_}deactivate{/_}</a>
	{else}
	<a class="ink-button blue" href="{=BASE_URL}system/plugin/activate?name={$plugin->fullname}">{_}activate{/_}</a>
	{/if}
      </td>
      <td>{if $plugin->hasNewerVersion}<a class="ink-button orange" href="{=BASE_URL}system/plugin/upgrade?name={$plugin->fullname}">{_}upgrade{/_}</a>{/if}</td>
      <td><a class="ink-button red" href="{=BASE_URL}system/plugin/uninstall?name={$plugin->fullname}">{_}uninstall{/_}</a></td>
    </tr>
    {/foreach}
  </tbody>
</table>
{else}
<p>{_}no_plugin_installed{/_}</p>
{/if $plugin}
<h2>{_}uninstalled_plugins{/_}</h2>
{if}
<table class="ink-table alternating hover medium">
  <thead>
    <tr>
      <th class="align-left">{_}name{/_}</th>
      <th class="align-left">{_}version{/_}</th>
      <th class="align-left">{_}website{/_}</th>
      <th class="align-left">{_}description{/_}</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    {foreach array_filter( $plugins, function( $plugin ) {return !$plugin->isInstalled;} ) as $plugin}
    <tr>
      <td>{$plugin->name}</td>
      <td>{$plugin->version}</td>
      <td>{if $plugin->url}<a href="{$plugin->url}">{_}website{/_}</a>{/if}</td>
      <td>{$plugin->description|truncate:30}</td>
      <td><a class="ink-button green" href="{=BASE_URL}system/plugin/install?name={$plugin->fullname}">{_}install{/_}</a></td>
    </tr>
    {/foreach}
  </tbody>
</table>
{else}
<p>{_}no_plugin_available{/_}</p>
{/if $plugin}
{/block}
