Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
303
Merge Requests
303
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
25fad504
Commit
25fad504
authored
Apr 25, 2009
by
Dries
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Patch
#394146
by ksenzee, csevb10, dropcube: converted to the new database abstraction layer.
parent
fb5d44bc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
20 deletions
+52
-20
modules/filter/filter.admin.inc
modules/filter/filter.admin.inc
+41
-9
modules/filter/filter.install
modules/filter/filter.install
+1
-1
modules/filter/filter.module
modules/filter/filter.module
+4
-4
modules/filter/filter.test
modules/filter/filter.test
+6
-6
No files found.
modules/filter/filter.admin.inc
View file @
25fad504
...
...
@@ -50,7 +50,10 @@ function filter_admin_overview_submit($form, &$form_state) {
foreach
(
$form_state
[
'values'
]
as
$id
=>
$data
)
{
if
(
is_array
(
$data
)
&&
isset
(
$data
[
'weight'
]))
{
// Only update if this is a form element with weight.
db_query
(
"UPDATE
{
filter_format
}
SET weight = %d WHERE format = %d"
,
$data
[
'weight'
],
$id
);
db_update
(
'filter_format'
)
->
fields
(
array
(
'weight'
=>
$data
[
'weight'
]))
->
condition
(
'format'
,
$id
)
->
execute
();
}
}
drupal_set_message
(
t
(
'The text format ordering has been saved.'
));
...
...
@@ -239,7 +242,14 @@ function filter_admin_format_form_submit($form, &$form_state) {
$roles
=
','
.
implode
(
','
,
$roles
)
.
','
;
}
db_query
(
"UPDATE
{
filter_format
}
SET cache = %d, name='%s', roles = '%s' WHERE format = %d"
,
$cache
,
$name
,
$roles
,
$format
);
db_update
(
'filter_format'
)
->
fields
(
array
(
'cache'
=>
$cache
,
'name'
=>
$name
,
'roles'
=>
$roles
,
))
->
condition
(
'format'
,
$format
)
->
execute
();
cache_clear_all
(
$format
.
':'
,
'cache_filter'
,
TRUE
);
...
...
@@ -260,7 +270,7 @@ function filter_admin_format_form_submit($form, &$form_state) {
*/
function
filter_admin_delete
()
{
$format
=
arg
(
4
);
$format
=
db_
fetch_object
(
db_query
(
'SELECT * FROM {filter_format} WHERE format = %d'
,
$format
)
);
$format
=
db_
query
(
'SELECT * FROM {filter_format} WHERE format = :format'
,
array
(
':format'
=>
$format
))
->
fetchObject
(
);
if
(
$format
)
{
if
(
$format
->
format
!=
variable_get
(
'filter_default_format'
,
1
))
{
...
...
@@ -283,14 +293,31 @@ function filter_admin_delete() {
* Process filter delete form submission.
*/
function
filter_admin_delete_submit
(
$form
,
&
$form_state
)
{
db_query
(
"DELETE FROM
{
filter_format
}
WHERE format = %d"
,
$form_state
[
'values'
][
'format'
]);
db_query
(
"DELETE FROM
{
filter
}
WHERE format = %d"
,
$form_state
[
'values'
][
'format'
]);
db_delete
(
'filter_format'
)
->
condition
(
'format'
,
$form_state
[
'values'
][
'format'
])
->
execute
();
db_delete
(
'filter'
)
->
condition
(
'format'
,
$form_state
[
'values'
][
'format'
])
->
execute
();
$default
=
variable_get
(
'filter_default_format'
,
1
);
// Replace existing instances of the deleted format with the default format.
db_query
(
"UPDATE
{
node_revision
}
SET format = %d WHERE format = %d"
,
$default
,
$form_state
[
'values'
][
'format'
]);
db_query
(
"UPDATE
{
comment
}
SET format = %d WHERE format = %d"
,
$default
,
$form_state
[
'values'
][
'format'
]);
db_query
(
"UPDATE
{
box
}
SET format = %d WHERE format = %d"
,
$default
,
$form_state
[
'values'
][
'format'
]);
db_update
(
'node_revision'
)
->
fields
(
array
(
'format'
=>
$default
))
->
condition
(
'format'
,
$form_state
[
'values'
][
'format'
])
->
execute
();
if
(
db_table_exists
(
'comment'
))
{
db_update
(
'comment'
)
->
fields
(
array
(
'format'
=>
$default
))
->
condition
(
'format'
,
$form_state
[
'values'
][
'format'
])
->
execute
();
}
if
(
db_table_exists
(
'box'
))
{
db_update
(
'box'
)
->
fields
(
array
(
'format'
=>
$default
))
->
condition
(
'format'
,
$form_state
[
'values'
][
'format'
])
->
execute
();
}
cache_clear_all
(
$form_state
[
'values'
][
'format'
]
.
':'
,
'cache_filter'
,
TRUE
);
drupal_set_message
(
t
(
'Deleted text format %format.'
,
array
(
'%format'
=>
$form_state
[
'values'
][
'name'
])));
...
...
@@ -404,7 +431,12 @@ function theme_filter_admin_order($form) {
function
filter_admin_order_submit
(
$form
,
&
$form_state
)
{
foreach
(
$form_state
[
'values'
][
'weights'
]
as
$id
=>
$weight
)
{
list
(
$module
,
$delta
)
=
explode
(
'/'
,
$id
);
db_query
(
"UPDATE
{
filter
}
SET weight = %d WHERE format = %d AND module = '%s' AND delta = %d"
,
$weight
,
$form_state
[
'values'
][
'format'
],
$module
,
$delta
);
db_update
(
'filter'
)
->
fields
(
array
(
'weight'
=>
$weight
))
->
condition
(
'format'
,
$form_state
[
'values'
][
'format'
])
->
condition
(
'module'
,
$module
)
->
condition
(
'delta'
,
$delta
)
->
execute
();
}
drupal_set_message
(
t
(
'The filter ordering has been saved.'
));
...
...
modules/filter/filter.install
View file @
25fad504
...
...
@@ -113,7 +113,7 @@ function filter_update_7000() {
function
filter_update_7001
()
{
$ret
=
array
();
$result
=
db_query
(
"SELECT format FROM
{
filter_formats
}
"
);
while
(
$format
=
db_fetch_object
(
$result
)
)
{
foreach
(
$result
as
$format
)
{
// Deprecated constants FILTER_HTML_STRIP = 1 and FILTER_HTML_ESCAPE = 2.
if
(
variable_get
(
'filter_html_'
.
$format
->
format
,
1
)
==
2
)
{
$ret
[]
=
update_sql
(
"INSERT INTO
{
filters
}
(format, module, delta, weight) VALUES ("
.
$format
->
format
.
", 'filter', 4, 0)"
);
...
...
modules/filter/filter.module
View file @
25fad504
...
...
@@ -364,7 +364,7 @@ function filter_format_allowcache($format) {
static
$cache
=
array
();
$format
=
filter_resolve_format
(
$format
);
if
(
!
isset
(
$cache
[
$format
]))
{
$cache
[
$format
]
=
db_
result
(
db_query
(
'SELECT cache FROM {filter_format} WHERE format = %d'
,
$format
)
);
$cache
[
$format
]
=
db_
query
(
'SELECT cache FROM {filter_format} WHERE format = :format'
,
array
(
':format'
=>
$format
))
->
fetchField
(
);
}
return
$cache
[
$format
];
}
...
...
@@ -377,8 +377,8 @@ function filter_list_format($format) {
if
(
!
isset
(
$filters
[
$format
]))
{
$filters
[
$format
]
=
array
();
$result
=
db_query
(
"SELECT * FROM
{
filter
}
WHERE format =
%d ORDER BY weight, module, delta"
,
$format
);
while
(
$filter
=
db_fetch_object
(
$result
)
)
{
$result
=
db_query
(
"SELECT * FROM
{
filter
}
WHERE format =
:format ORDER BY weight, module, delta"
,
array
(
':format'
=>
$format
)
);
foreach
(
$result
as
$filter
)
{
$list
=
module_invoke
(
$filter
->
module
,
'filter'
,
'list'
);
if
(
isset
(
$list
)
&&
is_array
(
$list
)
&&
isset
(
$list
[
$filter
->
delta
]))
{
$filter
->
name
=
$list
[
$filter
->
delta
];
...
...
@@ -549,7 +549,7 @@ function _filter_tips($format, $long = FALSE) {
$formats
=
filter_formats
();
}
else
{
$formats
=
array
(
db_
fetch_object
(
db_query
(
"SELECT * FROM
{
filter_format
}
WHERE format = %d"
,
$format
)
));
$formats
=
array
(
db_
query
(
"SELECT * FROM
{
filter_format
}
WHERE format = :format"
,
array
(
':format'
=>
$format
))
->
fetchObject
(
));
}
$tips
=
array
();
...
...
modules/filter/filter.test
View file @
25fad504
...
...
@@ -41,7 +41,7 @@ class FilterAdminTestCase extends DrupalWebTestCase {
$this
->
assertRaw
(
htmlentities
(
$edit
[
'allowed_html_1'
]),
t
(
'Tag displayed.'
));
$result
=
db_
fetch_object
(
db_query
(
'SELECT * FROM {cache_filter}'
)
);
$result
=
db_
query
(
'SELECT * FROM {cache_filter}'
)
->
fetchObject
(
);
$this
->
assertFalse
(
$result
,
t
(
'Cache cleared.'
));
// Reorder filters.
...
...
@@ -51,9 +51,9 @@ class FilterAdminTestCase extends DrupalWebTestCase {
$this
->
drupalPost
(
'admin/settings/filter/'
.
$filtered
.
'/order'
,
$edit
,
t
(
'Save configuration'
));
$this
->
assertText
(
t
(
'The filter ordering has been saved.'
),
t
(
'Order saved successfully.'
));
$result
=
db_query
(
'SELECT * FROM {filter} WHERE format =
%d ORDER BY weight ASC'
,
$filtered
);
$result
=
db_query
(
'SELECT * FROM {filter} WHERE format =
:format ORDER BY weight ASC'
,
array
(
':format'
=>
$filtered
)
);
$filters
=
array
();
while
(
$filter
=
db_fetch_object
(
$result
)
)
{
foreach
(
$result
as
$filter
)
{
if
(
$filter
->
delta
==
$second_filter
||
$filter
->
delta
==
$first_filter
)
{
$filters
[]
=
$filter
;
}
...
...
@@ -155,7 +155,7 @@ class FilterAdminTestCase extends DrupalWebTestCase {
$filtered
=
-
1
;
$full
=
-
1
;
while
(
$format
=
db_fetch_object
(
$result
)
)
{
foreach
(
$result
as
$format
)
{
if
(
$format
->
name
==
'Filtered HTML'
)
{
$filtered
=
$format
->
format
;
}
...
...
@@ -174,7 +174,7 @@ class FilterAdminTestCase extends DrupalWebTestCase {
* @return object Filter object.
*/
function
getFilter
(
$name
)
{
return
db_
fetch_object
(
db_query
(
"SELECT * FROM
{
filter_format
}
WHERE name = '%s'"
,
$name
)
);
return
db_
query
(
"SELECT * FROM
{
filter_format
}
WHERE name = :name"
,
array
(
':name'
=>
$name
))
->
fetchObject
(
);
}
}
...
...
@@ -224,7 +224,7 @@ class FilterTestCase extends DrupalWebTestCase {
'filters[filter/'
.
$filter
.
']'
=>
TRUE
,
);
$this
->
drupalPost
(
'admin/settings/filter/add'
,
$edit
,
t
(
'Save configuration'
));
return
db_
fetch_object
(
db_query
(
"SELECT * FROM
{
filter_format
}
WHERE name = '%s'"
,
$edit
[
'name'
])
);
return
db_
query
(
"SELECT * FROM
{
filter_format
}
WHERE name = :name"
,
array
(
':name'
=>
$edit
[
'name'
]))
->
fetchObject
(
);
}
function
deleteFormat
(
$format
)
{
...
...
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