/home
/lareferencia
/vufind
/module
/VuFind
/src
/VuFind
/Cookie
/CookieManager.php
* Get the name of the cookie
*
* @return mixed
*/
public function getSessionName()
{
return $this->sessionName;
}
/**
* Support method for setGlobalCookie -- proxy PHP's setcookie() function
* for compatibility with unit testing.
*
* @return bool
*/
public function proxySetCookie()
{
// Special case: in test suite -- don't actually write headers!
return defined('VUFIND_PHPUNIT_RUNNING')
? true : call_user_func_array('setcookie', func_get_args());
}
/**
* Support method for set() -- set the actual cookie in PHP.
*
* @param string $key Name of cookie to set
* @param mixed $value Value to set
* @param int $expire Cookie expiration time
*
* @return bool
*/
public function setGlobalCookie($key, $value, $expire)
{
// Simple case: flat value.
if (!is_array($value)) {
return $this->proxySetCookie(
$key, $value, $expire, $this->path, $this->domain, $this->secure
);
}
/home
/lareferencia
/vufind
/module
/VuFind
/src
/VuFind
/Cookie
/CookieManager.php
* Get the name of the cookie
*
* @return mixed
*/
public function getSessionName()
{
return $this->sessionName;
}
/**
* Support method for setGlobalCookie -- proxy PHP's setcookie() function
* for compatibility with unit testing.
*
* @return bool
*/
public function proxySetCookie()
{
// Special case: in test suite -- don't actually write headers!
return defined('VUFIND_PHPUNIT_RUNNING')
? true : call_user_func_array('setcookie', func_get_args());
}
/**
* Support method for set() -- set the actual cookie in PHP.
*
* @param string $key Name of cookie to set
* @param mixed $value Value to set
* @param int $expire Cookie expiration time
*
* @return bool
*/
public function setGlobalCookie($key, $value, $expire)
{
// Simple case: flat value.
if (!is_array($value)) {
return $this->proxySetCookie(
$key, $value, $expire, $this->path, $this->domain, $this->secure
);
}
/home
/lareferencia
/vufind
/module
/VuFind
/src
/VuFind
/Cookie
/CookieManager.php
// Special case: in test suite -- don't actually write headers!
return defined('VUFIND_PHPUNIT_RUNNING')
? true : call_user_func_array('setcookie', func_get_args());
}
/**
* Support method for set() -- set the actual cookie in PHP.
*
* @param string $key Name of cookie to set
* @param mixed $value Value to set
* @param int $expire Cookie expiration time
*
* @return bool
*/
public function setGlobalCookie($key, $value, $expire)
{
// Simple case: flat value.
if (!is_array($value)) {
return $this->proxySetCookie(
$key, $value, $expire, $this->path, $this->domain, $this->secure
);
}
// Complex case: array of values.
$success = true;
foreach ($value as $i => $curr) {
$lastSuccess = $this->proxySetCookie(
$key . '[' . $i . ']', $curr, $expire,
$this->path, $this->domain, $this->secure
);
if (!$lastSuccess) {
$success = false;
}
}
return $success;
}
/**
* Set a cookie.
*
/home
/lareferencia
/vufind
/module
/VuFind
/src
/VuFind
/Cookie
/CookieManager.php
);
if (!$lastSuccess) {
$success = false;
}
}
return $success;
}
/**
* Set a cookie.
*
* @param string $key Name of cookie to set
* @param mixed $value Value to set
* @param int $expire Cookie expiration time
*
* @return bool
*/
public function set($key, $value, $expire = 0)
{
if ($success = $this->setGlobalCookie($key, $value, $expire)) {
$this->cookies[$key] = $value;
}
return $success;
}
/**
* Clear a cookie.
*
* @param string $key Name of cookie to unset
*
* @return bool
*/
public function clear($key)
{
$value = $this->get($key);
if (is_array($value)) {
$success = true;
foreach (array_keys($value) as $i) {
if (!$this->clear($key . '[' . $i . ']')) {
$success = false;
/home
/lareferencia
/vufind
/module
/VuFindTheme
/src
/VuFindTheme
/Initializer.php
{
// Load standard configuration options:
$standardTheme = $this->config->theme;
$mobileTheme = $this->mobile->enabled()
? $this->config->mobile_theme : false;
// Find out if the user has a saved preference in the POST, URL or cookies:
$selectedUI = $request->getPost()->get(
'ui', $request->getQuery()->get(
'ui', isset($request->getCookie()->ui)
? $request->getCookie()->ui : null
)
);
if (empty($selectedUI)) {
$selectedUI = ($mobileTheme && $this->mobile->detect())
? 'mobile' : 'standard';
}
// Save the current setting to a cookie so it persists:
$this->cookieManager->set('ui', $selectedUI);
// Do we have a valid mobile selection?
if ($mobileTheme && $selectedUI == 'mobile') {
return $mobileTheme;
}
// Do we have a non-standard selection?
if ($selectedUI != 'standard'
&& isset($this->config->alternate_themes)
) {
// Check the alternate theme settings for a match:
$parts = explode(',', $this->config->alternate_themes);
foreach ($parts as $part) {
$subparts = explode(':', $part);
if ((trim($subparts[0]) == trim($selectedUI))
&& isset($subparts[1]) && !empty($subparts[1])
) {
return $subparts[1];
}
}
/home
/lareferencia
/vufind
/module
/VuFindTheme
/src
/VuFindTheme
/Initializer.php
// Attach our own listener in place of the one we removed:
$injectTemplateListener = new InjectTemplateListener();
$sharedEvents->attach(
'Zend\Stdlib\DispatchableInterface', MvcEvent::EVENT_DISPATCH,
[$injectTemplateListener, 'injectTemplate'], $injectTemplatePriority
);
}
/**
* Initialize the theme. This needs to be triggered as part of the dispatch
* event.
*
* @throws \Exception
* @return void
*/
public function init()
{
// Determine the current theme:
$currentTheme = $this->pickTheme($this->event->getRequest());
// Determine theme options:
$this->sendThemeOptionsToView();
// Make sure the current theme is set correctly in the tools object:
try {
$this->tools->setTheme($currentTheme);
} catch (\Exception $error) {
// If an illegal value is passed in, the setter may throw an exception.
// We should ignore it for now and throw it after we have set up the
// theme (the setter will use a safe value instead of the illegal one).
}
// Using the settings we initialized above, actually configure the themes; we
// need to do this even if there is an error, since we need a theme in order
// to display an error message!
$this->setUpThemes(array_reverse($this->tools->getThemeInfo()));
// If we encountered an error loading theme settings, fail now.
if (isset($error)) {
/home
/lareferencia
/vufind
/module
/VuFind
/src
/VuFind
/Bootstrapper.php
* @return void
*/
protected function initTheme()
{
// Themes not needed in console mode:
if (Console::isConsole()) {
return;
}
// Attach template injection configuration to the route event:
$this->events->attach(
'route', ['VuFindTheme\Initializer', 'configureTemplateInjection']
);
// Attach remaining theme configuration to the dispatch event at high
// priority (TODO: use priority constant once defined by framework):
$config = $this->config->Site;
$callback = function ($event) use ($config) {
$theme = new \VuFindTheme\Initializer($config, $event);
$theme->init();
};
$this->events->attach('dispatch.error', $callback, 9000);
$this->events->attach('dispatch', $callback, 9000);
}
/**
* Set up custom HTTP status based on exception information.
*
* @return void
*/
protected function initExceptionBasedHttpStatuses()
{
// HTTP statuses not needed in console mode:
if (Console::isConsole()) {
return;
}
$callback = function ($e) {
$exception = $e->getParam('exception');
if ($exception instanceof \VuFind\Exception\HttpStatusInterface) {
/home
/lareferencia
/vufind
/vendor
/zendframework
/zend-eventmanager
/src
/EventManager.php
}
if ($this->sharedManager) {
foreach ($this->sharedManager->getListeners($this->identifiers, $name) as $priority => $listeners) {
$listOfListenersByPriority[$priority][] = $listeners;
}
}
// Sort by priority in reverse order
krsort($listOfListenersByPriority);
// Initial value of stop propagation flag should be false
$event->stopPropagation(false);
// Execute listeners
$responses = new ResponseCollection();
foreach ($listOfListenersByPriority as $listOfListeners) {
foreach ($listOfListeners as $listeners) {
foreach ($listeners as $listener) {
$response = $listener($event);
$responses->push($response);
// If the event was asked to stop propagating, do so
if ($event->propagationIsStopped()) {
$responses->setStopped(true);
return $responses;
}
// If the result causes our validation callback to return true,
// stop propagation
if ($callback && $callback($response)) {
$responses->setStopped(true);
return $responses;
}
}
}
}
return $responses;
}
/home
/lareferencia
/vufind
/vendor
/zendframework
/zend-eventmanager
/src
/EventManager.php
$event = clone $this->eventPrototype;
$event->setName($eventName);
if ($target !== null) {
$event->setTarget($target);
}
if ($argv) {
$event->setParams($argv);
}
return $this->triggerListeners($event, $callback);
}
/**
* @inheritDoc
*/
public function triggerEvent(EventInterface $event)
{
return $this->triggerListeners($event);
}
/**
* @inheritDoc
*/
public function triggerEventUntil(callable $callback, EventInterface $event)
{
return $this->triggerListeners($event, $callback);
}
/**
* @inheritDoc
*/
public function attach($eventName, callable $listener, $priority = 1)
{
if (! is_string($eventName)) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects a string for the event; received %s',
__METHOD__,
(is_object($eventName) ? get_class($eventName) : gettype($eventName))
/home
/lareferencia
/vufind
/vendor
/zendframework
/zend-mvc
/src
/DispatchListener.php
$request = $e->getRequest();
$response = $application->getResponse();
$caughtException = null;
try {
$return = $controller->dispatch($request, $response);
} catch (\Throwable $ex) {
$caughtException = $ex;
} catch (\Exception $ex) { // @TODO clean up once PHP 7 requirement is enforced
$caughtException = $ex;
}
if ($caughtException !== null) {
$e->setName(MvcEvent::EVENT_DISPATCH_ERROR);
$e->setError($application::ERROR_EXCEPTION);
$e->setController($controllerName);
$e->setControllerClass(get_class($controller));
$e->setParam('exception', $caughtException);
$return = $application->getEventManager()->triggerEvent($e)->last();
if (! $return) {
$return = $e->getResult();
}
}
return $this->complete($return, $e);
}
/**
* @param MvcEvent $e
*/
public function reportMonitorEvent(MvcEvent $e)
{
$error = $e->getError();
$exception = $e->getParam('exception');
if ($exception instanceof \Exception || $exception instanceof \Throwable) { // @TODO clean up once PHP 7 requirement is enforced
zend_monitor_custom_event_ex($error, $exception->getMessage(), 'Zend Framework Exception', ['code' => $exception->getCode(), 'trace' => $exception->getTraceAsString()]);
}
}
/home
/lareferencia
/vufind
/vendor
/zendframework
/zend-eventmanager
/src
/EventManager.php
}
if ($this->sharedManager) {
foreach ($this->sharedManager->getListeners($this->identifiers, $name) as $priority => $listeners) {
$listOfListenersByPriority[$priority][] = $listeners;
}
}
// Sort by priority in reverse order
krsort($listOfListenersByPriority);
// Initial value of stop propagation flag should be false
$event->stopPropagation(false);
// Execute listeners
$responses = new ResponseCollection();
foreach ($listOfListenersByPriority as $listOfListeners) {
foreach ($listOfListeners as $listeners) {
foreach ($listeners as $listener) {
$response = $listener($event);
$responses->push($response);
// If the event was asked to stop propagating, do so
if ($event->propagationIsStopped()) {
$responses->setStopped(true);
return $responses;
}
// If the result causes our validation callback to return true,
// stop propagation
if ($callback && $callback($response)) {
$responses->setStopped(true);
return $responses;
}
}
}
}
return $responses;
}
/home
/lareferencia
/vufind
/vendor
/zendframework
/zend-eventmanager
/src
/EventManager.php
$event->setParams($argv);
}
return $this->triggerListeners($event, $callback);
}
/**
* @inheritDoc
*/
public function triggerEvent(EventInterface $event)
{
return $this->triggerListeners($event);
}
/**
* @inheritDoc
*/
public function triggerEventUntil(callable $callback, EventInterface $event)
{
return $this->triggerListeners($event, $callback);
}
/**
* @inheritDoc
*/
public function attach($eventName, callable $listener, $priority = 1)
{
if (! is_string($eventName)) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects a string for the event; received %s',
__METHOD__,
(is_object($eventName) ? get_class($eventName) : gettype($eventName))
));
}
$this->events[$eventName][(int) $priority][0][] = $listener;
return $listener;
}
/**
/home
/lareferencia
/vufind
/vendor
/zendframework
/zend-mvc
/src
/Application.php
$response = $result->last();
if ($response instanceof ResponseInterface) {
$event->setName(MvcEvent::EVENT_FINISH);
$event->setTarget($this);
$event->setResponse($response);
$event->stopPropagation(false); // Clear before triggering
$events->triggerEvent($event);
$this->response = $response;
return $this;
}
}
if ($event->getError()) {
return $this->completeRequest($event);
}
// Trigger dispatch event
$event->setName(MvcEvent::EVENT_DISPATCH);
$event->stopPropagation(false); // Clear before triggering
$result = $events->triggerEventUntil($shortCircuit, $event);
// Complete response
$response = $result->last();
if ($response instanceof ResponseInterface) {
$event->setName(MvcEvent::EVENT_FINISH);
$event->setTarget($this);
$event->setResponse($response);
$event->stopPropagation(false); // Clear before triggering
$events->triggerEvent($event);
$this->response = $response;
return $this;
}
$response = $this->response;
$event->setResponse($response);
$this->completeRequest($event);
return $this;
}
/home
/lareferencia
/vufind
/public
/index.php
if (file_exists('vendor/autoload.php')) {
$loader = include 'vendor/autoload.php';
}
// Support for ZF2_PATH environment variable
if ($zf2Path = getenv('ZF2_PATH')) {
if (isset($loader)) {
$loader->add('Zend', $zf2Path . '/Zend');
} else {
include $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
AutoloaderFactory::factory();
}
}
if (!class_exists('Zend\Loader\AutoloaderFactory')) {
throw new RuntimeException('Unable to load ZF2.');
}
// Run the application!
Zend\Mvc\Application::init(require 'config/application.config.php')->run();
// Handle final profiling details, if necessary:
if ($xhprof) {
$xhprofData = extension_loaded('xhprof') ? xhprof_disable() : tideways_disable();
$xhprofRunId = uniqid();
$suffix = 'vufind';
$dir = ini_get('xhprof.output_dir');
if (empty($dir)) {
$dir = sys_get_temp_dir();
}
file_put_contents("$dir/$xhprofRunId.$suffix.xhprof", serialize($xhprofData));
$url = "$xhprof?run=$xhprofRunId&source=$suffix";
echo "<a href='$url'>Profiler output</a>";
}