function getSummary()

in tools/reporter.class.php [76:163]


    function getSummary(){
        global $DASHBOARD;
        foreach($this->summaryRegion as $check => $dataSet){
            foreach($dataSet as $region => $obj){
                #check criticality
                $critical = $this->__checkCriticality($check);
                if(empty($DASHBOARD['CRITICALITY'][$region][$critical]))
                    $DASHBOARD['CRITICALITY'][$region][$critical] = 0;
                $DASHBOARD['CRITICALITY'][$region][$critical]+= sizeof($obj);
                
                if($critical == 'H'){
                    $DASHBOARD['SERV'][$this->service][$region]['H'] += sizeof($obj);
                }
                
                #check category
                $category = $this->__checkCategory($check);
                $mainCategory = $category[0];
                if(empty($DASHBOARD['CATEGORY'][$region][$mainCategory]))
                    $DASHBOARD['CATEGORY'][$region][$mainCategory] = 0;
                    
                $DASHBOARD['CATEGORY'][$region][$mainCategory]+= sizeof($obj);
            }
        }
        
        $this->cardSummary = [];
        
        $service = $this->service;
        
        ksort($this->summary);
        foreach($this->summary as $check => $items){
            if(!array_key_exists($check, $this->config)){
                __info("<$check> not exists in ".$service.".reporter.json");
                continue;
            }
            
            $this->cardSummary[$check] = $this->config[$check];
            
            ## Process Field by Field:
            #   Process description
            $desc = $this->__getConfigValue($check, '^description');
            if($desc){
                $COUNT = sizeof($items);
                $COUNT = "<strong><u>$COUNT</u></strong>";
                eval("\$x = \"$desc\";");
                
                $this->cardSummary[$check]['^description'] = $x;
            }
            
            #   Process category
            $category = $this->__getConfigValue($check, 'category');
            if($category){
                $this->cardSummary[$check]['__categoryMain'] = $category[0];
                if(strlen($category) > 1)
                    $this->cardSummary[$check]['__categorySub'] = substr($category, 1);
                
                unset($this->cardSummary[$check]['category']);
            }
            
            #   Process ref
            $ref = $this->__getConfigValue($check, 'ref');
            if($ref && is_array($ref)){
                $links = [];
                foreach($ref as $link){
                    preg_match('/\[(.*)\]<(.*)>/', $link, $output);
                    if(empty($output))
                        continue;
                    
                    $links[] = "<a href='{$output[2]}'>{$output[1]}</a>";
                }
                
                $this->cardSummary[$check]['__links'] = $links;
                unset($this->cardSummary[$check]['ref']);
            }
            
            $resourceByRegion = [];
            foreach($this->summaryRegion[$check] as $region => $insts){
                $resourceByRegion[$region] = $insts;
            }
            
            $this->cardSummary[$check]['__affectedResources'] = $resourceByRegion;
        }
        
        unset($this->summaryRegion);
        unset($this->summary);
        
        # __pr($this->cardSummary);
        return $this;
    }