Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 31st, 2012  |  syntax: None  |  size: 0.94 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.   function migrate_views_panes(){
  2.           $views_panes = db_query("SELECT * FROM {panels_pane} WHERE type = 'views2'");
  3.           while($view_pane = db_fetch_object($views_panes)){
  4.             $config = unserialize($view_pane->configuration);
  5.                         $view = views_get_view($view_pane->subtype);
  6.             $keys = array_keys($view->display["default"]->display_options["arguments"]);
  7.             $new_args = array();
  8.                         foreach($keys as $i=>$key){
  9.                           if($key != "group_nid"){
  10.                                   $new_args[$key] = $config["arguments"][$i];
  11.                           }
  12.                         }
  13.                         $subtype = $view_pane->subtype . "-panel_pane_1";
  14.                         if(isset($config["arguments"])){
  15.                           $config["arguments"] = $new_args;
  16.                         }
  17.                         if(isset($config["nodes_per_page"])){
  18.                                 $config["items_per_page"] = $config["nodes_per_page"];
  19.                                 unset($config["nodes_per_page"]);
  20.                         }
  21.                         $record = array("pid" => $view_pane->pid, "type" => "views_panes", "configuration" => $config, "subtype" => $subtype);
  22.                         drupal_write_record('panels_pane',$record,'pid');
  23.           }
  24.   }