Source for file rpc.xmlgrid.php
Documentation is available at rpc.xmlgrid.php
* File di gestione della tabella dinamica dhtmlGrid.
* Viene richiamato dallo script {@link scheda.php} e dalle funzioni javascript.
* @author Mario Marcello Verona <marcelloverona@gmail.com>
* @copyright 2007 Mario Marcello Verona
* @license http://www.gnu.org/licenses/gpl.html GNU Public License
require ("./inc/conn.php");
require ("./inc/func.frontend.php");
require ("./inc/func.comuni.php");
* Da una query SQL viene restituito l'XML generato per la griglia dxhtmlGrid
* @param string $filename
function xmlize_grid($sql,$offset= 0,$filename= null,$header= true,$PK= null){
global $link,$_VARIABILI;
$XML= ($header) ? "<?xml version='1.0' encoding='utf-8'?>\n" : "";
# Se è un contesto di ricerca...
$offset_ricerca= $RS['n_offset']+ 1;
$XML.= "\t\t<cell>". $offset_ricerca. "</cell>\n";
# identificativo (offset)
$XML.= "\t\t<cell>". $offset. "</cell>\n";
foreach($RS as $k=> $val){
// Il campo speciale prendi valore imposta l'offset per la ricerca
if(isset ($_VARIABILI['max_char_tabella']) && intval($_VARIABILI['max_char_tabella'])> 0){
if(strlen($val)> $_VARIABILI['max_char_tabella']) $val = substr($val,0,$_VARIABILI['max_char_tabella']). "...";
// togli new line e sostituisci gli spazi
$val = str_replace(array(" ","-","\n","\r","\n\r","\r\n"),array(" "," ","","","",""),$val);
if($val!= '' && !is_numeric($val)) $val= "<![CDATA[". $val. "]]>";
if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) {
header("Content-type: application/xhtml+xml");
header("Content-type: text/xml");
$fp = fopen($filename,"w");
* Genera l'XML dal campo dato con gli eventuali attributi
foreach($attr as $k=> $val){
$attributi .= " $k=\"$val\"";
return "<". $tag. $attributi. ">";
##########################################################################################################
echo "Tabella inesistente";
$OFFSET = (isset ($_GET['rowsLoaded'])) ? intval($_GET['rowsLoaded']) : 0;
// altro modo di prendere l'offset... e sovrascrivo.
$OFFSET = (isset ($_GET['of'])) ? intval($_GET['of']) : $OFFSET;
// $info_campi = prendi_colonne_frontend($tabella,"column_name",false);
$sql_campi_tab= "SELECT column_name FROM {$db1['frontend']}.registro_col c, {$db1['frontend']}.registro_tab t
WHERE c.id_table=t.id_table
AND t.table_name='$tabella'
AND t.gid='". intval($_SESSION['gid']). "'
ORDER BY c.ordinal_position";
list ($column_name) = $info_campi;
include("./inc/func.var_frontend.php");
// Prendi la variabile di LIMIT
$LIMIT = (isset ($_VARIABILI['n_record_tabella']) && ($_VARIABILI['n_record_tabella']> 0))
? $_VARIABILI['n_record_tabella'] : 20;
$campi_vis= implode(',',$column_name);
$ORDERBY = (is_campo($orderby_val)) ? "ORDER BY ". $orderby_val : "";
$ORDERBY = ($orderby_val!= "") ? "ORDER BY ". $orderby_val : "";
// prendi la chiave primaria:
######################################################################
# RISPOSTA DI RICERCA CON MOLTI RISULTATI:
$WHERE = " WHERE $PK IN ('". $ids. "') ";
$orderby_campo = str_replace(array("ASC","DESC"),"",$orderby_val);
$campi_vis_rep = str_replace("$orderby_campo", "$orderby_campo as prendi_valore", $campi_vis);
$sql = "SELECT $PK as pk, $campi_vis ".
######################################################################
$sql= "SELECT $PK as pk, $campi_vis
// xmlize_grid($sql,$OFFSET,'test.xml',true,$PK);
|