【php开源代码栏目提醒】:网学会员为广大网友收集整理了,plugin_interface.lib.php,希望对大家有所帮助!
<?php
/* $Id: plugin_interface.lib.php,v 1.3 2006/01/17 17:02:30 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
/**
* Generic plugin interface.
*/
/**
* array PMA_getPlugins(string $plugins_dir, mixed $plugin_param)
*
* Reads all plugin information from directory $plugins_dir.
*
* @uses ksort()
* @uses opendir()
* @uses readdir()
* @uses is_file()
* @uses eregi()
* @param string $plugins_dir directrory with plugins
* @param mixed $plugin_param parameter to plugin by which they can decide whether they can work
* @return array list of plugins
*/
function PMA_getPlugins($plugins_dir, $plugin_param)
{
/* Scan for plugins */
$plugin_list = array();
if ($handle = @opendir($plugins_dir)) {
$is_first = 0;
while ($file = @readdir($handle)) {
if (is_file($plugins_dir . $file) && eregi('\.php$', $file)) {
include $plugins_dir . $file;
}
}
}
ksort($plugin_list);
return $plugin_list;
}
/**
* string PMA_getString(string $name)
*
* returns locale string for $name or $name if no locale is found
*
* @uses $GLOBALS
* @param string $name for local string
* @return string locale string for $name
*/
function PMA_getString($name)
{
return isset($GLOBALS[$name]) ? $GLOBALS[$name] : $name;
}
/**
* string PMA_pluginCheckboxCheck(string $section, string $opt)
*
* returns html input tag option 'checked' if plugin $opt should be set by config or request
*
* @uses $_REQUEST
* @uses $GLOBALS['cfg']
* @uses $GLOBALS['timeout_passed']
* @param string $section name of config section in
* $GLOBALS['cfg'][$section] for plugin
* @param string $opt name of option
* @return string hmtl input tag option 'checked'
*/
function PMA_pluginCheckboxCheck($section, $opt)
{
if ((isset($GLOBALS['timeout_passed']) && $GLOBALS['timeout_passed'] && isset($_REQUEST[$opt])) ||
(isset($GLOBALS['cfg'][$section][$opt]) && $GLOBALS['cfg'][$section][$opt])) {
return ' checked="checked"';
}
return '';
}
/**
* string PMA_pluginGetDefault(string $section, string $opt)
*
* returns default value for option $opt
*
* @uses htmlspecialchars()
* @uses $_REQUEST
* @uses $GLOBALS['cfg']
* @uses $GLOBALS['timeout_passed']
* @param string $section name of config section in
* $GLOBALS['cfg'][$section] for plugin
* @param string $opt name of option
* @return string default value for option $opt
*/
function PMA_pluginGetDefault($section, $opt)
{
if (isset($GLOBALS['timeout_passed']) && $GLOBALS['timeout_passed'] && isset($_REQUEST[$opt])) {
return htmlspecialchars($_REQUEST[$opt]);
} elseif (isset($GLOBALS['cfg'][$section][$opt])) {
return htmlspecialchars($GLOBALS['cfg'][$section][$opt]);
}
return '';
}
/**
* string PMA_pluginIsActive(string $section, string $opt, string $val)
*
* returns html input tag option 'checked' if option $opt should be set by config or request
*
* @uses $_REQUEST
* @uses $GLOBALS['cfg']
* @uses $GLOBALS['timeout_passed']
* @param string $section name of config section in
* $GLOBALS['cfg'][$section] for plugin
* @param string $opt name of option
* @param string $val value of option to check against
* @return string html input tag option 'checked'
*/
function PMA_pluginIsActive($section, $opt, $val)
{
if ( ! empty($GLOBALS['timeout_passed']) && isset($_REQUEST[$opt])) {
if ($_REQUEST[$opt] == $val) {
return ' checked="checked"';
}
} elseif (isset($GLOBALS['cfg'][$section][$opt]) && $GLOBALS['cfg'][$section][$opt] == $val) {
return ' checked="checked"';
}
return '';
}
/**
* string PMA_pluginGetChoice(string $section, string $name, array &$list)
*
* returns html radio form element for plugin choice
*
* @uses PMA_pluginIsActive()
* @uses PMA_getString()
* @param string $section name of config section in
* $GLOBALS['cfg'][$section] for plugin
* @param string $name name of radio element
* @param array &$list array with plugin configuration defined in plugin file
* @return string html input radio tag
*/
function PMA_pluginGetChoice($section, $name, &$list)
{
$ret = '';
foreach ($list as $plugin_name => $val) {
$ret .= '<!-- ' . $plugin_name . ' -->' . "\n";
$ret .= '<input type="radio" name="' . $name . '" value="' . $plugin_name . '"'
. ' id="radio_plugin_' . $plugin_name . '"'
. ' onclick="if(this.checked) { hide_them_all();'
.' document.getElementById(\'' . $plugin_name . '_options\').style.display = \'block\'; };'
.' return true"'
. PMA_pluginIsActive($section, $name, $