예제 #1
0
 /**
  * Build the code files.
  */
 function collectFiles(&$files)
 {
     $theme_registry = theme_get_registry();
     // Our theme base was set in our incoming component data.
     $theme_base = $this->base_component->component_data['theme_hook_bases'][$this->name];
     $theme_info = $theme_registry[$theme_base];
     //drush_print_r($this);
     //drush_print_r($theme_info);
     // Get the original TPL file we want to copy.
     // Due to how the theme registry works, this will be one of:
     //  - the original file from the module
     //  - an overridden tpl file in the current theme (eg, if you request
     //    node--article, and your theme has node.tpl, then you get that)
     //  - an overridden tpl file in a parent theme, same principle.
     $original_tpl_file = $theme_info['path'] . '/' . $theme_info['template'] . '.tpl.php';
     $tpl_code = file_get_contents($original_tpl_file);
     //print $tpl_code;
     $theme_path = path_to_theme();
     // Try a 'templates' folder inside it.
     if (file_exists($theme_path . '/templates')) {
         $file_path .= 'templates';
     } else {
         $file_path = '';
     }
     $files['info'] = array('path' => $file_path, 'filename' => $this->name . '.tpl.php', 'body' => array($tpl_code));
 }
 function edit_form_submit(&$form, &$form_state)
 {
     parent::edit_form_submit($form, $form_state);
     // Ensure that the Stack layout theme exists in the theme registry,
     // otherwise, rebuild it.
     $theme_hooks = theme_get_registry();
     if (!isset($theme_hooks['panels_frame_stack'])) {
         drupal_theme_rebuild();
     }
 }
예제 #3
0
 /**
  * Compute any messages which should be displayed beforeupgrade.
  *
  * Note: This function is called iteratively for each upcoming
  * revision to the database.
  *
  * @param $preUpgradeMessage
  * @param string $rev
  *   a version number, e.g. '4.3.alpha1', '4.3.beta3', '4.3.0'.
  * @param null $currentVer
  *
  * @return void|bool
  */
 public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL)
 {
     if ($rev == '4.3.beta3') {
         //CRM-12084
         //sql for checking orphaned contribution records
         $sql = "SELECT COUNT(ct.id) FROM civicrm_contribution ct LEFT JOIN civicrm_contact c ON ct.contact_id = c.id WHERE c.id IS NULL";
         $count = CRM_Core_DAO::singleValueQuery($sql, array(), TRUE, FALSE);
         if ($count > 0) {
             $error = ts("There is a data integrity issue with this CiviCRM database. It contains %1 contribution records which are linked to contact records that have been deleted. You will need to correct this manually before you can run the upgrade. Use the following MySQL query to identify the problem records: %2 These records will need to be deleted or linked to an existing contact record.", array(1 => $count, 2 => '<em>SELECT ct.* FROM civicrm_contribution ct LEFT JOIN civicrm_contact c ON ct.contact_id = c.id WHERE c.id IS NULL;</em>'));
             CRM_Core_Error::fatal($error);
             return FALSE;
         }
     }
     if ($rev == '4.3.beta4' && CRM_Utils_Constant::value('CIVICRM_UF', FALSE) == 'Drupal6') {
         // CRM-11823 - Make sure the D6 HTML HEAD technique will work on
         // upgrade pages ... except when we're in Drush.
         if (!function_exists('drush_main')) {
             theme('item_list', array());
             // force-load theme registry
             $theme_registry = theme_get_registry();
             if (!isset($theme_registry['page']['preprocess functions']) || FALSE === array_search('civicrm_preprocess_page_inject', $theme_registry['page']['preprocess functions'])) {
                 CRM_Core_Error::fatal('Please reset the Drupal cache (Administer => Site Configuration => Performance => Clear cached data))');
             }
         }
     }
     if ($rev == '4.3.6') {
         $constraintArray = array('civicrm_contact' => 'contact_id', 'civicrm_payment_processor' => 'payment_processor_id');
         if (version_compare('4.1alpha1', $currentVer) <= 0) {
             $constraintArray['civicrm_campaign'] = 'campaign_id';
         }
         if (version_compare('4.3alpha1', $currentVer) <= 0) {
             $constraintArray['civicrm_financial_type'] = 'financial_type_id';
         }
         foreach ($constraintArray as $key => $value) {
             $query = "SELECT contri_recur.id FROM civicrm_contribution_recur contri_recur LEFT JOIN {$key} ON contri_recur.{$value} = {$key}.id\nWHERE {$key}.id IS NULL";
             if ($value != 'contact_id') {
                 $query .= " AND contri_recur.{$value} IS NOT NULL ";
             }
             $dao = CRM_Core_DAO::executeQuery($query);
             if ($dao->N) {
                 $invalidDataMessage = '<strong>Oops, it looks like you have orphaned recurring contribution records in your database. Before this upgrade can complete they will need to be fixed or deleted. <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/Fixing+Orphaned+Contribution+Recur+Records" target="_blank">You can review steps to correct this situation on the documentation wiki.</a></strong>';
                 CRM_Core_Error::fatal($invalidDataMessage);
                 return FALSE;
             }
         }
     }
 }
