Source for file xmlsub.php
Documentation is available at xmlsub.php
* File sperimentale che gestisce l'output delle tabelle in XML
* con i record delle sottomaschere
* @desc Output XML comprese le sottomaschere
* @author M.Marcello Verona
* @copyright 2007 M.Marcello Verona
* @license http://www.gnu.org/licenses/gpl.html GNU Public License
require ("../inc/conn.php");
require ("../inc/func.comuni.php");
require ("../inc/func.frontend.php");
require ("../inc/func.xmlize.php");
* Funzione che genera l'XML con anche i record delle sottomaschere.
* Partendo da una tabella prestabilita con anche la gestione
* dei record figli presenti nelle sottomaschere attivate.
* @param int $oid ID della tabella per il gruppo
* @param string $filename Nome della tabella
* @param bool $sub Mostra anche i record delle sottomaschere
* @param int $offset Offset riportato nell'XML
* @param int $tot Totale di record, riportato nell'XML
* @param string $xsl Eventuale foglio di stile da associare
* @param string $dtd Eventuale DTD da associare
* @param bool $header Manda un header di tipo "Content-type=XML" (default: true)
* @return string XML output
* @todo Questa funzione se ottimizzata puņ sostituire la procedura richiamata dal file xml.php
function xmlize_table_sub($oid,$filename= null,$sub= true,$offset= 0,$tot= 0,$xsl= '',$dtd= '',$header= true){
$ORDER_BY = ($cols[2][0]!= '') ? "ORDER BY ". $cols[2][0]. " ". $cols[3][0] : "";
$OFF= ($offset== 0) ? "" : "$offset";
$sql= "SELECT ". implode(",",$cols[0]). " FROM ". $cols[1][0]. " $ORDER_BY $LIMIT";
$XML.= ($header) ? "<?xml version='1.0' encoding='utf-8'?>\n" : "";
$XML.= ($dtd) ? "<!DOCTYPE vfront SYSTEM \"$dtd\">\n" : "";
$XML.= ($xsl!= '') ? "<?xml-stylesheet type=\"text/xsl\" href=\"$xsl\" ?>\n" : "";
$XML.= "<recordset tot=\"$tot\">\n";
$XML.= "\t". xmlize_campo('row',array("offset"=> $offset)). "\n";
foreach($RS as $k=> $val){
$val= "<![CDATA[". $val. "]]>";
if(is_null($filename)) return $XML;
$fp = fopen($filename,"w");
* Funzione di generazione di XML da una sottomaschera
* @param int $id_parent id_table della tabella parent di questa sottomaschera
* @param int $oid ID della sottomaschera considerata
* @param int $gid ID del gruppo considerato
* @param bool $solo_campi_visibili Se vera mostra solo i campi con diritti SELECT della sottomaschera
* @return string Frammento di XML
for($i= 0;$i< count($sub);$i++ ){
$order_sub = ($sub[$i]["orderby_sub"]!= '') ? "ORDER BY ". $sub[$i]["orderby_sub"] : "";
$sql_sub= "SELECT * FROM ". $sub[$i]['nome_tabella']. " WHERE ". $sub[$i]['campo_fk_sub']. "='$id_parent' $order_sub limit 10";
$XMLSUB.= "\t\t<subrecordset tabella=\"". $sub[$i]['nome_tabella']. "\" nomefrontend=\"". $sub[$i]['nome_frontend']. "\">\n";
$XMLSUB.= "\t\t\t". xmlize_campo('subrow',array("offset"=> $offset)). "\n";
foreach($RS as $k=> $val){
$val= "<![CDATA[". $val. "]]>";
$XMLSUB.= "\t\t\t</subrow>\n";
$XMLSUB.= "\t\t</subrecordset>\n";
//header('Content-type: text/xml');
//echo xmlize_table_sub(1,null,true,0,50);
$OID = (int) $_GET['oid'];
$SUB = (bool) $_GET['sub'];
$xsl = (isset ($_GET['type']) && $_GET['type']== 'XML') ? "" : FRONT_DOCROOT. "/xml/". oid2name($OID). "/stile.xml";
// SINGOLO RECORD BASATO SULLA SERIE ORDINATA
// INTERVALLO DI RECORD BASATO SULLA SERIE ORDINATA
elseif(preg_match("'([0-9]+),([0-9]+)'",$_GET['c'],$match)> 0){
// $XML = xmlize("SELECT ".$campi_tabella." FROM $tabella ORDER BY $orderby_doppio LIMIT $offset,$limit",null,true,false,$tot_records,$xsl,$dtd);
elseif($_GET['c']== 'all'){
// $XML = xmlize("SELECT ".$campi_tabella." FROM $tabella ORDER BY $orderby_doppio ",null,true,false,$tot_records,$xsl);
// RECORD PER SINGOLO ID (DA CAMPO PK)
// $XML = xmlize("SELECT ".$campi_tabella." FROM $tabella WHERE $PK=".intval($_GET['id'])." ORDER BY $orderby_doppio ",null,true,false,$tot_records,$xsl,$dtd);
header("Content-Type: text/xml");
|