linea21-modules
[ class tree: linea21-modules ] [ index: linea21-modules ] [ all elements ]

Source for file display.php

Documentation is available at display.php

  1. <?php
  2. /**
  3.  * @package linea21.modules
  4.  * @subpackage news
  5.  * @author linea21 <info@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  */
  10.  
  11. themeInclude('../news/' . SQL . '.inc.php');
  12.  
  13. /**
  14.  * DisplayListNews()
  15.  * Affichage de la liste des news publique
  16.  *
  17.  * @param  $statut 
  18.  * @param  $filter 
  19.  * @param  $id_filter 
  20.  * @param  $debut 
  21.  * @return void echo content
  22.  */
  23. function DisplayListNews($statut, $filter, $id_filter, $debut)
  24. {
  25.   if ($statut == 'public') {
  26.     $pas = 100;
  27.     $suffix = '';
  28.   } else $pas = SELECT_LIMIT;
  29.   if ($statut == 'archives_p') $suffix = ' "'.strtolower(_t('statut','PA')).'"';
  30.   $data = $GLOBALS['sql_object']->DBSelect(SQL_getNewsList($debut, $pas, $statut, $filter, $id_filter));
  31.   $datacount = $GLOBALS['sql_object']->DBSelect(SQL_getCountNewsList($statut, $filter, $id_filter));
  32.   $bdd_nb_com = $datacount[0]['num_rows'];
  33.   $bdd_nb_com_display = '<p>' . $bdd_nb_com . ' ' . _t('news','name2') . $suffix . '</p>' . END_LINE;
  34.   $content = '<h1 class="semnone">' . _t('news','list') . '</h1>' . END_LINE;
  35.   if ($data != 0) {
  36.     // echo $bdd_nb_com_display;    // affichage du nombre d'enregistrements
  37.     $current_link = array('rub' => $GLOBALS['links'][LANGUAGE]['news-archives']['linkvalue']);
  38.     Display_linkin_page($current_link, $bdd_nb_com, $debut, $pas);
  39.     for($i = 0; $i < count($data); $i++) {
  40.       $link_detail = array('rub' => $GLOBALS['links'][LANGUAGE]['news']['linkvalue'], 'id' => $data[$i]['news_id'], 'name' => $data[$i]['news_title']);
  41.       $link_theme = array('rub' => $GLOBALS['links'][LANGUAGE]['news']['linkvalue'], 'filter' => $GLOBALS['filters'][LANGUAGE]['theme']['linkvalue'], 'id' => $data[$i]['sdtheme_id'], 'name' => $data[$i]['sdtheme_name']);
  42.       $link_level = array('rub' => $GLOBALS['links'][LANGUAGE]['news']['linkvalue'], 'filter' => $GLOBALS['filters'][LANGUAGE]['level']['linkvalue'], 'id' => $data[$i]['news_level'], 'name' => $data[$i]['level_name']);
  43.       $link_scale = array('rub' => $GLOBALS['links'][LANGUAGE]['news']['linkvalue'], 'filter' => $GLOBALS['filters'][LANGUAGE]['scale']['linkvalue'], 'id' => $data[$i]['news_scale'], 'name' => $data[$i]['scale_denomination']);
  44.       $link_user = array('rub' => $GLOBALS['links'][LANGUAGE]['user-profile']['linkvalue'], 'id' => $data[$i]['news_posted_by'], 'name' => $data[$i]['user_login']);
  45.       $news_title = formatText($data[$i]['complete_news_title'], '2HTML');
  46.       $news_header = formatText(cutText($data[$i]['news_header'], 300), '2HTML');
  47.       $news_sdtheme = formatText($data[$i]['sdtheme_name'], '2HTML');
  48.       $level_name = formatText($data[$i]['level_name'], '2HTML');
  49.       $scale_denomination = formatText($data[$i]['scale_denomination'], '2HTML');
  50.       $news_posted_on = formatText($data[$i]['news_published_date_display'], '2HTML');
  51.       $news_posted_by = formatText($data[$i]['user_login'], '2HTML');
  52.  
  53.       $content .= '<h2 class="nobottommargin"><a href="' . HrefMaker($link_detail) . '" title="' . formatText($news_title, '2ATT') . '">' . $news_title . '</a>' . END_LINE;
  54.       $content .= '</h2>' . END_LINE;
  55.       $content .= '<p class="published_by">' . END_LINE;
  56.       $content .= _t('statut','published_on') . ' ' . $news_posted_on . ' ';
  57.       $content .= _t('divers','by').' <a href="' . HrefMaker($link_user) . '" title="' . $GLOBALS['links'][LANGUAGE]['user-profile']['desc'] . ' (' . $news_posted_by . ')">' . $news_posted_by . '</a>';
  58.       $content .= '</p>' . END_LINE;
  59.           
  60.       $content .= '<p class="list_textcontent">' . $news_header . '</p>' . END_LINE;
  61.       $content .= '<p class="filter_info">';
  62.       $content .= _t('divers','level') . ' : ';
  63.       $content .= '<a href="' . HrefMaker($link_level) . '" title="' . $GLOBALS['filters'][LANGUAGE]['level']['desc'] . ' : ' . formatText($level_name, '2ATT') . '" class="filter_info_level">' . $level_name . '</a> ' . END_LINE;
  64.       $content .= _t('divers','themeref') . ' : ';
  65.       $content .= ' <a href="' . HrefMaker($link_theme) . '" title="' . $GLOBALS['filters'][LANGUAGE]['theme']['desc'] . ' : ' . formatText($news_sdtheme, '2ATT') . '" class="filter_info_theme">' . $news_sdtheme . '</a>' . END_LINE;
  66.       $content .= _t('divers','scale') . ' : ';
  67.       $content .= ' <a href="' . HrefMaker($link_scale) . '" title="' . $GLOBALS['filters'][LANGUAGE]['scale']['desc'] . ' : ' . formatText($scale_denomination, '2ATT') . '" class="filter_info_scale">' . $scale_denomination . '</a></p>' . END_LINE;
  68.       if($i<count($data)-1) $content .= '<hr />' . END_LINE;
  69.     }
  70.   } else {
  71.     $content .= '<p class="info">' . _t('divers','nodata') . '</p>';
  72.   }
  73.  
  74.   echo $content;
  75. }
  76.  
  77. /**
  78.  * DisplayOneNews()
  79.  * Affichage d'une actualté en détail
  80.  *
  81.  * @param  $news_id 
  82.  * @return $stat Nom du statut + echo content
  83.  */
  84. function DisplayOneNews($news_id)
  85. {
  86.   $data = $GLOBALS['sql_object']->DBSelect(SQL_getoneCompleteNews($news_id));
  87.   $content = '';
  88.   if (count($data) != 1) exit;
  89.   else {
  90.     $link_theme = array('rub' => $GLOBALS['links'][LANGUAGE]['news']['linkvalue'], 'filter' => $GLOBALS['filters'][LANGUAGE]['theme']['linkvalue'], 'id' => $data[0]['theme_sd_theme'], 'name' => $data[0]['sdtheme_name']);
  91.     $link_level = array('rub' => $GLOBALS['links'][LANGUAGE]['news']['linkvalue'], 'filter' => $GLOBALS['filters'][LANGUAGE]['level']['linkvalue'], 'id' => $data[0]['news_level'], 'name' => $data[0]['level_name']);
  92.     $link_scale = array('rub' => $GLOBALS['links'][LANGUAGE]['news']['linkvalue'], 'filter' => $GLOBALS['filters'][LANGUAGE]['scale']['linkvalue'], 'id' => $data[0]['news_scale'], 'name' => $data[0]['scale_denomination']);
  93.     $link_user = array('rub' => $GLOBALS['links'][LANGUAGE]['user-profile']['linkvalue'], 'id' => $data[0]['news_posted_by'], 'name' => $data[0]['user_login']);
  94.     $link_self = array('rub' => $GLOBALS['links'][LANGUAGE]['news']['linkvalue'], 'id' => $news_id);
  95.     $news_title = formatText($data[0]['news_title'], '2HTML');
  96.     $news_header = linkin_content(formatText($data[0]['news_header'], '2HTML'));
  97.     $news_body = linkin_content(formatText($data[0]['news_body'], '2HTML'));
  98.     $news_template = $data[0]['news_template'];
  99.     $news_photo_uri = $data[0]['news_photo_uri'];
  100.     $news_sdtheme = formatText($data[0]['sdtheme_name'], '2HTML');
  101.     $news_scale_denomination = formatText($data[0]['scale_denomination'], '2HTML');
  102.     $news_theme = formatText($data[0]['theme_name'], '2HTML');
  103.     $news_level = formatText($data[0]['level_name'], '2HTML');
  104.     $news_posted_on = formatText($data[0]['news_published_date_display'], '2HTML');
  105.     $news_modify_on = formatText($data[0]['news_last_modify_display'], '2HTML');
  106.     $news_posted_by = formatText($data[0]['user_login'], '2HTML');
  107.     $news_statut = $data[0]['news_statut'];
  108.  
  109.     $contents = TemplateFormat($news_title, $news_header, $news_body, $news_template, $news_photo_uri);
  110.  
  111.     $content .= '<h1 class="nobottommargin">' . $news_title . '</h1>' . END_LINE;
  112.     $content .= '<p class="published_by">' . END_LINE;
  113.     $content .= _t('statut','published_on') . ' ' . $news_posted_on . ' ';
  114.     $content .= _t('divers','by').' <a href="' . HrefMaker($link_user) . '" title="' . $GLOBALS['links'][LANGUAGE]['user-profile']['desc'] . ' (' . $news_posted_by . ')">' . $news_posted_by . '</a>';
  115.     if ($news_statut == 'PA') {
  116.       $content .= ' (' . _t('statut','archived_on') . ' ' . $news_modify_on . ')';
  117.     }
  118.     $content .= formatted_permalink($link_self, ' - ');
  119.     $content .= '</p>' . END_LINE;
  120.  
  121.     $content .= $contents;
  122.  
  123.     $content .= '<p class="filter_info">' . END_LINE;
  124.     $content .= _t('divers','level') . ' : ';
  125.     $content .= '<a href="' . HrefMaker($link_level) . '" title="' . $GLOBALS['filters'][LANGUAGE]['level']['desc'] . ' : ' . formatText($news_level, '2ATT') . '" class="filter_info_level">' . $news_level . '</a> ' . END_LINE;
  126.     $content .= ' ' . _t('divers','themeref') . ' : ';
  127.     $content .= '<a href="' . HrefMaker($link_theme) . '" title="' . $GLOBALS['filters'][LANGUAGE]['theme']['desc'] . ' : ' . formatText($news_sdtheme, '2ATT') . '" class="filter_info_theme">' . $news_sdtheme . '</a> ';
  128.     //$content .= ' '._t('divers','sousthemeref') . ' :';
  129.     //$content .= $news_theme . END_LINE;
  130.     $content .= ' ' . _t('divers','scale') . ' : ';
  131.     $content .= '<a href="' . HrefMaker($link_scale) . '" title="' . $GLOBALS['filters'][LANGUAGE]['scale']['desc'] . ' : ' . formatText($news_scale_denomination, '2ATT') . '" class="filter_info_scale">' . $news_scale_denomination . '</a>' . END_LINE;
  132.     $content .= '</p>' . END_LINE;
  133.   }
  134.   echo $content;
  135.   return GetStatutName($news_statut);
  136. }
  137.  
  138. /**
  139.  * GetStatutName()
  140.  *
  141.  * @param  $statut 
  142.  * @return $stat Nom du statut
  143.  */
  144. function GetStatutName($statut)
  145. {
  146.   switch ($statut) {
  147.     case 'P':
  148.       $stat = 'public';
  149.       break;
  150.     case 'PA':
  151.       $stat = 'archives_p';
  152.       break;
  153.     case 'AA':
  154.       $stat = 'archives_a';
  155.       break;
  156.     default:
  157.       $stat = 'public';
  158.   }
  159.   return $stat;
  160. }
  161.  
  162. /**
  163.  * DisplayLinkNews()
  164.  * Affiche ou non 1 lien vers les news a venir ou qui précéde.
  165.  *
  166.  * @param  $current_news 
  167.  * @param  $direction 
  168.  * @param  $statut 
  169.  * @return echo content
  170.  */
  171. function DisplayLinkNews($current_news, $direction, $statut)
  172. {
  173.   if ($direction == 'NEXT') {
  174.     $requete = SQL_getNextNews($current_news, $statut);
  175.     $class = 'next';
  176.     $prefix = '&gt; &gt; ';
  177.     $suffix = '';
  178.     $title = _t('news','next_news');
  179.   }
  180.   if ($direction == 'PREVIOUS') {
  181.     $requete = SQL_getPreviousNews($current_news, $statut);
  182.     $class = 'previous';
  183.     $prefix = '';
  184.     $suffix = ' &lt; &lt;';
  185.     $title = _t('news','prev_news');
  186.   }
  187.   $data = $GLOBALS['sql_object']->DBSelect($requete);
  188.  
  189.   if ($data == false || count($data) != 1) $content = '';
  190.   else {
  191.     $link_news = array('rub' => $GLOBALS['links'][LANGUAGE]['news']['linkvalue'], 'id' => $data[0]['news_id'], 'name' => $data[0]['news_title']);
  192.     $news_complete_title = formatText($data[0]['news_title'], '2HTML');
  193.     $news_title = formatText(cutText($data[0]['news_title'], 45), '2HTML');
  194.  
  195.     $content = '<div class="' . $class . '">' . END_LINE;
  196.     $content .= $prefix . END_LINE;
  197.     $content .= '<a href="' . HrefMaker($link_news) . '" title="' . $title .' : '.formatText($news_complete_title, '2ATT'). '">' . $news_title .'</a>';
  198.     $content .= $suffix . END_LINE;
  199.     $content .= '</div>' . END_LINE;
  200.   }
  201.   echo $content;
  202. }
  203.  
  204. /**
  205.  * TemplateFormat()
  206.  * Mise en page de l'actualité suivant son format
  207.  *
  208.  * @param  $title 
  209.  * @param  $header 
  210.  * @param  $body 
  211.  * @param  $template 
  212.  * @param  $photouri 
  213.  * @return $content 
  214.  */
  215. function TemplateFormat($title, $header, $body, $template, $photouri)
  216. {
  217.   // '3' Template 2 photos
  218.   if ($template == 3) {
  219.     list($photo1_src, $photo2_src) = GetAllPhotoUri($photouri);
  220.     list($body, $body2) = cutBody($body);
  221.   }
  222.   if ($template == 1 || $template == 2) list($photo1_src) = GetAllPhotoUri($photouri);
  223.   if ($template == 1) $style = ' class="tplimgleft"';
  224.   if ($template == 2 || $template == 3) $style = ' class="tplimgright"';
  225.  
  226.   $content = '<div>';
  227.   if ($template != 4) $content .= EnlargeImage('../' . $photo1_src, $style, 'visuel ' . $title);
  228.   $content .= '<p class="chapo">' . $header . '</p>' . END_LINE;
  229.   $content .= '<p class="textcontent">' . $body . '</p>' . END_LINE;
  230.   if ($template == 3) {
  231.     $style = ' class="tplimgleft"';
  232.     $content .= EnlargeImage('../' . $photo2_src, $style, 'visuel ' . $title);
  233.     $content .= '<p class="textcontent">' . $body2 . '</p>' . END_LINE;
  234.   }
  235.   $content .= '</div>';
  236.   $content .= '<br style="clear:both" />';
  237.  
  238.   return $content;
  239. }
  240.  
  241. ?>

Documentation generated on Fri, 16 Oct 2009 09:31:54 +0200 by phpDocumentor 1.4.1