Javascript-форум (https://javascript.ru/forum/)
-   ExtJS (https://javascript.ru/forum/extjs/)
-   -   Просмотрщик файлов на extjs 3 (https://javascript.ru/forum/extjs/35113-prosmotrshhik-fajjlov-na-extjs-3-a.html)

mario03 30.01.2013 22:58

Просмотрщик файлов на extjs 3
 
Здравствуйте! очень нужна ваша помощь. в эксте я не селён поэтому заранее извиняюсь. Имеется просмотрщик файлов на екст 4 нужно перевести его на екст 3. серверная часть одна и та же меняется только клиентская однако в первом случае все работает, а во втором даже запрос не отправляется заранее спасибо

//extjs 4
store_dir = Ext.create('Ext.data.TreeStore', {
proxy: {
type: 'ajax',
url: 'get_dir.php'
}
});

tree_dir = Ext.create('Ext.tree.Panel', {
title: 'Localhost Directory',
rootVisible: false,
store: store_dir,
split: true,
region: 'west',
collapsible: true,
floatable: false,
width: 200,
useArrows: true,
});

//extjs 3
var tree = new Ext.tree.TreePanel({
useArrows: true,
autoScroll: true,
animate: true,
enableDD: true,
containerScroll: true,
border: false,
// auto create TreeLoader
dataUrl: 'get_dir.php',
root: {
nodeType: 'async',
text: 'root',
draggable: false,
id: 'source'
}
});
tree.getRootNode().expand(true);

//get_dir.php

class MyDirectory {

public $json = '[';

public function get_children($dir, $child) {
$dh = opendir($dir);
while (($file = readdir($dh)) !== false) {
if ($file != '.' AND $file != '..' ) {
if (filetype($dir . $file) == 'dir') {
// must be checked if this folder have other subfolder
if ($this->count_sub_dir($dir . $file . '/') == 0) {
$this->json .= '{text:"'.$file.'", leaf: true, id: "'.$dir . $file.'"},';
} else {
$this->json .= '{text:"'.$file.'", id: "'.$dir . $file.'", children: [';
$this->get_children($dir . $file . '/', true);
}
}
}
}
if ($child) {
$this->json .= ']},';
}
closedir($dh);
}

public function count_sub_dir($dir) {
$dh = opendir($dir);
$countdir = 0;
while (($file = readdir($dh)) !== false) {
if ($file != '.' AND $file != '..' ) {
if (filetype($dir . $file) == 'dir') {
$countdir++;
}
}
}
closedir($dh);
return $countdir;
}
}

$host_dir = $_SERVER['DOCUMENT_ROOT']."/";

$dir = new MyDirectory();

$dir->get_children($host_dir, false);

$dir->json .= ']';
$dir->json = str_replace(",]", "]", $dir->json);

echo($dir->json);

?>


Часовой пояс GMT +3, время: 00:35.