Go to the documentation of this file.00001 <?php
00002
00012 class views_handler_area_view extends views_handler_area {
00013
00014 function option_definition() {
00015 $options = parent::option_definition();
00016
00017 $options['view_to_insert'] = array('default' => '');
00018 $options['inherit_arguments'] = array('default' => FALSE, 'boolean' => TRUE);
00019 return $options;
00020 }
00021
00026 function options_form(&$form, &$form_state) {
00027 parent::options_form($form, $form_state);
00028
00029 $view_display = $this->view->name . ':' . $this->view->current_display;
00030
00031 $options = array('' => t('-Select-'));
00032 $options += views_get_views_as_options(FALSE, 'all', $view_display);
00033 $form['view_to_insert'] = array(
00034 '#type' => 'select',
00035 '#title' => t('View to insert'),
00036 '#default_value' => $this->options['view_to_insert'],
00037 '#description' => t('The view to insert into this area.'),
00038 '#options' => $options,
00039 );
00040
00041 $form['inherit_arguments'] = array(
00042 '#type' => 'checkbox',
00043 '#title' => t('Inherit contextual filters'),
00044 '#default_value' => $this->options['inherit_arguments'],
00045 '#description' => t('If checked, this view will receive the same contextual filters as its parent.'),
00046 );
00047 }
00048
00052 function render($empty = FALSE) {
00053 if (!empty($this->options['view_to_insert'])) {
00054 list($view_name, $display_id) = explode(':', $this->options['view_to_insert']);
00055
00056 $view = views_get_view($view_name);
00057 if (empty($view) || !$view->access($display_id)) {
00058 return;
00059 }
00060 $view->set_display($display_id);
00061
00062
00063 $view->parent_views += $this->view->parent_views;
00064 $view->parent_views[] = "$view_name:$display_id";
00065
00066
00067 $search = "$view_name:$display_id";
00068 if (in_array($search, $this->view->parent_views)) {
00069 drupal_set_message(t("Recursion detected in view @view display @display.", array('@view' => $view_name, '@display' => $display_id)), 'error');
00070 }
00071 else {
00072 if (!empty($this->options['inherit_arguments']) && !empty($this->view->args)) {
00073 return $view->preview($display_id, $this->view->args);
00074 }
00075 else {
00076 return $view->preview($display_id);
00077 }
00078 }
00079 }
00080 return '';
00081 }
00082 }