Пример #1
0
/**
 * Lets modules know when the default environment is changed.
 *
 * @param string $env_id
 *   The machine name of the environment.
 * @param string $old_env_id
 *   The old machine name of the environment.
 */
function hook_apachesolr_default_environment($env_id, $old_env_id)
{
    $page = apachesolr_search_page_load('core_search');
    if ($page && $page['env_id'] != $env_id) {
        $page['env_id'] = $env_id;
        apachesolr_search_page_save($page);
    }
}
Пример #2
0
/**
 * Implementing hook_preprocess_html()
 */
function jjamerson_lc_preprocess_html(&$variables)
{
    /* Override head title on unique site sections: */
    global $_bss_section_information;
    $site_section = false;
    if (isset($_bss_section_information['tid'])) {
        $site_section_tid = $_bss_section_information['tid'];
        $site_section = taxonomy_term_load($site_section_tid);
    }
    if (isset($node['language'])) {
        $lang = $node['language'];
    } else {
        $lang = 'und';
    }
    if ($site_section && isset($site_section->field_base_url['und'][0]['value'])) {
        // Check to see if this is the homepage of the site section. If so, just use the site section name.
        // If not, use the current page title + the site section name.
        if (drupal_get_path_alias() === $site_section->field_base_url['und'][0]['value']) {
            $variables['head_title'] = $site_section->name;
            if (empty($site_section->field_standalone['und'][0]['value'])) {
                $variables['head_title'] .= ' | Berklee College of Music';
            }
        } else {
            if (isset($site_section->field_standalone['und'][0]['value']) && $site_section->field_standalone['und'][0]['value']) {
                $variables['head_title'] = $variables['head_title_array']['title'] . ' | ' . $site_section->name;
            }
        }
    }
    /* Override title on front page, because for some reason a pipe is being inserted into it */
    if ($variables['is_front']) {
        $variables['head_title'] = 'Berklee College of Music';
    }
    /* Add classes related to workbench moderation */
    if (isset($variables['page']['content']['system_main']['nodes'])) {
        $nodes = $variables['page']['content']['system_main']['nodes'];
        if (count($nodes) === 2) {
            $not_really_the_node = current($nodes);
            $node = $not_really_the_node['#node'];
            if (isset($node->workbench_moderation['published']) && $node->workbench_moderation['published']->vid === $node->vid) {
                $workbench_moderation = $node->workbench_moderation['published'];
            } else {
                if (isset($node->workbench_moderation)) {
                    $workbench_moderation = $node->workbench_moderation['current'];
                }
            }
            if (isset($workbench_moderation) && $workbench_moderation->state) {
                $variables['classes_array'][] = 'workbench-state-' . $workbench_moderation->state;
                if ($workbench_moderation->published) {
                    $variables['classes_array'][] = 'workbench-published';
                } else {
                    $variables['classes_array'][] = 'workbench-unpublished';
                }
            }
        }
    }
    /* Add tags on node as classes: */
    if (isset($variables['page']['content']['system_main']['nodes'])) {
        $nodes = $variables['page']['content']['system_main']['nodes'];
        if (count($nodes) === 2) {
            $not_really_the_node = current($nodes);
            if (isset($not_really_the_node['#node'])) {
                $node = $not_really_the_node['#node'];
                if (isset($node->field_isotope_tags[$lang]) && count($node->field_isotope_tags[$lang])) {
                    $tids = array();
                    foreach ($node->field_isotope_tags[$lang] as $tid) {
                        $tids[] = $tid['tid'];
                    }
                    try {
                        $tags = taxonomy_term_load_multiple($tids);
                        foreach ($tags as $tag) {
                            $tag_name = strtolower($tag->name);
                            $tag_name = preg_replace('/[^a-z0-9 -]+/', '', $tag_name);
                            $tag_name = preg_replace('/\\s/', '-', $tag_name);
                            $tag_name = 'tagged-' . $tag_name;
                            $variables['classes_array'][] = " {$tag_name}";
                        }
                    } catch (Exception $e) {
                        // do nothing
                    }
                }
            }
        }
    }
    if (isset($site_section->field_base_url) && isset($site_section->field_banner_image_large[$lang][0]['uri']) && $site_section->description) {
        $site_section_home = $site_section->field_base_url[$lang][0]['value'];
        if (drupal_get_path_alias() == $site_section_home) {
            $variables['classes_array'][] = "lead-page";
        }
    }
    /* Add a class to landing pages if the call-to-action field is empty: */
    if (isset($node) && $node->type === 'landing' && count($node->field_call_to_action) === 0) {
        $variables['classes_array'][] = 'empty-call-to-action';
    }
    /* Add a class to distinguish the Directory's starting page: */
    if (function_exists('apachesolr_search_page_load')) {
        $directory_search = apachesolr_search_page_load('directory');
        // Get the path from the page info
        $directory_path = $directory_search['search_path'];
        if ($directory_path === current_path()) {
            $variables['classes_array'][] = 'directory-front';
        }
    }
    /* Add the site section TID */
    global $_bss_section_information;
    if ($_bss_section_information) {
        $variables['classes_array'][] = 'section-' . $_bss_section_information['tid'];
    }
    if (isset($_GET['content-only'])) {
        $variables['classes_array'][] = 'content-only-display';
    }
    if (isset($_GET['render-only'])) {
        $variables['classes_array'][] = 'render-only render-only-' . $_GET['render-only'];
        unset($variables['classes_array']['logged-in']);
    }
    if (isset($_GET['iframed'])) {
        $variables['classes_array'][] = 'iframed';
        $target = array('#type' => 'markup', '#markup' => '<base target="_blank" />');
        drupal_add_html_head($target, 'jjamerson_lc-iframe-target');
    }
    /* Check for user testing variables and set a timestamp array variable  */
    $user_testing = false;
    if (isset($_GET['user-testing'])) {
        $user_testing = true;
        $_SESSION['berklee-user-testing']['last-used'] = time();
    } elseif (isset($_SESSION['berklee-user-testing']['last-used'])) {
        $user_testing_seconds = 1200;
        // 20 minutes
        if (time() - $_SESSION['berklee-user-testing']['last-used'] > $user_testing_seconds) {
            unset($_SESSION['berklee-user-testing']);
        }
    }
    if (isset($_GET['htln']) || isset($_GET['hide-top-left-nav']) || isset($_SESSION['berklee-user-testing']['hide-top-left-nav'])) {
        $variables['classes_array'][] = 'hide-top-left-nav';
        if ($user_testing) {
            $_SESSION['berklee-user-testing']['hide-top-left-nav'] = true;
        }
    }
    if (isset($_GET['hct']) || isset($_GET['hide-campus-tools']) || isset($_SESSION['berklee-user-testing']['hide-campus-tools'])) {
        $variables['classes_array'][] = 'hide-campus-tools';
        if ($user_testing) {
            $_SESSION['berklee-user-testing']['hide-campus-tools'] = true;
        }
    }
    if (isset($_GET['hs']) || isset($_GET['hide-search']) || isset($_SESSION['berklee-user-testing']['hide-search'])) {
        $variables['classes_array'][] = 'hide-search';
        if ($user_testing) {
            $_SESSION['berklee-user-testing']['hide-search'] = true;
        }
    }
    if (isset($_GET['hli']) || isset($_GET['hide-login']) || isset($_SESSION['berklee-user-testing']['hide-login'])) {
        $variables['classes_array'][] = 'hide-login';
        if ($user_testing) {
            $_SESSION['berklee-user-testing']['hide-login'] = true;
        }
    }
    if (isset($_GET['hap']) || isset($_GET['hide-apply']) || isset($_SESSION['berklee-user-testing']['hide-apply'])) {
        $variables['classes_array'][] = 'hide-apply';
        if ($user_testing) {
            $_SESSION['berklee-user-testing']['hide-apply'] = true;
        }
    }
}
Пример #3
0
 /**
  * Implements Drupal_SolrDevel_Adapter::analyzeQuery().
  */
 public function analyzeQuery($keys, $page_id, $entity_id, $entity_type)
 {
     $search_page = apachesolr_search_page_load($page_id);
     $conditions = apachesolr_search_conditions_default($search_page);
     $solr = apachesolr_get_solr($search_page->env_id);
     // Sets default parameters.
     $params = array('q' => $keys, 'fq' => isset($conditions['fq']) ? $conditions['fq'] : array(), 'rows' => 1);
     $params['fq'][] = 'id:' . apachesolr_document_id($entity_id, $entity_type);
     $results = apachesolr_search_run('apachesolr', $params, '', '', 0, $solr);
     return isset($results[0]) ? $results[0] : array();
 }