Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/theyoungdesigners_com/modules/storePages/ |
Upload File : |
<?php
namespace modules\storePages;
// Page layouts
class main extends \moduleMain {
use \modules\input\traits {
\modules\input\traits::__construct as __ConstructInput;
}
use \modules\database\traits {
\modules\database\traits::__construct as __ConstructDatabase;
}
use \modules\output\traits {
\modules\output\traits::__construct as __ConstructOutput;
}
private $view;
public function __construct() {
parent::__construct(__DIR__);
$this->__ConstructInput();
$this->__ConstructDatabase();
$this->__ConstructOutput();
}
public function Activate() {
hook_add('url.key.select', [$this, '__module_select'], 40);
hook_add('menu.admin', [$this, '__admin_menu'], 1);
hook_add('uri', [$this, '__homepage'], 1);
hook_add('url.key.expand', [$this, '__key']); // go to page or url
hook_add('seller', [$this, '__seller'], 1);
}
// intercept home page - this redirects a short url (/../s/xyz) to the long form
public function __homepage(&$uri, $__INPUT, $__OUTPUT) {
if (($p = strpos($uri, '?')) !== FALSE) {
$param = substr($uri, $p);
$uri = substr($uri, 0, $p);
} else {
$param = '';
}
$elements = explode('/', trim($uri, '/'));
$action = $elements[1] ?? '';
$record_id = $elements[2] ?? '';
if ((is_numeric($record_id) || $record_id == '') && $action == 's') {
$uri = '/pages/store/'. $record_id;
}
}
public function __admin_menu(&$menu) {
$menu[] = [
'caption' => 'Store Pages',
'href' => '/pages/editor/-1',
'hint' => 'Design Store Pages',
'icon' => '<i class="far fa-file"></i>',
's' => 0
];
}
public function __module_select(&$param) {
// landing page
$model = $this->LoadModel('pages_model');
$items = $model->generateSelect();
$param = array_merge($param, $items);
}
public function __key(&$uri) {
if (preg_match('~^(.*?)\:([-]?\d+)$~', $uri, $match)) {
if ($match[1] == 'page') $uri = '/pages/store/' . $match[2];
}
}
public function __seller(&$html, $param, $text) {
$param = trim(preg_replace('/\s+/', ' ',$text));
[$action, $record_id] = explode(' ', $param . ' ');
$model_pages = $this->LoadModel('pages_model');
if ($record_id == '') $record_id = -1;
$model_pages->PageId($record_id);
$product_model = $this->LoadModel('product_model', 'store');
$categories = $model_pages->getCategoryInfo();
$category_model = $this->LoadModel('productgroup_model', 'store');
$list = [];
$cat = [];
foreach($categories[0] as $x) {
$cat[$x] = $category_model->getChildCategories($x);
$list = array_merge($list, $cat[$x]);
}
$categories[0] = $list;
// now expand the unfeatured 0 = all, 1 = featured
$products = $product_model->getProductsByCategory( $categories );
$item = $model_pages->AsHandlebars($products, $cat);
$product_model->RecordId(0);
$settings = $GLOBALS['loader']->LoadModuleSettings('store');
$res['priceformat'] = intval($settings['priceformat'] ?? '1');
$res = array_merge($res, $item);
$this->__LoadView('storepages_view');
$template = $this->LoadHandlebarsView('StorePages_View::store_page_view');
$html .= $template($res);
}
}