<?php

/**
==============================================================================
*	This script contains the actual html code to display the "header"
*	or "banner" on top of every Dokeos page.
*	@package dokeos.include

==============================================================================

*/
if(isset($GLOBALS['HTTP_SESSION_VARS']['user_language_choice'])){
  $langselection = $GLOBALS['HTTP_SESSION_VARS']['user_language_choice'];
}
elseif(isset($_GET['language'])){
    $langselection = $_GET['language'];
}
else{
 $langselection = "greek";
}
if(isset($GLOBALS['HTTP_SESSION_VARS']['user_language_choice']) && isset($_GET['language'])){
    if($GLOBALS['HTTP_SESSION_VARS']['user_language_choice']!= $_GET['language']){
          $langselection = $_GET['language'];
      }


}
// always show student's help, but only teachers see the teacher's help
//$help_path = api_get_path(WEB_CODE_PATH).'help/greek/';

$help_path = api_get_path(WEB_CODE_PATH).'help/'.$langselection.'/';

if ($GLOBALS['is_allowedCreateCourse'] || $GLOBALS['is_platformAdmin'] || api_is_allowed_to_edit() || api_is_course_admin()) {
	$help_path .= 'teacher/index.html';
} else {
	$help_path .= 'student/index.html';
}
$web_course_path = api_get_path(WEB_COURSE_PATH);
//  echo $help_path;
?>
        <!-- start OF header -->

        <table style="width:100%;">
            <tr>
                <td  style="color:white;padding-left:15px;text-align:left">
                <a href="http://www.e-gnosis.gov.cy/"><span class="style1" style="color:white;font-size:18px"><span style="color:orange">e-</span>gnosis</span></a></td>
                <td style="text-align:right;padding-right:15px;"><span class="style1" style="color:white;font-family:arial"> <?php echo get_lang('descrHeader'); ?></span></td>
            </tr>
        </table>


      <?php
        //Put the name of the course in the header
        /* --- Course Title Section --- */
        if (isset ($_cid) && 2==3){
     ?>
     <div id="my_courses">
        <a href="<?php echo api_get_path(WEB_COURSE_PATH).$_course['path']; ?>/index.php" target="_top">
    	<?php
          echo $_course['name']." ";
          if (get_setting("display_coursecode_in_courselist") == "true"){
  		echo $_course['official_code'];
          }
          if (get_setting("display_coursecode_in_courselist") == "true" AND get_setting("display_teacher_in_courselist") == "true"){
  		echo " - ";
      	}
          if (get_setting("display_teacher_in_courselist") == "true"){
  	    	echo $_course['titular'];
      	}
          echo "</a></div>";
        }
        //Put the name of the user-tools in the header
        elseif (isset ($nameTools) && $langFile != 'course_home' && 2==3)
        {
          if (!isset ($_uid))
            echo " ";
          elseif(!$noPHP_SELF){
    		echo "<div id=\"my_courses\"><a href=\"".$_SERVER['PHP_SELF']."?".api_get_cidreq(), "\" target=\"_top\">", $nameTools, "</a></div>", "\n";
          }
          else{
    		echo "<div id=\"my_courses\">$nameTools</div>\n";
            }
        }
        //not to let the header disappear if there's nothing on the left
        //load appropriate plugins for banner section
        if (is_array($plugins['banner'])){
           foreach ($plugins['banner'] as $this_plugin){
           	include (api_get_path(PLUGIN_PATH)."$this_plugin/index.php");
        	}
         }
         ?>


  <?php
if ($_uid) {/* --- User Section --- */
?>
<div id="header2"> <!-- start user section line with name, my course, my profile, scorm info, etc -->

<form method="get" name="frmMainTop" action="<?php echo api_get_path(WEB_PATH); ?>index<?php echo $_SESSION["prefix"]?>.php" class="banner_links" target="_top">


<table style="width:98%;margin:0px 0px 0Px 15PX ; padding: 0px 10px 3px 0px;">
    <tr>
        <td>
      <b><?php echo $_user ['lastName']," ",$_user ['firstName'] ?> :</b>

<a href="<?php echo api_get_path(WEB_PATH); ?>index.php" target="_top">

 <?php echo get_lang("MyCourses"); ?></a>

 |

<a href="<?php echo $clarolineRepositoryWeb ?>auth/profile.php<?php if(!empty($_course['path'])) echo '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code']; ?>" target="_top">

 <?php echo get_lang("ModifyProfile"); ?></a>

 |

<a href="<?php echo $clarolineRepositoryWeb ?>calendar/myagenda.php<?php if(!empty($_course['path'])) echo '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code']; ?>" target="_top">

 <?php echo get_lang("MyAgenda"); ?></a>

 <?php



	if (api_is_platform_admin())

	{

		echo "| <a href=\"".$rootAdminWeb."\" target=\"_top\">".get_lang("PlatformAdmin")."</a>";

	}
    if ($_uid)

{

	if (api_is_course_admin() && is_student_view_enabled())

	{

		echo ' | ';

		display_tool_view_option($_GET['isStudentView']);

		echo '';

	}

}

?>    </td>
    <td>
           <input type="hidden" name="logout" value="true"/>

           <input type="hidden" name="uid" value="<?php echo $_uid;?>"/>
           <div id="logout">
            <table>
            <tr>
                <td>
                 <a href="#" onclick="document.frmMainTop.submit()">
                    <img src="<?php echo api_get_path(WEB_CODE_PATH); ?>img/exit.png" style="width:30px;vertical-align: middle;" alt="<?php echo get_lang("Logout") ?>"/>&nbsp;<?php echo get_lang("Logout") ?></a>
                </a>


                </td>
                <td> | <?php $help_path =get_help_button();?>
             <a href="#" onClick="MyWindow=window.open('<?php echo $help_path;?>', 'MyWindow', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=770,height=600,left=200,top=20'); return false;">
            <img src="<?php echo api_get_path(WEB_CODE_PATH); ?>img/help.png" style="width:30px;vertical-align: middle;" alt="<?php echo get_lang("Help") ?>"/>&nbsp;<?php echo get_lang("Help") ?></a>
</td>
            </tr>
        </table>


           </div>
        </td>
    </tr>
</table>


</form>

</div> <!-- end of header2 (user) section -->

<?php
} else {//not registered users

}
?>
   <div id="header3" >

 <?php
    if (isset ($_cid)){ ?>
 	 <a href="<?php echo api_get_path(WEB_PATH) ?>index.php" target="_top">
 	    <?php echo get_setting('siteName'); ?></a> &gt;
 	 <a href="<?php echo $web_course_path . $_course['path']?>/index.php" target="_top">
        <?php echo $_course['name']; ?>
     </a>
<?php }

