@@ -16,11 +16,11 @@ |
||
| 16 | 16 | * Purger la liste des travaux en attente |
| 17 | 17 | * @return void |
| 18 | 18 | */ |
| 19 | -function action_purger_queue_dist(){ |
|
| 20 | - $securiser_action = charger_fonction('securiser_action','inc'); |
|
| 19 | +function action_purger_queue_dist() { |
|
| 20 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 21 | 21 | $securiser_action(); |
| 22 | 22 | |
| 23 | - if (autoriser('purger','queue')){ |
|
| 23 | + if (autoriser('purger', 'queue')) { |
|
| 24 | 24 | include_spip('inc/queue'); |
| 25 | 25 | queue_purger(); |
| 26 | 26 | } |
@@ -19,14 +19,14 @@ discard block |
||
| 19 | 19 | * |
| 20 | 20 | * @param string|null $arg |
| 21 | 21 | */ |
| 22 | -function action_calculer_taille_cache_dist($arg=null){ |
|
| 23 | - if (is_null($arg)){ |
|
| 22 | +function action_calculer_taille_cache_dist($arg = null) { |
|
| 23 | + if (is_null($arg)) { |
|
| 24 | 24 | $securiser_action = charger_fonction('securiser_action', 'inc'); |
| 25 | 25 | $arg = $securiser_action(); |
| 26 | 26 | } |
| 27 | 27 | include_spip('inc/filtres'); |
| 28 | 28 | |
| 29 | - if ($arg=='images'){ |
|
| 29 | + if ($arg == 'images') { |
|
| 30 | 30 | $taille = calculer_taille_dossier(_DIR_VAR); |
| 31 | 31 | $res = _T('ecrire:taille_cache_image', |
| 32 | 32 | array( |
@@ -44,14 +44,14 @@ discard block |
||
| 44 | 44 | +calculer_taille_dossier(_DIR_CACHE.'contextes/') |
| 45 | 45 | ; |
| 46 | 46 | $taille += intval(taille_du_cache()); |
| 47 | - if ($taille<=150000){ |
|
| 47 | + if ($taille <= 150000) { |
|
| 48 | 48 | $res = _T('taille_cache_vide'); |
| 49 | 49 | } |
| 50 | - elseif ($taille<=1024*1024){ |
|
| 51 | - $res = _T('taille_cache_moins_de',array('octets'=>taille_en_octets(1024*1024))); |
|
| 50 | + elseif ($taille <= 1024 * 1024) { |
|
| 51 | + $res = _T('taille_cache_moins_de', array('octets'=>taille_en_octets(1024 * 1024))); |
|
| 52 | 52 | } |
| 53 | 53 | else { |
| 54 | - $res = _T('taille_cache_octets',array('octets'=>taille_en_octets($taille))); |
|
| 54 | + $res = _T('taille_cache_octets', array('octets'=>taille_en_octets($taille))); |
|
| 55 | 55 | } |
| 56 | 56 | $res = "<b>$res</b>"; |
| 57 | 57 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @param $dir |
| 70 | 70 | * @return int |
| 71 | 71 | */ |
| 72 | -function calculer_taille_dossier ($dir) { |
|
| 72 | +function calculer_taille_dossier($dir) { |
|
| 73 | 73 | $handle = @opendir($dir); |
| 74 | 74 | if (!$handle) return 0; |
| 75 | 75 | $taille = 0; |
@@ -16,13 +16,13 @@ |
||
| 16 | 16 | * Annuler un travail |
| 17 | 17 | * @return void |
| 18 | 18 | */ |
| 19 | -function action_annuler_job_dist(){ |
|
| 20 | - $securiser_action = charger_fonction('securiser_action','inc'); |
|
| 19 | +function action_annuler_job_dist() { |
|
| 20 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 21 | 21 | $id_job = $securiser_action(); |
| 22 | 22 | |
| 23 | 23 | if ($id_job = intval($id_job) |
| 24 | - AND autoriser('annuler','job',$id_job) |
|
| 25 | - ){ |
|
| 24 | + AND autoriser('annuler', 'job', $id_job) |
|
| 25 | + ) { |
|
| 26 | 26 | job_queue_remove($id_job); |
| 27 | 27 | } |
| 28 | 28 | } |
@@ -14,26 +14,26 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | // mise a jour des donnees si envoi via formulaire |
| 16 | 16 | // http://doc.spip.org/@enregistre_modif_plugin |
| 17 | -function enregistre_modif_plugin(){ |
|
| 17 | +function enregistre_modif_plugin() { |
|
| 18 | 18 | include_spip('inc/plugin'); |
| 19 | 19 | // recuperer les plugins dans l'ordre des $_POST |
| 20 | 20 | $test = array(); |
| 21 | - foreach(liste_plugin_files() as $file){ |
|
| 22 | - $test['s'.substr(md5(_DIR_PLUGINS.$file),0,16)] = $file; |
|
| 21 | + foreach (liste_plugin_files() as $file) { |
|
| 22 | + $test['s'.substr(md5(_DIR_PLUGINS.$file), 0, 16)] = $file; |
|
| 23 | 23 | } |
| 24 | 24 | if (defined('_DIR_PLUGINS_SUPPL')) |
| 25 | - foreach(liste_plugin_files(_DIR_PLUGINS_SUPPL) as $file){ |
|
| 26 | - $test['s'.substr(md5(_DIR_PLUGINS_SUPPL.$file),0,16)] = $file; |
|
| 25 | + foreach (liste_plugin_files(_DIR_PLUGINS_SUPPL) as $file) { |
|
| 26 | + $test['s'.substr(md5(_DIR_PLUGINS_SUPPL.$file), 0, 16)] = $file; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - $plugin=array(); |
|
| 29 | + $plugin = array(); |
|
| 30 | 30 | |
| 31 | - foreach($_POST as $choix=>$val){ |
|
| 32 | - if (isset($test[$choix])&&$val=='O') |
|
| 33 | - $plugin[]=$test[$choix]; |
|
| 31 | + foreach ($_POST as $choix=>$val) { |
|
| 32 | + if (isset($test[$choix]) && $val == 'O') |
|
| 33 | + $plugin[] = $test[$choix]; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - spip_log("Changement des plugins actifs par l'auteur " . $GLOBALS['visiteur_session']['id_auteur'] . ": " . join(',', $plugin)); |
|
| 36 | + spip_log("Changement des plugins actifs par l'auteur ".$GLOBALS['visiteur_session']['id_auteur'].": ".join(',', $plugin)); |
|
| 37 | 37 | ecrire_plugin_actifs($plugin); |
| 38 | 38 | |
| 39 | 39 | // Chaque fois que l'on valide des plugins, on memorise la liste de ces plugins comme etant "interessants", avec un score initial, qui sera decremente a chaque tour : ainsi un plugin active pourra reter visible a l'ecran, jusqu'a ce qu'il tombe dans l'oubli. |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | $plugins_interessants2 = array(); |
| 45 | 45 | |
| 46 | - foreach($plugins_interessants as $plug => $score) |
|
| 46 | + foreach ($plugins_interessants as $plug => $score) |
|
| 47 | 47 | if ($score > 1) |
| 48 | - $plugins_interessants2[$plug] = $score-1; |
|
| 48 | + $plugins_interessants2[$plug] = $score - 1; |
|
| 49 | 49 | foreach ($plugin as $plug) |
| 50 | 50 | $plugins_interessants2[$plug] = 10; // score initial |
| 51 | 51 | ecrire_meta('plugins_interessants', serialize($plugins_interessants2)); |
@@ -12,14 +12,14 @@ |
||
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) return; |
| 14 | 14 | |
| 15 | -function action_ajouter_lien_dist($arg=null){ |
|
| 16 | - if (is_null($arg)){ |
|
| 17 | - $securiser_action = charger_fonction('securiser_action','inc'); |
|
| 15 | +function action_ajouter_lien_dist($arg = null) { |
|
| 16 | + if (is_null($arg)) { |
|
| 17 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 18 | 18 | $arg = $securiser_action(); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - $arg = explode("-",$arg); |
|
| 22 | - list($objet_source,$ids,$objet_lie,$idl) = $arg; |
|
| 21 | + $arg = explode("-", $arg); |
|
| 22 | + list($objet_source, $ids, $objet_lie, $idl) = $arg; |
|
| 23 | 23 | |
| 24 | 24 | include_spip('action/editer_liens'); |
| 25 | 25 | objet_associer(array($objet_source=>$ids), array($objet_lie=>$idl)); |
@@ -16,48 +16,48 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | ####### modifications possibles dans ecrire/mes_options |
| 18 | 18 | # on peut indiquer '.html' pour faire joli |
| 19 | -define ('_terminaison_urls_page', ''); |
|
| 19 | +define('_terminaison_urls_page', ''); |
|
| 20 | 20 | # ci-dessous, ce qu'on veut ou presque (de preference pas de '/') |
| 21 | 21 | # attention toutefois seuls '' et '=' figurent dans les modes de compatibilite |
| 22 | -define ('_separateur_urls_page', ''); |
|
| 22 | +define('_separateur_urls_page', ''); |
|
| 23 | 23 | # on peut indiquer '' si on a installe le .htaccess |
| 24 | -define ('_debut_urls_page', get_spip_script('./').'?'); |
|
| 24 | +define('_debut_urls_page', get_spip_script('./').'?'); |
|
| 25 | 25 | ####### |
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | // http://doc.spip.org/@_generer_url_page |
| 29 | -function _generer_url_page($type,$id, $args='', $ancre='') { |
|
| 29 | +function _generer_url_page($type, $id, $args = '', $ancre = '') { |
|
| 30 | 30 | |
| 31 | - if ($generer_url_externe = charger_fonction("generer_url_$type",'urls',true)) { |
|
| 31 | + if ($generer_url_externe = charger_fonction("generer_url_$type", 'urls', true)) { |
|
| 32 | 32 | $url = $generer_url_externe($id, $args, $ancre); |
| 33 | 33 | if (NULL != $url) return $url; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - $url = _debut_urls_page . $type . _separateur_urls_page |
|
| 37 | - . $id . _terminaison_urls_page; |
|
| 36 | + $url = _debut_urls_page.$type._separateur_urls_page |
|
| 37 | + . $id._terminaison_urls_page; |
|
| 38 | 38 | |
| 39 | - if ($args) $args = strpos($url,'?') ? "&$args" : "?$args"; |
|
| 40 | - return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : ''); |
|
| 39 | + if ($args) $args = strpos($url, '?') ? "&$args" : "?$args"; |
|
| 40 | + return _DIR_RACINE.$url.$args.($ancre ? "#$ancre" : ''); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // retrouve le fond et les parametres d'une URL abregee |
| 44 | 44 | // le contexte deja existant est fourni dans args sous forme de tableau ou query string |
| 45 | 45 | // http://doc.spip.org/@urls_page_dist |
| 46 | -function urls_page_dist($i, &$entite, $args='', $ancre='') |
|
| 46 | +function urls_page_dist($i, &$entite, $args = '', $ancre = '') |
|
| 47 | 47 | { |
| 48 | 48 | if (is_numeric($i)) |
| 49 | 49 | return _generer_url_page($entite, $i, $args, $ancre); |
| 50 | 50 | |
| 51 | 51 | // traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23 |
| 52 | - if ($GLOBALS['profondeur_url']>0 AND $entite=='sommaire'){ |
|
| 53 | - return array(array(),'404'); |
|
| 52 | + if ($GLOBALS['profondeur_url'] > 0 AND $entite == 'sommaire') { |
|
| 53 | + return array(array(), '404'); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | // voir s'il faut recuperer le id_* implicite et les &debut_xx; |
| 57 | 57 | if (is_array($args)) |
| 58 | 58 | $contexte = $args; |
| 59 | 59 | else |
| 60 | - parse_str($args,$contexte); |
|
| 60 | + parse_str($args, $contexte); |
|
| 61 | 61 | include_spip('inc/urls'); |
| 62 | 62 | $r = nettoyer_url_page($i, $contexte); |
| 63 | 63 | if ($r) { |
@@ -83,11 +83,11 @@ discard block |
||
| 83 | 83 | : '' |
| 84 | 84 | )); |
| 85 | 85 | if ($url_propre) { |
| 86 | - if ($GLOBALS['profondeur_url']<=0) |
|
| 87 | - $urls_anciennes = charger_fonction('propres','urls',true); |
|
| 86 | + if ($GLOBALS['profondeur_url'] <= 0) |
|
| 87 | + $urls_anciennes = charger_fonction('propres', 'urls', true); |
|
| 88 | 88 | else |
| 89 | - $urls_anciennes = charger_fonction('arbo','urls',true); |
|
| 90 | - return $urls_anciennes?$urls_anciennes($url_propre, $entite, $contexte):''; |
|
| 89 | + $urls_anciennes = charger_fonction('arbo', 'urls', true); |
|
| 90 | + return $urls_anciennes ? $urls_anciennes($url_propre, $entite, $contexte) : ''; |
|
| 91 | 91 | } |
| 92 | 92 | /* Fin du bloc compatibilite url-propres */ |
| 93 | 93 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) return; |
| 14 | 14 | |
| 15 | -if (!defined('_DATA_SOURCE_MAX_SIZE')) define('_DATA_SOURCE_MAX_SIZE',2*1048576); |
|
| 15 | +if (!defined('_DATA_SOURCE_MAX_SIZE')) define('_DATA_SOURCE_MAX_SIZE', 2 * 1048576); |
|
| 16 | 16 | |
| 17 | 17 | |
| 18 | 18 | /** |
@@ -86,8 +86,8 @@ discard block |
||
| 86 | 86 | * @param $command |
| 87 | 87 | * @param array $info |
| 88 | 88 | */ |
| 89 | - public function __construct($command, $info=array()) { |
|
| 90 | - $this->type='DATA'; |
|
| 89 | + public function __construct($command, $info = array()) { |
|
| 90 | + $this->type = 'DATA'; |
|
| 91 | 91 | $this->command = $command; |
| 92 | 92 | $this->info = $info; |
| 93 | 93 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | // Si a ce stade on n'a pas de table, il y a un bug |
| 190 | 190 | if (!is_array($this->tableau)) { |
| 191 | 191 | $this->err = true; |
| 192 | - spip_log("erreur datasource ".var_export($command,true)); |
|
| 192 | + spip_log("erreur datasource ".var_export($command, true)); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | // {datapath query.results} |
@@ -226,8 +226,8 @@ discard block |
||
| 226 | 226 | # l'objet en cache ; cf plugins/icalendar |
| 227 | 227 | # perf : pas de fonction table_to_array ! (table est deja un array) |
| 228 | 228 | if (isset($this->command['sourcemode']) |
| 229 | - AND !in_array($this->command['sourcemode'],array('table', 'array', 'tableau'))) |
|
| 230 | - charger_fonction($this->command['sourcemode'] . '_to_array', 'inc', true); |
|
| 229 | + AND !in_array($this->command['sourcemode'], array('table', 'array', 'tableau'))) |
|
| 230 | + charger_fonction($this->command['sourcemode'].'_to_array', 'inc', true); |
|
| 231 | 231 | |
| 232 | 232 | # le premier argument peut etre un array, une URL etc. |
| 233 | 233 | $src = $this->command['source'][0]; |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | # avons-nous un cache dispo ? |
| 236 | 236 | $cle = null; |
| 237 | 237 | if (is_string($src)) |
| 238 | - $cle = 'datasource_'.md5($this->command['sourcemode'].':'.var_export($this->command['source'],true)); |
|
| 238 | + $cle = 'datasource_'.md5($this->command['sourcemode'].':'.var_export($this->command['source'], true)); |
|
| 239 | 239 | |
| 240 | 240 | $cache = $this->cache_get($cle); |
| 241 | 241 | if (isset($this->command['datacache'])) |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | $u = recuperer_page($src, false, false, _DATA_SOURCE_MAX_SIZE); |
| 272 | 272 | if (!$u) |
| 273 | 273 | throw new Exception("404"); |
| 274 | - if (!isset($ttl)) $ttl = 24*3600; |
|
| 274 | + if (!isset($ttl)) $ttl = 24 * 3600; |
|
| 275 | 275 | } else if (@is_dir($src)) { |
| 276 | 276 | $u = $src; |
| 277 | 277 | if (!isset($ttl)) $ttl = 10; |
@@ -283,10 +283,10 @@ discard block |
||
| 283 | 283 | if (!isset($ttl)) $ttl = 10; |
| 284 | 284 | } |
| 285 | 285 | if (!$this->err |
| 286 | - AND $g = charger_fonction($this->command['sourcemode'] . '_to_array', 'inc', true)) { |
|
| 286 | + AND $g = charger_fonction($this->command['sourcemode'].'_to_array', 'inc', true)) { |
|
| 287 | 287 | $args = $this->command['source']; |
| 288 | 288 | $args[0] = $u; |
| 289 | - if (is_array($a = call_user_func_array($g,$args))) { |
|
| 289 | + if (is_array($a = call_user_func_array($g, $args))) { |
|
| 290 | 290 | $this->tableau = $a; |
| 291 | 291 | } |
| 292 | 292 | } |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | if (!is_array($this->tableau)) |
| 296 | 296 | $this->err = true; |
| 297 | 297 | |
| 298 | - if (!$this->err AND isset($ttl) and $ttl>0) |
|
| 298 | + if (!$this->err AND isset($ttl) and $ttl > 0) |
|
| 299 | 299 | $this->cache_set($cle, $ttl); |
| 300 | 300 | |
| 301 | 301 | } |
@@ -348,10 +348,10 @@ discard block |
||
| 348 | 348 | $this->command['enum'] = $this->command['enum'][0]; |
| 349 | 349 | } |
| 350 | 350 | } |
| 351 | - if (count($this->command['enum'])>=3) |
|
| 352 | - $enum = range(array_shift($this->command['enum']),array_shift($this->command['enum']),array_shift($this->command['enum'])); |
|
| 351 | + if (count($this->command['enum']) >= 3) |
|
| 352 | + $enum = range(array_shift($this->command['enum']), array_shift($this->command['enum']), array_shift($this->command['enum'])); |
|
| 353 | 353 | else |
| 354 | - $enum = range(array_shift($this->command['enum']),array_shift($this->command['enum'])); |
|
| 354 | + $enum = range(array_shift($this->command['enum']), array_shift($this->command['enum'])); |
|
| 355 | 355 | $this->tableau = $enum; |
| 356 | 356 | } |
| 357 | 357 | |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | **/ |
| 364 | 364 | protected function select_datapath() { |
| 365 | 365 | list(,$base) = each($this->command['datapath']); |
| 366 | - if (strlen($base = ltrim(trim($base),"/"))) { |
|
| 366 | + if (strlen($base = ltrim(trim($base), "/"))) { |
|
| 367 | 367 | $this->tableau = table_valeur($this->tableau, $base); |
| 368 | 368 | if (!is_array($this->tableau)) { |
| 369 | 369 | $this->tableau = array(); |
@@ -381,11 +381,11 @@ discard block |
||
| 381 | 381 | protected function select_orderby() { |
| 382 | 382 | $sortfunc = ''; |
| 383 | 383 | $aleas = 0; |
| 384 | - foreach($this->command['orderby'] as $tri) { |
|
| 384 | + foreach ($this->command['orderby'] as $tri) { |
|
| 385 | 385 | // virer le / initial pour les criteres de la forme {par /xx} |
| 386 | 386 | if (preg_match(',^\.?([/\w]+)( DESC)?$,iS', ltrim($tri, '/'), $r)) { |
| 387 | 387 | // tri par cle |
| 388 | - if ($r[1] == 'cle'){ |
|
| 388 | + if ($r[1] == 'cle') { |
|
| 389 | 389 | if (isset($r[2]) and $r[2]) |
| 390 | 390 | krsort($this->tableau); |
| 391 | 391 | else |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | $k = array_keys($this->tableau); |
| 397 | 397 | shuffle($k); |
| 398 | 398 | $v = array(); |
| 399 | - foreach($k as $cle) |
|
| 399 | + foreach ($k as $cle) |
|
| 400 | 400 | $v[$cle] = $this->tableau[$cle]; |
| 401 | 401 | $this->tableau = $v; |
| 402 | 402 | } |
@@ -406,10 +406,10 @@ discard block |
||
| 406 | 406 | $tv = '%s'; |
| 407 | 407 | # {par valeur/xx/yy} ?? |
| 408 | 408 | else |
| 409 | - $tv = 'table_valeur(%s, '.var_export($r[1],true).')'; |
|
| 409 | + $tv = 'table_valeur(%s, '.var_export($r[1], true).')'; |
|
| 410 | 410 | $sortfunc .= ' |
| 411 | - $a = '.sprintf($tv,'$aa').'; |
|
| 412 | - $b = '.sprintf($tv,'$bb').'; |
|
| 411 | + $a = '.sprintf($tv, '$aa').'; |
|
| 412 | + $b = '.sprintf($tv, '$bb').'; |
|
| 413 | 413 | if ($a <> $b) |
| 414 | 414 | return ($a ' . ((isset($r[2]) and $r[2]) ? '>' : '<').' $b) ? -1 : 1;'; |
| 415 | 415 | } |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | // virer le / initial pour les criteres de la forme {fusion /xx} |
| 435 | 435 | if (strlen($fusion = ltrim($this->command['groupby'][0], '/'))) { |
| 436 | 436 | $vu = array(); |
| 437 | - foreach($this->tableau as $k => $v) { |
|
| 437 | + foreach ($this->tableau as $k => $v) { |
|
| 438 | 438 | $val = table_valeur($v, $fusion); |
| 439 | 439 | if (isset($vu[$val])) |
| 440 | 440 | unset($this->tableau[$k]); |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | * L'iterateur est-il encore valide ? |
| 450 | 450 | * @return bool |
| 451 | 451 | */ |
| 452 | - public function valid(){ |
|
| 452 | + public function valid() { |
|
| 453 | 453 | return !is_null($this->cle); |
| 454 | 454 | } |
| 455 | 455 | |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | * Passer a la valeur suivante |
| 474 | 474 | * @return void |
| 475 | 475 | */ |
| 476 | - public function next(){ |
|
| 476 | + public function next() { |
|
| 477 | 477 | if ($this->valid()) |
| 478 | 478 | list($this->cle, $this->valeur) = each($this->tableau); |
| 479 | 479 | } |
@@ -529,14 +529,14 @@ discard block |
||
| 529 | 529 | * @return array |
| 530 | 530 | * |
| 531 | 531 | */ |
| 532 | -function inc_object_to_array( $object ) { |
|
| 533 | - if( !is_object( $object ) && !is_array( $object ) ) { |
|
| 532 | +function inc_object_to_array($object) { |
|
| 533 | + if (!is_object($object) && !is_array($object)) { |
|
| 534 | 534 | return $object; |
| 535 | 535 | } |
| 536 | - if( is_object( $object ) ) { |
|
| 537 | - $object = get_object_vars( $object ); |
|
| 536 | + if (is_object($object)) { |
|
| 537 | + $object = get_object_vars($object); |
|
| 538 | 538 | } |
| 539 | - return array_map( 'inc_object_to_array', $object ); |
|
| 539 | + return array_map('inc_object_to_array', $object); |
|
| 540 | 540 | } |
| 541 | 541 | |
| 542 | 542 | /** |
@@ -593,8 +593,8 @@ discard block |
||
| 593 | 593 | */ |
| 594 | 594 | function inc_csv_to_array_dist($u) { |
| 595 | 595 | include_spip('inc/csv'); |
| 596 | - list($entete,$csv) = analyse_csv($u); |
|
| 597 | - array_unshift($csv,$entete); |
|
| 596 | + list($entete, $csv) = analyse_csv($u); |
|
| 597 | + array_unshift($csv, $entete); |
|
| 598 | 598 | |
| 599 | 599 | include_spip('inc/charsets'); |
| 600 | 600 | foreach ($entete as $k => $v) { |
@@ -645,9 +645,9 @@ discard block |
||
| 645 | 645 | * @return bool|array |
| 646 | 646 | * @throws Exception |
| 647 | 647 | */ |
| 648 | -function inc_yaml_to_array_dist($u){ |
|
| 648 | +function inc_yaml_to_array_dist($u) { |
|
| 649 | 649 | include_spip('inc/yaml-mini'); |
| 650 | - if (!function_exists("yaml_decode")){ |
|
| 650 | + if (!function_exists("yaml_decode")) { |
|
| 651 | 651 | throw new Exception('YAML: impossible de trouver la fonction yaml_decode'); |
| 652 | 652 | return false; |
| 653 | 653 | } |
@@ -665,7 +665,7 @@ discard block |
||
| 665 | 665 | * @param int $limit |
| 666 | 666 | * @return array|bool |
| 667 | 667 | */ |
| 668 | -function inc_pregfiles_to_array_dist($dir, $regexp=-1, $limit=10000) { |
|
| 668 | +function inc_pregfiles_to_array_dist($dir, $regexp = -1, $limit = 10000) { |
|
| 669 | 669 | return (array) preg_files($dir, $regexp, $limit); |
| 670 | 670 | } |
| 671 | 671 | |
@@ -697,21 +697,21 @@ discard block |
||
| 697 | 697 | * @param Object $object |
| 698 | 698 | * @return array|bool |
| 699 | 699 | */ |
| 700 | -function XMLObjectToArray($object){ |
|
| 700 | +function XMLObjectToArray($object) { |
|
| 701 | 701 | $xml_array = array(); |
| 702 | - for( $object->rewind(); $object->valid(); $object->next() ) { |
|
| 703 | - if(array_key_exists($key = $object->key(), $xml_array)){ |
|
| 702 | + for ($object->rewind(); $object->valid(); $object->next()) { |
|
| 703 | + if (array_key_exists($key = $object->key(), $xml_array)) { |
|
| 704 | 704 | $key .= '-'.uniqid(); |
| 705 | 705 | } |
| 706 | 706 | $vars = get_object_vars($object->current()); |
| 707 | 707 | if (isset($vars['@attributes'])) |
| 708 | - foreach($vars['@attributes'] as $k => $v) |
|
| 708 | + foreach ($vars['@attributes'] as $k => $v) |
|
| 709 | 709 | $xml_array[$key][$k] = $v; |
| 710 | - if($object->hasChildren()){ |
|
| 710 | + if ($object->hasChildren()) { |
|
| 711 | 711 | $xml_array[$key][] = XMLObjectToArray( |
| 712 | 712 | $object->current()); |
| 713 | 713 | } |
| 714 | - else{ |
|
| 714 | + else { |
|
| 715 | 715 | $xml_array[$key][] = strval($object->current()); |
| 716 | 716 | } |
| 717 | 717 | } |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | * array command: les commandes d'initialisation |
| 67 | 67 | * array info: les infos sur le squelette |
| 68 | 68 | */ |
| 69 | - public function __construct($command, $info=array()) { |
|
| 70 | - $this->type='SQL'; |
|
| 69 | + public function __construct($command, $info = array()) { |
|
| 70 | + $this->type = 'SQL'; |
|
| 71 | 71 | $this->command = $command; |
| 72 | 72 | $this->info = $info; |
| 73 | 73 | $this->select(); |
@@ -113,12 +113,12 @@ discard block |
||
| 113 | 113 | * @param null|string $continue |
| 114 | 114 | * @return bool |
| 115 | 115 | */ |
| 116 | - public function seek($n=0, $continue=null) { |
|
| 116 | + public function seek($n = 0, $continue = null) { |
|
| 117 | 117 | if (!sql_seek($this->sqlresult, $n, $this->command['connect'], $continue)) { |
| 118 | 118 | // SQLite ne sait pas seek(), il faut relancer la query |
| 119 | 119 | // si la position courante est apres la position visee |
| 120 | 120 | // il faut relancer la requete |
| 121 | - if ($this->pos>$n){ |
|
| 121 | + if ($this->pos > $n) { |
|
| 122 | 122 | $this->free(); |
| 123 | 123 | $this->select(); |
| 124 | 124 | $this->valid(); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | return false; |
| 129 | 129 | } |
| 130 | 130 | $this->row = sql_fetch($this->sqlresult, $this->command['connect']); |
| 131 | - $this->pos = min($n,$this->count()); |
|
| 131 | + $this->pos = min($n, $this->count()); |
|
| 132 | 132 | return true; |
| 133 | 133 | } |
| 134 | 134 | |
@@ -136,9 +136,9 @@ discard block |
||
| 136 | 136 | * Avancer d'un cran |
| 137 | 137 | * @return void |
| 138 | 138 | */ |
| 139 | - public function next(){ |
|
| 139 | + public function next() { |
|
| 140 | 140 | $this->row = sql_fetch($this->sqlresult, $this->command['connect']); |
| 141 | - $this->pos ++; |
|
| 141 | + $this->pos++; |
|
| 142 | 142 | $this->firstseek |= true; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * Avancer et retourner les donnees pour le nouvel element |
| 147 | 147 | * @return array|bool|null |
| 148 | 148 | */ |
| 149 | - public function fetch(){ |
|
| 149 | + public function fetch() { |
|
| 150 | 150 | if ($this->valid()) { |
| 151 | 151 | $r = $this->current(); |
| 152 | 152 | $this->next(); |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | * liberer les ressources |
| 160 | 160 | * @return bool |
| 161 | 161 | */ |
| 162 | - public function free(){ |
|
| 162 | + public function free() { |
|
| 163 | 163 | if (!$this->sqlresult) return true; |
| 164 | 164 | $a = sql_free($this->sqlresult, $this->command['connect']); |
| 165 | 165 | $this->sqlresult = null; |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | ) |
| 27 | 27 | ); |
| 28 | 28 | foreach (get_class_methods($iteratorName) as $method) { |
| 29 | - $b->show['field'][ strtolower($method) ] = 'METHOD'; |
|
| 29 | + $b->show['field'][strtolower($method)] = 'METHOD'; |
|
| 30 | 30 | } |
| 31 | 31 | /* |
| 32 | 32 | foreach (get_class_vars($iteratorName) as $property) { |