Переход с MaxiGallery на 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('maxigallery')} ORDER BY `gal_id` ASC, `pos` ASC, `id` ASC"); $fs = \Helpers\FS::getInstance(); $sg = new \SimpleGallery\sgData($modx); while ($row = $modx->db->getRow($q)) { $path = 'assets/galleries/'.$row['gal_id'].'/'.$row['filename']; if ($fs->checkFile($path)) { $sg->create(); $sg->set('sg_rid',$row['gal_id']); $sg->set('sg_title',$row['title']); $sg->set('sg_description',$row['descr']); $sg->set('sg_createdon',$row['date']); $sg->set('sg_image',$path); $name = MODX_BASE_PATH . $path; $info = getimagesize($name); $properties = array( 'width' => $info[0], 'height' => $info[1], 'size' => filesize($name) ); $sg->set('sg_properties',$properties); $sg->save(); } }