Example #1
1
 /**
  * {@inheritdoc}
  */
 function fieldFindCandidate(array $items)
 {
     $terms = array();
     foreach ($items as $item) {
         $terms[$item['tid']] = TRUE;
     }
     if (count($terms) > 1) {
         $walk = $terms;
         $visited = array();
         while (!empty($walk)) {
             $visited += $walk;
             foreach ($walk as $tid => $true) {
                 $parents = taxonomy_get_parents($tid);
                 unset($walk[$tid]);
                 foreach ($parents as $parent_tid => $parent) {
                     unset($terms[$parent_tid]);
                     if (!isset($visited[$parent_tid])) {
                         $walk[$parent_tid] = $parent;
                     }
                 }
             }
         }
     }
     // Return the path of the first found term, if any.
     foreach ($terms as $tid => $term_info) {
         $term = taxonomy_term_load($tid);
         if (!empty($term)) {
             $uri = entity_uri('taxonomy_term', $term);
             if (!empty($uri)) {
                 return $uri['path'];
             }
         }
     }
     return NULL;
 }
Example #2
1
 public static function term($type, $value, $name)
 {
     if (!self::checkFieldValue($value, 'tid')) {
         return null;
     }
     return new FieldValue($value, taxonomy_term_load($value['tid']), $type);
 }
Example #3
1
/**
 * Implemements hook_process_page
 * @param array $variables
 */
function fs_core_preprocess_page(&$variables)
{
    //Search form
    $search_form = drupal_get_form('search_form');
    $search_form_box = drupal_render($search_form);
    $variables['search_box'] = $search_form_box;
    if ($views_page = views_get_page_view()) {
        $variables['theme_hook_suggestions'][] = 'page__views__' . $views_page->name;
        $variables['theme_hook_suggestions'][] = 'page__views__' . $views_page->name . '_' . $views_page->current_display;
    }
    if (isset($variables['node']->type)) {
        $variables['theme_hook_suggestions'][] = 'page__' . $variables['node']->type;
    }
    // changes the links tree for the main menu, since by
    // default Drupal just provides first level ones
    $menu_tree = menu_tree_all_data('main-menu');
    $menu_tree = menu_tree_output($menu_tree);
    foreach ($menu_tree as $k => $v) {
        if (is_numeric($k) && count($v['#below'])) {
            $menu_tree[$k]['#below']['#theme_wrappers'][0] = 'menu_tree__submenu';
        }
    }
    $variables['main_menu'] = $menu_tree;
    if (arg(0) == 'taxonomy' && arg(1) == 'term') {
        $tid = (int) arg(2);
        $term = taxonomy_term_load($tid);
        if (is_object($term)) {
            $variables['theme_hook_suggestions'][] = 'page__taxonomy__' . $term->vocabulary_machine_name;
        }
    }
}
Example #4
1
/**
 * @file
 * This file is empty by default because the base theme chain (Alpha & Omega) provides
 * all the basic functionality. However, in case you wish to customize the output that Drupal
 * generates through Alpha & Omega this file is a good place to do so.
 * 
 * Alpha comes with a neat solution for keeping this file as clean as possible while the code
 * for your subtheme grows. Please read the README.txt in the /preprocess and /process subfolders
 * for more information on this topic.
 */
function songlap_preprocess_page(&$vars)
{
    if (drupal_is_front_page()) {
        $breadcrumb = array();
        $breadcrumb[] = t('Home');
        drupal_set_breadcrumb($breadcrumb);
    }
    if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_null(arg(3))) {
        $term = taxonomy_term_load(arg(2));
        $breadcrumb = '';
        $breadcrumb .= '<div class="breadcrumb">';
        $breadcrumb .= '<a href="' . $vars['front_page'] . '">' . t('Home') . '</a> ';
        $breadcrumb .= '» ' . $term->name;
        $breadcrumb .= '</div>';
        $vars['breadcrumb'] = $breadcrumb;
    }
    if ($_GET['q'] == 'projects') {
        $breadcrumb = '';
        $breadcrumb .= '<div class="breadcrumb">';
        $breadcrumb .= '<a href="' . $vars['front_page'] . '">' . t('Home') . '</a> ';
        $breadcrumb .= '» ' . t('Projects');
        $breadcrumb .= '</div>';
        $vars['breadcrumb'] = $breadcrumb;
    }
}
Example #5
1
function lt_preprocess_views_view(&$vars)
{
    if ($vars['view']->name == 'articles' && arg(0) == 'taxonomy') {
        $term = taxonomy_term_load(arg(2));
        $vars['header'] = '<h2 class="block-title">' . $term->name . '</h2>';
    }
}
/**
 * Implements hook_preprocess_html().
 * Meta tags https://drupal.org/node/1468582#comment-5698732
 */
