<?php
/**
 * @package linea21.core
 * @subpackage public
 * @author linea21 <info@linea21.com>
 * @version $id SVN
 * @access public
 * @license http://opensource.org/licenses/gpl-3.0.html
 */
?>

<?php
//////////////////////////////////////////
/////affichage partie dossier
//////////////////////////////////////////

if(ActiveItemKey($GLOBALS['activeitem']) == 'publication' || ActiveItemKey($GLOBALS['activeitem']) == 'publication-archives') {

  SetHTMLTitle(_t('publication','section')); // set HTML title
  setBreadcrumb(array(ucfirst(formatText(_t('publication', 'section'), '2HTML')) => false));


  if(ActiveItemKey($GLOBALS['activeitem']) == 'publication') {
    $GLOBALS['filters'][U_L]['theme']['active'] = 1; // filter activation
    $GLOBALS['filters'][U_L]['level']['active'] = 1; // filter activation
    $GLOBALS['filters'][U_L]['scale']['active'] = 1; // filter activation
  }
  include_once(override('../publication/display.php'));
  /** préparation des variables
   * 	$statut
   * 	$debut default 0
   * 	$id -> default -1
   * 	$filter default -1
   **/
  if(ActiveItemKey($GLOBALS['activeitem'])=='publication') $statut='public';
  if(ActiveItemKey($GLOBALS['activeitem'])=='publication-archives') $statut='archives_p';
  if(isset($_REQUEST['id'])) $id=$_REQUEST['id']; else $id=-1;
  if(isset($_REQUEST['debut'])) $debut=$_REQUEST['debut']; else $debut=0;
  if(isset($_REQUEST['filter'])) {
    if($_REQUEST['filter']==$GLOBALS['filters'][U_L]['scale']['linkvalue']) $filter='SCALE';
    if($_REQUEST['filter']==$GLOBALS['filters'][U_L]['theme']['linkvalue']) $filter='THEME';
    if($_REQUEST['filter']==$GLOBALS['filters'][U_L]['level']['linkvalue']) $filter='LEVEL';
  } else $filter=-1;


  /** Affichage du lien de consultation d'archives ( si nécessaire
   */
  if(ActiveItemKey($GLOBALS['activeitem']) != 'publication-archives')  {

    $link_archive= array('rub'=> $GLOBALS['links'][U_L]['publication-archives']['linkvalue']);
    echo '<div class="switchnav">';
    echo '<a class="button" href="'.HrefMaker($link_archive).'" title="'._t('divers','goto_archives').'">'._t('divers','goto_archives').'</a>'.END_LINE;
    echo '</div>';
  }

  /** Affichage du lien de consultation de la liste courante ( si nécessaire
   */
  if(ActiveItemKey($GLOBALS['activeitem']) == 'publication-archives')  {

    $link_archive= array('rub'=> $GLOBALS['links'][U_L]['publication']['linkvalue']);
    echo '<div class="switchnav">';
    echo '<a class="button" href="'.HrefMaker($link_archive).'" title="'._t('divers','goto_currentlist').'">'._t('divers','goto_currentlist').'</a>'.END_LINE;
    echo '</div>';
  }

  /** Affichage du Listing Des Dossiers et Dossiers archivés
   */
  if((isset($_REQUEST['id']) && isset($_REQUEST['filter'])) || (!isset($_REQUEST['id']) && !isset($_REQUEST['filter'])))
  {
  	$content= '<h1>'._t('publication','listing').'</h1>'.END_LINE;
  	$content.='<div class="sub-title">';
  	$content.=_t('publication','h1_public_comment');
  	$content.='</div>';
  	
  	echo $content;
  	
    DisplayListPublication($statut, $filter, $id, $debut);
  }


  /** Détail d'un dossier
   */
  if(isset($_REQUEST['id']) && !isset($_REQUEST['filter'])) {
    // set HTML Title
    $result=$GLOBALS['sql_object']->DBSelect(SQL_getPublicationTitle($id));
    SetHTMLTitle(formatText($result[0]['publi_title'], '2HTML'));
    setBreadcrumb(array(ucfirst(formatText(_t('publication', 'section'), '2HTML')) => HrefMaker(array('rub'=> $GLOBALS['links'][U_L]['publication']['linkvalue'])), formatText($result[0]['publi_title'], '2HTML') => false));
    
    $publi_statut=DisplayOnePublication($id);
    DisplayPublicationParts($id);
    echo '<div id="ressources">'.END_LINE;
    DisplayPublicationLinks($id);
    DisplayPublicationMulti($id);
    DisplayPublicationBiblio($id);
    echo '</div>'.END_LINE;
    if(commentEnabled('publication')) {
      echo '<h3>'._t('comment', 'section').'</h3>'.END_LINE;
      echo '<div id="comments">'.END_LINE;
      displayComments(array('module'=> 'publication', 'module_id'=> $id, 'order_by' => 'ASC'), false, true);
      if($publi_statut == 'P') displayCommentForm(array('module'=> 'publication', 'module_id'=> $id));
      echo '</div>'.END_LINE;
    }
  }
}

