Changeset 1580


Ignore:
Timestamp:
Oct 27, 2006, 2:25:02 AM (17 years ago)
Author:
rvelices
Message:
  • plugins can add now their page to the admin page
  • new plugin (event_tracer) that demonstrate it and useful to see all calls

to trigger_event

Location:
trunk
Files:
6 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions_plugins.inc.php

    r1578 r1580  
    9999  return false;
    100100}
     101
     102/*allows plugins to add their content to the administration page*/
     103function add_plugin_admin_menu($title, $func)
     104{
     105  global $page;
     106
     107  $uid = md5( var_export($func, true) );
     108  $page['plugin_admin_menu'][] =
     109    array(
     110      'title' => $title,
     111      'function' => $func,
     112      'uid' => $uid
     113    );
     114}
     115
    101116?>
  • trunk/admin/plugins.php

    r1578 r1580  
    33// | PhpWebGallery - a PHP based picture gallery                           |
    44// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    5 // | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
     5// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
    66// +-----------------------------------------------------------------------+
    77// | branch        : BSF (Best So Far)
     
    6565$template->set_filenames(array('plugins' => 'admin/plugins.tpl'));
    6666
    67 if (count($plugins))
     67
     68trigger_event('plugin_admin_menu');
     69
     70$template->assign_block_vars('plugin_menu.menu_item',
     71    array(
     72      'NAME' => l10n('Plugins'),
     73      'URL' => PHPWG_ROOT_PATH.'admin.php?page=plugins'
     74    )
     75  );
     76
     77if ( isset($page['plugin_admin_menu']) )
    6878{
    69   $template->assign_block_vars( 'plugins', array() );
    70   foreach( $plugins as $plugin_id => $plugin )
     79  $plug_base_url = PHPWG_ROOT_PATH.'admin.php?page=plugin&section=';
     80  foreach ($page['plugin_admin_menu'] as $menu)
    7181  {
    72     $action_url = $my_base_url.'&plugin='.$plugin_id;
    73     if ( isset( $active_plugins[$plugin_id] ) )
    74     {
    75       $action_url .= '&action=deactivate';
    76       $action_name = l10n('Deactivate');
    77     }
    78     else
    79     {
    80       $action_url .= '&action=activate';
    81       $action_name = l10n('Activate');
    82     }
    83     $template->assign_block_vars( 'plugins.plugin',
     82    $template->assign_block_vars('plugin_menu.menu_item',
    8483        array(
    85           'NAME' => $plugin['name'],
    86           'DESCRIPTION' => $plugin['description'],
    87           'L_ACTION' => $action_name,
    88           'U_ACTION' => $action_url,
    89           )
    90        );
     84          'NAME' => $menu['title'],
     85          'URL' => $plug_base_url.$menu['uid']
     86        )
     87      );
    9188  }
    9289}
     90
     91$num=0;
     92foreach( $plugins as $plugin_id => $plugin )
     93{
     94  $action_url = $my_base_url.'&plugin='.$plugin_id;
     95  if ( isset( $active_plugins[$plugin_id] ) )
     96  {
     97    $action_url .= '&action=deactivate';
     98    $action_name = l10n('Deactivate');
     99  }
     100  else
     101  {
     102    $action_url .= '&action=activate';
     103    $action_name = l10n('Activate');
     104  }
     105  $display_name = $plugin['name'];
     106  if ( !empty($plugin['uri']) )
     107  {
     108    $display_name='<a href="'.$plugin['uri'].'">'.$display_name.'</a>';
     109  }
     110  $template->assign_block_vars( 'plugins.plugin',
     111      array(
     112        'NAME' => $display_name,
     113        'VERSION' => $plugin['version'],
     114        'DESCRIPTION' => $plugin['description'],
     115        'CLASS' => ($num++ % 2 == 1) ? 'row2' : 'row1',
     116        'L_ACTION' => $action_name,
     117        'U_ACTION' => $action_url,
     118        )
     119     );
     120}
     121
     122
    93123$template->assign_var_from_handle('ADMIN_CONTENT', 'plugins');
    94124?>
  • trunk/language/en_UK.iso-8859-1/admin.lang.php

    r1565 r1580  
    4343$lang['A new version of PhpWebGallery is available.'] = 'A new version of PhpWebGallery is available.';
    4444$lang['Actions'] = 'Actions';
     45$lang['Activate'] = 'Activate';
    4546$lang['Add a tag'] = 'Add a tag';
    4647$lang['Add a user'] = 'Add a user';
     
    6667$lang['Current name'] = 'Current name';
    6768$lang['Database'] = 'Database';
     69$lang['Deactivate'] = 'Deactivate';
    6870$lang['Delete Representant'] = 'Delete Representant';
    6971$lang['Delete selected tags'] = 'Delete selected tags';
     
    138140$lang['PhpWebGallery version'] = 'PhpWebGallery version';
    139141$lang['Picture informations updated'] = 'Picture informations updated';
     142$lang['Plugins'] = 'Plugins';
    140143$lang['Position'] = 'Position';
    141144$lang['Preferences'] = 'Preferences';
     
    176179$lang['Validate'] = 'Validate';
    177180$lang['Validation'] = 'Validation';
     181$lang['Version'] = 'Version';
    178182$lang['Virtual categories movement'] = 'Virtual categories movement';
    179183$lang['Virtual categories to move'] = 'Virtual categories to move';
  • trunk/language/fr_FR.iso-8859-1/admin.lang.php

    r1565 r1580  
    4343$lang['A new version of PhpWebGallery is available.'] = 'Une nouvelle version de PhpWebGallery est disponible.';
    4444$lang['Actions'] = 'Actions';
     45$lang['Activate'] = 'Activer';
    4546$lang['Add a tag'] = 'Ajouter un tag';
    4647$lang['Add a user'] = 'Ajouter un utilisateur';
     
    6667$lang['Current name'] = 'Nom courant';
    6768$lang['Database'] = 'Base de données';
     69$lang['Deactivate'] = 'Désactiver';
    6870$lang['Delete Representant'] = 'Supprimer le représentant';
    6971$lang['Delete selected tags'] = 'Supprimer les tags sélectionnés';
     
    138140$lang['PhpWebGallery version'] = 'Version de PhpWebGallery';
    139141$lang['Picture informations updated'] = 'Informations de l\'image mises à jour';
     142$lang['Plugins'] = 'Plugins';
    140143$lang['Position'] = 'Position';
    141144$lang['Preferences'] = 'Préférences';
     
    176179$lang['Validate'] = 'Valider';
    177180$lang['Validation'] = 'Validation';
     181$lang['Version'] = 'Version';
    178182$lang['Virtual categories movement'] = 'Déplacement de catégories virtuelles';
    179183$lang['Virtual categories to move'] = 'Catégories virtuelles à déplacer';
  • trunk/template/yoga/admin/plugins.tpl

    r1578 r1580  
    11<div class="titrePage">
    2   <h2>{lang:Plugins}</h2>
     2  <h2>
     3<!-- BEGIN plugin_menu -->
     4<!-- BEGIN menu_item -->
     5  <span style="margin-left:2px;"><a href="{plugin_menu.menu_item.URL}">{plugin_menu.menu_item.NAME}</a></span>
     6<!-- END menu_item -->
     7<!-- END plugin_menu -->
     8  </h2>
    39</div>
    410
     11
    512<!-- BEGIN plugins -->
    6 <table>
    7 <thead><tr>
     13<table class="table2">
     14<thead><tr class="throw">
    815  <td>{lang:Name}</td>
     16  <td>{lang:Version}</td>
    917  <td>{lang:Description}</td>
    10   <td>{lang:Action}</td>
     18  <td>{lang:Actions}</td>
    1119</tr></thead>
    1220<!-- BEGIN plugin -->
    13 <tr>
     21<tr class="{plugins.plugin.CLASS}">
    1422  <td>{plugins.plugin.NAME}</td>
     23  <td>{plugins.plugin.VERSION}</td>
    1524  <td>{plugins.plugin.DESCRIPTION}</td>
    1625  <td><a href="{plugins.plugin.U_ACTION}">{plugins.plugin.L_ACTION}</a></td>
Note: See TracChangeset for help on using the changeset viewer.