Definition in file panels_views.module.
Go to the source code of this file.
| panels_views_add_view | ( | $ | view_name | ) |
Page callback to add a new view pane from an existing view.
Definition at line 213 of file panels_views.module.
References panels_views_default_view_pane().
00213 { 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 }
| panels_views_add_view_form | ( | ) |
Form to select a view for creating a new view pane.
Definition at line 189 of file panels_views.module.
References panels_views_get_all_views().
00189 { 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 }
| panels_views_add_view_form_submit | ( | $ | form_id, | |
| $ | form_values | |||
| ) |
| panels_views_content_types | ( | ) |
Return a list of each view type we support.
Definition at line 719 of file panels_views.module.
References panels_get_path(), and panels_views_load_all().
00719 { 00720 $panes = panels_views_load_all(); 00721 $types = array(); 00722 foreach ($panes as $name => $pv) { 00723 // Skip default but disabled panel views. 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 }
| panels_views_default_view_pane | ( | $ | view | ) |
Provide default settings for a new view pane.
Definition at line 1265 of file panels_views.module.
References panels_views_pane_fields().
Referenced by panels_views_add_view().
01265 { 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 }
| panels_views_delete | ( | $ | pv | ) |
Delete a view pane.
Definition at line 1454 of file panels_views.module.
Referenced by panels_views_delete_confirm_submit().
01454 { 01455 db_query("DELETE FROM {panels_views} WHERE pvid = %d", $pv->pvid); 01456 return TRUE; 01457 }
| panels_views_delete_confirm | ( | $ | panel_view | ) |
Provide a form to confirm deletion of a view pane.
Definition at line 556 of file panels_views.module.
References panels_views_load().
00556 { 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 }
| panels_views_delete_confirm_submit | ( | $ | form_id, | |
| $ | form | |||
| ) |
Handle the submit button to delete a view pane.
Definition at line 576 of file panels_views.module.
References panels_views_delete().
00576 { 00577 if ($form['confirm']) { 00578 panels_views_delete((object) $form); 00579 return 'admin/panels/views'; 00580 } 00581 }
| panels_views_disable_page | ( | $ | name = NULL |
) |
Disable a default view pane.
Definition at line 685 of file panels_views.module.
References panels_views_default_panels().
00685 { 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 }
| panels_views_edit | ( | $ | id, | |
| $ | parents, | |||
| $ | conf = array() | |||
| ) |
Provide the pane edit dialog.
Definition at line 897 of file panels_views.module.
References panels_views_load().
00897 { 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 // Provide defaults for the items we let the user edit. 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 // Provide form gadgets only on the things that th euser can change. 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 // TODO: Because javascript in the dialogs is kind of weird, dependent checkboxes 01042 // don't work right for external modules. This needs fixing in panels itself. 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 }
| panels_views_edit_view | ( | $ | view_name | ) |
Page callback to edit a view pane.
Definition at line 225 of file panels_views.module.
References panels_views_load().
00225 { 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 }
| panels_views_edit_view_form | ( | $ | view, | |
| $ | panel_view | |||
| ) |
Form to add or edit add a view pane.
Definition at line 239 of file panels_views.module.
References panels_get_contexts(), panels_load_include(), and panels_views_pane_arguments().
00239 { 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 }
| panels_views_edit_view_form_submit | ( | $ | form_id, | |
| $ | form_values | |||
| ) |
Submit the edit form and save the values.
Definition at line 542 of file panels_views.module.
References panels_views_pane_fields(), and panels_views_save().
00542 { 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 }
| panels_views_edit_view_form_validate | ( | $ | form_id, | |
| $ | form_values, | |||
| $ | form | |||
| ) |
Validate the edit form.
Definition at line 520 of file panels_views.module.
00520 { 00521 // Test uniqueness of name: 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 }
| panels_views_enable_page | ( | $ | name = NULL |
) |
Enable a default view pane.
Definition at line 671 of file panels_views.module.
References panels_views_default_panels().
00671 { 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 }
| panels_views_export | ( | $ | pv, | |
| $ | prefix = '' | |||
| ) |
Export a view pane into PHP code.
This code is suitable to run through eval() and then be used in panels_views_save().
Definition at line 1465 of file panels_views.module.
References panels_var_export(), and panels_views_pane_fields().
Referenced by panels_views_export_view(), and panels_views_panels_exportables().
01465 { 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 }
| panels_views_export_view | ( | $ | pv, | |
| $ | prefix = '' | |||
| ) |
Page callback to export a view pane.
Definition at line 647 of file panels_views.module.
References panels_views_export(), and panels_views_load().
00647 { 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 }
| panels_views_form_alter | ( | $ | form_id, | |
| &$ | form | |||
| ) |
Implementation of hook_form_alter().
Ugly, hacky fix to compensate for the fact that panels_views isn't aware when views changes the system name of a view. With the system name wrong, panels_views breaks.
Definition at line 1516 of file panels_views.module.
01516 { 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 }
| panels_views_get_all_views | ( | ) |
Get a list of all views as an option array.
This really should be included with views.
Definition at line 1077 of file panels_views.module.
Referenced by panels_views_add_view_form().
01077 { 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 }
| panels_views_import_form | ( | ) |
Form for the view pane import.
Definition at line 600 of file panels_views.module.
00600 { 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 }
| panels_views_import_form_submit | ( | $ | form_id, | |
| $ | form | |||
| ) |
Handle the submit button on importing a view pane.
Definition at line 621 of file panels_views.module.
00621 { 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 }
| panels_views_import_view | ( | ) |
Page callback to import a view pane.
Definition at line 586 of file panels_views.module.
00586 { 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 }
| panels_views_list_views | ( | ) |
Page callback to list view panes and the initial form to add new view panes.
Definition at line 103 of file panels_views.module.
References panels_views_load_all().
00103 { 00104 // Run the form first as it may redirect; no point in doing the rest of 00105 // the work if it does. 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 // this is safe as it's always programmatic 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 }
| panels_views_load | ( | $ | name | ) |
Load a view pane from the database.
Definition at line 1358 of file panels_views.module.
References panels_views_default_panels(), and panels_views_pane_fields().
Referenced by panels_views_delete_confirm(), panels_views_edit(), panels_views_edit_view(), panels_views_export_view(), and panels_views_render().
01358 { 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 // Determine if default panel is enabled or disabled. 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 }
| panels_views_load_all | ( | ) |
Load all view panes.
Definition at line 1396 of file panels_views.module.
References panels_views_default_panels(), and panels_views_pane_fields().
Referenced by panels_views_content_types(), panels_views_list_views(), and panels_views_panels_exportables().
01396 { 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 // Now load all the in-code versions 01418 $status = variable_get('panels_views_defaults', array()); 01419 01420 foreach (panels_views_default_panels() as $pv) { 01421 // Determine if default panel is enabled or disabled. 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 }
| panels_views_menu | ( | $ | may_cache | ) |
Implementation of hook_menu().
Definition at line 16 of file panels_views.module.
00016 { 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 }
| panels_views_pane_arguments | ( | $ | view, | |
| &$ | panel_view | |||
| ) |
Adjust a pane for a view's arguments, adding or subtracting as needed to match the current view's argument configuration.
Definition at line 1293 of file panels_views.module.
Referenced by panels_views_edit_view_form().
01293 { 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 // By copying this back, we automatically erase any arguments that may 01310 // no longer exist. 01311 $panel_view->contexts = $contexts; 01312 }
| panels_views_pane_fields | ( | ) |
Poor man's schema API.
Definition at line 1102 of file panels_views.module.
Referenced by panels_views_default_view_pane(), panels_views_edit_view_form_submit(), panels_views_export(), panels_views_install(), panels_views_load(), panels_views_load_all(), and panels_views_save().
01102 { 01103 // Schema version 0 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 // Whether or not array these things are allowed from the pane UI. 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 }
| panels_views_panels_content_types | ( | ) |
Implementation of hook_panels_content_types().
Definition at line 702 of file panels_views.module.
00702 { 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 }
| panels_views_panels_exportables | ( | $ | op = 'list', |
|
| $ | panels = NULL, |
|||
| $ | name = 'foo' | |||
| ) |
Implementation of hook_panels_exportables().
Definition at line 1480 of file panels_views.module.
References panels_views_export(), and panels_views_load_all().
01480 { 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 }
| panels_views_perm | ( | ) |
| panels_views_render | ( | $ | conf, | |
| $ | panel_args, | |||
| &$ | contexts | |||
| ) |
Render a view as a pane.
Definition at line 752 of file panels_views.module.
References panels_views_load().
00752 { 00753 $pv = panels_views_load($conf['name']); 00754 if (empty($pv)) { 00755 return; 00756 } 00757 00758 $v = views_get_view($pv->view); 00759 // no view, we go no further 00760 if (empty($v)) { 00761 return; 00762 } 00763 // Use clone to make sure this is fresh. 00764 $view = drupal_clone($v); 00765 00766 // Check to make sure the user can view this view. 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 // Only fill $args if a panel arg was passed in that belongs there 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 // Put in the wildcard. 00797 $args[] = $view->arguments[$id]['wildcard'] ? $view->arguments[$id]['wildcard'] : '*'; 00798 break; 00799 00800 case 'none': 00801 default: 00802 // Put in NULL. 00803 // views.module knows what to do with NULL (or missing) arguments 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 // link to view 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 // more link 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 // Alternative "more" link text 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 // Turn on pager? 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 // remove any trailing NULL arguments as these are non-args: 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 // Provide administrative links 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 }
| panels_views_save | ( | $ | panel_view | ) |
Write a view pane to the database.
Definition at line 1317 of file panels_views.module.
References panels_views_pane_fields().
Referenced by panels_views_edit_view_form_submit().
01317 { 01318 $fields = $types = $values = $pairs = array(); 01319 // If pvid is empty, this is an insert, otherwise an update. 01320 $insert = empty($panel_view->pvid); 01321 01322 // Build arrays of fields and types (resp. pairs of both) and of values. 01323 foreach (panels_views_pane_fields() as $field => $data) { 01324 $primary = !empty($data['primary']); 01325 // Skip primary key and empty values. 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 // Build the $values array, serializing some fields. 01336 $serialize = !empty($data['serialize']); 01337 $values[] = $serialize ? serialize($panel_view->$field) : $panel_view->$field; 01338 } 01339 } 01340 01341 if ($insert) { 01342 // Determine the new primary key. 01343 $panel_view->pvid = db_next_id('{panels_views}_pvid'); 01344 // Build the query adding the new primary key. 01345 $sql = 'INSERT INTO {panels_views} (' . implode(', ', $fields) . ', pvid) VALUES (' . implode(', ', $types) . ', %d)'; 01346 } 01347 else { 01348 // Build the query filtering by the primary key. 01349 $sql = 'UPDATE {panels_views} SET ' . implode(', ', $pairs) . ' WHERE pvid = %d'; 01350 } 01351 $values[] = $panel_view->pvid; 01352 db_query($sql, $values); 01353 }
| panels_views_title | ( | $ | conf | ) |
| panels_views_update_pvids_submit | ( | $ | form_id, | |
| $ | form_values | |||
| ) |
If we've gotten this far, then we know we've got pvids that could need updating. Don't bother with fancy footwork to see if the view name was actually changed - just update em to be safe. Also no need to update the whole view pane, so we just batch update using IN ().
Definition at line 1540 of file panels_views.module.
01540 { 01541 db_query("UPDATE {panels_views} SET view = '%s' WHERE pvid IN (" . implode(', ', $form_values['dependent_pvids']) . ")", $form_values['name']); 01542 }
| theme_panels_views_add_view_form | ( | $ | form | ) |
Definition at line 201 of file panels_views.module.
00201 { 00202 $row = array(drupal_render($form['view']), drupal_render($form['submit'])); 00203 return theme('table', array(), array($row)) . drupal_render($form); 00204 }
1.5.6