[geeklog-cvs] geeklog: Cosmetics: Try to display the plugin's full/display name
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Mon Jan 5 05:06:19 EST 2009
details: http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/e02ca493ee9a
changeset: 6597:e02ca493ee9a
user: Dirk Haun <dirk at haun-online.de>
date: Sat Dec 27 11:46:10 2008 +0100
description:
Cosmetics: Try to display the plugin's full/display name
diffstat:
3 files changed, 67 insertions(+), 16 deletions(-)
public_html/admin/plugins.php | 70 ++++++++++--
public_html/layout/professional/admin/plugins/editor.thtml | 2
system/lib-admin.php | 11 +
diffs (173 lines):
diff -r 2a81ead43d9c -r e02ca493ee9a public_html/admin/plugins.php
--- a/public_html/admin/plugins.php Sat Dec 27 10:47:14 2008 +0100
+++ b/public_html/admin/plugins.php Sat Dec 27 11:46:10 2008 +0100
@@ -32,8 +32,6 @@
// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// | |
// +---------------------------------------------------------------------------+
-//
-// $Id: plugins.php,v 1.84 2008/09/18 19:09:38 dhaun Exp $
require_once '../lib-common.php';
require_once 'auth.inc.php';
@@ -73,11 +71,8 @@
$retval = '';
- if (strlen ($pi_name) == 0) {
- $retval .= COM_startBlock ($LANG32[13], '',
- COM_getBlockTemplate ('_msg_block', 'header'));
- $retval .= COM_errorLog ($LANG32[12]);
- $retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
+ if (strlen($pi_name) == 0) {
+ $retval .= COM_showMessageText($LANG32[12], $LANG32[13]);
return $retval;
}
@@ -108,13 +103,13 @@
$plg_templates->set_var('lang_save', $LANG_ADMIN['save']);
$plg_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
$plg_templates->set_var('lang_delete', $LANG_ADMIN['delete']);
- $plg_templates->set_var ('pi_icon', PLG_getIcon ($pi_name));
+ $plg_templates->set_var('pi_icon', PLG_getIcon($pi_name));
if (!empty($pi_name)) {
$plg_templates->set_var ('delete_option', '<input type="submit" value="'
. $LANG_ADMIN['delete'] . '" name="mode"' . XHTML . '>');
}
$plugin_code_version = PLG_chkVersion($pi_name);
- if (empty ($plugin_code_version)) {
+ if (empty($plugin_code_version)) {
$code_version = 'N/A';
} else {
$code_version = $plugin_code_version;
@@ -130,6 +125,7 @@
$plg_templates->set_var('confirmed', $confirmed);
$plg_templates->set_var('lang_pluginname', $LANG32[26]);
$plg_templates->set_var('pi_name', $pi_name);
+ $plg_templates->set_var('pi_display_name', plugin_get_pluginname($pi_name));
$plg_templates->set_var('lang_pluginhomepage', $LANG32[27]);
$plg_templates->set_var('pi_homepage', $A['pi_homepage']);
$plg_templates->set_var('lang_pluginversion', $LANG32[28]);
@@ -298,7 +294,7 @@
}
$url .= '&' . CSRF_TOKEN . '=' . $token;
$data_arr[] = array(
- 'pi_name' => $dir,
+ 'pi_name' => plugin_get_pluginname($dir),
'number' => $index,
'install_link' => COM_createLink($LANG32[22], $url)
);
@@ -441,7 +437,7 @@
);
// this is a dummy variable so we know the form has been used if all plugins
- // should be disabled in order to disable the last one.
+ // should be disabled in order to disable the last one.
$form_arr = array('bottom' => '<input type="hidden" name="pluginenabler" value="true"' . XHTML . '>');
$retval .= ADMIN_list('plugins', 'ADMIN_getListField_plugins', $header_arr,
@@ -1007,6 +1003,58 @@
return true;
}
+/**
+* See if we can figure out the plugin's real name
+*
+* @param string $plugin internal name / directory name
+* @return string real or beautified name
+*
+*/
+function plugin_get_pluginname($plugin)
+{
+ global $_CONF;
+
+ $retval = '';
+
+ $plugins_dir = $_CONF['path'] . 'plugins/';
+ $autoinstall = $plugins_dir . $plugin . '/autoinstall.php';
+
+ // for new plugins, get the name from the autoinstall.php
+ if (file_exists($autoinstall)) {
+
+ require_once $autoinstall;
+
+ $fn = 'plugin_autoinstall_' . $plugin;
+ if (function_exists($fn)) {
+ $info = $fn($plugin);
+ if (is_array($info) && isset($info['info']) &&
+ isset($info['info']['pi_display_name'])) {
+ $retval = $info['info']['pi_display_name'];
+ }
+ }
+
+ }
+
+ if (empty($retval)) {
+ // else try the 'getadminoption' function
+ // - may fail if we don't have the proper permissions
+ $fn = 'plugin_getadminoption_' . $plugin;
+ if (function_exists($fn)) {
+ $result = $fn();
+ if (is_array($result) && !empty($result[0])) {
+ $retval = $result[0];
+ }
+ }
+ }
+
+ if (empty($retval)) {
+ // give up and fake it
+ $retval = strtoupper($plugin{0}) . substr($plugin, 1);
+ }
+
+ return $retval;
+}
+
// MAIN
$display = '';
diff -r 2a81ead43d9c -r e02ca493ee9a public_html/layout/professional/admin/plugins/editor.thtml
--- a/public_html/layout/professional/admin/plugins/editor.thtml Sat Dec 27 10:47:14 2008 +0100
+++ b/public_html/layout/professional/admin/plugins/editor.thtml Sat Dec 27 11:46:10 2008 +0100
@@ -18,7 +18,7 @@
</tr>
<tr>
<td class="alignright"><b>{lang_pluginname}:</b></td>
- <td>{pi_name}</td>
+ <td>{pi_display_name}</td>
</tr>
<tr>
<td class="alignright"><b>{lang_pluginhomepage}:</b></td>
diff -r 2a81ead43d9c -r e02ca493ee9a system/lib-admin.php
--- a/system/lib-admin.php Sat Dec 27 10:47:14 2008 +0100
+++ b/system/lib-admin.php Sat Dec 27 11:46:10 2008 +0100
@@ -32,8 +32,6 @@
// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// | |
// +---------------------------------------------------------------------------+
-//
-// $Id: lib-admin.php,v 1.136 2008/09/21 08:37:11 dhaun Exp $
if (strpos(strtolower($_SERVER['PHP_SELF']), 'lib-admin.php') !== false) {
die('This file can not be used on its own!');
@@ -957,14 +955,19 @@
return $retval;
}
-function ADMIN_getListField_plugins($fieldname, $fieldvalue, $A, $icon_arr, $token) {
+function ADMIN_getListField_plugins($fieldname, $fieldvalue, $A, $icon_arr, $token)
+{
global $_CONF, $LANG_ADMIN, $LANG32;
+
$retval = '';
switch($fieldname) {
- case "edit":
+ case 'edit':
$retval = COM_createLink($icon_arr['edit'],
"{$_CONF['site_admin_url']}/plugins.php?mode=edit&pi_name={$A['pi_name']}");
+ break;
+ case 'pi_name':
+ $retval = plugin_get_pluginname($A['pi_name']);
break;
case 'pi_version':
$plugin_code_version = PLG_chkVersion ($A['pi_name']);
More information about the geeklog-cvs
mailing list