[phpwebapp-commits] CVS: web_app/boxes/folderListing folderListing.php,1.4,1.5
Brought to you by:
dashohoxha
From: Dashamir H. <das...@us...> - 2004-07-22 16:25:52
|
Update of /cvsroot/phpwebapp/web_app/boxes/folderListing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9224/boxes/folderListing Modified Files: folderListing.php Log Message: reformated and modified the copyleft notice Index: folderListing.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/boxes/folderListing/folderListing.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** folderListing.php 25 Aug 2003 13:18:33 -0000 1.4 --- folderListing.php 22 Jul 2004 16:25:39 -0000 1.5 *************** *** 1,21 **** <?php /* ! Copyright 2001,2002,2003 Dashamir Hoxha, das...@us... ! This file is part of phpWebApp. ! phpWebApp is free software; you can redistribute it and/or modify ! it under the terms of the GNU General Public License as published by ! the Free Software Foundation; either version 2 of the License, or ! (at your option) any later version. ! phpWebApp is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ --- 1,22 ---- <?php /* ! This file is part of phpWebApp, which is a framework for building web ! application based on relational databases. ! Copyright 2001,2002,2003,2004 Dashamir Hoxha, das...@us... ! phpWebApp is free software; you can redistribute it and/or modify it ! under the terms of the GNU General Public License as published by the ! Free Software Foundation; either version 2 of the License, or (at your ! option) any later version. ! phpWebApp is distributed in the hope that it will be useful, but ! WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with phpWebApp; if not, write to the Free Software Foundation, ! Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ *************** *** 28,96 **** { function init() ! { ! $this->addSVar("fileFilter", ".*"); ! $this->addSVar("root", APP_PATH); ! $this->addSVar("currentPath", ""); ! $this->addSVar("selectedFile", "{{FOLDERLISTING_PATH}}empty.html"); ! } function eventHandler($event) ! { ! switch ($event->name) ! { ! case "changeRoot": ! $root_folder = $event->args["root_folder"]; ! if (substr($root_folder, -1)<>"/") $root_folder .= "/"; ! $this->setSVar("root", $root_folder); ! $this->setSVar("currentPath", ""); ! break; ! case "path": ! $current_path = $event->args["path"]; ! $this->setSVar("currentPath", $current_path); ! break; ! case "up": ! $current_path = $this->getSVar("currentPath"); ! $current_path = ereg_replace("[^/]*/$", "", $current_path); ! $this->setSVar("currentPath", $current_path); ! break; ! case "root": ! $this->setSVar("currentPath", ""); ! break; ! case "folder": ! $folder_name = $event->args["folder_name"]; ! $current_path = $this->getSVar("currentPath"); ! $current_path .= $folder_name."/"; ! $this->setSVar("currentPath", $current_path); ! break; ! case "file": ! $root = $this->getSVar("root"); ! $path = $this->getSVar("currentPath"); ! $file_name = $event->args["file_name"]; ! $this->setSVar("selectedFile", $root.$path.$file_name); ! break; ! } ! } function onRender() ! { ! $root = $this->getSVar("root"); ! $path = $this->getSVar("currentPath"); ! $filter = $this->getSVar("fileFilter"); ! list($rs_folders,$rs_files) = $this->readFolder($root.$path, $filter); ! $rs_paths = $this->get_path_rs($path); ! $rs_paths->ID = "paths"; ! $rs_folders->ID = "folders"; ! $rs_files->ID = "files"; ! global $webPage; ! $webPage->addRecordset($rs_paths); ! $webPage->addRecordset($rs_folders); ! $webPage->addRecordset($rs_files); ! } /** --- 29,97 ---- { function init() ! { ! $this->addSVar("fileFilter", ".*"); ! $this->addSVar("root", APP_PATH); ! $this->addSVar("currentPath", ""); ! $this->addSVar("selectedFile", "{{FOLDERLISTING_PATH}}empty.html"); ! } function eventHandler($event) ! { ! switch ($event->name) ! { ! case "changeRoot": ! $root_folder = $event->args["root_folder"]; ! if (substr($root_folder, -1)<>"/") $root_folder .= "/"; ! $this->setSVar("root", $root_folder); ! $this->setSVar("currentPath", ""); ! break; ! case "path": ! $current_path = $event->args["path"]; ! $this->setSVar("currentPath", $current_path); ! break; ! case "up": ! $current_path = $this->getSVar("currentPath"); ! $current_path = ereg_replace("[^/]*/$", "", $current_path); ! $this->setSVar("currentPath", $current_path); ! break; ! case "root": ! $this->setSVar("currentPath", ""); ! break; ! case "folder": ! $folder_name = $event->args["folder_name"]; ! $current_path = $this->getSVar("currentPath"); ! $current_path .= $folder_name."/"; ! $this->setSVar("currentPath", $current_path); ! break; ! case "file": ! $root = $this->getSVar("root"); ! $path = $this->getSVar("currentPath"); ! $file_name = $event->args["file_name"]; ! $this->setSVar("selectedFile", $root.$path.$file_name); ! break; ! } ! } function onRender() ! { ! $root = $this->getSVar("root"); ! $path = $this->getSVar("currentPath"); ! $filter = $this->getSVar("fileFilter"); ! list($rs_folders,$rs_files) = $this->readFolder($root.$path, $filter); ! $rs_paths = $this->get_path_rs($path); ! $rs_paths->ID = "paths"; ! $rs_folders->ID = "folders"; ! $rs_files->ID = "files"; ! global $webPage; ! $webPage->addRecordset($rs_paths); ! $webPage->addRecordset($rs_folders); ! $webPage->addRecordset($rs_files); ! } /** *************** *** 99,160 **** */ function readFolder($folder_path, $filter) ! { ! if (filetype($folder_path) <> 'dir') ! { ! print WebApp::error_msg("'$folder_path' is not a folder."); ! return; ! } ! $dir = opendir($folder_path); ! if (!$dir) ! { ! print WebApp::error_msg("Cannot open folder '$folder_path'."); ! return; ! } ! $rs_folders = new EditableRS; ! $rs_folders->Open(); ! $rs_files = new EditableRS; ! $rs_files->Open(); ! if ( substr($folder_path, -1) <> "/" ) $folder_path .= "/"; ! while ($fname = readdir($dir)) ! { ! if (filetype($folder_path.$fname) == 'dir') ! { ! if ($fname=="." or $fname==".." or $fname=="CVS") continue; ! $rs_folders->addRec(array("folder"=>$fname)); ! } ! else if (filetype($folder_path.$fname) == 'file') ! { ! if ( eregi($filter,$fname) ) ! { ! $rs_files->addRec(array("file"=>$fname)); ! } ! } ! } ! closedir($dir); ! return array($rs_folders, $rs_files); ! } /** $path is a string like this: "folder1/folder2/folder3/" */ function get_path_rs($path) ! { ! $rs_paths = new EditableRS; ! $rs_paths->Open(); ! $rec = array("folder"=>"Root", "path"=>""); ! $rs_paths->addRec($rec); ! $folders = explode("/", $path); ! $folder_path = ""; ! for ($i=0; $i < sizeof($folders) - 1; $i++) ! { ! $folder_path .= $folders[$i] . "/"; ! $rec = array("folder"=>$folders[$i], "path"=>$folder_path); ! $rs_paths->addRec($rec); ! } ! return $rs_paths; ! } } ?> \ No newline at end of file --- 100,161 ---- */ function readFolder($folder_path, $filter) ! { ! if (filetype($folder_path) <> 'dir') ! { ! print WebApp::error_msg("'$folder_path' is not a folder."); ! return; ! } ! $dir = opendir($folder_path); ! if (!$dir) ! { ! print WebApp::error_msg("Cannot open folder '$folder_path'."); ! return; ! } ! $rs_folders = new EditableRS; ! $rs_folders->Open(); ! $rs_files = new EditableRS; ! $rs_files->Open(); ! if ( substr($folder_path, -1) <> "/" ) $folder_path .= "/"; ! while ($fname = readdir($dir)) ! { ! if (filetype($folder_path.$fname) == 'dir') ! { ! if ($fname=="." or $fname==".." or $fname=="CVS") continue; ! $rs_folders->addRec(array("folder"=>$fname)); ! } ! else if (filetype($folder_path.$fname) == 'file') ! { ! if ( eregi($filter,$fname) ) ! { ! $rs_files->addRec(array("file"=>$fname)); ! } ! } ! } ! closedir($dir); ! return array($rs_folders, $rs_files); ! } /** $path is a string like this: "folder1/folder2/folder3/" */ function get_path_rs($path) ! { ! $rs_paths = new EditableRS; ! $rs_paths->Open(); ! $rec = array("folder"=>"Root", "path"=>""); ! $rs_paths->addRec($rec); ! $folders = explode("/", $path); ! $folder_path = ""; ! for ($i=0; $i < sizeof($folders) - 1; $i++) ! { ! $folder_path .= $folders[$i] . "/"; ! $rec = array("folder"=>$folders[$i], "path"=>$folder_path); ! $rs_paths->addRec($rec); ! } ! return $rs_paths; ! } } ?> \ No newline at end of file |