Changeset 47997 in spip-zone
- Timestamp:
- May 22, 2011, 2:12:51 PM (10 years ago)
- Location:
- _plugins_/spip_proprietaire
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/spip_proprietaire/balise/proprietaire.php
r45310 r47997 3 3 4 4 function balise_PROPRIETAIRE($p) { 5 spip_proprio_ proprietaire_texte();6 5 spip_proprio_charger_toutes_les_langues(); 6 return calculer_balise_dynamique($p,PROPRIETAIRE,array()); 7 7 } 8 8 … … 10 10 include_spip('inc/presentation'); 11 11 $conf = spip_proprio_recuperer_config(); 12 static $spip_proprio_no_config = false; 13 if (is_null($conf)) { 14 include_spip('inc/autoriser'); 15 if ($spip_proprio_no_config===false && autoriser('ecrire')) { 16 $div = propre( _T('proprietaire:pas_config', array( 17 'url_config' => generer_url_ecrire('spip_proprio') 18 )) ); 19 echo $div; 20 $spip_proprio_no_config = true; 21 } 22 return; 23 } 24 12 25 $nb = ' '; 13 26 $div = ''; 14 27 15 if (isset($conf[$wich])) $div = $conf[$wich];28 if (isset($conf[$wich])) $div = $conf[$wich]; 16 29 else switch($wich){ 17 30 case 'footer': … … 19 32 $nom_site = typo($conf['proprietaire_nom']) 20 33 .( strlen($conf['adresse_pays']) ? ' - '.$conf['adresse_pays'] : ''); 21 if ($wich == 'footer') $div .= '<small>';34 if ($wich == 'footer') $div .= '<small>'; 22 35 $div = _T('proprietaire:copyright_info', array( 23 36 'nom_site' => $nom_site, 24 37 'date' => ( strlen($conf['copyright_annee']) ? $conf['copyright_annee'].'-' : '').date("Y"), 25 38 )); 26 if (strlen($conf['copyright_complement']))39 if (strlen($conf['copyright_complement'])) 27 40 $div .= $separator.typo($conf['copyright_complement']); 28 if (strlen($conf['copyright_comment']))41 if (strlen($conf['copyright_comment'])) 29 42 $div .= $separator.typo($conf['copyright_comment']); 30 if ($wich == 'footer') $div .= '</small>';43 if ($wich == 'footer') $div .= '</small>'; 31 44 break; 32 45 case 'googlemap_string': 33 if ($google = make_google_map_proprietaire($conf)) $div .= $google;46 if ($google = make_google_map_proprietaire($conf)) $div .= $google; 34 47 break; 35 48 case 'vcard' : … … 46 59 'administrateur'=>url_absolue(generer_url_public('carte_visite','type=admin')), 47 60 ); 48 if ( isset($GLOBALS['meta']['email_webmaster']) AND strlen($GLOBALS['meta']['email_webmaster']) )61 if ( isset($GLOBALS['meta']['email_webmaster']) AND strlen($GLOBALS['meta']['email_webmaster']) ) 49 62 $cartes_visite_urls['webmaster'] = url_absolue(generer_url_public('carte_visite','type=webmaster')); 50 63 $div .= propre( _T('proprietaire:carte_visite_info', $cartes_visite_urls) ); … … 58 71 'administrateur'=>url_absolue(generer_url_public('carte_visite','type=admin')), 59 72 ); 60 if ( isset($GLOBALS['meta']['email_webmaster']) AND strlen($GLOBALS['meta']['email_webmaster']) )73 if ( isset($GLOBALS['meta']['email_webmaster']) AND strlen($GLOBALS['meta']['email_webmaster']) ) 61 74 $cartes_visite_urls['webmaster'] = url_absolue(generer_url_public('carte_visite','type=webmaster')); 62 75 $div .= propre( _T('proprietaire:carte_visite_info', $cartes_visite_urls) ); … … 69 82 case 'carte_visite_image' : 70 83 $contexte = $conf; 71 if (strlen($who)){72 if (in_array(trim($who), array('admin', 'administrateur', 'administration')))84 if (strlen($who)){ 85 if (in_array(trim($who), array('admin', 'administrateur', 'administration'))) 73 86 $who = 'admin'; 74 elseif (in_array(trim($who), array('webmaster', 'webmestre')))87 elseif (in_array(trim($who), array('webmaster', 'webmestre'))) 75 88 $who = 'webmaster'; 76 elseif (in_array(trim($who), array('responsable', 'boss', 'chef')))89 elseif (in_array(trim($who), array('responsable', 'boss', 'chef'))) 77 90 $who = 'chef'; 78 91 } 79 92 $contexte['who'] = $who; 80 if ( $wich == 'carte_visite_image' )93 if ( $wich == 'carte_visite_image' ) 81 94 $contexte['type'] = 'image'; 82 95 $div .= recuperer_fond("modeles/carte_visite", $contexte); 83 96 break; 84 97 case 'googlemap' : 85 if (!strlen($who)) $who = 'proprietaire';98 if (!strlen($who)) $who = 'proprietaire'; 86 99 $contexte['googlemap_string'] = make_google_map_proprietaire($conf, $who); 87 100 $div .= recuperer_fond("modeles/noisette_googlemap", $contexte); … … 91 104 $contexte = $conf; 92 105 $contexte['separator'] = $separator; 93 if ($wich == 'logo') $contexte['logo'] = 'oui';106 if ($wich == 'logo') $contexte['logo'] = 'oui'; 94 107 $div .= recuperer_fond("modeles/noisette_proprietaire", $contexte); 95 108 break; -
_plugins_/spip_proprietaire/balise/textes_legaux.php
r40936 r47997 3 3 4 4 function balise_TEXTES_LEGAUX($p) { 5 return calculer_balise_dynamique($p,TEXTES_LEGAUX,array()); 5 spip_proprio_charger_toutes_les_langues(); 6 return calculer_balise_dynamique($p,TEXTES_LEGAUX,array()); 6 7 } 7 8 … … 10 11 include_spip('spip_proprio_fonctions'); 11 12 $conf = spip_proprio_recuperer_config(); 13 static $spip_proprio_no_config = false; 14 if (is_null($conf)) { 15 include_spip('inc/autoriser'); 16 if ($spip_proprio_no_config===false && autoriser('ecrire')) { 17 $div = propre( _T('proprietaire:pas_config', array( 18 'url_config' => generer_url_ecrire('spip_proprio') 19 )) ); 20 echo $div; 21 $spip_proprio_no_config = true; 22 } 23 return; 24 } 25 12 26 $conf['nom_site'] = $GLOBALS['meta']['nom_site']; 13 27 $conf['url_site'] = $GLOBALS['meta']['adresse_site']; -
_plugins_/spip_proprietaire/balise/textes_proprietaire.php
r40936 r47997 3 3 4 4 function balise_TEXTES_PROPRIETAIRE($p) { 5 return calculer_balise_dynamique($p,TEXTES_PROPRIETAIRE,array()); 5 spip_proprio_charger_toutes_les_langues(); 6 return calculer_balise_dynamique($p,TEXTES_PROPRIETAIRE,array()); 6 7 } 7 8 -
_plugins_/spip_proprietaire/exec/spip_proprio.php
r47379 r47997 36 36 ."</div>". fin_boite_info(true); 37 37 38 // on force le chargement de proprietaire_ frsi present39 spip_proprio_ proprietaire_texte();38 // on force le chargement de proprietaire_XX si present 39 spip_proprio_charger_toutes_les_langues(); 40 40 if( $save = _request('save') AND $save == 'oui' ){ 41 41 $raccourci = _request('raccourci') ? _request('raccourci') : false; -
_plugins_/spip_proprietaire/spip_proprio_fonctions.php
r47281 r47997 16 16 $delim = false; 17 17 foreach($spip_proprio_usual_delimiters as $delimiter) { 18 if (strpos($str, $delimiter)) $delim = $delimiter;18 if (strpos($str, $delimiter)) $delim = $delimiter; 19 19 } 20 20 return $delim; … … 38 38 39 39 function spip_proprio_recuperer_extension($str){ 40 return ( substr(strrchr($str, '.'), 1));40 return substr(strrchr($str, '.'), 1); 41 41 } 42 42 … … 107 107 */ 108 108 function apostrophe($str='', $article='', $exception=false){ 109 // On retourne direct si non FR 110 if ($GLOBALS['spip_ang']!='fr') return $article.' '.$str; 111 109 112 $voyelles = array('a', 'e', 'i', 'o', 'u'); 110 113 $article = trim($article); … … 113 116 $article_fin = substr($article, -1, 1); 114 117 115 if (in_array($str_deb, $voyelles) OR $exception)116 return ( substr($article, 0, strlen($article)-1)."'".$str );118 if (in_array($str_deb, $voyelles) OR $exception) 119 return substr($article, 0, strlen($article)-1)."'".$str; 117 120 return $article.' '.$str; 118 121 } 119 122 120 123 function modifier_guillemets($str){ 121 return ( str_replace("'", '"', $str));124 return str_replace("'", '"', $str); 122 125 } 123 126 … … 358 361 // Avec l'aide inestimable de Paris-Bayrouth (http://www.paris-beyrouth.org/) 359 362 function spip_proprio_image_alpha($img, $alpha='', $src=false){ 360 if (!$alpha OR !strlen($alpha) OR $alpha == '0') return $img;363 if (!$alpha OR !strlen($alpha) OR $alpha == '0') return $img; 361 364 include_spip("inc/filtres_images"); 362 365 $image = _image_valeurs_trans($img, "one", "png"); 363 366 //var_export($image); 364 367 $img = image_alpha($img, $alpha); 365 if ($src) return( extraire_attribut($img, 'src') );366 return ($img);368 if ($src) return( extraire_attribut($img, 'src') ); 369 return $img; 367 370 } 368 371 -
_plugins_/spip_proprietaire/spip_proprio_options.php
r46690 r47997 130 130 function make_google_map_proprietaire($conf, $who='proprietaire'){ 131 131 $str = $google_str = ''; 132 if (strlen($conf[$who.'_adresse_rue']))132 if (strlen($conf[$who.'_adresse_rue'])) 133 133 $str .= str_replace(array(',', ';', '.', ':', '/'), '', strip_tags($conf[$who.'_adresse_rue'])); 134 if (strlen($conf[$who.'_adresse_code_postal']))134 if (strlen($conf[$who.'_adresse_code_postal'])) 135 135 $str .= ' '.str_replace(array(',', ';', '.', ':', '/'), '', strip_tags($conf[$who.'_adresse_code_postal'])); 136 if (strlen($conf[$who.'_adresse_ville']))136 if (strlen($conf[$who.'_adresse_ville'])) 137 137 $str .= ' '.str_replace(array(',', ';', '.', ':', '/'), '', strip_tags($conf[$who.'_adresse_ville'])); 138 if (strlen($str)) {138 if (strlen($str)) { 139 139 $entries = explode(' ', $str); 140 140 foreach($entries as $entry) 141 if (strlen($entry)) $google_str .= urlencode($entry).'+';141 if (strlen($entry)) $google_str .= urlencode($entry).'+'; 142 142 $google_str = trim($google_str, '+'); 143 143 return $google_str; … … 151 151 152 152 function spip_proprio_enregistrer_config($args){ 153 if (!is_array($args)) return;153 if (!is_array($args)) return; 154 154 $mess = array(); 155 155 $_conf = spip_proprio_recuperer_config(); … … 162 162 163 163 function spip_proprio_recuperer_config($str=''){ 164 if (!isset($GLOBALS['meta'][_META_SPIP_PROPRIO])) return NULL; 164 165 $_conf = unserialize($GLOBALS['meta'][_META_SPIP_PROPRIO]); 165 if (strlen($str)) {166 if (isset($_conf[$str])) return $_conf[$str];166 if (strlen($str)) { 167 if (isset($_conf[$str])) return $_conf[$str]; 167 168 return false; 168 169 } … … 191 192 * Fonction de gestion des textes proprietaire 192 193 */ 193 function spip_proprio_proprietaire_texte($str='', $args=array() ){194 function spip_proprio_proprietaire_texte($str='', $args=array(), $langdef='fr'){ 194 195 $souvenir = $GLOBALS['spip_lang']; 195 $GLOBALS['spip_lang'] = 'fr'; 196 $test = _T('proprietaire:exemple'); 197 if(!isset($GLOBALS['i18n_proprietaire_fr'])){ 196 $GLOBALS['spip_lang'] = $langdef; 197 198 // Verification que la langue existe 199 // $test = _T('proprietaire:exemple'); 200 // Ne fonctionne pas correctement avec '_T', on reprend la traduction pure de SPIP 201 static $traduire=false ; 202 if (!$traduire) { 203 $traduire = charger_fonction('traduire', 'inc'); 204 include_spip('inc/lang'); 205 } 206 $text = $traduire('proprietaire:test_fichier_langue',$GLOBALS['spip_lang']); 207 208 if (!isset($GLOBALS['i18n_proprietaire_'.$langdef])){ 198 209 $test = _T('textes_legaux:exemple'); 199 creer_fichier_textes_proprietaire( $GLOBALS['i18n_textes_legaux_ fr']);200 $GLOBALS['i18n_proprietaire_ fr'] = $GLOBALS['i18n_textes_legaux_fr'];210 creer_fichier_textes_proprietaire( $GLOBALS['i18n_textes_legaux_'.$langdef], $langdef ); 211 $GLOBALS['i18n_proprietaire_'.$langdef] = $GLOBALS['i18n_textes_legaux_'.$langdef]; 201 212 } 202 213 $GLOBALS['spip_lang'] = $souvenir; … … 204 215 } 205 216 206 function textes_proprietaire( $array=false ){ 207 $globale = 'i18n_proprietaire_'.$GLOBALS['spip_lang']; 208 209 $ok = spip_proprio_proprietaire_texte(); 210 if(isset($GLOBALS["$globale"])) 217 /** 218 * Creation de tous les fichiers de langue 'proprietaire_XX' 219 * pour toutes les langues utilisees en partie publique 220 */ 221 function spip_proprio_charger_toutes_les_langues(){ 222 // on force le chargement de proprietaire_XX si present 223 // pour toutes les langues utilisees en partie publique 224 $langues_du_site = array('fr'); 225 foreach(array('langues_utilisees', 'langues_multilingue', 'langue_site') as $ln_meta) { 226 if (isset($GLOBALS['meta'][$ln_meta])) 227 $langues_du_site = array_merge($langues_du_site, explode(',',$GLOBALS['meta'][$ln_meta])); 228 } 229 $langues_du_site = array_unique($langues_du_site); 230 foreach($langues_du_site as $ln) { 231 spip_proprio_proprietaire_texte('', '', $ln); 232 } 233 return; 234 } 235 236 function textes_proprietaire( $array=false, $lang=null ){ 237 if (is_null($lang)) $lang = $GLOBALS['spip_lang']; 238 $globale = 'i18n_proprietaire_'.$lang; 239 240 $ok1 = spip_proprio_proprietaire_texte(); 241 if ($lang != 'fr') 242 $ok2 = spip_proprio_proprietaire_texte('', '', $lang); 243 if (isset($GLOBALS["$globale"])) 211 244 $GLOBALS["$globale"] = array_merge($GLOBALS['i18n_proprietaire_fr'], $GLOBALS["$globale"]); 212 245 else 213 246 $GLOBALS["$globale"] = $GLOBALS['i18n_proprietaire_fr']; 214 if ($array)247 if ($array) 215 248 return $GLOBALS["$globale"]; 216 249 return false; … … 224 257 $valeurs = array(); 225 258 $tableau = textes_proprietaire(true); 226 if (isset($tableau) AND is_array($tableau)) {259 if (isset($tableau) AND is_array($tableau)) { 227 260 ksort($tableau); 228 261 if($bloc) $div .= debut_cadre_relief('',true,'','','raccourcis'); … … 237 270 } 238 271 $div .= "</table>"; 239 if ($bloc) $div .= fin_cadre_relief(true);272 if ($bloc) $div .= fin_cadre_relief(true); 240 273 } 241 274 return $div; 242 275 } 243 276 244 function traiter_textes_proprietaire($raccourci ){277 function traiter_textes_proprietaire($raccourci, $lang='fr'){ 245 278 include_spip('inc/texte'); 246 279 $valeur = _request('value'); 247 280 $array_langue = textes_proprietaire(true); 248 281 // $valeur = propre( $valeur ); 249 if (strlen($valeur)) $array_langue[$raccourci] = $valeur;250 elseif (isset($array_langue[$raccourci])) unset($array_langue[$raccourci]);251 if ($ok = creer_fichier_textes_proprietaire($array_langue))282 if (strlen($valeur)) $array_langue[$raccourci] = $valeur; 283 elseif (isset($array_langue[$raccourci])) unset($array_langue[$raccourci]); 284 if ($ok = creer_fichier_textes_proprietaire($array_langue, $lang)) 252 285 return $valeur; 253 286 return false; 254 287 } 255 288 256 function creer_fichier_textes_proprietaire($array_langue){ 257 global $spip_lang; 258 $file = 'proprietaire_'.$spip_lang; 259 $globale = 'i18n_proprietaire_'.$spip_lang; 260 if( !file_exists( find_in_path('lang/'.$file) ) ){ 289 function creer_fichier_textes_proprietaire($array_langue, $lang='fr'){ 290 $file = 'proprietaire_'.$lang; 291 $globale = 'i18n_proprietaire_'.$lang; 292 if ( !file_exists( find_in_path('lang/'.$file) ) ){ 261 293 include_spip('inc/flock'); 262 294 $contenu = var_export($array_langue, true);
Note: See TracChangeset
for help on using the changeset viewer.