« Programmation PHP/Exemples/MiniCMS/Développement » : différence entre les versions

Contenu supprimé Contenu ajouté
Ligne 4 :
*Code de service vs Code métier
 
=== *Modélisation ===
La modélisation se veut simple et polyvalente.
 
==== Champs de données ====
 
<b>[champs contenus]</b>
 
Sous customer1/contents, les champs ou "espaces de données" sont organisés en paquets d'enregistrements. D'autres modèles sont possibles.
<source lang="xml">
<?xml version="1.0" encoding="UTF-8"?>
<!-- content dataChunk model -->
<crop id="" number="" scope="" links="">
<topic/>
<assert>
<!-- HERE COMES FRONT END CODE -->
</assert>
 
<!-- Content records -->
<fields>
<field id="" number="" subject="">
<topic/>
<assert/>
<content></content>
</field>
</fields>
 
</crop>
</source>
Distribués ou non, les paquets s'accèdent par du service le plus possible. Pour ne pas dépendre d'un développement purement métier. On peut opérer la distinction service / métier, en disant que le service est moins spécialisé.
La méthode d'accession aux données sera par exemple un :
*getCropById ou byScope (prendreChampParId ou parEtendue)
*getFieldNearSubject (prendreDonnéePrèsDuSujet)
 
L'id permettant une extraction directe de contenu.
 
 
<b>[champs utilisateurs]</b>
 
 
Même logique de service :
 
<source lang="xml">
<?xml version="1.0" encoding="UTF-8"?>
<!-- users dataChunk model -->
<users id="" number="" links="">
 
<!-- u:usr / m:mod / a:adm -->
<user login="" pass="" lastname="" forname="" rights="u|m|a" />
 
</users>
</source>
 
Mêmes accès que pour le modèle précédent.
 
 
<b>[Champs templates]</b>
 
{{Boîte déroulante|titre= :: standard :: |contenu =
<source lang="xml">
<?xml version="1.0" encoding="UTF-8"?>
 
<!-- templateChunk model -->
<template id="standard" number="" topic="" links="">
<!-- HEADER CONTENT -->
<header>
<assert>
<![CDATA[
:: HERE COMES SERVER/CLIENT SIDE SNIPPETS ::
]]>
</assert>
<!-- -->
<content>
<![CDATA[
<html><head/>
]]>
</content>
</header>
<!-- HEADER CONTENT -->
<main>
<assert>
<![CDATA[
:: HERE COMES SERVER/CLIENT SIDE SNIPPETS ::
]]>
</assert>
<!-- -->
<content>
<![CDATA[
<body>
...
]]>
</content>
</main>
<!-- FOOTER CONTENT -->
<footer>
<assert>
<![CDATA[
:: HERE COMES SNIPPET ::
]]>
</assert>
<content>
<![CDATA[
</body></html>
]]>
</content>
</footer>
 
</template>
</source>
}}
 
La version suivante a une complétion par points d'ancrages. Cette version va orienter le projet.
 
{{Boîte déroulante|titre= :: nested :: |contenu =
<source lang="xml">
<?xml version="1.0" encoding="UTF-8"?>
 
<!-- templateChunk model -->
<template id="nested" number="" topic="" links="">
<!-- HEADER CONTENT -->
<header>
<assert>
<![CDATA[
:: HERE COMES SERVER/CLIENT SIDE SNIPPETS ::
]]>
</assert>
<!-- -->
<content>
<styles>
<style id="" />
<style id="christmas">
body
{
background-color:red;
font-family:verdana;
padding:10px;
}
.style_01
{
/* some style in */
}
</style>
</styles>
 
<scripts>
<script id="scr_1" number="1"/>
<script id="scr_2" number="2"/>
...
</scripts>
</content>
</header>
<!-- HEADER CONTENT -->
<main>
<assert>
<![CDATA[
:: HERE COMES SERVER/CLIENT SIDE SNIPPETS ::
]]>
</assert>
<!-- -->
<content>
<page id="standard">
<![CDATA[
<table width="100%" border="0">
<tr><td>
{{inc:page[header]}}
</td></tr>
<tr><td>
{{inc:page[main]}}
</td></tr>
</table>
]]>
</page>
<page id="lay_01"/>
<page id="lay_02"/>
<page id="lay_03"/>
</content>
</main>
<!-- PAGE CONTENT -->
<frameset>
<assert>
<code type="text/javascript" id="scr_01">
<![CDATA[
function lastScript()
{
return "this is last script";
}
]]>
</code>
<code type="action/php" id="act_01">
<![CDATA[
ContentCompleter::setContent(array("frameset.content[text/head]","header.content[*]"));
ContentCompleter::setContent(array("frameset.content[text/body]","main.content[*]"));
]]>
</code>
<code type="action/php" id="act_02">
<![CDATA[
ContentCompleter::setContent(array("frameset.assert.code[id:scr_01]","footer.content[text/id:inc_03]"));
]]>
</code>
<code type="text/php" id="toStringClass">
<![CDATA[
class toString
{//
public $self = array();
public function __construct( /* ... */ $init )
{
}
}
$tmp = new toString(1);
]]>
</code>
</assert>
<content><!-- -->
<![CDATA[
<?xml version="1.0" encoding="UTF-8" ?>
{{inc:token[strict]}}
<html>
<head>
<style>{{inc:style[christmas]}}</style>
<script>{{inc:script[topScript]}}</script>
</head>
<body onload="feedContent()">
{{inc:page[standard]}}
</body>
<script>
{{inc:script[endScript]}}
</script>
</html>
]]>
</content>
</frameset>
<!-- FOOTER CONTENT -->
<footer>
<assert>
<![CDATA[
:: HERE COMES SNIPPET ::
]]>
</assert>
<content>
<![CDATA[
{{inc:scripts[last]}}
<script>
action.load();
</script>
<script id="inc_03">
</script>
]]>
</content>
</footer>
<tokens>
<token id="HTML4">
<![CDATA[
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
]]>
</token>
<token id="xhtml_xmlns">
<![CDATA[
http://www.w3.org/1999/xhtml
]]>
</token>
</tokens>
</template>
 
</source>
}}
L'autorisation de snippets php exécutables rendra possible l'intégration coté client (''customer'').
L'adjonction du contenu à l'output se faisant par injection aux points d'ancrage {{inc:nomDeCle[idDeCle]}} par la méthode servant à compléter le flux avant sa sortie, comme :
*getFeedByTagName ou getPartByName ...
*incomes(header/content) à l'injection
Le contenu peut être sorti coté php ou ajaxifié comme ici par le javascript de fin de flux (frameset/content) feedContent().
 
=== Implémentation ===