<?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('../user/'.SQL.'.inc.php');

if(!function_exists('getPastEvents')) {
  function getPastEvents($nb) {

    global $sql_object;

    $data= $sql_object->DBSelect(SQLget_pastEvents($nb));

    if($data!=0)
    {
      $content= '<ul>';
      for($i=0; $i<count($data); $i++) {

        $link = HrefMaker(array('rub'=> $GLOBALS['links'][U_L]['calendar']['linkvalue'],'id'=>$data[$i]['workcal_workshop_id'], '#' => 'cal-'.$data[$i]['workcal_id']));
        $workshop_title =  _t('name', 'workshop_module') .' : '.formatText($data[$i]['workshop_denomination'], '2ATT');
        $workshop_task= formatText($data[$i]['workcal_task'], '2HTML');

        // no link if shared event
        if($data[$i]['workcal_workshop_id'] == 999999999) {
          $link = $_SERVER["PHP_SELF"].'#';
          $workshop_title =  _t('workshop_mod', 'event_common');
        }

        $content.= '<li><a href="'.$link.'" title="'.$workshop_title.'" class="tips">'.$data[$i]['task_date'].' : '.$workshop_task.'</a></li>';
      }
      $content.= '</ul>';
    } else {
      $content= '<p>'._t('divers', 'nodata').'</p>';
    }
    return $content;
  }
}

if(!function_exists('getIncomingEvents')) {
  function getIncomingEvents($nb) {
    global $sql_object;

    $data= $sql_object->DBSelect(SQLget_incomingEvents($nb));

    if($data!=0)
    {
      $content= '<ul>';
      for($i=0; $i<count($data); $i++) {

        $link = HrefMaker(array('rub'=> $GLOBALS['links'][U_L]['calendar']['linkvalue'],'id'=>$data[$i]['workcal_workshop_id'], '#' => 'cal-'.$data[$i]['workcal_id']));
        $workshop_title =  _t('name', 'workshop_module') .' : '.formatText($data[$i]['workshop_denomination'], '2ATT');
        $workshop_task= formatText($data[$i]['workcal_task'], '2HTML');

        // no link if shared event
        if($data[$i]['workcal_workshop_id'] == 999999999) {
          $link = $_SERVER["PHP_SELF"].'#';
          $workshop_title =  _t('workshop_mod', 'event_common');
        }

        $content.= '<li><a href="'.$link.'" title="'.$workshop_title.'" class="tips">'.$data[$i]['task_date'].' : '.$workshop_task.'</a></li>';
         
      }
      $content.= '</ul>';
    } else {
      $content= '<p>'._t('divers', 'nodata').'</p>';
    }
    return $content;
  }
}

if(!function_exists('getEvents')) {
	function getEvents($nb) {

		global $sql_object;

		$data= $sql_object->DBSelect(SQLget_Events($nb));

		if($data!=0)
		{
			$content= '<ul>';
			for($i=0; $i<count($data); $i++) {

				$link = HrefMaker(array('rub'=> $GLOBALS['links'][U_L]['calendar']['linkvalue'],'id'=>$data[$i]['workcal_workshop_id'], '#' => 'cal-'.$data[$i]['workcal_id']));
				$workshop_title =  _t('name', 'workshop_module') .' : '.formatText($data[$i]['workshop_denomination'], '2ATT');
				$workshop_task= formatText($data[$i]['workcal_task'], '2HTML');

				// no link if shared event
				if($data[$i]['workcal_workshop_id'] == 999999999) {
					$link = $_SERVER["PHP_SELF"].'#';
					$workshop_title =  _t('workshop_mod', 'event_common');
				}

				$content.= '<li><a href="'.$link.'" title="'.$workshop_title.'" class="tips">'.$data[$i]['task_date'].' : '.$workshop_task.'</a></li>';
			}
			$content.= '</ul>';
		} else {
			$content= '<p>'._t('divers', 'nodata').'</p>';
		}
		return $content;
	}
}

