context_reaction_block.theme.inc

Go to the documentation of this file.
00001 <?php
00002 
00003 /**
00004  * Block form.
00005  */
00006 function theme_context_block_form($vars) {
00007   $row = array(
00008     array('data' => drupal_render($vars['form']['blocks']), 'class' => array('blocks')),
00009     array('data' => drupal_render($vars['form']['selector']) . drupal_render($vars['form']['block']['help']), 'class' => array('selector')),
00010   );
00011 
00012   $output = drupal_render_children($vars['form']);
00013 
00014   $table = array(
00015     'rows' => array($row),
00016     'attributes' => array('id' => 'context-blockform'),
00017   );
00018   $output .= theme('table', $table);
00019   return $output;
00020 }
00021 
00022 /**
00023  * Generates the AJAX enabled block administration portion of the context_ui admin form.
00024  */
00025 function theme_context_block_regions_form($vars) {
00026   $form = $vars['form'];
00027 
00028   // Add draggable weights
00029   drupal_add_js('misc/tableheader.js');
00030   drupal_add_js(drupal_get_path('module', 'context') . '/plugins/context_reaction_block.js');
00031   drupal_add_css(drupal_get_path('module', 'context') . '/plugins/context_reaction_block.css');
00032 
00033   $output = '';
00034 
00035   foreach (element_children($form) as $region) {
00036     $attr = array(
00037       'id' => "context-blockform-region-{$region}",
00038       'class' => array("context-blockform-region"),
00039     );
00040     drupal_add_tabledrag($attr['id'], 'order', 'sibling', 'tabledrag-hide', NULL, NULL, FALSE);
00041     $rows = array();
00042     foreach (element_children($form[$region]) as $id) {
00043       $form[$region][$id]['weight']['#attributes'] = array('class' => array('tabledrag-hide'));
00044       $label = $form[$region][$id]['#value'];
00045       $remove = l(t('X'), $_GET['q'], array('fragment' => 'remove', 'attributes' => array('class' => array('remove'))));
00046       $rows[] = array(
00047         'data' => array($label, drupal_render($form[$region][$id]['weight']), $remove),
00048         'class' => array('draggable'),
00049         'id' => $id,
00050       );
00051     }
00052     $output .= "<div class='label context-blockform-regionlabel-{$region}'>";
00053     $output .= l(t('+') . ' ' . t('Add'), $_GET['q'], array('fragment' => $region, 'attributes' => array('class' => array('add-block'))));
00054     $output .= $form[$region]['#title'];
00055     $output .= "</div>";
00056     $output .= theme('table', array('rows' => $rows, 'attributes' => $attr));
00057   }
00058   return $output;
00059 }
00060 
00061 /**
00062  * Use placeholder content for script tags that need to be replaced.
00063  */
00064 function theme_context_block_script_placeholder($text = '') {
00065   $message = t('Please reload the page to view this block.');
00066   return "<div class='script-placeholder'><strong>{$text}</strong><div class='description'>{$message}</div></div>";
00067 }
00068 
00069 /**
00070  * Preprocessor for theme('context_block_browser').
00071  */
00072 function template_preprocess_context_block_browser(&$vars) {
00073   $categories = array(
00074     '#type' => 'select',
00075     '#options' => array(0 => '<' . t('All Categories') . '>'),
00076     '#attributes' => array('class' => array('context-block-browser-categories')),
00077     '#value' => 0,
00078     '#size' => 1,
00079     '#id' => '',
00080     '#name' => '',
00081     '#parents' => array(''),
00082     '#multiple' => FALSE,
00083     '#required' => FALSE,
00084   );
00085   $blocks = array();
00086   // Group blocks by module.
00087   foreach ($vars['blocks'] as $block) {
00088     $group = isset($block->context_group) ? $block->context_group : $block->module;
00089     // Normalize the $group, borrowed from drupal_html_id
00090     $group = strtr(drupal_strtolower($group), array(' ' => '-', '_' => '-', '[' => '-', ']' => ''));
00091     if (!isset($categories[$group])) {
00092       $info = system_get_info('module', $block->module);
00093       $title = isset($block->context_group) ? $block->context_group : (!empty($info['name']) ? $info['name'] : $block->module);
00094       $categories['#options'][$group] = $title;
00095     }
00096     $blocks[$group][$block->bid] = $block; // Don't call theme('context_block_browser_item') to allow others to alter.
00097   }
00098 
00099   //add help text to tell people how to use the block browser
00100   $help_text = array(
00101     '#prefix' => '<div class="context_ui-help-text">',
00102     '#markup' => t('To add a block to the current region, simply click on the block.  You may use the category filter to filter by
00103       block type or the search filter to find the block that you wish to add.'),
00104     '#suffix' => '</div>',
00105   );
00106 
00107   $filter_label = array(
00108     '#prefix' => '<div class="filter-label">',
00109     '#markup' => t('Search Filter'),
00110     '#suffix' => '</div>',
00111   );
00112 
00113   $vars['categories'] = $categories; // Don't call theme('select') here to allow further preprocesses to alter the element.
00114   $vars['blocks'] = $blocks;
00115   $vars['help_text'] = $help_text;
00116   $vars['filter_label'] = $filter_label;
00117 }
00118 
00119 /**
00120  * Preprocessor for theme('context_block_browser_item').
00121  */
00122 function template_preprocess_context_block_browser_item(&$vars) {
00123   static $added = array();
00124   $vars['bid'] = $vars['block']->bid;
00125   $vars['info'] = check_plain($vars['block']->info);
00126   if (empty($added[$vars['bid']])) {
00127     drupal_add_js(array('contextBlockEditor' => array('block_tokens' => array($vars['bid'] => drupal_get_token($vars['bid'])))), 'setting');
00128     $added[$vars['bid']] = TRUE;
00129   }
00130 }

Generated on Wed Jun 19 02:24:09 2013 for Context by  doxygen 1.4.7