예제 #4
0
파일: Theme.php 프로젝트: josoroma/lastime
 /**
  * Declares the subcomponents for this component.
  *
  * These are not necessarily child classes, just components this needs.
  *
  * @return
  *  An array of subcomponent types.
  */
 protected function requiredComponents()
 {
     $theme_data = $this->component_data;
     //drush_print_r($theme_data);
     drupal_theme_initialize();
     $theme_registry = theme_get_registry();
     $components = array();
     foreach ($this->component_data['themeables'] as $theme_hook_name) {
         $hook = $theme_hook_name;
         // Iteratively strip everything after the last '--' delimiter, until an
         // implementation is found.
         // (We use -- rather than __ because they're easier to type!)
         // TODO: allow both!
         while ($pos = strrpos($hook, '--')) {
             $hook = substr($hook, 0, $pos);
             if (isset($theme_registry[$hook])) {
                 break;
             }
         }
         if (!isset($theme_registry[$hook])) {
             // Bad name. Skip it.
             continue;
         }
         //drush_print_r($hook);
         if (isset($theme_registry[$hook]['template'])) {
             $components[$theme_hook_name] = 'themeTemplate';
             // Store data about this theme hook that we've found.
             $this->component_data['theme_hook_bases'][$theme_hook_name] = $hook;
         } else {
             // Fall through, as 'function' is optional in hook_theme().
             // TODO: we don't do theme functions yet -- need a system to add code
             // to existing files!
             //$components[$theme_hook_name] = 'theme_function';
         }
     }
     //drush_print_r($components);
     return $components;
 }
예제 #5
0
/**
 * Preprocess theme variables for templates.
 *
 * This hook allows modules to preprocess theme variables for theme templates.
 * It is called for all theme hooks implemented as templates, but not for theme
 * hooks implemented as functions. hook_preprocess_HOOK() can be used to
 * preprocess variables for a specific theme hook, whether implemented as a
 * template or function.
 *
 * For more detailed information, see _theme().
 *
 * @param $variables
 *   The variables array (modify in place).
 * @param $hook
 *   The name of the theme hook.
 */
function hook_preprocess(&$variables, $hook)
{
    static $hooks;
    // Add contextual links to the variables, if the user has permission.
    if (!\Drupal::currentUser()->hasPermission('access contextual links')) {
        return;
    }
    if (!isset($hooks)) {
        $hooks = theme_get_registry();
    }
    // Determine the primary theme function argument.
    if (isset($hooks[$hook]['variables'])) {
        $keys = array_keys($hooks[$hook]['variables']);
        $key = $keys[0];
    } else {
        $key = $hooks[$hook]['render element'];
    }
    if (isset($variables[$key])) {
        $element = $variables[$key];
    }
    if (isset($element) && is_array($element) && !empty($element['#contextual_links'])) {
        $variables['title_suffix']['contextual_links'] = contextual_links_view($element);
        if (!empty($variables['title_suffix']['contextual_links'])) {
            $variables['attributes']['class'][] = 'contextual-links-region';
        }
    }
}
예제 #6
0
/**
 * Override of theme_blocks().
 * Allows additional theme functions to be defined per region to
 * control block display on a per-region basis. Falls back to default
 * block region handling if no region-specific overrides are found.
 */
