]> git.mxchange.org Git - friendica.git/blobdiff - src/Render/FriendicaSmartyEngine.php
Merge pull request #8558 from annando/corrected-view
[friendica.git] / src / Render / FriendicaSmartyEngine.php
index 36e46435fe675124c7279b3f3a03e636c325ae4a..6984daa15871e41c4b4079f1eddc3989fec95a61 100644 (file)
@@ -1,15 +1,31 @@
 <?php
 /**
- * @file src/Render/FriendicaSmartyEngine.php
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
  */
+
 namespace Friendica\Render;
 
 use Friendica\Core\Hook;
+use Friendica\DI;
 
 /**
  * Smarty implementation of the Friendica template engine interface
- *
- * @author Hypolite Petovan <hypolite@mrpetovan.com>
  */
 class FriendicaSmartyEngine implements ITemplateEngine
 {
@@ -32,7 +48,7 @@ class FriendicaSmartyEngine implements ITemplateEngine
                        $s = new FriendicaSmarty();
                }
 
-               $r['$APP'] = \get_app();
+               $r['$APP'] = DI::app();
 
                // "middleware": inject variables into templates
                $arr = [
@@ -52,16 +68,18 @@ class FriendicaSmartyEngine implements ITemplateEngine
                return $s->parsed($template);
        }
 
-       public function getTemplateFile($file, $root = '')
+       public function getTemplateFile($file, $subDir = '')
        {
-               $a = \get_app();
+               $a = DI::app();
                $template = new FriendicaSmarty();
 
                // Make sure $root ends with a slash /
-               if ($root !== '' && substr($root, -1, 1) !== '/') {
-                       $root = $root . '/';
+               if ($subDir !== '' && substr($subDir, -1, 1) !== '/') {
+                       $subDir = $subDir . '/';
                }
 
+               $root = DI::basePath() . '/' . $subDir;
+
                $theme = $a->getCurrentTheme();
                $filename = $template::SMARTY3_TEMPLATE_FOLDER . '/' . $file;