You are here

function skinr_panels_preprocess_page in Skinr 8.2

Same name and namespace in other branches
  1. 7.2 skinr_panels/skinr_panels.module \skinr_panels_preprocess_page()

Implements hook_preprocess_page().

File

skinr_panels/skinr_panels.module, line 139
Provides Skinr integration with Panels.

Code

function skinr_panels_preprocess_page(&$variables) {
  if (module_exists('skinr_context')) {
    if ($skins = skinr_panels_get_skin_options()) {
      $contexts = context_active_contexts();
      $search = array_keys($skins);
      $replace = array();
      foreach ($skins as $placeholder => $skin) {
        if (!empty($skin->gid) && ($group = skinr_context_group_load($skin->gid))) {

          // Remove skins for groups that arent in the right context.
          if (!isset($contexts['skinr_group__' . $skin->gid])) {
            $replace[] = '';
          }
          else {
            $classes_array = skinr_flatten_skins_array(array(
              $skin->skin => $skin->options,
            ));
            $replace[] = implode(' ', $classes_array);
          }
        }
      }
      $is_node = isset($variables['node']) && $variables['node']->type == 'panel' && module_exists('panels_node');
      $is_page = isset($variables['page']);
      if ($is_node) {

        // Panel node page.
        $panel =& $variables['page']['content']['system_main']['nodes'][$variables['node']->nid]['body']['#markup'];
      }
      elseif ($is_page) {

        // Panel page.
        $panel =& $variables['page']['content']['system_main']['content']['#markup'];
      }
      $panel = str_replace($search, $replace, $panel);
    }
  }
}