<?php
/**
 * Default directory template
 * 
 * This file can be overriden. Discover logic and examples on :
 * @url http://dev.linea21.com/projects/linea21/wiki/Override
 * @url http://dev.linea21.com/projects/linea21/wiki/Personnalisation_de_l%27interface_publique
 * 
 * @package linea21\core\public
 * @author $Author$ - linea21 <info@linea21.com>
 * @version $Id$ 
 * @access public
 * @license http://opensource.org/licenses/gpl-3.0.html
 */

include_once(override('../yellowpages/display.php'));
$GLOBALS['filters'][U_L]['level']['active'] = 0; // 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]['level']['linkvalue']) {
 	  $filter_id=$_REQUEST['id'];
 	  $filter='LEVEL';
 	}
}
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>'.PHP_EOL;
	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>'.PHP_EOL;
	  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')) => HrefMaker(array('rub'=> $GLOBALS['links'][U_L]['directory']['linkvalue']))));

	  }
  }
  /**
   * 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>'.PHP_EOL;
  echo DisplayAddYellowPages();
}

?>
