Ejemplo n.º 1
0
 /**
  * @see IRenderEngine::display()
  */
 function display($template)
 {
     if (strpos('.', $template) === false) {
         $template .= '.html';
     }
     return $this->twig->display($template, $this->assignments);
 }
Ejemplo n.º 2
0
 /**
  * Display a template for provided handle.
  *
  * The template will be loaded and compiled, if necessary, first.
  *
  * This function calls hooks.
  *
  * @param string $handle Handle to display
  * @return \phpbb\template\template $this
  */
 public function display($handle)
 {
     $result = $this->call_hook($handle, __FUNCTION__);
     if ($result !== false) {
         return $result[0];
     }
     $this->twig->display($this->get_filename_from_handle($handle), $this->get_template_vars());
     return $this;
 }
Ejemplo n.º 3
0
 public function display($template, $data = [], $config = [])
 {
     if ($config) {
         $this->config($config);
     }
     $key = md5($template);
     $loader = new \Twig_Loader_Array([$key => $template]);
     $twig = new \Twig_Environment($loader, ['debug' => APP_DEBUG, 'auto_reload' => true, 'cache' => $this->config['cache_path']]);
     $twig->display($key, $data);
 }
Ejemplo n.º 4
0
 /**
  * Render banwire scripts view
  */
 public function renderPaymentScripts()
 {
     $this->environment->display('BanwireBundle:Banwire:scripts.html.twig', array('currency' => $this->paymentBridgeInterface->getCurrency()));
 }
Ejemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function display($name, array $context = [])
 {
     $level = ob_get_level();
     ob_start();
     try {
         parent::display($name, $context);
     } catch (\Exception $e) {
         while (ob_get_level() > $level) {
             ob_end_clean();
         }
         throw $e;
     }
     $output = ob_get_clean();
     echo $this->inject_assets($output);
 }
Ejemplo n.º 6
0
<?php

declare (encoding='UTF-8');
require_once 'Twig/Autoloader.php';
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem('templates');
$twig = new Twig_Environment($loader);
require_once "SizePrice.php";
require_once "Item.php";
require_once "config.php";
$twig->display('index.html', array("items" => $items));
 /**
  * Render redsys api form view
  *
  * @param string $viewTemplate An optional template to render.
  *
  * @return string view html
  */
 public function renderPaymentView($viewTemplate = null)
 {
     $formType = $this->formFactory->create('redsys_api_type');
     $this->environment->display($viewTemplate ?: $this->viewTemplate, array('redsys_api_form' => $formType->createView(), 'redsys_api_execute_route' => RedsysApiRoutesLoader::ROUTE_NAME));
 }
Ejemplo n.º 8
0
 /**
  * display the template
  * @param string $template template name
  * @param bool $defaultExtension if to use the default template engine's file extension for template files
  * @return ITemplateEngine
  */
 public function display($template, $defaultExtension = false)
 {
     $this->twigEnv->display($template . ($defaultExtension ? self::DEFAULT_EXTENSION : ''), $this->variables);
     return $this;
 }
Ejemplo n.º 9
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once __DIR__ . '/vendor/autoload.php';
$loader = new Twig_Loader_Filesystem(__DIR__ . '/templates');
$twig = new Twig_Environment($loader);
$twig->addFunction(new \Twig_SimpleFunction('asset', function ($asset) {
    return '/build/' . ltrim($asset, '/');
}));
$uriParts = explode('?', $_SERVER['REQUEST_URI']);
$templatePath = $uriParts[0] . (substr($uriParts[0], -1, 1) === '/' ? 'index' : '');
try {
    $twig->display("pages{$templatePath}.html.twig");
} catch (Twig_Error_Loader $e) {
    header('HTTP/1.0 404 Not Found');
    $twig->display('errors/404.html.twig');
} catch (RuntimeException $e) {
    $twig->display('errors/runtime.html.twig', array('error' => $e));
}
Ejemplo n.º 10
0
 /**
  * Render stripe scripts view
  *
  * @return string js code needed by Stripe behaviour
  */
 public function renderPaymentScripts()
 {
     return $this->environment->display($this->scriptsTemplate, array('public_key' => $this->publicKey, 'currency' => $this->paymentBridgeInterface->getCurrency()));
 }
Ejemplo n.º 11
0
 /**
  * Extended view, for detailed representation
  */
 public function render(\Twig_Environment $env, array $params)
 {
     $params = array_merge(array('date' => $this), $params);
     $env->display("@values/date.twig", $params);
 }
Ejemplo n.º 12
0
 public function display($name, array $context = array())
 {
     return parent::display($name, $this->transformContext($context));
 }
