public function summary($page) { require_once 'ServiceUtil.php'; $util = new ServiceUtil(); require_once 'Config.php'; $myConfig = new Config(); $myConfig->loadJsonConfig($data); $pageName = NULL; $termObj = NULL; $pageName = $page; $pos = strpos($pageName, ":"); //echo "----pos:".$pos; if ($pos == false) { $pageName = str_replace("_", "%20", $page); $pageName = str_replace(",", "%2c", $pageName); $data["page"] = $page; } $isNifID = false; $originalPageName = ""; if ($pos != false) { $termObj[0] = $util->getObjByCurie($pageName); #echo "\n-------Willy----!is_null(termObj):".!is_null($termObj)."\n"; if (!is_null($termObj) && !is_null($termObj[0])) { $data['curie'] = $termObj[0]->curie; if (count($termObj[0]->labels) > 0) { $data['pageName'] = $termObj[0]->labels[0]; $pageName = $data['pageName']; $originalPageName = $pageName; $pageName = str_replace(" ", "%20", $pageName); $pageName = str_replace(",", "%2c", $pageName); $data['pageName'] = $pageName; $isNifID = true; } else { $data['pageName'] = $pageName; } } else { $data['pageName'] = $pageName; $termObj = getTerm($pageName); } } $pageName = str_replace(str_split('_'), '%20', $pageName); $pageName = str_replace(str_split(','), '%2c', $pageName); $pageName = str_replace(str_split('/'), '%2f', $pageName); $data['pageName'] = $pageName; $data['page_title'] = $pageName; $data['enable_config'] = true; $stitle = ""; if (!$isNifID) { $stitle = ucfirst($page); $stitle = str_replace("_", " ", $stitle); $data['title'] = $stitle; } else { $stitle = $originalPageName; $data['title'] = $stitle; } $this->handleDataSpace($data, $pageName); $this->load->view('api/view_summary', $data); }
public function view($page = 'home') { require_once 'ServiceUtil.php'; $util = new ServiceUtil(); require_once 'Config.php'; $myConfig = new Config(); $myConfig->loadJsonConfig($data); $pageName = $page; $termObj = NULL; $termObj[0] = $util->getObjByCurie($pageName); #echo "\n-------Willy----!is_null(termObj):".!is_null($termObj)."\n"; if (!is_null($termObj) && !is_null($termObj[0])) { $data['curie'] = $termObj[0]->curie; if (count($termObj[0]->labels) > 0) { $data['pageName'] = $termObj[0]->labels[0]; $pageName = $data['pageName']; //echo "PageName here-----".$pageName; $originalPageName = $pageName; $pageName = str_replace(" ", "%20", $pageName); // echo "<br/>PageName here-----".$pageName; $pageName = str_replace(",", "%2c", $pageName); // echo "<br/>PageName here-----".$pageName; $data['pageName'] = $pageName; $isNifID = true; } else { $data['pageName'] = $pageName; } } $pageName = str_replace(str_split('_'), '%20', $pageName); $pageName = str_replace(str_split(','), '%2c', $pageName); $pageName = str_replace(str_split('/'), '%2f', $pageName); $data['pageName'] = $pageName; $data['page_title'] = $pageName; $data['title'] = $pageName; $data['enable_config'] = true; //$newCurie = str_replace(":","_",$data['curie']); $fileName = "/" . $data['config_array']->cache_folder . "/" . $data['curie'] . "-literature-String.cache"; //echo "<br/>".$fileName; $stats = NULL; if (file_exists($fileName)) { $stats = stat($fileName); } $current = time(); $diff = $current - $stats[9]; /*if (file_exists($fileName) && $diff > (86400 * 1)) { unlink($fileName); //echo "unlinking due to expiration."; } else if(file_exists($fileName) && filesize($fileName) == 0) { unlink($fileName); //echo "unlinking due to empty file"; }*/ // $fileContent = file_get_contents($fileName); //echo "<br/>File content:".$fileContent."------"; if (!file_exists($fileName)) { //echo "<br/>----File does not exist:".$fileName."-----"; $this->handleLiterature($data, $pageName); $this->load->view('pages/outputLiteratureAsString', $data); } else { //echo "<br/>----File exists:".$fileName; $fileContent = file_get_contents($fileName); $data['fileContent'] = $fileContent; $this->load->view('pages/outputLiteratureAsString2', $data); } //$this->load->view('templates/header2', $data); //$this->load->view('templates/footer2', $data); }
public function view($page = 'home') { //require 'Globals.php'; //$enableCaching = false; //require_once 'CacheConfig.php'; //require_once 'JsonClientUtil.php'; //require_once 'Config.php'; $this->load->helper('url'); require_once 'ServiceUtil.php'; $util = new ServiceUtil(); require_once 'Config.php'; $myConfig = new Config(); $myConfig->loadJsonConfig($data); //$this->loadJsonConfig($data); //init(); /*if ( ! file_exists(APPPATH.'/views/pages/'.$page.'.php')) { // Whoops, we don't have a page for that! show_404(); }*/ $pageName = NULL; $termObj = NULL; $pageName = $page; $pos = strpos($pageName, ":"); //echo "----pos:".$pos; if ($pos == false) { $pageName = str_replace("_", "%20", $page); $pageName = str_replace(",", "%2c", $pageName); $data["page"] = $page; } $isNifID = false; $originalPageName = ""; //Loading sources configurations /*$sources = $this->loadSourcesConfig($data); if($sources != null) { $data['ks_sources'] = $sources; }*/ //Loading categories configurations /*$categories = $this->loadCategoriesConfig($data); if($categories != null) { $data['categories'] = $categories; }*/ if ($pos != false) { $termObj[0] = $util->getObjByCurie($pageName); #echo "\n-------Willy----!is_null(termObj):".!is_null($termObj)."\n"; if (!is_null($termObj) && !is_null($termObj[0])) { $data['curie'] = $termObj[0]->curie; if (count($termObj[0]->labels) > 0) { $data['pageName'] = $termObj[0]->labels[0]; $pageName = $data['pageName']; //echo "PageName here-----".$pageName; $originalPageName = $pageName; $pageName = str_replace(" ", "%20", $pageName); // echo "<br/>PageName here-----".$pageName; $pageName = str_replace(",", "%2c", $pageName); // echo "<br/>PageName here-----".$pageName; $data['pageName'] = $pageName; $isNifID = true; } else { $data['pageName'] = $pageName; } } else { $data['pageName'] = $pageName; $termObj = getTerm($pageName); } } else { $data['pageName'] = $pageName; //echo "-----pageName:".$pageName; $termObj = $util->getTerm($pageName); //var_dump($termObj); $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://"; $domainName = $_SERVER['HTTP_HOST']; if (!is_null($termObj)) { //echo "-------------termObj size: ".count($termObj); if (count($termObj) == 1 && isset($termObj[0]) && !is_null($termObj[0]->curie)) { //redirect('http://google.com', 'location'); redirect($protocol . "://" . $domainName . "/" . Config::$localContextName . "/index.php/pages/view/" . $termObj[0]->curie, 'refresh'); } if (count($termObj) > 1) { //http://localhost/NeuroKS/index.php/TermLanding/view/cerebellum%20purkinje%20cell //redirect($protocol.":/".$domainName."/".Config::$localContextName."/index.php/Term/view/".$page, 'refresh'); $data['termObj'] = $termObj; $temp_page_title = $pageName = str_replace(str_split('_,'), ' ', $page); $data['page_title'] = "Term:" . $temp_page_title; $data['enable_config'] = false; //redirect('http://google.com', 'location'); //redirect($protocol."://".$domainName."/".Config::$localContextName."/index.php/pages/view/".$termObj[0]->curie, 'refresh'); //exit(0); $this->load->view('templates/header2', $data); $this->load->view('pages/DisplayTermLanding', $data); $this->load->view('templates/footer2', $data); return; //exit(0); } $data['curie'] = $termObj[0]->curie; } } //$pageName = str_replace(" ", "%20", $pageName); //$pageName = str_replace(",", "%2c", $pageName); //$pageName = str_replace("/", "%20", $pageName); $pageName = str_replace(str_split('_'), '%20', $pageName); $pageName = str_replace(str_split(','), '%2c', $pageName); $pageName = str_replace(str_split('/'), '%2f', $pageName); $data['pageName'] = $pageName; $data['page_title'] = $pageName; $data['enable_config'] = true; ////////////////////// //$cachefile = '/webCache/'.basename($_SERVER['PHP_SELF']).'.cache'; // e.g. cache/index.php.cache $cachefile = $data["config_array"]->cache_folder . basename($_SERVER['PHP_SELF']) . '.cache'; // e.g. cache/index.php.cache $cachetime = 3600 * 24; // time to cache in seconds $c = ""; //if($this->enableCaching) //echo "--------".$data["config_array"]->enableCaching; if ($data["config_array"]->enable_caching) { //echo "====cachiing----"; if (!file_exists($cachefile)) { //Do nothing } else { if (file_exists($cachefile) && time() - $cachetime <= filemtime($cachefile)) { $c = @file_get_contents($cachefile); echo $c; exit; } else { unlink($cachefile); } } /////////////////////// if (is_null($termObj)) { show_404(); return; } ob_start(); } /////////////////////////////////////////////////////// $this->handleSummary($data, $termObj, $pageName); //$data['title'] = ucfirst($page); // Capitalize the first letter $stitle = ""; if (!$isNifID) { $stitle = ucfirst($page); $stitle = str_replace("_", " ", $stitle); $data['title'] = $stitle; } else { $stitle = $originalPageName; $data['title'] = $stitle; } #echo "\nWilly--------pageName:".$pageName."\n"; $this->handleDataSpace($data, $pageName); if (isset($termObj[0])) { $this->handleLexicon($data, $termObj[0]->curie); } $this->handleLiterature($data, $pageName); $this->load->view('templates/header2', $data); //$this->load->view('pages/'.$page, $data); //$this->load->view('pages/term', $data); $this->load->view('pages/layout', $data); $this->load->view('templates/footer2', $data); /////////////////////////////////////////////// //if($this->enableCaching) if ($data["config_array"]->enable_caching) { $c = ob_get_contents(); file_put_contents($cachefile, $c); } }