Location: PHPKode > projects > PhpScheduler > PhpScheduler/template/index.template.php
<?php
$basedir = dirname( __FILE__ ) . '/..';
require_once( $basedir . "/lib/user.php" );
require_once( $basedir . "/lib/version.php" );
require_once( $basedir . "/template/schedule.template.php" );
require_once( $basedir . "/template/admin.template.php" );
class Index_Template {
	private $user;
	/**
	 * Contructeur de la classe
	 *
	 */
	function __construct()
	{
		if ( isset( $_SESSION["user"] ) ) {
			$this -> user = unserialize( $_SESSION["user"] );
		}else {
			$this -> user = new user();
		}
	}
	/**
	 * Destructeur de la classe
	 *
	 */
	function __destruct()
	{
		unset( $this -> user );
	}
	/**
	 * Affichage de la partie HEAD HTML
	 *
	 */
	function print_html_header()
	{
		$this -> print_html_header_with_meta( "" );
	}
	/**
	 * Affichage de la partie HEAD HTML avec balise meta personnalisŽ
	 *
	 */
	function print_html_header_with_meta( $meta )
	{
		echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-Strict.dtd\">\n";
		echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"fr\" xml:lang=\"fr\">\n";
		echo "<head>\n";
		echo "<title>PhpScheduler</title>\n";
		echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"css/template.css\" />\n";
		if ( isset( $_GET["page"] ) ) {
			if ( $_GET["page"] == "schedule" ) {
				echo "<script src=\"script/schedule.php\" type=\"text/javascript\"></script>\n";
				echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"css/schedule.css\" />\n";
				echo "<link id=\"css_scheduler\" type=\"text/css\" rel=\"stylesheet\" href=\"lib/CSS_generator.php?forceReload=null\" />\n";
				echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"css/couleur.css\" />\n";
				echo "<script src=\"script/couleur.js\" type=\"text/javascript\"></script>\n";
			}
			if ( $_GET["page"] == "admin" ) {
				echo "<script src=\"script/admin.php\" type=\"text/javascript\"></script>\n";
				echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"css/admin.css\" />\n";
				echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"css/couleur.css\" />\n";
				echo "<script src=\"script/couleur.js\" type=\"text/javascript\"></script>\n";
			}
		}
		echo "<script src=\"script/myscript.php\" type=\"text/javascript\"></script>\n";
		echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n";
		echo $meta . "\n";
		echo "</head>\n";
		echo "<body>\n";
	}
	/**
	 * Affichage de la page
	 *
	 * @param string $page
	 */
	function print_body( $page )
	{
		echo "<div id=\"grayfrog\">&nbsp;</div>\n";
		echo "<div id=\"add_element\">\n";
		echo "<div id=\"add_element_titre\" class=\"subcat_title\">Add_element</div>\n";
		echo "<div id=\"add_element_text\">&nbsp;</div>\n";
		echo "<div class=\"button\" onclick=\"add_element_close();\">Fermer</div>\n";
		echo "</div>\n";
		echo "<div class=\"logo\"><img alt=\"logo\" src=\"images/logo.png\" /></div>\n";
		echo "<div class=\"title\">PhpScheduler</div>\n";
		echo "<div class=\"title\"></div>\n";
		echo "<table width=\"100%\" cellspacing=\"0\">\n";
		echo "<tr>\n";
		switch ( $page ) {
			case "userlist":
				echo "<td class=\"mybar1\" >Liste des utilisateurs</td>\n";
				break;
			case "account":
				echo "<td class=\"mybar1\" >Mon Compte</td>\n";
				break;
			case "register":
				echo "<td class=\"mybar1\" >Inscription</td>\n";
				break;
			case "schedule":
				echo "<td class=\"mybar1\" >Emploi du Temps</td>\n";
				break;
			case "admin":
				echo "<td class=\"mybar1\" >Administration</td>\n";
				break;
			default:
				echo "<td class=\"mybar1\" >Bienvenue dans PhpScheduler</td>\n";
		}
		echo $this -> print_login_form();
		echo "</tr>\n";
		echo "<tr>\n";
		echo "<td colspan=\"2\" class=\"menu\">\n";
		
		echo "<a class=\"menulink\" href=\"index.php\">index</a>\n";
		echo "<a class=\"menulink\" href=\"index.php?page=userlist\">Utilisateurs</a>\n";
		if ( $this -> user -> logged ) {
			echo "<a class=\"menulink\" href=\"index.php?page=account\">Mon compte</a>\n";
			echo "<a class=\"menulink\" href=\"index.php?page=schedule\">Emploi du temps</a>\n";
			if ( $this -> user -> droits > 0 ) {
				echo "<a class=\"menulink\" href=\"index.php?page=admin\">Administration</a>\n";
			}
		}else {
			echo "<a class=\"menulink\" href=\"index.php?page=register\">Inscription</a>\n";
		}
		echo "</td></tr>\n";
		echo "<tr>\n";
		echo "<td colspan=\"2\" class=\"tdbody\">\n";
		switch ( $page ) {
			case "userlist":
				$this -> print_userlist();
				break;
			case "account":
				if ( $this -> user -> logged ) {
					$this -> print_account();
				}else {
					$this -> print_index();
				}
				break;
			case "register":
				$this -> print_register();
				break;
			case "schedule":
				if ( $this -> user -> logged ) {
					global $basedir;
					$schedule_template = new Schedule_Template();
					echo "<div class=\"schedule_title\">\n";
					echo "Semaine du <b>" . $schedule_template->startdate . "</b> au <b>" . $schedule_template -> stopdate . "</b>\n";
					echo "</div>\n";
					if ( file_exists( $basedir . "/cache/" . $schedule_template -> annee . "_" . $schedule_template -> semaine . ".php" ) ) {
						echo "<div id=\"conteneur\">\n";
						include( $basedir . "/cache/" . $schedule_template -> annee . "_" . $schedule_template -> semaine . ".php" );
						echo "</div>\n";
						$schedule_template -> print_week_list();
					}else {
						$schedule_template -> print_Week();
						if ( file_exists( $basedir . "/cache/" . $schedule_template -> annee . "_" . $schedule_template -> semaine . ".php" ) ) {
							echo "<div id=\"conteneur\">\n";
							include( $basedir . "/cache/" . $schedule_template -> annee . "_" . $schedule_template -> semaine . ".php" );
							echo "</div>\n";
							$schedule_template -> print_week_list();
						}
					}
				}else {
					$this -> print_index();
				}
				break;
			case "admin":
				if ( $this -> user -> logged && $this -> user -> droits > 0 ) {
					Admin_Template :: print_admin();
				}else {
					$this -> print_index();
				}
				break;
			default:
				$this -> print_index();
		}
		echo "</td></tr>\n";


	}
	/**
	 * Affichage de la partie Inscription
	 *
	 */
	private function print_register()
	{
		echo "<div class=\"cat_title\">Inscription</div>\n";
		echo "<form action=\"index.php\" method=\"post\">\n";
		echo "<table width=\"100%\" cellspacing=\"0\">\n";

		echo "<tr>\n";
		echo "<td class=\"usertitle\">Login Souhait&eacute; *</td>\n";
		echo "<td><input id=\"register_login\" class=\"login_input\" type=\"text\" name=\"register_login\" onchange=\"check_login();\" />\n";
		echo "<span id=\"login_result\">&nbsp;</span></td>\n";
		echo "</tr>\n";

		echo "<tr>\n";
		echo "<td>&nbsp;</td>\n";
		echo "<td>&nbsp;</td>\n";
		echo "</tr>\n";

		echo "<tr>\n";
		echo "<td class=\"usertitle\">Mot de passe *</td>\n";
		echo "<td class=\"usertitle\">Retapez le mot de passe *</td>\n";
		echo "</tr>\n";

		echo "<tr>\n";
		echo "<td><input id=\"register1_pass\" class=\"login_input\" type=\"password\" name=\"register_pass1\" onchange=\"activate_register_button();\" /></td>\n";
		echo "<td><input id=\"register2_pass\" class=\"login_input\" type=\"password\" name=\"register_pass2\" onchange=\"activate_register_button();\" />\n";
		echo "<span id=\"pass_result\">&nbsp;</span></td>\n";
		echo "</tr>\n";

		echo "<tr>\n";
		echo "<td>&nbsp;</td>\n";
		echo "<td>&nbsp;</td>\n";
		echo "</tr>\n";

		echo "<tr>\n";
		echo "<td class=\"usertitle\">Email *</td>\n";
		echo "<td class=\"usertitle\">Retapez votre email *</td>\n";
		echo "</tr>\n";

		echo "<tr>\n";
		echo "<td><input id=\"register1_email\" class=\"login_input\" type=\"text\" name=\"register_email1\" onchange=\"activate_register_button();\" /></td>\n";
		echo "<td><input id=\"register2_email\" class=\"login_input\" type=\"text\" name=\"register_email2\" onchange=\"activate_register_button();\" />\n";
		echo "<span id=\"email_result\">&nbsp;</span></td>\n";
		echo "</tr>\n";

		echo "<tr>\n";
		echo "<td>&nbsp;</td>\n";
		echo "<td>&nbsp;</td>\n";
		echo "</tr>\n";

		echo "<tr>\n";
		echo "<td class=\"usertitle\">Nom</td>\n";
		echo "<td><input class=\"login_input\" type=\"text\" name=\"register_nom\" /></td>\n";
		echo "</tr>\n";

		echo "<tr>\n";
		echo "<td class=\"usertitle\">Pr&eacute;nom</td>\n";
		echo "<td><input class=\"login_input\" type=\"text\" name=\"register_prenom\" /></td>\n";
		echo "</tr>\n";

		echo "<tr>\n";
		echo "<td class=\"usertitle\">Adresse</td>\n";
		echo "<td><textarea name=\"register_adresse\" cols=\"20\" rows=\"5\"></textarea></td>\n";
		echo "</tr>\n";

		echo "<tr>\n";
		echo "<td>&nbsp;</td>\n";
		echo "<td id=\"register_submit\"><div class=\"button_no\">Valider</div></td>\n";
		echo "</tr>\n";

		echo "<tr>\n";
		echo "<td colspan=\"2\">* : champs obligatoire</td>";
		echo "</tr>\n";

		echo "</table>\n";
		echo "</form>\n";
	}
	/**
	 * Affichage de la liste des utilisateur
	 *
	 */
	private function print_userlist()
	{
		echo "<div class=\"cat_title\">Liste des membres</div>";
		$mysql = new mysql();
		$table_utilisateur=$mysql -> get_table("Utilisateurs");
		$table_droits=$mysql -> get_table("Droits");
		$userlist = $mysql -> select_query( "SELECT login,nom,prenom,adresse,email,intitule FROM $table_utilisateur u,$table_droits d WHERE u.id_droit=d.id_droit");
		if( $userlist != null ){
			$i = 0;
			echo "<table width=\"100%\" cellspacing=\"0\">\n";
			foreach( $userlist as $ac_user ) {
				if ( round( $i / 2, 0 ) * 2 == $i ) {
					echo "<tr class=\"userlist1\">";
				}else {
					echo "<tr class=\"userlist2\">";
				}
				echo "<td>" . $ac_user["login"] . "&nbsp;</td>";
				if ( $this -> user -> logged ) {
					echo "<td>" . $ac_user["nom"] . "&nbsp;</td>";
					echo "<td>" . $ac_user["prenom"] . "&nbsp;</td>";
					echo "<td>" . $ac_user["adresse"] . "&nbsp;</td>";
					echo "<td>" . $ac_user["email"] . "&nbsp;</td>";
					echo "<td>" . $ac_user["intitule"] . "&nbsp;</td>";
				}
				echo"</tr>\n";
				$i++;
			}
		}
		unset( $mysql );
		echo "</table>\n";

	}
	/**
	 * Affichage de la partie mon compte
	 *
	 */
	private function print_account()
	{
		echo "<div class=\"cat_title\">Mon Compte</div>";
		echo "<table width=\"100%\" cellspacing=\"0\" class=\"accounttable\">";
		echo "<tr><td>";
		echo "<div class=\"usertitle\">Login</div>";
		echo "<div class=\"userinfo\">" . $this -> user -> login . "</div>";
		echo "<div class=\"usertitle\">Nom</div>";
		echo "<div class=\"userinfo\">" . $this -> user -> nom . "</div>";
		echo "<div class=\"usertitle\">Pr&eacute;nom</div>";
		echo "<div class=\"userinfo\">" . $this -> user -> prenom . "</div>";
		echo "<div class=\"usertitle\">Adresse</div>";
		echo "<div class=\"userinfo\">" . $this -> user -> adresse . "</div>";
		echo "<div class=\"usertitle\">Email</div>";
		echo "<div class=\"userinfo\">" . $this -> user -> email . "</div>";
		echo "</td><td>";
		echo "<div>Modifier votre mots de passe</div>";
		echo "<form action=\"index.php?page=account\" method=\"post\">";
		echo "<div>mot de passe <input type=\"password\" class=\"login_input\" name=\"newpassword1\" /></div>";
		echo "<div>mot de passe <input type=\"password\" class=\"login_input\" name=\"newpassword2\" /></div>";
		echo "<div><input type=\"submit\" class=\"button\" name=\"changepassword\" value=\"modifier\" /></div>";
		echo "</form></td></tr></table>";
	}
	/**
	 * Affichage de la page d'acceuil
	 *
	 */
	private function print_index()
	{
		echo "<div class=\"cat_title\">Accueil</div>";
		echo "<div class=\"index_text\">
			<p>
			Bienvenue sur la plateforme de gestion d'emploi du temps
			PHPSCHEDULER
			</p>
			<p>
			Cette version est actuellement en cours de d&eacute;veloppement
			vous pouvez l'utiliser cependant toutes les fonctionnalit&eacute;s ne son pas encore pr&eacute;sentes.
			</p>
			<p>
			La version actuelle est 0.1 RC2.
			</p>
			<p>
			Vous pouvez suivre le d&eacute;veloppement du projet sur&nbsp;: <a href=\"http://trac.polyspot.info\">http://trac.polyspot.info</a><br />
			Vous pouvez tester la d&eacute;mo de la derni&egrave;re r&eacute;vision subversion sur&nbsp;: <a href=\"http://phpscheduler.polymorf.fr\">http://phpscheduler.polymorf.fr</a><br />
			La page du projet sur SourceForge&nbsp;: <a href=\"http://sourceforge.net/projects/phpscheduler\">http://sourceforge.net/projects/phpscheduler</a><br />
			</p>
			<p>
			Vous souhaitez utiliser la derni&egrave;re version disponible&nbsp;utilisez
			le repos subversion de phpscheduler&nbsp;: <a href=\"https://phpscheduler.svn.sourceforge.net/svnroot/phpscheduler/trunk/PhpScheduler\">sourceforge svn</a>
			</p>
			</div>";
	}
	/**
	 * Affichage de la partie connection de la barre de menu
	 *
	 */
	private function print_login_form()
	{
		echo "<td class=\"mybar2\">\n";
		if ( $this -> user -> logged ) {
			echo "<div>Bienvenue " . $this -> user -> login . "</div>";
			echo "<div><a href=\"index.php?disconnect\">deconnexion</a></div>\n";
		}else {
			echo "<form action=\"login.php\" method=\"post\">\n";
			echo "<div>Identifiant&nbsp;<input class=\"login_input\" type=\"text\" name=\"login\" /></div>\n";
			echo "<div>Mot de passe&nbsp;<input class=\"login_input\" type=\"password\" name=\"pass\" /></div>\n";
			echo "<div><input class=\"radio\" type=\"radio\" name=\"remember\" value=\"1\" />Se souvenir de moi ?</div>\n";
			echo "<div><input class=\"button\" type=\"submit\" value=\"S'Identifier\" /></div>\n";
			echo "</form>\n";
		}
		echo "</td>\n";
	}
	/**
	 * Affichage du bas de la page fermeture des balise utilisŽ
	 *
	 */
	function print_footer()
	{
		echo "<tr>\n<td colspan=\"2\" class=\"menu\"><div class=\"centertext\">Propuls&eacute; par PhpScheduler " . VERSION . "</div></td>\n</tr>\n</table>\n";
		echo "<div class=\"validator\">\n";
		echo "<img alt=\"PHP5 powered\" src=\"images/php5.png\" />\n";
		echo "</div>\n";
		echo "<div class=\"validator\">\n";
		echo "<img alt=\"CSS valide\" src=\"images/valid-css2-blue.png\" />\n";
		echo "<img alt=\"XHTML valide\" src=\"images/valid-xhtml10-blue.png\" />\n";
		echo "</div>\n";
	}
	/**
	 * Fermeture des balise body et html
	 *
	 */
	function print_html_footer()
	{
		echo "</body>\n</html>\n";
	}
}
?>
Return current item: PhpScheduler