//////////////////////////////////////////
/////affichage rapport de groupe de travail
//////////////////////////////////////////

if(ActiveItemKey($GLOBALS['activeitem']) == 'report') {
  include_once(override('../workshoprep/display.php'));

  SetHTMLTitle(_t('workshoprep','section')); // set HTML title
  setBreadcrumb(array(ucfirst(formatText(_t('workshop', 'name'), '2HTML')) => HrefMaker(array('rub'=> $GLOBALS['links'][U_L]['workgroup']['linkvalue']))));
  /** préparation des variables
   * 	$id -> default -1
   **/
  if(isset($_REQUEST['id'])) $id=$_REQUEST['id']; else $id=-1;

  /** Détail d'un rapport
   */
  if(isset($_REQUEST['id'])) {
    $result=$GLOBALS['sql_object']->DBSelect(SQL_getoneCompleteWorkshopRep($id));
    $status = $result[0]['workrep_statut'];
    SetHTMLTitle(formatText($result[0]['workrep_title']. ' ('.$result[0]['workshop_denomination'].')', '2HTML'));
    setBreadcrumb(array(formatText($result[0]['workshop_denomination'], '2HTML') => HrefMaker(array('rub'=> $GLOBALS['links'][U_L]['workgroup']['linkvalue'], 'id' => $result[0]['workrep_workshop_id'], 'name' => formatText($result[0]['workshop_denomination'], '2HTML')))));

    DisplayOneWorkshopRep($id);
    DisplayWorkshopRepParts($id);
    echo '<div id="ressources">'.END_LINE;
    DisplayWorkshopRepLinks($id);
    DisplayWorkshopRepBiblio($id);
    echo '</div>'.END_LINE;
    if(commentEnabled('report')) {
      echo '<h3>'._t('comment', 'section').'</h3>'.END_LINE;
      echo '<div id="comments">'.END_LINE;
      displayComments(array('module'=> 'report', 'module_id'=> $id, 'order_by' => 'ASC'), false, true);
      if($status == 'P') displayCommentForm(array('module'=> 'report', 'module_id'=> $id));
      echo '</div>'.END_LINE;
    }
  }

}


//////////////////////////////////////////
/////	affichage Parties par parties
/////	Rapports de groupe de travail et Dossiers
//////////////////////////////////////////

