/** * Returns a list of blocks. * * Uses Drupal block interface and appends any blocks * assigned by the Context module. * Taken from Fusion Core. */ function _bootstrap_barrio_block_list($region) { $drupal_list = array(); if (module_exists('block')) { $drupal_list = block_list($region); } if (module_exists('context') && ($context = context_get_plugin('reaction', 'block'))) { $context_list = $context->block_list($region); $drupal_list = array_merge($context_list, $drupal_list); } return $drupal_list; }
/** * Alter/add a condition to a node-related event. * * Allows modules to add one or more context condition plugin executions to a * node view, form, etc. * * @param $node * The node object. * @param $op * The node-related operation: 'node', 'form', 'comment'. */ function hook_context_node_condition_alter(&$node, $op) { if ($plugin = context_get_plugin('condition', 'bar')) { $plugin->execute($node, $op); } }
/** * Modifies a context object from submitted form values. * * @param $context * The context object to modify. * @param $form * A form array with submitted values * @param $submit * A flag indicating if we are building a context on submit. If on * submit, it will clear out conditions/reactions that are empty. * * @return * A context object */ function context_ui_form_process($context, $form, $submit = TRUE) { $context->name = isset($form['name']) ? $form['name'] : $context->name; $context->description = isset($form['description']) ? $form['description'] : NULL; $context->tag = isset($form['tag']) ? $form['tag'] : NULL; $context->condition_mode = isset($form['condition_mode']) ? $form['condition_mode'] : NULL; $context->conditions = array(); $context->reactions = array(); if (!empty($form['conditions'])) { $enabled = explode(',', $form['conditions']['state']); foreach ($form['conditions']['plugins'] as $condition => $values) { if (in_array($condition, $enabled, TRUE) && ($plugin = context_get_plugin('condition', $condition))) { if (isset($values['values'])) { $context->conditions[$condition]['values'] = $plugin->condition_form_submit($values['values']); } if (isset($values['options'])) { $context->conditions[$condition]['options'] = $plugin->options_form_submit($values['options']); } if ($submit && context_empty($context->conditions[$condition]['values'])) { unset($context->conditions[$condition]); } } } } if (!empty($form['reactions'])) { $enabled = explode(',', $form['reactions']['state']); foreach ($form['reactions']['plugins'] as $reaction => $values) { if (in_array($reaction, $enabled, TRUE) && ($plugin = context_get_plugin('reaction', $reaction))) { if (isset($values)) { $context->reactions[$reaction] = $plugin->options_form_submit($values); } if ($submit && context_empty($context->reactions[$reaction])) { unset($context->reactions[$reaction]); } } } } return $context; }
function _lullacog_process_menus(&$vars) { // Add the footer links if (function_exists('context_get_plugin')) { $plugin = context_get_plugin('reaction', 'menu'); $vars['primary_links_sub'] = $plugin->menu_navigation_links(variable_get('menu_primary_links_source', 'primary-links'), 1); $vars['secondary_links_sub'] = $plugin->menu_navigation_links(variable_get('menu_secondary_links_source', 'secondary-links'), 1); $vars['footer_links'] = $plugin->menu_navigation_links('footer-links'); } else { $vars['primary_links_sub'] = menu_navigation_links(variable_get('menu_primary_links_source', 'primary-links'), 1); $vars['secondary_links_sub'] = menu_navigation_links(variable_get('menu_secondary_links_source', 'secondary-links'), 1); $vars['footer_links'] = menu_navigation_links('footer-links'); } $menus = array('primary_links', 'primary_links_sub', 'secondary_links', 'secondary_links_sub', 'footer_links'); foreach ($menus as $menu_name) { if (isset($vars[$menu_name])) { $vars[$menu_name . '_html'] = theme('links', $vars[$menu_name]); } } // Also set up a full tree menu for the footer links. $vars['footer_links_tree'] = menu_tree('footer-links'); }
/** * Implements hook_preprocess_node(). */ function cu_omega_preprocess_node(&$vars) { // Custom display templates will be called node--[type]--[viewmode].tpl.php $vars['theme_hook_suggestions'][] = 'node__' . $vars['type'] . '__' . $vars['view_mode']; // Making comments appear at the bottom of $content $vars['content']['comments']['#weight'] = 1000; if (module_exists('context') && ($plugin = context_get_plugin('reaction', 'block'))) { if ($context_content_sidebar_left_blocks = $plugin->block_get_blocks_by_region('content_sidebar_left')) { $vars['content_sidebar_left'] = $context_content_sidebar_left_blocks; $vars['content_sidebar_left']['#theme_wrappers'] = array('region'); $vars['content_sidebar_left']['#region'] = 'content_sidebar_left'; } if ($context_content_sidebar_right_blocks = $plugin->block_get_blocks_by_region('content_sidebar_right')) { $vars['content_sidebar_right'] = $context_content_sidebar_right_blocks; $vars['content_sidebar_right']['#theme_wrappers'] = array('region'); $vars['content_sidebar_right']['#region'] = 'content_sidebar_right'; } if ($context_content_bottom_blocks = $plugin->block_get_blocks_by_region('content_bottom')) { $vars['content_bottom'] = $context_content_bottom_blocks; $vars['content_bottom']['#theme_wrappers'] = array('region'); $vars['content_bottom']['#region'] = 'content_bottom'; $vars['classes_array'][] = 'content-bottom'; } } if ($content_sidebar_left_blocks = block_get_blocks_by_region('content_sidebar_left')) { $vars['content_sidebar_left'] = $content_sidebar_left_blocks; $vars['content_sidebar_left']['#theme_wrappers'] = array('region'); $vars['content_sidebar_left']['#region'] = 'content_sidebar_left'; } if ($content_sidebar_right_blocks = block_get_blocks_by_region('content_sidebar_right')) { $vars['content_sidebar_right'] = $content_sidebar_right_blocks; $vars['content_sidebar_right']['#theme_wrappers'] = array('region'); $vars['content_sidebar_right']['#region'] = 'content_sidebar_right'; } if ($context_content_bottom_blocks = block_get_blocks_by_region('content_bottom')) { $vars['content_bottom'] = $context_content_bottom_blocks; $vars['content_bottom']['#theme_wrappers'] = array('region'); $vars['content_bottom']['#region'] = 'content_bottom'; $vars['classes_array'][] = 'content-bottom'; } if (!empty($vars['content_sidebar_left']) && !empty($vars['content_sidebar_right'])) { $vars['content_sidebar_left']['#region'] = 'content_sidebars'; $vars['content_sidebar_right']['#region'] = 'content_sidebars'; } switch ($vars['type']) { case 'slider': unset($vars['content_sidebar_left']); unset($vars['content_sidebar_right']); break; case 'file': unset($vars['content_sidebar_left']); unset($vars['content_sidebar_right']); break; case 'video': unset($vars['content_sidebar_left']); unset($vars['content_sidebar_right']); break; case 'person': unset($vars['content_sidebar_left']); unset($vars['content_sidebar_right']); break; case 'page': unset($vars['content']['links']); break; } }
function open_framework_is_in_nav_menu($element) { // #theme holds one or more suggestions for theming function names for the link // simplify things by casting into an array $link_theming_functions = isset($element['#theme']) ? (array) $element['#theme'] : array(); // Avoid calculating this more than once $nav_theming_functions =& drupal_static(__FUNCTION__); // if not done yet, calculate the names of the theming function for all the blocks // in the navigation region if (!isset($nav_theming_functions)) { // get all blocks in the navigation region $blocks = block_list('navigation'); // Blocks placed using the context module don't show up using Drupal's block_list // If context is enabled, see if it has placed any blocks in the navigation area // See: http://drupal.org/node/785350 $context_blocks = array(); if (module_exists('context')) { $reaction_block_plugin = context_get_plugin('reaction', 'block'); $context_blocks = $reaction_block_plugin->block_list('navigation'); } $blocks = array_merge($blocks, $context_blocks); // extract just their IDs (<module>_<delta>) $ids = array_keys($blocks); // translate the ids into function names for comparison purposes $nav_theming_functions = array_map('open_framework_block_id_to_function_name', $ids); } // if there is nothing in the navigation section, the main menu is added automatically, so // we watch for that. // 'menu_link__main_menu' is the theming function name for the main-menu if (empty($nav_theming_functions) && in_array('menu_link__main_menu', $link_theming_functions)) { return TRUE; } // Find out if any of the theming functions for the blocks are the same // as the theming functions for the link. $intersect = array_intersect($nav_theming_functions, $link_theming_functions); if (!empty($intersect)) { return TRUE; } else { return FALSE; } }
/** * Returns a list of blocks. * Uses Drupal block interface and appends any blocks assigned by the Context module. */ function webpro_core_block_list($region) { $drupal_list = array(); if (module_exists('context') && ($context = context_get_plugin('reaction', 'region'))) { // Region reaction might be disabling this region. If it // does, an empty array should be returned. $dummy_page = array($region => 1); $context->execute($dummy_page); if (!isset($dummy_page[$region])) { return array(); } } if (module_exists('block')) { $drupal_list = block_list($region); } if (module_exists('context') && ($context = context_get_plugin('reaction', 'block'))) { $context_list = $context->block_list($region); $drupal_list = array_merge($context_list, $drupal_list); } return $drupal_list; }
/** * Photolist implementation for the grid. */ function photolist_isotope_grid(array $vars) { // A config name specified in context will override whatever we have been // passed. $config_name = $vars['config']; if (module_exists('context')) { if ($plugin = context_get_plugin('reaction', 'isotope')) { $context_name = $plugin->execute(); if (!empty($context_name)) { $config_name = $context_name; } } } // Add the sorting options to the initial configuration. $additional_config = array('getSortData' => array()); foreach ($vars['items'] as $item) { $item['data'] = !empty($item['data']) ? $item['data'] : array(); foreach ($item['data'] as $key => $value) { $additional_config['getSortData'][$key] = '.' . $key; } } // Retrieve the desired configuration (plus sorting options). $config = views_isotope_get_config_json($config_name, $additional_config); // Make sure the instance name is unique per page load. $global_instances =& drupal_static(__FUNCTION__); $global_instances = isset($global_instances) ? $global_instances : array(); if (!empty($vars['instance']) && !in_array($vars['instance'], $global_instances)) { $instance_name = $vars['instance']; } else { for ($i = 0; $i >= 0; $i++) { if (!in_array($i, $global_instances)) { $instance_name = $i; // Break the infinite loop when successful. break; } } } $global_instances[] = $instance_name; $instance = 'isotope-instance-' . $instance_name; $items = array(array('data' => '', 'class' => array('isotope-grid-sizer')), array('data' => '', 'class' => array('isotope-gutter-sizer'))); foreach ($vars['items'] as $item) { $sorts = ''; $item['data'] = !empty($item['data']) ? $item['data'] : array(); foreach ($item['data'] as $key => $value) { if (!is_array($value)) { $value = array($value); } foreach ($value as $sort) { $sorts .= '<div class="sort-data ' . $key . '">' . views_isotope_sanitize($sort) . '</div>'; } $item['data'][$key] = views_isotope_sanitize($value); } $classes = array_values($item['data']); $classes[] = 'isotope-element'; $items[] = array('data' => $item['value'] . $sorts, 'class' => $classes); } $markup = ''; foreach ($items as $item) { if (!empty($item['data'])) { $markup .= '<div class="' . implode(' ', $item['class']) . '">' . $item['data'] . '</div>'; } } $return = array('#theme' => 'container', '#children' => $markup, '#attributes' => array('class' => 'isotope-container js-isotope', 'id' => $instance, 'data-isotope-options' => $config), '#attached' => array('js' => array(drupal_get_path('module', 'views_isotope') . '/views_isotope.js'), 'css' => array(drupal_get_path('module', 'views_isotope') . '/views_isotope.css'))); views_isotope_addjs($config_name); return drupal_render($return); }
function urbanmediaspace_blocks($region, $show_blocks = NULL) { if (module_exists("context")) { // Since Drupal 6 doesn't pass $show_blocks to theme_blocks, we manually call // theme('blocks', NULL, $show_blocks) so that this function can remember the // value on later calls. static $render_sidebars = TRUE; if (!is_null($show_blocks)) { $render_sidebars = $show_blocks; } // Is the Context module enabled? If so make sure that the blocks Context wants to display get displayed if ($region) { $output = ''; if (module_exists("context")) { // Get the Context plugin needed to get the blocks that needs to be displayed for this region $plugin = context_get_plugin('reaction', 'block'); // Let's get the blocks that should be displayed from Context. if (is_object($plugin)) { $output .= $plugin->execute($region); } } else { // If $renders_sidebars is FALSE, don't render any region whose name begins // with "sidebar_". if (($render_sidebars || strpos($region, 'sidebar_') !== 0) && ($list = block_list($region))) { foreach ($list as $key => $block) { // $key == module_delta $output .= theme('block', $block); } } // Add any content assigned to this region through drupal_set_content() calls. $output .= drupal_get_content($region); } $elements['#children'] = $output; $elements['#region'] = $region; return $output ? theme('region', $elements) : ''; } } else { return zen_blocks($region, $show_blocks); } }
/** * Returns a list of blocks. * Uses Drupal block interface and appends any blocks assigned by the Context module. */ function fusion_core_block_list($region) { $drupal_list = block_list($region); if (module_exists('context')) { $context = context_get_plugin('reaction', 'block'); $context_list = $context->block_list($region); $drupal_list = array_merge($context_list, $drupal_list); } return $drupal_list; }