function treetopstravel_preprocess_html(&$variables)
{
    $meta_charset = array('#tag' => 'meta', '#attributes' => array('charset' => 'utf-8'));
    drupal_add_html_head($meta_charset, 'meta_charset');
    $meta_x_ua_compatible = array('#tag' => 'meta', '#attributes' => array('http-equiv' => 'x-ua-compatible', 'content' => 'ie=edge, chrome=1'));
    drupal_add_html_head($meta_x_ua_compatible, 'meta_x_ua_compatible');
    $meta_mobile_optimized = array('#tag' => 'meta', '#attributes' => array('name' => 'MobileOptimized', 'content' => 'width'));
    drupal_add_html_head($meta_mobile_optimized, 'meta_mobile_optimized');
    $meta_handheld_friendly = array('#tag' => 'meta', '#attributes' => array('name' => 'HandheldFriendly', 'content' => 'true'));
    drupal_add_html_head($meta_handheld_friendly, 'meta_handheld_friendly');
    $meta_viewport = array('#tag' => 'meta', '#attributes' => array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1'));
    drupal_add_html_head($meta_viewport, 'meta_viewport');
    $meta_cleartype = array('#tag' => 'meta', '#attributes' => array('http-equiv' => 'cleartype', 'content' => 'on'));
    drupal_add_html_head($meta_cleartype, 'meta_cleartype');
    // Use html5shiv.
    if (theme_get_setting('html5shim')) {
        $element = array('element' => array('#tag' => 'script', '#value' => '', '#attributes' => array('type' => 'text/javascript', 'src' => file_create_url(drupal_get_path('theme', 'treetopstravel') . '/js/html5shiv-printshiv.js'))));
        $html5shim = array('#type' => 'markup', '#markup' => "<!--[if lt IE 9]>\n" . theme('html_tag', $element) . "<![endif]-->\n");
        drupal_add_html_head($html5shim, 'treetopstravel_html5shim');
    }
    // Use Respond.js.
    if (theme_get_setting('respond_js')) {
        drupal_add_js(drupal_get_path('theme', 'treetopstravel') . '/js/respond.min.js', array('group' => JS_LIBRARY, 'weight' => -100));
    }
    // Use normalize.css
    if (theme_get_setting('normalize_css')) {
        drupal_add_css(drupal_get_path('theme', 'treetopstravel') . '/css/normalize.css', array('group' => CSS_SYSTEM, 'weight' => -100));
    }
    if (arg(0) == 'taxonomy' && arg(1) == 'term') {
        $term = taxonomy_term_load(arg(2));
        $variables['classes_array'][] = 'vocabulary-' . strtolower($term->vocabulary_machine_name);
    }
    flexslider_add();
}
Example #7
0
function snowpilot_unit_prefs_get($entity, $type = 'user')
{
    $state_name = _helper_cleaner($entity, 'field_loaction', 'tid') != '' ? taxonomy_term_load(_helper_cleaner($entity, 'field_loaction', 'tid'))->name : '';
    $range_name = _helper_cleaner($entity, 'field_loaction', 'tid', 1) != '' ? taxonomy_term_load(_helper_cleaner($entity, 'field_loaction', 'tid', 1))->name : '';
    $unit_prefs = array('field_depth_0_from' => _helper_cleaner($entity, 'field_depth_0_from'), 'measureFrom' => _helper_cleaner($entity, 'field_depth_0_from'), 'field_depth_units' => _helper_cleaner($entity, 'field_depth_units'), 'depthUnits' => _helper_cleaner($entity, 'field_depth_units'), 'field_temp_units' => _helper_cleaner($entity, 'field_temp_units'), 'tempUnits' => _helper_cleaner($entity, 'field_temp_units'), 'field_coordinate_type' => _helper_cleaner($entity, 'field_coordinate_type'), 'coordType' => _helper_cleaner($entity, 'field_coordinate_type'), 'field_elevation_units' => _helper_cleaner($entity, 'field_elevation_units'), 'elvUnits' => _helper_cleaner($entity, 'field_elevation_units'), 'field_longitude_type' => _helper_cleaner($entity, 'field_longitude_type'), 'longType' => _helper_cleaner($entity, 'field_longitude_type'), 'field_latitude_type' => _helper_cleaner($entity, 'field_latitude_type'), 'latType' => _helper_cleaner($entity, 'field_latitude_type'), 'field_longitude' => _helper_cleaner($entity, 'field_longitude'), 'longitude' => _helper_cleaner($entity, 'field_longitude'), 'field_latitude' => _helper_cleaner($entity, 'field_latitude'), 'lat' => _helper_cleaner($entity, 'field_latitude'), 'field_utm_zone' => _helper_cleaner($entity, 'field_utm_zone'), 'zone' => _helper_cleaner($entity, 'field_utm_zone'), 'field_north' => _helper_cleaner($entity, 'field_north'), 'north' => _helper_cleaner($entity, 'field_north'), 'field_east' => _helper_cleaner($entity, 'field_east'), 'east' => _helper_cleaner($entity, 'field_east'), 'field_density_units' => _helper_cleaner($entity, 'field_density_units'), 'rhoUnits' => _helper_cleaner($entity, 'field_density_units'), 'field_fracture_category' => _helper_cleaner($entity, 'field_fracture_category'), 'fractureCat' => _helper_cleaner($entity, 'field_fracture_category'), 'field_hardness_scale' => _helper_cleaner($entity, 'field_hardness_scale'), 'hardnessScaling' => _helper_cleaner($entity, 'field_hardness_scale'), 'field_loaction_0' => _helper_cleaner($entity, 'field_loaction', 'tid'), 'state' => $state_name, 'field_loaction_1' => _helper_cleaner($entity, 'field_loaction', 'tid', '1'), 'range' => $range_name);
    //////
    /*
         These fields are not present in the 'node' variable that this function works on.
    */
    if ($type == 'user') {
        $unit_prefs['field_first_name'] = _helper_cleaner($entity, 'field_first_name');
        $unit_prefs['first'] = _helper_cleaner($entity, 'field_first_name');
        $unit_prefs['field_last_name'] = _helper_cleaner($entity, 'field_last_name');
        $unit_prefs['last'] = _helper_cleaner($entity, 'field_last_name');
        $unit_prefs['field_phone'] = _helper_cleaner($entity, 'field_phone');
        $unit_prefs['phone'] = _helper_cleaner($entity, 'field_phone');
        $unit_prefs['field_professional'] = _helper_cleaner($entity, 'field_professional');
        $unit_prefs['prof'] = _helper_cleaner($entity, 'field_professional');
        $unit_prefs['field_professional_affiliation'] = _helper_cleaner($entity, 'field_professional_affiliation', 'tid');
        $unit_prefs['affil'] = _helper_cleaner($entity, 'field_professional_affiliation', 'tid');
        // tid needs to be converted to name
        $unit_prefs['name'] = $entity->name;
        // hey, this is the same key name in both core drupal and avscience db!
        $unit_prefs['mail'] = $entity->mail;
        $unit_prefs['email'] = $entity->mail;
    }
    return $unit_prefs;
}
Example #8
0
function gavias_laikafood_format_comma_field($field_category, $node, $limit = NULL)
{
    if (module_exists('i18n_taxonomy')) {
        $language = i18n_language();
    }
    $category_arr = array();
    $category = '';
    $field = field_get_items('node', $node, $field_category);
    if (!empty($field)) {
        foreach ($field as $item) {
            $term = taxonomy_term_load($item['tid']);
            if ($term) {
                if (module_exists('i18n_taxonomy')) {
                    $term_name = i18n_taxonomy_term_name($term, $language->language);
                    // $term_desc = tagclouds_i18n_taxonomy_term_description($term, $language->language);
                } else {
                    $term_name = $term->name;
                    //$term_desc = $term->description;
                }
                $category_arr[] = l($term_name, 'taxonomy/term/' . $item['tid']);
            }
            if ($limit) {
                if (count($category_arr) == $limit) {
                    $category = implode(', ', $category_arr);
                    return $category;
                }
            }
        }
    }
    $category = implode(', ', $category_arr);
    return $category;
}
Example #9
0
function jollyness_preprocess_html(&$vars)
{
    //Process portfolio color
    if ($portfolio_category = taxonomy_vocabulary_machine_name_load('portfolio_category')) {
        $terms = taxonomy_get_tree($portfolio_category->vid);
        $less = new lessc();
        $css = '';
        $color = '';
        $class = '';
        foreach ($terms as $t) {
            $term = taxonomy_term_load($t->tid);
            $class = drupal_html_class($t->name);
            if (!empty($term->field_color)) {
                foreach ($term->field_color as $v) {
                    $color = $v[0]['value'];
                    break;
                }
            }
            if ($color) {
                $css .= ".dexp-masonry-filter,.dexp-portfolio-filter{.{$class} span:before{background-color: {$color} !important;}}";
                $css .= ".{$class} .portfolio-item-overlay{background-color: rgba(red({$color}), green({$color}), blue({$color}), 0.7) !important;}";
            }
        }
        $css = $less->compile($css);
        drupal_add_css($css, array('type' => 'inline'));
    }
}
Example #10
0
function suitcase_preprocess_region(&$vars)
{
    if ($vars['region'] == 'content' && arg(0) == 'node' && is_numeric(arg(1)) && arg(2) !== 'edit') {
        $node = node_load(arg(1));
        if ($node->type == 'people' && !empty($node->field_people_category)) {
            $vars['categories'] = array();
            foreach ($node->field_people_category[LANGUAGE_NONE] as $category) {
                $tax = taxonomy_term_load($category['tid']);
                array_push($vars['categories'], $tax->name);
            }
        }
    } else {
        if ($vars['region'] == 'branding') {
            // Prepare Logo
            $vars['suitcase_config_logo'] = FALSE;
            $logo = variable_get('suitcase_config_logo');
            $vars['site_name'] = variable_get('site_name');
            if ($logo) {
                $logo_url = file_create_url($logo['uri']);
                $vars['suitcase_config_logo'] = '<div class="logo-img"><a href="' . $GLOBALS['base_url'] . '" rel="home" title="' . $vars['site_name'] . '" class="active"><img src="' . $logo_url . '" alt="Go to ' . $vars['site_name'] . ' home" id="logo" /></a></div>';
            }
            $vars['dept_url'] = variable_get('dept_url', $default = NULL);
            $vars['show_isu_nameplate'] = variable_get('suitcase_config_isu_nameplate_display', 1);
        }
    }
}
/**
 * Alter the space_type or section_type options from other modules.
 *
 * @param array &$optionts
 *   An associative array keyed by the Taxonomy term id containing the option
 *   data returned by all module via hook_oa_core_space_type_options().
 * @param string $vocab_name
 *   The name of the vocabulary that this Taxonomy term comes from.
 */
function hook_oa_core_space_type_options_alter(&$options, $vocab_name)
{
    if ($vocab_name == 'space_type') {
        foreach ($options as $tid => &$option) {
            $term = taxonomy_term_load($tid);
            // Modify some data on the option data.
            $option['blah'] = 'arbitrary string';
        }
    }
}
Example #12
0
function localdm_get_other_link($autre_lien)
{
    $html_return = '<div class="sidefeature"><h3>Articles similaires:</h3><ul>';
    foreach ($autre_lien['und'] as $categorie) {
        $taxonomy = taxonomy_term_load($categorie['tid']);
        $html_return .= '<li><a href="' . $taxonomy->field_lien_page['und'][0]['value'] . '">' . $taxonomy->name . '</a></li>';
    }
    $html_return .= '</ul></div>';
    return $html_return;
}
Example #13
0
function suitcase_preprocess_region(&$vars)
{
    $vars['dept_url'] = variable_get('dept_url', $default = NULL);
    if ($vars['elements']['#region'] == 'content' && arg(0) == 'node' && is_numeric(arg(1)) && arg(2) !== 'edit') {
        $node = node_load(arg(1));
        if ($node->type == 'people' && !empty($node->field_people_category)) {
            $vars['categories'] = array();
            foreach ($node->field_people_category[LANGUAGE_NONE] as $category) {
                $tax = taxonomy_term_load($category['tid']);
                array_push($vars['categories'], $tax->name);
            }
        }
    }
}
function createGFCTournament($mynodeidparent)
{
    // /********************************************************************************
    // //CREATE A TOURNAMENT and Update Drupal Tournaments Node with Challonge tourney ID
    //
    // Include the Challonge API Class
    include '/opt/bitnami/apps/drupal/htdocs/includes/challonge.class.php';
    $c = new ChallongeAPI('XqrMnBPs15MvmX0izddB4zyIHKswRCoaIAyq4cTt');
    // get the GFC data needed to create tourney in Challonge
    //$mynodeidparent = 18; //test id for debugging
    $node = node_load($mynodeidparent);
    $wrapper = entity_metadata_wrapper('node', $node);
    // retreive param values needed from GFC data
    // get tourney name
    $tourney_name = $wrapper->field_tournament_name->value();
    // get type of play
    $term = taxonomy_term_load($wrapper->field_tournament_type->raw());
    $wrapper2 = entity_metadata_wrapper('taxonomy_term', $term);
    $tourney_type = $term->name;
    // get description
    $tourney_descriptions = $wrapper->field_tournament_description->value();
    //get url value
    $tourney_url = (string) uniqid();
    //str_replace ( ' ', '', $tourney_name ); // TODO: invent good url scheme
    // set paramater values for challonge from GFC values
    $params = array("tournament[name]" => $tourney_name, "tournament[tournament_type]" => $tourney_type, "tournament[url]" => $tourney_url, "tournament[description]" => $tourney_descriptions);
    // call to challonge to create tournament
    $tournament = $c->makeCall("tournaments", $params, "post");
    $tournament = $c->createTournament($params);
    //Save new URL value to GFC
    $wrapper->field_tournament_challonge_url->set($tourney_url);
    // save value
    $wrapper->save();
    // *************************
    // update GFC with returned tournament ID
    // *************************
    //****************NOTE: Need to reload by URL value from CHALLONGE due to bug
    $tournament_id = $tourney_url;
    $params = array("include_matches " => 0);
    $tournament = $c->makeCall("tournaments/{$tournament_id}", $params, "get");
    $tournament = $c->getTournament($tournament_id, $params);
    // retreive new tournament id and set to variable
    $challonge_id = (int) $tournament->id;
    // id set value
    $wrapper->field_tournament_challonge_id->set($challonge_id);
    //set url value
    // save value
    $wrapper->save();
    return $c->result;
}
/**
 * Get the path of the vsite which the vocab belong.
 *
 * @param $tid
 *  The term ID.
 *
 * @return
 *  The path of the vsite.
 */
function os_taxonomy_vsite_path($tid)
{
    $term = taxonomy_term_load($tid);
    $purls =& drupal_static(__FUNCTION__, array());
    if (in_array($term->vid, $purls)) {
        // We already found purl for this vocab. Return the purl from the static
        // cache.
        return $purls[$term->vid];
    }
    $relation = og_vocab_relation_get($term->vid);
    $vsite = vsite_get_vsite($relation->gid);
    $purls[$term->vid] = $vsite->group->purl;
    return $vsite->group->purl;
}
Example #16
0
/**
 * @file
 * template.php
 */
function faces_preprocess_page(&$variables)
{
    if (!empty($variables['node']) && !empty($variables['node']->type)) {
        $variables['theme_hook_suggestions'][] = 'page__node__' . $variables['node']->type;
    }
    if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
        $term = taxonomy_term_load(arg(2));
        $variables['theme_hook_suggestions'][] = 'page__vocabulary__' . $term->vocabulary_machine_name;
        unset($variables['page']['content']['system_main']['term_heading']['term']);
    }
    if (isset($variables['page']['content']['system_main']['no_content'])) {
        unset($variables['page']['content']['system_main']['no_content']);
    }
}
Example #17
0
/**
 * Modify theme_preprocess_page()
 */