if(ActiveItemKey($GLOBALS['activeitem']) =='report-part' || ActiveItemKey($GLOBALS['activeitem']) == 'publication-part') {
  include_once(override('../contents/display.php'));

  /** préparation des variables
   * 	$id -> default -1
   *   $parentid -> default -1
   **/

  if(isset($_REQUEST['id'])) $id=$_REQUEST['id']; else $id=-1;
  if(isset($_REQUEST['parentid'])) $parentid=$_REQUEST['parentid']; else $parentid=-1;

  /** Détail d'une partie
   */
  if(ActiveItemKey($GLOBALS['activeitem']) =='report-part')
  {
    include_once(override('../workshoprep/display.php'));

    SetHTMLTitle(_t('workshoprep','section')); // set HTML title
    $result=$GLOBALS['sql_object']->DBSelect(SQL_getoneCompleteWorkshopRep($parentid));
    $status = $result[0]['workrep_statut'];
    SetHTMLTitle(formatText($result[0]['workrep_title']. ' ('.$result[0]['workshop_denomination'].')', '2HTML'));
    setBreadcrumb(array(ucfirst(formatText(_t('workshop', 'name'), '2HTML')) => HrefMaker(array('rub'=> $GLOBALS['links'][U_L]['workgroup']['linkvalue']))));
    setBreadcrumb(array(formatText($result[0]['workshop_denomination'], '2HTML') => HrefMaker(array('rub'=> $GLOBALS['links'][U_L]['workgroup']['linkvalue'], 'id' => $result[0]['workrep_workshop_id'], 'name' => formatText($result[0]['workshop_denomination'], '2HTML')))));
    setBreadcrumb(array(formatText($result[0]['workrep_title'], '2HTML') => false));

    $result=$GLOBALS['sql_object']->DBSelect(SQL_getOneWorkshopParts($id));

    SetHTMLTitle(formatText($result[0]['workrepcon_title'], '2HTML'));
    
    DisplayWorkshopNameAndGroup($parentid);

    DisplayWorkshopRepLinkinPart($id, $parentid, 'TEXT');
    if(commentEnabled('report')) {
      postCommentAction(array('module'=> 'report', 'module_id'=> $parentid));
      echo '<div id="anchor-comments">'.END_LINE;
      echo getCommentsAnchor(array('module'=> 'report', 'module_id'=> $parentid));
      if($status == 'P') echo getPostCommentAnchor();
      echo '</div>'.END_LINE;
    }
    DisplayOneWorkshopPart($id);
    echo '<div class="nextprev">'.END_LINE;
    DisplayLinkParts($id, $parentid, 'PREVIOUS', 'W');
    DisplayLinkParts($id, $parentid, 'NEXT', 'W');
    echo '</div>'.END_LINE;
    echo '<div id="ressources">'.END_LINE;
    DisplayWorkshopRepLinks($parentid);
    DisplayWorkshopRepBiblio($parentid);
    echo '</div>'.END_LINE;
    if(commentEnabled('report')) {
      echo '<h3>'._t('comment', 'section').'</h3>'.END_LINE;
      echo '<div id="comments">'.END_LINE;
      displayComments(array('module'=> 'report', 'module_id'=> $parentid, 'order_by' => 'ASC'), false, true);
      if($status == 'P') displayCommentForm(array('module'=> 'report', 'module_id'=> $parentid));
      echo '</div>'.END_LINE;
    }
  }
  if(ActiveItemKey($GLOBALS['activeitem']) == 'publication-part')
  {
    include_once(override('../publication/display.php'));

    SetHTMLTitle(_t('publication','section')); // set HTML title
    $result=$GLOBALS['sql_object']->DBSelect(SQL_getPublicationTitle($parentid));
    $status = $result[0]['publi_statut'];
    SetHTMLTitle(formatText($result[0]['publi_title'], '2HTML'));
    setBreadcrumb(array(ucfirst(formatText(_t('publication', 'section'), '2HTML')) => HrefMaker(array('rub'=> $GLOBALS['links'][U_L]['publication']['linkvalue'])), formatText($result[0]['publi_title'], '2HTML') => HrefMaker(array('rub'=> $GLOBALS['links'][U_L]['publication']['linkvalue'], 'id' => $parentid, 'name' => formatText($result[0]['publi_title'], '2HTML')))));
    $result=$GLOBALS['sql_object']->DBSelect(SQL_getOnePublicationParts($id));
    SetHTMLTitle(formatText($result[0]['publicon_title'], '2HTML'));

    DisplayPublicationTitle($parentid);
    if(commentEnabled('publication')) {
      postCommentAction(array('module'=> 'publication', 'module_id'=> $parentid));
      echo '<div id="anchor-comments">'.END_LINE;
      echo getCommentsAnchor(array('module'=> 'publication', 'module_id'=> $parentid));
      if($status == 'P') echo getPostCommentAnchor();
      echo '</div>'.END_LINE;
    }
    DisplayPublicationLinkinPart($id, $parentid, 'TEXT');
    DisplayOnePublicationPart($id);
    echo '<div class="nextprev">'.END_LINE;
    DisplayLinkParts($id, $parentid, 'PREVIOUS', 'P');
    DisplayLinkParts($id, $parentid, 'NEXT', 'P');
    echo '</div>'.END_LINE;
    echo '<div id="ressources">'.END_LINE;
    DisplayPublicationLinks($parentid);
    DisplayPublicationMulti($parentid);
    DisplayPublicationBiblio($parentid);
    echo '</div>'.END_LINE;
    if(commentEnabled('publication')) {
      echo '<h3>'._t('comment', 'section').'</h3>'.END_LINE;
      echo '<div id="comments">'.END_LINE;
      displayComments(array('module'=> 'publication', 'module_id'=> $parentid, 'order_by' => 'ASC'), false, true);
      if($status == 'P') displayCommentForm(array('module'=> 'publication', 'module_id'=> $parentid));
      echo '</div>'.END_LINE;
    }
  }


}


//////////////////////////////////////////
/////affichage partie news
//////////////////////////////////////////

