Skip to content
Extraits de code Groupes Projets
Valider 5d25ad7f rédigé par cerdic's avatar cerdic
Parcourir les fichiers

aafficher_contenu_objet abandonne l'usine a gaz au profit d'un squelette personalisable

par type, dont le resultat passe dans un pipeline pour permettre l'extension par les plugins
parent cf6d04ed
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -266,6 +266,10 @@ dist/prive/article_infos_fonctions.php -text
dist/prive/auteur_infos.html -text
dist/prive/breve_infos.html -text
dist/prive/breve_infos_fonctions.php -text
dist/prive/contenu/article.html -text
dist/prive/contenu/breve.html -text
dist/prive/contenu/rubrique.html -text
dist/prive/contenu/site.html -text
dist/prive/rubrique_infos.html -text
dist/prive/site_infos.html -text
dist/prive/site_infos_fonctions.php -text
......
<BOUCLE_afficher_contenu(ARTICLES){id_article=#ENV{id}}{statut?}>
<span class="champ contenu_surtitre[ (#SURTITRE*|?{'',vide})]">
<span class='label'><:texte_sur_titre:></span>
<span dir='#LANG_DIR' class='#EDIT{surtitre} surtitre'>#SURTITRE</span>
</span>
<span class="champ contenu_titre[ (#TITRE*|?{'',vide})]">
<span class='label'><:info_titre:></span>
<span dir='#LANG_DIR' class='#EDIT{titre} titre'>#TITRE</span>
</span>
<span class="champ contenu_soustitre[ (#SOUSTITRE*|?{'',vide})]">
<span class='label'><:texte_sous_titre:></span>
<span dir='#LANG_DIR' class='#EDIT{soustitre} soustitre'>#SOUSTITRE</span>
</span>
<span class="champ contenu_descriptif[ (#DESCRIPTIF*|?{'',vide})]">
<span class='label'><:info_descriptif:></span>
<span dir='#LANG_DIR' class='#EDIT{descriptif} descriptif'>#DESCRIPTIF</span>
</span>
<span class="champ contenu_chapo[ (#CHAPO*|?{'',vide})]">
<span class='label'><:info_chapeau:></span>
<span dir='#LANG_DIR' class='#EDIT{chapo} chapo'>#CHAPO</span>
</span>
<span class="champ contenu_nom_site[ (#NOM_SITE*|?{'',vide})]">
<span class='label'><:lien_voir_en_ligne:></span>
<span dir='#LANG_DIR' class='#EDIT{hyperlien} nom_site'><a href='#URL_SITE'>#NOM_SITE</a></span>
</span>
<span class="champ contenu_texte[ (#TEXTE*|?{'',vide})]">
<span class='label'><:info_texte:></span>
<span dir='#LANG_DIR' class='#EDIT{texte} texte'>#TEXTE</span>
</span>
<span class="champ contenu_ps[ (#PS*|?{'',vide})]">
<span class='label'><:info_ps:></span>
<span dir='#LANG_DIR' class='#EDIT{ps} ps'>#PS</span>
</span>
[<span class="champ contenu_notes">
<span class='label'><:info_notes:></span>
<span dir='#LANG_DIR' class='#EDIT{notes} notes'>(#NOTES)</span>
</span>]
[(#ENV{champs_extra}|?{' '})
[(#EXTRA**|extra_affichage)]
]
</BOUCLE_afficher_contenu>
\ No newline at end of file
<BOUCLE_afficher_contenu(BREVES){id_breve=#ENV{id}}{statut?}>
<span class="champ contenu_titre[ (#TITRE*|?{'',vide})]">
<span class='label'><:info_titre:></span>
<span dir='#LANG_DIR' class='#EDIT{titre} titre'>#TITRE</span>
</span>
<span class="champ contenu_texte[ (#TEXTE*|?{'',vide})]">
<span class='label'><:info_texte:></span>
<span dir='#LANG_DIR' class='#EDIT{texte} texte'>#TEXTE</span>
</span>
<span class="champ contenu_lien_titre[ (#LIEN_TITRE*|?{'',vide})]">
<span class='label'><:lien_voir_en_ligne:></span>
<span dir='#LANG_DIR' class='#EDIT{hyperlien} lien_titre'><a href='#LIEN_URL'>#LIEN_TITRE</a></span>
</span>
[<span class="champ contenu_notes">
<span class='label'><:info_notes:></span>
<span dir='#LANG_DIR' class='#EDIT{notes} notes'>(#NOTES)</span>
</span>]
[(#ENV{champs_extra}|?{' '})
[(#EXTRA**|extra_affichage)]
]
</BOUCLE_afficher_contenu>
\ No newline at end of file
<BOUCLE_afficher_contenu(RUBRIQUES){id_rubrique=#ENV{id}}{statut?}>
<span class="champ contenu_titre[ (#TITRE*|?{'',vide})]">
<span class='label'><:info_titre:></span>
<span dir='#LANG_DIR' class='#EDIT{titre} titre'>#TITRE</span>
</span>
<span class="champ contenu_descriptif[ (#DESCRIPTIF*|?{'',vide})]">
<span class='label'><:info_descriptif:></span>
<span dir='#LANG_DIR' class='#EDIT{descriptif} descriptif'>#DESCRIPTIF</span>
</span>
<span class="champ contenu_texte[ (#TEXTE*|?{'',vide})]">
<span class='label'><:info_texte:></span>
<span dir='#LANG_DIR' class='#EDIT{texte} texte'>#TEXTE</span>
</span>
[<span class="champ contenu_notes">
<span class='label'><:info_notes:></span>
<span dir='#LANG_DIR' class='#EDIT{notes} notes'>(#NOTES)</span>
</span>]
[(#ENV{champs_extra}|?{' '})
[(#EXTRA**|extra_affichage)]
]
</BOUCLE_afficher_contenu>
\ No newline at end of file
<BOUCLE_afficher_contenu(SYNDIC){id_syndic=#ENV{id}}{statut?}>
<span class="champ contenu_nom_site[ (#NOM_SITE*|?{'',vide})]">
<span class='label'><:form_prop_nom_site:></span>
<span dir='#LANG_DIR' class='#EDIT{hyperlien} nom_site'><a href='#URL_SITE'>#NOM_SITE</a></span>
</span>
<span class="champ contenu_descriptif[ (#DESCRIPTIF*|?{'',vide})]">
<span class='label'><:info_descriptif:></span>
<span dir='#LANG_DIR' class='#EDIT{descriptif} descriptif'>#DESCRIPTIF</span>
</span>
[<span class="champ contenu_notes">
<span class='label'><:info_notes:></span>
<span dir='#LANG_DIR' class='#EDIT{notes} notes'>(#NOTES)</span>
</span>]
[(#ENV{champs_extra}|?{' '})
[(#EXTRA**|extra_affichage)]
]
</BOUCLE_afficher_contenu>
\ No newline at end of file
......@@ -13,93 +13,14 @@
// affichage du contenu d'un objet spip (onglet contenu)
// Cas generique, utilise pour tous les objets
// http://doc.spip.org/@inc_afficher_contenu_objet_dist
function inc_afficher_contenu_objet_dist($type, $id,$row = NULL){
$table = table_objet($type);
$key = id_table_objet($type);
if (!$row) {
$res = sql_select(array('*'),array("spip_$table"),array("$key=".sql_quote($id)));
$row = sql_fetch($res);
}
if (!$row) return "";
if (isset($row['lang'])) {
changer_typo($row['lang']);
}
$lang_dir = lang_dir($GLOBALS['lang_objet']);
// demander un englobant des champs=>libelles a afficher pour cet objet
$champs_libelles = pipeline(
'afficher_objet_champs_libelles',
array(
'data'=>afficher_objet_champs_libelles($type,$table,$id,$row),
'args'=>array('type'=>$type,$key=>$id)
)
);
// ne considerer que les champs presents en base
foreach($champs_libelles as $champ=>$libelle)
if ($champ!='notes' && !isset($row[$champ]))
unset($champs_libelles[$champ]);
if (isset($champs_libelles['nom_site']))
unset($champs_libelles['url_site']);
if (isset($champs_libelles['lien_titre']))
unset($champs_libelles['lien_url']);
/* TODO, mais il manque encore des concepts comme la boucle FOR pour y arriver
$contexte = array($key=>$id,'type'=>$type,'valeurs'=>$row, 'champs'=>$champs_libelles);
include_spip('inc/assembler');
$contenu_objet = recuperer_fond('prive/afficher_contenu_objet',$contexte);*/
global $table_des_traitements;
include_spip('public/interfaces');
// afficher chaque champ
// lui appliquer le traitement public
$contenu_objet = '';
foreach($champs_libelles as $champ=>$libelle) {
if ($champ!='notes') {
$valeur = $row[$champ];
}
else $valeur = $GLOBALS['les_notes'];
if (($champ=='nom_site') && isset($row['url_site']) && $row['url_site']){
$valeur = "[" . ($valeur?$valeur:$row['url_site']) . " -> " . $row['url_site'] ."]";
$valeur = propre($valeur);
}
elseif (($champ=='lien_titre') && isset($row['lien_url']) && $row['lien_url']){
$valeur = "[" . ($valeur?$valeur:$row['lien_titre']) . " -> " . $row['lien_url'] ."]";
$valeur = propre($valeur);
}
else {
$balise = strtoupper($champ);
if (isset($table_des_traitements[$balise])) {
$filtre = isset($table_des_traitements[$balise][$table])
? $table_des_traitements[$balise][$table]
: $table_des_traitements[$balise][0];
$filtre = str_replace('%s','$valeur', $filtre);
# dans l'espace prive on veut afficher le rang
# (temporaire, en attendant un vrai champ rang ??)
$filtre = str_replace('supprimer_numero(','(', $filtre);
$connect = "";
$valeur = eval("return $filtre;");
}
}
if ($champ!='notes' OR strlen($valeur))
$contenu_objet .=
"<span class='champ contenu_$champ" .(strlen($valeur)?"":" vide") . "'>"
. "<span class='label'>$libelle</span>"
. "<span dir='$lang_dir' class='$champ crayon $type-$champ-$id'>$valeur</span>"
. "</span>";
}
// pas de squelette pour les champs extra (vieillissants)
if ($GLOBALS['champs_extra'] AND $row['extra']) {
function inc_afficher_contenu_objet_dist($type, $id,$row = NULL){
include_spip('public/assembler');
if ($GLOBALS['champs_extra'] AND $row['extra'])
include_spip('inc/extra');
$contenu_objet .= extra_affichage($row['extra'], $table);
}
$contexte = array('id'=>$id,'champs_extra'=>$GLOBALS['champs_extra']);
$contenu_objet .= recuperer_fond("prive/contenu/$type",$contexte);
// permettre a un plugin de faire des modifs
// permettre aux plugin de faire des modifs ou des ajouts
$contenu_objet = pipeline(
'afficher_contenu_objet',
array(
......@@ -111,39 +32,5 @@ function inc_afficher_contenu_objet_dist($type, $id,$row = NULL){
return "<div id='wysiwyg'>$contenu_objet</div>";
}
// donner la liste des champs a afficher dans l'espace prive
// pour un objet
// cette liste peut etre un englobant, les elements non pertinents pour l'objet considere seront enleves
// http://doc.spip.org/@afficher_objet_champs_libelles
function afficher_objet_champs_libelles($type,$table,$id, $row){
$liste = array(
'surtitre' => _T('texte_sur_titre'),
'titre' => _T('info_titre'),
'soustitre' => _T('texte_sous_titre'),
'descriptif' => _T('info_descriptif'),
'chapo' => _T('info_chapeau'),
'nom_site' => ($type=='site'?_T('form_prop_nom_site'):_T('lien_voir_en_ligne')),
'url_site' => ($type=='site'?_T('form_prop_nom_site'):_T('info_lien_hypertexte')),
'texte' => _T('info_texte'),
'lien_titre' => _T('lien_voir_en_ligne'),
'lien_url' => _T('info_lien_hypertexte'),
'ps' => _T('info_ps'),
'notes' => _T('info_notes')
);
// gerer les champs desactives sur option
foreach($liste as $champ => $x) {
if (isset($GLOBALS['meta'][$x = ($table . '_' . $champ)])
AND $GLOBALS['meta'][$x]=='non'
AND (!isset($row[$champ]) OR !strlen($row[$champ]))) {
unset($liste[$champ]);
}
}
// TODO , gerer ici des eventuelles autorisation de voir via autoriser ...
return $liste;
}
?>
?>
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter