X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=www%2Fplugins-dist%2Fvertebres%2Fpublic%2Fvertebrer.php;fp=www%2Fplugins-dist%2Fvertebres%2Fpublic%2Fvertebrer.php;h=4cca59917ab2b7e6be7b1b63600702c343b6e231;hb=a33c2ba9d919664b3bb0f565f8e9a8b9d8530cdb;hp=0000000000000000000000000000000000000000;hpb=8945248b3d948385798d9aa355c70e7089aca2b3;p=lhc%2Fweb%2Fclavette_www.git diff --git a/www/plugins-dist/vertebres/public/vertebrer.php b/www/plugins-dist/vertebres/public/vertebrer.php new file mode 100644 index 0000000..4cca599 --- /dev/null +++ b/www/plugins-dist/vertebres/public/vertebrer.php @@ -0,0 +1,186 @@ + $t) { + $res .= "\n\t\t[(#TRI{"."$n,$n,ajax})]"; + } + return $res; +} + +// Autant de formulaire que de champs (pour les criteres conditionnels) +// http://doc.spip.org/@vertebrer_form +function vertebrer_form($fields) +{ + $res = ''; + $url = join('|', array_keys($fields)); + $url = "#SELF|\n\t\t\tparametre_url{'$url',''}"; + foreach($fields as $n => $t) { + $s = sql_test_int($t) ? 11 + : (preg_match('/char\s*\((\d)\)/i', $t, $r) ? $r[1] : ''); + + if (!in_array($n, array('date', 'date_redac', 'lang'))){ + $res .= "\n\t\t + [(#ENV{".$n."}|non) + [(#CHEMIN_IMAGE{rechercher-20.png}|balise_img)] + ] +
" + . "
" + . "\n\t\t\t\n\t\t\t[($url|\n\t\t\tform_hidden)]" + . "\n\t\t
"; + } + else + $res .= ""; + } + return $res; +} + +// Autant de criteres conditionnels que de champs + +// http://doc.spip.org/@vertebrer_crit +function vertebrer_crit($v) +{ + $res = ""; + foreach($v as $n => $t) { + if (!in_array($n, array('date', 'date_redac', 'lang', 'recherche','logo'))) + $res .= "\n\t\t{" . $n . " ?}"; + } + return $res; +} + + +// Class CSS en fonction de la parite du numero de ligne. +// Style text-align en fonction du type SQL (numerique ou non). +// Filtre de belle date sur type SQL signalant une date ou une estampille. +// Si une colonne reference une table, ajoute un href sur sa page dynamique +// (il faudrait aller chercher sa def pour ilustrer les jointures en SPIP) + +// http://doc.spip.org/@vertebrer_cell +function vertebrer_cell($fields) +{ + $res = ""; + foreach($fields as $n => $t) { + $texte = "#CHAMP_SQL{".$n."}"; + if (preg_match('/\s+references\s+([\w_]+)/' , $t, $r)) { + $url = "[(#SELF|parametre_url{page,'" . $r[1] . "'})]"; + $texte = "" . $texte . ""; + } + if (sql_test_int($t)) + $s = " style='text-align: right;'"; + else { + $s = ''; + if (sql_test_date($t)) + $texte = "[($texte|affdate_heure)]"; + } + $res .= "\n\t\t$texte"; + } + return $res; +} + +// http://doc.spip.org/@public_vertebrer_dist +function public_vertebrer_dist($desc) +{ + $nom = $desc['table']; + $surnom = $desc['id_table']; + $connexion = $desc['connexion']; + $field = $desc['field']; + $key = $desc['key']; + + $defaut_tri = array_keys($field); + $defaut_tri = reset($defaut_tri); + + //ksort($field); + + $form = vertebrer_form($field); + $crit = vertebrer_crit($field); + $cell = vertebrer_cell($field); + $sort = vertebrer_sort($field,''); + $distant = !$connexion ? '' : "&connect=$connexion"; + + return +"#CACHE{0} + +

[(#GRAND_TOTAL|singulier_ou_pluriel{vertebres:1_donnee,vertebres:nb_donnees})]

+[

(#PAGINATION)

] +
+ + + + + $sort + + + $form + + + + + + $cell + + + + + + + $sort + + +
+

#TRI{'>',#CHEMIN_IMAGE{tri-asc-16.png}|balise_img{up},ajax} #TRI{'<',#CHEMIN_IMAGE{tri-desc-16.png}|balise_img{desc},ajax}

+
#COMPTEUR_BOUCLE
+

#TRI{'>',#CHEMIN_IMAGE{tri-asc-16.png}|balise_img{up},ajax} #TRI{'<',#CHEMIN_IMAGE{tri-desc-16.png}|balise_img{desc},ajax}

+
+ +
+

<:texte_vide:>

+ + + + + $sort + + + $form + + +
+

#TRI{'>',#CHEMIN_IMAGE{tri-asc-16.png}|balise_img{up},ajax} #TRI{'<',#CHEMIN_IMAGE{tri-desc-16.png}|balise_img{desc},ajax}

+
+ +
+"; +} +?>