/var
/www
/clients
/client1
/web2
/web
/private
/beautycare
/libraries
/Frontend.php
//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
$slugGenitori = $this->getLivello($this->templateParameters['currentPath'], $this->templateParameters['menu'][0], 1, [null], $depthCategorie);
//template
$template = 'categoria-vuota';
if(!isset($this->routeParameters['path'])) {
//categorie 0 level
$template = 'categorie-0';
} else {
$this->addApplicationTranslations('gamme_prodotti','gamme_prodotti.ini');
//categorie 1+ level
if($this->templateParameters['categoriaSelezionata']['numero_figlie'] > 0) {
$template = 'categorie-1+';
}
//gamme prodotti
if($this->templateParameters['categoriaSelezionata']['numero_gamme'] > 0) {
//elenco gamme
$gamme = $this->getGammeCategoria($this->templateParameters['categoriaSelezionata']['categoria_id']);
$pathDepth = count($this->templateParameters['currentPath']);
$gammaLevel = $this->templateParameters['categoriaSelezionata']['numero_gamme'] == 1 ? $depthCategorie : $depthCategorie + 1;
$prodottoSelezionato = isset($this->templateParameters['currentPath'][$gammaLevel + 1]);
//path to gamma
$this->templateParameters['pathToGamma'] = join('/',array_slice($this->templateParameters['currentPath'], 0, $gammaLevel));
//gamma prodotti
if(!$prodottoSelezionato) {
//gamma unica o selezionata
if($this->templateParameters['categoriaSelezionata']['numero_gamme'] == 1 || $pathDepth > $depthCategorie) {
//locale
$this->addApplicationTranslations('espositori','espositori.ini');
//section
$this->templateParameters['section'] = isset($this->templateParameters['currentPath'][$gammaLevel]) ? $this->templateParameters['currentPath'][$gammaLevel] : false;
if($this->templateParameters['categoriaSelezionata']['numero_gamme'] == 1) {
/var
/www
/clients
/client1
/web2
/web
/private
/beautycare
/libraries
/Frontend.php
//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
$slugGenitori = $this->getLivello($this->templateParameters['currentPath'], $this->templateParameters['menu'][0], 1, [null], $depthCategorie);
//template
$template = 'categoria-vuota';
if(!isset($this->routeParameters['path'])) {
//categorie 0 level
$template = 'categorie-0';
} else {
$this->addApplicationTranslations('gamme_prodotti','gamme_prodotti.ini');
//categorie 1+ level
if($this->templateParameters['categoriaSelezionata']['numero_figlie'] > 0) {
$template = 'categorie-1+';
}
//gamme prodotti
if($this->templateParameters['categoriaSelezionata']['numero_gamme'] > 0) {
//elenco gamme
$gamme = $this->getGammeCategoria($this->templateParameters['categoriaSelezionata']['categoria_id']);
$pathDepth = count($this->templateParameters['currentPath']);
$gammaLevel = $this->templateParameters['categoriaSelezionata']['numero_gamme'] == 1 ? $depthCategorie : $depthCategorie + 1;
$prodottoSelezionato = isset($this->templateParameters['currentPath'][$gammaLevel + 1]);
//path to gamma
$this->templateParameters['pathToGamma'] = join('/',array_slice($this->templateParameters['currentPath'], 0, $gammaLevel));
//gamma prodotti
if(!$prodottoSelezionato) {
//gamma unica o selezionata
if($this->templateParameters['categoriaSelezionata']['numero_gamme'] == 1 || $pathDepth > $depthCategorie) {
//locale
$this->addApplicationTranslations('espositori','espositori.ini');
//section
$this->templateParameters['section'] = isset($this->templateParameters['currentPath'][$gammaLevel]) ? $this->templateParameters['currentPath'][$gammaLevel] : false;
if($this->templateParameters['categoriaSelezionata']['numero_gamme'] == 1) {
/var
/www
/clients
/client1
/web2
/web
/private
/beautycare
/libraries
/Frontend.php
} else {
$logAction = 'display-login';
$logLabel = $this->translations['frontend']['main_menu']['login_link'];
}
$this->templateParameters['menu'] = [
[
'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']);
/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);