Changeset 93630 in spip-zone
- Timestamp:
- Dec 13, 2015, 11:59:24 AM (5 years ago)
- Location:
- _core_/plugins/vertebres
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
_core_/plugins/vertebres/public/vertebrer.php
r93300 r93630 22 22 * - tri ascendant et descendant sur chacune des colonnes 23 23 * - critere conditionnel donnant l'extrait correspondant a la colonne en URL 24 * 24 * 25 25 * @package SPIP\Vertebres\Fonctions 26 **/ 27 28 if (!defined("_ECRIRE_INC_VERSION")) return; 26 **/ 27 28 if (!defined("_ECRIRE_INC_VERSION")) { 29 return; 30 } 29 31 30 32 … … 37 39 * @return string 38 40 * Ligne de tableau 39 **/ 40 function vertebrer_sort($fields) 41 { 41 **/ 42 function vertebrer_sort($fields) { 42 43 $res = ''; 43 foreach($fields as $n => $t) { 44 $res .= "\n\t\t<th scope='col'>[(#TRI{"."$n,$n,ajax})]</th>"; 45 } 44 foreach ($fields as $n => $t) { 45 $res .= "\n\t\t<th scope='col'>[(#TRI{" . "$n,$n,ajax})]</th>"; 46 } 47 46 48 return $res; 47 49 } … … 50 52 * Retourne un morceau de squelette pour ajouter des recherches sur chaque champ de la table 51 53 * 52 * Autant de formulaire que de champs (pour les criteres conditionnels) 53 * 54 * Autant de formulaire que de champs (pour les criteres conditionnels) 55 * 54 56 * @param array $fields 55 57 * Liste des champs de la table 56 58 * @return string 57 59 * Ligne de tableau 58 **/ 59 function vertebrer_form($fields) 60 { 60 **/ 61 function vertebrer_form($fields) { 61 62 $res = ''; 62 63 $url = join('|', array_keys($fields)); 63 64 $url = "#SELF|\n\t\t\tparametre_url{'$url',''}"; 64 foreach ($fields as $n => $t) {65 foreach ($fields as $n => $t) { 65 66 $s = sql_test_int($t) ? 11 66 :(preg_match('/char\s*\((\d)\)/i', $t, $r) ? $r[1] : '');67 68 if (!in_array($n, array('date', 'date_redac', 'lang'))) {67 : (preg_match('/char\s*\((\d)\)/i', $t, $r) ? $r[1] : ''); 68 69 if (!in_array($n, array('date', 'date_redac', 'lang'))) { 69 70 $res .= "\n\t\t<td> 70 [(#ENV{" .$n."}|non)71 [(#ENV{" . $n . "}|non) 71 72 <a href='#' onclick=\"jQuery(this).toggle('fast').siblings('form').toggle('fast');return false;\">[(#CHEMIN_IMAGE{rechercher-20.png}|balise_img)]</a> 72 73 ] 73 <form class='[(#ENV{".$n."}|non)none-js]' action='./' method='get'>" 74 . "<div>" 75 . "\n\t\t\t<input name='$n'" 76 . ($s ? " size='$s'" : '') 77 . "value=\"[(#ENV{".$n."}|entites_html)]\"" 78 . " />\n\t\t\t[($url|\n\t\t\tform_hidden)]" 79 . "\n\t\t</div></form></td>"; 80 } 81 else 74 <form class='[(#ENV{" . $n . "}|non)none-js]' action='./' method='get'>" 75 . "<div>" 76 . "\n\t\t\t<input name='$n'" 77 . ($s ? " size='$s'" : '') 78 . "value=\"[(#ENV{" . $n . "}|entites_html)]\"" 79 . " />\n\t\t\t[($url|\n\t\t\tform_hidden)]" 80 . "\n\t\t</div></form></td>"; 81 } else { 82 82 $res .= "<td></td>"; 83 } 83 } 84 } 85 84 86 return $res; 85 87 } … … 89 91 * 90 92 * Autant de criteres conditionnels que de champs 91 * 93 * 92 94 * @param array $fields 93 95 * Liste des champs de la table 94 96 * @return string 95 97 * Critères de boucles 96 **/ 97 function vertebrer_crit($fields) 98 { 98 **/ 99 function vertebrer_crit($fields) { 99 100 $res = ""; 100 foreach($fields as $n => $t) { 101 if (!in_array($n, array('date', 'date_redac', 'lang', 'recherche','logo'))) 102 $res .= "\n\t\t{" . $n . " ?}"; 103 } 101 foreach ($fields as $n => $t) { 102 if (!in_array($n, array('date', 'date_redac', 'lang', 'recherche', 'logo'))) { 103 $res .= "\n\t\t{" . $n . " ?}"; 104 } 105 } 106 104 107 return $res; 105 108 } … … 109 112 * Retourne un morceau de squelette pour afficher le contenu de chaque 110 113 * champ SQL dans une ligne d'un tableau 111 * 114 * 112 115 * Class CSS en fonction de la parité du numero de ligne. 113 116 * Style text-align en fonction du type SQL (numerique ou non). 114 * 117 * 115 118 * Filtre de belle date sur type SQL signalant une date ou une estampillé. 116 119 * 117 120 * Si une colonne référence une table, ajoute un href sur sa page dynamique 118 121 * (il faudrait aller chercher sa def pour ilustrer les jointures en SPIP) 119 * 122 * 120 123 * @param array $fields 121 124 * Liste des champs de la table 122 125 * @return string 123 126 * Ligne de tableau 124 **/ 125 function vertebrer_cell($fields) 126 { 127 **/ 128 function vertebrer_cell($fields) { 127 129 $res = ""; 128 foreach ($fields as $n => $t) {129 $texte = "#CHAMP_SQL{" .$n."}";130 if (preg_match('/\s+references\s+([\w_]+)/' 130 foreach ($fields as $n => $t) { 131 $texte = "#CHAMP_SQL{" . $n . "}"; 132 if (preg_match('/\s+references\s+([\w_]+)/', $t, $r)) { 131 133 $url = "[(#SELF|parametre_url{page,'" . $r[1] . "'})]"; 132 134 $texte = "<a href='$url'>" . $texte . "</a>"; … … 142 144 $res .= "\n\t\t<td$s>$texte</td>"; 143 145 } 146 144 147 return $res; 145 148 } … … 149 152 * table SQL à partir de la description de cette table. 150 153 * 151 * @see base_trouver_table_dist()154 * @see base_trouver_table_dist() 152 155 * @uses vertebrer_form() 153 156 * @uses vertebrer_crit() 154 157 * @uses vertebrer_cell() 155 158 * @uses vertebrer_sort() 156 * 159 * 157 160 * @param array $desc 158 161 * Descrption de la table, telle que retournéer par trouver_table. 159 162 * @return string 160 163 * Contenu du squelette pour la table 161 **/ 162 function public_vertebrer_dist($desc) 163 { 164 **/ 165 function public_vertebrer_dist($desc) { 164 166 $nom = $desc['table']; 165 167 $surnom = $desc['id_table']; … … 180 182 181 183 return 182 "#CACHE{0}184 "#CACHE{0} 183 185 <B1> 184 186 <h2>[(#GRAND_TOTAL|singulier_ou_pluriel{vertebres:1_donnee,vertebres:nb_donnees})]</h2> -
_core_/plugins/vertebres/vertebres_pipelines.php
r93299 r93630 12 12 13 13 /** 14 * Utilisations de pipelines 14 * Utilisations de pipelines 15 15 * 16 16 * @package SPIP\Vertebres\Pipelines 17 **/17 **/ 18 18 19 if (!defined('_ECRIRE_INC_VERSION')) return; 19 if (!defined('_ECRIRE_INC_VERSION')) { 20 return; 21 } 20 22 21 23 if (!defined('_DIR_VERTEBRES')) { 22 24 /** 23 25 * Chemin du répertoire stockant les squelettes calculés des vertèbres 26 * 24 27 * @var string 25 **/28 **/ 26 29 define('_DIR_VERTEBRES', _DIR_CACHE . 'vertebres/'); 27 30 } … … 37 40 * @uses base_trouver_table_dist() 38 41 * @uses public_vertebrer_dist() 39 * 42 * 40 43 * @param array $flux Données du pipeline 41 44 * @return array Données du pipeline … … 47 50 if (!$squelette = $flux['data'] 48 51 AND $fond = $flux['args']['fond'] 49 AND strncmp($fond, 'prive/vertebres:',16)==050 AND $table = substr($fond, 16)52 AND strncmp($fond, 'prive/vertebres:', 16) == 0 53 AND $table = substr($fond, 16) 51 54 AND include_spip('inc/autoriser') 52 AND autoriser('webmestre') )53 {55 AND autoriser('webmestre') 56 ) { 54 57 55 58 $ext = $flux['args']['ext']; … … 59 62 // et si l'on a la permission de l'afficher 60 63 $trouver_table = charger_fonction('trouver_table', 'base'); 61 if ($desc = $trouver_table($table, $connect)) {64 if ($desc = $trouver_table($table, $connect)) { 62 65 $fond = $table; 63 66 $base = _DIR_VERTEBRES . 'table_' . $fond . ".$ext"; … … 72 75 } 73 76 } 74 77 75 78 return $flux; 76 79 }
Note: See TracChangeset
for help on using the changeset viewer.