if(!function_exists('getWorkgroupList')) {
  function getWorkgroupList($nb) {

    global $sql_object;

    $data= $sql_object->DBSelect(SQLget_WorkshopList($nb));

    if($data!=0)
    {
      $content= '<ul id="vnav">';
      for($i=0; $i<count($data); $i++) {

        $workshop_title=formatText($data[$i]['workshop_denomination'], '2HTML');
        $workshop_resume=formatText($data[$i]['workshop_resume'], '2HTML');
        $content.='<li><a href="#tabs-'.$i.'" class="selected" title="'.formatText($workshop_title, '2ATT').'">'.$workshop_title.'</a></li>'.END_LINE;

      }
      $content.='</ul>';

      for($i=0; $i<count($data); $i++) {
         
        $link = array('rub'=> $GLOBALS['links'][U_L]['workgroup']['linkvalue'],'id'=>$data[$i]['workshop_id'],'name'=>$data[$i]['workshop_denomination']);
        $workshop_title=formatText($data[$i]['workshop_denomination'], '2HTML');
        $workshop_resume=formatText($data[$i]['workshop_resume'], '2HTML');
        $content.= '<div id="tabs-'.$i.'" class="ie6bugfix">';
        $content.= '<h3>'.$workshop_title.'</h3>'.END_LINE;
        $content.= '<div>'.$workshop_resume.'</div>';
        $content.= '<p><a href="'.HrefMaker($link).'" title="'.formatText($workshop_title, '2ATT').'" class="readmore">'._t('workshop', 'access_to').'</a></p>';
        $content.= '</div>';

      }
    }
    else
    {
      $content='<p class="info">'._t('divers','nodata').'</p>';
    }

    return $content;

  }
}

if(!function_exists('DisplayLastPublications')) {

  function DisplayLastPublications($nb) {
    $data=$GLOBALS['sql_object']->DBSelect(SQL_Get_LastPublications($nb));

    $content ='<div id="home_publication">'.END_LINE;
    $content.='<h2>'._t('public','last_news_h1').'</h2>'.END_LINE;

    $link_publi= array('rub'=> $GLOBALS['links'][U_L]['publication']['linkvalue']);

    for($i=0; $i<count($data); $i++) {
      $publi_id=$data[$i]['publi_id'];
      $publi_title=formatText($data[$i]['publi_title'],'2HTML');
      $publi_resume=formatText($data[$i]['publi_resume'],'2HTML');
      $link_this= array('rub'=> $GLOBALS['links'][U_L]['publication']['linkvalue'], 'id'=>$publi_id, 'name'=> $data[$i]['publi_title']);
       
      $content.='<div>';
      $content.='<h3>'.$publi_title.'</h3>';
      $content.='<a href="'.HrefMaker($link_this).'" title="'.formatText($GLOBALS['links'][U_L]['publication']['desc'].' : '.$publi_title, '2ATT').'">';
      $content.=$publi_resume;
      $content.='</a>';
      $content.='</div><br />';
    }
    //$content.='<a href="'.HrefMaker($link_publi).'" title="'.$GLOBALS['links'][U_L]['publication']['desc'].'">';
    //$content.='accéder à la liste des dossiers';
    //$content.='</a>';
    $content.='</div>	'.END_LINE;

    echo $content;
  }
}

if(!function_exists('DisplayEdito')) {

  function DisplayEdito() {
    $content ='<div id="home_edito">'.END_LINE;
    $content.='<h2>'._t('header', 'welcome').'</h2>'.END_LINE;
    $content.='<p>';
    $content.=_t('public','edito');
    $content.='</p>'.END_LINE;
    $content.='</div>';
    echo $content;
  }
}

if(!function_exists('DisplayGDT')) {

  function DisplayGDT() {
    $link_gdt= array('rub'=> $GLOBALS['links'][U_L]['workgroup']['linkvalue']);

    $content ='<div id="home_top"><div id="home_gdt">'.END_LINE;
    $content.='<h2>'._t('public','workgroup_h1').'</h2>'.END_LINE;
    $content.='<p>';
    $content.='<a href="'.HrefMaker($link_gdt).'" title="'.formatText($GLOBALS['links'][U_L]['workgroup']['desc'], '2ATT').'">';
    $content.=_t('public','workgroup_edito');
    $content.='</a>';
    $content.='</p>'.END_LINE;
    $content.='</div>';
    echo $content;
  }
}

