Re: [PHP] SimpleXML doesn't work with one single XML tag line...

2005-07-15 Thread Christian Stocker
On 7/15/05, Daevid Vincent <[EMAIL PROTECTED]> wrote:
> Maybe I'm missing something about XML specifications, but this doesn't seem
> right to me.
> 
> http://www.php.net/manual/en/ref.simplexml.php
> 
> Here is a code fragment I use:
> 
> $xml = simplexml_load_string($returnData);
> var_dump($xml);
> if (is_object($xml))
> {
> //first lets make sure we didn't get an 
> if ($xml->error)
> {
> echo "An ERROR was encountered\n";
> echo "CODE: ".((string)$xml->error->code)."\n";
> echo "STRING: ".((string)$xml->error->string)."\n";
> exit;
> }
> 
> ...
> }
> 
> I have my XML setup such that if there is an error, I return:
> 
> 
> 

this are attributes, which have to accessed differently. and the first
object you get is already the root node (error in your case).

try  echo "CODE: ".((string)$xml['code'])."\n";

(not tested, but should work)

chregu

> 
> But simple XML will not detect this as illustrated by var_dump($xml)
> 
> object(SimpleXMLElement)#1 (0) {
> }
> 
> However, if I change my output to be:
> 
> 
> 
>   tbd
>   user not found with those credentials.
> 
> 
> Then I get...
> 
> object(SimpleXMLElement)#1 (2) {
>   ["code"]=>
>   string(3) "tbd"
>   ["string"]=>
>   string(38) "user not found."
> }
> 
> Notice also that my object is not nested inside an ["error"] as I would
> expect it to be.
> So I would expect to get this (in BOTH cases actually):
> 
> object(SimpleXMLElement)#1 (1) {
>   ["error"]=>
> object(SimpleXMLElement)#1 (2) {
>   ["code"]=>
>   string(3) "tbd"
>   ["string"]=>
>   string(38) "user not found."
> }
> }
> 
> More useful information:
> 
> [EMAIL PROTECTED]:/lockdown/includes/api# php -v
> PHP 5.0.3 (cli) (built: Jul 11 2005 12:33:48)
> Copyright (c) 1997-2004 The PHP Group
> Zend Engine v2.0.3, Copyright (c) 1998-2004 Zend Technologies
> with Zend Extension Manager v1.0.6, Copyright (c) 2003-2004, by Zend
> Technologies
> with Zend Optimizer v2.5.7, Copyright (c) 1998-2004, by Zend
> Technologies
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] XSLT processor and xsl:param - expected behavior?

2005-06-09 Thread Christian Stocker
On 6/9/05, John Browne <[EMAIL PROTECTED]> wrote:
> Question..  I'm using PHP 5.0.4 with the built-in libxslt-based xsl
> extension. I'm passing XSL parameters to the XSL processor like so:
> 
> $xslt_proc->setParameter('', 'param_test', "some test value");
> 
> My question is, is it *required* to declare this parameter in the XSL
> stylesheet with:
> 
> 
> 
> What I have noticed is, the transformation is successful and works the
> same whether I declare the parameter using xsl:param or not.  The
> following:
> 
> 
> 
> works fine without the xsl:param declaration, the xsl processor does
> not give an error, and the parameter is available for use in the
> stylesheet.
> 
> Shouldn't the xsl:param declaration be required and cause a
> transformation error if it's missing?

Indeed, that's working ;)

But PHP doesn't do much here, I'd say it's more a libxslt "bug", but I
didn't look up the standards (but your assumption seems obvious)

chregu
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Impossible to list attributes of xml-element?

2005-05-27 Thread Christian Stocker
On 5/26/05, Victor Spång Arthursson <[EMAIL PROTECTED]> wrote:
> Ciao!
> 
> I'm selecting an element in the xml using xpath. I know there is only
> one element matching the xpath-query, but still I get the result as a
> list. Nevermind.
> 
> This list is of the type domnodelist, on which only one action is
> allowed:  item()
> 
> Selecting [xpath-result]->item(0) gives me the only element in the
> result in the form of a domelement. This domelement should have a lot
> of attributes, but I cant find no way to get some kind of list over
> those attributes, to work further with.
> 
> Could someone please point me in the same direction?

$domelement->attributes

gives you a DomNodeList back with all attributes

chregu
> 
> Sincerely
> 
> Victor
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Parsing XML with php

2005-05-16 Thread Christian Stocker
On 5/12/05, Burhan Khalid <[EMAIL PROTECTED]> wrote:
> Merlin wrote:
> > Hi there,
> >
> > I am curious if PHP is now able to pars xml without aditional tools like
> > xmlrpc.
> > If yes which version is required? Is the current php 4.x tree sufficient?
> 
> 4.x requires the expat parser (so I guess it would require external libs).

Wrong, the exapt library  is included in PHP 4.

> 5.x has the simplexml extension (which I believe requires no external libs).

Wrong, libxml2 is needed as external library for having *any* XML
support in PHP 5 (if you have libxml2 installed, you should get SAX
(aka ext/xml), DOM and simplexml support out of the box)

chregu
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Extending Element class in a dom tree?

2005-04-30 Thread Christian Stocker
Hi again

On 4/30/05, Christian Stocker <[EMAIL PROTECTED]> wrote:
> On 4/30/05, Erik Franzén <[EMAIL PROTECTED]> wrote:
> > The DOM implementation i PHP5 allows classes to be extended. Extending
> > the Document class is no problem, but how can I extend the Element class
> > and use it in a DOM tree?
> >
> > DOMDocument::createElement returns a DOMElement object which you cannot
> > extend.
> >
> > Could this be a solution?
> >
> > class MyElement extends DomElement {
> >  function __construct($a_stTagName) {
> >  //has to be called!
> >  parent::__construct($a_stTagName);
> >  }
> >
> >  function myFunction() {
> > // do something
> >  }
> > }
> >
> > $oDom = new DomDocument();
> > $oMyElement = new MyElement('mytag');
> >
> > $oMyElement = $oDom->importNode($oMyElement, true);
> > $oMyElement = $oDom->appendChild($oMyElement);
> 
> Does not work, will never work, just forget about it ;)

Ok, that was not the really right answer ;) Of course it does work.
You can even do stuff on that element, if you use the variable, resp.
reference ($oMyElement) for doing this.

What doesn't work (and I  referred to that) is getting this object
back from the DomDocument, so for example:
$oDom->documentElement will give you the DomElement back and not your
new MyElement.

Hope it's a little bit clearer now
chregu
> 
> chregu
> >
> > Regards
> > /Erik
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> --
> christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
> phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
> http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Extending Element class in a dom tree?

2005-04-30 Thread Christian Stocker
On 4/30/05, Erik Franzén <[EMAIL PROTECTED]> wrote:
> The DOM implementation i PHP5 allows classes to be extended. Extending
> the Document class is no problem, but how can I extend the Element class
> and use it in a DOM tree?
> 
> DOMDocument::createElement returns a DOMElement object which you cannot
> extend.
> 
> Could this be a solution?
> 
> class MyElement extends DomElement {
>  function __construct($a_stTagName) {
>  //has to be called!
>  parent::__construct($a_stTagName);
>  }
> 
>  function myFunction() {
> // do something
>  }
> }
> 
> $oDom = new DomDocument();
> $oMyElement = new MyElement('mytag');
> 
> $oMyElement = $oDom->importNode($oMyElement, true);
> $oMyElement = $oDom->appendChild($oMyElement);

Does not work, will never work, just forget about it ;)

chregu
> 
> Regards
> /Erik
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[suspicious - maybe spam] [PHP] [suspicious - maybe spam] Re: [PHP] [suspicious - maybe spam] URL encoding in XSL - Yes, a PHP question

2005-04-23 Thread Christian Stocker
On 4/23/05, Brian Dunning <[EMAIL PROTECTED]> wrote:
> All the resources I've found on the web for URL encoding values within
> an XSL stylesheet are either .NET or Java, so I'm looking for some help
> with how to do this using PHP's special flavor of XML/XSL.
> 
> Within the XSL doc, I've got:
> 
> 
>  href="http://www.anrdoezrs.net/click-1692198-5463217?loc={$ItemLink}";>

Are you using sablotron in PHP 4? Or the domxslt support in PHP 4? Or
already PHP 5?

If you use one of the later, you could use
http://exslt.org/str/functions/encode-uri/index.html, this should be
available in libxslt

With PHP 5, you can also call PHP functions from within xslt:

http://ch2.php.net/manual/en/function.xsl-xsltprocessor-register-php-functions.php

Read the usercomments for more info

chregu
> 
> and $ItemLink needs to be URL encoded. How do I do this on my PHP box?
> Sorry no Java or .NET available...   :)
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Appending DOM doc as child in another DOM doc

2005-02-16 Thread Christian Stocker
Hi


On Mon, 14 Feb 2005 11:34:15 -0600, Chris Boget <[EMAIL PROTECTED]> wrote:
> Is there a way to take an already existing DomDocument object
> and appending it as a child node within a seperate DomDocument
> object?  Or would I have to pull it apart first and generate new
> DomNode/DomElement objects using the data then append those
> DomNode/DomElement objects to the seperate DomDocument?

//$node1 is a node of $dom1

$node1->appendChild($dom1->importNode($dom2->documentElement,true));

chregu


 
> thnx,
> Chris
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP5: DOM->removeChild Problem

2005-01-25 Thread Christian Stocker
On Fri, 21 Jan 2005 12:02:51 +0100, Mike Blank
<[EMAIL PROTECTED]> wrote:
> Hi Guys!
> 
> I've got a problem with Dom and php 5.0.2. I'm trying to access an xml
> node with $item = $objDom->documentElement->childNodes->item(0);. That
> seems to work, because on the next line I can output the node Value with
> echo $item->nodeValue. But when I use the command
> $objDom->removeChild($item); on the next line, dom throws a
> DOMException:

$objDom has to to be the parent node of $item., not the document itself.

$objDom->documentElement->removeChild($item);
should work in your case. or more general

$item->parentNode->removeChild($item);

chregu

> 
> Fatal error: Uncaught exception 'DOMException' with message 'Not Found
> Error' in
> /opt/lampp/htdocs/www/snap_chubb/extensions/features/mitarbeiter/main.fe
> a.php:13 Stack trace: #0
> /opt/lampp/htdocs/www/snap_chubb/admin/admin.class.php(179): require()
> #1 /opt/lampp/htdocs/www/snap_chubb/admin/admin.class.php(154) :
> eval()'d code(1): Admin->editFeature(Object(DOMElement)) #2
> /opt/lampp/htdocs/www/snap_chubb/admin/admin.class.php(154): eval() #3
> /opt/lampp/htdocs/www/snap_chubb/admin/index.php(142):
> Admin->drawContent() #4 {main} thrown in
> /opt/lampp/htdocs/www/snap_chubb/extensions/features/mitarbeiter/main.fe
> a.php on line 13
> 
> Below you can see my code:
> 
> Index.php
> ---
> 
> $objDom = new DomDocument(); // neues dom objekt
> $strXML = $this->loadXMLTree($objDATA->fields['pfe_con_id']); //
> funktion, die eine xml datei als string aus der db ausliest if ($strXML
> != false) {
> $objDom->loadXML($strXML); // string wird in das dom objekt
> geladen } $item = $objDom->documentElement->childNodes->item(0); //
> adressierung eines knoten echo $item->nodeValue; // ausgabe funktioniert
> ohne probleme
> $objDom->removeChild($item); // diese zeile spuckt den oben genannten
> Error aus!
> 
> Geladener XML string
> ---
> 
> 
> 
> 
> /images/43/team_fabian-bischof_kl.jpg
> Fabian Bischof
> 45
> 
> 
> /images/43/team_sandra-varela_kl.jpg
> Sandra Varela
> 0
> 
> 
> /images/43/team_sandra-varela_kl.jpg
> Sandra Varela
> 0
> 
> 
> -------
> 
> I hope somebody can help me somehow! I'm really desperate!
> 
> Cheers
> 
> mike
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: [PHP-XML-DEV] DomXPath and default XML namespaces

2004-12-13 Thread Christian Stocker

On 14.12.2004 6:45 Uhr, Dan Phiffer wrote:
Adam Maccabee Trachtenberg wrote:
This is an XPath FAQ. Without a ns prefix, XPath doesn't choose
elements living in the default ns, but ones living in no namespace.

Are there any good references you might point me to? I'm pretty new to 
this stuff and beyond my "in a Nutshell" book don't have many places to 
consult yet.

 > what happens to:

  

  
  
   
  

And /root/foo/qxx? Do you select qxx in the default ns? Or not?
-adam
That makes perfect sense. I'm realizing that XPaths are not as portable 
as I thought they were. At least not without some way of converting 
element prefixes easily...
You just have to learn that prefixes are just aliases to the real 
namespaces, then you're fine. Don't count on prefixes, they itself are 
meaninngless. And always use registerNamespace() for all namespaces you 
need in the XPath query. Then XPath is very portable.

chregu
Thanks,
-Dan
--
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Parsing multiple XML documents as strings. Inbox

2004-12-06 Thread Christian Stocker
On Mon, 6 Dec 2004 23:10:15 +0100, Goformusic Support
<[EMAIL PROTECTED]> wrote:
> Hi,
> 
> We worked with Sablotron before but switched over to the libxslt
> library on PHP5 to perform XSL transformations. We used the wrapper
> code found on http://be.php.net/xsl so that our old xslt_ functions
> continued to work.
> 
> Now, with Sablotron we used to parse multiple XML documents as strings
> and one XSL file from disk. With libxslt it doesn't seem possible
> parsing XML documents as strings.
> 
> This is the old method which worked fine, using Sablotron:
> 
> $args["/list_docu"] = "some xml";
> $result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $args, $params);
> 
> This node could then be access with XSL:
> 
> 
> When I run this code using libxslt/PHP5 and the wrapper I get the error:
> Warning: I/O warning : failed to load external entity "arg:/list_docu"
> 
> This is because the XML documents must be saved on disk I guess.
> Isn't there any way to load the XML documents as strings???

I don't know your wrapper class, but it's perfectly possible to load
XML documents from strings:

see

http://ch.php.net/manual/en/ref.xsl.php

and

http://ch.php.net/manual/en/function.dom-domdocument-loadxml.php

for further details.

chregu

> 
> Grtz,
> 
> Bart
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] XML Signature verification in PHP

2004-11-03 Thread Christian Stocker
On Wed, 3 Nov 2004 22:51:53 -0800 (PST), Rajesh Batchu
<[EMAIL PROTECTED]> wrote:
> HI All,
> 
> I am getting a xml document from my customer which is signed with XML Signature.
> 
> Customer is Signing the document with xmlsec library ( parser is libxml2).
> 
> I have to verify the signature on my side and do the rest of the processing.
> 
> I saw sevaral examples on the http://www.aleksey.com/xmlsec site for signing
> and verification. But the problem is all of those examples are in C language.
> 
> Is there any way, I can do this verification in PHP ?
> I could not find any API or Sample code in PHP.

There's no extension or interface for xmlsec, AFAIK, for PHP. Maybe
you do it with commandline tools

Or even better, write an extension based on the xmlsec library,
shouldn't be an impossible task, since that is also based on libxml2

chregu

> Regards,
> Rajesh B.
> 
> 
> __
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Unable to validate XML with Schema if namespace is specified.

2004-10-31 Thread Christian Stocker
On Sun, 31 Oct 2004 19:08:04 +, Dusty Bin <[EMAIL PROTECTED]> wrote:
> I am trying to validate an XML document, using
> DomDocument::schemaValidate() as in the following code:
> 
>  $txt =<< 
> 
>ItemText
> 
> EOT;
> $dom = new DOMDocument();
> $dom->loadXML($txt);
> if ($dom->schemaValidate("Article.xsd")) {
> print $dom->saveXML();
> }
> ?>
> 
> The schema I am trying to validate against is:
> 
> 
> http://www.w3.org/2001/XMLSchema"; >
> 
> 
> 
> 
> 
> 
> 
> 
> 
> This produces the following output:
> 
> Warning: Element Article not declared in E:\PHPTest\testXML.php on line 10
> 
> Warning: Element Article not declared in E:\PHPTest\testXML.php on line 10

Aren't you missing any namespace declaration in your Schema File?

I'm no XML Schema Expert at al, so I took trang and let it made one
out of your XML and it produced the following:


http://www.w3.org/2001/XMLSchema";
elementFormDefault="qualified"
targetNamespace="http://www.example.com/xml";
xmlns:x="http://www.example.com/xml";>
  

  

  

  
  


And this validates (at least with libxml2 version 2.6.14, the PHP
version doesn't matter, since all the validation is done by
libxml2...)

chregu


> 
> If I remove the default namespace from the article tag, the XML
> validates correctly.  I seem to recollect that namespace support is not
> fully implemented, so my question is, is this a bug, or just something
> not yet implemented, or is there an obvious blunder in what I am trying
> to do, which I cannot see.
> Best regards. . . Dusty
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] DOM XML/XSL questions

2004-10-27 Thread Christian Stocker
On Wed, 27 Oct 2004 13:52:13 +0100, Dusty Bin <[EMAIL PROTECTED]> wrote:
> I have a requirement to create an XML file which looks approximately like:
> 
> 
> 
> 
>Item Text
>...
> 
> 
> The file needs to be formatted.
> 
> I built a dom using the Dom extension, creating a document, adding
> nodes, and I got a nicely formatted XML file from $dom->saveXML();
> 
> The only problem I had, was that I could see no way to add the
> stylesheet definition to the XML.  I'm not sure that a DOM should know
> anything about stylesheets, but an XML file probably should.
> 
> I managed to bypass the problem, by loading the dom from a file, with
> the style sheet and the root element included, and then proceeding to
> build the dom by adding the extra nodes.  This also worked fine, but now
> the output from $dom->saveXML() is no longer formatted.
> Here is some sample code:
> 
>  $txt =<< 
> 
>  xmlns='http://www.example.com/xml'
> xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
> xsi:schemaLocation='http://www.example.com/test/xml article.xsd'>
> 
> EOT;
> 
> $dom = new DOMDocument();
> $dom->preserveWhiteSpace = FALSE;
> $dom->resolveExternals = TRUE;
> $dom->loadXML($txt);
> 
> $item = $dom->createElement("Item");
> $itemText = $dom->createTextNode("Item Text");
> $item->appendChild($itemText);
> $dom->documentElement->appendChild($item);
> 
> $dom->formatOutput = TRUE;
> 
> echo $dom->saveXML();
> ?>
> 
> My questions are:
> 1) How should I add a stylesheet to this type of document? (I do not
> need to process the stylesheet in php, it is for the guidance of the end
> user of the document, who may use it or modify it),
> and,

Use $dom->createProcessingInstruction($target, $data) ;
and then append this to the document.
that could maybe work
see
http://ch.php.net/manual/en/function.dom-domdocument-createprocessinginstruction.php
for more details.


> 2) Is this a (dare I say bug in an experimental extension) that if I
> load the dom, and perform operations on the dom, I lose formatting(A dom
> that is just loaded, or just created by dom operations, is correctly
> formatted, a dom with mixed processes is not).

The extension is not experimental anymore ;)
And the formatting is not lost. you didn't provide any ;) The DOM
Extension doesn't make any assumptions about the formatting of your
XML document (or correctly said, it doesn't insert whitespace
"automagically" ) but you can try to set the property formatOutput
just before saveXML:

$doc->formatOutput = true;

Never tested, but should work

chregu

> TIA for any advice...   Dusty
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] DOMXML html_dump_mem question

2004-10-22 Thread Christian Stocker
On Fri, 22 Oct 2004 10:44:48 +0200, franco bevilacqua
<[EMAIL PROTECTED]> wrote:
> Christian Stocker wrote:
> > On Fri, 22 Oct 2004 09:07:46 +0200, franco bevilacqua
> > <[EMAIL PROTECTED]> wrote:
> >
> >>  Hello,
> >>I have a question regarding the html_dump_mem function. I build an xml
> >>tree with HTML tags. When I dump it, I expect that my brother interpret
> >>HTML tag procduced by the dump. But the dump produce only a text with my
> >>html tag. Does someone knows how to do HTML interpretation with using
> >>DOMXML print
> >>
> >>The following example explains exactly what whant to do.
> >>(Inspired from html_dump_mem example )
> >
> >
> > I see nothing wrong with the output, what exactly did you expect?
> I expect to have the text "This is the title" printed as H1 by the
> brother, ( without the tags around the text ). I want that the brother
> interpret the dumped text as html and not as text. Do you have an idea
> to do that ?

Aaah, brother == printer ;)

No, that's not possible. PHP doesn't have a built in HTML renderer ...

chregu

> Thanks
> 
> 
> >
> > chregu
> >
> >> >>
> >>// Creates the document
> >>$doc = domxml_new_doc("1.0");
> >>
> >>$root = $doc->create_element("html");
> >>$root = $doc->append_child($root);
> >>
> >>$body = $doc->create_element("body");
> >>$body = $root->append_child($head);
> >>
> >>$h1 = $doc->create_element("h1");
> >>$h1 = $head->append_child($h1);
> >>
> >>$text = $doc->create_text_node("This is the header1");
> >>$text = $title->append_child($text);
> >>
> >>echo $doc->html_dump_mem();
> >>
> >>?>
> >>The following dump is produced:
> >>
> >>This is the title
> >>
> >>But I expect the following result:
> >>
> >>"This is the title" : formated as HTML header1
> >>
> >>Thanks for your help.
> >>
> >>Best regards
> >>Franco
> >>
> >>--
> >>PHP General Mailing List (http://www.php.net/)
> >>To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >
> >
> >
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] DOMXML html_dump_mem question

2004-10-22 Thread Christian Stocker
On Fri, 22 Oct 2004 09:07:46 +0200, franco bevilacqua
<[EMAIL PROTECTED]> wrote:
>   Hello,
> I have a question regarding the html_dump_mem function. I build an xml
> tree with HTML tags. When I dump it, I expect that my brother interpret
> HTML tag procduced by the dump. But the dump produce only a text with my
> html tag. Does someone knows how to do HTML interpretation with using
> DOMXML print
> 
> The following example explains exactly what whant to do.
> (Inspired from html_dump_mem example )

I see nothing wrong with the output, what exactly did you expect?

chregu
> 
>  
> // Creates the document
> $doc = domxml_new_doc("1.0");
> 
> $root = $doc->create_element("html");
> $root = $doc->append_child($root);
> 
> $body = $doc->create_element("body");
> $body = $root->append_child($head);
> 
> $h1 = $doc->create_element("h1");
> $h1 = $head->append_child($h1);
> 
> $text = $doc->create_text_node("This is the header1");
> $text = $title->append_child($text);
> 
> echo $doc->html_dump_mem();
> 
> ?>
> The following dump is produced:
> 
> This is the title
> 
> But I expect the following result:
> 
> "This is the title" : formated as HTML header1
> 
> Thanks for your help.
> 
> Best regards
> Franco
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] SimpleXML: DOM, SAX or Other?

2004-10-15 Thread Christian Stocker
Hi


On 15 Oct 2004 11:51:33 -, PHPDiscuss - PHP Newsgroups and mailing
lists <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> Does anybody have any depthful knowledge of the SimpleXML extension in
> PHP5?..
> 
> More accurately, do you know if the simpleXml->xpath() method uses DOM,
> SAX or some other method of parsing a loaded XML document?
> 
> I ask because I am trying to parse arbitrary XML documents as efficiently
> as possible (avoiding DOM).

Hi

SimpleXML uses the same stuff as DOM in the backend. So you won't gain
any efficency using SimpleXML

chregu
> 
> Kieran
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] What do I need in order to validate XMl against an XSD using php?

2004-09-27 Thread Christian Stocker
On Mon, 27 Sep 2004 11:15:23 -0500, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> Are their any specific php extensions or modules that I'd need in order to do
> something like this very easily?

You need PHP 5  and preferably the latest libxml2 release. 
The dom extension of PHP 5 has  XSD Schema Validation built in.


chregu


> 
> Thanks,
> Brent
> 
> 
> This message was sent using IMP, the Internet Messaging Program.
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 



-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: configure --with-xsl & getting error

2004-09-24 Thread Christian Stocker
On Fri, 24 Sep 2004 08:46:23 +0200, Gerrit P. Haase <[EMAIL PROTECTED]> wrote:
> Christian Stocker wrote:
> 
> > Ever thought of reporting a bug to http://bugs.php.net instead of
> > trolling around here?
> 
> > But I don't think, it's  a bug, because  --with-dom  is enabled by
> > default, so there must something else wrong with your configuration.
> > There's actually no --with-dom option at all, just --without-dom..
> 
> > Check the configure output, what it reports about libxml, dom etc.
> 
> It works well if I define
>--with-dom=shared \
>--enable-dom=shared \
> and if you don't believe me, then try it yourself instead of starting to
> flame.
> 
> And please keep this on the list *only* and send no personal replies to
> my private mail account.

Sorry for answering privately, I hit the wrong button...

PHP doesn't build anything shared by default, so you have to tell 
configure  to do that.

And if you want to discuss improvements of the php build system, write
to the internals PHP mailinglist. Here's certainly the wrong place, as
hardly any core developer reads this list here.

I'm not in charge for nor do I have any further insight of the build
system at all, therefore this is the end of discussion for me here.

Nice day

chregu


> 
> 
> 
> 
> Gerrit
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 



-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: configure --with-xsl & getting error

2004-09-23 Thread Christian Stocker
Ever thought of reporting a bug to http://bugs.php.net instead of
trolling around here?

But I don't think, it's  a bug, because  --with-dom  is enabled by
default, so there must something else wrong with your configuration.
There's actually no --with-dom option at all, just --without-dom..

Check the configure output, what it reports about libxml, dom etc.

chregu


On Thu, 23 Sep 2004 20:12:39 +0200, Gerrit P. Haase <[EMAIL PROTECTED]> wrote:
> Hello Mikey,
> 
> > Have you tried doing "make clean" first?
> 
> That is not the point.
> 
> The point is that it is a bug that configure is exiting because
> I define --enable-xyz when the xyz dependency is not available instead
> of to disable the extension and continue the configury.  And it is a
> bug that configure is doing nothing about wrong definitions as in my
> case, where xsl requires dom to be build and there is no warning if
> you define with-xsl but not enable-dom, nor does it define enable-dom
> by itself for the average dummy user that I am proud to be.
> 
> The configury of this package is buggy but they state that they are
> proud to have abandoned automake, I don't wonder that it was
> neccessary to do so because there seems to care nobody about improving
> this system.
> 
> I need to define a hundred flags to configure instead of saying
> --enable-all=shared or s.th. similar to get all possible shared
> modules to be compiled.
> 
> 
> 
> 
> Gerrit
> --
> =^..^=
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 



-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] DOM loadXML not loading doctype as expected in PHP5

2004-08-31 Thread Christian Stocker
On Tue, 31 Aug 2004 11:47:22 -0400, David Numan <[EMAIL PROTECTED]> wrote:
> It worked! Thank you so much!

no problem

> I couldn't find documentation for this anywhere. I think I will add a
> note on the DOM Function page in the php docs.

The properties are unfortunately not documented yet :( And yes, please
just add a User Note for the time being)

chregu

> 
> -dave
> 
> 
> 
> On Tue, 2004-08-31 at 01:23, Christian Stocker wrote:
> > On Tue, 31 Aug 2004 00:27:25 -0400, David Numan <[EMAIL PROTECTED]> wrote:
> > > Hi
> > >
> > > I'm working on a project using PHP5 and I'm using the DOM extension
> > > quite heavily. I need to be able to store various character entities
> > > such as $nbsp; and é Note: this is for a custom XML document, not
> > > standard (X)HTML.
> > >
> > > When I load my XML string into my domDocument I've been trying
> > > variations of $doctype1 and $doctype2 below. Here is my code:
> > >
> > > $doctype1 = << > >  > >  > > "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent";>
> > > %ISOlat1;
> > >  > > "http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent";>
> > > %ISOsymbol;
> > >  > > "http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent";>
> > > %ISOspecial;
> > > ]>
> > > EODT;
> > >
> > > $doctype2 = ' > > "http://gv.ca/dtd/character-entities.dtd";>';
> > >
> > > $xml = ''.$doctype1.
> > >' ';
> > > $dom = new domDocument();
> > > $dom->loadXML($xml);
> > > echo $dom->saveXML();
> > >
> > > The above code works as-is and the   is present in the huge output.
> > > However, when I change it to use $doctype2 the   is no longer there
> > > and returns the warning "Entity 'nbsp' not defined in Entity, line 1".
> > > Of course the $doctype2 string is the one I need.
> > >
> > > What am I doing wrong? Why isn't it loading the external entities? Is
> > > there some other way of doing this that I somehow missed? I tested the
> > > exact same xml code using "xmllint -format -loaddtd file.xml" and it
> > > worked fine.
> >
> > try if it works with
> >
> > $dom->resolveExternals = true:
> >
> > before $dom->load()
> >
> > not tested, but I assume it has something to do with not loading
> > external entities
> >
> > chregu
> > >
> > > Tested on Gentoo with PHP 5.0.0 and 5.0.1 with libxml 2.6.11.
> > >
> > > Any ideas would be appreciated.
> > > Thanks,
> > > --
> > > David Numan <[EMAIL PROTECTED]>
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> -- 
> David H. Numan, Software Architect
> Guided Vision: Internet Application Construction
> (905) 528-3095   http://guidedvision.com
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] CMS, Seperation of concerns - the Cocoon style

2004-08-31 Thread Christian Stocker
You maybe want to have a  look at Popoon - Cocoon for PHP ...

Documentation is sparse, but see:
http://www.bitflux.ch/developer/cms/popoon.html

It's for PHP 5 only in the meantime.

If you have any questions, just ask

chregu

On Tue, 31 Aug 2004 11:37:39 +0200, Thomas Hochstetter
<[EMAIL PROTECTED]> wrote:
> Hi there,
> 
> I was thinking about this a lot today and was wondering if there are any
> people here on this list that have experimented with this:
> 
> I hope you know what Cocoon does. If I can just sum up what I am concerned
> about:
> 
> *   Separation of concerns (i.e. Design, Content and Logic are
> COMPLETELY separate entities)
> *   Pipelining xml to create out of one content file many other,
> semantically different files (like xhtml, pdf, wml .)
> *   To use such a system as a generic template system, say for
> Conferences
> 
> What is was now wondering about is, what would be the best practice here. I
> have read a little up on the use of PHP in combination with Cocoon 2, and it
> looks like that there are a few ways of doing this.
> 
> Question: the reason why I went the PHP and not the XSP way was because of
> the huge complexity and slowness of Cocoon (jsp, xsp, servlets) compared to
> PHP. So now the combination of the two still does not sound feasible, or
> does it not matter much? The fact still remains that xml transformations
> nibble CPU time. Then there is also Java involved. :-/
> 
> A second option would be to write my own PHP 5 driven XML
> transformers/template engine (I would not dare to say that I could do so!).
> I know that PHP 5 has got a hugely improved XML and DOM interface. And one
> could possibly combine this with PEAR classes and Smarty (or something
> similar).
> 
> Then there are things like . err, forgot the name, but there is an open
> source project out there that emulates what Cocoon does (separation of
> concerns and pipelining), by using only PHP.
> 
> I am quite keen on getting some sort of backbone going where I can create,
> manipulate pdf's and even stuff like Word files and rtfs. I am still
> mesmerized by the whole XML idea. Some people talk about it having failed
> the web . hmmm, not sure of that. Maybe it's just not been tried enough?
> 
> So, any inputs on that? I would not mind going the java route, just prefer
> rapid development over: asant - asant deploy - asant undeploy - asant clean
> .. And so on .
> 
> Thanks,
> 
> Thomas
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] DOM loadXML not loading doctype as expected in PHP5

2004-08-30 Thread Christian Stocker
On Tue, 31 Aug 2004 00:27:25 -0400, David Numan <[EMAIL PROTECTED]> wrote:
> Hi
> 
> I'm working on a project using PHP5 and I'm using the DOM extension
> quite heavily. I need to be able to store various character entities
> such as $nbsp; and é Note: this is for a custom XML document, not
> standard (X)HTML.
> 
> When I load my XML string into my domDocument I've been trying
> variations of $doctype1 and $doctype2 below. Here is my code:
> 
> $doctype1 = <<   "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent";>
> %ISOlat1;
>  "http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent";>
> %ISOsymbol;
>  "http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent";>
> %ISOspecial;
> ]>
> EODT;
> 
> $doctype2 = ' "http://gv.ca/dtd/character-entities.dtd";>';
> 
> $xml = ''.$doctype1.
>' ';
> $dom = new domDocument();
> $dom->loadXML($xml);
> echo $dom->saveXML();
> 
> The above code works as-is and the   is present in the huge output.
> However, when I change it to use $doctype2 the   is no longer there
> and returns the warning "Entity 'nbsp' not defined in Entity, line 1".
> Of course the $doctype2 string is the one I need.
> 
> What am I doing wrong? Why isn't it loading the external entities? Is
> there some other way of doing this that I somehow missed? I tested the
> exact same xml code using "xmllint -format -loaddtd file.xml" and it
> worked fine.

try if it works with

$dom->resolveExternals = true:

before $dom->load()

not tested, but I assume it has something to do with not loading
external entities

chregu
> 
> Tested on Gentoo with PHP 5.0.0 and 5.0.1 with libxml 2.6.11.
> 
> Any ideas would be appreciated.
> Thanks,
> --
> David Numan <[EMAIL PROTECTED]>
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Loading a html file using DOM XML

2004-08-29 Thread Christian Stocker
On Sun, 29 Aug 2004 06:23:53 -0700, Sam Hobbs <[EMAIL PROTECTED]> wrote:
> Correction: the documentation is quite clear in saying that the "DOM
> extension is the replacement for the DOM XML extension". So that is further
> indication that I should use DOM not DOM XML.

the domxml extension is for PHP 4
the dom extension for PHP 5

The above link is for PHP 4

If loadHTMLFile doesn't work, your libxml2 doesn't maybe have HTML
support, phpinfo() should tell you that (under the domxml section)

chregu


> 
> 
> "Sam Hobbs" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> 
> 
> > DOMDocument->loadHTMLFile is what I was using when I was unable to get the
> > domxml enabled. The documentation is confusing; I don't know if the DOM in
> > PHP (which includes DOMDocument->loadHTMLFile) will replace the XML DOM,
> or
> > if the XML DOM will repalce the DOM or if they are two different things
> and
> > both will continue to exist. However it does make sense that I need to use
> > DOMDocument->loadHTMLFile. As I said, I got confused.
> >
> > So if I need to use "DOM" instead of "DOM XML" then I need to enable "DOM"
> > instead of "DOM XML". I have enabled the domxml extension; is there a
> > different extension that I need for "DOM" (DOMDocument->loadHTMLFile)?
> >
> >
> >
> > "Christian Stocker" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED]
> > > DOMXML can basically only load well-formed XML documents and does this
> > > quite well. If it doesn't work, you are doing something wrong or your
> > > XML/HTML document is not wellformed. It's that simple.. And yes,
> > > FrontPage, doesn't produce well-formed code ;)
> > >
> > > But... There is a solution, which maybe helps, see
> > > http://ch.php.net/manual/en/function.dom-domdocument-loadhtmlfile.php
> > >
> > > This function can load HTML into a DOM Document without having to be
> > > well-formed
> > >
> > > chregu
> > >
> > >
> > >
> > >
> > > On Sun, 29 Aug 2004 05:56:51 -0700, Sam Hobbs <[EMAIL PROTECTED]>
> > wrote:
> > > > I don't want a XML document! I need a HTML document.
> > > >
> > > > Are you sure that that is the only possible explanation? I think not,
> > and if
> > > > not, then it is not accurate to say that that is the obvious answer.
> > > >
> > > > I did try changing the extension from "html" to "XML" and loading that
> > > > directly into IE. I did get errors. When I fixed the errors, the
> > document
> > > > loaded into IE, but of course it was shown as-is. That is not what I
> > need; I
> > > > need the HTML to be processed (formatted).
> > > >
> > > > When I load the corrected document in using domxml_open_file, it still
> > does
> > > > not load, regardlous of whether the extension is xml or html.
> > > >
> > > > So your answer is rather cryptic. I need to load a file that can be
> > created
> > > > and edited using a WYSIWYG editer, such as FrontPage. Then I need to
> > modify
> > > > it (to do things such as fill in a table) using the DOM and then show
> > that.
> > > > Perhaps the XML DOM is not capable of doing that then saying that the
> > > > problem is that it is not well-formed is a minor detail and the answer
> > is
> > > > that I need HTML DOM functions instead of XML DOM. In other words,
> > perhaps
> > > > PHP cannot do what I need.
> > > >
> > > > "Christian Stocker" <[EMAIL PROTECTED]> wrote in message
> > > > news:[EMAIL PROTECTED]
> > > >
> > > >
> > > > > It's obviously not a well-formed XML Document...
> > > >
> > > > --
> > > > PHP General Mailing List (http://www.php.net/)
> > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > >
> > > >
> > >
> > >
> > > --
> > > christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
> > > phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
> > > http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Loading a html file using DOM XML

2004-08-29 Thread Christian Stocker
DOMXML can basically only load well-formed XML documents and does this
quite well. If it doesn't work, you are doing something wrong or your
XML/HTML document is not wellformed. It's that simple.. And yes,
FrontPage, doesn't produce well-formed code ;)

But... There is a solution, which maybe helps, see
http://ch.php.net/manual/en/function.dom-domdocument-loadhtmlfile.php

This function can load HTML into a DOM Document without having to be
well-formed

chregu




On Sun, 29 Aug 2004 05:56:51 -0700, Sam Hobbs <[EMAIL PROTECTED]> wrote:
> I don't want a XML document! I need a HTML document.
> 
> Are you sure that that is the only possible explanation? I think not, and if
> not, then it is not accurate to say that that is the obvious answer.
> 
> I did try changing the extension from "html" to "XML" and loading that
> directly into IE. I did get errors. When I fixed the errors, the document
> loaded into IE, but of course it was shown as-is. That is not what I need; I
> need the HTML to be processed (formatted).
> 
> When I load the corrected document in using domxml_open_file, it still does
> not load, regardlous of whether the extension is xml or html.
> 
> So your answer is rather cryptic. I need to load a file that can be created
> and edited using a WYSIWYG editer, such as FrontPage. Then I need to modify
> it (to do things such as fill in a table) using the DOM and then show that.
> Perhaps the XML DOM is not capable of doing that then saying that the
> problem is that it is not well-formed is a minor detail and the answer is
> that I need HTML DOM functions instead of XML DOM. In other words, perhaps
> PHP cannot do what I need.
> 
> "Christian Stocker" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> 
> 
> > It's obviously not a well-formed XML Document...
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Loading a html file using DOM XML

2004-08-29 Thread Christian Stocker
It's obviously not a well-formed XML Document...

chregu

On Sun, 29 Aug 2004 05:11:19 -0700, Sam Hobbs <[EMAIL PROTECTED]> wrote:
> Is it possible to load a HTML file using DOM XML?
> 
> I tried loading a HTML file using:
> 
> $Document = domxml_open_file("DynamicTable.html");
> if (!$Document) {
> echo "Error loading the document\n";
> exit;
> }
> 
> Yet that does not work; I get the error.
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP5 DOM extension as a PECL package for PHP4?

2004-08-20 Thread Christian Stocker
Not at all possible

PHP5/DOM uses a lot of ZendEngine 2 specific feature, you can't port it to PHP 4

chregu

On Fri, 20 Aug 2004 10:56:41 +, libogen . <[EMAIL PROTECTED]> wrote:
> Hi All,
> 
> I was just wondering if there's any possibility that someone will port
> PHP5's DOM extension to PHP4, maybe making it available as a PECL package?
> I'm not even sure if it can be done!
> 
> This would make the better DOM functions available to users maybe a year
> earlier on shared webhost's servers, than waiting until the webhosts are
> comfortable upgrading from PHP4 to PHP5.
> 
> It would make it easier for website maintainers/developers to transition to
> PHP5's DOM extension as only a single PHP4 interpreter would be needed. They
> could also test old (DOMXML) and new (DOM) scripts side by side.
> 
> Cheers,
> Scrumpy :)
> 
> _
> Add photos to your messages with MSN 8. Get 2 months FREE*.
> http://join.msn.com/?page=features/featuredemail
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Validate XML data

2004-08-19 Thread Christian Stocker
On Thu, 19 Aug 2004 18:06:27 +0200, Jacob Friis Larsen <[EMAIL PROTECTED]> wrote:
> > It's possible in PHP 5, but not in PHP 4
> 
> Could you link me to the documentation?

http://ch2.php.net/manual/en/function.dom-domdocument-schemavalidate.php

chregu
> 
> > And I advise to use the most recent libxml2 libraries, since they made
> > big improvements concerning XSD support lately
> >
> >>It is possible to validate a XML document with XML Schema Definition
> >>Language (XSDL).
> >>
> >>Is it possible to use XSDL in Php?
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Validate XML data

2004-08-19 Thread Christian Stocker
It's possible in PHP 5, but not in PHP 4

And I advise to use the most recent libxml2 libraries, since they made
big improvements concerning XSD support lately

chregu

On Thu, 19 Aug 2004 17:11:47 +0200, Jacob Friis Larsen <[EMAIL PROTECTED]> wrote:
> It is possible to validate a XML document with XML Schema Definition
> Language (XSDL).
> 
> Is it possible to use XSDL in Php?
> 
> Thanks,
> Jacob
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP bug tracker, it is freely available

2004-08-13 Thread Christian Stocker
http://cvs.php.net/php-bugs-web/

chregu

On Fri, 13 Aug 2004 18:18:45 +0900, Jean-Christian Imbeault
<[EMAIL PROTECTED]> wrote:
> I absolutely love the PHP bug tracker and was wondering if it freely
> available software or software internal to php.net only?
> 
> I've looked around but can't find a link to it anywhere.
> 
> --
> Jean-Christian Imbeault
> Assistant Manager
> Technology Department
> _
> Mizuho Securities Co, Ltd.
> Tel: (03) 5208-2932 (direct)
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Old HTML convert to XHTML Class?

2004-08-04 Thread Christian Stocker
On Wed, 04 Aug 2004 14:57:45 +0200, Jay <[EMAIL PROTECTED]> wrote:
> Hi!
> 
> Is there any class, functions etc that will convert old HTML to XHTML.
> 
> I want to send in some HTML text and get XHTML back.

try tidy as external tool, or even better the tidy extension as native
php extension

chregu

> 
> e.g: the following would be converted:
> in=" size="2">hello"
> 
> out=" font-size: 10px; color:#cc">hello"
> 
> or something like that.
> 
> Any opensource, commercials?
> 
> Thanx In Advance
> Jay
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] XML validation with XML Schema

2004-07-30 Thread Christian Stocker
Hi

On Fri, 30 Jul 2004 14:25:44 -0300, Matias Bagini
<[EMAIL PROTECTED]> wrote:
> Is there any way to validate an XML with XML Schema using PHP4... I need
> something like the
> 
> bool DOMDocument->schemaValidate ( string filename)

No, not implemented in PHP 4. The Schema Implementatin of libxml2 is
not complete/finished anyway (but their getting there slowly...)

chregu

> 
> that exists on PHP5
> 
> Thanks,
> 
> Matias.
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php 5 DOM tutorials / examples?

2004-07-26 Thread Christian Stocker
On Mon, 26 Jul 2004 18:02:51 -0700, Ed Lazor <[EMAIL PROTECTED]> wrote:
> Any recommendations on books, links, tutorials, etc. for PHP 5's new DOM /
> XML stuff?

Answered some hours ago here on this list

See http://news.php.net/php.general/191907

(there's certainly more ;) )

chregu


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] What is the PHP5 eqvivalent to domxml_open_mem in PHP4?

2004-07-26 Thread Christian Stocker
On Mon, 26 Jul 2004 19:19:56 +0200, Erik Franzén <[EMAIL PROTECTED]> wrote:
> The docs for PHP5 and dom xml is not written yet, 

yes they are: http://www.php.net/dom

> so I tried to find
> information about load and save methods on the w3c site, but I didn't
> find anything.

You didn't look good enough ;)

http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407/

> What's is the PHP5 eqvivalent to domxml_open_mem in PHP4?

DomDOcument::loadXML();

Further readings:

http://php5.bitflux.org/phpconf2004/slide_68.php
and
http://zend.com/php5/articles/php5-xmlphp.php

chregu

> 
> /Erik
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php5: domDocument source encoding?

2004-07-26 Thread Christian Stocker
On Mon, 26 Jul 2004 17:18:48 +0200, Andreas Goetz <[EMAIL PROTECTED]> wrote:
> Excellent, thank you. So I should read the document, the do a $doc->encoding
> = 'ISO-8859-1' before reading any nodedata values to obtain ISO characters?!

No, if you access the nodeData with for example ->nodeValue, it's
UTF-8, always. $doc->encoding is only honoured during save() or
saveXML().

> 
> As documentation hasn't caught up with $doc->encoding, how could I've found
> out myself?

reading the source or the W3C Specs ;)

chregu
> 
> Thanks again for the quick help,
> Andreas
> 
> "Christian Stocker" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> 
> 
> > Hi
> >
> > On Mon, 26 Jul 2004 16:31:38 +0200, Andreas Goetz <[EMAIL PROTECTED]> wrote:
> > > I'm confused and google couldn't answer :(
> > >
> > > I'm parsing XML files using domDocument and XPath in php5. Works like a
> > > charm. But- how do I know if I need to apply and utf8decode to the data
> > > returned from the domDocument? Unlike xml_parser_create the domDocument
> does
> > > not seem to offer an parameter for source encoding.
> >
> > if you're using ->save or saveXML() it should use the initial encoding
> > (and state that in the  > $element->nodeValue) it's always utf-8. You can also read and write
> > the attribute $doc->encoding to change the output encoding (or to read
> > the input encoding).
> >
> > But as a general rule. Except for the load (where it uses the value in
> > the  >
> > chregu
> >
> > > Any ideas?
> > >
> > > Thanks a lot,
> > > Andi
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
> >
> > --
> > christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
> > phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
> > http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php5: domDocument source encoding?

2004-07-26 Thread Christian Stocker
Hi

On Mon, 26 Jul 2004 16:31:38 +0200, Andreas Goetz <[EMAIL PROTECTED]> wrote:
> I'm confused and google couldn't answer :(
> 
> I'm parsing XML files using domDocument and XPath in php5. Works like a
> charm. But- how do I know if I need to apply and utf8decode to the data
> returned from the domDocument? Unlike xml_parser_create the domDocument does
> not seem to offer an parameter for source encoding.

if you're using ->save or saveXML() it should use the initial encoding
(and state that in the nodeValue) it's always utf-8. You can also read and write
the attribute $doc->encoding to change the output encoding (or to read
the input encoding).

But as a general rule. Except for the load (where it uses the value in
the  Any ideas?
> 
> Thanks a lot,
> Andi
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: DOMXML support should be added to PHP5

2004-07-25 Thread Christian Stocker
On 25 Jul 2004 12:34:15 -, Scrumpy <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] (Jason Barnett) wrote in
> news:[EMAIL PROTECTED]:
> 
> > Well you are right that if
> > you used the old DOMXML functions in PHP4 that there is no clean way
> > to move that code forward without rewriting / supporting two
> > infrastructures.  I'm not a core developer but my guess is that they
> > didn't mind dropping the support completely because in PHP4 it was all
> > tagged as "experimental".
> 
> Looking at the two approaches, I preferred using DOMXML and as it was based
> on libxml2 & libxslt it seemed to be the better option.

I don't get that. The new DOM  and XSL extension is still based on
libxml2 and libxslt. Actually, the whole XML support in PHP 5 is now
based on libxml2 (meaning SimpleXML, ext/xml et al. as well)

> Clearly I've learn't my lesson never to use anything tagged as experimental
> again unless I'm highly competent with that language and if necessary, be
> willing and able to code everything myself.

Transitioning from DOMXML/PHP4 to DOM/PHP5 isn't really that
complicated. You have to change some methods and most if it can be
done with find&replace (for example create_element() to
createElement() ). Some functions are not anymore available in DOM, so
you have to invest a little bit more, but the logic of you're whole
application doesn't have to be changed (one such example is
new_child(), which has to be replaced with createElement/appendChild).

I agree that writing code, which should work on PHP4 and PHP 5 is a
little bit more complicated, but feasible as well (see
http://alexandre.alapetite.net/doc-alex/domxml-php4-php5/ for a start
(reposting this link, because I think the first message by me to this
topic didn't made it to the lists..))

> > It's unfortunate for you, but I think making the change now makes
> > sense because of the new DOM / SimpleXML support.
> 
> To a 'certain' extent the timing of the change is out of my hands as, like
> the majority of users, my website is hosted on a shared web server whose
> settings are out of my control.

But he will inform you some time in advance, right? ;)

[...]
> 
> In the future a transitional approach in PHP to replacing any function
> should be implemented. IMO, that is part of good project/life-cycle
> management.

It's usually the approach of PHP, but due to the chaotic and
nonstandard API of DOMXML/PHP4, it was decided to make a clear cut and
not invest any time in that, but instead really concentrate on
DOM/PHP5.
Furthermore it was marked (as you realized) experimental, so "we" warned you ;)

It won't happen again. DOM/PHP5 follows the standards established by
the W3C, so there's  no reason to break backwards compatibility
again... And it's not marked as experimental anymore.

> 
> My hope for the future is that PHP remains accessible and attractive to new
> users. It could be all too easy for the core PHP 'guru' developers to
> become blase about this aspect of the language.

Drop your "guru" conspiracy, please ;) 
The PHP core team is usually very concerned about BC (backwards
compatibility) and as you maybe realized, 99% of PHP 4 scripts run on
PHP 5 without any problems at all. The one big exception is DOMXML,
for the reasons stated above.

chregu


> 
> Cheers,
> Scrumpy :)
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP5, XPath and count()

2004-07-24 Thread Christian Stocker
On Sat, 24 Jul 2004 17:35:59 +0200, Victor Boivie <[EMAIL PROTECTED]> wrote:
> Christian Stocker wrote:
> 
> >>var_dump($xpath->query("count(/catalog/cd")->item(0));
> >
> >
> > this doesn't work yet in DOM. The returned value has to be a nodeset.
> > Will be fixed some day ;)
> >
> 
> Thanks, both Jason and Christian
> 
> I found something else that I think is strange.
> 
>$dom = new DOMDocument();
> 
>$root = $dom->createElement("test");
>$dom->appendChild($root);
> 
>$node = $dom->createElement("foo", "which entities does it
> escape & which doesn't it?");
>$root->appendChild($node);
> 
>echo $dom->saveXML();

Yep, that looks like a bug...  Can you please file a bug at bugs.php.net?

The workaround is the write the following:

$node = $dom->createElement("foo");
$text = $dom->createTextNode( "which entities does it
escape & which doesn't it?");
$node->appendChild($text);
$root->appendChild($node);


While a little more to type, it's at least the official W3C way ;)

chregu

> 
> The result will be:
> 
> 
> which entities <i>does</i> it escape 
> 
> It stops at the &, which I think is strange. It escapes the < to <
> and > to >, but not & to &. It would be better if it escaped none
> or all entites that "can do harm".
> 
> Or what do you think?
> regards,
> Victor
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP5, XPath and count()

2004-07-21 Thread Christian Stocker
On Tue, 20 Jul 2004 22:57:20 +0200, Victor Boivie
<[EMAIL PROTECTED]> wrote:
> Assume an XML file that looks like:
> 
> 
>   
>..
>   
>   
>..
>   
>   ..
> 
> 
> ... and that I would like to know the number of CDs. An xpath expression
> would look like count(/catalog/cd), but how do I run this expression?
> 
> $dom = new DOMDocument();
> $dom->load("catalog.xml");
> $xpath = new DOMXpath($dom);
> var_dump($xpath->query("count(/catalog/cd")->item(0));

this doesn't work yet in DOM. The returned value has to be a nodeset.
Will be fixed some day ;)

see victors answer for the work around

chregu
> 
> ... returns NULL.
> 
> Any ideas?
> 
> Thanks in advance,
> Victor
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: [PHP-XML-DEV] Re: [PHP] PHP5: ext/dom - set namespace of node manually

2004-02-16 Thread Christian Stocker


On 2/16/04 12:07 PM, Rob Richards wrote:

Porting the setNamespace function to PHP5 would be nice. Another solution
could be the possibility to append a namespace-node (is the
domnamespacenode class currently used by any functions?) or the
setAttribute checks wether some "xmlns"/"xmlns:" attribute is set and
updates namespaceUri itself... would be more W3C standard compliant.


The namespace node isnt really used with any functions. It is also a
"special" node as its not a standard node type in libxml.
Via the specs, it doesnt really exist, but it can be returned via xpath,
which is why dom manipulates the libxml namespace into a returnable type,
which a few of the properties are allowed to work with it (otherwise either
dom would either have to prevent xpath from returning it or let the system
crash when its returned - neither of these options was acceptable - thus
this special node).
As far as setAttributeNS goes. This function actually does do checks,
however it doesnt put the element into the current namespace (which possibly
may be a logic bug - namespaces internally are so damned confusing).
Using the syntax:

$node->setAttributeNS("http://www.w3.org/2000/xmlns/";, "xmlns:b",
"http://www.somedomain.de/";);
This sets the definition on the element but doesnt put that node into the
namespace, it just puts the namespace into the scope of the node, so that
elements added with createelementns and appended as children of $node can be
placed within the namespace and would be prefixed with "b".
Now here is the question, if a namespace is not associated on the element at
that point, should the above set the element into the new namespace? (Easy
enough to implement, but really have no clue if this is the proper logic or
not). Any namespace gurus around here?
IMHO, that would be very confusing.

I liked the idea by vivian with a third optional namespaceURI argument 
for the element object, so that at least you can use your own extended 
classes for that.

And maybe we still need a ->setNamespaceURI method, even if W3C didnt 
think of that ;)

chregu

Rob

--
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: [PHP-XML-DEV] Re: [PHP] PHP5: ext/dom - set namespace of node manually

2004-02-15 Thread Christian Stocker


On 2/16/04 1:24 AM, Adam Bregenzer wrote:

On Sun, 2004-02-15 at 19:04, Vivian Steller wrote:

As you can see it is impossible to set the namespace manually! I tried to
set it with the help of a DomNamespaceNode-object but those objects are no
"real" nodes (why!?!) and the consequence is that you couldn't append such
a node with $node->appendChild($domnamspacenode_object); ...


I am not sure if PHP 5 has many changes from PHP 4, however have you
tried calling set_namespace[1]?
$node->set_namespace('http://www.somedomain.de/');
[1] http://www.php.net/domnode-set-namespace


Vivian, it's not possible the set the namespace according to the W3C 
standard, except with createElementNS(). As Adam said, in PHP 4, there 
was the option set_namespace, which isn't ported to PHP5 (yet).

Maybe we should port that function as well, to allow some deeper level 
manipulation of the namespaces...

Currently, I don't have a solution to your problem, except porting 
setNamespace to PHP5...

chregu

--
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [EMAIL PROTECTED]  |  gnupg-keyid 0x5CE1DECB
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Question and PHP DOMXML and Apache

2002-04-23 Thread Christian Stocker

In <[EMAIL PROTECTED]>, Sebastian A. wrote:

> Have the new DOM XML functions been included in the latest version of
> PHP (4.2) when I try to use one of the new functions, such as
> domxml_open_file() I get an error message saying I am calling and
> undefined function. Has anyone successfully used these new functions
> with PHP 4.2? 

domxml_open_file() will be in PHP4.3 (or whatever the version number for
the next major php-release will be). until then use xmldocfile();

> My second question is about apache. How do I do a "clean"
> shutdown of apache? When I shut I down through the console, the next
> time I start it up I am told something about an unclean shutdown...

apachectl stop?

chregu

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: XML closing elements called for

2002-02-06 Thread Christian Stocker

In <000a01c1af5a$dbf70140$73fd883e@laptop>, Hammy wrote:

> Is there any way to suppress or detect when the closing element event
> fires from tags in the form  rather than ?
> 

no, i don't think so. It means exactly the same in the XML-sense, so why
should there be a difference in reporting it...

chregu

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: PEAR IMAGICK [WAS-> RANT: Why doesn't PHP have built-in support for dynamic]

2002-02-04 Thread Christian Stocker

In <[EMAIL PROTECTED]>, Michael Kimsal wrote:

> Christian Stocker wrote:
> 
> 
>>>see (which is how I labelled it above) and what I'm capable of actually
>>>contributing.
>>>Doing C-code PHP extensions is beyond my capabilities, so I make do
>>>with what others contribute.  Simply because something is opensource
>>>doesn't mean everyone has equal talent to add in actual code.  :( I
>>>thank you for your contribution of this code so far, and should you
>>>continue to work on it in whatever fashion you choose, so much the
>>>better.  It is appreciated, OO or not (it would just be appreciated
>>>more if it was OO.)  :)
>>>
>>>
>> i would it appreciate as well, if it was OO. I was just not capable
>> back then to do it OO, maybe i am the next time I invest more time in
>> it.
>> 
>> christian
>> 
>> 
>> 
> FWIW, I re-evaluated the situation, and I think I was mistaken- it's not
> a PHP exension you're writing, is it?  It's just PHP code, like much of
> PEAR right?  Or is it an actual extension that I'd compile in?

it's an actual extension, which has to be compiled in.

chregu

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: Why doesn't PHP have built-in support for dynamic image generation?

2002-02-03 Thread Christian Stocker

In <[EMAIL PROTECTED]>, Andy wrote:

> Hi guys,
> 
> I think his original question was how to install GD!
> 
> It's not a big deal!
> - Install PHP > 4.06
> - edit the php.ini -> delete the comment tags from the gd import module
> - restart your server if it is running not as a CGI extension
> 
> Thats it!!!

If you have windows ...

But said that, i never had any problems in compiling php with gdlib under
debian testing...

chregu

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: PEAR IMAGICK [WAS-> RANT: Why doesn't PHP have built-in support for dynamic]

2002-02-03 Thread Christian Stocker

In <[EMAIL PROTECTED]>, Michael Kimsal wrote:



>>>Someone seems to have started this, although I'm not sure why he's not
>>>going more object-based.
>>>
>>>
>>>http://pear.php.net/manual/en/packages.imagick.php
>>>
>>>I would prefer something like
>>>
>>>$i = new Imagick();
>>>$i->read("file");
>>>
>>>instead of
>>>$i= imagick_create();
>>>imagick_read($i,"file");
>>>
>>>
>> it's open source. just do it more object orientated ... and i'm sure
>> the author (me...) will be very happy to impelement it ;)
>> 
>> honestly, OO-Interface was and still is planned, but i think more
>> functionality is  much more needed at the moment than an oo interface.
>> it was my first extension, so i wanted to keep it simple for the
>> beginning.
>> 
>> but if someone else likes to implement it earlier, i'm the last, who
>> has a problem with that (and don't expect 00 soon from me ...)
>> 
>> chregu
>> 
>> 
>> 
> Hello -
> 
> Please don't take my comment the wrong way - I know what I'd *like* to

no, didn't take it the wrong way. maybe my answer was a bit to harsh ;)

> see (which is how I labelled it above) and what I'm capable of actually
> contributing.
> Doing C-code PHP extensions is beyond my capabilities, so I make do with
> what others contribute.  Simply because something is opensource doesn't
> mean everyone has equal talent to add in actual code.  :(
> I thank you for your contribution of this code so far, and should you
> continue to work on it in whatever fashion you choose, so much the
> better.  It is appreciated, OO or not (it would just be appreciated more
> if it was OO.)  :)

i would it appreciate as well, if it was OO. I was just not capable back
then to do it OO, maybe i am the next time I invest more time in it.

christian

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: PEAR IMAGICK [WAS-> RANT: Why doesn't PHP have built-in support for dynamic]

2002-02-03 Thread Christian Stocker

In <[EMAIL PROTECTED]>, Michael Kimsal wrote:

> Weston Houghton wrote:
> 
>> Anybody interested in working on a PEAR module to interface PHP with
>> something like ImageMagick directly? I would love to see it. Maybe if I
>> am unemployed long enough soon I can work on it myself. Not that I
>> really want that to happen...
>> 
>> I think that might be the best solution for PHP's lack of image
>> functionality though...
>> 
>> Wes
>> 
>> 
> Someone seems to have started this, although I'm not sure why he's not
> going more object-based.
> 
> 
> http://pear.php.net/manual/en/packages.imagick.php
> 
> I would prefer something like
> 
> $i = new Imagick();
> $i->read("file");
> 
> instead of
> $i= imagick_create();
> imagick_read($i,"file");

it's open source. just do it more object orientated ... and i'm sure the
author (me...) will be very happy to impelement it ;)

honestly, OO-Interface was and still is planned, but i think
more functionality is  much more needed at the moment than an oo
interface. it was my first extension, so i wanted to keep it simple for
the beginning.

but if someone else likes to implement it earlier, i'm the last, who has
a problem with that (and don't expect 00 soon from me ...)

chregu

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] RANT: Why doesn't PHP have built-in support for dynamic image generation?

2002-02-03 Thread Christian Stocker

In <[EMAIL PROTECTED]>, Victor Boivie wrote:

> PEAR? I think it would be better if someone did a "real" PHP module for
> ImageMagick, just like PerlMagick is for Perl. There is one at
> http://php.chregu.tv/imagick/, but it's far from complete. If someone
> would like to help him with the project then it would be great.

yeah. do it :)

chregu

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: printing an XML node

2002-01-18 Thread Christian Stocker

In <[EMAIL PROTECTED]>, Christian Stocker
wrote:

> In <[EMAIL PROTECTED]>, Thomas Gagne wrote:
> 
>> dumpmem works great for entire documents, but what is the strategy for
>> printing the contents of a single node?  It is impossible to use
>> dumpmem on a node since the code looks for a 'doc' property that
>> doesn't exist in nodes.
> 
> it's not possible at the moment, but there's a libxml-function, which
> does exactly that. if i find some time, i will implement it in the not
> so distant future :)

ok. did it. it's in cvs now.

$string = domxml_dump_node($docobject,$nodeobj);

or

$string = $docobject->dump_node($nodeobj);

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: printing an XML node

2002-01-17 Thread Christian Stocker

In <[EMAIL PROTECTED]>, Thomas Gagne wrote:

> dumpmem works great for entire documents, but what is the strategy for
> printing the contents of a single node?  It is impossible to use dumpmem
> on a node since the code looks for a 'doc' property that doesn't exist
> in nodes.

it's not possible at the moment, but there's a libxml-function, which
does exactly that. if i find some time, i will implement it in the not so
distant future :)

chregu

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] LIBXML- Auto-Indent - How do it?

2001-12-17 Thread Christian Stocker

In <100984FEB15DD511BA9300104B6980760AC36B@EXCHANGE-RIO>, Ricardo Junior
wrote:

> The conversion to plain text mail format changed the correct indent that
> I need I'm needing it like this:
> 
> 
>   
> 
>   
> 
> 
> Thanks !!!

no need to scream here :)

here's a function, which maybe helps you (it adds indentation to a string
containing xml-stuff)

 function get_indented_xml($xml,$instring = "") {
$xml = preg_replace("/(\>)\n/","$1",$xml);
$xml = preg_replace("/\>\s*\\n<",$xml);

$axml = explode("\n",$xml);

$indent=-1;
$xmls = "";
foreach ($axml as $key => $value) {

if (preg_match("/<[^\/{1}]/",$value)) {
$indent++;
}
if ($indent < 0)
$indent = 0;
$xmls .= str_repeat($instring,$indent);
if (preg_match("/\<\//",$value) || preg_match("/\/\>/",$value)|| 
preg_match("/-->/",$value)) {
$indent--;
}
$xmls .= trim($value)."\n";
}
   return $xmls;
}

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] LIBXML- Auto-Indent - How do it?

2001-12-17 Thread Christian Stocker

In <100984FEB15DD511BA9300104B6980760AC36B@EXCHANGE-RIO>, Ricardo Junior
wrote:

> The conversion to plain text mail format changed the correct indent that
> I need I'm needing it like this:
>
> 
>   
> 
>   
> 
>
> Thanks !!!

no need to scream here :)

here's a function, which maybe helps you (it adds indentation to a string
containing xml-stuff)

 function get_indented_xml($xml,$instring = "") {
$xml = preg_replace("/(\>)\n/","$1",$xml);
$xml = preg_replace("/\>\s*\\n<",$xml);

$axml = explode("\n",$xml);

$indent=-1;
$xmls = "";
foreach ($axml as $key => $value) {

if (preg_match("/<[^\/{1}]/",$value)) {
$indent++;
}
if ($indent < 0)
$indent = 0;
$xmls .= str_repeat($instring,$indent);
if (preg_match("/\<\//",$value) ||
preg_match("/\/\>/",$value)|| preg_match("/-->/",$value)) {
$indent--;
}
$xmls .= trim($value)."\n";
}
   return $xmls;
}



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: PHP and JAVA

2001-12-02 Thread Christian Stocker

In <00f501c17b22$dd26da20$0600a8c0@shaemeli>, Steve Haemelinck wrote:

> Hi all
> 
> Does anyone got any experience with JAVA in PHP? I tried to rebuild php
> with java support. Everything worked well but when I try to initiate
> Java in PHP, I get cannot instantiate Virtual machine. I use kaffe and I
> believe I have configured PHP correctly.
> 
> See http://www.haemelinck.be:8080/phpinfo.phtml
> 
> 
look at http://php.chregu.tv/java-debian.html

maybe this gives you a hint what you could have missed.

chregu

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: XSLT error functions

2001-10-20 Thread Christian Stocker

In <[EMAIL PROTECTED]>, Vikram Vaswani
wrote:

> Hi all,
> 
> Am working with the XSLT functions in PHP. I'm trying to trap errors
> with the xslt_error() functions - however, the function generates no
> output even if I deliberately introduce errors into the XSLT sheet.
> 
> Same goes for the openlog() function. Any one have any ideas how I can
> use these to generate and log errors?


as far as i know, ext/sablot from 4.0.6 doesn't really support the error
function. you have to wait for 4.1.0 and the new ext/xslt extension,
which does support that just fine.
 
> Finally, I don't think the Sablot engine which ships with 4.0.6 supports
> all the features of the XSLT spec. Any clues on where I can find a list
> of supported items?

http://www.gingerall.com

chregu

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] ext/java with sun jdk 1.3.1?

2001-09-14 Thread Christian Stocker

Hello

Was anyone ever able to get jdk 1.3.1 from sun running together with
ext/java in php? jdk 1.2.2 was not a big problem, but if i switch to
1.3.1, the scripts do not output anything. not even an entry in the
logfiles is made.

if it's really impossible, i'll stay with 1.2.2 and will not try any
further ;)

I'm using debian unstable and php 4.0.7RC2.

thanks for any hints.

chregu

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-CVS] cvs: php4 /pear/Experimental/XML sql2xml.php

2001-04-06 Thread Christian Stocker

chregu  Fri Apr  6 03:13:13 2001 EDT

  Modified files:  
/php4/pear/Experimental/XML sql2xml.php 
  Log:
  - Row and result Tag names are now configurable
  - some errorchecking
  
  
Index: php4/pear/Experimental/XML/sql2xml.php
diff -u php4/pear/Experimental/XML/sql2xml.php:1.6 
php4/pear/Experimental/XML/sql2xml.php:1.7
--- php4/pear/Experimental/XML/sql2xml.php:1.6  Wed Apr  4 02:15:57 2001
+++ php4/pear/Experimental/XML/sql2xml.php  Fri Apr  6 03:13:13 2001
@@ -15,19 +15,16 @@
 // | Authors: Christian Stocker <[EMAIL PROTECTED]> |
 // +--+
 //
-// $Id: sql2xml.php,v 1.6 2001/04/04 09:15:57 chregu Exp $
+// $Id: sql2xml.php,v 1.7 2001/04/06 10:13:13 chregu Exp $
 
-require_once("PEAR.php");
-
 /**
 * This class takes a PEAR::DB-Result Object, a sql-query-string or an array
 *  and returns a xml-representation of it.
 *
-* More docs will follow
-*
 * TODO
 *   -encoding etc, options for header
-*   - ERROR CHECKING
+*   -ERROR CHECKING
+*
 * Usage example
 *
 * include_once ("DB.php");
@@ -39,16 +36,17 @@
 *
 * or
 *
+* include_once ("DB.php");
+* include_once("XML/sql2xml.php");
 * $sql2xml = new xml_sql2xml("mysql://root@localhost/xmltest");
-* $sql2xml->AddSql("select * from bands");
+* $sql2xml->Add("select * from bands");
 * $xmlstring = $sql2xml->getXML();
 *
-* more examples and outputs on
+* More documentation and a tutorial/how-to can be found at
 *   http://www.nomad.ch/php/sql2xml
-*   for the time being
 *
 * @author   Christian Stocker <[EMAIL PROTECTED]>
-* @version  $Id: sql2xml.php,v 1.6 2001/04/04 09:15:57 chregu Exp $
+* @version  $Id: sql2xml.php,v 1.7 2001/04/06 10:13:13 chregu Exp $
 * @package  XML
 */
 class XML_sql2xml {
@@ -67,6 +65,22 @@
 var $nested = True;
 
 /**
+* Name of the tag element for resultsets
+*
+* @var  string
+* @see  insertNewResult()
+*/
+var $tagNameResult = "result";
+
+/**
+* Name of the tag element for rows
+*
+* @var  string
+* @see  insertNewRow()
+*/
+var $tagNameRow = "row";
+
+/**
 *
 * @var   object PEAR::DB
 * @acces private
@@ -159,15 +173,12 @@
 * @param  $dsn string with PEAR::DB "data source name" or object DB object
 * @param  $root string of the name of the xml-doc root element.
 */
-function XML_sql2xml ($dsn=False,$root = "root") {
+function XML_sql2xml ($dsn=Null,$root = "root") {
 
-if (DB::isError($dsn)) {
-print "The given param for XML_sql2xml was not valid in file ".__FILE__." 
at line ".__LINE__."\n";
-return new DB_Error($dsn->code,PEAR_ERROR_DIE);
-}
-
 // if it's a string, then it must be a dsn-identifier;
-if (is_string($dsn)) {
+if (is_string($dsn))
+{
+include_once ("DB.php");
 $this->db = DB::Connect($dsn);
 if (DB::isError($this->db))
 {
@@ -176,6 +187,13 @@
 }
 
 }
+
+elseif (DB::isError($dsn))
+{
+print "The given param for XML_sql2xml was not valid in file ".__FILE__." 
+at line ".__LINE__."\n";
+return new DB_Error($dsn->code,PEAR_ERROR_DIE);
+}
+
 // if parent class is db_common, then it's already a connected identifier
 elseif (get_parent_class($dsn) == "db_common")
 {
@@ -306,9 +324,12 @@
 new DB_Error($result->code,PEAR_ERROR_DIE);
 }
 
-//user should be able to give his own tableInfo-array, but not implemented yet
+// the method_exists is here, cause tableInfo is only in the cvs at the moment
+// (should be in 4.0.6)
+// BE CAREFUL: if you have fields with the same name in different tables, you 
+will get errors
+// later, since DB_FETCHMODE_ASSOC doesn't differentiate that stuff.
 
-if (! ($tableInfo = $result->tableInfo(False)))
+if (!method_exists($result,"tableInfo") || ! ($tableInfo = 
+$result->tableInfo(False)))
 {
 //emulate tableInfo. this can go away, if every db supports tableInfo
 $fetchmode = DB_FETCHMODE_ASSOC;
@@ -318,7 +339,7 @@
 
 while (list($key, $val) = each($res))
 {
-$tableInfo[$i]["table"]= "result";
+$tableInfo[$i]["table"]= $this->tagNameResult;
 $tableInfo[$i]["name"] = $key;
 $resFirstRow[$i] = $val;
 $i++;
@@ -363,7 +384,6 @@
 {
 //FirstFetchDone is only for emulating tableInfo, as long as not all dbs 
support tableInfo. can go awa

[PHP-CVS] cvs: php4 /pear/Experimental/XML sql2xml.php

2001-04-04 Thread Christian Stocker

chregu  Wed Apr  4 02:15:58 2001 EDT

  Modified files:  
/php4/pear/Experimental/XML sql2xml.php 
  Log:
  - new function addArray() for adding Arrays to the xml
  - new function addSql() for providing sql-strings as input
  - constructor takes a dsn or a pear::db object as param (API-Change..)
  - a lot of inline-documentation (not finished...)
  
  

Index: php4/pear/Experimental/XML/sql2xml.php
diff -u php4/pear/Experimental/XML/sql2xml.php:1.5 
php4/pear/Experimental/XML/sql2xml.php:1.6
--- php4/pear/Experimental/XML/sql2xml.php:1.5  Fri Mar 30 04:55:30 2001
+++ php4/pear/Experimental/XML/sql2xml.php  Wed Apr  4 02:15:57 2001
@@ -15,74 +15,174 @@
 // | Authors: Christian Stocker <[EMAIL PROTECTED]> |
 // +--+
 //
-// $Id: sql2xml.php,v 1.5 2001/03/30 12:55:30 chregu Exp $
+// $Id: sql2xml.php,v 1.6 2001/04/04 09:15:57 chregu Exp $
 
+require_once("PEAR.php");
+
 /**
-* This class takes a PEAR::DB-Result Object (or more than one)
+* This class takes a PEAR::DB-Result Object, a sql-query-string or an array
 *  and returns a xml-representation of it.
 *
 * More docs will follow
 *
+* TODO
+*   -encoding etc, options for header
+*   - ERROR CHECKING
 * Usage example
 *
 * include_once ("DB.php");
 * include_once("XML/sql2xml.php");
 * $db = DB::connect("mysql://root@localhost/xmltest");
-* $xml = new xml_sql2xml;
+* $sql2xml = new xml_sql2xml();
 * $result = $db->query("select * from bands");
-* $xmlstring = $xml->getXML($result,$options));
+* $xmlstring = $sql2xml->getXML($result);
+*
+* or
 *
+* $sql2xml = new xml_sql2xml("mysql://root@localhost/xmltest");
+* $sql2xml->AddSql("select * from bands");
+* $xmlstring = $sql2xml->getXML();
+*
 * more examples and outputs on
 *   http://www.nomad.ch/php/sql2xml
 *   for the time being
 *
 * @author   Christian Stocker <[EMAIL PROTECTED]>
-* @version  $Id: sql2xml.php,v 1.5 2001/03/30 12:55:30 chregu Exp $
+* @version  $Id: sql2xml.php,v 1.6 2001/04/04 09:15:57 chregu Exp $
+* @package  XML
 */
 class XML_sql2xml {
 
 /**
+* If joined-tables should be output nested.
+*  Means, if you have joined two or more queries, the later
+*   specified tables will be nested within the result of the former
+*   table.
+*   Works at the moment only with mysql automagically. For other RDBMS
+*   you have to provide your table-relations by hand (see user_tableinfo)
 *
 * @var  boolean
+* @see  $user_tableinfo, doSql2Xml(), doArray2Xml();
 */
 var $nested = True;
 
+/**
+*
+* @var   object PEAR::DB
+* @acces private
+*/
+var $db = Null;
+
 
 /**
+* Options to be used in extended Classes (for example in sql2xml_ext).
+* They are passed with SetOptions as an array (arrary("user_optpaions" = array());
+*  and can then be accessed with $this->user_options["bla"] from your
+*  extended classes for additional features.
+*  This array is not use in this base class, it's only for passing easy parameters
+*  to extended classes.
 *
-* @var  boolean
+* @var  array
 */
-var $user_options = False;
+var $user_options = array();
 
 
 /**
+* The DomDocument Object to be used in the whole class
 *
-* @var  object  domxml
+* @var  object  DomDocument
+* @accesprivate
 */
 var $xmldoc;
 
 
 /**
+* The Root of the domxml object
+* I'm not sure, if we need this as a class variable
 *
-* @var  string
+* @var  object DomNode
+* @accesprivate
 */
-var $xmlroot = "";
+var $xmlroot;
 
 
 /**
+* This array is used to give the structure of your database to the class.
+*  It's especially useful, if you don't use mysql, since other RDBMS than
+*  mysql are not able at the moment to provide the right information about
+*  your database structure within the query. And if you have more than 2
+*  tables joined in the sql it's also not possible for mysql to find out
+*  your real relations.
+*  The parameters are the same as in fieldInfo from the PEAR::DB and some
+*   additional ones. Here they come:
+*  From PEAR::DB->fieldinfo:
 *
-* @var  boolean
+*$tableInfo[$i]["table"]: the table, which field #$i belongs to.
+*   for some rdbms/comples queries and with arrays, it's impossible
+*   to find out to which table the field actually belongs. You can
+*   specify it here more accurate. Or if you want, that one fields
+*   belongs to another table, than it actually says (yes, there's
+*   use for that, see the upcoming tutorial ...)
+*
+*$tableInfo[$i]["name"]

[PHP-CVS] cvs: php4 /pear/Experimental/XML fo2pdf.php

2001-03-31 Thread Christian Stocker

chregu  Sat Mar 31 05:38:58 2001 EDT

  Modified files:  
/php4/pear/Experimental/XML fo2pdf.php 
  Log:
  - converted tabs to spaces
  - more links in the docs about xsl:fo
  
  
  

Index: php4/pear/Experimental/XML/fo2pdf.php
diff -u php4/pear/Experimental/XML/fo2pdf.php:1.5 
php4/pear/Experimental/XML/fo2pdf.php:1.6
--- php4/pear/Experimental/XML/fo2pdf.php:1.5   Fri Mar 30 04:55:07 2001
+++ php4/pear/Experimental/XML/fo2pdf.php   Sat Mar 31 05:38:58 2001
@@ -15,7 +15,7 @@
 // | Authors: Christian Stocker <[EMAIL PROTECTED]> |
 // +--+
 //
-// $Id: fo2pdf.php,v 1.5 2001/03/30 12:55:07 chregu Exp $
+// $Id: fo2pdf.php,v 1.6 2001/03/31 13:38:58 chregu Exp $
 
 
 /**
@@ -23,9 +23,16 @@
 *
 * with fo (formating objects) it's quite easy to convert xml-documents into
 *  pdf-docs.
-* 
+*
 * An introduction into formating objects can be found at
 *  http://www.w3.org/TR/xsl/slice6.html#fo-section
+*  http://www.ibiblio.org/xml/books/bible/updates/15.html
+* A tutorial is here:
+*  http://www.xml.com/pub/a/2001/01/17/xsl-fo/
+*  http://www.xml.com/pub/a/2001/01/24/xsl-fo/
+* A html_to_fo.xsl can also be found there
+*  http://www.xml.com/2001/01/24/xsl-fo/fop_article.tgz
+*  but it didn't work for my simple xhtml files..
 *
 * The way to use this class is, produce a fo-file from a xml-file with a
 * xsl-stylesheet, then feed this class with this fo-file and you get a pdf
@@ -44,9 +51,9 @@
 *  Furthermore you have to compile your php with --with-java and to adjust
 *   your php.ini file. It can be a rather painful task to get java and php
 *   to work together.
-*   See http://www.phpbuilder.com/columns/marknold20001221.php3 or 
-*  http://www.linuxwebdevnews.com/articles/php-java-xslt.php?pid=347
-*  for more details about java and php or ask me, if you're stuck 
+*   See http://www.phpbuilder.com/columns/marknold20001221.php3 or
+*   http://www.linuxwebdevnews.com/articles/php-java-xslt.php?pid=347
+*   for more details about java and php or ask me, if you're stuck
 *   (especially with linux. windows is not my area..)
 *
 * Todo:
@@ -84,191 +91,191 @@
 *print $cache->end("+30");
 *
 * @author   Christian Stocker <[EMAIL PROTECTED]>
-* @version  $Id: fo2pdf.php,v 1.5 2001/03/30 12:55:07 chregu Exp $
+* @version  $Id: fo2pdf.php,v 1.6 2001/03/31 13:38:58 chregu Exp $
 * @package  XML
 */
 
 class XML_fo2pdf {
 
-   /**
-   * fo-file used in this class
-   *
-   * @var  string
-   */
-   var $fo = "";
-
-   /**
-   * pdf-file used in this class
-   *
-   * @var  string
-   */
-   var $pdf = "";
-
-   /**
-   * Where the temporary fo and pdf files should be stored
-   *
-   * @var  string
-   */
-   var $tmpdir = "/tmp";
-
-   /**
-   * A prefix for the temporary files
-   *
-   * @var  string
-   */
-   var $tmppdfprefix = "pdffo";
-
-
-   /**
-   * constructor
-   * One can pass an input fo-file already here (the other possibility
-   * is with the run or runFromString method).
-   *  and if the pdf should be stored permanently, a filename/path for
-   *  that can also be passed here.
-   *
-   * @paramstring  file input fo-file
-   * @paramstring  file output pdf-file
-   * @see run(), runFromString(), runFromFile()
-   */
-   function xml_fo2pdf($fo = "", $pdf = "")
-   {
-   if ($fo) {
-   $this->run($fo, $pdf);
-   }
-   }
-
-   /**
-   * Calls the Main Fop-Java-Programm
-   *
-   * One has to pass an input fo-file
-   *  and if the pdf should be stored permanently, a filename/path for
-   *  the pdf.
-   *  if the pdf is not passed or empty/false, a temporary pdf-file
-   *   will be created
-   *
-   * @paramstring  file input fo-file
-   * @paramstring  file output pdf-file
-   * @paramboolean if the fo should be deleted after execution
-   * @see runFromString()
-   */
-   function run($fo, $pdf = "", $DelFo = False)
-   {
-   if (!$pdf)
-   $pdf = tempnam($this->tmpdir, $this->tmppdfprefix);
-
-   $this->pdf = $pdf;
-   $this->fo = $fo;
-   $options = array($this->fo, $this->pdf);
-   $java = new Java("org.apache.fop.apps.CommandLine", $options);
-   $java->run();
-   if ($DelFo) {
-   $this->deleteFo($fo);
-   }
-   }
-
-   /**
-   * If the fo is a string, not a file, use this.
-   *
-   * If you generate the fo dynamically (for example with a
-   *  xsl-stylesheet), y

[PHP-CVS] cvs: php4 /pear/Experimental/XML sql2xml.php

2001-03-30 Thread Christian Stocker

chregu  Fri Mar 30 04:55:30 2001 EDT

  Modified files:  
/php4/pear/Experimental/XML sql2xml.php 
  Log:
  too much whitespaces after ?>
  
  
Index: php4/pear/Experimental/XML/sql2xml.php
diff -u php4/pear/Experimental/XML/sql2xml.php:1.4 
php4/pear/Experimental/XML/sql2xml.php:1.5
--- php4/pear/Experimental/XML/sql2xml.php:1.4  Fri Mar 30 03:03:11 2001
+++ php4/pear/Experimental/XML/sql2xml.php  Fri Mar 30 04:55:30 2001
@@ -15,7 +15,7 @@
 // | Authors: Christian Stocker <[EMAIL PROTECTED]> |
 // +--+
 //
-// $Id: sql2xml.php,v 1.4 2001/03/30 11:03:11 chregu Exp $
+// $Id: sql2xml.php,v 1.5 2001/03/30 12:55:30 chregu Exp $
 
 /**
 * This class takes a PEAR::DB-Result Object (or more than one)
@@ -37,7 +37,7 @@
 *   for the time being
 *
 * @author   Christian Stocker <[EMAIL PROTECTED]>
-* @version  $Id: sql2xml.php,v 1.4 2001/03/30 11:03:11 chregu Exp $
+* @version  $Id: sql2xml.php,v 1.5 2001/03/30 12:55:30 chregu Exp $
 */
 class XML_sql2xml {
 
@@ -376,5 +376,3 @@
 
 }
 ?>
-
-



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-CVS] cvs: php4 /pear/Experimental/XML fo2pdf.php

2001-03-30 Thread Christian Stocker

chregu  Fri Mar 30 04:55:07 2001 EDT

  Modified files:  
/php4/pear/Experimental/XML fo2pdf.php 
  Log:
  printPDF() din't print out the correct header, if no pdf was specified
  
  
Index: php4/pear/Experimental/XML/fo2pdf.php
diff -u php4/pear/Experimental/XML/fo2pdf.php:1.4 
php4/pear/Experimental/XML/fo2pdf.php:1.5
--- php4/pear/Experimental/XML/fo2pdf.php:1.4   Thu Mar 29 13:26:53 2001
+++ php4/pear/Experimental/XML/fo2pdf.php   Fri Mar 30 04:55:07 2001
@@ -15,7 +15,7 @@
 // | Authors: Christian Stocker <[EMAIL PROTECTED]> |
 // +--+
 //
-// $Id: fo2pdf.php,v 1.4 2001/03/29 21:26:53 uw Exp $
+// $Id: fo2pdf.php,v 1.5 2001/03/30 12:55:07 chregu Exp $
 
 
 /**
@@ -84,7 +84,7 @@
 *print $cache->end("+30");
 *
 * @author   Christian Stocker <[EMAIL PROTECTED]>
-* @version  $Id: fo2pdf.php,v 1.4 2001/03/29 21:26:53 uw Exp $
+* @version  $Id: fo2pdf.php,v 1.5 2001/03/30 12:55:07 chregu Exp $
 * @package  XML
 */
 
@@ -246,8 +246,9 @@
*/
function  printPDF($pdf = "")
{
+   $pdf = $this->returnPDF($pdf);
Header("Content-type: application/pdf\nContent-Length: " . 
strlen($pdf));
-   print $this->returnPDF($pdf);
+   print $pdf;
}
 
/**
@@ -260,7 +261,7 @@
* @see run()
*/
function returnPDF($pdf = "")
-{
+   {
   if (!$pdf)
   $pdf = $this->pdf;
 
@@ -271,4 +272,4 @@
 }
 
 }
-?>
\ No newline at end of file
+?>



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-CVS] cvs: php4 /pear/Experimental/XML sql2xml.php

2001-03-30 Thread Christian Stocker

chregu  Fri Mar 30 03:03:11 2001 EDT

  Modified files:  
/php4/pear/Experimental/XML sql2xml.php 
  Log:
  one api-change ulf forgot:
  
  getxml() -> getXML()
  
  
Index: php4/pear/Experimental/XML/sql2xml.php
diff -u php4/pear/Experimental/XML/sql2xml.php:1.3 
php4/pear/Experimental/XML/sql2xml.php:1.4
--- php4/pear/Experimental/XML/sql2xml.php:1.3  Fri Mar 30 02:36:42 2001
+++ php4/pear/Experimental/XML/sql2xml.php  Fri Mar 30 03:03:11 2001
@@ -15,7 +15,7 @@
 // | Authors: Christian Stocker <[EMAIL PROTECTED]> |
 // +--+
 //
-// $Id: sql2xml.php,v 1.3 2001/03/30 10:36:42 chregu Exp $
+// $Id: sql2xml.php,v 1.4 2001/03/30 11:03:11 chregu Exp $
 
 /**
 * This class takes a PEAR::DB-Result Object (or more than one)
@@ -37,7 +37,7 @@
 *   for the time being
 *
 * @author   Christian Stocker <[EMAIL PROTECTED]>
-* @version  $Id: sql2xml.php,v 1.3 2001/03/30 10:36:42 chregu Exp $
+* @version  $Id: sql2xml.php,v 1.4 2001/03/30 11:03:11 chregu Exp $
 */
 class XML_sql2xml {
 
@@ -114,7 +114,7 @@
 * @return   string  xml
 * @access   public
 */
-function getxml($result = False, $options = False)
+function getXML($result = False, $options = False)
 {
 return domxml_dumpmem($this->getXMLObject($result, $options));
 }



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-CVS] cvs: php4 /pear/Experimental/XML sql2xml_ext.php

2001-03-30 Thread Christian Stocker

chregu  Fri Mar 30 02:37:35 2001 EDT

  Modified files:  
/php4/pear/Experimental/XML sql2xml_ext.php 
  Log:
  a lot of new customizable options too much to be listed here, 
  documentation will follow.
  
  
Index: php4/pear/Experimental/XML/sql2xml_ext.php
diff -u php4/pear/Experimental/XML/sql2xml_ext.php:1.2 
php4/pear/Experimental/XML/sql2xml_ext.php:1.3
--- php4/pear/Experimental/XML/sql2xml_ext.php:1.2  Thu Mar 29 13:26:53 2001
+++ php4/pear/Experimental/XML/sql2xml_ext.php  Fri Mar 30 02:37:35 2001
@@ -15,7 +15,7 @@
 // | Authors: Christian Stocker <[EMAIL PROTECTED]> |
 // +--+
 //
-// $Id: sql2xml_ext.php,v 1.2 2001/03/29 21:26:53 uw Exp $
+// $Id: sql2xml_ext.php,v 1.3 2001/03/30 10:37:35 chregu Exp $
 
 require_once ("XML/sql2xml.php");
 
@@ -41,7 +41,7 @@
  *   for the time being
  *
  * @author   Christian Stocker <[EMAIL PROTECTED]>
- * @version  $Id: sql2xml_ext.php,v 1.2 2001/03/29 21:26:53 uw Exp $
+ * @version  $Id: sql2xml_ext.php,v 1.3 2001/03/30 10:37:35 chregu Exp $
  */
 class XML_sql2xml_ext extends XML_sql2xml {
 
@@ -49,11 +49,12 @@
 function insertNewRow($parent_row, $res, $key, &$tableInfo)
 {
 
-$new_row = $parent_row->new_child("row", NULL);
+$new_row= $parent_row->new_child($tableInfo[$key]["table"],Null);
 /* make an unique ID attribute in the row element with tablename.id if 
there's an id
otherwise just make an unique id with the php-function, just that 
there's a unique id for this row.
 CAUTION: This ID changes every time ;) (if no id from db-table)
*/
+$new_row->set_attribute("type","row");
 if ($res[$tableInfo["id"][$tableInfo[$key]["table"]]])
 {
 if ($res[$tableInfo["id"][$tableInfo[$key]["table"]]] == 
$this->user_options[id])
@@ -64,7 +65,9 @@
 }
 else
 {
-$new_row->set_attribute("ID", uniqid($tableInfo[$key]["table"]));
+$this->IDcounter[$tableInfo[$key]["table"]]++;
+$new_row->set_attribute("ID", 
+$tableInfo[$key]["table"].$this->IDcounter[$tableInfo[$key]["table"]]);
+
 }
 
 return $new_row;
@@ -72,21 +75,27 @@
 
 
 function insertNewResult(&$tableInfo) {
-
+
+if ($this->user_options["result_root"]) 
+$result_root = $this->user_options["result_root"];
+else 
+$result_root = $tableInfo[0]["table"];
+
 if ($this->xmlroot)
-$xmlroot=$this->xmlroot->new_child($tableInfo[0]["table"], NULL);
+$xmlroot=$this->xmlroot->new_child($result_root,Null);
 else
-$xmlroot= $this->xmldoc->add_root($tableInfo[0]["table"]);
-
-$xmlroot->set_attribute("type", "Database");
-
+$xmlroot= $this->xmldoc->add_root($result_root);
+$xmlroot->set_attribute("type","resultset");
 return $xmlroot;
 }
 
 
 function insertNewElement($parent, $res, $key, &$tableInfo, &$subrow) {
 
-if ($this->user_options["xml_seperator"])
+if (is_array($this->user_options["attributes"]) && 
+in_array($tableInfo[$key]["name"],$this->user_options["attributes"])) {
+
+$subrow=$parent->set_attribute($tableInfo[$key]["name"],$this->xml_encode($res[$key]));
+}
+elseif ($this->user_options["xml_seperator"])
 {
 //the preg should be only done once
 $i = 0;
@@ -100,24 +109,23 @@
 $subrow[$regs[1][$i]] = $subrow[$regs[1][$i - 
1]]->new_child($regs[1][$i], NULL);
 }
 }
-$subrows = $subrow[$regs[1][$i - 1]]->new_child($regs[1][$i], 
utf8_encode($res[$key]));
+$subrows = $subrow[$regs[1][$i - 1]]->new_child($regs[1][$i], 
+$this->xml_encode($res[$key]));
 }
 else
 {
-$regs[1][0] = $tableInfo[$key]["name"];
-$i = 0;
-$subrow=$parent->new_child($regs[1][$i], utf8_encode($res[$key]));
+$subrow=$parent->new_child($tableInfo[$key]["name"], 
+$this->xml_encode($res[$key]));
 }
 
 }
 
 function addTableinfo($key, $value, &$tableInfo) {
-
-if (!$metdata["id"][$value[table]] && $value[name] == 
$this->user_options["element_id"] )
+if (!$tableInfo[id][$value["table"]] && $value["name"

[PHP-CVS] cvs: php4 /pear/Experimental/XML sql2xml.php

2001-03-30 Thread Christian Stocker

chregu  Fri Mar 30 02:36:42 2001 EDT

  Modified files:  
/php4/pear/Experimental/XML sql2xml.php 
  Log:
  - new user_tableInfo option for user-contributed xml-structure
  - Error checking in doSql2Xml
  - xml_encode function for correctly parsing of &s.
  
  
Index: php4/pear/Experimental/XML/sql2xml.php
diff -u php4/pear/Experimental/XML/sql2xml.php:1.2 
php4/pear/Experimental/XML/sql2xml.php:1.3
--- php4/pear/Experimental/XML/sql2xml.php:1.2  Thu Mar 29 13:26:53 2001
+++ php4/pear/Experimental/XML/sql2xml.php  Fri Mar 30 02:36:42 2001
@@ -15,7 +15,7 @@
 // | Authors: Christian Stocker <[EMAIL PROTECTED]> |
 // +--+
 //
-// $Id: sql2xml.php,v 1.2 2001/03/29 21:26:53 uw Exp $
+// $Id: sql2xml.php,v 1.3 2001/03/30 10:36:42 chregu Exp $
 
 /**
 * This class takes a PEAR::DB-Result Object (or more than one)
@@ -37,7 +37,7 @@
 *   for the time being
 *
 * @author   Christian Stocker <[EMAIL PROTECTED]>
-* @version  $Id: sql2xml.php,v 1.2 2001/03/29 21:26:53 uw Exp $
+* @version  $Id: sql2xml.php,v 1.3 2001/03/30 10:36:42 chregu Exp $
 */
 class XML_sql2xml {
 
@@ -71,7 +71,14 @@
 
 /**
 *
+* @var  boolean
+*/
+var $user_tableInfo = False;
+
+
+/**
 *
+*
 * @param  string
 */
 function XML_sql2xml ($root = "root") {
@@ -139,6 +146,11 @@
 function doSql2Xml($result, $options = False)
 {
 
+if (DB::IsError($result)) {
+print "Error in file ".__FILE__." at line ".__LINE__."\n";
+new DB_Error($result->code,PEAR_ERROR_DIE);
+}
+
 //set options
 if (is_array($options))
 {
@@ -191,6 +203,12 @@
 }
 
 // end initialize
+
+// if user made some own tableInfo data, merge them here.
+if ($this->user_tableInfo) 
+{
+$tableInfo = $this->array_merge_clobber($tableInfo,$this->user_tableInfo);
+}
 $parent[root] = $this->insertNewResult(&$tableInfo);
 
 while ($FirstFetchDone || $res = $result->FetchRow($fetchmode))
@@ -299,7 +317,7 @@
 */
 function insertNewElement($parent, $res, $key, &$metadata, &$subrow)
 {
-return  $parent->new_child($metadata[$key]["name"], utf8_encode($res[$key]));
+return  $parent->new_child($metadata[$key]["name"], 
+$this->xml_encode($res[$key]));
 }
 
 
@@ -313,5 +331,50 @@
 function addTableInfo($key, $value, &$metadata) {
 
 }
+
+/**
+*
+* @param
+* @abstract
+*/
+function xml_encode ($text) {
+$text = utf8_encode(ereg_replace("&","&",$text));
+return $text;
+}
+//taken from [EMAIL PROTECTED] at 
+http://www.php.net/manual/en/function.array-merge-recursive.php
+/**
+* There seemed to be no built in function that would merge two arrays recursively 
+and clobber
+*   any existing key/value pairs. Array_Merge() is not recursive, and 
+array_merge_recursive
+*   seemed to give unsatisfactory results... it would append duplicate key/values.
+*
+*   So here's a cross between array_merge and array_merge_recursive
+**/
+
+/**
+*
+* @param  
+* @param  
+* @abstract
+*/
+function array_merge_clobber($a1,$a2)
+{
+if(!is_array($a1) || !is_array($a2)) return false;
+$newarray = $a1;
+while (list($key, $val) = each($a2))
+{
+if (is_array($val) && is_array($newarray[$key]))
+{
+$newarray[$key] = $this->array_merge_clobber($newarray[$key], $val);
+}
+else
+{
+$newarray[$key] = $val;
+}
+}
+return $newarray;
+}
+
 }
 ?>
+
+



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-CVS] cvs: php4 /pear/Experimental/XML fo2pdf.php

2001-03-29 Thread Christian Stocker

chregu  Thu Mar 29 02:13:50 2001 EDT

  Modified files:  
/php4/pear/Experimental/XML fo2pdf.php 
  Log:
  MSIE needs a Content-Length: Header to display pdfs correctly. so here it 
  is..
  
  
Index: php4/pear/Experimental/XML/fo2pdf.php
diff -u php4/pear/Experimental/XML/fo2pdf.php:1.2 
php4/pear/Experimental/XML/fo2pdf.php:1.3
--- php4/pear/Experimental/XML/fo2pdf.php:1.2   Tue Mar 27 06:35:21 2001
+++ php4/pear/Experimental/XML/fo2pdf.php   Thu Mar 29 02:13:50 2001
@@ -15,7 +15,7 @@
 // | Authors: Christian Stocker <[EMAIL PROTECTED]> |
 // +--+
 //
-// $Id: fo2pdf.php,v 1.2 2001/03/27 14:35:21 chregu Exp $
+// $Id: fo2pdf.php,v 1.3 2001/03/29 10:13:50 chregu Exp $
 
 
 /**
@@ -84,7 +84,7 @@
 *print $cache->end("+30");
 *
 * @author   Christian Stocker <[EMAIL PROTECTED]>
-* @version  $Id: fo2pdf.php,v 1.2 2001/03/27 14:35:21 chregu Exp $
+* @version  $Id: fo2pdf.php,v 1.3 2001/03/29 10:13:50 chregu Exp $
 * @package  XML
 */
 
@@ -254,7 +254,7 @@
*/
function  print_pdf($pdf="")
{
-   Header("Content-type: application/pdf");
+   Header("Content-type: application/pdf\nContent-Length: ".strlen($pdf));
print $this->return_pdf($pdf);
}
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-CVS] cvs: php4 /pear/Experimental/XML fo2pdf.php

2001-03-27 Thread Christian Stocker

chregu  Tue Mar 27 06:35:22 2001 EDT

  Modified files:  
/php4/pear/Experimental/XML fo2pdf.php 
  Log:
  corrected Usage example
  
  
Index: php4/pear/Experimental/XML/fo2pdf.php
diff -u php4/pear/Experimental/XML/fo2pdf.php:1.1 
php4/pear/Experimental/XML/fo2pdf.php:1.2
--- php4/pear/Experimental/XML/fo2pdf.php:1.1   Tue Mar 27 01:53:00 2001
+++ php4/pear/Experimental/XML/fo2pdf.php   Tue Mar 27 06:35:21 2001
@@ -15,7 +15,7 @@
 // | Authors: Christian Stocker <[EMAIL PROTECTED]> |
 // +--+
 //
-// $Id: fo2pdf.php,v 1.1 2001/03/27 09:53:00 chregu Exp $
+// $Id: fo2pdf.php,v 1.2 2001/03/27 14:35:21 chregu Exp $
 
 
 /**
@@ -46,7 +46,8 @@
 *   to work together.
 *   See http://www.phpbuilder.com/columns/marknold20001221.php3 or 
 *  http://www.linuxwebdevnews.com/articles/php-java-xslt.php?pid=347
-*  for more details about java and php or ask me, if you're stuck (especially  *  
 with linux. windows is not my area..)
+*  for more details about java and php or ask me, if you're stuck 
+*   (especially with linux. windows is not my area..)
 *
 * Todo:
 *  - Errordetection
@@ -56,7 +57,7 @@
 * see http://xml.apache.org/fop/embedding.html for details
 *
 * Usage:
-*
+*require_once("XML/fo2pdf.php");
 *//make a pdf from simple.fo and save the pdf in a tmp-folder
 *$fop = new xml_fo2pdf("simple.fo");
 *//print pdf to the outputbuffer,
@@ -66,26 +67,24 @@
 *$fop->delete_pdf();
 *
 *   With Cache:
-*
+*require_once("XML/fo2pdf.php");
 *require_once("Cache/Output.php");
 *$container = "file";
 *$options = array("cache_dir"=>"/tmp/");
 *$cache = new Cache_Output("$container",$options);
 *$cache_handle = $cache->generateID($REQUEST_URI);
 *if ($content = $cache->start($cache_handle)) {
-*  $cache->printContentTypeHeader();
+*  Header("Content-type: application/pdf");
 *  print $content;
-*  print "Cache hit";
 *  die();
 *}
-*$cache->SetContentType("application/pdf");
 *$fop = new xml_fo2pdf("simple.fo");
 *$fop->print_pdf();
 *$fop->delete_pdf();
 *print $cache->end("+30");
 *
 * @author   Christian Stocker <[EMAIL PROTECTED]>
-* @version  $Id: fo2pdf.php,v 1.1 2001/03/27 09:53:00 chregu Exp $
+* @version  $Id: fo2pdf.php,v 1.2 2001/03/27 14:35:21 chregu Exp $
 * @package  XML
 */
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-CVS] cvs: php4 /pear/Experimental/XML fo2pdf.php

2001-03-27 Thread Christian Stocker

chregu  Tue Mar 27 01:53:00 2001 EDT

  Added files: 
/php4/pear/Experimental/XML fo2pdf.php 
  Log:
  a class for rendering (xsl-)formatting objects files into a pdf.
  
  

Index: php4/pear/Experimental/XML/fo2pdf.php
+++ php4/pear/Experimental/XML/fo2pdf.php
http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to   |
// | obtain it through the world-wide-web, please send a note to  |
// | [EMAIL PROTECTED] so we can mail you a copy immediately.   |
// +--+
// | Authors: Christian Stocker <[EMAIL PROTECTED]> |
// +--+
//
// $Id: fo2pdf.php,v 1.1 2001/03/27 09:53:00 chregu Exp $


/**
* fo to pdf converter.
*
* with fo (formating objects) it's quite easy to convert xml-documents into
*  pdf-docs.
* 
* An introduction into formating objects can be found at
*  http://www.w3.org/TR/xsl/slice6.html#fo-section
*
* The way to use this class is, produce a fo-file from a xml-file with a
* xsl-stylesheet, then feed this class with this fo-file and you get a pdf
* back (either directly to the browser for really dynamic-pdf production or
* as a file on your filesystem)
*
* It is recommended to use the Cache-Classes from PEAR, if you want dynamic
* pdf production, since the process of making the pdfs takes some time. For
* an example of how to  use Cache and fo2pdf see below.
*
* Requirements:
*
*  You need Fop from the xml-apache project (http://xml.apache.org/fop) and
*   Java (1.1.x or later, i tested it with 1.2.2 from sun on linux, see the
*   Fop-Docs for details).
*  Furthermore you have to compile your php with --with-java and to adjust
*   your php.ini file. It can be a rather painful task to get java and php
*   to work together.
*   See http://www.phpbuilder.com/columns/marknold20001221.php3 or 
*   http://www.linuxwebdevnews.com/articles/php-java-xslt.php?pid=347
*   for more details about java and php or ask me, if you're stuck (especially  *  
 with linux. windows is not my area..)
*
* Todo:
*  - Errordetection
*  - Use embedding instead of org.apache.fop.apps.CommandLine-
* this way, we maybe do not have to write temp-files and
* we can render other stuff than only pdf (txt,pcl,ps,...)
* see http://xml.apache.org/fop/embedding.html for details
*
* Usage:
*
*//make a pdf from simple.fo and save the pdf in a tmp-folder
*$fop = new xml_fo2pdf("simple.fo");
*//print pdf to the outputbuffer,
*// including correct Header ("Content-type: application/pdf")
*$fop->print_pdf();
*//delete the temporary pdf file
*$fop->delete_pdf();
*
*   With Cache:
*
*require_once("Cache/Output.php");
*$container = "file";
*$options = array("cache_dir"=>"/tmp/");
*$cache = new Cache_Output("$container",$options);
*$cache_handle = $cache->generateID($REQUEST_URI);
*if ($content = $cache->start($cache_handle)) {
*  $cache->printContentTypeHeader();
*  print $content;
*  print "Cache hit";
*  die();
*}
*$cache->SetContentType("application/pdf");
*$fop = new xml_fo2pdf("simple.fo");
*$fop->print_pdf();
*$fop->delete_pdf();
*print $cache->end("+30");
*
* @author   Christian Stocker <[EMAIL PROTECTED]>
* @version  $Id: fo2pdf.php,v 1.1 2001/03/27 09:53:00 chregu Exp $
* @package  XML
*/

class XML_fo2pdf {

/**
* fo-file used in this class
*
* @var  string
*/
var $fo;

/**
* pdf-file used in this class
*
* @var  string
*/
var $pdf;

/**
* Where the temporary fo and pdf files should be stored
*
* @var  string
*/
var $tmpdir = "/tmp";

/**
* A prefix for the temporary files
*
* @var  string
*/
var $tmppdfprefix = "pdffo";


/**
* constructor
* One can pass an input fo-file already here (the other possibility
* is with the run or run_from_string method).
*  and if the pdf should be stored permanently, a filename/path for
*  that can also be passed here.
*
* @params string file input fo-file
* @params string file output pdf-file
* @return Null
* @see run(), run_from_string(), run_from_file()
*/
function xml_fo2pdf($fo="", $pdf="")
{

if ($fo) {
$this->run($fo, $pdf);
}
}
/**
* Calls the Main Fop-Java-Programm
*
* One has to pass an input

[PHP-CVS] cvs: php4 /pear/Experimental/XML sql2xml.php sql2xml_ext.php

2001-03-24 Thread Christian Stocker

chregu  Sat Mar 24 12:00:03 2001 EDT

  Added files: 
/php4/pear/Experimental/XML sql2xml.php sql2xml_ext.php 
  Log:
  First Commit of the sql2xml classes.
  
  This class takes a PEAR::DB-Result Object (or more than one) and returns a
  xml-representation of it.
  
  
  


Index: php4/pear/Experimental/XML/sql2xml.php
+++ php4/pear/Experimental/XML/sql2xml.php
http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to   |
// | obtain it through the world-wide-web, please send a note to  |
// | [EMAIL PROTECTED] so we can mail you a copy immediately.   |
// +--+
// | Authors: Christian Stocker <[EMAIL PROTECTED]> |
// +--+
//
// $Id: sql2xml.php,v 1.1 2001/03/24 20:00:02 chregu Exp $

/**
* This class takes a PEAR::DB-Result Object (or more than one)
*  and returns a xml-representation of it.
*
* More docs will follow
*
* Usage example
*
* include_once ("DB.php");
* include_once("XML/sql2xml.php");
* $db = DB::connect("mysql://root@localhost/xmltest");
* $xml = new xml_sql2xml;
* $result = $db->query("select * from bands");
* $xmlstring = $xml->getxml($result,$options));
*
* more examples and outputs on
*   http://www.nomad.ch/php/sql2xml
*   for the time being
*
* @author   Christian Stocker <[EMAIL PROTECTED]>
* @version  $Id: sql2xml.php,v 1.1 2001/03/24 20:00:02 chregu Exp $
*/
class XML_sql2xml {

/**
*
* @var  boolean
*/
var $nested = True;


/**
*
* @var  boolean
*/
var $user_options = False;


/**
*
* @var  object  domxml
*/
var $xmldoc;


/**
*
* @var  string
*/
var $xmlroot = "";


/**
*
*
* @param  string
*/
function XML_sql2xml ($root = "root") {

$this->xmldoc = domxml_new_xmldoc('1.0');
if ($root) {
$this->xmlroot = $this->xmldoc->add_root($root);
}

}

/**
  * Adds an aditional resultset to the xml-document
  *
  * @paramObject result result from a DB-query
  * @paramarray  mixed   options to be passed (does it need that?)
  * @return   string  xml
  * @access   public
  */
function add_result($result, $options = False)
{
$this->do_sql2xml($result, $options);
}

/**
  * Returns an xml-string with a xml-representation of the resultsets.
  *
  * The resultset can be directly provided here, or if you need more than one
  * in your xml, then you have to provide each of them with add_result befor getxml
  *
  * @paramObject  result result from a DB-query
  * @paramarray   mixed   options to be passed (does it need that?)
  * @return   string  xml
  * @access   public
  */

function getxml($result = False, $options = False)
{
return domxml_dumpmem($this->getxmlObject($result, $options));
}

/**
  * Returns an xml DomDocument Object with a xml-representation of the resultsets.
  *
  * The resultset can be directly provided here, or if you need more than one
  * in your xml, then you have to provide each of them with add_result befor getxml
  *
  * @paramObject result result from a DB-query
  * @paramarray  mixed   options to be passed (does it need that?)
  * @return   Object DomDocument
  * @access   public
  */
function getxmlObject($result = False, $options = False) {
if ($result) {
$this->do_sql2xml($result, $options);
}
return $this->xmldoc;
}

function do_sql2xml($result, $options = False)
{

//set options
if (is_array($options))
{
foreach ($options as $option => $value)
{
$this->setOption($option, $value);
}
}
//user should be able to give his own tableInfo-array, but not implemented yet
if (! ($tableInfo = $result->tableInfo(False)))
{
//emulate tableInfo. this can go away, if every db supports tableInfo
$fetchmode = DB_FETCHMODE_ASSOC;
$res = $result->FetchRow($fetchmode);
$this->nested = False;
$i = 0;

while (list($key, $val) = each($res))
{
$tableInfo[$i][table]= "result";
$tableInfo[$i][name] = $key;
$resFirstRow[$i] = $val;
$i++;
}
$res  = $resFirstRow;
$FirstFetchDone = True;
$fetchmode = DB_FETCHMODE_ORDERED;
}
else
{
$fetchmode = DB_FETCHMODE_ORDERED;

[PHP-CVS] cvs: php4(PHP_4_0_5) /pear/Cache Output.php

2001-03-23 Thread Christian Stocker

chregu  Fri Mar 23 10:36:37 2001 EDT

  Modified files:  (Branch: PHP_4_0_5)
/php4/pear/CacheOutput.php 
  Log:
  GarbageCollection was moved into a PEAR-Deconstructor
  (from the HEAD Branch)
  
  
Index: php4/pear/Cache/Output.php
diff -u php4/pear/Cache/Output.php:1.11 php4/pear/Cache/Output.php:1.11.2.1
--- php4/pear/Cache/Output.php:1.11 Sat Mar 10 23:46:58 2001
+++ php4/pear/Cache/Output.php  Fri Mar 23 10:36:36 2001
@@ -17,64 +17,78 @@
 // |  Vinai Kopp <[EMAIL PROTECTED]>   |
 // +--+
 //
-// $Id: Output.php,v 1.11 2001/03/11 07:46:58 sbergmann Exp $
+// $Id: Output.php,v 1.11.2.1 2001/03/23 18:36:36 chregu Exp $
 
 require_once 'Cache.php';
 
 /**
 * Class to cache the output of a script using the output buffering functions
 *
-* Simple output cache. Some pages require lots of time to compute. Caching the 
+* Simple output cache. Some pages require lots of time to compute. Caching the
 * output can increase the overall speed dramatically, especially if you use
 * a Shared Memory storage container.
-* 
-* As you can see in the example the usage is extemely simple. To cache a script 
-* simple put some few lines of code in front of your script and some at the end. 
-* A preferrable place for this are the auto_prepend and auto_append files (=> 
php.ini). 
-* 
+*
+* As you can see in the example the usage is extemely simple. To cache a script
+* simple put some few lines of code in front of your script and some at the end.
+* A preferrable place for this are the auto_prepend and auto_append files (=> 
+php.ini).
+*
 * Usage example:
 *
 *  // place this somewhere in a central config file
 *  define(CACHE_STORAGE_CLASS, "file");
-* // file storage needs a dir to put the cache files
-* define(CACHE_DIR, "/var/tmp/");
+*  // file storage needs a dir to put the cache files
+*  define(CACHE_DIR, "/var/tmp/");
 *
-* // get a cache object
+*  // get a cache object
 *  $cache = new Cache_Output(CACHE_STORAGE_CLASS, array("cache_dir" => CACHE_DIR));
 *
 *  // compute the unique handle.
-*  // if your script depends on Cookie and HTTP Post data as well 
+*  // if your script depends on Cookie and HTTP Post data as well
 *  // you should use:
-*  // $cache_handle = array( 
+*  // $cache_handle = array(
 *  //   "file" => $REQUEST_URI,
 *  //   "post" => $HTTP_POST_VAS"
 *  //   "cookie"  => $HTTP_COOKIE_VARS
 *  //);
-*  $cache_handle = $REQUEST_URI;
-* 
-*  // now the magic happens: if cached call die() 
+*  // But be warned, using all GET or POST Variables as a seed
+*  // can be used for a DOS attack. Calling 
+http://www.example.com/example.php?whatever
+*  // where whatever is a random text might be used to flood your cache.
+*  $cache_handle = $cache->generateID($REQUEST_URI);
+*
+*  // now the magic happens: if cached call die()
 *  // to end the time consumptiong script script execution and use the cached value!
 *  if ($content = $cache->start($cache_handle)) {
 * print $content;
+* print "Cache hit";
 * die();
 *  }
-*  
-*  // time consumption script goes here. 
-* 
+*
+*  // time consumption script goes here.
+*
 *  // store the output of the cache into the cache and print the output.
 *  print $cache->end();
-* 
-* If you do not want to cache a whole page - no problem:
-* 
-* if (!($content = $cache->start($cache_handle))) {
-*// do the computation here
-*print $cache->end()
-* } else {
-print $content;
-* }
+*  print "Cache miss, stored using the ID '$id'.";
+*
+*  If you do not want to cache a whole page - no problem:
+*
+*  if (!($content = $cache->start($cache_handle))) {
+* // do the computation here
+* print $cache->end()
+*  } else {
+ print $content;
+*  }
+*
+*  If you need an example script check the (auto_)prepend and (auto_)append
+*  files of my homepage:
+*
+*http://www.ulf-wendel.de/php/show_source.php?file=prepend
+*http://www.ulf-wendel.de/php/show_source.php?file=append
 *
-* Have fun!
-* 
+*  Don't know how to use it or you need profiling informations?`
+*  Ask Christian he was patient with me and he'll be so with your questions ;).
+*
+*  Have fun!
+*
 * @authors  Ulf Wendel <[EMAIL PROTECTED]>
 * @version  $ID: $
 * @package  Cache
@@ -84,7 +98,7 @@
 
 /**
 * ID passed to start()
-* 
+*
 * @var  string
 * @see  start(), end()
 */
@@ -92,25 +106,34 @@
 
 /**
 * Group passed to start()
-* 
-* @var  string  
+*
+* @var  string
 * @see  start(), end()
 */
 var $output_group = "";
 
 /**
+* PEAR-Deconstructor
+* Call deconstructor of parent
+*/
+function _Cache_Output()
+{
+$this->_Cache();
+}
+
+/**
 * starts the output buffering and returns an empty string or returns the cached 
output from the cache.
-* 
+*

[PHP-CVS] cvs: php4(PHP_4_0_5) /pear/Cache/Container file.php

2001-03-23 Thread Christian Stocker

chregu  Fri Mar 23 10:35:17 2001 EDT

  Modified files:  (Branch: PHP_4_0_5)
/php4/pear/Cache/Container  file.php 
  Log:
  just the changes from the HEAD dev here. rather important
  
  
Index: php4/pear/Cache/Container/file.php
diff -u php4/pear/Cache/Container/file.php:1.8 
php4/pear/Cache/Container/file.php:1.8.2.1
--- php4/pear/Cache/Container/file.php:1.8  Thu Mar  8 12:39:16 2001
+++ php4/pear/Cache/Container/file.php  Fri Mar 23 10:35:17 2001
@@ -16,7 +16,7 @@
 // |  Sebastian Bergmann <[EMAIL PROTECTED]>   |
 // +--+
 //
-// $Id: file.php,v 1.8 2001/03/08 20:39:16 uw Exp $
+// $Id: file.php,v 1.8.2.1 2001/03/23 18:35:17 chregu Exp $
 
 require_once 'Cache/Container.php';
 
@@ -24,29 +24,29 @@
 * Stores cache contents in a file.
 *
 * @author   Ulf Wendel  <[EMAIL PROTECTED]>
-* @version  $Id: file.php,v 1.8 2001/03/08 20:39:16 uw Exp $
+* @version  $Id: file.php,v 1.8.2.1 2001/03/23 18:35:17 chregu Exp $
 */
 class Cache_Container_file extends Cache_Container {
 
 /**
 * Directory where to put the cache files.
-* 
+*
 * @var  string  Make sure to add a trailing slash
 */
 var $cache_dir = "";
 
 /**
 * Filename prefix for cache files.
-* 
+*
 * You can use the filename prefix to implement a "domain" based cache or just
-* to give the files a more descriptive name. The word "domain" is borroed from 
-* a user authentification system. One user id (cached dataset with the ID x) 
+* to give the files a more descriptive name. The word "domain" is borroed from
+* a user authentification system. One user id (cached dataset with the ID x)
 * may exists in different domains (different filename prefix). You might want
 * to use this to have different cache values for a production, development and
 * quality assurance system. If you want the production cache not to be influenced
 * by the quality assurance activities, use different filename prefixes for them.
-* 
-* I personally don't think that you'll never need this, but 640kb happend to be 
+*
+* I personally don't think that you'll never need this, but 640kb happend to be
 * not enough, so... you know what I mean. If you find a useful application of the
 * feature please update this inline doc.
 *
@@ -56,7 +56,7 @@
 
 /**
 * Creates the cache directory if neccessary
-* 
+*
 * @paramarray   Config options: ["cache_dir" => ..., "filename_prefix" => ...]
 */
 function Cache_Container_file($options = "") {
@@ -65,6 +65,11 @@
 
 clearstatcache();
 
+//make relative paths absolute for use in deconstructor.
+// it looks like the deconstructor has problems with relative paths
+if (preg_match("/\.+/",$this->cache_dir))
+$this->cache_dir=realpath(getcwd()."/".$this->cache_dir)."/";
+
 if (!file_exists($this->cache_dir) || !is_dir($this->cache_dir))
 mkdir($this->cache_dir, 0755);
 } // end func contructor
@@ -92,7 +97,7 @@
 
 /**
 * Stores a dataset.
-* 
+*
 * WARNING: If you supply userdata it must not contain any linebreaks,
 * otherwise it will break the filestructure.
 */
@@ -119,7 +124,7 @@
 
 return true;
 } // end func save
-
+
 function delete($id, $group) {
 $this->flushPreload($id, $group);
 
@@ -147,20 +152,20 @@
 
 function idExists($id, $group) {
 return file_exists($this->getFilename($id, $group));
-
+
 } // end func idExists
 
 /**
 * Deletes all expired files.
-* 
+*
 * Garbage collection for files is a rather "expensive", "long time"
-* operation. All files in the cache directory have to be examined which 
-* means that they must be opened for reading, the expiration date has to be 
+* operation. All files in the cache directory have to be examined which
+* means that they must be opened for reading, the expiration date has to be
 * read from them and if neccessary they have to be unlinked (removed).
 * If you have a user comment for a good default gc probability please add it to
 * to the inline docs.
-* 
-* @paramstring  directory to examine - don't sets this parameter, it's used 
for a 
+*
+* @paramstring  directory to examine - don't sets this parameter, it's used 
+for a
 *   recursive function call!
 */
 function garbageCollection($dir = "") {
@@ -177,8 +182,10 @@
 continue;
 
 $file = $dir . $file;
-if (is_dir($file))
+if (is_dir($file)) {
 $this->garbageCollection($file . "/");
+continue;
+}
 
 // skip trouble makers but inform the user
 if (!($fh = @fopen($file, "rb"))) {
@@ -186,7 +193,7 @@
 continue;
   

[PHP-CVS] cvs: php4 /pear/Cache/Container dbx.php

2001-03-22 Thread Christian Stocker

chregu  Thu Mar 22 06:29:02 2001 EDT

  Added files: 
/php4/pear/Cache/Container  dbx.php 
  Log:
  a new container, which uses the new dbx extension of php as db-abstraction
  
  

Index: php4/pear/Cache/Container/dbx.php
+++ php4/pear/Cache/Container/dbx.php
http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to   |
// | obtain it through the world-wide-web, please send a note to  |
// | [EMAIL PROTECTED] so we can mail you a copy immediately.   |
// +--+
// | Authors: Christian Stocker <[EMAIL PROTECTED]> |
// +--+
//
// $Id: dbx.php,v 1.1 2001/03/22 14:29:01 chregu Exp $


require_once 'Cache/Container.php';

/**
* ext/dbx Cache Container.
*
* WARNING: Other systems might or might not support certain datatypes of 
* the tables shown. As far as I know there's no large binary 
* type in SQL-92 or SQL-99. Postgres seems to lack any 
* BLOB or TEXT type, for MS-SQL you could use IMAGE, don't know 
* about other databases. Please add sugestions for other databases to 
* the inline docs.
*
* The field 'changed' has no meaning for the Cache itself. It's just there 
* because it's a good idea to have an automatically updated timestamp
* field for debugging in all of your tables.
*
* For _MySQL_ you need this DB table:
*
* CREATE TABLE cache (
*   id  CHAR(32) NOT NULL DEFAULT '',
*   cachegroup  VARCHAR(127) NOT NULL DEFAULT '',
*   cachedata   BLOB NOT NULL DEFAULT '',
*   userdataVARCHAR(255) NOT NULL DEFAULT '',
*   expires INT(9) NOT NULL DEFAULT 0,
*  
*   changed TIMESTAMP(14) NOT NULL,
*  
*   INDEX (expires),
*   PRIMARY KEY (id, cachegroup)
* )
*
* @author   Christian Stocker <[EMAIL PROTECTED]>
* @version  $Id: dbx.php,v 1.1 2001/03/22 14:29:01 chregu Exp $
* @package  Cache
*/
class Cache_Container_dbx extends Cache_Container {

/**
* Name of the DB table to store caching data
* 
* @see  Cache_Container_file::$filename_prefix
*/  
var $cache_table = '';

/**
* DBx module to use
*
*  at the moment only mysql or odbc
* 
* @var  string
*/

var $module = '';

/**
* DB host to use
* 
* @var  string
*/
var $host = '';

/**
* DB database to use
* 
* @var  string
*/
var $db = '';

/**
* DB username to use
* 
* @var  string
*/

var $username = '';

/**
* DB password to use
* 
* @var  string
*/
var $password = '';

/**
* PEAR DB object
* 
* @var  object PEAR_DB
*/
var $db;

function Cache_Container_dbx($options)
{
if (!is_array($options) ) {
return new Cache_Error('No options specified!', __FILE__, __LINE__);
}

$this->setOptions($options, array('module','host','db','username','password', 
'cache_table'));

if (!$this->module)
return new Cache_Error('No module specified!', __FILE__, __LINE__);

$this->db = 
dbx_connect($this->module,$thos->host,$this->db,$this->username,$this->password);

if (dbx_error($this->db)) {
return new Cache_Error('DBx connect failed: ' . dbx_error($this->db), 
__FILE__, __LINE__);
} else {
//not implemented yet in dbx
//$this->db->setFetchMode(DB_FETCHMODE_ASSOC);
}
}

function fetch($id, $group)
{
$query = sprintf("SELECT cachedata, userdata, expires FROM %s WHERE id = '%s' 
AND cachegroup = '%s'",
 $this->cache_table,
 addslashes($id),
 addslashes($group)
);

$res = dbx_query($this->db,$query);

if (dbx_error($this->db))
return new Cache_Error('DBx query failed: ' . dbx_error($this->db), 
__FILE__, __LINE__);

$row = $res->data[0];

if (is_array($row))
return array($row['expires'], $this->decode($row['cachedata']), 
$row['userdata']);
}

/**
* Stores a dataset.
* 
* WARNING: we use the SQL command REPLACE INTO this might be 
* MySQL specific. As MySQL is very popular the method should
* work fine for 95% of you.
*/
function save($id, $data, $expires, $group, $userdata)
{
$this->flushPreload($id, $group);

$query = sprintf("REPLACE INTO %s (userdata, 

[PHP-CVS] cvs: php4 /pear/Cache/Container file.php

2001-03-17 Thread Christian Stocker

chregu  Sat Mar 17 08:07:42 2001 EDT

  Modified files:  
/php4/pear/Cache/Container  file.php 
  Log:
  GarbageCollection didn't work properly (wanted to delete files, relative
  paths don't work in deconstructors)
  
  
Index: php4/pear/Cache/Container/file.php
diff -u php4/pear/Cache/Container/file.php:1.8 php4/pear/Cache/Container/file.php:1.9
--- php4/pear/Cache/Container/file.php:1.8  Thu Mar  8 12:39:16 2001
+++ php4/pear/Cache/Container/file.php  Sat Mar 17 08:07:42 2001
@@ -16,7 +16,7 @@
 // |  Sebastian Bergmann <[EMAIL PROTECTED]>   |
 // +--+
 //
-// $Id: file.php,v 1.8 2001/03/08 20:39:16 uw Exp $
+// $Id: file.php,v 1.9 2001/03/17 16:07:42 chregu Exp $
 
 require_once 'Cache/Container.php';
 
@@ -24,29 +24,29 @@
 * Stores cache contents in a file.
 *
 * @author   Ulf Wendel  <[EMAIL PROTECTED]>
-* @version  $Id: file.php,v 1.8 2001/03/08 20:39:16 uw Exp $
+* @version  $Id: file.php,v 1.9 2001/03/17 16:07:42 chregu Exp $
 */
 class Cache_Container_file extends Cache_Container {
 
 /**
 * Directory where to put the cache files.
-* 
+*
 * @var  string  Make sure to add a trailing slash
 */
 var $cache_dir = "";
 
 /**
 * Filename prefix for cache files.
-* 
+*
 * You can use the filename prefix to implement a "domain" based cache or just
-* to give the files a more descriptive name. The word "domain" is borroed from 
-* a user authentification system. One user id (cached dataset with the ID x) 
+* to give the files a more descriptive name. The word "domain" is borroed from
+* a user authentification system. One user id (cached dataset with the ID x)
 * may exists in different domains (different filename prefix). You might want
 * to use this to have different cache values for a production, development and
 * quality assurance system. If you want the production cache not to be influenced
 * by the quality assurance activities, use different filename prefixes for them.
-* 
-* I personally don't think that you'll never need this, but 640kb happend to be 
+*
+* I personally don't think that you'll never need this, but 640kb happend to be
 * not enough, so... you know what I mean. If you find a useful application of the
 * feature please update this inline doc.
 *
@@ -56,7 +56,7 @@
 
 /**
 * Creates the cache directory if neccessary
-* 
+*
 * @paramarray   Config options: ["cache_dir" => ..., "filename_prefix" => ...]
 */
 function Cache_Container_file($options = "") {
@@ -65,6 +65,11 @@
 
 clearstatcache();
 
+//make relative paths absolute for use in deconstructor.
+// it looks like the deconstructor has problems with relative paths
+if (preg_match("/\.+/",$this->cache_dir))
+$this->cache_dir=realpath(getcwd()."/".$this->cache_dir)."/";
+
 if (!file_exists($this->cache_dir) || !is_dir($this->cache_dir))
 mkdir($this->cache_dir, 0755);
 } // end func contructor
@@ -92,7 +97,7 @@
 
 /**
 * Stores a dataset.
-* 
+*
 * WARNING: If you supply userdata it must not contain any linebreaks,
 * otherwise it will break the filestructure.
 */
@@ -119,7 +124,7 @@
 
 return true;
 } // end func save
-
+
 function delete($id, $group) {
 $this->flushPreload($id, $group);
 
@@ -147,20 +152,20 @@
 
 function idExists($id, $group) {
 return file_exists($this->getFilename($id, $group));
-
+
 } // end func idExists
 
 /**
 * Deletes all expired files.
-* 
+*
 * Garbage collection for files is a rather "expensive", "long time"
-* operation. All files in the cache directory have to be examined which 
-* means that they must be opened for reading, the expiration date has to be 
+* operation. All files in the cache directory have to be examined which
+* means that they must be opened for reading, the expiration date has to be
 * read from them and if neccessary they have to be unlinked (removed).
 * If you have a user comment for a good default gc probability please add it to
 * to the inline docs.
-* 
-* @paramstring  directory to examine - don't sets this parameter, it's used 
for a 
+*
+* @paramstring  directory to examine - don't sets this parameter, it's used 
+for a
 *   recursive function call!
 */
 function garbageCollection($dir = "") {
@@ -177,8 +182,10 @@
 continue;
 
 $file = $dir . $file;
-if (is_dir($file))
+if (is_dir($file)) {
 $this->garbageCollection($file . "/");
+continue;
+}
 
 // skip trouble makers but inform the user
 if (!($fh = @fopen($file, "rb"))) {
@@ -186,7 +193,7 @@
 

[PHP-CVS] cvs: php4 /pear Cache.php /pear/Cache Output.php

2001-03-17 Thread Christian Stocker

chregu  Sat Mar 17 08:06:31 2001 EDT

  Modified files:  
/php4/pear  Cache.php 
/php4/pear/CacheOutput.php 
  Log:
  GarbageCollection was moved into a PEAR-Deconstructor
  
  

Index: php4/pear/Cache.php
diff -u php4/pear/Cache.php:1.7 php4/pear/Cache.php:1.8
--- php4/pear/Cache.php:1.7 Thu Mar  8 12:41:39 2001
+++ php4/pear/Cache.php Sat Mar 17 08:06:31 2001
@@ -16,7 +16,7 @@
 // |  Sebastian Bergmann <[EMAIL PROTECTED]>   |
 // +--+
 //
-// $Id: Cache.php,v 1.7 2001/03/08 20:41:39 uw Exp $
+// $Id: Cache.php,v 1.8 2001/03/17 16:06:31 chregu Exp $
 
 require_once "Cache/Error.php";
 
@@ -25,12 +25,16 @@
 *
 * TODO: Simple usage example goes here.
 *
+* WARNING: No File/DB-Table-Row locking is implemented yet,
+*  it's possible, that you get corrupted data-entries under
+*  bad circumstances  (especially with the file container)
+*
 * @author   Ulf Wendel <[EMAIL PROTECTED]>
-* @version  $Id: Cache.php,v 1.7 2001/03/08 20:41:39 uw Exp $
+* @version  $Id: Cache.php,v 1.8 2001/03/17 16:06:31 chregu Exp $
 * @package  Cache
-* @access   public 
+* @access   public
 */
-class Cache {
+class Cache extends PEAR {
 
 /**
 * Disables the caching.
@@ -45,8 +49,8 @@
 /**
 * Garbage collection: probability in seconds
 *
-* If set to a value above 0 a garbage collection will 
-* flush all cache entries older than the specified number 
+* If set to a value above 0 a garbage collection will
+* flush all cache entries older than the specified number
 * of seconds.
 *
 * @var  integer
@@ -68,35 +72,40 @@
 
 /**
 * Storage container object.
-* 
+*
 * @var  object Cache_Container
-*/
+*/
 var $container;
 
 //
 // public methods
 //
 
-/**
+/**
 *
 * @paramstring  Name of storage container class
 * @paramarray   Array with storage class dependend config options
 */
 function Cache($storage_driver, $storage_options = "")
 {
+$this->PEAR();
 $storage_driver = strtolower($storage_driver);
 $storage_class = 'Cache_Container_' . $storage_driver;
 $storage_classfile = 'Cache/Container/' . $storage_driver . '.php';
 
 include_once $storage_classfile;
 $this->container = new $storage_class($storage_options);
+}
+
+//deconstructor
+function _Cache()
+{
 $this->garbageCollection();
-
 }
 
 /**
 * Returns the requested dataset it if exists and is not expired
-*  
+*
 * @paramstring  dataset ID
 * @paramstring  cache group
 * @return   mixed   cached data or NULL on failure
@@ -105,16 +114,16 @@
 function get($id, $group = "default") {
 if ($this->no_cache)
 return "";
-
+
 if ($this->isCached($id, $group) && !$this->isExpired($id, $group))
 return $this->load($id, $group);
-
-return NULL;
+
+return NULL;
 } // end func get
 
 /**
 * Stores the given data in the cache.
-* 
+*
 * @paramstring  dataset ID used as cache identifier
 * @parammixed   data to cache
 * @paraminteger lifetime of the cached data in seconds - 0 for endless
@@ -125,13 +134,13 @@
 function save($id, $data, $expires = 0, $group = "default") {
 if ($this->no_cache)
 return true;
-
+
 return $this->container->save($id, $data, $expires, $group, "");
 } // end func save
 
 /**
 * Stores a dataset without additional userdefined data.
-* 
+*
 * @paramstring  dataset ID
 * @parammixed   data to store
 * @paramstring  additional userdefined data
@@ -151,16 +160,16 @@
 
 /**
 * Loads the given ID from the cache.
-* 
+*
 * @paramstring  dataset ID
 * @paramstring  cache group
-* @return   mixed   cached data or NULL on failure 
+* @return   mixed   cached data or NULL on failure
 * @access   public
 */
 function load($id, $group = "default") {
 if ($this->no_cache)
 return "";
-
+
 return $this->container->load($id, $group);
 } // end func load
 
@@ -176,13 +185,13 @@
 function getUserdata($id, $group = "default") {
 if ($this->no_cache)
 return "";
-
+
 return $this->container->getUserdata($id, $group);
 } // end func getUserdata
 
 /**
 * Removes the specified dataset from the cache.
-* 
+*
 * @paramstring  dataset ID
 * @paramstring  cache group
 * @return   boolean
@@ -191,28 +200,28 @@
 function delete($id, $group = "default") {
 if ($this->no_cache)
 return true;
-
+
 return $this->container->delete($id, $group);
 } // end func

Re: [PHP-CVS] cvs: php4 /pear Cache.php /pear/Cache Container.phpError.php /pear/Cache/Container db.php file.php phplib.php

2001-03-08 Thread Christian Stocker

<<< No Message Collected >>>

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-CVS] cvs: php4 /pear/Cache Container.php Output.php /pear/Cache/Container db.php file.php phplib.php

2001-03-08 Thread Christian Stocker

chregu  Thu Mar  8 03:57:16 2001 EDT

  Modified files:  
/php4/pear/CacheContainer.php Output.php 
/php4/pear/Cache/Container  db.php file.php phplib.php 
  Log:
  Introduced getExpiresAbsolute($expire) function, which translates 
  relative/human readable/unixtime expire-times in unixtime-format.
  
  
Index: php4/pear/Cache/Container.php
diff -u php4/pear/Cache/Container.php:1.6 php4/pear/Cache/Container.php:1.7
--- php4/pear/Cache/Container.php:1.6   Tue Mar  6 07:27:30 2001
+++ php4/pear/Cache/Container.php   Thu Mar  8 03:57:15 2001
@@ -14,9 +14,10 @@
 // +--+
 // | Authors: Ulf Wendel <[EMAIL PROTECTED]>   |
 // |  Sebastian Bergmann <[EMAIL PROTECTED]>   |
+// |      Christian Stocker <[EMAIL PROTECTED]> |
 // +--+
 //
-// $Id: Container.php,v 1.6 2001/03/06 15:27:30 sbergmann Exp $
+// $Id: Container.php,v 1.7 2001/03/08 11:57:15 chregu Exp $
 
 /**
 * Common base class of all cache storage container.
@@ -36,7 +37,7 @@
 * not recommended!
 * 
 * @author   Ulf Wendel <[EMAIL PROTECTED]>
-* @version  $Id: Container.php,v 1.6 2001/03/06 15:27:30 sbergmann Exp $
+* @version  $Id: Container.php,v 1.7 2001/03/08 11:57:15 chregu Exp $
 * @package  Cache
 * @access   public
 * @abstract
@@ -372,5 +373,47 @@
 else
 return unserialize($data);
 } // end func decode
+
+/**
+* Translates human readable/relative times in unixtime
+*
+* @var  mixed   can be in the following formats:
+*   human readable  : mmddhhmm[ss]] eg: 20010308095100
+*   relative in seconds (1) : +xx  eg: +10
+*   relative in seconds (2) : x <  946681200   eg: 10
+*   absolute unixtime   : x < 2147483648   eg: 2147483648
+*   see comments in code for details
+*/
+
+function getExpiresAbsolute($expires)
+
+{
+if (!$expires)
+return 0;
+//for api-compatibility, one has not to provide a "+",
+// if integer is < 946681200 (= Jan 01 2000 00:00:00)
+if ('+' == $expires[0] || $expires < 946681200)
+{
+return(time() + $expires);
+}
+//if integer is < 1000 (= in 3140 years),
+// it must be an absolut unixtime
+// (since the "human readable" definition asks for a higher number)
+elseif ($expires < 1000)
+{
+return $expires;
+}
+// else it's "human readable";
+else
+{
+$year = substr($expires, 0, 4);
+$month = substr($expires, 4, 2);
+$day = substr($expires, 6, 2);
+$hour = substr($expires, 8, 2);
+$minute = substr($expires, 10, 2);
+$second = substr($expires, 12, 2);
+return mktime($hour, $minute, $second, $month, $day, $year);
+}
+}
 }
 ?>
Index: php4/pear/Cache/Output.php
diff -u php4/pear/Cache/Output.php:1.9 php4/pear/Cache/Output.php:1.10
--- php4/pear/Cache/Output.php:1.9  Tue Mar  6 07:27:30 2001
+++ php4/pear/Cache/Output.php  Thu Mar  8 03:57:15 2001
@@ -17,7 +17,7 @@
 // |  Vinai Kopp <[EMAIL PROTECTED]>   |
 // +--+
 //
-// $Id: Output.php,v 1.9 2001/03/06 15:27:30 sbergmann Exp $
+// $Id: Output.php,v 1.10 2001/03/08 11:57:15 chregu Exp $
 
 require_once 'Cache.php';
 
@@ -129,11 +129,11 @@
 /*
 * Stores the content of the output buffer into the cache and returns the content.
 *
-* @paraminteger lifetime of the cached data in seconds - 0 for endless
+* @parammixed   lifetime of the cached data in seconds - 0 for endless. More 
+formats available. see Container::getExpiresAbsolute()
 * @paramstring  additional userdefined data
 * @return   string  cached output
 * @access   public
-* @see  endPrint(), endGet()
+* @see  endPrint(), endGet(), Container::getExpiresAbsolute()
 */
 function end($expire = 0, $userdata = "") {
 $content = ob_get_contents();
Index: php4/pear/Cache/Container/db.php
diff -u php4/pear/Cache/Container/db.php:1.7 php4/pear/Cache/Container/db.php:1.8
--- php4/pear/Cache/Container/db.php:1.7Tue Mar  6 07:27:30 2001
+++ php4/pear/Cache/Container/db.phpThu Mar  8 03:57:16 2001
@@ -17,7 +17,7 @@
 // |  Chuck Hagenbuch <[EMAIL PROTECTED]>   |
 // +--+
 //
-// $Id: db.php,v 1.7 2001/03/06 15:27:30 sbergmann Exp $
+// $Id: db.php,v 1.8 2001/03/08 11:57:16 ch

[PHP-CVS] cvs: php4 /pear/Cache/Container file.php

2001-03-06 Thread Christian Stocker

chregu  Tue Mar  6 05:25:45 2001 EDT

  Modified files:  
/php4/pear/Cache/Container  file.php 
  Log:
  deleteDir deletes now the created "group"-Directories as well.
  Hope it works on windows as well...
  
  
Index: php4/pear/Cache/Container/file.php
diff -u php4/pear/Cache/Container/file.php:1.4 php4/pear/Cache/Container/file.php:1.5
--- php4/pear/Cache/Container/file.php:1.4  Sat Mar  3 11:02:54 2001
+++ php4/pear/Cache/Container/file.php  Tue Mar  6 05:25:43 2001
@@ -16,7 +16,7 @@
 // |  Sebastian Bergmann <[EMAIL PROTECTED]>   |
 // +--+
 //
-// $Id: file.php,v 1.4 2001/03/03 19:02:54 uw Exp $
+// $Id: file.php,v 1.5 2001/03/06 13:25:43 chregu Exp $
 
 require_once 'Cache/Container.php';
 
@@ -24,7 +24,7 @@
 * Stores cache contents in a file.
 *
 * @author   Ulf Wendel  <[EMAIL PROTECTED]>
-* @version  $Id: file.php,v 1.4 2001/03/03 19:02:54 uw Exp $
+* @version  $Id: file.php,v 1.5 2001/03/06 13:25:43 chregu Exp $
 */
 class Cache_Container_file extends Cache_Container {
 
@@ -53,35 +53,35 @@
 * @var  string
 */
 var $filename_prefix = "";
-
+
 /**
 * Creates the cache directory if neccessary
 * 
 * @paramarray   Config options: ["cache_dir" => ..., "filename_prefix" => ...]
 */
 function Cache_Container_file($options = "") {
-
+
 if (is_array($options))
 $this->setOptions($options, array("cache_dir", "filename_prefix"));
-
+
 clearstatcache();
 
 if (!file_exists($this->cache_dir) || !is_dir($this->cache_dir))
 mkdir($this->cache_dir, 0755);
-
+
 } // end func contructor
 
 
 function fetch($id, $group) {
-
+
 $file = $this->getFilename($id, $group);
-if (!file_exists($file)) 
+if (!file_exists($file))
 return array(NULL, NULL, NULL);
-   
+
 // retrive the content
 if (!($fh = @fopen($file, "rb")))
 return new CacheError("Can't access cache file '$file'. Check access 
rights and path.", __FILE__, __LINE__);
-
+
 // file format:
 // 1st line: expiration date
 // 2nd line: user data
@@ -102,13 +102,13 @@
 * otherwise it will break the filestructure.
 */
 function save($id, $cachedata, $expires, $group, $userdata) {
-
+
 $this->flushPreload($id, $group);
-
+
 $file = $this->getFilename($id, $group);
 if (!($fh = @fopen($file, "wb")))
 return new CacheError("Can't access '$file' to store cache data. Check 
access rights and path.", __FILE__, __LINE__);
-
+
 // file format:
 // 1st line: expiration date
 // 2nd line: user data
@@ -123,28 +123,28 @@
 // I'm not sure if we need this
 touch($file);
 
-return true;
+return true;
 } // end func save
 
 function delete($id, $group) {
-
+
 $this->flushPreload($id, $group);
-
+
 $file = $this->getFilename($id, $group);
 if (file_exists($file)) {
-   
+
 $ok = unlink($file);
 clearstatcache();
 
 return $ok;
 }
-
-return false;
+
+return false;
 } // end func delete
 
 
 function flush($group) {
-
+
 $this->flushPreload();
 $dir = ($group) ? $this->cache_dir . $group . "/" : $this->cache_dir;
 
@@ -153,8 +153,8 @@
 
 return $num_removed;
 } // end func flush
-
 
+
 function idExists($id, $group) {
 
 return file_exists($this->getFilename($id, $group));
@@ -176,24 +176,24 @@
 *   recursive function call!
 */
 function garbageCollection($dir = "") {
-
-$this->flushPreload();  
+
+$this->flushPreload();
 
 if (!$dir)
 $dir = $this->cache_dir;
 
 if (!($dh = opendir($dir)))
 return new CacheError("Can't access cache directory '$dir'. Check 
permissions and path.", __FILE__, __LINE__);
-
+
 while ($file = readdir($dh)) {
 if ("." == $file || ".." == $file)
 continue;
-
+
 $file = $dir . $file;
 if (is_dir($file))
 $this->garbageCollection($file . "/");
-
-// skip trouble makers but inform the user
+
+// skip trouble makers but inform the user
 if (!($fh = @fopen($file, "rb"))) {
 new CacheError("Can't access cache file '$file', skipping it. Check 
permissions and path.", __FILE__, __LINE__);
 continue;
@@ -205,8 +2

[PHP-CVS] cvs: php4 /pear/Cache Container.php /pear/Cache/Container db.php phplib.php

2001-03-06 Thread Christian Stocker

chregu  Tue Mar  6 03:32:10 2001 EDT

  Modified files:  
/php4/pear/CacheContainer.php 
/php4/pear/Cache/Container  db.php phplib.php 
  Log:
  replaced db->quoteString with addslashes
  
  adjusted encoding_mode = "slash" that it doesn't quote slashes, the 
  save() function in phplib/db-container is now in charge for that.
  
  
  
Index: php4/pear/Cache/Container.php
diff -u php4/pear/Cache/Container.php:1.4 php4/pear/Cache/Container.php:1.5
--- php4/pear/Cache/Container.php:1.4   Sat Mar  3 11:14:36 2001
+++ php4/pear/Cache/Container.php   Tue Mar  6 03:32:10 2001
@@ -1,4 +1,5 @@
|
 // +--+
 //
-// $Id: Container.php,v 1.4 2001/03/03 19:14:36 uw Exp $
+// $Id: Container.php,v 1.5 2001/03/06 11:32:10 chregu Exp $
 
 /**
 * Common base class of all cache storage container.
@@ -36,7 +37,7 @@
 * not recommended!
 * 
 * @author   Ulf Wendel <[EMAIL PROTECTED]>
-* @version  $Id: Container.php,v 1.4 2001/03/03 19:14:36 uw Exp $
+* @version  $Id: Container.php,v 1.5 2001/03/06 11:32:10 chregu Exp $
 * @package  Cache
 * @access   public
 * @abstract
@@ -215,7 +216,7 @@
 * @return   boolean
 */
 function isCached($id, $group) {
-
+
 if ($this->preload) {
 
 if ($this->id != $id || $this->group != $group)
@@ -343,7 +344,7 @@
 
 // Uuups, unknown ID
 $this->flushPreload();
-
+
 return false;
 }
 
@@ -406,7 +407,7 @@
 if ("base64" == $this->encoding_mode) 
 return base64_encode(serialize($data));
 else 
-return addslashes(serialize($data));
+return serialize($data);
 
 } // end func encode
 
@@ -421,9 +422,9 @@
 if ("base64" == $this->encoding_mode)
 return unserialize(base64_decode($data));
 else
-return unserialize(stripslashes($data));
+return unserialize($data);
 
 } // end func decode
 
 }
-?>
\ No newline at end of file
+?>
Index: php4/pear/Cache/Container/db.php
diff -u php4/pear/Cache/Container/db.php:1.5 php4/pear/Cache/Container/db.php:1.6
--- php4/pear/Cache/Container/db.php:1.5Sat Mar  3 11:01:03 2001
+++ php4/pear/Cache/Container/db.phpTue Mar  6 03:32:10 2001
@@ -17,7 +17,7 @@
 // |  Chuck Hagenbuch <[EMAIL PROTECTED]>   |
 // +--+
 //
-// $Id: db.php,v 1.5 2001/03/03 19:01:03 uw Exp $
+// $Id: db.php,v 1.6 2001/03/06 11:32:10 chregu Exp $
 
 require_once 'DB.php';
 require_once 'Cache/Container.php';
@@ -52,7 +52,7 @@
 * )
 
  * @author   Sebastian Bergmann <[EMAIL PROTECTED]>
- * @version  $Id: db.php,v 1.5 2001/03/03 19:01:03 uw Exp $
+ * @version  $Id: db.php,v 1.6 2001/03/06 11:32:10 chregu Exp $
  * @package  Cache
  */
 class Cache_Container_db extends Cache_Container {
@@ -107,8 +107,8 @@
 {
 $query = sprintf("SELECT cachedata, userdata, expires FROM %s WHERE id = '%s' 
AND cachegroup = '%s'",
  $this->cache_table,
- $this->db->quoteString($id),
- $this->db->quoteString($group)
+ addslashes($id),
+ addslashes($group)
  );
 
 $res = $this->db->query($query);
@@ -117,7 +117,7 @@
 return new CacheError('DB::query failed: ' . DB::errorMessage($res), 
__FILE__, __LINE__);
 
 $row = $res->fetchRow();
-
+
 if (is_array($row))
 return array($row['expires'], $this->decode($row['cachedata']), 
$row['userdata']);
 }
@@ -136,17 +136,17 @@
 
 $query = sprintf("REPLACE INTO %s (userdata, cachedata, expires, id, 
cachegroup) VALUES ('%s', '%s', %d, '%s', '%s')",
  $this->cache_table,
- $this->db->quoteString($userdata),
- $this->db->quoteString($this->encode(($data))),
+ addslashes($userdata),
+ addslashes($this->encode($data)),
  ($expires) ? $expires + time() : 0,
- $this->db->quoteString($id),
- $this->db->quoteString($group)
+ addslashes($id),
+ addslashes($group)
 );
-
+
 $res = $this->db->query($query);
 
 if (DB::isError($res)) {
-return new CacheError('DB::query failed: ' . DB::errorMessage($res), 
__FILE__, __LINE__);
+return new CacheError('DB::query failed: ' . DB::errorMessage($res) , 
+__FILE__, __LINE__);
 }
 }
 
@@ -157,8 +157,8 @@
 
 $query = sprintf("DELETE FROM %s WHERE id = '%s' and cachegroup = '%s'",
 

[PHP-CVS] cvs: php4 /pear/Cache Output.php

2001-03-02 Thread Christian Stocker

chregu  Fri Mar  2 06:46:01 2001 EDT

  Modified files:  
/php4/pear/CacheOutput.php 
  Log:
  Wrong order of Parameters in $this->container->save();
  and $this->cache_id instead of $this->id on the same line
  
  
  
Index: php4/pear/Cache/Output.php
diff -u php4/pear/Cache/Output.php:1.3 php4/pear/Cache/Output.php:1.4
--- php4/pear/Cache/Output.php:1.3  Fri Mar  2 02:39:36 2001
+++ php4/pear/Cache/Output.php  Fri Mar  2 06:46:01 2001
@@ -17,7 +17,7 @@
 // |  Vinai Kopp <[EMAIL PROTECTED]>   |
 // +--+
 //
-// $Id: Output.php,v 1.3 2001/03/02 10:39:36 sbergmann Exp $
+// $Id: Output.php,v 1.4 2001/03/02 14:46:01 chregu Exp $
 
 require_once'Cache.php';
 
@@ -98,12 +98,12 @@
 function start($id) {
 if ($this->no_cache)
 return "";
-
-// this is already cached return it from the cache so that the user 
+
+// this is already cached return it from the cache so that the user
 // can use the cache content and stop script execution
 if ($content = $this->get($id))
 return $content;
-
+
 // remember some data to be able to fill the cache on calling end()
 $this->cache_id = $id;
 
@@ -113,7 +113,7 @@
 
 return "";
 } // end func start
-
+
 /*
 * Stores the content of the output buffer into the cache and returns the content.
 *
@@ -129,8 +129,8 @@
 
 // store in the cache
 if (!$this->no_cache)
-$this->container->save($content, $this->id, $expire);
-
+$this->container->save($this->cache_id,$content,  $expire);
+
 return $content;
 } // end func end()
 
@@ -141,10 +141,10 @@
 */
 function endPrint($expire = 0) {
 
-print $this->end($expire);  
+print $this->end($expire);
 
 } // end func endPrint
-
+
 
 } // end class output
 ?>



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]