cleanup
[xendri.git] / lib / core / PCLHandler.php
blob9d2514de3cce72b6cad3ffc48b26fd4864502799
1 <?php
3 class PCLHandler {
4 private $source;
5 private $name = '';
6 function __construct($name) {
7 $this->name = $name;
8 $file = $name.".pcl";
9 if (is_a($file, 'SimpleXMLElement')) {
10 $file = $file['src'];
12 try {
13 $this->source = Styler::locate ( $file );
15 catch (Exception $e) {
16 return false;
18 $res = '';
19 if (! trim ( $this->source )) {
20 Log::warning ( 'Unable to find page contents list!' );
23 function getContents() {
24 if (!$this->source) return false;
25 $pcl = simplexml_load_file ( $this->source );
26 if (!$pcl) Log::fatal('Bad pcl file '.$this->source, QConst::X_UNDEFINED);
27 $ret = $this->recurseXML($pcl);
28 return $ret;
31 function recurseXML(SimpleXMLElement $node) {
32 $childs = $node->children();
33 $res = '';
34 if (count($childs) > 0) {
35 $res = '<'.$node->getName().'>';
36 foreach ( $childs as $content ) {
37 $res .= $this->recurseXML($content);
39 $res .= '</'.$node->getName().'>';
41 else {
42 $pe = new PageElement ( $node );
43 $res .= $pe->getValue ();
45 return $res;