[Chameleon] How to include (join) php code in custom widget
Ines
mleonsoft at yahoo.com.ar
Fri Jan 26 08:20:35 EST 2007
Hi, I added that line in index.phtml at the first line but the application
don´t show me errors. With the isset the page is white when I click the
button of the widget:
* widget, it wants to overwrite the gszAppPath with its own
*/
error_reporting(E_ALL);
$gszAppPath = dirname(__FILE__);
include( "../../htdocs/chameleon.php" );
Before I included de code to read the xml file in the widget, I proved the
code out of the widget and it works very well. I have 3 files in the
geointegrator folder (readxml.php, XML.inc.php (the class), archivo4.xml ),
and I execute readxml.php in this way in the Internet Explorer:
http://localhost/wmsviewer/geointegrator/readxml.php
But my problem is when I put the code of readxml.php in the widget. I just
put the code in the widget, and XML.inc.php (the class), archivo4.xml are
still in the geointegrator folder.
As I commented you, all the variables of the code that I included in the
widget (the code of readxml.php), I had to declare in the widget (ex. var
$xml_file;) and access in the in the widget in this way: $this->xml_file
because the application showed errors with the new variables. I corrected
all the new variables in the widget on that way and the application just
show me one error with the XML.inc.php:
if(is_object($this->_actual_tag->$name) ||
is_array($this->_actual_tag->$name)){
This is the structure of muy files/folders:
ms4w/apps/myapp/geointegrator/htdocs:
index.phtml
geointegrator.html (template)
.....etc......
readxml.php (the code to read the xml that I put in the widget)
XML.inc.php (the class)
archivo4.xml (the xml file)
Then in:
ms4w/apps/myapp:
folder admin
folder config
----etc-------
folder geointegrator
folder htdocs:
folder widgets (contain all the widgets folder and UUW folder too)
folder skins
folder images
--- etc---------
----etc----
I send you the complete code of readxml.php, XML.inc.php, archivo4.xml if
you want to prove the code that is working very well out of the widget. And
finally, I send you the code of the widget (UUW.widget.php) with the new
code included.
------------------------------------readxml.php:----------------------------
----------
<?php
require_once("XML.inc.php");
$xml_file="./archivo4.xml";
$xml_data=implode("",file($xml_file));//(result)
$namespace = substr($xml_data, strpos($xml_data, "<content xmlns:")+15,
strpos($xml_data, "=", strpos($xml_data, "<content xmlns:")) -
strpos($xml_data, "<content xmlns:") -15);
$xml_data=str_replace($namespace.":", "", $xml_data);
$xml=new XML();
$xml->parse($xml_data); ///$result
$tot = count($xml->response);
echo "cantidad de etiquetas 'response': $tot <br>";
//$tot = count($xml->version);
//echo "cantidad de etiquetas 'version': $tot <br>";
if($tot > 0)
{
$tot_a = count($xml->response->content);
echo "cantidad de etiquetas 'content': $tot_a <br>";
//$aa= $xml->response->header->_param['xmlns:xsd'];
// echo "Contenido 'content': $aa <br>";
if($tot_a > 0)
{
// $tot_b = count($xml->response->record);
// echo "cantidad de etiquetas 'record':".$tot_b."<br>";
$tot_b = count($xml->response->content->record);
echo "cantidad de etiquetas 'record':".$tot_b."<br>";
if($tot_b > 0)
{
echo "<b>Nombre Buscado</b>: Inga oerstediana <br>";
for($j = 0; $j < $tot_b; $j++)
{
$sc_name = $xml->response->content->record[$j]->ScientificName->_value;
if($sc_name == "Inga oerstediana")
{
$sc_name2= $xml->response->content->record[$j]->ScientificName->_value;
$latitud= $xml->response->content->record[$j]->Latitude->_value;
$longitud= $xml->response->content->record[$j]->Longitude->_value;
echo "<br><br>";
echo "<b>Nombre: </b>".$sc_name2."<br>";
echo "<b>Latitud: </b>".$latitud."<br>";
echo "<b>Longitud: </b>".$longitud."<br>";
exit;
}
}
}
else
{
echo "No hay etiquetas 'record'";
}
}
else
{
echo "No hay etiquetas 'content'";
}
}
else
{
echo "No hay response";
}
?>
-------------------------XML.inc.php----------------------------------------
---------
<?php
/*
* XML.inc.php
*
* Class to convert an XML file into an object
*
* Copyright (C) 2006 Oliver Strecke <oliver.strecke at browsertec.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
class XML{
var $_parser;
var $_xml_data;
var $_actual_tag;
//Constructor...
function xml(){
$this->_parser=xml_parser_create("ISO-8859-1");
$this->_xml_data="";
$this->_actual_tag=$this;
xml_set_object($this->_parser,$this);
xml_parser_set_option($this->_parser,XML_OPTION_CASE_FOLDING,false);
xml_set_element_handler($this->_parser,"tag_open","tag_close");
xml_set_character_data_handler($this->_parser,"tag_data");
xml_set_default_handler($this->_parser,"tag_data");
}
//get XML data from file...
function file_read($xml_file){
if(file_exists($xml_file)){
$this->_xml_data=implode("",file($xml_file));
}
return 1;
}
//parse XML data...
function parse($xml_data=0){
if($xml_data)$this->_xml_data=$xml_data;
xml_parse($this->_parser,$this->_xml_data);
xml_parser_free($this->_parser);
return 1;
}
function tag_open($parser,$name,$attrs){
//create new tag...
$tag=new XML_TAG(&$this->_actual_tag);
$tag->_name=$name;
$tag->_param=$attrs;
//add tag object to parent/actual tag object...
if(is_a($this->_actual_tag,"XML_TAG")){
//if(isset($this->_actual_tag->$name) &&
(is_object($this->_actual_tag->$name) ||
is_array($this->_actual_tag->$name))){
if(is_object($this->_actual_tag->$name) ||
is_array($this->_actual_tag->$name)){
//same child objects -> Array...
$last_index=$this->_actual_tag->new_child_array($tag,$name);
$this->_actual_tag=&$this->_actual_tag->{$name}[$last_index];
}else{
//add new child object to actual tag...
$this->_actual_tag->new_child($tag,$name);
$this->_actual_tag=&$this->_actual_tag->$name;
}
}else{
//copy first tag object in this object...
$this->$name=$tag;
$this->_actual_tag=&$this->{$name};
}
return 1;
}
function tag_data($parser,$string){
if(strlen(trim($string))>0)$this->_actual_tag->_value=$string;
return 1;
}
function tag_close($parser,$name){
$this->_actual_tag=&$this->_actual_tag->_parent;
return 1;
}
//Debug...
function debug($exit=0){
echo "<pre>";
print_r($this);
echo "</pre>";
if($exit)exit;
}
}
class XML_TAG {
var $_parent;
var $_name;
var $_value;
var $_param;
//Constructor...
function xml_tag($parent){
$this->_parent=&$parent;
$this->_name="";
$this->_value=false;
$this->_param=Array();
return 1;
}
//simply add ne child to this object...
function new_child($child,$child_name){
$this->$child_name=&$child;
}
//add child array for more same childs to this object...
function new_child_array($child,$child_name){
//create array and set old child object to the first array element...
if(is_object($this->$child_name)){
$tmp_obj=$this->$child_name;
$this->$child_name=Array();
$this->new_child_array($tmp_obj,$child_name);
}
//push child reference into child array...
$this->{$child_name}[]=&$child;
$last_index=count($this->$child_name)-1;
return $last_index;
}
//Debug...
function debug(){
echo "<pre>";
print_r($this);
echo "</pre>";
}
}
?>
---------------------------------------
archivo4.xml-------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<response xmlns="http://digir.net/schema/protocol/2003/1.0">
<header>
<version>$Revision: 1.17 $</version>
<sendTime>2006-11-09TCentral Ame:rica Standard Time</sendTime>
<source
resource="Nicaragua-HULE">http://10.0.1.216:80/digir/DiGIR.php</source>
<destination>10.0.1.124</destination>
<type>search</type>
</header>
<content xmlns:darwin="http://digir.net/schema/conceptual/darwin/2003/1.0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<record>
<darwin:DateLastModified>2006-10-26TCentral Ame:rica Standard
Time</darwin:DateLastModified>
<darwin:InstitutionCode>HULE</darwin:InstitutionCode>
<darwin:CollectionCode>Plantae</darwin:CollectionCode>
<darwin:CatalogNumber>100187</darwin:CatalogNumber>
<darwin:ScientificName>Inga oerstediana</darwin:ScientificName>
<darwin:BasisOfRecord>S</darwin:BasisOfRecord>
<darwin:Kingdom xsi:nil="true" />
<darwin:Phylum xsi:nil="true" />
<darwin:Class xsi:nil="true" />
<darwin:Order xsi:nil="true" />
<darwin:Family>Fabaceae</darwin:Family>
<darwin:Genus>Inga</darwin:Genus>
<darwin:Species xsi:nil="true" />
<darwin:Subspecies xsi:nil="true" />
<darwin:ScientificNameAuthor>Benth.</darwin:ScientificNameAuthor>
<darwin:IdentifiedBy />
<darwin:YearIdentified xsi:nil="true" />
<darwin:MonthIdentified xsi:nil="true" />
<darwin:DayIdentified xsi:nil="true" />
<darwin:TypeStatus xsi:nil="true" />
<darwin:CollectorNumber>P.P. Moreno 195</darwin:CollectorNumber>
<darwin:FieldNumber xsi:nil="true" />
<darwin:Collector>P.P. Moreno</darwin:Collector>
<darwin:YearCollected>1980</darwin:YearCollected>
<darwin:MonthCollected>5</darwin:MonthCollected>
<darwin:DayCollected>4</darwin:DayCollected>
<darwin:JulianDay xsi:nil="true" />
<darwin:TimeOfDay xsi:nil="true" />
<darwin:ContinentOcean xsi:nil="true" />
<darwin:Country>Nicaragua</darwin:Country>
<darwin:StateProvince xsi:nil="true" />
<darwin:County xsi:nil="true" />
<darwin:Locality>entrada al Hotel Santa Maria de Ostuma, 9 km al NO de
Matagalpa</darwin:Locality>
<darwin:Longitude>-85.933333</darwin:Longitude>
<darwin:Latitude>13</darwin:Latitude>
<darwin:CoordinatePrecision xsi:nil="true" />
<darwin:MinimumElevation>1300</darwin:MinimumElevation>
<darwin:MaximumElevation>1500</darwin:MaximumElevation>
<darwin:MinimumDepth xsi:nil="true" />
<darwin:MaximumDepth xsi:nil="true" />
<darwin:Sex xsi:nil="true" />
<darwin:PreparationType xsi:nil="true" />
<darwin:IndividualCount xsi:nil="true" />
<darwin:PreviousCatalogNumber xsi:nil="true" />
<darwin:RelationshipType xsi:nil="true" />
<darwin:RelatedCatalogItem xsi:nil="true" />
<darwin:Notes xsi:nil="true" />
</record>
<record>
<darwin:DateLastModified>2006-10-26TCentral Ame:rica Standard
Time</darwin:DateLastModified>
<darwin:InstitutionCode>HULE</darwin:InstitutionCode>
<darwin:CollectionCode>Plantae</darwin:CollectionCode>
<darwin:CatalogNumber>100899</darwin:CatalogNumber>
<darwin:ScientificName>Inga densiflora</darwin:ScientificName>
<darwin:BasisOfRecord>S</darwin:BasisOfRecord>
<darwin:Kingdom xsi:nil="true" />
<darwin:Phylum xsi:nil="true" />
<darwin:Class xsi:nil="true" />
<darwin:Order xsi:nil="true" />
<darwin:Family>Fabaceae</darwin:Family>
<darwin:Genus>Inga</darwin:Genus>
<darwin:Species xsi:nil="true" />
<darwin:Subspecies xsi:nil="true" />
<darwin:ScientificNameAuthor>Benth.</darwin:ScientificNameAuthor>
<darwin:IdentifiedBy />
<darwin:YearIdentified xsi:nil="true" />
<darwin:MonthIdentified xsi:nil="true" />
<darwin:DayIdentified xsi:nil="true" />
<darwin:TypeStatus xsi:nil="true" />
<darwin:CollectorNumber>1322</darwin:CollectorNumber>
<darwin:FieldNumber xsi:nil="true" />
<darwin:Collector />
<darwin:YearCollected>1983</darwin:YearCollected>
<darwin:MonthCollected>4</darwin:MonthCollected>
<darwin:DayCollected>30</darwin:DayCollected>
<darwin:JulianDay xsi:nil="true" />
<darwin:TimeOfDay xsi:nil="true" />
<darwin:ContinentOcean xsi:nil="true" />
<darwin:Country>Nicaragua</darwin:Country>
<darwin:StateProvince xsi:nil="true" />
<darwin:County xsi:nil="true" />
<darwin:Locality>Quipó</darwin:Locality>
<darwin:Longitude>-85.044167</darwin:Longitude>
<darwin:Latitude>13.627778</darwin:Latitude>
<darwin:CoordinatePrecision xsi:nil="true" />
<darwin:MinimumElevation>320</darwin:MinimumElevation>
<darwin:MaximumElevation>320</darwin:MaximumElevation>
<darwin:MinimumDepth xsi:nil="true" />
<darwin:MaximumDepth xsi:nil="true" />
<darwin:Sex xsi:nil="true" />
<darwin:PreparationType xsi:nil="true" />
<darwin:IndividualCount xsi:nil="true" />
<darwin:PreviousCatalogNumber xsi:nil="true" />
<darwin:RelationshipType xsi:nil="true" />
<darwin:RelatedCatalogItem xsi:nil="true" />
<darwin:Notes xsi:nil="true" />
</record>
<record>
<darwin:DateLastModified>2006-10-26TCentral Ame:rica Standard
Time</darwin:DateLastModified>
<darwin:InstitutionCode>HULE</darwin:InstitutionCode>
<darwin:CollectionCode>Plantae</darwin:CollectionCode>
<darwin:CatalogNumber>101051</darwin:CatalogNumber>
<darwin:ScientificName>Inga vera</darwin:ScientificName>
<darwin:BasisOfRecord>S</darwin:BasisOfRecord>
<darwin:Kingdom xsi:nil="true" />
<darwin:Phylum xsi:nil="true" />
<darwin:Class xsi:nil="true" />
<darwin:Order xsi:nil="true" />
<darwin:Family>Fabaceae</darwin:Family>
<darwin:Genus>Inga</darwin:Genus>
<darwin:Species xsi:nil="true" />
<darwin:Subspecies xsi:nil="true" />
<darwin:ScientificNameAuthor>Willd.</darwin:ScientificNameAuthor>
<darwin:IdentifiedBy />
<darwin:YearIdentified xsi:nil="true" />
<darwin:MonthIdentified xsi:nil="true" />
<darwin:DayIdentified xsi:nil="true" />
<darwin:TypeStatus xsi:nil="true" />
<darwin:CollectorNumber>1155</darwin:CollectorNumber>
<darwin:FieldNumber xsi:nil="true" />
<darwin:Collector />
<darwin:YearCollected>1983</darwin:YearCollected>
<darwin:MonthCollected>4</darwin:MonthCollected>
<darwin:DayCollected>30</darwin:DayCollected>
<darwin:JulianDay xsi:nil="true" />
<darwin:TimeOfDay xsi:nil="true" />
<darwin:ContinentOcean xsi:nil="true" />
<darwin:Country>Nicaragua</darwin:Country>
<darwin:StateProvince xsi:nil="true" />
<darwin:County xsi:nil="true" />
<darwin:Locality>Río Ulí</darwin:Locality>
<darwin:Longitude>-84.856944</darwin:Longitude>
<darwin:Latitude>13.707222</darwin:Latitude>
<darwin:CoordinatePrecision xsi:nil="true" />
<darwin:MinimumElevation>100</darwin:MinimumElevation>
<darwin:MaximumElevation>100</darwin:MaximumElevation>
<darwin:MinimumDepth xsi:nil="true" />
<darwin:MaximumDepth xsi:nil="true" />
<darwin:Sex xsi:nil="true" />
<darwin:PreparationType xsi:nil="true" />
<darwin:IndividualCount xsi:nil="true" />
<darwin:PreviousCatalogNumber xsi:nil="true" />
<darwin:RelationshipType xsi:nil="true" />
<darwin:RelatedCatalogItem xsi:nil="true" />
<darwin:Notes xsi:nil="true" />
</record>
<record>
<darwin:DateLastModified>2006-10-26TCentral Ame:rica Standard
Time</darwin:DateLastModified>
<darwin:InstitutionCode>HULE</darwin:InstitutionCode>
<darwin:CollectionCode>Plantae</darwin:CollectionCode>
<darwin:CatalogNumber>101093</darwin:CatalogNumber>
<darwin:ScientificName>Inga oerstediana</darwin:ScientificName>
<darwin:BasisOfRecord>S</darwin:BasisOfRecord>
<darwin:Kingdom xsi:nil="true" />
<darwin:Phylum xsi:nil="true" />
<darwin:Class xsi:nil="true" />
<darwin:Order xsi:nil="true" />
<darwin:Family>Fabaceae</darwin:Family>
<darwin:Genus>Inga</darwin:Genus>
<darwin:Species xsi:nil="true" />
<darwin:Subspecies xsi:nil="true" />
<darwin:ScientificNameAuthor>Benth.</darwin:ScientificNameAuthor>
<darwin:IdentifiedBy />
<darwin:YearIdentified xsi:nil="true" />
<darwin:MonthIdentified xsi:nil="true" />
<darwin:DayIdentified xsi:nil="true" />
<darwin:TypeStatus xsi:nil="true" />
<darwin:CollectorNumber>1339</darwin:CollectorNumber>
<darwin:FieldNumber xsi:nil="true" />
<darwin:Collector />
<darwin:YearCollected>1983</darwin:YearCollected>
<darwin:MonthCollected>4</darwin:MonthCollected>
<darwin:DayCollected>30</darwin:DayCollected>
<darwin:JulianDay xsi:nil="true" />
<darwin:TimeOfDay xsi:nil="true" />
<darwin:ContinentOcean xsi:nil="true" />
<darwin:Country>Nicaragua</darwin:Country>
<darwin:StateProvince xsi:nil="true" />
<darwin:County xsi:nil="true" />
<darwin:Locality>Quipó</darwin:Locality>
<darwin:Longitude>-85.044167</darwin:Longitude>
<darwin:Latitude>13.627778</darwin:Latitude>
<darwin:CoordinatePrecision xsi:nil="true" />
<darwin:MinimumElevation>320</darwin:MinimumElevation>
<darwin:MaximumElevation>320</darwin:MaximumElevation>
<darwin:MinimumDepth xsi:nil="true" />
<darwin:MaximumDepth xsi:nil="true" />
<darwin:Sex xsi:nil="true" />
<darwin:PreparationType xsi:nil="true" />
<darwin:IndividualCount xsi:nil="true" />
<darwin:PreviousCatalogNumber xsi:nil="true" />
<darwin:RelationshipType xsi:nil="true" />
<darwin:RelatedCatalogItem xsi:nil="true" />
<darwin:Notes xsi:nil="true" />
</record>
<record>
<darwin:DateLastModified>2006-10-26TCentral Ame:rica Standard
Time</darwin:DateLastModified>
<darwin:InstitutionCode>HULE</darwin:InstitutionCode>
<darwin:CollectionCode>Plantae</darwin:CollectionCode>
<darwin:CatalogNumber>101149</darwin:CatalogNumber>
<darwin:ScientificName>Inga goldmanii</darwin:ScientificName>
<darwin:BasisOfRecord>S</darwin:BasisOfRecord>
<darwin:Kingdom xsi:nil="true" />
<darwin:Phylum xsi:nil="true" />
<darwin:Class xsi:nil="true" />
<darwin:Order xsi:nil="true" />
<darwin:Family>Fabaceae</darwin:Family>
<darwin:Genus>Inga</darwin:Genus>
<darwin:Species xsi:nil="true" />
<darwin:Subspecies xsi:nil="true" />
<darwin:ScientificNameAuthor>Pittier</darwin:ScientificNameAuthor>
<darwin:IdentifiedBy />
<darwin:YearIdentified xsi:nil="true" />
<darwin:MonthIdentified xsi:nil="true" />
<darwin:DayIdentified xsi:nil="true" />
<darwin:TypeStatus xsi:nil="true" />
<darwin:CollectorNumber>1255</darwin:CollectorNumber>
<darwin:FieldNumber xsi:nil="true" />
<darwin:Collector />
<darwin:YearCollected>1983</darwin:YearCollected>
<darwin:MonthCollected>4</darwin:MonthCollected>
<darwin:DayCollected>30</darwin:DayCollected>
<darwin:JulianDay xsi:nil="true" />
<darwin:TimeOfDay xsi:nil="true" />
<darwin:ContinentOcean xsi:nil="true" />
<darwin:Country>Nicaragua</darwin:Country>
<darwin:StateProvince xsi:nil="true" />
<darwin:County xsi:nil="true" />
<darwin:Locality>Río Danlí</darwin:Locality>
<darwin:Longitude>-84.887778</darwin:Longitude>
<darwin:Latitude>13.696667</darwin:Latitude>
<darwin:CoordinatePrecision xsi:nil="true" />
<darwin:MinimumElevation>100</darwin:MinimumElevation>
<darwin:MaximumElevation>100</darwin:MaximumElevation>
<darwin:MinimumDepth xsi:nil="true" />
<darwin:MaximumDepth xsi:nil="true" />
<darwin:Sex xsi:nil="true" />
<darwin:PreparationType xsi:nil="true" />
<darwin:IndividualCount xsi:nil="true" />
<darwin:PreviousCatalogNumber xsi:nil="true" />
<darwin:RelationshipType xsi:nil="true" />
<darwin:RelatedCatalogItem xsi:nil="true" />
<darwin:Notes xsi:nil="true" />
</record>
<record>
<darwin:DateLastModified>2006-10-26TCentral Ame:rica Standard
Time</darwin:DateLastModified>
<darwin:InstitutionCode>HULE</darwin:InstitutionCode>
<darwin:CollectionCode>Plantae</darwin:CollectionCode>
<darwin:CatalogNumber>101159</darwin:CatalogNumber>
<darwin:ScientificName>Inga</darwin:ScientificName>
<darwin:BasisOfRecord>S</darwin:BasisOfRecord>
<darwin:Kingdom xsi:nil="true" />
<darwin:Phylum xsi:nil="true" />
<darwin:Class xsi:nil="true" />
<darwin:Order xsi:nil="true" />
<darwin:Family>Fabaceae</darwin:Family>
<darwin:Genus>Inga</darwin:Genus>
<darwin:Species xsi:nil="true" />
<darwin:Subspecies xsi:nil="true" />
<darwin:ScientificNameAuthor />
<darwin:IdentifiedBy />
<darwin:YearIdentified xsi:nil="true" />
<darwin:MonthIdentified xsi:nil="true" />
<darwin:DayIdentified xsi:nil="true" />
<darwin:TypeStatus xsi:nil="true" />
<darwin:CollectorNumber>P.P. Moreno 272</darwin:CollectorNumber>
<darwin:FieldNumber xsi:nil="true" />
<darwin:Collector>P.P. Moreno</darwin:Collector>
<darwin:YearCollected>1980</darwin:YearCollected>
<darwin:MonthCollected>5</darwin:MonthCollected>
<darwin:DayCollected>10</darwin:DayCollected>
<darwin:JulianDay xsi:nil="true" />
<darwin:TimeOfDay xsi:nil="true" />
<darwin:ContinentOcean xsi:nil="true" />
<darwin:Country>Nicaragua</darwin:Country>
<darwin:StateProvince xsi:nil="true" />
<darwin:County xsi:nil="true" />
<darwin:Locality>Cerro Mombachito</darwin:Locality>
<darwin:Longitude>-85.55</darwin:Longitude>
<darwin:Latitude>12.4</darwin:Latitude>
<darwin:CoordinatePrecision xsi:nil="true" />
<darwin:MinimumElevation>900</darwin:MinimumElevation>
<darwin:MaximumElevation>1000</darwin:MaximumElevation>
<darwin:MinimumDepth xsi:nil="true" />
<darwin:MaximumDepth xsi:nil="true" />
<darwin:Sex xsi:nil="true" />
<darwin:PreparationType xsi:nil="true" />
<darwin:IndividualCount xsi:nil="true" />
<darwin:PreviousCatalogNumber xsi:nil="true" />
<darwin:RelationshipType xsi:nil="true" />
<darwin:RelatedCatalogItem xsi:nil="true" />
<darwin:Notes xsi:nil="true" />
</record>
<record>
<darwin:DateLastModified>2006-10-26TCentral Ame:rica Standard
Time</darwin:DateLastModified>
<darwin:InstitutionCode>HULE</darwin:InstitutionCode>
<darwin:CollectionCode>Plantae</darwin:CollectionCode>
<darwin:CatalogNumber>101202</darwin:CatalogNumber>
<darwin:ScientificName>Inga oerstediana</darwin:ScientificName>
<darwin:BasisOfRecord>S</darwin:BasisOfRecord>
<darwin:Kingdom xsi:nil="true" />
<darwin:Phylum xsi:nil="true" />
<darwin:Class xsi:nil="true" />
<darwin:Order xsi:nil="true" />
<darwin:Family>Fabaceae</darwin:Family>
<darwin:Genus>Inga</darwin:Genus>
<darwin:Species xsi:nil="true" />
<darwin:Subspecies xsi:nil="true" />
<darwin:ScientificNameAuthor>Benth.</darwin:ScientificNameAuthor>
<darwin:IdentifiedBy />
<darwin:YearIdentified xsi:nil="true" />
<darwin:MonthIdentified xsi:nil="true" />
<darwin:DayIdentified xsi:nil="true" />
<darwin:TypeStatus xsi:nil="true" />
<darwin:CollectorNumber>P.P. Moreno 280</darwin:CollectorNumber>
<darwin:FieldNumber xsi:nil="true" />
<darwin:Collector>P.P. Moreno</darwin:Collector>
<darwin:YearCollected>1980</darwin:YearCollected>
<darwin:MonthCollected>5</darwin:MonthCollected>
<darwin:DayCollected>10</darwin:DayCollected>
<darwin:JulianDay xsi:nil="true" />
<darwin:TimeOfDay xsi:nil="true" />
<darwin:ContinentOcean xsi:nil="true" />
<darwin:Country>Nicaragua</darwin:Country>
<darwin:StateProvince xsi:nil="true" />
<darwin:County xsi:nil="true" />
<darwin:Locality>Cerro Mombachito</darwin:Locality>
<darwin:Longitude>-85.55</darwin:Longitude>
<darwin:Latitude>12.4</darwin:Latitude>
<darwin:CoordinatePrecision xsi:nil="true" />
<darwin:MinimumElevation>900</darwin:MinimumElevation>
<darwin:MaximumElevation>1000</darwin:MaximumElevation>
<darwin:MinimumDepth xsi:nil="true" />
<darwin:MaximumDepth xsi:nil="true" />
<darwin:Sex xsi:nil="true" />
<darwin:PreparationType xsi:nil="true" />
<darwin:IndividualCount xsi:nil="true" />
<darwin:PreviousCatalogNumber xsi:nil="true" />
<darwin:RelationshipType xsi:nil="true" />
<darwin:RelatedCatalogItem xsi:nil="true" />
<darwin:Notes xsi:nil="true" />
</record>
<record>
<darwin:DateLastModified>2006-10-26TCentral Ame:rica Standard
Time</darwin:DateLastModified>
<darwin:InstitutionCode>HULE</darwin:InstitutionCode>
<darwin:CollectionCode>Plantae</darwin:CollectionCode>
<darwin:CatalogNumber>101313</darwin:CatalogNumber>
<darwin:ScientificName>Inga vera</darwin:ScientificName>
<darwin:BasisOfRecord>S</darwin:BasisOfRecord>
<darwin:Kingdom xsi:nil="true" />
<darwin:Phylum xsi:nil="true" />
<darwin:Class xsi:nil="true" />
<darwin:Order xsi:nil="true" />
<darwin:Family>Fabaceae</darwin:Family>
<darwin:Genus>Inga</darwin:Genus>
<darwin:Species xsi:nil="true" />
<darwin:Subspecies xsi:nil="true" />
<darwin:ScientificNameAuthor>Willd.</darwin:ScientificNameAuthor>
<darwin:IdentifiedBy />
<darwin:YearIdentified xsi:nil="true" />
<darwin:MonthIdentified xsi:nil="true" />
<darwin:DayIdentified xsi:nil="true" />
<darwin:TypeStatus xsi:nil="true" />
<darwin:CollectorNumber>1020</darwin:CollectorNumber>
<darwin:FieldNumber xsi:nil="true" />
<darwin:Collector />
<darwin:YearCollected>1983</darwin:YearCollected>
<darwin:MonthCollected>4</darwin:MonthCollected>
<darwin:DayCollected>30</darwin:DayCollected>
<darwin:JulianDay xsi:nil="true" />
<darwin:TimeOfDay xsi:nil="true" />
<darwin:ContinentOcean xsi:nil="true" />
<darwin:Country>Nicaragua</darwin:Country>
<darwin:StateProvince xsi:nil="true" />
<darwin:County xsi:nil="true" />
<darwin:Locality>Rosa Grande, Río Labú (río abajo)</darwin:Locality>
<darwin:Longitude>-84.986944</darwin:Longitude>
<darwin:Latitude>13.651944</darwin:Latitude>
<darwin:CoordinatePrecision xsi:nil="true" />
<darwin:MinimumElevation>300</darwin:MinimumElevation>
<darwin:MaximumElevation>300</darwin:MaximumElevation>
<darwin:MinimumDepth xsi:nil="true" />
<darwin:MaximumDepth xsi:nil="true" />
<darwin:Sex xsi:nil="true" />
<darwin:PreparationType xsi:nil="true" />
<darwin:IndividualCount xsi:nil="true" />
<darwin:PreviousCatalogNumber xsi:nil="true" />
<darwin:RelationshipType xsi:nil="true" />
<darwin:RelatedCatalogItem xsi:nil="true" />
<darwin:Notes xsi:nil="true" />
</record>
<record>
<darwin:DateLastModified>2006-10-26TCentral Ame:rica Standard
Time</darwin:DateLastModified>
<darwin:InstitutionCode>HULE</darwin:InstitutionCode>
<darwin:CollectionCode>Plantae</darwin:CollectionCode>
<darwin:CatalogNumber>101326</darwin:CatalogNumber>
<darwin:ScientificName>Inga ruiziana</darwin:ScientificName>
<darwin:BasisOfRecord>S</darwin:BasisOfRecord>
<darwin:Kingdom xsi:nil="true" />
<darwin:Phylum xsi:nil="true" />
<darwin:Class xsi:nil="true" />
<darwin:Order xsi:nil="true" />
<darwin:Family>Fabaceae</darwin:Family>
<darwin:Genus>Inga</darwin:Genus>
<darwin:Species xsi:nil="true" />
<darwin:Subspecies xsi:nil="true" />
<darwin:ScientificNameAuthor>G.Don</darwin:ScientificNameAuthor>
<darwin:IdentifiedBy />
<darwin:YearIdentified xsi:nil="true" />
<darwin:MonthIdentified xsi:nil="true" />
<darwin:DayIdentified xsi:nil="true" />
<darwin:TypeStatus xsi:nil="true" />
<darwin:CollectorNumber>1289</darwin:CollectorNumber>
<darwin:FieldNumber xsi:nil="true" />
<darwin:Collector />
<darwin:YearCollected>1983</darwin:YearCollected>
<darwin:MonthCollected>4</darwin:MonthCollected>
<darwin:DayCollected>30</darwin:DayCollected>
<darwin:JulianDay xsi:nil="true" />
<darwin:TimeOfDay xsi:nil="true" />
<darwin:ContinentOcean xsi:nil="true" />
<darwin:Country>Nicaragua</darwin:Country>
<darwin:StateProvince xsi:nil="true" />
<darwin:County xsi:nil="true" />
<darwin:Locality>Amparo</darwin:Locality>
<darwin:Longitude>-84.822222</darwin:Longitude>
<darwin:Latitude>13.666667</darwin:Latitude>
<darwin:CoordinatePrecision xsi:nil="true" />
<darwin:MinimumElevation>130</darwin:MinimumElevation>
<darwin:MaximumElevation>160</darwin:MaximumElevation>
<darwin:MinimumDepth xsi:nil="true" />
<darwin:MaximumDepth xsi:nil="true" />
<darwin:Sex xsi:nil="true" />
<darwin:PreparationType xsi:nil="true" />
<darwin:IndividualCount xsi:nil="true" />
<darwin:PreviousCatalogNumber xsi:nil="true" />
<darwin:RelationshipType xsi:nil="true" />
<darwin:RelatedCatalogItem xsi:nil="true" />
<darwin:Notes xsi:nil="true" />
</record>
<record>
<darwin:DateLastModified>2006-10-26TCentral Ame:rica Standard
Time</darwin:DateLastModified>
<darwin:InstitutionCode>HULE</darwin:InstitutionCode>
<darwin:CollectionCode>Plantae</darwin:CollectionCode>
<darwin:CatalogNumber>101333</darwin:CatalogNumber>
<darwin:ScientificName>Inga samanensis</darwin:ScientificName>
<darwin:BasisOfRecord>S</darwin:BasisOfRecord>
<darwin:Kingdom xsi:nil="true" />
<darwin:Phylum xsi:nil="true" />
<darwin:Class xsi:nil="true" />
<darwin:Order xsi:nil="true" />
<darwin:Family>Fabaceae</darwin:Family>
<darwin:Genus>Inga</darwin:Genus>
<darwin:Species xsi:nil="true" />
<darwin:Subspecies xsi:nil="true" />
<darwin:ScientificNameAuthor>L. Uribe</darwin:ScientificNameAuthor>
<darwin:IdentifiedBy />
<darwin:YearIdentified xsi:nil="true" />
<darwin:MonthIdentified xsi:nil="true" />
<darwin:DayIdentified xsi:nil="true" />
<darwin:TypeStatus xsi:nil="true" />
<darwin:CollectorNumber>2092</darwin:CollectorNumber>
<darwin:FieldNumber xsi:nil="true" />
<darwin:Collector />
<darwin:YearCollected>1984</darwin:YearCollected>
<darwin:MonthCollected>8</darwin:MonthCollected>
<darwin:DayCollected>30</darwin:DayCollected>
<darwin:JulianDay xsi:nil="true" />
<darwin:TimeOfDay xsi:nil="true" />
<darwin:ContinentOcean xsi:nil="true" />
<darwin:Country>Nicaragua</darwin:Country>
<darwin:StateProvince xsi:nil="true" />
<darwin:County xsi:nil="true" />
<darwin:Locality>Sector de Coperna; 13 |140 N, 84 |132 W. Alt. menos de
200 m.</darwin:Locality>
<darwin:Longitude>-84.533333</darwin:Longitude>
<darwin:Latitude>13.666667</darwin:Latitude>
<darwin:CoordinatePrecision xsi:nil="true" />
<darwin:MinimumElevation>200</darwin:MinimumElevation>
<darwin:MaximumElevation>200</darwin:MaximumElevation>
<darwin:MinimumDepth xsi:nil="true" />
<darwin:MaximumDepth xsi:nil="true" />
<darwin:Sex xsi:nil="true" />
<darwin:PreparationType xsi:nil="true" />
<darwin:IndividualCount xsi:nil="true" />
<darwin:PreviousCatalogNumber xsi:nil="true" />
<darwin:RelationshipType xsi:nil="true" />
<darwin:RelatedCatalogItem xsi:nil="true" />
<darwin:Notes xsi:nil="true" />
</record>
</content>
<diagnostics>
<diagnostic code="Unknown PHP Error [8]" severity="warn">Use of undefined
constant DIGIR_STATISTICS_TRACKING - assumed 'DIGIR_STATISTICS_TRACKING'
(C:\opt\digirpro\DiGIRprov\www\DiGIR.php:541)</diagnostic>
<diagnostic code="Unknown PHP Error [8]" severity="warn">Use of undefined
constant DIGIR_STATISTICS_PATH - assumed 'DIGIR_STATISTICS_PATH'
(C:\opt\digirpro\DiGIRprov\www\DiGIR.php:543)</diagnostic>
<diagnostic code="Unknown PHP Error [8]" severity="warn">Use of undefined
constant DIGIR_STATISTICS_PATH - assumed 'DIGIR_STATISTICS_PATH'
(C:\opt\digirpro\DiGIRprov\www\DiGIR.php:545)</diagnostic>
<diagnostic code="Unknown PHP Error [2]" severity="warn">touch(): Unable
to create file DIGIR_STATISTICS_PATH/2006_11.tbl because No such file or
directory (C:\opt\digirpro\DiGIRprov\www\DiGIR.php:545)</diagnostic>
<diagnostic code="Unknown PHP Error [8]" severity="warn">Use of undefined
constant DIGIR_STATISTICS_PATH - assumed 'DIGIR_STATISTICS_PATH'
(C:\opt\digirpro\DiGIRprov\www\DiGIR.php:548)</diagnostic>
<diagnostic code="STATUS_INTERVAL" severity="info">600</diagnostic>
<diagnostic code="STATUS_DATA" severity="info">0,1,0</diagnostic>
<diagnostic code="MATCH_COUNT" severity="info">585</diagnostic>
<diagnostic code="RECORD_COUNT" severity="info">10</diagnostic>
<diagnostic code="END_OF_RECORDS" severity="info">false</diagnostic>
</diagnostics>
</response>
----------------------------
UUW.widget.php-----------------------------------------
<?php
// inherit from the NavTool
include_once(dirname(__FILE__)."/../NavTool.php");
//include( 'utils.inc.php' );
require_once('XML.inc.php');
/**
____________________________________________________________________________
_
|
| "UUW" Widget Class
|___________________________________________________________________________
__
**/
class UUW extends NavTool
{
// define member vars
// i.e. var $mszMyVariable;
var $x;
var $y;
var $mszCoords;
var $poLayer;
var $pt;
var $ln;
var $shp;
var $pt;
var $ln;
var $shp;
//Variables requeridas para leer el XML
var $xml_file;
var $xml_data;
var $namespace;
var $xml;
var $tot;
var $tot_a;
var $tot_b;
var $sc_name;
var $j;
var $sc_name2;
var $latitud;
var $longitud;
//Variables lee XML2
var $xml_fuente;
var $xml_busqueda;
var $res;
var $key;
var $val;
var $archivo_xml;
var $f;
var $contenido;
var $registros;
var $cant;
var $ini;
var $fin;
var $record;
var $ini2;
var $fin2;
var $cant;
var $poscont;
var $registros;
var $archivo_xml;
var $f;
var $especie;
var $espe;
var $v;
var $archivo;
var $fp;
//var $contenido;
var $write;
/**
_________________________________________________________________________
|
| Constructor: "UUW" Widget Class
|_________________________________________________________________________
**/
function UUW()
{
// set the language file
$this->mszLanguageResource = dirname(__FILE__).'/UUW.dbf';
// invoke constructor of parent
parent::NavTool();
$this->SetNavCommand('UUW');
$this->maAttributes['COORDS'] =
new StringAttribute( 'COORDS', true, array( 'aa' ) );
// set the description for this widget
$this->szWidgetDescription = <<<EOT
This is the UUW.
EOT;
// set the maturity level
$this->mnMaturityLevel = MATURITY_ALPHA;
// end constructor
}
function InitDefaults()
{
// init defaults for parent
parent::InitDefaults();
$this->mszCoords = isset( $this->maParams['COORDS'] )?
$this->maParams['COORDS'] : '';
// end InitDefaults function.
}
function ParseURL()
{
// execute parent function
parent::ParseURL();
// work some magic
if ( $this->isVarSet( "NAV_CMD" ) &&
$this->getVar( "NAV_CMD" ) == 'UUW' )
{
if ( $this->mszCoords == 'aa')
{
$this->xml_file='./archivo4.xml';
$this->xml_data=implode("",file($this->xml_file));
$this->namespace = substr($this->xml_data, strpos($this->xml_data,
"<content xmlns:")+15, strpos($this->xml_data, "=", strpos($this->xml_data,
"<content xmlns:")) - strpos($this->xml_data, "<content xmlns:") -15);
$this->xml_data=str_replace($this->namespace.":", "", $this->xml_data);
$this->xml=new XML();
$this->xml->parse($this->xml_data);
$this->tot = count($this->xml->response);
if($this->tot > 0)
{
$this->tot_a = count($this->xml->response->content);
if($this->tot_a > 0)
{
$this->tot_b = count($this->xml->response->content->record);
if($this->tot_b > 0)
{
for($this->j = 0; $this->j < $this->tot_b; $this->j++)
{
$this->sc_name =
$this->xml->response->content->record[$this->j]->ScientificName->_value;
if($this->sc_name == "Inga oerstediana")
{
$this->sc_name2=
$this->xml->response->content->record[$this->j]->ScientificName->_value;
$this->latitud=
$this->xml->response->content->record[$this->j]->Latitude->_value;
$this->longitud=
$this->xml->response->content->record[$this->j]->Longitude->_value;
exit;
}
}
}
else
{
return false;
}
}
else
{
return false;
}
}
else
{
return false;
}
$this->x = $this->longitud;
$this->y = $this->latitud;
//$this->lb = $this->getVar('especie');
if ($this->isVarSet('espe') == 0)
{
$this->lb = "no";
}
else
{
$this->lb = $this->getVar('espe');
}
$poLayer = $this->moMapObject->oMap->getLayerByName('pointlatlon');
$poLayer->set("status", MS_ON);
$pt = ms_newPointObj();
$ln = ms_newLineObj();
$shp = ms_newShapeObj(MS_SHAPE_POINT);
$shp->set("text", $this->lb);
$pt->setXY($this->x,$this->y);
$ln->add($pt);
$shp->add($ln);
$poLayer->addFeature($shp);
}
}
// return success
return true;
}
function DrawPublish()
{
// init vars
$szReturn = "<font color='#000000' size='2' face='Arial, Helvetica,
sans-serif'>Search by scientific name </font><input type='text'
name='especie' > ";
$this->espe= $this->getVar('especie');
// execute parent
$szReturn .= parent::DrawPublish();
// return
return $szReturn;
// end DrawPublish() function
}
/**
_________________________________________________________________________
|
| GetHTMLHiddenVariables()
|
| OPTIONAL - Use this function to define any hidden html form
variables
| required by the widget.
|
| Postcondition: This function defines html form variables and adds
| them to the array.
|
| Example:
|
| $szVariable = "MY_HIDDEN_VAR";
| $szValue = " <INPUT TYPE=HIDDEN NAME=$szVariable VALUE=\"0\">";
| $aReturn[$szVariable] = $szValue;
|
| @return Array - Array of html form variables.
| @desc Defines html form variables.
|_________________________________________________________________________
**/
/** REMOVE THIS LINE TO USE THIS FUNCTION
function GetHTMLHiddenVariables()
{
// init vars
$aReturn = parent::GetHTMLHiddenVariables();
///////// ADD CODE HERE IF NECESSARY /////////
// return
return $aReturn;
// end GetHTMLHiddenVariables() function
}
/**
_________________________________________________________________________
|
| GetJavascriptIncludeFunctions()
|
| OPTIONAL - Use this function to include any external javascript
files
| that are required by the widget.
|
| Postcondition: This function defines the javascript include
statements.
|
| Example:
|
| $szVar = "myjavascript.js";
| $aReturn[$szVar] = '<script src="http://myjavascript.js"
|
type="text/javascript"></script>';
|
|
| @return Array - Array of include statements.
| @desc Defines javascript include statements.
|_________________________________________________________________________
**/
/** REMOVE THIS LINE TO USE THIS FUNCTION
function GetJavascriptIncludeFunctions()
{
// init vars
$aReturn = parent::GetJavascriptIncludeFunctions();
///////// ADD CODE HERE IF NECESSARY /////////
// return
return $aReturn;
// end GetJavascriptIncludeFunctions() function
}
/**
_________________________________________________________________________
|
| GetJavascriptVariables()
|
| OPTIONAL - Use this function to define any javascript variables that
| are required by this widget.
|
| Postcondition: This function defines javascript variables and adds
| them to the array.
|
| Example:
|
| $aReturn['MyJSVar'] = 'var szMyJSVar = "Default Value";'."\n";
|
| @return Array - Array of javascript variables.
| @desc Defines javascript variables.
|_________________________________________________________________________
**/
/** REMOVE THIS LINE TO USE THIS FUNCTION
function GetJavascriptVariables()
{
// init vars
$aReturn = parent::GetJavascriptVariables();
///////// ADD CODE HERE IF NECESSARY /////////
// return
return $aReturn;
// end GetJavascriptVariables() function
}
/**
_________________________________________________________________________
|
| GetJavascriptFunctions()
|
| OPTIONAL - Use this function to define all javascript functions
needed
| by this widget
|
| Postcondition: This function defines javascript functions and adds
| them to the array.
|
| Example:
|
| $szJsFunctionName = "myJSFunction";
| $szFunction = <<<EOT
| function {$szJsFunctionName}()
| {
| alert('myJSFunction');
| return true;
| }
| EOT;
| $aReturn[$szJsFunctionName] = $szFunction;
|
|
| @return Array - Array of javascript functions.
| @desc Defines javascript functions.
|_________________________________________________________________________
**/
/**
function GetJavascriptFunctions()
{
// init vars
$aReturn = parent::GetJavascriptFunctions();
// return
return $aReturn;
// end GetJavascriptFunctions() function
}
/**
_________________________________________________________________________
|
| GetJavascriptInitFunctions()
|
| OPTIONAL - Use this function to define a list of functions that need
| to run to initialize this widget's javascript variables.
|
| Postcondition: This function defines the list javascript functions
| and adds them to the array.
|
| Example:
|
| $aReturn['MyInitFunction'] = "MyInitFunction();\n";
|
| @return Array - Array of javascript functions.
| @desc Defines javascript functions.
|_________________________________________________________________________
**/
/** REMOVE THIS LINE TO USE THIS FUNCTION
function GetJavascriptInitFunctions()
{
// call parent function
$aReturn = parent::GetJavascriptInitFunctions();
///////// ADD CODE HERE IF NECESSARY /////////
// return
return $aReturn;
// end GetJavascriptInitFunctions() function
}
/**
_________________________________________________________________________
|
| GetJavascriptOnLoadFunctions()
|
| OPTIONAL - Use this function to define the list of javascript
functions
| to execute in the onload function of the widget.
|
| Postcondition: This function defines javascript functions and adds
| them to the array.
|
| Example:
|
| $aReturn['MyOnloadFunction'] = "MyOnloadFunction();\n";
|
| @return Array - Array of javascript functions.
| @desc Defines javascript functions.
|_________________________________________________________________________
**/
/**
function GetJavascriptOnLoadFunctions()
{
// init vars
$aReturn = parent::GetJavascriptOnLoadFunctions();
///////// ADD CODE HERE IF NECESSARY /////////
// return
return $aReturn;
// end GetJavascriptOnLoadFunctions() function
}
/**
_________________________________________________________________________
|
| GetJavascriptOnMouseMoveFunctions()
|
| OPTIONAL - Use this function to define the list of javascript
functions
| to execute on a mouse move event.
|
| Postcondition: This function defines mouse move functions and adds
| them to the array.
|
| Example:
|
| $szJsFunctionName = "MyMouseMove";
| $szFunction = "$szJsFunctionName(e);\n";
| $aReturn[$szJsFunctionName] = $szFunction;
|
| @return Array - Array of mouse move functions.
| @desc Defines mouse move functions.
|_________________________________________________________________________
**/
/** REMOVE THIS LINE TO USE THIS FUNCTION
function GetJavascriptOnMouseMoveFunctions()
{
// init vars
$aReturn = parent::GetJavascriptOnMouseMoveFunctions();
///////// ADD CODE HERE IF NECESSARY /////////
// return
return $aReturn;
// end GetJavascriptOnMouseMoveFunctions() function
}
/** **/
// end "UUW"
}
?>
Thank you very much again
Ines
-----Mensaje original-----
De: Julien-Samuel Lacroix [mailto:jlacroix at mapgears.com]
Enviado el: jueves, 25 de enero de 2007 11:57
Para: Ines
CC: chameleon at lists.maptools.org
Asunto: Re: [Chameleon] How to include (join) php code in custom widget
There's probably a php error and your php installation is probably
configured to not show them.
Try adding the following at the begining of your index.phtml file (or
whatever the file name is):
error_reporting(E_ALL);
Julien
Ines wrote:
> Hi, I tried with adding the isset, but when I run the widget, it goes to a
> white page. Don't show me the application and don´t show me the errors,
just
> a white page whit no content. I don´t know why. What another thing it
could
> be? I checked the files(archivo4.xml, XML.inc.php), the locations and
> everything seems right. That two files are in the htdocs folder of my
> aplication.
>
> Thanks again
> Ines
>
>
>
>
> -----Mensaje original-----
> De: Julien-Samuel Lacroix [mailto:jlacroix at mapgears.com]
> Enviado el: martes, 23 de enero de 2007 9:09
> Para: Ines
> CC: chameleon at lists.maptools.org
> Asunto: Re: [Chameleon] How to include (join) php code in custom widget
>
>
> Hi,
>
> I think the problem is caused by the fact that sometimes
> $this->_actual_tag->$name doesn't exist. By adding an isset at line 66
> you should solve the problem.
>
> if(isset($this->_actual_tag->$name) &&
> (is_object($this->_actual_tag->$name) ||
> is_array($this->_actual_tag->$name))){
>
> Julien
>
> Ines wrote:
>
>>Julien, I tried puting the code just where you tell me. But I had errors
>>with the variables of my new code. The application don't recognize all the
>>new variables, for example: $xml_file (the first new variable) and the
>>others.
>>
>>So,
>>
>>1) I declared all the new variables in: class UUW extends NavTool:
>>
>>var $xml_file;
>>var $xml_data;
>>var $namespace;
>>var $xml;
>>............etc.
>>
>>2) I access at the new variables in this way:
>>
>>Example: variable: $xml_file
>>I access in this way: $this->xml_file
>>
>>Now, the application don't show me errors with the new variables. Is 1)
>
> and
>
>>2) right?
>>
>>But the application show me one error in the required file
>>(require_once('XML.inc.php'), class to use the new code:
>>
>>It could be a problem between the objects?
>>
>>
>>I send you:
>>
>>A) The error
>>B) The new code into the widget with all the "$this->variablexx" access
>>C) The file 'XML.inc.php' with the line 66 marked
>>
>>A)
>>
>>This is the error, all the errors at the line 66. It marks all the xml
>
> tags
>
>>(header, version, etc)
>>
>>Notice: Undefined property: header in
>>D:\ms4w\apps\wmsviewer\geointegrator\htdocs\XML.inc.php on line 66
>>Notice: Undefined property: header in
>>D:\ms4w\apps\wmsviewer\geointegrator\htdocs\XML.inc.php on line 66
>>Notice: Undefined property: version in
>>D:\ms4w\apps\wmsviewer\geointegrator\htdocs\XML.inc.php on line 66
>>Notice: Undefined property: version in
>>D:\ms4w\apps\wmsviewer\geointegrator\htdocs\XML.inc.php on line 66
>>Notice: Undefined property: sendTime in
>>D:\ms4w\apps\wmsviewer\geointegrator\htdocs\XML.inc.php on line 66
>>Notice: Undefined property: sendTime in
>>D:\ms4w\apps\wmsviewer\geointegrator\htdocs\XML.inc.php on line 66
>>Notice: Undefined property: source in
>>D:\ms4w\apps\wmsviewer\geointegrator\htdocs\XML.inc.php on line 66
>>Notice: Undefined property: source in
>>D:\ms4w\apps\wmsviewer\geointegrator\htdocs\XML.inc.php on line 66
>>Notice: Undefined property: destination in
>>D:\ms4w\apps\wmsviewer\geointegrator\htdocs\XML.inc.php on line 66
>>Notice: Undefined property: destination in
>>D:\ms4w\apps\wmsviewer\geointegrator\htdocs\XML.inc.php on line 66
>>Notice: Undefined property: type in
>>D:\ms4w\apps\wmsviewer\geointegrator\htdocs\XML.inc.php on line 66
>>Notice: Undefined property: type in
>>D:\ms4w\apps\wmsviewer\geointegrator\htdocs\XML.inc.php on line 66
>>Notice: Undefined property: content in
>>D:\ms4w\apps\wmsviewer\geointegrator\htdocs\XML.inc.php on line 66
>>Notice: Undefined property: content in
>>D:\ms4w\apps\wmsviewer\geointegrator\htdocs\XML.inc.php on line 66
>>................etc
>>--------------------------------------------------------------------------
>
> --
>
>>------------------
>>
>>B)
>>
>>if ( $this->isVarSet( "NAV_CMD" ) &&
>> $this->getVar( "NAV_CMD" ) == 'UUW' )
>>{
>>
>> if ( $this->mszCoords == 'aa')
>> {
>>
>> $this->xml_file="archivo4.xml";
>> $this->xml_data=implode("",file($this->xml_file));
>>
>> $this->namespace = substr($this->xml_data, strpos($this->xml_data,
>>"<content xmlns:")+15, strpos($this->xml_data, "=",
>
> strpos($this->xml_data,
>
>>"<content xmlns:")) - strpos($this->xml_data, "<content xmlns:") -15);
>>
>>
>> $this->xml_data=str_replace($this->namespace.":", "", $this->xml_data);
>>
>> $this->xml=new XML();
>>
>> $this->xml->parse($this->xml_data);
>>
>> $this->tot = count($this->xml->response);
>>
>>
>> if($this->tot > 0)
>> {
>> $this->tot_a = count($this->xml->response->content);
>>
>> if($this->tot_a > 0)
>> {
>> $this->tot_b = count($this->xml->response->content->record);
>>
>> if($this->tot_b > 0)
>> {
>>
>> for($this->j = 0; $this->j < $this->tot_b; $this->j++)
>> {
>> $this->sc_name =
>>$this->xml->response->content->record[$this->j]->ScientificName->_value;
>>
>> if($this->sc_name == "Inga oerstediana")
>> {
>> $this->sc_name2=
>>$this->xml->response->content->record[$this->j]->ScientificName->_value;
>> $this->latitud=
>>$this->xml->response->content->record[$this->j]->Latitude->_value;
>> $this->longitud=
>>$this->xml->response->content->record[$this->j]->Longitude->_value;
>>
>> exit;
>> }
>> }
>> }
>> else
>> {
>> return false;
>>
>> }
>>
>> }
>> else
>> {
>> return false;
>>
>> }
>> }
>> else
>> {
>> return false;
>> }
>>
>>
>> $this->x = $this->longitud;
>> $this->y = $this->latitud;
>>
>> //$this->lb = $this->getVar('especie');
>>
>> if ($this->isVarSet('espe') == 0)
>> {
>> $this->lb = "no";
>> }
>> else
>> {
>> $this->lb = $this->getVar('espe');
>> }
>>
>> $poLayer = $this->moMapObject->oMap->getLayerByName('pointlatlon');
>> $poLayer->set("status", MS_ON);
>> $pt = ms_newPointObj();
>> $ln = ms_newLineObj();
>> $shp = ms_newShapeObj(MS_SHAPE_POINT);
>> $shp->set("text", $this->lb);
>> $pt->setXY($this->x,$this->y);
>> $ln->add($pt);
>> $shp->add($ln);
>> $poLayer->addFeature($shp);
>>
>>
>> }
>>
>>
>>}
>>
>>--------------------------------------------------------------------------
>
> --
>
>>---------------------
>>
>>C)
>>
>>
>><?php
>>/*
>>* XML.inc.php
>>*
>>* Class to convert an XML file into an object
>>*
>>* Copyright (C) 2006 Oliver Strecke <oliver.strecke at browsertec.de>
>>*
>>* This library is free software; you can redistribute it and/or
>>* modify it under the terms of the GNU Lesser General Public
>>* License as published by the Free Software Foundation; either
>>* version 2 of the License, or (at your option) any later version.
>>*
>>* This library 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
>>* Lesser General Public License for more details.
>>*
>>* You should have received a copy of the GNU Lesser General Public
>>* License along with this library; if not, write to the Free Software
>>* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
>
> USA
>
>>*/
>>
>>class XML{
>> var $_parser;
>> var $_xml_data;
>> var $_actual_tag;
>>
>> //Constructor...
>> function xml(){
>> $this->_parser=xml_parser_create("ISO-8859-1");
>> $this->_xml_data="";
>> $this->_actual_tag=$this;
>>
>> xml_set_object($this->_parser,$this);
>>
>
> xml_parser_set_option($this->_parser,XML_OPTION_CASE_FOLDING,false);
>
>> xml_set_element_handler($this->_parser,"tag_open","tag_close");
>> xml_set_character_data_handler($this->_parser,"tag_data");
>> xml_set_default_handler($this->_parser,"tag_data");
>> }
>>
>> //get XML data from file...
>> function file_read($xml_file){
>> if(file_exists($xml_file)){
>> $this->_xml_data=implode("",file($xml_file));
>> }
>> return 1;
>> }
>>
>> //parse XML data...
>> function parse($xml_data=0){
>> if($xml_data)$this->_xml_data=$xml_data;
>> xml_parse($this->_parser,$this->_xml_data);
>> xml_parser_free($this->_parser);
>> return 1;
>> }
>>
>> function tag_open($parser,$name,$attrs){
>> //create new tag...
>> $tag=new XML_TAG(&$this->_actual_tag);
>> $tag->_name=$name;
>> $tag->_param=$attrs;
>>
>> //add tag object to parent/actual tag object...
>> if(is_a($this->_actual_tag,"XML_TAG")){
>>
>>///////////////-----------LINE
>>66: --------------///////////////////////////////////////
>>
>> if(is_object($this->_actual_tag->$name) ||
>>is_array($this->_actual_tag->$name)){
>>
>>
>
>
////////////////////////////////////////////////////////////////////////////
>
>>////////////////
>>
>> //same child objects -> Array...
>> $last_index=$this->_actual_tag->new_child_array($tag,$name);
>> $this->_actual_tag=&$this->_actual_tag->{$name}[$last_index];
>> }else{
>> //add new child object to actual tag...
>> $this->_actual_tag->new_child($tag,$name);
>> $this->_actual_tag=&$this->_actual_tag->$name;
>> }
>> }else{
>> //copy first tag object in this object...
>> $this->$name=$tag;
>> $this->_actual_tag=&$this->{$name};
>> }
>> return 1;
>> }
>>
>> function tag_data($parser,$string){
>> if(strlen(trim($string))>0)$this->_actual_tag->_value=$string;
>> return 1;
>> }
>>
>> function tag_close($parser,$name){
>> $this->_actual_tag=&$this->_actual_tag->_parent;
>> return 1;
>> }
>>
>> //Debug...
>> function debug($exit=0){
>> echo "<pre>";
>> print_r($this);
>> echo "</pre>";
>> if($exit)exit;
>> }
>>}
>>
>>class XML_TAG{
>> var $_parent;
>> var $_name;
>> var $_value;
>> var $_param;
>>
>> //Constructor...
>> function xml_tag($parent){
>> $this->_parent=&$parent;
>> $this->_name="";
>> $this->_value=false;
>> $this->_param=Array();
>> return 1;
>> }
>>
>> //simply add ne child to this object...
>> function new_child($child,$child_name){
>> $this->$child_name=&$child;
>> }
>>
>> //add child array for more same childs to this object...
>> function new_child_array($child,$child_name){
>> //create array and set old child object to the first array element...
>> if(is_object($this->$child_name)){
>> $tmp_obj=$this->$child_name;
>> $this->$child_name=Array();
>> $this->new_child_array($tmp_obj,$child_name);
>> }
>> //push child reference into child array...
>> $this->{$child_name}[]=&$child;
>> $last_index=count($this->$child_name)-1;
>> return $last_index;
>> }
>>
>> //Debug...
>> function debug(){
>> echo "<pre>";
>> print_r($this);
>> echo "</pre>";
>> }
>>}
>>?>
>>
>>Thank you very much again,
>>Ines
>>
>>-------------------------------------
>>
>>Hi,
>>
>>Sorry for the late response. Put your PHP where your $this->x=... is.
>>This will give you a widget file like the following. Note that I will
>>skip some part of the code to make the message shorter.
>>
>>function ParseURL()
>> {
>> // execute parent function
>> parent::ParseURL();
>>
>> // work some magic
>>if ( $this->isVarSet( "NAV_CMD" ) &&
>> $this->getVar( "NAV_CMD" ) == 'UUW' )
>>{
>> if ( $this->mszCoords == 'aa')
>> {
>>
>>/////////////////////////////
>>// Put your code here
>>/////////////////////////////
>>$xml_file="./archivo4.xml";
>>$xml_data=implode("",file($xml_file));
>>
>>//[...snip...]
>>
>> for($j = 0; $j < $tot_b; $j++)
>> {
>> $sc_name =
>
> $xml->response->content->record[$j]->ScientificName->_value;
>
>> if($sc_name == "Inga oerstediana")
>> {
>>
>>/////////////////////////////////////////////////////
>>/// Here//////////////
>>////////////////////////////////////////////////
>> $sc_name2=
>
> $xml->response->content->record[$j]->ScientificName->_value;
>
>> $this->y= $xml->response->content->record[$j]->Latitude->_value;
>> $this->x= $xml->response->content->record[$j]->Longitude->_value;
>> }
>> }
>> }
>> else
>> {
>>//////////////////// Note that! /////////
>>return false;
>> }
>>
>>
>> }
>> else
>> {
>>//////////////////// Note that! /////////
>>return false;
>> }
>>}
>>else
>>{
>>//////////////////// Note that! /////////
>>return false;
>>}
>>
>> //$this->lb = $this->getVar('especie');
>>
>> if ($this->isVarSet('espe') == 0)
>> {
>> $this->lb = "no";
>> }
>> else
>> {
>> $this->lb = $this->getVar('espe');
>> }
>>
>> $poLayer = $this->moMapObject->oMap->getLayerByName('pointlatlon');
>>//[...snip...]
>>
>>
>>
>>Ines wrote:
>>
>>
>>>Hi, I'm customizing my widget and have to include a php code in it to
take
>>>the value of differents variables. I need to know in which place of the
>>>widget have I to write the code.
>>>
>>>This is my objective:
>>>
>>>1) I have my custom widget yet. The objective of the widget is take a
>>>longitude and latitude (x, y) an draw a point in the map in that coords.
I
>>>have this code and it works very well and I can see the point in the map.
>>
>>I
>>
>>
>>>solved it in the ParseURL() function but using x,y coords (variables)
with
>>
>>a
>>
>>
>>>fixed value to prove. Ex: $this->x = -85; $this->y = 13;
>>>
>>>2) Now, I have to take that values from a XML file to make the values of
x
>>>and y variables (change the values of x and y) for draw the point layer
in
>>>another coords. I have the code in php to read my XML file and it works
>>
>>very
>>
>>
>>>good, but not into the widget.
>>>
>>>3) My question is: In wich place or where do I have to put my php code
(to
>>>read my xml file) in the widget? to use the value of the variables that
>>
>>read
>>
>>
>>>the xml file of my php code. I need to join the widget with my php code.
I
>>>see the widget have many functions. I tried to copy-paste my php code in
>>>the ParseUrl() function but it show me errors.
>>>
>>>
>>
>>--
>>Julien-Samuel Lacroix
>>Mapgears
>>http://www.mapgears.com/
>>
>>_______________________________________________
>>Chameleon mailing list
>>Chameleon at lists.maptools.org
>>http://lists.maptools.org/mailman/listinfo/chameleon
>
>
> --
> Julien-Samuel Lacroix
> Mapgears
> http://www.mapgears.com/
>
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon
--
Julien-Samuel Lacroix
Mapgears
http://www.mapgears.com/
More information about the Chameleon
mailing list