2008-06-25 08:09:25 +00:00
|
|
|
<?php // $Id$
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// //
|
|
|
|
// NOTICE OF COPYRIGHT //
|
|
|
|
// //
|
|
|
|
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
|
|
|
// http://moodle.com //
|
|
|
|
// //
|
|
|
|
// Copyright (C) 2008 onwards Moodle Pty Ltd http://moodle.com //
|
|
|
|
// //
|
|
|
|
// This program 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. //
|
|
|
|
// //
|
|
|
|
// This program 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: //
|
|
|
|
// //
|
|
|
|
// http://www.gnu.org/copyleft/gpl.html //
|
|
|
|
// //
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
2008-06-27 05:48:24 +00:00
|
|
|
* This is the base class of the repository class
|
2008-06-27 03:33:40 +00:00
|
|
|
*
|
2008-07-14 05:31:01 +00:00
|
|
|
* To use repository plugin, you need to create a new folder under repository/, named as the remote
|
2008-06-27 03:33:40 +00:00
|
|
|
* repository, the subclass must be defined in the name
|
|
|
|
|
|
|
|
*
|
|
|
|
* class repository is an abstract class, some functions must be implemented in subclass.
|
|
|
|
*
|
|
|
|
* See an example of use of this library in repository/box/repository.class.php
|
|
|
|
*
|
|
|
|
* A few notes :
|
2008-07-14 05:31:01 +00:00
|
|
|
* // options are stored as serialized format in database
|
|
|
|
* $options = array('api_key'=>'dmls97d8j3i9tn7av8y71m9eb55vrtj4',
|
2008-06-27 03:33:40 +00:00
|
|
|
* 'auth_token'=>'', 'path_root'=>'/');
|
|
|
|
* $repo = new repository_xxx($options);
|
|
|
|
* // print login page or a link to redirect to another page
|
|
|
|
* $repo->print_login();
|
|
|
|
* // call get_listing, and print result
|
|
|
|
* $repo->print_listing();
|
|
|
|
* // print a search box
|
|
|
|
* $repo->print_search();
|
|
|
|
*
|
|
|
|
* @version 1.0 dev
|
2008-07-16 05:15:14 +00:00
|
|
|
* @package repository
|
2008-06-27 03:33:40 +00:00
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
2008-06-25 08:09:25 +00:00
|
|
|
*/
|
2008-07-28 08:24:55 +00:00
|
|
|
require_once(dirname(dirname(__FILE__)) . '/config.php');
|
2008-07-31 02:51:28 +00:00
|
|
|
require_once(dirname(dirname(__FILE__)).'/lib/filelib.php');
|
2008-06-25 08:09:25 +00:00
|
|
|
|
2008-06-27 05:48:24 +00:00
|
|
|
abstract class repository {
|
2008-06-27 03:33:40 +00:00
|
|
|
protected $options;
|
|
|
|
public $name;
|
|
|
|
public $context;
|
|
|
|
public $repositoryid;
|
2008-06-30 07:10:13 +00:00
|
|
|
public $listing;
|
2008-06-25 08:09:25 +00:00
|
|
|
|
|
|
|
/**
|
2008-06-27 03:33:40 +00:00
|
|
|
* Take an array as a parameter, which contains necessary information
|
|
|
|
* of repository.
|
|
|
|
*
|
|
|
|
* @param string $parent The parent path, this parameter must
|
|
|
|
* not be the folder name, it may be a identification of folder
|
|
|
|
* @param string $search The text will be searched.
|
|
|
|
* @return array the list of files, including meta infomation
|
2008-06-25 08:09:25 +00:00
|
|
|
*/
|
2008-08-07 03:33:47 +00:00
|
|
|
public function __construct($repositoryid, $contextid = SITEID, $options = array()){
|
2008-06-27 03:33:40 +00:00
|
|
|
$this->repositoryid = $repositoryid;
|
2008-08-07 03:33:47 +00:00
|
|
|
$this->context = get_context_instance_by_id($contextid);
|
2008-06-27 03:33:40 +00:00
|
|
|
$this->options = array();
|
2008-06-27 05:48:24 +00:00
|
|
|
if (is_array($options)) {
|
|
|
|
foreach ($options as $n => $v) {
|
2008-06-27 03:33:40 +00:00
|
|
|
$this->options[$n] = $v;
|
|
|
|
}
|
|
|
|
}
|
2008-06-25 08:09:25 +00:00
|
|
|
}
|
|
|
|
|
2008-06-27 05:48:24 +00:00
|
|
|
public function __set($name, $value) {
|
2008-06-27 03:33:40 +00:00
|
|
|
$this->options[$name] = $value;
|
|
|
|
}
|
2008-06-25 08:09:25 +00:00
|
|
|
|
2008-06-27 05:48:24 +00:00
|
|
|
public function __get($name) {
|
2008-06-27 03:33:40 +00:00
|
|
|
if (array_key_exists($name, $this->options)){
|
|
|
|
return $this->options[$name];
|
|
|
|
}
|
|
|
|
trigger_error('Undefined property: '.$name, E_USER_NOTICE);
|
|
|
|
return null;
|
|
|
|
}
|
2008-06-25 08:09:25 +00:00
|
|
|
|
2008-06-27 05:48:24 +00:00
|
|
|
public function __isset($name) {
|
2008-06-27 03:33:40 +00:00
|
|
|
return isset($this->options[$name]);
|
2008-06-25 08:09:25 +00:00
|
|
|
}
|
|
|
|
|
2008-06-27 05:48:24 +00:00
|
|
|
public function __toString() {
|
2008-06-27 03:33:40 +00:00
|
|
|
return 'Repository class: '.__CLASS__;
|
|
|
|
}
|
2008-07-16 05:15:14 +00:00
|
|
|
/**
|
|
|
|
* Given a URL, get a file from there.
|
|
|
|
* @param string $url the url of file
|
|
|
|
* @param string $file save location
|
|
|
|
*/
|
2008-07-18 07:40:12 +00:00
|
|
|
public function get_file($url, $file = '') {
|
2008-07-16 05:15:14 +00:00
|
|
|
global $CFG;
|
2008-07-17 03:54:20 +00:00
|
|
|
if (!file_exists($CFG->dataroot.'/repository/download')) {
|
|
|
|
mkdir($CFG->dataroot.'/repository/download/', 0777, true);
|
|
|
|
}
|
|
|
|
if(is_dir($CFG->dataroot.'/repository/download')) {
|
|
|
|
$dir = $CFG->dataroot.'/repository/download/';
|
|
|
|
}
|
2008-07-18 07:44:14 +00:00
|
|
|
if(empty($file)) {
|
|
|
|
$file = uniqid('repo').'_'.time().'.tmp';
|
|
|
|
}
|
|
|
|
if(file_exists($dir.$file)){
|
|
|
|
$file = uniqid('m').$file;
|
2008-07-16 05:15:14 +00:00
|
|
|
}
|
2008-07-18 07:44:14 +00:00
|
|
|
$fp = fopen($dir.$file, 'w');
|
|
|
|
$c = new curl;
|
|
|
|
$c->download(array(
|
|
|
|
array('url'=>$url, 'file'=>$fp)
|
|
|
|
));
|
|
|
|
return $dir.$file;
|
2008-06-27 03:33:40 +00:00
|
|
|
}
|
2008-06-25 08:09:25 +00:00
|
|
|
|
|
|
|
/**
|
2008-06-27 03:33:40 +00:00
|
|
|
* Given a path, and perhaps a search, get a list of files.
|
|
|
|
*
|
|
|
|
* @param string $parent The parent path, this parameter can
|
|
|
|
* a folder name, or a identification of folder
|
|
|
|
* @param string $search The text will be searched.
|
|
|
|
* @return array the list of files, including meta infomation
|
2008-06-25 08:09:25 +00:00
|
|
|
*/
|
2008-06-27 03:33:40 +00:00
|
|
|
abstract public function get_listing($parent = '/', $search = '');
|
2008-06-25 08:09:25 +00:00
|
|
|
|
|
|
|
/**
|
2008-06-27 03:33:40 +00:00
|
|
|
* Print a list or return string
|
|
|
|
*
|
|
|
|
* @param string $list
|
|
|
|
* $list = array(
|
|
|
|
* array('name'=>'moodle.txt', 'size'=>12, 'path'=>'', 'date'=>''),
|
|
|
|
* array('name'=>'repository.txt', 'size'=>32, 'path'=>'', 'date'=>''),
|
|
|
|
* array('name'=>'forum.txt', 'size'=>82, 'path'=>'', 'date'=>''),
|
|
|
|
* );
|
|
|
|
*
|
|
|
|
* @param boolean $print if printing the listing directly
|
|
|
|
*
|
2008-06-25 08:09:25 +00:00
|
|
|
*/
|
2008-06-27 05:48:24 +00:00
|
|
|
public function print_listing($listing = array(), $print=true) {
|
2008-06-30 07:10:13 +00:00
|
|
|
if(empty($listing)){
|
|
|
|
$listing = $this->get_listing();
|
|
|
|
}
|
2008-06-27 05:48:24 +00:00
|
|
|
if (empty($listing)) {
|
|
|
|
$str = '';
|
|
|
|
} else {
|
|
|
|
$count = 0;
|
|
|
|
$str = '<table>';
|
|
|
|
foreach ($listing as $v){
|
|
|
|
$str .= '<tr id="entry_'.$count.'">';
|
|
|
|
$str .= '<td><input type="checkbox" /></td>';
|
|
|
|
$str .= '<td>'.$v['name'].'</td>';
|
|
|
|
$str .= '<td>'.$v['size'].'</td>';
|
|
|
|
$str .= '<td>'.$v['date'].'</td>';
|
|
|
|
$str .= '</tr>';
|
|
|
|
$count++;
|
|
|
|
}
|
2008-06-27 06:26:36 +00:00
|
|
|
$str .= '</table>';
|
2008-06-27 03:33:40 +00:00
|
|
|
}
|
2008-06-27 05:48:24 +00:00
|
|
|
if ($print){
|
2008-06-27 03:33:40 +00:00
|
|
|
echo $str;
|
|
|
|
return null;
|
|
|
|
} else {
|
|
|
|
return $str;
|
|
|
|
}
|
2008-06-25 08:09:25 +00:00
|
|
|
}
|
2008-07-14 05:31:01 +00:00
|
|
|
|
2008-06-27 03:33:40 +00:00
|
|
|
/**
|
|
|
|
* Show the login screen, if required
|
|
|
|
* This is an abstract function, it must be overriden.
|
|
|
|
* The specific plug-in need to specify authentication types in database
|
|
|
|
* options field
|
|
|
|
* Imagine following cases:
|
|
|
|
* 1. no need of authentication
|
|
|
|
* 2. Use username and password to authenticate
|
|
|
|
* 3. Redirect to authentication page, in this case, the repository
|
|
|
|
* will callback moodle with following common parameters:
|
|
|
|
* (1) boolean callback To tell moodle this is a callback
|
2008-07-14 05:31:01 +00:00
|
|
|
* (2) int id Specify repository ID
|
2008-06-27 03:33:40 +00:00
|
|
|
* The callback page need to use these parameters to init
|
|
|
|
* the repository plug-ins correctly. Also, auth_token or ticket may
|
|
|
|
* attach in the callback url, these must be taken into account too.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
abstract public function print_login();
|
2008-06-25 08:09:25 +00:00
|
|
|
|
2008-06-27 03:33:40 +00:00
|
|
|
/**
|
|
|
|
* Show the search screen, if required
|
|
|
|
*
|
|
|
|
* @return null
|
|
|
|
*/
|
|
|
|
abstract public function print_search();
|
2008-06-25 08:09:25 +00:00
|
|
|
|
|
|
|
/**
|
2008-06-27 03:33:40 +00:00
|
|
|
* Cache login details for repositories
|
|
|
|
*
|
|
|
|
* @param string $username
|
|
|
|
* @param string $password
|
|
|
|
* @param string $userid The id of specific user
|
|
|
|
* @return array the list of files, including meta infomation
|
2008-06-25 08:09:25 +00:00
|
|
|
*/
|
2008-08-07 03:33:47 +00:00
|
|
|
public function store_login($username = '', $password = '', $userid = 1) {
|
2008-06-27 05:48:24 +00:00
|
|
|
global $DB;
|
|
|
|
|
|
|
|
$repository = new stdclass;
|
2008-07-28 08:24:55 +00:00
|
|
|
if (!empty($this->repositoryid)) {
|
|
|
|
$repository->id = $this->repositoryid;
|
|
|
|
} else {
|
|
|
|
$repository->userid = $userid;
|
|
|
|
$repository->repositorytype = $this->type;
|
2008-08-07 03:33:47 +00:00
|
|
|
$repository->contextid = $this->context->id;
|
2008-07-28 08:24:55 +00:00
|
|
|
}
|
2008-06-27 05:48:24 +00:00
|
|
|
if ($entry = $DB->get_record('repository', $repository)) {
|
|
|
|
$repository->id = $entry->id;
|
|
|
|
$repository->username = $username;
|
|
|
|
$repository->password = $password;
|
|
|
|
return $DB->update_record('repository', $repository);
|
|
|
|
} else {
|
|
|
|
$repository->username = $username;
|
|
|
|
$repository->password = $password;
|
|
|
|
return $DB->insert_record('repository', $repository);
|
|
|
|
}
|
|
|
|
return false;
|
2008-06-25 08:09:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-06-27 03:33:40 +00:00
|
|
|
* Defines operations that happen occasionally on cron
|
|
|
|
*
|
2008-06-25 08:09:25 +00:00
|
|
|
*/
|
2008-06-27 05:48:24 +00:00
|
|
|
public function cron() {
|
2008-06-27 03:33:40 +00:00
|
|
|
return true;
|
2008-06-25 08:09:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-23 04:43:53 +00:00
|
|
|
/**
|
|
|
|
* exception class for repository api
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
class repository_exception extends moodle_exception {
|
|
|
|
}
|
2008-06-25 08:09:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Listing object describing a listing of files and directories
|
|
|
|
*/
|
|
|
|
|
|
|
|
abstract class repository_listing {
|
|
|
|
}
|
|
|
|
|
2008-06-30 05:24:00 +00:00
|
|
|
function repository_set_option($id, $position, $config = array()){
|
|
|
|
global $DB;
|
|
|
|
$repository = new stdclass;
|
|
|
|
$position = (int)$position;
|
|
|
|
$config = serialize($config);
|
|
|
|
if( $position < 1 || $position > 5){
|
|
|
|
print_error('invalidoption', 'repository', '', $position);
|
|
|
|
}
|
|
|
|
if ($entry = $DB->get_record('repository', array('id'=>$id))) {
|
|
|
|
$option = 'option'.$position;
|
|
|
|
$repository->id = $entry->id;
|
|
|
|
$repository->$option = $config;
|
|
|
|
return $DB->update_record('repository', $repository);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
function repository_get_option($id, $position){
|
|
|
|
global $DB;
|
|
|
|
$entry = $DB->get_record('repository', array('id'=>$id));
|
|
|
|
$option = 'option'.$position;
|
|
|
|
$ret = (array)unserialize($entry->$option);
|
|
|
|
return $ret;
|
|
|
|
}
|
2008-08-07 08:36:12 +00:00
|
|
|
|
|
|
|
function repository_user_instances($context){
|
2008-07-17 09:34:15 +00:00
|
|
|
global $DB, $CFG, $USER;
|
|
|
|
$params = array();
|
|
|
|
$sql = 'SELECT * FROM {repository} r WHERE ';
|
|
|
|
$sql .= ' (r.userid = 0 or r.userid = ?) ';
|
|
|
|
$params[] = $USER->id;
|
2008-08-07 03:33:47 +00:00
|
|
|
if($context->id == SITEID) {
|
2008-07-17 09:34:15 +00:00
|
|
|
$sql .= 'AND (r.contextid = ?)';
|
|
|
|
$params[] = SITEID;
|
|
|
|
} else {
|
|
|
|
$sql .= 'AND (r.contextid = ? or r.contextid = ?)';
|
|
|
|
$params[] = SITEID;
|
2008-08-07 03:33:47 +00:00
|
|
|
$params[] = $context->id;
|
2008-07-17 09:34:15 +00:00
|
|
|
}
|
|
|
|
if(!$repos = $DB->get_records_sql($sql, $params)) {
|
|
|
|
$repos = array();
|
|
|
|
}
|
|
|
|
return $repos;
|
|
|
|
}
|
2008-08-07 08:36:12 +00:00
|
|
|
|
2008-07-28 08:24:55 +00:00
|
|
|
function repository_instance($id){
|
|
|
|
global $DB, $CFG;
|
|
|
|
|
|
|
|
if (!$instance = $DB->get_record('repository', array('id' => $id))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
require_once($CFG->dirroot . '/repository/'. $instance->repositorytype
|
|
|
|
. '/repository.class.php');
|
|
|
|
$classname = 'repository_' . $instance->repositorytype;
|
|
|
|
return new $classname($instance->id, $instance->contextid);
|
|
|
|
}
|
2008-07-07 06:54:39 +00:00
|
|
|
function repository_get_plugins(){
|
|
|
|
global $CFG;
|
|
|
|
$repo = $CFG->dirroot.'/repository/';
|
|
|
|
$ret = array();
|
|
|
|
if($dir = opendir($repo)){
|
|
|
|
while (false !== ($file = readdir($dir))) {
|
2008-07-14 05:31:01 +00:00
|
|
|
if(is_dir($file) && $file != '.' && $file != '..'
|
2008-07-07 06:54:39 +00:00
|
|
|
&& file_exists($repo.$file.'/repository.class.php')){
|
|
|
|
require_once($repo.$file.'/version.php');
|
2008-07-14 05:31:01 +00:00
|
|
|
$ret[] = array('name'=>$plugin->name,
|
|
|
|
'version'=>$plugin->version,
|
2008-07-07 06:54:39 +00:00
|
|
|
'path'=>$repo.$file,
|
2008-07-14 05:31:01 +00:00
|
|
|
'settings'=>file_exists($repo.$file.'/settings.php'));
|
2008-07-07 06:54:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $ret;
|
|
|
|
}
|
2008-08-04 05:53:53 +00:00
|
|
|
|
2008-08-05 05:12:30 +00:00
|
|
|
function move_to_filepool($path, $name, $itemid) {
|
2008-08-04 05:53:53 +00:00
|
|
|
global $DB, $CFG, $USER;
|
|
|
|
$context = get_context_instance(CONTEXT_USER, $USER->id);
|
|
|
|
$entry = new object();
|
|
|
|
$entry->filearea = 'user_draft';
|
|
|
|
$entry->contextid = $context->id;
|
|
|
|
$entry->filename = $name;
|
|
|
|
$entry->filepath = '/';
|
|
|
|
$entry->timecreated = time();
|
|
|
|
$entry->timemodified = time();
|
2008-08-05 05:12:30 +00:00
|
|
|
if(is_numeric($itemid)) {
|
|
|
|
$entry->itemid = $itemid;
|
|
|
|
} else {
|
|
|
|
$entry->itemid = 0;
|
|
|
|
}
|
2008-08-04 05:53:53 +00:00
|
|
|
$entry->mimetype = mimeinfo('type', $path);
|
|
|
|
$entry->userid = $USER->id;
|
|
|
|
$fs = get_file_storage();
|
|
|
|
$browser = get_file_browser();
|
|
|
|
if ($file = $fs->create_file_from_pathname($entry, $path)) {
|
|
|
|
$id = json_encode($file->get_itemid());
|
|
|
|
$ret = $browser->get_file_info($context, $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $file->get_filename());
|
2008-08-05 05:12:30 +00:00
|
|
|
return array('url'=>$ret->get_url(),'id'=>$file->get_itemid());
|
2008-08-04 05:53:53 +00:00
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-06 08:09:01 +00:00
|
|
|
// TODO
|
|
|
|
// Need to pass contextid and contextlevel here
|
2008-08-07 03:33:47 +00:00
|
|
|
function get_repository_client($context){
|
2008-08-06 08:09:01 +00:00
|
|
|
global $CFG, $USER;
|
2008-08-05 05:12:30 +00:00
|
|
|
$suffix = uniqid();
|
2008-07-31 02:51:28 +00:00
|
|
|
$strsubmit = get_string('submit', 'repository');
|
|
|
|
$strlistview = get_string('listview', 'repository');
|
|
|
|
$strthumbview = get_string('thumbview', 'repository');
|
|
|
|
$strsearch = get_string('search', 'repository');
|
|
|
|
$strlogout = get_string('logout', 'repository');
|
|
|
|
$strloading = get_string('loading', 'repository');
|
|
|
|
$strtitle = get_string('title', 'repository');
|
|
|
|
$filename = get_string('filename', 'repository');
|
|
|
|
$strsync = get_string('sync', 'repository');
|
|
|
|
$strdownload = get_string('download', 'repository');
|
|
|
|
$strback = get_string('back', 'repository');
|
|
|
|
$strclose = get_string('close', 'repository');
|
|
|
|
|
|
|
|
$js = <<<EOD
|
|
|
|
<style type="text/css">
|
2008-08-05 05:49:33 +00:00
|
|
|
#list-$suffix{line-height: 1.5em}
|
|
|
|
#list-$suffix a{ padding: 3px }
|
|
|
|
#list-$suffix li a:hover{ background: gray; color:white; }
|
|
|
|
#paging-$suffix{margin:10px 5px; clear:both}
|
|
|
|
#paging-$suffix a{padding: 4px; border: 1px solid gray}
|
|
|
|
#panel-$suffix{padding:0;margin:0; text-align:left;}
|
2008-07-31 02:51:28 +00:00
|
|
|
.file_name{color:green;}
|
|
|
|
.file_date{color:blue}
|
|
|
|
.file_size{color:gray}
|
|
|
|
.grid{width:80px; float:left;text-align:center;}
|
|
|
|
.grid div{width: 80px; height: 36px; overflow: hidden}
|
|
|
|
.repo-opt{font-size: 10px;color:red}
|
|
|
|
</style>
|
|
|
|
<style type="text/css">
|
|
|
|
@import "$CFG->wwwroot/lib/yui/reset-fonts-grids/reset-fonts-grids.css";
|
|
|
|
@import "$CFG->wwwroot/lib/yui/reset/reset-min.css";
|
|
|
|
@import "$CFG->wwwroot/lib/yui/resize/assets/skins/sam/resize.css";
|
|
|
|
@import "$CFG->wwwroot/lib/yui/container/assets/skins/sam/container.css";
|
|
|
|
@import "$CFG->wwwroot/lib/yui/layout/assets/skins/sam/layout.css";
|
|
|
|
@import "$CFG->wwwroot/lib/yui/button/assets/skins/sam/button.css";
|
|
|
|
</style>
|
2008-08-01 04:23:54 +00:00
|
|
|
<script type="text/javascript" src="$CFG->wwwroot/lib/yui/yahoo-dom-event/yahoo-dom-event.js"></script>
|
|
|
|
<script type="text/javascript" src="$CFG->wwwroot/lib/yui/element/element-beta-min.js"></script>
|
|
|
|
<script type="text/javascript" src="$CFG->wwwroot/lib/yui/dragdrop/dragdrop-min.js"></script>
|
|
|
|
<script type="text/javascript" src="$CFG->wwwroot/lib/yui/container/container-min.js"></script>
|
|
|
|
<script type="text/javascript" src="$CFG->wwwroot/lib/yui/resize/resize-beta-min.js"></script>
|
|
|
|
<script type="text/javascript" src="$CFG->wwwroot/lib/yui/layout/layout-beta-min.js"></script>
|
|
|
|
<script type="text/javascript" src="$CFG->wwwroot/lib/yui/connection/connection-min.js"></script>
|
|
|
|
<script type="text/javascript" src="$CFG->wwwroot/lib/yui/json/json-min.js"></script>
|
|
|
|
<script type="text/javascript" src="$CFG->wwwroot/lib/yui/button/button-min.js"></script>
|
|
|
|
<script type="text/javascript" src="$CFG->wwwroot/lib/yui/selector/selector-beta-min.js"></script>
|
2008-07-31 02:51:28 +00:00
|
|
|
<script>
|
2008-08-05 05:12:30 +00:00
|
|
|
var repository_client_$suffix = (function() {
|
2008-07-31 02:51:28 +00:00
|
|
|
// private static field
|
|
|
|
var dver = '1.0';
|
|
|
|
// private static methods
|
|
|
|
function alert_version(){
|
|
|
|
alert(dver);
|
|
|
|
}
|
|
|
|
function _client(){
|
|
|
|
// public varible
|
2008-08-05 05:12:30 +00:00
|
|
|
this.name = 'repository_client_$suffix';
|
2008-07-31 02:51:28 +00:00
|
|
|
// private varible
|
|
|
|
var Dom = YAHOO.util.Dom, Event = YAHOO.util.Event, layout = null, resize = null;
|
|
|
|
var IE_QUIRKS = (YAHOO.env.ua.ie && document.compatMode == "BackCompat");
|
|
|
|
var IE_SYNC = (YAHOO.env.ua.ie == 6 || (YAHOO.env.ua.ie == 7 && IE_QUIRKS));
|
|
|
|
var PANEL_BODY_PADDING = (10*2);
|
|
|
|
var btn_list = {label: '$strlistview', value: 'l', checked: true, onclick: {fn: _client.viewlist}};
|
|
|
|
var btn_thumb = {label: '$strthumbview', value: 't', onclick: {fn: _client.viewthumb}};
|
|
|
|
var select = new YAHOO.util.Element('select');
|
|
|
|
var list = null;
|
|
|
|
var resize = null;
|
2008-08-05 05:12:30 +00:00
|
|
|
var panel = new YAHOO.widget.Panel('file-picker-$suffix', {
|
2008-07-31 02:51:28 +00:00
|
|
|
draggable: true,
|
|
|
|
close: true,
|
|
|
|
underlay: 'none',
|
|
|
|
width: '510px',
|
2008-08-01 03:35:09 +00:00
|
|
|
zindex: 666666,
|
2008-07-31 02:51:28 +00:00
|
|
|
xy: [100, 100]
|
|
|
|
});
|
|
|
|
// construct code section
|
|
|
|
{
|
|
|
|
panel.setHeader('$strtitle');
|
2008-08-05 05:49:33 +00:00
|
|
|
panel.setBody('<div id="layout-$suffix"></div>');
|
2008-07-31 02:51:28 +00:00
|
|
|
panel.beforeRenderEvent.subscribe(function() {
|
2008-08-05 05:49:33 +00:00
|
|
|
Event.onAvailable('layout-$suffix', function() {
|
|
|
|
layout = new YAHOO.widget.Layout('layout-$suffix', {
|
2008-07-31 02:51:28 +00:00
|
|
|
height: 400, width: 490,
|
|
|
|
units: [
|
|
|
|
{position: 'top', height: 32, resize: false,
|
2008-08-05 05:49:33 +00:00
|
|
|
body:'<div class="yui-buttongroup" id="repo-viewbar-$suffix"></div>', gutter: '2'},
|
2008-07-31 02:51:28 +00:00
|
|
|
{position: 'left', width: 150, resize: true,
|
2008-08-05 05:49:33 +00:00
|
|
|
body:'<ul id="repo-list-$suffix"></ul>', gutter: '0 5 0 2', minWidth: 150, maxWidth: 300 },
|
|
|
|
{position: 'center', body: '<div id="panel-$suffix"></div>',
|
2008-07-31 02:51:28 +00:00
|
|
|
scroll: true, gutter: '0 2 0 0' }
|
|
|
|
]
|
|
|
|
});
|
|
|
|
layout.render();
|
|
|
|
});
|
|
|
|
});
|
2008-08-05 05:12:30 +00:00
|
|
|
resize = new YAHOO.util.Resize('file-picker-$suffix', {
|
2008-07-31 02:51:28 +00:00
|
|
|
handles: ['br'],
|
|
|
|
autoRatio: true,
|
|
|
|
status: true,
|
|
|
|
minWidth: 380,
|
|
|
|
minHeight: 400
|
|
|
|
});
|
|
|
|
resize.on('resize', function(args) {
|
|
|
|
var panelHeight = args.height;
|
|
|
|
var headerHeight = this.header.offsetHeight; // Content + Padding + Border
|
|
|
|
var bodyHeight = (panelHeight - headerHeight);
|
|
|
|
var bodyContentHeight = (IE_QUIRKS) ? bodyHeight : bodyHeight - PANEL_BODY_PADDING;
|
|
|
|
YAHOO.util.Dom.setStyle(this.body, 'height', bodyContentHeight + 'px');
|
|
|
|
if (IE_SYNC) {
|
|
|
|
this.sizeUnderlay();
|
|
|
|
this.syncIframe();
|
|
|
|
}
|
|
|
|
layout.set('height', bodyContentHeight);
|
|
|
|
layout.set('width', (args.width - PANEL_BODY_PADDING));
|
|
|
|
layout.resize();
|
|
|
|
|
|
|
|
}, panel, true);
|
|
|
|
_client.viewbar = new YAHOO.widget.ButtonGroup({
|
2008-08-05 05:49:33 +00:00
|
|
|
id: 'btngroup-$suffix',
|
2008-07-31 02:51:28 +00:00
|
|
|
name: 'buttons',
|
|
|
|
disabled: true,
|
2008-08-05 05:49:33 +00:00
|
|
|
container: 'repo-viewbar-$suffix'
|
2008-07-31 02:51:28 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
// public method
|
|
|
|
this.show = function(){
|
|
|
|
panel.show();
|
|
|
|
}
|
2008-08-06 03:26:57 +00:00
|
|
|
this.hide = function(){
|
|
|
|
panel.hide();
|
|
|
|
}
|
2008-07-31 02:51:28 +00:00
|
|
|
this.create_picker = function(){
|
|
|
|
// display UI
|
|
|
|
panel.render();
|
|
|
|
_client.viewbar.addButtons([btn_list, btn_thumb]);
|
|
|
|
// init repository list
|
2008-08-05 05:49:33 +00:00
|
|
|
list = new YAHOO.util.Element('repo-list-$suffix');
|
2008-07-31 02:51:28 +00:00
|
|
|
list.on('contentReady', function(e){
|
|
|
|
for(var i=0; i<_client.repos.length; i++) {
|
|
|
|
var repo = _client.repos[i];
|
|
|
|
li = document.createElement('ul');
|
2008-08-05 05:49:33 +00:00
|
|
|
li.innerHTML = '<a href="###" id="repo-call-$suffix-'+repo.id+'">'+
|
2008-07-31 02:51:28 +00:00
|
|
|
repo.repositoryname+'</a><br/>';
|
2008-08-05 05:12:30 +00:00
|
|
|
li.innerHTML += '<a href="###" class="repo-opt" onclick="repository_client_$suffix.search('+repo.id+')">$strsearch</a>';
|
2008-08-05 05:49:33 +00:00
|
|
|
li.innerHTML += '<a href="###" class="repo-opt" id="repo-logout-$suffix-'+repo.id+'">$strlogout</a>';
|
|
|
|
li.id = 'repo-$suffix-'+repo.id;
|
2008-07-31 02:51:28 +00:00
|
|
|
this.appendChild(li);
|
2008-08-05 05:49:33 +00:00
|
|
|
var e = new YAHOO.util.Element('repo-call-$suffix-'+repo.id);
|
2008-07-31 02:51:28 +00:00
|
|
|
e.on('click', function(e){
|
2008-08-05 05:49:33 +00:00
|
|
|
var re = /repo-call-$suffix-(\d+)/i;
|
2008-07-31 02:51:28 +00:00
|
|
|
var id = this.get('id').match(re);
|
2008-08-05 05:12:30 +00:00
|
|
|
repository_client_$suffix.req(id[1], 1, 0);
|
2008-07-31 02:51:28 +00:00
|
|
|
});
|
2008-08-05 05:49:33 +00:00
|
|
|
e = new YAHOO.util.Element('repo-logout-$suffix-'+repo.id);
|
2008-07-31 02:51:28 +00:00
|
|
|
e.on('click', function(e){
|
2008-08-05 05:49:33 +00:00
|
|
|
var re = /repo-logout-$suffix-(\d+)/i;
|
2008-07-31 02:51:28 +00:00
|
|
|
var id = this.get('id').match(re);
|
2008-08-05 05:12:30 +00:00
|
|
|
repository_client_$suffix.req(id[1], 1, 1);
|
2008-07-31 02:51:28 +00:00
|
|
|
});
|
|
|
|
repo = null;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// public static varible
|
|
|
|
_client.repos = [];
|
|
|
|
_client.repositoryid = 0;
|
|
|
|
_client.datasource,
|
|
|
|
_client.viewmode = 0;
|
|
|
|
_client.viewbar =null;
|
|
|
|
// public static mehtod
|
|
|
|
_client.postdata = function(obj) {
|
|
|
|
var str = '';
|
|
|
|
for(k in obj) {
|
|
|
|
if(obj[k] instanceof Array) {
|
|
|
|
for(i in obj[k]) {
|
|
|
|
str += (encodeURIComponent(k) +'[]='+encodeURIComponent(obj[k][i]));
|
|
|
|
str += '&';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
str += encodeURIComponent(k) +'='+encodeURIComponent(obj[k]);
|
|
|
|
str += '&';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
_client.loading = function(){
|
2008-08-05 05:49:33 +00:00
|
|
|
var panel = new YAHOO.util.Element('panel-$suffix');
|
2008-07-31 02:51:28 +00:00
|
|
|
panel.get('element').innerHTML = '<span>$strloading</span>';
|
|
|
|
}
|
|
|
|
_client.rename = function(oldname, url){
|
2008-08-05 05:49:33 +00:00
|
|
|
var panel = new YAHOO.util.Element('panel-$suffix');
|
2008-07-31 02:51:28 +00:00
|
|
|
var html = '<div>';
|
|
|
|
html += '<label for="newname">$filename</label>';
|
2008-08-05 05:49:33 +00:00
|
|
|
html += '<input type="text" id="newname-$suffix" value="'+oldname+'" /><br/>';
|
2008-07-31 02:51:28 +00:00
|
|
|
html += '<label for="syncfile">$strsync</label>';
|
2008-08-05 05:49:33 +00:00
|
|
|
html += '<input type="checkbox" id="syncfile-$suffix" /><br/>';
|
|
|
|
html += '<input type="hidden" id="fileurl-$suffix" value="'+url+'" />';
|
2008-08-05 05:12:30 +00:00
|
|
|
html += '<input type="button" onclick="repository_client_$suffix.download()" value="$strdownload" />';
|
|
|
|
html += '<a href="###" onclick="repository_client_$suffix.viewfiles()">$strback</a>';
|
2008-07-31 02:51:28 +00:00
|
|
|
html += '</div>';
|
|
|
|
panel.get('element').innerHTML = html;
|
|
|
|
}
|
|
|
|
_client.print_login = function(){
|
2008-08-05 05:49:33 +00:00
|
|
|
var panel = new YAHOO.util.Element('panel-$suffix');
|
2008-07-31 02:51:28 +00:00
|
|
|
var data = _client.datasource.l;
|
|
|
|
var str = '';
|
|
|
|
for(var k in data){
|
|
|
|
str += '<p>';
|
|
|
|
var lable_id = '';
|
|
|
|
var field_id = '';
|
|
|
|
var field_value = '';
|
|
|
|
if(data[k].id){
|
|
|
|
lable_id = ' for="'+data[k].id+'"';
|
|
|
|
field_id = ' id="'+data[k].id+'"';
|
|
|
|
}
|
|
|
|
if (data[k].label) {
|
|
|
|
str += '<label'+lable_id+'>'+data[k].label+'</label>';
|
|
|
|
}
|
|
|
|
if(data[k].value){
|
|
|
|
field_value = ' value="'+data[k].value+'"';
|
|
|
|
}
|
|
|
|
str += '<input type="'+data[k].type+'"'+' name="'+data[k].name+'"'+field_id+field_value+' />';
|
|
|
|
str += '</p>';
|
|
|
|
}
|
2008-08-05 05:12:30 +00:00
|
|
|
str += '<p><input type="button" onclick="repository_client_$suffix.login()" value="$strsubmit" /></p>';
|
2008-07-31 02:51:28 +00:00
|
|
|
panel.get('element').innerHTML = str;
|
|
|
|
}
|
|
|
|
|
|
|
|
_client.viewfiles = function(){
|
|
|
|
if(_client.viewmode) {
|
|
|
|
_client.viewthumb();
|
|
|
|
} else {
|
|
|
|
_client.viewlist();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_client.viewthumb = function(){
|
2008-08-05 05:49:33 +00:00
|
|
|
var panel = new YAHOO.util.Element('panel-$suffix');
|
2008-07-31 02:51:28 +00:00
|
|
|
_client.viewbar.check(1);
|
|
|
|
obj = _client.datasource.list;
|
|
|
|
var str = '';
|
|
|
|
str += _client.makepage();
|
|
|
|
for(k in obj){
|
|
|
|
str += '<div class="grid">';
|
|
|
|
str += '<img title="'+obj[k].title+'" src="'+obj[k].thumbnail+'" />';
|
|
|
|
str += '<div style="text-align:center">';
|
|
|
|
str += ('<input type="radio" title="'+obj[k].title
|
|
|
|
+'" name="selected-files" value="'+obj[k].source
|
2008-08-05 05:12:30 +00:00
|
|
|
+'" onclick=\'repository_client_$suffix.rename("'+obj[k].title+'", "'
|
2008-07-31 02:51:28 +00:00
|
|
|
+obj[k].source+'")\' />');
|
|
|
|
str += obj[k].title+'</div>';
|
|
|
|
str += '</div>';
|
|
|
|
}
|
|
|
|
panel.get('element').innerHTML = str;
|
|
|
|
_client.viewmode = 1;
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
_client.viewlist = function(){
|
2008-08-05 05:49:33 +00:00
|
|
|
var panel = new YAHOO.util.Element('panel-$suffix');
|
2008-07-31 02:51:28 +00:00
|
|
|
var str = '';
|
|
|
|
_client.viewbar.check(0);
|
|
|
|
obj = _client.datasource.list;
|
|
|
|
str += _client.makepage();
|
|
|
|
var re = new RegExp();
|
|
|
|
re.compile("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$");
|
|
|
|
for(k in obj){
|
2008-08-05 05:12:30 +00:00
|
|
|
str += ('<input type="radio" title="'+obj[k].title+'" name="selected-files" value="'+obj[k].source+'" onclick=\'repository_client_$suffix.rename("'+obj[k].title+'", "'+obj[k].source+'")\' /> ');
|
2008-07-31 02:51:28 +00:00
|
|
|
if(re.test(obj[k].source)) {
|
|
|
|
str += '<a class="file_name" href="'+obj[k].source+'">'+obj[k].title+'</a>';
|
|
|
|
} else {
|
|
|
|
str += '<span class="file_name" >'+obj[k].title+'</span>';
|
|
|
|
}
|
|
|
|
str += '<br/>';
|
|
|
|
str += '<label>Date: </label><span class="file_date">'+obj[k].date+'</span><br/>';
|
|
|
|
str += '<label>Size: </label><span class="file_size">'+obj[k].size+'</span>';
|
|
|
|
str += '<br/>';
|
|
|
|
}
|
|
|
|
panel.get('element').innerHTML = str;
|
|
|
|
_client.viewmode = 0;
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
// XXX: An ugly hack to show paging for flickr
|
|
|
|
_client.makepage = function(){
|
|
|
|
var str = '';
|
|
|
|
if(_client.datasource.pages){
|
2008-08-05 05:49:33 +00:00
|
|
|
str += '<div id="paging-$suffix">';
|
2008-07-31 02:51:28 +00:00
|
|
|
for(var i = 1; i <= _client.datasource.pages; i++) {
|
2008-08-05 05:12:30 +00:00
|
|
|
str += '<a onclick="repository_client_$suffix.req('+_client.repositoryid+', '+i+', 0)" href="###">';
|
2008-07-31 02:51:28 +00:00
|
|
|
str += String(i);
|
|
|
|
str += '</a> ';
|
|
|
|
}
|
|
|
|
str += '</div>';
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
_client.download = function(){
|
2008-08-05 05:49:33 +00:00
|
|
|
var title = document.getElementById('newname-$suffix').value;
|
|
|
|
var file = document.getElementById('fileurl-$suffix').value;
|
2008-08-05 08:12:21 +00:00
|
|
|
var itemid = 1;
|
2008-08-05 05:12:30 +00:00
|
|
|
if(_client.itemid){
|
|
|
|
itemid = _client.itemid;
|
|
|
|
}
|
2008-07-31 02:51:28 +00:00
|
|
|
_client.loading();
|
|
|
|
var trans = YAHOO.util.Connect.asyncRequest('POST',
|
2008-08-07 03:33:47 +00:00
|
|
|
'$CFG->wwwroot/repository/ws.php?ctx_id=$context->id&repo_id='+_client.repositoryid+
|
2008-08-05 05:12:30 +00:00
|
|
|
'&action=download',
|
|
|
|
_client.dlfile, _client.postdata({'itemid': itemid, 'env':_client.env, 'file':file, 'title':title}));
|
2008-07-31 02:51:28 +00:00
|
|
|
}
|
|
|
|
_client.login = function(){
|
|
|
|
var obj = {};
|
|
|
|
var data = _client.datasource.l;
|
|
|
|
for (var k in data) {
|
|
|
|
var el = document.getElementsByName(data[k].name)[0];
|
|
|
|
obj[data[k].name] = '';
|
|
|
|
if(el.type == 'checkbox') {
|
|
|
|
obj[data[k].name] = el.checked;
|
|
|
|
} else {
|
|
|
|
obj[data[k].name] = el.value;
|
|
|
|
}
|
|
|
|
}
|
2008-08-01 04:10:31 +00:00
|
|
|
obj['env'] = _client.env;
|
2008-08-07 03:33:47 +00:00
|
|
|
obj['ctx_id'] = $context->id;
|
2008-07-31 02:51:28 +00:00
|
|
|
_client.loading();
|
|
|
|
var trans = YAHOO.util.Connect.asyncRequest('POST',
|
|
|
|
'$CFG->wwwroot/repository/ws.php', _client.callback,
|
|
|
|
_client.postdata(obj));
|
|
|
|
}
|
2008-08-04 05:53:53 +00:00
|
|
|
_client.end = function(str){
|
|
|
|
_client.target.value = str;
|
2008-08-05 05:12:30 +00:00
|
|
|
_client.formcallback();
|
2008-08-06 03:26:57 +00:00
|
|
|
_client.instance.hide();
|
2008-08-04 05:53:53 +00:00
|
|
|
_client.viewfiles();
|
|
|
|
}
|
2008-07-31 02:51:28 +00:00
|
|
|
_client.callback = {
|
|
|
|
success: function(o) {
|
2008-08-05 05:49:33 +00:00
|
|
|
var panel = new YAHOO.util.Element('panel-$suffix');
|
2008-07-31 02:51:28 +00:00
|
|
|
try {
|
|
|
|
var ret = YAHOO.lang.JSON.parse(o.responseText);
|
|
|
|
} catch(e) {
|
|
|
|
alert('Callback: Invalid JSON String'+o.responseText);
|
|
|
|
};
|
|
|
|
if(ret.e){
|
|
|
|
panel.get('element').innerHTML = ret.e;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_client.datasource = ret;
|
|
|
|
if(_client.datasource.l){
|
|
|
|
_client.print_login();
|
|
|
|
} else if(_client.datasource.list) {
|
|
|
|
if(_client.viewmode) {
|
|
|
|
_client.viewthumb();
|
|
|
|
} else {
|
|
|
|
_client.viewlist();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_client.dlfile = {
|
|
|
|
success: function(o) {
|
2008-08-05 05:49:33 +00:00
|
|
|
var panel = new YAHOO.util.Element('panel-$suffix');
|
2008-07-31 02:51:28 +00:00
|
|
|
try {
|
|
|
|
var ret = YAHOO.lang.JSON.parse(o.responseText);
|
|
|
|
} catch(e) {
|
|
|
|
alert('Invalid JSON String'+o.responseText);
|
|
|
|
}
|
|
|
|
if(ret.e){
|
|
|
|
panel.get('element').innerHTML = ret.e;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var html = '<h1>Download Successfully!</h1>';
|
2008-08-05 05:12:30 +00:00
|
|
|
html += '<button onclick="repository_client_$suffix.end(\''+ret+'\')">Add!</button>';
|
2008-07-31 02:51:28 +00:00
|
|
|
panel.get('element').innerHTML = html;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// request file list or login
|
|
|
|
_client.req = function(id, path, reset) {
|
|
|
|
_client.viewbar.set('disabled', false);
|
|
|
|
_client.loading();
|
|
|
|
_client.repositoryid = id;
|
2008-08-07 03:33:47 +00:00
|
|
|
var trans = YAHOO.util.Connect.asyncRequest('GET', '$CFG->wwwroot/repository/ws.php?ctx_id=$context->id&repo_id='+id+'&p='+path+'&reset='+reset+'&env='+_client.env, _client.callback);
|
2008-07-31 02:51:28 +00:00
|
|
|
}
|
|
|
|
_client.search = function(id){
|
|
|
|
var data = window.prompt("What are you searching for?");
|
|
|
|
if(data == null || data == '') {
|
|
|
|
alert('nothing entered');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_client.viewbar.set('disabled', false);
|
|
|
|
_client.loading();
|
2008-08-07 03:33:47 +00:00
|
|
|
var trans = YAHOO.util.Connect.asyncRequest('GET', '$CFG->wwwroot/repository/ws.php?ctx_id=$context->id&repo_id='+id+'&s='+data+'&env='+_client.env, _client.callback);
|
2008-07-31 02:51:28 +00:00
|
|
|
}
|
|
|
|
return _client;
|
|
|
|
})();
|
|
|
|
EOD;
|
|
|
|
|
2008-08-07 08:36:12 +00:00
|
|
|
$repos = repository_user_instances($context);
|
2008-07-31 02:51:28 +00:00
|
|
|
foreach($repos as $repo) {
|
2008-08-05 05:49:33 +00:00
|
|
|
$js .= "\r\n";
|
2008-08-05 05:12:30 +00:00
|
|
|
$js .= 'repository_client_'.$suffix.'.repos.push('.json_encode($repo).');'."\n";
|
2008-07-31 02:51:28 +00:00
|
|
|
}
|
2008-08-05 05:49:33 +00:00
|
|
|
$js .= "\r\n";
|
2008-07-31 02:51:28 +00:00
|
|
|
|
|
|
|
$js .= <<<EOD
|
2008-08-05 05:12:30 +00:00
|
|
|
function openpicker_$suffix(obj) {
|
|
|
|
if(!repository_client_$suffix.instance) {
|
|
|
|
repository_client_$suffix.env = obj.env;
|
|
|
|
repository_client_$suffix.target = obj.target;
|
|
|
|
repository_client_$suffix.instance = new repository_client_$suffix();
|
|
|
|
repository_client_$suffix.instance.create_picker();
|
|
|
|
if(obj.itemid){
|
|
|
|
repository_client_$suffix.itemid = obj.itemid;
|
|
|
|
}
|
|
|
|
if(obj.callback){
|
|
|
|
repository_client_$suffix.formcallback = obj.callback;
|
|
|
|
} else {
|
|
|
|
repository_client_$suffix.formcallback = function(){};
|
|
|
|
}
|
2008-07-31 02:51:28 +00:00
|
|
|
} else {
|
2008-08-05 05:12:30 +00:00
|
|
|
repository_client_$suffix.instance.show();
|
2008-07-31 02:51:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
EOD;
|
|
|
|
$html = <<<EOD
|
|
|
|
<div class='yui-skin-sam'>
|
2008-08-05 05:12:30 +00:00
|
|
|
<div id="file-picker-$suffix"></div>
|
2008-07-31 02:51:28 +00:00
|
|
|
</div>
|
|
|
|
EOD;
|
2008-08-05 05:12:30 +00:00
|
|
|
return array('html'=>$html, 'js'=>$js, 'suffix'=>$suffix);
|
2008-07-31 02:51:28 +00:00
|
|
|
}
|