Пример #1
0
 /**
  * Get users
  *
  * @param integer $page
  * @param integer $perPage
  * @param string $orderBy
  * @param string $orderType
  * @param array $filters
  *      string nickname
  *      string email
  *      string status
  *      integer role
  * @return object
  */
 public function getUsers($page = 1, $perPage = 0, $orderBy = null, $orderType = null, array $filters = [])
 {
     $orderFields = ['id', 'nickname', 'email', 'registered', 'status'];
     $orderType = !$orderType || $orderType == 'desc' ? 'desc' : 'asc';
     $orderBy = $orderBy && in_array($orderBy, $orderFields) ? $orderBy : 'id';
     $select = $this->select();
     $select->from(['a' => 'user_list'])->columns(['id' => 'user_id', 'nickname' => 'nick_name', 'email', 'status', 'registered', 'role_id' => 'role'])->join(['b' => 'acl_role'], 'a.role = b.id', ['role' => 'name'])->order($orderBy . ' ' . $orderType);
     // filter by nickname
     if (!empty($filters['nickname'])) {
         $select->where([new LikePredicate('nick_name', $filters['nickname'] . '%')]);
     }
     // filter by email
     if (!empty($filters['email'])) {
         $select->where(['email' => $filters['email']]);
     }
     // filter by status
     if (!empty($filters['status'])) {
         $select->where(['status' => $filters['status']]);
     }
     // filter by role
     if (!empty($filters['role'])) {
         $select->where(['role' => $filters['role']]);
     }
     $paginator = new Paginator(new DbSelectPaginator($select, $this->adapter));
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage(PaginationUtility::processPerPage($perPage));
     $paginator->setPageRange(SettingService::getSetting('application_page_range'));
     return $paginator;
 }
