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. include_once(override('../news/' . SQL . '.inc.php'));
  12.  
  13.  
  14.  
  15. /**
  16.  * get_latestnews_id()
  17.  * return latestnews_id
  18.  *
  19.  * @return int or false
  20.  */
  21.  
  22. function get_latestnews_id()
  23. {
  24.     global $sql_object;
  25.  
  26.     $r = $sql_object->DBSelect(SQL_getLatestNews());
  27.  
  28.     if(isset($r[0])) return $r[0]['news_id'];
  29.  
  30.     return false;
  31. }
  32.  
  33. /**
  34.  * DisplayListNews()
  35.  * Affichage de la liste des news publique
  36.  *
  37.  * @param  $statut 
  38.  * @param  $filter 
  39.  * @param  $id_filter 
  40.  * @param  $debut 
  41.  * @return void echo content
  42.  */
  43. if(!function_exists('DisplayListNews')) {
  44.  
  45.   function DisplayListNews($statut, $filter, $id_filter, $debut)
  46.   {
  47.     if ($statut == 'public') {
  48.       $pas = SELECT_LIMIT;
  49.       $suffix = '';
  50.     } else $pas = SELECT_LIMIT;
  51.     
  52.     
  53.     if ($statut == 'archives_p') $suffix = ' "'.strtolower(_t('statut','PA')).'"';
  54.     $data = $GLOBALS['sql_object']->DBSelect(SQL_getNewsList($debut, $pas, $statut, $filter, $id_filter));
  55.     $datacount = $GLOBALS['sql_object']->DBSelect(SQL_getCountNewsList($statut, $filter, $id_filter));
  56.     $bdd_nb_com = $datacount[0]['num_rows'];
  57.     $bdd_nb_com_display = '<p>' . $bdd_nb_com . ' ' . _t('news','name2') . $suffix . '</p>' . END_LINE;
  58.     $content = '<h1>' . _t('news','list') . '</h1>' . END_LINE;
  59.     if ($data != 0) {
  60.       // echo $bdd_nb_com_display;    // affichage du nombre d'enregistrements
  61.       $current_link = array('rub' => $GLOBALS['links'][U_L][ActiveItemKey($GLOBALS['activeitem'])]['linkvalue']);
  62.       $content .= get_linkin_page($current_link, $bdd_nb_com, $debut, $pas);
  63.       
  64.       for($i = 0; $i < count($data); $i++) {
  65.         $link_detail = array('rub' => $GLOBALS['links'][U_L]['news']['linkvalue'], 'id' => $data[$i]['news_id'], 'name' => $data[$i]['news_title']);
  66.         $link_theme = array('rub' => $GLOBALS['links'][U_L]['news']['linkvalue'], 'filter' => $GLOBALS['filters'][U_L]['theme']['linkvalue'], 'id' => $data[$i]['sdtheme_id'], 'name' => $data[$i]['sdtheme_name']);
  67.         $link_level = array('rub' => $GLOBALS['links'][U_L]['news']['linkvalue'], 'filter' => $GLOBALS['filters'][U_L]['level']['linkvalue'], 'id' => $data[$i]['news_level'], 'name' => $data[$i]['level_name']);
  68.         $link_scale = array('rub' => $GLOBALS['links'][U_L]['news']['linkvalue'], 'filter' => $GLOBALS['filters'][U_L]['scale']['linkvalue'], 'id' => $data[$i]['news_scale'], 'name' => $data[$i]['scale_denomination']);
  69.         $link_user = array('rub' => $GLOBALS['links'][U_L]['user-profile']['linkvalue'], 'id' => $data[$i]['news_posted_by'], 'name' => $data[$i]['user_login']);
  70.         $news_title = formatText($data[$i]['complete_news_title'], '2HTML');
  71.         $news_header = formatText($data[$i]['news_header'], '2HTML');
  72.         $news_sdtheme = formatText($data[$i]['sdtheme_name'], '2HTML');
  73.         $level_name = formatText($data[$i]['level_name'], '2HTML');
  74.         $scale_denomination = formatText($data[$i]['scale_denomination'], '2HTML');
  75.         $news_posted_on = formatText($data[$i]['news_published_date_display'], '2HTML');
  76.         $news_posted_by = formatText($data[$i]['user_login'], '2HTML');
  77.  
  78.         $content .= '<h2>'.END_LINE;
  79.         $content .= '<a href="' . HrefMaker($link_detail) . '" title="' . formatText($news_title, '2ATT') . '">' . $news_title . '</a>' . END_LINE;
  80.         $content .= '</h2>' . END_LINE;
  81.         $content .= '<p class="published_by">' . END_LINE;
  82.         $content .= '<span class="published-on">'._t('statut','published_on') . '</span> <span class="date">' . $news_posted_on . '</span> ';
  83.         $content .= _t('divers','by').' <a href="' . HrefMaker($link_user) . '" title="' . $GLOBALS['links'][U_L]['user-profile']['desc'] . ' (' . $news_posted_by . ')">' . $news_posted_by . '</a>';
  84.         $content .= '</p>' . END_LINE;
  85.          
  86.         $content .= '<div class="chapo">' . $news_header . '</div>' . END_LINE;
  87.         $content .= '<a class="readmore" href="'.HrefMaker($link_detail).'">'._t('btn', 'read_more').'</a>';
  88.         $content .= '<p class="filter_info">';
  89.         $content .= _t('divers','level') . ' : ';
  90.         $content .= '<a href="' . HrefMaker($link_level) . '" title="' . $GLOBALS['filters'][U_L]['level']['desc'] . ' : ' . formatText($level_name, '2ATT') . '" class="filter_info_level">' . $level_name . '</a> ' . END_LINE;
  91.         $content .= _t('divers','themeref') . ' : ';
  92.         $content .= ' <a href="' . HrefMaker($link_theme) . '" title="' . $GLOBALS['filters'][U_L]['theme']['desc'] . ' : ' . formatText($news_sdtheme, '2ATT') . '" class="filter_info_theme">' . $news_sdtheme . '</a>' . END_LINE;
  93.         $content .= _t('divers','scale') . ' : ';
  94.         $content .= ' <a href="' . HrefMaker($link_scale) . '" title="' . $GLOBALS['filters'][U_L]['scale']['desc'] . ' : ' . formatText($scale_denomination, '2ATT') . '" class="filter_info_scale">' . $scale_denomination . '</a></p>' . END_LINE;
  95.         if($i<count($data)-1) $content .= '<hr />' . END_LINE;
  96.       }
  97.     } else {
  98.       $content .= '<p class="info">' . _t('divers','nodata') . '</p>';
  99.     }
  100.     $content .= get_linkin_page($current_link, $bdd_nb_com, $debut, $pas);
  101.  
  102.     echo $content;
  103.   }
  104. }
  105.  
  106. /**
  107.  * DisplayOneNews()
  108.  * Affichage d'une actualté en détail
  109.  *
  110.  * @param  $news_id 
  111.  * @return $stat Nom du statut + echo content
  112.  */
  113. if(!function_exists('DisplayOneNews')) {
  114.  
  115.   function DisplayOneNews($news_id, $display_comments = true)
  116.   {
  117.     $data = $GLOBALS['sql_object']->DBSelect(SQL_getoneCompleteNews($news_id, array('P', 'PA')));
  118.     $content = '';
  119.     
  120.     if($data == 0) error_redirect();
  121.     
  122.     if (count($data) != 1) exit;
  123.     else {
  124.       $link_theme = array('rub' => $GLOBALS['links'][U_L]['news']['linkvalue'], 'filter' => $GLOBALS['filters'][U_L]['theme']['linkvalue'], 'id' => $data[0]['theme_sd_theme'], 'name' => $data[0]['sdtheme_name']);
  125.       $link_level = array('rub' => $GLOBALS['links'][U_L]['news']['linkvalue'], 'filter' => $GLOBALS['filters'][U_L]['level']['linkvalue'], 'id' => $data[0]['news_level'], 'name' => $data[0]['level_name']);
  126.       $link_scale = array('rub' => $GLOBALS['links'][U_L]['news']['linkvalue'], 'filter' => $GLOBALS['filters'][U_L]['scale']['linkvalue'], 'id' => $data[0]['news_scale'], 'name' => $data[0]['scale_denomination']);
  127.       $link_user = array('rub' => $GLOBALS['links'][U_L]['user-profile']['linkvalue'], 'id' => $data[0]['news_posted_by'], 'name' => $data[0]['user_login']);
  128.       $link_self = array('rub' => $GLOBALS['links'][U_L]['news']['linkvalue'], 'id' => $news_id);
  129.       $news_title = formatText($data[0]['news_title'], '2HTML');
  130.       $news_header = linkin_content(formatText($data[0]['news_header'], '2HTML'));
  131.       $news_body = linkin_content(formatText($data[0]['news_body'], '2HTML'));
  132.       $news_sdtheme = formatText($data[0]['sdtheme_name'], '2HTML');
  133.       $news_scale_denomination = formatText($data[0]['scale_denomination'], '2HTML');
  134.       $news_theme = formatText($data[0]['theme_name'], '2HTML');
  135.       $news_level = formatText($data[0]['level_name'], '2HTML');
  136.       $news_posted_on = formatText($data[0]['news_published_date_display'], '2HTML');
  137.       $news_modify_on = formatText($data[0]['news_last_modify_display'], '2HTML');
  138.       $news_posted_by = formatText($data[0]['user_login'], '2HTML');
  139.       $news_statut = $data[0]['news_statut'];
  140.  
  141.       if(commentEnabled('news') && $display_comments == true) {
  142.         postCommentAction(array('module'=> ActiveItemKey($GLOBALS['activeitem']), 'module_id'=> $news_id));
  143.         $content .= '<div id="anchor-comments">'.END_LINE;
  144.         $content .= getCommentsAnchor(array('module'=> ActiveItemKey($GLOBALS['activeitem']), 'module_id'=> $news_id));
  145.         if($news_statut == 'P') $content .= getPostCommentAnchor();
  146.         $content .= '</div>'.END_LINE;
  147.       }
  148.       $content .= '<h1>' . $news_title . '</h1>' . END_LINE;
  149.  
  150.       $content .= '<p class="published_by">' . END_LINE;
  151.       $content .= '<span class="published-on">'._t('statut','published_on') . '</span> <span class="date">' . $news_posted_on . '</span> ';
  152.       $content .= _t('divers','by').' <a href="' . HrefMaker($link_user) . '" title="' . $GLOBALS['links'][U_L]['user-profile']['desc'] . ' (' . $news_posted_by . ')">' . $news_posted_by . '</a>';
  153.       if ($news_statut == 'PA') {
  154.         $content .= ' (' . _t('statut','archived_on') . ' ' . $news_modify_on . ')';
  155.       }
  156.       $content .= formatted_permalink($link_self, ' - ');
  157.       $content .= '</p>' . END_LINE;
  158.  
  159.       $content .= '<div class="chapo">' . $news_header . '</div>' . END_LINE;
  160.       $content .= '<div class="body">' . $news_body . '</div>' . END_LINE;
  161.  
  162.       $content .= '<p class="filter_info">' . END_LINE;
  163.       $content .= _t('divers','level') . ' : ';
  164.       $content .= '<a href="' . HrefMaker($link_level) . '" title="' . $GLOBALS['filters'][U_L]['level']['desc'] . ' : ' . formatText($news_level, '2ATT') . '" class="filter_info_level">' . $news_level . '</a> ' . END_LINE;
  165.       $content .= ' ' . _t('divers','themeref') . ' : ';
  166.       $content .= '<a href="' . HrefMaker($link_theme) . '" title="' . $GLOBALS['filters'][U_L]['theme']['desc'] . ' : ' . formatText($news_sdtheme, '2ATT') . '" class="filter_info_theme">' . $news_sdtheme . '</a> ';
  167.       //$content .= ' '._t('divers','sousthemeref') . ' :';
  168.       //$content .= $news_theme . END_LINE;
  169.       $content .= ' ' . _t('divers','scale') . ' : ';
  170.       $content .= '<a href="' . HrefMaker($link_scale) . '" title="' . $GLOBALS['filters'][U_L]['scale']['desc'] . ' : ' . formatText($news_scale_denomination, '2ATT') . '" class="filter_info_scale">' . $news_scale_denomination . '</a>' . END_LINE;
  171.       $content .= '</p>' . END_LINE;
  172.     }
  173.     echo $content;
  174.     return GetStatutName($news_statut);
  175.   }
  176. }
  177.  
  178. /**
  179.  * GetStatutName()
  180.  *
  181.  * @param  $statut 
  182.  * @return $stat Nom du statut
  183.  */
  184. if(!function_exists('GetStatutName')) {
  185.  
  186.   function GetStatutName($statut)
  187.   {
  188.     switch ($statut) {
  189.       case 'P':
  190.         $stat = 'public';
  191.         break;
  192.       case 'PA':
  193.         $stat = 'archives_p';
  194.         break;
  195.       case 'AA':
  196.         $stat = 'archives_a';
  197.         break;
  198.       default:
  199.         $stat = 'public';
  200.     }
  201.     return $stat;
  202.   }
  203. }
  204.  
  205. /**
  206.  * DisplayLinkNews()
  207.  * Affiche ou non 1 lien vers les news a venir ou qui précéde.
  208.  *
  209.  * @param  $current_news 
  210.  * @param  $direction 
  211.  * @param  $statut 
  212.  * @return echo content
  213.  */
  214. if(!function_exists('DisplayLinkNews')) {
  215.  
  216.   function DisplayLinkNews($current_news, $direction, $statut)
  217.   {
  218.     $q = SQL_getNewsRangeAndDate($current_news);
  219.     $r = $GLOBALS['sql_object']->DBSelect($q);
  220.  
  221.     $range = $r[0]['news_range'];
  222.     $published_date = $r[0]['news_published_date'];
  223.  
  224.     if ($direction == 'NEXT') {
  225.       if($range != 0) {
  226.         $q = SQL_getNextNewsByRange($current_news, $range, $statut);
  227.       } else {
  228.         $q = SQL_getNextNewsByDate($current_news, $published_date, $statut);
  229.       }
  230.       $class = 'next';
  231.       $prefix = ' | ';
  232.       $suffix = ' →';
  233.       $title = _t('news','next_news');
  234.     }
  235.     if ($direction == 'PREVIOUS') {
  236.       if($range != 0) {
  237.         $q = SQL_getPreviousNewsByRange($current_news, $range, $statut);
  238.       } else {
  239.         $q = SQL_getPreviousNewsByDate($current_news, $published_date, $statut);
  240.       }
  241.       $class = 'previous';
  242.       $prefix = '← ';
  243.       $suffix = '';
  244.       $title = _t('news','prev_news');
  245.     }
  246.     $data = $GLOBALS['sql_object']->DBSelect($q);
  247.  
  248.     if ($data == false || count($data) != 1) $content = '';
  249.     else {
  250.       $link_news = array('rub' => $GLOBALS['links'][U_L]['news']['linkvalue'], 'id' => $data[0]['news_id'], 'name' => $data[0]['news_title']);
  251.       $news_complete_title = formatText($data[0]['news_title'], '2HTML');
  252.       $news_title = formatText(cutText($data[0]['news_title'], 45), '2HTML');
  253.  
  254.       $content = '<div class="' . $class . '">' . END_LINE;
  255.       $content .= $prefix . END_LINE;
  256.       $content .= '<a href="' . HrefMaker($link_news) . '" title="' . $title .' : '.formatText($news_complete_title, '2ATT'). '">' . $news_title .'</a>';
  257.       $content .= $suffix . END_LINE;
  258.       $content .= '</div>' . END_LINE;
  259.     }
  260.     echo $content;
  261.   }
  262. }
  263.  
  264. ?>

Documentation generated on Thu, 20 Mar 2014 16:47:55 +0100 by phpDocumentor 1.4.1