Changeset 1705 for trunk/admin.php


Ignore:
Timestamp:
Jan 9, 2007, 12:38:54 PM (17 years ago)
Author:
rvelices
Message:

Plugins: new way of adding links and content to administration pages...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin.php

    • Property svn:keywords changed from Author Date Id Revision to Author Date Id Revision Rev URL
    r1700 r1705  
    33// | PhpWebGallery - a PHP based picture gallery                           |
    44// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    5 // | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
     5// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
    66// +-----------------------------------------------------------------------+
    77// | branch        : BSF (Best So Far)
    8 // | file          : $RCSfile$
     8// | file          : $Id$
    99// | last update   : $Date$
    1010// | last modifier : $Author$
     
    5555// +-----------------------------------------------------------------------+
    5656
    57 unset($page['page']);
    58 
    59 if
    60   (
    61     isset($_GET['page'])
     57if (isset($_GET['page'])
    6258    and preg_match('/^[a-z_]*$/', $_GET['page'])
    63   )
     59    and is_file(PHPWG_ROOT_PATH.'admin/'.$_GET['page'].'.php'))
    6460{
    65   if
    66     (
    67       (!isset($_GET['page_type']) or $_GET['page_type'] == 'standard')
    68       and is_file(PHPWG_ROOT_PATH.'admin/'.$_GET['page'].'.php')
    69     )
    70   {
    71     $page['page']['type'] = 'standard';
    72     $page['page']['name'] = $_GET['page'];
    73   }
    74   else if
    75     (
    76       (isset($_GET['page_type']) and $_GET['page_type'] == 'plugin')
    77       and isset($_GET['plugin_id'])
    78       and preg_match('/^[a-z_]*$/', $_GET['plugin_id'])
    79       and is_file(PHPWG_PLUGINS_PATH.$_GET['plugin_id'].'/admin/'.$_GET['page'].'.php')
    80     )
    81   {
    82     if (function_exists('mysql_real_escape_string'))
    83     {
    84       $page['page']['plugin_id'] = mysql_real_escape_string($_GET['plugin_id']);
    85     }
    86     else
    87     {
    88       $page['page']['plugin_id'] = mysql_escape_string($_GET['plugin_id']);
    89     }
    90 
    91     $check_db_plugin = get_db_plugins('active', $page['page']['plugin_id']);
    92     if (!empty($check_db_plugin))
    93     {
    94       $page['page']['type'] = $_GET['page_type'];
    95       $page['page']['name'] = $_GET['page'];
    96     }
    97     else
    98     {
    99       unset($page['page']);
    100     }
    101     unset($check_db_plugin);
    102   }
     61  $page['page'] = $_GET['page'];
    10362}
    104 
    105 if (!isset($page['page']))
     63else
    10664{
    107   if (isset($_GET['page_type']) and $_GET['page_type'] == 'plugin')
    108   {
    109     $page['page']['type'] = 'standard';
    110     $page['page']['name'] = 'plugins';
    111   }
    112   else
    113   {
    114     $page['page']['type'] = 'standard';
    115     $page['page']['name'] = 'intro';
    116   }
     65  $page['page'] = 'intro';
    11766}
    11867
     
    185134
    186135// required before plugin page inclusion
    187 trigger_action('plugin_admin_menu');
    188 
    189 switch($page['page']['type'])
    190 {
    191   case 'standard':
    192   {
    193     include(PHPWG_ROOT_PATH.'admin/'.$page['page']['name'].'.php');
    194     break;
    195   }
    196   case 'plugin':
    197   {
    198     include(PHPWG_PLUGINS_PATH.$page['page']['plugin_id'].'/admin/'.$page['page']['name'].'.php');
    199     break;
    200   }
    201   default:
    202   {
    203     die ("Hacking attempt!");
    204     break;
    205   }
    206 }
    207 
    208 
    209 //------------------------------------------------------------- content display
    210 $template->assign_block_vars('plugin_menu.menu_item',
     136$plugin_menu_links = array(
    211137    array(
    212138      'NAME' => l10n('admin'),
     
    214140    )
    215141  );
    216 if ( isset($page['plugin_admin_menu']) )
     142$plugin_menu_links = trigger_event('get_admin_plugin_menu_links',
     143  $plugin_menu_links );
     144
     145
     146include(PHPWG_ROOT_PATH.'admin/'.$page['page'].'.php');
     147
     148//------------------------------------------------------------- content display
     149foreach ($plugin_menu_links as $menu_item)
    217150{
    218   $plug_base_url = $link_start.'plugin&section=';
    219   foreach ($page['plugin_admin_menu'] as $menu)
    220   {
    221     $template->assign_block_vars('plugin_menu.menu_item',
    222         array(
    223           'NAME' => $menu['title'],
    224           'URL' => $plug_base_url.$menu['uid']
    225         )
    226       );
    227   }
     151  $template->assign_block_vars('plugin_menu.menu_item', $menu_item);
    228152}
    229153
Note: See TracChangeset for help on using the changeset viewer.