Skip to content

Instantly share code, notes, and snippets.

@sashabeep
Last active April 2, 2018 07:36
Show Gist options
  • Save sashabeep/184c8bcb2c983d03edd5d53a0b61d31d to your computer and use it in GitHub Desktop.
Save sashabeep/184c8bcb2c983d03edd5d53a0b61d31d to your computer and use it in GitHub Desktop.
Script for moving from EvoGallery to SimpleGallery
<?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();
}
include_once(MODX_BASE_PATH.'assets/plugins/simplegallery/lib/table.class.php');
$modx->invokeEvent("OnManagerPageInit");
$q = $modx->db->query("SELECT * FROM {$modx->getFullTableName('portfolio_galleries')} ORDER BY `content_id` ASC, `sortorder` ASC, `id` ASC");
$fs = \Helpers\FS::getInstance();
$sg = new \SimpleGallery\sgData($modx);
while ($row = $modx->db->getRow($q)) {
$path = 'assets/galleries/'.$row['content_id'].'/';
if ($fs->checkFile($path.$row['filename'])) {
$sg->create();
$sg->set('sg_rid',$row['content_id']);
$sg->set('sg_title',$row['title']);
$sg->set('sg_description',$row['description']);
$sg->set('sg_image',$path.$row['filename']);
//$fs->moveFile($path.$row['filename'],$path.'large/'.$row['filename']);
//$fs->moveFile($path.'original/'.$row['filename'],$path.$row['filename']);
$name = MODX_BASE_PATH . $path.$row['filename'];
$info = getimagesize($name);
$properties = array(
'width' => $info[0],
'height' => $info[1],
'size' => filesize($name)
);
$sg->set('sg_properties',$properties);
$sg->save();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment