Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
unused_modules
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
unused_modules
Commits
42ea673b
Commit
42ea673b
authored
10 years ago
by
Niels de Feyter
Browse files
Options
Downloads
Patches
Plain Diff
Finish Drupal-6.x-Port
parent
f32bcde9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
unused_modules.info
+2
-1
2 additions, 1 deletion
unused_modules.info
unused_modules.module
+46
-23
46 additions, 23 deletions
unused_modules.module
with
48 additions
and
24 deletions
unused_modules.info
+
2
−
1
View file @
42ea673b
...
...
@@ -2,4 +2,5 @@ name = Unused Modules
description = List modules and projects that are unused and safe to delete.
package = Development
configure = admin/config/development/unused_modules
core = 7.x
\ No newline at end of file
dependencies[] = drupal_static
core = 6.x
\ No newline at end of file
This diff is collapsed.
Click to expand it.
unused_modules.module
+
46
−
23
View file @
42ea673b
...
...
@@ -104,7 +104,8 @@ function unused_modules_show_projects($op = 'all') {
return
t
(
"Hurray, no orphaned projects!"
);
}
return
theme
(
'table'
,
array
(
'header'
=>
$header
,
'rows'
=>
$rows
));
// @drupal-6 backport: pass $header and $rows directly to theme_table.
return
theme
(
'table'
,
$header
,
$rows
);
}
/**
...
...
@@ -151,7 +152,8 @@ function unused_modules_show_modules($op) {
return
t
(
"Hurray, no orphaned modules!"
);
}
return
theme
(
'table'
,
array
(
'header'
=>
$header
,
'rows'
=>
$rows
));
// @drupal-6 backport: pass $header and $rows directly to theme_table.
return
theme
(
'table'
,
$header
,
$rows
);
}
/**
...
...
@@ -211,17 +213,19 @@ function _unused_modules_get_modules_by_project() {
* Returns an array of available modules.
*/
function
_unused_modules_get_available_modules
()
{
// @drupal-6 backport: needs dependency module 'drupal_static'.
$available_modules
=
&
drupal_static
(
__FUNCTION__
);
if
(
!
isset
(
$available_modules
))
{
// Get all modules available.
$available_modules
=
drupal_system_listing
(
"/\.module$/"
,
"modules"
,
'name'
,
0
);
// @drupal-6 backport: little different regex for .module selector.
$available_modules
=
drupal_system_listing
(
'\.module$'
,
'modules'
,
'name'
,
0
);
// Sort for readability.
ksort
(
$available_modules
);
// Remove core modules.
_unused_modules_remove_core_modules
(
$available_modules
);
// Add module info.
_unused_modules_add_module_info
(
$available_modules
);
// Remove core modules.
_unused_modules_remove_core_modules
(
$available_modules
);
// Add information from .info file.
_unused_modules_add_info_file_information
(
$available_modules
);
// Add project info.
...
...
@@ -258,8 +262,11 @@ function _unused_modules_get_enabled_modules() {
*/
function
_unused_modules_add_module_info
(
&
$modules
)
{
foreach
(
$modules
as
&
$module
)
{
// @drupal-6 backport: use module filename for uri.
$module
->
uri
=
$module
->
filename
;
// Set module_path.
$module
->
module_path
=
str_replace
(
"/"
.
$module
->
fil
ename
,
""
,
$module
->
uri
);
$module
->
module_path
=
str_replace
(
"/"
.
$module
->
bas
ename
,
""
,
$module
->
uri
);
}
}
...
...
@@ -276,27 +283,43 @@ function _unused_modules_add_project_path(&$modules) {
$modules_grouped_by_project
[
$module
->
project
][
$module
->
name
]
=
$module
;
}
// Determine common basepath by picking the shortest path of all project
// modules.
// Add project_path to module.
foreach
(
$modules_grouped_by_project
as
$project
)
{
$project_paths
=
array
();
// Determine common basepath by looking for needle "/<project>/" in uri.
// As a fallback use the shortest path method.
foreach
(
$project
as
$module
)
{
$project_paths
[]
=
$module
->
module_path
;
if
(
$module
->
error
!==
TRUE
)
{
$needle
=
"/"
.
$module
->
project
.
"/"
;
$before_needle
=
TRUE
;
$project_path
=
strstr
(
$module
->
uri
,
$needle
,
$before_needle
)
.
"/"
.
$module
->
project
;
$module
->
project_path
=
$project_path
;
}
}
// Get length of each module path in a project.
$lengths
=
array_map
(
'strlen'
,
$project_paths
);
// Sort by value (lowest number first)
asort
(
$lengths
);
// Get lowest key.
reset
(
$lengths
);
$key
=
key
(
$lengths
);
// Shortest path.
$shortest_path
=
$project_paths
[
$key
];
// Add the project_path to each module.
foreach
(
$project
as
$module
)
{
$module
->
project_path
=
$shortest_path
;
// Fallback: determine common basepath by picking the shortest path of all
// project modules.
if
(
!
isset
(
$module
->
project_path
))
{
$project_paths
=
array
();
foreach
(
$project
as
$module
)
{
$project_paths
[]
=
$module
->
module_path
;
}
// Get length of each module path in a project.
$lengths
=
array_map
(
'strlen'
,
$project_paths
);
// Sort by value (lowest number first)
asort
(
$lengths
);
// Get lowest key.
reset
(
$lengths
);
$key
=
key
(
$lengths
);
// Shortest path.
$shortest_path
=
$project_paths
[
$key
];
// Add the project_path to each module.
foreach
(
$project
as
$module
)
{
$module
->
project_path
=
$shortest_path
;
}
}
unset
(
$project_paths
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment