ebd2f7f2d1e5b765dc360b36f32029cb96327e57
4 * Gestion des recherches de plugins par version ou branche
6 * @plugin SVP pour SPIP
8 * @package SPIP\SVP\Recherche
11 if (!defined("_ECRIRE_INC_VERSION")) {
16 * Construit le WHERE d'une requête SQL de selection des plugins ou paquets
17 * compatibles avec une version ou une branche de spip.
19 * Cette fonction est appelée par le critère {compatible_spip}
21 * @used-by svp_compter()
22 * @used-by critere_compatible_spip_dist()
24 * @param string $version
25 * Numéro de version de SPIP, tel que 2.0.8
26 * @param string $table
27 * Table d'application ou son alias SQL
29 * Opérateur de comparaison, tel que '>' ou '='
31 * Expression where de la requête SQL
33 function inc_where_compatible_spip($version = '', $table, $op) {
35 // le critere s'applique a une VERSION (1.9.2, 2.0.8, ...)
36 if (count(explode('.', $version)) == 3) {
37 $min = 'SUBSTRING_INDEX(' . $table . '.compatibilite_spip, \';\', 1)';
38 $max = 'SUBSTRING_INDEX(' . $table . '.compatibilite_spip, \';\', -1)';
40 $where = 'CASE WHEN ' . $min . ' = \'\'
41 OR ' . $min . ' = \'[\'
42 THEN \'1.9.0\' <= \'' . $version . '\'
43 ELSE TRIM(LEADING \'[\' FROM ' . $min . ') <= \'' . $version . '\'
46 CASE WHEN ' . $max . ' = \'\'
47 OR ' . $max . ' = \']\'
48 THEN \'99.99.99\' >= \'' . $version . '\'
49 WHEN ' . $max . ' = \')\'
50 OR ' . $max . ' = \'[\'
51 THEN \'99.99.99\' > \'' . $version . '\'
52 WHEN RIGHT(' . $max . ', 1) = \')\'
53 OR RIGHT(' . $max . ', 1) = \'[\'
54 THEN LEFT(' . $max . ', LENGTH(' . $max . ') - 1) > \'' . $version . '\'
55 ELSE LEFT(' . $max . ', LENGTH(' . $max . ') - 1) >= \'' . $version . '\'
57 } // le critere s'applique a une BRANCHE (1.9, 2.0, ...)
58 elseif (count(explode('.', $version)) == 2) {
59 $where = 'LOCATE(\'' . $version . '\', ' . $table . '.branches_spip) ' . $op . ' 0';
60 } // le critere est vide ou mal specifie