default.ctp 12.8 KB
<?php
/**
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc.
 * (http://cakefoundation.org)
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link http://cakephp.org CakePHP(tm) Project
 * @since 0.10.0
 * @license http://www.opensource.org/licenses/mit-license.php MIT License
 */


// --- Elements set by Controller ---
//$USER_IS_UTILISATEUR = $USER_IS_UTILISATEUR;
$configuration = $configuration;
/* 
 * (EP 20200722)
 * 
 * Si un nom "court" de labo est défini, on l'utilise comme extension pour les fichiers de logo
 * Ex: 
 * - pour "IRAP", on lira les fichiers logo_software_IRAP.jpg et logo_entity_IRAP.jpg
 * - pour "IAS", on lira les fichiers logo_software_IAS.jpg et logo_entity_IAS.jpg
 * - ...
 * Si pas de nom court défini, on utilisera les fichiers de logo standards logo_software.jpg et logo_entity.jpg
 * 
 */
$logo_software_name = "logo_software";
$logo_entity_name = "logo_entity";
if ($configuration->labNameShort) {
    $labshortname = $configuration->labNameShort;
    //$this->d("lab name is set to $labshortname");
    $logo_software_name .= "_$labshortname";
    $logo_entity_name .= "_$labshortname";
}
$logo_software_name .= '.jpg';
$logo_entity_name .= '.jpg';
//debug($logo_entity_name);
//debug($logo_software_name);

/* 
 TODO: (EP 2020 02) 
    J'ai commencé à m'inspirer du template par defaut de bootstrap-ui 
    dans vendor/friendsofcake/bootstrap-ui/src/Template/Layout/default.ctp
    Il faudrait continuer à s'en inspirer complètement (ajouter les sections html, meta, title...)
*/ 

// $cakeDescription = 'CakePHP: the rapid development php framework';
$cakeDescription = 'Labinvent 2';

/**
 * Prepend `css` block with Bootstrap stylesheets and append
 * the `$html5Shim`.
 */
$html5Shim =
<<<HTML

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
HTML;
// https://book.cakephp.org/4/en/views/helpers/html.html#linking-to-css-files
//$this->prepend('css', $this->Html->css(['bootstrap/bootstrap']));
$this->prepend('css', $this->Html->css(['bootstrap/bootstrap.min', 'jquery-ui/jquery-ui.min']));
$this->append('css', $html5Shim);


// <!-- Added for LabInvent : START -->

//echo $this->Html->css('smoothness');
$this->append('css', $this->Html->css(['smoothness', 'inventirap', 'font-awesome', 'responsive']));
//<= $this->Html->css('inventirap') >
//<= $this->Html->css('font-awesome') >

/*
 <!-- EP modif 17/2/20
 <=$this->Html->script('jquery-1.5.2')>
 <=$this->Html->script('jquery-1.8.12')>
 $this->prepend('script', $this->Html->script(['jquery/jquery', 'bootstrap/bootstrap']));
 -->
 */
//Prepend `script` block with jQuery and Bootstrap scripts
//echo $this->Html->script('jquery/jquery');
//echo $this->Html->script('bootstrap/bootstrap');
//$this->prepend('script', $this->Html->script(['jquery/jquery', 'bootstrap/bootstrap']));
$this->prepend('script', $this->Html->script(['jquery/jquery.min', 'bootstrap/bootstrap.min', 'jquery-ui/jquery-ui.min']));
//echo $this->Html->script('script');
//echo $this->Html->script('DatepickerConfig');
//echo $this->Html->script('onTabHover');
$this->append('script', $this->Html->script(['script', 'DatepickerConfig', 'onTabHover']));

