en | fr  | Contact  | Print  | Share

FrameBeurk File

Fmbk/prive/accueilFmbk.php

<?php //FrameBeurk V0.65 Copyright ToolOscope 2016. Licence CeCILL-C.

if ($DIALOG['Langue'] == 'fr_FR') {
    
$TRANSAC['Page']['Titre'] = 'Accueil Fmbk';

?>
<h1>Bienvenue dans votre Fmbk</h1>
<p>Ce site est motorisé par FrameBeurk, le Framework Php alternatif. Vous pourrez trouver toute la documentation de FrameBeurk sur le site de <a href="http://www.tooloscope.com">ToolOscope</a>.</p>
<p>En guise de tutoriel pour les développeurs d'applications web, pour vous permettre de comprendre l'essentiel du fonctionnement de FrameBeurk, jouons à un jeu de questions-réponses, en partant du point de départ : Vous venez d'installer FrameBeurk.</p>
<br />
<h2>Pourquoi voyez-vous cette page ?</h2>
<ul>
<li>Ouvrez un explorateur sur le répertoire d'intallation, vous allez trouver le fichier de configuration du site ici :
<span class="chemin">/prive/_site/config_site.php</span></li>
<li>Parcourez ce fichier. Il alimente le tableau <span class="valeur">$CONFIG</span> avec les données de votre site.
Dans la dernière partie sont établis les valeurs par défaut
<div class="code">$CONFIG['Defaut'] = array(
    .../...
    'ActVue' => 'detail',
    'IdVue' => 'Site',
    'PageStatique' => 'accueil',</div>
</li>
<li>Les 2 premières lignes ci-dessus signifient que par défaut, FrameBeurk affichera la vue générée par l'action <span class="valeur">detail</span> de l'entité <span class="valeur">Site</span>.</li>
<li>C'est le module <span class="valeur">Kom1</span> qui définit cette entité. Tous les modules ont un fichier de configuration qui alimente <span class="valeur">$CONFIG</span>. Dans <span class="chemin">/Module/Kom1/configKom1.php</span>, on trouve :
<div class="code">$CONFIG['Entite']['<span class="valeur">Site</span>'] = array(
    'Module' => 'Kom1',
    'Maj' => array(),
    'Vue' => array(
        'reaffiche' => array('Auto' => 'Tous'),
        'recherche' => array('Auto' => 'Tous',
            'Clef' => array('Perimetre', 'Createur', 'DateCreation', 'MotCle', 'NoPage')),
        'modere'    => array('Auto' => 'Admin'),
        'explore'    => array('Auto' => 'Logue'),
        '<span class="valeur">detail</span>'     => array('Auto' => 'Tous',
            'Clef' => array('<span class="valeur">PageStatique</span>')
    )));</div>
</li>
<li>L'entité <span class="valeur">Site</span> n'a pas d'action de type Maj (dont la fonction est de mettre à jour la base de donnée), et 5 actions de type Vue (fonction d'affichage).
L'action Vue <span class="valeur">detail</span> est autorisée à tous les utilisateurs (Rem : <span class="valeur">Tous</span> est associé à une fonction d'autorisation dans <span class="chemin">configUzers.php</span>).
Elle a pour unique paramètre <span class="valeur">PageStatique</span>, qui précise la page à afficher.</li>
<li>Dans notre cas, la valeur par défaut de <span class="valeur">PageStatique</span> est <span class="valeur">accueil</span> qui est le code interne d'une page. Ce code est associé à un fichier statique un peu plus haut dans le fichier <span class="chemin">config_site.php</span> :
<div class="code">$CONFIG['Controle'] = array(
    .../...
    'PageStatique' => array('<span class="valeur">accueil</span>' => '<span class="valeur">accueilFmbk.php</span>'),</div>
</li>
<li>Ouvrez le code de la vue <span class="chemin">/Module/Kom1/Site/Vue/detailSite.php</span>. Après quelques contrôles, vous trouvez :
<div class="code">if (file_exists($Import = INSTALL_PATH . '<span class="valeur">/prive/</span>' . $CONFIG['Controle']['PageStatique'][$PageStatique])) {
    include($Import);
} else {
    Beurk_messageEtape('Page inconnue', true);
    ...</div>
Le fichier à afficher sera recherché dans le répertoire <span class="chemin">/prive</span>. Ce répertoire est prévu pour accueillir toutes les ressources externes à FrameBeurk qui ne doivent pas être accessible au navigateur Internet de l'utilisateur.
Au contraire du répertoire <span class="chemin">/public</span> qui est accessible à tous. Si le fichier n'existe pas, l'action retourne le message d'erreur <span class="valeur">Page inconnue</span> (qui sera éventuellement traduit) et positionne une erreur sur la Vue (2ème argument à <span class="valeur">true</span>)
</li>
</ul>

<br />
<h2>Comment changer la page d'accueil ?</h2>
<p>Il y a plusieurs possibilités :
<ul>
<li>Editer cette page pour en changer le contenu. Ouvrez <span class="chemin">/prive/accueilFmbk.php</span> dans un éditeur. Vous allez constater que différentes parties du code HTML de cette page sont conditionnés :
<div class="code">&lt;?php
if ($DIALOG['Langue'] == 'fr_FR') {
    $TRANSAC['Page']['Titre'] = 'Accueil Fmbk';
?&gt;</div>
<span class="valeur">$DIALOG</span> contient les données qui sont conservées tout au long de la conversation avec l'utilisateur, alors que <span class="valeur">$TRANSAC</span> est réinitialisé à chaque transaction.
Le paragraphe qui suit cette condition ne sera affiché que si la langue en cours est <span class="valeur">fr_FR</span>. Le titre de la page (affiché dans l'historique du navigateur) sera alors <span class="valeur">Accueil Fmbk</span>.
Ceci est une des méthodes utilisables dans FrameBeurk pour gérer du contenu en plusieurs langues.
</li>
<li>Créer une nouvelle page. Dans un éditeur de texte, saisissez le contenu que vous souhaitez, au format texte, html ou php. Enregistrez cette page dans le répertoire <span class="chemin">/prive</span> ou un sous-répertoire.
Il faut ensuite déclarer dans le fichier <span class="chemin">/prive/_site/config_site.php</span> cette nouvelle page pour qu'elle soit reconnue par l'action <span class="valeur">detail-Site</span> :
<div class="code">$CONFIG['Controle'] = array(
    .../...
    'PageStatique' => array('accueil' => 'accueilFmbk.php',
            '<span class="valeur">perso1</span>' => '<span class="valeur">accueilPerso.php</span>'),</div>
Et la configurer en tant qu'argument par défaut de l'action :
<div class="code">$CONFIG['Defaut'] = array(
    .../...
    'PageStatique' => '<span class="valeur">perso1</span>',</div>
</li>
<li>Paramétrer une action déjà existante dans un des modules installés, comme afficher le Forum ou les News (module <span class="valeur">Rhum</span>).
Editez le fichier <span class="chemin">/prive/_site/config_site.php</span> et paramétrez l'action désirée :
<div class="code">$CONFIG['Defaut'] = array(
    .../...
    'ActVue' => 'detail',
    'IdVue' => 'Forum',   // 'News'</div>
Ouvrez le fichier <span class="chemin">/Module/Rhum/configRhum.php</span> et constatez que la Vue <span class="valeur">detail-Forum</span> n'a pas de paramètre.
La Vue <span class="valeur">detail-News</span> a pour paramètre <span class="valeur">NoPage</span>, mais ne gère pas de valeur par défaut.
En effet, compte-tenu de la fréquence de cet paramètre, la valeur par défaut est fixée à <span class="valeur">1</span> par <span class="chemin">/Module/Beurk/controleurVue.php</span>
</li>
</ul>
<p><b>Remarque importante</b> :</p>
<ul>
<li>Vous venez de peut-être de modifier la configuration, mais celle-ci ne sera pas prise en compte si elle a déjà été chargée en session : Pour des raisons de performances, la configuration n'est rechargée que lorsque sa version change.
Ouvrez dans un éditeur le fichier <span class="chemin">\modules\Beurk\bootstrap.php</span>. Celui-ci est exécuté par le serveur au début de chaque transaction. Vous trouvez le code suivant :
<div class="code">include(INSTALL_PATH . "<span class="chemin">/prive/_site/bootstrap_site.php</span>");

// configuration déjà stockée en session
if (isset($_SESSION['CONFIG']) && $_SESSION['CONFIG']['Param']['Version'] == <span class="valeur">$TRANSAC['version']</span>)
    <span class="valeur">$CONFIG = $_SESSION['CONFIG']</span>;
    
// nouvelle configuration à charger
else {
    $CONFIG = array();
    include(INSTALL_PATH . "<span class="chemin">/prive/_site/config_site.php</span>");
    .../...
    <span class="valeur">$_SESSION['CONFIG'] = $CONFIG</span>;
}</div>
C'est le fichier <span class="chemin">bootstrap_site.php</span> qui alimente le numéro de version de la configuration.
Si <span class="valeur">$CONFIG</span> a déjà été stocké en session PHP et que le numéro de version y est identique, FrameBeurk restaure <span class="valeur">$CONFIG</span> depuis la session.
Sinon, FrameBeurk établit la configuration à partir de tous les fichiers de configuration (à commencer par <span class="chemin">config_site.php</span>) puis la sauve en session.
</li>
<li>Pour modifier le numéro de version de la configuration et ainsi forcer son rechargement, ouvrez le fichier <span class="chemin">/prive/_site/bootstrap_site.php</span> et modifiez le numéro (sa valeur n'a pas d'importance en soi, mais doit être changée).
<div class="code">require(INSTALL_PATH . '/Module/mysqli_layer.php');
$TRANSAC['Db']['Fmbk'] = db_CONNECT('localhost:3306', 'root', '', 'Fmbk06') or die('Connexion à la Database KO');
$TRANSAC['Db']['Courante'] = $TRANSAC['Db']['Fmbk'];

$TRANSAC['version'] = '<span class="valeur">0.2040w</span>';</div>
On en profite pour constater que c'est ce script qui charge la couche de communication avec le gestionnaire de bases de données, ouvre la connexion et choisit la database.
</li>
</ul>
<?php 

} else { // $DIALOG['Langue'] == 'en_US' -----------------------------------------------------------------------------------------------------------------
    
$TRANSAC['Page']['Titre'] = 'Home Page';
?>
<h1>Welcome to your Fmbk</h1>
<p>This site is powered by FrameBeurk, the alternative PHP Framework. You can find all the documentation of FrameBeurk on the website of <a href="http://www.tooloscope.com">ToolOscope</a>.</p>
<p>As a tutorial for the developpers of web applications, to let you understand the basics of FrameBeurk functioning, let's play at a questions & answers game, starting from the beginning : You have just installed FrameBeurk.</p>
<br />
<h2>Why do you see this page ?</h2>
<ul>
<li>Open an explorer on the installation folder, you are going to find the configuration file of this site here :
<span class="chemin">/prive/_site/config_site.php</span></li>
<li>Read through this file. It populates the associative array <span class="valeur">$CONFIG</span> with the data of your site.
In the last part are set the default values
<div class="code">$CONFIG['Defaut'] = array(
    .../...
    'ActVue' => 'detail',
    'IdVue' => 'Site',
    'PageStatique' => 'accueil',</div>
</li>
<li>The first 2 lines above are meaning that by default, FrameBeurk displays the view generated by the action named <span class="valeur">detail</span> of the entity <span class="valeur">Site</span>.</li>
<li>It is the module <span class="valeur">Kom1</span> that defines this entity. All modules have a configuration file that populates <span class="valeur">$CONFIG</span>. In <span class="chemin">/Module/Kom1/configKom1.php</span>, we find :
<div class="code">$CONFIG['Entite']['<span class="valeur">Site</span>'] = array(
    'Module' => 'Kom1',
    'Maj' => array(),
    'Vue' => array(
        'reaffiche' => array('Auto' => 'Tous'),
        'recherche' => array('Auto' => 'Tous',
            'Clef' => array('Perimetre', 'Createur', 'DateCreation', 'MotCle', 'NoPage')),
        'modere'    => array('Auto' => 'Admin'),
        'explore'    => array('Auto' => 'Logue'),
        '<span class="valeur">detail</span>'     => array('Auto' => 'Tous',
            'Clef' => array('<span class="valeur">PageStatique</span>')
    )));</div>
</li>
<li>The entity <span class="valeur">Site</span> has no action of type Maj (whose purpose is usually to update the database), and 5 actions of type Vue (View functions).
The view action <span class="valeur">detail</span> is authorized to all users (Rem : <span class="valeur">Tous</span> is associated to an authorization function in <span class="chemin">configUzers.php</span>).
It has for unique parameter <span class="valeur">PageStatique</span>, that precise the page to display.</li>
<li>In our case, the default value of <span class="valeur">PageStatique</span> is <span class="valeur">accueil</span> which is the internal code of a page. This code is associated to a static file, a few lines above in the file <span class="chemin">config_site.php</span> :
<div class="code">$CONFIG['Controle'] = array(
    .../...
    'PageStatique' => array('<span class="valeur">accueil</span>' => '<span class="valeur">accueilFmbk.php</span>'),</div>
</li>
<li>Open the code of view <span class="chemin">/Module/Kom1/Site/Vue/detailSite.php</span>. After a few controls, you can find :
<div class="code">if (file_exists($Import = INSTALL_PATH . '<span class="valeur">/prive/</span>' . $CONFIG['Controle']['PageStatique'][$PageStatique])) {
    include($Import);
} else {
    Beurk_messageEtape('Page inconnue', true);
    ...</div>
The file to display will be searched in folder <span class="chemin">/prive</span>. This folder is meant to store all the resources external to FrameBeurk that should not be accessed by the Internet browser of the user.
On the opposit of folder <span class="chemin">/public</span> which can be accessed by all. If the file does not exist, the action returns the error message <span class="valeur">Page inconnue</span> (that may be translated) and set an error on the view (because the 2nd argument is <span class="valeur">true</span>)
</li>
</ul>

<br />
<h2>How to change the home page ?</h2>
<p>There are several options :
<ul>
<li>Edit this page to change its content. Open <span class="chemin">/prive/accueilFmbk.php</span> in a text editor. You can see that different parts of the HTML code of this page are conditioned :
<div class="code">&lt;?php
if ($DIALOG['Langue'] == 'fr_FR') {
    $TRANSAC['Page']['Titre'] = 'Accueil Fmbk';
?&gt;</div>
<span class="valeur">$DIALOG</span> contains the data that is kept all along the conversation between the server and the user, while <span class="valeur">$TRANSAC</span> is reset at each transaction.
The paragraph that follows this condition will only be displayed if the language currently in use is <span class="valeur">fr_FR</span>. The title of the page (displayed in the history of the browser) will be <span class="valeur">Accueil Fmbk</span>.
This is one of the methods that can be used in FrameBeurk to manage content in several tongues.
</li>
<li>Create a new page. In a text editor, enter the content that you want, in text format, or html or php. Save this page in folder <span class="chemin">/prive</span> or in a sub-folder.
Then you have to declare that new page in the file <span class="chemin">/prive/_site/config_site.php</span>, so that it will be recognized by action <span class="valeur">detail-Site</span> :
<div class="code">$CONFIG['Controle'] = array(
    .../...
    'PageStatique' => array('accueil' => 'accueilFmbk.php',
            '<span class="valeur">perso1</span>' => '<span class="valeur">homePerso.php</span>'),</div>
And set the default value of the argument of the action :
<div class="code">$CONFIG['Defaut'] = array(
    .../...
    'PageStatique' => '<span class="valeur">perso1</span>',</div>
</li>
<li>Set-up an action that already exists in one of the installed modules, e.g. display the Forum or the News (module <span class="valeur">Rhum</span>).
Edit the file <span class="chemin">/prive/_site/config_site.php</span> and set the desired action by default :
<div class="code">$CONFIG['Defaut'] = array(
    .../...
    'ActVue' => 'detail',
    'IdVue' => 'Forum',   // 'News'</div>
Open file <span class="chemin">/Module/Rhum/configRhum.php</span> and see that the view (Vue) <span class="valeur">detail-Forum</span> has no parameter.
The View <span class="valeur">detail-News</span> has <span class="valeur">NoPage</span> for parameter, but does not manage a default value.
Indeed, given the frequent usage of this parameter, the default value is set to <span class="valeur">1</span> by <span class="chemin">/Module/Beurk/controleurVue.php</span>
</li>
</ul>
<p><b>Important Remark</b> :</p>
<ul>
<li>You may have just modified the configuration, but this one will not be taken into account if it has already been loaded into session : For performance optimization, once loaded, the configuration is only reloaded when the version number changes.
Open in a text editor the file <span class="chemin">\modules\Beurk\bootstrap.php</span>. This one is executed by the server at the beginning of each transaction. You find there the following code :
<div class="code">include(INSTALL_PATH . "<span class="chemin">/prive/_site/bootstrap_site.php</span>");

// configuration already saved into session
if (isset($_SESSION['CONFIG']) && $_SESSION['CONFIG']['Param']['Version'] == <span class="valeur">$TRANSAC['version']</span>)
    <span class="valeur">$CONFIG = $_SESSION['CONFIG']</span>;
    
// new configuration to load
else {
    $CONFIG = array();
    include(INSTALL_PATH . "<span class="chemin">/prive/_site/config_site.php</span>");
    .../...
    <span class="valeur">$_SESSION['CONFIG'] = $CONFIG</span>;
}</div>
This is the file <span class="chemin">bootstrap_site.php</span> that sets the version number of the configuration.
If <span class="valeur">$CONFIG</span> has been saved into a PHP session and that the version number stays unchanged, FrameBeurk restores <span class="valeur">$CONFIG</span> from the session.
Else, FrameBeurk sets up the configuration using all the configuration files of the modules (beginning with <span class="chemin">config_site.php</span>) and saves it into session.
</li>
<li>To modify the version number of the configuration and therefore force its reload, open the file <span class="chemin">/prive/_site/bootstrap_site.php</span> and modify the value (it has no meaning in itself, but it has to be different).
<div class="code">require(INSTALL_PATH . '/Module/mysqli_layer.php');
$TRANSAC['Db']['Fmbk'] = db_CONNECT('localhost:3306', 'root', '', 'Fmbk06') or die('Connexion à la Database KO');
$TRANSAC['Db']['Courante'] = $TRANSAC['Db']['Fmbk'];

$TRANSAC['version'] = '<span class="valeur">0.2040w</span>';</div>
We can see by the way that this is the script that loads the database communication layer, opens the connexion and chooses the database.
</li>
</ul>

<?php }


© 2010-2015 by ToolOscope SASU. © 2016-2018 by Arnaud De Rette. All rights reserved