Changeset 93559 in spip-zone for _plugins_/spipclear/spipclear_fonctions.php
- Timestamp:
- Dec 11, 2015, 4:53:43 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/spipclear/spipclear_fonctions.php
r66886 r93559 1 1 <?php 2 2 3 function affdate_long($date) { 4 return affdate_base($date, 'nom_jour').' '.affdate_base($date, 'entier'); 3 if (!defined('_ECRIRE_INC_VERSION')) { 4 return; 5 } 6 7 /** 8 * Afficher la date au complet. 9 * 10 * @param string $date 11 * 12 * @return string 13 */ 14 function affdate_long($date) { 15 return affdate_base($date, 'nom_jour').' '.affdate_base($date, 'entier'); 16 } 17 18 /** 19 * |me compare un id_auteur avec les auteurs d'un article 20 * et renvoie la valeur booleenne true (vrai) si on trouve une correspondance 21 * utilisation: <div id="forum#ID_FORUM" [(#ID_ARTICLE|me{#ID_AUTEUR}|?{' ', ''})class="me"]>. 22 * 23 * @param int $id_article identifiant de l'article 24 * @param int $id_auteur identifiant de l'auteur 25 * 26 * @return bool true si l'id de l'auteur est celui de l'article sinon false 27 */ 28 function me($id_article, $id_auteur = 0) { 29 static $deja = false; 30 static $auteurs = array(); 31 32 /* en spip 3 auteur_articles est remplacé - adapter la requete */ 33 $table = 'spip_auteurs_articles'; 34 $where = 'id_article'; 35 if ($GLOBALS['meta']['version_installee'] >= '19268') { 36 $table = 'spip_auteurs_liens'; 37 $where = "objet='article' AND id_objet"; 38 } 39 if (!$deja) { 40 $r = spip_query('SELECT id_auteur FROM '.$table.' WHERE '.$where."=$id_article"); 41 while ($row = spip_fetch_array($r)) { 42 $auteurs[] = intval($row['id_auteur']); 43 } 44 $deja = true; 5 45 } 6 46 7 /*** 8 * |me compare un id_auteur avec les auteurs d'un article 9 * et renvoie la valeur booleenne true (vrai) si on trouve une correspondance 10 * utilisation: <div id="forum#ID_FORUM"[(#ID_ARTICLE|me{#ID_AUTEUR}|?{' ', ''})class="me"]> 11 ***/ 12 function me($id_article, $id_auteur = 0) { 13 static $deja = false; 14 static $auteurs = array(); 47 return in_array($id_auteur, $auteurs); 48 } 15 49 16 /* en spip 3 auteur_articles est remplacé - adapter la requete */ 17 $table="spip_auteurs_articles"; 18 $where="id_article"; 19 if ($GLOBALS['meta']['version_installee'] >= '19268') { 20 $table="spip_auteurs_liens"; 21 $where="objet='article' AND id_objet"; 50 /** 51 * lister les themes présents dans plugins/spipclear/themes. 52 * 53 * @return string Liste sous la forme ul/li 54 */ 55 function lister_themes() { 56 $dir = _DIR_PLUGIN_SPIPCLEAR.'themes/'; 57 $dir_perso = find_in_path('squelettes/themes/'); 58 $Treps_themes = array(); 59 $htm = ''; 60 if (is_dir($dir) and $t = @opendir($dir)) { 61 $htm .= '<ul style="height: 350px; overflow: auto; margin: 10px 0; border: 1px solid #ccc; background: #fff;">'; 62 while (($rt = readdir($t)) !== false) { 63 if (is_dir($dir.$rt) and $r = @opendir($dir.$rt) and $rt != '..') { 64 $capture = false; 65 $nom_theme = false; 66 while (($f = readdir($r)) !== false) { 67 // à minima un theme doit avoir un fichier style.css 68 if ($f == 'style.css') { 69 $nom_theme = $rt; 70 } 71 if ($f == 'screenshot.jpg') { 72 $capture = true; 73 } 74 } 75 if ($nom_theme) { 76 $htm .= '<li style="padding-left: 10px; border-bottom: 2px solid #ccc;"><p><a id="'.$nom_theme.'" class="theme" href="#" title="'._T(selectionner_theme).'">'.$nom_theme.'</p>'; 77 if ($capture) { 78 $htm .= '<img src="'._DIR_PLUGIN_SPIPCLEAR.'themes/'.$rt.'/screenshot.jpg" />'; 79 } 80 $htm .= "</a></li>\r\n"; 81 } 82 } 22 83 } 23 if(!$deja) { 24 $r = spip_query("SELECT id_auteur FROM ".$table." WHERE ".$where."=$id_article"); 25 while($row = spip_fetch_array($r)) 26 $auteurs[] = intval($row['id_auteur']); 27 $deja = true; 28 } 29 return in_array($id_auteur, $auteurs); 30 } 31 32 // lister les themes présents dans plugins/spipclear/themes 33 function lister_themes() { 34 $dir = _DIR_PLUGIN_SPIPCLEAR.'themes/'; 35 $dir_perso = find_in_path('squelettes/themes/'); 36 $Treps_themes = array(); 37 $htm = ''; 38 if (is_dir($dir) AND $t = @opendir($dir)) { 39 $htm .= '<ul style="height: 350px; overflow: auto; margin: 10px 0; border: 1px solid #ccc; background: #fff;">'; 40 while (($rt = readdir($t)) !== false) { 41 if (is_dir($dir.$rt) AND $r = @opendir($dir.$rt) AND $rt != '..') { 42 $capture = false; 43 $nom_theme = false; 44 while (($f = readdir($r)) !== false) { 45 // à minima un theme doit avoir un fichier style.css 46 if ($f == 'style.css') $nom_theme = $rt; 47 if ($f == 'screenshot.jpg') $capture = true; 48 } 49 if ($nom_theme) { 50 $htm .= '<li style="padding-left: 10px; border-bottom: 2px solid #ccc;"><p><a id="'. $nom_theme .'" class="theme" href="#" title="'. _T(selectionner_theme) .'">'. $nom_theme .'</p>'; 51 if ($capture) { 52 $htm .= '<img src="'._DIR_PLUGIN_SPIPCLEAR.'themes/'.$rt.'/screenshot.jpg" />'; 53 } 54 $htm .= "</a></li>\r\n"; 55 } 56 } 57 } 58 if (is_dir($dir_perso) AND $t = @opendir($dir_perso)) { 84 if (is_dir($dir_perso) and $t = @opendir($dir_perso)) { 59 85 while (($rt = readdir($t)) !== false) { 60 if (is_dir($dir_perso.$rt) AND $r = @opendir($dir_perso.$rt) AND$rt != '..') {86 if (is_dir($dir_perso.$rt) and $r = @opendir($dir_perso.$rt) and $rt != '..') { 61 87 $capture = false; 62 88 $nom_theme = false; 63 89 while (($f = readdir($r)) !== false) { 64 // à minima un theme doit avoir un fichier style.css 65 if ($f == 'style.css') $nom_theme = $rt; 66 if ($f == 'screenshot.jpg') $capture = true; 90 // à minima un theme doit avoir un fichier style.css 91 if ($f == 'style.css') { 92 $nom_theme = $rt; 93 } 94 if ($f == 'screenshot.jpg') { 95 $capture = true; 96 } 67 97 } 68 98 if ($nom_theme) { 69 $htm .= '<li style="padding-left: 10px; border-bottom: 2px solid #ccc;"><p><a id="'. $nom_theme .'" class="theme" href="#" title="'. _T(selectionner_theme) .'">'. $nom_theme.'</p>';99 $htm .= '<li style="padding-left: 10px; border-bottom: 2px solid #ccc;"><p><a id="'.$nom_theme.'" class="theme" href="#" title="'._T(selectionner_theme).'">'.$nom_theme.'</p>'; 70 100 if ($capture) { 71 101 $htm .= '<img src="'.$dir_perso.$rt.'/screenshot.jpg" />'; … … 77 107 } 78 108 $htm .= '</ul>'; 79 80 return $htm; 81 } 82 ?> 109 } 110 111 return $htm; 112 }
Note: See TracChangeset
for help on using the changeset viewer.