// <!-- Added for LabInvent : STOP -->
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>

	<?php
	// Charset
	// Meta tag specifying the document’s character (http-equiv)
	// (https://book.cakephp.org/4/en/views/helpers/html.html#creating-charset-tags)
	echo $this->Html->charset(); // Default is UTF-8
    // Autres possibilités
    //echo $this->Html->charset('ISO-8859-1');
	
	// viewport
	echo $this->Html->meta(
        'viewport',
        'width=device-width,initial-scale=1,minimum-scale=1'
    );
	// equivaut à :
	//<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1"/>
    ?>

	<title>
        <?= $cakeDescription ?>:
        <?= $this->fetch('title') ?>
	</title>

	<!--  
	https://book.cakephp.org/4/en/views/helpers/html.html#creating-meta-tags
	-->
    <?= $this->Html->meta('icon') ?>
    <!-- Deactivated, but should be re-activated (TODO:) : 
    START 
    <//?= $this->Html->css('base.css') ?//>
	<//?= $this->Html->css('cake.css') ?//>
    END 
    -->
    <?= $this->fetch('meta') ?>
    <?= $this->fetch('css') ?>
    <?= $this->fetch('script') ?>
    <style>
        #footer a, #footer p, #footer font {
	       font-size: x-small;
        }
    </style>
</head>