if(ActiveItemAlias($GLOBALS['activeitem'])=='news') {

  SetHTMLTitle(_t('news','section')); // set HTML title
  setBreadcrumb(array(ucfirst(formatText(_t('news', 'section'), '2HTML')) => false));

  if(ActiveItemKey($GLOBALS['activeitem'])=='news') {
    $GLOBALS['filters'][U_L]['theme']['active'] = 1; // filter activation
    $GLOBALS['filters'][U_L]['level']['active'] = 1; // filter activation
    $GLOBALS['filters'][U_L]['scale']['active'] = 1; // filter activation
  }
  include_once(override('../news/display.php'));
  /** préparation des variables
   * 	$statut
   * 	$debut default 0
   * 	$id -> default -1
   * 	$filter default -1
   **/
  if(ActiveItemKey($GLOBALS['activeitem'])=='news') $statut='public';
  if(ActiveItemKey($GLOBALS['activeitem'])=='news-archives') $statut='archives_p';
  if(isset($_REQUEST['id'])) $id=$_REQUEST['id']; else $id=-1;
  if(isset($_REQUEST['debut'])) $debut=$_REQUEST['debut']; else $debut=0;
  if(isset($_REQUEST['filter'])) {
    if($_REQUEST['filter']==$GLOBALS['filters'][U_L]['scale']['linkvalue']) $filter='SCALE';
    if($_REQUEST['filter']==$GLOBALS['filters'][U_L]['theme']['linkvalue']) $filter='THEME';
    if($_REQUEST['filter']==$GLOBALS['filters'][U_L]['level']['linkvalue']) $filter='LEVEL';
  } else $filter=-1;

  /** Affichage du lien de consultation d'archives ( si nécessaire
   */

  if(ActiveItemKey($GLOBALS['activeitem']) != 'news-archives')  {

    $link_archive= array('rub'=> $GLOBALS['links'][U_L]['news-archives']['linkvalue']);

    echo '<div class="switchnav">';
    echo '<a class="button" href="'.HrefMaker($link_archive).'" title="'._t('divers','goto_archives').'">'._t('divers','goto_archives').'</a>'.END_LINE;
    echo '</div>';

  }


  /** Affichage du lien de consultation liste principale ( si nécessaire
   */
  if(ActiveItemKey($GLOBALS['activeitem']) == 'news-archives')  {

    $link_archive= array('rub'=> $GLOBALS['links'][U_L]['news']['linkvalue']);

    echo '<div class="switchnav">';
    echo '<a class="button" href="'.HrefMaker($link_archive).'" title="'._t('divers','goto_currentlist').'">'._t('divers','goto_currentlist').'</a>'.END_LINE;
    echo '</div>';

  }

  /** Affichage du Listing Actualité + Archives
   */

  if((isset($_REQUEST['id']) && isset($_REQUEST['filter'])) || (!isset($_REQUEST['id']) && !isset($_REQUEST['filter'])))
  {
    DisplayListNews($statut, $filter, $id, $debut);
  }


  /** Détail d'une actualité
   */
  if(isset($_REQUEST['id']) && !isset($_REQUEST['filter'])) {

    // set HTML Title
    $result=$GLOBALS['sql_object']->DBSelect(SQL_getNewsTitle($id));
    SetHTMLTitle(formatText($result[0]['news_title'], '2HTML'));
    setBreadcrumb(array(ucfirst(formatText(_t('news', 'section'), '2HTML')) => HrefMaker(array('rub'=> $GLOBALS['links'][U_L]['news']['linkvalue'])), formatText($result[0]['news_title'], '2HTML') => false));
    
    $news_statut=DisplayOneNews($id);
    echo '<hr />'.END_LINE;
    echo '<div class="nextprev">'.END_LINE;
    DisplayLinkNews($id, 'PREVIOUS', $news_statut);
    DisplayLinkNews($id, 'NEXT', $news_statut);
    echo '</div>'.END_LINE;
    if(commentEnabled('news')) {
      echo '<h3>'._t('comment', 'section').'</h3>'.END_LINE;
      echo '<div id="comments">'.END_LINE;
      displayComments(array('module'=> ActiveItemKey($GLOBALS['activeitem']), 'module_id'=> $id, 'order_by' => 'ASC'), false, true);
      if($news_statut == 'public') displayCommentForm(array('module'=> ActiveItemKey($GLOBALS['activeitem']), 'module_id'=> $id));
      echo '</div>'.END_LINE;
    }
  }


}

//////////////////////////////////////////
/////affichage partie projet
//////////////////////////////////////////

