コード例 #1
0
ファイル: template.php プロジェクト: rollinsb1010/bbcom
function bbcom_theme_language_switcher_form(&$form_state, $node = NULL)
{
    global $language;
    $translations = array();
    if (!is_null($node) && $node->tnid) {
        $translations = translation_node_get_translations($node->tnid);
    }
    $path = drupal_is_front_page() ? '<front>' : $_GET['q'];
    $languages = language_list('enabled');
    $options = array();
    foreach ($languages[1] as $lang_item) {
        $langcode = $lang_item->language;
        if ($language->language == $langcode) {
            $url = '';
        } else {
            $url = check_url(url(isset($translations[$langcode]) ? 'node/' . $translations[$langcode]->nid : $path, array('language' => $lang_item, 'absolute' => TRUE)));
        }
        $options[$url] = $lang_item->native;
    }
    $form['my_language_select'] = array('#type' => 'select', '#title' => t('My Language'), '#options' => $options, '#default_value' => '');
    $form['submit'] = array('#type' => 'submit', '#value' => t('Change'));
    return $form;
}
コード例 #2
0
ファイル: template.php プロジェクト: Txorua/argoitia
function _argoitia_node_translations($nid, $lang)
{
    $translations = translation_node_get_translations($nid);
    $path = drupal_get_path_alias('node/' . $translations[$lang]->nid, $lang);
    return $lang . '/' . $path;
}
コード例 #3
0
/**
 * Implements hook_language_switch_links_alter().
 */
function eu_projects_theme_language_switch_links_alter(array &$links, $type, $path)
{
    $node = menu_get_object();
    $path_explode = explode('/', $path);
    // Unset lang-switcher links for non-existent translations.
    if ($node) {
        $language = $node->language;
        $translations = translation_node_get_translations($node->tnid);
        foreach ($links as $langcode => &$link) {
            $links[$langcode]['attributes']['lang'] = $langcode;
            $links[$langcode]['attributes']['title'] = $links[$langcode]['title'];
            if ($language == $langcode) {
                unset($links[$langcode]);
            }
            if (!isset($translations[$langcode])) {
                unset($links[$langcode]);
            }
        }
    }
}
コード例 #4
0
ファイル: page--front.tpl.php プロジェクト: Txorua/argoitia
    <div class="col-xs-12 col-sm-8 col-md-7">
      <div class="hidden-xs col-sm-12 clearfix">
        <nav class="header-links">
          <ul class="nav nav-pills nav-top pull-right h5">
            <li><a href="<?php 
global $language, $base_url;
print $base_url . '/' . $language->language;
?>
/contact"><span class="glyphicon glyphicon-envelope">&nbsp;</span><?php 
print t('Contact');
?>
</a></li>
            <li class="phone"><a href="#"><span class="glyphicon glyphicon-earphone">&nbsp;</span>+34 943 14 09 57</a></li>
            <?php 
$translations = translation_node_get_translations(142);
$path = drupal_get_path_alias('node/' . $translations[$language->language]->nid, $language->language);
$name = '<span class="glyphicon glyphicon-map-marker">&nbsp;</span>' . t('How to reach');
$options = array('attributes' => array('language' => $language->language), 'html' => true);
$link = l($name, $path, $options);
?>
            <li><?php 
print $link;
?>
</li>
          </ul>
        </nav>
      </div>
      <div class="col-xs-12 pull-right">
        <nav class="header-links">
          <ul class="nav nav-pills nav-top pull-right h5">
コード例 #5
0
ファイル: template.php プロジェクト: nivaria/arquideasprod
/**
 * Node preprocessing
 */