function goodnex_preprocess_page(&$vars, $hook)
{
    if (isset($vars['node'])) {
        $suggest = "page__node__{$vars['node']->type}";
        $vars['theme_hook_suggestions'][] = $suggest;
    }
    $status = drupal_get_http_header("status");
    if ($status == "404 Not Found") {
        $vars['theme_hook_suggestions'][] = 'page__404';
    }
    if (arg(0) == 'taxonomy' && arg(1) == 'term') {
        $term = taxonomy_term_load(arg(2));
        $vars['theme_hook_suggestions'][] = 'page--taxonomy--vocabulary--' . $term->vid;
    }
}
Example #18
0
/**
 * Implementation of hook_preprocess_calendar_item().
 */
function wk_bartik_preprocess_calendar_item(&$vars)
{
    static $outp = FALSE;
    // At the last possible minute we fix the values in rendered_fields so it
    // contains the correct rendered content for the type of item and item display.
    $item = $vars['item'];
    $branch_output = '';
    $branch_group_terms = FALSE;
    if (isset($item->entity->taxonomy_vocabulary_2[LANGUAGE_NONE])) {
        $branch_group_terms = $item->entity->taxonomy_vocabulary_2[LANGUAGE_NONE];
        foreach ($branch_group_terms as $index => $term_info) {
            if (isset($term_info['tid'])) {
                $term = taxonomy_term_load($term_info['tid']);
                if (isset($term->field_arms[LANGUAGE_NONE])) {
                    $img_uri = $term->field_arms[LANGUAGE_NONE][0]['uri'];
                    $image_path = file_create_url($img_uri);
                    $image_path = parse_url($image_path, PHP_URL_PATH);
                    $branch_output .= "<img src='{$image_path}'>";
                }
                /*
                // The "drupal way" would be to replace the code above
                // and use field_view_field instead, as shown below,
                // but we don't want all of the markup this produces,
                // and stripping the markup off the img tags is inelegant.
                $view = field_view_field('taxonomy_term', $term, 'field_arms');
                if (!empty($view)) {
                  $branch_output .= render($view);
                }
                */
            }
        }
    }
    if (!empty($item->rendered) && empty($item->is_multi_day)) {
        if (!empty($branch_output)) {
            $item->rendered = "<div class='calendar-event-branch'>{$branch_output}</div>" . $item->rendered;
        }
        $vars['rendered_fields'] = array($item->rendered);
    }
    if (!empty($item->is_multi_day) && empty($item->continuation) && !empty($vars['rendered_fields'])) {
        array_unshift($vars['rendered_fields'], "<div class='calendar-event-branch'>{$branch_output}</div>");
    }
    if (!empty($vars['rendered_fields'])) {
        $event_type = $item->entity->field_event_type[LANGUAGE_NONE][0]['value'];
        array_unshift($vars['rendered_fields'], "<div class='calendar-event-type--{$event_type}'>");
        $vars['rendered_fields'][] = "</div>";
    }
}
Example #19
0
 /**
  * @param $tid
  * @param $vocabulary
  *
  * @return bool|object
  */
 public static function termExistsForTid($tid, $vocabulary = NULL)
 {
     if (!is_numeric($tid)) {
         return FALSE;
     }
     $term = taxonomy_term_load($tid);
     if (!$term) {
         return FALSE;
     }
     if (!is_null($vocabulary) && $term->vocabulary_machine_name != $vocabulary) {
         return FALSE;
     }
     $short_class = Utils::makeTitleCase($term->vocabulary_machine_name);
     $full_class = "RedTest\\entities\\TaxonomyTerm\\" . $short_class;
     $termObject = new $full_class($term->tid);
     return $termObject;
 }
