Переход с MultiPhotos на SimpleGallery
Поддержать: USDT TRC20: TBGKTYDs4yzU17vQbobbUB8epFFtFb6PKh
<?php define('MODX_API_MODE', true); define('MODX_BASE_PATH', __DIR__ . '/'); define('MODX_BASE_URL', '/'); define('MODX_SITE_URL', 'http://sitename.ru/'); include_once("index.php"); $modx->db->connect(); if (empty ($modx->config)) { $modx->getSettings(); } $modx->invokeEvent("OnManagerPageInit"); $tvIds = "0"; //Здесь указываем через запятую id параметров с галереями $q = $modx->db->query("SELECT * FROM {$modx->getFullTableName('site_tmplvar_contentvalues')} WHERE `tmplvarid` IN ({$tvIds})"); include_once(MODX_BASE_PATH.'assets/plugins/simplegallery/lib/table.class.php'); $fs = \Helpers\FS::getInstance(); $sg = new \SimpleGallery\sgData($modx); while ($row = $modx->db->getRow($q)) { $path = 'assets/galleries/'.$row['contentid'].'/'; $images = json_decode($row['value'], true); if (!is_array($images)) continue; foreach ($images as $image) { $name = $fs->takeFileBaseName($image[0]); $fs->copyFile($image[0],$path.$name); $sg->create(); $sg->set('sg_rid',$row['contentid']); $sg->set('sg_title',$image[2]); $sg->set('sg_description',''); $sg->set('sg_image',$path.$name); $name = MODX_BASE_PATH . $path.$name; $info = getimagesize($name); $properties = array( 'width' => $info[0], 'height' => $info[1], 'size' => filesize($name) ); $sg->set('sg_properties',$properties); $sg->save(); } }