本文整理汇总了PHP中PEAR_Singleton::isError方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_Singleton::isError方法的具体用法?PHP PEAR_Singleton::isError怎么用?PHP PEAR_Singleton::isError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR_Singleton
的用法示例。
在下文中一共展示了PEAR_Singleton::isError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: launch
function launch()
{
global $interface;
global $configArray;
global $library;
global $locationSingleton;
global $timer;
global $user;
if ($user) {
$catalog = new CatalogConnection($configArray['Catalog']['driver']);
$patron = $catalog->patronLogin($user->cat_username, $user->cat_password);
$profile = $catalog->getMyProfile($patron);
if (!PEAR_Singleton::isError($profile)) {
$interface->assign('profile', $profile);
}
if (!isset($_REQUEST['overDriveId']) || !isset($_REQUEST['formatId'])) {
header('Location: /');
exit;
} else {
$interface->assign('overDriveId', $_REQUEST['overDriveId']);
$interface->assign('overDriveFormatId', $_REQUEST['formatId']);
$interface->setPageTitle('OverDrive Loan Period');
$interface->setTemplate('od-loan-period.tpl');
}
//Var for the IDCLREADER TEMPLATE
$interface->assign('ButtonBack', false);
$interface->assign('ButtonHome', true);
$interface->assign('MobileTitle', 'OverDrive Loan Period');
} else {
$interface->setTemplate('odCOlogin.tpl');
}
$interface->display('layout.tpl');
}
示例2: Login
function Login()
{
global $configArray;
// Fetch Salt
$salt = $this->generateSalt();
// HexDecode Password
$password = pack('H*', $_GET['password']);
// Decrypt Password
/*
require_once 'Crypt/Blowfish.php';
$cipher = new Crypt_Blowfish($salt);
$password = $cipher->decrypt($_GET['password']);
*/
/*
require_once 'Crypt/XXTEA.php';
$cipher = new Crypt_XXTEA();
$cipher->setKey($salt);
$password = $cipher->decrypt($password);
*/
require_once 'Crypt/rc4.php';
$password = rc4Encrypt($salt, $password);
// Put the username/password in POST fields where the authentication module
// expects to find them:
$_POST['username'] = $_GET['username'];
$_POST['password'] = $password;
// Authenticate the user:
$user = UserAccount::login();
if (PEAR_Singleton::isError($user)) {
return 'Error';
} else {
return 'True';
}
}
示例3: loadEnrichment
/**
* Load information from the review provider and update the interface with the data.
*
* @param string $isbn The ISBN to load data for
* @return array Returns array with review data, otherwise a
* PEAR_Error.
*/
static function loadEnrichment($isbn)
{
global $interface;
global $configArray;
$enrichment = array();
// Fetch from provider
if (isset($configArray['Content']['enrichment'])) {
$providers = explode(',', $configArray['Content']['enrichment']);
foreach ($providers as $provider) {
$provider = explode(':', trim($provider));
$func = strtolower($provider[0]);
if (method_exists(new Record_Enrichment(), $func)) {
$enrichment[$func] = Record_Enrichment::$func($isbn);
// If the current provider had no valid reviews, store nothing:
if (empty($enrichment[$func]) || PEAR_Singleton::isError($enrichment[$func])) {
unset($enrichment[$func]);
}
}
}
}
if ($enrichment) {
$interface->assign('enrichment', $enrichment);
}
return $enrichment;
}
示例4: sendSMS
function sendSMS()
{
global $configArray;
global $interface;
// Get Holdings
try {
$catalog = new CatalogConnection($configArray['Catalog']['driver']);
} catch (PDOException $e) {
return new PEAR_Error('Cannot connect to ILS');
}
$holdingsSummary = $catalog->getStatusSummary($_GET['id']);
if (PEAR_Singleton::isError($holdingsSummary)) {
return $holdingsSummary;
}
if (isset($holdingsSummary['callnumber'])) {
$interface->assign('callnumber', $holdingsSummary['callnumber']);
}
if (isset($holdingsSummary['availableAt'])) {
$interface->assign('availableAt', strip_tags($holdingsSummary['availableAt']));
}
if (isset($holdingsSummary['downloadLink'])) {
$interface->assign('downloadLink', $holdingsSummary['downloadLink']);
}
$interface->assign('title', $this->recordDriver->getBreadcrumb());
$interface->assign('recordID', $_GET['id']);
$message = $interface->fetch('Emails/catalog-sms.tpl');
return $this->sms->text($_REQUEST['provider'], $_REQUEST['to'], $configArray['Site']['email'], $message);
}
示例5: authenticate
public function authenticate()
{
global $user;
//Check to see if the username and password are provided
if (!array_key_exists('username', $_REQUEST) && !array_key_exists('password', $_REQUEST)) {
//If not, check to see if we have a valid user already authenticated
if ($user) {
return $user;
}
}
$this->username = $_REQUEST['username'];
$this->password = $_REQUEST['password'];
if ($this->username == '' || $this->password == '') {
$user = new PEAR_Error('authentication_error_blank');
} else {
// Connect to Database
$catalog = CatalogFactory::getCatalogConnectionInstance();
if ($catalog->status) {
$patron = $catalog->patronLogin($this->username, $this->password);
if ($patron && !PEAR_Singleton::isError($patron)) {
$user = $this->processILSUser($patron);
//Also call getPatronProfile to update extra fields
$catalog = CatalogFactory::getCatalogConnectionInstance();
$catalog->getMyProfile($user);
} else {
$user = new PEAR_Error('authentication_error_invalid');
}
} else {
$user = new PEAR_Error('authentication_error_technical');
}
}
return $user;
}
示例6: launch
function launch()
{
global $interface;
global $finesIndexEngine;
global $configArray;
$ils = $configArray['Catalog']['ils'];
$interface->assign('showDate', $ils == 'Koha' || $ils == 'Horizon');
$interface->assign('showReason', $ils != 'Koha');
$interface->assign('showOutstanding', $ils == 'Koha');
// Get My Fines
if ($patron = $this->catalogLogin()) {
if (PEAR_Singleton::isError($patron)) {
PEAR_Singleton::raiseError($patron);
}
if ($this->catalog->checkFunction('getMyFines')) {
$result = $this->catalog->getMyFines($patron, true);
if (!PEAR_Singleton::isError($result)) {
$interface->assign('fines', $result);
} else {
PEAR_Singleton::raiseError($result);
}
} else {
$interface->assign('finesData', translate('This catalog does not support listing fines.'));
}
}
$interface->assign('sidebar', 'MyAccount/account-sidebar.tpl');
$interface->setTemplate('fines.tpl');
$interface->setPageTitle('My Fines');
$interface->display('layout.tpl');
}
示例7: getWikipediaImageURL
/**
* getWikipediaImageURL
*
* This method is responsible for obtaining an image URL based on a name.
*
* @param string $imageName The image name to look up
* @return mixed URL on success, false on failure
* @access private
*/
private function getWikipediaImageURL($imageName)
{
$url = "http://{$this->lang}.wikipedia.org/w/api.php" . '?prop=imageinfo&action=query&iiprop=url&iiurlwidth=150&format=php' . '&titles=Image:' . $imageName;
$client = new Proxy_Request();
$client->setMethod(HTTP_REQUEST_METHOD_GET);
$client->setURL($url);
$result = $client->sendRequest();
if (PEAR_Singleton::isError($result)) {
return false;
}
if ($response = $client->getResponseBody()) {
if ($imageinfo = unserialize($response)) {
if (isset($imageinfo['query']['pages']['-1']['imageinfo'][0]['url'])) {
$imageUrl = $imageinfo['query']['pages']['-1']['imageinfo'][0]['url'];
}
// Hack for wikipedia api, just in case we couldn't find it
// above look for a http url inside the response.
if (!isset($imageUrl)) {
preg_match('/\\"http:\\/\\/(.*)\\"/', $response, $matches);
if (isset($matches[1])) {
$imageUrl = 'http://' . substr($matches[1], 0, strpos($matches[1], '"'));
}
}
}
}
return isset($imageUrl) ? $imageUrl : false;
}
示例8: launch
function launch()
{
global $configArray;
global $interface;
global $user;
global $timer;
// Get My Transactions
if ($this->catalog->status) {
if ($user->cat_username) {
$patron = $this->catalog->patronLogin($user->cat_username, $user->cat_password);
$timer->logTime("Logged in patron to get checked out items.");
if (PEAR_Singleton::isError($patron)) {
PEAR_Singleton::raiseError($patron);
}
$patronResult = $this->catalog->getMyProfile($patron);
if (!PEAR_Singleton::isError($patronResult)) {
$interface->assign('profile', $patronResult);
}
$timer->logTime("Got patron profile to get checked out items.");
// Define sorting options
$sortOptions = array('title' => 'Title', 'author' => 'Author', 'dueDate' => 'Due Date', 'format' => 'Format');
$interface->assign('sortOptions', $sortOptions);
$selectedSortOption = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'dueDate';
$interface->assign('defaultSortOption', $selectedSortOption);
$interface->assign('showNotInterested', false);
require_once ROOT_DIR . '/Drivers/EContentDriver.php';
$driver = new EContentDriver();
if (isset($_REQUEST['multiAction']) && $_REQUEST['multiAction'] == 'suspendSelected') {
$ids = array();
foreach ($_REQUEST['unavailableHold'] as $id => $selected) {
$ids[] = $id;
}
$suspendDate = $_REQUEST['suspendDate'];
$dateToReactivate = strtotime($suspendDate);
$suspendResult = $driver->suspendHolds($ids, $dateToReactivate);
//Redirect back to the EContentHolds page
header("Location: " . $configArray['Site']['path'] . "/MyResearch/EContentHolds?section=unavailable");
}
$result = $driver->getMyHolds($user);
$interface->assign('holds', $result['holds']);
$timer->logTime("Loaded econtent from catalog.");
}
}
$hasSeparateTemplates = $interface->template_exists('MyResearch/eContentAvailableHolds.tpl');
if ($hasSeparateTemplates) {
$section = isset($_REQUEST['section']) ? $_REQUEST['section'] : 'available';
$interface->assign('section', $section);
if ($section == 'available') {
$interface->setPageTitle('Available eContent');
$interface->setTemplate('eContentAvailableHolds.tpl');
} else {
$interface->setPageTitle('eContent On Hold');
$interface->setTemplate('eContentUnavailableHolds.tpl');
}
} else {
$interface->setTemplate('eContentHolds.tpl');
$interface->setPageTitle('On Hold eContent');
}
$interface->display('layout.tpl');
}
示例9: launch
function launch()
{
global $interface;
global $configArray;
$id = strip_tags($_REQUEST['id']);
$interface->assign('id', $id);
if (isset($_POST['submit'])) {
$result = $this->sendEmail($_POST['to'], $_POST['from'], $_POST['message']);
if (!PEAR_Singleton::isError($result)) {
require_once 'Home.php';
EcontentRecord_Home::launch();
exit;
} else {
$interface->assign('message', $result->getMessage());
}
}
// Display Page
if (isset($_GET['lightbox'])) {
$interface->assign('lightbox', true);
echo $interface->fetch('EcontentRecord/email.tpl');
} else {
$interface->setPageTitle('Email Record');
$interface->assign('subTemplate', 'email.tpl');
$interface->setTemplate('view-alt.tpl');
$interface->display('layout.tpl', 'RecordEmail' . $_GET['id']);
}
}
示例10: launch
function launch()
{
global $interface;
$id = $_GET['id'];
$interface->assign('id', $id);
$this->eContentRecord = new EContentRecord();
$this->eContentRecord->id = $_GET['id'];
$this->eContentRecord->find(true);
$recordDriver = new EcontentRecordDriver();
$recordDriver->setDataObject($this->eContentRecord);
$interface->assign('sourceUrl', $this->eContentRecord->sourceUrl);
$interface->assign('source', $this->eContentRecord->source);
$interface->setPageTitle(translate('Copies') . ': ' . $recordDriver->getBreadcrumb());
$driver = new EContentDriver();
$holdings = $driver->getHolding($id);
$showEContentNotes = false;
foreach ($holdings as $holding) {
if (strlen($holding->notes) > 0) {
$showEContentNotes = true;
}
}
$interface->assign('showEContentNotes', $showEContentNotes);
$interface->assign('holdings', $holdings);
//Load status summary
$result = $driver->getStatusSummary($id, $holdings);
if (PEAR_Singleton::isError($result)) {
PEAR_Singleton::raiseError($result);
}
$holdingData->holdingsSummary = $result;
$interface->assign('subTemplate', 'view-holdings.tpl');
$interface->setTemplate('view-alt.tpl');
// Display Page
$interface->display('layout.tpl');
}
示例11: launch
function launch()
{
global $interface;
global $configArray;
if (isset($_REQUEST['searchId'])) {
$_SESSION['searchId'] = $_REQUEST['searchId'];
$interface->assign('searchId', $_SESSION['searchId']);
} else {
if (isset($_SESSION['searchId'])) {
$interface->assign('searchId', $_SESSION['searchId']);
}
}
$interface->assign('overDriveVersion', isset($configArray['OverDrive']['interfaceVersion']) ? $configArray['OverDrive']['interfaceVersion'] : 1);
$this->id = strip_tags($_REQUEST['id']);
$interface->assign('id', $this->id);
$recordDriver = new OverDriveRecordDriver($this->id);
if (!$recordDriver->isValid()) {
$interface->setTemplate('../Record/invalidRecord.tpl');
$interface->display('layout.tpl');
die;
} else {
$interface->assign('recordDriver', $recordDriver);
//Load status summary
require_once ROOT_DIR . '/Drivers/OverDriveDriverFactory.php';
$driver = OverDriveDriverFactory::getDriver();
$holdings = $driver->getHoldings($recordDriver);
$scopedAvailability = $driver->getScopedAvailability($recordDriver);
$holdingsSummary = $driver->getStatusSummary($this->id, $scopedAvailability, $holdings);
if (PEAR_Singleton::isError($holdingsSummary)) {
PEAR_Singleton::raiseError($holdingsSummary);
}
$interface->assign('holdingsSummary', $holdingsSummary);
//Load the citations
$this->loadCitations($recordDriver);
// Retrieve User Search History
$interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false);
//Get Next/Previous Links
$searchSource = isset($_REQUEST['searchSource']) ? $_REQUEST['searchSource'] : 'local';
$searchObject = SearchObjectFactory::initSearchObject();
$searchObject->init($searchSource);
$searchObject->getNextPrevLinks();
// Set Show in Main Details Section options for templates
// (needs to be set before moreDetailsOptions)
global $library;
foreach ($library->showInMainDetails as $detailoption) {
$interface->assign($detailoption, true);
}
$interface->setPageTitle($recordDriver->getTitle());
$interface->assign('moreDetailsOptions', $recordDriver->getMoreDetailsOptions());
// Display Page
$interface->assign('sidebar', 'OverDrive/full-record-sidebar.tpl');
$interface->assign('moreDetailsTemplate', 'GroupedWork/moredetails-accordion.tpl');
$interface->setTemplate('view.tpl');
$interface->display('layout.tpl');
}
}
示例12: launch
function launch()
{
global $interface;
$interface->caching = false;
// Retrieve User Search History
$interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false);
// Initialise from the current search globals
$searchObject = SearchObjectFactory::initSearchObject();
$searchObject->init();
// TODO : Stats
$result = $searchObject->processSearch();
if (PEAR_Singleton::isError($result)) {
PEAR_Singleton::raiseError($result->getMessage());
}
$interface->assign('sortList', $searchObject->getSortList());
$interface->assign('lookfor', $searchObject->displayQuery());
$interface->assign('searchType', $searchObject->getSearchType());
$interface->assign('searchIndex', $searchObject->getSearchIndex());
$interface->assign('qtime', round($searchObject->getQuerySpeed(), 2));
$summary = $searchObject->getResultSummary();
// Post processing, remember that the REAL results here with regards to
// numbers and pagination are the author facet, not the document
// results from the solr index. So access '$summary' with care.
$page = $summary['page'];
$limit = $summary['perPage'];
// The search object will have returned an array of author facets that
// is offset to display the current page of results but which has more
// than a single page worth of content. This allows a user to dig deeper
// and deeper into the result set even though we have no way of finding
// out the exact count of results without risking a memory overflow or
// long delay. We need to use the current page information to adjust the
// known total count accordingly, and we need to use the page size to
// crop off extra results when displaying the list to the user.
// See VUFIND-127 in JIRA for more details.
$authors = $result['facet_counts']['facet_fields']['authorStr'];
$cnt = ($page - 1) * $limit + count($authors);
$interface->assign('recordSet', array_slice($authors, 0, $limit));
$interface->assign('recordCount', $cnt);
$interface->assign('recordStart', ($page - 1) * $limit + 1);
if ($cnt < $limit || $page * $limit > $cnt) {
$interface->assign('recordEnd', $cnt);
} else {
$interface->assign('recordEnd', $page * $limit);
}
$link = $searchObject->renderLinkPageTemplate();
$options = array('totalItems' => $cnt, 'fileName' => $link);
$pager = new VuFindPager($options);
$interface->assign('pageLinks', $pager->getLinks());
$interface->setPageTitle('Author Browse');
$interface->setTemplate('list.tpl');
$interface->display('layout.tpl');
}
示例13: login
public static function login()
{
global $configArray;
// Perform authentication:
$authN = AuthenticationFactory::initAuthentication($configArray['Authentication']['method']);
$user = $authN->authenticate();
// If we authenticated, store the user in the session:
if (!PEAR_Singleton::isError($user)) {
self::updateSession($user);
}
// Send back the user object (which may be a PEAR error):
return $user;
}
示例14: launch
function launch()
{
global $interface;
global $configArray;
global $library;
global $locationSingleton;
global $timer;
global $user;
// Include Search Engine Class
require_once ROOT_DIR . '/sys/' . $configArray['Index']['engine'] . '.php';
$timer->logTime('Include search engine');
$interface->assign('showBreadcrumbs', 0);
if ($user) {
$catalog = new CatalogConnection($configArray['Catalog']['driver']);
$patron = $catalog->patronLogin($user->cat_username, $user->cat_password);
$profile = $catalog->getMyProfile($patron);
if (!PEAR_Singleton::isError($profile)) {
$interface->assign('profile', $profile);
}
}
//Get the lists to show on the home page
require_once ROOT_DIR . '/sys/ListWidget.php';
$widgetId = 1;
$activeLocation = $locationSingleton->getActiveLocation();
if ($activeLocation != null && $activeLocation->homePageWidgetId > 0) {
$widgetId = $activeLocation->homePageWidgetId;
$widget = new ListWidget();
$widget->id = $widgetId;
if ($widget->find(true)) {
$interface->assign('widget', $widget);
}
} else {
if (isset($library) && $library->homePageWidgetId > 0) {
$widgetId = $library->homePageWidgetId;
$widget = new ListWidget();
$widget->id = $widgetId;
if ($widget->find(true)) {
$interface->assign('widget', $widget);
}
}
}
// Cache homepage
$interface->caching = 0;
$cacheId = 'homepage|' . $interface->lang;
//Disable Home page caching for now.
if (!$interface->is_cached('layout.tpl', $cacheId)) {
$interface->setPageTitle('Catalog Home');
$interface->setTemplate('home.tpl');
}
$interface->display('layout.tpl', $cacheId);
}
示例15: launch
function launch()
{
global $interface;
// Depending on context, we may get the record ID that initiated the "add
// list" action in a couple of different places -- make sure we check all
// necessary options before giving up!
if (!isset($_GET['id']) && isset($_REQUEST['recordId'])) {
$_GET['id'] = $_REQUEST['recordId'];
}
$interface->assign('recordId', isset($_GET['id']) ? $_GET['id'] : false);
$interface->assign('source', isset($_GET['source']) ? $_GET['source'] : false);
// Check if user is logged in
if (!$this->user) {
if (isset($_GET['lightbox'])) {
$interface->assign('title', $_GET['message']);
$interface->assign('message', 'You must be logged in first');
return $interface->fetch('AJAX/login.tpl');
} else {
require_once ROOT_DIR . '/services/MyAccount/Login.php';
$loginAction = new MyAccount_Login();
$loginAction->launch();
}
exit;
}
// Display Page
if (isset($_GET['lightbox'])) {
$interface->assign('title', translate('Create new list'));
echo $interface->fetch('MyResearch/list-form.tpl');
} else {
if (isset($_REQUEST['submit'])) {
$result = $this->addList();
if (PEAR_Singleton::isError($result)) {
$interface->assign('listError', $result->getMessage());
} else {
if (!empty($_REQUEST['recordId'])) {
$url = '../Record/' . urlencode($_REQUEST['recordId']) . '/Save';
} else {
$url = 'Home';
}
header('Location: ' . $url);
die;
}
}
$interface->setPageTitle('Create a List');
$interface->assign('subTemplate', 'list-form.tpl');
$interface->setTemplate('view-alt.tpl');
$interface->display('layout.tpl');
}
}