skinr.skinr.inc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * @file
  4. * Implements page and region level rules, and adds default groups.
  5. */
  6. /**
  7. * Implements hook_skinr_api_VERSION().
  8. */
  9. function skinr_skinr_api_2() {
  10. }
  11. /**
  12. * Implements hook_skinr_group_info().
  13. */
  14. function skinr_skinr_group_info() {
  15. $groups['general'] = array(
  16. 'title' => t('General'),
  17. 'description' => t('Styles for content such as lists, buttons, margins, padding, etc.'),
  18. 'weight' => -10,
  19. );
  20. $groups['box'] = array(
  21. 'title' => t('Box styles'),
  22. 'description' => t('Presentational styles for the container.'),
  23. );
  24. $groups['typography'] = array(
  25. 'title' => t('Typography'),
  26. 'description' => t('Fonts, styles, sizes and other typography related skins.'),
  27. );
  28. $groups['layout'] = array(
  29. 'title' => t('Layout'),
  30. 'description' => t('Grid, layout and other structural related skins.'),
  31. );
  32. return $groups;
  33. }
  34. /**
  35. * Implementation of hook_skinr_config_info().
  36. */
  37. function skinr_skinr_config_info() {
  38. return array('rules');
  39. }
  40. /**
  41. * Implements hook_skinr_theme_hooks().
  42. */
  43. function skinr_skinr_theme_hooks($module, $element) {
  44. $theme_hooks = array();
  45. if ($module == 'rules') {
  46. $rule = skinr_rule_load($element);
  47. $hooks = explode('__', $rule->rule_type);
  48. while (count($hooks)) {
  49. $theme_hooks[] = implode('__', $hooks);
  50. array_pop($hooks);
  51. }
  52. }
  53. return $theme_hooks;
  54. }
  55. /**
  56. * Implements hook_skinr_elements().
  57. */
  58. function skinr_skinr_elements($variables, $hook) {
  59. $elements = array();
  60. if ($hook == 'html' || $hook == 'region') {
  61. $elements['rules'] = array();
  62. $rule_type = 'page';
  63. if ($hook == 'region') {
  64. $rule_type = 'region__' . $variables['region'];
  65. }
  66. $rules = skinr_rule_load_multiple(array(), array('rule_type' => $rule_type));
  67. foreach ($rules as $rule) {
  68. if (skinr_rule_is_visible($rule->rid)) {
  69. $elements['rules'][] = $rule->rid;
  70. }
  71. }
  72. }
  73. return $elements;
  74. }