当前位置: 首页>>代码示例>>PHP>>正文


PHP PEAR_Singleton类代码示例

本文整理汇总了PHP中PEAR_Singleton的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_Singleton类的具体用法?PHP PEAR_Singleton怎么用?PHP PEAR_Singleton使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PEAR_Singleton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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');
 }
开发者ID:victorfcm,项目名称:VuFind-Plus,代码行数:30,代码来源:Fines.php

示例2: connectToDatabase

 /**
  * Connect to the database.
  *
  * @return void
  * @access public
  */
 public static function connectToDatabase()
 {
     global $configArray;
     if (!defined('DB_DATAOBJECT_NO_OVERLOAD')) {
         define('DB_DATAOBJECT_NO_OVERLOAD', 0);
     }
     $options =& PEAR_Singleton::getStaticProperty('DB_DataObject', 'options');
     // If we're using PostgreSQL, we need to set up some extra configuration
     // settings so that unique ID sequences are properly registered:
     if (substr($configArray['Database']['database'], 0, 5) == 'pgsql') {
         $tables = array('comments', 'oai_resumption', 'resource', 'resource_tags', 'search', 'session', 'tags', 'user', 'user_list', 'user_resource');
         foreach ($tables as $table) {
             $configArray['Database']['sequence_' . $table] = $table . '_id_seq';
         }
     }
     $options = $configArray['Database'];
     if (substr($configArray['Database']['database'], 0, 5) == 'mysql') {
         // If we're using MySQL, we need to make certain adjustments (ANSI
         // quotes, pipes as concatenation operator) for proper compatibility
         // with code built for other database systems like PostgreSQL or Oracle.
         $obj = new DB_DataObject();
         $conn = $obj->getDatabaseConnection();
         $conn->query("SET @@SESSION.sql_mode='ANSI_QUOTES,PIPES_AS_CONCAT'");
     } else {
         if (substr($configArray['Database']['database'], 0, 4) == 'oci8') {
             // If we are using Oracle, set some portability values:
             $temp_db = new DB_DataObject();
             $db =& $temp_db->getDatabaseConnection();
             $db->setOption('portability', DB_PORTABILITY_NUMROWS | DB_PORTABILITY_NULL_TO_EMPTY);
             // Update the date format to fix issues with Oracle being evil
             $db->query("ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'");
         }
     }
 }
开发者ID:bryandease,项目名称:VuFind-Plus,代码行数:40,代码来源:ConnectionManager.php

示例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;
 }
开发者ID:bryandease,项目名称:VuFind-Plus,代码行数:32,代码来源:Enrichment.php

示例4: 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');
 }
开发者ID:bryandease,项目名称:VuFind-Plus,代码行数:33,代码来源:ODLoanPeriod.php

示例5: launch

 function launch()
 {
     global $interface;
     global $configArray;
     // Sanitize the topic name to include only alphanumeric characters
     // or underscores.
     $safe_topic = preg_replace('/[^\\w]/', '', $_GET['topic']);
     // Construct three possible template names -- the help screen in the current
     // selected language, help in the site's default language, and help in English
     // (most likely to exist).  The code will attempt to display most appropriate
     // help screen that actually exists.
     $tpl_user = 'Help/' . $interface->getLanguage() . "/{$safe_topic}.tpl";
     $tpl_site = "Help/{$configArray['Site']['language']}/{$safe_topic}.tpl";
     $tpl_en = 'Help/en/' . $safe_topic . '.tpl';
     // Best case -- help is available in the user's chosen language
     if ($interface->template_exists($tpl_user)) {
         $interface->setTemplate($tpl_user);
         // Compromise -- help is available in the site's default language
     } else {
         if ($interface->template_exists($tpl_site)) {
             $interface->setTemplate($tpl_site);
             $interface->assign('warning', true);
             // Last resort -- help is available in English
         } else {
             if ($interface->template_exists($tpl_en)) {
                 $interface->setTemplate($tpl_en);
                 $interface->assign('warning', true);
                 // Error -- help isn't available at all!
             } else {
                 PEAR_Singleton::raiseError(new PEAR_Error('Unknown Help Page'));
             }
         }
     }
     $interface->display('Help/help.tpl');
 }
开发者ID:victorfcm,项目名称:VuFind-Plus,代码行数:35,代码来源:Home.php

示例6: 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';
     }
 }
开发者ID:victorfcm,项目名称:VuFind-Plus,代码行数:33,代码来源:Home.php

示例7: 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);
 }
开发者ID:bryandease,项目名称:VuFind-Plus,代码行数:28,代码来源:SMS.php

