本文整理汇总了PHP中SearchObjectFactory::deminify方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchObjectFactory::deminify方法的具体用法?PHP SearchObjectFactory::deminify怎么用?PHP SearchObjectFactory::deminify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchObjectFactory
的用法示例。
在下文中一共展示了SearchObjectFactory::deminify方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadSavedSearch
/**
* Load a saved search, if appropriate and legal; assign an error to the
* interface if necessary.
*
* @access protected
* @return SearchObject_Base|boolean mixed Search Object on successful load, false otherwise
*/
protected function loadSavedSearch()
{
global $interface;
global $user;
// Are we editing an existing search?
if (isset($_REQUEST['edit']) || isset($_SESSION['lastSearchId'])) {
// Go find it
$search = new SearchEntry();
$search->id = isset($_REQUEST['edit']) ? $_REQUEST['edit'] : $_SESSION['lastSearchId'];
if ($search->find(true)) {
// Check permissions
if ($search->session_id == session_id() || $search->user_id == $user->id) {
// Retrieve the search details
$minSO = unserialize($search->search_object);
$savedSearch = SearchObjectFactory::deminify($minSO);
// Make sure it's an advanced search
if ($savedSearch->getSearchType() == 'advanced') {
// Activate facets so we get appropriate descriptions
// in the filter list:
$savedSearch->activateAllFacets('Advanced');
return $savedSearch;
} else {
$interface->assign('editErr', 'notAdvanced');
}
// No permissions
} else {
$interface->assign('editErr', 'noRights');
}
// Not found
} else {
$interface->assign('editErr', 'notFound');
}
}
return false;
}
示例2: __construct
function __construct($subAction = false, $record_id = null)
{
global $interface;
global $configArray;
global $library;
global $timer;
global $user;
//Check to see if a user is logged in with admin permissions
if ($user && $user->hasRole('genealogyContributor')) {
$interface->assign('userIsAdmin', true);
} else {
$interface->assign('userIsAdmin', false);
}
$searchSource = isset($_REQUEST['searchSource']) ? $_REQUEST['searchSource'] : 'local';
//Load basic information needed in subclasses
if ($record_id == null || !isset($record_id)) {
$this->id = $_GET['id'];
} else {
$this->id = $record_id;
}
// Setup Search Engine Connection
// Include Search Engine Class
require_once ROOT_DIR . '/sys/' . $configArray['Genealogy']['engine'] . '.php';
$timer->logTime('Include search engine');
// Initialise from the current search globals
$this->db = SearchObjectFactory::initSearchObject($configArray['Genealogy']['searchObject']);
$this->db->init($searchSource);
// Retrieve Full Marc Record
if (!($record = $this->db->getRecord('person' . $this->id))) {
PEAR_Singleton::raiseError(new PEAR_Error('Record Does Not Exist'));
}
$this->record = $record;
//Load person from the database to get additional information
$person = Person::staticGet('personId', $this->id);
$record['picture'] = $person->picture;
$interface->assign('record', $record);
$interface->assign('person', $person);
$this->recordDriver = RecordDriverFactory::initRecordDriver($record);
$timer->logTime('Initialized the Record Driver');
$marriages = array();
$personMarriages = $person->marriages;
if (isset($personMarriages)) {
foreach ($personMarriages as $marriage) {
$marriageArray = (array) $marriage;
$marriageArray['formattedMarriageDate'] = $person->formatPartialDate($marriage->marriageDateDay, $marriage->marriageDateMonth, $marriage->marriageDateYear);
$marriages[] = $marriageArray;
}
}
$interface->assign('marriages', $marriages);
$obituaries = array();
$personObituaries = $person->obituaries;
if (isset($personObituaries)) {
foreach ($personObituaries as $obit) {
$obitArray = (array) $obit;
$obitArray['formattedObitDate'] = $person->formatPartialDate($obit->dateDay, $obit->dateMonth, $obit->dateYear);
$obituaries[] = $obitArray;
}
}
$interface->assign('obituaries', $obituaries);
//Do actions needed if this is the main action.
$interface->assign('id', $this->id);
// Retrieve User Search History
$interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false);
$this->cacheId = 'Person|' . $_GET['id'] . '|' . get_class($this);
// Send down text for inclusion in breadcrumbs
$interface->assign('breadcrumbText', $this->recordDriver->getBreadcrumb());
$formattedBirthdate = $person->formatPartialDate($person->birthDateDay, $person->birthDateMonth, $person->birthDateYear);
$interface->assign('birthDate', $formattedBirthdate);
$formattedDeathdate = $person->formatPartialDate($person->deathDateDay, $person->deathDateMonth, $person->deathDateYear);
$interface->assign('deathDate', $formattedDeathdate);
//Setup next and previous links based on the search results.
if (isset($_REQUEST['searchId'])) {
//rerun the search
$s = new SearchEntry();
$s->id = $_REQUEST['searchId'];
$interface->assign('searchId', $_REQUEST['searchId']);
$currentPage = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
$interface->assign('page', $currentPage);
$s->find();
if ($s->N > 0) {
$s->fetch();
$minSO = unserialize($s->search_object);
$searchObject = SearchObjectFactory::deminify($minSO);
$searchObject->setPage($currentPage);
//Run the search
$result = $searchObject->processSearch(true, false, false);
//Check to see if we need to run a search for the next or previous page
$currentResultIndex = $_REQUEST['recordIndex'] - 1;
$recordsPerPage = $searchObject->getLimit();
if ($currentResultIndex % $recordsPerPage == 0 && $currentResultIndex > 0) {
//Need to run a search for the previous page
$interface->assign('previousPage', $currentPage - 1);
$previousSearchObject = clone $searchObject;
$previousSearchObject->setPage($currentPage - 1);
$previousSearchObject->processSearch(true, false, false);
$previousResults = $previousSearchObject->getResultRecordSet();
} else {
if (($currentResultIndex + 1) % $recordsPerPage == 0 && $currentResultIndex + 1 < $searchObject->getResultTotal()) {
//Need to run a search for the next page
$nextSearchObject = clone $searchObject;
//.........这里部分代码省略.........
示例3: send
/**
* Send scheduled alerts
*
* @return void
*/
public function send()
{
global $configArray;
global $interface;
global $translator;
$iso8601 = 'Y-m-d\\TH:i:s\\Z';
ini_set('display_errors', true);
$configArray = $mainConfig = readConfig();
$datasourceConfig = getExtraConfigArray('datasources');
$siteLocal = $configArray['Site']['local'];
// Set up time zone. N.B. Don't use msg() or other functions requiring date before this.
date_default_timezone_set($configArray['Site']['timezone']);
$this->msg('Sending scheduled alerts');
// Setup Local Database Connection
ConnectionManager::connectToDatabase();
// Initialize Mailer
$mailer = new VuFindMailer();
// Find all scheduled alerts
$sql = 'SELECT * FROM "search" WHERE "schedule" > 0 ORDER BY user_id';
$s = new SearchEntry();
$s->query($sql);
$this->msg('Processing ' . $s->N . ' searches');
$user = false;
$interface = false;
$institution = false;
$todayTime = new DateTime();
while ($s->fetch()) {
$lastTime = new DateTime($s->last_executed);
if ($s->schedule == 1) {
// Daily
if ($todayTime->format('Y-m-d') == $lastTime->format('Y-m-d')) {
$this->msg('Bypassing search ' . $s->id . ': previous execution too recent (daily, ' . $lastTime->format($iso8601) . ')');
continue;
}
} elseif ($s->schedule == 2) {
// Weekly
$diff = $todayTime->diff($lastTime);
if ($diff->days < 6) {
$this->msg('Bypassing search ' . $s->id . ': previous execution too recent (weekly, ' . $lastTime->format($iso8601) . ')');
continue;
}
} else {
$this->msg('Search ' . $s->id . ': unknown schedule: ' . $s->schedule);
continue;
}
if ($user === false || $s->user_id != $user->id) {
$user = User::staticGet($s->user_id);
}
if (!$user->email || trim($user->email) == '') {
$this->msg('User ' . $user->username . ' does not have an email address, bypassing alert ' . $s->id);
continue;
}
$userInstitution = reset(explode(':', $user->username, 2));
if (!$institution || $institution != $userInstitution) {
$institution = $userInstitution;
if (!isset($datasourceConfig[$institution])) {
foreach ($datasourceConfig as $code => $values) {
if (isset($values['institution']) && strcasecmp($values['institution'], $institution) == 0) {
$institution = $code;
break;
}
}
}
if (!($configArray = $this->readInstitutionConfig($institution))) {
continue;
}
$configArray['Site']['url'] = $s->schedule_base_url;
// Start Interface
$interface = new UInterface($siteLocal);
$validLanguages = array_keys($configArray['Languages']);
$dateFormat = new VuFindDate();
}
$language = $user->language;
if (!in_array($user->language, $validLanguages)) {
$language = $configArray['Site']['language'];
}
$translator = new I18N_Translator(array($configArray['Site']['local'] . '/lang', $configArray['Site']['local'] . '/lang_local'), $language, $configArray['System']['debug']);
$interface->setLanguage($language);
$minSO = unserialize($s->search_object);
// Check minified search object type
$searchObject = SearchObjectFactory::deminify($minSO);
if (!$searchObject instanceof SearchObject_Solr) {
$this->msg('Search ' . $s->id . ': search object type not supported');
continue;
}
// Create a new search object to avoid cached defaults for e.g.
// hidden filters.
$searchObject = SearchObjectFactory::initSearchObject();
$searchObject->deminify($minSO);
$searchObject->setSort('first_indexed desc');
$searchTime = time();
$searchDate = gmdate($iso8601, time());
$searchObject->setLimit(50);
$searchObject->disableLogging();
$results = $searchObject->processSearch();
//.........这里部分代码省略.........
示例4: _restoreLastSearch
/**
* Restore the last saved search.
*
* @return SearchObject
* @access private
*/
private function _restoreLastSearch()
{
if (isset($_SESSION['lastSearchId'])) {
$search = new SearchEntry();
$search->id = $_SESSION['lastSearchId'];
if ($search->find(true)) {
$minSO = unserialize($search->search_object);
$savedSearch = SearchObjectFactory::deminify($minSO);
return $savedSearch;
}
}
return null;
}
示例5: launch
/**
* Process incoming parameters and display the page.
*
* @return void
* @access public
*/
public function launch()
{
global $interface;
global $user;
// Assign the ID of the last search so the user can return to it.
$interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : 'perkele');
$dateFormat = new VuFindDate();
// In some contexts, we want to require a login before showing search
// history:
if (isset($_REQUEST['require_login']) && !UserAccount::isLoggedIn()) {
include_once 'services/MyResearch/Login.php';
Login::launch();
exit;
}
$interface->setPageTitle('Search History');
// Retrieve search history
$s = new SearchEntry();
$searchHistory = $s->getSearches(session_id(), is_object($user) ? $user->id : null);
if (count($searchHistory) > 0) {
// Build an array of history entries
$links = array();
$saved = array();
// Loop through the history
foreach ($searchHistory as $search) {
$size = strlen($search->search_object);
$minSO = unserialize($search->search_object);
$searchObject = SearchObjectFactory::deminify($minSO);
// Make sure all facets are active so we get appropriate
// descriptions in the filter box.
$searchObject->activateAllFacets();
$newItem = array('time' => $dateFormat->convertToDisplayDate("U", floor($searchObject->getStartTime())), 'url' => $searchObject->renderSearchUrl(), 'searchId' => $searchObject->getSearchId(), 'description' => $searchObject->displayQuery(), 'filters' => $searchObject->getFilterList(), 'hits' => number_format($searchObject->getResultTotal(), 0, ',', ' '), 'speed' => round($searchObject->getQuerySpeed(), 2) . "s", 'size' => round($size / 1024, 3) . "kb", 'schedule' => $search->schedule, 'last_executed' => $search->last_executed);
// Saved searches
if ($search->saved == 1) {
$saved[] = $newItem;
} else {
// All the others...
// If this was a purge request we don't need this
if (isset($_REQUEST['purge']) && $_REQUEST['purge'] == 'true') {
$search->delete();
// We don't want to remember the last search after a purge:
unset($_SESSION['lastSearchURL']);
unset($_SESSION['lastSearchDisplayQuery']);
} else {
// Otherwise add to the list
$links[] = $newItem;
}
}
}
// One final check, after a purge make sure we still have a history
if (count($links) > 0 || count($saved) > 0) {
$interface->assign('links', array_reverse($links));
$interface->assign('saved', array_reverse($saved));
$interface->assign('noHistory', false);
} else {
// Nothing left in history
$interface->assign('noHistory', true);
}
} else {
// No history
$interface->assign('noHistory', true);
}
$interface->setTemplate('history.tpl');
$interface->display('layout.tpl');
}
示例6: getNextPrevLinks
public function getNextPrevLinks()
{
global $interface;
global $timer;
//Setup next and previous links based on the search results.
if (isset($_REQUEST['searchId']) && isset($_REQUEST['recordIndex'])) {
//rerun the search
$s = new SearchEntry();
$s->id = $_REQUEST['searchId'];
$interface->assign('searchId', $_REQUEST['searchId']);
$currentPage = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
$interface->assign('page', $currentPage);
$s->find();
if ($s->N > 0) {
$s->fetch();
$minSO = unserialize($s->search_object);
$searchObject = SearchObjectFactory::deminify($minSO);
$searchObject->setPage($currentPage);
//Run the search
$result = $searchObject->processSearch(true, false, false);
//Check to see if we need to run a search for the next or previous page
$currentResultIndex = $_REQUEST['recordIndex'] - 1;
$recordsPerPage = $searchObject->getLimit();
$adjustedResultIndex = $currentResultIndex - $recordsPerPage * ($currentPage - 1);
if ($currentResultIndex % $recordsPerPage == 0 && $currentResultIndex > 0) {
//Need to run a search for the previous page
$interface->assign('previousPage', $currentPage - 1);
$previousSearchObject = clone $searchObject;
$previousSearchObject->setPage($currentPage - 1);
$previousSearchObject->processSearch(true, false, false);
$previousResults = $previousSearchObject->getResultRecordSet();
} else {
if (($currentResultIndex + 1) % $recordsPerPage == 0 && $currentResultIndex + 1 < $searchObject->getResultTotal()) {
//Need to run a search for the next page
$nextSearchObject = clone $searchObject;
$interface->assign('nextPage', $currentPage + 1);
$nextSearchObject->setPage($currentPage + 1);
$nextSearchObject->processSearch(true, false, false);
$nextResults = $nextSearchObject->getResultRecordSet();
}
}
if (PEAR_Singleton::isError($result)) {
//If we get an error excuting the search, just eat it for now.
} else {
if ($searchObject->getResultTotal() < 1) {
//No results found
} else {
$recordSet = $searchObject->getResultRecordSet();
//Record set is 0 based, but we are passed a 1 based index
if ($currentResultIndex > 0) {
if (isset($previousResults)) {
$previousRecord = $previousResults[count($previousResults) - 1];
} else {
$previousId = $adjustedResultIndex - 1;
if (isset($recordSet[$previousId])) {
$previousRecord = $recordSet[$previousId];
}
}
//Convert back to 1 based index
if (isset($previousRecord)) {
$interface->assign('previousIndex', $currentResultIndex - 1 + 1);
$interface->assign('previousTitle', $previousRecord['title_display']);
if (strpos($previousRecord['id'], 'econtentRecord') === 0) {
$interface->assign('previousType', 'EcontentRecord');
$interface->assign('previousId', str_replace('econtentRecord', '', $previousRecord['id']));
} elseif (strpos($previousRecord['id'], 'list') === 0) {
$interface->assign('previousType', 'MyAccount/MyList');
$interface->assign('previousId', str_replace('list', '', $previousRecord['id']));
} else {
if ($previousRecord['recordtype'] == 'grouped_work') {
$interface->assign('previousType', 'GroupedWork');
$interface->assign('previousId', $previousRecord['id']);
} else {
$interface->assign('previousType', 'Record');
$interface->assign('previousId', $previousRecord['id']);
}
}
}
}
if ($currentResultIndex + 1 < $searchObject->getResultTotal()) {
if (isset($nextResults)) {
$nextRecord = $nextResults[0];
} else {
$nextRecordIndex = $adjustedResultIndex + 1;
if (isset($recordSet[$nextRecordIndex])) {
$nextRecord = $recordSet[$nextRecordIndex];
}
}
//Convert back to 1 based index
$interface->assign('nextIndex', $currentResultIndex + 1 + 1);
if (isset($nextRecord)) {
$interface->assign('nextTitle', $nextRecord['title_display']);
if (strpos($nextRecord['id'], 'econtentRecord') === 0) {
$interface->assign('nextType', 'EcontentRecord');
$interface->assign('nextId', str_replace('econtentRecord', '', $nextRecord['id']));
} elseif (strpos($nextRecord['id'], 'list') === 0) {
$interface->assign('nextType', 'MyAccount/MyList');
$interface->assign('nextId', str_replace('list', '', $nextRecord['id']));
} else {
if ($nextRecord['recordtype'] == 'grouped_work') {
//.........这里部分代码省略.........
示例7: restoreSavedSearch
/**
* If there is a saved search being loaded through $_REQUEST, redirect to the
* URL for that search. If no saved search was requested, return false. If
* unable to load a requested saved search, return a PEAR_Error object.
*
* @return mixed Does not return on successful load, returns false if no search
* to restore, returns PEAR_Error object in case of trouble.
* @access protected
*/
protected function restoreSavedSearch()
{
global $user;
// Is this is a saved search?
if (isset($_REQUEST['saved'])) {
// Yes, retrieve it
$search = new SearchEntry();
$search->id = $_REQUEST['saved'];
if ($search->find(true)) {
// Found, make sure the user has the
// rights to view this search
if ($search->session_id == session_id() || $search->user_id == $user->id) {
// They do, deminify it to a new object.
$minSO = unserialize($search->search_object);
$savedSearch = SearchObjectFactory::deminify($minSO);
// Now redirect to the URL associated with the saved search;
// this simplifies problems caused by mixing different classes
// of search object, and it also prevents the user from ever
// landing on a "?saved=xxxx" URL, which may not persist beyond
// the current session. (We want all searches to be
// persistent and bookmarkable).
header('Location: ' . $savedSearch->renderSearchUrl());
die;
} else {
// They don't
// TODO : Error handling -
// User is trying to view a saved search from
// another session (deliberate or expired) or
// associated with another user.
return new PEAR_Error("Attempt to access invalid search ID");
}
}
}
// Report no saved search to restore.
return false;
}
示例8: launch
function launch()
{
global $interface;
global $user;
// In some contexts, we want to require a login before showing search
// history:
if (isset($_REQUEST['require_login']) && !UserAccount::isLoggedIn()) {
require_once ROOT_DIR . '/services/MyAccount/Login.php';
MyAccount_Login::launch();
exit;
}
$interface->setPageTitle('Search History');
// Retrieve search history
$s = new SearchEntry();
$searchHistory = $s->getSearches(session_id(), is_object($user) ? $user->id : null);
if (count($searchHistory) > 0) {
// Build an array of history entries
$links = array();
$saved = array();
// Loop through the history
foreach ($searchHistory as $search) {
$size = strlen($search->search_object);
$minSO = unserialize($search->search_object);
$searchObject = SearchObjectFactory::deminify($minSO);
// Make sure all facets are active so we get appropriate
// descriptions in the filter box.
$searchObject->activateAllFacets();
$newItem = array('id' => $search->id, 'time' => date("g:ia, jS M y", $searchObject->getStartTime()), 'url' => $searchObject->renderSearchUrl(), 'searchId' => $searchObject->getSearchId(), 'description' => $searchObject->displayQuery(), 'filters' => $searchObject->getFilterList(), 'hits' => number_format($searchObject->getResultTotal()), 'speed' => round($searchObject->getQuerySpeed(), 2) . "s", 'size' => round($size / 1024, 3) . "kb");
// Saved searches
if ($search->saved == 1) {
$saved[] = $newItem;
// All the others
} else {
// If this was a purge request we don't need this
if (isset($_REQUEST['purge']) && $_REQUEST['purge'] == 'true') {
$search->delete();
// We don't want to remember the last search after a purge:
unset($_SESSION['lastSearchURL']);
// Otherwise add to the list
} else {
$links[] = $newItem;
}
}
}
// One final check, after a purge make sure we still have a history
if (count($links) > 0 || count($saved) > 0) {
$interface->assign('links', array_reverse($links));
$interface->assign('saved', array_reverse($saved));
$interface->assign('noHistory', false);
// Nothing left in history
} else {
$interface->assign('noHistory', true);
}
// No history
} else {
$interface->assign('noHistory', true);
}
//Load profile information for display in My Account menu
//This code is also in MyResearch.php
if ($user !== false) {
global $configArray;
$this->catalog = CatalogFactory::getCatalogConnectionInstance();
// Get My Profile
if ($this->catalog->status) {
if ($user->cat_username) {
$patron = $this->catalog->patronLogin($user->cat_username, $user->cat_password);
if (PEAR_Singleton::isError($patron)) {
PEAR_Singleton::raiseError($patron);
}
$result = $this->catalog->getMyProfile($patron);
if (!PEAR_Singleton::isError($result)) {
$interface->assign('profile', $result);
}
}
}
//Figure out if we should show a link to classic opac to pay holds.
global $library;
$homeLibrary = $library->getLibraryForLocation($user->homeLocationId);
if ($homeLibrary->showEcommerceLink == 1) {
$interface->assign('showEcommerceLink', true);
$interface->assign('minimumFineAmount', $homeLibrary->minimumFineAmount);
} else {
$interface->assign('showEcommerceLink', false);
$interface->assign('minimumFineAmount', 0);
}
}
$interface->assign('sidebar', 'MyAccount/account-sidebar.tpl');
$interface->setTemplate('history.tpl');
$interface->display('layout.tpl');
}