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 project
  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('../project/' . SQL . '.inc.php');
  12.  
  13. /**
  14.  * DisplayListProject()
  15.  * Affichage de la liste des projets publics
  16.  *
  17.  * @param string $statut 
  18.  * @param integer $filter 
  19.  * @param string $id_filter 
  20.  * @param integer $debut 
  21.  * @return string $content
  22.  */
  23. function DisplayListProject($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_getProjectsList($debut, $pas, $statut, $filter, $id_filter));
  31.   $datacount = $GLOBALS['sql_object']->DBSelect(SQL_getCountProjectsList($statut, $filter, $id_filter));
  32.   $bdd_nb_com = $datacount[0]['num_rows'];
  33.   $bdd_nb_com_display = '<p>' . $bdd_nb_com . ' ' . _t('project','name') . $suffix . '</p>' . END_LINE;
  34.   $content = '<h1 class="semnone">' . _t('project','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]['project']['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]['project']['linkvalue'], 'id' => $data[$i]['project_id'], 'name' => $data[$i]['project_name']);
  41.       $link_scale = array('rub' => $GLOBALS['links'][LANGUAGE]['project']['linkvalue'], 'filter' => $GLOBALS['filters'][LANGUAGE]['scale']['linkvalue'], 'id' => $data[$i]['project_scale_id'], 'name' => $data[$i]['scale_denomination']);
  42.       $link_priority = array('rub' => $GLOBALS['links'][LANGUAGE]['project']['linkvalue'], 'filter' => $GLOBALS['filters'][LANGUAGE]['priority']['linkvalue'], 'id' => $data[$i]['priority_id'] , 'name' => $data[$i]['priority_name']);
  43.       $link_user = array('rub' => $GLOBALS['links'][LANGUAGE]['user-profile']['linkvalue'], 'id' => $data[$i]['project_posted_by'], 'name' => $data[$i]['user_login']);
  44.       $project_name = formatText($data[$i]['complete_project_name'], '2HTML');
  45.       $project_description = formatText(cutText($data[$i]['project_description'], 300), '2HTML');
  46.       $scale_denomination = formatText($data[$i]['scale_denomination'], '2HTML');
  47.       $project_posted_on = formatText($data[$i]['project_published_date_display'], '2HTML');
  48.       $project_posted_by = formatText($data[$i]['user_login'], '2HTML');
  49.       $project_priority = formatText($data[$i]['priority_name'], '2HTML');
  50.       $project_theme_id = $data[$i]['project_theme_id'];
  51.       if($project_theme_id != 0) {
  52.         $project_theme = formatText($data[$i]['sdtheme_name'], '2HTML');
  53.         $link_theme = array('rub' => $GLOBALS['links'][LANGUAGE]['project']['linkvalue'], 'filter' => $GLOBALS['filters'][LANGUAGE]['theme']['linkvalue'], 'id' => $data[$i]['theme_sd_theme'], 'name' => $project_theme);
  54.       }
  55.  
  56.       $content .= '<h2 class="nobottommargin"><a href="' . HrefMaker($link_detail) . '" title="' . formatText($project_name, '2ATT') . '">' . $project_name . '</a>' . END_LINE;
  57.       $content .= '</h2>' . END_LINE;
  58.       $content .= '<p class="published_by">' . END_LINE;
  59.       $content .= _t('statut','published_on') . ' ' . $project_posted_on . ' ';
  60.       $content .= _t('divers','by').' <a href="' . HrefMaker($link_user) . '" title="' . $GLOBALS['links'][LANGUAGE]['user-profile']['desc'] . ' (' . $project_posted_by . ')">' . $project_posted_by . '</a>';
  61.       $content .= '</p>' . END_LINE;
  62.        
  63.       $content .= '<p class="list_textcontent">' . $project_description . '</p>' . END_LINE;
  64.       $content .= '<p class="filter_info">';
  65.       $content .= _t('project','priority') . ' : ';
  66.       $content .= ' <a href="' . HrefMaker($link_priority) . '" title="' . $GLOBALS['filters'][LANGUAGE]['priority']['desc'] . ' : ' . formatText($project_priority, '2ATT') . '" class="filter_info_priority">' . $project_priority . '</a> ' . END_LINE;
  67.       $content .= _t('divers','scale') . ' : ';
  68.       $content .= ' <a href="' . HrefMaker($link_scale) . '" title="' . $GLOBALS['filters'][LANGUAGE]['scale']['desc'] . ' : ' . formatText($scale_denomination, '2ATT') . '" class="filter_info_scale">' . $scale_denomination . '</a>' . END_LINE;
  69.       if($project_theme_id != 0) {
  70.         $content .= ' ' . _t('divers','themeref') . ' : ';
  71.         $content .= '<a href="' . HrefMaker($link_theme) . '" title="' . $GLOBALS['filters'][LANGUAGE]['theme']['desc'] . ' : ' . formatText($project_theme, '2ATT') . '" class="filter_info_scale">' . $project_theme . '</a>' . END_LINE;
  72.       }
  73.       $content .= '</p>'.END_LINE;
  74.       if($i<count($data)-1) $content .= '<hr />' . END_LINE;
  75.     }
  76.   } else {
  77.     $content .= '<p class="info">' . _t('divers','nodata') . '</p>';
  78.   }
  79.  
  80.   echo $content;
  81. }
  82.  
  83. /**
  84.  * DisplayOneProject()
  85.  * Affichage d'un projet en détail
  86.  *
  87.  * @param integer $project_id 
  88.  * @return string $stat status name
  89.  */
  90. function DisplayOneProject($project_id)
  91. {
  92.   $data = $GLOBALS['sql_object']->DBSelect(SQL_getoneCompleteProject($project_id));
  93.   $content = '';
  94.   if (count($data) != 1) exit;
  95.   else {
  96.     $link_scale = array('rub' => $GLOBALS['links'][LANGUAGE]['project']['linkvalue'], 'filter' => $GLOBALS['filters'][LANGUAGE]['scale']['linkvalue'], 'id' => $data[0]['project_scale_id'], 'name' => $data[0]['scale_denomination']);
  97.     $link_priority = array('rub' => $GLOBALS['links'][LANGUAGE]['project']['linkvalue'], 'filter' => $GLOBALS['filters'][LANGUAGE]['priority']['linkvalue'], 'id' => $data[0]['project_priority_id'], 'name' => $data[0]['project_priority']);
  98.     $link_user = array('rub' => $GLOBALS['links'][LANGUAGE]['user-profile']['linkvalue'], 'id' => $data[0]['project_posted_by'], 'name' => $data[0]['user_login']);
  99.     $link_parent = array('rub' => $GLOBALS['links'][LANGUAGE]['project']['linkvalue'], 'id' => $data[0]['project_parent_id'], 'name' => $data[0]['parent_name']);
  100.     $link_self = array('rub' => $GLOBALS['links'][LANGUAGE]['project']['linkvalue'], 'id' => $project_id);
  101.     $project_name = formatText($data[0]['project_name'], '2HTML');
  102.     $project_description = linkin_content(formatText($data[0]['project_description'], '2HTML'));
  103.     $project_body = linkin_content(formatText($data[0]['project_body'], '2HTML'));
  104.     $project_parent = formatText($data[0]['parent_name'], '2HTML');
  105.     $project_scale = formatText($data[0]['scale_denomination'], '2HTML');
  106.     $project_priority = formatText($data[0]['project_priority'], '2HTML');
  107.     $project_begin_date = formatText(empty_nc($data[0]['project_begin_date_display']), '2HTML');
  108.     $project_estimated_date = formatText(empty_nc($data[0]['project_estimated_date_display']), '2HTML');
  109.     $project_end_date = formatText(empty_nc($data[0]['project_end_date_display']), '2HTML');
  110.     $workshop_id = formatText(empty_nc($data[0]['project_workshop_id']), '2HTML');
  111.     $workshop_name = formatText(empty_nc($data[0]['workshop_denomination']), '2HTML');
  112.     $scale_id = $data[0]['project_scale_id'];
  113.     $project_theme_id = $data[0]['project_theme_id'];
  114.     if($project_theme_id != 0) {
  115.       $project_theme = formatText($data[0]['sdtheme_name'], '2HTML');
  116.       $link_theme = array('rub' => $GLOBALS['links'][LANGUAGE]['project']['linkvalue'], 'filter' => $GLOBALS['filters'][LANGUAGE]['theme']['linkvalue'], 'id' => $data[0]['theme_sd_theme'], 'name' => $project_theme);
  117.     }
  118.  
  119.     $schedule_table = getScheduleTable($data[0]['project_begin_date_display'], $data[0]['project_estimated_date_display'], $data[0]['project_end_date_display']);
  120.  
  121.     $project_posted_on = formatText($data[0]['project_published_date_display'], '2HTML');
  122.     $project_modify_on = formatText($data[0]['project_last_modify_display'], '2HTML');
  123.     $project_posted_by = formatText($data[0]['user_login'], '2HTML');
  124.     $project_status = $data[0]['project_statut'];
  125.  
  126.     $content .= '<h1 class="nobottommargin">' . $project_name . '</h1>' . END_LINE;
  127.     $content .= '<p class="published_by">' . END_LINE;
  128.     $content .= _t('statut','published_on') . ' ' . $project_posted_on . ' ';
  129.     $content .= _t('divers','by').' <a href="' . HrefMaker($link_user) . '" title="' . $GLOBALS['links'][LANGUAGE]['user-profile']['desc'] . ' (' . $project_posted_by . ')">' . $project_posted_by . '</a>';
  130.     if ($project_status == 'PA') {
  131.       $content .= ' (' . _t('statut','archived_on') . ' ' . $project_modify_on . ')';
  132.     }
  133.     $content .= formatted_permalink($link_self, ' - ');
  134.     $content .= '</p>' . END_LINE;
  135.     if($data[0]['project_parent_id'] != 0) {
  136.       $content .= '<div id="parent_project">' . END_LINE;
  137.       $content .= _t('project','parent') . ' : ';
  138.       $content .= '<a href="' . HrefMaker($link_parent) . '" title="' . _t('project','parent') . ' : ' . formatText($project_parent, '2ATT') . '" class="filter_info_parent">' . $project_parent . '</a> ';
  139.       $content .= '</div>' . END_LINE;
  140.     }
  141.     $content .= '<p class="chapo">' . $project_description . '</p>' . END_LINE;
  142.  
  143.     $content .= '<div class="schedule">' . $schedule_table . '</div>' . END_LINE;
  144.     $content .= '<p class="textcontent">' . $project_body . '</p>' . END_LINE;
  145.     $content .= getProjectChildren($project_id);
  146.     $content .= getAssociatedIndicators($project_id, $scale_id);
  147.     $content .= getAssociatedWorkshop($workshop_id, $workshop_name);
  148.     $content .= '<p class="filter_info">' . END_LINE;
  149.     $content .= _t('project','priority') . ' : ';
  150.     $content .= '<a href="' . HrefMaker($link_priority) . '" title="' . $GLOBALS['filters'][LANGUAGE]['priority']['desc'] . ' : ' . formatText($project_priority, '2ATT') . '" class="filter_info_priority">' . $project_priority . '</a> ' . END_LINE;
  151.     $content .= ' ' . _t('divers','scale') . ' : ';
  152.     $content .= '<a href="' . HrefMaker($link_scale) . '" title="' . $GLOBALS['filters'][LANGUAGE]['scale']['desc'] . ' : ' . formatText($project_scale, '2ATT') . '" class="filter_info_scale">' . $project_scale . '</a>' . END_LINE;
  153.     if($project_theme_id != 0) {
  154.       $content .= ' ' . _t('divers','themeref') . ' : ';
  155.       $content .= '<a href="' . HrefMaker($link_theme) . '" title="' . $GLOBALS['filters'][LANGUAGE]['theme']['desc'] . ' : ' . formatText($project_theme, '2ATT') . '" class="filter_info_scale">' . $project_theme . '</a>' . END_LINE;
  156.     }
  157.     $content .= '</p>' . END_LINE;
  158.   }
  159.   echo $content;
  160.   return GetStatusName($project_status);
  161. }
  162.  
  163. /**
  164.  * GetProjectChildren()
  165.  *
  166.  * @param  $id 
  167.  * @return string 
  168.  */
  169. function getProjectChildren($id)
  170. {
  171.   $data = $GLOBALS['sql_object']->DBSelect(SQL_getProjectChildren($id));
  172.  
  173.   $content = '';
  174.   if (count($data) != 0 && $data[0]!=0) {
  175.  
  176.     $content .= '<div id="project_children">'.END_LINE;
  177.     $content .= '<p>'._t('project','sub-projects').' : </p><ul>'.END_LINE;
  178.     for($i = 0; $i < count($data); $i++) {
  179.       $link = array('rub' => $GLOBALS['links'][LANGUAGE]['project']['linkvalue'], 'id' => $data[$i]['project_id'], 'name' => $data[$i]['project_name']);
  180.       $name = formatText($data[$i]['project_name'], '2HTML');
  181.  
  182.       $content .= '<li><a href="' . HrefMaker($link) . '" title="' . _t('project','parent') . ' : ' . formatText($name, '2ATT') . '" class="filter_info_parent">' . $name . '</a></li>' .END_LINE;
  183.     }
  184.     $content .= '</ul></div>'.END_LINE;
  185.   }
  186.  
  187.   return $content;
  188. }
  189.  
  190. /**
  191.  * GetStatusName()
  192.  *
  193.  * @param  $status 
  194.  * @return $stat Status name
  195.  */
  196. function GetStatusName($status)
  197. {
  198.   switch ($status) {
  199.     case 'P':
  200.       $stat = 'public';
  201.       break;
  202.     case 'PA':
  203.       $stat = 'archives_p';
  204.       break;
  205.     case 'AA':
  206.       $stat = 'archives_a';
  207.       break;
  208.     default:
  209.       $stat = 'public';
  210.   }
  211.   return $stat;
  212. }
  213.  
  214. /**
  215.  * getScheduleTable()
  216.  *
  217.  * @param string $s_date 
  218.  * @param string $es_date 
  219.  * @param string $e_date 
  220.  * @return string $content
  221.  */
  222. function getScheduleTable($s_date, $es_date, $e_date) {
  223.  
  224.   $es_date_class = 'nothing';
  225.   $e_date_class = 'nothing';
  226.  
  227.   if(!isNullDate($es_date)) {
  228.     if(!isNullDate($e_date)) $es_date_class = date_compare($e_date, $es_date, '>') ? 'warn' : 'good';
  229.     else $es_date_class = date_compare(date("Y-m-d"), $es_date, '>') ? 'bad' : 'good';
  230.   }
  231.   if(!isNullDate($e_date)) {
  232.     if(!isNullDate($es_date)) $e_date_class = date_compare($e_date, $es_date, '>') ? 'bad' : 'good';
  233.     else $e_date_class = 'good';
  234.   } else {
  235.     if(!isNullDate($es_date)) {
  236.       $e_date_class = date_compare(date("Y-m-d"), $es_date, '>') ? 'warn' : 'nothing';
  237.     }
  238.   }
  239.  
  240.   $content  = '<table class="project" cellpading="0" cellspacing="0">'.END_LINE;
  241.   $content .= '<thead>'.END_LINE;
  242.   $content .= '<tr>'.END_LINE;
  243.   $content .= '<th>'._t('project','begin_date').'</th>'.END_LINE;
  244.   $content .= '<th>'._t('project','estimated_date').'</th>'.END_LINE;
  245.   $content .= '<th>'._t('project','end_date').'</th>'.END_LINE;
  246.   $content .= '</tr>'.END_LINE;
  247.   $content .= '</thead>'.END_LINE;
  248.   $content .= '<tbody>'.END_LINE;
  249.   $content .= '<tr>'.END_LINE;
  250.   $content .= '<td>'.formatText(empty_nc($s_date)).'</td>'.END_LINE;
  251.   $content .= '<td class="'.$es_date_class.'">'.formatText(empty_nc($es_date)).'</td>'.END_LINE;
  252.   $content .= '<td class="'.$e_date_class.'">'.formatText(empty_nc($e_date)).'</td>'.END_LINE;
  253.   $content .= '</tr>'.END_LINE;
  254.   $content .= '</tbody>'.END_LINE;
  255.   $content .= '</table>'.END_LINE;
  256.   return $content;
  257. }
  258.  
  259. /**
  260.  * getAssociatedWorkshop()
  261.  *
  262.  * @param  $id 
  263.  * @return string 
  264.  */
  265. function getAssociatedWorkshop($wid, $wname)
  266. {
  267.   $content = '';
  268.   if($wid != 0) {
  269.       $link = array('rub' => $GLOBALS['links'][LANGUAGE]['workgroup']['linkvalue'], 'id' => $wid, 'name' => $wname);
  270.       $content .= '<div id="project_workshop">'.END_LINE;
  271.       $content .= '<p>'.ucfirst(_t('project','workshop')).' : <a href="' . HrefMaker($link) . '" title="' . _t('project','workshop') . ' : ' . formatText($wname, '2ATT') . '">' . $wname . '</a></p>' .END_LINE;
  272.       $content .= '</div>'.END_LINE;
  273.   }
  274.  
  275.   return $content;
  276. }
  277.  
  278. /**
  279.  * getAssociatedWorkshop()
  280.  *
  281.  * @param  $id 
  282.  * @return string 
  283.  */
  284. function getAssociatedIndicators($id, $scale_id)
  285. {
  286.   $data = $GLOBALS['sql_object']->DBSelect(SQL_getProjectSdi($id));
  287.  
  288.   $content = '';
  289.   if (count($data) != 0 && $data[0]!=0) {
  290.  
  291.     $content .= '<div id="project_indicators">'.END_LINE;
  292.     $content .= '<p>'.ucfirst(_t('project','sdi')).' : </p>'.END_LINE;
  293.     $content .= '<ul>'.END_LINE;
  294.     for($i = 0; $i < count($data); $i++) {
  295.       $link = array('rub' => $GLOBALS['links'][LANGUAGE]['dashboard']['linkvalue'], 'id' => $data[$i]['sdii_id'], 'parentid' => $scale_id, 'name' => $data[$i]['sdii_name']);
  296.       $name = formatText($data[$i]['sdii_name'], '2HTML');
  297.  
  298.       $content .= '<li><a href="' . HrefMaker($link) . '" title="' . _t('project','sdi') . ' : ' . formatText($name, '2ATT') . '">' . $name . '</a></li>' .END_LINE;
  299.     }
  300.     $content .= '</ul></div>'.END_LINE;
  301.   }
  302.  
  303.   return $content;
  304. }
  305.  
  306.  
  307. ?>

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