/var/www/html/vendor/wmindsrl/common/src/EntityCMS/bin/appLoader.php
public $folder_entity;
public $root_entitydata;
public $root_entitycache;
public $pages;
/**
* Carica la configurazione da file JSON
*
* @param string $appcode Codice dell'app (es: "agrivite")
* @param array $param Parametri di inizializzazione
* @throws \RuntimeException Se il file JSON non esiste o è malformato
*/
public function __construct(string $appcode, array $param = []) {
$this->pages = $param['pages'] ?? null;
// Percorso del file JSON di configurazione
$config_path = $this->getConfigPath($appcode);
if (!file_exists($config_path)) {
throw new \RuntimeException("EntityCMS config file not found: " . $config_path);
}
// Carica e decodifica il JSON
$json_content = file_get_contents($config_path);
$config = json_decode($json_content, true);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \RuntimeException("Invalid JSON in config file: " . json_last_error_msg());
}
// Imposta le proprietà base
$this->database = $config['database'] ?? null;
$this->table_pre = $config['table_pre'] ?? null;
$this->folder_entity = $config['folder_entity'] ?? null;
// Hardcode delle costanti (come discusso)
$this->root_entitydata = defined('SRC_ENTITYDATA') ? constant('SRC_ENTITYDATA') : null;
$this->root_entitycache = defined('SRC_ENTITYCACHE') ? constant('SRC_ENTITYCACHE') : null;
// Processa categorymap e relationmap
/var/www/html/vendor/wmindsrl/common/src/EntityCMS/bin/entitycms.php
// Update app properties runtime
if(!empty($param['app'])) $this->updateAppRuntime($param['app']);
}
function initApp(?string $app = null) {
$appcode = !empty($app) ? $app : (defined("ENTITYCMS_APP") ? constant("ENTITYCMS_APP") : NULL);
if(empty($appcode)) throw new \UnexpectedValueException("APP not set");
if($this->pages->enabled) {
// Frontend: pages già caricato con load()
$param = ["pages" => $this->pages];
} else {
// Backend: carichiamo con setAppid + load
$this->pages->setAppid($appcode);
$this->pages->load();
$param = ["pages" => $this->pages];
}
$this->app = new appLoader($appcode, $param);
if(empty($this->app->root_entitydata)) throw new \RuntimeException("Root entitydata non impostata (".$app.")");
if(empty($this->app->folder_entity)) throw new \RuntimeException("Folder entitydata non impostata (".$app.")");
$this->src_entitydata = $this->app->root_entitydata.$this->app->folder_entity."/";
if(!empty($this->app->root_entitycache) && is_dir($this->app->root_entitycache.$this->app->folder_entity."/")) {
$this->src_entitycache = $this->app->root_entitycache.$this->app->folder_entity."/";
if(!is_writable($this->src_entitycache)) throw new \RuntimeException("SRC entitycache not writable (".$this->src_entitycache.", ".$app.")");
$this->cache_enabled = true;
}
}
protected function saveCache(string $functionname, array $param, array $data) :void {
if(!$this->cache_enabled) return;
$src = $this->getSrc($functionname, $param);
$jsondata = json_encode($data);
try {
file_put_contents($src,$jsondata);
} catch(\Exception $e) {
throw new \RuntimeException("Unable to write cache file (".$src.")");
/var/www/html/vendor/wmindsrl/common/src/EntityCMS/bin/entitycms.php
var $cache_clear = false;
var $debug;
function __construct(Pages $pages, array $param = []) {
// Initialize validator and sanitizer
$this->validator = new DataValidator();
$this->sanitizer = new DataSanitize();
$this->pages = $pages;
$this->cms = $this->pages->cms;
$this->db = $this->cms->db;
$this->lang = $param['lang'] ?? (empty($this->cms) ? null : $this->cms->getLocale());
if($this->cms->forceclearcache == true) $this->cache_clear = true;
if($this->cms->currentenv == "svil") $this->cache_ttl = 1;
$this->debug = $this->pages->cms->getEnv('DEBUG') ? false : true;
$this->initApp($param['appid'] ?? null);
$this->initTable($this->app->database . '.' . $this->app->table_pre);
// Update app properties runtime
if(!empty($param['app'])) $this->updateAppRuntime($param['app']);
}
function initApp(?string $app = null) {
$appcode = !empty($app) ? $app : (defined("ENTITYCMS_APP") ? constant("ENTITYCMS_APP") : NULL);
if(empty($appcode)) throw new \UnexpectedValueException("APP not set");
if($this->pages->enabled) {
// Frontend: pages già caricato con load()
$param = ["pages" => $this->pages];
} else {
// Backend: carichiamo con setAppid + load
$this->pages->setAppid($appcode);
$this->pages->load();
$param = ["pages" => $this->pages];
}
/var/www/html/vendor/wmindsrl/common/src/EntityCMS/entities.php
<?php
namespace Wmind\Common\EntityCMS;
use \Wmind\Common\Core\Pages;
class entities extends bin\entitycms {
private $param = [];
function __construct(Pages $pages) {
parent::__construct($pages);
}
public function withcategory($categories) :self {
if(!is_array($categories)) $categories = [$categories];
$this->param['category_code'] = $categories;
return $this;
}
public function withcategories(array $categories) :self {
$this->param['category_code'] = $categories;
return $this;
}
public function withrelation(string $relation_code, $entity, bool $inverse = false) :self {
// entity can be string (entity_code) or int (identity) or null (no relation)
//if(empty($entity)) throw new \RuntimeException("Entity for withrelation cannot be empty");
if($entity === null) $this->param['entity_null'] = true; // case null
if(intval($entity)) $this->param['identity'] = intval($entity); // case identity
if(!intval($entity)) $this->param['entity_code'] = $entity; // case entity_code
$this->param['relation_code'] = $relation_code;
$this->param['relation_inverse'] = $inverse;
return $this;
}
public function withparam(string $param_code, $value) :self {
if(empty($this->param['withparam'])) $this->param['withparam'] = [];
$this->param['withparam'][] = ["code" => $param_code, "value" => $value];
/var/www/html/modules/index/videogallery.php
<div class="row align-items-center">
<div class="col-12 col-md-11 col-lg-5 pl-lg-5 text-left content animated" data-animation="">
<span class="caption"><?=__("VGALLERY title area caption");?></span>
<h1 class="my-3 title"><?=__("VGALLERY title area H1");?></h1>
<p class="description"><?=__("VGALLERY title area description");?></p>
</div>
</div>
</div>
<?php
$cms->getModule("_include/_breadcrumb");
breadcrumb($cms->getBreadcrumb());
?>
</section>
<section id="gallery-video">
<h6 style="display: none;">hidden_item</h6>
<div class="container-fluid">
<?php
//elenco video della videogallery
$videos = (new entities($pages))
->withcategory("VIDEOGALLERY")
->get();
if(!empty($videos)) {
$i_n = 1;
foreach($videos as $v) {
?>
<div style="display:none;" id="video<?=$i_n;?>">
<iframe width="100%" height="400" src="<?=$v->text("URL_VIDEO");?>" title="<?=$v->text("DESCR");?>" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
<?php
$i_n++;
}
?>
<ul id="video-gallery" class="list-unstyled row">
<?php
$i_n = 1;
foreach($videos as $v) {
/var/www/html/modules/index/_controller.php
<?php
global $cms, $pages;
main();
/var/www/html/modules/index/videogallery.php
<?php
require_once(__DIR__ . "/_controller.php");
use Wmind\Common\EntityCMS\entities;
function main() {
global $cms,$pages;
?>
<!DOCTYPE html>
<html>
<head>
<?php $cms->getModule("_include/head");?>
<link rel="stylesheet" href="<?= URL_ASSETS; ?>plugins/slick-carousel/slick.min.css" />
<style>
</style>
</head>
<body class="">
<?php $cms->getModule("_include/header");?>
<!-- main_content -->
<div id="main-content" role="main" class="main-content">
<div class="wrapper ">
<section id="hero" class="d-flex align-items-center" style="background-image: url('<?= URL_ASSETS; ?>images/header/header_videogallery.png')">
<div class="container-fluid pl-lg-5">
<div class="row align-items-center">
<div class="col-12 col-md-11 col-lg-5 pl-lg-5 text-left content animated" data-animation="">
<span class="caption"><?=__("VGALLERY title area caption");?></span>
<h1 class="my-3 title"><?=__("VGALLERY title area H1");?></h1>
<p class="description"><?=__("VGALLERY title area description");?></p>
</div>
</div>
</div>
<?php
$cms->getModule("_include/_breadcrumb");
breadcrumb($cms->getBreadcrumb());
?>
</section>
/var/www/html/vendor/wmindsrl/common/src/Core/myCms.php
public function getModule(?string $site, bool $root = false) {
if($this->isMaintenance() && $root) {
$this->header503();
} elseif($this->existsSite($site)) {
$module = $this->getSitePath($site);
$appid = $this->appid;
} elseif($root) {
$this->header404();
} else {
throw new \Exception($site . " not exists");
}
if(!is_callable($this->authcallback)) {
return require($module);
}
if(call_user_func($this->authcallback, $site, $appid)) {
return require($module);
} else {
// Check if user is logged in
if($this->user && method_exists($this->user, 'islogged') && !$this->user->islogged()) {
// User is not logged in - redirect to login page with original URL
$originalUrl = $this->currentRequest();
// Include query string if present
if(!empty($this->remoteinfo['querystring'])) {
$originalUrl .= '?' . $this->remoteinfo['querystring'];
}
// Validate redirect URL is internal (security check)
$loginUrl = $this->currentUrl() . "admin/login/index";
if(!empty($originalUrl) && $originalUrl !== "admin/login/index" && $this->isValidRelativeUrl($originalUrl)) {
$loginUrl .= "?redirect=" . urlencode($originalUrl);
}
$this->redirect302($loginUrl);
return;
/var/www/html/vendor/wmindsrl/common/src/Core/myCms.php
public function setAlternate(string $locale, string $url) :void {
$this->alternate[$locale] = ["locale" => $locale, "url" => $url];
}
public function getAlternate(string $locale) :array {
return $this->alternate[$locale] ?? [];
}
public function getAlternates() :array {
return $this->alternate;
}
public function run(string $site) {
$site = trim($site);
if(empty($site)) $site = "index/index";
$this->site = $site;
$this->action = isset($_GET['action']) ? $_GET['action'] : false;
$this->forceclearcache = empty($_GET['clearcache']) ? false : true;
$this->defineCostants();
$this->getModule($this->site, true);
}
public function getModule(?string $site, bool $root = false) {
if($this->isMaintenance() && $root) {
$this->header503();
} elseif($this->existsSite($site)) {
$module = $this->getSitePath($site);
$appid = $this->appid;
} elseif($root) {
$this->header404();
} else {
throw new \Exception($site . " not exists");
}
if(!is_callable($this->authcallback)) {
/var/www/html/vendor/wmindsrl/common/src/Core/Pages.php
} elseif(!$withslash && !$withdot && empty($flex)) {
$url = $this->baseurl.$req."/";
$this->cms->redirect301($url);
return;
} elseif($withslash && $withdot && empty($flex)) {
$url = $this->baseurl.$req;
$this->cms->redirect301($url);
return;
}
if(isset($flex)) $this->cms->flex($flex);
if($urlmode == self::URLMODE_FIXED || ($urlmode == self::URLMODE_FLEX && empty($flex))) {
$this->cms->setMeta("canonical", $this->baseurl.(empty($req) ? null : $req."/"));
foreach($this->getAlternate($this->key) as $a) {
$this->cms->setAlternate($a['locale'], $a['url']);
}
}
//added to get cms locale
$this->site = $site;
if(empty($param['norun'])) $this->cms->run($this->site);
} elseif($statuscode == 301) {
$this->cms->redirect301($redirecturl);
return;
} elseif($statuscode == 302) {
$this->cms->redirect302($redirecturl);
return;
} elseif($statuscode == 404) {
$this->cms->header404();
return;
} elseif($statuscode == 410) {
$this->cms->header410();
return;
} else {
throw new \UnexpectedValueException("Status code not valid: ".$statuscode);
}
/var/www/html/wwwroot/index.php
define("GOOGLE_RECAPTCHAV3_PUBLIC", $cms->getEnv("GOOGLE_RECAPTCHAV3_PUBLIC"));
define("GOOGLE_RECAPTCHAV3_SECRET", $cms->getEnv("GOOGLE_RECAPTCHAV3_SECRET"));
define("URL_FACEBOOK", $cms->getEnv("URL_FACEBOOK"));
define("URL_INSTAGRAM", $cms->getEnv("URL_INSTAGRAM"));
define("URL_TWITTER", $cms->getEnv("URL_TWITTER"));
global $pages;
$pages = (new Pages($cms))
->load();
// Disable on production
//if(!$cms->isTrusted()) {
// if(empty($_GET['enablepreview']) && empty($_SESSION['enablepreview'])) {
// $pages->disableLocale("it");
// } else {
// $_SESSION['enablepreview'] = true;
// }
//}
$pages->run(["defaultlocale" => "it"]);