Пример #2
0
 /**
  * Get resources
  *
  * @param integer $roleId
  * @param integer $page
  * @param integer $perPage
  * @param string $orderBy
  * @param string $orderType
  * @param array $filters
  *      array modules
  *      string status
  * @return object
  */
 public function getResources($roleId, $page = 1, $perPage = 0, $orderBy = null, $orderType = null, array $filters = [])
 {
     $orderFields = ['id', 'connection'];
     $orderType = !$orderType || $orderType == 'desc' ? 'desc' : 'asc';
     $orderBy = $orderBy && in_array($orderBy, $orderFields) ? $orderBy : 'id';
     $select = $this->select();
     $select->from(['a' => 'acl_resource'])->columns(['id', 'description'])->join(['b' => 'application_module'], new Expression('a.module = b.id and b.status = ?', [self::MODULE_STATUS_ACTIVE]), ['module' => 'name'])->join(['c' => 'acl_resource_connection'], new Expression('a.id = c.resource and c.role = ?', [$roleId]), ['connection' => 'id'], 'left')->order($orderBy . ' ' . $orderType);
     // filter by modules
     if (!empty($filters['modules']) && is_array($filters['modules'])) {
         $select->where->in('module', $filters['modules']);
     }
     // filter by status
     if (!empty($filters['status'])) {
         switch ($filters['status']) {
             case 'disallowed':
                 $select->where->IsNull('c.id');
                 break;
             case 'allowed':
             default:
                 $select->where->IsNotNull('c.id');
         }
     }
     $paginator = new Paginator(new DbSelectPaginator($select, $this->adapter));
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage(PaginationUtility::processPerPage($perPage));
     $paginator->setPageRange(SettingService::getSetting('application_page_range'));
     return $paginator;
 }
 /**
  * Get answers
  *
  * @param integer $questionId
  * @param integer $page
  * @param integer $perPage
  * @param string $orderBy
  * @param string $orderType
  * @return \Zend\Paginator\Paginator
  */
 public function getAnswers($questionId, $page = 1, $perPage = 0, $orderBy = null, $orderType = null)
 {
     $orderFields = ['id', 'answer', 'created', 'order'];
     $orderType = !$orderType || $orderType == 'desc' ? 'desc' : 'asc';
     $orderBy = $orderBy && in_array($orderBy, $orderFields) ? $orderBy : 'id';
     $select = $this->select();
     $select->from(['a' => 'poll_answer'])->columns(['id', 'answer', 'order', 'created'])->where(['question_id' => $questionId])->order($orderBy . ' ' . $orderType);
     $paginator = new Paginator(new DbSelectPaginator($select, $this->adapter));
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage(PaginationUtility::processPerPage($perPage));
     $paginator->setPageRange(SettingService::getSetting('application_page_range'));
     return $paginator;
 }
 /**
  * Get not installed modules
  *
  * @param integer $page
  * @param integer $perPage
  * @param string $orderBy
  * @param string $orderType
  * @return array
  */
 public function getNotInstalledModules($page = 1, $perPage = 0, $orderBy = null, $orderType = null)
 {
     $orderFields = ['vendor', 'vendor_email', 'version', 'date'];
     $orderType = !$orderType || $orderType == 'desc' ? SORT_DESC : SORT_ASC;
     $orderBy = $orderBy && in_array($orderBy, $orderFields) ? $orderBy : 'date';
     // get installed active modules
     $installedModules = array_map('strtolower', $this->getAllInstalledModules());
     // get all directories and files
     $directoryIterator = new DirectoryIterator(ApplicationService::getModulePath());
     $modules = new CallbackFilterIterator($directoryIterator, function ($current) use($installedModules) {
         // skip already installed modules
         if ($current->isDot() || !$current->isDir() || in_array(strtolower($current->getFileName()), $installedModules)) {
             return false;
         }
         // check module
         return $this->isCustomModule($current->getFileName());
     });
     $processedModules = [];
     $orderValues = [];
     // process not installed modules
     foreach ($modules as $data) {
         $moduleInstallConfig = $this->getCustomModuleInstallConfig($data->getFileName(), false);
         $moduleInfo = ['name' => $data->getFileName(), 'vendor' => !empty($moduleInstallConfig['vendor']) ? $moduleInstallConfig['vendor'] : null, 'email' => !empty($moduleInstallConfig['vendor_email']) ? $moduleInstallConfig['vendor_email'] : null, 'version' => !empty($moduleInstallConfig['version']) ? $moduleInstallConfig['version'] : null, 'description' => !empty($moduleInstallConfig['description']) ? $moduleInstallConfig['description'] : null, 'date' => $data->getMTime(), 'module_depends' => $this->checkModuleDepends($moduleInstallConfig), 'system_requirements' => count($this->getNotValidatedModuleSystemRequirements($moduleInstallConfig)) ? false : true];
         $processedModules[] = $moduleInfo;
         $orderValues[] = $moduleInfo[$orderBy];
         // load the module's translations
         $this->addModuleTranslations($this->getSystemModuleConfig($data->getFileName(), false));
     }
     array_multisort($orderValues, $orderType, $processedModules);
     $paginator = new Paginator(new ArrayAdapterPaginator($processedModules));
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage(PaginationUtility::processPerPage($perPage));
     $paginator->setPageRange(SettingService::getSetting('application_page_range'));
     return $paginator;
 }
 /**
  * Get actions log
  *
  * @param integer $page
  * @param integer $perPage
  * @param string $orderBy
  * @param string $orderType
  * @param array $filters
  *      array modules
  * @return \Zend\Paginator\Paginator
  */
 public function getActionsLog($page = 1, $perPage = 0, $orderBy = null, $orderType = null, array $filters = [])
 {
     $orderFields = ['id', 'registered'];
     $orderType = !$orderType || $orderType == 'desc' ? 'desc' : 'asc';
     $orderBy = $orderBy && in_array($orderBy, $orderFields) ? $orderBy : 'id';
     $select = $this->select();
     $select->from(['a' => 'action_tracker_log'])->columns(['id', 'description', 'description_params', 'registered'])->join(['b' => 'application_event'], 'a.action_id = b.id', [])->join(['c' => 'application_module'], new Expression('b.module = c.id and c.status = ?', [self::MODULE_STATUS_ACTIVE]), ['module' => 'name'])->order($orderBy . ' ' . $orderType);
     // filter by modules
     if (!empty($filters['modules']) && is_array($filters['modules'])) {
         $select->where->in('b.module', $filters['modules']);
     }
     $paginator = new Paginator(new DbSelectPaginator($select, $this->adapter));
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage(PaginationUtility::processPerPage($perPage));
     $paginator->setPageRange(SettingService::getSetting('application_page_range'));
     return $paginator;
 }
