i18n_page_views.module in i18n page views 7
File
i18n_page_views.module
View source
<?php
function i18n_page_views_views_api() {
return array(
'api' => '3.0-alpha1',
'path' => drupal_get_path('module', 'i18n_page_views') . '/includes',
);
}
function i18n_page_views_url_outbound_alter(&$path, &$options, $original_path) {
global $language;
$views = views_get_all_views();
foreach ($views as $view) {
foreach (array_keys($view->display) as $id) {
if ($view->display[$id]->display_plugin == 'i18n_page') {
$items = array();
$languages = locale_language_list();
foreach ($languages as $langcode => $langname) {
if (isset($view->display[$id]->display_options['path_' . $langcode]) && $path == $view->display[$id]->display_options['path_' . $langcode]) {
if (isset($options['language'])) {
$path = $view->display[$id]->display_options['path_' . $options['language']->language];
}
}
}
}
}
}
}
function i18n_page_views_context_plugins() {
$plugins = array();
$plugins['context_condition_i18n_views'] = array(
'handler' => array(
'path' => drupal_get_path('module', 'i18n_page_views'),
'file' => 'context_condition_i18n_views.inc',
'class' => 'context_condition_i18n_views',
'parent' => 'context_condition',
),
);
return $plugins;
}
function i18n_page_views_context_registry() {
return array(
'conditions' => array(
'context_condition_i18n_views' => array(
'title' => t('i18n Views'),
'plugin' => 'context_condition_i18n_views',
'description' => t('Set this context when displaying the page of one of these i18n views.'),
),
),
);
}
function i18n_page_views_views_pre_view($view, $args) {
if (module_exists('context')) {
if ($plugin = context_get_plugin('condition', 'context_condition_i18n_views')) {
$plugin
->execute($view);
}
}
}