Compare commits
No commits in common. "master" and "dev" have entirely different histories.
18 changed files with 209 additions and 547 deletions
30
README.md
30
README.md
|
@ -1,28 +1,18 @@
|
|||
# Gamuform
|
||||
Plugin pour générer des formulaires via saisies et des vues via gamutable semi automatiquement.
|
||||
|
||||
## Configuration de l'interface pour chaque objet
|
||||
### Chaines de langues de l'interface (2 possibilités)
|
||||
* On déclare la `$GLOBALS['gamuform_i18n']['nom_objet']`
|
||||
Plugin pour générer des formulaires et des vues via gamutable semi automatiquement.
|
||||
Il suffit de déclarer la globals
|
||||
|
||||
```php
|
||||
$GLOBALS['gamuform_i18n'] = array_merge(
|
||||
$GLOBALS['gamuform_i18n'] ?? [],
|
||||
[
|
||||
'app_competition' => [
|
||||
'singulier' => 'competition',
|
||||
'pluriel' => 'compétitions',
|
||||
'creer' => 'Créer une nouvelle compétition'
|
||||
]
|
||||
]
|
||||
$GLOBALS['gamuform_objets'] = array_merge(
|
||||
$GLOBALS['gamuform_objets'],
|
||||
[ 'osdve_interventions_type' => "Types d'intervention"]
|
||||
);
|
||||
```
|
||||
* On cree un fichier de lang mon_objet_fr.php, avec les 3 cles (singulier, pluriel, creer)
|
||||
Et de creer une fonction gamuform/mon_objet.php avec une fonction qui renvoie l'array des saisies
|
||||
> il y a un exemple gamuform/exemple.php
|
||||
|
||||
|
||||
## Configuration des objets pour les saisies et pour l'affichage avec gamutable
|
||||
Il faut creer une fonction gamuform/mon_objet.php avec une fonction qui renvoie l'array des saisies, qui peut etre enrichi par des entrées gamutables
|
||||
> il y a un exemple commenté dans gamuform/exemple.php avec toutes les possibilités offertes
|
||||
Ensuite, il suffit d'appeler cette page , en paramettre le nom de l'objet voulu:
|
||||
> spip.php?page=voir_gamuform&objet=auteur
|
||||
|
||||
## Page
|
||||
Il suffit d'appeler cette page `spip.php?page=voir_gamuform`, en paramettre le nom de l'objet voulu `&objet=auteur` :
|
||||
`spip.php?page=voir_gamuform&objet=auteur`
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
|
||||
<INCLURE{fond=inclure/editer_gamuform,env}>
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<div class='formulaire_spip formulaire_editer formulaire_#FORM formulaire_#FORM-#ENV{id_gamuform,nouveau}'>
|
||||
[<p class="reponse_formulaire reponse_formulaire_ok">(#ENV**{message_ok})</p>]
|
||||
[<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>]
|
||||
|
||||
<form method="post" action="#ENV{action}"><div>
|
||||
#ACTION_FORMULAIRE
|
||||
|
||||
<div class="editer_groupe">
|
||||
#GENERER_SAISIES{#ENV{_saisies}}
|
||||
</div>
|
||||
|
||||
<p class="boutons"><input type="submit" class="submit" value="<:bouton_enregistrer:>" /></p>
|
||||
</div></form>
|
||||
</div>
|
|
@ -4,50 +4,43 @@ if (!defined('_ECRIRE_INC_VERSION')) {
|
|||
}
|
||||
|
||||
|
||||
function formulaires_editer_gamuform_saisies_dist($id_objet = 0, $objet = '', $options = [], $id_redirect = null, $redirect = '') {
|
||||
function formulaires_editer_gamuform_saisies_dist($id_objet = 0, $objet = '', $redirect = '') {
|
||||
$saisies = false;
|
||||
if (gamuform_objet_autoriser($objet)) {
|
||||
$saisies = gamuform_recup_tableau_objet($objet, false);
|
||||
$saisies = gamuform_recup_saisies($objet);
|
||||
}
|
||||
return $saisies;
|
||||
}
|
||||
|
||||
function formulaires_editer_gamuform_charger_dist($id_objet = 0, $objet = '', $options = [], $id_redirect = null, $redirect = '') {
|
||||
function formulaires_editer_gamuform_charger_dist($id_objet = 0, $objet = '', $redirect = '') {
|
||||
|
||||
$table = table_objet_sql($objet);
|
||||
$id = id_table_objet($objet);
|
||||
$s = gamuform_recup_champs_saisies($objet);
|
||||
$s = gamuform_recup_champ($objet, true);
|
||||
|
||||
if (intval($id_objet)) {
|
||||
$filtrer_champs_objet = charger_fonction('filtrer_champs_objet', 'inc');
|
||||
$s = $filtrer_champs_objet($objet, $s);
|
||||
$valeurs = sql_fetsel($s, $table, "$id=".intval($id_objet));
|
||||
} else {
|
||||
foreach ($s as $c) {
|
||||
$valeurs[$c] = null;
|
||||
$valeurs[$c] = '';
|
||||
}
|
||||
}
|
||||
|
||||
return $valeurs;
|
||||
}
|
||||
|
||||
function formulaires_editer_gamuform_verifier_dist($id_objet = 0, $objet = '', $options = [], $id_redirect = null, $redirect = '') {
|
||||
function formulaires_editer_gamuform_verifier_dist($id_objet = 0, $objet = '', $redirect = '') {
|
||||
|
||||
$erreurs = [];
|
||||
$erreurs = array();
|
||||
if (!gamuform_objet_autoriser($objet)) {
|
||||
$erreurs['message_erreur'] = "Pb d'objet";
|
||||
}
|
||||
return $erreurs;
|
||||
}
|
||||
|
||||
function formulaires_editer_gamuform_traiter_dist($id_objet = 0, $objet = '', $options = [], $id_redirect = null, $redirect = '') {
|
||||
$id_objet = (int) $id_objet;
|
||||
$id_redirect = (int) $id_redirect;
|
||||
|
||||
$saisies = gamuform_recup_tableau_objet($objet, false);
|
||||
if (array_key_exists('options', $saisies)) {
|
||||
unset($saisies['options']);
|
||||
}
|
||||
function formulaires_editer_gamuform_traiter_dist($id_objet = 0, $objet = '', $redirect = '') {
|
||||
|
||||
$saisies = gamuform_recup_saisies($objet);
|
||||
$table = table_objet_sql($objet);
|
||||
$id = id_table_objet($objet);
|
||||
|
||||
|
@ -60,65 +53,35 @@ function formulaires_editer_gamuform_traiter_dist($id_objet = 0, $objet = '', $o
|
|||
$set = [];
|
||||
if (!empty($saisies)) {
|
||||
foreach ($saisies as $saisie) {
|
||||
if ($saisie['saisie'] === "explication") {
|
||||
continue;
|
||||
}
|
||||
|
||||
$champ = $saisie['options']['nom'];
|
||||
if (
|
||||
isset($saisie['options']['fonction'])
|
||||
and $f = $saisie['options']['fonction']
|
||||
isset($saisies['options']['fonction'])
|
||||
and $f = $saisies['options']['fonction']
|
||||
) {
|
||||
$f($id_objet, $objet, $champ, _request($champ));
|
||||
} elseif (
|
||||
isset($saisie['options']['modifier'])
|
||||
and $m = $saisie['options']['modifier']
|
||||
isset($saisies['options']['modifier'])
|
||||
and $m = $saisies['options']['modifier']
|
||||
) {
|
||||
$set[$champ] = $m($champ, _request($champ));
|
||||
} else {
|
||||
if ($saisie['saisie'] === 'date') {
|
||||
$date = _request($champ);
|
||||
$verifier = charger_fonction('verifier', 'inc/');
|
||||
$verifier($date, 'date', ['normaliser' => 'datetime'], $date);
|
||||
$set[$champ] = $date;
|
||||
} else {
|
||||
$set[$champ] = _requests($champ);
|
||||
}
|
||||
$set[$champ] = _request($champ);
|
||||
}
|
||||
}
|
||||
if (count($set)) {
|
||||
$set = pipeline(
|
||||
'pre_edition',
|
||||
[
|
||||
'args' => [
|
||||
array(
|
||||
'args' => array(
|
||||
'table' => $table,
|
||||
'id_objet' => $id_objet,
|
||||
'objet' => $objet,
|
||||
'action' => 'gamuform',
|
||||
'update' => $update,
|
||||
'options' => $options
|
||||
],
|
||||
'update' => $update
|
||||
),
|
||||
'data' => $set
|
||||
]
|
||||
)
|
||||
);
|
||||
$r = sql_updateq($table, $set, "$id=".intval($id_objet));
|
||||
if ($r) {
|
||||
pipeline(
|
||||
'post_edition',
|
||||
[
|
||||
'args' => [
|
||||
'table' => $table,
|
||||
'id_objet' => $id_objet,
|
||||
'objet' => $objet,
|
||||
'action' => 'gamuform',
|
||||
'update' => $update,
|
||||
'options' => $options
|
||||
],
|
||||
'data' => $set
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
sql_updateq($table, $set, "$id=".intval($id_objet));
|
||||
}
|
||||
}
|
||||
include_spip('inc/invalideur');
|
||||
|
@ -129,9 +92,9 @@ function formulaires_editer_gamuform_traiter_dist($id_objet = 0, $objet = '', $o
|
|||
if ($redirect === 'gamutable') {
|
||||
$retour['redirect'] = '';
|
||||
if ($update) {
|
||||
$retour['message_ok'] = gamutable_fermer_modalbox($id_redirect ?: $id_objet);
|
||||
$retour['message_ok'] = gamutable_fermer_modalbox($id_objet);
|
||||
} else {
|
||||
$retour['message_ok'] = gamutable_fermer_modalbox($id_redirect ?: 0);
|
||||
$retour['message_ok'] = gamutable_fermer_modalbox();
|
||||
}
|
||||
} else if ($redirect) {
|
||||
$retour['redirect'] = $redirect;
|
||||
|
|
|
@ -5,79 +5,37 @@ if (!defined('_ECRIRE_INC_VERSION')) {
|
|||
|
||||
function gamuform_exemple_dist(){
|
||||
|
||||
$js = <<<EOF
|
||||
<script>console.log('coucou');</script>
|
||||
EOF;
|
||||
|
||||
return [
|
||||
// API SAISIES
|
||||
'options' => [
|
||||
'texte_submit' => 'Valider c’est gagné',
|
||||
'inserer_debut' => 'coucou le debut',
|
||||
'inserer_fin' => $js,
|
||||
],
|
||||
[
|
||||
'saisie' => 'input',
|
||||
'options' => [
|
||||
'options' => array(
|
||||
'nom' => 'type_intervention',
|
||||
'libelle' => 'Type',
|
||||
'label' => "Type d'intervention",
|
||||
'obligatoire' => 'oui',
|
||||
//'fonction' => 'ma_super_fonction' // Nom de la fonction appelée pour enregistrer ce champ de facon autonome
|
||||
//'modifier' => 'ma_super_fonction_pour_modifier' // Nom de la fonction appelée pour faire un traitement sur un champ avant l'insertion en bdd
|
||||
],
|
||||
// la cle gamutable n'est pas obligatoire, si absente, gamutable utilisera des valeurs par defaut et des infos de la clé options de saisie
|
||||
'gamutable' => [ // pour le champ type_intervention, comme on définit la clé gamutable, c'est elle qui sera utilisé pour la vue, avec les memes clés que gamutable
|
||||
'champ' => 'type_intervention',
|
||||
'header' => 'Type',
|
||||
'classes' => 'w200p',
|
||||
'filtreCol' => 'select',
|
||||
'ordreCol' => 'asc',
|
||||
'crayons' => 'nom_objet_SPIP', // nom de l'objet du crayons
|
||||
'fonction' => 'Majuscules', // fonction php pour filtre le contenu du champ, elle recoit en argument la valeur du champ
|
||||
]
|
||||
//'fonction' => 'ma_super_fonction'
|
||||
//'modifier' => 'ma_super_fonction_pour_modifier'
|
||||
)
|
||||
],
|
||||
[
|
||||
'saisie' => 'input',
|
||||
'options' => [
|
||||
'options' => array(
|
||||
'nom' => 'desc_type_intervention',
|
||||
'libelle' => 'Description',
|
||||
'label' => 'Description',
|
||||
'obligatoire' => 'oui',
|
||||
'fonction' => '_array_maSuperFonction' // on peut prefixer le nom de la fonction par _array_ et dans ce cas, on cherche une fonction qui
|
||||
// s'appelle _array_maSuperFonction ou simplement maSuperFonction, elle recoit en arg, l'array de la ligne (fetsel) et non simplement la valeur du champ
|
||||
],
|
||||
'gamutable' => [
|
||||
'champ' => 'desc_type_intervention',
|
||||
'header' => 'Compétition',
|
||||
'ordreCol' => 'desc',
|
||||
'classes' => 'w200p',
|
||||
]
|
||||
//'fonction' => 'ma_super_fonction'
|
||||
)
|
||||
],
|
||||
[
|
||||
'saisie' => 'radio',
|
||||
'options' => [
|
||||
'options' => array(
|
||||
'nom' => 'controle_ok',
|
||||
'libelle' => 'Contrôle OK',
|
||||
'label' => 'Contrôle OK',
|
||||
'data' => ['oui' => 'Oui', '' => 'Non']
|
||||
//'fonction' => 'ma_super_fonction'
|
||||
],
|
||||
// la cle gamutable est "normalement" pas obligatoire
|
||||
// 'gamutable' => [
|
||||
// 'champ' => 'desc_type_intervention',
|
||||
// 'header' => 'Compétition',
|
||||
// 'classes' => 'w200p',
|
||||
// ]
|
||||
],
|
||||
// possible un array avec simplement la cle gamutable, que pour l'affichage
|
||||
// cela permet d'avoir une colonne qui s'intercale entre 2 colonnes de champs venant de SAISIES
|
||||
[
|
||||
'gamutable' => [
|
||||
'champ' => 'maj',
|
||||
'header' => '<:prefix:toto:>',
|
||||
'classes' => 'w200p text-center',
|
||||
'filtreCol' => 'input',
|
||||
]
|
||||
)
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
45
gamuform_administrations.php
Normal file
45
gamuform_administrations.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
/**
|
||||
* Fichier gérant l'installation et désinstallation du plugin GamuForm
|
||||
*
|
||||
* @plugin GamuForm
|
||||
* @copyright 2020
|
||||
* @author tofulm
|
||||
* @licence GNU/GPL
|
||||
* @package SPIP\Gamuform\Installation
|
||||
*/
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fonction d'installation et de mise à jour du plugin GamuForm.
|
||||
*
|
||||
* @param string $nom_meta_base_version
|
||||
* Nom de la meta informant de la version du schéma de données du plugin installé dans SPIP
|
||||
* @param string $version_cible
|
||||
* Version du schéma de données dans ce plugin (déclaré dans paquet.xml)
|
||||
* @return void
|
||||
**/
|
||||
function gamuform_upgrade($nom_meta_base_version, $version_cible) {
|
||||
$maj = array();
|
||||
|
||||
// $maj['create'] = array(array('maj_tables', array('spip_gamuforms', 'spip_gamuforms_valeurs')));
|
||||
|
||||
include_spip('base/upgrade');
|
||||
maj_plugin($nom_meta_base_version, $version_cible, $maj);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fonction de désinstallation du plugin GamuForm.
|
||||
*
|
||||
* @param string $nom_meta_base_version
|
||||
* Nom de la meta informant de la version du schéma de données du plugin installé dans SPIP
|
||||
* @return void
|
||||
**/
|
||||
function gamuform_vider_tables($nom_meta_base_version) {
|
||||
effacer_meta($nom_meta_base_version);
|
||||
}
|
|
@ -21,42 +21,34 @@ function gamuform_autoriser() {
|
|||
}
|
||||
|
||||
function autoriser_gamuform_modifier_dist($faire, $type, $id, $qui, $opt) {
|
||||
if (autoriser('webmestre')) {
|
||||
return true;
|
||||
}
|
||||
if (!empty($opt['objet'])) {
|
||||
return autoriser('modifier', $opt['objet'], $id, $qui, []);
|
||||
}
|
||||
return false;
|
||||
|
||||
return autoriser('webmestre');
|
||||
}
|
||||
|
||||
|
||||
function autoriser_gamuform_voir_dist($faire, $type, $id, $qui, $opt) {
|
||||
if (autoriser('webmestre')) {
|
||||
return true;
|
||||
}
|
||||
if (!empty($opt['objet'])) {
|
||||
return autoriser('voir', $opt['objet'], $id, $qui, []);
|
||||
}
|
||||
return false;
|
||||
|
||||
return autoriser('webmestre');
|
||||
}
|
||||
|
||||
function autoriser_gamuform_creer_dist($faire, $type, $id, $qui, $opt) {
|
||||
if (autoriser('webmestre')) {
|
||||
return true;
|
||||
}
|
||||
if (!empty($opt['objet'])) {
|
||||
return autoriser('creer', $opt['objet'], $id, $qui, []);
|
||||
}
|
||||
return false;
|
||||
|
||||
return autoriser('webmestre');
|
||||
}
|
||||
|
||||
function autoriser_gamuform_supprimer_dist($faire, $type, $id, $qui, $opt) {
|
||||
if (autoriser('webmestre')) {
|
||||
return true;
|
||||
}
|
||||
if (!empty($opt['objet'])) {
|
||||
return autoriser('supprimer', $opt['objet'], $id, $qui, []);
|
||||
return autoriser('voir', $opt['objet'], $id, $qui, []);
|
||||
}
|
||||
return false;
|
||||
|
||||
return autoriser('webmestre');
|
||||
}
|
||||
|
|
|
@ -13,61 +13,6 @@ if (!defined('_ECRIRE_INC_VERSION')) {
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
function gamuform_lang(?string $chaine):string {
|
||||
if (strpos($chaine, ':>') !== false) {
|
||||
$chaine = substr($chaine, 2, -2);
|
||||
$chaine = _T($chaine);
|
||||
}
|
||||
return $chaine ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* filtre generale qui appelle un filtre spécifique, déclaré dans l'array saisies avec la cle : gamutable/filtre
|
||||
* si cette fonction commence par _array_ ex: _array_maSuperFonction => elle aura en parametre l'array de la ligne
|
||||
* sinon la valeur
|
||||
* cf gamuform/exemple.php
|
||||
*
|
||||
* @param String $objet
|
||||
* @param String $champ
|
||||
* @param String $valeur
|
||||
*
|
||||
* @return String valeur modifiée ou pas par le filtre
|
||||
*/
|
||||
function gamufiltre($objet, $champ, $ligne, $integer = false) {
|
||||
$valeur = $ligne[$champ] ?? '';
|
||||
if (gamuform_objet_autoriser($objet)) {
|
||||
$T = gamuform_recup_tableau_objet($objet);
|
||||
|
||||
if (!empty($T)) {
|
||||
foreach ($T as $s) {
|
||||
if (
|
||||
(!empty($s['gamutable']) or !empty($s['options']))
|
||||
and $champ_tab = $s['gamutable']['champ'] ?? $s['options']['nom']
|
||||
and $champ_tab === $champ
|
||||
and !empty($s['gamutable']['fonction'])
|
||||
) {
|
||||
$filtre = $s['gamutable']['fonction'];
|
||||
if (strpos($filtre, '_array_') !== false) {
|
||||
$f = substr($filtre, 7);
|
||||
if (function_exists($f)) {
|
||||
return $f($ligne, $integer) ?? '';
|
||||
} else if(function_exists($filtre)) {
|
||||
return $filtre($ligne, $integer) ?? '';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
return $filtre($valeur, $integer) ?? '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $valeur;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* recuperation du tableau des saisies d'un objet
|
||||
* dans : gamuform/mon_objet.php
|
||||
|
@ -77,7 +22,7 @@ function gamufiltre($objet, $champ, $ligne, $integer = false) {
|
|||
* @return array
|
||||
*
|
||||
*/
|
||||
function gamuform_recup_tableau_objet(string $objet, bool $all = true):array {
|
||||
function gamuform_recup_saisies(string $objet):array {
|
||||
$f = charger_fonction($objet, 'gamuform', true);
|
||||
if (!$f) {
|
||||
return [];
|
||||
|
@ -86,217 +31,51 @@ function gamuform_recup_tableau_objet(string $objet, bool $all = true):array {
|
|||
if (empty($T)) {
|
||||
$T = [];
|
||||
}
|
||||
// on filtre les entrées vides, qui peuvent arriver si on on des autorisations
|
||||
$T = array_filter($T, function($d){
|
||||
return !empty($d);
|
||||
});
|
||||
$options = [];
|
||||
if (!empty($T['options'])) {
|
||||
$options = $T['options'];
|
||||
unset($T['options']);
|
||||
}
|
||||
|
||||
if (!$all) {
|
||||
$T = array_filter($T, function($d){
|
||||
return !empty($d['saisie']);
|
||||
});
|
||||
$T = array_merge(['options' => $options], $T);
|
||||
}
|
||||
return $T;
|
||||
}
|
||||
|
||||
function gamuform_objet_autoriser(string $objet):bool {
|
||||
if (
|
||||
!empty($GLOBALS['gamuform_objets'])
|
||||
and !empty($objet)
|
||||
and in_array($objet, array_keys($GLOBALS['gamuform_objets']))
|
||||
) {
|
||||
return true;
|
||||
// if (
|
||||
// !empty($GLOBALS['gamuform_objets'])
|
||||
// and !empty($objet)
|
||||
// and in_array($objet, array_keys($GLOBALS['gamuform_objets']))
|
||||
// ) {
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function gamuform_nom_objet($objet, $quoi = 'pluriel'):string {
|
||||
$trad = '';
|
||||
function gamuform_nom_objet($objet):string {
|
||||
$nom = '';
|
||||
if (gamuform_objet_autoriser($objet)) {
|
||||
if (!empty($GLOBALS['gamuform_objets'][$objet][$quoi])) {
|
||||
$trad = $GLOBALS['gamuform_objets'][$objet][$quoi];
|
||||
} else if ( !empty($GLOBALS['gamuform_i18n'][$objet][$quoi])){
|
||||
$trad = $GLOBALS['gamuform_i18n'][$objet][$quoi];
|
||||
} else {
|
||||
$trad = _T($objet . ':' . $quoi);
|
||||
$nom = $GLOBALS['gamuform_objets'][$objet];
|
||||
}
|
||||
}
|
||||
return $trad;
|
||||
}
|
||||
/**
|
||||
* recuperation des champs de l'objet pour les saisies
|
||||
*
|
||||
* @param String $objet
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function gamuform_recup_champs_gamutable(string $objet):array {
|
||||
$c = [];
|
||||
|
||||
if (gamuform_objet_autoriser($objet)) {
|
||||
$T = gamuform_recup_tableau_objet($objet);
|
||||
if (!empty($T)) {
|
||||
foreach ($T as $s) {
|
||||
$c[] = $s['gamutable']['champ'] ?? $s['options']['nom'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
return $nom;
|
||||
}
|
||||
|
||||
/**
|
||||
* recuperation des champs de l'objet pour les saisies
|
||||
* recuperation des champs de l'objet que l'on veut traiter
|
||||
*
|
||||
* @param String $objet
|
||||
* @param Bool $keys (optional) le type de sortie que l'on souhaite
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function gamuform_recup_champs_saisies(string $objet):array {
|
||||
function gamuform_recup_champ(string $objet, bool $keys = false):array {
|
||||
$c = [];
|
||||
|
||||
if (gamuform_objet_autoriser($objet)) {
|
||||
$T = gamuform_recup_tableau_objet($objet, false);
|
||||
if (array_key_exists('options', $T)) {
|
||||
unset($T['options']);
|
||||
}
|
||||
$T = gamuform_recup_saisies($objet);
|
||||
|
||||
if (!empty($T)) {
|
||||
foreach ($T as $s) {
|
||||
if ($keys) {
|
||||
$c[] = $s['options']['nom'];
|
||||
} else {
|
||||
$c[$s['options']['nom']] = $s['options']['libelle'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
|
||||
/**
|
||||
* recuperation du header de l'objet que l'on veut afficher dans gamutable
|
||||
*
|
||||
* @param String $objet
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function gamuform_recup_header(string $objet):array {
|
||||
$c = [];
|
||||
|
||||
if (gamuform_objet_autoriser($objet)) {
|
||||
$T = gamuform_recup_tableau_objet($objet);
|
||||
|
||||
if (!empty($T)) {
|
||||
foreach ($T as $s) {
|
||||
$champ = $s['gamutable']['champ'] ?? $s['options']['nom'];
|
||||
$c[$champ] = $s['gamutable']['header'] ?? $s['options']['nom'];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $c;
|
||||
}
|
||||
/**
|
||||
* recuperation des filtreCol de l'objet que l'on veut afficher dans gamutable
|
||||
*
|
||||
* @param String $objet
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function gamuform_recup_crayons(string $objet):array {
|
||||
$c = [];
|
||||
|
||||
if (gamuform_objet_autoriser($objet)) {
|
||||
$T = gamuform_recup_tableau_objet($objet);
|
||||
|
||||
if (!empty($T)) {
|
||||
foreach ($T as $s) {
|
||||
if (
|
||||
!empty($s['gamutable']['crayons'])
|
||||
and $champ = $s['gamutable']['champ'] ?? $s['options']['nom']
|
||||
) {
|
||||
$c[$champ] = $s['gamutable']['crayons'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
/**
|
||||
* recuperation des ordreCol de l'objet que l'on veut afficher dans gamutable
|
||||
*
|
||||
* @param String $objet
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function gamuform_recup_ordreCol(string $objet):array {
|
||||
$c = [];
|
||||
|
||||
if (gamuform_objet_autoriser($objet)) {
|
||||
$T = gamuform_recup_tableau_objet($objet);
|
||||
|
||||
if (!empty($T)) {
|
||||
foreach ($T as $s) {
|
||||
if (
|
||||
!empty($s['gamutable']['ordreCol'])
|
||||
and $champ = $s['gamutable']['champ'] ?? $s['options']['nom']
|
||||
) {
|
||||
$c[$champ] = $s['gamutable']['ordreCol'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
/**
|
||||
* recuperation des filtreCol de l'objet que l'on veut afficher dans gamutable
|
||||
*
|
||||
* @param String $objet
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function gamuform_recup_filtreCol(string $objet):array {
|
||||
$c = [];
|
||||
|
||||
if (gamuform_objet_autoriser($objet)) {
|
||||
$T = gamuform_recup_tableau_objet($objet);
|
||||
if (!empty($T)) {
|
||||
foreach ($T as $s) {
|
||||
if (
|
||||
!empty($s['gamutable']['filtreCol'])
|
||||
and in_array($s['gamutable']['filtreCol'], ['input', 'select'])
|
||||
and $champ = $s['gamutable']['champ'] ?? $s['options']['nom']
|
||||
) {
|
||||
$c[$champ] = $s['gamutable']['filtreCol'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $c;
|
||||
}
|
||||
|
||||
/**
|
||||
* recuperation des classes de l'objet que l'on veut afficher dans gamutable
|
||||
*
|
||||
* @param String $objet
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
function gamuform_recup_classes(string $objet):array {
|
||||
$c = [];
|
||||
|
||||
if (gamuform_objet_autoriser($objet)) {
|
||||
$T = gamuform_recup_tableau_objet($objet);
|
||||
|
||||
if (!empty($T)) {
|
||||
foreach ($T as $s) {
|
||||
$champ = $s['gamutable']['champ'] ?? $s['options']['nom'];
|
||||
$c[$champ] = $s['gamutable']['classes'] ?? '';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $c;
|
||||
}
|
||||
|
@ -309,27 +88,22 @@ function gamuform_recup_classes(string $objet):array {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
function gamuform_recup_valeurs($objet, $id_objet = 0, $where = null):array {
|
||||
function gamuform_recup_valeurs($objet, $id_objet = 0):array {
|
||||
$r = [];
|
||||
if (gamuform_objet_autoriser($objet)) {
|
||||
$table = table_objet_sql($objet);
|
||||
$id = id_table_objet($objet);
|
||||
// $s = gamuform_recup_champs_gamutable($objet);
|
||||
$s = gamuform_recup_champ($objet, true);
|
||||
|
||||
// $s[] = $id;
|
||||
$s[] = $id;
|
||||
if (intval($id_objet)) {
|
||||
$valeurs = sql_fetsel('*', $table, "$id=".intval($id_objet));
|
||||
$valeurs = sql_fetsel($s, $table, "$id=".intval($id_objet));
|
||||
$valeurs['id'] = $valeurs[$id];
|
||||
if (!empty($valeurs)) {
|
||||
$r[0] = $valeurs;
|
||||
}
|
||||
} else {
|
||||
if ($where) {
|
||||
$w[] = $where;
|
||||
} else {
|
||||
$w = 1;
|
||||
}
|
||||
$T = sql_allfetsel('*', $table, $w);
|
||||
$T = sql_allfetsel($s, $table, 1);
|
||||
if (!empty($T)) {
|
||||
foreach ($T as $t) {
|
||||
$t['id'] = $t[$id];
|
||||
|
|
|
@ -13,3 +13,5 @@ if (!defined('_ECRIRE_INC_VERSION')) {
|
|||
return;
|
||||
}
|
||||
|
||||
// initialisation de l'objet global
|
||||
$GLOBALS['gamuform_objets'] = [];
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
#CACHE{0}
|
||||
[(#AUTORISER{modifier, gamuform, #ENV{id_objet}, '', #ARRAY{objet, #ENV{objet}}}|sinon_interdire_acces)]
|
||||
|
||||
#SET{options,#ARRAY}
|
||||
[(#ENV{options}|oui) #SET{options,#ENV{options}} ]
|
||||
|
||||
<div class="inner">
|
||||
<div class="ajax">
|
||||
[(#FORMULAIRE_EDITER_GAMUFORM{#ENV{id_objet}, #ENV{objet}, #GET{options}, #ENV{id_redirect}, #ENV{redirect}})]
|
||||
[(#FORMULAIRE_EDITER_GAMUFORM{#ENV{id_objet}, #ENV{objet}, #ENV{redirect}})]
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,27 +1,20 @@
|
|||
[(#AUTORISER{voir, gamuform, #ENV{id_objet}, '', #ARRAY{objet, #ENV{objet}}}|sinon_interdire_acces)]
|
||||
|
||||
<div class="conf-inner">
|
||||
<h2 class="text-center"><:gamuform:configuration_des|ucfirst:> [ (#ENV{objet}|gamuform_nom_objet)]</h2>
|
||||
<h2 class="text-center">Configuration des [ (#ENV{objet}|gamuform_nom_objet)]</h2>
|
||||
<div class="tableau">
|
||||
|
||||
[(#AUTORISER{creer, gamuform, 0, '', #ARRAY{objet, #ENV{objet}}}|oui)
|
||||
[(#SET{lien,<a class="modalbox btn btn-gamuform"
|
||||
href="[(#URL_PAGE{editer_gamuform}|parametre_url{objet,#ENV{objet}}|parametre_url{redirect,#SELF})]">
|
||||
<i class="osdve-plus-circle"></i>
|
||||
[(#ENV{objet}|gamuform_nom_objet{creer})]
|
||||
</a>})]
|
||||
[(#SET{lien,<a class="modalbox btn--osdve" href="[(#URL_PAGE{editer_gamuform}|parametre_url{objet,#ENV{objet}}|parametre_url{redirect,#SELF})]"><i class="osdve-plus-circle"></i> Nouveau</a>})]
|
||||
]
|
||||
#SET{url,spip.php?page=json_gamuform.json}
|
||||
#SET{url,#GET{url}|parametre_url{lang,#ENV{lang}}}
|
||||
#SET{url,#GET{url}|parametre_url{objet,#ENV{objet}}}
|
||||
#SET{url,#GET{url}|parametre_url{w,#ENV{w}}}
|
||||
#SET{namecsv,#ENV{objet}.csv}
|
||||
#SET{tparpage,#ENV{tparpage, [15,25,50,'Tous']}}
|
||||
#SET{url,spip.php?page=json_gamuform.json&objet=}
|
||||
#SET{url,#GET{url}|concat{#ENV{objet}}}
|
||||
<INCLURE{fond=inclure/gamutable,
|
||||
apiuri=#GET{url},
|
||||
tparpage=#GET{tparpage},
|
||||
includespip=#GET{lien},
|
||||
namecsv=#GET{namecsv},
|
||||
champcsv=#ENV{champcsv,search},
|
||||
env
|
||||
}>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,44 +1,20 @@
|
|||
#HTTP_HEADER{Content-Type: application/json; charset=#CHARSET}
|
||||
[(#AUTORISER{voir, gamuform, #ENV{id_objet}, '', #ARRAY{objet, #ENV{objet}}}|sinon_interdire_acces)]
|
||||
|
||||
#SET{header,#ENV{objet}|gamuform_recup_header}
|
||||
#SET{champs,#ENV{objet}|gamuform_recup_champs_gamutable}
|
||||
#SET{classes,#ENV{objet}|gamuform_recup_classes}
|
||||
#SET{filtreCol,#ENV{objet}|gamuform_recup_filtreCol}
|
||||
#SET{ordreCol,#ENV{objet}|gamuform_recup_ordreCol}
|
||||
#SET{crayons,#ENV{objet}|gamuform_recup_crayons}
|
||||
|
||||
#SET{header,#ENV{objet}|gamuform_recup_champ}
|
||||
[{
|
||||
"header":{
|
||||
"id": "id",
|
||||
[(#AUTORISER{modifier, gamuform, #ENV{id_objet}, '', #ARRAY{objet, #ENV{objet}}}|oui)
|
||||
"edit": "",]
|
||||
<BOUCLE_header(DATA){source table,#GET{header}}{','}>
|
||||
[(#CLE|json_encode)] : [(#VALEUR*|gamuform_lang|mb_ucfirst|json_encode)]
|
||||
"edit": "",
|
||||
<BOUCLE_header(DATA){source table,#GET{header}}>
|
||||
[(#CLE|json_encode)] : [(#VALEUR|json_encode)],
|
||||
</BOUCLE_header>
|
||||
[(#AUTORISER{supprimer, gamuform, #ENV{id_objet}, '', #ARRAY{objet, #ENV{objet}}}|oui)
|
||||
,"sup": ""
|
||||
]
|
||||
"sup": ""
|
||||
},
|
||||
"crayons":{
|
||||
<BOUCLE_crayons(DATA){source table,#GET{crayons}}{','}>
|
||||
[(#CLE|json_encode)] : [(#VALEUR|json_encode)]
|
||||
</BOUCLE_crayons>
|
||||
},
|
||||
"ordreCol" : {
|
||||
<BOUCLE_ordreCol(DATA){source table,#GET{ordreCol}}{','}>
|
||||
[(#CLE|json_encode)] : [(#VALEUR|json_encode)]
|
||||
</BOUCLE_ordreCol>
|
||||
},
|
||||
"filtreCol" : {
|
||||
<BOUCLE_filtreCol(DATA){source table,#GET{filtreCol}}{','}>
|
||||
[(#CLE|json_encode)] : [(#VALEUR|json_encode)]
|
||||
</BOUCLE_filtreCol>
|
||||
},
|
||||
"classes" : {
|
||||
<BOUCLE_classes(DATA){source table,#GET{classes}}>
|
||||
[(#CLE|json_encode)] : [(#VALEUR|json_encode)],
|
||||
</BOUCLE_classes>
|
||||
"id": "w80p",
|
||||
"edit": "w50p",
|
||||
"sup": "w50p"
|
||||
|
@ -46,31 +22,39 @@
|
|||
}
|
||||
<B_gamuform>
|
||||
,
|
||||
<BOUCLE_gamuform(DATA){source table, #ENV{objet}|gamuform_recup_valeurs{#ENV{id},#ENV{w}}}{','}>
|
||||
<BOUCLE_gamuform(DATA){source table, #ENV{objet}|gamuform_recup_valeurs{#ENV{id}}}{','}>
|
||||
#SET{ligne,#VALEUR}
|
||||
[(#SET{edit, #MODELE{lien_editer_gamuform,ligne=#GET{ligne},env} })]
|
||||
[(#SET{sup, #MODELE{lien_supprimer_gamuform,ligne=#GET{ligne},env} })]
|
||||
[(#SET{edit, <a class="modalbox"
|
||||
href="[(#URL_PAGE{editer_gamuform}
|
||||
|parametre_url{id_objet,#GET{ligne/id}}
|
||||
|parametre_url{objet,#ENV{objet}}
|
||||
|parametre_url{redirect,gamutable})]">
|
||||
<i class="fas fa-edit"></i>
|
||||
</a> })]
|
||||
[(#SET{sup,
|
||||
<a class="url_action" href="[(#URL_ACTION_AUTEUR{supprimer_gamuform,#GET{ligne/id}/#ENV{objet},#SELF})]"
|
||||
data-confirm="Confirmez vous la suppression de cette ligne ?"
|
||||
>
|
||||
<i class="fas fa-trash"></i>
|
||||
</a>})]
|
||||
{
|
||||
"html": {
|
||||
"id": #GET{ligne/id},
|
||||
[(#AUTORISER{modifier, gamuform, #ENV{id_objet}, '', #ARRAY{objet, #ENV{objet}}}|oui)
|
||||
"edit": [(#GET{edit}|json_encode)],
|
||||
]
|
||||
<BOUCLE_champsA(DATA){source table,#GET{champs}}{','}>
|
||||
[(#VALEUR|json_encode)] : [(#ENV{objet}|gamufiltre{#VALEUR,#GET{ligne}}|json_encode)]
|
||||
</BOUCLE_champsA>
|
||||
[(#AUTORISER{supprimer, gamuform, #ENV{id_objet}, '', #ARRAY{objet, #ENV{objet}}}|oui)
|
||||
,"sup": [(#GET{sup}|json_encode)]
|
||||
]
|
||||
<BOUCLE_headerB(DATA){source table,#GET{header}}>
|
||||
[(#CLE|json_encode)] : [(#GET{ligne/#CLE}|json_encode)],
|
||||
</BOUCLE_headerB>
|
||||
"sup": [(#GET{sup}|json_encode)]
|
||||
},
|
||||
"search": {
|
||||
"id": #GET{ligne/id},
|
||||
"edit": "",
|
||||
<BOUCLE_champsB(DATA){source table,#GET{champs}}>
|
||||
[(#VALEUR|json_encode)] : [(#ENV{objet}|gamufiltre{#VALEUR,#GET{ligne},integer}|json_encode{32})],
|
||||
</BOUCLE_champsB>
|
||||
<BOUCLE_headerC(DATA){source table,#GET{header}}>
|
||||
[(#CLE|json_encode)] : [(#GET{ligne/#CLE}|textebrut|json_encode)],
|
||||
</BOUCLE_headerC>
|
||||
"sup":""
|
||||
}
|
||||
}
|
||||
</BOUCLE_gamuform>
|
||||
]
|
||||
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
<?php
|
||||
// This is a SPIP language file -- Ceci est un fichier langue de SPIP
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$GLOBALS[$GLOBALS['idx_lang']] = array(
|
||||
|
||||
// AA
|
||||
|
||||
// CC
|
||||
"configuration_des" => "Konfiguration von",
|
||||
|
||||
// EE
|
||||
"enregistrer" => "registrieren",
|
||||
|
||||
// II
|
||||
|
||||
// RR
|
||||
|
||||
// SS
|
||||
|
||||
// TT
|
||||
);
|
|
@ -1,26 +0,0 @@
|
|||
<?php
|
||||
// This is a SPIP language file -- Ceci est un fichier langue de SPIP
|
||||
|
||||
if (!defined('_ECRIRE_INC_VERSION')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$GLOBALS[$GLOBALS['idx_lang']] = array(
|
||||
|
||||
// AA
|
||||
|
||||
// CC
|
||||
"configuration_des" => "configuración de",
|
||||
|
||||
// EE
|
||||
"enregistrer" => "Regístrese en",
|
||||
|
||||
// II
|
||||
|
||||
// RR
|
||||
|
||||
// SS
|
||||
|
||||
// TT
|
||||
);
|
|
@ -8,19 +8,37 @@ if (!defined('_ECRIRE_INC_VERSION')) {
|
|||
|
||||
$GLOBALS[$GLOBALS['idx_lang']] = array(
|
||||
|
||||
// AA
|
||||
// A
|
||||
'ajouter_lien_gamuform' => 'Ajouter ce gamuform',
|
||||
|
||||
// CC
|
||||
"configuration_des" => "configuration des",
|
||||
// C
|
||||
'champ_titre_label' => 'Titre',
|
||||
'confirmer_supprimer_gamuform' => 'Confirmez-vous la suppression de cet gamuform ?',
|
||||
|
||||
// EE
|
||||
"enregistrer" => "Enregistrer",
|
||||
// I
|
||||
'icone_creer_gamuform' => 'Créer un gamuform',
|
||||
'icone_modifier_gamuform' => 'Modifier ce gamuform',
|
||||
'info_1_gamuform' => 'Un gamuform',
|
||||
'info_aucun_gamuform' => 'Aucun gamuform',
|
||||
'info_gamuforms_auteur' => 'Les gamuforms de cet auteur',
|
||||
'info_nb_gamuforms' => '@nb@ gamuforms',
|
||||
|
||||
// II
|
||||
// R
|
||||
'retirer_lien_gamuform' => 'Retirer ce gamuform',
|
||||
'retirer_tous_liens_gamuforms' => 'Retirer tous les gamuforms',
|
||||
|
||||
// RR
|
||||
// S
|
||||
'supprimer_gamuform' => 'Supprimer cet gamuform',
|
||||
|
||||
// SS
|
||||
|
||||
// TT
|
||||
// T
|
||||
'texte_ajouter_gamuform' => 'Ajouter un gamuform',
|
||||
'texte_changer_statut_gamuform' => 'Ce gamuform est :',
|
||||
'texte_creer_associer_gamuform' => 'Créer et associer un gamuform',
|
||||
'texte_definir_comme_traduction_gamuform' => 'Ce gamuform est une traduction du gamuform numéro :',
|
||||
'titre_gamuform' => 'Gamuform',
|
||||
'titre_gamuforms' => 'Gamuforms',
|
||||
'titre_gamuforms_rubrique' => 'Gamuforms de la rubrique',
|
||||
'titre_langue_gamuform' => 'Langue de ce gamuform',
|
||||
'titre_logo_gamuform' => 'Logo de ce gamuform',
|
||||
'titre_objets_lies_gamuform' => 'Liés à ce gamuform',
|
||||
);
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
#SET{ligne,#ENV{ligne}}
|
||||
<a class="modalbox"
|
||||
href="[(#URL_PAGE{editer_gamuform}
|
||||
|parametre_url{id_objet,#GET{ligne/id}}
|
||||
|parametre_url{objet,#ENV{objet}}
|
||||
|parametre_url{redirect,gamutable})]">
|
||||
<i class="fas fa-edit"></i>
|
||||
</a>
|
|
@ -1,7 +0,0 @@
|
|||
#SET{ligne,#ENV{ligne}}
|
||||
<a class="url_action" href="[(#URL_ACTION_AUTEUR{supprimer_gamuform,#GET{ligne/id}/#ENV{objet},#SELF})]"
|
||||
data-confirm="Confirmez vous la suppression de cette ligne ?"
|
||||
>
|
||||
<i class="fas fa-trash"></i>
|
||||
</a>
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
<paquet
|
||||
prefix="gamuform"
|
||||
categorie="outil"
|
||||
version="1.3.2"
|
||||
version="1.0.0"
|
||||
etat="dev"
|
||||
compatibilite="[4.0.0;4.*]"
|
||||
compatibilite="[4.0.0;4.0.*]"
|
||||
logo="prive/themes/spip/images/gamuform-xx.svg"
|
||||
documentation=""
|
||||
>
|
||||
|
@ -16,8 +16,6 @@
|
|||
<licence>GNU/GPL</licence>
|
||||
<necessite nom="saisies" compatibilite="[3.23.2;]" />
|
||||
<necessite nom="gamutable" compatibilite="[3.2.1;]" />
|
||||
<necessite nom="verifier" compatibilite="[2.0.0;]" />
|
||||
<necessite nom="gamufonctions" compatibilite="[1.0.0;]" />
|
||||
|
||||
|
||||
<pipeline nom="autoriser" inclure="gamuform_autorisations.php" />
|
||||
|
|
Loading…
Add table
Reference in a new issue