function _panels_page_update in Panels 5.2
Same name and namespace in other branches
- 6.2 panels_page/panels_page.write.inc \_panels_page_update()
Save an existing panel page to the database.
1 call to _panels_page_update()
- panels_page_save in panels_page/
panels_page.admin.inc - Main entry point for panels_page save functions.
File
- panels_page/
panels_page.admin.inc, line 1049 - panels_page.admin.inc
Code
function _panels_page_update(&$panel_page) {
$values = $pairs = array();
// Save the display if one was given to us.
if (!empty($panel_page->display)) {
panels_save_display($panel_page->display);
if (!empty($panel_page->export)) {
$panel_page->displays[$panel_page->export]['did'] = $panel_page->display->did;
unset($panel_page->displays[$panel_page->export]['display']);
$panel_page->current = $panel_page->export;
}
}
// Build arrays of fields and types (resp. pairs of both) and of values.
foreach (panels_page_fields() as $field => $placeholder) {
// Skip empty values.
if (isset($panel_page->{$field})) {
$pairs[] = $field . " = " . $placeholder;
$values[] = _panels_page_save_value($field, $panel_page->{$field});
}
}
// Build the query filtering by the primary key.
$sql = 'UPDATE {panels_page} SET ' . implode(', ', $pairs) . ' WHERE pid = %d';
$values[] = $panel_page->pid;
db_query($sql, $values);
// Return the pid for convenience.
return $panel_page->pid;
}