- Author
- Requirements
- Related Extensions
- Installation
- Usage
- Class Diagram
- Command Line Utility Available
VERSION 1.0
Fileman is a yii framework component, it allows you to handle files attached to a given Identity (maybe your current user id or something else).
This component is based on an abstract class YiiFileManager, so many child classes can be built to satisfy business dependencies like: Storing files in a disk file (YiiDiskFileManager), in a database (YiiDbFileManager currently under development), and so on.
About Widgets: This file manager is the base component for a future familiy of more advanced UI widgets (currently under development).
Author ¶
- Christian Salazar christiansalazarh@gmail.com
- Twitter: @salazarchris74
- yii forum profile: Bluyell
Requirements ¶
Yii 1.1.10+
Related Extensions ¶
You can display the user's files (pic or doc) using the Yiifilemanagerfilepicker extension. By using this extension you get a multi file ajax uploader with progress bar, rename files, delete files and a file viewer tool.
Installation ¶
A) Download from Bitbucket: https://bitbucket.org/christiansalazarh/yiifilemanager
B) or clone it using GIT ~~~ cd yourapp/protected/extensions git clone https://bitbucket.org/christiansalazarh/yiifilemanager.git ~~~
C) Register the fileman component into your config file.
'import'=>array(
...bla...
'application.extensions.yiifilemanager.*', // <<--HERE
),
'components'=>array(
'fileman' => array(
'class'=>'application.extensions.yiifilemanager.YiiDiskFileManager',
'storage_path' => "/var/tmp/fileman",
),
Usage ¶
// ADD FILES
// add_files return an array of file_id.
Yii::app()->fileman->add_files($identity,"/some/place/filename.mp3");
Yii::app()->fileman->add_files($identity,array("file1", "file2"));
// LIST FILES
// it returns an array of file-data:
// "id" (identity), "file_id", "filename", "longfilename"
foreach(Yii::app()->fileman->list_files($identity) as $fd)
printf("file -> [%s] [%s] [%s]\n",
$fd['id'],$fd['file_id'],$fd['filename']);
// QUERY THE REAL PATH FOR A GIVEN FILE ID
//
$real_path = Yii::app()->fileman->get_file_path($id, "18aac1a12");
// ..do what ever you want with this file...
printf("the real local path is: %s\n",$real_path);
// QUERY IF THE GIVEN USER ID CAN READ A FILE USING ITS FILE_ID
//
$bool = Yii::app()->fileman->can_read(Yii::app()->user->id, "188abc123");
// RENAME FILES
//
$bool = Yii::app()->fileman->rename_file(Yii::app()->user->id, "188abc123", "new file name");
// REMOVE FILES
// using the file_id provided when calling list_files()
Yii::app()->fileman->remove_file($identity, "18ac11981");
Yii::app()->fileman->remove_file($identity, array("288abc12","2029acb12"));
Class Diagram ¶
Command Line Utility Available ¶
The command line utility is available in the 'commands' directory into this extension.
1) Copy the provided file from:
'protected/extensions/yiifilemanager/commands/FilemanCommand.php'
to:
"protected/commands/FilemanCommand.php"
2) Be sure you have the rigth config file in "protected/yiic.php" and test it:
cd myapp
cd protected
./yiic fileman --id=123456 --cmd=list
./yiic fileman --id=123456 --cmd=add --files=/home/mydoc.txt,/home/some.mp3
Known Issues:
exception 'CException' with message 'Property CConsoleApplication.fileman is not defined.'
in /home/christian/www/yii/framework/base/CComponent.php:130
Reason:
Check your file: protected/yiic.php, it must point to config/main.php, or edit your config/console.php file in order to register the yiifilemanager component into it
Demo
Please demo page ...
about demo page
hi, to enable a demo the easiest way is to create a command into any existing yii application, read this section in this same document
install the extension, create a local directory, give it 777 permissions (to avoid any security issue while we are using a demo) and copy the provided command class into your commands directory,
a simple file manager for web users?
Where is the simple things?
Yii::app()->fileman->add_files($identity,"/some/place/filename.mp3"); Yii::app()->fileman->add_files($identity,array("file1", "file2")); foreach(Yii::app()->fileman->list_files($identity) as $fd) printf("file -> [%s] [%s] [%s]\n", $fd['id'],$fd['file_id'],$fd['filename']); // QUERY THE REAL PATH FOR A GIVEN FILE ID // $real_path = Yii::app()->fileman->get_file_path($id, "18aac1a12");
Sorry, but to me, PHP function basically is more simple than that.
to keripik_jagung
dear @keripik_jagung please read and take a nice understanding before make a negative vote:
"¿ Where is the simple things ?"
yiifilemanager allows you to abstract "a file". it can be a diskfile, a blob/ram file (a file not pyhisically stored in a disk). having this in mind you can have a FileExplorer (the yiifilemanagerfilepicker extension) using a yiifilemanager component, and your user never knows if their files are real or phisical ones, and your app doesnt deal with this details due to abstraction.
yiifilemanager provides you an abstract layer to deal with files of any kind (real disk files, or ram memory files), including access control, separating files for a given identity.
yiifilemanaer allows your app to deal with crc32 id numbers instead of handling not secure paths as "traditional" way.
in your words, then using a framework is bad idea ? then, why are you using Yii framework ?
About variable
Please tell me about function for this variable bellow:
$identity
$id
and string 18aac1a12
in this script
Yii::app()->fileman->add_files($identity,"/some/place/filename.mp3");
Yii::app()->fileman->get_file_path($id, "18aac1a12");
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.