/var
/www
/clients
/client1
/web2
/web
/private
/beautycare
/libraries
/Frontend.php
$prodotti = $this->queryBuilder->get();
$numProdotti = count($prodotti);
for($i=0; $i<$numProdotti; $i++) {
if($prodotti[$i]->immagine_visualizzata) {
$prodotti[$i]->immagine_visualizzata = current(json_decode($prodotti[$i]->immagine_visualizzata));
}
}
return $prodotti;
}
/**
* gets prodotto
* @param int $gamma_prodotti_id
*/
private function getGammaProdotti($slug)
{
$this->queryBuilder->table('v_gamme_prodotti')->where('slug', $slug);
$gamma = current($this->queryBuilder->get());
//$this->queryBuilder->outputQuery();
$pdf_steso = json_decode($gamma->pdf_steso);
$gamma->pdf_stesi = [];
if($pdf_steso) {
foreach($pdf_steso as $pdf) {
$gamma->pdf_stesi[] = [
'name' => str_replace(['_'],' ',pathinfo($pdf->input->name, PATHINFO_FILENAME)),
'path' => $pdf->outputs->full->path
];
}
//r($gamma->pdf_stesi);
$gamma->pdf_stesi = array_reverse($gamma->pdf_stesi);
//~r($gamma->pdf_stesi);
}
//get
return $gamma;
}
/**
* gets prodotto
* @param string $slug
*/
/var
/www
/clients
/client1
/web2
/web
/private
/beautycare
/libraries
/Frontend.php
$prodotti = $this->queryBuilder->get();
$numProdotti = count($prodotti);
for($i=0; $i<$numProdotti; $i++) {
if($prodotti[$i]->immagine_visualizzata) {
$prodotti[$i]->immagine_visualizzata = current(json_decode($prodotti[$i]->immagine_visualizzata));
}
}
return $prodotti;
}
/**
* gets prodotto
* @param int $gamma_prodotti_id
*/
private function getGammaProdotti($slug)
{
$this->queryBuilder->table('v_gamme_prodotti')->where('slug', $slug);
$gamma = current($this->queryBuilder->get());
//$this->queryBuilder->outputQuery();
$pdf_steso = json_decode($gamma->pdf_steso);
$gamma->pdf_stesi = [];
if($pdf_steso) {
foreach($pdf_steso as $pdf) {
$gamma->pdf_stesi[] = [
'name' => str_replace(['_'],' ',pathinfo($pdf->input->name, PATHINFO_FILENAME)),
'path' => $pdf->outputs->full->path
];
}
//r($gamma->pdf_stesi);
$gamma->pdf_stesi = array_reverse($gamma->pdf_stesi);
//~r($gamma->pdf_stesi);
}
//get
return $gamma;
}
/**
* gets prodotto
* @param string $slug
*/
/var
/www
/clients
/client1
/web2
/web
/private
/beautycare
/libraries
/Frontend.php
$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) {
$gamma = array_shift($gamme);
} else {
$gammaSelezionata = array_pop($categorieSelezionate);
if($gammaSelezionata == 'materiali') {
$gammaSelezionata = array_pop($categorieSelezionate);
}
$gamma = $this->getGammaProdotti($gammaSelezionata);
}
$this->templateParameters['sections'] = ['volantini' => false, 'gammaProdotti' => false];
//gamma prodotti
if(!$this->templateParameters['section']) $this->templateParameters['section'] = 'gamma-prodotti';
if($gamma->numero_prodotti > 0) {
//if(!$this->templateParameters['section']) $this->templateParameters['section'] = 'gamma-prodotti';
//$this->templateParameters['sections']['gammaProdotti'] = true;
$gamma->prodotti = $this->getProdottiGamma($gamma->gamma_prodotti_id);
}
//materiali
if($gamma->logo) {
//if(!$this->templateParameters['section']) $this->templateParameters['section'] = 'volantini';
//$this->templateParameters['sections']['volantini'] = true;
$logo = current(json_decode($gamma->logo));
$gamma->logo = ['thumb' => $logo->outputs->thumb->path, 'full' => $logo->outputs->full->path];
}
/*if($gamma->pdf_steso) {
$pdf_steso = json_decode($gamma->pdf_steso);
r($pdf_steso);
$gamma->pdf_steso = ['path' => $pdf_steso->outputs->full->path];
/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);