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/storeImage/ |
Upload File : |
<?php
namespace modules\storeImage;
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() {
$this->view = $GLOBALS['loader']->getView('storeclient_images', __DIR__);
hook_add('html.head', [$this, '__meta'], 11); // add OpenGraph image
hook_add('template.store.product.COL1', [$this, '__column1'], 5); // add Images
hook_add('store.product.admin', [$this, '__editmenu']);
hook_add('template.product', [$this, '__getData'], 20);
hook_add('product.tab', [$this, '__product_tabs'], 80);
hook_add('product.tab.media', [$this, '__tab_content']);
hook_add('product.list', [$this, '__ProductList'], 90); // add primary image to product
hook_add('product.clone', [$this, '__ProductClone']);
hook_add('cart.display', [$this, '__AddCartContent']);
hook_add('order.list', [$this, '__order_list'], 60); // add product images
hook_add('mediamanager.update', [$this, '__updateImage']); // an image has just been uploaded using media manager
hook_add('media.filename', [$this, '__filename']); // using virtual filename?
}
// add Images
public function __column1(&$html) {
$text = $this->view->Column1Text();
$this->view->UpdateHTML($html, 'COL1', $text);
}
public function __getData(&$res) {
$product_id = $res['sp_id'];
$model = $this->LoadModel('images_model');
$model->ProductId($product_id)
->addHandlebars($res);
}
public function __editmenu(&$menu) {
// get current product
$product = \Product_model::GetHandle();
$productbase = '/admin/product/' . $product->RecordId();
$menu[] = [
'caption' => 'Image Library', // images and video
'href' => "$productbase/edit#media",
'hint' => 'Add/Remove Images',
];
}
final function image($hash, $filename = '') {
$data = new \StdClass;
$data->name = str_replace(['..', '&', '<', '>', '|'], '', $hash);
$data = hook_execute('mediamanager.image', $data);
header("Content-type: {$data->mime}");
die($data->image);
}
public function __product_tabs(&$tabs, $uri) {
$node = [
'name' => 'Media',
'icon' => '<i class="fas fa-photo-video"></i>',
'fragment' => 'media',
'className' => '',
];
$tabs['_tab'][] = $node;
}
public function __tab_content(&$data, $ephemeral) {
$product_id = $ephemeral['product_id'];
$data = hook_execute('execute.internal', NULL, '/admin/store-image/' . $product_id . '/tab-images');
}
public function __ProductClone($param) {
$model = $this->LoadModel('images_model');
$model->ProductId($param['source'])
->CloneProduct($param);
}
public function __AddCartContent(&$cart) {
$model = $this->LoadModel('images_model');
$model->AddCartContent($cart);
}
public function __order_list(&$data, $user_id = 0, $daycount = 30) {
$model = $this->LoadModel('images_model');
$model->AddOrderContent($data);
}
public function __updateImage(&$node, $query = []) {
// update the images for the product with the list of files just uploaded.
// verify product id has not been altered
$model = $this->LoadModel('images_model');
$product_id = hook_execute( 'nonce.verify', FALSE, 'product', FALSE, $query['auth2'] ?? '' );
if ($product_id) {
$model->ProductId($product_id);
$model->updateImageData($node); // rename target file to content hash, update database
$node['updated'] = TRUE;
}
}
public function __filename(&$filename) {
$param = $this->param('param', '');
[$category, $product] = explode(':', $param . '::');
if ($category == 'product') {
$model = $this->LoadModel('images_model');
$filename = $model->ProductId($product)
->getFileHashByName($filename[0]);
$filename = [$filename];
}
}
public function __meta(&$html) {
// get hostname and store name
$model_product = $this->LoadModel('product_model', 'store');
if (!$model_product->empty()) {
$model = $this->LoadModel('images_model');
$model->ProductId($model_product->RecordId());
$image = $model->getPrimaryImage();
if ($image !== FALSE) {
$url = $this->Hostname(TRUE);
$html .= "<meta property=\"og:image\" content=\"{$url}{$image}\" />\n";
}
}
}
public function __ProductList(&$products) {
$model = $this->LoadModel('images_model');
$model->addPrimaryImage($products);
}
final function rebuild() {
header('Content-type: text/plain');
$model = $this->LoadModel('images_model');
$model->Rebuild();
die("\nDone\n");
}
}