diff options
-rw-r--r-- | apps/files_sharing/appinfo/routes.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/controller/adminsettingscontroller.php | 2 | ||||
-rw-r--r-- | core/css/fixes.css | 5 | ||||
-rw-r--r-- | core/img/actions/caret.png | bin | 296 -> 2876 bytes | |||
-rw-r--r-- | core/img/actions/logout.png | bin | 761 -> 3071 bytes | |||
-rw-r--r-- | core/templates/layout.user.php | 2 | ||||
-rw-r--r-- | lib/private/appframework/http/dispatcher.php | 33 | ||||
-rw-r--r-- | lib/public/appframework/controller.php | 24 | ||||
-rw-r--r-- | tests/lib/appframework/controller/ControllerTest.php | 32 |
9 files changed, 77 insertions, 23 deletions
diff --git a/apps/files_sharing/appinfo/routes.php b/apps/files_sharing/appinfo/routes.php index 5b6286e2bfb..78d4276f98a 100644 --- a/apps/files_sharing/appinfo/routes.php +++ b/apps/files_sharing/appinfo/routes.php @@ -12,7 +12,7 @@ $app = new Sharing(); $app->registerRoutes($this, array('routes' => array( // mailTemplate settings - array('name' => 'admin_settings#render', 'url' => '/settings/mailtemplate', 'verb' => 'GET'), + array('name' => 'admin_settings#render_raw', 'url' => '/settings/mailtemplate', 'verb' => 'GET'), array('name' => 'admin_settings#update', 'url' => '/settings/mailtemplate', 'verb' => 'POST'), diff --git a/apps/files_sharing/controller/adminsettingscontroller.php b/apps/files_sharing/controller/adminsettingscontroller.php index fed3147a99c..5192b6239e4 100644 --- a/apps/files_sharing/controller/adminsettingscontroller.php +++ b/apps/files_sharing/controller/adminsettingscontroller.php @@ -17,7 +17,7 @@ class AdminSettingsController extends ApiController { * @param string $template * @return \OCA\Files_Sharing\Http\MailTemplateResponse */ - public function render( $theme, $template ) { + public function renderRaw( $theme, $template ) { try { $template = new \OCA\Files_Sharing\MailTemplate( $theme, $template ); return $template->getResponse(); diff --git a/core/css/fixes.css b/core/css/fixes.css index acea53258eb..f1dc016cad2 100644 --- a/core/css/fixes.css +++ b/core/css/fixes.css @@ -86,3 +86,8 @@ select { left: 6px; } +/* fix background of navigation popup in IE8 */ +.ie8 #navigation { + background-color: #24282F; +} + diff --git a/core/img/actions/caret.png b/core/img/actions/caret.png Binary files differindex f6d76b0628b..736beb667bd 100644 --- a/core/img/actions/caret.png +++ b/core/img/actions/caret.png diff --git a/core/img/actions/logout.png b/core/img/actions/logout.png Binary files differindex 64126a55625..bada7a12616 100644 --- a/core/img/actions/logout.png +++ b/core/img/actions/logout.png diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index efa169c333b..3f1b939a12d 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -52,7 +52,7 @@ <div class="header-appname"> <?php p(!empty($_['application'])?$_['application']: $l->t('Apps')); ?> </div> - <div class="icon-caret"></div> + <div class="icon-caret svg"></div> </a> <div id="logo-claim" style="display:none;"><?php p($theme->getLogoClaim()); ?></div> <div id="settings" class="svg"> diff --git a/lib/private/appframework/http/dispatcher.php b/lib/private/appframework/http/dispatcher.php index 442e33ee726..fa8d3c47a8b 100644 --- a/lib/private/appframework/http/dispatcher.php +++ b/lib/private/appframework/http/dispatcher.php @@ -52,9 +52,9 @@ class Dispatcher { * @param IRequest $request the incoming request */ public function __construct(Http $protocol, - MiddlewareDispatcher $middlewareDispatcher, - ControllerMethodReflector $reflector, - IRequest $request) { + MiddlewareDispatcher $middlewareDispatcher, + ControllerMethodReflector $reflector, + IRequest $request) { $this->protocol = $protocol; $this->middlewareDispatcher = $middlewareDispatcher; $this->reflector = $reflector; @@ -75,7 +75,7 @@ class Dispatcher { $out = array(null, array(), null); try { - // prefill reflector with everything thats needed for the + // prefill reflector with everything thats needed for the // middlewares $this->reflector->reflect($controller, $methodName); @@ -132,14 +132,14 @@ class Dispatcher { // it to the type annotated in the @param annotation $value = $this->request->getParam($param, $default); $type = $this->reflector->getType($param); - - // if this is submitted using GET or a POST form, 'false' should be + + // if this is submitted using GET or a POST form, 'false' should be // converted to false if(($type === 'bool' || $type === 'boolean') && - $value === 'false' && + $value === 'false' && ( $this->request->method === 'GET' || - strpos($this->request->getHeader('Content-Type'), + strpos($this->request->getHeader('Content-Type'), 'application/x-www-form-urlencoded') !== false ) ) { @@ -148,7 +148,7 @@ class Dispatcher { } elseif(in_array($type, $types)) { settype($value, $type); } - + $arguments[] = $value; } @@ -156,21 +156,14 @@ class Dispatcher { // format response if not of type response if(!($response instanceof Response)) { - + // get format from the url format or request format parameter $format = $this->request->getParam('format'); - + // if none is given try the first Accept header if($format === null) { - $header = $this->request->getHeader('Accept'); - $formats = explode(',', $header); - - if($header !== null && count($formats) > 0) { - $accept = strtolower(trim($formats[0])); - $format = str_replace('application/', '', $accept); - } else { - $format = 'json'; - } + $headers = $this->request->getHeader('Accept'); + $format = $controller->getResponderByHTTPHeader($headers); } $response = $controller->buildResponse($response, $format); diff --git a/lib/public/appframework/controller.php b/lib/public/appframework/controller.php index 79491902bfd..b22eb73343a 100644 --- a/lib/public/appframework/controller.php +++ b/lib/public/appframework/controller.php @@ -71,6 +71,30 @@ abstract class Controller { /** + * Parses an HTTP accept header and returns the supported responder type + * @param string $acceptHeader + * @return string the responder type + */ + public function getResponderByHTTPHeader($acceptHeader) { + $headers = explode(',', $acceptHeader); + + // return the first matching responder + foreach ($headers as $header) { + $header = strtolower(trim($header)); + + $responder = str_replace('application/', '', $header); + + if (array_key_exists($responder, $this->responders)) { + return $responder; + } + } + + // no matching header defaults to json + return 'json'; + } + + + /** * Registers a formatter for a type * @param string $format * @param \Closure $responder diff --git a/tests/lib/appframework/controller/ControllerTest.php b/tests/lib/appframework/controller/ControllerTest.php index 65144e78f53..e97ec548939 100644 --- a/tests/lib/appframework/controller/ControllerTest.php +++ b/tests/lib/appframework/controller/ControllerTest.php @@ -30,6 +30,14 @@ use OCP\AppFramework\Http\JSONResponse; class ChildController extends Controller { + + public function __construct($appName, $request) { + parent::__construct($appName, $request); + $this->registerResponder('tom', function ($respone) { + return 'hi'; + }); + } + public function custom($in) { $this->registerResponder('json', function ($response) { return new JSONResponse(array(strlen($response))); @@ -161,5 +169,29 @@ class ControllerTest extends \PHPUnit_Framework_TestCase { } + public function testDefaultResponderToJSON() { + $responder = $this->controller->getResponderByHTTPHeader('*/*'); + + $this->assertEquals('json', $responder); + } + + + public function testResponderAcceptHeaderParsed() { + $responder = $this->controller->getResponderByHTTPHeader( + '*/*, application/tom, application/json' + ); + + $this->assertEquals('tom', $responder); + } + + + public function testResponderAcceptHeaderParsedUpperCase() { + $responder = $this->controller->getResponderByHTTPHeader( + '*/*, apPlication/ToM, application/json' + ); + + $this->assertEquals('tom', $responder); + } + } |