diff --git a/action/crayons_html.php b/action/crayons_html.php index c0b62d6..6edb82c 100644 --- a/action/crayons_html.php +++ b/action/crayons_html.php @@ -31,7 +31,7 @@ function affiche_controleur($class, $c = null) { $regs[] = $class; // A-t-on le droit de crayonner ? - spip_log("autoriser('crayonner', $type, $id, NULL, array('modele'=>$champ)", 'crayons_distant'); + spip_log("autoriser('crayonner', $type, $id, NULL, array('modele'=>$champ)", 'crayons'); if (!autoriser('crayonner', $type, $id, null, array('modele'=>$champ))) { $return['$erreur'] = "$type $id: " . _U('crayons:non_autorise'); } else { @@ -41,6 +41,8 @@ function affiche_controleur($class, $c = null) { or $f = charger_fonction($type, 'controleurs', true) or $f = 'controleur_dist'; + #spip_log("$type:$id:$champ controleur '$f'", 'crayons'); + $f = pipeline('crayons_controleur', array( 'args' => array( 'nomcrayon' => $nomcrayon, @@ -104,8 +106,7 @@ function controleur_dist($regs, $c = null) { $valeur = valeur_colonne_table($type, $champ, $id); - #spip_log("$valeur = valeur_colonne_table($type, $champ, $id);"); - #spip_log($champ); + #spip_log(json_encode($valeur) ." = valeur_colonne_table($type, $champ, $id);", 'crayons'); if ($valeur === false) { return array("$type $id $champ: " . _U('crayons:pas_de_valeur'), 6); @@ -123,6 +124,7 @@ function controleur_dist($regs, $c = null) { } else { $sqltype = colonne_table($type, $champ); + #spip_log("$type $champ sql : ".json_encode($sqltype), 'crayons'); $inmode = crayons_determine_input_mode($type, $champ, $sqltype); // car particulier prioritaire : si la valeur actuelle comporte des retour ligne il faut un mode texte if (preg_match(",[\n\r],", $valeur[$champ]) @@ -154,9 +156,11 @@ function controleur_dist($regs, $c = null) { } } + #spip_log("$type $champ crayon : ".json_encode([$nomcrayon, $valeur, $options, $c]), 'crayons'); $crayon = new Crayon($nomcrayon, $valeur, $options, $c); $inputAttrs['style'] = implode('', $crayon->styles); + #spip_log("$type $champ crayon : controleur : $controleur", 'crayons'); if (!$controleur) { $inputAttrs['style'] .= 'width:' . $crayon->largeur . 'px;' . ($crayon->hauteur ? ' height:' . $crayon->hauteur . 'px;' : ''); diff --git a/inc/crayons.php b/inc/crayons.php index 7d09169..fac14fd 100644 --- a/inc/crayons.php +++ b/inc/crayons.php @@ -221,11 +221,11 @@ function vignette_revision($id, $data, $type, $ref) { if ($data['vignette']) { define('FILE_UPLOAD', true); if (is_numeric($s['id_vignette']) and ($s['id_vignette'] > 0)) { - spip_log('suppression de la vignette'); + spip_log('suppression de la vignette', 'crayons'); // Suppression du document $vignette = sql_getfetsel('fichier', 'spip_documents', 'id_document='.intval($s['id_vignette'])); if (@file_exists($f = get_spip_doc($vignette))) { - spip_log("efface $f"); + spip_log("efface $f", 'crayons'); supprimer_fichier($f); } sql_delete('spip_documents', 'id_document='.intval($s['id_vignette'])); @@ -263,7 +263,7 @@ function vignette_revision($id, $data, $type, $ref) { // Suppression du document $vignette = sql_getfetsel('fichier', 'spip_documents', 'id_document='.intval($s['id_vignette'])); if (@file_exists($f = get_spip_doc($vignette))) { - spip_log("efface $f"); + spip_log("efface $f", 'crayons'); supprimer_fichier($f); } sql_delete('spip_documents', 'id_document='.intval($s['id_vignette'])); @@ -384,7 +384,7 @@ function crayons_get_table_name_and_primary($type) { and ($tabid = explode(',', $tabref['key']['PRIMARY KEY']))) { return $types[$type] = array($nom_table, $tabid); } - spip_log('crayons: table ' . $type . ' inconnue'); + spip_log('crayons: table ' . $type . ' inconnue ou sans cle primaire', 'crayons'); return $types[$type] = false; } @@ -419,10 +419,13 @@ function table_where($type, $id, $where_en_tableau = false) { function valeur_colonne_table_dist($type, $col, $id) { + #spip_log("valeur_colonne_table_dist $type $id cols: ".json_encode($col), 'crayons'); // Table introuvable ou sans clé primaire if (!$infos = crayons_get_table_name_and_primary($type)) { + #spip_log("valeur_colonne_table_dist $type $id infos:".json_encode($infos), 'crayons'); return false; } + #spip_log("valeur_colonne_table_dist $type $id infos:".json_encode($infos), 'crayons'); $table = reset($infos); $r = array(); @@ -441,12 +444,22 @@ function valeur_colonne_table_dist($type, $col, $id) { list($distant, $table) = distant_table($type); list($nom_table, $where) = table_where($type, $id); - if ($s = spip_query( - 'SELECT `' . implode($col, '`, `') . - '` FROM ' . $nom_table . ' WHERE ' . $where, - $distant - ) and $t = sql_fetch($s)) { - $r = array_merge($r, $t); + $row = false; + if (include_spip('base/abstract_sql') and function_exists('sql_fetsel')) { + $row = sql_fetsel('`' . implode('`, `', $col).'`', $nom_table, $where, '', '', '', '', $distant); + } + else { + // legacy code + if ($s = spip_query( + 'SELECT `' . implode('`, `', $col) . + '` FROM ' . $nom_table . ' WHERE ' . $where, + $distant + )) { + $row = sql_fetch($s); + } + } + if ($row) { + $r = array_merge($r, $row); } } @@ -571,13 +584,23 @@ function &crayons_get_table($type, &$nom_table) { static $return = array(); static $noms = array(); if (!isset($return[$table])) { - $try = array(table_objet_sql($table), 'spip_'.table_objet($table), 'spip_' . $table . 's', $table . 's', 'spip_' . $table, $table); + $trouver_table = charger_fonction('trouver_table', 'base', true); + $try = array(table_objet_sql($table), 'spip_'.table_objet($table), 'spip_' . $table . 's', $table . 's', 'spip_' . $table, $table); foreach ($try as $nom) { - if ($q = sql_showtable($nom, !$distant, $distant)) { - $noms[$table] = $nom; - $return[$table] = $q; - break; + if ($trouver_table) { + if ($q = $trouver_table($nom, $distant, !$distant)) { + $noms[$table] = $q['table_sql']; + $return[$table] = $q; + } + } + else { + // legacy code + if ($q = sql_showtable($nom, !$distant, $distant)) { + $noms[$table] = $nom; + $return[$table] = $q; + break; + } } } } diff --git a/js/crayons.js b/js/crayons.js index 402467d..6a273aa 100644 --- a/js/crayons.js +++ b/js/crayons.js @@ -83,6 +83,9 @@ $.fn.opencrayon = function(evt, percent) { if (evt && evt.stopPropagation) { evt.stopPropagation(); } + if (evt) { + evt.preventDefault(); + } return this .each(function(){ var $me = $(this); @@ -317,7 +320,6 @@ $.fn.activatecrayon = function(percent) { if (d.erreur > '' || d.$invalides) { crayon - .find('form') .css('opacity', 1.0) .find(".crayon-boutons,.resizehandle") .show() @@ -393,7 +395,7 @@ $.fn.activatecrayon = function(percent) { .find('input:visible:not(:disabled):not([readonly]):first').focus().end() .find("textarea.crayon-active,input.crayon-active[type=text]") .each(function(n){ - // focus pour commencer a taper son texte directement dans le champ + // focus pour commencer a taper son texte directement dans le champ // sur le premier textarea non readonly ni disabled // on essaie de positionner la selection (la saisie) au niveau du clic // ne pas le faire sur un input de [type=file] diff --git a/paquet.xml b/paquet.xml index 2fe58d0..a09d41d 100644 --- a/paquet.xml +++ b/paquet.xml @@ -1,7 +1,7 @@