Created
December 26, 2019 12:56
-
-
Save ExileofAranei/61bcc2c643c9d3c89f98ff0c64febf46 to your computer and use it in GitHub Desktop.
Update ms2gallery images
This file contains 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 | |
$step = 5; | |
$offset = isset($_SESSION['galgenoffset']) && $_SESSION['galgenoffset'] ? $_SESSION['galgenoffset'] : 0; | |
$ms2Gallery = $modx->getService('ms2gallery', 'ms2Gallery', MODX_CORE_PATH . 'components/ms2gallery/model/ms2gallery/'); | |
$modx->setLogLevel(MODX_LOG_LEVEL_ERROR); | |
$q = $modx->newQuery('msResourceFile', array('parent' => 0)); | |
$total = $modx->getCount('msResourceFile', $q); | |
$q->sortby('resource_id', 'ASC'); | |
$q->sortby('rank', 'DESC'); | |
$q->limit($step,$offset); | |
$resources = $modx->getCollection('msResourceFile', $q); | |
foreach ($resources as $resource) { | |
$modx->runProcessor('mgr/gallery/generate', array('id' => $resource->id), | |
array('processors_path' => $modx->getOption('core_path').'components/ms2gallery/processors/')); | |
} | |
$_SESSION['galgenoffset'] = $offset + $step; | |
if ($_SESSION['galgenoffset'] >= $total) { | |
$sucsess = 100; | |
$_SESSION['Console']['completed'] = true; | |
unset($_SESSION['galgenoffset']); | |
} else { | |
$sucsess = round($_SESSION['galgenoffset'] / $total, 2) * 100; | |
$_SESSION['Console']['completed'] = false; | |
} | |
for ($i=0; $i<=100; $i++) { | |
if ($i <= $sucsess) { | |
print '='; | |
} else { | |
print '_'; | |
} | |
} | |
$current = $_SESSION['galgenoffset'] ? | |
$_SESSION['galgenoffset'] : | |
($sucsess == 100 ? $total : 0); | |
print "\n"; | |
print $sucsess.'% ('.$current.')'."\n\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment