Source for file class.xml.php
Documentation is available at class.xml.php
* Logique des fonctionnalités XML
* LODEL - Logiciel d'Edition ELectronique.
* Home page: http://www.lodel.org
* E-Mail: lodel@lodel.org
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* @author Ghislain Picard
* @copyright 2001-2002, Ghislain Picard, Marin Dacos
* @copyright 2003, Ghislain Picard, Marin Dacos, Luc Santeramo, Nicolas Nutten, Anne Gentil-Beccot
* @copyright 2004, Ghislain Picard, Marin Dacos, Luc Santeramo, Anne Gentil-Beccot, Bruno Cénou
* @copyright 2005, Ghislain Picard, Marin Dacos, Luc Santeramo, Gautier Poupeau, Jean Lamy, Bruno Cénou
* @copyright 2006, Marin Dacos, Luc Santeramo, Bruno Cénou, Jean Lamy, Mikaël Cixous, Sophie Malafosse
* @copyright 2007, Marin Dacos, Bruno Cénou, Sophie Malafosse, Pierre-Alain Mignot
* @licence http://www.gnu.org/copyleft/gpl.html
* @since Fichier ajouté depuis la version 0.8
* @version CVS:$Id: class.xml.php 4006 2007-10-05 11:53:41Z malafosse $
* Classe de logique des fonctionnalités XML
* @author Ghislain Picard
* @copyright 2001-2002, Ghislain Picard, Marin Dacos
* @copyright 2003, Ghislain Picard, Marin Dacos, Luc Santeramo, Nicolas Nutten, Anne Gentil-Beccot
* @copyright 2004, Ghislain Picard, Marin Dacos, Luc Santeramo, Anne Gentil-Beccot, Bruno Cénou
* @copyright 2005, Ghislain Picard, Marin Dacos, Luc Santeramo, Gautier Poupeau, Jean Lamy, Bruno Cénou
* @copyright 2006, Marin Dacos, Luc Santeramo, Bruno Cénou, Jean Lamy, Mikaël Cixous, Sophie Malafosse
* @copyright 2007, Marin Dacos, Bruno Cénou, Sophie Malafosse, Pierre-Alain Mignot
* @licence http://www.gnu.org/copyleft/gpl.html
* @since Classe ajouté depuis la version 0.8
$this->Logic ("translations");
* Generate the XML for an entity.
* Must have context['id'] given
die ('ERROR : no id given. Id attribute is required to generate XML file');
//check if the given id is OK
$row = $db->getOne(lq("SELECT 1 FROM #_TP_objects WHERE id='$id' AND class='entities'"));
if (!$row) {//if the object is not an entity do not generate XML
header ("Location: not-found.html"); return;
$row = $db->getRow(lq("SELECT e.id,t.type,t.class FROM #_TP_entities as e, #_TP_types as t WHERE e.id='$id' AND e.idtype=t.id"));
if (!$row) die("Error. Type and Class unknown for this entity");
$context['class'] = $class = $row['class'];
$context['type'] = $row['type'];
$context['identity'] = $id;
require_once ("xmlfunc.php");
// validation shall be implemented in ServOO first. The code here comes from the 0.7 and is not adapted to the lodel 0.8 and higher.
// if ($context['valid']) {
// $contents .= $contents;
// $tmpfile = tempnam ($tmpdir, "lodelxml_");
// writefile($tmpfile.".xml",$contents);
// $contents=calculateXMLSchema ($context);
// writefile ($tmpfile.".xsd", $contents);
// if ($zipcmd && $zipcmd!="pclzip") { // ZIP command
// $errfile=$tmpfile.".err";
// system($zipcmd." $tmpfile.zip $tmpfile.xsd $tmpfile.xml 1>&2 2>$errfile");
// if (filesize($errfile)>0)
// die ("ERROR: $errormsg<br />".str_replace ("\n","<br>", htmlentities (@join ("", @file ($errfile)))));
// @unlink("$tmpfile.err");
// } else {// PCLZIP library.
// require ("pclzip.lib.php");
// $archive = new PclZip ($tmpfile.".zip");
// $v_list = $archive->create (array($tmpfile.".xsd", $tmpfile.".xml"));
// if ($v_list == 0) die ("ERROR : ".$archive->errorInfo(true));
// require ("servoofunc.php");
// $client = new ServOO ();
// if ($client->error_message) {
// if ($context['url']) $error['url']='+';
// if ($context['username'])$error['username']='+';
// if ($context['passwd']) $error['passwd']='+';
// $ret = $client->validateXML("","");
// $ret="Aucun ServOO n'est configuré pour réaliser la conversion. " .
// "Vous pouvez faire la configuration dans les options du site (Administrer/Options)";
// @unlink ($tmpfile.".zip");
// $context['reponse'] = str_replace ("\n","<br />", htmlentities($ret));
// require_once ("calcul-page.php");
// calcul_page ($context,"xml-valid");
download ("", "$class-$id.xml", $contents);
* Generate the XSD Schema for a class
* Must have context['class'] given
die ('ERROR: no class given. Class attribute is required to generate XSD Schema');
//verif if the given class is OK
$class = $context['class'];
$row = $db->getOne (lq ("SELECT id FROM #_TP_classes WHERE class='$class'"));
header ("Location: not-found.html"); return;
$originalname = $context['site']. '-'. $context['class']. '-schema-xml.xsd';
|