Browse Source

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

Move ITemplateEngine to src
pull/3915/head
Michael Vogel 4 years ago
committed by GitHub
parent
commit
27af65918e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      include/friendica_smarty.php
  2. 4
      include/text.php
  3. 15
      object/TemplateEngine.php
  4. 2
      src/App.php
  5. 15
      src/Render/ITemplateEngine.php

9
include/friendica_smarty.php

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

4
include/text.php

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

15
object/TemplateEngine.php

@ -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 = '');
}

2
src/App.php

@ -295,7 +295,7 @@ class App {
// Register template engines
$dc = get_declared_classes();
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);
}
}

15
src/Render/ITemplateEngine.php

@ -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 = '');
}
Loading…
Cancel
Save