Esempio n. 1
0
 public function buildModule()
 {
     $options = [];
     $options['clearSelect'] = true;
     $options['select'][] = \Rebond\Cms\Module\Data::getList(['id', 'title']);
     $options['where'][] = 'module.status = 1';
     $items = \Rebond\Cms\Module\Data::loadAll($options);
     return Util\Form::buildDropdownList('moduleId' . $this->unique, $items, 'id', 'title', $this->getModel()->getModuleId());
 }
Esempio n. 2
0
 public function buildModule()
 {
     $options = [];
     $options['clearSelect'] = true;
     $options['select'][] = \Rebond\Cms\Module\Data::getList(['id', 'has_content', 'title']);
     $options['where'][] = 'module.status = 1';
     $options['order'][] = 'module.title';
     $items = \Rebond\Cms\Module\Data::loadAll($options);
     $form = '<select class="input" name="moduleId" id="moduleId">';
     if ($items) {
         foreach ($items as $item) {
             $selected = $item->getId() == $this->getModel()->getModuleId() ? ' selected="selected"' : '';
             $form .= '<option value="' . $item->getId() . '" data-app=' . $item->getHasContent() . $selected . '>' . $item->getTitle() . '</option>';
         }
     }
     $form .= '</select>';
     return $form;
 }
Esempio n. 3
0
 protected static function autoJoin(Util\Data $db, $moduleName, $select = true)
 {
     $module = \Rebond\Cms\Module\Data::loadByTitle($moduleName);
     if (!isset($module)) {
         Util\Error::kill(Util\Error::ITEM_NOT_FOUND, 'module ' . $module . ' not found', __FILE__, __LINE__);
     }
     if ($select) {
         $db->buildQuery('select', \Rebond\Cms\Content\Data::getList());
         $db->buildQuery('select', \Rebond\Cms\Module\Data::getList([], 'content_module'));
         if ($module->getHasFilter()) {
             $db->buildQuery('select', \Rebond\Cms\Filter\Data::getList([], 'content_filter'));
         }
     }
     $db->buildQuery('join', 'cms_content content ON x.app_id = content.app_id');
     $db->buildQuery('join', 'cms_module content_module ON content_module.id = content.module_id');
     if ($module->getHasFilter()) {
         $db->buildQuery('leftJoin', 'cms_filter content_filter ON content_filter.id = content.filter_id');
     }
     $db->buildQuery('where', ['content.module_id = ?', $module->getId()]);
 }
Esempio n. 4
0
 public function buildModule()
 {
     $options = [];
     $options['clearSelect'] = true;
     $options['select'][] = \Rebond\Cms\Module\Data::getList(['id', 'title']);
     $models = \Rebond\Cms\Module\Data::loadAll($options);
     return Util\Form::buildDropdownList('moduleId' . $this->unique, $models, 'id', 'title', $this->getModel()->getModuleId(), $this->moduleValidator['foreignKey']);
 }
Esempio n. 5
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');
 }
Esempio n. 6
0
 public function search()
 {
     if (!$this->hasPrivilege('admin.content.search')) {
         return $this->noPrivilege('admin.content.search');
     }
     $json = [];
     $json['result'] = ResultType::ERROR;
     // check
     $search = Converter::string('search', 'post');
     if (!isset($search)) {
         $json['message'] = Lang::lang('errorInvalidParameters');
         return json_encode($json);
     }
     $searchResults = [];
     // search and build views
     $options = [];
     $options['clearSelect'] = true;
     $options['select'][] = \Rebond\Cms\Module\Data::getList(['id', 'title']);
     $options['where'][] = 'module.status = 1';
     $options['where'][] = 'module.has_content = 1';
     $modules = \Rebond\Cms\Module\Data::loadAll($options);
     $options2 = [];
     $options2['clearSelect'] = true;
     $options2['where'][] = ['LOWER(content.title) LIKE ?', '%' . strtolower($search) . '%'];
     $options2['where'][] = ['content.version IN (?)', [0, 1, 3]];
     $options2['limit'][] = '0, 10';
     foreach ($modules as $module) {
         $appData = '\\Rebond\\App\\' . $module->getTitle() . '\\Data';
         $options2['select'][] = $appData::getList(['app_id']);
         $options2['select'][] = \Rebond\Cms\Content\Data::getList(['title', 'version']);
         $items = $appData::loadAll($options2);
         if (isset($items) && count($items) > 0) {
             foreach ($items as $item) {
                 $result = new \Rebond\Cms\Search();
                 $result->setType($module->getTitle());
                 $result->setAppId($item->getAppId());
                 $result->setTitle($item->getTitle());
                 $result->setVersion($item->getVersion());
                 $result->setVersionValue($item->getVersionValue());
                 $result->setLink('/content/edit/?module=' . $module->getTitle() . '&id=' . $item->getAppId());
                 $searchResults[] = $result;
             }
         }
     }
     // view
     $tpl = new Template(Template::SITE, ['admin']);
     $tpl->set('search', $search);
     $tpl->set('results', $searchResults);
     $json['result'] = ResultType::SUCCESS;
     $json['message'] = $tpl->render('search');
     return json_encode($json);
 }