<body>

	<div id="container">

		<div class="row" id="header">
            <div class="col-lg-2">
                <?=
                $this->Html->image($logo_software_name, [
                    'alt' => 'Logo de l\'application','border' => '0','height' => '70px','url' => '/'
                ])
                ?>
            </div>
            <div class="offset-lg-6 col-lg-4 user">
                <?php
                    if (isset($username) && $username != " ") {
                        echo 'Bienvenue ' . $username . '<br/>';
                        echo $role . '<br/>';
                        echo $this->Html->link('Se déconnecter', [
                            'controller' => 'Users',
                            'action' => 'logout'
                        ]);
                    } else {
                        echo 'Bienvenue invité<br/>';
                        echo $this->Html->link('Se connecter', [
                            'controller' => 'Users',
                            'action' => 'login'
                        ]);
                    }
                ?>
			</div> <!-- user -->
		</div> <!-- header -->


    <!-- Barre de menu horizontale -->
    <div>
	<?php
	   /* 
	    * Si on est sur la page /materiels/index (liste des materiels),
	    * (et SEULEMENT pour cette vue là),
	    * on désactive le champ général de recherche de matériels intégré au menu,
	    * car cette vue en contient déjà un (qui est plus souple à utiliser)
	    * 
	    * $has_search_field = false;
	    * 
	    */
	   //debug($this->request->params['controller']);
	   //debug($this->request->params['action']);
	   $controller = $this->request->getParam('controller');
	   $action = $this->request->getParam('action');
	   $has_search_field = ! ($controller == 'Materiels' && $action == 'index');
	   //$has_search_field = true;
	   //$this->element('menu_responsive');
        echo $this->element('menu_responsive', [
            'has_search_field' => $has_search_field,
        ])
    ?>
    </div>


		<!-- Contenu principal de chaque page web -->
		<div class="col-lg-12" id="content">
		
			<!-- Message Flash éventuel -->
			<?= $this->Flash->render() ?>
			<!-- 
			 Avant 3.4.0, cette ligne sera également nécessaire
			<= $this->Flash->render('auth') ?>
			--> 

			<!-- 
			 Contenu complet de la page web 
			 (par exemple src/Template/Materiels/index.ctp pour la liste des matos) 
			-->
			<?= $this->fetch('content') ?>

    	</div> <!-- content -->

            <div class="row" id="footer">

              <section class="row col-lg-12">

                <div class="col-lg-2">
                	<!-- https://book.cakephp.org/4/en/views/helpers/html.html#linking-to-images -->
                	<?=$this->Html->image($logo_entity_name, ['alt'=>'Logo du labo', 'border'=>'0', 'height'=>'50px'])?>
                	<?php //echo $this->Html->image('DebugKit.icon.png'); ?>
                </div>

                <a class="col-lg-2" href="http://cakephp.org">Baked with CAKEPHP</a>

                <div class="col-lg-5" id="bugreport">
                	<!-- 
                	 <a href="https://tinyurl.com/labinvent#heading=h.2gyqfeghae4k"><h3>WHAT's NEW ?</h3></a>
                	 -->
                	<a href="/pages/changes"><h3>WHAT's NEW ?</h3></a>
                  	<i>
                    <!-- 
                    (<a href="https://projects.irap.omp.eu/projects/inventirap/roadmap?tracker_ids[]=1&tracker_ids[]=2&tracker_ids[]=4&tracker_ids[]=5&tracker_ids[]=6&tracker_ids[]=7&tracker_ids[]=8&tracker_ids[]=9#version_2.04_-_Impl%C3%A9mentation_des_ACL_%28droits%29">ROADMAP : Activité restant à réaliser</a>)
                    (<a href="https://projects.irap.omp.eu/projects/inventirap/issues?query_id=263">ROADMAP => Activité restant à réaliser - TODO LIST</a>)
                    -->
                    (<a href="https://docs.google.com/spreadsheets/d/1vRW67Mr_l5gg1Ae9w7wpMAFYBP74MqFD6J3q4iZ0Ax4/edit#gid=0">ROADMAP => Activité restant à réaliser - TODO LIST</a>)
                    <br/><h6>Merci de communiquer remarques et bugs à <a href="mailto:inventirap@irap.omp.eu">LABINVENT-MAILING-LIST</a></h6>
                  	</i>
                </div>
                
                <div class="col-lg-3" id="version">
                  <?php
                    // LECTURE DE LA VERSION DU LOGICIEL DANS LE FICHIER README
                    // Set $version and $version_date 
                    // pour "what's new" : &nbsp;&nbsp;&nbsp
                    // (cf https://book.cakephp.org/3.0/fr/core-libraries/file-folder.html#Cake\Filesystem)
                    //$version = '2.9.1.4';
                    //$version_date = '21/12/2018';
                    $wwwroot_dir = new Cake\Filesystem\Folder(WWW_ROOT);
                    $readme_file_path = $wwwroot_dir->pwd() . DS . '..' . DS . 'README.md';
                    /* (OLD) VERSION PLUS LENTE CAR ON LISAIT TOUT LE FICHIER
                    $readme_file = new Cake\Filesystem\File($readme_file_path);
                    //dump($file);
                    $contents = $readme_file->read();
                    $lines = explode("\n", $contents);
                    for ($i = 0; $i < sizeof($lines); $i++) {
                        $line = $lines[$i];
                        if (substr($line, 0, strlen("Date:")) === "Date:") {
                            $version_date = ltrim( explode(":", $line)[1] );
                            $version = explode(":", $lines[$i+1])[1];
                            break;
                        }
                    }
                    // $readme_file->write('J'écris dans ce fichier');
                    // $readme_file->append('J'ajoute à la fin de ce fichier.');
                    // $readme_file->delete(); // Je supprime ce fichier
                    $readme_file->close(); // Assurez-vous de fermer le fichier quand c'est fini
                    */
                    // VERSION PLUS RAPIDE CAR ON LE LIT QUE JUSQU'A LA VERSION
                    try {
                        $f = new SplFileObject($readme_file_path, "r");
                    } catch (Exception $e) {
                        die("Le fichier README $readme_file_path n'existe pas !");
                    }
                    $version = 'XXX';
                    $version_date = 'date?';
                    while (!$f->eof()) {
                        $line = $f->fgets();
                        if (substr($line, 0, strlen("Date:")) === "Date:") {
                            $version_date = ltrim( explode(":", $line)[1] );
                            // ligne suivante
                            $line = $f->fgets();
                            $version = explode(":", $line)[1];
                            break;
                        }
                    }
                    // Close file
                    $f=null;
                  ?>
                  <!-- VERSION M.m.f.b (version (M)ajeure, version (m)ineure, numero de nouvelle (f)onctionnalite, numero de (b)ugfix) -->
                  <font color="black">
                    <!-- 
                     VERSION 2.9.1.4 (21/12/2018)
                    -->
                    <?="VERSION $version ($version_date)"?>
                    <br/>
                    <a href="<?=$this->request->getAttribute("webroot")?>webroot/doc/userguide/labinvent2_userguide.pdf" onclick="window.open(this.href); return false;">Documentation utilisateurs</a> 
                    <br/>
                    <a href="https://tinyurl.com/labinvent" onclick="window.open(this.href); return false;">Documentation technique générale</a>
                    <!-- 
                    <a href="https://projects.irap.omp.eu/projects/inventirap/wiki/Installation" onclick="window.open(this.href); return false;">Wiki installation</a>
                    -->
                  </font>
                </div>
                
              </section>
            </div> <!-- footer -->


	</div> <!-- container -->

</body>

</html>