X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..HEAD:/examples/tree/get-nodes.php?ds=inline
diff --git a/examples/tree/get-nodes.php b/examples/tree/get-nodes.php
index 67130fd5..6e73e59c 100644
--- a/examples/tree/get-nodes.php
+++ b/examples/tree/get-nodes.php
@@ -1,43 +1,80 @@
-=$factor;$i++)
- $val /= $factor;
- $p = strpos($val, ".");
- if($p !== false && $p > $digits) $val = round($val);
- elseif($p !== false) $val = round($val, $digits-$p);
- return round($val, $digits) . " " . $symbols[$i] . $bB;
-}
-
-$dir = isset($_REQUEST['lib'])&&$_REQUEST['lib'] == 'yui' ? '../../../' : '../../';
-$node = isset($_REQUEST['node'])?$_REQUEST['node']:"";
-if(strpos($node, '..') !== false){
- die('Nice try buddy.');
-}
-$nodes = array();
-$d = dir($dir.$node);
-while($f = $d->read()){
- if($f == '.' || $f == '..' || substr($f, 0, 1) == '.')continue;
- $lastmod = date('M j, Y, g:i a',filemtime($dir.$node.'/'.$f));
- if(is_dir($dir.$node.'/'.$f)){
- $qtip = 'Type: Folder
Last Modified: '.$lastmod;
- $nodes[] = array('text'=>$f, 'id'=>$node.'/'.$f/*, 'qtip'=>$qtip*/, 'cls'=>'folder');
- }else{
- $size = formatBytes(filesize($dir.$node.'/'.$f), 2);
- $qtip = 'Type: JavaScript File
Last Modified: '.$lastmod.'
Size: '.$size;
- $nodes[] = array('text'=>$f, 'id'=>$node.'/'.$f, 'leaf'=>true/*, 'qtip'=>$qtip, 'qtipTitle'=>$f */, 'cls'=>'file');
- }
-}
-$d->close();
-echo json_encode($nodes);
+=$factor;$i++)
+ $val /= $factor;
+ $p = strpos($val, '.');
+ if($p !== false && $p > $digits) $val = round($val);
+ elseif($p !== false) $val = round($val, $digits-$p);
+ return round($val, $digits) . ' ' . $symbols[$i] . $bB;
+}
+
+// grab the custom params
+$path = isset($_REQUEST['path'])&&$_REQUEST['path'] == 'extjs' ? '../../../' : '../../';
+
+$node = isset($_REQUEST['node']) ? $_REQUEST['node'] : '';
+$isXml = isset($_REQUEST['isXml']);
+
+if(strpos($node, '..') !== false){
+ die('Nice try buddy.');
+}
+
+$nodes = array();
+$directory = $path.$node;
+if (is_dir($directory)){
+ $d = dir($directory);
+ while($f = $d->read()){
+ if($f == '.' || $f == '..' || substr($f, 0, 1) == '.') continue;
+
+ $filename = $directory . '/' . $f;
+ date_default_timezone_set('America/Los_Angeles');
+ $lastmod = date('M j, Y, g:i a', filemtime($filename));
+
+ if(is_dir($directory.'/'.$f)){
+ $qtip = 'Type: Folder
Last Modified: '.$lastmod;
+ $nodes[] = array(
+ 'text' => $f,
+ 'id' => $node.'/'.$f,
+ 'cls' => 'folder'
+ );
+ } else {
+ $size = formatBytes(filesize($filename), 2);
+ $qtip = 'Type: JavaScript File
Last Modified: '.$lastmod.'
Size: '.$size;
+ $nodes[] = array(
+ 'text' => $f,
+ 'id' => $node.'/'.$f,
+ 'leaf' => true,
+ 'cls' => 'file'
+ );
+ }
+ }
+ $d->close();
+}
+
+if ($isXml) {
+ $xmlDoc = new DOMDocument();
+ $root = $xmlDoc->appendChild($xmlDoc->createElement("nodes"));
+ foreach ($nodes as $node) {
+ $xmlNode = $root->appendChild($xmlDoc->createElement("node"));
+ $xmlNode->appendChild($xmlDoc->createElement("text", $node['text']));
+ $xmlNode->appendChild($xmlDoc->createElement("id", $node['id']));
+ $xmlNode->appendChild($xmlDoc->createElement("cls", $node['cls']));
+ $xmlNode->appendChild($xmlDoc->createElement("leaf", isset($node['leaf'])));
+ }
+ header("Content-Type: text/xml");
+ $xmlDoc->formatOutput = true;
+ echo $xmlDoc->saveXml();
+} else {
+ echo json_encode($nodes);
+}
\ No newline at end of file