-
Notifications
You must be signed in to change notification settings - Fork 6
Connector configuration options
This is a list of the available options for Finder connector (PHP part), along with their default values. Options are specified by passing an array with certain keys as first argument to Finder()
class constructor. Example:
<?php
$opts = array(
'locale' => '',
'roots' => array(
array(
'driver' => 'LocalFileSystem',
'path' => '/path/to/files/',
'URL' => 'http://localhost/to/files/'
)
)
);
// run Finder
$connector = new Finder($opts);
$connector->run();
Set locale. Currently only UTF-8 locales are supported. Passed to setLocale
PHP function.
Data type: string
Default value: 'en_US.UTF-8'
Send debug to client.
Data type: boolean
Default value: false
Bind callbacks to events similar to jQuery .bind()
. Accepts array(key => value)
pairs where:
key
is a space separated list of [events](Binding Events) to bind to;
value
is a valid [callback](Php Callbacks)
Callback will be called with next parameters $cmd, $result, $args, $finder
.
Data type: array
Default value: array()
Example:
<?php
/**
* Simple callback catcher
*
* @param string $event event name
* @param array $result command result
* @param array $args command arguments from client
* @param object $finder Finder instance
* @return void|true
**/
function mySimpleCallback( $cmd, $result, $args, $finder ){
// do something here
}
$opts = array(
'bind' => array(
'mkdir mkfile rename duplicate upload rm paste' => 'mySimpleCallback'
),
'roots' => array(...)
);
Logging example
These two options can define callbacks that will be used in combination to allow the finder to save and fetch user data on the server. Some care should be taken to ensure the data is saved securely as the data passed through the callbacks can contain sensitive information like ftp usernames and passwords.
Data type: [callback](Php Callbacks)
Default value: false
Example:
<?php
/**
* Use php $_SESSION for data storage
*/
session_start();
function SaveFinderData($data){
$_SESSION['finder_data'] = $data;
}
function ReturnFinderData(){
if( isset($_SESSION['finder_data']) ){
return $_SESSION['finder_data'];
}
return false;
}
$opts = array(
'locale' => '',
'saveData' => 'SaveFinderData',
'returnData' => 'ReturnFinderData',
'roots' => array(
array(
'driver' => 'LocalFileSystem',
'path' => '/path/to/files/',
'URL' => 'http://localhost/to/files/'
)
)
);
// run Finder
$connector = new Finder($opts);
$connector->run();
Array of arrays with per root settings. This is the only required option.
Data type: array
Default value: array()
Example:
<?php
$opts = array(
'roots' => array(
array(
'driver' => 'LocalFileSystem',
'path' => '/path/to/files/',
'URL' => 'http://localhost/to/files/'
),
array(
'driver' => 'MySQL',
'host' => 'localhost',
'user' => 'user',
'pass' => 'pass',
'db' => 'finder'
'path' => 1,
),
array(
'driver' => 'FTP',
'host' => '192.168.1.1',
'user' => 'user',
'pass' => 'pass',
'path' => '/'
)
)
);