Example #1
0
 public function buildFilter()
 {
     $options = [];
     $options['clearSelect'] = true;
     $options['select'][] = \Rebond\Cms\Filter\Data::getList(['id', 'title']);
     $options['where'][] = ['filter.module_id = ?', $this->getModel()->getModuleId()];
     $options['order'][] = 'filter.display_order, filter.title';
     $items = \Rebond\Cms\Filter\Data::loadAll($options);
     return Util\Form::buildDropdownList('filterId' . $this->unique, $items, 'id', 'title', $this->getModel()->getFilterId());
 }
Example #2
0
 public function buildFilter()
 {
     $options = [];
     $options['clearSelect'] = true;
     $options['select'][] = \Rebond\Cms\Filter\Data::getList(['id', 'title']);
     $models = \Rebond\Cms\Filter\Data::loadAll($options);
     return Util\Form::buildDropdownList('filterId' . $this->unique, $models, 'id', 'title', $this->getModel()->getFilterId(), $this->filterValidator['foreignKey']);
 }
Example #3
0
 public function filter()
 {
     // auth
     Auth::isAdminAuthorized($this->signedUser, 'admin.cms.filter', true, '/cms');
     $options = [];
     $options['select'][] = \Rebond\Cms\Module\Data::getList([], 'filter_module');
     $options['join'][] = 'cms_module filter_module ON filter_module.id = filter.module_id';
     $options['order'][] = 'filter_module.title, filter.title';
     $filters = \Rebond\Cms\Filter\Data::loadAll($options);
     // view
     $this->setTpl();
     // filter
     $tplFilter = new Template(Template::MODULE, ['cms', 'filter']);
     $tplFilter->set('count', count($filters));
     // main
     $tplMain = new Template(Template::MODULE, ['cms', 'filter']);
     $tplMain->set('items', $filters);
     // layout
     $this->tplLayout->set('column1', $tplFilter->render('filter'));
     $this->tplLayout->set('column2', $tplMain->render('listing'));
     // master
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-2-row'));
     return $this->tplMaster->render('tpl-default');
 }
Example #4
0
 public function selectGadgetFilter()
 {
     if (!$this->hasPrivilege('admin.page.gagdet')) {
         return $this->noPrivilege('admin.page.gagdet');
     }
     $json = [];
     $json['result'] = ResultType::ERROR;
     // check
     $id = Converter::int('id', 'post', 0);
     $search = Converter::string('search', 'post');
     $gadget = \Rebond\Cms\Gadget\Data::loadById($id);
     if (!isset($gadget)) {
         $json['message'] = Lang::lang('itemNotFound', [$id]);
         return json_encode($json);
     }
     $results = [];
     // Single Item
     if ($gadget->getComponent()->getType() == \Rebond\Cms\ComponentType::SINGLE_ITEM) {
         $appData = '\\Rebond\\App\\' . $gadget->getComponent()->getModule()->getTitle() . '\\Data';
         $options = [];
         $options['where'][] = ['content.version IN (?)', [0, 1, 3]];
         if (isset($search) && $search != '') {
             $options['where'][] = ['content.title LIKE ?', '%' . $search . '%'];
         }
         $options['order'][] = 'content.title';
         $items = $appData::loadAll($options, false);
         if (isset($items) && count($items) > 0) {
             foreach ($items as $item) {
                 $result = new \Rebond\Cms\Filter();
                 $result->setId($item->getContentGroup());
                 $result->setTitle($item->getTitle());
                 $result->setAppId($item->getAppId());
                 $results[] = $result;
             }
         }
         // Listing
     } else {
         if ($gadget->getComponent()->getType() == \Rebond\Cms\ComponentType::LISTING) {
             // Filtered Listing
         } else {
             if ($gadget->getComponent()->getType() == \Rebond\Cms\ComponentType::FILTERED_LISTING) {
                 $options = [];
                 $options['where'][] = ['filter.module_id = ?', $gadget->getComponent()->getModuleId()];
                 if ($search != '') {
                     $options['where'][] = ['filter.title LIKE ?', '%' . $search . '%'];
                 }
                 $options['order'][] = 'filter.title';
                 $filters = \Rebond\Cms\Filter\Data::loadAll($options);
                 if (isset($filters) && count($filters) > 0) {
                     foreach ($filters as $filter) {
                         $result = new \Rebond\Cms\Filter();
                         $result->setId($filter->getId());
                         $result->setTitle($filter->getTitle());
                         $result->setAppId($filter->getId());
                         $results[] = $result;
                     }
                 }
                 // Custom Listing
             } else {
                 if ($gadget->getComponent()->getType() == 'CustomListing') {
                     // Generic
                 } else {
                     if ($gadget->getComponent()->getType() == 'Generic') {
                     }
                 }
             }
         }
     }
     $tpl = new Template(Template::MODULE, ['cms', 'gadget']);
     $tpl->set('id', $gadget->getId());
     $tpl->set('results', $results);
     $tpl->set('search', $search);
     $json['result'] = ResultType::SUCCESS;
     $json['html'] = $tpl->render('select-filter');
     return json_encode($json);
 }