Merge pull request #3914 from MrPetovan/issue/#3878-move-itemplateengine-to-src

Move ITemplateEngine to src
This commit is contained in:
Michael Vogel 2017-11-19 16:28:18 +01:00 committed by GitHub
commit 27af65918e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 22 deletions

View file

@ -1,6 +1,7 @@
<?php <?php
require_once "object/TemplateEngine.php"; use Friendica\Render\ITemplateEngine;
require_once("library/Smarty/libs/Smarty.class.php"); require_once("library/Smarty/libs/Smarty.class.php");
require_once "include/plugin.php"; require_once "include/plugin.php";
@ -54,7 +55,7 @@ class FriendicaSmartyEngine implements ITemplateEngine {
} }
// ITemplateEngine interface // ITemplateEngine interface
public function replace_macros($s, $r) { public function replaceMacros($s, $r) {
$template = ''; $template = '';
if (gettype($s) === 'string') { if (gettype($s) === 'string') {
$template = $s; $template = $s;
@ -80,7 +81,7 @@ class FriendicaSmartyEngine implements ITemplateEngine {
return $s->parsed($template); return $s->parsed($template);
} }
public function get_template_file($file, $root=''){ public function getTemplateFile($file, $root=''){
$a = get_app(); $a = get_app();
$template_file = get_template_file($a, SMARTY3_TEMPLATE_FOLDER.'/'.$file, $root); $template_file = get_template_file($a, SMARTY3_TEMPLATE_FOLDER.'/'.$file, $root);
$template = new FriendicaSmarty(); $template = new FriendicaSmarty();

View file

@ -30,7 +30,7 @@ function replace_macros($s, $r) {
$t = $a->template_engine(); $t = $a->template_engine();
try { try {
$output = $t->replace_macros($s, $r); $output = $t->replaceMacros($s, $r);
} catch (Exception $e) { } catch (Exception $e) {
echo "<pre><b>" . __FUNCTION__ . "</b>: " . $e->getMessage() . "</pre>"; echo "<pre><b>" . __FUNCTION__ . "</b>: " . $e->getMessage() . "</pre>";
killme(); killme();
@ -591,7 +591,7 @@ function get_markup_template($s, $root = '') {
$a = get_app(); $a = get_app();
$t = $a->template_engine(); $t = $a->template_engine();
try { try {
$template = $t->get_template_file($s, $root); $template = $t->getTemplateFile($s, $root);
} catch (Exception $e) { } catch (Exception $e) {
echo "<pre><b>" . __FUNCTION__ . "</b>: " . $e->getMessage() . "</pre>"; echo "<pre><b>" . __FUNCTION__ . "</b>: " . $e->getMessage() . "</pre>";
killme(); killme();

View file

@ -1,15 +0,0 @@
<?php
/**
* @file object/TemplateEngine.php
*/
require_once 'boot.php';
/**
* Interface for template engines
*/
interface ITemplateEngine
{
public function replace_macros($s, $v);
public function get_template_file($file, $root = '');
}

View file

@ -295,7 +295,7 @@ class App {
// Register template engines // Register template engines
$dc = get_declared_classes(); $dc = get_declared_classes();
foreach ($dc as $k) { foreach ($dc as $k) {
if (in_array('ITemplateEngine', class_implements($k))) { if (in_array('Friendica\Render\ITemplateEngine', class_implements($k))) {
$this->register_template_engine($k); $this->register_template_engine($k);
} }
} }

View file

@ -0,0 +1,15 @@
<?php
/**
* @file src/Render/ITemplateEngine.php
*/
namespace Friendica\Render;
/**
* Interface for template engines
*/
interface ITemplateEngine
{
public function replaceMacros($s, $v);
public function getTemplateFile($file, $root = '');
}