
commit
08b3cde609
43 changed files with 2319 additions and 0 deletions
@ -0,0 +1,43 @@
|
||||
* text=auto !eol |
||||
action/iextras.php -text |
||||
action/iextras_exporter.php -text |
||||
base/iextras.php -text |
||||
formulaires/editer_champs_extras.html -text |
||||
formulaires/editer_champs_extras.php -text |
||||
formulaires/importer_champs_extras.html -text |
||||
formulaires/importer_champs_extras.php -text |
||||
/iextras_administrations.php -text |
||||
images/iextras-16.png -text |
||||
images/iextras-24.png -text |
||||
images/iextras-64.png -text |
||||
inc/iextras.php -text |
||||
inc/iextras_autoriser.php -text |
||||
lang/iextras.xml -text |
||||
lang/iextras_en.php -text |
||||
lang/iextras_es.php -text |
||||
lang/iextras_fr.php -text |
||||
lang/iextras_it.php -text |
||||
lang/iextras_sk.php -text |
||||
lang/paquet-iextras.xml -text |
||||
lang/paquet-iextras_en.php -text |
||||
lang/paquet-iextras_es.php -text |
||||
lang/paquet-iextras_fr.php -text |
||||
lang/paquet-iextras_it.php -text |
||||
lang/paquet-iextras_ru.php -text |
||||
lang/paquet-iextras_sk.php -text |
||||
/paquet.xml -text |
||||
prive/objets/contenu/champs_extras_possibles.html -text |
||||
prive/objets/contenu/champs_extras_possibles_fonctions.php -text |
||||
prive/objets/infos/champs_extras.html -text |
||||
prive/objets/liste/champs_extras_objets.html -text |
||||
prive/objets/liste/champs_extras_objets_fonctions.php -text |
||||
prive/squelettes/contenu/champs_extras.html -text |
||||
prive/squelettes/contenu/champs_extras_edit.html -text |
||||
prive/squelettes/contenu/champs_extras_exporter_importer.html -text |
||||
prive/squelettes/navigation/champs_extras.html -text |
||||
prive/squelettes/navigation/champs_extras_exporter_importer.html -text |
||||
prive/style_prive_plugin_iextras.html -text |
||||
prive/themes/spip/images/iextras-16.png -text |
||||
prive/themes/spip/images/iextras-24.png -text |
||||
prive/themes/spip/images/iextras-download-26.png -text |
||||
prive/themes/spip/images/iextras-upload-26.png -text |
@ -0,0 +1,85 @@
|
||||
<?php |
||||
|
||||
if (!defined("_ECRIRE_INC_VERSION")) return; |
||||
|
||||
function action_iextras_dist() { |
||||
$securiser_action = charger_fonction('securiser_action', 'inc'); |
||||
$arg = $securiser_action(); |
||||
|
||||
// droits |
||||
include_spip('inc/autoriser'); |
||||
if (!autoriser('configurer', 'iextra')) { |
||||
include_spip('inc/minipres'); |
||||
echo minipres(); |
||||
exit; |
||||
} |
||||
|
||||
@list($arg, $id_extra_ou_table, $champ) = explode ('/', $arg); |
||||
|
||||
// actions possibles |
||||
if (!in_array($arg, array( |
||||
'associer_champ', |
||||
'supprimer_champ'))){ |
||||
include_spip('inc/minipres'); |
||||
echo minipres(_T('iextras:erreur_action',array("action"=>$arg))); |
||||
exit; |
||||
} |
||||
|
||||
// cas de l'association d'un champ existant |
||||
if (($arg == 'associer_champ') and ($table = $id_extra_ou_table) and $champ){ |
||||
$extra_id = action_associer_champ_sql_comme_champ_extra($table, $champ); |
||||
} |
||||
|
||||
// cas de la suppression d'un champ existant |
||||
if (($arg == 'supprimer_champ') and ($table = $id_extra_ou_table) and $champ){ |
||||
action_supprimer_champ_sql($table, $champ); |
||||
} |
||||
} |
||||
|
||||
|
||||
// definir un champ SQL existant comme un champ extra a prendre |
||||
// en compte par ce plugin |
||||
function action_associer_champ_sql_comme_champ_extra($table, $champ){ |
||||
// recuperer la description du champ |
||||
include_spip('inc/cextras'); |
||||
include_spip('inc/iextras'); |
||||
$champs = extras_champs_anormaux(); |
||||
if (isset($champs[$table][$champ])) { |
||||
|
||||
$sql = $champs[$table][$champ]; |
||||
$saisies = iextras_champs_extras_definis($table); |
||||
|
||||
include_spip('inc/saisies'); |
||||
$saisies_sql = saisies_lister_disponibles_sql(); |
||||
|
||||
$type_saisie = 'textarea'; |
||||
|
||||
$saisies = saisies_inserer($saisies, array( |
||||
'saisie' => $type_saisie, |
||||
'options' => array_merge( |
||||
$saisies_sql[$type_saisie]['defaut']['options'], array( |
||||
'nom' => $champ, |
||||
'label' => ucfirst($champ) |
||||
)))); |
||||
|
||||
// sauver |
||||
ecrire_meta('champs_extras_' . $table, serialize($saisies)); |
||||
|
||||
// supprimer la session d'edition du formulaire pour le remettre a zero |
||||
session_set('constructeur_formulaire_champs_extras_' . $table, null); |
||||
} |
||||
} |
||||
|
||||
// suppression de la base d'un champ d'une table donnee. |
||||
function action_supprimer_champ_sql($table, $champ) { |
||||
// recuperer les descriptions |
||||
// pour verifier que le champ n'est pas declare par quelqu'un |
||||
include_spip('inc/cextras'); |
||||
$champs = extras_champs_anormaux(); |
||||
if (isset($champs[$table][$champ])) { |
||||
// suppression |
||||
extras_log("Suppression du champ $table/$champ par auteur ".$GLOBALS['auteur_session']['id_auteur'],true); |
||||
|
||||
sql_alter("TABLE $table DROP COLUMN ".$champ); |
||||
} |
||||
} |
@ -0,0 +1,282 @@
|
||||
<?php |
||||
|
||||
if (!defined("_ECRIRE_INC_VERSION")) return; |
||||
|
||||
/** |
||||
* Exporte des champs extras |
||||
* |
||||
* Crée un fichier PHP contenant des informations relatives (array) |
||||
* aux saisies utilisées par les champs extras sur un ou plusieurs objets |
||||
* |
||||
* Paramètres d'action : |
||||
* |
||||
* - yaml/tous Tous les champs extras de tous les objets |
||||
* - php/tous Tous les champs extras de tous les objets (export PHP) |
||||
* - yaml/objet/{type}/tous Tous les champs extras de l'objet {type}. {@example: `yaml/objet/auteur/tous`} |
||||
* - yaml/objet/{type}/champ/{nom} Le champ {nom} de l'objet {type}. {@example: `yaml/objet/auteur/champ/date_naissance`} |
||||
* |
||||
**/ |
||||
function action_iextras_exporter_dist() { |
||||
$securiser_action = charger_fonction('securiser_action', 'inc'); |
||||
$arg = $securiser_action(); |
||||
|
||||
// droits |
||||
include_spip('inc/autoriser'); |
||||
if (!autoriser('configurer', 'iextra')) { |
||||
include_spip('inc/minipres'); |
||||
echo minipres(); |
||||
exit; |
||||
} |
||||
|
||||
list($format, $quoi, $objet, $quoi_objet, $champ) = array_pad(explode('/', $arg), 5, null); |
||||
|
||||
// formats possibles |
||||
if (!in_array($format, array('yaml', 'php'))) { |
||||
include_spip('inc/minipres'); |
||||
echo minipres(_T('iextras:erreur_format_export',array("format" => $format))); |
||||
exit; |
||||
} |
||||
|
||||
// actions possibles |
||||
if (!in_array($quoi, array('tous','objet'))) { |
||||
include_spip('inc/minipres'); |
||||
echo minipres(_T('iextras:erreur_action',array("action" => $quoi))); |
||||
exit; |
||||
} |
||||
|
||||
// liste des champs extras par table SQL array(table sql => array(saisies)) |
||||
$champs = array(); |
||||
$titre = ""; |
||||
|
||||
if ($quoi == 'tous') { |
||||
$titre = 'tous'; |
||||
$champs = iextras_exporter_tous(); |
||||
} |
||||
elseif ($quoi_objet == 'tous') { |
||||
$titre = $objet; |
||||
$champs = iextras_exporter_objet_tous($objet); |
||||
} |
||||
else { |
||||
$titre = "$objet-$champ"; |
||||
$champs = iextras_exporter_objet_champ($objet, $champ); |
||||
} |
||||
|
||||
return iextras_envoyer_export($champs, $titre, $format); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Retourne tous les champs extras par table SQL |
||||
**/ |
||||
function iextras_exporter_tous() { |
||||
include_spip('inc/iextras'); |
||||
$tables = lister_tables_objets_sql(); |
||||
$champs = array(); |
||||
foreach ($tables as $table => $desc) { |
||||
if ($liste = iextras_champs_extras_definis($table)) { |
||||
$champs[$table] = $liste; |
||||
} |
||||
} |
||||
return $champs; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Retourne tous les champs extras d'un objet |
||||
* |
||||
* @param string $objet |
||||
**/ |
||||
function iextras_exporter_objet_tous($objet) { |
||||
include_spip('inc/iextras'); |
||||
$champs = array(); |
||||
$table = table_objet_sql($objet); |
||||
if ($liste = iextras_champs_extras_definis($table)) { |
||||
$champs[$table] = $liste; |
||||
} |
||||
return $champs; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Retourne un champ extra d'un objet |
||||
* |
||||
* @param string $objet |
||||
* @param string $champ |
||||
**/ |
||||
function iextras_exporter_objet_champ($objet, $champ) { |
||||
include_spip('inc/iextras'); |
||||
$champs = array(); |
||||
$table = table_objet_sql($objet); |
||||
if ($liste = iextras_champs_extras_definis($table)) { |
||||
include_spip('inc/saisies'); |
||||
$liste = saisies_lister_par_nom($liste); |
||||
if (!empty($liste[$champ])) { |
||||
$champs[$table] = array(); |
||||
$champs[$table][] = $liste[$champ]; |
||||
} |
||||
} |
||||
return $champs; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Exporte un contenu (description de champs extras) au format YAML |
||||
* |
||||
* Envoie les données au navigateur ! |
||||
* |
||||
* @param array $export |
||||
* @param string $nom_fichier |
||||
* @param string $format |
||||
* Format d'export (yaml ou php) |
||||
**/ |
||||
function iextras_envoyer_export($export, $nom_fichier, $format = 'yaml') { |
||||
|
||||
switch ($format) { |
||||
case 'php': |
||||
$export = iextras_preparer_export_php($export); |
||||
$export = iextras_ecrire_export_php($export); |
||||
|
||||
break; |
||||
|
||||
case 'yaml': |
||||
default: |
||||
// On envode en yaml |
||||
include_spip('inc/yaml'); |
||||
$export = yaml_encode($export); |
||||
break; |
||||
} |
||||
|
||||
|
||||
$date = date("Ymd-His"); |
||||
Header("Content-Type: text/x-yaml;"); |
||||
Header("Content-Disposition: attachment; filename=champs_extras_export-$date-$nom_fichier.$format"); |
||||
Header("Content-Length: " . strlen($export)); |
||||
echo $export; |
||||
exit; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Prépare les saisies (les simplifie) pour un export au format PHP |
||||
* |
||||
* @param array $export |
||||
* Liste des saisies, par table SQL |
||||
* @return array |
||||
* Idem, simplifié |
||||
**/ |
||||
function iextras_preparer_export_php($export) { |
||||
include_spip('inc/saisies'); |
||||
foreach ($export as $table => $champs) { |
||||
if (!$champs) { |
||||
unset($export[$table]); |
||||
continue; |
||||
} |
||||
|
||||
// simplifier chaque champ |
||||
foreach ($champs as $i => $champ) { |
||||
$export[$table][$i] = iextras_preparer_export_php_saisie($champ); |
||||
} |
||||
} |
||||
|
||||
return $export; |
||||
} |
||||
|
||||
/** |
||||
* Simplifie l'écriture d'une saisie de champs extras |
||||
* |
||||
* @param array Description de saisie |
||||
* @return array |
||||
**/ |
||||
function iextras_preparer_export_php_saisie($saisie) { |
||||
|
||||
// 1 mettre 'saisie' en tout premier, c'est plus pratique ! |
||||
$saisie = array('saisie' => $saisie['saisie']) + $saisie; |
||||
|
||||
// 2 mettre 'saisies' en dernier |
||||
if (isset($saisie['saisies'])) { |
||||
$saisies = $saisie['saisies']; |
||||
unset($saisie['saisies']); |
||||
$saisie['saisies'] = $saisies; |
||||
// 2 bis : traiter toutes les saisies enfants |
||||
foreach ($saisie['saisies'] as $k => $s) { |
||||
$saisie['saisies'][$k] = iextras_preparer_export_php_saisie($s); |
||||
} |
||||
} |
||||
|
||||
// 3 pas besoin d'identifiant |
||||
unset($saisie['identifiant']); |
||||
// 4 nettoyage de quelques champs souvent vides |
||||
if (isset($saisie['options']['restrictions'])) { |
||||
if (empty($saisie['options']['restrictions']['secteurs'])) { |
||||
unset($saisie['options']['restrictions']['secteurs']); |
||||
} |
||||
if (empty($saisie['options']['restrictions']['branches'])) { |
||||
unset($saisie['options']['restrictions']['branches']); |
||||
} |
||||
if (empty($saisie['options']['restrictions']['voir']['auteur'])) { |
||||
unset($saisie['options']['restrictions']['voir']['auteur']); |
||||
} |
||||
if (empty($saisie['options']['restrictions']['modifier']['auteur'])) { |
||||
unset($saisie['options']['restrictions']['modifier']['auteur']); |
||||
} |
||||
if (empty($saisie['options']['restrictions']['voir'])) { |
||||
unset($saisie['options']['restrictions']['voir']); |
||||
} |
||||
if (empty($saisie['options']['restrictions']['modifier'])) { |
||||
unset($saisie['options']['restrictions']['modifier']); |
||||
} |
||||
if (empty($saisie['options']['restrictions'])) { |
||||
unset($saisie['options']['restrictions']); |
||||
} |
||||
} |
||||
|
||||
// 5 les datas doivent être des tableaux |
||||
if (isset($saisie['options']['datas'])) { |
||||
if (!is_array($saisie['options']['datas'])) { |
||||
$saisie['options']['datas'] = saisies_chaine2tableau($saisie['options']['datas']); |
||||
} |
||||
} |
||||
|
||||
return $saisie; |
||||
} |
||||
|
||||
/** |
||||
* Écrit le code PHP de l'export PHP |
||||
* |
||||
* @param array $export |
||||
* Liste des saisies, par table SQL |
||||
* @return string |
||||
* Code PHP |
||||
**/ |
||||
function iextras_ecrire_export_php($export) { |
||||
$contenu = <<<EOF |
||||
<?php |
||||
if (!defined("_ECRIRE_INC_VERSION")) return; |
||||
|
||||
function monplugin_declarer_champs_extras(\$champs = array()) { |
||||
EOF; |
||||
foreach ($export as $table => $champs) { |
||||
$contenu .= " |
||||
|
||||
// Table : $table |
||||
if (!is_array(\$champs['$table'])) { |
||||
\$champs['$table'] = array(); |
||||
} |
||||
"; |
||||
foreach ($champs as $champ) { |
||||
$nom = $champ['options']['nom']; |
||||
$desc = var_export($champ, true); |
||||
$desc = explode("\n", $desc); |
||||
$desc = implode("\n\t\t", $desc); |
||||
$contenu .= "\n\t\$champs['$table']['$nom'] = $desc;\n"; |
||||
} |
||||
} |
||||
|
||||
$contenu .= <<<EOF |
||||
|
||||
return \$champs; |
||||
} |
||||
EOF; |
||||
|
||||
return $contenu; |
||||
} |
@ -0,0 +1,19 @@
|
||||
<?php |
||||
if (!defined("_ECRIRE_INC_VERSION")) return; |
||||
|
||||
function iextras_declarer_champs_extras($saisies_tables=array()) { |
||||
include_spip('inc/iextras'); |
||||
|
||||
// lors du renouvellement de l'alea, au demarrage de SPIP |
||||
// les chemins de plugins ne sont pas encore connus. |
||||
// il faut se mefier et charger tout de meme la fonction, sinon page blanche. |
||||
if (!function_exists('iextras_champs_extras_definis')) { |
||||
spip_log("ERREUR : inclusion inc/iextras non executee", 'iextras'); |
||||
include_once(dirname(__file__).'/../inc/iextras.php'); |
||||
} |
||||
|
||||
// recuperer le tableau de champ et les ajouter. |
||||
$extras = iextras_champs_extras_definis(); |
||||
$saisies_tables = array_merge_recursive($saisies_tables, $extras); |
||||
return $saisies_tables; |
||||
} |
@ -0,0 +1,38 @@
|
||||
<div class="formulaire_spip formulaire_editer formulaire_#FORM"> |
||||
[<p class="reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})</p>] |
||||
[<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>] |
||||
|
||||
[(#ENV*{message_erreur}|non) |
||||
<div class="ajax"> |
||||
#FORMULAIRE_CONSTRUIRE_FORMULAIRE{champs_extras_#ENV{table}, #ENV{_saisies}, #ENV{_options}} |
||||
</div> |
||||
] |
||||
|
||||
<BOUCLE_si_editable(CONDITION){si #ENV{editable}}> |
||||
<form method='post' action='#ENV{action}'><div> |
||||
#ACTION_FORMULAIRE{#ENV{action}} |
||||
|
||||
[(#REM) ajouter les saisies supplementaires : extra et autre, a cet endroit ] |
||||
<!--extra--> |
||||
<p class="boutons"> |
||||
<span class="image_loading"></span> |
||||
[(#ENV*{message_erreur}|non) |
||||
<em class="attention"><:saisies:construire_attention_enregistrer:></em> |
||||
<button type="submit" class="submit"> |
||||
<img src="#CHEMIN{images/formulaire-enregistrer-16.png}" alt="" /> |
||||
<:bouton_enregistrer:> |
||||
</button> |
||||
] |
||||
[(#ENV*{message_erreur}|oui) |
||||
<button type="submit" class="link" name="annulation" value="oui"> |
||||
<:bouton_annuler:> |
||||
</button> |
||||
<button type="submit" class="submit" name="confirmation" value="oui"> |
||||
<img src="#CHEMIN{images/formulaire-enregistrer-16.png}" alt="" /> |
||||
<:bouton_enregistrer:> |
||||
</button> |
||||
] |
||||
</p> |
||||
</div></form> |
||||
</BOUCLE_si_editable> |
||||
</div> |
@ -0,0 +1,63 @@
|
||||
<?php |
||||
if (!defined("_ECRIRE_INC_VERSION")) return; |
||||
|
||||
|
||||
function formulaires_editer_champs_extras_charger_dist($objet, $redirect=''){ |
||||
$valeurs = array( |
||||
'table' => table_objet_sql($objet), |
||||
'objet' => $objet, |
||||
'redirect' => $redirect |
||||
); |
||||
|
||||
include_spip('inc/iextras'); |
||||
$saisies = iextras_champs_extras_definis( table_objet_sql($objet) ); |
||||
|
||||
$valeurs['_saisies'] = $saisies; |
||||
$valeurs['_options'] = array( |
||||
"modifier_nom"=>true, |
||||
"nom_unique"=>true, |
||||
); |
||||
|
||||
return $valeurs; |
||||
} |
||||
|
||||
|
||||
function formulaires_editer_champs_extras_verifier_dist($objet, $redirect=''){ |
||||
$erreurs = array(); |
||||
return $erreurs; |
||||
} |
||||
|
||||
|
||||
function formulaires_editer_champs_extras_traiter_dist($objet, $redirect=''){ |
||||
$retour = array( |
||||
'redirect' => $redirect |
||||
); |
||||
|
||||
$table = table_objet_sql($objet); |
||||
|
||||
include_spip('inc/iextras'); |
||||
$saisies = iextras_champs_extras_definis( $table ); |
||||
|
||||
$nouvelles_saisies = session_get('constructeur_formulaire_champs_extras_' . $table); |
||||
$diff = saisies_comparer_par_identifiant($saisies, $nouvelles_saisies); |
||||
|
||||
$extras = array(); |
||||
|
||||
include_spip('inc/cextras'); |
||||
// supprimer les champs supprimes |
||||
champs_extras_supprimer($table, $diff['supprimees']); |
||||
// ajouter les nouveaux champs; |
||||
champs_extras_creer($table, $diff['ajoutees']); |
||||
// modifier les champs modifies; |
||||
if ($diff['modifiees']) { |
||||
$anciennes = saisies_lister_par_identifiant($saisies); |
||||
$anciennes = array_intersect_key($anciennes, $diff['modifiees']); |
||||
champs_extras_modifier($table, $diff['modifiees'], $anciennes); |
||||
} |
||||
# champs_extras_modifier($table, # modifiees nouvelles, # modifiees anciennes); |
||||
|
||||
|
||||
ecrire_meta("champs_extras_" . $table, serialize($nouvelles_saisies)); |
||||
$retour['message_ok'] = 'Super !'; |
||||
return $retour; |
||||
} |
@ -0,0 +1,39 @@
|
||||
<div class="formulaire_spip formulaire_editer formulaire_#FORM"> |
||||
<h3 class='titrem'>[(#CHEMIN_IMAGE{iextras-upload-26.png}|balise_img{'',cadre-icone}) ]<:iextras:titre_iextras_importer:></h3> |
||||
|
||||
[<div class="reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})</div>] |
||||
[<div class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</div>] |
||||
|
||||
<p class='explication'><:iextras:importer_explications:></p> |
||||
|
||||
<BOUCLE_si_editable(CONDITION){si #ENV{editable}}> |
||||
<form method='post' action='#ENV{action}'><div> |
||||
#ACTION_FORMULAIRE |
||||
|
||||
<div class='editer-groupe'> |
||||
[(#SAISIE{input,fichier, |
||||
type=file, |
||||
label=<:iextras:importer_fichier:>, |
||||
explication=<:iextras:importer_fichier_explication:>})] |
||||
|
||||
[(#SAISIE{radio,fusionner, |
||||
label=<:iextras:importer_fusionner:>, |
||||
explication=<:iextras:importer_fusionner_explication:>, |
||||
datas=[(#ARRAY{ |
||||
oui,<:iextras:importer_fusionner_oui:>, |
||||
non,<:iextras:importer_fusionner_non:>})]})] |
||||
</div> |
||||
|
||||
[(#REM) ajouter les saisies supplementaires : extra et autre, a cet endroit ] |
||||
<!--extra--> |
||||
|
||||
<p class="boutons"> |
||||
<button type="submit" class="submit"> |
||||
[(#CHEMIN_IMAGE{iextras-upload-26.png}|image_reduire{16}) ] |
||||
<:iextras:bouton_importer:> |
||||
</button> |
||||
</p> |
||||
|
||||
</div></form> |
||||
</BOUCLE_si_editable> |
||||
</div> |
@ -0,0 +1,156 @@
|
||||
<?php |
||||
|
||||
if (!defined("_ECRIRE_INC_VERSION")) return; |
||||
|
||||
|
||||
function formulaires_importer_champs_extras_charger_dist() { |
||||
if (!autoriser('configurer', 'champs_extras')) { |
||||
return false; |
||||
} |
||||
|
||||
$valeurs = array( |
||||
'fichier' => '', |
||||
'fusionner' => 'non', |
||||
); |
||||
|
||||
return $valeurs; |
||||
} |
||||
|
||||
|
||||
|
||||
function formulaires_importer_champs_extras_verifier_dist() { |
||||
$erreurs = array(); |
||||
|
||||
if (empty($_FILES['fichier']['tmp_name'])) { |
||||
$erreurs['fichier'] = _T('info_obligatoire'); |
||||
} |
||||
|
||||
return $erreurs; |
||||
} |
||||
|
||||
|
||||
function formulaires_importer_champs_extras_traiter_dist() { |
||||
$res = array('editable' => true); |
||||
|
||||
$fichier = $_FILES['fichier']['tmp_name']; |
||||
lire_fichier($fichier, $yaml); |
||||
|
||||
if (!$yaml) { |
||||
$res['message_erreur'] = "Lecture du fichier en erreur."; |
||||
return $res; |
||||
} |
||||
|
||||
include_spip('inc/yaml'); |
||||
$description = yaml_decode($yaml, true); |
||||
|
||||
if (!$description OR !is_array($description)) { |
||||
$res['message_erreur'] = "Pas de champ trouvé dans le fichier."; |
||||
return $res; |
||||
} |
||||
|
||||
if (iextras_importer_description($description, $message, _request('fusionner') == 'oui')) { |
||||
$res['message_ok'] = $message; |
||||
} else { |
||||
$res['message_erreur'] = $message; |
||||
} |
||||
|
||||
return $res; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Importe une description de champs extras donnée |
||||
* |
||||
* @param array $description |
||||
* description des champs extras (table sql => liste des champs extras) |
||||
* @param string $message |
||||
* message de retour, rempli par cette fonction |
||||
* @param bool $fusionner_doublons |
||||
* true si on fusionne les champs présents dans la sauvegarde et aussi présents sur le site. False pour les ignorer. |
||||
* @return bool |
||||
* true si tout s'est bien passé, false sinon |
||||
**/ |
||||
function iextras_importer_description($description, &$message, $fusionner_doublons = false) { |
||||
include_spip('inc/iextras'); |
||||
include_spip('inc/saisies'); |
||||
include_spip('inc/texte'); |
||||
include_spip('inc/cextras'); |
||||
|
||||
$tables_sql_presentes = array_keys(lister_tables_objets_sql()); |
||||
|
||||
$message = ''; |
||||
$nbt = count($description); |
||||
$message .= "{{Fichier importé :}}\n"; |
||||
$message .= "- $nbt objets éditoriaux.\n"; |
||||
|
||||
$nbc = 0; |
||||
foreach ($description as $table => $saisies) { |
||||
$nbc += count($saisies); |
||||
} |
||||
$message .= "- $nbc champs extras.\n"; |
||||
|
||||
foreach ($description as $table => $saisies) { |
||||
|
||||
if (!in_array($table, $tables_sql_presentes)) { |
||||
$message .= "\nTable {{ $table }} absente sur le site\n"; |
||||
$message .= count($saisies) . " champs extras ignorés !!\n"; |
||||
continue; |
||||
} |
||||
|
||||
$champs_presents = $champs_futurs = iextras_champs_extras_definis($table); |
||||
$champs_presents_par_nom = saisies_lister_par_nom($champs_presents); |
||||
|
||||
$objet = objet_type($table); |
||||
$titre = _T(objet_info($objet, 'texte_objets')); |
||||
$message .= "\n{{ $titre :}}\n"; |
||||
$message .= count($saisies) . " champs extras\n"; |
||||
|
||||
foreach ($saisies as $saisie) { |
||||
$nom = isset($saisie['options']['nom']) ? $saisie['options']['nom'] : ''; |
||||
if (!$nom) { |
||||
$message .= "- !! Saisie sans nom ignorée\n"; |
||||
continue; |
||||
} |
||||
|
||||
// champ déjà présent ? |
||||
if (isset($champs_presents_par_nom[$nom])) { |
||||
if ($fusionner_doublons) { |
||||
$message .= "- {{ $nom :}} modifié (déjà présent)\n"; |
||||
$champs_futurs = saisies_modifier($champs_futurs, $nom, $saisie); |
||||
} else { |
||||
$message .= "- {{ $nom :}} ignoré (déjà présent)\n"; |
||||
} |
||||
} else { |
||||
$message .= "- {{ $nom :}} ajouté\n"; |
||||
$champs_futurs = saisies_inserer($champs_futurs, $saisie); |
||||
} |
||||
} |
||||
|
||||
$diff = saisies_comparer_par_identifiant($champs_presents, $champs_futurs); |
||||
|
||||
// ajouter les nouveaux champs; |
||||
if ($diff['ajoutees']) { |
||||
$message .= count($diff['ajoutees']) . " champs ajoutés.\n"; |
||||
champs_extras_creer($table, $diff['ajoutees']); |
||||
} |
||||
|
||||
// modifier les champs modifies; |
||||
if ($diff['modifiees']) { |
||||
$message .= count($diff['modifiees']) . " champs modifiés.\n"; |
||||
$anciennes = saisies_lister_par_identifiant($champs_presents); |
||||
$anciennes = array_intersect_key($anciennes, $diff['modifiees']); |
||||
champs_extras_modifier($table, $diff['modifiees'], $anciennes); |
||||
} |
||||
|
||||
// enregistrer la nouvelle config |
||||
if ($diff['ajoutees'] or $diff['modifiees']) { |
||||
ecrire_meta("champs_extras_" . $table, serialize($champs_futurs)); |
||||
} else { |
||||
$message .= "Aucune modification !\n"; |
||||
} |
||||
} |
||||
|
||||
$message = propre($message); |
||||
|
||||
return true; |
||||
} |
@ -0,0 +1,286 @@
|
||||
<?php |
||||
if (!defined('_ECRIRE_INC_VERSION')) return; |
||||
|
||||
// installation : migrer depuis Champs Extras 2 |
||||
function iextras_upgrade($nom_meta_base_version, $version_cible){ |
||||
|
||||
$maj = array(); |
||||
$maj['create'] = array( |
||||
array('iextras_upgrade_to_saisies'), |
||||
); |
||||
include_spip('base/upgrade'); |
||||
maj_plugin($nom_meta_base_version, $version_cible, $maj); |
||||
} |
||||
|
||||
// on ne supprime aucun champ lorsqu'on desinstalle le plugin |
||||
// trop risqué ! |
||||
function iextras_vider_tables($nom_meta_base_version) { |
||||
effacer_meta($nom_meta_base_version); |
||||
} |
||||
|
||||
|
||||
|
||||
// ====================================================================== |
||||
// |
||||
// Migration Champs Extras 2 (Spip 2.1) -> Champs Extras 3 (SPIP 3 +) |
||||
// |
||||
// |
||||
|
||||
/** |
||||
* Migration vers le plugin saisie |
||||
* On épluche l'ancienne meta stockee |
||||
* si elle existe, et si c'est le cas, on tente de migrer |
||||
* ses donnees dans la nouvelle structure |
||||
* |
||||
**/ |
||||
function iextras_upgrade_to_saisies() { |
||||
include_spip('inc/config'); |
||||
$old_extras = lire_config('iextras', ''); |
||||
if (!$old_extras) { |
||||
// rien a faire |
||||
return true; |
||||
} |
||||
|
||||
// juste pour pouvoir deserializer... |
||||
if (!class_exists('ChampExtra')) { |
||||
class ChampExtra{}; |
||||
} |
||||
|
||||
// logiquement, c'est bon du premier coup... |
||||
if (!$oextras = unserialize($old_extras)) { |
||||
// mais parfois, en cas d'import hasardeux... |
||||
|
||||
// tentative avec uniquement des \n |
||||
$o = str_replace(array("\r\n","\r"), "\n", $old_extras); |
||||
if (!$oextras = unserialize($o)) { |
||||
|
||||
// tentative avec des \r\n |
||||
$o = str_replace("\n", "\r\n", $o); |
||||
if (!$oextras = unserialize($o)) { |
||||
// c'est foutu ! |
||||
spip_log("Erreur de mise à jour : deserialisation ratée...", "iextras"); |
||||
echo _L("L'installation n'a pas réussi à restaurer les informations de la version 2. |
||||
Il vous faudra réassocier vous-même les champs extras."); |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (!$oextras) { |
||||
return false; |
||||
} |
||||
|
||||
unset ($old_extras, $o); |
||||
|
||||
$extras = array(); |
||||
|
||||
// pour chaque extra, on va l'ajouter tranquilou dans la base. |
||||
foreach ($oextras as $e) { |
||||
// on passe la classe en tableau |
||||
$te = array(); |
||||
foreach ($e as $c=>$v) { |
||||
$te[$c] = $v; |
||||
} |
||||
|
||||
// on ne garde pas ce qui est à false, à NULL ou ''. |
||||
foreach ($te as $c=>$v) { |
||||
if (is_array($v)) { |
||||
foreach ($v as $n=>$m) { |
||||
if (!$m) unset($v[$n]); |
||||
} |
||||
} |
||||
if (!$v) unset($te[$c]); |
||||
} |
||||
|
||||
// regroupement par table sql. |
||||
$table = $te['_table_sql'] ? $te['_table_sql'] : table_objet_sql($te['table']); |
||||
if (!is_array($extras[$table])) |
||||
$extras[$table] = array(); |
||||
|
||||
$extras[$table][ $te['champ'] ] = $te; |
||||
} |
||||
|
||||
unset ($oextras); |
||||
|
||||
$nsaisie = array( |
||||
'bloc' => 'textarea', |
||||
'ligne' => 'input', |
||||
'auteur' => 'auteurs', // ! multiple='' |
||||
'auteurs' => 'auteurs', // ! multiple='on' |
||||
'oui-non' => 'oui_non', |
||||
'menu-radio' => 'radio', |
||||
'menu-enum' => 'selection', |
||||
'menu-cases' => 'checkbox', |
||||
); |
||||
|
||||
include_spip('inc/saisies'); |
||||
include_spip('inc/config'); |
||||
|
||||
// stocker les extras qui n'ont pas été importés totalement |
||||
$reste = array(); |
||||
|
||||
// pour chaque table sql |
||||
foreach ($extras as $table => $champs) { |
||||
// on recupere les champs extras declares pour la nouvelle version |
||||
$ici = $GLOBALS['meta']['champs_extras_' . $table] ? unserialize($GLOBALS['meta']['champs_extras_' . $table]) : array(); |
||||
$desc = sql_showtable($table); |
||||
|
||||
#var_dump($table, $ici); |
||||
# var_dump($champs); |
||||
|
||||
// pour chaque champs extras decrits |
||||
foreach ($champs as $champ=>$extra) { |
||||
|
||||
// si la colonne SQL n'existe pas, on passe |
||||
if (!isset($desc['field'][$champ])) { |
||||
unset($champs[$champ]); |
||||
continue; |
||||
} |
||||
|
||||
// si le champs est deja decrit dans la nouvelle structure, on passe |
||||
foreach ($ici as $c) { |
||||
if ($c['options']['nom'] == $champ) { |
||||
unset($champs[$champ]); |
||||
continue 2; |
||||
} |
||||
} |
||||
|
||||
// nous sommes face a un champs extras ancien, non encore |
||||
// pris en compte dans la nouvelle version |
||||
|
||||
|
||||
// selon les anciennes saisies, on redirige sur les nouvelles |
||||
if (!isset($nsaisie[$extra['type']])) { |
||||
// saisie inconnue |
||||
echo "- Type de saisie non trouvé : $extra[type]. Passage en textarea.<br />\n"; |
||||
$extra['type'] = 'bloc'; |
||||
} |
||||
|
||||
$nouveau = saisie_identifier(array()); |
||||
$nouveau['saisie'] = $nsaisie[$extra['type']]; |
||||
$nouveau['options'] = array('nom' => $champ); |
||||
|
||||
// cas particulier des auteurs |
||||
if ($extra['type'] == 'auteurs') { |
||||
$nouveau['options']['multiple'] = 'on'; |
||||
} |
||||
|
||||
foreach (array( |
||||
'champ' => 'nom', |
||||
'label' => 'label', |
||||
'sql' => 'sql', |
||||
'explication' => 'explication', |
||||
'attention' => 'attention', |
||||
'obligatoire' => 'obligatoire', |
||||
'traitements' => 'traitements', |
||||
'rechercher' => 'rechercher', |
||||
'enum' => 'datas', |
||||
'type' => '', |
||||
'table' => '', |
||||
'_id' => '', |
||||
'_type' => '', |
||||
'_objet' => '', |
||||
'_table_sql' => '', |
||||
'saisie_parametres/class' => 'class', |
||||
'saisie_parametres/li_class' => 'conteneur_class', |
||||
'saisie_parametres/explication' => 'explication', |
||||
'saisie_parametres/attention' => 'attention', |
||||
) as $old => $new) { |
||||
// si $new est vide : on utilise pas. |
||||
// si le contenu de $old est vide, on ne prend pas. |
||||
// si iextras_upgrade_to_saisies_$old() existe, |
||||
// on l'utilise pour calculer la nouvelle valeur |
||||
if (!function_exists($f = 'iextras_upgrade_to_saisies_' . str_replace('/', '_', $old))) { |
||||
$f = 'iextras_upgrade_to_saisies_all'; |
||||
} |
||||
|
||||
$old = explode('/', $old); |
||||
$cle = array_pop($old); |
||||
if ($rep = array_pop($old)) { |
||||
if (array_key_exists($rep, $extra)) { |
||||
if (array_key_exists($cle, $extra[$rep])) { |
||||
if ($new and $val = $f($extra[$rep][$cle])) { |
||||
$nouveau['options'][$new] = $val; |
||||
} |
||||
unset($extra[$rep][$cle]); |
||||
} |
||||
if (!$extra[$rep]) unset($extra[$rep]); |
||||
} |
||||
} else { |
||||
if (isset($extra[$cle])) { |
||||
if ($new and $val = $f($extra[$cle])) { |
||||
$nouveau['options'][$new] = $val; |
||||
} |
||||
unset($extra[$cle]); |
||||
} |
||||
} |
||||
} |
||||
|
||||
// cas particuliers des classes |
||||
if (isset($nouveau['options']['class']) and $c = $nouveau['options']['class']) { |
||||
if (in_array('inserer_barre_edition', explode(' ', $c))) { |
||||
$nouveau['options']['inserer_barre'] = 'edition'; |
||||
$c = trim(str_replace('inserer_barre_edition', '', $c)); |
||||
} |
||||
if (in_array('inserer_barre_forum', explode(' ', $c))) { |
||||
$nouveau['options']['inserer_barre'] = 'forum'; |
||||
$c = trim(str_replace('inserer_barre_forum', '', $c)); |
||||
$nouveau['options']['class'] = $c; |
||||
} |
||||
if (in_array('inserer_previsualisation', explode(' ', $c))) { |
||||
$nouveau['options']['previsualisation'] = 'on'; |
||||
$c = trim(str_replace('inserer_previsualisation', '', $c)); |
||||
} |
||||
if ($c) { |
||||
$nouveau['options']['class'] = $c; |
||||
} else { |
||||
unset($nouveau['options']['class']); |
||||
} |
||||
} |
||||
|
||||
|
||||
// s'il en reste, c'est que y a des choses dont on ne sait pas |
||||
// quoi en faire... |
||||
if ($extra) { |
||||
echo "------------------------------<br />"; |
||||
echo "Les attributs suivants ont etes ignores pour le champ |
||||
$champ de type $extra[type].<br />"; |
||||
|
||||
var_dump($extra); |
||||
|
||||
echo "----- Données conservées : <br />"; |
||||
var_dump($nouveau); |
||||
|
||||
$reste[] = $extra; |
||||
} |
||||
|
||||
// on ajoute le nouvel extra |
||||
$ici[] = $nouveau; |
||||
} |
||||
|
||||
// on sauve |
||||
# var_dump($ici); |
||||
ecrire_config('champs_extras_' . $table, serialize($ici)); |
||||
} |
||||
|
||||
if (!$reste) { |
||||
effacer_config('iextras'); |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
|
||||
function iextras_upgrade_to_saisies_all($val) { |
||||
return $val; |
||||
} |
||||
|
||||
|
||||
// enum => datas |
||||
function iextras_upgrade_to_saisies_enum($val) { |
||||
// le vide par defaut... |
||||
// ,-vide-\r\n1,Valeur 1.... |
||||
if (md5($val) == '56517a44e77b255f38728c8625643a15') { |
||||
return ''; |
||||
} |
||||
return str_replace(',','|',$val); |
||||
} |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 5.7 KiB |
@ -0,0 +1,257 @@
|
||||
<?php |
||||
|
||||
if (!defined("_ECRIRE_INC_VERSION")) return; |
||||
|
||||
include_spip('inc/cextras'); |
||||
|
||||
/** |
||||
* Retourne la liste des saisies extras pour |
||||
* un objet donné. |
||||
* |
||||
* @param string $table Nom de la table SQL de l'objet éditorial |
||||
* @return Array Liste de saisies |
||||
**/ |
||||
function iextras_champs_extras_definis($table='') { |
||||
static $tables = array(); |
||||
|
||||
if (!$tables) { |
||||
// sinon calculer... |
||||
$n = strlen('champs_extras_'); |
||||
foreach ($GLOBALS['meta'] as $cle => $val) { |
||||
if (strpos($cle, 'champs_extras_') === 0) { |
||||
$_table = substr($cle, $n); |
||||
$s = unserialize($val); |
||||
$tables[$_table] = $s ? $s : array(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (!$table) { |
||||
return $tables; |
||||
} elseif (isset($tables[$table])) { |
||||
return $tables[$table]; |
||||
} |
||||
|
||||
return array(); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Compter les saisies extras d'une table |
||||
* |
||||
* @param String $table Table sql |
||||
* @return Int Nombre d'éléments. |
||||
**/ |
||||
function compter_champs_extras($table) { |
||||
static $tables = array(); |
||||
|
||||
if (!count($tables)) { |
||||
include_spip('inc/saisies'); |
||||
$saisies_tables = iextras_champs_extras_definis(); |
||||
foreach($saisies_tables as $t=>$s) { |
||||
if ($s = saisies_lister_par_nom($s)) { |
||||
$tables[$t] = count($s); |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (isset($tables[$table])) { |
||||
return $tables[$table]; |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Ajouter les saisies SQL et de recherche |
||||
* sur les options de config d'une saisie (de champs extras) |
||||
* |
||||
* @param array |
||||
* @return array |
||||
**/ |
||||
function iextras_formulaire_verifier($flux) { |
||||
if ($flux['args']['form'] == 'construire_formulaire' |
||||
AND strpos($flux['args']['args'][0], 'champs_extras_')===0 |
||||
AND $nom_ou_id = _request('configurer_saisie') ) { |
||||
|
||||
// On ajoute le préfixe devant l'identifiant |
||||
$identifiant = 'constructeur_formulaire_'.$flux['args']['args'][0]; |
||||
// On récupère le formulaire à son état actuel |
||||
$formulaire_actuel = session_get($identifiant); |
||||
|
||||
if ($nom_ou_id[0] == '@') { |
||||
$saisies_actuelles = saisies_lister_par_identifiant($formulaire_actuel); |
||||
$name = $saisies_actuelles[$nom_ou_id]['options']['nom']; |
||||
} else { |
||||
$saisies_actuelles = saisies_lister_par_nom($formulaire_actuel); |
||||
$name = $nom_ou_id; |
||||
} |
||||
|
||||
// saisie inexistante => on sort |
||||
if (!isset($saisies_actuelles[$nom_ou_id])) { |
||||
return $flux; |
||||
} |
||||
|
||||
$nom = 'configurer_' . $name; |
||||
$table = substr($flux['args']['args'][0], strlen('champs_extras_')); |
||||
|
||||
|
||||
// on ajoute le fieldset de restrictions de champs |
||||
// (des autorisations pre-reglées en quelque sorte) |
||||
$saisies_restrictions = array(); |
||||
|
||||
// les restrictions de X ne peuvent apparaître que |
||||
// si l'objet possede un Y. |
||||
// secteurs -> id_secteur |
||||
// branches -> id_rubrique |
||||
// groupes -> id_groupe |
||||
$desc = lister_tables_objets_sql($table); |
||||
$types = array( |
||||
'secteurs' => 'id_secteur', |
||||
'branches' => 'id_rubrique', |
||||
'groupes' => 'id_groupe', |
||||
); |
||||
foreach ($types as $type => $champ) { |
||||
if (isset($desc['field'][$champ])) { |
||||
$saisies_restrictions[] = array( |
||||
'saisie' => 'input', |
||||
'options' => array( |
||||
'nom' => "saisie_modifiee_${name}[options][restrictions][$type]", |
||||
'label' => _T('iextras:label_restrictions_' . $type), |
||||
'explication' => _T('iextras:precisions_pour_restrictions_' . $type), |
||||
'defaut' => '', |
||||
) |
||||
); |
||||
} |
||||
} |
||||
|
||||
// ajout des restrictions voir | modifier par auteur |
||||
$actions = array('voir', 'modifier'); |
||||
foreach ($actions as $action) { |
||||
$saisies_restrictions[] = array( |
||||
'saisie' => 'fieldset', |
||||
'options' => array( |
||||
'nom' => "saisie_modifiee_${name}[options][restrictions][$action]", |
||||
'label' => _T('iextras:legend_restrictions_' . $action), |
||||
), |
||||
'saisies' => array( |
||||
array( |
||||
'saisie' => 'radio', |
||||
'options' => array( |
||||
'nom' => "saisie_modifiee_${name}[options][restrictions][$action][auteur]", |
||||
'label' => _T('iextras:label_restrictions_auteur'), |
||||
'defaut' => '', |
||||
'datas' => array( |
||||
'' => _T('iextras:radio_restrictions_auteur_aucune'), |
||||
'admin' => _T('iextras:radio_restrictions_auteur_admin'), |
||||
'admin_complet' => _T('iextras:radio_restrictions_auteur_admin_complet'), |
||||
'webmestre' => _T('iextras:radio_restrictions_auteur_webmestre'), |
||||
) |
||||
) |
||||
) |
||||
) |
||||
); |
||||
} |
||||
|
||||
|
||||
$flux['data'][$nom] = saisies_inserer($flux['data'][$nom], array( |
||||
'saisie' => 'fieldset', |
||||
'options' => array( |
||||
'nom' => "saisie_modifiee_${name}[options][restrictions]", |
||||
'label' => _T('iextras:legend_restriction'), |
||||
), |
||||
'saisies' => $saisies_restrictions |
||||
)); |
||||
|
||||
|
||||
|
||||
// on récupère les informations de la saisie |
||||
// pour savoir si c'est un champs éditable (il a une ligne SQL) |
||||
// et dans ce cas, on ajoute les options techniques |
||||
$type_saisie = $saisies_actuelles[$nom_ou_id]['saisie']; |
||||
$saisies_sql = saisies_lister_disponibles_sql(); |
||||
|
||||
if (isset($saisies_sql[$type_saisie])) { |
||||
|
||||
// liste 'type_de_saisie' => 'Titre de la saisie' |
||||
$liste_saisies = array(); |
||||
foreach ($saisies_sql as $s=>$d) { |
||||
$liste_saisies[$s] = $d['titre']; |
||||
} |
||||
|
||||
$sql = $saisies_sql[$type_saisie]['defaut']['options']['sql']; |
||||
$flux['data'][$nom] = saisies_inserer($flux['data'][$nom], array( |
||||
|
||||
'saisie' => 'fieldset', |
||||
'options' => array( |
||||
'nom' => "saisie_modifiee_${name}[options][options_techniques]", |
||||
'label' => _T('iextras:legend_options_techniques'), |
||||
), |
||||
'saisies' => array( |
||||
array( |
||||
'saisie' => 'input', |
||||
'options' => array( |
||||
'nom' => "saisie_modifiee_${name}[options][sql]", |
||||
'label' => _T('iextras:label_sql'), |
||||
'obligatoire' => 'oui', |
||||
'size' => 50, |
||||
'defaut' => $sql |
||||
) |
||||
), |
||||
array( |
||||
'saisie' => 'oui_non', |
||||
'options' => array( |
||||
'nom' => "saisie_modifiee_${name}[options][rechercher]", |
||||
'label' => _T('iextras:label_rechercher'), |
||||
'explication' => _T('iextras:precisions_pour_rechercher'), |
||||
'defaut' => '' |
||||
) |
||||
), |
||||
array( |
||||
'saisie' => 'input', |
||||
'options' => array( |
||||
'nom' => "saisie_modifiee_${name}[options][rechercher_ponderation]", |
||||
'label' => _T('iextras:label_rechercher_ponderation'), |
||||
'explication' => _T('iextras:precisions_pour_rechercher_ponderation'), |
||||
'defaut' => 2, |
||||
'afficher_si' => "@saisie_modifiee_${name}[options][rechercher]@ != ''", |
||||
) |
||||
), |
||||
array( |
||||
'saisie' => 'radio', |
||||
'options' => array( |
||||
'nom' => "saisie_modifiee_${name}[options][traitements]", |
||||
'label' => _T('iextras:label_traitements'), |
||||
'explication' => _T('iextras:precisions_pour_traitements'), |
||||
'defaut' => '', |
||||
'datas' => array( |
||||
'' => _T('iextras:radio_traitements_aucun'), |
||||
'_TRAITEMENT_TYPO' => _T('iextras:radio_traitements_typo'), |
||||
'_TRAITEMENT_RACCOURCIS' => _T('iextras:radio_traitements_raccourcis'), |
||||
) |
||||
) |
||||
), |
||||
array( |
||||
'saisie' => 'oui_non', |
||||
'options' => array( |
||||
'nom' => "saisie_modifiee_${name}[options][versionner]", |
||||
'label' => _T('iextras:label_versionner'), |
||||
'explication' => _T('iextras:precisions_pour_versionner'), |
||||
'defaut' => '' |
||||
) |
||||
), |
||||
array( |
||||
'saisie' => 'selection', |
||||
'options' => array( |
||||
'nom' => "saisie_modifiee_${name}[options][nouveau_type_saisie]", |
||||
'label' => _T('iextras:label_saisie'), |
||||
'explication' => _T('iextras:precisions_pour_nouvelle_saisie'), |
||||
'attention' => _T('iextras:precisions_pour_nouvelle_saisie_attention'), |
||||
'defaut' => $type_saisie, |
||||
'datas' => $liste_saisies |
||||
) |
||||
), |
||||
))); |
||||
} |
||||
} |
||||
return $flux; |
||||
} |
@ -0,0 +1,33 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* Déclaration d'autorisations pour l'interface des champs extras |
||||
* |
||||
* @package SPIP\Iextras\Autorisations |
||||
**/ |
||||
|
||||
// sécurité |
||||
if (!defined("_ECRIRE_INC_VERSION")) return; |
||||
|
||||
/** |
||||
* Fonction d'appel pour le pipeline autoriser |
||||
* @pipeline autoriser |
||||
*/ |
||||
function iextras_autoriser(){} |
||||
|
||||
/** |
||||
* Autorisation de configurer les champs extras |
||||
* |
||||
* Il faut être webmestre ! |
||||
* |
||||
* @param string $faire Action demandée |
||||
* @param string $type Type d'objet sur lequel appliquer l'action |
||||
* @param int $id Identifiant de l'objet |
||||
* @param array $qui Description de l'auteur demandant l'autorisation |
||||
* @param array $opt Options de cette autorisation |
||||
* @return bool true s'il a le droit, false sinon |
||||
**/ |
||||
function autoriser_iextras_configurer_dist($faire, $type, $id, $qui, $opt) { |
||||
return autoriser('webmestre', $type, $id, $qui, $opt); |
||||
} |
||||
|
@ -0,0 +1,15 @@
|
||||
<traduction module="iextras" gestionnaire="salvatore" url="http://trad.spip.net" source="svn://zone.spip.org/spip-zone/_plugins_/champs_extras/interface/trunk/lang/" reference="fr"> |
||||
<langue code="en" url="http://trad.spip.net/tradlang_module/iextras?lang_cible=en" total="104" traduits="81" relire="0" modifs="2" nouveaux="21" pourcent="77.88"> |
||||
<traducteur nom="kent1" lien="http://trad.spip.net/auteur/kent1" /> |
||||
</langue> |
||||
<langue code="es" url="http://trad.spip.net/tradlang_module/iextras?lang_cible=es" total="104" traduits="81" relire="0" modifs="2" nouveaux="21" pourcent="77.88"> |
||||
<traducteur nom="Raquel S. Bujaldón" lien="http://trad.spip.net/auteur/raquel-s-bujaldon" /> |
||||
</langue> |
||||
<langue code="fr" url="http://trad.spip.net/tradlang_module/iextras?lang_cible=fr" total="104" traduits="104" relire="0" modifs="0" nouveaux="0" pourcent="100.00"> |
||||
</langue> |
||||
<langue code="it" url="http://trad.spip.net/tradlang_module/iextras?lang_cible=it" total="104" traduits="53" relire="0" modifs="2" nouveaux="49" pourcent="50.96"> |
||||
</langue> |
||||
<langue code="sk" url="http://trad.spip.net/tradlang_module/iextras?lang_cible=sk" total="104" traduits="81" relire="0" modifs="2" nouveaux="21" pourcent="77.88"> |
||||
<traducteur nom="jaro" lien="http://trad.spip.net/auteur/jaro" /> |
||||
</langue> |
||||
</traduction> |
@ -0,0 +1,121 @@
|
||||
<?php |
||||
// This is a SPIP language file -- Ceci est un fichier langue de SPIP |
||||
// extrait automatiquement de http://trad.spip.net/tradlang_module/iextras?lang_cible=es |
||||
// ** ne pas modifier le fichier ** |
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) return; |
||||
|
||||
$GLOBALS[$GLOBALS['idx_lang']] = array( |
||||
|
||||
// A |
||||
'action_associer' => 'gestionar este campo', |
||||
'action_associer_title' => 'Gestionar la presentación de este campo adicional', |
||||
'action_desassocier' => 'desasociar', |
||||
'action_desassocier_title' => 'Dejar de gestionar la presentación de este campo adicional', |
||||
'action_descendre' => 'descender', |
||||
'action_descendre_title' => 'Desplazar el campo una fila hacia abajo', |
||||
'action_modifier' => 'modificar', |
||||
'action_modifier_title' => 'Modificar la configuración del campo adicional', |
||||
'action_monter' => 'subir', |
||||
'action_monter_title' => 'Subir el campo una afila hacia arriba', |
||||
'action_supprimer' => 'eliminar', |
||||
'action_supprimer_title' => 'Eliminar totalmente el campo de la base de datos', |
||||
|
||||
// C |
||||
'caracteres_autorises_champ' => 'Caracteres posibles: letras sin acento, cifras, - y _', |
||||
'caracteres_interdits' => 'Algunos caracteres utilizados no son adecuados para este campo.', |
||||
'champ_deja_existant' => 'Un campo homónimo ya existe para esta tabla. ', |
||||
'champ_sauvegarde' => '¡Campo adicional guardado!', |
||||
'champs_extras' => 'Campos Adicionales', |
||||
'champs_extras_de' => 'Campos Adicionales de: @objet@', |
||||
|
||||
// E |
||||
'erreur_action' => 'Acción @action@ desconocida.', |
||||
'erreur_enregistrement_champ' => 'Problema de creación de campo adicional. ', |
||||
|
||||
// I |
||||
'icone_creer_champ_extra' => 'Crear un nuevo campo adicional ', |
||||
'info_description_champ_extra' => 'Esta página permite administrar campos adicionales, es decir, campos adicionales en la tablas de SPIP, tomados en cuenta en los formularios de edición.', |
||||
'info_description_champ_extra_creer' => 'Puede crear nuevos campos que se mostrarán sobre esta página, en el cuadro «Lista de campos extras», así como en los formularios.', # MODIF |
||||
'info_description_champ_extra_presents' => 'Finalmente, si los campos ya existen en vuestra base de datos, pero no están declarados (por un plugin o un juego de esqueletos), puede pedir a este plugin que los administre. Estos campos, si los hay, aparecen en el cuadro «Lista de los campos no administrados».', |
||||
'info_modifier_champ_extra' => 'Modificar campo adicional', |
||||
'info_nouveau_champ_extra' => 'Nuevo campo adicional', |
||||
'info_saisie' => 'Entrada:', |
||||
|
||||
// L |
||||
'label_attention' => 'Explicaciones muy importantes', |
||||
'label_champ' => 'Nombre del campo', |
||||
'label_class' => 'Clases CSS', |
||||
'label_datas' => 'Lista de valores', |
||||
'label_explication' => 'Explicaciones de la entrada', |
||||
'label_label' => 'Etiqueta de la entrada', |
||||
'label_obligatoire' => '¿Campo obligatorio?', |
||||
'label_rechercher' => 'Búsqueda', |
||||
'label_rechercher_ponderation' => 'Ponderación de búsqueda', |
||||
'label_restrictions_auteur' => 'Por autor', |
||||
'label_restrictions_branches' => 'Por rama', |
||||
'label_restrictions_groupes' => 'Por grupo', |
||||
'label_restrictions_secteurs' => 'Por sector', |
||||
'label_saisie' => 'Tipo de entrada', |
||||
'label_sql' => 'Definición SQL', |
||||
'label_table' => 'Objeto', |
||||
'label_traitements' => 'Tratamientos automáticos', |
||||
'label_versionner' => 'Versionar el contenido del campo', |
||||
'legend_declaration' => 'Declaración', |
||||
'legend_options_saisies' => 'Opciones de la entrada', |
||||
'legend_options_techniques' => 'Técnica', |
||||
'legend_restriction' => 'Restricción', |
||||
'legend_restrictions_modifier' => 'Modificar la entrada', |
||||
'legend_restrictions_voir' => 'Ver la entrada', |
||||
'liste_des_extras' => 'Lista de campos adicionales', |
||||
'liste_des_extras_possibles' => 'Lista de campos no administrados', |
||||
'liste_objets_applicables' => 'Lista de objetos editoriales', |
||||
|
||||
// N |
||||
'nb_element' => '1 elemento', |
||||
'nb_elements' => '@nb@ elementos', |
||||
|
||||
// P |
||||
'precisions_pour_attention' => 'Para algo muy importante a indicar. |
||||
¡Utilizar con mucha moderación! |
||||
Puede ser una cadena de idioma «plugin:cadena».', |
||||
'precisions_pour_class' => 'Añadir las clases CSS sobre el elemento, separados por un espacio. Ejemplo: "inserer_barre_edition" para un blog con el plugin Porte Plume', |
||||
'precisions_pour_datas' => 'Algunos tipos de campo solicitan una lista de valores acceptados: indíquelos uno por línea, seguidos por una coma y una descripción. Una líena vacía para el valor por defecto. La descripción puede ser una cadena de idioma. ', |
||||
'precisions_pour_explication' => 'Puede dar más información sobre la entrada. |
||||
Puede ser una cadena de idioma «plugin:cadena».', |
||||
'precisions_pour_label' => 'Puede ser una cadena de idioma «plugin:cadena».', |
||||
'precisions_pour_nouvelle_saisie' => 'Permite cambiar el tipo de entrada utilizada para este campo', |
||||
'precisions_pour_nouvelle_saisie_attention' => '¡Tenga cuidado! Un cambio de tipo de entrada pierde las opciones de configuración de la entrada actual que no son comunes con la nueva entrada.', |
||||
'precisions_pour_rechercher' => '¿Incluir este campo en el motor de búsqueda?', |
||||
'precisions_pour_rechercher_ponderation' => 'SPIP pondera una búsqueda en una columna por un coeficient |
||||
Esto permite poner en relieve las columnas más importantes (las que aluden al título, por ejemplo), respecto a otras que lo son menos. |
||||
El coeficiente aplicado sobre los campos extras es 2 por defecto. Para que se haga una idea, tenga en cuenta que SPIP utiliza 8 para el título, 1 para el texto.', |
||||
'precisions_pour_restrictions_branches' => 'Identificadores de ramas para restringir (separador «:»)', |
||||
'precisions_pour_restrictions_groupes' => 'Identificadores de grupos para restringir (separador «:»)', |
||||
'precisions_pour_restrictions_secteurs' => 'Identificadores de sectores para restringir (separador «:»)', |
||||
'precisions_pour_saisie' => 'Mostrar una entrada de tipo:', |
||||
'precisions_pour_traitements' => 'Aplicar automáticamente un tratamiento para la etiqueta #NOM_DU_CHAMP resultante:', |
||||
'precisions_pour_versionner' => 'El versionado se aplicará únicamente si el plugin «revisiones» está activo y si el objeto editorial del campo está en sí mismo versionado', |
||||
|
||||
// R |
||||
'radio_restrictions_auteur_admin' => 'Solamente los administradores', # MODIF |
||||
'radio_restrictions_auteur_aucune' => 'Todo el mundo puede', |
||||
'radio_restrictions_auteur_webmestre' => 'Solamente los webmasters', |
||||
'radio_traitements_aucun' => 'Ninguno', |
||||
'radio_traitements_raccourcis' => 'Tratamientos de atajos SPIP (propre)', |
||||
'radio_traitements_typo' => 'Tratamientos de tipografía únicamente (tipo)', |
||||
|
||||
// S |
||||
'saisies_champs_extras' => 'De «Campos Adicionales»', |
||||
'saisies_saisies' => 'De «Entradas»', |
||||
'supprimer_reelement' => '¿Eliminar este campo?', |
||||
|
||||
// T |
||||
'titre_iextras' => 'Campos Adicionales', |
||||
'titre_page_iextras' => 'Campos Adicionales', |
||||
|
||||
// V |
||||
'veuillez_renseigner_ce_champ' => '¡Rellene por favor este campo!' |
||||
); |
||||
|
||||
?> |
@ -0,0 +1,157 @@
|
||||
<?php |
||||
// This is a SPIP language file -- Ceci est un fichier langue de SPIP |
||||
// Fichier source, a modifier dans svn://zone.spip.org/spip-zone/_plugins_/champs_extras/interface/trunk/lang/ |
||||
if (!defined('_ECRIRE_INC_VERSION')) return; |
||||
|
||||
$GLOBALS[$GLOBALS['idx_lang']] = array( |
||||
|
||||
// A |
||||
'action_associer' => 'gérer ce champ', |
||||
'action_associer_title' => 'Gérer l’affichage de ce champ extra', |
||||
'action_desassocier' => 'désassocier', |
||||
'action_desassocier_title' => 'Ne plus gérer l’affichage de ce champ extra', |
||||
'action_descendre' => 'descendre', |
||||
'action_descendre_title' => 'Déplacer le champ d’un rang vers le bas', |
||||
'action_modifier' => 'modifier', |
||||
'action_modifier_title' => 'Modifier les paramètres du champ extra', |
||||
'action_monter' => 'monter', |
||||
'action_monter_title' => 'Monter le champ d’un rang vers le haut', |
||||
|