예제 #1
0
 function proxy()
 {
     $this->load->model('model_log');
     //Only record page one of search
     if ($this->input->post('page') === NULL || $this->input->post('page') == 1) {
         $this->model_log->log_activity($this->input->post('s_q'), 'search');
     }
     // copy all parameters that start with s.
     $query_arr = array();
     // PhP replaces . with _ in _REQUEST keys
     // http://www.php.net/manual/en/language.variables.external.php
     // fallback - simply 'q'
     if ($this->input->post('q') !== FALSE) {
         $query_arr['s.q'] = $this->input->post('q');
     }
     if ($this->input->post('page') !== FALSE && is_numeric($this->input->post('page')) && $this->input->post('page') > 0) {
         $page = $this->input->post('page');
     } else {
         $page = 1;
     }
     if (!isset($query_arr['s.q'])) {
         $query_arr['s.q'] = '';
     }
     foreach ($_REQUEST as $key => $value) {
         if (strpos($key, "t_") === 0) {
             $query_arr['s.q'] = $query_arr['s.q'] . " " . substr($key, 2) . ":(" . $value . ")";
             continue;
         }
         // replace the first _ with a .?
         $count = 1;
         $key2 = str_replace('_', '.', $key, $count);
         $query_arr[$key2] = $value;
     }
     $summon = new Summon(SUMMON_API_ID, SUMMON_API_KEY);
     $result = $summon->query($query_arr, null, $page);
     header("Content-Type: application/json");
     $reply = $result;
     if ($this->input->post('callback') !== FALSE) {
         $reply = $this->input->post('callback') . "(" . $reply . ")";
     }
     echo $reply;
 }
예제 #2
0
 /**
  * Constructor
  *
  * @access public
  */
 public function __construct()
 {
     global $interface;
     global $configArray;
     // Call parent constructor
     parent::__construct();
     // Fetch Record
     $summon = new Summon($configArray['Summon']['apiId'], $configArray['Summon']['apiKey']);
     $record = $summon->getRecord($_REQUEST['id']);
     if (PEAR::isError($record)) {
         PEAR::raiseError($record);
     } else {
         if (!isset($record['documents'][0])) {
             PEAR::raiseError(new PEAR_Error("Cannot access record {$_REQUEST['id']}"));
         } else {
             $this->record = $record['documents'][0];
         }
     }
     // Set Proxy URL
     $interface->assign('proxy', isset($configArray['EZproxy']['host']) ? $configArray['EZproxy']['host'] : false);
     // Send record ID to template
     $interface->assign('id', $_REQUEST['id']);
 }
예제 #3
0
파일: Home.php 프로젝트: bharatm/NDL-VuFind
 /**
  * Display the page.
  *
  * @return void
  * @access public
  */
 public function launch()
 {
     global $interface;
     global $configArray;
     // Cache homepage
     $interface->caching = 1;
     $cacheId = 'summon-homepage|' . $interface->lang . '|' . (UserAccount::isLoggedIn() ? '1' : '0') . '|' . (isset($_SESSION['lastUserLimit']) ? $_SESSION['lastUserLimit'] : '') . '|' . (isset($_SESSION['lastUserSort']) ? $_SESSION['lastUserSort'] : '');
     if (!$interface->is_cached('layout.tpl', $cacheId)) {
         $interface->setPageTitle('Search Home');
         $interface->setTemplate('home.tpl');
         // Search Summon
         $summon = new Summon($configArray['Summon']['apiId'], $configArray['Summon']['apiKey']);
         $results = $summon->query('', null, null, 0, null, array('ContentType,or,1,20', 'Language,or,1,20'));
         // Summon may not return facet values in a predictable order -- process
         // them to ensure we display the right thing in the right place:
         $facets = array();
         foreach ($results['facetFields'] as $current) {
             $facets[$current['displayName']] = $current;
         }
         $interface->assign('formatList', $facets['ContentType']);
         $interface->assign('languageList', $facets['Language']);
     }
     $interface->display('layout.tpl', $cacheId);
 }
예제 #4
0
 public function __construct($apiId, $apiKey)
 {
     $this->version = '2.0.0';
     return parent::__construct($apiId, $apiKey);
 }