JeroenDeDauw /
Maps
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * Static class for hooks handled by the Maps extension. |
||
| 5 | * |
||
| 6 | * @since 0.7 |
||
| 7 | * |
||
| 8 | * @licence GNU GPL v2+ |
||
| 9 | * @author Jeroen De Dauw < [email protected] > |
||
| 10 | */ |
||
| 11 | final class MapsHooks { |
||
| 12 | |||
| 13 | /** |
||
| 14 | * Adds a link to Admin Links page. |
||
| 15 | * |
||
| 16 | * @since 0.7 |
||
| 17 | * |
||
| 18 | * @param ALTree $admin_links_tree |
||
| 19 | * |
||
| 20 | * @return boolean |
||
| 21 | */ |
||
| 22 | public static function addToAdminLinks( ALTree &$admin_links_tree ) { |
||
| 23 | $displaying_data_section = $admin_links_tree->getSection( wfMessage( 'smw_adminlinks_displayingdata' )->text() ); |
||
| 24 | |||
| 25 | // Escape if SMW hasn't added links. |
||
| 26 | if ( is_null( $displaying_data_section ) ) { |
||
| 27 | return true; |
||
| 28 | } |
||
| 29 | |||
| 30 | $smw_docu_row = $displaying_data_section->getRow( 'smw' ); |
||
| 31 | |||
| 32 | $maps_docu_label = wfMessage( 'adminlinks_documentation', 'Maps' )->text(); |
||
| 33 | $smw_docu_row->addItem( AlItem::newFromExternalLink( 'https://semantic-mediawiki.org/wiki/Maps', $maps_docu_label ) ); |
||
| 34 | |||
| 35 | return true; |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Adds global JavaScript variables. |
||
| 40 | * |
||
| 41 | * @since 1.0 |
||
| 42 | * @see http://www.mediawiki.org/wiki/Manual:Hooks/MakeGlobalVariablesScript |
||
| 43 | * @param array &$vars Variables to be added into the output |
||
| 44 | * @param OutputPage $outputPage OutputPage instance calling the hook |
||
| 45 | * @return boolean true in all cases |
||
| 46 | */ |
||
| 47 | public static function onMakeGlobalVariablesScript( array &$vars, OutputPage $outputPage ) { |
||
|
0 ignored issues
–
show
onMakeGlobalVariablesScript uses the super-global variable $GLOBALS which is generally not recommended.
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: // Bad
class Router
{
public function generate($path)
{
return $_SERVER['HOST'].$path;
}
}
// Better
class Router
{
private $host;
public function __construct($host)
{
$this->host = $host;
}
public function generate($path)
{
return $this->host.$path;
}
}
class Controller
{
public function myAction(Request $request)
{
// Instead of
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
// Better (assuming you use the Symfony2 request)
$page = $request->query->get('page', 1);
}
}
Loading history...
|
|||
| 48 | global $egMapsGlobalJSVars; |
||
| 49 | |||
| 50 | $vars['egMapsDebugJS'] = $GLOBALS['egMapsDebugJS']; |
||
| 51 | $vars[ 'egMapsAvailableServices' ] = $GLOBALS['egMapsAvailableServices']; |
||
| 52 | |||
| 53 | $vars += $egMapsGlobalJSVars; |
||
| 54 | |||
| 55 | return true; |
||
| 56 | } |
||
| 57 | |||
| 58 | } |
||
| 59 | |||
| 60 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.