Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
c9157a23
Commit
c9157a23
authored
Oct 30, 2002
by
Dries
Browse files
- Made sure blocks are sorted by weight. Patch by Ax.
parent
aa28ec52
Changes
2
Hide whitespace changes
Inline
Side-by-side
modules/block.module
View file @
c9157a23
...
...
@@ -79,8 +79,15 @@ function block_admin_save($edit) {
}
}
function
block_rehash
()
{
$result
=
db_query
(
"SELECT * FROM blocks ORDER BY weight"
);
/**
* update blocks db table with blocks currently exported by modules
*
* @param array $order_by php array_multisort() style sort ordering, eg. "weight", SORT_ASC, SORT_STRING. see {@link http://www.php.net/manual/en/function.array-multisort.php}
* @return array blocks currently exported by modules, sorted by $order_by
* @access private
*/
function
_block_rehash
(
$order_by
=
array
(
"weight"
))
{
$result
=
db_query
(
"SELECT * FROM blocks"
);
while
(
$old_block
=
db_fetch_object
(
$result
))
{
$old_blocks
[
$old_block
->
module
][
$old_block
->
delta
]
=
$old_block
;
}
...
...
@@ -109,10 +116,16 @@ function block_rehash() {
db_query
(
"INSERT INTO blocks (module, delta, status, weight, region, path, custom) VALUES ('%s', '%d', '%d', '%d', '%d', '%s', '%d')"
,
$block
[
"module"
],
$block
[
"delta"
],
$block
[
"status"
],
$block
[
"weight"
],
$block
[
"region"
],
$block
[
"path"
],
$block
[
"custom"
]);
$blocks
[]
=
$block
;
// build array to sort on
$order
[
$order_by
[
0
]][]
=
$block
[
$order_by
[
0
]];
}
}
}
// sort
array_multisort
(
$order
[
$order_by
[
0
]],
$order_by
[
1
]
?
$order_by
[
1
]
:
SORT_ASC
,
$order_by
[
2
]
?
$order_by
[
2
]
:
SORT_REGULAR
,
$blocks
);
return
$blocks
;
}
...
...
@@ -121,7 +134,7 @@ function block_admin_display() {
$output
=
"<table border=
\"
1
\"
cellpadding=
\"
2
\"
cellspacing=
\"
2
\"
>
\n
"
;
$output
.
=
"<tr><th>block</th><th>module</th><th>enabled</th><th>custom</th><th>weight</th><th>region</th><th>path</th><th colspan=
\"
2
\"
>operations</th></tr>
\n
"
;
$blocks
=
block_rehash
();
$blocks
=
_
block_rehash
();
foreach
(
$blocks
as
$block
)
{
$output
.
=
"<tr>"
;
...
...
modules/block/block.module
View file @
c9157a23
...
...
@@ -79,8 +79,15 @@ function block_admin_save($edit) {
}
}
function
block_rehash
()
{
$result
=
db_query
(
"SELECT * FROM blocks ORDER BY weight"
);
/**
* update blocks db table with blocks currently exported by modules
*
* @param array $order_by php array_multisort() style sort ordering, eg. "weight", SORT_ASC, SORT_STRING. see {@link http://www.php.net/manual/en/function.array-multisort.php}
* @return array blocks currently exported by modules, sorted by $order_by
* @access private
*/
function
_block_rehash
(
$order_by
=
array
(
"weight"
))
{
$result
=
db_query
(
"SELECT * FROM blocks"
);
while
(
$old_block
=
db_fetch_object
(
$result
))
{
$old_blocks
[
$old_block
->
module
][
$old_block
->
delta
]
=
$old_block
;
}
...
...
@@ -109,10 +116,16 @@ function block_rehash() {
db_query
(
"INSERT INTO blocks (module, delta, status, weight, region, path, custom) VALUES ('%s', '%d', '%d', '%d', '%d', '%s', '%d')"
,
$block
[
"module"
],
$block
[
"delta"
],
$block
[
"status"
],
$block
[
"weight"
],
$block
[
"region"
],
$block
[
"path"
],
$block
[
"custom"
]);
$blocks
[]
=
$block
;
// build array to sort on
$order
[
$order_by
[
0
]][]
=
$block
[
$order_by
[
0
]];
}
}
}
// sort
array_multisort
(
$order
[
$order_by
[
0
]],
$order_by
[
1
]
?
$order_by
[
1
]
:
SORT_ASC
,
$order_by
[
2
]
?
$order_by
[
2
]
:
SORT_REGULAR
,
$blocks
);
return
$blocks
;
}
...
...
@@ -121,7 +134,7 @@ function block_admin_display() {
$output
=
"<table border=
\"
1
\"
cellpadding=
\"
2
\"
cellspacing=
\"
2
\"
>
\n
"
;
$output
.
=
"<tr><th>block</th><th>module</th><th>enabled</th><th>custom</th><th>weight</th><th>region</th><th>path</th><th colspan=
\"
2
\"
>operations</th></tr>
\n
"
;
$blocks
=
block_rehash
();
$blocks
=
_
block_rehash
();
foreach
(
$blocks
as
$block
)
{
$output
.
=
"<tr>"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment