Created
December 2, 2017 07:14
-
-
Save Pathologic/4042cc6a0d54a5c46c18e44987bb8b63 to your computer and use it in GitHub Desktop.
MaxiGallery to Simple Gallery converter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('MODX_API_MODE', true); | |
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); | |
$fs->unlink('assets/galleries/'.$row['gal_id'].'/tn_'.$row['filename']); | |
$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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment