Skip to content

Commit

Permalink
Code cleanup and whitespace
Browse files Browse the repository at this point in the history
- Use Closure instead of defining a function to sort plugins
- Remove unnecessary variable assignments
  • Loading branch information
dregad committed Jun 2, 2014
1 parent fb68df7 commit f7a5cd8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
4 changes: 2 additions & 2 deletions core/plugin_api.php
Expand Up @@ -166,7 +166,7 @@ function plugin_file( $p_file, $p_redirect = false, $p_base_name = null ) {
*/
function plugin_file_include( $p_filename, $p_basename = null ) {

global $g_plugin_mime_types;
global $g_plugin_mime_types;

if( is_null( $p_basename ) ) {
$t_current = plugin_get_current();
Expand Down Expand Up @@ -200,7 +200,7 @@ function plugin_file_include( $p_filename, $p_basename = null ) {
}

if ( $t_content_type )
header('Content-Type: ' . $t_content_type );
header('Content-Type: ' . $t_content_type );

readfile( $t_file_path );
}
Expand Down
16 changes: 5 additions & 11 deletions manage_plugin_page.php
Expand Up @@ -55,18 +55,12 @@

print_manage_menu( 'manage_plugin_page.php' );

/**
* Sort Plugins by name
* @param MantisPlugin $p_plugin1 Plugin 1
* @param MantisPlugin $p_plugin2 Plugin 2
* @return string
*/
function plugin_sort( $p_plugin1, $p_plugin2 ) {
return strcasecmp( $p_plugin1->name, $p_plugin2->name );
}

$t_plugins = plugin_find_all();
uasort( $t_plugins, 'plugin_sort' );
uasort( $t_plugins,
function ( $p1, $p2 ) {
return strcasecmp( $p1->name, $p2->name );
}
);

$t_plugins_installed = array();
$t_plugins_available = array();
Expand Down
5 changes: 2 additions & 3 deletions plugin.php
Expand Up @@ -35,10 +35,9 @@

$t_plugin_path = config_get( 'plugin_path' );

$f_page= gpc_get_string( 'page' );
$t_matches = array();
$f_page = gpc_get_string( 'page' );

if ( !preg_match( '/^([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+[\/a-zA-Z0-9_-]*)/', $f_page, $t_matches ) ) {
if( !preg_match( '/^([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+[\/a-zA-Z0-9_-]*)/', $f_page, $t_matches ) ) {
error_parameters( $f_page );
trigger_error( ERROR_PLUGIN_INVALID_PAGE, ERROR );
}
Expand Down
3 changes: 1 addition & 2 deletions plugin_file.php
Expand Up @@ -39,9 +39,8 @@
$t_plugin_path = config_get( 'plugin_path' );

$f_file = gpc_get_string( 'file' );
$t_matches = array();

if ( !preg_match( '/^([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+[\/a-zA-Z0-9_-]*\.?[a-zA-Z0-9_-]*)/', $f_file, $t_matches ) ) {
if( !preg_match( '/^([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+[\/a-zA-Z0-9_-]*\.?[a-zA-Z0-9_-]*)/', $f_file, $t_matches ) ) {
error_parameters( $f_file );
trigger_error( ERROR_PLUGIN_INVALID_FILE, ERROR );
}
Expand Down

0 comments on commit f7a5cd8

Please sign in to comment.