/**
  * @param   string $moduleName
  * @param   bool $forceEmptyResults
  * Return an empty listView
  * @return  View
  */
 public function getListView($moduleName, $forceEmptyResults = false)
 {
     assert('is_string($moduleName)');
     $pageSize = $this->pageSize;
     $module = Yii::app()->findModule($moduleName);
     $searchFormClassName = $module::getGlobalSearchFormClassName();
     $modelClassName = $module::getPrimaryModelName();
     $model = new $modelClassName(false);
     $searchForm = new $searchFormClassName($model);
     $sanitizedSearchAttributes = MixedTermSearchUtil::getGlobalSearchAttributeByModuleAndPartialTerm($module, $this->term);
     $metadataAdapter = new SearchDataProviderMetadataAdapter($searchForm, $this->user->id, $sanitizedSearchAttributes);
     $listViewClassName = $module::getPluralCamelCasedName() . 'ForMixedModelsSearchListView';
     $sortAttribute = SearchUtil::resolveSortAttributeFromGetArray($modelClassName);
     $sortDescending = SearchUtil::resolveSortDescendingFromGetArray($modelClassName);
     if ($forceEmptyResults) {
         $dataProviderClass = 'EmptyRedBeanModelDataProvider';
         $emptyText = '';
     } else {
         $dataProviderClass = 'RedBeanModelDataProvider';
         $emptyText = null;
     }
     $dataProvider = RedBeanModelDataProviderUtil::makeDataProvider($metadataAdapter->getAdaptedMetadata(false), $modelClassName, $dataProviderClass, $sortAttribute, $sortDescending, $pageSize, $module->getStateMetadataAdapterClassName());
     $listView = new $listViewClassName('default', $module->getId(), $modelClassName, $dataProvider, GetUtil::resolveSelectedIdsFromGet(), '-' . $moduleName, array('route' => '', 'class' => 'SimpleListLinkPager', 'firstPageLabel' => '<span>first</span>', 'prevPageLabel' => '<span>previous</span>', 'nextPageLabel' => '<span>next</span>', 'lastPageLabel' => '<span>last</span>'));
     $listView->setRowsAreSelectable(false);
     $listView->setEmptyText($emptyText);
     return $listView;
 }
 protected static function makeModelClassNamesAndSearchAttributeData($partialTerm, User $user, $scopeData)
 {
     assert('is_string($partialTerm)');
     assert('$user->id > 0');
     assert('$scopeData == null || is_array($scopeData)');
     $modelClassNamesAndSearchAttributeData = array();
     $modelNamesAndLabels = WorkflownQueuesSearchForm::getInQueueSearchableModelNamesAndLabels();
     foreach ($modelNamesAndLabels as $modelClassName => $notUsed) {
         $moduleClassName = $modelClassName::getModuleClassName();
         $module = Yii::app()->findModule($moduleClassName::getDirectoryName());
         $globalSearchFormClassName = $moduleClassName::getGlobalSearchFormClassName();
         if ($globalSearchFormClassName != null && RightsUtil::canUserAccessModule(get_class($module), $user) && ($scopeData == null || in_array($modelClassName, $scopeData))) {
             $searchAttributes = MixedTermSearchUtil::getGlobalSearchAttributeByModuleAndPartialTerm($module, $partialTerm);
             if (!empty($searchAttributes)) {
                 $model = new $modelClassName(false);
                 assert('$model instanceof RedBeanModel');
                 $searchForm = new $globalSearchFormClassName($model);
                 assert('$searchForm instanceof SearchForm');
                 $metadataAdapter = new SearchDataProviderMetadataAdapter($searchForm, $user->id, $searchAttributes);
                 $metadata = $metadataAdapter->getAdaptedMetadata(false);
                 $modelClassNamesAndSearchAttributeData[$globalSearchFormClassName] = array($modelClassName => $metadata);
             }
         }
     }
     return $modelClassNamesAndSearchAttributeData;
 }
 public function testGetGlobalSearchAttributeByModuleAndPartialTerm()
 {
     $searchAttributes = MixedTermSearchUtil::getGlobalSearchAttributeByModuleAndPartialTerm(Yii::app()->findModule('accounts'), 'abc');
     $compareData = array('anyEmail' => 'abc', 'name' => 'abc', 'officePhone' => 'abc');
     $this->assertEquals($compareData, $searchAttributes);
     $searchAttributes = MixedTermSearchUtil::getGlobalSearchAttributeByModuleAndPartialTerm(Yii::app()->findModule('contacts'), 'def');
     $compareData = array('anyEmail' => 'def', 'fullName' => 'def', 'officePhone' => 'def', 'mobilePhone' => 'def');
     $this->assertEquals($compareData, $searchAttributes);
 }
 protected static function makeModelClassNamesAndSearchAttributeData($partialTerm, User $user, $scopeData)
 {
     assert('is_string($partialTerm)');
     assert('$user->id > 0');
     assert('$scopeData == null || is_array($scopeData)');
     $modelClassNamesAndSearchAttributeData = array();
     $modules = Module::getModuleObjects();
     foreach ($modules as $module) {
         $globalSearchFormClassName = $module::getGlobalSearchFormClassName();
         if (GlobalSearchUtil::resolveIfModuleShouldBeGloballySearched($module) && $globalSearchFormClassName != null && RightsUtil::canUserAccessModule(get_class($module), $user) && ($scopeData == null || in_array($module->getName(), $scopeData))) {
             $modelClassName = $module::getPrimaryModelName();
             $searchAttributes = MixedTermSearchUtil::getGlobalSearchAttributeByModuleAndPartialTerm($module, $partialTerm);
             if (!empty($searchAttributes)) {
                 $model = new $modelClassName(false);
                 assert('$model instanceof RedBeanModel');
                 $searchForm = new $globalSearchFormClassName($model);
                 assert('$searchForm instanceof SearchForm');
                 $metadataAdapter = new SearchDataProviderMetadataAdapter($searchForm, $user->id, $searchAttributes);
                 $metadata = $metadataAdapter->getAdaptedMetadata(false);
                 $stateMetadataAdapterClassName = $module::getStateMetadataAdapterClassName();
                 if ($stateMetadataAdapterClassName != null) {
                     $stateMetadataAdapter = new $stateMetadataAdapterClassName($metadata);
                     $metadata = $stateMetadataAdapter->getAdaptedDataProviderMetadata();
                 }
                 $modelClassNamesAndSearchAttributeData[$globalSearchFormClassName] = array($modelClassName => $metadata);
             }
         }
     }
     return $modelClassNamesAndSearchAttributeData;
 }