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');
|
2014-03-13 16:14:30 +01:00
|
|
|
$ajaxContext->addActionContext('upload', 'json')
|
2014-03-21 18:22:00 +01:00
|
|
|
->addActionContext('recent-uploads', 'json')
|
2012-03-14 16:14:22 +01:00
|
|
|
->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
|
|
|
|
2014-03-21 18:22:00 +01:00
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
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']);
|
2014-03-21 18:22:00 +01:00
|
|
|
$this->view->headLink()->appendStylesheet($baseUrl.'css/addmedia.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
|
|
|
}
|
2014-03-21 18:22:00 +01:00
|
|
|
|
|
|
|
public function recentUploadsAction()
|
2014-03-10 21:32:23 +01:00
|
|
|
{
|
2014-03-21 18:22:00 +01:00
|
|
|
//$this->dis
|
|
|
|
//( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
|
|
|
|
$limit = isset($_GET['iDisplayLength']) ? $_GET['iDisplayLength'] : 10;
|
|
|
|
$rowStart = isset($_GET['iDisplayStart']) ? $_GET['iDisplayStart'] : 0;
|
2014-03-10 21:32:23 +01:00
|
|
|
|
2014-03-21 18:22:00 +01:00
|
|
|
$recentUploads = CcFilesQuery::create()->filterByDbUtime(array('min' => time() - 30 * 24 * 60 * 60))
|
|
|
|
->orderByDbUtime(Criteria::DESC)
|
|
|
|
->offset($rowStart)
|
|
|
|
->limit($limit)
|
|
|
|
->find();
|
|
|
|
|
|
|
|
$numRecentUploads = $limit;
|
|
|
|
|
|
|
|
$numTotalRecentUploads = CcFilesQuery::create()->filterByDbUtime(array('min' => time() - 30 * 24 * 60 * 60))
|
|
|
|
->count();
|
|
|
|
|
|
|
|
//$this->_helper->json->sendJson(array("jsonrpc" => "2.0", "tempfilepath" => $tempFileName));
|
|
|
|
|
|
|
|
$uploadsArray = array();
|
|
|
|
|
|
|
|
foreach ($recentUploads as $upload)
|
|
|
|
{
|
|
|
|
$upload->toArray(BasePeer::TYPE_FIELDNAME);
|
|
|
|
//array_push($uploadsArray, $upload); //TODO: $this->sanitizeResponse($upload));
|
|
|
|
|
|
|
|
//$this->_helper->json->sendJson($upload->asJson());
|
|
|
|
array_push($uploadsArray, $upload->toArray(BasePeer::TYPE_FIELDNAME));
|
|
|
|
}
|
2014-03-10 21:32:23 +01:00
|
|
|
|
2012-03-14 16:14:22 +01:00
|
|
|
|
2014-03-21 18:22:00 +01:00
|
|
|
$this->view->sEcho = intval($this->getRequest()->getParam('sEcho'));
|
|
|
|
$this->view->iTotalDisplayRecords = $numTotalRecentUploads;
|
|
|
|
//$this->view->iTotalDisplayRecords = $numRecentUploads; //$r["iTotalDisplayRecords"];
|
|
|
|
$this->view->iTotalRecords = $numTotalRecentUploads; //$r["iTotalRecords"];
|
|
|
|
$this->view->files = $uploadsArray; //$r["aaData"];
|
|
|
|
}
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|