|
|
|
@ -5,7 +5,9 @@
|
|
|
|
|
*
|
|
|
|
|
* @package SPIP\Fabrique\Formulaires
|
|
|
|
|
**/
|
|
|
|
|
if (!defined("_ECRIRE_INC_VERSION")) return;
|
|
|
|
|
|
|
|
|
|
if (!defined('_ECRIRE_INC_VERSION')) { return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Hash du formulaire de fabrication de plugin
|
|
|
|
@ -13,7 +15,7 @@ if (!defined("_ECRIRE_INC_VERSION")) return;
|
|
|
|
|
* @return string
|
|
|
|
|
* Hash du formulaire
|
|
|
|
|
**/
|
|
|
|
|
function formulaires_fabriquer_plugin_identifier_dist(){
|
|
|
|
|
function formulaires_fabriquer_plugin_identifier_dist() {
|
|
|
|
|
return serialize(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -31,9 +33,9 @@ function formulaires_fabriquer_plugin_charger_dist() {
|
|
|
|
|
$v_futur = explode('.', $v_spip);
|
|
|
|
|
array_pop($v_futur);
|
|
|
|
|
$v_futur = implode('.', $v_futur) . '.*';
|
|
|
|
|
$contexte = array(
|
|
|
|
|
'fabrique' => array(), // ne sert pas dans ce formulaire, mais un jour peut être
|
|
|
|
|
'paquet' => array(
|
|
|
|
|
$contexte = [
|
|
|
|
|
'fabrique' => [], // ne sert pas dans ce formulaire, mais un jour peut être
|
|
|
|
|
'paquet' => [
|
|
|
|
|
'prefixe' => '',// 'Nouveau plugin',
|
|
|
|
|
'version' => '1.0.0',
|
|
|
|
|
'auteur' => $GLOBALS['visiteur_session']['nom'],
|
|
|
|
@ -42,21 +44,21 @@ function formulaires_fabriquer_plugin_charger_dist() {
|
|
|
|
|
'compatibilite' => '[' . $v_spip . ';' . $v_futur . ']',
|
|
|
|
|
'licence' => 'GNU/GPL',
|
|
|
|
|
'schema' => '1.0.0',
|
|
|
|
|
'fichiers' => array(),
|
|
|
|
|
'fichiers' => [],
|
|
|
|
|
'exemples' => '', // inserer des exemples, de l'aide dans les fichiers.
|
|
|
|
|
),
|
|
|
|
|
'objets' => array(),
|
|
|
|
|
);
|
|
|
|
|
],
|
|
|
|
|
'objets' => [],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// On initialise la session si elle est vide
|
|
|
|
|
if (is_null($fabrique = session_get(FABRIQUE_ID))){
|
|
|
|
|
if (is_null($fabrique = session_get(FABRIQUE_ID))) {
|
|
|
|
|
session_set(FABRIQUE_ID, $contexte);
|
|
|
|
|
$fabrique = array();
|
|
|
|
|
$fabrique = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ça merge que la profondeur 1, c'est surtout la 2 qui interesse
|
|
|
|
|
#$contexte = array_merge($contexte, $fabrique);
|
|
|
|
|
foreach ($contexte as $c=>$v) {
|
|
|
|
|
foreach ($contexte as $c => $v) {
|
|
|
|
|
if (isset($fabrique[$c])) {
|
|
|
|
|
$contexte[$c] = array_merge($contexte[$c], $fabrique[$c]);
|
|
|
|
|
}
|
|
|
|
@ -84,10 +86,10 @@ function formulaires_fabriquer_plugin_charger_dist() {
|
|
|
|
|
|
|
|
|
|
// on ouvre du coup le 2e accordion par defaut.
|
|
|
|
|
// si l'objet a deja ete rempli une fois
|
|
|
|
|
$accordion = _request('open_accordion', array());
|
|
|
|
|
$accordion = _request('open_accordion', []);
|
|
|
|
|
foreach ($contexte['objets'] as $c => $o) {
|
|
|
|
|
if (isset($o['champs']) and count($o['champs'])) {
|
|
|
|
|
$accordion[$c+1] = 1;
|
|
|
|
|
$accordion[$c + 1] = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$contexte['open_accordion'] = $accordion;
|
|
|
|
@ -112,35 +114,35 @@ function formulaires_fabriquer_plugin_charger_dist() {
|
|
|
|
|
* @return array
|
|
|
|
|
* Erreurs du formulaire
|
|
|
|
|
**/
|
|
|
|
|
function formulaires_fabriquer_plugin_verifier_dist(){
|
|
|
|
|
function formulaires_fabriquer_plugin_verifier_dist() {
|
|
|
|
|
|
|
|
|
|
// cas d'action qui n'ont pas a être testées ici.
|
|
|
|
|
if (_request('f_action')) {
|
|
|
|
|
return array(); // forcer aucune erreur
|
|
|
|
|
return []; // forcer aucune erreur
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$erreurs = array();
|
|
|
|
|
$erreurs = [];
|
|
|
|
|
|
|
|
|
|
$paquet = _request('paquet');
|
|
|
|
|
foreach (array('prefixe', 'version', 'etat', 'nom') as $obli) {
|
|
|
|
|
foreach (['prefixe', 'version', 'etat', 'nom'] as $obli) {
|
|
|
|
|
if (!$paquet[$obli]) {
|
|
|
|
|
$erreurs['paquet'][$obli] = _T("info_obligatoire");
|
|
|
|
|
$erreurs['paquet'][$obli] = _T('info_obligatoire');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$objets = _request('objets');
|
|
|
|
|
if (is_array($objets)) {
|
|
|
|
|
foreach ($objets as $c => $o) {
|
|
|
|
|
foreach (array('nom', 'table') as $obli) {
|
|
|
|
|
foreach (['nom', 'table'] as $obli) {
|
|
|
|
|
if (!$o[$obli]) {
|
|
|
|
|
$erreurs['objets'][$c][$obli] = _T("info_obligatoire");
|
|
|
|
|
$erreurs['objets'][$c][$obli] = _T('info_obligatoire');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (isset($o['champs']) and is_array($o['champs'])) {
|
|
|
|
|
foreach ($o['champs'] as $n => $champ) {
|
|
|
|
|
foreach (array('nom', 'champ', 'sql') as $obli) {
|
|
|
|
|
foreach (['nom', 'champ', 'sql'] as $obli) {
|
|
|
|
|
if (!$champ[$obli]) {
|
|
|
|
|
$erreurs['objets'][$c]['champs'][$n][$obli] = _T("info_obligatoire");
|
|
|
|
|
$erreurs['objets'][$c]['champs'][$n][$obli] = _T('info_obligatoire');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -149,7 +151,7 @@ function formulaires_fabriquer_plugin_verifier_dist(){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (count($erreurs)) {
|
|
|
|
|
$erreurs['message_erreur'] = _T("fabrique:erreurs");
|
|
|
|
|
$erreurs['message_erreur'] = _T('fabrique:erreurs');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $erreurs;
|
|
|
|
@ -164,21 +166,21 @@ function formulaires_fabriquer_plugin_verifier_dist(){
|
|
|
|
|
* @return array
|
|
|
|
|
* Retours du traitement
|
|
|
|
|
**/
|
|
|
|
|
function formulaires_fabriquer_plugin_traiter_dist(){
|
|
|
|
|
function formulaires_fabriquer_plugin_traiter_dist() {
|
|
|
|
|
include_spip('fabrique_fonctions');
|
|
|
|
|
include_spip('formulaires/fabriquer_plugin_actions');
|
|
|
|
|
|
|
|
|
|
$paquet = _request('paquet');
|
|
|
|
|
$objets = _request('objets');
|
|
|
|
|
if (!is_array($objets)) {
|
|
|
|
|
$objets = array();
|
|
|
|
|
$objets = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$data = array(
|
|
|
|
|
'fabrique' => array('version' => FABRIQUE_VERSION),
|
|
|
|
|
$data = [
|
|
|
|
|
'fabrique' => ['version' => FABRIQUE_VERSION],
|
|
|
|
|
'paquet' => $paquet,
|
|
|
|
|
'objets' => $objets,
|
|
|
|
|
);
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// gerer les cas d'envoi d'images.
|
|
|
|
|
// (avant les éventuels retours sur l'ajout / suppression d'objet !)
|
|
|
|
@ -200,7 +202,7 @@ function formulaires_fabriquer_plugin_traiter_dist(){
|
|
|
|
|
$data['objets'][$c]['cle_primaire'] = id_table_objet($o['table']);
|
|
|
|
|
}
|
|
|
|
|
if ($o['table'] and !$o['cle_primaire_sql']) {
|
|
|
|
|
$data['objets'][$c]['cle_primaire_sql'] = "bigint(21) NOT NULL";
|
|
|
|
|
$data['objets'][$c]['cle_primaire_sql'] = 'bigint(21) NOT NULL';
|
|
|
|
|
}
|
|
|
|
|
if ($o['table'] and !$o['table_type']) {
|
|
|
|
|
$data['objets'][$c]['table_type'] = objet_type($data['objets'][$c]['cle_primaire']);
|
|
|
|
@ -235,7 +237,8 @@ function formulaires_fabriquer_plugin_traiter_dist(){
|
|
|
|
|
'destination',
|
|
|
|
|
'destination_plugin',
|
|
|
|
|
'destination_backup',
|
|
|
|
|
'destination_ancien_plugin');
|
|
|
|
|
'destination_ancien_plugin'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// executer des actions si demandees
|
|
|
|
|
fabrique_executer_script('pre_copie', $data, $contexte_scripts);
|
|
|
|
@ -247,10 +250,10 @@ function formulaires_fabriquer_plugin_traiter_dist(){
|
|
|
|
|
// il vaut mieux quitter en indiquant une erreur
|
|
|
|
|
if (is_dir($_destination_ancien_plugin)) {
|
|
|
|
|
fabrique_remettre_contexte($data);
|
|
|
|
|
return array(
|
|
|
|
|
'editable'=>'oui',
|
|
|
|
|
'message_erreur' => _T('fabrique:erreur_suppression_sauvegarde', array('dir'=>$_destination_ancien_plugin))
|
|
|
|
|
);
|
|
|
|
|
return [
|
|
|
|
|
'editable' => 'oui',
|
|
|
|
|
'message_erreur' => _T('fabrique:erreur_suppression_sauvegarde', ['dir' => $_destination_ancien_plugin])
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (is_dir($_destination_plugin)) {
|
|
|
|
@ -258,10 +261,10 @@ function formulaires_fabriquer_plugin_traiter_dist(){
|
|
|
|
|
if (!@rename($_destination_plugin, $_destination_ancien_plugin)) {
|
|
|
|
|
// une erreur sur le rename signifie qu'on a pas les droits suffisants sur $_destination_plugin
|
|
|
|
|
fabrique_remettre_contexte($data);
|
|
|
|
|
return array(
|
|
|
|
|
'editable'=>'oui',
|
|
|
|
|
'message_erreur' => _T('fabrique:erreur_copie_sauvegarde', array('dir'=>$_destination_plugin))
|
|
|
|
|
);
|
|
|
|
|
return [
|
|
|
|
|
'editable' => 'oui',
|
|
|
|
|
'message_erreur' => _T('fabrique:erreur_copie_sauvegarde', ['dir' => $_destination_plugin])
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (is_dir($_destination_plugin)) {
|
|
|
|
@ -295,15 +298,15 @@ function formulaires_fabriquer_plugin_traiter_dist(){
|
|
|
|
|
// on nettoie les saisies checkbox de vue_liens qui peuvent ne rien envoyer
|
|
|
|
|
// on nettoie une eventuelle table ayant servi a pre-remplir l'objet
|
|
|
|
|
foreach ($data['objets'] as $c => $o) {
|
|
|
|
|
if (!isset($o['vue_liens']) OR !is_array($o['vue_liens'])) {
|
|
|
|
|
$o['vue_liens'] = array();
|
|
|
|
|
if (!isset($o['vue_liens']) or !is_array($o['vue_liens'])) {
|
|
|
|
|
$o['vue_liens'] = [];
|
|
|
|
|
}
|
|
|
|
|
unset($data['objets'][$c]['renseigner_avec_table']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// cas particulier data (+images) pour l'export.
|
|
|
|
|
fabriquer_fichier("fabrique_prefixe.php", array_merge($data, array('data'=>array_merge($data, array('images' => $images)))));
|
|
|
|
|
fabriquer_fichier('fabrique_prefixe.php', array_merge($data, ['data' => array_merge($data, ['images' => $images])]));
|
|
|
|
|
fabrique_sauvegarde_tournante_export($destination_plugin . "fabrique_$prefixe.php", $destination_backup);
|
|
|
|
|
|
|
|
|
|
// pour tous les autres, on ajoute des informations dans notre tableau de données
|
|
|
|
@ -317,48 +320,46 @@ function formulaires_fabriquer_plugin_traiter_dist(){
|
|
|
|
|
|
|
|
|
|
// creer le paquet.xml
|
|
|
|
|
// en declarant tous les fichiers necessaires
|
|
|
|
|
$fichiers_coches = isset($data['paquet']['fichiers']) ? $data['paquet']['fichiers'] : array();
|
|
|
|
|
$fichiers_coches = isset($data['paquet']['fichiers']) ? $data['paquet']['fichiers'] : [];
|
|
|
|
|
$data['paquet']['fichiers'] = $fichiers;
|
|
|
|
|
fabriquer_fichier("paquet.xml", $data);
|
|
|
|
|
fabriquer_fichier('paquet.xml', $data);
|
|
|
|
|
// on remet ce qu'avait saisi l'utilisateur
|
|
|
|
|
$data['paquet']['fichiers'] = $fichiers_coches;
|
|
|
|
|
|
|
|
|
|
// creer la langue du paquet.
|
|
|
|
|
fabriquer_fichier("lang/paquet-prefixe_fr.php", $data);
|
|
|
|
|
fabriquer_fichier('lang/paquet-prefixe_fr.php', $data);
|
|
|
|
|
|
|
|
|
|
// creer la langue du plugin
|
|
|
|
|
fabriquer_fichier("lang/prefixe_fr.php", $data);
|
|
|
|
|
fabriquer_fichier('lang/prefixe_fr.php', $data);
|
|
|
|
|
|
|
|
|
|
// creer le formulaire de configuration
|
|
|
|
|
if ($paquet['formulaire_config']) {
|
|
|
|
|
// creer le squelette d'appel du formulaire
|
|
|
|
|
fabriquer_fichier("prive/squelettes/contenu/configurer_prefixe.html", $data);
|
|
|
|
|
fabriquer_fichier('prive/squelettes/contenu/configurer_prefixe.html', $data);
|
|
|
|
|
|
|
|
|
|
// creer le formulaire de config (simple, type CFG avec un champ d'exemple)
|
|
|
|
|
fabriquer_fichier("formulaires/configurer_prefixe.html", $data);
|
|
|
|
|
fabriquer_fichier('formulaires/configurer_prefixe.html', $data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// creer le fichier d'administrations
|
|
|
|
|
if ($paquet['administrations'] or count($data['objets'])) {
|
|
|
|
|
fabriquer_fichier("prefixe_administrations.php", $data);
|
|
|
|
|
fabriquer_fichier('prefixe_administrations.php', $data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// creer le fichier d'options, de fonctions, autorisations et de pipelines
|
|
|
|
|
foreach($fichiers as $fichier) {
|
|
|
|
|
foreach ($fichiers as $fichier) {
|
|
|
|
|
fabriquer_fichier("prefixe_$fichier.php", $data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// gerer plus specifiquement les objets
|
|
|
|
|
if (count($data['objets'])) {
|
|
|
|
|
|
|
|
|
|
// creer le fichier de declaration de tables SQL
|
|
|
|
|
fabriquer_fichier("base/prefixe.php", $data);
|
|
|
|
|
fabriquer_fichier('base/prefixe.php', $data);
|
|
|
|
|
|
|
|
|
|
// pour chaque objet
|
|
|
|
|
foreach ($data['objets'] as $c => $objet) {
|
|
|
|
|
|
|
|
|
|
// des raccourcis de plus pour les squelettes specifiques aux objets
|
|
|
|
|
$data['objet'] = $objet;
|
|
|
|
|
$data['id_objet'] = $objet['id_objet'];
|
|
|
|
@ -371,68 +372,68 @@ function formulaires_fabriquer_plugin_traiter_dist(){
|
|
|
|
|
$data['parent'] = $objet['parent'];
|
|
|
|
|
|
|
|
|
|
// creer les langues
|
|
|
|
|
fabriquer_fichier("lang/objet_fr.php", $data);
|
|
|
|
|
fabriquer_fichier('lang/objet_fr.php', $data);
|
|
|
|
|
|
|
|
|
|
// créer le formulaire d'edition
|
|
|
|
|
fabriquer_fichier("formulaires/editer_objet.html", $data);
|
|
|
|
|
fabriquer_fichier("formulaires/editer_objet.php", $data);
|
|
|
|
|
fabriquer_fichier('formulaires/editer_objet.html', $data);
|
|
|
|
|
fabriquer_fichier('formulaires/editer_objet.php', $data);
|
|
|
|
|
|
|
|
|
|
// créer la vue du contenu d'un objet
|
|
|
|
|
fabriquer_fichier("prive/objets/contenu/objet.html", $data);
|
|
|
|
|
fabriquer_fichier('prive/objets/contenu/objet.html', $data);
|
|
|
|
|
|
|
|
|
|
// créer la liste d'un objet
|
|
|
|
|
fabriquer_fichier("prive/objets/liste/objets.html", $data);
|
|
|
|
|
fabriquer_fichier('prive/objets/liste/objets.html', $data);
|
|
|
|
|
|
|
|
|
|
// appel du formulaire d'édition, si liens ou parenté directe autre que rubrique
|
|
|
|
|
if (option_presente($objet, 'vue_liens') or option_presente($objet, 'liaison_directe')) {
|
|
|
|
|
fabriquer_fichier("prive/squelettes/contenu/objet_edit.html", $data);
|
|
|
|
|
fabriquer_fichier('prive/squelettes/contenu/objet_edit.html', $data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// si parenté autre que rubrique, créer des squelettes de hiérarchie
|
|
|
|
|
if (option_presente($objet, 'liaison_directe')) {
|
|
|
|
|
fabriquer_fichier("prive/squelettes/hierarchie/objet.html", $data);
|
|
|
|
|
fabriquer_fichier("prive/squelettes/hierarchie/objet_edit.html", $data);
|
|
|
|
|
fabriquer_fichier('prive/squelettes/hierarchie/objet.html', $data);
|
|
|
|
|
fabriquer_fichier('prive/squelettes/hierarchie/objet_edit.html', $data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// s'il a des enfants connus ici, créer le fichier d'info pour avoir le nombre d'enfants affichés
|
|
|
|
|
if (fabrique_objets_enfants_directs($objet, $objets)) {
|
|
|
|
|
fabriquer_fichier("prive/objets/infos/objet.html", $data);
|
|
|
|
|
fabriquer_fichier('prive/objets/infos/objet.html', $data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// créer les listes de liaison
|
|
|
|
|
if (option_presente($objet, 'vue_liens')) {
|
|
|
|
|
fabriquer_fichier("prive/objets/liste/objets_lies.html", $data);
|
|
|
|
|
fabriquer_fichier("prive/objets/liste/objets_lies_fonctions.php", $data); // pff
|
|
|
|
|
fabriquer_fichier("prive/objets/liste/objets_associer.html", $data);
|
|
|
|
|
fabriquer_fichier("prive/objets/liste/objets_associer_fonctions.php", $data); // pff
|
|
|
|
|
fabriquer_fichier('prive/objets/liste/objets_lies.html', $data);
|
|
|
|
|
fabriquer_fichier('prive/objets/liste/objets_lies_fonctions.php', $data); // pff
|
|
|
|
|
fabriquer_fichier('prive/objets/liste/objets_associer.html', $data);
|
|
|
|
|
fabriquer_fichier('prive/objets/liste/objets_associer_fonctions.php', $data); // pff
|
|
|
|
|
|
|
|
|
|
// la meme chose avec des roles s'il y en a
|
|
|
|
|
if (option_presente($objet, 'roles')) {
|
|
|
|
|
fabriquer_fichier("prive/objets/liste/objets_roles_lies.html", $data);
|
|
|
|
|
fabriquer_fichier("prive/objets/liste/objets_roles_lies_fonctions.php", $data); // pff
|
|
|
|
|
fabriquer_fichier("prive/objets/liste/objets_roles_associer.html", $data);
|
|
|
|
|
fabriquer_fichier("prive/objets/liste/objets_roles_associer_fonctions.php", $data); // pff
|
|
|
|
|
fabriquer_fichier('prive/objets/liste/objets_roles_lies.html', $data);
|
|
|
|
|
fabriquer_fichier('prive/objets/liste/objets_roles_lies_fonctions.php', $data); // pff
|
|
|
|
|
fabriquer_fichier('prive/objets/liste/objets_roles_associer.html', $data);
|
|
|
|
|
fabriquer_fichier('prive/objets/liste/objets_roles_associer_fonctions.php', $data); // pff
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// lister aussi les liaisons sur la vue de cet objet
|
|
|
|
|
if (option_presente($objet, 'afficher_liens')) {
|
|
|
|
|
fabriquer_fichier("prive/objets/liste/\objets_lies_objet.html", $data);
|
|
|
|
|
fabriquer_fichier("prive/squelettes/contenu/objet.html", $data); // fichier habituellement échafaudé
|
|
|
|
|
fabriquer_fichier('prive/objets/liste/\objets_lies_objet.html', $data);
|
|
|
|
|
fabriquer_fichier('prive/squelettes/contenu/objet.html', $data); // fichier habituellement échafaudé
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// si traductions demandees, creer le fichier de pre-chargement
|
|
|
|
|
if (champ_present($objet, 'id_trad')) {
|
|
|
|
|
fabriquer_fichier("inc/precharger_objet.php", $data);
|
|
|
|
|
fabriquer_fichier('inc/precharger_objet.php', $data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// si inclusion dans plan du site
|
|
|
|
|
if (champ_present($objet, 'id_rubrique') and option_presente($objet, 'plan')) {
|
|
|
|
|
fabriquer_fichier("prive/squelettes/inclure/plan-objets.html", $data);
|
|
|
|
|
fabriquer_fichier('prive/squelettes/inclure/plan-objets.html', $data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// fichiers demandés explicitement (échafaudés normalement par SPIP ou autres spécifiques)
|
|
|
|
|
if (isset($objet['fichiers']) AND is_array($objet['fichiers'])) {
|
|
|
|
|
if (isset($objet['fichiers']) and is_array($objet['fichiers'])) {
|
|
|
|
|
foreach ($objet['fichiers'] as $type => $fichiers) {
|
|
|
|
|
// type : echafaudages | explicites
|
|
|
|
|
if (is_array($fichiers)) {
|
|
|
|
@ -457,15 +458,14 @@ function formulaires_fabriquer_plugin_traiter_dist(){
|
|
|
|
|
|
|
|
|
|
// Si l'on n'a pas de statut pour cet objet, proposer un bouton de suppression et l'action correspondante.
|
|
|
|
|
if (!champ_present($objet, 'statut')) {
|
|
|
|
|
fabriquer_fichier("action/supprimer_objet.php", $data);
|
|
|
|
|
fabriquer_fichier('action/supprimer_objet.php', $data);
|
|
|
|
|
// être certain d'avoir ce fichier (échafaudé)
|
|
|
|
|
fabriquer_fichier("prive/objets/infos/objet.html", $data);
|
|
|
|
|
fabriquer_fichier('prive/objets/infos/objet.html', $data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unset($data['objet'], $data['id_objet'], $data['type'], $data['table']);
|
|
|
|
|
unset($data['mobjet'], $data['lobjet'], $data['mtype'], $data['mid_objet']);
|
|
|
|
|
unset($data['objet'], $data['id_objet'], $data['type'], $data['table']);
|
|
|
|
|
unset($data['mobjet'], $data['lobjet'], $data['mtype'], $data['mid_objet']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// creer les images
|
|
|
|
@ -489,9 +489,9 @@ function formulaires_fabriquer_plugin_traiter_dist(){
|
|
|
|
|
}
|
|
|
|
|
fabriquer_miniatures($prefixe, $logo_objet_base, $obj, [32]);
|
|
|
|
|
$i_precedent = $logo_objet_base;
|
|
|
|
|
foreach (array(32, 24, 16, 12) as $taille) {
|
|
|
|
|
foreach ([32, 24, 16, 12] as $taille) {
|
|
|
|
|
if (
|
|
|
|
|
(isset($image['logo'][$taille]) AND $i = $image['logo'][$taille]['fichier'])
|
|
|
|
|
(isset($image['logo'][$taille]) and $i = $image['logo'][$taille]['fichier'])
|
|
|
|
|
or ($i = $i_precedent)
|
|
|
|
|
) {
|
|
|
|
|
$i_precedent = $i; // privilegier l'image juste plus grande que la precedente
|
|
|
|
@ -511,8 +511,11 @@ function formulaires_fabriquer_plugin_traiter_dist(){
|
|
|
|
|
// supprimer tous les fichiers .ok des sous-répertoires de destination
|
|
|
|
|
$fichiers =
|
|
|
|
|
new RegexIterator(
|
|
|
|
|
new RecursiveIteratorIterator(
|
|
|
|
|
new RecursiveDirectoryIterator($destination . $prefixe)), '/[.]ok$/');
|
|
|
|
|
new RecursiveIteratorIterator(
|
|
|
|
|
new RecursiveDirectoryIterator($destination . $prefixe)
|
|
|
|
|
),
|
|
|
|
|
'/[.]ok$/'
|
|
|
|
|
);
|
|
|
|
|
foreach ($fichiers as $f) {
|
|
|
|
|
supprimer_fichier((string)$f);
|
|
|
|
|
}
|
|
|
|
@ -535,15 +538,15 @@ function formulaires_fabriquer_plugin_traiter_dist(){
|
|
|
|
|
|
|
|
|
|
// indiquer qu'on peut creer le repertoire dans plugins.
|
|
|
|
|
if (!is_writable(_DIR_PLUGINS . rtrim(FABRIQUE_DESTINATION_PLUGINS, '/'))) {
|
|
|
|
|
set_request("message_info", _T('fabrique:repertoire_plugin_fabrique', array(
|
|
|
|
|
set_request('message_info', _T('fabrique:repertoire_plugin_fabrique', [
|
|
|
|
|
'dir' => rtrim(FABRIQUE_DESTINATION_PLUGINS, '/'),
|
|
|
|
|
'dir_cache' => rtrim(FABRIQUE_DESTINATION_CACHE, '/'))));
|
|
|
|
|
'dir_cache' => rtrim(FABRIQUE_DESTINATION_CACHE, '/')]));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$res = array(
|
|
|
|
|
'editable'=>'oui',
|
|
|
|
|
'message_ok' => _T('fabrique:plugin_cree_succes_dans', array('dir'=>$destination_plugin))
|
|
|
|
|
);
|
|
|
|
|
$res = [
|
|
|
|
|
'editable' => 'oui',
|
|
|
|
|
'message_ok' => _T('fabrique:plugin_cree_succes_dans', ['dir' => $destination_plugin])
|
|
|
|
|
];
|
|
|
|
|
return $res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -558,15 +561,15 @@ function formulaires_fabriquer_plugin_traiter_dist(){
|
|
|
|
|
* Environnement du calcul
|
|
|
|
|
**/
|
|
|
|
|
function fabriquer_fichier($chemin, $data) {
|
|
|
|
|
static $reps = array(); // repertoire de destination deja crees.
|
|
|
|
|
static $chemins = array(); // fichiers sources deja utilises
|
|
|
|
|
static $reps = []; // repertoire de destination deja crees.
|
|
|
|
|
static $chemins = []; // fichiers sources deja utilises
|
|
|
|
|
// retrouver la destination de copie des fichiers
|
|
|
|
|
$destination = fabrique_destination();
|
|
|
|
|
$destination .= $data['paquet']['prefixe'] . '/';
|
|
|
|
|
|
|
|
|
|
// on retrouve le nom du fichier et la base du chemin de destination
|
|
|
|
|
$dest = explode('/', $chemin);
|
|
|
|
|
$chemin = str_replace("\o", "o", $chemin); // enlever l'échappement \objet
|
|
|
|
|
$chemin = str_replace('\o', 'o', $chemin); // enlever l'échappement \objet
|
|
|
|
|
$nom = array_pop($dest);
|
|
|
|
|
$chemin_dest = implode('/', $dest);
|
|
|
|
|
|
|
|
|
@ -580,18 +583,18 @@ function fabriquer_fichier($chemin, $data) {
|
|
|
|
|
// 'prefixe' => $prefixe.
|
|
|
|
|
// 'objet' => $objet.
|
|
|
|
|
// mais on conserve si '\objets'
|
|
|
|
|
$nom = str_replace("\o", "\1o\\", $nom);
|
|
|
|
|
$nom = str_replace('\o', "\1o\\", $nom);
|
|
|
|
|
$nom = str_replace('prefixe', $data['paquet']['prefixe'], $nom);
|
|
|
|
|
if (isset($data['objet'])) {
|
|
|
|
|
$nom = str_replace('objets', $data['objet']['lobjet'], $nom);
|
|
|
|
|
$nom = str_replace('objet', $data['objet']['type'], $nom);
|
|
|
|
|
$nom = str_replace('objets', $data['objet']['lobjet'], $nom);
|
|
|
|
|
$nom = str_replace('objet', $data['objet']['type'], $nom);
|
|
|
|
|
}
|
|
|
|
|
$nom = str_replace("\1o\\", "o", $nom);
|
|
|
|
|
$nom = str_replace("\1o\\", 'o', $nom);
|
|
|
|
|
|
|
|
|
|
// calcul du squelette et copie a destination du contenu.
|
|
|
|
|
$contenu = recuperer_fond(FABRIQUE_SKEL_SOURCE . $chemin, $data);
|
|
|
|
|
// Enlever les espaces de fins de ligne et toujours finir un fichier avec un saut de ligne
|
|
|
|
|
$contenu = str_replace(", \n", ",\n", str_replace("\n \n", "\n\n", str_replace("} \n", "}\n", str_replace("; \n", ";\n", $contenu))))."\n";
|
|
|
|
|
$contenu = str_replace(", \n", ",\n", str_replace("\n \n", "\n\n", str_replace("} \n", "}\n", str_replace("; \n", ";\n", $contenu)))) . "\n";
|
|
|
|
|
|
|
|
|
|
ecrire_fichier($destination . $chemin_dest . '/' . $nom, $contenu);
|
|
|
|
|
}
|
|
|
|
@ -643,11 +646,10 @@ function fabriquer_repertoire_themes_images($prefixe) {
|
|
|
|
|
// creer une fois l'arborescence de destination
|
|
|
|
|
static $chemin = false;
|
|
|
|
|
if (!$chemin) {
|
|
|
|
|
$chemin = "prive/themes/spip/images";
|
|
|
|
|
$chemin = 'prive/themes/spip/images';
|
|
|
|
|
sous_repertoire_complet($destination . $chemin);
|
|
|
|
|
}
|
|
|
|
|
return $destination . $chemin;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Prépare une image SVG dont l'adresse est donnée,
|
|
|
|
@ -679,7 +681,7 @@ function fabriquer_miniature_svg($prefixe, $src, $nom, $taille = 0, $specifique
|
|
|
|
|
} else {
|
|
|
|
|
$nom = "$nom-xx.svg";
|
|
|
|
|
}
|
|
|
|
|
ecrire_fichier( "$destination/$nom", $contenu);
|
|
|
|
|
ecrire_fichier("$destination/$nom", $contenu);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -715,8 +717,8 @@ function fabriquer_miniature_png($prefixe, $src, $nom, $taille = 128, $variante
|
|
|
|
|
$src_img = array_shift($src_img);
|
|
|
|
|
$contenu = spip_file_get_contents($src_img);
|
|
|
|
|
if ($contenu) {
|
|
|
|
|
$nom = $nom . ($variante ? "-$variante" : ''). "-$taille.png";
|
|
|
|
|
ecrire_fichier( "$destination/$nom", $contenu);
|
|
|
|
|
$nom = $nom . ($variante ? "-$variante" : '') . "-$taille.png";
|
|
|
|
|
ecrire_fichier("$destination/$nom", $contenu);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -731,8 +733,8 @@ function fabriquer_miniature_png($prefixe, $src, $nom, $taille = 128, $variante
|
|
|
|
|
* Liste des fichiers indispensables au plugin (et ceux qui étaient déjà demandés)
|
|
|
|
|
**/
|
|
|
|
|
function fabrique_fichiers_paquets($data) {
|
|
|
|
|
$fichiers = array();
|
|
|
|
|
if (isset($data['paquet']['fichiers']) AND is_array($data['paquet']['fichiers'])) {
|
|
|
|
|
$fichiers = [];
|
|
|
|
|
if (isset($data['paquet']['fichiers']) and is_array($data['paquet']['fichiers'])) {
|
|
|
|
|
$fichiers = $data['paquet']['fichiers'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -742,10 +744,12 @@ function fabrique_fichiers_paquets($data) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!in_array('pipelines', $fichiers)) {
|
|
|
|
|
if (fabrique_necessite_pipeline($data['objets'], 'optimiser_base_disparus')
|
|
|
|
|
OR fabrique_necessite_pipeline($data['objets'], 'affiche_enfants')
|
|
|
|
|
OR fabrique_necessite_pipeline($data['objets'], 'affiche_auteurs_interventions')
|
|
|
|
|
OR fabrique_necessite_pipeline($data['objets'], 'affiche_milieu')) {
|
|
|
|
|
if (
|
|
|
|
|
fabrique_necessite_pipeline($data['objets'], 'optimiser_base_disparus')
|
|
|
|
|
or fabrique_necessite_pipeline($data['objets'], 'affiche_enfants')
|
|
|
|
|
or fabrique_necessite_pipeline($data['objets'], 'affiche_auteurs_interventions')
|
|
|
|
|
or fabrique_necessite_pipeline($data['objets'], 'affiche_milieu')
|
|
|
|
|
) {
|
|
|
|
|
$fichiers[] = 'pipelines';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -775,7 +779,7 @@ function fabrique_remettre_contexte($data) {
|
|
|
|
|
// on reintroduit le contexte complet, parce que l'erreur ne repasse pas dans charger() dans ce cas.
|
|
|
|
|
$data = fabrique_completer_contexte_images($data); // liste des fichiers images presents (pour paquet.xml)
|
|
|
|
|
$data = fabrique_completer_contexte($data); // raccourcis
|
|
|
|
|
foreach($data as $nom => $valeur) {
|
|
|
|
|
foreach ($data as $nom => $valeur) {
|
|
|
|
|
set_request($nom, $valeur);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -796,12 +800,13 @@ function fabrique_completer_contexte($data) {
|
|
|
|
|
$data['prefixe'] = $data['paquet']['prefixe'];
|
|
|
|
|
$data['mprefixe'] = strtoupper($data['paquet']['prefixe']); // m = majuscule
|
|
|
|
|
$data['exemples'] = $data['paquet']['exemples'];
|
|
|
|
|
if (!is_array($data['objets'])) $data['objets'] = array();
|
|
|
|
|
$data['les_objets'] = $data['les_types'] = $data['les_id_objets'] = array();
|
|
|
|
|
foreach( $data['objets'] as $c => $o ) {
|
|
|
|
|
if (!is_array($data['objets'])) { $data['objets'] = [];
|
|
|
|
|
}
|
|
|
|
|
$data['les_objets'] = $data['les_types'] = $data['les_id_objets'] = [];
|
|
|
|
|
foreach ($data['objets'] as $c => $o) {
|
|
|
|
|
// quelques raccourcis
|
|
|
|
|
if (isset($o['table']) and $o['table']) {
|
|
|
|
|
$data['objets'][$c]['objets_surnoms'] = array();
|
|
|
|
|
$data['objets'][$c]['objets_surnoms'] = [];
|
|
|
|
|
|
|
|
|
|
// si la table est different de spip_xxs
|
|
|
|
|
// ou si elle possede des espaces spip_xx_yys
|
|
|
|
@ -847,7 +852,7 @@ function fabrique_completer_contexte($data) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// indiquer les parentés
|
|
|
|
|
foreach($data['objets'] as $c => $o) {
|
|
|
|
|
foreach ($data['objets'] as $c => $o) {
|
|
|
|
|
$data['objets'][$c]['parent'] = fabrique_parent($o, $data['objets']);
|
|
|
|
|
}
|
|
|
|
|
// fabrique_lister_tables() apres avoir ajoute les infos en plus sur les objets
|
|
|
|
@ -874,27 +879,27 @@ function fabrique_completer_contexte_images($data) {
|
|
|
|
|
// en dehors des donnees postees
|
|
|
|
|
// pour ne pas surcharger le formulaire
|
|
|
|
|
// et poster à chaque fois les images.
|
|
|
|
|
$images = array(
|
|
|
|
|
'paquet' => array(
|
|
|
|
|
'logo' => array(
|
|
|
|
|
0 => array(
|
|
|
|
|
$images = [
|
|
|
|
|
'paquet' => [
|
|
|
|
|
'logo' => [
|
|
|
|
|
0 => [
|
|
|
|
|
'fichier' => '',
|
|
|
|
|
'extension' => '',
|
|
|
|
|
'contenu' => '',
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
'objets' => array()
|
|
|
|
|
);
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
],
|
|
|
|
|
'objets' => []
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// On initialise la session image si elle est vide
|
|
|
|
|
if (is_null($fabrique_images = session_get(FABRIQUE_ID_IMAGES)) OR !is_array($fabrique_images)){
|
|
|
|
|
if (is_null($fabrique_images = session_get(FABRIQUE_ID_IMAGES)) or !is_array($fabrique_images)) {
|
|
|
|
|
session_set(FABRIQUE_ID_IMAGES, $images);
|
|
|
|
|
$fabrique_images = array();
|
|
|
|
|
$fabrique_images = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// On merge avec ce que l'on a dans la session
|
|
|
|
|
foreach ($images as $c=>$v) {
|
|
|
|
|
foreach ($images as $c => $v) {
|
|
|
|
|
if (isset($fabrique_images[$c])) {
|
|
|
|
|
$images[$c] = array_merge($images[$c], $fabrique_images[$c]);
|
|
|
|
|
}
|
|
|
|
@ -904,22 +909,22 @@ function fabrique_completer_contexte_images($data) {
|
|
|
|
|
// logo de plugin
|
|
|
|
|
if (isset($images['paquet']['logo'][0]['fichier']) and $f = $images['paquet']['logo'][0]['fichier']) {
|
|
|
|
|
if (!isset($data['paquet']['logo']) or !is_array($data['paquet']['logo'])) {
|
|
|
|
|
$data['paquet']['logo'] = array();
|
|
|
|
|
$data['paquet']['logo'] = [];
|
|
|
|
|
}
|
|
|
|
|
if (!isset($data['paquet']['logo'][0]) or !is_array($data['paquet']['logo'][0])) {
|
|
|
|
|
$data['paquet']['logo'][0] = array();
|
|
|
|
|
$data['paquet']['logo'][0] = [];
|
|
|
|
|
}
|
|
|
|
|
$data['paquet']['logo'][0]['fichier'] = $f;
|
|
|
|
|
}
|
|
|
|
|
// logo des objets
|
|
|
|
|
foreach ($images['objets'] as $c=>$image) {
|
|
|
|
|
foreach (array(0, 32, 24, 16, 12) as $taille) {
|
|
|
|
|
foreach ($images['objets'] as $c => $image) {
|
|
|
|
|
foreach ([0, 32, 24, 16, 12] as $taille) {
|
|
|
|
|
if (isset($image['logo'][$taille]['fichier']) and $f = $image['logo'][$taille]['fichier']) {
|
|
|
|
|
if (!isset($data['objets'][$c]['logo']) or !is_array($data['objets'][$c]['logo'])) {
|
|
|
|
|
$data['objets'][$c]['logo'] = array();
|
|
|
|
|
$data['objets'][$c]['logo'] = [];
|
|
|
|
|
}
|
|
|
|
|
if (!isset($data['objets'][$c]['logo'][$taille]) or !is_array($data['objets'][$c]['logo'][$taille])) {
|
|
|
|
|
$data['objets'][$c]['logo'][$taille] = array();
|
|
|
|
|
$data['objets'][$c]['logo'][$taille] = [];
|
|
|
|
|
}
|
|
|
|
|
$data['objets'][$c]['logo'][$taille]['fichier'] = $f;
|
|
|
|
|
}
|
|
|
|
@ -965,7 +970,7 @@ function fabrique_renseigner_objet($objet) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// prefixer systematiquement de spip_ la table
|
|
|
|
|
if (substr($table_spip,0,5) !== 'spip_') {
|
|
|
|
|
if (substr($table_spip, 0, 5) !== 'spip_') {
|
|
|
|
|
$table_spip = 'spip_' . $table_spip;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -980,7 +985,7 @@ function fabrique_renseigner_objet($objet) {
|
|
|
|
|
// id_rubrique
|
|
|
|
|
if (isset($fields['id_rubrique'])) {
|
|
|
|
|
if (!isset($objet['rubriques'])) {
|
|
|
|
|
$objet['rubriques'] = array();
|
|
|
|
|
$objet['rubriques'] = [];
|
|
|
|
|
}
|
|
|
|
|
if (!in_array('id_rubrique', $objet['rubriques'])) {
|
|
|
|
|
$objet['rubriques'][] = 'id_rubrique';
|
|
|
|
@ -997,7 +1002,7 @@ function fabrique_renseigner_objet($objet) {
|
|
|
|
|
// lang
|
|
|
|
|
if (isset($fields['lang'])) {
|
|
|
|
|
if (!isset($objet['langues'])) {
|
|
|
|
|
$objet['langues'] = array();
|
|
|
|
|
$objet['langues'] = [];
|
|
|
|
|
}
|
|
|
|
|
if (!in_array('lang', $objet['langues'])) {
|
|
|
|
|
$objet['langues'][] = 'lang';
|
|
|
|
@ -1008,7 +1013,7 @@ function fabrique_renseigner_objet($objet) {
|
|
|
|
|
// id_trad
|
|
|
|
|
if (isset($fields['id_trad'])) {
|
|
|
|
|
if (!isset($objet['langues'])) {
|
|
|
|
|
$objet['langues'] = array();
|
|
|
|
|
$objet['langues'] = [];
|
|
|
|
|
}
|
|
|
|
|
if (!in_array('id_trad', $objet['langues'])) {
|
|
|
|
|
$objet['langues'][] = 'id_trad';
|
|
|
|
@ -1036,7 +1041,7 @@ function fabrique_renseigner_objet($objet) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// champ titre
|
|
|
|
|
foreach (array('titre', 'nom') as $titre) {
|
|
|
|
|
foreach ( |