', array(), 301);
}
}
}
/**
* Implements hook_menu().
*/
function oieau_pages_menu() {
$items['admin/export_pages'] = array(
'title' => 'Export pages pour traduction',
'page callback' => '_oieau_pages_export',
'access arguments' => array('administer content'),
'type' => MENU_CALLBACK,
);
return $items;
}
function oieau_pages_views_pre_render(&$view) {
// Make a "DISTINCT" on the "nid" column
// (We have to do this bc it doesn't work
// via SQL)
if ($view->name == 'chiffre_cles' && ($view->current_display == 'page_1' || $view->current_display == 'block_3')) {
$cc_gen = array();
foreach ($view->result as $key => $result) {
if(in_array($result->nid, $cc_gen) !== false) {
unset($view->result[$key]);
} else {
$cc_gen[] = $result->nid;
}
}
}
}
function _oieau_pages_export() {
// Return all nids of nodes of type "page".
$nids = db_select('node', 'n')
->fields('n', array('nid'))
->fields('n', array('type'))
->condition('n.type', 'page')
->execute()
->fetchCol();
// Now return the node objects.
$nodes = node_load_multiple($nids);
$output = "
Site www.oieau.fr : articles à traduire
";
foreach($nodes as $node) {
$output .= "" . $node->title ."
";
$output .= "Lien vers l'article : " . l("http://www.oieau.fr/node/" . $node->nid, 'node/' . $node->nid) . "
";
if($node->log === "") {
if(!empty($node->body[LANGUAGE_NONE]['0']['summary'])) {
$output .= "Résumé" . $node->body[LANGUAGE_NONE]['0']['summary'];
}
if(!empty($node->body[LANGUAGE_NONE]['0']['value'])) {
$output .= "Contenu de l'article" . preg_replace("/
]+>/", "", $node->body[LANGUAGE_NONE]['0']['value']);;
}
}
$output .= "
";
}
print $output;
die;
}
function oieau_pages_preprocess_views_view(&$variables) {
$view = $variables['view'];
if ($view->name == 'phototheque' && $view->current_display == 'page_1') {
$node = node_load(arg(2));
$view->set_title($node->title);
}
if ($view->name == 'projets' && $view->current_display == 'page_1') {
$code = (string)arg(2);
$country = country_get_list();
if ('' != arg(2) && isset($country[$code])) {
//get country name from iso2 14/5000
//Our references Nuestras referencias
$view->set_title(t("Our references @country", ['@country' => $country[$code]]));
}
}
}
/**
* Implements hook_block_info().
*/
function oieau_pages_block_info() {
$blocks = array();
$blocks['page_niveau_un'] = array(
'info' => t('Pages level 1'),
);
$blocks['page_niveau_deux'] = array(
'info' => t('Pages level 2'),
);
return $blocks;
}
/**
* Implements hook_block_view().
*/
function oieau_pages_block_view($delta='') {
$block = array();
switch($delta) {
case 'page_niveau_un' :
$block['content'] = _oieau_pages_page_nv_un();
break;
case 'page_niveau_deux' :
$block['content'] = _oieau_pages_page_nv_deux();
break;
}
return $block;
}
/**
* Custom function to assemble renderable array for block content.
* Returns a renderable array with the block content.
* @return
* returns a renderable array of block content.
*/
function _oieau_pages_page_nv_un() {
$block = array(
'#type' => 'markup',
'#markup' => '',
);
// krumo(1);
$menus = i18n_menu_localize_tree(menu_tree_page_data('main-menu', null, true));
foreach($menus as $menu) {
if(!empty($menu['below'])) {
foreach($menu['below'] as $below) {
if($menu['link']['link_path'] == current_path() && !empty($below)) {
if($below['link']['hidden'] != 1) {
$page_path = explode('/', $below['link']['link_path']);
if((isset($page_path[0]) && $page_path[0] === 'node') && (isset($page_path[1]) && is_numeric($page_path[1]))) {
$page = node_load($page_path[1]);
$block['#markup'] .= "" . l($page->title, 'node/' . $page->nid) . "
";
if(isset($page->body[LANGUAGE_NONE][0]['summary']) && !empty($page->body[LANGUAGE_NONE][0]['summary'])) {
$block['#markup'] .= $page->body[LANGUAGE_NONE][0]['summary'];
$block['#markup'] .= l(t("For more information"), 'node/' . $page->nid);
}
if(isset($page->body[$GLOBALS['language']->language][0]['summary']) && !empty($page->body[$GLOBALS['language']->language][0]['summary'])) {
$block['#markup'] .= $page->body[$GLOBALS['language']->language][0]['summary'];
$block['#markup'] .= l(t("For more information"), 'node/' . $page->nid);
}
}
}
}
}
}
}
if($block['#markup'] == "") {
$menus = i18n_menu_localize_tree(menu_tree_page_data('menu-top-menu', null, true));
foreach($menus as $menu) {
if(!empty($menu['below'])) {
foreach($menu['below'] as $below) {
if($menu['link']['link_path'] == current_path() && !empty($below)) {
if($below['link']['hidden'] != 1) {
$page_path = explode('/', $below['link']['link_path']);
if((isset($page_path[0]) && $page_path[0] === 'node') && (isset($page_path[1]) && is_numeric($page_path[1]))) {
$page = node_load($page_path[1]);
$block['#markup'] .= "" . l($page->title, 'node/' . $page->nid) . "
";
if(isset($page->body[LANGUAGE_NONE][0]['summary']) && !empty($page->body[LANGUAGE_NONE][0]['summary'])) {
$block['#markup'] .= $page->body[LANGUAGE_NONE][0]['summary'];
$block['#markup'] .= l(t("For more information"), 'node/' . $page->nid);
}
if(isset($page->body[$GLOBALS['language']->language][0]['summary']) && !empty($page->body[$GLOBALS['language']->language][0]['summary'])) {
$block['#markup'] .= $page->body[$GLOBALS['language']->language][0]['summary'];
$block['#markup'] .= l(t("For more information"), 'node/' . $page->nid);
}
} elseif((isset($page_path[0]) && $page_path[0] === 'taxonomy') &&(isset($page_path[1]) && $page_path[1] === 'term') && (isset($page_path[2]) && is_numeric($page_path[2]))) {
$page_path = explode('/', $below['link']['link_path']);
$page = taxonomy_term_load($page_path[2]);
$block['#markup'] .= "" . l($page->name, 'taxonomy/term/' . $page->tid) . "
";
// if(isset($page->body[LANGUAGE_NONE][0]['summary']) && !empty($page->body[LANGUAGE_NONE][0]['summary'])) {
// $block['#markup'] .= $page->body[LANGUAGE_NONE][0]['summary'];
// $block['#markup'] .= l(t("For more information"), 'node/' . $page->nid);
// }
} else {
// krumo(1.4);
// krumo($below);
//$block['#markup'] .= "" . l($below['link']['link_title'], $below['link']['link_path']) . "
";
$block['#markup'] .= "" . l($below['link']['title'], $below['link']['link_path']) . "
";
}
}
}
}
}
}
}
return $block;
}
/**
* Custom function to assemble renderable array for block content.
* Returns a renderable array with the block content.
* @return
* returns a renderable array of block content.
*/
function _oieau_pages_page_nv_deux() {
$block = array(
'#type' => 'markup',
'#markup' => '',
);
$menus =i18n_menu_localize_tree( menu_tree_page_data('main-menu', null, true));
foreach($menus as $menu) {
if(!empty($menu['below'])) {
foreach($menu['below'] as $below) {
if($below['link']['link_path'] == current_path() && !empty($below['below'])) {
foreach ($below['below'] as $pages) {
if($pages['link']['hidden'] != 1) {
$page_path = explode('/', $pages['link']['link_path']);
if((isset($page_path[0]) && $page_path[0] === 'node') && (isset($page_path[1]) && is_numeric($page_path[1]))) {
$page = node_load($page_path[1]);
$block['#markup'] .= "" . l($page->title, 'node/' . $page->nid) . "
";
//for content type with translation NOT activated
if(isset($page->body[LANGUAGE_NONE][0]['summary']) && !empty($page->body[LANGUAGE_NONE][0]['summary'])) {
$block['#markup'] .= $page->body[LANGUAGE_NONE][0]['summary'];
$block['#markup'] .= l(t("For more information"), 'node/' . $page->nid);
}
//for content type with translation activated
if(isset($page->body[$GLOBALS['language']->language][0]['summary']) && !empty($page->body[$GLOBALS['language']->language][0]['summary'])) {
$block['#markup'] .= $page->body[$GLOBALS['language']->language][0]['summary'];
$block['#markup'] .= l(t("For more information"), 'node/' . $page->nid);
}
}
}
}
}
}
}
}
if($block['#markup'] == "") {
$menus = i18n_menu_localize_tree(menu_tree_page_data('menu-top-menu', null, true));
foreach($menus as $menu) {
if(!empty($menu['below'])) {
foreach($menu['below'] as $below) {
if($below['link']['link_path'] == current_path() && !empty($below['below'])) {
foreach ($below['below'] as $pages) {
if($pages['link']['hidden'] != 1) {
$page_path = explode('/', $pages['link']['link_path']);
if((isset($page_path[0]) && $page_path[0] === 'node') && (isset($page_path[1]) && is_numeric($page_path[1]))) {
$page = node_load($page_path[1]);
$block['#markup'] .= "" . l($page->title, 'node/' . $page->nid) . "
";
//for content type with translation NOT activated
if(isset($page->body[LANGUAGE_NONE][0]['summary']) && !empty($page->body[LANGUAGE_NONE][0]['summary'])) {
$block['#markup'] .= $page->body[LANGUAGE_NONE][0]['summary'];
$block['#markup'] .= l("For more informationn", 'node/' . $page->nid);
}
//for content type with translation activated
if(isset($page->body[$GLOBALS['language']->language][0]['summary']) && !empty($page->body[$GLOBALS['language']->language][0]['summary'])) {
$block['#markup'] .= $page->body[$GLOBALS['language']->language][0]['summary'];
$block['#markup'] .= l(t("For more information"), 'node/' . $page->nid);
}
} else { //not a node, maybe a view like phototeques/25 ans d el'oieau
// krumo($below);
$block['#markup'] .= "" . l($pages['link']['title'], $pages['link']['link_path']) . "
";
}
}
}
}
}
}
}
}
return $block;
}