mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-08-11 19:23:01 +02:00
Plugins: new way of adding links and content to administration pages...
git-svn-id: http://piwigo.org/svn/trunk@1705 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | PhpWebGallery - a PHP based picture gallery |
|
||||
// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | branch : BSF (Best So Far)
|
||||
// | file : $Id$
|
||||
@@ -68,36 +68,16 @@ function get_fs_plugins()
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
/*allows plugins to add their content to the administration page*/
|
||||
function add_plugin_admin_menu($title, $func)
|
||||
/**
|
||||
* Retrieves an url for a plugin page.
|
||||
* @param string plugin_id
|
||||
* @param string page - the php script file name (without .php extension)
|
||||
*/
|
||||
function get_admin_plugin_menu_link($plugin_id, $page)
|
||||
{
|
||||
global $page;
|
||||
if ( is_array( $func) )
|
||||
{
|
||||
$s = '';
|
||||
foreach( $func as $e)
|
||||
{
|
||||
if (is_object($e))
|
||||
{
|
||||
$s.=get_class($e)."\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$s.=$e;
|
||||
}
|
||||
}
|
||||
$uid = md5( $s );
|
||||
}
|
||||
else
|
||||
{
|
||||
$uid = md5( $func );
|
||||
}
|
||||
$page['plugin_admin_menu'][] =
|
||||
array(
|
||||
'title' => $title,
|
||||
'function' => $func,
|
||||
'uid' => $uid
|
||||
);
|
||||
$url = get_root_url().'admin.php?page=plugin&section='
|
||||
.urlencode($plugin_id .'~'. $page);
|
||||
return $url;
|
||||
}
|
||||
|
||||
?>
|
||||
+20
-20
@@ -2,10 +2,10 @@
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | PhpWebGallery - a PHP based picture gallery |
|
||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | branch : BSF (Best So Far)
|
||||
// | file : $RCSfile$
|
||||
// | file : $Id$
|
||||
// | last update : $Date$
|
||||
// | last modifier : $Author$
|
||||
// | revision : $Revision$
|
||||
@@ -33,27 +33,27 @@ if( !defined("PHPWG_ROOT_PATH") )
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||
check_status(ACCESS_ADMINISTRATOR);
|
||||
|
||||
$template->set_filenames(array('plugin' => 'admin/plugin.tpl'));
|
||||
|
||||
if ( isset($page['plugin_admin_menu']) )
|
||||
$section = explode('~', $_GET['section'] );
|
||||
if (count($section)!=2)
|
||||
{
|
||||
foreach ($page['plugin_admin_menu'] as $menu)
|
||||
{
|
||||
if (isset($_GET['section']) and $menu['uid']==$_GET['section'])
|
||||
{
|
||||
$found_menu=$menu;
|
||||
break;
|
||||
}
|
||||
}
|
||||
die('Invalid plugin URL');
|
||||
}
|
||||
|
||||
if ( isset($found_menu) )
|
||||
$plugin_id = $section[0];
|
||||
$check_db_plugin = get_db_plugins('active', $plugin_id );
|
||||
if (empty($check_db_plugin))
|
||||
{
|
||||
$template->assign_var('PLUGIN_TITLE', $found_menu['title'] );
|
||||
call_user_func(
|
||||
$found_menu['function'],
|
||||
PHPWG_ROOT_PATH.'admin.php?page=plugin&section='.$found_menu['uid'] );
|
||||
die('Invalid URL - plugin '.$plugin_id.' not active');
|
||||
}
|
||||
$section[1]=str_replace('./', '', $section[1]); // no up in dir structure
|
||||
|
||||
$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin');
|
||||
?>
|
||||
$filename = PHPWG_PLUGINS_PATH.$plugin_id.'/'.$section[1].'.php';
|
||||
if (is_file($filename))
|
||||
{
|
||||
include_once($filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
die('Missing '.$filename);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user