示例8: 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']);
     }
 }
开发者ID:bryandease,项目名称:VuFind-Plus,代码行数:27,代码来源:Email.php

示例9: 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');
 }
开发者ID:victorfcm,项目名称:VuFind-Plus,代码行数:60,代码来源:EContentHolds.php

示例10: 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;
 }
开发者ID:victorfcm,项目名称:VuFind-Plus,代码行数:33,代码来源:ILSAuthentication.php

示例11: launch

 function launch($msg = null)
 {
     global $interface;
     global $configArray;
     global $user;
     if (!($user = UserAccount::isLoggedIn())) {
         require_once 'Login.php';
         Login::launch();
         exit;
     }
     // Save Data
     if (isset($_REQUEST['tagId'])) {
         //Remove the tag for the user.
         $resource = new Resource();
         if (isset($_REQUEST['resourceId'])) {
             $resource = $resource->staticGet('record_id', $_REQUEST['resourceId']);
             $resource->removeTag($_REQUEST['tagId'], $user, false);
             header('Location: ' . $configArray['Site']['path'] . '/Record/' . $_REQUEST['resourceId']);
             exit;
         } else {
             $resource->removeTag($_REQUEST['tagId'], $user, true);
             header('Location: ' . $configArray['Site']['path'] . '/MyResearch/Favorites');
             exit;
         }
     } else {
         //No id provided to delete raise an error?
         PEAR_Singleton::raiseError(new PEAR_Error('Tag Id Missing'));
     }
 }
开发者ID:bryandease,项目名称:VuFind-Plus,代码行数:29,代码来源:RemoveTag.php

示例12: launch

 /**
  * Process parameters and display the page.
  *
  * @return void
  * @access public
  */
 public function launch()
 {
     global $interface;
     // Retrieve the record from the index
     if (!($record = $this->db->getRecord($_GET['id']))) {
         PEAR_Singleton::raiseError(new PEAR_Error('Record Does Not Exist'));
     }
     // Send basic information to the template.
     $interface->setPageTitle(isset($record['heading']) ? $record['heading'] : 'Heading unavailable.');
     $interface->assign('record', $record);
     // Load MARC data
     require_once ROOT_DIR . '/sys/MarcLoader.php';
     $marcRecord = MarcLoader::loadMarcRecordFromRecord($record);
     if (!$marcRecord) {
         PEAR_Singleton::raiseError(new PEAR_Error('Cannot Process MARC Record'));
     }
     $xml = trim($marcRecord->toXML());
     // Transform MARCXML
     $style = new DOMDocument();
     $style->load('services/Record/xsl/record-marc.xsl');
     $xsl = new XSLTProcessor();
     $xsl->importStyleSheet($style);
     $doc = new DOMDocument();
     if ($doc->loadXML($xml)) {
         $html = $xsl->transformToXML($doc);
         $interface->assign('details', $html);
     }
     // Assign the ID of the last search so the user can return to it.
     $interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false);
     // Display Page
     $interface->setTemplate('record.tpl');
     $interface->display('layout.tpl');
 }
开发者ID:bryandease,项目名称:VuFind-Plus,代码行数:39,代码来源:Record.php

示例13: 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;
 }
开发者ID:victorfcm,项目名称:VuFind-Plus,代码行数:36,代码来源:Wikipedia.php

示例14: saveChanges

 private function saveChanges($user)
 {
     global $interface;
     $resource = new Resource();
     $resource->id = $_REQUEST['resourceId'];
     if ($resource->find(true)) {
         $interface->assign('resource', $resource);
     } else {
         PEAR_Singleton::raiseError(new PEAR_Error("Could not find resource {$_REQUEST['resourceId']}"));
     }
     // Loop through the list of lists on the edit screen:
     foreach ($_POST['lists'] as $listId) {
         // Create a list object for the current list:
         $list = new User_list();
         if ($listId != '') {
             $list->id = $listId;
             $list->find(true);
         } else {
             PEAR_Singleton::raiseError(new PEAR_Error('List ID Missing'));
         }
         // Extract tags from the user input:
         preg_match_all('/"[^"]*"|[^ ]+/', $_POST['tags' . $listId], $tagArray);
         // Save extracted tags and notes:
         $user->addResource($resource, $list, $tagArray[0], $_POST['notes' . $listId]);
     }
 }
开发者ID:bryandease,项目名称:VuFind-Plus,代码行数:26,代码来源:Edit.php

示例15: 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');
 }
开发者ID:bryandease,项目名称:VuFind-Plus,代码行数:34,代码来源:Copies.php


注:本文中的PEAR_Singleton类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。