Projet

Général

Profil

Paste
Télécharger (6,72 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / themes / adaptivetheme / at_core / layouts / panels / five_5x20 / five_5x20.inc @ 74f6bef0

1
<?php
2

    
3
/**
4
 * @file
5
 * Implimentation of an Adaptivetheme Panels Layout Plugin
6
 * A panels layout plugin on steroids and an implementation of
7
 * hook_panels_layouts().
8
 *
9
 * These plugins must use the function method - Panels can support two
10
 * methods, one that uses a function name and one that simply defines
11
 * a $plugins array. You MUST use the function method, which requires
12
 * correct naming of the function:
13
 * function [theme name]_[plugin name]_panels_layouts()
14
 *
15
 * Adaptivetheme needs more data to build the actual CSS since it does not use
16
 * Panels normal method of defining a static CSS file. In AT the CSS is built
17
 * programmatically for each selected option when the user saves the theme
18
 * settings. This is for two main reasons - first so we are optimizing the
19
 * CSS and not adding any duplicate CSS declarations, and secondly so we can
20
 * easily insert the CSS into the right media query in the generated stylsheet.
21
 *
22
 * Adding Selectors and CSS Declarations:
23
 * Each CSS declaration is an array, keyed by an "identifier". The array items
24
 * are selector/css pairs. For example:
25
 * '40' => array('.five-5x20 .row-1' => 'width:40%'),
26
 * Here '40' is the identifier, '.five-5x20 .row-1' is the selector and 'width:40%'
27
 * is the actual CSS style.
28
 *
29
 * Identifiers:
30
 * Each identifier represents a CSS style. It's basically shorthand notation for the
31
 * actual CSS. To ensure the CSS is optimized as much as possible you should use an
32
 * existing identifier if it exists, although you can use your own, just make sure
33
 * to re-use them as much as possible in order to get the smallest CSS files -
34
 * here is a full list of the existing identifiers used by AT Core Panels plugins:
35

    
36
 Basic Widths (all must be in percentages):
37

    
38
 ID       CSS
39

    
40
 '25'     'width:25%'
41
 '33'     'width:33.333333%'
42
 '40'     'width:40%'
43
 '50'     'width:50%'
44
 '60'     'width:60%'
45
 '66'     'width:66.666666%'
46
 '75'     'width:75%'
47
 '100'    'width:100%'
48

    
49
 Floats with widths:
50

    
51
 '25fl'   'width:25%;float:left'
52
 '25fr'   'width:25%;float:right'
53
 '33fl'   'width:33.333333%;float:left'
54
 '50fl'   'width:50%;float:left'
55
 '75fl'   'width:75%;float:left'
56
 '75fr'   'width:75%;float:right'
57

    
58
 Floats:
59

    
60
 'fl'     'float:left'
61
 'fr'     'float:right'
62
 'fn'     'float:none'
63

    
64
 Stacked Regions get a specail cased identifier:
65

    
66
 'fdw'    'float:none;display:block;width:100%;clear:both'
67

    
68
 */
69

    
70
function adaptivetheme_five_5x20_panels_layouts() {
71
  $items['five_5x20'] = array(
72
    'title'    => t('AT Five column 5x20'),
73
    'category' => t('AT Responsive Panels - 4,5,6 column'),
74
    'icon'     => 'five_5x20.png', // Used in Panels Admin only. AT Core uses a CSS sprite for the icons in theme settings.
75
    'theme'    => 'five_5x20',
76
    'admin css' => 'five_5x20.admin.css', // This holds a basic layout for Panels Admin and the CSS for theme settings sprite. Sprite icons must be 40px by 40px.
77
    'theme arguments' => array('id', 'content'),
78
    'regions' => array(
79
      'five_first'  => t('Column 1'),
80
      'five_second' => t('Column 2'),
81
      'five_third'  => t('Column 3'),
82
      'five_fourth' => t('Column 4'),
83
      'five_fifth'  => t('Column 5'),
84
    ),
85

    
86
    // The array items below are added by Adaptivetheme and are not normally present
87
    // in a Panels layout plugin. AT uses these to build the theme settings and generate
88
    // the CSS used when rendering the layout in the front end.
89
    'type' => 'five',            // - type: dictates what group it will fall into in theme settings.
90
    'options' => array(          // - options: the various layout options the user can choose in theme settings for each device group.
91
      'five-5x20' => 'default',  // - option key: the key used here MUST match the key used in the 'styles', the first one must be called 'default'.
92
      'five-5x20-2x3-grid' => '2/3 split grid',
93
      'five-5x20-1x2x2-grid' => 'stack',
94
      'five-5x20-stack-2' => 'Stack 50/50 bottom',
95
      'five-5x20-stack' => 'stack', // stack should always refer to "all regions stacked", and use the 'fdw' identifier in 'styles'.
96
    ),
97
    'styles' => array(          // - styles: these items are used to programatically build and optimize the CSS for each break-point.
98
      'five-5x20' => array(     // - styles keys: these key must match the 'options' keys, the first one must be the default.
99
        'css' => array(         // - css: holds the array of CSS identifiers
100
          '40' => array('.five-5x20 > .row-1' => 'width:40%'), // selectors as keys, CSS as values, values should align to the the "css" array key identifiers.
101
          '60' => array('.five-5x20 > .row-2' => 'width:60%'),
102
          'fl' => array('.five-5x20 > .panel-row' => 'float:left'),
103
          '50' => array('.five-5x20 > .row-1 > .region' => 'width:50%'),
104
          '33' => array('.five-5x20 > .row-2 > .region' => 'width:33.333333%'),
105
        ),
106
      ),
107
      'five-5x20-2x3-grid' => array(
108
        'css' => array(
109
          '33' => array('.five-5x20 > .panel-row > .region' => 'width:33.333333%'),
110
          '50' => array('.five-5x20 > .row-1 div.region-five-first,.five-5x20 .row-1 div.region-five-second' => 'width:50%'),
111
          'fdw' => array('.five-5x20 > .panel-row' => 'float:none;display:block;width:100%;clear:both'),
112
        ),
113
      ),
114
      'five-5x20-1x2x2-grid' => array(
115
        'css' => array(
116
          '50' => array('.five-5x20 > .panel-row > div.region' => 'width:50%'),
117
          'fdw' => array('.five-5x20 > div.panel-row,.five-5x20 > div.panel-row > div.region-five-fifth' => 'float:none;display:block;width:100%;clear:both'),
118
        ),
119
      ),
120
      'five-5x20-stack-2' => array(
121
        'css' => array(
122
          '50' => array('.five-5x20 > .row-1 > div.region' => 'width:50%'),
123
          'fdw' => array('.five-5x20 > .panel-row,.five-5x20 > .row-2 > .region' => 'float:none;display:block;width:100%;clear:both'),
124
        ),
125
      ),
126
      'five-5x20-stack' => array(
127
        'css' => array(
128
          'fdw' => array('.five-5x20 > .panel-row > .region,.five-5x20 > .panel-row' => 'float:none;display:block;width:100%;clear:both'),
129
        ),
130
      ),
131
    ),
132
  );
133

    
134
  return $items;
135
}
136

    
137
/**
138
 * Preprocess variables for five-5x20.tpl.php
139
 */
140
function template_preprocess_five_5x20(&$vars) {
141
 /**
142
  * We need to initialize these variables when Panels is displaying the template.
143
  * These are used primarily when the template is being rendered via Display suite
144
  * as a "node" so we can programatically wrap the layout in <article> elements
145
  * with appropriate classes and id.
146
  *
147
  * Note that in Display Suite layout plugin preprocess and process functions are
148
  * not fired, instead we need to use the functions for the template being
149
  * modified by DS, such as node, user or search. AT Core sets these prefix and
150
  * suffix vars for nodes in adaptivetheme_process_node().
151
  */
152
  $vars['panel_prefix'] = '';
153
  $vars['panel_suffix'] = '';
154
}