You are here

function sweaver_load_theme_selectors in Sweaver 7

Load all inclusive selectors defined in the theme .info

Return value

An array of selectors

1 call to sweaver_load_theme_selectors()
_sweaver_default_sweaver_selector in ./sweaver.registry.inc
Default selectors.

File

./sweaver.module, line 280
Sweaver functions.

Code

function sweaver_load_theme_selectors() {
  $selectors = array();
  if (variable_get('sweaver_selectors_source', FALSE)) {
    $theme_key = Sweaver::get_instance()
      ->get_theme_key();
    $theme_info = sweaver_get_theme_info($theme_key);
    if (isset($theme_info['sweaver']['selectors'])) {
      foreach ($theme_info['sweaver']['selectors'] as $selector_selector => $selector_description) {
        if (is_array($selector_description)) {
          if (!isset($selector_description['type'])) {
            $selector_description['type'] = 'add';
          }
          if ($selector_description['type'] == 'add') {

            // in this case this is a selector that needs to be added to others defined in regestry
            $selector = new stdClass();

            // Major properties
            $selector->api_version = 1;
            $selector->disabled = FALSE;
            $selector->export_type = 2;
            if (isset($selector_description['name'])) {
              $name = $selector_description['name'];
            }
            else {
              $name = str_replace(array(
                '',
                '.',
                '-',
              ), array(
                '',
              ), $selector_selector);
            }
            $selector->name = $name;
            $selector->description = isset($selector_description['description']) ? $selector_description['description'] : $selector->name;
            $selector->selector_selector = $selector_selector;
            if (isset($selector_description['selector_highlight'])) {
              if ($selector_description['selector_highlight']) {
                $selector->selector_highlight = TRUE;
              }
              else {
                $selector->selector_highlight = FALSE;
              }
            }
            else {
              $selector->selector_highlight = FALSE;
            }
            if (isset($selector_description['weight'])) {
              $selector->weight = $selector_description['weight'];
            }
            $selectors[$selector->name] = $selector;
          }
        }
      }
    }
  }
  return $selectors;
}