Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!isset($modx->miniShop) || !is_object($modx->miniShop)) {
- $modx->miniShop = $modx->getService('minishop','miniShop', $modx->getOption('core_path').'components/minishop/model/minishop/', $scriptProperties);
- if (!($modx->miniShop instanceof miniShop)) return '';
- }
- $id = $modx->getOption('id', $scriptProperties, $modx->resource->get('id'));
- // if (!$modx->getCount('modResource', $id)) {return $modx->lexicon('ms.goods.err_nf');}
- $arr = array();
- $q = $modx->newQuery('ModGallery');
- $q->select(array('id','gid','name','description','file','fileorder'));
- $q->andCondition(array('gid' => $id, 'wid' => $_SESSION['minishop']['warehouse']), '', 0);
- if ($onlyImg) {
- $extensions = explode(',',$modx->getOption('upload_images'));
- $tmp = array();
- foreach ($extensions as $v) {
- $q->orCondition(array('file:LIKE' => '%.'.$v), '', 1);
- }
- }
- if ($q->prepare() && $q->stmt->execute()) {
- $total = $q->stmt->rowCount();
- }
- if ($total == 0) return;
- $modx->setPlaceholder($totalVar, $total);
- $q->sortby($sortby,$sortdir);
- if (!empty($limit)) {
- $q->limit($limit,$offset);
- }
- if ($q->prepare() && $q->stmt->execute()) {
- $gallery = $q->stmt->fetchAll(PDO::FETCH_ASSOC);
- }
- $result = array();
- foreach ($gallery as $v) {
- if (!$res = $modx->getChunk($tpl, $v)) {
- $res = '<pre>'.(print_r($v, true)).'</pre>';
- }
- $result[] = $res;
- }
- return implode($outputSeparator, $result);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement