Skip to content
liseli edited this page Mar 10, 2026 · 2 revisions

Core Components

System Classes (sys/)

1. Interface.php (sys/Interface.php)

  • Purpose: Smarty template engine wrapper
  • Extends: Smarty
  • Key Methods:
    • __construct() - Sets up template directories, registers functions
    • assign() - Assign variables to templates
    • display() - Render template

2. VFSession.php (sys/VFSession.php)

  • Purpose: Session management for VuFind
  • Extends: DSession
  • Singleton Pattern: VFSession::instance()
  • Key Methods:
    • instance() - Get/create session instance
    • (Inherits from DSession: set, get, delete, is_set)

3. DSession.php (sys/DSession.php)

  • Purpose: Database-backed session storage
  • Storage: MySQL sessions table
  • Key Features:
    • UUID-based session IDs
    • HttpOnly secure cookies
    • Automatic session expiration
    • Data serialization
  • Key Methods:
    • singleton() - Get/create session
    • set($var, $val) - Store data
    • is_set($var, $val) - Check existence
    • get($var) - Retrieve data
    • delete($var) - Remove data
    • write() - Persist to database
    • kill() - Destroy session

4. Solr.php (sys/Solr.php)

  • Purpose: Solr search interface
  • Key Methods:
    • __construct($host, $index) - Connect to Solr
    • simplesearch($query) - Execute search
    • standardSearchComponents() - Construct Solr query
    • getRecord($id) - Fetch single record

5. SolrConnection.php (sys/SolrConnection.php)

  • Purpose: HTTP client for Solr
  • Uses: HTTP_Request2 (PEAR)
  • Key Methods:
    • send($url) - Execute HTTP request
    • Response parsing and error handling

6. HTStatus.php (sys/HTStatus.php)

  • Purpose: HathiTrust user access status
  • Data Source: HTstatus cookie (set by Shibboleth SSO)
  • Key Properties:
    • $logged_in - Boolean
    • $institution_code - Institution identifier
    • $auth_type - Authentication method
    • $emergency_access - Emergency access flag
    • $mapped_institution_code - Mapped institution for consortia

7. GeoIP.php (sys/GeoIP.php)

  • Purpose: IP geolocation
  • Database: MaxMind GeoIP2
  • Key Methods:
    • ip_to_iso($ip) - Get country code from IP

8. RecordUtils.php (services/Record/RecordUtils.php)

  • Purpose: Record-specific business logic
  • Key Methods:
    • Access determination
    • Rights interpretation
    • Format detection
    • URL generation

Service Controllers (services/)

Pattern: Action Class

All controllers (service/Record/Record.php and service/Search/Home.php) extend the base Action class. The base Action class is a PEAR-derived stub whose only method is an empty launch(); every service action is expected to override launch (or run its workflow on construction).

services/Record/Record.php keeps the action inside the constructor instead of overriding launch, instantiating a record immediately normalizes the incoming id/mergesearch parameters (including redirects/404s or merged-item shortcuts), records the default tab, and wires $interface with session metadata and the configured search engine before pulling the MARC data.

Once the raw record is retrieved, it is assigned to Smarty, decorated with summary/link data, similar records, subjects, legacy URLs, and the MDL flag so the templated view can render the “record” page without any further controller logic; helpers like getEditions() and getLinkNums() keep per-record enrichment localized.

services/Search/Home.php follows the more conventional action pattern: launch() calls setup() to build the SearchStructure, session, and the Solr connection, then decides whether module/action parameters are present.

  • If so, it sets the page title and invokes search(); otherwise, it renders the static home page.
  • search() acts as the main workflow: it primes Smarty with sort/search/session/facet metadata, enforces pagination limits, calls newprocessSearch() to run the backend query, handles no-results/error cases, enriches each hit with MARC/title/link data, caches the query in a cookie, and finally displays the list template after populating facet counts.
  • The supporting methods newprocessSearch() and getFacetCounts() encapsulate the Solr call and facet aggregation so search() can remain a clean orchestration point.

services/Search/

  • Home.php - Search results page
  • Advanced.php - Advanced search form
  • Reserves.php - Course reserves
  • Suggest.php - Autocomplete suggestions
  • SearchExport.php - RSS feed generation
  • Error.php - Error action

services/Record/

  • Home.php - Record display
  • Export.php - Citation export formats
  • RecordUtils.php - Record utility functions . . .

Clone this wiki locally