本文整理汇总了PHP中ConnectionManager::connectToIndex方法的典型用法代码示例。如果您正苦于以下问题:PHP ConnectionManager::connectToIndex方法的具体用法?PHP ConnectionManager::connectToIndex怎么用?PHP ConnectionManager::connectToIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionManager
的用法示例。
在下文中一共展示了ConnectionManager::connectToIndex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: launch
/**
* Process incoming parameters and display the page.
*
* @return void
* @access public
*/
public function launch()
{
global $configArray, $interface;
// Execute Default Tab
$defaultTab = isset($configArray['Site']['defaultRecordTab']) ? $configArray['Site']['defaultRecordTab'] : 'Holdings';
// Don't let bots crawl holdings
if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT'])) {
$defaultTab = 'Description';
} else {
// We need to do a whole bunch of extra work to determine the default
// tab if we have the hideHoldingsTabWhenEmpty setting turned on; only
// do this work if we absolutely have to!
if (isset($configArray['Site']['hideHoldingsTabWhenEmpty']) && $configArray['Site']['hideHoldingsTabWhenEmpty'] && $defaultTab == "Holdings") {
$db = ConnectionManager::connectToIndex();
if (!($record = $db->getRecord($_REQUEST['id']))) {
PEAR::raiseError(new PEAR_Error('Record Does Not Exist'));
}
$recordDriver = RecordDriverFactory::initRecordDriver($record);
$showHoldingsTab = $recordDriver->hasHoldings();
$defaultTab = $showHoldingsTab ? 'Holdings' : 'Description';
}
}
include_once $defaultTab . '.php';
$service = new $defaultTab();
$service->recordHit();
$service->launch();
}
示例2: __construct
/**
* Constructor.
*
* @access public
*/
public function __construct()
{
parent::__construct();
// Setup Search Engine Connection
$this->db = ConnectionManager::connectToIndex();
$_SESSION['no_store'] = true;
}
示例3: __construct
/**
* Constructor
*
* @access public
*/
public function __construct()
{
global $interface;
$interface->assign('id', $_GET['id']);
// Setup Search Engine Connection
$this->db = ConnectionManager::connectToIndex('SolrAuth');
parent::__construct();
}
示例4: launch
/**
* Process incoming parameters and generate an appropriate JSON response.
*
* @return void
* @access public
*/
public function launch()
{
//header('Content-type: application/x-suggestions+json');
header('Content-type: application/json');
// Setup Search Engine Connection
$db = ConnectionManager::connectToIndex();
$results = $db->getSuggestion(strtolower($_GET['lookfor']), 'title_sort', 10);
echo json_encode($results);
}
示例5: __construct
/**
* Private constructor to ensure singleton pattern.
*
* @access private
*/
private function __construct()
{
global $configArray;
if (isset($configArray['Site']['bookBagMaxSize'])) {
$this->_maxSize = $configArray['Site']['bookBagMaxSize'];
}
$this->_items = array();
// Setup Search Engine Connection
$this->db = ConnectionManager::connectToIndex();
}
示例6: launch
/**
* Display the page.
*
* @return void
* @access public
*/
public function launch()
{
global $interface;
global $configArray;
// Connect to Solr:
$db = ConnectionManager::connectToIndex();
// Process incoming parameters:
$source = isset($_GET['source']) ? $_GET['source'] : false;
$from = isset($_GET['from']) ? $_GET['from'] : false;
$rowid = isset($_GET['rowid']) ? $_GET['rowid'] : false;
$page = isset($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page'] : 0;
$limit = isset($configArray['AlphaBrowse']['page_size']) ? $configArray['AlphaBrowse']['page_size'] : 20;
$extras = isset($configArray['AlphaBrowse_Extras'][$source]) ? $configArray['AlphaBrowse_Extras'][$source] : null;
// Normalize input for call numbers
if ($source == 'lcc' && $from) {
$from = $this->_normalizeCallNumber($from);
}
// If required parameters are present, load results:
if ($source && ($from !== false || $rowid !== false)) {
// Load Solr data or die trying:
$result = $db->alphabeticBrowse($source, $from, $rowid, $page, $limit, $extras, true);
$this->_checkError($result);
// No results? Try the previous page just in case we've gone past the
// end of the list....
if ($result['Browse']['totalCount'] == 0) {
$page--;
$result = $db->alphabeticBrowse($source, $from, $rowid, $page, $limit, $extras, true);
$this->_checkError($result);
}
// Only display next/previous page links when applicable:
$interface->assign('nextpage', $page + 1);
$interface->assign('nextRowid', $result['Browse']['endRow']);
if ($result['Browse']['startRow'] > 1) {
$interface->assign('prevpage', -1);
$interface->assign('prevRowid', $result['Browse']['startRow']);
}
// Send other relevant values to the template:
$interface->assign('source', $source);
$interface->assign('from', $from);
// Before assigning results, lets dedupe the extras
foreach ($result['Browse']['items'] as &$item) {
if (isset($item['extras'])) {
foreach ($item['extras'] as &$extra) {
$extra = array_unique($extra);
}
}
}
$interface->assign('result', $result);
}
// We also need to load all the same details as the basic Home action:
parent::launch();
}
示例7: __construct
/**
* Constructor
*
* @param bool $skipLogin Set to true to bypass the default login requirement.
*
* @access public
*/
public function __construct($skipLogin = false)
{
global $interface;
global $configArray;
global $user;
if (!$skipLogin && !UserAccount::isLoggedIn()) {
include_once 'Login.php';
Login::launch();
exit;
}
// Setup Search Engine Connection
$this->db = ConnectionManager::connectToIndex();
// Connect to Database
$this->catalog = ConnectionManager::connectToCatalog();
// Is Placing Holds allowed?
$this->checkHolds = $this->catalog->checkFunction("Holds", null);
// Is Cancelling Holds allowed?
$this->cancelHolds = $this->catalog->checkFunction("cancelHolds", null);
// Is Renewing Items allowed?
$this->checkRenew = $this->catalog->checkFunction("Renewals", null);
// Register Library Catalog Account
if (isset($_POST['submit']) && !empty($_POST['submit']) && $this->catalog && isset($_POST['cat_username']) && isset($_POST['cat_password'])) {
$username = $_POST['cat_username'];
$password = $_POST['cat_password'];
$loginTarget = isset($_POST['login_target']) ? $_POST['login_target'] : false;
if ($loginTarget) {
$username = "{$loginTarget}.{$username}";
}
if (UserAccount::processCatalogLogin($username, $password)) {
$interface->assign('user', $user);
} else {
$interface->assign('loginError', 'Invalid Patron Login');
}
}
// Assign Exporter Options
$exportOptions = array();
if ($configArray['BulkExport']['enabled']) {
$options = explode(':', $configArray['BulkExport']['options']);
foreach ($options as $option) {
if ($configArray['Export'][$option] == true) {
$exportOptions[] = $option;
}
}
$interface->assign('exportOptions', $exportOptions);
}
// Get Messages
$this->infoMsg = isset($_GET['infoMsg']) ? $_GET['infoMsg'] : false;
$this->errorMsg = isset($_GET['errorMsg']) ? $_GET['errorMsg'] : false;
$this->showExport = isset($_GET['showExport']) ? $_GET['showExport'] : false;
$this->followupUrl = false;
}
示例8: launch
/**
* Get similar items and return html snippet
*
* @return void
*/
public function launch()
{
global $interface;
if (!isset($_REQUEST['id'])) {
return;
}
$this->db = ConnectionManager::connectToIndex();
// Retrieve the record from the index
if (!($record = $this->db->getRecord($_REQUEST['id']))) {
PEAR::raiseError(new PEAR_Error('Record Does Not Exist'));
}
$this->recordDriver = RecordDriverFactory::initRecordDriver($record);
$interface->display($this->recordDriver->getSimilarItems());
}
示例9: __construct
/**
* Constructor.
*/
public function __construct()
{
// Load Configuration for this Module
$this->ilsConfigArray = parse_ini_file('conf/Unicorn.ini', true);
global $configArray;
// allow user to specify the full url to the Sirsi side perl script
$this->url = $this->ilsConfigArray['Catalog']['url'];
// host/port/search_prog kept for backward compatibility
if (isset($this->ilsConfigArray['Catalog']['host']) && isset($this->ilsConfigArray['Catalog']['port']) && isset($this->ilsConfigArray['Catalog']['search_prog'])) {
$this->host = $this->ilsConfigArray['Catalog']['host'];
$this->port = $this->ilsConfigArray['Catalog']['port'];
$this->search_prog = $this->ilsConfigArray['Catalog']['search_prog'];
}
$this->db = ConnectionManager::connectToIndex();
}
示例10: init
/**
* Initialize the driver.
*
* Validate configuration and perform all resource-intensive tasks needed to
* make the driver active.
*
* @throws ILSException
* @return void
*/
public function init()
{
if (empty($this->config)) {
throw new ILSException('Configuration needs to be set.');
}
// allow user to specify the full url to the Sirsi side perl script
$this->url = $this->config['Catalog']['url'];
// host/port/search_prog kept for backward compatibility
if (isset($this->config['Catalog']['host']) && isset($this->config['Catalog']['port']) && isset($this->config['Catalog']['search_prog'])) {
$this->host = $this->config['Catalog']['host'];
$this->port = $this->config['Catalog']['port'];
$this->search_prog = $this->config['Catalog']['search_prog'];
}
$this->db = ConnectionManager::connectToIndex();
}
示例11: launch
/**
* Process parameters and display the page.
*
* @return void
* @access public
*/
public function launch()
{
global $interface;
// Run the specified method if it exists... but don't run the launch
// method or we'll end up in an infinite loop!!
if (isset($_GET['util']) && $_GET['util'] != 'launch' && method_exists($this, $_GET['util'])) {
// Setup Search Engine Connection
$this->_db = ConnectionManager::connectToIndex();
$this->{$_GET}['util']();
} else {
$interface->setTemplate('records.tpl');
$interface->setPageTitle('Record Management');
$interface->display('layout-admin.tpl');
}
}
示例12: launch
/**
* Process parameters and display the page.
*
* @return void
* @access public
*/
public function launch()
{
global $configArray;
global $interface;
// Load SOLR Statistics
$solr = ConnectionManager::connectToIndex('SolrStats');
// All Statistics
$result = $solr->search('*:*', null, null, 0, null, array('field' => array('ipaddress', 'browser')), '', null, null, null, HTTP_REQUEST_METHOD_GET);
if (!PEAR::isError($result)) {
if (isset($result['facet_counts']['facet_fields']['ipaddress'])) {
$interface->assign('ipList', $result['facet_counts']['facet_fields']['ipaddress']);
}
if (isset($result['facet_counts']['facet_fields']['browser'])) {
$interface->assign('browserList', $result['facet_counts']['facet_fields']['browser']);
}
}
// Search Statistics
$result = $solr->search('phrase:[* TO *]', null, null, 0, null, array('field' => array('noresults', 'phrase')), '', null, null, null, HTTP_REQUEST_METHOD_GET);
if (!PEAR::isError($result)) {
$interface->assign('searchCount', $result['response']['numFound']);
// Extract the count of no hit results by finding the "no hit" facet
// entry set to boolean true.
$nohitCount = 0;
$nhFacet =& $result['facet_counts']['facet_fields']['noresults'];
if (isset($nhFacet) && is_array($nhFacet)) {
foreach ($nhFacet as $nhRow) {
if ($nhRow[0] == 'true') {
$nohitCount = $nhRow[1];
}
}
}
$interface->assign('nohitCount', $nohitCount);
$interface->assign('termList', $result['facet_counts']['facet_fields']['phrase']);
}
// Record View Statistics
$result = $solr->search('recordId:[* TO *]', null, null, 0, null, array('field' => array('recordId')), '', null, null, null, HTTP_REQUEST_METHOD_GET);
if (!PEAR::isError($result)) {
$interface->assign('recordViews', $result['response']['numFound']);
$interface->assign('recordList', $result['facet_counts']['facet_fields']['recordId']);
}
$interface->setTemplate('statistics.tpl');
$interface->setPageTitle('Statistics');
$interface->display('layout-admin.tpl');
}
示例13: getCartAsHTML
/**
* Process parameters and return the cart content as HTML.
*
* @return string the cart content formatted as HTML
* @access public
*/
public function getCartAsHTML()
{
global $interface;
// Setup Search Engine Connection
$db = ConnectionManager::connectToIndex();
// fetch records from search engine
// FIXME: currently only work with VuFind records
// we should make this work with Summon/WorldCat too
$records = array();
$items = $this->cart->getItems();
foreach ($items as $item) {
if ($record = $db->getRecord($item)) {
// TODO: perhaps we could use RecordDriver here
$records[] = $record;
}
}
$interface->assign('records', $records);
return $interface->fetch('Cart/cart.tpl');
}
示例14: launch
/**
* Process incoming parameters and display the page.
*
* @return void
* @access public
*/
public function launch()
{
global $configArray;
header('Content-Type: text/html; charset=ISO-8859-1');
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\">\n";
// Load information on the requested record:
// Setup Search Engine Connection
$db = ConnectionManager::connectToIndex();
// Retrieve the record from the index
if (!($record = $db->getRecord($_REQUEST['id']))) {
PEAR::raiseError(new PEAR_Error('Record Does Not Exist'));
}
if (strlen($record['fullrecord'])) {
$xml = $record['fullrecord'];
$result = simplexml_load_string($xml);
}
$url = isset($result->url) ? trim($result->url) : false;
if (empty($url)) {
PEAR::raiseError(new PEAR_Error('Not a VuDL Record'));
}
// Set up the XSLT processor:
$xslt = new XSLTProcessor();
// Register all non-private methods other than "launch" for access via XSLT:
$class = get_class($this);
$methods = get_class_methods($class);
foreach ($methods as $method) {
if ($method != 'launch' && substr($method, 0, 1) != '_') {
$xslt->registerPHPFunctions($class . '::' . $method);
}
}
$xsl = new DOMDocument();
$xsl->load(dirname(__FILE__) . '/xsl/transform.xsl');
$xslt->importStylesheet($xsl);
$xslt->setParameter('', 'path', $configArray['Site']['path']);
$sXml = file_get_contents($url);
$XML = new DOMDocument();
$XML->loadXML($sXml);
$html = $xslt->transformToXML($XML);
$html = str_replace('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">', '', $html);
$html = preg_replace('/<html[^>]*>/', '<html>', $html);
echo $html;
}
示例15: __construct
/**
* Constructor. Initialise some details about the server
*
* @access public
*/
public function __construct()
{
// Standard logic from parent class:
parent::__construct();
global $configArray;
// Connect to the index
$this->_indexEngine = ConnectionManager::connectToIndex('SolrReserves');
// Set up appropriate results action:
$this->resultsModule = 'Search';
$this->resultsAction = 'Reserves';
// Set up basic and advanced search types; default to basic.
$this->searchType = $this->basicSearchType = 'Reserves';
// Get default facet settings
$this->facetConfig = array();
$this->recommendIni = 'reserves';
// Load search preferences:
$searchSettings = getExtraConfigArray('reserves');
if (isset($searchSettings['General']['facet_limit'])) {
$this->_facetLimit = $searchSettings['General']['facet_limit'];
}
if (isset($searchSettings['General']['default_handler'])) {
$this->defaultIndex = $searchSettings['General']['default_handler'];
}
if (isset($searchSettings['General']['default_sort'])) {
$this->defaultSort = $searchSettings['General']['default_sort'];
}
if (isset($searchSettings['Basic_Searches'])) {
$this->basicTypes = $searchSettings['Basic_Searches'];
}
if (isset($searchSettings['Advanced_Searches'])) {
$this->advancedTypes = $searchSettings['Advanced_Searches'];
}
if (isset($searchSettings['Autocomplete']['enabled'])) {
$this->autocompleteStatus = $searchSettings['Autocomplete']['enabled'];
}
// Load sort preferences (or defaults if none in .ini file):
if (isset($searchSettings['Sorting'])) {
$this->sortOptions = $searchSettings['Sorting'];
} else {
$this->sortOptions = array('instructor_str' => 'sort_instructor', 'course_str' => 'sort_course', 'department_str' => 'sort_department');
}
}