Пример #6
0
 /**
  * Get last news
  *
  * @param integer $page
  * @param integer|array $categories
  * @param integer $limit
  * @return array|\Zend\Paginator\Paginator
  */
 public function getLastNews($page, $categories = null, $limit = null)
 {
     $select = $this->select();
     $select->from(['a' => 'news_list'])->columns(['title', 'slug', 'intro', 'image', 'created'])->order('a.created desc, a.id desc')->where(['a.language' => $this->getCurrentLanguage(), 'a.status' => self::STATUS_APPROVED])->where->lessThanOrEqualTo('created', time());
     // filter by categories
     if ($categories) {
         // check categories
         if (null != ($existingCategories = $this->getAllCategories())) {
             if (!is_array($categories)) {
                 $categories = [$categories];
             }
             // arrays diff (we can keep deleted categories in settings)
             if (null != ($categories = array_intersect(array_keys($existingCategories), $categories))) {
                 $select->join(['b' => 'news_category_connection'], 'a.id = b.news_id', []);
                 $select->where([new InPredicate('b.category_id', $categories)]);
                 $select->group('a.id');
             }
         }
     }
     if ($limit) {
         $select->limit($limit);
         $statement = $this->prepareStatementForSqlObject($select);
         $resultSet = new ResultSet();
         $resultSet->initialize($statement->execute());
         return $resultSet->toArray();
     }
     $paginator = new Paginator(new DbSelectPaginator($select, $this->adapter));
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage(PaginationUtility::processPerPage(null));
     $paginator->setPageRange(SettingService::getSetting('application_page_range'));
     return $paginator;
 }
Пример #7
0
 /**
  * Get installed layouts
  *
  * @param integer $page
  * @param integer $perPage
  * @param string $orderBy
  * @param string $orderType
  * @param array $filters
  *      string name
  *      string type
  * @return object
  */
 public function getInstalledLayouts($page = 1, $perPage = 0, $orderBy = null, $orderType = null, array $filters = [])
 {
     $orderFields = ['id', 'name', 'type', 'version', 'vendor', 'email'];
     $orderType = !$orderType || $orderType == 'desc' ? 'desc' : 'asc';
     $orderBy = $orderBy && in_array($orderBy, $orderFields) ? $orderBy : 'id';
     $select = $this->select();
     $select->from('layout_list')->columns(['id', 'name', 'type', 'version', 'vendor', 'email' => 'vendor_email'])->order($orderBy . ' ' . $orderType);
     // filter by name
     if (!empty($filters['name'])) {
         $select->where([new LikePredicate('name', '%' . $filters['name'] . '%')]);
     }
     // filter by type
     if (!empty($filters['type'])) {
         switch ($filters['type']) {
             case self::LAYOUT_TYPE_CUSTOM:
             case self::LAYOUT_TYPE_SYSTEM:
                 $select->where(['type' => $filters['type']]);
                 break;
             default:
         }
     }
     $paginator = new Paginator(new DbSelectPaginator($select, $this->adapter));
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage(PaginationUtility::processPerPage($perPage));
     $paginator->setPageRange(SettingService::getSetting('application_page_range'));
     return $paginator;
 }
Пример #8
0
 /**
  * Get structure pages
  *
  * @param integer $parentId
  * @param integer $page
  * @param integer $perPage
  * @param string $orderBy
  * @param string $orderType
  * @param array $filters
  *      array modules
  *      string status
  *      string slug
  * @return object Paginator
  */
 public function getStructurePages($parentId = null, $page = 1, $perPage = 0, $orderBy = null, $orderType = null, array $filters = [])
 {
     $orderFields = ['id', 'position', 'slug', 'widgets'];
     $orderType = !$orderType || $orderType == 'asc' ? 'asc' : 'desc';
     $orderBy = $orderBy && in_array($orderBy, $orderFields) ? $orderBy : 'position';
     $dependentCheckSelect = $this->select();
     $dependentCheckSelect->from(['i' => 'page_system_page_depend'])->columns(['id'])->join(['f' => 'page_structure'], new Expression('i.page_id = f.system_page and f.language = ?', [$this->getCurrentLanguage()]), [])->where(['a.system_page' => new Expression('i.depend_page_id')])->limit(1);
     $select = $this->select();
     $select->from(['a' => 'page_structure'])->columns(['id', 'position' => 'left_key', 'type', 'title', 'slug', 'left_key', 'right_key', 'system_page', 'dependent_page' => new Expression('(' . $this->getSqlStringForSqlObject($dependentCheckSelect) . ')')])->join(['b' => 'page_system'], 'b.id = a.system_page', ['system_title' => 'title'], 'left')->join(['c' => 'page_widget_connection'], 'a.id = c.page_id', [], 'left')->join(['d' => 'page_widget'], new Expression('c.widget_id = d.id and d.type = ?', [self::WIDGET_TYPE_PUBLIC]), [], 'left')->join(['dd' => 'page_structure'], new Expression('dd.system_page = d.depend_page_id and dd.language = ? and dd.active = ?', [$this->getCurrentLanguage(), PageNestedSet::PAGE_STATUS_ACTIVE]), [], 'left')->join(['i' => 'application_module'], new Expression('i.id = d.module and i.status = ? and (d.depend_page_id is null
                     or d.depend_page_id is not null and dd.system_page is not null)', [self::MODULE_STATUS_ACTIVE]), ['widgets' => new Expression('count(i.id)')], 'left')->join(['f' => 'application_module'], new Expression('f.id = a.module and f.status = ?', [self::MODULE_STATUS_ACTIVE]), [])->group('a.id')->order($orderBy . ' ' . $orderType)->where(['a.language' => $this->getCurrentLanguage()]);
     null === $parentId ? $select->where->isNull('a.parent_id') : $select->where(['a.parent_id' => $parentId]);
     // filter by modules
     if (!empty($filters['modules']) && is_array($filters['modules'])) {
         $select->where->in('f.id', $filters['modules']);
     }
     // filter by status
     if (!empty($filters['status'])) {
         switch ($filters['status']) {
             case 'active':
                 $select->where(['a.active' => PageNestedSet::PAGE_STATUS_ACTIVE]);
                 break;
             default:
                 $select->where->IsNull('a.active');
         }
     }
     // filter by slug
     if (!empty($filters['slug'])) {
         $select->where(['a.slug' => $filters['slug']]);
     }
     $paginator = new Paginator(new DbSelectPaginator($select, $this->adapter));
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage(PaginationUtility::processPerPage($perPage));
     $paginator->setPageRange(SettingService::getSetting('application_page_range'));
     return $paginator;
 }
 /**
  * Get coupons
  *
  * @param integer $page
  * @param integer $perPage
  * @param string $orderBy
  * @param string $orderType
  * @param array $filters
  *      string slug
  *      integer discount
  *      integer used
  *      integer start
  *      integer end
  * @return \Zend\Paginator\Paginator
  */
 public function getCoupons($page = 1, $perPage = 0, $orderBy = null, $orderType = null, array $filters = [])
 {
     $orderFields = ['id', 'slug', 'discount', 'used', 'start', 'end'];
     $orderType = !$orderType || $orderType == 'desc' ? 'desc' : 'asc';
     $orderBy = $orderBy && in_array($orderBy, $orderFields) ? $orderBy : 'id';
     $select = $this->select();
     $select->from('payment_discount_coupon')->columns(['id', 'slug', 'discount', 'used', 'start' => 'date_start', 'end' => 'date_end'])->order($orderBy . ' ' . $orderType);
     // filter by a slug
     if (!empty($filters['slug'])) {
         $select->where(['slug' => $filters['slug']]);
     }
     // filter by a discount
     if (!empty($filters['discount'])) {
         $select->where(['discount' => $filters['discount']]);
     }
     // filter by a status
     if (isset($filters['used']) && $filters['used'] != null) {
         $select->where(['used' => (int) $filters['used'] == self::COUPON_USED ? $filters['used'] : self::COUPON_NOT_USED]);
     }
     // filter by an activation date
     if (!empty($filters['start'])) {
         $select->where(['date_start' => $filters['start']]);
     }
     // filter by a deactivation date
     if (!empty($filters['end'])) {
         $select->where(['date_end' => $filters['end']]);
     }
     $paginator = new Paginator(new DbSelectPaginator($select, $this->adapter));
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage(PaginationUtility::processPerPage($perPage));
     $paginator->setPageRange(SettingService::getSetting('application_page_range'));
     return $paginator;
 }
 /**
  * Get news
  *
  * @param integer $page
  * @param integer $perPage
  * @param string $orderBy
  * @param string $orderType
  * @param array $filters
  *      string title
  *      string status
  *      array categories
  * @return \Zend\Paginator\Paginator
  */
 public function getNews($page = 1, $perPage = 0, $orderBy = null, $orderType = null, array $filters = [])
 {
     $orderFields = ['id', 'title', 'status', 'created'];
     $orderType = !$orderType || $orderType == 'desc' ? 'desc' : 'asc';
     $orderBy = $orderBy && in_array($orderBy, $orderFields) ? $orderBy : 'id';
     $select = $this->select();
     $select->from(['a' => 'news_list'])->columns(['id', 'title', 'status', 'created'])->where(['a.language' => $this->getCurrentLanguage()])->order('a.' . $orderBy . ' ' . $orderType);
     // filter by status
     if (!empty($filters['status'])) {
         $select->where(['a.status' => $filters['status']]);
     }
     // filter by title
     if (!empty($filters['title'])) {
         $select->where([new LikePredicate('a.title', '%' . $filters['title'] . '%')]);
     }
     // filter by categories
     if (!empty($filters['categories']) && is_array($filters['categories'])) {
         $select->join(['b' => 'news_category_connection'], 'a.id = b.news_id', []);
         $select->where([new InPredicate('b.category_id', $filters['categories'])]);
         $select->group('a.id');
     }
     $paginator = new Paginator(new DbSelectPaginator($select, $this->adapter));
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage(PaginationUtility::processPerPage($perPage));
     $paginator->setPageRange(SettingService::getSetting('application_page_range'));
     return $paginator;
 }
 /**
  * Get membership levels
  *
  * @param integer $page
  * @param integer $perPage
  * @param string $orderBy
  * @param string $orderType
  * @param array $filters
  *      string title
  *      float cost
  *      integer lifetime
  *      integer role
  *      integer active
  * @return \Zend\Paginator\Paginator
  */
 public function getMembershipLevels($page = 1, $perPage = 0, $orderBy = null, $orderType = null, array $filters = [])
 {
     $orderFields = ['id', 'title', 'cost', 'lifetime', 'active', 'subscribers'];
     $orderType = !$orderType || $orderType == 'desc' ? 'desc' : 'asc';
     $orderBy = $orderBy && in_array($orderBy, $orderFields) ? $orderBy : 'id';
     $select = $this->select();
     $select->from(['a' => 'membership_level'])->columns(['id', 'title', 'cost', 'lifetime', 'active', 'description', 'image', 'role_id'])->join(['b' => 'membership_level_connection'], 'b.membership_id = a.id', ['subscribers' => new Expression('count(b.id)')], 'left')->join(['c' => 'acl_role'], 'a.role_id = c.id', ['role' => 'name'])->join(['d' => 'payment_currency'], new Expression('d.primary_currency = ?', [PaymentBaseModel::PRIMARY_CURRENCY]), array('currency' => 'code'))->group('a.id')->order($orderBy . ' ' . $orderType)->where(['a.language' => $this->getCurrentLanguage()]);
     // filter by a title
     if (!empty($filters['title'])) {
         $select->where(['a.title' => $filters['title']]);
     }
     // filter by a cost
     if (!empty($filters['cost'])) {
         $select->where(['a.cost' => $filters['cost']]);
     }
     // filter by a lifetime
     if (!empty($filters['lifetime'])) {
         $select->where(['a.lifetime' => $filters['lifetime']]);
     }
     // filter by a role
     if (!empty($filters['role'])) {
         $select->where(['c.id' => $filters['role']]);
     }
     // filter by a active
     if (isset($filters['active']) && $filters['active'] != null) {
         $select->where(['a.active' => (int) $filters['active'] == self::MEMBERSHIP_LEVEL_STATUS_ACTIVE ? $filters['active'] : self::MEMBERSHIP_LEVEL_STATUS_NOT_ACTIVE]);
     }
     $paginator = new Paginator(new DbSelectPaginator($select, $this->adapter));
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage(PaginationUtility::processPerPage($perPage));
     $paginator->setPageRange(SettingService::getSetting('application_page_range'));
     return $paginator;
 }
 /**
  * Get comments
  *
  * @param integer $page
  * @param integer $perPage
  * @param string $orderBy
  * @param string $orderType
  * @param array $filters
  *      string comment
  *      string status
  *      string ip
  *      string email
  *      string name
  *      integer date_start
  *      integer date_end
  *      string page_slug
  *      integer page_id
  * @return \Zend\Paginator\Paginator
  */
 public function getComments($page = 1, $perPage = 0, $orderBy = null, $orderType = null, array $filters = [])
 {
     $orderFields = ['id', 'active', 'ip', 'created'];
     $orderType = !$orderType || $orderType == 'desc' ? 'desc' : 'asc';
     $orderBy = $orderBy && in_array($orderBy, $orderFields) ? $orderBy : 'created';
     $select = $this->select();
     $select->from(['a' => 'comment_list'])->columns(['id', 'guest_id', 'name', 'user_id', 'email', 'ip', 'active', 'created', 'comment', 'slug'])->join(['b' => 'page_structure'], 'a.page_id = b.id', ['page_slug' => 'slug'])->join(['c' => 'user_list'], 'a.user_id = c.user_id', ['registered_nickname' => 'nick_name', 'registered_email' => 'email'], 'left')->order($orderBy . ' ' . $orderType)->where(['a.language' => $this->getCurrentLanguage()]);
     // filter by comment
     if (!empty($filters['comment'])) {
         $select->where([new LikePredicate('a.comment', '%' . $filters['comment'] . '%')]);
     }
     // filter by status
     if (!empty($filters['status'])) {
         $select->where(['a.active' => $filters['status'] == 'active' ? CommentNestedSetModel::COMMENT_STATUS_ACTIVE : CommentNestedSetModel::COMMENT_STATUS_NOT_ACTIVE]);
     }
     // filter by page id
     if (!empty($filters['page_id'])) {
         $select->where(['a.page_id' => $filters['page_id']]);
     }
     // filter by page slug
     if (!empty($filters['page_slug'])) {
         $select->where(['a.slug' => $filters['page_slug']]);
     }
     // filter by ip
     if (!empty($filters['ip'])) {
         $select->where(['a.ip' => inet_pton($filters['ip'])]);
     }
     // filter by email
     if (!empty($filters['email'])) {
         $select->where->nest->equalTo('a.email', $filters['email'])->or->equalTo('c.email', $filters['email'])->unnest;
     }
     // filter by name
     if (!empty($filters['name'])) {
         $select->where->nest->equalTo('a.name', $filters['name'])->or->equalTo('c.nick_name', $filters['name'])->unnest;
     }
     // filter by date start
     if (!empty($filters['date_start'])) {
         $select->where->greaterThanOrEqualTo('a.created', $filters['date_start']);
     }
     // filter by date end
     if (!empty($filters['date_end'])) {
         $select->where->lessThanOrEqualTo('a.created', $filters['date_end']);
     }
     $paginator = new Paginator(new DbSelectPaginator($select, $this->adapter));
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage(PaginationUtility::processPerPage($perPage));
     $paginator->setPageRange(SettingService::getSetting('application_page_range'));
     return $paginator;
 }
Пример #13
0
 /**
  * Get files
  *
  * @param string $directory
  * @param integer $page
  * @param integer $perPage
  * @param string $orderBy
  * @param string $orderType
  * @param array $filters
  *      string file_type (image , file, media)
  *      string name
  *      string type (directory, file)
  * @return array
  */
 public function getFiles($directory, $page = 1, $perPage = 0, $orderBy = null, $orderType = null, array $filters = [])
 {
     $orderFields = ['name', 'size', 'type', 'date'];
     $orderType = !$orderType || $orderType == 'desc' ? SORT_DESC : SORT_ASC;
     $orderBy = $orderBy && in_array($orderBy, $orderFields) ? $orderBy : 'name';
     // get all directories and files
     $directoryIterator = new DirectoryIterator($directory);
     $files = new CallbackFilterIterator($directoryIterator, function ($current, $key, $iterator) use($filters) {
         if ($current->isDot() || $current->isLink()) {
             return false;
         }
         // filter by files type - image, media, etc
         if (!empty($filters['file_type']) && !$current->isDir()) {
             switch ($filters['file_type']) {
                 // show only images
                 case 'image':
                     if (!in_array(FileSystemUtility::getFileExtension($current->getFileName()), explode(',', strtolower(SettingService::getSetting('file_manager_image_extensions'))))) {
                         return false;
                     }
                     break;
                 case 'media':
                     if (!in_array(FileSystemUtility::getFileExtension($current->getFileName()), explode(',', strtolower(SettingService::getSetting('file_manager_media_extensions'))))) {
                         return false;
                     }
                     break;
                 default:
             }
         }
         // filter by type
         if (!empty($filters['type'])) {
             switch ($filters['type']) {
                 case 'directory':
                     if ($current->isFile()) {
                         return false;
                     }
                     break;
                 case 'file':
                     if ($current->isDir()) {
                         return false;
                     }
                     break;
                 default:
             }
         }
         // filter by name
         return empty($filters['name']) || null != stristr($current->getFileName(), $filters['name']);
     });
     $processedFiles = [];
     $orderValues = [];
     foreach ($files as $data) {
         $fileInfo = ['name' => $data->getFileName(), 'type' => $data->isDir(), 'date' => $data->getMTime(), 'size' => !$data->isDir() ? $data->getSize() : 0];
         $processedFiles[] = $fileInfo;
         $orderValues[] = $fileInfo[$orderBy];
     }
     array_multisort($orderValues, $orderType, $processedFiles);
     $paginator = new Paginator(new ArrayAdapterPaginator($processedFiles));
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage(PaginationUtility::processPerPage($perPage));
     $paginator->setPageRange(SettingService::getSetting('application_page_range'));
     return $paginator;
 }
 /**
  * Get shopping cart items
  *
  * @param integer $page
  * @param integer $perPage
  * @param string $orderBy
  * @param string $orderType
  * @return \Zend\Paginator\Paginator
  */
 public function getShoppingCartItems($page = 1, $perPage = 0, $orderBy = null, $orderType = null)
 {
     $orderFields = ['id', 'title', 'cost', 'discount', 'count', 'total'];
     $orderType = !$orderType || $orderType == 'desc' ? 'desc' : 'asc';
     $orderBy = $orderBy && in_array($orderBy, $orderFields) ? $orderBy : 'id';
     $select = $this->select();
     $select->from(['a' => 'payment_shopping_cart'])->columns(['id', 'object_id', 'title', 'cost', 'discount', 'count', 'total' => new Expression('cost * count - discount'), 'slug', 'extra_options'])->join(['b' => 'payment_module'], 'a.module = b.module', ['countable', 'multi_costs', 'handler', 'page_name', 'module_extra_options' => 'extra_options'])->join(['c' => 'application_module'], new Expression('b.module = c.id and c.status = ?', [self::MODULE_STATUS_ACTIVE]), [])->order($orderBy . ' ' . $orderType)->where(array('shopping_cart_id' => $this->getShoppingCartId(), 'language' => $this->getCurrentLanguage()));
     $paginator = new Paginator(new DbSelectPaginator($select, $this->adapter));
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage(PaginationUtility::processPerPage($perPage));
     $paginator->setPageRange(SettingService::getSetting('application_page_range'));
     return $paginator;
 }