00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 function panels_views_menu($may_cache) {
00017 $items = array();
00018
00019 if ($may_cache) {
00020 $access = user_access('administer panel views');
00021 $items[] = array(
00022 'path' => 'admin/panels/views',
00023 'title' => t('Views panes'),
00024 'access' => $access,
00025 'type' => MENU_NORMAL_ITEM,
00026 'callback' => 'panels_views_list_views',
00027 'description' => t('Configure Views to be used as panes within panel displays.'),
00028 );
00029 $items[] = array(
00030 'path' => 'admin/panels/views/list',
00031 'title' => t('List'),
00032 'access' => $access,
00033 'type' => MENU_DEFAULT_LOCAL_TASK,
00034 'callback' => 'panels_views_list_views',
00035 'weight' => -10,
00036 );
00037 $items[] = array(
00038 'path' => 'admin/panels/views/add',
00039 'title' => t('Add'),
00040 'access' => $access,
00041 'callback' => 'panels_views_add_view',
00042 'type' => MENU_CALLBACK,
00043 );
00044 $items[] = array(
00045 'path' => 'admin/panels/views/edit',
00046 'title' => t('Edit'),
00047 'access' => $access,
00048 'callback' => 'panels_views_edit_view',
00049 'type' => MENU_CALLBACK,
00050 );
00051 $items[] = array(
00052 'path' => 'admin/panels/views/delete',
00053 'title' => t('Delete'),
00054 'access' => $access,
00055 'callback' => 'drupal_get_form',
00056 'callback arguments' => array('panels_views_delete_confirm'),
00057 'type' => MENU_CALLBACK,
00058 );
00059 $items[] = array(
00060 'path' => 'admin/panels/views/import',
00061 'title' => t('Import'),
00062 'access' => $access,
00063 'callback' => 'panels_views_import_view',
00064 'type' => MENU_LOCAL_TASK,
00065 );
00066 $items[] = array(
00067 'path' => 'admin/panels/views/export',
00068 'title' => t('Export'),
00069 'access' => $access,
00070 'callback' => 'drupal_get_form',
00071 'callback arguments' => array('panels_views_export_view'),
00072 'type' => MENU_CALLBACK,
00073 );
00074 $items[] = array(
00075 'path' => 'admin/panels/views/disable',
00076 'access' => $access,
00077 'callback' => 'panels_views_disable_page',
00078 'weight' => -1,
00079 'type' => MENU_CALLBACK,
00080 );
00081 $items[] = array(
00082 'path' => 'admin/panels/views/enable',
00083 'access' => $access,
00084 'callback' => 'panels_views_enable_page',
00085 'weight' => -1,
00086 'type' => MENU_CALLBACK,
00087 );
00088 }
00089
00090 return $items;
00091 }
00092
00093
00094
00095
00096 function panels_views_perm() {
00097 return array('administer panel views');
00098 }
00099
00100
00101
00102
00103 function panels_views_list_views() {
00104
00105
00106 $form = drupal_get_form('panels_views_add_view_form');
00107 $items = array();
00108 $sorts = array();
00109
00110 $header = array(
00111 array('data' => t('Title'), 'field' => 'title'),
00112 array('data' => t('Name'), 'field' => 'name', 'sort' => 'asc'),
00113 array('data' => t('Type'), 'field' => 'type'),
00114 array('data' => t('View'), 'field' => 'view'),
00115 t('Operations'),
00116 );
00117
00118 foreach (panels_views_load_all() as $panel_view) {
00119 $ops = array();
00120 if (empty($panel_view->disabled)) {
00121 $ops[] = l(t('Edit'), "admin/panels/views/edit/$panel_view->name");
00122 $ops[] = l(t('Export'), "admin/panels/views/export/$panel_view->name");
00123 }
00124 if ($panel_view->type != t('Default')) {
00125 $text = ($panel_view->type == t('Overridden')) ? t('Revert') : t('Delete');
00126 $ops[] = l($text, "admin/panels/views/delete/$panel_view->name");
00127 }
00128 else {
00129 if (empty($panel_view->disabled)) {
00130 $ops[] = l(t('Disable'), "admin/panels/views/disable/$panel_view->name", NULL, drupal_get_destination());
00131 }
00132 else {
00133 $ops[] = l(t('Enable'), "admin/panels/views/enable/$panel_view->name", NULL, drupal_get_destination());
00134 }
00135 }
00136
00137 $item = array();
00138 $item[] = check_plain($panel_view->title);
00139 $item[] = check_plain($panel_view->name);
00140
00141 $item[] = $panel_view->type;
00142 $item[] = check_plain($panel_view->view);
00143
00144 $item[] = implode(' | ', $ops);
00145 $items[] = $item;
00146
00147 $ts = tablesort_init($header);
00148 switch ($ts['sql']) {
00149 case 'title':
00150 $sorts[] = $item[0];
00151 break;
00152
00153 case 'name':
00154 default:
00155 $sorts[] = $item[1];
00156 break;
00157
00158 case 'type':
00159 $sorts[] = $panel_view->type . $item[0];
00160 break;
00161
00162 case 'view':
00163 $sorts[] = $item[2];
00164 break;
00165 }
00166 }
00167
00168 if (drupal_strtolower($ts['sort']) == 'desc') {
00169 arsort($sorts);
00170 }
00171 else {
00172 asort($sorts);
00173 }
00174
00175 $i = array();
00176 foreach ($sorts as $id => $title) {
00177 $i[] = $items[$id];
00178 }
00179
00180 $output = theme('table', $header, $i);
00181
00182 $output .= $form;
00183 return $output;
00184 }
00185
00186
00187
00188
00189 function panels_views_add_view_form() {
00190 $form['view'] = array(
00191 '#type' => 'select',
00192 '#options' => panels_views_get_all_views(),
00193 );
00194 $form['submit'] = array(
00195 '#type' => 'submit',
00196 '#value' => t('Create panel view'),
00197 );
00198 return $form;
00199 }
00200
00201 function theme_panels_views_add_view_form($form) {
00202 $row = array(drupal_render($form['view']), drupal_render($form['submit']));
00203 return theme('table', array(), array($row)) . drupal_render($form);
00204 }
00205
00206 function panels_views_add_view_form_submit($form_id, $form_values) {
00207 return 'admin/panels/views/add/' . $form_values['view'];
00208 }
00209
00210
00211
00212
00213 function panels_views_add_view($view_name) {
00214 $view = views_get_view($view_name);
00215 if (empty($view)) {
00216 return drupal_not_found();
00217 }
00218
00219 return drupal_get_form('panels_views_edit_view_form', $view, panels_views_default_view_pane($view));
00220 }
00221
00222
00223
00224
00225 function panels_views_edit_view($view_name) {
00226 $pv = panels_views_load($view_name);
00227 if (empty($pv)) {
00228 return drupal_not_found();
00229 }
00230
00231 $view = views_get_view($pv->view);
00232 drupal_set_title(t("Edit '@title'", array('@title' => $pv->title)));
00233 return drupal_get_form('panels_views_edit_view_form', $view, $pv);
00234 }
00235
00236
00237
00238
00239 function panels_views_edit_view_form($view, $panel_view) {
00240 panels_views_pane_arguments($view, $panel_view);
00241
00242
00243 $form['basic'] = array(
00244 '#type' => 'fieldset',
00245 '#title' => t('Basic information'),
00246 );
00247
00248 if (!empty($panel_view->pvid) && is_numeric($panel_view->pvid)) {
00249 $form['pvid'] = array(
00250 '#type' => 'value',
00251 '#value' => $panel_view->pvid,
00252 );
00253 }
00254
00255 $form['view'] = array(
00256 '#type' => 'value',
00257 '#value' => $panel_view->view,
00258 );
00259
00260 $form['basic']['name'] = array(
00261 '#type' => 'textfield',
00262 '#title' => t('Panel view name'),
00263 '#description' => t('Enter a unique name for this view pane. It must contain only letters and numbers.'),
00264 '#default_value' => $panel_view->name,
00265 );
00266
00267 $form['basic']['title'] = array(
00268 '#type' => 'textfield',
00269 '#title' => t('Panel view title'),
00270 '#description' => t('The title of the pane; this will appear in the add content dialog.'),
00271 '#default_value' => $panel_view->title,
00272 );
00273
00274 $form['basic']['description'] = array(
00275 '#type' => 'textfield',
00276 '#title' => t('Description'),
00277 '#description' => t('This description will be shown to the user when as a hover tip when adding this pane.'),
00278 '#default_value' => $panel_view->description,
00279 );
00280
00281 $form['basic']['category'] = array(
00282 '#type' => 'textfield',
00283 '#title' => t('Category'),
00284 '#category' => t('The category this view will appear in using the add content dialog.'),
00285 '#default_value' => $panel_view->category,
00286 );
00287
00288 $form['basic']['category_weight'] = array(
00289 '#type' => 'select',
00290 '#default_value' => $panel_view->category_weight,
00291 '#title' => t('Category weight'),
00292 '#description' => t('The weight of the category; lower numbers will appear closer to the top of the dialog.'),
00293 '#options' => drupal_map_assoc(range(-10, 10)),
00294 );
00295
00296 $form['basic']['view_type'] = array(
00297 '#type' => 'select',
00298 '#default_value' => $panel_view->view_type,
00299 '#title' => t('View type'),
00300 '#description' => t('Select which type of the view to display.'),
00301 '#options' => array('page' => t('Page'), 'block' => t('Block'), 'embed' => t('Embedded')),
00302 );
00303
00304 $form['contexts'] = array(
00305 '#tree' => TRUE,
00306 );
00307
00308 views_load_cache();
00309 $arginfo = _views_get_arguments();
00310
00311 panels_load_include('plugins');
00312
00313 $contexts = panels_get_contexts();
00314 $context_options = array('any' => t('Any context'));
00315 foreach ($contexts as $name => $context) {
00316 $context_options[$name] = $context['title'];
00317 }
00318 asort($context_options);
00319
00320 foreach ($panel_view->contexts as $id => $info) {
00321 $name = $arginfo[$view->argument[$id]['type']]['name'];
00322 $form['contexts'][$id] = array(
00323 '#type' => 'fieldset',
00324 '#title' => t('Argument: @arg', array('@arg' => $name)),
00325 '#tree' => TRUE,
00326 );
00327
00328 $form['contexts'][$id]['type'] = array(
00329 '#type' => 'select',
00330 '#options' => array(
00331 'wildcard' => t('Argument wildcard'),
00332 'none' => t('No argument'),
00333 'context' => t('From context'),
00334 'panel' => t('From panel argument'),
00335 'fixed' => t('Fixed'),
00336 'user' => t('Input on pane config'),
00337 ),
00338 '#title' => t('Argument source'),
00339 '#default_value' => $panel_view->contexts[$id]['type'],
00340 );
00341 $form['contexts'][$id]['context'] = array(
00342 '#type' => 'select',
00343 '#title' => t('Required context'),
00344 '#description' => t('If "From context" is selected, which context to require.'),
00345 '#default_value' => $panel_view->contexts[$id]['context'],
00346 '#options' => $context_options,
00347 );
00348 $form['contexts'][$id]['panel'] = array(
00349 '#type' => 'select',
00350 '#title' => t('Panel argument'),
00351 '#description' => t('If "From panel argument" is selected, which panel argument to use.'),
00352 '#default_value' => $panel_view->contexts[$id]['panel'],
00353 '#options' => array(0 => t('First'), 1 => t('Second'), 2 => t('Third'), 3 => t('Fourth'), 4 => t('Fifth'), 5 => t('Sixth')),
00354 );
00355 $form['contexts'][$id]['fixed'] = array(
00356 '#type' => 'textfield',
00357 '#title' => t('Fixed argument'),
00358 '#description' => t('If "Fixed" is selected, what to use as an argument.'),
00359 '#default_value' => $panel_view->contexts[$id]['fixed'],
00360 );
00361 $form['contexts'][$id]['label'] = array(
00362 '#type' => 'textfield',
00363 '#title' => t('Label'),
00364 '#description' => t('If this argument is presented to the panels user, what label to apply to it.'),
00365 '#default_value' => empty($panel_view->contexts[$id]['label']) ? $name : $panel_view->contexts[$id]['label'],
00366 );
00367 }
00368
00369 $form['pager'] = array(
00370 '#type' => 'fieldset',
00371 '#title' => t('Paging information'),
00372 );
00373
00374 $form['pager']['use_pager'] = array(
00375 '#type' => 'checkbox',
00376 '#title' => t('Use pager'),
00377 '#description' => t('Use a pager with this view'),
00378 '#default_value' => $panel_view->use_pager,
00379 );
00380
00381 $form['pager']['pager_id'] = array(
00382 '#type' => 'textfield',
00383 '#title' => t('Pager ID'),
00384 '#description' => t('If using a pager, what pager ID to use; every pager on the page should be unique and you should always use the lowest pager ID available. Use 0 if at all possible.'),
00385 '#default_value' => $panel_view->pager_id,
00386 );
00387
00388 $form['pager']['allow_use_pager'] = array(
00389 '#type' => 'checkbox',
00390 '#title' => t('Allow the pane configuration to modify the use pager setting.'),
00391 '#default_value' => $panel_view->allow_use_pager,
00392 );
00393
00394 $form['pager']['nodes_per_page'] = array(
00395 '#type' => 'textfield',
00396 '#title' => t('Items to display'),
00397 '#description' => t('The maximum number of nodes to display.'),
00398 '#default_value' => $panel_view->nodes_per_page,
00399 );
00400
00401 $form['pager']['allow_nodes_per_page'] = array(
00402 '#type' => 'checkbox',
00403 '#title' => t('Allow the pane configuration to modify the items to display setting'),
00404 '#default_value' => $panel_view->allow_nodes_per_page,
00405 );
00406
00407 $form['pager']['offset'] = array(
00408 '#type' => 'textfield',
00409 '#title' => t('Offset'),
00410 '#description' => t('Enter the item number to start at; this option only works if "use pager" is not checked. Enter 0 to start at the first item, 1 to start at the second, etc.'),
00411 '#default_value' => $panel_view->offset,
00412 );
00413
00414 $form['pager']['allow_offset'] = array(
00415 '#type' => 'checkbox',
00416 '#title' => t('Allow the pane configuration to modify the offset setting'),
00417 '#default_value' => $panel_view->allow_offset,
00418 );
00419
00420 $form['deco'] = array(
00421 '#type' => 'fieldset',
00422 '#title' => t('Pane decorations'),
00423 );
00424
00425 $form['deco']['link_to_view'] = array(
00426 '#type' => 'checkbox',
00427 '#title' => t('Link to view'),
00428 '#description' => t('If checked, link the title of the pane to the view.'),
00429 '#default_value' => $panel_view->link_to_view,
00430 );
00431
00432 $form['deco']['allow_link_to_view'] = array(
00433 '#type' => 'checkbox',
00434 '#title' => t('Allow the pane configuration to modify the link to view setting.'),
00435 '#default_value' => $panel_view->allow_link_to_view,
00436 );
00437
00438 $form['deco']['more_link'] = array(
00439 '#type' => 'checkbox',
00440 '#title' => t('More link'),
00441 '#description' => t('If checked, Panels will provide a "more" link that links to the view URL; this is different from the view\'s "more" link which will automatically be disabled.'),
00442 '#default_value' => $panel_view->more_link,
00443 );
00444
00445 $form['deco']['allow_more_link'] = array(
00446 '#type' => 'checkbox',
00447 '#title' => t('Allow the pane configuration to modify the "more" link setting.'),
00448 '#default_value' => $panel_view->allow_more_link,
00449 );
00450
00451 $form['deco']['more_text'] = array(
00452 '#type' => 'textfield',
00453 '#title' => t('More link text'),
00454 '#description' => t('If you checked the above box allowing Panels to provide its own "more" link, Panels will render that link using the text you enter here. If left blank, defaults to "more".'),
00455 '#default_value' => $panel_view->more_text,
00456 );
00457
00458 $form['deco']['allow_more_text'] = array(
00459 '#type' => 'checkbox',
00460 '#title' => t('Allow the pane configuration to modify the "more" link text.'),
00461 '#default_value' => $panel_view->allow_more_text,
00462 );
00463
00464 $form['deco']['feed_icons'] = array(
00465 '#type' => 'checkbox',
00466 '#title' => t('Show feed icons'),
00467 '#description' => t('If checked, any feed icons provided by the view will be visible in the pane.'),
00468 '#default_value' => $panel_view->feed_icons,
00469 );
00470
00471 $form['deco']['allow_feed_icons'] = array(
00472 '#type' => 'checkbox',
00473 '#title' => t('Allow the pane configuration to modify the feed icon setting.'),
00474 '#default_value' => $panel_view->allow_feed_icons,
00475 );
00476
00477 $form['deco']['url_override'] = array(
00478 '#type' => 'checkbox',
00479 '#title' => t('Override the panel URL with a manually set URL.'),
00480 '#default_value' => $panel_view->url_override,
00481 );
00482
00483 $form['deco']['url'] = array(
00484 '#type' => 'textfield',
00485 '#title' => t('Override view URL'),
00486 '#description' => t('If override URL is set, the URL the view thinks it is using; all "more", "exposed filters", "summary" and "feed" type links will use this URL.') .' '. t('You may use $arg to pass panel arguments to the view.'),
00487 '#default_value' => $panel_view->url,
00488 );
00489
00490 $form['deco']['allow_url_override'] = array(
00491 '#type' => 'checkbox',
00492 '#title' => t('Allow the pane configuration to modify the URL override setting.'),
00493 '#default_value' => $panel_view->allow_url_override,
00494 );
00495
00496 $form['deco']['url_from_panel'] = array(
00497 '#type' => 'checkbox',
00498 '#title' => t('Set view URL to panel URL'),
00499 '#description' => t('If checked, the URL of the view will be changed to the URL of the panel; this setting is ignored if the "Override view URL" setting, above, is set or allowed.'),
00500 '#default_value' => $panel_view->url_from_panel,
00501 );
00502
00503 $form['deco']['allow_url_from_panel'] = array(
00504 '#type' => 'checkbox',
00505 '#title' => t('Allow the pane configuration to modify the "set view URL to panel URL" setting.'),
00506 '#default_value' => $panel_view->allow_url_from_panel,
00507 );
00508
00509 $form['submit'] = array(
00510 '#type' => 'submit',
00511 '#value' => t('Save'),
00512 );
00513
00514 return $form;
00515 }
00516
00517
00518
00519
00520 function panels_views_edit_view_form_validate($form_id, $form_values, $form) {
00521
00522 if (!$form_values['name']) {
00523 form_error($form['basic']['name'], t('Panel view name is required.'));
00524 }
00525 else if (preg_match("/[^A-Za-z0-9_]/", $form_values['name'])) {
00526 form_error($form['basic']['name'], t('Name must be alphanumeric or underscores only.'));
00527 }
00528 else {
00529 $query = "SELECT pvid FROM {panels_views} WHERE name = '%s'";
00530 if (!empty($form_values['pvid']) && is_numeric($form_values['pvid'])) {
00531 $query .= " AND pvid != $form_values[pvid]";
00532 }
00533 if (db_result(db_query($query, $form_values['name']))) {
00534 form_error($form['basic']['name'], t('Panel name must be unique.'));
00535 }
00536 }
00537 }
00538
00539
00540
00541
00542 function panels_views_edit_view_form_submit($form_id, $form_values) {
00543 $form_values['contexts'] = isset($form_values['contexts']) ? $form_values['contexts'] : array();
00544 $pv = new stdClass();
00545 foreach (array_keys(panels_views_pane_fields()) as $field) {
00546 $pv->$field = $form_values[$field];
00547 }
00548 panels_views_save($pv);
00549 drupal_set_message(t("The panel view has been saved."));
00550 return 'admin/panels/views';
00551 }
00552
00553
00554
00555
00556 function panels_views_delete_confirm($panel_view) {
00557 if (!is_object($panel_view)) {
00558 $panel_view = panels_views_load($panel_view);
00559 }
00560 if (empty($panel_view) || empty($panel_view->pvid)) {
00561 return drupal_not_found();
00562 }
00563
00564 $form['pvid'] = array('#type' => 'value', '#value' => $panel_view->pvid);
00565 return confirm_form($form,
00566 t('Are you sure you want to delete the panel view "@title"?', array('@title' => $panel_view->title)),
00567 $_GET['destination'] ? $_GET['destination'] : 'admin/panels/views',
00568 t('This action cannot be undone.'),
00569 t('Delete'), t('Cancel')
00570 );
00571 }
00572
00573
00574
00575
00576 function panels_views_delete_confirm_submit($form_id, $form) {
00577 if ($form['confirm']) {
00578 panels_views_delete((object) $form);
00579 return 'admin/panels/views';
00580 }
00581 }
00582
00583
00584
00585
00586 function panels_views_import_view() {
00587 if ($_POST['form_id'] == 'panels_views_edit_view_form') {
00588 $panel_view = $_SESSION['pv_import'];
00589 drupal_set_title(t('Import panel view "@s"', array('@s' => $panel_view->title)));
00590 $view = views_get_view($panel_view->view);
00591 return drupal_get_form('panels_views_edit_view_form', $view, $panel_view);
00592 }
00593
00594 return drupal_get_form('panels_views_import_form');
00595 }
00596
00597
00598
00599
00600 function panels_views_import_form() {
00601 $form['panel_view'] = array(
00602 '#type' => 'textarea',
00603 '#title' => t('Panel view code'),
00604 '#cols' => 60,
00605 '#rows' => 15,
00606 '#description' => t('Cut and paste the results of an exported panel view here.'),
00607 );
00608
00609 $form['submit'] = array(
00610 '#type' => 'submit',
00611 '#value' => t('Import'),
00612 );
00613
00614 $form['#redirect'] = NULL;
00615 return $form;
00616 }
00617
00618
00619
00620
00621 function panels_views_import_form_submit($form_id, $form) {
00622 ob_start();
00623 eval($form['panel_view']);
00624 ob_end_clean();
00625
00626 if (isset($panel_view)) {
00627 $view = views_get_view($panel_view->view);
00628 if (empty($view)) {
00629 drupal_set_message(t('Unable to load the view for that import. Be sure the view already exists in your system.'));
00630 return;
00631 }
00632
00633 drupal_set_title(t('Import panel view "@s"', array('@s' => $panel_view->title)));
00634 $_SESSION['pv_import'] = $panel_view;
00635 $output = drupal_get_form('panels_views_edit_view_form', $view, $panel_view);
00636 print theme('page', $output);
00637 exit;
00638 }
00639 else {
00640 drupal_set_message(t('Unable to get a panel view out of that.'));
00641 }
00642 }
00643
00644
00645
00646
00647 function panels_views_export_view($pv, $prefix = '') {
00648 if (!is_object($pv)) {
00649 $pv = panels_views_load($pv);
00650 }
00651 if (empty($pv)) {
00652 return drupal_not_found();
00653 }
00654
00655 drupal_set_title(check_plain($pv->title));
00656 $code = panels_views_export($pv);
00657
00658 $lines = substr_count($code, "\n");
00659 $form['code'] = array(
00660 '#type' => 'textarea',
00661 '#title' => $pv->title,
00662 '#default_value' => $code,
00663 '#rows' => $lines,
00664 );
00665 return $form;
00666 }
00667
00668
00669
00670
00671 function panels_views_enable_page($name = NULL) {
00672 $defaults = panels_views_default_panels();
00673 if (isset($defaults[$name])) {
00674 $status = variable_get('panels_views_defaults', array());
00675 $status[$name] = FALSE;
00676 variable_set('panels_views_defaults', $status);
00677 drupal_set_message(t('Panel view enabled'));
00678 }
00679 drupal_goto();
00680 }
00681
00682
00683
00684
00685 function panels_views_disable_page($name = NULL) {
00686 $defaults = panels_views_default_panels();
00687 if (isset($defaults[$name])) {
00688 $status = variable_get('panels_views_defaults', array());
00689 $status[$name] = TRUE;
00690 variable_set('panels_views_defaults', $status);
00691 drupal_set_message(t('Panel view disabled'));
00692 }
00693 drupal_goto();
00694 }
00695
00696
00697
00698
00699
00700
00701
00702 function panels_views_panels_content_types() {
00703 $items['views2'] = array(
00704 'title' => t('View'),
00705 'content_types' => 'panels_views_content_types',
00706 'render callback' => 'panels_views_render',
00707 'add callback' => 'panels_views_edit',
00708 'edit callback' => 'panels_views_edit',
00709 'title callback' => 'panels_views_title',
00710 'add validate callback' => 'panels_views_edit_validate',
00711 'edit validate callback' => 'panels_views_edit_validate',
00712 );
00713 return $items;
00714 }
00715
00716
00717
00718
00719 function panels_views_content_types() {
00720 $panes = panels_views_load_all();
00721 $types = array();
00722 foreach ($panes as $name => $pv) {
00723
00724 if (!empty($pv->disabled)) {
00725 continue;
00726 }
00727
00728 $contexts = array();
00729 if (!empty($pv->contexts)) {
00730 foreach ($pv->contexts as $context) {
00731 if ($context['type'] == 'context') {
00732 $contexts[] = new panels_required_context($context['label'], $context['context']);
00733 }
00734 }
00735 }
00736 $types[$name] = array(
00737 'title' => filter_xss_admin($pv->title),
00738 'icon' => $pv->view_type == 'block' ? 'icon_views_block.png' : 'icon_views_page.png',
00739 'description' => filter_xss_admin($pv->description),
00740 'path' => panels_get_path('content_types/views'),
00741 'required context' => $contexts,
00742 'category' => empty($pv->category) ? array(t('Views'), -1) : array($pv->category, $pv->category_weight),
00743 );
00744 }
00745
00746 return $types;
00747 }
00748
00749
00750
00751
00752 function panels_views_render($conf, $panel_args, &$contexts) {
00753 $pv = panels_views_load($conf['name']);
00754 if (empty($pv)) {
00755 return;
00756 }
00757
00758 $v = views_get_view($pv->view);
00759
00760 if (empty($v)) {
00761 return;
00762 }
00763
00764 $view = drupal_clone($v);
00765
00766
00767 if (function_exists('views_access') && !views_access($view)) {
00768 return;
00769 }
00770
00771 $args = array();
00772 if (!empty($pv->contexts)) {
00773 foreach ($pv->contexts as $id => $data) {
00774 switch ($data['type']) {
00775 case 'context':
00776 $c = array_shift($contexts);
00777 $args[] = $c->argument;
00778 break;
00779
00780 case 'fixed':
00781 $args[] = $data['fixed'];
00782 break;
00783
00784 case 'panel':
00785
00786 if (array_key_exists($data['panel'], $panel_args)) {
00787 $args[] = $panel_args[$data['panel']];
00788 }
00789 break;
00790
00791 case 'user':
00792 $args[] = $conf['arguments'][$id];
00793 break;
00794
00795 case 'wildcard':
00796
00797 $args[] = $view->arguments[$id]['wildcard'] ? $view->arguments[$id]['wildcard'] : '*';
00798 break;
00799
00800 case 'none':
00801 default:
00802
00803
00804 $args[] = NULL;
00805 break;
00806 }
00807 }
00808 }
00809
00810 if ($pv->allow_url_override && $conf['url']) {
00811 $view->url = $conf['url'];
00812 }
00813 else {
00814 if ($pv->url_override) {
00815 $view->url = $pv->url;
00816 }
00817 }
00818
00819 $block = new stdClass();
00820 $block->module = 'views';
00821 $block->delta = $view->name;
00822
00823 $view_type = $pv->view_type == 'embed' ? 'page' : $pv->view_type;
00824 $block->subject = views_get_title($view, $view_type, $args);
00825
00826
00827 if (($pv->allow_link_to_view && !empty($conf['link_to_view'])) ||
00828 (!$pv->allow_link_to_view && $pv->link_to_view)) {
00829 $block->title_link = views_get_url($view, $args);
00830 }
00831
00832
00833 if (($pv->allow_more_link && !empty($conf['more_link'])) ||
00834 (!$pv->allow_more_link && $pv->more_link)) {
00835 $block->more = array('href' => views_get_url($view, $args));
00836 $view->block_more = FALSE;
00837
00838
00839 if ($pv->allow_more_text && $conf['more_text']) {
00840 $block->more['title'] = $conf['more_text'];
00841 }
00842 else if ($pv->more_text) {
00843 $block->more['title'] = $pv->more_text;
00844 }
00845 }
00846
00847
00848 if ($pv->allow_use_pager) {
00849 $pager_id = empty($conf['use_pager']) ? 0 : (intval($conf['pager_id']) + 1);
00850 }
00851 else {
00852 $pager_id = empty($pv->use_pager) ? 0 : (intval($pv->pager_id) + 1);
00853 }
00854
00855 $nodes_per_page = ($pv->allow_nodes_per_page) ? $conf['nodes_per_page'] : $pv->nodes_per_page;
00856 $offset = ($pv->allow_offset) ? $conf['offset'] : $pv->offset;
00857
00858 $stored_feeds = drupal_add_feed();
00859
00860
00861 while (count($args) && end($args) === NULL) {
00862 array_pop($args);
00863 }
00864
00865 $block->content = views_build_view($pv->view_type, $view, $args, $pager_id, $nodes_per_page, 0, $offset);
00866
00867 if ($view->num_rows < $nodes_per_page) {
00868 unset($block->more);
00869 }
00870
00871 if (($pv->allow_feed_icons && !empty($conf['feed_icons'])) ||
00872 (!$pv->allow_feed_icons && $pv->feed_icons)) {
00873 $new_feeds = drupal_add_feed();
00874 if ($diff = array_diff(array_keys($new_feeds), array_keys($stored_feeds))) {
00875 foreach ($diff as $url) {
00876 $block->feeds[$url] = $new_feeds[$url];
00877 }
00878 }
00879 }
00880
00881
00882 if (user_access('administer views')) {
00883 $block->admin_links['update'] = array(
00884 'title' => t('Edit view'),
00885 'alt' => t("Edit this view"),
00886 'href' => $view->vid ? "admin/build/views/$view->name/edit" : "admin/build/views/add/$view->name",
00887 'query' => drupal_get_destination(),
00888 );
00889 }
00890
00891 return $block;
00892 }
00893
00894
00895
00896
00897 function panels_views_edit($id, $parents, $conf = array()) {
00898 $pv = panels_views_load($id);
00899 if (empty($pv)) {
00900 $form['markup'] = array(
00901 '#value' => t('The view for this pane is not valid or has been deleted from the system. This pane cannot render; you must either delete this pane or restore the panel view. If you save this pane and then restore the panel view, your settings may be lost.'),
00902 );
00903 return $form;
00904 }
00905
00906
00907 if (empty($conf)) {
00908 if ($pv->allow_type) {
00909 $conf['view_type'] = $pv->view_type;
00910 }
00911 if ($pv->allow_link_to_view) {
00912 $conf['link_to_view'] = $pv->link_to_view;
00913 }
00914 if ($pv->allow_more_link) {
00915 $conf['more_link'] = $pv->more_link;
00916 }
00917 if ($pv->allow_more_text) {
00918 $conf['more_text'] = $pv->more_text;
00919 }
00920 if ($pv->allow_feed_icons) {
00921 $conf['feed_icons'] = $pv->feed_icons;
00922 }
00923 if ($pv->allow_use_pager) {
00924 $conf['use_pager'] = $pv->use_pager;
00925 $conf['pager_id'] = $pv->pager_id;
00926 }
00927 if ($pv->allow_nodes_per_page) {
00928 $conf['nodes_per_page'] = $pv->nodes_per_page;
00929 }
00930 if ($pv->allow_offset) {
00931 $conf['offset'] = $pv->offset;
00932 }
00933 if ($pv->allow_url_override) {
00934 $conf['url'] = $pv->url;
00935 }
00936 if ($pv->allow_url_from_panel) {
00937 $conf['url_from_panel'] = $pv->url_from_panel;
00938 }
00939 }
00940
00941 $form['title'] = array(
00942 '#type' => 'hidden',
00943 '#value' => $pv->title,
00944 );
00945 $form['name'] = array(
00946 '#type' => 'hidden',
00947 '#value' => $id,
00948 );
00949
00950 foreach ($pv->contexts as $id => $data) {
00951 if ($data['type'] == 'user') {
00952 $form['arguments'][$id] = array(
00953 '#type' => 'textfield',
00954 '#default_value' => $conf['arguments'][$id],
00955 '#title' => $data['label'],
00956 );
00957 }
00958 }
00959
00960 if ($pv->allow_type) {
00961 $form['view_type'] = array(
00962 '#type' => 'select',
00963 '#default_value' => $conf['view_type'],
00964 '#title' => t('View type'),
00965 '#description' => t('Select which type of the view to display.'),
00966 '#options' => array('page' => t('Page'), 'block' => t('Block'), 'embed' => t('Embedded')),
00967 );
00968 }
00969 if ($pv->allow_link_to_view) {
00970 $form['link_to_view'] = array(
00971 '#type' => 'checkbox',
00972 '#default_value' => $conf['link_to_view'],
00973 '#title' => t('Link title to view'),
00974 '#description' => t('If checked, the title will be a link to the view.'),
00975 );
00976 }
00977 if ($pv->allow_more_link) {
00978 $form['more_link'] = array(
00979 '#type' => 'checkbox',
00980 '#default_value' => $conf['more_link'],
00981 '#title' => t('Provide a "more" link that links to the view'),
00982 '#description' => t('This is independent of any more link that may be provided by the view itself; if you see two more links, turn this one off. Views will only provide a more link if using the "block" type, however, so if using embed, use this one.'),
00983 );
00984 if ($pv->allow_more_text) {
00985 $form['more_text'] = array(
00986 '#type' => 'textfield',
00987 '#default_value' => $conf['more_text'],
00988 '#title' => t('"More" link text'),
00989 '#description' => t('If you activated panels own "more" link above, this allows you to customize the text to display.'),
00990 );
00991 }
00992 }
00993 if ($pv->allow_feed_icons) {
00994 $form['feed_icons'] = array(
00995 '#type' => 'checkbox',
00996 '#default_value' => $conf['feed_icons'],
00997 '#title' => t('Display feed icons'),
00998 '#description' => t('If checked, any feed icons provided by this view will be displayed.'),
00999 );
01000 }
01001 if ($pv->allow_use_pager) {
01002 $form['pager_aligner_start'] = array(
01003 '#value' => '<div class="option-text-aligner">',
01004 );
01005 $form['use_pager'] = array(
01006 '#type' => 'checkbox',
01007 '#title' => t('Use pager'),
01008 '#default_value' => $conf['use_pager'],
01009 '#id' => 'use-pager-checkbox',
01010 );
01011 $form['pager_id'] = array(
01012 '#type' => 'textfield',
01013 '#default_value' => $conf['pager_id'],
01014 '#title' => t('Pager ID'),
01015 '#size' => 4,
01016 '#id' => 'use-pager-textfield',
01017 );
01018 $form['pager_aligner_stop'] = array(
01019 '#value' => '</div><div style="clear: both; padding: 0; margin: 0"></div>',
01020 );
01021 }
01022 if ($pv->allow_nodes_per_page) {
01023 $form['nodes_per_page'] = array(
01024 '#type' => 'textfield',
01025 '#default_value' => $conf['nodes_per_page'],
01026 '#title' => t('Num posts'),
01027 '#size' => 4,
01028 '#description' => t('Select the number of posts to display, or 0 to display all results.'),
01029 );
01030 }
01031 if ($pv->allow_offset) {
01032 $form['offset'] = array(
01033 '#type' => 'textfield',
01034 '#default_value' => $conf['offset'],
01035 '#title' => t('Offset'),
01036 '#size' => 4,
01037 '#description' => t('Enter the item number to start at; this option only works if "use pager" is not checked. Enter 0 to start at the first item, 1 to start at the second, etc.'),
01038 );
01039 }
01040 if ($pv->allow_url_override) {
01041
01042
01043 $form['url'] = array(
01044 '#type' => 'textfield',
01045 '#default_value' => $conf['url'],
01046 '#title' => t('Override URL'),
01047 '#size' => 30,
01048 '#description' => t('If this is set, override the View URL; this can sometimes be useful to set to the panel URL.') .' '. t('You may use $arg to pass panel arguments to the view.'),
01049 );
01050 }
01051 if ($pv->allow_url_from_panel) {
01052 $form['url_from_panel'] = array(
01053 '#type' => 'checkbox',
01054 '#title' => t('Set view URL to panel URL'),
01055 '#default_value' => $conf['url_from_panel'],
01056 );
01057 }
01058
01059 return $form;
01060 }
01061
01062
01063
01064
01065 function panels_views_title($conf) {
01066 return $conf['title'];
01067 }
01068
01069
01070
01071
01072
01073
01074
01075
01076
01077 function panels_views_get_all_views() {
01078 views_load_cache();
01079 $result = db_query("SELECT name, description FROM {view_view} ORDER BY name");
01080 $views = array();
01081 while ($view = db_fetch_object($result)) {
01082 $views[$view->name] = check_plain($view->name);
01083 }
01084
01085 $default_views = _views_get_default_views();
01086 $views_status = variable_get('views_defaults', array());
01087 foreach ($default_views as $view) {
01088 if (!$views[$view->name] &&
01089 ($views_status[$view->name] == 'enabled' || (!$views_status[$view->name] && !$view->disabled))) {
01090 $views[$view->name] = check_plain($view->name);
01091 }
01092 }
01093 return $views;
01094 }
01095
01096
01097
01098
01099
01100
01101
01102 function panels_views_pane_fields() {
01103
01104 $names = array(
01105 'pvid' => array(
01106 'default' => 'NULL',
01107 'arg' => '%d',
01108 'definition' => 'integer NOT NULL PRIMARY KEY',
01109 'primary' => TRUE,
01110 ),
01111 'view' => array(
01112 'default' => '',
01113 'arg' => "'%s'",
01114 'definition' => 'varchar(255)',
01115 ),
01116 'name' => array(
01117 'default' => '',
01118 'arg' => "'%s'",
01119 'definition' => 'varchar(255) UNIQUE',
01120 ),
01121 'description' => array(
01122 'default' => '',
01123 'arg' => "'%s'",
01124 'definition' => 'varchar(255)',
01125 ),
01126 'title' => array(
01127 'default' => '',
01128 'arg' => "'%s'",
01129 'definition' => 'varchar(255)',
01130 ),
01131 'category' => array(
01132 'default' => 'Views',
01133 'arg' => "'%s'",
01134 'definition' => 'varchar(255)',
01135 ),
01136 'category_weight' => array(
01137 'default' => -1,
01138 'arg' => "%d",
01139 'definition' => 'integer',
01140 ),
01141 'view_type' => array(
01142 'default' => '',
01143 'arg' => "'%s'",
01144 'definition' => 'varchar(255)',
01145 ),
01146 'use_pager' => array(
01147 'default' => FALSE,
01148 'arg' => '%d',
01149 'definition' => 'integer',
01150 ),
01151 'pager_id' => array(
01152 'default' => 0,
01153 'arg' => '%d',
01154 'definition' => 'integer',
01155 ),
01156 'nodes_per_page' => array(
01157 'default' => 0,
01158 'arg' => '%d',
01159 'definition' => 'integer',
01160 ),
01161 'offset' => array(
01162 'default' => 0,
01163 'arg' => '%d',
01164 'definition' => 'integer',
01165 ),
01166 'link_to_view' => array(
01167 'default' => FALSE,
01168 'arg' => '%d',
01169 'definition' => 'integer',
01170 ),
01171 'more_link' => array(
01172 'default' => FALSE,
01173 'arg' => '%d',
01174 'definition' => 'integer',
01175 ),
01176 'more_text' => array(
01177 'default' => '',
01178 'arg' => "'%s'",
01179 'definition' => 'varchar(255)',
01180 ),
01181 'feed_icons' => array(
01182 'default' => FALSE,
01183 'arg' => '%d',
01184 'definition' => 'integer',
01185 ),
01186 'url_override' => array(
01187 'default' => FALSE,
01188 'arg' => '%d',
01189 'definition' => 'integer',
01190 ),
01191 'url' => array(
01192 'default' => '',
01193 'arg' => "'%s'",
01194 'definition' => 'varchar(255)',
01195 ),
01196 'url_from_panel' => array(
01197 'default' => FALSE,
01198 'arg' => '%d',
01199 'definition' => 'integer',
01200 ),
01201 'contexts' => array(
01202 'default' => array(),
01203 'arg' => "'%s'",
01204 'serialize' => TRUE,
01205 'definition' => 'text',
01206 ),
01207
01208 'allow_type' => array(
01209 'default' => FALSE,
01210 'arg' => '%d',
01211 'definition' => 'integer',
01212 ),
01213 'allow_nodes_per_page' => array(
01214 'default' => FALSE,
01215 'arg' => '%d',
01216 'definition' => 'integer',
01217 ),
01218 'allow_offset' => array(
01219 'default' => FALSE,
01220 'arg' => '%d',
01221 'definition' => 'integer',
01222 ),
01223 'allow_use_pager' => array(
01224 'default' => FALSE,
01225 'arg' => '%d',
01226 'definition' => 'integer',
01227 ),
01228 'allow_link_to_view' => array(
01229 'default' => FALSE,
01230 'arg' => '%d',
01231 'definition' => 'integer',
01232 ),
01233 'allow_more_link' => array(
01234 'default' => FALSE,
01235 'arg' => '%d',
01236 'definition' => 'integer',
01237 ),
01238 'allow_more_text' => array(
01239 'default' => FALSE,
01240 'arg' => '%d',
01241 'definition' => 'integer',
01242 ),
01243 'allow_feed_icons' => array(
01244 'default' => FALSE,
01245 'arg' => '%d',
01246 'definition' => 'integer',
01247 ),
01248 'allow_url_override' => array(
01249 'default' => FALSE,
01250 'arg' => '%d',
01251 'definition' => 'integer',
01252 ),
01253 'allow_url_from_panel' => array(
01254 'default' => FALSE,
01255 'arg' => '%d',
01256 'definition' => 'integer',
01257 ),
01258 );
01259 return $names;
01260 }
01261
01262
01263
01264
01265 function panels_views_default_view_pane($view) {
01266 $names = panels_views_pane_fields();
01267 $panel_view = new stdClass();
01268 foreach ($names as $name => $info) {
01269 $panel_view->$name = $info['default'];
01270 }
01271
01272 $panel_view->view = $panel_view->name = $view->name;
01273 $panel_view->description = $view->description;
01274
01275 if ($view->page) {
01276 $panel_view->view_type = 'page';
01277 $panel_view->nodes_per_page = $view->nodes_per_page;
01278 $panel_view->title = $view->page_title;
01279 }
01280 else {
01281 $panel_view->view_type = 'block';
01282 $panel_view->nodes_per_page = $view->nodes_per_block;
01283 $panel_view->title = $view->block_title;
01284 }
01285
01286 return $panel_view;
01287 }
01288
01289
01290
01291
01292
01293 function panels_views_pane_arguments($view, &$panel_view) {
01294 $contexts = array();
01295 foreach ($view->argument as $id => $arg) {
01296 if (empty($panel_view->contexts[$id])) {
01297 $contexts[$id] = array(
01298 'type' => 'context',
01299 'context' => 'any',
01300 'panel' => 0,
01301 'fixed' => '',
01302 );
01303 }
01304 else {
01305 $contexts[$id] = $panel_view->contexts[$id];
01306 }
01307 }
01308
01309
01310
01311 $panel_view->contexts = $contexts;
01312 }
01313
01314
01315
01316
01317 function panels_views_save($panel_view) {
01318 $fields = $types = $values = $pairs = array();
01319
01320 $insert = empty($panel_view->pvid);
01321
01322
01323 foreach (panels_views_pane_fields() as $field => $data) {
01324 $primary = !empty($data['primary']);
01325
01326 if (!$primary && isset($panel_view->$field)) {
01327 if ($insert) {
01328 $fields[] = $field;
01329 $types[] = $data['arg'];
01330 }
01331 else {
01332 $pairs[] = "$field = $data[arg]";
01333 }
01334
01335
01336 $serialize = !empty($data['serialize']);
01337 $values[] = $serialize ? serialize($panel_view->$field) : $panel_view->$field;
01338 }
01339 }
01340
01341 if ($insert) {
01342
01343 $panel_view->pvid = db_next_id('{panels_views}_pvid');
01344
01345 $sql = 'INSERT INTO {panels_views} (' . implode(', ', $fields) . ', pvid) VALUES (' . implode(', ', $types) . ', %d)';
01346 }
01347 else {
01348
01349 $sql = 'UPDATE {panels_views} SET ' . implode(', ', $pairs) . ' WHERE pvid = %d';
01350 }
01351 $values[] = $panel_view->pvid;
01352 db_query($sql, $values);
01353 }
01354
01355
01356
01357
01358 function panels_views_load($name) {
01359 static $panel_views = array();
01360
01361 if (array_key_exists($name, $panel_views)) {
01362 return $panel_views[$name];
01363 }
01364
01365 $pv = db_fetch_object(db_query("SELECT * FROM {panels_views} WHERE name = '%s'", $name));
01366 if (empty($pv)) {
01367 $defaults = panels_views_default_panels();
01368 if (isset($defaults[$name])) {
01369 $pv = $defaults[$name];
01370 $status = variable_get('panels_views_defaults', array());
01371
01372 if (isset($status[$pv->name])) {
01373 $pv->disabled = $status[$pv->name];
01374 }
01375 $panel_views[$name] = $pv;
01376 return $pv;
01377 }
01378 $panel_views[$name] = NULL;
01379 return;
01380 }
01381
01382 $names = panels_views_pane_fields();
01383 foreach ($names as $key => $data) {
01384 if (!empty($data['serialize'])) {
01385 $pv->$key = unserialize($pv->$key);
01386 }
01387 }
01388 $panel_views[$name] = $pv;
01389
01390 return $panel_views[$name];
01391 }
01392
01393
01394
01395
01396 function panels_views_load_all() {
01397 static $panel_views = NULL;
01398
01399 if (isset($panel_views)) {
01400 return $panel_views;
01401 }
01402
01403 $panel_views = array();
01404 $names = panels_views_pane_fields();
01405 $result = db_query("SELECT * FROM {panels_views}");
01406
01407 while ($pv = db_fetch_object($result)) {
01408 foreach ($names as $name => $data) {
01409 if (!empty($data['serialize'])) {
01410 $pv->$name = unserialize($pv->$name);
01411 }
01412 }
01413 $pv->type = t('Local');
01414 $panel_views[$pv->name] = $pv;
01415 }
01416
01417
01418 $status = variable_get('panels_views_defaults', array());
01419
01420 foreach (panels_views_default_panels() as $pv) {
01421
01422 if (isset($status[$pv->name])) {
01423 $pv->disabled = $status[$pv->name];
01424 }
01425
01426 if (!empty($panel_views[$pv->name])) {
01427 $panel_views[$pv->name]->type = t('Overridden');
01428 }
01429 else {
01430 $pv->type = t('Default');
01431 $panel_views[$pv->name] = $pv;
01432 }
01433 }
01434 return $panel_views;
01435 }
01436
01437
01438
01439
01440
01441
01442 function panels_views_default_panels() {
01443 $panels = module_invoke_all('default_panel_views');
01444 if (!is_array($panels)) {
01445 $panels = array();
01446 }
01447
01448 return $panels;
01449 }
01450
01451
01452
01453
01454 function panels_views_delete($pv) {
01455 db_query("DELETE FROM {panels_views} WHERE pvid = %d", $pv->pvid);
01456 return TRUE;
01457 }
01458
01459
01460
01461
01462
01463
01464
01465 function panels_views_export($pv, $prefix = '') {
01466 $output = '';
01467 $fields = panels_views_pane_fields();
01468 $output .= $prefix . '$panel_view = new stdClass()' . ";\n";
01469 foreach ($fields as $field => $data) {
01470 $value = empty($data['primary']) ? $pv->$field : 'new';
01471 $output .= $prefix . ' $panel_view->' . $field . ' = ' . panels_var_export($value, ' ') . ";\n";
01472 }
01473
01474 return $output;
01475 }
01476
01477
01478
01479
01480 function panels_views_panels_exportables($op = 'list', $panels = NULL, $name = 'foo') {
01481 static $all_panels = NULL;
01482
01483 if ($op == 'list') {
01484 if (empty($all_panels)) {
01485 $all_panels = panels_views_load_all();
01486 }
01487
01488 foreach ($all_panels as $name => $panel) {
01489 $return[$name] = check_plain($name) . ' (' . check_plain($panel->title) . ')';
01490 }
01491 return $return;
01492 }
01493
01494 if ($op == 'export') {
01495 $code = "/**\n";
01496 $code .= " * Implementation of hook_default_panel_views().\n";
01497 $code .= " */\n";
01498 $code .= "function " . $name . "_default_panel_views() {\n";
01499 foreach ($panels as $panel => $truth) {
01500 $code .= panels_views_export($all_panels[$panel], ' ');
01501 $code .= ' $panel_views[\'' . check_plain($panel) . '\'] = $panel_view;' . "\n\n\n";
01502 }
01503 $code .= " return \$panel_views;\n";
01504 $code .= "}\n";
01505 return $code;
01506 }
01507 }
01508
01509
01510
01511
01512
01513
01514
01515
01516 function panels_views_form_alter($form_id, &$form) {
01517 if ($form_id == 'views_edit_view' && !empty($form['basic-info']['name']['#default_value'])) {
01518 $pvids = array();
01519 $result = db_query("SELECT pvid FROM {panels_views} WHERE view = '%s'", $form['basic-info']['name']['#default_value']);
01520 while ($row = db_fetch_object($result)) {
01521 $pvids[] = $row->pvid;
01522 }
01523 if (!empty($pvids)) {
01524 $form['dependent_pvids'] = array(
01525 '#type' => 'value',
01526 '#value' => $pvids,
01527 );
01528 $form['#submit'] += array('panels_views_update_pvids_submit' => array());
01529 }
01530 }
01531 }
01532
01533
01534
01535
01536
01537
01538
01539
01540 function panels_views_update_pvids_submit($form_id, $form_values) {
01541 db_query("UPDATE {panels_views} SET view = '%s' WHERE pvid IN (" . implode(', ', $form_values['dependent_pvids']) . ")", $form_values['name']);
01542 }