public ViewEditForm::getDisplayDetails($view, $display)
Helper function to get the display details section of the edit UI.
Parameters
$display:
Return value
array A renderable page build array.
File
- core/modules/views_ui/src/ViewEditForm.php, line 366
Class
- ViewEditForm
- Form controller for the Views edit form.
Namespace
Drupal\views_ui
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | public function getDisplayDetails( $view , $display ) { $display_title = $this ->getDisplayLabel( $view , $display [ 'id' ], FALSE); $build = array ( '#theme_wrappers' => array ( 'container' ), '#attributes' => array ( 'id' => 'edit-display-settings-details' ), ); $is_display_deleted = ! empty ( $display [ 'deleted' ]); // The master display cannot be duplicated. $is_default = $display [ 'id' ] == 'default' ; // @todo: Figure out why getOption doesn't work here. $is_enabled = $view ->getExecutable()->displayHandlers->get( $display [ 'id' ])->isEnabled(); if ( $display [ 'id' ] != 'default' ) { $build [ 'top' ][ '#theme_wrappers' ] = array ( 'container' ); $build [ 'top' ][ '#attributes' ][ 'id' ] = 'edit-display-settings-top' ; $build [ 'top' ][ '#attributes' ][ 'class' ] = array ( 'views-ui-display-tab-actions' , 'edit-display-settings-top' , 'views-ui-display-tab-bucket' , 'clearfix' ); // The Delete, Duplicate and Undo Delete buttons. $build [ 'top' ][ 'actions' ] = array ( '#theme_wrappers' => array ( 'dropbutton_wrapper' ), ); // Because some of the 'links' are actually submit buttons, we have to // manually wrap each item in <li> and the whole list in <ul>. $build [ 'top' ][ 'actions' ][ 'prefix' ][ '#markup' ] = '<ul class="dropbutton">' ; if (! $is_display_deleted ) { if (! $is_enabled ) { $build [ 'top' ][ 'actions' ][ 'enable' ] = array ( '#type' => 'submit' , '#value' => $this ->t( 'Enable @display_title' , [ '@display_title' => $display_title ]), '#limit_validation_errors' => array (), '#submit' => array ( '::submitDisplayEnable' , '::submitDelayDestination' ), '#prefix' => '<li class="enable">' , "#suffix" => '</li>' , ); } // Add a link to view the page unless the view is disabled or has no // path. elseif ( $view ->status() && $view ->getExecutable()->displayHandlers->get( $display [ 'id' ])->hasPath()) { $path = $view ->getExecutable()->displayHandlers->get( $display [ 'id' ])->getPath(); if ( $path && ( strpos ( $path , '%' ) === FALSE)) { if (! parse_url ( $path , PHP_URL_SCHEME)) { // @todo Views should expect and store a leading /. See: $url = Url::fromUserInput( '/' . ltrim( $path , '/' )); } else { $url = Url::fromUri( "base:$path" ); } $build [ 'top' ][ 'actions' ][ 'path' ] = array ( '#type' => 'link' , '#title' => $this ->t( 'View @display_title' , [ '@display_title' => $display_title ]), '#options' => array ( 'alt' => array ( $this ->t( "Go to the real page for this display" ))), '#url' => $url , '#prefix' => '<li class="view">' , "#suffix" => '</li>' , ); } } if (! $is_default ) { $build [ 'top' ][ 'actions' ][ 'duplicate' ] = array ( '#type' => 'submit' , '#value' => $this ->t( 'Duplicate @display_title' , [ '@display_title' => $display_title ]), '#limit_validation_errors' => array (), '#submit' => array ( '::submitDisplayDuplicate' , '::submitDelayDestination' ), '#prefix' => '<li class="duplicate">' , "#suffix" => '</li>' , ); } // Always allow a display to be deleted. $build [ 'top' ][ 'actions' ][ 'delete' ] = array ( '#type' => 'submit' , '#value' => $this ->t( 'Delete @display_title' , [ '@display_title' => $display_title ]), '#limit_validation_errors' => array (), '#submit' => array ( '::submitDisplayDelete' , '::submitDelayDestination' ), '#prefix' => '<li class="delete">' , "#suffix" => '</li>' , ); foreach (Views::fetchPluginNames( 'display' , NULL, array ( $view ->get( 'storage' )->get( 'base_table' ))) as $type => $label ) { if ( $type == $display [ 'display_plugin' ]) { continue ; } $build [ 'top' ][ 'actions' ][ 'duplicate_as' ][ $type ] = array ( '#type' => 'submit' , '#value' => $this ->t( 'Duplicate as @type' , [ '@type' => $label ]), '#limit_validation_errors' => array (), '#submit' => array ( '::submitDuplicateDisplayAsType' , '::submitDelayDestination' ), '#prefix' => '<li class="duplicate">' , '#suffix' => '</li>' , ); } } else { $build [ 'top' ][ 'actions' ][ 'undo_delete' ] = array ( '#type' => 'submit' , '#value' => $this ->t( 'Undo delete of @display_title' , [ '@display_title' => $display_title ]), '#limit_validation_errors' => array (), '#submit' => array ( '::submitDisplayUndoDelete' , '::submitDelayDestination' ), '#prefix' => '<li class="undo-delete">' , "#suffix" => '</li>' , ); } if ( $is_enabled ) { $build [ 'top' ][ 'actions' ][ 'disable' ] = array ( '#type' => 'submit' , '#value' => $this ->t( 'Disable @display_title' , [ '@display_title' => $display_title ]), '#limit_validation_errors' => array (), '#submit' => array ( '::submitDisplayDisable' , '::submitDelayDestination' ), '#prefix' => '<li class="disable">' , "#suffix" => '</li>' , ); } $build [ 'top' ][ 'actions' ][ 'suffix' ][ '#markup' ] = '</ul>' ; // The area above the three columns. $build [ 'top' ][ 'display_title' ] = array ( '#theme' => 'views_ui_display_tab_setting' , '#description' => $this ->t( 'Display name' ), '#link' => $view ->getExecutable()->displayHandlers->get( $display [ 'id' ])->optionLink( $display_title , 'display_title' ), ); } $build [ 'columns' ] = array (); $build [ 'columns' ][ '#theme_wrappers' ] = array ( 'container' ); $build [ 'columns' ][ '#attributes' ] = array ( 'id' => 'edit-display-settings-main' , 'class' => array ( 'clearfix' , 'views-display-columns' )); $build [ 'columns' ][ 'first' ][ '#theme_wrappers' ] = array ( 'container' ); $build [ 'columns' ][ 'first' ][ '#attributes' ] = array ( 'class' => array ( 'views-display-column' , 'first' )); $build [ 'columns' ][ 'second' ][ '#theme_wrappers' ] = array ( 'container' ); $build [ 'columns' ][ 'second' ][ '#attributes' ] = array ( 'class' => array ( 'views-display-column' , 'second' )); $build [ 'columns' ][ 'second' ][ 'settings' ] = array (); $build [ 'columns' ][ 'second' ][ 'header' ] = array (); $build [ 'columns' ][ 'second' ][ 'footer' ] = array (); $build [ 'columns' ][ 'second' ][ 'empty' ] = array (); $build [ 'columns' ][ 'second' ][ 'pager' ] = array (); // The third column buckets are wrapped in details. $build [ 'columns' ][ 'third' ] = array ( '#type' => 'details' , '#title' => $this ->t( 'Advanced' ), '#theme_wrappers' => array ( 'details' ), '#attributes' => array ( 'class' => array ( 'views-display-column' , 'third' , ), ), ); // Collapse the details by default. $build [ 'columns' ][ 'third' ][ '#open' ] = \Drupal::config( 'views.settings' )->get( 'ui.show.advanced_column' ); // Each option (e.g. title, access, display as grid/table/list) fits into one // of several "buckets," or boxes (Format, Fields, Sort, and so on). $buckets = array (); // Fetch options from the display plugin, with a list of buckets they go into. $options = array (); $view ->getExecutable()->displayHandlers->get( $display [ 'id' ])->optionsSummary( $buckets , $options ); // Place each option into its bucket. foreach ( $options as $id => $option ) { // Each option self-identifies as belonging in a particular bucket. $buckets [ $option [ 'category' ]][ 'build' ][ $id ] = $this ->buildOptionForm( $view , $id , $option , $display ); } // Place each bucket into the proper column. foreach ( $buckets as $id => $bucket ) { // Let buckets identify themselves as belonging in a column. if (isset( $bucket [ 'column' ]) && isset( $build [ 'columns' ][ $bucket [ 'column' ]])) { $column = $bucket [ 'column' ]; } // If a bucket doesn't pick one of our predefined columns to belong to, put // it in the last one. else { $column = 'third' ; } if (isset( $bucket [ 'build' ]) && is_array ( $bucket [ 'build' ])) { $build [ 'columns' ][ $column ][ $id ] = $bucket [ 'build' ]; $build [ 'columns' ][ $column ][ $id ][ '#theme_wrappers' ][] = 'views_ui_display_tab_bucket' ; $build [ 'columns' ][ $column ][ $id ][ '#title' ] = ! empty ( $bucket [ 'title' ]) ? $bucket [ 'title' ] : '' ; $build [ 'columns' ][ $column ][ $id ][ '#name' ] = $id ; } } $build [ 'columns' ][ 'first' ][ 'fields' ] = $this ->getFormBucket( $view , 'field' , $display ); $build [ 'columns' ][ 'first' ][ 'filters' ] = $this ->getFormBucket( $view , 'filter' , $display ); $build [ 'columns' ][ 'first' ][ 'sorts' ] = $this ->getFormBucket( $view , 'sort' , $display ); $build [ 'columns' ][ 'second' ][ 'header' ] = $this ->getFormBucket( $view , 'header' , $display ); $build [ 'columns' ][ 'second' ][ 'footer' ] = $this ->getFormBucket( $view , 'footer' , $display ); $build [ 'columns' ][ 'second' ][ 'empty' ] = $this ->getFormBucket( $view , 'empty' , $display ); $build [ 'columns' ][ 'third' ][ 'arguments' ] = $this ->getFormBucket( $view , 'argument' , $display ); $build [ 'columns' ][ 'third' ][ 'relationships' ] = $this ->getFormBucket( $view , 'relationship' , $display ); return $build ; } |
Please login to continue.