t('Views'), '#description' => t('Set this context when displaying the page of one of these views.'), '#options' => _context_ui_contrib_get_views(), '#type' => 'checkboxes', '#context_ui' => 'setter', ); } // Nodequeue if (module_exists('nodequeue')) { $result = db_query("SELECT qid, title FROM {nodequeue_queue}"); $options = array(); while ($nq = db_fetch_object($result)) { $options[$nq->qid] = $nq->title; } $items['nodequeue'] = array( '#title' => t('Nodequeue'), '#description' => t('Set this context when a node in the selected nodequeue(s) is viewed.'), '#options' => $options, '#type' => 'checkboxes', '#context_ui' => 'setter', ); } // Outline if (module_exists('outline')) { $result = db_query("SELECT volume_id, title FROM {outline_volume}"); $options = array(); while ($vol = db_fetch_object($result)) { $options[$vol->volume_id] = $vol->title; } $items['outline'] = array( '#title' => t('Outline'), '#description' => t('Set this context when a node in the selected volumes(s) is viewed.'), '#options' => $options, '#type' => 'checkboxes', '#context_ui' => 'setter', ); } // CSS Injector if (module_exists('css_injector')) { $items['css_injector'] = array( '#title' => t('CSS injector'), '#description' => t('Inject the selected css when this context is set.'), '#options' => _context_ui_contrib_get_css_injector(), '#type' => 'checkboxes', '#context_ui' => 'getter', ); } return $items; } /** * Implementation of hook_context_getter(). */ function context_ui_contrib_context_getter($context) { if (module_exists('css_injector')) { _context_ui_contrib_css_injector_response($context); } } /** * Implementation of hook_nodeapi(). */ function context_ui_contrib_nodeapi(&$node, $op, $teaser, $page) { if ($op == 'view' && $page && arg(0) == 'node') { // Implementation of context_ui_set for nodequeue. if (module_exists('nodequeue')) { $result = db_query("SELECT qid FROM {nodequeue_nodes} WHERE nid = %d", $node->nid); while($qid = db_fetch_object($result)) { context_ui_set('nodequeue', $qid->qid); } } // Implementation of context_ui_set for outline if (module_exists('outline') && $vol = $node->volume_id) { context_ui_set('outline', $vol); } } } /** * Implementation of hook_views_pre_query(). */ function context_ui_contrib_views_pre_view($display_id, $args) { if ($display_id->type == 'Normal') { context_ui_set('views', $display_id->name); } } /** * Helper function to generate a list of database and module provided views. */ function _context_ui_contrib_get_views() { $enabled_views = array(); $views = views_get_all_views(); foreach ($views as $view) { if (!isset($views[$view->name]->disabled) || !$views[$view->name]->disabled) { $enabled_views[$view->name] = $view->name; } } ksort($enabled_views); return $enabled_views; } /** * Helper function to generate a list of css_injector files. */ function _context_ui_contrib_get_css_injector() { $list = array(); foreach (_css_injector_load_rule() as $css_rule) { $list[$css_rule['crid']] = $css_rule['title']; } ksort($list); return $list; } /** * Getter response function for css injector */ function _context_ui_contrib_css_injector_response($context) { if (is_array($context->css_injector)) { foreach ($context->css_injector as $crid) { if ($css_rule = _css_injector_load_rule($crid)) { drupal_add_css(file_create_path($css_rule['file_path']), 'module', $css_rule['media'], $css_rule['preprocess']); } } } else { return; } }