identite_extra: Etendre le formulaire de configuration du site et creation de balises personalisées ex: #IDENTITE_TELEPHONE
parent
7a56a34f9a
commit
7b30e2f618
@ -1 +1,16 @@
|
||||
* text=auto !eol
|
||||
balise/identite_.php -text
|
||||
/identite_extra_administrations.php -text
|
||||
/identite_extra_fonctions.php -text
|
||||
/identite_extra_ieconfig.php -text
|
||||
/identite_extra_options.php -text
|
||||
/identite_extra_pipelines.php -text
|
||||
lang/identite_extra_fr.php -text
|
||||
lang/paquet-identite_extra_fr.php -text
|
||||
lang/plugin-identite_extra_fr.php -text
|
||||
modeles/organization.html -text
|
||||
/paquet.xml -text
|
||||
prive/formulaires/configurer_identite_extra.html -text
|
||||
prive/themes/spip/images/identite_extra-16.png -text
|
||||
prive/themes/spip/images/identite_extra-24.png -text
|
||||
prive/themes/spip/images/identite_extra-32.png -text
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
function balise_IDENTITE_($p) {
|
||||
|
||||
$cfg = $GLOBALS['identite_extra'];
|
||||
|
||||
$nom = $p->nom_champ;
|
||||
$champ = substr(strtolower($nom),9);
|
||||
|
||||
if ($nom === 'IDENTITE_') {
|
||||
$msg = array('zbug_balise_sans_argument', array('balise' => ' IDENTITE_'));
|
||||
erreur_squelette($msg, $p);
|
||||
$p->interdire_scripts = false;
|
||||
return $p;
|
||||
} elseif ( !in_array($champ, $cfg) ) {
|
||||
$msg = array('zbug_balise_inexistante', array('balise' => $nom, 'from' => 'identite_extra'));
|
||||
erreur_squelette($msg, $p);
|
||||
$p->interdire_scripts = false;
|
||||
return $p;
|
||||
} else {
|
||||
$p->code = 'lire_config("identite_extra/' . $champ .'")';
|
||||
$p->interdire_scripts = false;
|
||||
return $p;
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
include_spip('inc/meta');
|
||||
include_spip('base/create');
|
||||
|
||||
function identite_extra_upgrade($nom_meta_base_version, $version_cible){
|
||||
|
||||
include_spip('base/upgrade');
|
||||
$maj = array();
|
||||
|
||||
maj_plugin($nom_meta_base_version, $version_cible, $maj);
|
||||
}
|
||||
|
||||
function identite_extra_vider_tables($nom_meta_base_version) {
|
||||
|
||||
// on efface la meta de configuration du plugin
|
||||
effacer_meta('identite_extra');
|
||||
|
||||
// Supprimer la meta de version du plugin
|
||||
effacer_meta($nom_meta_base_version);
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
function balise_IDENTITE_dist($p) {
|
||||
$values = "lire_config('identite_extra')";
|
||||
$p->code = $values;
|
||||
return $p;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
//proposer l'export de la config via le plugin ieconfig
|
||||
function identite_extra_ieconfig_metas($table){
|
||||
|
||||
if (isset($GLOBALS['identite_extra']) AND is_array($GLOBALS['identite_extra'])) {
|
||||
$table['identite_extra']['titre'] = _T('identite_extra:identite_extra');;
|
||||
$table['identite_extra']['icone'] = 'identite_extra-16.png';
|
||||
$table['identite_extra']['metas_brutes'] = 'identite_extra';
|
||||
}
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
|
||||
?>
|
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
// Des champs par défaut pour identite extra
|
||||
if (!isset($GLOBALS['identite_extra']))
|
||||
$GLOBALS['identite_extra'] = array('nom_organisation','telephone', 'adresse', 'ville', 'code_postal','region','pays');
|
||||
|
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION'))
|
||||
return;
|
||||
|
||||
/**
|
||||
* Ajouter des champs supplémentaires sur configurer_identite
|
||||
* les champs sont définis dans une globale facilement surchargeable dans le fichier mes_options.php
|
||||
*
|
||||
* exemple:
|
||||
* $GLOBALS['identite_extra'] = array('champs1','champs2','champs3',...)
|
||||
*
|
||||
* @param array $flux
|
||||
* @return array
|
||||
*/
|
||||
function identite_extra_formulaire_fond($flux) {
|
||||
|
||||
# formulaire : configurer_identite
|
||||
if ( $flux['args']['form'] == 'configurer_identite'
|
||||
AND ( $p = strpos($flux['data'], '<!--extra-->') )
|
||||
AND isset( $GLOBALS['identite_extra'] )
|
||||
AND is_array( $GLOBALS['identite_extra'] ) ) {
|
||||
|
||||
$ajout = recuperer_fond("prive/formulaires/configurer_identite_extra", $flux['args']['contexte'] );
|
||||
$flux['data'] = substr_replace($flux['data'], $ajout, $p, 0);
|
||||
}
|
||||
|
||||
return $flux;
|
||||
}
|
||||
|
||||
// Charger les valeurs déjà existantes dans la méta
|
||||
function identite_extra_formulaire_charger($flux) {
|
||||
|
||||
# formulaire : configurer_identite
|
||||
if ( $flux['args']['form'] == 'configurer_identite' ) {
|
||||
|
||||
$valeurs = array();
|
||||
foreach ($GLOBALS['identite_extra'] as $k)
|
||||
$valeurs['identite_extra'][$k] = lire_config('identite_extra/' . $k, '');
|
||||
|
||||
$flux['data'] = array_merge($flux['data'],$valeurs);
|
||||
}
|
||||
return $flux;
|
||||
}
|
||||
|
||||
|
||||
// Mettre à jour la méta
|
||||
function identite_extra_formulaire_traiter($flux) {
|
||||
|
||||
# formulaire : configurer_identite
|
||||
if ( $flux['args']['form'] == 'configurer_identite' AND $config = _request('identite_extra') ) {
|
||||
ecrire_config('identite_extra', $config);
|
||||
}
|
||||
return $flux;
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/* FICHIER DE LANG FR */
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
$GLOBALS[$GLOBALS['idx_lang']] = array(
|
||||
|
||||
'identite_extra' => 'Identité extra',
|
||||
|
||||
//valeurs par défaut
|
||||
'nom_organisation' => 'Nom de l\'organisation',
|
||||
'telephone' => 'Téléphone',
|
||||
'adresse' => 'Adresse',
|
||||
'ville' => 'Ville',
|
||||
'code_postal' => 'Code postal',
|
||||
'region' => 'Région',
|
||||
'pays' => 'Pays',
|
||||
'zbug_balise_champ_non_defini' => 'champ non defini @balise@',
|
||||
|
||||
);
|
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
$GLOBALS[$GLOBALS['idx_lang']] = array(
|
||||
|
||||
//
|
||||
'identite_extra_titre' => 'Identité extra',
|
||||
'identite_extra_description' => 'Déclarez vos champs supplémentaires dans <em>mes_options.php</em>. Une fois saisies dans <em>?exec=configurer_identite</em>, les valeurs sont accessibles dans vos squelettes via <code>#CONFIG{identite_extra/telephone}</code>.' ,
|
||||
'identite_extra_slogan' => 'Étendre facilement le formulaire Identité du site',
|
||||
|
||||
);
|
||||
?>
|
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
/* FICHIER DE LANG FR */
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return;
|
||||
|
||||
$GLOBALS[$GLOBALS['idx_lang']] = array(
|
||||
|
||||
'zbug_balise_champ_non_defini' => 'champ non defini @balise@',
|
||||
|
||||
);
|
||||
?>
|
@ -0,0 +1,21 @@
|
||||
[<!--(#REM)
|
||||
|
||||
http://schema-creator.org/organization.php
|
||||
|
||||
NB : on échappe un traitement sur #ADRESSE* éventuellement produit par le plugin contacts et organisations
|
||||
|
||||
-->]
|
||||
<div class="schema organization" itemscope itemtype="http://schema.org/LocalBusiness">
|
||||
[<div itemprop="name" class="item organization__nom"><strong>(#IDENTITE_NOM_ORGANISATION)</strong></div>]
|
||||
<div class="organization__adresse item" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
|
||||
[<div class="item__sub">
|
||||
<i class="icon-location"></i>
|
||||
<span class="[(#EDIT{meta-identite_extra/adresse})]" itemprop="streetAddress">(#IDENTITE_ADRESSE)</span><span class="sep"></span>[ <span class="#EDIT{meta-identite_extra/ville} ville" itemprop="addressLocality">(#IDENTITE_VILLE)</span>]
|
||||
</div>]
|
||||
[<div class="item__sub">
|
||||
[<span class="#EDIT{meta-identite_extra/code_postal} code-postal zip" itemprop="postalCode">(#IDENTITE_CODE_POSTAL)</span>]
|
||||
[<span class="#EDIT{meta-identite_extra/region} region" itemprop="addressRegion">(#IDENTITE_REGION)</span>]
|
||||
<span class="#EDIT{meta-identite_extra/pays} pays" itemprop="addressCountry">(#IDENTITE_PAYS)</span>
|
||||
</div>]
|
||||
</div>
|
||||
</div><!-- .schema-organization -->
|
@ -0,0 +1,25 @@
|
||||
<paquet
|
||||
prefix="identite_extra"
|
||||
categorie="communication"
|
||||
version="1.2.3"
|
||||
etat="test"
|
||||
compatibilite="[3.0.0;["
|
||||
logo="prive/themes/spip/images/identite_extra-32.png"
|
||||
documentation=""
|
||||
schema="1.0.0"
|
||||
>
|
||||
|
||||
<nom>Identité extra</nom>
|
||||
|
||||
<auteur>Sylvain CUSSAC</auteur>
|
||||
<auteur>Pierre LASZCZAK</auteur>
|
||||
|
||||
<utilise nom="ieconfig" compatibilite="[1.3.1;[" />
|
||||
|
||||
<pipeline nom="formulaire_fond" inclure="identite_extra_pipelines.php" />
|
||||
<pipeline nom="formulaire_charger" inclure="identite_extra_pipelines.php" />
|
||||
<pipeline nom="formulaire_verifier" inclure="identite_extra_pipelines.php" />
|
||||
<pipeline nom="formulaire_traiter" inclure="identite_extra_pipelines.php" />
|
||||
<pipeline nom="ieconfig_metas" inclure="identite_extra_ieconfig.php" />
|
||||
|
||||
</paquet>
|
@ -0,0 +1,16 @@
|
||||
[<!--(#REM) Squelette "addon" au form configurer_identite -->]
|
||||
#SET{version,#EVAL{$GLOBALS['spip_version_affichee']}}
|
||||
[(#GET{version}|version_compare{3.1.0,'>='}|oui)#SET{div,div}]
|
||||
|
||||
<B_data>
|
||||
<[(#GET{div,ul}) ]class="editer-groupe">
|
||||
<BOUCLE_data(DATA){source table,#ENV{identite_extra}}>
|
||||
<[(#GET{div,li}) ]class="editer editer_[(#CLE)][ (#ENV{erreur/#CLE}|oui)erreur]">
|
||||
<label for="#CLE">[(#VAL{identite_extra:#CLE}|_T)]</label>
|
||||
[<span class='erreur_message'>(#ENV{erreurs/#CLE})</span>]
|
||||
<input type='text' class='text' name='identite_extra[#CLE]' id='#CLE' value="#ENV{identite_extra/#CLE, #VALEUR}" />
|
||||
</[(#GET{div,li})]>
|
||||
</BOUCLE_data>
|
||||
</[(#GET{div,ul})]>
|
||||
</B_data>
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 569 B |
Binary file not shown.
After Width: | Height: | Size: 922 B |
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
Loading…
Reference in New Issue