function tao_blocks($region)
{
    // Allow theme functions some additional control over regions.
    $registry = theme_get_registry();
    if (isset($registry['blocks_' . $region])) {
        return theme('blocks_' . $region);
    }
    return module_exists('context') && function_exists('context_blocks') ? context_blocks($region) : theme_blocks($region);
}
예제 #7
0
 public function themeRegistry()
 {
     $hooks = theme_get_registry();
     ksort($hooks);
     return array('#markup' => kprint_r($hooks, TRUE));
 }
예제 #8
0
/**
 * Override of theme_blocks().
 * Allows additional theme functions to be defined per region to
 * control block display on a per-region basis. Falls back to default
 * block region handling if no region-specific overrides are found.
 */
function tao_blocks($region)
{
    static $list;
    $output = '';
    $list = module_exists('context') && function_exists('context_block_list') ? context_block_list($region) : block_list($region);
    // Allow theme functions some additional control over regions
    if ($list) {
        $registry = theme_get_registry();
        if (isset($registry['blocks_' . $region])) {
            $output .= theme('blocks_' . $region, $list);
        } else {
            foreach ($list as $key => $block) {
                $output .= theme("block", $block);
            }
            $output .= drupal_get_content($region);
        }
        return $output;
    }
    return '';
}
예제 #9
0
 public function themeRegistry()
 {
     drupal_theme_initialize();
     $hooks = theme_get_registry();
     ksort($hooks);
     return kprint_r($hooks, TRUE);
 }
예제 #10
0
파일: template.php 프로젝트: eReolen/ding2
/**
 * Implements hook_preprocess_node().
 *
 * Override or insert variables into the node templates.
 */
