portal changes

This commit is contained in:
yuri
2016-02-17 16:54:53 +02:00
parent fee64fd5ac
commit da059b2589
4 changed files with 9 additions and 23 deletions
+5 -1
View File
@@ -29,7 +29,11 @@
require_once('../../../bootstrap.php');
$portalId = explode('/', $_SERVER['REQUEST_URI'])[count(explode('/', $_SERVER['SCRIPT_NAME'])) - 1];
if (!empty($_GET['portalId'])) {
$portalId = $_GET['portalId'];
} else {
$portalId = explode('/', $_SERVER['REQUEST_URI'])[count(explode('/', $_SERVER['SCRIPT_NAME'])) - 1];
}
$app = new \Espo\Core\Portal\Application($portalId);
$app->run();
+1 -2
View File
@@ -102,8 +102,7 @@ class Application
$slim = $this->getSlim();
$container = $this->getContainer();
$slim->get('/', function() {});
$slim->post('/', function() {});
$slim->any('.*', function() {});
$entryPointManager = new \Espo\Core\EntryPointManager($container);
-18
View File
@@ -39,33 +39,19 @@ class Slim extends \Slim\Slim
*/
public function run()
{
//set_error_handler(array('\Slim\Slim', 'handleErrors')); //Espo: no needs to use this handler
//Apply final outer middleware layers
if ($this->config('debug')) {
//Apply pretty exceptions only in debug to avoid accidental information leakage in production
//$this->add(new \Slim\Middleware\PrettyExceptions()); //Espo: no needs to use this handler
}
//Invoke middleware and application stack
$this->middleware[0]->call();
//Fetch status, header, and body
list($status, $headers, $body) = $this->response->finalize();
// Serialize cookies (with optional encryption)
\Slim\Http\Util::serializeCookies($headers, $this->response->cookies, $this->settings);
//Send headers
if (headers_sent() === false) {
//Send status
if (strpos(PHP_SAPI, 'cgi') === 0) {
header(sprintf('Status: %s', \Slim\Http\Response::getMessageForCode($status)));
} else {
header(sprintf('HTTP/%s %s', $this->config('http.version'), \Slim\Http\Response::getMessageForCode($status)));
}
//Send headers
foreach ($headers as $name => $value) {
$hValues = explode("\n", $value);
foreach ($hValues as $hVal) {
@@ -74,12 +60,9 @@ class Slim extends \Slim\Slim
}
}
//Send body, but only if it isn't a HEAD request
if (!$this->request->isHead()) {
echo $body;
}
//restore_error_handler(); //Espo: no needs to use this handler
}
public function printError($error, $status)
@@ -87,5 +70,4 @@ class Slim extends \Slim\Slim
echo static::generateTemplateMarkup($status, '<p>'.$error.'</p><a href="' . $this->request->getRootUri() . '/">Visit the Home Page</a>');
}
}
+3 -2
View File
@@ -50,12 +50,13 @@ class Portal extends Record
protected function loadUrlField(Entity $entity)
{
$siteUrl = $this->getConfig()->get('siteUrl');
$url = $siteUrl . '?entryPoint=portal';
$siteUrl = rtrim($siteUrl , '/') . '/';
$url = $siteUrl . 'portal';
if ($entity->id === $this->getConfig()->get('defaultPortalId')) {
$entity->set('isDefault', true);
$entity->setFetched('isDefault', true);
} else {
$url .= '&id=' . $entity->id;
$url .= '?id=' . $entity->id;
$entity->setFetched('isDefault', false);
}
$entity->set('url', $url);