Permalink
Browse files

Add favicon.ico to top level router and serve the theme icon.

  • Loading branch information...
1 parent 5ea466f commit 4fb8f31a09c6e32fa9854dafa73b50a822e26e05 @cdujeu cdujeu committed Jun 20, 2016
@@ -35,12 +35,23 @@ class Base
public static function handleRoute($base, $route){
if($route === "/api") {
+
$server = new Rest\RestServer($base.$route);
- }else if($route === "/user"){
+
+ }else if($route === "/user") {
+
$_GET["get_action"] = "user_access_point";
$server = new Server($base);
+
+ }else if($route == "/favicon"){
+
+ $_GET["get_action"] = "serve_favicon";
+ $server = new Server($base);
+
}else{
+
$server = new Server($base);
+
}
$server->registerCatchAll();
@@ -49,6 +49,14 @@
"path" : "plugins/action.share/src/ShareCenter.php",
"method": "publicRoute"
},
+ "/favicon":{
+ "methods": "GET",
+ "routes":[
+ "/favicon.ico"
+ ],
+ "class":"Pydio\\Core\\Http\\Base",
+ "method":"handleRoute"
+ },
"/": {
"methods": "*",
"routes": [
@@ -8,6 +8,11 @@
</serverCallback>
</processing>
</action>
+ <action name="serve_favicon" skipSecureToken="true">
+ <processing>
+ <serverCallback methodName="switchAction" restParams="/" developerComment="Return site favicon"/>
+ </processing>
+ </action>
<action name="display_doc">
<processing>
<serverCallback methodName="switchAction" restParams="/doc_file" developerComment="Load a doc file">
@@ -24,6 +24,7 @@
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Pydio\Core\Http\Middleware\SecureTokenMiddleware;
+use Pydio\Core\Http\Response\FileReaderResponse;
use Pydio\Core\Model\Context;
use Pydio\Core\Model\ContextInterface;
use Pydio\Core\Services\ConfService;
@@ -213,6 +214,15 @@ public function switchAction(ServerRequestInterface $requestInterface, ResponseI
switch ($requestInterface->getAttribute("action")) {
+ case "serve_favicon":
+
+ $image = AJXP_THEME_FOLDER."/images/html-folder.png";
+ $reader = new FileReaderResponse($image);
+ $reader->setHeaderType("image");
+ $responseInterface = $responseInterface->withBody($reader);
+
+ break;
+
//------------------------------------
// GET I18N MESSAGES
//------------------------------------
@@ -223,8 +233,9 @@ public function switchAction(ServerRequestInterface $requestInterface, ResponseI
LocaleService::setLanguage($httpVars["lang"]);
$refresh = true;
}
- HTMLWriter::charsetHeader("application/json");
- echo json_encode(LocaleService::getMessages($refresh));
+ //HTMLWriter::charsetHeader("application/json");
+ //echo json_encode(LocaleService::getMessages($refresh));
+ $responseInterface = new JsonResponse(LocaleService::getMessages($refresh));
break;

0 comments on commit 4fb8f31

Please sign in to comment.