function ddbasic_preprocess_node(&$variables, $hook)
{
    // Opening hours on library list. but not on the search page.
    $path = drupal_get_path_alias();
    if (!(strpos($path, 'search', 0) === 0)) {
        $hooks = theme_get_registry(FALSE);
        if (isset($hooks['opening_hours_week']) && $variables['type'] == 'ding_library') {
            $variables['opening_hours'] = theme('opening_hours_week', array('node' => $variables['node']));
        }
    }
    // Add ddbasic_byline to variables.
    $variables['ddbasic_byline'] = t('By: ');
    // Add event node specific ddbasic variables.
    if (isset($variables['content']['#bundle']) && $variables['content']['#bundle'] == 'ding_event') {
        // Add event location variables.
        if (!empty($variables['content']['field_ding_event_location'][0]['#address']['name_line'])) {
            $variables['ddbasic_event_location'] = $variables['content']['field_ding_event_location'][0]['#address']['name_line'] . '<br/>' . $variables['content']['field_ding_event_location'][0]['#address']['thoroughfare'] . ', ' . $variables['content']['field_ding_event_location'][0]['#address']['locality'];
        } else {
            // User OG group ref to link back to library.
            if (isset($variables['content']['og_group_ref'])) {
                $variables['ddbasic_event_location'] = $variables['content']['og_group_ref'];
            }
        }
        // Add event date to variables. A render array is created based on the date
        // format "date_only".
        $event_date_ra = field_view_field('node', $variables['node'], 'field_ding_event_date', array('label' => 'hidden', 'type' => 'date_default', 'settings' => array('format_type' => 'ding_date_only', 'fromto' => 'both')));
        $variables['ddbasic_event_date'] = $event_date_ra[0]['#markup'];
        // Add event time to variables. A render array is created based on the date
        // format "time_only".
        $event_time_ra = field_view_field('node', $variables['node'], 'field_ding_event_date', array('label' => 'hidden', 'type' => 'date_default', 'settings' => array('format_type' => 'ding_time_only', 'fromto' => 'both')));
        $variables['ddbasic_event_time'] = $event_time_ra[0]['#markup'];
    }
    // Add tpl suggestions for node view modes.
    if (isset($variables['view_mode'])) {
        $variables['theme_hook_suggestions'][] = 'node__view_mode__' . $variables['view_mode'];
    }
    // Add "read more" links to event, news and e-resource in search result view
    // mode.
    if ($variables['view_mode'] == 'search_result') {
        switch ($variables['node']->type) {
            case 'ding_event':
                $more_link = array('#theme' => 'link', '#text' => '<i class="icon-chevron-right"></i>', '#path' => 'node/' . $variables['nid'], '#options' => array('attributes' => array('title' => $variables['title']), 'html' => TRUE), '#prefix' => '<div class="event-arrow-link">', '#surfix' => '</div>', '#weight' => 6);
                $variables['content']['group_right_col_search']['more_link'] = $more_link;
                break;
            case 'ding_news':
                $more_link = array('#theme' => 'link', '#text' => t('Read more'), '#path' => 'node/' . $variables['nid'], '#options' => array('attributes' => array('title' => $variables['title']), 'html' => FALSE), '#prefix' => '<span class="news-link">', '#surfix' => '</span>', '#weight' => 6);
                $variables['content']['group_right_col_search']['more_link'] = $more_link;
                break;
            case 'ding_eresource':
                $more_link = array('#theme' => 'link', '#text' => t('Read more'), '#path' => 'node/' . $variables['nid'], '#options' => array('attributes' => array('title' => $variables['title']), 'html' => FALSE), '#prefix' => '<span class="eresource-link">', '#surfix' => '</span>', '#weight' => 6);
                $variables['content']['group_right_col_search']['more_link'] = $more_link;
                break;
        }
    }
    // For search result view mode move title into left col. group.
    if (isset($variables['content']['group_right_col_search'])) {
        $variables['content']['group_right_col_search']['title'] = array('#theme' => 'link', '#text' => decode_entities($variables['title']), '#path' => 'node/' . $variables['nid'], '#options' => array('attributes' => array('title' => $variables['title']), 'html' => FALSE), '#prefix' => '<h2>', '#suffix' => '</h2>');
    }
    // Add updated to variables.
    $variables['ddbasic_updated'] = t('!datetime', array('!datetime' => format_date($variables['node']->changed, $type = 'long', $format = '', $timezone = NULL, $langcode = NULL)));
    // Modified submitted variable.
    if ($variables['display_submitted']) {
        $variables['submitted'] = t('!datetime', array('!datetime' => format_date($variables['created'], $type = 'long', $format = '', $timezone = NULL, $langcode = NULL)));
    }
}
예제 #11
0
파일: template.php 프로젝트: kkaefer/Atrium
/**
 * Override of theme_blocks().
 * Allows additional theme functions to be defined per region to
 * control block display on a per-region basis. Falls back to default
 * block region handling if no region-specific overrides are found.
 */
function tao_blocks($region)
{
    // Bail if this region has been disabled through context.
    if (module_exists('context')) {
        $disabled_regions = context_active_values('theme_regiontoggle');
        if (!empty($disabled_regions) && in_array($region, $disabled_regions)) {
            return '';
        }
    }
    $output = '';
    $list = module_exists('context') && function_exists('context_block_list') ? context_block_list($region) : block_list($region);
    if (!empty($list)) {
        // Allow theme functions some additional control over regions
        $registry = theme_get_registry();
        if (isset($registry['blocks_' . $region])) {
            return theme('blocks_' . $region, $list);
        }
        // Otherwise, flow through regular stack
        foreach ($list as $key => $block) {
            $output .= theme("block", $block);
        }
    }
    return $output . drupal_get_content($region);
}