if(!function_exists('DisplayIDD')) {

  function DisplayIDD() {
    $link_idd= array('rub'=> $GLOBALS['links'][U_L]['dashboard']['linkvalue']);
    $content ='<div id="home_idd">'.END_LINE;
    $content.='<h2>'._t('public','dashboard_h1').'</h2>'.END_LINE;
    $content.='<p>';
    $content.='<a href="'.HrefMaker($link_idd).'" title="'.formatText($GLOBALS['links'][U_L]['dashboard']['desc'], '2ATT').'">';
    $content.=_t('public','dashboard_edito');
    $content.='</a>';
    $content.='</p>'.END_LINE;
    $content.='</div></div>';
    echo $content;
  }
}


/**
 * DisplayMenu()
 * Affichage du menu
 *
 * @return void ( echo string )
 */
if(!function_exists('DisplayMenu')) {

  function DisplayMenu()
  {
    //$content .= '<a href="#contenu" class="semnone" title="'._t('header','goto_contents').'" accesskey="2">'._t('header','goto_contents').'</a>'.END_LINE;
    $content = '<ul>'.END_LINE;
    while (list($key, $value) = each ($GLOBALS['menuitems'])) {

      (ActiveItemAlias($GLOBALS['activeitem']) == $value) ? $classe = ' class="actif"' : $classe = '' ;
      $current_link = array('rub' => $GLOBALS['links'][U_L][$value]['linkvalue']);
      $content .= '<li id="menu_'.$value.'"'.$classe.'>';
      $content .= '<a href="' . HrefMaker($current_link) . '" title="' . $GLOBALS['links'][U_L][$value]['desc'] . '" accesskey="' . $GLOBALS['links'][U_L][$value]['accesskey'] . '" id="amenu_'.$value.'">' . mb_ucfirst($GLOBALS['links'][U_L][$value]['title']) . '</a>';
      $content .= '</li>' . END_LINE;
    }
    $content .= "</ul>";
    echo $content;
  }
}

/**
 * MyAccount()
 * Renvoie les liens de creation de compte ou de déconnexion
 * suivant le statut de l'utilisateur
 *
 * @return string content
 */
if(!function_exists('MyAccount')) {

  function MyAccount()
  {
  	global $l21auth;
  	
    $link_account = array('rub' => $GLOBALS['links'][U_L]['user-prefs']['linkvalue']);
    $link_create = array('rub' => $GLOBALS['links'][U_L]['user-registration']['linkvalue']);
    $link_logout = array('rub' => $GLOBALS['links'][U_L]['logout']['linkvalue']);
    
    $content  = '<div id="myaccount">';
    if ($l21auth->isAuthenticated()) {
      if(isset($_SESSION['userfirstname'])) $title= ucfirst($_SESSION['userfirstname']);
      else $title= $_SESSION['userlogin'];
      $content .= '<h2>'._t('header','welcome'). ' '.$title.',</h2>';
      $str = ucfirst(_t('divers','myprofile'));
    } else {
      $content .= '<h2>'._t('header','myaccount').'</h2>';
      $str = ucfirst(_t('divers','auth'));
    }
    $content .= '<ul>' . END_LINE;
    $content .= '<li><a href="' . HrefMaker($link_account) . '" accesskey="u" title="'._t('header','myaccount_title').'">' . $str . '</a></li>';
    
    if ($l21auth->isAuthenticated()) {
    	if($l21auth->isSuperAdmin()) {
    		$content .= '<li><a href="../admin/" accesskey="l" title="'._t('divers','title_login').'">' . mb_ucfirst(_t('admin','console')) . '</a></li>';
    	}
    	$content .= '<li><a href="' . HrefMaker($link_logout) . '" accesskey="l" title="'._t('header','deconnexion_title').'">' . mb_ucfirst(_t('header','deconnexion')) . '</a></li>';
    	
    }
  
    else {
    	$content .= '<li><a href="' . HrefMaker($link_create) . '" accesskey="c" title="'._t('divers','user_inscription_title').'">' . _t('divers','user_inscription') . '</a></li>';
    }
    $content .= '</ul></div>' . END_LINE;
    echo $content;
  }
}

