/** * used for the list of plugins in admin/plugins.php * * @param string $fieldName * @param string $fieldValue * @param array $A * @param array $icon_arr * @param string $token * @return string */ function ADMIN_getListField_plugins($fieldName, $fieldValue, $A, $icon_arr, $token) { global $_CONF, $LANG_ADMIN, $LANG32; $retval = ''; switch ($fieldName) { case 'info_installed': $retval = COM_createLink($icon_arr['info'], "{$_CONF['site_admin_url']}/plugins.php?mode=info_installed&pi_name={$A['pi_name']}", array('title' => $LANG32[13])); break; case 'pi_name': $retval = plugin_get_pluginname($A['pi_name']); break; case 'pi_version': $plugin_code_version = PLG_chkVersion($A['pi_name']); if (empty($plugin_code_version)) { $code_version = $LANG_ADMIN['na']; } else { $code_version = $plugin_code_version; } $pi_installed_version = $A['pi_version']; if (empty($plugin_code_version) || $pi_installed_version == $code_version) { $retval = $pi_installed_version; } else { $retval = "{$LANG32[37]}: {$pi_installed_version}, {$LANG32[36]}: {$plugin_code_version}"; if ($A['pi_enabled'] == 1) { $retval .= " <b>{$LANG32[38]}</b>"; $csrfToken = '&' . CSRF_TOKEN . '=' . $token; $style = 'style="vertical-align: middle;"'; $img = $_CONF['layout_url'] . '/images/update.png'; $img = "<img {$style} alt=\"[" . $LANG32[38] . "]\" src=\"{$img}\"" . XHTML . ">"; $url = $_CONF['site_admin_url'] . '/plugins.php?mode=updatethisplugin&pi_name=' . $A['pi_name'] . $csrfToken; $retval .= COM_createLink($img, $url, array('title' => $LANG32[42])); } } break; case 'pi_dependencies': if (PLG_checkDependencies($A['pi_name'])) { $retval = COM_getTooltip($LANG32[51], PLG_printDependencies($A['pi_name'], $A['pi_gl_version'])); } else { $style = "display: inline; color: #a00; border-bottom: 1px dotted #a00;"; $retval = COM_getTooltip("<b class='notbold' style='{$style}'>{$LANG32[52]}</b>", PLG_printDependencies($A['pi_name'], $A['pi_gl_version'])); } break; case 'pi_load': $csrfToken = '&' . CSRF_TOKEN . '=' . $token; $style = "style='vertical-align: middle;'"; $upimg = $_CONF['layout_url'] . '/images/admin/up.png'; $dnimg = $_CONF['layout_url'] . '/images/admin/down.png'; $url = $_CONF['site_admin_url'] . '/plugins.php?mode=change_load_order&pi_name=' . $A['pi_name'] . $csrfToken . '&where='; $retval .= COM_createLink("<img {$style} alt='+' src='{$upimg}'" . XHTML . ">", $url . 'up', array('title' => $LANG32[44])); $retval .= ' ' . $A['pi_load'] . ' '; $retval .= COM_createLink("<img {$style} alt='-' src='{$dnimg}'" . XHTML . ">", $url . 'dn', array('title' => $LANG32[45])); break; case 'pi_enabled': if (!PLG_checkDependencies($A['pi_name'])) { $retval = str_replace('<img ', '<img title="' . $LANG32[64] . '" ', $icon_arr['warning']); } else { $not_present = false; if ($A['pi_enabled'] == 1) { $switch = 'enabled'; $title = $LANG32[49]; } else { $switch = 'disabled'; $title = $LANG32[48]; if (!file_exists($_CONF['path'] . 'plugins/' . $A['pi_name'] . '/functions.inc')) { $not_present = true; } } if ($not_present) { $retval = str_replace('<img ', '<img title="' . $LANG32[64] . '" ', $icon_arr['unavailable']); } else { $sorting = ''; $csrfToken2 = '&' . CSRF_TOKEN . '=' . $token; if (!empty($_GET['order']) && !empty($_GET['direction'])) { // Remember how the list was sorted $ord = trim($_GET['order']); $dir = trim($_GET['direction']); $old = trim($_GET['prevorder']); $sorting = "&order={$ord}&direction={$dir}&prevorder={$old}"; } $retval = COM_createLink($icon_arr[$switch], $_CONF['site_admin_url'] . '/plugins.php?mode=toggle&pi_name=' . $A['pi_name'] . $csrfToken2 . $sorting, array('title' => $title)); } } break; case 'delete': $csrfToken2 = '&' . CSRF_TOKEN . '=' . $token; $id = 'uninstall_' . $A['pi_name']; // used by JavaScript $message = sprintf($LANG32[47], "\\'" . plugin_get_pluginname($A['pi_name']) . "\\'"); // used by JavaScript $url = $_CONF['site_admin_url'] . '/plugins.php?mode=delete&pi_name=' . $A['pi_name'] . $csrfToken2; $link_args = array('title' => $LANG32[46], 'onclick' => "confirm_action('{$message}', '{$url}&confirmed=1')", 'id' => $id); $retval .= COM_createLink($icon_arr['deleteitem'], $url, $link_args); // If javascript is available, we will be using it to get a confirmation from the user. So we need to hide the default link. $retval .= '<script type="text/javascript">document.getElementById("' . $id . '").href = "javascript:void(0);";</script>'; break; default: $retval = $fieldValue; break; } return $retval; }
/** * Creates list of uninstalled plugins (if any) and offers install link to them. * * @param string $token Security token to use in list * @return string HTML containing list of uninstalled plugins * */ function show_newplugins($token) { global $_CONF, $_TABLES, $LANG32; require_once $_CONF['path_system'] . 'lib-admin.php'; $plugins = array(); $plugins_dir = $_CONF['path'] . 'plugins/'; $fd = opendir($plugins_dir); $index = 1; $retval = ''; $data_arr = array(); while (($dir = @readdir($fd)) == TRUE) { if ($dir != '.' && $dir != '..' && $dir != 'CVS' && substr($dir, 0, 1) != '.' && is_dir($plugins_dir . $dir)) { clearstatcache(); // Check and see if this plugin is installed - if there is a record. // If not then it's a new plugin if (DB_count($_TABLES['plugins'], 'pi_name', $dir) == 0) { $plugin_ok = false; $plugin_new_style = false; // additionally, check if a 'functions.inc' exists if (file_exists($plugins_dir . $dir . '/functions.inc')) { // new plugins will have a autoinstall.php if (file_exists($plugins_dir . $dir . '/autoinstall.php')) { $plugin_ok = true; $plugin_new_style = true; } else { // and finally, since we're going to link to it, check // if an install script exists $adminurl = $_CONF['site_admin_url']; if (strrpos($adminurl, '/') == strlen($adminurl)) { $adminurl = substr($adminurl, 0, -1); } $pos = strrpos($adminurl, '/'); if ($pos === false) { // didn't work out - use the URL $admindir = $_CONF['site_admin_url']; } else { $admindir = $_CONF['path_html'] . substr($adminurl, $pos + 1); } $fh = @fopen($admindir . '/plugins/' . $dir . '/install.php', 'r'); if ($fh) { fclose($fh); $plugin_ok = true; $plugin_new_style = false; } } if ($plugin_ok) { if ($plugin_new_style) { $url = $_CONF['site_admin_url'] . '/plugins.php' . '?mode=autoinstall&plugin=' . $dir; } else { $url = $_CONF['site_admin_url'] . '/plugins/' . $dir . '/install.php?action=install'; } $url .= '&' . CSRF_TOKEN . '=' . $token; $data_arr[] = array('pi_name' => $dir, 'pi_display_name' => plugin_get_pluginname($dir), 'pi_gl_version' => '', 'number' => $index, 'install_link' => $url); $index++; } } } } } $header_arr = array(array('text' => $LANG32[59], 'field' => 'info_uninstalled'), array('text' => $LANG32[16], 'field' => 'pi_display_name'), array('text' => $LANG32[17], 'field' => 'pi_version'), array('text' => $LANG32[50], 'field' => 'pi_dependencies'), array('text' => $LANG32[22], 'field' => 'install_link')); $text_arr = array('title' => $LANG32[14]); $retval .= ADMIN_simpleList('ADMIN_getListField_newplugins', $header_arr, $text_arr, $data_arr); return $retval; }
/** * used for the list of plugins in admin/plugins.php * */ function ADMIN_getListField_plugins($fieldname, $fieldvalue, $A, $icon_arr, $token) { global $_CONF, $LANG_ADMIN, $LANG32; static $added_token; $retval = ''; switch ($fieldname) { 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']); if (empty($plugin_code_version)) { $code_version = $LANG_ADMIN['na']; } else { $code_version = $plugin_code_version; } $pi_installed_version = $A['pi_version']; if (empty($plugin_code_version) || $pi_installed_version == $code_version) { $retval = $pi_installed_version; } else { $retval = "{$LANG32[37]}: {$pi_installed_version}, {$LANG32[36]}: {$plugin_code_version}"; if ($A['pi_enabled'] == 1) { $retval .= " <b>{$LANG32[38]}</b>" . ' <input type="image" src="' . $_CONF['layout_url'] . '/images/update.png" alt="[' . $LANG32[38] . ']" name="updatethisplugin" value="' . $A['pi_name'] . '" onclick="submit()" title="' . $LANG32[42] . '"' . XHTML . '>'; if (!isset($added_token)) { $retval .= '<input type="hidden" name="' . CSRF_TOKEN . '" ' . 'value="' . $token . '"' . XHTML . '>'; $added_token = true; } } } break; case 'enabled': $not_present = false; if ($A['pi_enabled'] == 1) { $switch = ' checked="checked"'; } else { $switch = ''; if (!file_exists($_CONF['path'] . 'plugins/' . $A['pi_name'] . '/functions.inc')) { $not_present = true; } } if ($not_present) { $retval = '<input type="checkbox" name="enabledplugins[' . $A['pi_name'] . ']" disabled="disabled"' . XHTML . '>'; } else { $retval = '<input type="checkbox" name="enabledplugins[' . $A['pi_name'] . ']" onclick="submit()" value="1"' . $switch . XHTML . '>'; if (!isset($added_token)) { $retval .= '<input type="hidden" name="' . CSRF_TOKEN . '" ' . 'value="' . $token . '"' . XHTML . '>'; $added_token = true; } } break; default: $retval = $fieldvalue; break; } return $retval; }