Ejemplo n.º 13
0
$action = explode('/', substr($query, 1));
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') {
    //JSON
    if ($_SERVER['REQUEST_URI'] = '/getEvents') {
        $events = $_POST['events'];
        if (count($events) > 0) {
            $events = implode(',', $events);
            echo json_encode(Fetch($config['query']['getEventsByIDs'], ['ids' => $events]));
        }
    }
} else {
    if ($action[0] == 'card') {
        //=============================card=============================
        if (isset($action[1])) {
            $res = Fetch($config['query']['getEventsByNumber'], ['number' => $action[1]]);
            $twig->display('log_detail.twig', array('cards' => $res, 'env' => $env));
        } else {
            $res = Fetch($config['query']['getSplash'][$env['db']['alias']], ['limit' => 500]);
            $twig->display('card.twig', array('cards' => $res, 'env' => $env));
        }
    } elseif ($action[0] == 'test') {
        //=============================test=============================
        echo "<pre>" . print_r($config, true) . "</pre>>";
    } elseif ($action[0] == 'db') {
        //=============================db=============================
        if (isset($config['dbs'][$action[1]])) {
            $_SESSION['db'] = $config['dbs'][$action[1]];
            $url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/';
            header('Location: ' . $url);
        } else {
            header("HTTP/1.0 500 Internal Server Error ");
Ejemplo n.º 14
0
 /**
  * Extended view, for detailed representation
  */
 public function render(\Twig_Environment $env, array $params)
 {
     $params = array_merge(array('text' => $this, 'plain' => false), $params);
     $env->display("@values/text.twig", $params);
 }
Ejemplo n.º 15
0
<?php

ini_set('display_errors', 1);
error_reporting(E_ALL ^ E_NOTICE);
require_once '../vendor/autoload.php';
// Twig инициализация
$loader = new Twig_Loader_Filesystem('../templates');
// Twig папка с шаблонами
//$twig = new Twig_Environment($loader, array('cache' => 'cache',));
$twig = new Twig_Environment($loader, array('cache' => '', 'trim_blocks' => true));
echo $twig->display(basename(__DIR__) . '.twig', array('admin_fio' => 'Калиничев Владимир', 'section' => basename(__DIR__), 'sections' => array('' => 'Home', 'bills' => 'Счета', 'users' => 'Пользователи', 'supply' => 'Расходники')));
Ejemplo n.º 16
0
 /**
  * Render & Display selected template
  *
  * @param $template
  * @param null $context
  */
 public function display($template, $context = null)
 {
     $this->twig->display($template, $context);
 }
 /**
  * Render paypal express checkout form view
  *
  * @return string view html
  */
 public function renderPaymentView()
 {
     $formType = $this->formFactory->create('paypal_express_checkout_view');
     return $this->environment->display('PaypalExpressCheckoutBundle:PaypalExpressCheckout:view.html.twig', array('paypal_express_checkout_form' => $formType->createView()));
 }
Ejemplo n.º 18
0
 /**
  * Extended view, for detailed representation
  */
 public function render(\Twig_Environment $env, array $params)
 {
     $params = array_merge(array('user' => $this, 'link' => false), $params);
     $env->display('values/user.twig', $params);
 }
Ejemplo n.º 19
0
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem('templates');
$twig = new Twig_Environment($loader);
require_once "SizePrice.php";
require_once "Item.php";
require_once "config.php";
require_once "functions.php";
/**
 * Contains the list of items to order. All orders are contained within the "item" key, and each subentry
 * contains the item and it's size as well as the order amount.
 */
$orderItems = array();
foreach ($_REQUEST["item"] as $key => $value) {
    if ($value !== "") {
        $orderItems[] = array("name" => mb_str_pad($key, 40), "amount" => mb_str_pad($value, 4));
    }
}
$variables = array();
$variables["name"] = $_REQUEST["name"];
$variables["email"] = $_REQUEST["email"];
$variables["comments"] = $_REQUEST["comments"];
$variables["items"] = $orderItems;
$twig->display('ordercomplete.html', $variables);
flush();
$mailtext = $twig->render('mailtemplate.txt', $variables);
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=utf-8\r\n";
$headers .= "Content-Transfer-Encoding: 8bit";
// targetMails is defined in config.php, gets appended with the order person's mail
$targetMails[] = $_REQUEST["email"];
mail(implode(",", $targetMails), "RZL-Merchandise-Shop Bestellung", $mailtext, $headers);
Ejemplo n.º 20
0
 /**
  * Render authorizenet form view
  *
  * @return string view html
  */
 public function renderPaymentView()
 {
     $formType = $this->formFactory->create('authorizenet_view');
     return $this->environment->display('AuthorizenetBundle:Authorizenet:view.html.twig', array('authorizenet_form' => $formType->createView(), 'authorizenet_execute_route' => AuthorizenetRoutesLoader::ROUTE_NAME));
 }
Ejemplo n.º 21
0
$haml = new MtHaml\Environment('twig', array('enable_escaper' => false));
$arrayLoader = new Twig_Loader_Filesystem(array(__DIR__));
/*
 * Use a custom loader as a proxy to the actual loader. The custom loader is
 * responsible of converting HAML templates to Twig, before returning them.
 */
$hamlLoader = new MtHaml\Support\Twig\Loader($haml, $arrayLoader);
$twig = new Twig_Environment($hamlLoader);
/*
 * Register the Twig extension. Compiled templates sometimes need this to
 * execute, depending on HAML features in use (some filters, some attributes).
 */
$twig->addExtension(new MtHaml\Support\Twig\Extension($haml));
/*
 * Execute the template:
 */
echo "\n\nExecuted Template:\n\n";
if (true) {
    // parsed as haml because of extension
    $twig->display('example-twig.haml', array());
} else {
    // parsed as haml because code starts with {% haml %}
    $twig->display('example-twig-noext.twig', array());
}
/*
 * See how MtHaml compiles HAML to Twig:
 */
$template = __DIR__ . '/example-twig.haml';
$compiled = $haml->compileString(file_get_contents($template), $template);
echo "\n\nHow the template was compiled:\n\n";
echo $compiled;
Ejemplo n.º 22
0
 public function display($name, array $values = array())
 {
     return $this->engine->display($name . $this->suffix, $values);
 }
Ejemplo n.º 23
0
Archivo: oc.php Proyecto: sd-studio/oc
 public static function display($tpl, &$params = array())
 {
     $loader = new Twig_Loader_Filesystem();
     $paths = scandir(self::$twig);
     foreach ($paths as $path) {
         if ($path != '.' && $path != '..' && is_dir(self::$twig . "/{$path}")) {
             $loader->addPath(self::$twig . "/{$path}", $path);
         }
     }
     $twig = new Twig_Environment($loader, array('cache' => $_SERVER['DOCUMENT_ROOT'] . '/twig_cache', 'autoescape' => false, 'debug' => true, 'auto_reload' => true));
     $twig->addExtension(new Twig_Extension_Debug());
     $thumb = new Twig_SimpleFunction('thumb', function ($img, $w, $h) {
         return oc::model('tool_image')->resize($img, $w, $h);
     });
     $twig->addFunction($thumb);
     $watermark = new Twig_SimpleFilter('watermark', function ($img, $type = 'tiles', $hide = 100) {
         return oc::image_watermark($img, $type, $hide);
     });
     $twig->addFilter($watermark);
     $image_url = new Twig_SimpleFilter('image_url', function ($path) {
         return oc::image_url($path);
     });
     $twig->addFilter($image_url);
     $showPrice = new Twig_SimpleFilter('price', function ($n, $decimals = 0, $dec_point = '.', $thousands_sep = ' ') {
         return number_format($n, $decimals, $dec_point, $thousands_sep);
     });
     $twig->addFilter($showPrice);
     $showdate = new Twig_SimpleFunction('show_date', function ($dt, $to = 'full', $from = 'mysql') {
         static $months = array('января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря');
         $parts = array();
         if ($from == 'mysql') {
             //2011-09-30 01:06:53
             preg_match("/^(\\d{4})-(\\d{2})-(\\d{2})/", $dt, $parts);
         }
         if ($to == 'full') {
             return $parts[3] . ' ' . $months[$parts[2] - 1] . ' ' . $parts[1] . ' г.';
         } else {
             if ($to == 'short') {
                 return $parts[3] . '.' . $parts[2] . '.' . $parts[1];
             }
         }
     });
     $twig->addFunction($showdate);
     $repeat = new Twig_SimpleFilter('repeat', function ($s, $n) {
         return str_repeat($s, $n);
     });
     $twig->addFilter($repeat);
     $firstp = new Twig_SimpleFilter('firstp', function ($s) {
         return substr($s, 0, strpos($s, "</p>") + 4);
     });
     $twig->addFilter($firstp);
     $replaceURI = new Twig_SimpleFilter('replaceURI', function ($url, $nm, $val) {
         return preg_match("/[?&]{1}{$nm}=/", $url) ? preg_replace("/([?&]{1}{$nm})=[^&]*/", "\$1={$val}", $url) : $url . (strpos($url, '?') === false ? '?' : '&') . "{$nm}={$val}";
     });
     $twig->addFilter($replaceURI);
     $findAttribute = new Twig_SimpleFilter('attribute', function ($allAttributes, $name) {
         list($groupName, $attrName) = explode(':', $name);
         foreach ($allAttributes as $group) {
             if (mb_strtolower($group['name'], 'UTF-8') == mb_strtolower($groupName, 'UTF-8')) {
                 foreach ($group['attribute'] as $attribute) {
                     if (mb_strtolower($attribute['name'], 'UTF-8') == mb_strtolower($attrName, 'UTF-8')) {
                         return $attribute['text'];
                     }
                 }
             }
         }
         return '';
     });
     $twig->addFilter($findAttribute);
     self::$params['path'] = self::$root;
     self::$params['server'] = array('request_uri' => html_entity_decode($_SERVER['REQUEST_URI']));
     self::$params['cart'] = array('total_products' => oc::cart()->countProducts(), 'total_sum' => oc::cart()->getTotal());
     self::$params['uname'] = oc::customer()->isLogged() ? oc::customer()->getLastName() . ' ' . oc::customer()->getFirstName() : null;
     $twig->display("@{$tpl}.html", self::$params);
 }