Format code using php-cs-fixer

This commit is contained in:
jo 2021-10-11 16:10:47 +02:00
parent 43d7dc92cd
commit d52c6184b9
352 changed files with 17473 additions and 17041 deletions

View file

@ -5,9 +5,10 @@ class PluploadController extends Zend_Controller_Action
public function init()
{
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('upload', 'json')
->addActionContext('recent-uploads', 'json')
->initContext();
$ajaxContext->addActionContext('upload', 'json')
->addActionContext('recent-uploads', 'json')
->initContext()
;
}
public function indexAction()
@ -17,16 +18,16 @@ class PluploadController extends Zend_Controller_Action
$baseUrl = Application_Common_OsPath::getBaseDir();
$locale = Application_Model_Preference::GetLocale();
$this->view->headScript()->appendFile($baseUrl.'js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
$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');
$this->view->headScript()->appendFile($baseUrl.'js/libs/dropzone.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl . 'js/datatables/js/jquery.dataTables.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
$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');
$this->view->headScript()->appendFile($baseUrl . 'js/libs/dropzone.min.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'css/plupload.queue.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/addmedia.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'css/dashboard.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl . 'css/plupload.queue.css?' . $CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl . 'css/addmedia.css?' . $CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl . 'css/dashboard.css?' . $CC_CONFIG['airtime_version']);
$this->view->quotaLimitReached = false;
if (Application_Model_Systemstatus::isDiskOverQuota()) {
@ -60,56 +61,56 @@ class PluploadController extends Zend_Controller_Action
$observed_csrf_token = $this->_getParam('csrf_token');
$expected_csrf_token = $current_namespace->authtoken;
if($observed_csrf_token == $expected_csrf_token){
$upload_dir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
if ($observed_csrf_token == $expected_csrf_token) {
$upload_dir = ini_get('upload_tmp_dir') . DIRECTORY_SEPARATOR . 'plupload';
$tempFilePath = Application_Model_StoredFile::uploadFile($upload_dir);
$tempFileName = basename($tempFilePath);
$this->_helper->json->sendJson(array("jsonrpc" => "2.0", "tempfilepath" => $tempFileName));
}else{
$this->_helper->json->sendJson(array("jsonrpc" => "2.0", "valid" => false, "error" => "CSRF token did not match."));
$this->_helper->json->sendJson(['jsonrpc' => '2.0', 'tempfilepath' => $tempFileName]);
} else {
$this->_helper->json->sendJson(['jsonrpc' => '2.0', 'valid' => false, 'error' => 'CSRF token did not match.']);
}
}
public function recentUploadsAction()
{
$request = $this->getRequest();
$filter = $request->getParam('uploadFilter', "all");
$request = $this->getRequest();
$filter = $request->getParam('uploadFilter', 'all');
$limit = intval($request->getParam('iDisplayLength', 10));
$rowStart = intval($request->getParam('iDisplayStart', 0));
$recentUploadsQuery = CcFilesQuery::create();
//old propel 1.5 to reuse this query item (for counts/finds)
$recentUploadsQuery->keepQuery(true);
//Hide deleted files
$recentUploadsQuery->filterByDbFileExists(true);
$numTotalRecentUploads = $recentUploadsQuery->count();
$numTotalDisplayUploads = $numTotalRecentUploads;
if ($filter == "pending") {
if ($filter == 'pending') {
$recentUploadsQuery->filterByDbImportStatus(1);
$numTotalDisplayUploads = $recentUploadsQuery->count();
} else if ($filter == "failed") {
} elseif ($filter == 'failed') {
$recentUploadsQuery->filterByDbImportStatus(2);
$numTotalDisplayUploads = $recentUploadsQuery->count();
//TODO: Consider using array('min' => 200)) or something if we have multiple errors codes for failure.
}
$recentUploads = $recentUploadsQuery
->orderByDbUtime(Criteria::DESC)
->offset($rowStart)
->limit($limit)
->find();
$uploadsArray = array();
$utcTimezone = new DateTimeZone("UTC");
->orderByDbUtime(Criteria::DESC)
->offset($rowStart)
->limit($limit)
->find()
;
$uploadsArray = [];
$utcTimezone = new DateTimeZone('UTC');
$displayTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone());
foreach ($recentUploads as $upload)
{
foreach ($recentUploads as $upload) {
$upload = $upload->toArray(BasePeer::TYPE_FIELDNAME);
//TODO: $this->sanitizeResponse($upload));
$upload['utime'] = new DateTime($upload['utime'], $utcTimezone);
@ -119,7 +120,7 @@ class PluploadController extends Zend_Controller_Action
//TODO: Invoke sanitization here (MediaController's removeBlacklist stuff)
array_push($uploadsArray, $upload);
}
$this->view->sEcho = intval($request->getParam('sEcho'));
$this->view->iTotalDisplayRecords = $numTotalDisplayUploads;
$this->view->iTotalRecords = $numTotalRecentUploads;
@ -127,7 +128,7 @@ class PluploadController extends Zend_Controller_Action
}
/**
* get configured upload max size from php
* get configured upload max size from php.
*
* Pinched from Drupal: https://github.com/drupal/drupal/blob/4204b0b29a7318008f10765cf88114bf3ed21c32/core/includes/file.inc#L1099
*
@ -135,10 +136,10 @@ class PluploadController extends Zend_Controller_Action
* way. I'm adding the method here since it's part of their core and I did
* not find an easy way to grab that thrrough composer in an isolated way.
*/
private function file_upload_max_size() {
private function file_upload_max_size()
{
static $max_size = -1;
if ($max_size < 0) {
// Start with post_max_size.
$max_size = $this->bytes_to_int(ini_get('post_max_size'));
@ -149,19 +150,23 @@ class PluploadController extends Zend_Controller_Action
$max_size = $upload_max;
}
}
return $max_size;
}
/**
* Pinched from Drupal: https://github.com/drupal/drupal/blob/4204b0b29a7318008f10765cf88114bf3ed21c32/core/lib/Drupal/Component/Utility/Bytes.php#L27
* Pinched from Drupal: https://github.com/drupal/drupal/blob/4204b0b29a7318008f10765cf88114bf3ed21c32/core/lib/Drupal/Component/Utility/Bytes.php#L27.
*
* This is the real point of importing the Drupal solution. They have done
* an implementation for figuring out what the user specified in the
* post_max_size and upload_max_size configuration. Sadly php does not
* support a nice way to get at the results of this config after it is
* parsed by the engine, hence the below hack.
*
* @param mixed $size
*/
private function bytes_to_int($size) {
private function bytes_to_int($size)
{
// Remove the non-unit characters from the size.
$unit = preg_replace('/[^bkmgtpezy]/i', '', $size);
// Remove the non-numeric characters from the size.
@ -170,8 +175,8 @@ class PluploadController extends Zend_Controller_Action
// Find the position of the unit in the ordered string which is the power
// of magnitude to multiply a kilobyte by.
return round($size * pow(1024, stripos('bkmgtpezy', $unit[0])));
} else {
return round($size);
}
return round($size);
}
}