/** * Constructor * * @param \phpbb\config\config $phpbb_config The phpBB configuration * @param \phpbb\path_helper $path_helper phpBB path helper * @param \phpbb\extension\manager $extension_manager phpBB extension manager * @param \Twig_LoaderInterface $loader Twig loader interface * @param array $options Array of options to pass to Twig */ public function __construct($phpbb_config, \phpbb\path_helper $path_helper, \phpbb\extension\manager $extension_manager = null, \Twig_LoaderInterface $loader = null, $options = array()) { $this->phpbb_config = $phpbb_config; $this->phpbb_path_helper = $path_helper; $this->extension_manager = $extension_manager; $this->phpbb_root_path = $this->phpbb_path_helper->get_phpbb_root_path(); $this->web_root_path = $this->phpbb_path_helper->get_web_root_path(); return parent::__construct($loader, $options); }
/** * Constructor * * @param \phpbb\config\config $phpbb_config The phpBB configuration * @param \phpbb\filesystem\filesystem $filesystem * @param \phpbb\path_helper $path_helper phpBB path helper * @param \Symfony\Component\DependencyInjection\ContainerInterface $container The dependency injection container * @param string $cache_path The path to the cache directory * @param \phpbb\extension\manager $extension_manager phpBB extension manager * @param \Twig_LoaderInterface $loader Twig loader interface * @param array $options Array of options to pass to Twig */ public function __construct(\phpbb\config\config $phpbb_config, \phpbb\filesystem\filesystem $filesystem, \phpbb\path_helper $path_helper, \Symfony\Component\DependencyInjection\ContainerInterface $container, $cache_path, \phpbb\extension\manager $extension_manager = null, \Twig_LoaderInterface $loader = null, $options = array()) { $this->phpbb_config = $phpbb_config; $this->filesystem = $filesystem; $this->phpbb_path_helper = $path_helper; $this->extension_manager = $extension_manager; $this->container = $container; $this->phpbb_root_path = $this->phpbb_path_helper->get_phpbb_root_path(); $this->web_root_path = $this->phpbb_path_helper->get_web_root_path(); $options = array_merge(array('cache' => defined('IN_INSTALL') ? false : $cache_path, 'debug' => false, 'auto_reload' => (bool) $this->phpbb_config['load_tplcompile'], 'autoescape' => false), $options); return parent::__construct($loader, $options); }
/** * Constructor. * * @param \phpbb\path_helper $path_helper * @param \phpbb\config\config $config * @param \phpbb\user $user * @param \phpbb\template\context $context template context * @param \phpbb\extension\manager $extension_manager extension manager, if null then template events will not be invoked */ public function __construct(\phpbb\path_helper $path_helper, $config, $user, \phpbb\template\context $context, \phpbb\extension\manager $extension_manager = null) { $this->path_helper = $path_helper; $this->phpbb_root_path = $path_helper->get_phpbb_root_path(); $this->php_ext = $path_helper->get_php_ext(); $this->config = $config; $this->user = $user; $this->context = $context; $this->extension_manager = $extension_manager; $this->cachepath = $this->phpbb_root_path . 'cache/twig/'; // Initiate the loader, __main__ namespace paths will be setup later in set_style_names() $loader = new \phpbb\template\twig\loader(''); $this->twig = new \phpbb\template\twig\environment( $this->config, $this->path_helper, $this->extension_manager, $loader, array( 'cache' => (defined('IN_INSTALL')) ? false : $this->cachepath, 'debug' => defined('DEBUG'), 'auto_reload' => (bool) $this->config['load_tplcompile'], 'autoescape' => false, ) ); $this->twig->addExtension( new \phpbb\template\twig\extension( $this->context, $this->user ) ); $lexer = new \phpbb\template\twig\lexer($this->twig); $this->twig->setLexer($lexer); // Add admin namespace if ($this->path_helper->get_adm_relative_path() !== null && is_dir($this->phpbb_root_path . $this->path_helper->get_adm_relative_path() . 'style/')) { $this->twig->getLoader()->setPaths($this->phpbb_root_path . $this->path_helper->get_adm_relative_path() . 'style/', 'admin'); } }
/** * Constructor. * * @param \phpbb\path_helper $path_helper * @param \phpbb\config\config $config * @param \phpbb\template\context $context template context * @param \phpbb\template\twig\environment $twig_environment * @param string $cache_path * @param \phpbb\user|null $user * @param array|\ArrayAccess $extensions * @param \phpbb\extension\manager $extension_manager extension manager, if null then template events will not be invoked */ public function __construct(\phpbb\path_helper $path_helper, $config, \phpbb\template\context $context, \phpbb\template\twig\environment $twig_environment, $cache_path, \phpbb\user $user = null, $extensions = array(), \phpbb\extension\manager $extension_manager = null) { $this->path_helper = $path_helper; $this->phpbb_root_path = $path_helper->get_phpbb_root_path(); $this->php_ext = $path_helper->get_php_ext(); $this->config = $config; $this->user = $user; $this->context = $context; $this->extension_manager = $extension_manager; $this->cachepath = $cache_path; $this->twig = $twig_environment; foreach ($extensions as $extension) { $this->twig->addExtension($extension); } // Add admin namespace if ($this->path_helper->get_adm_relative_path() !== null && is_dir($this->phpbb_root_path . $this->path_helper->get_adm_relative_path() . 'style/')) { $this->twig->getLoader()->setPaths($this->phpbb_root_path . $this->path_helper->get_adm_relative_path() . 'style/', 'admin'); } }
/** * Set path component * * @param string $path Path component * @param boolean $urlencode If true, parts of path should be encoded with rawurlencode() */ public function set_path($path, $urlencode = false) { // Since 1.7.0 Twig returns the real path of the file. We need it to be relative to the working directory. $real_root_path = realpath($this->path_helper->get_phpbb_root_path()) . DIRECTORY_SEPARATOR; // If the asset is under the phpBB root path we need to remove its path and then prepend $phpbb_root_path if (substr($path . DIRECTORY_SEPARATOR, 0, strlen($real_root_path)) === $real_root_path) { $path = $this->path_helper->get_phpbb_root_path() . str_replace('\\', '/', substr($path, strlen($real_root_path))); } else { // Else we make the path relative to the current working directory $real_root_path = realpath('.') . DIRECTORY_SEPARATOR; if ($real_root_path && substr($path . DIRECTORY_SEPARATOR, 0, strlen($real_root_path)) === $real_root_path) { $path = str_replace('\\', '/', substr($path, strlen($real_root_path))); } } if ($urlencode) { $paths = explode('/', $path); foreach ($paths as &$dir) { $dir = rawurlencode($dir); } $path = implode('/', $paths); } $this->components['path'] = $path; }
public function __construct(\phpbb\path_helper $path_helper, $config, $user, \phpbb\template\context $context, \phpbb\extension\manager $extension_manager = null) { $this->path_helper = $path_helper; $this->phpbb_root_path = $path_helper->get_phpbb_root_path(); $this->php_ext = $path_helper->get_php_ext(); $this->config = $config; $this->user = $user; $this->context = $context; $this->extension_manager = $extension_manager; $this->cachepath = $this->phpbb_root_path . 'cache/twig/'; // Initiate the loader, __main__ namespace paths will be setup later in set_style_names() $loader = new \phpbb\template\twig\loader(''); $this->twig = new \phpbb\template\twig\environment($this->config, $this->path_helper, $this->extension_manager, $loader, array('cache' => defined('IN_INSTALL') ? false : $this->cachepath, 'debug' => defined('DEBUG'), 'auto_reload' => (bool) $this->config['load_tplcompile'], 'autoescape' => false)); $this->twig->addExtension(new \phpbb\template\twig\extension($this->context, $this->user)); // Initialize Gantry. $style = 'gantry'; $this->gantry = (require_once $this->phpbb_root_path . "styles/{$style}/gantry.php"); $this->gantry['streams']; $this->gantry['theme']->add_to_twig($this->twig); if (defined('ADMIN_START')) { // We are in admin. define('GANTRYADMIN_PATH', GANTRY5_ROOT . '/ext/rockettheme/gantry'); $this->gantry['admin.theme'] = function () { return new \Gantry\Admin\Theme(GANTRYADMIN_PATH); }; // Boot the service. $this->gantry['admin.theme']; } // Initialize lexer. $lexer = new \phpbb\template\twig\lexer($this->twig); $this->twig->setLexer($lexer); // Add admin namespace if ($this->path_helper->get_adm_relative_path() !== null && is_dir($this->phpbb_root_path . $this->path_helper->get_adm_relative_path() . 'style/')) { $this->twig->getLoader()->setPaths($this->phpbb_root_path . $this->path_helper->get_adm_relative_path() . 'style/', 'admin'); } }