X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2Frender%2FPageBuilder.php;h=512bb79e3555cc4833566af10822cea5be67b649;hb=820cae27cfcc94af552818f3f1e5342e00478f6c;hp=41b357dd72caccc9fe0525b29d3dbc2a31876db2;hpb=72fbbcd6794facea2cf06d9742359d190257b00f;p=github%2Fshaarli%2FShaarli.git diff --git a/application/render/PageBuilder.php b/application/render/PageBuilder.php index 41b357dd..512bb79e 100644 --- a/application/render/PageBuilder.php +++ b/application/render/PageBuilder.php @@ -3,7 +3,7 @@ namespace Shaarli\Render; use Exception; -use exceptions\MissingBasePathException; +use Psr\Log\LoggerInterface; use RainTPL; use Shaarli\ApplicationUtils; use Shaarli\Bookmark\BookmarkServiceInterface; @@ -35,6 +35,9 @@ class PageBuilder */ protected $session; + /** @var LoggerInterface */ + protected $logger; + /** * @var BookmarkServiceInterface $bookmarkService instance. */ @@ -54,17 +57,25 @@ class PageBuilder * PageBuilder constructor. * $tpl is initialized at false for lazy loading. * - * @param ConfigManager $conf Configuration Manager instance (reference). - * @param array $session $_SESSION array - * @param BookmarkServiceInterface $linkDB instance. - * @param string $token Session token - * @param bool $isLoggedIn + * @param ConfigManager $conf Configuration Manager instance (reference). + * @param array $session $_SESSION array + * @param LoggerInterface $logger + * @param null $linkDB instance. + * @param null $token Session token + * @param bool $isLoggedIn */ - public function __construct(&$conf, $session, $linkDB = null, $token = null, $isLoggedIn = false) - { + public function __construct( + ConfigManager &$conf, + array $session, + LoggerInterface $logger, + $linkDB = null, + $token = null, + $isLoggedIn = false + ) { $this->tpl = false; $this->conf = $conf; $this->session = $session; + $this->logger = $logger; $this->bookmarkService = $linkDB; $this->token = $token; $this->isLoggedIn = $isLoggedIn; @@ -98,7 +109,7 @@ class PageBuilder $this->tpl->assign('newVersion', escape($version)); $this->tpl->assign('versionError', ''); } catch (Exception $exc) { - logm($this->conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], $exc->getMessage()); + $this->logger->error(format_log('Error: ' . $exc->getMessage(), client_ip_id($_SERVER))); $this->tpl->assign('newVersion', ''); $this->tpl->assign('versionError', escape($exc->getMessage())); } @@ -174,10 +185,12 @@ class PageBuilder } } + $rootPath = preg_replace('#/index\.php$#', '', $basePath); $this->assign('base_path', $basePath); + $this->assign('root_path', $rootPath); $this->assign( 'asset_path', - $basePath . '/' . + $rootPath . '/' . rtrim($this->conf->get('resource.raintpl_tpl', 'tpl'), '/') . '/' . $this->conf->get('resource.theme', 'default') );