<commit_before><?php
/*
 * GlobalSearchResultsDataCollection
 * @param
 */
    class GlobalSearchResultsDataCollection 
    {        
        
        private $term;       
        private $scopeData;        
        private $user;        
        private $views = array();        
        
        /*
         * @param   string      
         * @param   integer     
         * @param   User        User model
         * @param   array       Modules to be searched
         */
        public function __construct($term, $pageSize, $user, $scopeData = null) {
            //TODO: make asserts
            $this->term = $term;
            $this->pageSize = $pageSize;
            $this->user = $user;
            $this->scopeData = $scopeData;
            $this->makeViews();            
        }
              
        /*
         * makeViews
         * @return  array   moduleName => listView
         */
        private function makeViews()
        {                                                
            $pageSize = $this->pageSize;
            $globalSearchModuleNamesAndLabelsData = GlobalSearchUtil::
                    getGlobalSearchScopingModuleNamesAndLabelsDataByUser($this->user);            
            foreach ($globalSearchModuleNamesAndLabelsData as $moduleName => $label)
            {        
                if ($this->scopeData == null || in_array($moduleName, $this->scopeData))
                {                        
                    $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() . 'ListView';                
                    $dataProvider = RedBeanModelDataProviderUtil::makeDataProvider(
                             $metadataAdapter->getAdaptedMetadata(false),
                             $modelClassName,
                             'RedBeanModelDataProvider',
                             'createdDateTime',
                             true,
                             $pageSize,
                             $module->getStateMetadataAdapterClassName()
                        );                             
                    $listView = new $listViewClassName(
                            'default',
                            $module->getId(),
                            $modelClassName,
                            $dataProvider,
                            GetUtil::resolveSelectedIdsFromGet(),
                            '-' .$moduleName);                                               
                    $this->views[$moduleName] = $listView;
                }
            }
        }
        
        public function getViews()
        {
            return $this->views;
        }              
    }
?><commit_msg>Fixing sort issue.<commit_after><?php
/*
 * GlobalSearchResultsDataCollection
 * @param
 */
    class GlobalSearchResultsDataCollection
    {

        private $term;
        private $scopeData;
        private $user;
        private $views = array();

        /*
         * @param   string
         * @param   integer
         * @param   User        User model
         * @param   array       Modules to be searched
         */
        public function __construct($term, $pageSize, $user, $scopeData = null) {
            //TODO: make asserts
            $this->term = $term;
            $this->pageSize = $pageSize;
            $this->user = $user;
            $this->scopeData = $scopeData;
            $this->makeViews();
        }

        /*
         * makeViews
         * @return  array   moduleName => listView
         */
        private function makeViews()
        {
            $pageSize = $this->pageSize;
            $globalSearchModuleNamesAndLabelsData = GlobalSearchUtil::
                    getGlobalSearchScopingModuleNamesAndLabelsDataByUser($this->user);
            foreach ($globalSearchModuleNamesAndLabelsData as $moduleName => $label)
            {
                if ($this->scopeData == null || in_array($moduleName, $this->scopeData))
                {
                    if($moduleName == 'contacts')
                    {
                        $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() . 'ListView';
                        $sortAttribute     = SearchUtil::resolveSortAttributeFromGetArray($modelClassName);
                        $sortDescending    = SearchUtil::resolveSortDescendingFromGetArray($modelClassName);
                        $dataProvider = RedBeanModelDataProviderUtil::makeDataProvider(
                                 $metadataAdapter->getAdaptedMetadata(false),
                                 $modelClassName,
                                 'RedBeanModelDataProvider',
                                 $sortAttribute,
                                 $sortDescending,
                                 $pageSize,
                                 $module->getStateMetadataAdapterClassName()
                            );
                        $listView = new $listViewClassName(
                                'default',
                                $module->getId(),
                                $modelClassName,
                                $dataProvider,
                                GetUtil::resolveSelectedIdsFromGet(),
                                '-' .$moduleName
                                );
                        $this->views[$moduleName] = $listView;
                    }
                }
            }
        }

        public function getViews()
        {
            return $this->views;
        }
    }
?>
{'fraction_non_alphanumeric': 0.08498819608387724, 'fraction_numerical': 0.0, 'mean_word_length': 1.066571018651363, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1220333', 'n_tokens_mistral': 1537, 'n_tokens_neox': 1478, 'n_words': 248}