public function fixSearchName($term)
 {
     require_once 'ServiceUtil.php';
     $util = new ServiceUtil();
     $newName = $term;
     $searchName = $term;
     if (strcasecmp($searchName, "cell") == 0) {
         $newName = $searchName;
     } else {
         if (strcasecmp($searchName, "neuron") == 0) {
             $newName = $searchName;
         } else {
             if ($util->endsWith($searchName, "%20cell")) {
                 $tempName = substr($searchName, 0, strlen($searchName) - strlen("%20cell"));
                 $newName = $tempName;
             } else {
                 if ($util->endsWith($searchName, "%20neuron")) {
                     $tempName = substr($searchName, 0, strlen($searchName) - strlen("%20neuron"));
                     $newName = $tempName;
                 }
             }
         }
     }
     return $newName;
 }
 private function handleDataSpace(&$data, $searchName)
 {
     //require_once  'Globals.php';
     require_once 'ServiceUtil.php';
     $util = new ServiceUtil();
     $newName = $searchName;
     if (strcasecmp($searchName, "cell") == 0) {
         $newName = $searchName;
     } else {
         if (strcasecmp($searchName, "neuron") == 0) {
             $newName = $searchName;
         } else {
             if ($util->endsWith($searchName, "%20cell")) {
                 $tempName = substr($searchName, 0, strlen($searchName) - strlen("%20cell"));
                 $newName = $tempName;
             } else {
                 if ($util->endsWith($searchName, "%20neuron")) {
                     $tempName = substr($searchName, 0, strlen($searchName) - strlen("%20neuron"));
                     $newName = $tempName;
                 }
             }
         }
     }
     //echo "<p>----------------NewName:".$newName;
     $source_search_result = array();
     $sources = $data["config_array"]->sources;
     $category_to_source = $data["category_to_source"];
     $categories = $data["config_array"]->categories;
     $category_count_array = array();
     foreach ($sources as $source) {
         $source_search_result[$source->curie] = $util->searchWithinSource($newName, $source->curie, 20, 0);
     }
     foreach ($categories as $category) {
         $category_count_array[$category] = 0;
         $categorySources = $category_to_source[$category];
         foreach ($categorySources as $csource) {
             $sourceResult = $source_search_result[$csource->curie];
             if (!is_null($sourceResult)) {
                 $category_count_array[$category] = $category_count_array[$category] + $sourceResult->result->resultCount;
             }
         }
     }
     $data["source_search_result"] = $source_search_result;
     //var_dump($category_count_array);
     $data["category_count_array"] = $category_count_array;
 }
 public function view($sourceID, $term, $pageID)
 {
     //require_once  'JsonClientUtil.php';
     //require_once 'Config.php';
     require_once 'ServiceUtil.php';
     require_once 'Config.php';
     $util = new ServiceUtil();
     $myConfig = new Config();
     $myConfig->loadJsonConfig($data);
     $data['test'] = NULL;
     $term = str_replace("_", "%20", $term);
     $newName = $term;
     $searchName = $term;
     if (strcasecmp($searchName, "cell") == 0) {
         $newName = $searchName;
     } else {
         if (strcasecmp($searchName, "neuron") == 0) {
             $newName = $searchName;
         } else {
             if ($util->endsWith($searchName, "%20cell")) {
                 $tempName = substr($searchName, 0, strlen($searchName) - strlen("%20cell"));
                 $newName = $tempName;
             } else {
                 if ($util->endsWith($searchName, "%20neuron")) {
                     $tempName = substr($searchName, 0, strlen($searchName) - strlen("%20neuron"));
                     $newName = $tempName;
                 }
             }
         }
     }
     $offset = 0;
     //echo "\nSourceID------".$sourceID;
     //echo "\nTerm:".$term;
     if (!isset($pageID) || $pageID <= 1) {
         $offset = 0;
     } else {
         $offset = ($pageID - 1) * 20;
     }
     //echo "---------------".$newName;
     $data['resultObj'] = $util->searchWithinSource($newName, $sourceID, 20, $offset);
     // $data['resultObj'] = searchWithinSource2($term, $sourceID, 20,$offset);
     /*if(endsWith($term, "%20cell"))
       {
           
           $tempName = substr($term, 0, strlen($term)-strlen("%20cell"));
           //echo "-------------tempName:".$tempName."----".strlen($term)."--------";
           $tempResult = searchWithinSource2($tempName, $sourceID, 20,$offset);
           if($tempResult->result->resultCount > $data['resultObj']->result->resultCount)
               $data['resultObj'] = $tempResult;
       }*/
     $data['sourceID'] = $sourceID;
     $data['pageID'] = $pageID;
     $data['term'] = $term;
     $protocol = "http";
     if (isset($_SERVER['HTTPS'])) {
         $protocol = "https";
     }
     $surl = $protocol . "://" . $_SERVER['SERVER_NAME'] . "/" . Config::$localContextName . "/resources/source_description/" . $sourceID;
     //echo "\n".$surl;
     $responseCode = @get_headers($surl);
     //echo "CODE:".$file_headers[0]."---------";
     if ($responseCode[0] == 'HTTP/1.1 404 Not Found') {
         $data['description'] = "";
     } else {
         $data['description'] = file_get_contents($surl);
     }
     //var_dump($data['resultObj']);
     $data['page_title'] = "Search:" . str_replace("%20", " ", $term);
     $data['enable_config'] = true;
     $this->load->view('templates/header2', $data);
     $this->load->view('pages/resultDisplay', $data);
     $this->load->view('templates/footer2', $data);
 }
 private function handleDataSpace(&$data, $searchName)
 {
     //require_once  'Globals.php';
     require_once 'ServiceUtil.php';
     $util = new ServiceUtil();
     $newName = $searchName;
     if (strcasecmp($searchName, "cell") == 0) {
         $newName = $searchName;
     } else {
         if (strcasecmp($searchName, "neuron") == 0) {
             $newName = $searchName;
         } else {
             if ($util->endsWith($searchName, "%20cell")) {
                 $tempName = substr($searchName, 0, strlen($searchName) - strlen("%20cell"));
                 $newName = $tempName;
             } else {
                 if ($util->endsWith($searchName, "%20neuron")) {
                     $tempName = substr($searchName, 0, strlen($searchName) - strlen("%20neuron"));
                     $newName = $tempName;
                 }
             }
         }
     }
     //echo "<p>----------------NewName:".$newName;
     $source_search_result = array();
     $sources = $data["config_array"]->sources;
     $category_to_source = $data["category_to_source"];
     $categories = $data["config_array"]->categories;
     $category_count_array = array();
     foreach ($sources as $source) {
         $source_search_result[$source->curie] = $util->searchWithinSource($newName, $source->curie, 20, 0);
     }
     foreach ($categories as $category) {
         $category_count_array[$category] = 0;
         $categorySources = $category_to_source[$category];
         foreach ($categorySources as $csource) {
             $sourceResult = $source_search_result[$csource->curie];
             if (!is_null($sourceResult)) {
                 $category_count_array[$category] = $category_count_array[$category] + $sourceResult->result->resultCount;
             }
         }
     }
     $data["source_search_result"] = $source_search_result;
     //var_dump($category_count_array);
     $data["category_count_array"] = $category_count_array;
     $data['cilImages'] = array();
     $data['originalCILImages'] = array();
     $data['neuroMorphoImages'] = array();
     foreach ($sources as $source) {
         if ($source->has_images) {
             $tempImages = $util->getImageArray($source_search_result[$source->curie], 20);
             if (strcmp($source->curie, "nif-0000-37639-1") == 0) {
                 $data['originalCILImages'] = $tempImages;
                 //echo "------originalCILImages source:".$source->curie;
             } else {
                 if (strcmp($source->curie, "nif-0000-00006-1") == 0) {
                     $data['neuroMorphoImages'] = $tempImages;
                     //echo "------neuroMorphoImages source:".$source->curie;
                 }
             }
             $data['cilImages'] = array_merge($tempImages, $data['cilImages']);
         }
     }
     $imageGallery = array();
     if (strcmp($data['title'], "Neocortical pyramidal cell") == 0) {
         $gimage = "   <a href=\"http://celltypes.brain-map.org/mouse/experiment/morphology/330080937\" target=\"_blank\">" . "   <img width=\"84\" height=\"100\" src=\"http://celltypes.brain-map.org/cgi-bin/imageservice?path=/external/mousecelltypes/prod210/specimen_324466858/min_xy_324466858.aff&mime=2\"/>" . "   </a>";
         array_push($imageGallery, $gimage);
     }
     if (count($data['originalCILImages']) > 0) {
         array_push($imageGallery, $data['originalCILImages'][0]);
     }
     if (count($data['originalCILImages']) > 1) {
         array_push($imageGallery, $data['originalCILImages'][1]);
     }
     if (count($data['neuroMorphoImages']) > 0) {
         foreach ($data['neuroMorphoImages'] as $gimage) {
             array_push($imageGallery, $gimage);
             if (count($imageGallery) == 3) {
                 break;
             }
         }
     }
     if (count($data['originalCILImages']) > 2) {
         $cindex = 0;
         foreach ($data['originalCILImages'] as $gimage) {
             if (count($imageGallery) == 3) {
                 break;
             }
             if ($cindex > 1) {
                 array_push($imageGallery, $gimage);
             }
             $cindex++;
         }
     }
     $data['imageGallery'] = $imageGallery;
     /*
                 $data['neuroElectroResult'] = searchWithinSource($newName, $neuroElectro, 20);
                 $data['neuroMorphoResult'] = searchWithinSource($newName, $neuroMorpho, 20);
                 $data['genSatResult'] = searchWithinSource($newName, $genSat, 20);
                 $data['neuronDBResult'] = searchWithinSource($newName, $neuronDB, 20);
                 $data['humanBrainResult'] = searchWithinSource($newName, $humanBrainAtlas, 20);
                 $data['olfactoryMapResult'] = searchWithinSource($newName, $OlfactoryMap, 20);
                 $data['abaMorphoResult'] = searchWithinSource($newName, $abaMorpho, 20);
                 $data['abaCellResult'] = searchWithinSource($newName, $abaCell, 20);
                 $data['brainMapResult'] = searchWithinSource($newName, $brainMap, 20);
                 $data['connectivityResult'] = searchWithinSource($newName, $connectivity, 20);
                 $data['humanBrainProjectResult'] = searchWithinSource($newName, $humanBrainProject, 20);
                 
          
                     $data['neuroMLResult'] = searchWithinSource($newName, $neuroML, 20);
                     $data['modelDBResult'] = searchWithinSource($newName, $modelDB, 20);
                     $data['brainModelResult'] = searchWithinSource($newName, $brainModel, 20);
     
                     $data['cilResult'] = searchWithinSource($searchName, $CIL, 20);
                     $data['cilImages'] = getImageArray($data['cilResult'], 20);
     
                     $data['neuroMorphoImages'] = getImageArray($data['neuroMorphoResult'], 20);
                     $data['originalCILImages'] = $data['cilImages'];
                     $data['cilImages'] = array_merge($data['cilImages'], $data['neuroMorphoImages']);*/
 }