<?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
 */

include_once(override('../yellowpages/display.php'));
$GLOBALS['filters'][U_L]['theme']['active'] = 1; // filter activation

SetHTMLTitle(_t('yp','section'));

// récupération des variables GET et POST
if (isset($_REQUEST['id']) && !isset($_REQUEST['filter'])) {
  $yp_id=$_REQUEST['id'];
}
else $yp_id=-1;

if (isset($_REQUEST['filter'])) {
 	if ($_REQUEST['filter']=="alpha") {
 	  $filter_id=$_REQUEST['id'];
 	  $filter="alpha";
 	}
 	if ($_REQUEST['filter']==$GLOBALS['filters'][U_L]['theme']['linkvalue']) {

 	  $filter_id=$_REQUEST['id'];
 	  $filter=$GLOBALS['filters'][U_L]['theme']['linkvalue'];
 	}
}
else {
  $filter_id=-1;
  $filter=-1;
}
if (isset($_REQUEST['debut'])) $debut=$_REQUEST['debut'];
else $debut=0;


// Handle navigation
if (ActiveItemKey($GLOBALS['activeitem'])== 'directory-detail' || $filter!=-1 || ActiveItemKey($GLOBALS['activeitem'])== 'directory-add') {
	$link_archive= array('rub'=> $GLOBALS['links'][U_L]['directory']['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>';
}

if (ActiveItemKey($GLOBALS['activeitem'])=='directory' || ActiveItemKey($GLOBALS['activeitem'])== 'directory-detail') {
  
  
  /**
   * affichage de l'annuaire
   **/
  //DisplayUrlAddYellowpages();
  //DisplayAlphaBeta($filter,$filter_id);
  if(ActiveItemKey($GLOBALS['activeitem']) == 'directory') {
	  echo '<h1>'._t('yp','list').'</h1>'.END_LINE;
	  echo '<div class="sub-title">'._t('yp','h1_public_comment').'</div>';
	  echo DisplayUrlAddYellowpages().'<div style="clear:both"></div>';
	  if ($yp_id==-1) {
	    DisplayListYellowPages($debut, SELECT_LIMIT, $filter, $filter_id);
	    setBreadcrumb(array(ucfirst(_t('yp', 'section')) => false));
	
	  }
  }
  /**
   * affichage d'une organisation
   **/
  else {
    // set HTML Title
    $result=$GLOBALS['sql_object']->DBSelect(SQL_getOneYpName($yp_id));
    SetHTMLTitle(formatText($result[0]['yellowp_name'], '2HTML'));
    setBreadcrumb(array(ucfirst(_t('yp', 'section')) => HrefMaker(array('rub'=> $GLOBALS['links'][U_L]['directory']['linkvalue']))));
    setBreadcrumb(array(formatText($result[0]['yellowp_name'], '2HTML') => false));

    echo DisplayOneYellowPages($yp_id);
  }
}
/**
 * affichage du formulaire d'ajout
 **/
else {
  setBreadcrumb(array(ucfirst(_t('yp', 'section')) => HrefMaker(array('rub'=> $GLOBALS['links'][U_L]['directory']['linkvalue']))));
  setBreadcrumb(array(_t('yp','add_public') => false));
  echo '<br style="clear:both" />';
  echo '<h1>'._t('yp','add_public').'</h1>'.END_LINE;
  echo DisplayAddYellowPages();
}

?>
