theme-settings-structure.inc 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <?php
  2. /**
  3. * @file
  4. * Theme settings for regions.
  5. */
  6. /**
  7. * @todo
  8. */
  9. function alpha_theme_settings_structure(&$form, &$form_state) {
  10. $theme = alpha_get_theme();
  11. $containers = isset($theme->grids[$theme->settings['grid']]) ? alpha_container_options($theme->grids[$theme->settings['grid']]) : array();
  12. $options = alpha_zone_options($theme->zones);
  13. $columns = $spacing = !empty($containers) ? alpha_column_options(max(array_keys($containers))) : array();
  14. unset($columns[0]);
  15. array_pop($spacing);
  16. $form['alpha_settings']['structure'] = array(
  17. '#type' => 'fieldset',
  18. '#title' => t('Zone and region configuration'),
  19. '#weight' => -8,
  20. );
  21. $form['alpha_settings']['structure']['__unassigned__'] = array(
  22. '#type' => 'fieldset',
  23. '#title' => t('Unassigned zones'),
  24. '#description' => t('There are no unassigned zones.'),
  25. '#weight' => 100,
  26. '#attributes' => array(
  27. 'class' => array('alpha-unassigned'),
  28. ),
  29. );
  30. $form['alpha_settings']['structure']['__unassigned__']['__unassigned__']['regions'] = array(
  31. '#type' => 'fieldset',
  32. '#title' => t('Unassigned regions'),
  33. '#description' => t('There are no unassigned regions.'),
  34. '#weight' => 100,
  35. '#attributes' => array(
  36. 'class' => array('alpha-unassigned'),
  37. ),
  38. );
  39. foreach ($theme->sections as $section => $name) {
  40. $form['alpha_settings']['structure'][$section] = array(
  41. '#type' => 'fieldset',
  42. '#title' => $name . ' ' . t('Section'),
  43. '#description' => t('This section is empty.'),
  44. );
  45. }
  46. foreach ($theme->zones as $zone => $item) {
  47. $section = $item['enabled'] ? $item['section'] : '__unassigned__';
  48. unset($form['alpha_settings']['structure'][$section]['#description']);
  49. $form['alpha_settings']['structure'][$section][$zone] = array(
  50. '#type' => 'fieldset',
  51. '#title' => $item['name'] . ' ' . t('Zone'),
  52. '#weight' => $item['weight'],
  53. '#collapsible' => TRUE,
  54. '#collapsed' => TRUE,
  55. );
  56. $form['alpha_settings']['structure'][$section][$zone]['zone'] = array(
  57. '#type' => 'fieldset',
  58. '#title' => t('Configuration'),
  59. '#weight' => -999,
  60. '#collapsible' => TRUE,
  61. '#collapsed' => TRUE,
  62. '#attributes' => array(
  63. 'class' => array('alpha-inline'),
  64. ),
  65. );
  66. // Provide a full width wrapper around the zone (allowing for design elements outside the grid)
  67. $form['alpha_settings']['structure'][$section][$zone]['zone']['alpha_zone_' . $zone . '_wrapper'] = array(
  68. '#type' => 'checkbox',
  69. '#title' => t('Provide full width wrapper around this zone'),
  70. '#description' => t('Enabling this feature will give a &lt;div&gt; wrapper around the zone itself, allowing you to theme in elements that appear outside the 960 pixel container zone.'),
  71. '#default_value' => $item['wrapper'],
  72. );
  73. $form['alpha_settings']['structure'][$section][$zone]['zone']['alpha_zone_' . $zone . '_force'] = array(
  74. '#type' => 'checkbox',
  75. '#title' => t('Force this zone to be rendered'),
  76. '#description' => t('Enabling this will always render this zone, even if it is empty.'),
  77. '#default_value' => $item['force'],
  78. );
  79. $form['alpha_settings']['structure'][$section][$zone]['zone']['alpha_zone_' . $zone . '_order'] = array(
  80. '#type' => 'checkbox',
  81. '#title' => t('Customize the region positioning'),
  82. '#description' => t('This allows you to manipulate the placing of the regions in this zone.'),
  83. '#default_value' => $item['order'],
  84. '#element_validate' => array('alpha_theme_settings_validate_order'),
  85. '#zone' => $zone,
  86. );
  87. $form['alpha_settings']['structure'][$section][$zone]['zone']['alpha_zone_' . $zone . '_section'] = array(
  88. '#type' => 'select',
  89. '#title' => t('Section'),
  90. '#default_value' => $item['section'],
  91. '#element_validate' => array('alpha_theme_settings_validate_not_empty'),
  92. '#options' => array('_none' => '- None -') + $theme->sections,
  93. );
  94. $form['alpha_settings']['structure'][$section][$zone]['zone']['alpha_zone_' . $zone . '_weight'] = array(
  95. '#type' => 'weight',
  96. '#title' => t('Weight'),
  97. '#default_value' => $item['weight'],
  98. );
  99. // Create a container width selection menu for EACH zone
  100. $form['alpha_settings']['structure'][$section][$zone]['zone']['alpha_zone_' . $zone . '_columns'] = array(
  101. '#type' => 'select',
  102. '#title' => t('Column count'),
  103. '#default_value' => $item['columns'],
  104. '#options' => $containers,
  105. );
  106. // Decide which region is the primary item.
  107. // The primary region is the one that will absorb the size of empty regions that are related in the same zone.
  108. $form['alpha_settings']['structure'][$section][$zone]['zone']['alpha_zone_' . $zone . '_primary'] = array(
  109. '#type' => 'select',
  110. '#title' => t('Primary Region'),
  111. '#default_value' => $item['primary'],
  112. '#options' => array('_none' => t('- None -')) + alpha_zone_regions($zone, $theme->regions),
  113. '#element_validate' => array('alpha_theme_settings_validate_not_empty', 'alpha_theme_settings_validate_primary'),
  114. '#zone' => $zone,
  115. );
  116. // Allow for zone classes
  117. $form['alpha_settings']['structure'][$section][$zone]['zone']['alpha_zone_' . $zone . '_css'] = array(
  118. '#type' => 'textfield',
  119. '#title' => t('Additional zone classes'),
  120. '#size' => 60,
  121. '#default_value' => $item['css'],
  122. );
  123. // Allow for zone wrapper classes
  124. $form['alpha_settings']['structure'][$section][$zone]['zone']['alpha_zone_' . $zone . '_wrapper_css'] = array(
  125. '#type' => 'textfield',
  126. '#title' => t('Additional wrapper classes'),
  127. '#size' => 60,
  128. '#default_value' => $item['wrapper_css'],
  129. '#states' => array(
  130. 'visible' => array(
  131. ':input[name="alpha_zone_' . $zone . '_wrapper"]' => array('checked' => TRUE),
  132. ),
  133. ),
  134. );
  135. $form['alpha_settings']['structure'][$section][$zone]['regions'] = array(
  136. '#type' => 'fieldset',
  137. '#title' => t('Regions'),
  138. '#description' => t('This zone is empty.'),
  139. '#weight' => $item['weight'],
  140. '#collapsible' => TRUE,
  141. '#collapsed' => TRUE,
  142. );
  143. }
  144. foreach($theme->regions as $region => $item) {
  145. $zone = $item['enabled'] ? $item['zone'] : '__unassigned__';
  146. $section = $item['enabled'] && $theme->zones[$item['zone']]['enabled'] ? $item['section'] : '__unassigned__';
  147. unset($form['alpha_settings']['structure'][$section][$zone]['regions']['#description']);
  148. $form['alpha_settings']['structure'][$section][$zone]['regions'][$region] = array(
  149. '#type' => 'fieldset',
  150. '#title' => $item['name'],
  151. '#weight' => $item['weight'],
  152. '#collapsible' => TRUE,
  153. '#collapsed' => TRUE,
  154. '#attributes' => array(
  155. 'class' => array('alpha-inline'),
  156. ),
  157. );
  158. $form['alpha_settings']['structure'][$section][$zone]['regions'][$region]['alpha_region_' . $region . '_force'] = array(
  159. '#type' => 'checkbox',
  160. '#title' => t('Force this region to be rendered'),
  161. '#description' => t('Enabling this will always render this region, even if it is empty.'),
  162. '#default_value' => $item['force'],
  163. );
  164. $form['alpha_settings']['structure'][$section][$zone]['regions'][$region]['alpha_region_' . $region . '_zone'] = array(
  165. '#type' => 'select',
  166. '#title' => t('Zone'),
  167. '#default_value' => !empty($item['zone']) ? $item['zone'] : array('_none'),
  168. '#element_validate' => array('alpha_theme_settings_validate_not_empty'),
  169. '#options' => array('_none' => '- None -') + $options,
  170. );
  171. $form['alpha_settings']['structure'][$section][$zone]['regions'][$region]['alpha_region_' . $region . '_prefix'] = array(
  172. '#type' => 'select',
  173. '#title' => t('Prefix'),
  174. '#default_value' => $item['prefix'],
  175. '#options' => $spacing,
  176. );
  177. $form['alpha_settings']['structure'][$section][$zone]['regions'][$region]['alpha_region_' . $region . '_columns'] = array(
  178. '#type' => 'select',
  179. '#title' => t('Width'),
  180. '#default_value' => $item['columns'],
  181. '#options' => $columns,
  182. );
  183. $form['alpha_settings']['structure'][$section][$zone]['regions'][$region]['alpha_region_' . $region . '_suffix'] = array(
  184. '#type' => 'select',
  185. '#title' => t('Suffix'),
  186. '#default_value' => $item['suffix'],
  187. '#options' => $spacing,
  188. );
  189. $form['alpha_settings']['structure'][$section][$zone]['regions'][$region]['alpha_region_' . $region . '_weight'] = array(
  190. '#type' => 'weight',
  191. '#delta' => 50,
  192. '#title' => t('Weight'),
  193. '#default_value' => $item['weight'],
  194. );
  195. $form['alpha_settings']['structure'][$section][$zone]['regions'][$region]['alpha_region_' . $region . '_position'] = array(
  196. '#type' => 'weight',
  197. '#delta' => 50,
  198. '#title' => t('Position'),
  199. '#default_value' => $item['position'],
  200. '#states' => array(
  201. 'visible' => array(
  202. ':input[name="alpha_zone_' . $zone . '_order"]' => array('checked' => TRUE),
  203. ),
  204. ),
  205. );
  206. $form['alpha_settings']['structure'][$section][$zone]['regions'][$region]['alpha_region_' . $region . '_css'] = array(
  207. '#type' => 'textfield',
  208. '#title' => t('Additional region classes'),
  209. '#size' => 50,
  210. '#default_value' => $item['wrapper_css'],
  211. );
  212. }
  213. }