/**
 * forgotPass()
 * Formulaire envoi d'un mot de passe
 *
 * @param string $todo
 * @return void (echo string)
 */
if(!function_exists('forgotPass')) {

  function forgotPass($back = 1 )
  {
    if($back=== 1) $back=$_SERVER['HTTP_REFERER'];
    $input_hidden = $GLOBALS['links'][U_L]['forgot-password']['linkvalue'];

    $link_pass = array('rub' => $GLOBALS['links'][U_L]['forgot-password']['linkvalue']);

    if(isset($_POST['valid'])) {
      $r = $GLOBALS['l21auth']->identifyWithLogin($_POST['login']);
      if(!($r)) {
        $msg = '<div class="error">'.sprintf(_t('auth', 'no_user'), $_POST['login']).'</div>';
      } else {

      	if($r['user_password'] == '@ldap_forward') {
      		
      		$msg = '<div class="info">'.sprintf(_t('auth', 'ldap_user')).'</div>';
      		
      	} else {
      	
	        include_once('../class/class.user.php');
	        $user = new user;
	        $key = $user->generateNewPasskey($r['user_id'], $GLOBALS['sql_object']);
	
	        if($key != false) {
	          $todo_mail = 'forgot_pass';
	          $user_email = $r['profile_email'];
	          $link_pass = array('rub' => $GLOBALS['links'][U_L]['forgot-password']['linkvalue'], 'token' => $key);
	          include_once(override('../user/mail_actions.php'));
	          include_once(override('../mail/template.php'));
	          $msg =  '<div class="info">'.sprintf(_t('auth', 'sending_mail'), $user_email).'</div>';
	        }
      	}
      	
      }
    }

    $form = '<p>'. _t('auth','note') . '</p>' . END_LINE;
    if(isset($msg)) $form .= $msg . END_LINE;
    $form .= '<form action="index.php" method="post">' . END_LINE;
    $form .= '<div id="forgot_pass">' . END_LINE;
    $form .= '<p><label for="login" class="labelised">' . _t('divers','login') . ' : </label>' . END_LINE;
    $form .= '<input type="text" maxlength="20" class="tinytextfield" name="login" id="login" /></p>' . END_LINE;
    $form .= '<br />'.END_LINE;

    $form .= '<br />'.END_LINE;
    $form .= '<input type="hidden" name="rub" id="rub" value="' . $input_hidden . '" />' . END_LINE;
    $form .= '<input type="hidden" name="referer" id="referer" value="' . $back . '" />' . END_LINE;
    $form .= '<input type="submit" class="submitbut" value="'._t('btn','valid').'" title="'._t('btn','valid').'" name="valid" id="valid" />'.END_LINE;
    $form .= '</div>' . END_LINE;
    $form .= '</form>' . END_LINE;

    return $form;
  }
}

/**
 * AuthForm()
 * Formulaire d'authentification pour login ou inscription
 *
 * @param string $todo
 * @return void (echo string)
 */