if(ActiveItemAlias($GLOBALS['activeitem'])=='project') {

  include_once(override('../project/display.php'));
  SetHTMLTitle(_t('project','section')); // set HTML title
  setBreadcrumb(array(ucfirst(formatText(_t('project', 'section'), '2HTML')) => false));
  

  $GLOBALS['filters'][U_L]['priority']['active'] = 1; // filter activation
  /** préparation des variables
  * 	$statut
  * 	$debut default 0
  * 	$id -> default -1
  * 	$filter default -1
  **/
  if(ActiveItemKey($GLOBALS['activeitem'])=='project') $statut='public';
  if(ActiveItemKey($GLOBALS['activeitem'])=='project-archives') $statut='archives_p';
  if(isset($_REQUEST['id'])) $id=$_REQUEST['id']; else $id=-1;
  if(isset($_REQUEST['debut'])) $debut=$_REQUEST['debut']; else $debut=0;
  if(isset($_REQUEST['filter'])) {
    if($_REQUEST['filter']==$GLOBALS['filters'][U_L]['scale']['linkvalue']) $filter='SCALE';
    if($_REQUEST['filter']==$GLOBALS['filters'][U_L]['priority']['linkvalue']) $filter='PRIORITY';
    if($_REQUEST['filter']==$GLOBALS['filters'][U_L]['theme']['linkvalue']) $filter='THEME';

  } else $filter=-1;

  /** Affichage du lien de consultation d'archives ( si nécessaire
   */

  if(ActiveItemKey($GLOBALS['activeitem']) != 'project-archives')  {

  	$link_archive= array('rub'=> $GLOBALS['links'][U_L]['project-archives']['linkvalue']);
  	$link_project= array('rub'=> $GLOBALS['links'][U_L]['project']['linkvalue']);

  	echo '<div class="switchnav">';
  	if(isset($_REQUEST['id']) && isset($_REQUEST['filter'])) {
  		echo '<a class="button" href="'.HrefMaker($link_project).'" title="'._t('divers','goto_currentlist').'">'._t('divers','goto_currentlist').'</a>'.END_LINE;
  	}
  	echo '<a class="button" href="'.HrefMaker($link_archive).'" title="'._t('divers','goto_archives').'">'._t('divers','goto_archives').'</a>'.END_LINE;
  	echo '</div>';

  }
   
  /** Affichage du lien de consultation liste principale ( si nécessaire
   */
  if(ActiveItemKey($GLOBALS['activeitem']) == 'project-archives')  {

  	$link_project= array('rub'=> $GLOBALS['links'][U_L]['project']['linkvalue']);

  	echo '<div class="switchnav">';
  	 
  	echo '<a class="button" href="'.HrefMaker($link_project).'" title="'._t('divers','goto_currentlist').'">'._t('divers','goto_currentlist').'</a>'.END_LINE;
  	echo '</div>';

  }


  /** Affichage du lien de consultation liste principale ( si nécessaire
   */
  //	if(ActiveItemKey($GLOBALS['activeitem']) == 'project-archives')  {
  //
  //		$link_archive= array('rub'=> $GLOBALS['links'][U_L]['news']['linkvalue']);
  //
  //		echo '<div class="switchnav">';
  //		echo '<a class="button" href="'.HrefMaker($link_archive).'" title="'._t('divers','goto_currentlist').'">'._t('divers','goto_currentlist').'</a>'.END_LINE;
  //		echo '</div>';
  //
  //	}

  /** Affichage du Listing Projets + Archives
   */
  
  if((isset($_REQUEST['id']) && isset($_REQUEST['filter'])) || (!isset($_REQUEST['id']) && !isset($_REQUEST['filter'])))
  {
  	echo '<h1>' . _t('project','list') . '</h1>' . END_LINE;
  	
    DisplayListProject($statut, $filter, $id, $debut);
		//  DisplayListProjectByThemes($statut, $filter, $id, $debut);
  }


  /** Détail d'un projet
   */
  if(isset($_REQUEST['id']) && !isset($_REQUEST['filter'])) {

    // set HTML Title
    $result=$GLOBALS['sql_object']->DBSelect(SQL_getProjectName($id));
    SetHTMLTitle(formatText($result[0]['project_name'], '2HTML'));
    setBreadcrumb(array(ucfirst(formatText(_t('project', 'section'), '2HTML')) => HrefMaker(array('rub'=> $GLOBALS['links'][U_L]['project']['linkvalue'])), formatText($result[0]['project_name'], '2HTML') => false));

    $project_status=DisplayOneProject($id);
    if(commentEnabled('project')) {
      echo '<h3>'._t('comment', 'section').'</h3>'.END_LINE;
      echo '<div id="comments">'.END_LINE;
      displayComments(array('module'=> 'project', 'module_id'=> $id, 'order_by' => 'ASC'), false, true);
      if($project_status == 'public') displayCommentForm(array('module'=> ActiveItemKey($GLOBALS['activeitem']), 'module_id'=> $id));
      echo '</div>'.END_LINE;
    }
  }

}
?>