2010-12-07 20:19:27 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class PluploadController extends Zend_Controller_Action
|
|
|
|
{
|
|
|
|
|
|
|
|
public function init()
|
|
|
|
{
|
2012-03-14 16:14:22 +01:00
|
|
|
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
|
|
|
$ajaxContext->addActionContext('upload', 'json')
|
|
|
|
->addActionContext('copyfile', 'json')
|
|
|
|
->initContext();
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
|
2011-03-06 22:45:11 +01:00
|
|
|
public function indexAction()
|
|
|
|
{
|
2013-01-14 22:16:14 +01:00
|
|
|
$CC_CONFIG = Config::getConfig();
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2012-10-19 17:09:34 +02:00
|
|
|
$baseUrl = Application_Common_OsPath::getBaseDir();
|
2012-11-22 20:37:54 +01:00
|
|
|
$locale = Application_Model_Preference::GetLocale();
|
2011-04-18 17:02:09 +02:00
|
|
|
|
2013-01-14 22:00:38 +01:00
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/plupload/plupload.full.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/plupload/jquery.plupload.queue.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/airtime/library/plupload.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/plupload/i18n/'.$locale.'.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
2011-04-18 17:02:09 +02:00
|
|
|
|
2013-01-14 22:00:38 +01:00
|
|
|
$this->view->headLink()->appendStylesheet($baseUrl.'css/plupload.queue.css?'.$CC_CONFIG['airtime_version']);
|
2011-03-06 22:45:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function uploadAction()
|
|
|
|
{
|
|
|
|
$upload_dir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
|
2011-11-23 20:12:14 +01:00
|
|
|
$tempFilePath = Application_Model_StoredFile::uploadFile($upload_dir);
|
|
|
|
$tempFileName = basename($tempFilePath);
|
2011-03-18 22:15:12 +01:00
|
|
|
|
2013-01-31 20:06:45 +01:00
|
|
|
$this->_helper->json->sendJson(array("jsonrpc" => "2.0", "tempfilepath" => $tempFileName));
|
2011-03-06 22:45:11 +01:00
|
|
|
}
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public function copyfileAction()
|
|
|
|
{
|
2011-07-29 22:45:13 +02:00
|
|
|
$upload_dir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
|
|
|
|
$filename = $this->_getParam('name');
|
2011-11-23 20:12:14 +01:00
|
|
|
$tempname = $this->_getParam('tempname');
|
2012-08-27 23:58:09 +02:00
|
|
|
$result = Application_Model_StoredFile::copyFileToStor($upload_dir,
|
|
|
|
$filename, $tempname);
|
2012-03-27 01:00:40 +02:00
|
|
|
if (!is_null($result))
|
2013-02-07 21:41:47 +01:00
|
|
|
$this->_helper->json->sendJson(array("jsonrpc" => "2.0", "error" => $result));
|
2012-03-14 16:14:22 +01:00
|
|
|
|
2013-02-07 21:41:47 +01:00
|
|
|
$this->_helper->json->sendJson(array("jsonrpc" => "2.0"));
|
2011-07-29 22:45:13 +02:00
|
|
|
}
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|