Example #20
0
/**
 * Override or insert variables into the page template for HTML output.
 * 
 * For taxonomy page, insert vocabulary id class.
 * Define the variable to activate responsive behaivor.
 */
function bootstrap_barrio_preprocess_html(&$variables)
{
    if (arg(0) == 'taxonomy') {
        $tid = arg(2);
        $taxonomy = taxonomy_term_load($tid);
        $variables['classes_array'][] = 'vid-' . $taxonomy->vid;
    }
    if (theme_get_setting('is_one') && drupal_is_front_page()) {
        $variables['classes_array'][] = 'one-page';
    }
    if (theme_get_setting('toggle_responsive')) {
        $variables['mobile_friendly'] = TRUE;
    } else {
        $variables['mobile_friendly'] = FALSE;
        drupal_add_css(drupal_get_path('theme', 'bootstrap_barrio') . '/css/no-responsive.css', array('group' => CSS_DEFAULT, 'every_page' => TRUE));
    }
}
Example #21
0
function mis_theme_get_all_exercises($category, $language)
{
    $misQuery = new EntityFieldQuery();
    $result = $misQuery->entityCondition('entity_type', 'node')->propertyCondition('type', 'aefing')->propertyCondition('status', 1, '=')->propertyCondition('language', $language, '=')->propertyOrderBy('title', 'ASC')->fieldCondition('field_aldursflokkun', 'tid', $category)->execute();
    if (!empty($result['node'])) {
        $mis = entity_load('node', array_keys($result['node']));
    }
    foreach ($mis as $tmp) {
        if (isset($tmp->field_ahold['und'])) {
            foreach ($tmp->field_ahold['und'] as $key => &$ahald) {
                $tax = taxonomy_term_load($ahald['tid']);
                $ahald['name'] = $tax->name;
            }
        }
    }
    return $mis;
}
Example #22
0
function idigitaltimes_preprocess_node(&$variables)
{
    switch ($variables['view_mode']) {
        case 'full':
            $variables['node']->author_extra = ibtmedia_user_get_reporter_name_extra($variables['node']);
            break;
        case 'teaser':
            $variables['content']['type'] = $variables['node']->type;
            if ($variables['node']->type == 'alert') {
                $variables['content']['title'] = $variables['title'];
                $variables['content']['page_link'] = !empty($variables['field_page_link']['und'][0]['value']) ? $variables['field_page_link']['und'][0]['value'] : '';
                if (!empty($variables['content']['page_link'])) {
                    $variables['content']['title'] = l($variables['title'], $variables['content']['page_link']);
                    ibtmedia_core_update_text_links($variables['content']['title']);
                }
                $variables['content']['byline'] = !empty($variables['field_display_name']['und'][0]['value']) ? $variables['field_display_name']['und'][0]['value'] : '';
                $variables['content']['alert_type'] = !empty($variables['field_alert_type']['und'][0]['value']) ? $variables['field_alert_type']['und'][0]['value'] : '';
                $twitter = !empty($variables['field_twitter_handle']['und'][0]['value']) ? $variables['field_twitter_handle']['und'][0]['value'] : '';
                if (!empty($twitter)) {
                    if (strstr($twitter, "@")) {
                        $tmp = explode('@', $twitter);
                        $twitter = l('@' . $tmp[1], 'https://twitter.com/' . $tmp[1], array('attributes' => array('target' => '_blank', 'rel' => 'nofollow')));
                    }
                    $variables['content']['twitter'] = $twitter;
                }
            }
            if ($variables['node']->type == 'slideshow') {
                $variables['content']['slides_count'] = sizeof($variables['node']->field_slides['und']);
            }
            $variables['content']['display_largeimg'] = !empty($variables['field_display_largeimg']['und'][0]['value']) ? $variables['field_display_largeimg']['und'][0]['value'] : '';
            if (!empty($variables['field_topics'])) {
                $topics = '<ul class="topics">';
                foreach ($variables['field_topics']['und'] as $key => $value) {
                    $topic = taxonomy_term_load($value['tid']);
                    $topics .= '<li>' . l($topic->name, 'taxonomy/term/' . $value['tid']) . '</li>';
                }
                $topics .= '</ul>';
                $variables['content']['topics'] = $topics;
            }
            break;
    }
    $image_styles = array('large');
    ibtmedia_image_node_variables($variables['node'], $variables['view_mode'], $variables, $image_styles);
}
Example #23
0
function corporateclean_preprocess_page(&$vars)
{
    if (isset($vars['node'])) {
        // Ref suggestions cuz it's stupid long.
        $suggests =& $vars['theme_hook_suggestions'];
        // Get path arguments.
        $args = arg();
        // Remove first argument of "node".
        unset($args[0]);
        // Set type.
        $type = "page__{$vars['node']->type}";
        // Bring it all together.
        $suggests = array_merge($suggests, array($type), theme_get_suggestions($args, $type));
    }
    if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) {
        $term = taxonomy_term_load(arg(2));
        $vars['theme_hook_suggestions'][] = 'page__vocabulary__' . $term->vocabulary_machine_name;
    }
}
Example #24
0
function ichado1_breadcrumb($variables)
{
    $title_move_flag = FALSE;
    $cur_path = current_path();
    if ($cur_path == 'catalog') {
        $variables['breadcrumb'] = array();
        return;
    }
    $cur_path_alias = drupal_get_path_alias($cur_path);
    $add_breadcrumb = drupal_get_title();
    if ($cur_path == 'cart' || preg_match('/^checkout\\/[\\d]+$/', $cur_path) || preg_match('/^checkout\\/[\\d]+\\/complete$/', $cur_path) || preg_match('/^checkout\\/[\\d]+\\/review$/', $cur_path) || preg_match('/^o-nas$/', $cur_path_alias) || preg_match('/^kontakty$/', $cur_path_alias) || preg_match('/^kak-zakazat-0$/', $cur_path_alias) || preg_match('/^oplata$/', $cur_path_alias) || preg_match('/^dostavka$/', $cur_path_alias) || preg_match('/^garantii-vozvrata$/', $cur_path_alias)) {
        $title_move_flag = TRUE;
        if (preg_match('/^checkout\\/[\\d]+$/', $cur_path)) {
            $add_breadcrumb = 'Оформление заказа';
            //@todo wrap in t()
        }
    }
    $breadcrumb = $variables['breadcrumb'];
    $item = menu_get_item();
    if ($item['path'] === 'catalog/%') {
        $term = taxonomy_term_load(intval($item['page_arguments'][2]));
        if (is_object($term)) {
            if (count(taxonomy_get_parents($term->tid)) == 0) {
                array_pop($breadcrumb);
            } else {
                array_pop($breadcrumb);
                array_pop($breadcrumb);
            }
        }
    }
    //Remove breadcrumbs on user login and registration pages
    if ($item['path'] === 'user/login' || $item['path'] === 'user/register') {
        $breadcrumb = array();
    }
    if (!empty($breadcrumb)) {
        if ($title_move_flag) {
            $breadcrumb[] = '<span>' . $add_breadcrumb . '</span>';
        }
        $output = '<div class="breadcrumb">' . implode('<span>&nbsp&nbsp→&nbsp&nbsp</span>', $breadcrumb) . '</div>';
        return $output;
    }
}
Example #25
0
function portfolino_get_gallery()
{
    $query = new EntityFieldQuery();
    $i = (int) theme_get_setting('perpage_thumbs');
    $result = $query->entityCondition('entity_type', 'node')->entityCondition('bundle', 'article')->range(0, $i)->execute();
    $nids = array_keys($result['node']);
    $nodes = entity_load('node', $nids);
    $output = "";
    foreach ($nodes as $node) {
        $output .= "<a href='node/{$node->nid}' class='item'>";
        $output .= "<img src='" . image_style_url('medium', $node->field_image['und'][0]['uri']) . "' alt='{$node->title}'>";
        $output .= "<h3>{$node->title}</h3><p>";
        foreach ($node->field_tags['und'][0] as $tid) {
            $tax = taxonomy_term_load($tid);
            $output .= (isset($tax->name) ? $tax->name : '') . ", ";
        }
        $output .= "</p></a>";
    }
    return $output;
}
/**
 * Allow modules to alter the data that's used to to build a Juicebox gallery
 * and XML.
 *
 * @param array $data
 *   An associative array containing all the content and configuration data that
 *   will be used to render a Juicebox gallery and XML. This includes:
 *   - jlib_options: An associative array of Juicebox configuration options
 *     (these will be added as attributes to the "juicebox" element of the XML).
 *   - images: An indexed array of image data (this will be used to construct
 *     the attributes of each "image" element of the XML, along with the "title"
 *     and "caption" elements nested within).
 * @param array $settings
 *   An associative array of raw settings for the gallery. Provided for context.
 * @param array $source_info
 *   An associative array that provides source infomation for the gallery.
 *   Provided for context. This includes:
 *   - xml_path: The path for the gallery's XML which can also be used as an
 *     unique ID for the gallery. The pieces of this path also describe the
 *     data components from the source that are used to build the gallery.
 *   - source: The source object that was used for the XML data. If $xml_path
 *     starts with "juicebox/xml/view" this will be a rendered view object. If
 *     $xml_path starts with "juicebox/xml/entity" this will be an entity object
 *     (such as a node), etc.
 */
