Classes

File io/template/TemplateFunctions.class.php

File io/template/TemplateFunctions.class.php

  1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 
<?php
/**
 * @package     IO
 * @subpackage  Template
 * @copyright   &copy; 2005-2019 PHPBoost
 * @license     https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL-3.0
 * @author      Loic ROUCHON <horn@phpboost.com>
 * @version     PHPBoost 5.2 - last update: 2014 12 22
 * @since       PHPBoost 3.0 - 2010 09 11
*/

class TemplateFunctions
{
    /**
     * @var I18NMessages
     */
    private $i18n;

    public function __construct()
    {
        $this->i18n = new I18NMessages();
    }

    public function resources($resources)
    {
        $this->i18n->resources($resources);
    }

    private function add_resource($resource)
    {
        $this->i18n->add_resource($resource);
    }

    public function add_language_maps(array $lang)
    {
        $this->i18n->add_language_maps($lang);
    }

    public function i18n($key, array $parameters = null)
    {
        return $this->i18n->i18n($key, $parameters);
    }

    public function i18njs($key, array $parameters = null)
    {
        return $this->i18n->i18njs($key, $parameters);
    }

    public function i18njsraw($key, array $parameters = null)
    {
        return $this->i18n->i18njsraw($key, $parameters);
    }

    public function i18nraw($key, array $parameters = null)
    {
        return $this->i18n->i18nraw($key, $parameters);
    }

    /**
     * applies htmlspecialchars php function to the given string
     * @param $string A String
     * @return string the string without html special chars
     */
    public function escape($string)
    {
        return TextHelper::htmlspecialchars($string);
    }

    public function html($string)
    {
        return TextHelper::htmlspecialchars_decode($string);
    }

    /**
     * Exports a variable to be used in a javascript script.
     * @param string $string A PHP string to convert to a JS one
     * @param string $add_quotes If true, returned string will be bounded by quotes
     * @return string The js equivalent string
     */
    public function escapejs($string, $add_quotes = true)
    {
        return TextHelper::to_js_string($string, $add_quotes);
    }

    /**
     * Escape characters for use javascript script.
     * @param string $string string for conversion
     * @return string String escaped
     */
    public function escapejscharacters($string)
    {
        return strtr(Url::encode_rewrite($string), '-', '_');
    }

    public function set($string, array $parameters)
    {
        return StringVars::replace_vars($string, $parameters);
    }

    public function relative_url(Url $url)
    {
        return $url->rel();
    }

    public function absolute_url(Url $url)
    {
        return $url->absolute();
    }
}
?>