if(!function_exists('AuthForm')) {

  function AuthForm($todo = 'LOGON', $back = 1 )
  {
    if($back=== 1) $back = $_SERVER['HTTP_REFERER'];

    isset($_POST['login']) ? $form_login = $_POST['login'] : $form_login = '';
    isset($_POST['email']) ? $form_email = $_POST['email'] : $form_email = '';
    isset($_POST['firstname']) ? $form_firstname = strip_input(trim($_POST['firstname'])) : $form_firstname = '';
    isset($_POST['lastname']) ? $form_lastname = strip_input(trim($_POST['lastname'])) : $form_lastname = '';

    if ($todo == 'LOGON') {
      $input_hidden = $GLOBALS['links'][U_L]['user-prefs']['linkvalue'];
      $div_id = 'logon';
    } else {
      $input_hidden = $GLOBALS['links'][U_L]['user-registration']['linkvalue'];
      $div_id = 'subscribe';
    }
    $link_pass = array('rub' => $GLOBALS['links'][U_L]['forgot-password']['linkvalue']);
    $form = '<form action="index.php" method="post">' . END_LINE;
    $form .= '<div id="' . $div_id . '">' . END_LINE;
    $form .= '<p><label for="login" class="labelised">' . _t('divers','login') . ' : </label>' . END_LINE;
    $form .= '<input type="text" maxlength="20" class="tinytextfield" name="login" id="login" value="'.$form_login.'" />' . END_LINE;
    $form .= '</p>'.END_LINE;
    if ($todo == 'LOGON') {
      $form .= '<p><label for="password" class="labelised">' . _t('divers','password') . ' : </label>' . END_LINE;
      $form .= '<input type="password" maxlength="20" class="tinytextfield" name="password" id="password" /></p>' . END_LINE;
      
      if(defined('REMEMBER_ME') && REMEMBER_ME != 0) {
      	$form .= '<p class="login-remember">'. END_LINE;
      	$form .= '<input type="checkbox" name="rememberme" id="rememberme" />' . END_LINE;
      	$form .= '<label for="rememberme" class="labelised autowidth">' . _t('auth','rememberme') . '</label>' . END_LINE;
      }
      
      $form .= '<p class="forgot_pass"><a href="'.HrefMaker($link_pass).'">'._t('auth', 'forgot_password').'</a></p>' . END_LINE;
    } else {
      $form .= '<p><label for="email" class="labelised">' . _t('divers','email') . ' : </label>' . END_LINE;
      $form .= '<input type="text" maxlength="100" class="tinytextfield" name="email" id="email" value="'.$form_email.'" /></p>' . END_LINE;
      $form .= '<p><label for="firstname" class="labelised">' . ucfirst(_t('user','first_name')) . ' ('. _t('divers','optional') .') : </label>' . END_LINE;
      $form .= '<input type="text" maxlength="200" class="tinytextfield" name="firstname" id="firstname" value="'.$form_firstname.'" /></p>' . END_LINE;
      $form .= '<p><label for="lastname" class="labelised">' . ucfirst(_t('user','last_name')) . ' ('. _t('divers','optional') .') : </label>' . END_LINE;
      $form .= '<input type="text" maxlength="200" class="tinytextfield" name="lastname" id="lastname" value="'.$form_lastname.'" /></p>' . END_LINE;
      
      if(NEWSLETTER_AUTO_SUB == 1) {
      	$form .= '<div class="info">';
      	$form .= '<p>' . _t('user', 'newsletter_subscription_info') . '</p>';
      	if(isset($GLOBALS['lang']['user']['newsletter_law_reference'])) {
      		$form .= '<p>' . _t('user', 'newsletter_law_reference') . '</p>';
      	}
      	$form .= '</div>' . END_LINE;
      }
    }
    $form .= '<br />'.END_LINE;
    $form .= '<input type="hidden" name="rub" id="rub" value="' . $input_hidden . '" />' . END_LINE;
    $form .= '<input type="hidden" name="referer" id="referer" value="' . $back . '" />' . END_LINE;
    $form .= '<input type="submit" class="submitbut" value="'._t('btn','valid').'" title="'._t('btn','valid').'" name="valid" id="valid" />'.END_LINE;
    $form .= '</div>' . END_LINE;
    $form .= '</form>' . END_LINE;

    return $form;
  }
}

/**
 * MyGroups()
 * Return groups user has subscribed to
 * nothing if no groups
 * @return string
 */
