Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.46 KB | None | 0 0
  1. <?php
  2. /**
  3.  * @file
  4.  * Definition of the FIA wrapped style.
  5.  */
  6.  
  7. $plugin = array(
  8.   'title' => t('Custom pane wrapper plain'),
  9.   'render pane' => 'custom_plain_pane_wrapper_style_render_pane',
  10.   'pane settings form' => 'custom_plain_pane_wrapper_style_render_pane_settings_form',
  11.   'hook theme' => array(
  12.     'custom_pane_wrapper_plain' => array(
  13.       'variables' => array(
  14.         'wrapper' => NULL,
  15.         'css_id' => NULL,
  16.         'css_class' => NULL,
  17.         'title' => NULL,
  18.         'title_prefix' => NULL,
  19.         'title_suffix' => NULL,
  20.         'title_wrapper' => NULL,
  21.         'title_id' => NULL,
  22.         'title_class' => NULL,
  23.         'title_hide' => FALSE,
  24.         'content' => NULL,
  25.       ),
  26.       'path' => drupal_get_path('theme', 'penceo_theme') . '/plugins/styles/general/custom_pane_wrapper_plain',
  27.       'template' => 'custom-pane-wrapper-plain',
  28.     ),
  29.   ),
  30. );
  31.  
  32. /**
  33.  * Render callback.
  34.  *
  35.  * @ingroup themeable
  36.  */
  37. function theme_custom_plain_pane_wrapper_style_render_pane($vars) {
  38.   $settings = $vars['settings'];
  39.   $options = array(
  40.     'wrapper' => $settings['pane']['wrapper'] != 'none' ? $settings['pane']['wrapper'] : NULL,
  41.     'css_id' => $settings['pane']['css_id'] != '' ? $settings['pane']['css_id'] : NULL,
  42.     'css_class' => $settings['pane']['css_class'] != '' ? $settings['pane']['css_class'] : NULL,
  43.     'title' => isset($vars['content']->title) ? $vars['content']->title : NULL,
  44.     'title_prefix' => isset($vars['content']->title_prefix) ? $vars['content']->title_prefix : NULL,
  45.     'title_suffix' => isset($vars['content']->title_suffix) ? $vars['content']->title_suffix : NULL,
  46.     'title_wrapper' => $settings['title']['title_wrapper'] != 'none' ? $settings['title']['title_wrapper'] : NULL,
  47.     'title_hide' => isset($settings['title']['title_hide']) ? $settings['title']['title_hide'] : FALSE,
  48.     'content' => $vars['content']->content,
  49.   );
  50.  
  51.   if ($settings['title']['title_class'] != '') {
  52.     $options['title_attributes_array']['class'] = array($settings['title']['title_class']);
  53.   }
  54.  
  55.   if ($settings['title']['title_id']) {
  56.     $options['title_attributes_array']['id'] = $settings['title']['title_id'];
  57.   }
  58.  
  59.   $options['admin_links'] = '';
  60.  
  61.   $content =& $vars['content'];
  62.  
  63.   if (module_exists('contextual') && user_access('access contextual links')) {
  64.     $links = array();
  65.     // These are specified by the content.
  66.     if (!empty($content->admin_links)) {
  67.       $links += $content->admin_links;
  68.     }
  69.  
  70.     // Take any that may have been in the render array we were given and
  71.     // move them up so they appear outside the pane properly.
  72.     if (is_array($content->content) && isset($content->content['#contextual_links'])) {
  73.       $element = array(
  74.         '#type' => 'contextual_links',
  75.         '#contextual_links' => $content->content['#contextual_links'],
  76.       );
  77.       unset($content->content['#contextual_links']);
  78.  
  79.       // Add content to $element array.
  80.       if (is_array($content->content)) {
  81.         $element['#element'] = $content->content;
  82.       }
  83.  
  84.       $element = contextual_pre_render_links($element);
  85.       if (!empty($element['#links'])) {
  86.         $links += $element['#links'];
  87.       }
  88.     }
  89.  
  90.     if ($links) {
  91.       $build = array(
  92.         '#prefix' => '<div class="contextual-links-wrapper">',
  93.         '#suffix' => '</div>',
  94.         '#theme' => 'links__contextual',
  95.         '#links' => $links,
  96.         '#attributes' => array('class' => array('contextual-links')),
  97.         '#attached' => array(
  98.           'library' => array(array('contextual', 'contextual-links')),
  99.         ),
  100.       );
  101.  
  102.       if (isset($options['css_class'])) {
  103.         $options['css_class'] .= ' contextual-links-region';
  104.       }
  105.       else {
  106.         $options['css_class'] = 'contextual-links-region';
  107.       }
  108.       $options['admin_links'] = drupal_render($build);
  109.     }
  110.   }
  111.  
  112.   return theme('custom_pane_wrapper_plain', $options);
  113. }
  114.  
  115. /**
  116.  * Settings form callback.
  117.  */
  118. function custom_plain_pane_wrapper_style_render_pane_settings_form($style_settings) {
  119.   $form = array();
  120.  
  121.   $wrap_tags = array(
  122.     'div' => t('DIV'),
  123.     'h1' => t('H1'),
  124.     'h2' => t('H2'),
  125.     'h3' => t('H3'),
  126.     'h4' => t('H4'),
  127.     'h5' => t('H5'),
  128.     'h6' => t('H6'),
  129.     'span' => t('SPAN'),
  130.     'p' => t('P'),
  131.     'nav' => t('Nav'),
  132.     'article' => t('ARTICLE'),
  133.     'section' => t('SECTION'),
  134.     'aside' => t('ASIDE'),
  135.   );
  136.  
  137.   $form['pane'] = array(
  138.     '#type' => 'fieldset',
  139.     '#title' => t('Pane settings'),
  140.     '#collapsible' => TRUE,
  141.     '#collapsed' => FALSE,
  142.   );
  143.  
  144.   $form['pane']['wrapper'] = array(
  145.     '#title' => t('Wrapper'),
  146.     '#type' => 'select',
  147.     '#default_value' => !empty($style_settings['pane']['wrapper']) ? $style_settings['pane']['wrapper'] : 'none',
  148.     '#options' => $wrap_tags,
  149.     '#empty_value' => 'none',
  150.     '#empty_option' => t('No wrapper'),
  151.   );
  152.  
  153.   $form['pane']['css_id'] = array(
  154.     '#type' => 'textfield',
  155.     '#title' => t('CSS ID'),
  156.     '#default_value' => (isset($style_settings['pane']['css_id'])) ? $style_settings['pane']['css_id'] : '',
  157.   );
  158.  
  159.   $form['pane']['css_class'] = array(
  160.     '#type' => 'textfield',
  161.     '#title' => t('CSS classes'),
  162.     '#default_value' => (isset($style_settings['pane']['css_class'])) ? $style_settings['pane']['css_class'] : '',
  163.   );
  164.  
  165.   $form['title'] = array(
  166.     '#type' => 'fieldset',
  167.     '#title' => t('Title settings'),
  168.     '#collapsible' => TRUE,
  169.     '#collapsed' => TRUE,
  170.   );
  171.  
  172.   $form['title']['title_wrapper'] = array(
  173.     '#title' => t('Wrapper'),
  174.     '#type' => 'select',
  175.     '#default_value' => !empty($style_settings['title']['title_wrapper']) ? $style_settings['title']['title_wrapper'] : 'none',
  176.     '#options' => $wrap_tags,
  177.     '#empty_value' => 'none',
  178.     '#empty_option' => t('No wrapper'),
  179.   );
  180.  
  181.   $form['title']['title_class'] = array(
  182.     '#type' => 'textfield',
  183.     '#title' => t('Title CSS classes'),
  184.     '#default_value' => (isset($style_settings['title']['title_class'])) ? $style_settings['title']['title_class'] : '',
  185.   );
  186.  
  187.   $form['title']['title_id'] = array(
  188.     '#type' => 'textfield',
  189.     '#title' => t('Title CSS ID'),
  190.     '#default_value' => (isset($style_settings['title']['title_id'])) ? $style_settings['title']['title_id'] : '',
  191.   );
  192.  
  193.   $form['title']['title_hide'] = array(
  194.     '#type' => 'checkbox',
  195.     '#title' => t('Hide title'),
  196.     '#default_value' => (isset($style_settings['title']['hide_title'])) ? $style_settings['title']['hide_title'] : FALSE,
  197.   );
  198.  
  199.   return $form;
  200. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement