コード例 #1
0
ファイル: Data.php プロジェクト: vincium/bourg-la-reine
 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()]);
 }
コード例 #2
0
ファイル: Service.php プロジェクト: vincium/bourg-la-reine
 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);
 }