// if name tools or interbredcrump defined, we don't set the Site name bold

elseif (isset ($nameTools) || is_array($interbredcrump)){
	if (!isset ($_uid))
		echo " ";
	else {         ?>
          <a href="<?php echo api_get_path(WEB_PATH); ?>index.php" target="_top"> <?php echo get_setting('siteName');?></a>
  <?php   }
}


// else we set the Site name bold
if (is_array($interbredcrump)){
	while (list (, $bredcrumpStep) = each($interbredcrump)){
		$sep = '?';
		if (strrchr($bredcrumpStep['url'], '?'))
		{
			$sep = '&';
		}
		$last_link = $bredcrumpStep['url'].$sep.api_get_cidreq();
		// when in a scorm package
		echo " &gt; <a href=\"", $bredcrumpStep['url'].$sep.api_get_cidreq(), "\" target=\"_top\">", $bredcrumpStep['name'], "</a>\n";
	}
}

// clickable bredcrump construction
// parse the openDir path
$dir = $GLOBALS['openDir'];
$tmplink = './scormdocument.php?cidReq='.$_REQUEST['cidReq'];
if (strlen($dir)) {
	$last_pos = 0;
	$start_pos = 1;
	$found = 1;
	$full_link = '';
	$pos = FALSE;
	do {
		$pos = strpos($dir, '/', $start_pos);
		if ($pos !== FALSE) {
			$found = 1;
			$tmpdir = substr($dir, $last_pos, $pos - $last_pos);
			if (strlen($tmpdir) && ($tmpdir != '/')) {
				$fulldir = substr($dir, 0, $pos);
				$full_link .= ' <a href="'.$tmplink.'&subdirs=yes&openDir='.urlencode($fulldir).'" target="_top">'.$tmpdir.'</a> ';
				$last_pos = $pos;
				$start_pos = $pos + 1;
			}
		} else {
			$found = 0;
			$tmpdir = substr($dir, $last_pos);
			$last_link = '<a href="'.$tmplink.'&subdirs=yes&openDir='.urlencode($dir).'" target="_top">'.$tmpdir.'</a>';
			$full_link .= ' '.$last_link;
		}
	} while ($found);
}

if (strpos($GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'], 'scormdocument.php')) { // in learning path
	$nametool_link = $tmplink;
} else {
	$nametool_link = $_SERVER['REQUEST_URI'];
}

if (isset ($nameTools) && $langFile != 'course_home')

{

	if (!isset ($_uid))

		echo " &gt; ", "<a href=\"".$_SERVER['REQUEST_URI']."\" target=\"_top\">", $nameTools, "</a>", $full_link, "\n";

	else

	{

		if ($noPHP_SELF) {
			// when in a scorm package
			$full_link = str_replace($last_link, $tmpdir, $full_link);
			if (!strlen($full_link)) {
				echo "&gt; " . $nameTools;
			}
			echo $full_link . "\n";
		} else {
			// when not in a scorm package
			echo " &gt; ", "<a href=\"".$nametool_link."\" target=\"_top\">", $nameTools, "</a>", $full_link, "\n";
		}

	}
}
//not to let the empty header disappear and ensure help pic is inside the header

//echo "<div class=\"clear\">&nbsp;</div>";

?>
</div> <!-- End of header 3-->

   <?php


/*}*/
echo "<div class=\"clear\">&nbsp;</div>";

?>
    </div>
    <!-- end of header -->

	<div id="toolshortcuts">
		<?php if(get_setting('show_toolshortcuts')=="true") { include('tool_shortcuts.inc.php'); } ?>
	</div>
    <?php if (isset ($dokeos_database_connection)){

	// connect to the main database.

	// if single database, don't pefix table names with the main database name in SQL queries

	// (ex. SELECT * FROM `table`)

	// if multiple database, prefix table names with the course database name in SQL queries (or no prefix if the table is in

	// the main database)

	// (ex. SELECT * FROM `table_from_main_db`  -  SELECT * FROM `courseDB`.`table_from_course_db`)

    	mysql_select_db($mainDbName, $dokeos_database_connection);
    }

    ?>
   <div id="main">
     <div id="page-content-wrapper">
         <div id="page-content">

<?php



// ===== "call for chat" module section =====



$chat = strpos($_SERVER['PHP_SELF'], 'chat_banner.php');

if (!$chat)

{

	include_once (api_get_library_path()."/online.inc.php");

	echo $accept;

	$chatcall = chatcall();

	if ($chatcall)

	{

		Display :: display_normal_message($chatcall);

	}

}


// ===== end "call for chat" module section =====

?>

<!--   Begin Of script Output   -->