function arquideasprod_preprocess_node(&$vars)
{
    // Add node_right region content
    $vars['node_right'] = theme('blocks', 'node_right');
    //PREPROCESS CONTEST NODE
    if (isset($vars['type']) && $vars['type'] == 'contest') {
        $qt_name = 'quicktabs_contest_open';
        if (isset($vars['field_contest_state'])) {
            if (intval($vars['field_contest_state'][0]['value']) === ContestState::OPEN) {
                $vars['template_files'][] = 'node-contest-open';
            }
            if (intval($vars['field_contest_state'][0]['value']) >= ContestState::PRIZE) {
                $qt_name = 'quicktabs_contest_closed';
            }
        }
        $quicktabs = quicktabs_load($qt_name);
        $vars['contest_quicktab'] = theme('quicktabs', $quicktabs);
        if (isset($vars['links'])) {
            unset($vars['links']);
        }
    }
    $arr_types_og = og_get_types('group');
    if (isset($vars['node']) && in_array($vars['node']->type, $arr_types_og)) {
        if ($_GET['q'] == 'node/' . $vars['nid'] . '/edit') {
            $vars['is_edit'] = TRUE;
        } else {
            $vars['is_edit'] = FALSE;
        }
    }
    //PREPROCESS INSCRIPTION NODE
    if (isset($vars['node']) && $vars['node']->type == 'inscription') {
        $vars['picture'] = '';
        $cnid = $vars['node']->field_contest[0]['nid'];
        $cnode = node_load($cnid);
        $cnode_trans = NULL;
        if (!empty($cnode->tnid) && $cnode->tnid != 0) {
            $translations = translation_node_get_translations($cnode->tnid);
            if (!empty($translations[$user->language])) {
                $cnode_trans = node_load($translations[$user->language]->nid);
            }
        }
        if ($cnode) {
            $vars['contest'] = $cnode;
            if (!empty($cnode_trans)) {
                $vars['contest_translation'] = $cnode_trans;
                $vars['contest_title'] = $cnode_trans->title;
                $vars['field_contest_image'] = $cnode_trans->field_contest_image;
            } else {
                $vars['contest_title'] = $cnode->title;
                $vars['field_contest_image'] = $cnode->field_contest_image;
            }
            $vars['inscription_mission'] = $vars['node']->content['og_mission']['#value'];
        }
        $pattern = '/^inscription\\/\\d+$/';
        $match = preg_match($pattern, $_GET['q']);
        if ($match == 1) {
            $vars['template_files'][] = 'node-inscription-public';
        }
        $members = contest_notifications_get_group_members($vars['node']);
        $vars['num_members'] = count($members);
        if (count($members) > 1) {
            $vars['node_classes'] .= ' only-groups';
        }
    }
    //PREPROCESS WEBFORM NODE
    if (isset($vars['type']) && $vars['type'] == 'webform') {
        $vars['submitted'] = '';
        if (isset($vars['links'])) {
            unset($vars['links']);
        }
    }
    //PREPROCESS GROUP NODE (KM)
    if (isset($vars['type']) && $vars['type'] == 'group') {
        if (isset($vars['links'])) {
            unset($vars['links']);
        }
        $vars['group_attributes_rendered'] = '';
    }
    //PREPROCESS PROJECT NODE
    if (isset($vars['node']) && $vars['node']->type == 'project') {
        if ($_GET['q'] == 'node/' . $vars['nid'] . '/edit') {
            $vars['is_edit'] = TRUE;
        } else {
            $vars['is_edit'] = FALSE;
        }
    }
    //PREPROCESS NEWSLETTER ISSUE NODE
    if (isset($vars['node']) && $vars['node']->type == 'simplenews') {
        if ($_GET['q'] == 'node/' . $vars['nid'] . '/edit') {
            $vars['is_edit'] = TRUE;
        } else {
            $vars['is_edit'] = FALSE;
        }
        $generaltid = variable_get('nivaria_contests_base_newslettertid', 0);
        $node = $vars['node'];
        $vars['general_newsletter'] = FALSE;
        if (isset($node->taxonomy[$generaltid]) && $node->taxonomy[$generaltid]->tid == $generaltid) {
            $vars['general_newsletter'] = TRUE;
        }
    }
}