Format code using php-cs-fixer
This commit is contained in:
parent
43d7dc92cd
commit
d52c6184b9
352 changed files with 17473 additions and 17041 deletions
|
@ -3,25 +3,27 @@
|
|||
class Application_Common_HTTPHelper
|
||||
{
|
||||
/**
|
||||
* Returns start and end DateTime vars from given
|
||||
* HTTP Request object
|
||||
* Returns start and end DateTime vars from given
|
||||
* HTTP Request object.
|
||||
*
|
||||
* @param Request
|
||||
* @param mixed $request
|
||||
*
|
||||
* @return array(start DateTime, end DateTime)
|
||||
*/
|
||||
public static function getStartEndFromRequest($request)
|
||||
{
|
||||
return Application_Common_DateHelper::getStartEnd(
|
||||
$request->getParam("start", null),
|
||||
$request->getParam("end", null),
|
||||
$request->getParam("timezone", null)
|
||||
$request->getParam('start', null),
|
||||
$request->getParam('end', null),
|
||||
$request->getParam('timezone', null)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the base station URL
|
||||
* Construct the base station URL.
|
||||
*
|
||||
* @param boolean $secured whether or not to use HTTPS
|
||||
* @param bool $secured whether or not to use HTTPS
|
||||
*
|
||||
* @return string the station URL
|
||||
*/
|
||||
|
@ -34,84 +36,89 @@ class Application_Common_HTTPHelper
|
|||
$forceSSL = $CC_CONFIG['forceSSL'];
|
||||
$configProtocol = $CC_CONFIG['protocol'];
|
||||
if (empty($baseDir)) {
|
||||
$baseDir = "/";
|
||||
$baseDir = '/';
|
||||
}
|
||||
if ($baseDir[0] != "/") {
|
||||
$baseDir = "/" . $baseDir;
|
||||
if ($baseDir[0] != '/') {
|
||||
$baseDir = '/' . $baseDir;
|
||||
}
|
||||
if (substr($baseDir, -1) != "/") {
|
||||
$baseDir = $baseDir . "/";
|
||||
if (substr($baseDir, -1) != '/') {
|
||||
$baseDir = $baseDir . '/';
|
||||
}
|
||||
|
||||
# Set in reverse order of preference. ForceSSL configuration takes absolute preference, then
|
||||
# the protocol set in config. If neither are set, the port is used to determine the scheme
|
||||
$scheme = "http";
|
||||
if ($secured && $basePort == "443") {
|
||||
$scheme = "https";
|
||||
// Set in reverse order of preference. ForceSSL configuration takes absolute preference, then
|
||||
// the protocol set in config. If neither are set, the port is used to determine the scheme
|
||||
$scheme = 'http';
|
||||
if ($secured && $basePort == '443') {
|
||||
$scheme = 'https';
|
||||
}
|
||||
if (!empty($configProtocol)) {
|
||||
$scheme = $configProtocol;
|
||||
$scheme = $configProtocol;
|
||||
}
|
||||
if ($forceSSL) {
|
||||
$scheme = "https";
|
||||
$scheme = 'https';
|
||||
}
|
||||
|
||||
$portStr = "";
|
||||
if (($scheme == "http" && $basePort !== "80")
|
||||
|| ($scheme == "https" && $basePort !== "443")) {
|
||||
$portStr = ":${basePort}";
|
||||
$portStr = '';
|
||||
if (($scheme == 'http' && $basePort !== '80')
|
||||
|| ($scheme == 'https' && $basePort !== '443')) {
|
||||
$portStr = ":{$basePort}";
|
||||
}
|
||||
$stationUrl = "$scheme://${baseUrl}${portStr}${baseDir}";
|
||||
|
||||
return $stationUrl;
|
||||
return "{$scheme}://{$baseUrl}{$portStr}{$baseDir}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a cURL POST
|
||||
* Execute a cURL POST.
|
||||
*
|
||||
* @param string $url the URL to POST to
|
||||
* @param string[] $userPwd array of user args of the form ['user', 'pwd']
|
||||
* @param array $formData array of form data kwargs
|
||||
* @param string $url the URL to POST to
|
||||
* @param string[] $userPwd array of user args of the form ['user', 'pwd']
|
||||
* @param array $formData array of form data kwargs
|
||||
*
|
||||
* @return mixed the cURL result
|
||||
*/
|
||||
public static function doPost($url, $userPwd, $formData) {
|
||||
$params = "";
|
||||
foreach($formData as $key=>$value) {
|
||||
$params .= $key.'='.$value.'&';
|
||||
public static function doPost($url, $userPwd, $formData)
|
||||
{
|
||||
$params = '';
|
||||
foreach ($formData as $key => $value) {
|
||||
$params .= $key . '=' . $value . '&';
|
||||
}
|
||||
rtrim($params, '&');
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, TRUE);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
|
||||
curl_setopt($ch, CURLOPT_USERPWD, implode(':', $userPwd));
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
class ZendActionHttpException extends Exception {
|
||||
|
||||
class ZendActionHttpException extends Exception
|
||||
{
|
||||
/**
|
||||
* @param Zend_Controller_Action $action
|
||||
* @param int $statusCode
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Exception $previous
|
||||
* @param int $statusCode
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Exception $previous
|
||||
*
|
||||
* @throws Zend_Controller_Response_Exception
|
||||
*/
|
||||
public function __construct(Zend_Controller_Action $action, $statusCode, $message,
|
||||
$code = 0, Exception $previous = null) {
|
||||
Logging::error("Error in action " . $action->getRequest()->getActionName()
|
||||
. " with status code $statusCode: $message");
|
||||
public function __construct(
|
||||
Zend_Controller_Action $action,
|
||||
$statusCode,
|
||||
$message,
|
||||
$code = 0,
|
||||
Exception $previous = null
|
||||
) {
|
||||
Logging::error('Error in action ' . $action->getRequest()->getActionName()
|
||||
. " with status code {$statusCode}: {$message}");
|
||||
$action->getResponse()
|
||||
->setHttpResponseCode($statusCode)
|
||||
->appendBody($message);
|
||||
->appendBody($message)
|
||||
;
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue