Commit 75fb2d26 authored by Mindiell's avatar Mindiell
Browse files

First commit

parents
<span class="actuvignette" style="background-image:url('<?php print htmlspecialchars($node->image); ?>');"></span>
<h3><?php print l(trim($node->title), $node->link, $node->link_options); ?></h3>
<p class="<?php print $node->date_class; ?>"><?php print $node->date; ?></p>
<?php print $node->tags; ?>
<div class="teaser"><?php print $node->teaser; ?></div>
<div class="very-last-news">
<h2 class="title">
<a href="/fr/fuite-lue-fait-pression-pour-la-criminalisation-des-usages-non-commerciaux-dans-lacta">Fuite : L'UE fait pression pour la criminalisation des usages non-commerciaux dans l'ACTA</a>
</h2>
<ul class="metas">
<li class="submitted"><?=$date?>24 Juin 2010</li>
<li class="tag"><?=$tags?>ACTA</li>
</ul>
<p class="content">
<?=$content?><br />
<a class="more" href="<?=$link?>">Lire la suite</a> (<a href="/fr/fuite-lue-fait-pression-pour-la-criminalisation-des-usages-non-commerciaux-dans-lacta#attachments">2 fichiers attachés</a>)</p>
<div class="share-links"></div>
</div>
/* Onglets */
.tab_switcher .tab_list {
display:block;
list-style: none outside none;
padding:0;
margin:0;
width: 100%;
overflow:auto;
border-bottom: 8px solid #497ED5;
}
.tab_switcher .tab_list li {
float: left;
text-transform:uppercase;
}
.tab_switcher .tab_list li a {
background-color: #F2F2F2;
color:#666;
font-weight:bold;
display:block;
padding:6px 20px;
margin-right:2px;
}
.tab_switcher .tab_list li a.active {
background-color: #497ED5;
color: white;
}
/* Contenu */
.tab_switcher {
overflow:hidden; /* (ou auto) force la marge interieure du bas. */
}
.tab_switcher .tab_container {
background-color: #D6E2F5;
}
.tab_switcher .tab_container > .item-list > h3 {
display:none;
}
.tab_switcher .tab_container > .item-list > ul {
margin:0;
padding:0;
}
.tab_switcher .tab_container > .item-list > ul > li {
list-style: none outside none;
clear:both;
background-color:white;
margin-top:3px;
}
.tab_switcher .tab_container > .item-list > ul > li.first {
margin-top: 0;
}
.tab_switcher .tab_container > .item-list > ul > li.last {
margin-top: 0; /* The .last is a link... Not a classic element. */
}
/* Dates */
.tab_switcher .tab_container > .item-list > ul > li > .date {
float:right;
color:#B0B0B0;
}
.tab_switcher .teaser {
margin-top: 6px;
}
/* Tags */
.tab_switcher ul.tags,
.tab_switcher ul.tags li {
padding:0;
}
.tab_switcher ul.tags {
margin-bottom:0;
}
.tab_switcher ul.tags li {
display:inline-block;
}
.tab_switcher .item-list .item-list ul.tags a {
}
.tab_switcher ul.tags li.tag {
font-size: 0.8em;
margin-right: 10px;
margin-bottom: 2px;
background-color: #E6E6E6;
color: #B1C2E0;
padding: 2px;
}
/* Titre des articles */
.tab_switcher .node_title {
display: block;
font-size: 1.4em;
margin-bottom: 3px;
font-family: "SansusWebissimoRegular","DejaVu Sans Condensed",sans-serif;
}
/* Item étendu */
.tab_switcher .tab_container > .item-list > ul > li.complete-item {
position:relative;
padding:10px 10px 10px 170px;
}
.tab_switcher .actuvignette {
position:absolute;
top:5%;
bottom:0;
background-position: center top;
background-repeat: no-repeat;
display: block;
/* float: left;*/
margin-left:-160px;
/* height: 95px; */
width: 150px;
height: 95%;
}
.tab_switcher strong {
font-weight:normal; /* protection contre les strong des teasers */
}
.tab_switcher p {
font-size:1em;
margin:0;
max-width: 550px; /* aeration pour les grands ecrans */
text-align: justify;
}
.tab_switcher p img {
display:none; /* protection contre les images des teasers */
}
.tab_switcher .see-footnote, .tab_switcher .footnotes {
display:none; /* protection contre les footnotes des teasers */
}
/* Item simple */
.tab_switcher .tab_container > .item-list > ul > li.simple-item {
padding: 5px 10px;
}
div.prmore {
background: #487ED6;
color: white;
font-weight: 700;
text-align: left;
padding: 5px 10px;
}
div.prmore a {
color: white;
text-weight: 700;
}
div.prmore a:hover {
color: #D0D0D0;
text-weight: 700;
}
#proposals div.tab_container
{
background-color:white;
padding:5px 10px
}
; $Id$
name = "Latest nodes"
description = Generate lists of (the latest) nodes
core = 6.x
package = "La Quadrature"
(function( $, doc, undefined ) {
$(doc).ready(function() {
var $tab_switcher = $(".tab_switcher"),
$tabs = $tab_switcher.find(".tab_list a"),
$tab_container = $tab_switcher.find(".tab_container");
$tabs.click(function( e ) {
e.preventDefault();
$tabs.removeClass("active");
$(this).addClass("active");
$tab_container
.children("div").hide()
.end()
.find( "#" + this.rel ).parent().show();
});
$tabs.eq(0).click();
});
})( jQuery, document );
<?php
/**
* Returns the content of last block.
*
* @param $_type
* A string containing the type.
* @param $_dossier
* An object containing all informations the about a dossier.
* In particularly, name and tags ID separated by commas.
* @param $_nb
* The number of elements to return. By default 8.
* @param $_offset
* ...
*
* @return
* A string containing html, ready to be display.
*/
function lqdn_latest_nodes_list_items($_type, $_dossier = NULL, $_nb = 8, $_offset = 0, $_template = 'simple_item') {
global $language,$base_url;
switch ($_type) {
case 'rp':
$type = "'revue_de_presse'";
break;
case 'actu':
$type = "'actualite', 'important'";
break;
default:
$type = "'actualite', 'important', 'revue_de_presse'";
}
/**
* @todo use template.
*/
$items = array();
/*
* GIBUS : use DISTINCT here, because untranslated nodes (like for
* HADOPI, only in fr) are selected twice.
*/
$query = "
SELECT DISTINCT(n.`nid`), n.`created`, n.`title`, n.`language`, v.`teaser`, v.`body`
FROM {node} n
LEFT JOIN {node_revisions} v ON n.`vid` = v.`vid`";
if (!empty($_dossier)) $query .= "
LEFT JOIN {term_node} t ON n.vid = t.vid";
$query .= "
WHERE (n.`status` <> 0)
AND (n.`type` in (" . $type . "))";
if (!empty($_dossier)) $query .= "
AND (t.`tid` in (" . $_dossier->tags . "))";
$query .= "
AND (n.`language` in ('***NO_LANGUAGE***', '%s', ''))
ORDER BY n.`created` DESC
LIMIT %d, %d";
$result = db_query($query, $language->language, $_offset, $_nb);
$i = 0;
while ($data = db_fetch_object($result)) {
$options['attributes']['title'] = trim($data->title);
$options['attributes']['class'] = 'node_title';
$prev_date = $date;
$date = format_date($data->created, 'small');
$date_class = ($date != $prev_date) ? 'date first-date' : 'date';
$tags = array();
$node_o = node_load($data->nid);
foreach($node_o->taxonomy as $taxo) {
$tags[] = array('data'=>l( $taxo->name, 'taxonomy/term/' . $taxo->tid, array('rel'=>'tag')),'class'=>'tag');
}
//$items[] = '<span class="' . $date_class . '">' . $date . '</span> ' . l(trim($data->title), 'node/' . $data->nid, $options);
if ($_template == 'complete_item') {
$image = '';
$matches = array();
preg_match('`<img[^>]+src="([^"]+)"[^>]*>`i', $data->body, $matches);
if (!empty($matches[1]))
{
$image = $matches[1];
if (!preg_match('`^https?://`',$image))
{
$image = $base_url.$image;
}
$image_max_width = 140;
$image_max_height = 110;
$chtitimage_dirpath = file_directory_path().'/smallnodeimage';
$chtitimage = $chtitimage_dirpath.'/'.md5($image).'-'.$image_max_width.'x'.$image_max_height.'.jpg';
if (!file_exists($chtitimage))
{
$imagesizes = getimagesize($image);
if ($imagesizes[0] > $image_max_width || $imagesizes[1] > $image_max_height)
{
if (!file_exists($chtitimage_dirpath))
mkdir($chtitimage_dirpath);
exec("convert '".$image."' -resize ".$image_max_width."x".$image_max_height." ".$chtitimage);
$image = $chtitimage;
}
} else {
$image = $chtitimage;
}
} else {
$dossiers = _lqdn_similar_nodes_get_dossiers(_lqdn_similar_nodes_get_tags($data->nid));
if (!empty($dossiers))
$image = $dossiers[0]->image;
else {
$image = '/sites/all/themes/lqdn314/images/_logo.png';
}
}
}
$node = (object)array(
'title' => $data->title,
'link' => 'node/' . $data->nid,
'link_options' => $options,
'date' => $date,
'date_class' => $date_class,
'teaser' => check_markup($data->teaser),
'image' => $image,
'tags' => theme('item_list', $tags, NULL, 'ul', array('class' => 'tags'))
);
$items[] = array('data'=> theme($_template, $node), 'class'=> str_replace('_', '-',$_template));
$i++;
}
return $items;
}
/**
* Returns the content of last block.
*
* @param $_type
* A string containing the type.
* @param $_dossier
* An object containing all informations the about a dossier.
* In particularly, name and tags ID separated by commas.
* @param $_title
* By default set to NULL (no title). It can be set to TRUE (default title).
* It can be also a string.
* @param $_nb
* The number of elements to return. By default 8.
* @param $_offset
* ...
* @param $_attributes
* The attributes applied to the list element.
*
* @return
* A string containing html, ready to be display.
*/
function lqdn_latest_nodes_list($_type, $_dossier = NULL, $_title = NULL, $_nb = 8, $_offset = 0, $_attributes = NULL) {
switch ($_type) {
case 'rp':
$class = 'last-rp';
$title = t('Latest press articles on %dossier_name', array('%dossier_name' => $_dossier->name));
break;
case 'actu':
$class = 'last-actu';
$title = t('Latest news on %dossier_name', array('%dossier_name' => $_dossier->name));
break;
default:
$class = 'latest-nodes';
$title = '';
}
if ($_title === NULL || is_string($_title)) {
$title = $_title;
}
$items = lqdn_latest_nodes_list_items($_type, $_dossier, $_nb, $_offset);
return (count($items) <= 0) ? '' : '<div class="' . $class . '">' . theme('item_list', $items, $title, 'ul', $_attributes) . '</div>';
}
/**
* Implementation of hook_block().
*/
function lqdn_latest_nodes_block($op = 'list', $delta = 0, $edit = array()) {
global $language;
if ($op == 'list') {
$blocks[0]['info'] = t('The latest news');
$blocks[1]['info'] = t('Latest news');
$blocks[2]['info'] = t('Latest press articles');
$blocks[3]['info'] = t('Latest publications');
$blocks[4]['info'] = t('Latest publications (news and press articles)');
return $blocks;
}
else if ($op == 'configure' && $delta == 1) {
$form['ignore_the_latest_news'] = array(
'#type' => 'checkbox',
'#title' => t('Ignore the last news'),
'#default_value' => variable_get('ignore_the_latest_news', 1),
);
return $form;
}
else if ($op == 'save' && $delta == 1) {
variable_set('ignore_the_latest_news', $edit['ignore_the_latest_news']);
}
else if ($op == 'view') {
/**
* @todo gestion multilingue
*/
$more_pages = array(
1 => array('en' => 'news', 'fr' => 'actualite' ),
2 => array('en' => 'press-review', 'fr' => 'revue-de-presse'),
);
switch($delta) {
case 0:
$block = array(
'subject' => '',
'content' => _lqdn_latest_nodes_the_latest_news(),
);
break;
case 1:
$block = array();
$block['subject'] = t("Quad'news");
$block['content'] = _lqdn_latest_nodes_latest_news();
break;
case 2:
$block = array();
$block['subject'] = t('Press review');
$block['content'] = _lqdn_latest_nodes_latest_press_articles();
break;
case 3:
$block = array(
'subject' => t('Latest content'),
'content' => _lqdn_latest_nodes_latest_nodes() . '<div style="clear:both;"></div>',
);
break;
case 4:
$block = array(
'subject' => '',
'content' => _lqdn_latest_nodes_latest_news_and_press_articles(),
);
}
if ($delta >= 1 && $delta <= 2) {
$p = $more_pages[$delta][$language->language];
$block['content'] .= '<p>»&nbsp;' . l(t('Read more'), $p) . '</p>' .
'<div style="clear:both;"></div>';
}
return $block;
}
}
function _lqdn_latest_nodes_the_latest_news() {
global $language;
$query = "
SELECT n.`nid`, n.`created`
FROM `node` n
WHERE n.`status` <> 0
AND (n.`type` in ('actualite'))
AND (n.`language` in ('***NO_LANGUAGE***', '%s', ''))
ORDER BY n.`sticky` DESC, n.`created` DESC
LIMIT 1
";
$data = db_fetch_object(db_query(db_rewrite_sql($query), $language->language));
$node = node_load($data->nid);
//var_dump($node);
//return node_view($node, 1);
/*$tags = '<ul class="links inline">';
foreach($node->taxonomy as $taxo) {
$tags .= '<li class="taxonomy_term_' . $taxo->tid . '"><a title="" rel="tag" href="' . url('taxonomy/term/' . $taxo->tid) . '">' . str_replace(' ', '&nbsp;', $taxo->name) . '</a></li>';
}
$tags .= '</ul>';*/
$nb_files = count($node->files);
$content = '';
$content .= '<div id="very-last-news">';
$content .= ' <h2 class="tampon">' . t('Hot news!') . '</h2>';
$content .= ' <h3 class="title">';
$content .= ' ' . l($node->title, 'node/' . $node->nid);
$content .= ' </h3>';
$content .= ' ' . check_markup($node->teaser);
if (!empty($nb_files)) {
$text = format_plural($nb_files, '1 attachment', '@count attachments');
$path = "node/$node->nid";
$options = array('attributes' => array('title' => t('Read full article to view attachments.')),
'fragment' => 'attachments',
);
$attachments = l($text, $path, $options);
}
$metas = ' <ul class="metas">';
$metas .= ' <li class="submitted">' . format_date($node->created) . '</li>';
$metas .= ' <li class="more">' . l('» ' . t('Read more'), 'node/' . $node->nid) . '</li>';
if (!empty($attachments)) {
$metas .= ' <li class="attachments">(' . $attachments . ')</li>';
}
/*if (module_exists('lqdn_share_links')) {
$metas .= ' <li class="share-links">' . _lqdn_share_links($node) . '</li>';
}*/
//$metas .= ' <li class="tags">' . $tags . '</li>';
$metas .= ' </ul>';
$content .= $metas;
$content .= '</div>';
return $content;
}
function _lqdn_latest_nodes_latest_news() {
$offset = variable_get('ignore_the_latest_news', 1);
return _lqdn_latest_nodes_the_latest_news() .
lqdn_latest_nodes_list('actu', NULL, NULL, 10, $offset, NULL) .
'
<p><a href="#" class="more-nodes" data-type="actu">More...</a></p>
<script type="text/javascript">
$("a.more-nodes").click(function(){
$elem = $(this).parent().parent().find("div.last-actu div.item-list ul");
var from = $elem.find("li").size();
var type = $(this).attr("data-type");
var url = "/more-nodes/" + from + "/" + type + "/-";
$.getJSON(url, function(json){$elem.append($(json.content).hide().fadeIn(2000));});
return false;
});
</script>
';
}
function _lqdn_latest_nodes_latest_press_articles() {
return lqdn_latest_nodes_list('rp', NULL, NULL, 10, 0, NULL);
}
function _lqdn_latest_nodes_latest_nodes() {
return lqdn_latest_nodes_list(NULL, NULL, NULL, 10, 0, NULL);
}
//function lqdn_latest_nodes_list_items($_type, $_dossier = NULL, $_nb = 8, $_offset = 0)
function _lqdn_latest_nodes_latest_news_and_press_articles($_dossier = NULL, $_nb = 8, $_complete = 3) {
global $language;
drupal_add_css(drupal_get_path('module', 'lqdn_latest_nodes') . '/lqdn_latest_nodes.css');
drupal_add_js(drupal_get_path('module', 'lqdn_latest_nodes') . '/lqdn_latest_nodes.js');
if (empty($_dossier->name)) {
if ($language->language=="en") {
$l = l("Read more Quad'News", 'news');
}
else {
$l = l("La suite des Quadr'Actu", 'actualite');
}
}
else {
if ($language->language=="en") {
$l = l(t("Read more Quad'News about @dossier", array('@dossier' => $_dossier->name)), 'quad-news/' . $_dossier->machine_name);
}
else {
$l = l(t("La suite des Quadr'Actu sur @dossier", array('@dossier' => $_dossier->name)), 'quad-news/' . $_dossier->machine_name);
}
}
$moreactu = '<div class="prmore">' . $l . '</div>';
$quadnews_content = array_merge(
lqdn_latest_nodes_list_items('actu', $_dossier, $_complete, 0, 'complete_item'),
lqdn_latest_nodes_list_items('actu', $_dossier, ($_nb - $_complete), $_complete),
array($moreactu)
);
if (empty($_dossier)) {
if ($language->language=="en") {
$l = l("Read full press reviews", 'press-review');
}
else {
$l = l("Toute la revue de presse", 'revue-de-presse');
}
}
else {
if ($language->language=="en") {
$l = l(t("Read full press review about @dossier", array('@dossier' => $_dossier->name)), 'press-review/' . $_dossier->machine_name);
}
else {
$l = l(t("Toute la revue de presse sur @dossier", array('@dossier' => $_dossier->name)), 'press-review/' . $_dossier->machine_name);
}
}
$morepr = '<div class="prmore">' . $l . '</div>';
$pressreview_content = array_merge(
lqdn_latest_nodes_list_items('rp', $_dossier, $_complete, 0, 'complete_item'),
lqdn_latest_nodes_list_items('rp', $_dossier, ($_nb - $_complete), $_complete),
array($morepr)
);
$content = array(
(object)array(
'title' => t("Quad'news"),
'content' => $quadnews_content,
'id' => 'quadnews',
),
(object)array(
'title' => t("Press review"),
'content' => $pressreview_content,
'id' => 'pressreview',
),
);
return theme('tab_switcher', $content);
}
/**
* Implementation of hook_theme().
*/
function lqdn_latest_nodes_theme() {
return array(
'tab_switcher' => array(
'template' => 'tab-switcher',