本文整理汇总了PHP中Library::whereAdd方法的典型用法代码示例。如果您正苦于以下问题:PHP Library::whereAdd方法的具体用法?PHP Library::whereAdd怎么用?PHP Library::whereAdd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Library
的用法示例。
在下文中一共展示了Library::whereAdd方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLibraryForLocation
static function getLibraryForLocation($locationId)
{
if (isset($locationId)) {
$libLookup = new Library();
require_once ROOT_DIR . '/Drivers/marmot_inc/Location.php';
$libLookup->whereAdd('libraryId = (SELECT libraryId FROM location WHERE locationId = ' . $libLookup->escape($locationId) . ')');
$libLookup->find();
if ($libLookup->N > 0) {
$libLookup->fetch();
return clone $libLookup;
}
}
return null;
}
示例2: updateConfigForScoping
/**
* Update the configuration array as needed based on scoping rules defined
* by the subdomain.
*
* @param array $configArray the existing main configuration options.
*
* @return array the configuration options adjusted based on the scoping rules.
*/
function updateConfigForScoping($configArray)
{
global $timer;
//Get the subdomain for the request
global $serverName;
//split the servername based on
global $subdomain;
$subdomain = null;
if (strpos($_SERVER['SERVER_NAME'], '.')) {
$serverComponents = explode('.', $_SERVER['SERVER_NAME']);
if (count($serverComponents) >= 3) {
//URL is probably of the form subdomain.marmot.org or subdomain.opac.marmot.org
$subdomain = $serverComponents[0];
} else {
if (count($serverComponents) == 2) {
//URL could be either subdomain.localhost or marmot.org. Only use the subdomain
//If the second component is localhost.
if (strcasecmp($serverComponents[1], 'localhost') == 0) {
$subdomain = $serverComponents[0];
}
}
}
//Trim off test indicator when doing lookups for library/location
if (substr($subdomain, -1) == '2' || substr($subdomain, -1) == '3') {
$subdomain = substr($subdomain, 0, -1);
}
}
$timer->logTime('got subdomain');
//Load the library system information
global $library;
global $locationSingleton;
if (isset($_SESSION['library']) && isset($_SESSION['location'])) {
$library = $_SESSION['library'];
$locationSingleton = $_SESSION['library'];
} else {
$Library = new Library();
$Library->whereAdd("subdomain = '{$subdomain}'");
$Library->find();
if ($Library->N == 1) {
$Library->fetch();
//Make the library information global so we can work with it later.
$library = $Library;
} else {
//The subdomain can also indicate a location.
$Location = new Location();
$Location->whereAdd("code = '{$subdomain}'");
$Location->find();
if ($Location->N == 1) {
$Location->fetch();
//We found a location for the subdomain, get the library.
/** @var Library $librarySingleton */
global $librarySingleton;
$library = $librarySingleton->getLibraryForLocation($Location->locationId);
$locationSingleton->setActiveLocation(clone $Location);
} else {
//Check to see if there is only one library in the system
$Library = new Library();
$Library->find();
if ($Library->N == 1) {
$Library->fetch();
$library = $Library;
}
}
}
}
if (isset($library) && $library != null) {
//Update the title
$configArray['Site']['theme'] = $library->themeName . ',' . $configArray['Site']['theme'] . ',default';
$configArray['Site']['title'] = $library->displayName;
$location = $locationSingleton->getActiveLocation();
//Add an extra css file for the location if it exists.
$themes = explode(',', $library->themeName);
foreach ($themes as $themeName) {
if ($location != null && file_exists('./interface/themes/' . $themeName . '/images/' . $location->code . '_logo_responsive.png')) {
$configArray['Site']['responsiveLogo'] = '/interface/themes/' . $themeName . '/images/' . $location->code . '_logo_responsive.png';
}
if ($subdomain != null && file_exists('./interface/themes/' . $themeName . '/images/' . $subdomain . '_logo_responsive.png')) {
$configArray['Site']['responsiveLogo'] = '/interface/themes/' . $themeName . '/images/' . $subdomain . '_logo_responsive.png';
}
if ($location != null && file_exists('./interface/themes/' . $themeName . '/images/' . $location->code . '_logo_small.png')) {
$configArray['Site']['smallLogo'] = '/interface/themes/' . $themeName . '/images/' . $location->code . '_logo_small.png';
}
if ($location != null && file_exists('./interface/themes/' . $themeName . '/images/' . $location->code . '_logo_large.png')) {
$configArray['Site']['largeLogo'] = '/interface/themes/' . $themeName . '/images/' . $location->code . '_logo_large.png';
}
}
}
$timer->logTime('finished update config for scoping');
return $configArray;
}
示例3: getItemsFast
public function getItemsFast()
{
global $configArray;
if ($this->fastItems == null) {
$searchLibrary = Library::getSearchLibrary();
if ($searchLibrary) {
$libraryLocationCode = $searchLibrary->ilsCode;
}
$searchLocation = Location::getSearchLocation();
if ($searchLocation) {
$homeLocationCode = $searchLocation->code;
} else {
$homeLocation = Location::getUserHomeLocation();
if ($homeLocation) {
$homeLocationCode = $homeLocation->code;
}
}
$this->fastItems = array();
if ($this->itemsFromIndex) {
$this->fastItems = array();
foreach ($this->itemsFromIndex as $itemData) {
$isLocalItem = false;
$isLibraryItem = false;
if (array_key_exists('item', $itemData)) {
$itemId = $itemData['item'][0];
$locationCode = $itemData['item'][1];
$shelfLocation = mapValue('shelf_location', $locationCode);
$sharing = $itemData['item'][3];
$source = $itemData['item'][4];
$fileOrUrl = '';
if (count($itemData['item']) > 5) {
$fileOrUrl = $itemData['item'][5];
}
if (array_key_exists('scope', $itemData)) {
$isLocalItem = $itemData['scope'][1] == 'true';
$isLibraryItem = $itemData['scope'][2] == 'true';
}
} else {
$itemId = $itemData[1];
$locationCode = $itemData[2];
$shelfLocation = mapValue('shelf_location', $itemData[2]);
$sharing = $itemData[4];
$source = $itemData[5];
$fileOrUrl = '';
if (count($itemData) > 6) {
$fileOrUrl = $itemData[6];
}
$isLocalItem = isset($libraryLocationCode) && strlen($libraryLocationCode) > 0 && strpos($locationCode, $libraryLocationCode) === 0;
$isLibraryItem = isset($homeLocationCode) && strlen($homeLocationCode) > 0 && strpos($locationCode, $homeLocationCode) === 0;
}
$actions = $this->getActionsForItem($itemId, $fileOrUrl, null);
$libraryLabelObj = new Library();
$libraryLabelObj->whereAdd("'{$locationCode}' LIKE CONCAT(ilsCode, '%') and ilsCode <> ''");
$libraryLabelObj->selectAdd();
$libraryLabelObj->selectAdd('displayName');
if ($libraryLabelObj->find(true)) {
$libraryLabel = $libraryLabelObj->displayName;
} else {
$libraryLabel = $locationCode . ' Online';
}
//TODO: Get the correct number of available copies
$totalCopies = 1;
$this->fastItems[] = array('itemId' => $itemId, 'location' => $locationCode, 'callnumber' => '', 'availability' => $this->isItemAvailable($itemId, $totalCopies), 'holdable' => $this->isEContentHoldable($locationCode, $itemData), 'inLibraryUseOnly' => false, 'isLocalItem' => $isLocalItem, 'isLibraryItem' => $isLibraryItem, 'locationLabel' => 'Online', 'libraryLabel' => $libraryLabel, 'shelfLocation' => $shelfLocation, 'source' => 'Online ' . $source, 'sharing' => $sharing, 'actions' => $actions);
}
} else {
/** @var File_MARC_Data_Field[] $itemFields */
$itemFields = $this->getMarcRecord()->getFields('989');
foreach ($itemFields as $itemField) {
$locationCode = trim($itemField->getSubfield('d') != null ? $itemField->getSubfield('d')->getData() : '');
//Each item can have multiple item fields
/** @var File_MARC_Subfield[] $eContentFields */
$eContentFields = $itemField->getSubfields('w');
$itemId = $itemField->getSubfield('1')->getData();
$iType = $itemField->getSubfield($configArray['Reindex']['iTypeSubfield'])->getData();
foreach ($eContentFields as $eContentField) {
$eContentData = trim($eContentField->getData() != null ? $eContentField->getData() : '');
if ($eContentData && strpos($eContentData, ':') > 0) {
$eContentFieldData = explode(':', $eContentData);
$source = trim($eContentFieldData[0]);
$protectionType = strtolower(trim($eContentFieldData[1]));
$totalCopies = 1;
if ($this->isValidProtectionType($protectionType)) {
if ($this->isValidForUser($locationCode, $eContentFieldData)) {
$libraryLabelObj = new Library();
$libraryLabelObj->whereAdd("'{$locationCode}' LIKE CONCAT(ilsCode, '%') and ilsCode <> ''");
$libraryLabelObj->selectAdd();
$libraryLabelObj->selectAdd('displayName');
if ($libraryLabelObj->find(true)) {
$libraryLabel = $libraryLabelObj->displayName;
} else {
$libraryLabel = $locationCode . ' Online';
}
$locationLabelObj = new Location();
$locationLabelObj->whereAdd("'{$locationCode}' LIKE CONCAT(code, '%') and code <> ''");
if ($locationLabelObj->find(true)) {
$locationLabel = $locationLabelObj->displayName;
} else {
$locationLabel = $locationCode . ' Online';
}
//Get the file or url that is related to this item.
//.........这里部分代码省略.........
示例4: getProspectorDetailsForLocalRecord
/**
* Retrieve details about a record within prospector
*
* @param $record - The full record information from Prospector
* @return Associative array with the record number in prospector and the list of libraries that own the title in prospector
*/
function getProspectorDetailsForLocalRecord($record)
{
//Disable prospector details for now.
return false;
global $logger;
//Check to see if one of our libraries has a copy in Prospector.
$shortId = substr($record['id'], 1, -1);
$library = new Library();
$institutions = '';
foreach ($record['institution'] as $institution) {
if (strlen($institutions) > 0) {
$institutions .= ', ';
}
$institutions .= "'" . mysql_escape_string($institution) . "'";
}
$library->whereAdd("facetLabel IN ({$institutions})");
$library->whereAdd("prospectorCode != ''");
$library->find();
$results = array('recordId' => '', 'title' => $record['title'], 'author' => isset($record['author']) ? $record['author'] : null, 'numLibraries' => 0, 'owningLibraries' => array(), 'prospectorClassicUrl' => '', 'prospectorEncoreUrl' => '');
if ($library->N > 0) {
while ($library->fetch()) {
$prospectorCode = $library->prospectorCode;
//Call the url for the record using a local call number search
$curl_url = "http://prospector.coalliance.org/search~S0?/z{$prospectorCode}+{$shortId}/z{$prospectorCode}+{$shortId}/1,1,1,B/detlframeset&FF=z{$prospectorCode}+{$shortId}";
$cookieJar = tempnam("/tmp", "CURLCOOKIE");
$logger->log('Loading page ' . $curl_url, PEAR_LOG_INFO);
$curl_connection = curl_init($curl_url);
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl_connection, CURLOPT_UNRESTRICTED_AUTH, true);
curl_setopt($curl_connection, CURLOPT_COOKIEJAR, $cookieJar);
curl_setopt($curl_connection, CURLOPT_COOKIESESSION, false);
$sresult = curl_exec($curl_connection);
//We are getting bad results from Prospector from some local call number searches
if (preg_match('/Prehistoric Europe, from stone age man to the early Greeks/', $sresult)) {
continue;
}
//Parse the page to extract the owning libraries and the record id
//Record Id can be extracted from the save link
if (preg_match('/save=(.*?)"/s', $sresult, $matches)) {
$results['recordId'] = $matches[1];
}
//Owning libraries can be extracted with this regex
$libraries = array();
if (preg_match_all('/<tr class="holdings(.*?)"><td><a name="(.*?)"><\\/a>(.*?)<\\/td>/s', $sresult, $matches)) {
foreach ($matches[1] as $index => $libraryCode) {
$libraries[$libraryCode] = $matches[3][$index];
}
} else {
$fineInfo = "";
}
$results['numLibraries'] = count($libraries);
$results['owningLibraries'] = $libraries;
$prospectorUrl = "http://prospector.coalliance.org/search~S0/.{$results['recordId']}/.{$results['recordId']}/1,1,1,B/frameset~.{$results['recordId']}";
$results['prospectorClassicUrl'] = $prospectorUrl;
$prospectorUrl = "http://encore.coalliance.org/iii/encore/record/C__R" . urlencode($results['recordId']) . "?lang=eng&suite=def";
$results['prospectorEncoreUrl'] = $prospectorUrl;
$requestUrl = "http://encore.coalliance.org/iii/encore/InnreachRequestPage.external?lang=eng&sp=S" . urlencode($results['recordId']) . "&suite=def";
$results['requestUrl'] = $requestUrl;
break;
}
}
return $results;
}