Переход с PssGallery на SimpleGallery
Поддержать: USDT TRC20: TBGKTYDs4yzU17vQbobbUB8epFFtFb6PKh
<?php
define('MODX_API_MODE', true);
define('MODX_BASE_PATH', __DIR__ . '/');
define('MODX_BASE_URL', '/');
define('MODX_SITE_URL', 'https://modx-gu.ru/');
include_once("index.php");
$modx->db->connect();
if (empty ($modx->config)) {
$modx->getSettings();
}
include_once(MODX_BASE_PATH.'assets/plugins/simplegallery/lib/table.class.php');
$modx->invokeEvent("OnManagerPageInit");
$q = $modx->db->query("SELECT * FROM {$modx->getFullTableName('pss_gallery')} ORDER BY `document_id` ASC, `position` ASC, `id` ASC");
$fs = \Helpers\FS::getInstance();
$sg = new \SimpleGallery\sgData($modx);
while ($row = $modx->db->getRow($q)) {
$row['url_original_image'] = trim($row['url_original_image'],'/');
$pssImage = $row['url_original_image'];
$sgImage = str_replace('assets/images/gallery/','assets/galleries/',$pssImage);
if ($fs->checkFile($pssImage)) {
$sg->create();
$sg->set('sg_rid',$row['document_id']);
$sg->set('sg_title',$row['title']);
$sg->set('sg_description',$row['alt']);
$sg->set('sg_image',$sgImage);
$fs->moveFile($pssImage,$sgImage);
$name = MODX_BASE_PATH . $sgImage;
$info = getimagesize($name);
$properties = array(
'width' => $info[0],
'height' => $info[1],
'size' => filesize($name)
);
$sg->set('sg_properties',$properties);
$sg->save();
}
}