public function cf_dom::change_elements in Common Functionality 7.2
Change all elements of a given element type to another type.
Parameters
string $old_type: The old element type to be replaced.
string $new_type: The new element type to use.
bool $on_body: If TRUE, operate on body element. If FALSE, operate on head element. This defaults to TRUE.
Return value
bool TRUE on success, FALSE otherwise.
File
- modules/
cf_dom/ classes/ cf_dom.php, line 375 - Provides the cf_dom handling class.
Class
- cf_dom
- The cf_dom class assists in setting up and managing the custom dom object.
Code
public function change_elements($old_type, $new_type, $on_body = TRUE) {
if (cf_is_empty_or_non_string('oldtype', $old_type)) {
return FALSE;
}
if (cf_is_empty_or_non_string('new_type', $new_type)) {
return FALSE;
}
if ($on_body) {
if (!$this->body instanceof DOMNode) {
if (class_exists('cf_error')) {
cf_error::invalid_object('this->body');
}
return FALSE;
}
return $this
->p_change_elements($old_type, $new_type, $this->head);
}
if (!$this->head instanceof DOMNode) {
if (class_exists('cf_error')) {
cf_error::invalid_object('this->head');
}
return FALSE;
}
return $this
->p_change_elements($old_type, $new_type, $this->head);
}