function hook_juicebox_gallery_data_alter(&$data, $settings, $source_info)
{
    // See if this is a gallery sourced from a view.
    if (strpos($source_info['xml_path'], 'juicebox/xml/view') === 0) {
        $view = $source_info['source'];
        // Assume we have a view called "galleries" and a page called "page_1" that
        // structures galleries based on a taxonomy term contextual filter. We want
        // the juicebox "galleryDescription" option to be the term description, but
        // because this term description is dynamic (based on contextual filter) we
        // can't statically define it in the view's Juicebox settings. This hook
        // let's us do the job dynamically.
        if ($view->name == 'galleries' && $view->current_display == 'page_1') {
            if (!empty($view->args)) {
                $term = taxonomy_term_load($view->args[0]);
                if (!empty($term->description)) {
                    $data['jlib_options']['galleryDescription'] = strip_tags($term->description);
                }
            }
        }
    }
}
Example #27
0
/**
 * Overrides theme_menu_link__main_menu.
 */
function atento_menu_link__main_menu(&$vars)
{
    $element = $vars['element'];
    $sub_menu = '';
    if ($element['#below']) {
        $sub_menu = drupal_render($element['#below']);
    }
    $depth = $element['#original_link']['depth'];
    $element['#localized_options']['html'] = true;
    if ($depth == 1 && preg_match('/taxonomy\\/term\\/(\\d+)/', $element['#href'], $match)) {
        $tid = $match[1];
        if (($term = taxonomy_term_load($tid)) && $term->vid == 1) {
            $term_view = taxonomy_term_view($term, 'menu_top');
            $output = drupal_render($term_view);
            $output = l($output, $element['#href'], $element['#localized_options']);
        }
    }
    if (!isset($output)) {
        $output = l("<span>{$element['#title']}</span>", $element['#href'], $element['#localized_options']);
    }
    return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}
