".$msg[103]." ".$msg["count_connecteurs_categ"]." "; $requete = "SELECT connectors_categ_id, connectors_categ_name FROM connectors_categ order by connectors_categ_name"; $res = mysql_query($requete, $dbh); $parity=1; while($row=mysql_fetch_object($res)) { $count_query = 'SELECT count(*) FROM connectors_categ_sources WHERE num_categ='.$row->connectors_categ_id; $conn_count = mysql_result(mysql_query($count_query, $dbh), 0, 0); if ($parity % 2) { $pair_impair = "even"; } else { $pair_impair = "odd"; } $parity += 1; $tr_javascript=" onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='$pair_impair'\" onmousedown=\"document.location='./admin.php?categ=connecteurs&sub=categ&action=modif&id=$row->connectors_categ_id';\" "; print pmb_bidi(""); print pmb_bidi("".$row->connectors_categ_name.""); print pmb_bidi("$conn_count") ; print pmb_bidi(""); } print " "; } function category_form($categ_id=0, $new_categ_name="", $opac_expanded=false) { global $msg, $dbh, $charset; print '
'; if (!$categ_id) print '

'.$msg['connecteurs_categ_add'].'

'; else print '

'.$msg['connecteurs_categ_edit'].'

'; print '
'; print ''; print '

'; print '
'; print '

'; print '
'; $sources_sql = 'SELECT connectors_sources.source_id, connectors_sources.name, connectors_categ_sources.num_categ, id_connector FROM connectors_sources LEFT JOIN connectors_categ_sources ON (connectors_sources.source_id = connectors_categ_sources.num_source AND connectors_categ_sources.num_categ='.$categ_id.') order by connectors_sources.id_connector, connectors_sources.name'; $resultat = mysql_query($sources_sql, $dbh); while ($row=mysql_fetch_object($resultat)) { $sources[] = $row; } $nbsources=count($sources); $content_input = ''; print '

'; print $content_input; print '
'; print "
"; print " "; print ''; print "
"; if ($categ_id) { print confirmation_delete("./admin.php?categ=connecteurs&sub=categ&action=del&id="); print ""; } print "


"; print '
'; } switch($action) { case 'update': //Mettons a jours la catégorie if ($categ_id == 0) { $sql = "INSERT INTO connectors_categ (connectors_categ_name, opac_expanded) VALUES ('".$categ_name."', ".($categ_opac_expanded ? "1" : "0").");"; mysql_query($sql, $dbh); $categ_id = mysql_insert_id($dbh); } else { $sql = "UPDATE connectors_categ SET connectors_categ_name = '".$categ_name."', opac_expanded = ".($categ_opac_expanded ? "1" : "0")." WHERE connectors_categ_id = ".$categ_id; mysql_query($sql, $dbh); } $sql = "DELETE FROM connectors_categ_sources WHERE num_categ = ".$categ_id; mysql_query($sql, $dbh); if ($categ_content && !(count($categ_content == 1) && $categ_content[0] == "")) { $values = array(); foreach($categ_content as $asource_id) { $values[] = "(".addslashes($categ_id).", ".addslashes($asource_id).")"; } $values = implode(",", $values); $sql = "INSERT INTO connectors_categ_sources (num_categ, num_source) VALUES ".$values; mysql_query($sql, $dbh) or die (mysql_error()); } show_categories($dbh); break; case 'add': category_form(); break; case 'modif': if($id){ $requete = "SELECT * FROM connectors_categ WHERE connectors_categ_id=".$id; $res = mysql_query($requete, $dbh); if(mysql_num_rows($res)) { $row=mysql_fetch_object($res); $categ_name = $row->connectors_categ_name; $categ_opac_expanded=$row->opac_expanded; category_form($id, $categ_name, $categ_opac_expanded); } } break; case 'del': if ($id) { $ida = addslashes($id); $sql = "DELETE FROM connectors_categ WHERE connectors_categ_id=".$ida; mysql_query($sql, $dbh); $sql = "DELETE FROM connectors_categ_sources WHERE num_categ = ".$ida; mysql_query($sql, $dbh); } show_categories($dbh); break; default: show_categories($dbh); break; } ?>