Changeset 80169 in spip-zone
- Timestamp:
- Jan 21, 2014, 10:15:11 AM (7 years ago)
- Location:
- _plugins_/crayons
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/crayons/action/crayons_html.php
r77245 r80169 179 179 function Crayon($name, $texts = array(), $options = array(), $c=null) { 180 180 $this->name = $name; 181 list($this->type, $this->modele, $this->id) = explode('-', $this->name, 3); 181 182 list($this->type, $this->modele, $this->id) = array_pad(explode('-', $this->name, 3), 3, ''); 182 183 list($this->distant,$this->table) = distant_table($this->type); 183 184 if (is_scalar($texts) || is_null($texts)) { … … 317 318 . '" />'."\n"; 318 319 } 320 319 321 if (is_array($spec) && isset($spec[$champ]['attrs'])) { 320 322 foreach ($spec[$champ]['attrs'] as $attr=>$val) { -
_plugins_/crayons/action/crayons_store.php
r77245 r80169 38 38 * depuis jquery 1.5 (feature non documentee de jquery!) 39 39 */ 40 $content[$field] = is_array($_POST['content_'.$crayon.'_'.$field])?implode(',',$_POST['content_'.$crayon.'_'.$field]):$_POST['content_'.$crayon.'_'.$field]; 40 if (isset($_POST['content_'.$crayon.'_'.$field])) { 41 $content[$field] = is_array($_POST['content_'.$crayon.'_'.$field]) 42 ?implode(',',$_POST['content_'.$crayon.'_'.$field]) 43 :$_POST['content_'.$crayon.'_'.$field]; 44 } else { 45 $content[$field] = null; 46 } 41 47 } 42 48 } -
_plugins_/crayons/inc/crayons.php
r77245 r80169 382 382 list($distant,$table) = distant_table($type); 383 383 $nom_table = ''; 384 if (!(($tabref = &crayons_get_table($table, $nom_table)) && ($brut = $tabref['field'][$col]))) { 385 return false; 384 if (!(($tabref = &crayons_get_table($table, $nom_table)) 385 && isset($tabref['field'][$col]) 386 && ($brut = $tabref['field'][$col]))) { 387 return false; 386 388 } 387 389 $ana = explode(' ', $brut); … … 440 442 return $ret; 441 443 } 442 // var_dump(colonne_table('forum', 'id_syndic')); die(); 444 445 446 /** 447 * Obtient le nom de la table ainsi que sa ou ses clés primaires 448 * 449 * @param string $type 450 * Table sur laquelle s'applique le crayon. 451 * Ce type peut contenir le nom d'un connecteur distant tel que `{connect}__{table}` 452 * 453 * @return array|bool 454 * - false si on ne trouve pas de table ou de table ayant de clé primaire 455 * - liste : 456 * - - nom de la table sql 457 * - - tableau des noms de clés primaires 458 **/ 459 function crayons_get_table_name_and_primary($type) { 460 static $types = array(); 461 if (isset($types[$type])) { 462 return $types[$type]; 463 } 464 465 $nom_table = ''; 466 if ($tabref = &crayons_get_table($type, $nom_table) 467 and ($tabid = explode(',', $tabref['key']['PRIMARY KEY']))) 468 { 469 return $types[$type] = array($nom_table, $tabid); 470 } 471 spip_log('crayons: table ' . $type . ' inconnue'); 472 return $types[$type] = false; 473 } 474 443 475 444 476 function table_where($type, $id, $where_en_tableau = false) { 445 list($distant,$table) = distant_table($type); 446 $nom_table = ''; 447 if (!(($tabref = &crayons_get_table($type, $nom_table)) 448 && ($tabid = explode(',', $tabref['key']['PRIMARY KEY'])))) { 449 spip_log('crayons: table ' . $table . ' inconnue'); 477 478 479 if (!$infos = crayons_get_table_name_and_primary($type)) { 450 480 return array(false, false); 451 481 } 482 483 list($nom_table, $tabid) = $infos; 484 485 452 486 if (is_scalar($id)) 453 487 $id = explode('-', $id); … … 460 494 // sinon sortie texte pour sql_query 461 495 } else { 496 462 497 $where = $and = ''; 463 498 foreach ($id as $idcol => $idval) { … … 471 506 472 507 function valeur_colonne_table_dist($type, $col, $id) { 473 list($distant,$table) = distant_table($type); 474 list($nom_table, $where) = table_where($type, $id); 475 476 if (!$nom_table) 508 509 // Table introuvable ou sans clé primaire 510 if (!$infos = crayons_get_table_name_and_primary($type)) { 477 511 return false; 512 } 513 $table = reset($infos); 478 514 479 515 $r = array(); … … 488 524 489 525 // valeurs SQL 490 if (count($col) 491 AND $s = spip_query( 492 'SELECT `' . implode($col, '`, `') . 493 '` FROM ' . $nom_table . ' WHERE ' . $where, $distant) 494 AND $t = sql_fetch($s)) 495 $r = array_merge($r, $t); 526 if (count($col)) { 527 list($distant, $table) = distant_table($type); 528 list($nom_table, $where) = table_where($type, $id); 529 530 if ($s = spip_query( 531 'SELECT `' . implode($col, '`, `') . 532 '` FROM ' . $nom_table . ' WHERE ' . $where, $distant) 533 AND $t = sql_fetch($s)){ 534 $r = array_merge($r, $t); 535 } 536 } 496 537 497 538 return $r; -
_plugins_/crayons/paquet.xml
r78994 r80169 2 2 prefix="crayons" 3 3 categorie="edition" 4 version="1.1 6.6"4 version="1.17.0" 5 5 etat="stable" 6 6 compatibilite="[1.9.0;3.*.*]" -
_plugins_/crayons/plugin.xml
r78994 r80169 17 17 </licence> 18 18 <version> 19 1.1 6.619 1.17.0 20 20 </version> 21 21 <etat>
Note: See TracChangeset
for help on using the changeset viewer.