/var
/www
/clients
/client1
/web2
/private
/vendor
/twig
/twig
/lib
/Twig
/Loader
/Filesystem.php
if (!$this->isAbsolutePath($path)) {
$path = $this->rootPath.'/'.$path;
}
if (is_file($path.'/'.$shortname)) {
if (false !== $realpath = realpath($path.'/'.$shortname)) {
return $this->cache[$name] = $realpath;
}
return $this->cache[$name] = $path.'/'.$shortname;
}
}
$this->errorCache[$name] = sprintf('Unable to find template "%s" (looked into: %s).', $name, implode(', ', $this->paths[$namespace]));
if (!$throw) {
return false;
}
throw new Twig_Error_Loader($this->errorCache[$name]);
}
protected function parseName($name, $default = self::MAIN_NAMESPACE)
{
if (isset($name[0]) && '@' == $name[0]) {
if (false === $pos = strpos($name, '/')) {
throw new Twig_Error_Loader(sprintf('Malformed namespaced template name "%s" (expecting "@namespace/template_name").', $name));
}
$namespace = substr($name, 1, $pos - 1);
$shortname = substr($name, $pos + 1);
return array($namespace, $shortname);
}
return array($default, $name);
}
protected function normalizeName($name)
{
/var
/www
/clients
/client1
/web2
/private
/vendor
/twig
/twig
/lib
/Twig
/Loader
/Filesystem.php
}
}
public function getSource($name)
{
@trigger_error(sprintf('Calling "getSource" on "%s" is deprecated since 1.27. Use getSourceContext() instead.', get_class($this)), E_USER_DEPRECATED);
return file_get_contents($this->findTemplate($name));
}
public function getSourceContext($name)
{
$path = $this->findTemplate($name);
return new Twig_Source(file_get_contents($path), $name, $path);
}
public function getCacheKey($name)
{
$path = $this->findTemplate($name);
$len = strlen($this->rootPath);
if (0 === strncmp($this->rootPath, $path, $len)) {
return substr($path, $len);
}
return $path;
}
public function exists($name)
{
$name = $this->normalizeName($name);
if (isset($this->cache[$name])) {
return true;
}
try {
return false !== $this->findTemplate($name, false);
} catch (Twig_Error_Loader $exception) {
@trigger_error(sprintf('In %s::findTemplate(), you must accept a second argument that when set to "false" returns "false" instead of throwing an exception. Not supporting this argument is deprecated since version 1.27.', get_class($this)), E_USER_DEPRECATED);
/var
/www
/clients
/client1
/web2
/private
/vendor
/twig
/twig
/lib
/Twig
/Environment.php
/**
* Gets the template class associated with the given string.
*
* The generated template class is based on the following parameters:
*
* * The cache key for the given template;
* * The currently enabled extensions;
* * Whether the Twig C extension is available or not;
* * PHP version;
* * Twig version;
* * Options with what environment was created.
*
* @param string $name The name for which to calculate the template class name
* @param int|null $index The index if it is an embedded template
*
* @return string The template class name
*/
public function getTemplateClass($name, $index = null)
{
$key = $this->getLoader()->getCacheKey($name).$this->optionsHash;
return $this->templateClassPrefix.hash('sha256', $key).(null === $index ? '' : '_'.$index);
}
/**
* Gets the template class prefix.
*
* @return string The template class prefix
*
* @deprecated since 1.22 (to be removed in 2.0)
*/
public function getTemplateClassPrefix()
{
@trigger_error(sprintf('The %s method is deprecated since version 1.22 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
return $this->templateClassPrefix;
}
/**
* Renders a template.
/var
/www
/clients
/client1
/web2
/private
/vendor
/twig
/twig
/lib
/Twig
/Environment.php
/**
* Loads a template internal representation.
*
* This method is for internal use only and should never be called
* directly.
*
* @param string $name The template name
* @param int $index The index if it is an embedded template
*
* @return Twig_TemplateInterface A template instance representing the given template name
*
* @throws Twig_Error_Loader When the template cannot be found
* @throws Twig_Error_Runtime When a previously generated cache is corrupted
* @throws Twig_Error_Syntax When an error occurred during compilation
*
* @internal
*/
public function loadTemplate($name, $index = null)
{
$cls = $mainCls = $this->getTemplateClass($name);
if (null !== $index) {
$cls .= '_'.$index;
}
if (isset($this->loadedTemplates[$cls])) {
return $this->loadedTemplates[$cls];
}
if (!class_exists($cls, false)) {
if ($this->bcGetCacheFilename) {
$key = $this->getCacheFilename($name);
} else {
$key = $this->cache->generateKey($name, $mainCls);
}
if (!$this->isAutoReload() || $this->isTemplateFresh($name, $this->cache->getTimestamp($key))) {
$this->cache->load($key);
}
if (!class_exists($cls, false)) {
/var
/www
/clients
/client1
/web2
/private
/vendor
/twig
/twig
/lib
/Twig
/Environment.php
@trigger_error(sprintf('The %s method is deprecated since version 1.22 and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
return $this->templateClassPrefix;
}
/**
* Renders a template.
*
* @param string $name The template name
* @param array $context An array of parameters to pass to the template
*
* @return string The rendered template
*
* @throws Twig_Error_Loader When the template cannot be found
* @throws Twig_Error_Syntax When an error occurred during compilation
* @throws Twig_Error_Runtime When an error occurred during rendering
*/
public function render($name, array $context = array())
{
return $this->loadTemplate($name)->render($context);
}
/**
* Displays a template.
*
* @param string $name The template name
* @param array $context An array of parameters to pass to the template
*
* @throws Twig_Error_Loader When the template cannot be found
* @throws Twig_Error_Syntax When an error occurred during compilation
* @throws Twig_Error_Runtime When an error occurred during rendering
*/
public function display($name, array $context = array())
{
$this->loadTemplate($name)->display($context);
}
/**
* Loads a template.
*
/var
/www
/clients
/client1
/web2
/private
/vendor
/phpcraft
/template
/src
/TwigAdapter.php
/**
* Constructor.
*
* @param Twig_Environment $renderer
**/
public function __construct(Twig_Environment $renderer)
{
$this->renderer = $renderer;
}
/**
* Renders template
*
* @param string $template template path into Twig_Environment template directory
* @param array $templateParameters parameters to be passed to template
**/
public function render($template, $templateParameters = [])
{
return $this->renderer->render($template.'.html', $templateParameters);
}
/**
* adds a function
*
* @param string $template template path into Twig_Environment template directory
* @param array $templateParameters parameters to be passed to template
**/
public function addFunction($name, $functionBody)
{
$function = new \Twig_SimpleFunction($name, $functionBody);
$this->renderer->addFunction($function);
}
}
/var
/www
/clients
/client1
/web2
/private
/vendor
/phpcraft
/subject
/src
/Subject.php
* Sets a template parameter
* @param string $key;
* @param mixed $value;
**/
public function setTemplateParameter($key, $value)
{
$this->templateParameters[$key] = $value;
}
/**
* Renders action template
* @param string $path;
**/
protected function renderTemplate($path = false)
{
if(!$path) {
$path = sprintf('%s/%s/%s', $this->area, $this->subject, $this->action);
}
$this->templateParameters['translations'] = $this->translations;
$html = $this->template->render($path, $this->templateParameters);
$this->httpStream->write($html);
}
}
/var
/www
/clients
/client1
/web2
/web
/private
/beautycare
/libraries
/Frontend.php
[
'slug' => 'prodotti','nome' => $this->translations['frontend']['main_menu']['prodotti_link'],
],
/*[
'slug' => 'espositori','nome' => $this->translations['frontend']['main_menu']['display_link']
]
[
'slug' => 'artworks','nome' => $this->translations['frontend']['main_menu']['artworks_link']
],*/
[
'slug' => 'utenti/' . $logAction,'nome' => $logLabel
]
];
//handle subject
$template = $this->{'display' . ucfirst($this->subject)}();
$this->templateParameters['page_title'] = sprintf('%s - %s - %s', $this->translations['application']['marketing']['brand'], $this->translations['application']['marketing']['division'], $this->translations['application']['marketing']['area']);
//$this->setPageTitle($this->templateParameters['subject_title']);
//$this->templateParameters['translations'] = $this->translations;
$this->renderTemplate('frontend/' . $template);
}
/**
* displays prodotti
* @return string $template
*/
private function displayProdotti()
{
//locale
$this->addApplicationTranslations('prodotti','prodotti.ini');
//currently selected path
if(!isset($this->routeParameters['path'])) {
$categorieSelezionate = [];
} else {
$categorieSelezionate = explode('/', $this->routeParameters['path']);
$this->templateParameters['currentPath'] = array_merge($this->templateParameters['currentPath'], $categorieSelezionate);
}
//immagine testata di default
$this->templateParameters['immagineTestata'] = 'public/beautycare/assets/images/testata_default.png';
//menu
/var
/www
/clients
/client1
/web2
/private
/vendor
/phpcraft
/subject
/src
/Subject.php
* @param string $pathToIniFile file path into private/application-name/curent-language/
* @throws InvalidArgumentException if file is not found
**/
public function addApplicationTranslations($key, $pathToIniFile)
{
$path = sprintf('private/%s/locales/%s/%s', $this->application, $this->language, $pathToIniFile);
$this->addTranslations($key, $path);
}
/**
* tries to exec current action
* @throws Exception if there is no method defined to handle action
**/
public function execAction()
{
try {
$this->templateParameters['area'] = $this->area;
$this->templateParameters['areaAuthentication'] = $this->areaAuthentication;
$this->getBackPaths();
$this->{'exec'.ucfirst($this->sanitizeAction($this->action))}();
} catch(Exception $exception) {
throw new Exception(sprintf('no method for handling %s %s %s', $this->area, $this->subject, $this->action));
}
}
/**
* Stores a path to turn back lately
**/
public function execBackPath()
{
$arguments = array(
'backId' => FILTER_SANITIZE_STRING,
'backPath' => array(
'filter' => FILTER_SANITIZE_URL,
'flags' => FILTER_FLAG_PATH_REQUIRED
),
'backLabel' => FILTER_SANITIZE_STRING,
);
$input = filter_input_array(INPUT_POST, $arguments);
$this->cookie->set('backPaths[' . $input['backId'] . '][path]', $input['backPath']);
/var
/www
/clients
/client1
/web2
/web
/private
/beautycare
/procedures
/bootstrap.php
if(!in_array(LANGUAGE, $configuration['languages'])) throw new Exception("language not into configured languages");
//load specific area configuration and procedure if needed
if($configuration['areas'][AREA]['configuration']) {
require sprintf('private/%s/configurations/%s.php', APPLICATION, AREA);
}
if($configuration['areas'][AREA]['procedure']) {
require sprintf('private/%s/procedures/%s.php', APPLICATION, AREA);
}
//require subject procedure
$subject = require sprintf('private/%s/procedures/%s/%s.php', APPLICATION, AREA, SUBJECT);
//load specific application and area translations if needed
if($configuration['locale']) {
$subject->addApplicationTranslations('application', 'application.ini');
}
if($configuration['areas'][AREA]['locale']) {
$subject->addApplicationTranslations(AREA, sprintf('%s.ini', AREA));
}
//subject action
$subject->execAction();
}
//output
// set headers
foreach ($http->response->getHeaders() as $name => $values) {
foreach ($values as $value) {
@header(sprintf('%s: %s', $name, $value), false);
}
}
//check status code
switch($http->response->getStatusCode()) {
case 200:
break;
default:
@header($_SERVER["SERVER_PROTOCOL"]." " . $http->response->getStatusCode());
break;
}
// output body
$http->response = $http->response->withBody($http->stream);
echo $http->response->getBody();
/var
/www
/clients
/client1
/web2
/web
/index.php
<?php
//application name and namesapce
define('APPLICATION','beautycare');
define('APPLICATION_NAMESPACE','Beautycare');
//bootstrap
require sprintf('private/%s/procedures/bootstrap.php', APPLICATION);