if(!function_exists('MyGroups')) {
  function MyGroups()
  {

    if(!isset($_COOKIE['linea21']['workshop']) || !isset($_SESSION['authenticated'])) return false;

    global $sql_object;

    $link_account = array('rub' => $GLOBALS['links'][U_L]['user-prefs']['linkvalue']);

    // get and prepare user groups
    $groups = base64_decode($_COOKIE['linea21']['workshop']);
    if($groups[0]=='/') $groups = substr($groups, 1); // removing first separator
    if(!empty($groups)) {
      $groups = @explode('/',$groups);
      $data= $sql_object->DBSelect(SQL_Get_WorkshopsNames($groups));
    } else {
      $data=0;
    }

    $content  = '<div id="mygroups">'.END_LINE;
    $content .= '<h2>'._t('groups', 'mine').'</h2>'.END_LINE;
    if($data!=0)
    {
      $content .= '<ul>';
      for($i=0; $i<count($data); $i++) {

        $link = array('rub'=> $GLOBALS['links'][U_L]['workgroup']['linkvalue'],'id'=>$data[$i]['workshop_id']);
        $workshop_title =  formatText($data[$i]['workshop_denomination'], '2HTML');

        $content .= '<li><a href="'.HrefMaker($link).'" title="'.formatText($data[$i]['workshop_denomination'], '2ATT').'">'.$workshop_title.'</a></li>';
         
      }
      $content .= '</ul>';
    } else {
      return false;
    }
    $content .= '</div>';

    return $content;
  }
}

if(!function_exists('DisplayProjectBoard')) {
  function DisplayProjectBoard() {
    $content ='';
    if(ActiveItemKey($GLOBALS['activeitem']) == 'home') {
      $content .= '<a href="'.HrefMaker(array('rub' => $GLOBALS['links'][U_L]['project']['linkvalue'])).'" title="'.$GLOBALS['links'][U_L]['project']['title'].'">'.$GLOBALS['links'][U_L]['project']['title'].'</a>';
      $content .= '<br />';
    }
    echo $content;
  }
}

if(!function_exists('DisplayNewsletterForm')) {
  function DisplayNewsletterForm() {
    $action=$GLOBALS['links'][U_L]['subscribe-newsletter']['linkvalue'];
    
    $form  = '<div id="newsletter-form">' . END_LINE;
    $form .= '<form action="index.php" method="post">' . END_LINE;
    $form .= '<h3>'._t('menu_alt','newsletter').'</h3>';
    $form .= '<div class="sidebar-content">' . END_LINE;
    $form .= '<label for="newsletteremail">' . mb_ucfirst(_t('divers','email')) . ' : </label>' . END_LINE;
    $form .= '<input type="text" maxlength="200" size="19" class="tinytextfield" name="newsletteremail" id="newsletteremail" />' . END_LINE;
    $form .= '<input type="submit" value="'._t('btn','valid').'" title="'._t('btn','valid').'" name="valid"  id="valid_newsletter" />'.END_LINE;
    $form .='<br />';
    $form .= '<input type="hidden" name="rub" id="rub_newsletter" value='.$GLOBALS['links'][U_L]['subscribe-newsletter']['linkvalue'].' />' . END_LINE;
    $form .='<p class="newsletter-unsubscribe">';
    $form .= '<input type="checkbox" name="del_action" id="del_action" style="float:left;margin:0em 1em 0 3.2em" />';
    $form .= '<label for="del_action" class="checkboxlab">'._t('newsletter','unsubscribe').'</label>' . END_LINE;
    $form .='</p>';
    $form .= '</div>' . END_LINE;
    $form .= '</form>' . END_LINE;
    $form .= '</div>' . END_LINE;

    echo $form;
  }
}

if(!function_exists('DisplayBoardLastNews')) {
  function DisplayBoardLastNews($nb) {
    $data=$GLOBALS['sql_object'] -> DBSelect(SQL_Get_NewsBoard($nb));

    $content = '<div id="recentNews">'.END_LINE;
    //$content.= '<p>'._t('divers','actu_left').'</p>';
    $content.= '<h2>'._t('divers','actu_left').'</h2>';
    if($data!=0)
    {
      $content.= '<ul>'.END_LINE;
      for($i=0; $i<count($data); $i++) {
        $title=formatText($data[$i]['news_title'],'2HTML');
        $link_table= array('rub'=> $GLOBALS['links'][U_L]['news']['linkvalue'],'id'=>$data[$i]['news_id'], 'name' => $data[$i]['news_title']);
        $content.='<li><a href="'.HrefMaker($link_table).'" title="'.formatText($GLOBALS['links'][U_L]['news']['desc'].' : '.$title, '2ATT').'">'.$title.'</a>';
        #$content.='<em>'._t('statut', 'published_on').' '.$data[$i]['news_published_date_display'].'</em>'.END_LINE;
        $content.='</li>'.END_LINE;
      }
      $content.= '</ul>'.END_LINE;
    }
    else
    {
      $content.='<p>'._t('divers','nodata').'</p>';
    }
    $content.= '</div>'.END_LINE;

    echo $content;
  }
}