Example #28
0
/**
 * Implements hook_preprocess_node().
 */
function now_preprocess_node(&$variables)
{
    // In the News teasers.
    if ($variables['teaser'] && $variables['type'] === 'in_the_news') {
        // Load the primary source.
        $primary_source = entity_load('field_collection_item', array($variables['field_sources'][LANGUAGE_NONE][0]['value']));
        $primary_source = reset($primary_source);
        // Set the $node_url variable to the url of the first field collection url.
        $variables['node_url'] = $primary_source->field_url[LANGUAGE_NONE][0]['url'];
        // Set a $source_name variable to the value of the first field collection
        // source.
        $variables['source_name'] = taxonomy_term_load($primary_source->field_source[LANGUAGE_NONE][0]['tid'])->name;
        // Adding logic to add a class for In the News items so we can add the right
        // icon for the teaser display.
        if (strpos($variables['node_url'], 'uiowa.edu') !== FALSE) {
            $variables['classes_array'][] = 'local-story';
        } else {
            $variables['classes_array'][] = 'remote-story';
        }
        // Check to see if the node has an image, then add a class for styling
        if ($variables['field_primary_media']) {
            $variables['classes_array'][] = 'has-photo';
        }
    }
    // Achievement teasers.
    if ($variables['teaser'] && $variables['type'] === 'achievement') {
        // Set a $category variable to the name of the category term.
        if ($variables['field_achievement_category']) {
            $variables['category'] = taxonomy_term_load($variables['field_achievement_category'][LANGUAGE_NONE][0]['tid'])->name;
        }
    }
    // News Feature Teasers
    if ($variables['teaser'] && $variables['type'] === 'news_feature') {
        // Check to see if the node has an image, then add a class for styling
        if ($variables['field_primary_media']) {
            $variables['classes_array'][] = 'has-photo';
        }
    }
}
 /**
  * Default constructor of the taxonomy term form. You should not be invoking
  * TaxonomyFormTerm directly. Create a form for your vocabulary that extends
  * TaxonomyFormTerm and invoke that. The access level has to be kept public
  * here because access level of parent class has to be match that of child
  * class.
  *
  * @param null|int $tid
  *   Taxonomy term id if a taxonomy term edit form is to be loaded. If a
  *   taxonomy term add form is to be created, then keep it empty.
  */
 public function __construct($tid = NULL)
 {
     $classname = get_called_class();
     $class = new \ReflectionClass($classname);
     $class_shortname = $class->getShortName();
     $vocabulary_name = Utils::makeSnakeCase(substr($class_shortname, 0, -4));
     if (!is_null($tid) && is_numeric($tid)) {
         // Tid is not null and is numeric.
         $term = taxonomy_term_load($tid);
         if ($term->vocabulary_machine_name == $vocabulary_name) {
             $this->vocabulary = taxonomy_vocabulary_machine_name_load($vocabulary_name);
             $base_path = "RedTest\\entities\\TaxonomyTerm\\";
             $class_fullname = $base_path . substr($class_shortname, 0, -4);
             $termObject = new $class_fullname($tid);
             $this->setEntityObject($termObject);
             $this->includeFile('inc', 'taxonomy', 'taxonomy.admin');
             parent::__construct('taxonomy_form_term', $term, $this->vocabulary);
             $this->setInitialized(TRUE);
             return;
         } else {
             // Vocabulary name of the provided term does not match the class it was called from. Return with a FAIL response.
             $this->setErrors("Vocabulary of the provided term does not match the class it was called from.");
             $this->setInitialized(FALSE);
             return;
         }
     } else {
         // Proper tid is not provided. Create a dummy term object.
         $base_path = "RedTest\\entities\\TaxonomyTerm\\";
         $class_fullname = $base_path . substr($class_shortname, 0, -4);
         $termObject = new $class_fullname();
         $this->setEntityObject($termObject);
     }
     // tid is not provided or is not numeric.
     $this->vocabulary = taxonomy_vocabulary_machine_name_load($vocabulary_name);
     $this->includeFile('inc', 'taxonomy', 'taxonomy.admin');
     parent::__construct('taxonomy_form_term', array(), $this->vocabulary);
     $this->setInitialized(TRUE);
 }
Example #30
-1
/**
 * Define some variables for use in theme templates.
 */
function redcrackle_process_page(&$variables)
{
    $tid = arg(2);
    // Assign site name and slogan toggle theme settings to variables.
    $variables['disable_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE;
    $variables['disable_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE;
    // Assign site name/slogan defaults if there is no value.
    if ($variables['disable_site_name']) {
        $variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal'));
    }
    if ($variables['disable_site_slogan']) {
        $variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', ''));
    }
    if (!empty($tid) && arg(1) == 'term') {
        $term = taxonomy_term_load($tid);
        // Unset the default content
        //unset($variables['page']['content']);
        taxonomy_term_load($tid);
        $field_image = field_get_items('taxonomy_term', $term, 'field_image');
        $uri = !empty($field_image[0]['uri']) ? $field_image[0]['uri'] : '';
        $alt = !empty($field_image[0]['alt']) ? $field_image[0]['alt'] : '';
        if (!empty($uri)) {
            $variables['image_url'] = theme('image_style', array('path' => $uri, 'style_name' => 'large', 'alt' => $alt));
        }
        $variables['description'] = $term->description;
        $variables['theme_hook_suggestions'][] = 'page__taxonomy__services';
    }
}