You are here

function _panels_page_update in Panels 6.2

Same name and namespace in other branches
  1. 5.2 panels_page/panels_page.admin.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.write.inc
Main entry point for panels_page save functions.

File

panels_page/panels_page.write.inc, line 100
panels_page.write.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.
  $schema = drupal_get_schema('panels_page');
  foreach ($schema['fields'] as $field => $info) {

    // Skip empty values.
    if (isset($panel_page->{$field})) {
      $pairs[] = $field . " = " . db_type_placeholder($info['type']);
      $values[] = _panels_page_save_value($info, $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;
}