if(!function_exists('DisplayBoardLastSdi')) {
  function DisplayBoardLastSdi() {
    $data=$GLOBALS['sql_object'] -> DBSelect(SQL_Get_SdiBoard());

    $content = '<div id="recentIndicators">'.END_LINE;
    $content.= '<h2>'._t('divers','sdi_left').'</h2>';
    if($data!=0)
    {
      $content.= '<ul>'.END_LINE;
      $test=array();
      for($i=0; $i<count($data); $i++) {
        if (!in_array($data[$i]['sdii_id'], $test) && count($test)<3){
          $test[$i]=$data[$i]['sdii_id'];
          $title=formatText($data[$i]['sdii_name'],'2HTML');
          $link_table= array('rub'=> $GLOBALS['links'][U_L]['dashboard']['linkvalue'],'id'=>$data[$i]['sdii_id'], 'parentid'=>$data[$i]['sdiv_scale'], 'name' => $data[$i]['sdii_name'] );
          $content.='<li><a href="'.HrefMaker($link_table).'" title="'.formatText($GLOBALS['links'][U_L]['dashboard']['desc'].' : '.$title, '2ATT').'">'.$title.'</a>';
          $content.='</li>'.END_LINE;
        }
      }
      $content.= '</ul>'.END_LINE;
    }
    else
    {
      $content.=_t('divers','nodata');
    }
    $content.= '</div>'.END_LINE;

    echo $content;
  }
}


if(!function_exists('DisplaySearchForm')) {
  function DisplaySearchForm() {

    $action=$GLOBALS['links'][U_L]['search-result']['linkvalue'];
    
    $form ='<div id="search-input">'.END_LINE;
    $form.='<form action="index.php" method="get">'.END_LINE;
    $form.= '<h2>'._t('menu','search').'</h2>';
    $form.= '<div class="sidebar-content">' . END_LINE;
    $form.='<label for="search">'._t('menu','search').' </label>'.END_LINE;
    $form.='<input type="text" maxlength="100" name="search" id="search" accesskey="4" class="tinytextfield" />'.END_LINE;
    $form.= '<input type="hidden" name="rub" id="rub_search" value="'.$GLOBALS['links'][U_L]['search-result']['linkvalue'].'" />' . END_LINE;
    $form.='<input type="submit" value="'._t('btn','valid').'" name="valid" id="validsearch" />'.END_LINE;
    $form.='<p id="searchadv">';
    $form.='<a href="'.HrefMaker(array('rub'=> $GLOBALS['links'][U_L]['search']['linkvalue'])).'" title="'.formatText($GLOBALS['links'][U_L]['search']['title'], '2ATT').'">';
    $form.=_t('menu','advancedsearch');
    $form.='</a>';
    $form.='</p>';
    $form.='</div>'.END_LINE;
    $form.='</form>'.END_LINE;
    $form.='</div>'.END_LINE;
    

    echo $form;
  }
}

if(!function_exists('displayDefaultFooter')) {
  function displayDefaultFooter() {
    $content='<a href="mailto:'.SITE_MAIL.'" ';
    $content.='title="'.SITE_MAIL.'" >'._t('divers','contact').' </a> | ';
    $content.='<a href="'.HrefMaker(array('rub'=> $GLOBALS['links'][U_L]['accessibility']['linkvalue'])).'" ';
    $content.='title="'.formatText(_t('divers','accessibility'), '2ATT').'" accesskey="0"> '._t('divers','accessibility').' </a>  | <a href="rss2.php" title="RSS">RSS</a>';
    if(isset($_SESSION['authenticated']) && !$GLOBALS['l21auth']->isSimpleUser())  {
      	$content.=' | <a href="../admin/index.php" title="'. _t('header','title').'">'. _t('admin','console').'</a>';
    }
    echo $content;
  }
}

?>