diff --git a/composer.json b/composer.json index 3b6692f2dad1a47e079cd4900120104aee681d8c..fdb51b6f18335149102da9791c9071be60144ad3 100644 --- a/composer.json +++ b/composer.json @@ -92,7 +92,12 @@ }, "scripts": { "phing-install-dependencies": "phing installsolr installswaggerui", + "phpcs-finc": [ + "vendor/bin/phpcs --standard=tests/finc/phpcs.xml" + ], "post-install-cmd": "@phing-install-dependencies", - "post-update-cmd": "@phing-install-dependencies" + "post-update-cmd": "@phing-install-dependencies", + "pre-install-cmd": "@phpcs-finc", + "pre-update-cmd": "@phpcs-finc" } } diff --git a/module/finc/Module.php b/module/finc/Module.php index bca76dbfc3a16a2d451c0d2d89c7dc3584b39842..9472cd3c7d109f5f4a666a2c4b92e765355370e9 100644 --- a/module/finc/Module.php +++ b/module/finc/Module.php @@ -26,8 +26,9 @@ * @link https://github.com/dmj/vf2-proxy */ namespace finc; -use Zend\ModuleManager\ModuleManager, - Zend\Mvc\MvcEvent; + +use Zend\ModuleManager\ModuleManager; +use Zend\Mvc\MvcEvent; /** * Template for ZF2 module for storing local overrides. diff --git a/module/finc/src/finc/Cache/Manager.php b/module/finc/src/finc/Cache/Manager.php index d35e79b8be1e70a019e55c71d2306a68338e5fb9..394e7f92521f8cef330238513ccdfe11578f53c0 100644 --- a/module/finc/src/finc/Cache/Manager.php +++ b/module/finc/src/finc/Cache/Manager.php @@ -26,6 +26,7 @@ * @link https://vufind.org Main Page */ namespace finc\Cache; + use Zend\Config\Config; /** @@ -60,17 +61,18 @@ class Manager extends \VuFind\Cache\Manager $searchCacheType = isset($searchConfig->Cache->type) ? $searchConfig->Cache->type : false; switch ($searchCacheType) { - case 'APC': - $this->createAPCCache('branches'); - break; - case 'File': - $this->createFileCache( - 'branches', $cacheBase . 'branches' - ); - break; - case false: - $this->createNoCache('branches'); - break; + case 'APC': + $this->createAPCCache('branches'); + break; + case 'File': + $this->createFileCache( + 'branches', + $cacheBase . 'branches' + ); + break; + case false: + $this->createNoCache('branches'); + break; } } } diff --git a/module/finc/src/finc/Config/BranchesReader.php b/module/finc/src/finc/Config/BranchesReader.php index 9413c6a9bdede8f61f5594ff7bee64f276d4c691..c19aab120115a02e74ede6f4cb63714110a4838a 100644 --- a/module/finc/src/finc/Config/BranchesReader.php +++ b/module/finc/src/finc/Config/BranchesReader.php @@ -120,4 +120,3 @@ class BranchesReader extends \VuFind\Config\SearchSpecsReader return $results; } } - diff --git a/module/finc/src/finc/Controller/AjaxController.php b/module/finc/src/finc/Controller/AjaxController.php index 7a9503f8464d553a092d13ecd01eb180a817ee07..7ff1c973f958fdcbd02f0a17ae1c7ac063ec93bc 100644 --- a/module/finc/src/finc/Controller/AjaxController.php +++ b/module/finc/src/finc/Controller/AjaxController.php @@ -26,6 +26,7 @@ * @link https://vufind.org/wiki/development:plugins:controllers Wiki */ namespace finc\Controller; + use VuFind\Exception\Auth as AuthException; use VuFind\View\Helper\Root\SafeMoneyFormat; @@ -185,17 +186,23 @@ class AjaxController extends \VuFind\Controller\AjaxController if (count($record)) { if ($locationSetting == "group") { $current = $this->getItemStatusGroup( - $record, $messages, $callnumberSetting + $record, + $messages, + $callnumberSetting ); } else { $current = $this->getItemStatus( - $record, $messages, $locationSetting, $callnumberSetting + $record, + $messages, + $locationSetting, + $callnumberSetting ); } // If a full status display has been requested, append the HTML: if ($showFullStatus) { $current['full_status'] = $renderer->render( - 'ajax/status-full.phtml', [ + 'ajax/status-full.phtml', + [ 'statusItems' => $record, 'callnumberHandler' => $this->getCallnumberHandler() ] @@ -271,7 +278,7 @@ class AjaxController extends \VuFind\Controller\AjaxController /** * Get Ils Status * - * This will check the ILS for being online and will return the ils-offline + * This will check the ILS for being online and will return the ils-offline * template upon failure. * * @return \Zend\Http\Response @@ -311,8 +318,11 @@ class AjaxController extends \VuFind\Controller\AjaxController * * @return array Summarized availability information */ - protected function getItemStatus($record, $messages, $locationSetting, - $callnumberSetting + protected function getItemStatus( + $record, + $messages, + $locationSetting, + $callnumberSetting ) { // Summarize call number, location and availability info across all items: $callNumbers = $locations = []; @@ -340,17 +350,23 @@ class AjaxController extends \VuFind\Controller\AjaxController } $callnumberHandler = $this->getCallnumberHandler( - $callNumbers, $callnumberSetting + $callNumbers, + $callnumberSetting ); // Determine call number string based on findings: $callNumber = $this->pickValue( - $callNumbers, $callnumberSetting, 'Multiple Call Numbers' + $callNumbers, + $callnumberSetting, + 'Multiple Call Numbers' ); // Determine location string based on findings: $location = $this->pickValue( - $locations, $locationSetting, 'Multiple Locations', 'location_' + $locations, + $locationSetting, + 'Multiple Locations', + 'location_' ); if (!empty($services)) { diff --git a/module/finc/src/finc/Controller/AmslResourceController.php b/module/finc/src/finc/Controller/AmslResourceController.php index 37530c73821083d0038c498a1cbd759c203b0347..b0afc216c7d41368968458554f64b918a0da57f4 100644 --- a/module/finc/src/finc/Controller/AmslResourceController.php +++ b/module/finc/src/finc/Controller/AmslResourceController.php @@ -19,7 +19,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category finc + * @category Finc * @package Controller * @author Dorian Merz <merz@ub.uni-leipzig.de> * @author Ulf Seltmann <seltmann@ub.uni-leipzig.de> @@ -33,7 +33,7 @@ use VuFind\Controller\AbstractBase; /** * Controller for the user account area. * - * @category finc + * @category Finc * @package Controller * @author Dorian Merz <merz@ub.uni-leipzig.de> * @author Ulf Seltmann <seltmann@ub.uni-leipzig.de> @@ -63,8 +63,10 @@ class AmslResourceController extends AbstractBase * Constructor * * @param \Zend\Config\Config $config VuFind configuration - * @param \VuFind\Http $httpClient HttpClient - */ + * @param \VuFindHttp\HttpService $httpClient HttpClient + * + * @access public + */ public function __construct( \Zend\Config\Config $config, \VuFindHttp\HttpService $httpClient @@ -86,33 +88,27 @@ class AmslResourceController extends AbstractBase $api_conf = $this->config->get('API'); $view = $this->createViewModel(); try { - if ( - null == ( - $result - = $this->httpClient->get($api_conf->url) - ) - ) { + if (null == ($result = $this->httpClient->get($api_conf->url))) { throw new \Exception( 'Unexpected value: No api result received' ); } if ($result->isSuccess()) { switch ($api_conf->response_type) { - case 'application/json': - $amsl_sources = json_decode($result->getBody(), true); - break; - default: - throw new \Exception( - 'Invalid argument: No valid header scheme defined' - ); - break; + case 'application/json': + $amsl_sources = json_decode($result->getBody(), true); + break; + default: + throw new \Exception( + 'Invalid argument: No valid header scheme defined' + ); + break; } } if (isset($amsl_sources)) { $view->sources = $this->createSourceHierarchy($amsl_sources); } - } - catch (\Exception $e) { + } catch (\Exception $e) { $this->flashMessenger()->addMessage( 'resources_cannot_received', 'error' @@ -139,7 +135,7 @@ class AmslResourceController extends AbstractBase foreach ($amsl_sources as $source) { if (isset($source[$main_key])) { - if (isset($source[$sub_key])){ + if (isset($source[$sub_key])) { $label = $this->renderLabel($struct->sub_label, $source); $sources[$source[$main_key]][$label] = $source; } else { @@ -147,7 +143,7 @@ class AmslResourceController extends AbstractBase = $source; } } else { - if (isset($source[$sub_key])){ + if (isset($source[$sub_key])) { $label = $this->renderLabel($struct->sub_label, $source); $default[$label] = $source; } else { @@ -161,20 +157,23 @@ class AmslResourceController extends AbstractBase $label = $this->renderLabel($struct->main_label, current($main)); $out[$label] = $main; } - if (isset($default)) $out[$struct->default_main_label] = $default; + if (isset($default)) { + $out[$struct->default_main_label] = $default; + } return $out; } /** * Helper funtion to render label * - * @param $pattern - * @param $input_array + * @param string $pattern Pattern + * @param array $input_array Input * * @return mixed * @access protected */ - protected function renderLabel($pattern, $input_array) { + protected function renderLabel($pattern, $input_array) + { $struct = []; $replace = []; preg_match_all('/\%\%(\w+)\%\%/', $pattern, $struct); diff --git a/module/finc/src/finc/Controller/CustomTraits/AcquisitionTrait.php b/module/finc/src/finc/Controller/CustomTraits/AcquisitionTrait.php index 4f1ee62d247ff3336976792f3c4b4a4c86680775..c4b197df5fd54e185f3ada6e3801343e1180aa54 100644 --- a/module/finc/src/finc/Controller/CustomTraits/AcquisitionTrait.php +++ b/module/finc/src/finc/Controller/CustomTraits/AcquisitionTrait.php @@ -29,11 +29,12 @@ * @link http://vufind.org Main Site */ namespace finc\Controller\CustomTraits; -use VuFind\Exception\Mail as MailException, - finc\Mailer\Mailer, - Zend\Mail\Address, - Zend\Validator\StringLength, - Zend\Validator\Identical; + +use VuFind\Exception\Mail as MailException; +use finc\Mailer\Mailer; +use Zend\Mail\Address; +use Zend\Validator\StringLength; +use Zend\Validator\Identical; /** * Acquisition Trait @@ -114,7 +115,6 @@ trait AcquisitionTrait // Process form submission if ($this->formWasSubmitted('submit', $view->useRecaptcha)) { - // Collect the data submitted by form $params['field_of_study'] = !empty($view->acquisitionFieldOfStudy) ? $view->acquisitionFieldOfStudy : ''; $params['proposal'] = !empty($view->acquisitionProposal) ? $view->acquisitionProposal : ''; @@ -206,11 +206,13 @@ trait AcquisitionTrait // Custom template for emails (html-only) $bodyHtml = $renderer->render( - 'Email/acquisition-html.phtml', $params + 'Email/acquisition-html.phtml', + $params ); // Custom template for emails (text-only) $bodyPlain = $renderer->render( - 'Email/acquisition-text.phtml', $params + 'Email/acquisition-text.phtml', + $params ); // Build the subject diff --git a/module/finc/src/finc/Controller/CustomTraits/EblTrait.php b/module/finc/src/finc/Controller/CustomTraits/EblTrait.php index 88a836eccc99ea9e9d103b70a939f38ca48766d3..12b2241039528029cd3b491eeff3e973492505cf 100644 --- a/module/finc/src/finc/Controller/CustomTraits/EblTrait.php +++ b/module/finc/src/finc/Controller/CustomTraits/EblTrait.php @@ -63,4 +63,4 @@ trait EblTrait $link = $rewrite->resolveLink($link, $user); return $this->redirect()->toUrl($link); } -} \ No newline at end of file +} diff --git a/module/finc/src/finc/Controller/CustomTraits/EmailHoldTrait.php b/module/finc/src/finc/Controller/CustomTraits/EmailHoldTrait.php index 0b9688e919a8ea3cbb63bf0f396dff454d352532..65c6bec4845b9b91b142aabca3f8e3c269d7e636 100644 --- a/module/finc/src/finc/Controller/CustomTraits/EmailHoldTrait.php +++ b/module/finc/src/finc/Controller/CustomTraits/EmailHoldTrait.php @@ -28,9 +28,10 @@ * @link https://vufind.org Main Site */ namespace finc\Controller\CustomTraits; -use VuFind\Exception\Mail as MailException, - finc\Mailer\Mailer as Mailer, - Zend\Mail\Address as Address; + +use VuFind\Exception\Mail as MailException; +use finc\Mailer\Mailer as Mailer; +use Zend\Mail\Address as Address; /** * Email Hold trait (for subclasses of AbstractRecord) @@ -94,7 +95,9 @@ trait EmailHoldTrait // Block invalid requests: if (!$catalog->checkEmailHoldIsValid( - $driver->getUniqueID(), $gatheredDetails, $patron + $driver->getUniqueID(), + $gatheredDetails, + $patron )) { return $this->blockedEmailHoldAction(); } @@ -109,7 +112,7 @@ trait EmailHoldTrait && $item['item_id'] == $gatheredDetails['item_id'] ) { // make the full status information for the current item available in - // the view + // the view $itemStatus = $item; } } @@ -150,18 +153,21 @@ trait EmailHoldTrait // Custom template for emails (html-only) $bodyHtml = $renderer->render( - 'Email/journalhold-html.phtml', $details + 'Email/journalhold-html.phtml', + $details ); // Custom template for emails (text-only) $bodyPlain = $renderer->render( - 'Email/journalhold-plain.phtml', $details + 'Email/journalhold-plain.phtml', + $details ); $subject = "Zeitschrift von " . $details['patron']['lastname'] . ", " . $details['patron']['firstname'] . " | Signatur: " . $details['callnumber']; - $from = $reply = (isset($details['patron']['email']) + $from = $reply = ( + isset($details['patron']['email']) && !empty($details['patron']['email']) ) ? new Address( $details['patron']['email'], @@ -183,7 +189,8 @@ trait EmailHoldTrait ); $this->flashMessenger()->addMessage( - 'EmailHold::email_hold_place_success', 'success' + 'EmailHold::email_hold_place_success', + 'success' ); return $this->redirectToRecord('#top'); } catch (MailException $e) { diff --git a/module/finc/src/finc/Controller/CustomTraits/EmailProfileTrait.php b/module/finc/src/finc/Controller/CustomTraits/EmailProfileTrait.php index 04b981c7ee9de0749116e0e1e9a1c76738ede4fd..06967d8ac6648b532662ac1ccad44c0d229ddfe1 100644 --- a/module/finc/src/finc/Controller/CustomTraits/EmailProfileTrait.php +++ b/module/finc/src/finc/Controller/CustomTraits/EmailProfileTrait.php @@ -48,8 +48,9 @@ trait EmailProfileTrait /** * Returns the email profile configured in MailForms.ini * - * @param $profile - * @return array + * @param string $profile Name of profile + * + * @return array $mailConfig */ protected function getEmailProfile($profile) { diff --git a/module/finc/src/finc/Controller/CustomTraits/PdaTrait.php b/module/finc/src/finc/Controller/CustomTraits/PdaTrait.php index e6369e6246a8fa9800c7f747c4460b979f48068c..258c392e19f5e65e4611989f943a7a215a3fa5f2 100644 --- a/module/finc/src/finc/Controller/CustomTraits/PdaTrait.php +++ b/module/finc/src/finc/Controller/CustomTraits/PdaTrait.php @@ -29,11 +29,12 @@ * @link http://vufind.org Main Site */ namespace finc\Controller\CustomTraits; -use VuFind\Exception\Mail as MailException, - finc\Mailer\Mailer, - Zend\Mail\Address, - Zend\Validator\StringLength, - Zend\Validator\Identical; + +use VuFind\Exception\Mail as MailException; +use finc\Mailer\Mailer; +use Zend\Mail\Address; +use Zend\Validator\StringLength; +use Zend\Validator\Identical; /** * PDA Trait @@ -115,7 +116,6 @@ trait PdaTrait // Process form submission if ($this->formWasSubmitted('submit', $view->useRecaptcha)) { - // Collect the data submitted by form $params['field_of_study'] = !empty($view->pdaFieldOfStudy) ? $view->pdaFieldOfStudy : ''; $params['statement'] = !empty($view->pdaStatement) ? $view->pdaStatement : ''; @@ -217,11 +217,13 @@ trait PdaTrait // Custom template for emails (html-only) $bodyHtml = $renderer->render( - 'Email/acquisitionpda-html.phtml', $params + 'Email/acquisitionpda-html.phtml', + $params ); // Custom template for emails (text-only) $bodyPlain = $renderer->render( - 'Email/acquisitionpda-plain.phtml', $params + 'Email/acquisitionpda-plain.phtml', + $params ); // Build the subject diff --git a/module/finc/src/finc/Controller/CustomTraits/ReportErrorsTrait.php b/module/finc/src/finc/Controller/CustomTraits/ReportErrorsTrait.php index f642c998bd15857966c5b1db14322b3e6d50ecd0..868b79f5a8e73af46cd8ec7631b3d70a1d149689 100644 --- a/module/finc/src/finc/Controller/CustomTraits/ReportErrorsTrait.php +++ b/module/finc/src/finc/Controller/CustomTraits/ReportErrorsTrait.php @@ -27,10 +27,11 @@ * @SuppressWarnings(PHPMD.ExcessivePublicCount) */ namespace finc\Controller\CustomTraits; -use VuFind\Exception\Mail as MailException, - finc\Mailer\Mailer, - Zend\Mail\Address, - Zend\Validator\StringLength; + +use VuFind\Exception\Mail as MailException; +use finc\Mailer\Mailer; +use Zend\Mail\Address; +use Zend\Validator\StringLength; /** * ReportErrors Trait @@ -73,7 +74,6 @@ trait ReportErrorsTrait // Process form submission if ($this->formWasSubmitted('submit', $view->useRecaptcha)) { - // Collect the data submitted by form $params['reply_requested'] = $view->reply_requested; $params['email'] = !empty($view->email) ? $view->email : ''; @@ -161,11 +161,13 @@ trait ReportErrorsTrait // Custom template for emails (html-only) $bodyHtml = $renderer->render( - 'Email/reporterrors-html.phtml', $params + 'Email/reporterrors-html.phtml', + $params ); // Custom template for emails (text-only) $bodyPlain = $renderer->render( - 'Email/reporterrors-plain.phtml', $params + 'Email/reporterrors-plain.phtml', + $params ); // Build the subject @@ -174,8 +176,9 @@ trait ReportErrorsTrait $emailProfile->subject, $params['title_short'], $params['id'], - ($params['reply_requested'] == true - ? $this->translate('reporterrors_response_requested_subject') + ( + $params['reply_requested'] == true + ? $this->translate('reporterrors_response_requested_subject') : '' ) ) : $this->translate('ReportErrors'); diff --git a/module/finc/src/finc/Controller/CustomTraits/ResetPasswordTrait.php b/module/finc/src/finc/Controller/CustomTraits/ResetPasswordTrait.php index 4ead200f814cf09fa687b87aebed50f465c9eddb..d6cec6414d8159487156a6dab6f3f345c9e61707 100644 --- a/module/finc/src/finc/Controller/CustomTraits/ResetPasswordTrait.php +++ b/module/finc/src/finc/Controller/CustomTraits/ResetPasswordTrait.php @@ -29,11 +29,12 @@ * @link http://vufind.org Main Site */ namespace finc\Controller\CustomTraits; -use VuFind\Exception\Mail as MailException, - finc\Mailer\Mailer, - Zend\Mail\Address, - Zend\Validator\Identical, - Zend\Validator\EmailAddress; + +use VuFind\Exception\Mail as MailException; +use finc\Mailer\Mailer; +use Zend\Mail\Address; +use Zend\Validator\Identical; +use Zend\Validator\EmailAddress; /** * ResetPassword Trait @@ -68,7 +69,6 @@ trait ResetPasswordTrait // Process form submission: if ($this->formWasSubmitted('submit', $view->useRecaptcha)) { - $params = [ 'firstname' => !empty($view->firstname) ? $view->firstname : '', 'lastname' => !empty($view->lastname) ? $view->lastname : '', @@ -161,11 +161,13 @@ trait ResetPasswordTrait // Custom template for emails (html-only) $bodyHtml = $renderer->render( - 'Email/resetpassword-html.phtml', $params + 'Email/resetpassword-html.phtml', + $params ); // Custom template for emails (text-only) $bodyPlain = $renderer->render( - 'Email/resetpassword-plain.phtml', $params + 'Email/resetpassword-plain.phtml', + $params ); // Build the subject diff --git a/module/finc/src/finc/Controller/DocumentDeliveryServiceController.php b/module/finc/src/finc/Controller/DocumentDeliveryServiceController.php index ae9df22bc4c5fbf2925641cd263c026e9e72d8ff..bfb3038b6cadd30166589c3e8d4ae8440288d798 100644 --- a/module/finc/src/finc/Controller/DocumentDeliveryServiceController.php +++ b/module/finc/src/finc/Controller/DocumentDeliveryServiceController.php @@ -28,11 +28,11 @@ */ namespace finc\Controller; -use VuFind\Exception\Mail as MailException, - finc\Exception\DDS as DDSException, - finc\Mailer\Mailer as Mailer, - Zend\Mail\Address as Address, - Zend\Validator as Validator; +use VuFind\Exception\Mail as MailException; +use finc\Exception\DDS as DDSException; +use finc\Mailer\Mailer as Mailer; +use Zend\Mail\Address as Address; +use Zend\Validator as Validator; /** * Controller for Document Delivery Service @@ -210,7 +210,7 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase $departmentdetails = $this->getDetailsOfDepartment($content['department'], $content['division']); - $email['from'] = $this->getConfigVar('DDS','from'); + $email['from'] = $this->getConfigVar('DDS', 'from'); $email['subject'] = $this->setSubjectEmail($departmentdetails); $email['to'] = $this->setRecipientEmail($departmentdetails); $email['text'] = $body['text']; @@ -238,9 +238,9 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase $this->sendOrderToApi($content); $this->flashMessenger()->addMessage( - 'DDS::dds_order_success', 'success' + 'DDS::dds_order_success', + 'success' ); - } catch (MailException $e) { $this->flashMessenger()->addMessage($e->getMessage(), 'error'); return $this->createDDSViewModel($content); @@ -267,7 +267,6 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase */ protected function authenticateDDSService($auth_path = '/authorize') { - $method = 'POST'; $auth_data['email'] = isset($this->config['DDS']['username']) ? $this->config['DDS']['username'] : ''; @@ -297,7 +296,7 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase } else { $message = 'HTTP status ' . $response->getStatusCode() . ' received'; } - throw new DDSException ($message); + throw new DDSException($message); } $responseArray = $this->parseJsonAsArray($response->getBody()); @@ -333,7 +332,8 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase // Get department name instead of identifier $details['department'] = ($details['division'] == '15') ? $details['inputdepartment'] : $this->getDepartmentName( - $details['department'], $details['division'] + $details['department'], + $details['division'] ); // Set time $details['time'] = date('d.m.Y H:i'); @@ -343,10 +343,12 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase // Custom template for emails $body['text'] = $renderer->render( - 'Email/dds-text.phtml', $details + 'Email/dds-text.phtml', + $details ); $body['html'] = $renderer->render( - 'Email/dds-html.phtml', $details + 'Email/dds-html.phtml', + $details ); /*$body['customer'] = $renderer->render( 'Email/dds-confirmation-text.phtml', $details @@ -363,7 +365,7 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase * @return mixed Return Subito $url otherwise false. * @throws DDSException Exceptions for no sufficient delivered parameters. */ - private function buildSubitoUrl( $fields ) + private function buildSubitoUrl($fields) { if (count($fields) == 0) { return false; @@ -390,7 +392,7 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase if (!isset($this->config['SubitoService'][$var]) || strlen($this->config['SubitoService'][$var]) == 0 ) { - throw new DDSException ( + throw new DDSException( 'Do not found ' . $var . ' at [SubitoService] DDS.ini.' ); } @@ -400,7 +402,7 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase // Define obligated fields // obligated at least one of ss or jt if (empty($fields['issn']) && empty($fields['journal'])) { - throw new DDSException ( + throw new DDSException( 'At least issn or title of journal is necessary for an order at Subito service.' ); @@ -410,7 +412,7 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase empty($fields['publishdate']) || empty($fields['pages']) ) { - throw new DDSException ( + throw new DDSException( 'Pages, publish date and volume are binding statements., ' ); } @@ -423,7 +425,6 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase } } return $subito_url; - } catch (DDSException $e) { throw new DDSException($e->getCode() . ':' . $e->getMessage()); } @@ -436,8 +437,8 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase * * @return object $view */ - protected function createDDSViewModel($params = null) { - + protected function createDDSViewModel($params = null) + { $view = $this->createViewModel(); // Assign vars to view. foreach ($params as $key => $value) { @@ -473,7 +474,7 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase private function getContent() { if (false === $this->getDepartmentTaxonomy()) { - throw new DDSException ('Cannot load taxonomy of departments and ' . + throw new DDSException('Cannot load taxonomy of departments and ' . 'divisions'); } @@ -495,7 +496,6 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase 'publishdate', 'number', 'pages', 'inputdepartment', 'remarks']; foreach ($structure as $attribute) { - switch ($attribute) { case 'department': $this->content[$attribute] = @@ -574,13 +574,13 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase */ protected function getConfigVar($identifier, $var) { - if (isset($this->config[$identifier][$var])) { return $this->config[$identifier][$var]; } else { throw new DDSException( - 'Variable [' . $identifier . '] ' . $var . 'is ' - . 'not set at DDS.ini.'); + 'Variable [' . $identifier . '] ' . $var + . ' is not set at DDS.ini.' + ); } } @@ -605,7 +605,7 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase ] as $k) { $heap[$k] = $this->content[$k]; } - $this->content = [];; + $this->content = []; return $heap; } @@ -615,7 +615,8 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase * @return mixed If isset hashed token as string otherwise false. * @access protected */ - protected function getDDSToken() { + protected function getDDSToken() + { return (isset($this->session->ddsToken)) ? $this->session->ddsToken : false; } @@ -655,7 +656,6 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase '/user-details/' . $user_id, 'get' ); - } /** @@ -670,7 +670,6 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase */ protected function getDepartmentName($department, $division) { - // if medicine faculty return back department if (isset($division) && $division == '15') { return $department; @@ -693,9 +692,8 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase { $t = $this->httpServiceRequest('/departments', 'get'); foreach ($t as $arr) { - // Build and normalize dataset of division - if (FALSE === array_key_exists($arr['fakultaetid'], $this->division)) { + if (false === array_key_exists($arr['fakultaetid'], $this->division)) { $this->division[$arr['fakultaetid']] = $arr['fakultaet']; } // Build options dataset @@ -784,7 +782,6 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase */ protected function getOpenUrlParameters() { - $retvars = []; $query = $this->getRequest()->getQuery()->toArray(); @@ -912,13 +909,14 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase * @throws DDSException */ protected function httpServiceRequest( - $request_path, $request_type, $data = '' - ) - { + $request_path, + $request_type, + $data = '' + ) { $http_headers = []; if (false === $this->getDDSToken()) { if (true !== $this->authenticateDDSService()) { - throw new DDSException ('Access denied for HTTP request.'); + throw new DDSException('Access denied for HTTP request.'); } } @@ -956,7 +954,9 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase if (true === $this->isDDSTokenExpired($response->getContent())) { $this->authenticateDDSService(); $this->httpServiceRequest( - $request_path, $request_type, $data + $request_path, + $request_type, + $data ); exit; } @@ -972,7 +972,6 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase } return $this->parseJsonAsArray($response->getBody()); - } catch (DDSException $e) { throw new DDSException($e->getCode() . ':' . $e->getMessage()); } @@ -1080,7 +1079,6 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase */ private function setInputDepartmentToDepartment($content) { - if (isset($content['division']) && $content['division'] == 15) { if (isset($content['inputdepartment'])) { $content['department'] = $content['inputdepartment']; @@ -1106,13 +1104,13 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase if (isset($departmentdetails['branchEmail'])) { return $departmentdetails['branchEmail']; } - throw new DDSException ('No email recipient address is set at '. + throw new DDSException('No email recipient address is set at '. ' at database.'); } if (isset($this->config['DDS']['to'])) { return $this->config['DDS']['to']; } - throw new DDSException ('No email recipient address is set at DDS.ini.'); + throw new DDSException('No email recipient address is set at DDS.ini.'); } catch (DDSException $e) { throw new DDSException($e->getMessage()); } @@ -1141,7 +1139,7 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase if (isset($this->config['DDS']['subject'])) { return $this->config['DDS']['subject']; } - throw new DDSException ('No subject for document delivery service is set.'); + throw new DDSException('No subject for document delivery service is set.'); } catch (DDSException $e) { throw new DDSException($e->getMessage()); } @@ -1218,5 +1216,4 @@ class DocumentDeliveryServiceController extends \VuFind\Controller\AbstractBase $this->config['DDS']['use_database'] != '') ? true : false; } - -} \ No newline at end of file +} diff --git a/module/finc/src/finc/Controller/Factory.php b/module/finc/src/finc/Controller/Factory.php index ed37182fe73044c8ed5a3413db9b5a3ae4049720..d245734006dba524d42e36414e542a1d3737a02a 100644 --- a/module/finc/src/finc/Controller/Factory.php +++ b/module/finc/src/finc/Controller/Factory.php @@ -29,8 +29,8 @@ namespace finc\Controller; -use Zend\ServiceManager\ServiceManager, - VuFind\Controller\Factory as FactoryBase; +use Zend\ServiceManager\ServiceManager; +use VuFind\Controller\Factory as FactoryBase; /** * Factory for various top-level VuFind services. @@ -61,11 +61,11 @@ class Factory extends FactoryBase // Prepend the current namespace unless we receive a FQCN: $class = (strpos($name, '\\') === false) ? static::getNamespace() . '\\' . $name : $name; - if (!class_exists($class)) { - throw new \Exception('Cannot construct ' . $class); + if (!class_exists($class)) { + throw new \Exception('Cannot construct ' . $class); } return new $class($sm->getServiceLocator()); - } + } /** * Get namespace of class @@ -76,9 +76,10 @@ class Factory extends FactoryBase private static function getNamespace() { return substr( - static::class, 0, + static::class, + 0, strrpos(static::class, '\\') - ); + ); } @@ -89,8 +90,8 @@ class Factory extends FactoryBase * * @return AmslResourceController */ - public function getAmslResourceController(ServiceManager $sm) - { + public function getAmslResourceController(ServiceManager $sm) + { return new AmslResourceController( $sm->getServiceLocator()->get('VuFind/Config')->get('Amsl'), $sm->getServiceLocator()->get('VuFind/Http') @@ -107,10 +108,10 @@ class Factory extends FactoryBase */ public static function getDocumentDeliveryServiceController( ServiceManager $sm - ) - { + ) { $container = new \Zend\Session\Container( - 'DDS', $sm->getServiceLocator()->get('VuFind\SessionManager') + 'DDS', + $sm->getServiceLocator()->get('VuFind\SessionManager') ); return new DocumentDeliveryServiceController( $sm->getServiceLocator()->get('VuFind\Config')->get('config'), diff --git a/module/finc/src/finc/Controller/MyResearchController.php b/module/finc/src/finc/Controller/MyResearchController.php index 0467320082971aca76626da43af7ecf1d43bc9e9..b65581282cb3fd3f6a46229282f50f884b41f30f 100644 --- a/module/finc/src/finc/Controller/MyResearchController.php +++ b/module/finc/src/finc/Controller/MyResearchController.php @@ -26,6 +26,7 @@ * @link https://vufind.org Main Site */ namespace finc\Controller; + use Zend\Log\LoggerAwareInterface as LoggerAwareInterface; /** diff --git a/module/finc/src/finc/Controller/Plugin/EmailHold.php b/module/finc/src/finc/Controller/Plugin/EmailHold.php index 069220ec3e3239ea7914543304903c040d21d0ba..028310ecd04a128bff608e002715b4486a0299d4 100644 --- a/module/finc/src/finc/Controller/Plugin/EmailHold.php +++ b/module/finc/src/finc/Controller/Plugin/EmailHold.php @@ -38,5 +38,4 @@ namespace finc\Controller\Plugin; */ class EmailHold extends \VuFind\Controller\Plugin\AbstractRequestBase { - } diff --git a/module/finc/src/finc/Controller/Plugin/Factory.php b/module/finc/src/finc/Controller/Plugin/Factory.php index 2312fe4382a385a70b4f34878823e591391aff88..6b0b26c33f11208d5d3e775b1e38bfd4c9caabe2 100644 --- a/module/finc/src/finc/Controller/Plugin/Factory.php +++ b/module/finc/src/finc/Controller/Plugin/Factory.php @@ -22,11 +22,12 @@ * @category VuFind * @package View_Helpers * @author Demian Katz <demian.katz@villanova.edu> - * @author André Lahmann <lahmann@ub.uni-leipzig.de> + * @author André Lahmann <lahmann@ub.uni-leipzig.de> * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link https://vufind.org/wiki/development Wiki */ namespace finc\Controller\Plugin; + use Zend\ServiceManager\ServiceManager; /** @@ -57,4 +58,4 @@ class Factory $sm->getServiceLocator()->get('VuFind\SessionManager') ); } -} \ No newline at end of file +} diff --git a/module/finc/src/finc/Controller/RecordController.php b/module/finc/src/finc/Controller/RecordController.php index 5b68b6d3e88668df35f9c25e33df0d93f341b14c..4163afccad52d1329f3cebfd5859d5af08289519 100644 --- a/module/finc/src/finc/Controller/RecordController.php +++ b/module/finc/src/finc/Controller/RecordController.php @@ -28,6 +28,7 @@ * @link https://vufind.org Main Site */ namespace finc\Controller; + use Zend\Log\LoggerAwareInterface as LoggerAwareInterface; /** diff --git a/module/finc/src/finc/Exception/DDS.php b/module/finc/src/finc/Exception/DDS.php index d69c76f08cac9fc95d30bdb4c8261dc369132a23..44981091b0c7aa901827b2e074526f4eefbc5853 100644 --- a/module/finc/src/finc/Exception/DDS.php +++ b/module/finc/src/finc/Exception/DDS.php @@ -38,4 +38,4 @@ namespace finc\Exception; */ class DDS extends \Exception { -} \ No newline at end of file +} diff --git a/module/finc/src/finc/Export.php b/module/finc/src/finc/Export.php index 0861e80e25fff21b8defb17b4b4b6e35f12ae5e4..5a2a4692c7a392a8ac9ec6a6623f945ef6d34983 100644 --- a/module/finc/src/finc/Export.php +++ b/module/finc/src/finc/Export.php @@ -26,7 +26,9 @@ * @link https://vufind.org Main Site */ namespace finc; -use VuFind\SimpleXML, Zend\Config\Config; + +use VuFind\SimpleXML; +use Zend\Config\Config; /** * Export support class diff --git a/module/finc/src/finc/ILS/Connection.php b/module/finc/src/finc/ILS/Connection.php index dd82548683956aba9f70926158e47c541d6a0b81..4ddbdddb7def752e7bd4613feefb22c14e280a71 100644 --- a/module/finc/src/finc/ILS/Connection.php +++ b/module/finc/src/finc/ILS/Connection.php @@ -32,9 +32,10 @@ * @link https://vufind.org/wiki/development:plugins:ils_drivers Wiki */ namespace finc\ILS; -use VuFind\Exception\ILS as ILSException, - VuFind\ILS\Driver\DriverInterface, - VuFind\I18n\Translator\TranslatorAwareInterface; + +use VuFind\Exception\ILS as ILSException; +use VuFind\ILS\Driver\DriverInterface; +use VuFind\I18n\Translator\TranslatorAwareInterface; /** * Catalog Connection Class diff --git a/module/finc/src/finc/ILS/Driver/Factory.php b/module/finc/src/finc/ILS/Driver/Factory.php index ea2c7a5faa6997accd24c81753c63ed8f11061a3..dea94ff068ebacb808f88eb04086a5011f2d9f36 100644 --- a/module/finc/src/finc/ILS/Driver/Factory.php +++ b/module/finc/src/finc/ILS/Driver/Factory.php @@ -45,7 +45,7 @@ class Factory /** * Factory for FincILS driver. * - * @params ServiceManager $container Service manager. + * @param ContainerInterface $container Service manager. * * @return FincILS */ @@ -80,7 +80,7 @@ class Factory /** * Factory for PAIA driver. * - * @params ServiceManager $container Service manager. + * @param ContainerInterface $container Service manager. * * @return PAIA */ @@ -101,7 +101,7 @@ class Factory /** * Factory for FincTheca driver. * - * @params ServiceManager $container + * @param ContainerInterface $container * * @return FincTheca * @deprecated Remove when Bibliotheca support ends @@ -133,4 +133,4 @@ class Factory return $fl; } -} \ No newline at end of file +} diff --git a/module/finc/src/finc/ILS/Driver/FincILS.php b/module/finc/src/finc/ILS/Driver/FincILS.php index ea7d4a033e631867d58eb542350d9037d032683f..4eee68eebdedbb54116d87e874cb2f64edefac2e 100644 --- a/module/finc/src/finc/ILS/Driver/FincILS.php +++ b/module/finc/src/finc/ILS/Driver/FincILS.php @@ -27,16 +27,18 @@ */ namespace finc\ILS\Driver; +use DateTime; +use DateInterval; +use DateTimeZone; use Herrera\Json\Exception\Exception; -use VuFind\Exception\ILS as ILSException, - VuFindSearch\Query\Query, VuFindSearch\Service as SearchService, - ZfcRbac\Service\AuthorizationServiceAwareInterface, - ZfcRbac\Service\AuthorizationServiceAwareTrait, - Zend\Log\LoggerAwareInterface as LoggerAwareInterface, - DateTime, DateInterval, DateTimeZone, - Sabre\VObject; -use VuFind\Exception\ILS; +use Sabre\VObject; +use VuFind\Exception\ILS as ILSException; +use VuFindSearch\Query\Query; +use VuFindSearch\Service as SearchService; +use Zend\Log\LoggerAwareInterface as LoggerAwareInterface; use Zend\Escaper\Escaper; +use ZfcRbac\Service\AuthorizationServiceAwareInterface; +use ZfcRbac\Service\AuthorizationServiceAwareTrait; /** * Finc specific ILS Driver for VuFind, using PAIA and DAIA services. @@ -76,8 +78,10 @@ class FincILS extends PAIA implements LoggerAwareInterface * identifier retrieved by @_getILSRecordId() * * @var array + * @access private + * @deprecated */ - private $_idMapper = []; + private $idMapper = []; /** * Identifier used for interaction with ILS @@ -153,13 +157,13 @@ class FincILS extends PAIA implements LoggerAwareInterface /** * Constructor * - * @param \VuFind\Date\Converter $converter Date converter - * @param \VuFind\Record\Loader $loader Record loader - * @param \Zend\Config\Config $mainConfig VuFind main configuration + * @param \VuFind\Date\Converter $converter Date converter + * @param \Zend\Session\SessionManager $sessionManager Record loader + * @param \VuFind\Record\Loader $loader VuFind main configuration * (omit for built-in defaults) - * @param SearchService $ss Search Service - * @param mixed $mainConfig - * @param mixed $auth + * @param SearchService $ss Search Service + * @param mixed $mainConfig + * @param mixed $auth */ public function __construct( \VuFind\Date\Converter $converter, @@ -222,10 +226,10 @@ class FincILS extends PAIA implements LoggerAwareInterface // get ilsTestTimeout setting if set otherwise use default of 1 second $this->ilsTestTimeout = isset($this->config['General']) && isset($this->config['General']['ilsTestTimeout']) - ? $this->config['General']['ilsTestTimeout'] : 90; - + ? $this->config['General']['ilsTestTimeout'] : 90; } + /** * This optional method (introduced in VuFind 1.4) gets the online status of the * ILS – “ils-offline†for systems where the main ILS is offline, “ils-none†for @@ -242,7 +246,7 @@ class FincILS extends PAIA implements LoggerAwareInterface return false; } // test again - $this->_testILSConnections(); + $this->testILSConnections(); return false; } catch (\Exception $e) { $this->debug($e->getMessage()); @@ -285,13 +289,15 @@ class FincILS extends PAIA implements LoggerAwareInterface * Helper for checking the given item for the configured Email Hold validation * criteria * - * @param $item + * @param array $item Item + * * @return bool + * @access protected */ protected function checkEmailHoldValidationCriteria($item) { $criteria = $this->getEmailHoldValidationCriteria(); - foreach($criteria as $key => $value) { + foreach ($criteria as $key => $value) { if (isset($item[$key]) && ((is_array($item[$key]) && in_array($value, $item[$key])) || ($value == $item[$key])) @@ -352,9 +358,10 @@ class FincILS extends PAIA implements LoggerAwareInterface return isset($item['location']) ? [[ 'locationID' => - ($item['locationid']!='' - ? $item['locationid'] - : $item['location'] + ( + $item['locationid'] != '' + ? $item['locationid'] + : $item['location'] ), 'locationDisplay' => $item['location'] ]] @@ -380,7 +387,7 @@ class FincILS extends PAIA implements LoggerAwareInterface protected function getAlternativeItemId($id, $idType = null) { $array = explode(":", $id); - return $this->_getFincId(end($array), $idType); + return $this->getFincId(end($array), $idType); } /** @@ -396,16 +403,26 @@ class FincILS extends PAIA implements LoggerAwareInterface */ public function getStatus($id) { - if ($this->_hasILSData($id)) { + if ($this->hasILSData($id)) { return $this->_replaceILSId( - parent::getStatus($this->_getILSRecordId($id)), $id + parent::getStatus($this->_getILSRecordId($id)), + $id ); } else { - return $this->_getStaticStatus($id); + return $this->getStaticStatus($id); } } - protected function doGetStatus($id) { + /** + * ??? + * + * @param string $id Identifier + * + * @return mixed parent::getStatus() + * @access protected + */ + protected function doGetStatus($id) + { return parent::getStatus($id); } @@ -424,17 +441,19 @@ class FincILS extends PAIA implements LoggerAwareInterface $retval = []; foreach ($ids as $num => $id) { - if (!$this->_hasILSData($id)) { - $retval[] = $this->_getStaticStatus($id); + if (!$this->hasILSData($id)) { + $retval[] = $this->getStaticStatus($id); unset($ids[$num]); } } return array_merge( $retval, - $this->_replaceILSIds( - parent::getStatuses($this->_getILSRecordIds($ids)), $ids - )); + $this->replaceILSIds( + parent::getStatuses($this->getILSRecordIds($ids)), + $ids + ) + ); } /** @@ -502,9 +521,9 @@ class FincILS extends PAIA implements LoggerAwareInterface } // custom PAIA fields - // fee.about 0..1 string textual information about the fee - // fee.item 0..1 URI item that caused the fee - // fee.feeid 0..1 URI URI of the type of service that + // fee.about 0..1 string textual information about the fee + // fee.item 0..1 URI item that caused the fee + // fee.feeid 0..1 URI URI of the type of service that // caused the fee $additionalData['feeid'] = (isset($fee['feeid']) ? $fee['feeid'] : null); @@ -537,7 +556,8 @@ class FincILS extends PAIA implements LoggerAwareInterface foreach ($vcard->ADR as $adr) { $address[( (isset($adr->parameters['ALTID'])) - ? (string)$adr->parameters['ALTID'] : 'p' //sets default key 'p' for private address + //sets default key 'p' for private address + ? (string)$adr->parameters['ALTID'] : 'p' )] = $adr->getParts(); } } @@ -545,7 +565,8 @@ class FincILS extends PAIA implements LoggerAwareInterface foreach ($vcard->TEL as $tel) { $phone[( (isset($tel->parameters['TYPE'])) - ? (string)$tel->parameters['TYPE'] : 'home' //sets default key 'home' for private phone number + //sets default key 'home' for private phone number + ? (string)$tel->parameters['TYPE'] : 'home' )] = (string)$tel; } } @@ -566,7 +587,6 @@ class FincILS extends PAIA implements LoggerAwareInterface (string)$vcard->{'X-LIBRARY-ILS-PATRON-EDIT-ALLOW'} ); } - } catch (Exception $e) { throw $e; } @@ -576,7 +596,7 @@ class FincILS extends PAIA implements LoggerAwareInterface $replace = isset($this->config['PAIA']['profileFormEmptyInputReplacement']) ? $this->config['PAIA']['profileFormEmptyInputReplacement'] - : NULL; + : null; if (isset($address)) { foreach ($address as $key => $altid) { @@ -597,7 +617,9 @@ class FincILS extends PAIA implements LoggerAwareInterface if (isset($phone)) { // fill phone types to profile foreach ($phone as $parameter => $val) { - if ($val == $replace) $val = ''; + if ($val == $replace) { + $val = ''; + } $var = 'phone-' . $parameter; $profile[$var] = $val; // keep backward compatibility to old forms @@ -627,7 +649,6 @@ class FincILS extends PAIA implements LoggerAwareInterface 'home_library' => (!empty($home_library)) ? $home_library : null ]; return (isset($profile)) ? array_merge($idm, $profile) : $idm; - } return []; } @@ -642,13 +663,11 @@ class FincILS extends PAIA implements LoggerAwareInterface */ private function getEditableProfileFields($vcard_fields) { - $address_fields = ['address1', 'address2', 'city', 'country', 'zip']; $vcard_fields = explode(',', $vcard_fields); $fields = []; foreach ($vcard_fields as $fld) { - $match = []; if (0 < preg_match('/(TEL|ADR)-(\w+)/', $fld, $match)) { if ($match[1] == "ADR") { @@ -694,11 +713,10 @@ class FincILS extends PAIA implements LoggerAwareInterface */ public function setMyProfile($inval, $patron) { - $params['memberCode'] = $patron['cat_username']; $params['password'] = $patron['cat_password']; - if (isset($patron['address']) && strpos($patron['address'],'BEGIN:VCARD') === 0) { + if (isset($patron['address']) && strpos($patron['address'], 'BEGIN:VCARD') === 0) { $vcard = \Sabre\VObject\Reader::read($patron['address']); } else { $vcard = new VObject\Component\VCard(); @@ -706,17 +724,17 @@ class FincILS extends PAIA implements LoggerAwareInterface //handle name $params['name'] = ''; - $name_array = array_fill(0,2,null); - $noname = TRUE; + $name_array = array_fill(0, 2, null); + $noname = true; if (isset($inval['firstname'])) { $params['name'] .= $inval['firstname']; $name_array[1] = $inval['firstname']; - $noname = FALSE; + $noname = false; } if (isset($inval['lastname'])) { - $params['name'] .= ' '.$inval['lastname']; + $params['name'] .= ' ' . $inval['lastname']; $name_array[0] = $inval['lastname']; - $noname = FALSE; + $noname = false; } if (!$noname) { $this->setVCardValue($vcard, 'FN', $params['name']); @@ -726,7 +744,7 @@ class FincILS extends PAIA implements LoggerAwareInterface //handle e-mail if (isset($inval['email'])) { $params['email'] = $inval['email']; - $this->setVCardValue($vcard,'EMAIL',$inval['email']); + $this->setVCardValue($vcard, 'EMAIL', $inval['email']); } $addressParameterMap = self::$vcard_address_parameter_map; @@ -738,17 +756,21 @@ class FincILS extends PAIA implements LoggerAwareInterface //the empty-field marker in the used ILS $replace = isset($this->config['PAIA']['profileFormEmptyInputReplacement']) - ? $this->config['PAIA']['profileFormEmptyInputReplacement'] : NULL; + ? $this->config['PAIA']['profileFormEmptyInputReplacement'] : null; foreach ($inval as $key => $val) { - - if (empty($val) && !is_null($replace)) $val = $replace; + if (empty($val) && !is_null($replace)) { + $val = $replace; + } $match = []; // add phone inputs to vcard if (0 < preg_match('/phone-(\w+)/', $key, $match)) { $this->setVCardValue( - $vcard, 'TEL', $val, ['type' => $match[1]] + $vcard, + 'TEL', + $val, + ['type' => $match[1]] ); } @@ -756,7 +778,10 @@ class FincILS extends PAIA implements LoggerAwareInterface // push default phone input to vcard TYPE home if ($key == 'phone') { $this->setVCardValue( - $vcard, 'TEL', $inval['phone'], ['type' => 'home'] + $vcard, + 'TEL', + $inval['phone'], + ['type' => 'home'] ); } @@ -811,7 +836,10 @@ class FincILS extends PAIA implements LoggerAwareInterface } ksort($address); $this->setVCardValue( - $vcard, 'ADR', $address, ['ALTID' => strtoupper($type)] + $vcard, + 'ADR', + $address, + ['ALTID' => strtoupper($type)] ); } @@ -822,11 +850,13 @@ class FincILS extends PAIA implements LoggerAwareInterface $params['address'] = $address; } - $result = $this->paiaUpdatePatron($params,$patron); - if ($result['success']) return TRUE; + $result = $this->paiaUpdatePatron($params, $patron); + if ($result['success']) { + return true; + } $this->debug(__FUNCTION__.' '.$result['sysMessage']); - return FALSE; + return false; } /** @@ -837,8 +867,8 @@ class FincILS extends PAIA implements LoggerAwareInterface * @return mixed * @access private */ - private function splitAddress($address) { - + private function splitAddress($address) + { //the inval address might consist of street address and extended address //pattern "<street_address> <extended_address>" with a space in between //@see $this->getMyProfile() on that @@ -851,10 +881,10 @@ class FincILS extends PAIA implements LoggerAwareInterface $conf = $this->config; $regex = '(\D+\d[^\,]*)(?:\,\s*(.*))?'; $matches = []; - if (preg_match('/'.$regex.'/',$address, $matches)) { + if (preg_match('/'.$regex.'/', $address, $matches)) { return $matches; } - return FALSE; + return false; } /** @@ -863,11 +893,15 @@ class FincILS extends PAIA implements LoggerAwareInterface * @param string $key * @param string $value * @param array $type Subtype of vcard field as e.g. cell for phone + * + * @return void */ private function setVCardValue( - VObject\Component\VCard $vcard, $key, $value, $type = null - ) - { + VObject\Component\VCard $vcard, + $key, + $value, + $type = null + ) { if (is_string($value)) { $value = str_replace(',', '', $value); } elseif (is_array($value)) { @@ -877,7 +911,6 @@ class FincILS extends PAIA implements LoggerAwareInterface } $children = $vcard->select($key); if (empty($children)) { - // if the key is unknown, we add a new property with the value if (in_array($key, ['TEL', 'ADR'])) { $vcard->createComponent($key); @@ -898,8 +931,8 @@ class FincILS extends PAIA implements LoggerAwareInterface } } } - // refs #10912 - // if key exists in first dimension VCARD object return update true + // refs #10912 + // if key exists in first dimension VCARD object return update true } elseif (isset($key)) { foreach ($children as $child) { if ($key == $child->name) { @@ -952,7 +985,7 @@ class FincILS extends PAIA implements LoggerAwareInterface } try { - if($this->paiaLogin($this->root_username, $this->root_password)) { + if ($this->paiaLogin($this->root_username, $this->root_password)) { return $this->enrichUserDetails( $this->paiaGetUserDetails(($session->patron === 'root' ? $username : $session->patron)), $password, @@ -1052,7 +1085,7 @@ class FincILS extends PAIA implements LoggerAwareInterface $filterCounter = 0; foreach ($filter as $filterKey => $filterValue) { switch ($filterKey) { - case 'exclude' : + case 'exclude': // check exclude filters $excludeCounter = 0; foreach ($filterValue as $excludeKey => $excludeValue) { @@ -1068,7 +1101,7 @@ class FincILS extends PAIA implements LoggerAwareInterface $filterCounter++; } break; - case 'regex' : + case 'regex': // check regex filters $regexCounter = 0; foreach ($filterValue as $regexField => $regexPattern) { @@ -1156,7 +1189,7 @@ class FincILS extends PAIA implements LoggerAwareInterface foreach ($identifier as $key => $value) { $matches = []; if (preg_match(sprintf($idPattern, $key), $itemId, $matches)) { - return $this->_getFincId($matches[3], $value); + return $this->getFincId($matches[3], $value); } } }; @@ -1171,7 +1204,6 @@ class FincILS extends PAIA implements LoggerAwareInterface } } } - return $items; } @@ -1193,7 +1225,7 @@ class FincILS extends PAIA implements LoggerAwareInterface * descendingly (defaults to SORT_ASC). * @return array */ - protected function itemFieldSort ($items, $fieldName, $sortOrder = SORT_ASC) + protected function itemFieldSort($items, $fieldName, $sortOrder = SORT_ASC) { // array with items to be sorted $sortArray = []; @@ -1244,9 +1276,10 @@ class FincILS extends PAIA implements LoggerAwareInterface * returned * @param array $patron Patron details returned by patronLogin * -*@return array Array in the format [function => count] + * @return array Array in the format [function => count] */ - public function countItems($functions, $patron) { + public function countItems($functions, $patron) + { $retval = []; if (is_array($functions)) { foreach ($functions as $function) { @@ -1265,7 +1298,8 @@ class FincILS extends PAIA implements LoggerAwareInterface * * @return float */ - public function getFinesTotal($patron) { + public function getFinesTotal($patron) + { $fines = $this->getMyFines($patron); $total = 0.0; foreach ($fines as $fee) { @@ -1287,9 +1321,15 @@ class FincILS extends PAIA implements LoggerAwareInterface * * @return string */ - protected function addTime($date, $years = null, $months = null, $days = null, - $hours = null, $minutes = null, $seconds = null) - { + protected function addTime( + $date, + $years = null, + $months = null, + $days = null, + $hours = null, + $minutes = null, + $seconds = null + ) { try { // Get time zone $timezone = isset($this->mainConfig->Site->timezone) @@ -1321,10 +1361,11 @@ class FincILS extends PAIA implements LoggerAwareInterface * * @return array */ - private function _getStaticStatus($id) + private function getStaticStatus($id) { if (!$this->auth) { - $this->debug('Authorization service missing for checking availability ' . + $this->debug( + 'Authorization service missing for checking availability ' . 'of record ' . $id ); return ''; @@ -1337,7 +1378,7 @@ class FincILS extends PAIA implements LoggerAwareInterface ); $context = array( 'authenticator' => $this->auth, - 'record' => $this->_getRecord($id), + 'record' => $this->getRecord($id), ); $context = $eval($context); return [[ @@ -1350,7 +1391,7 @@ class FincILS extends PAIA implements LoggerAwareInterface 'services' => (array)$context['decider'] ]]; } - $permission = $this->_getRecord($id)->tryMethod('getRecordPermission'); + $permission = $this->getRecord($id)->tryMethod('getRecordPermission'); $isGranted = $permission != null ? $this->auth->isGranted($permission) : true; @@ -1374,14 +1415,14 @@ class FincILS extends PAIA implements LoggerAwareInterface * * @return bool */ - private function _hasILSData($id) + private function hasILSData($id) { $retVal = []; foreach ($this->config['General']['queryIls'] as $value) { list($methodName, $methodReturn) = explode(':', $value); // if we have one mismatch we can already stop as this record does // not qualify for querying the ILS - if (!in_array($methodReturn, (array) $this->_getRecord($id)->tryMethod($methodName))) { + if (!in_array($methodReturn, (array) $this->getRecord($id)->tryMethod($methodName))) { return false; } } @@ -1396,7 +1437,7 @@ class FincILS extends PAIA implements LoggerAwareInterface * * @return \VuFind\RecordDriver\AbstractBase */ - protected function _getRecord($id) + protected function getRecord($id) { return $this->recordLoader->load($id); } @@ -1411,7 +1452,7 @@ class FincILS extends PAIA implements LoggerAwareInterface * * @return mixed */ - private function _replaceILSId($array, $id) + private function replaceILSId($array, $id) { $statuses = []; foreach ($array as $status) { @@ -1442,14 +1483,14 @@ class FincILS extends PAIA implements LoggerAwareInterface * * @return array */ - private function _replaceILSIds($array, $ids) + private function replaceILSIds($array, $ids) { $results = []; foreach ($array as $statuses) { foreach ($ids as $id) { - if ($this->_containsILSid($statuses, $id)) { - // save the result if _replaceILSId had some effect - $results[] = $this->_replaceILSId($statuses, $id); + if ($this->containsILSId($statuses, $id)) { + // save the result if replaceILSId had some effect + $results[] = $this->replaceILSId($statuses, $id); } } } @@ -1466,7 +1507,7 @@ class FincILS extends PAIA implements LoggerAwareInterface * * @return bool */ - private function _containsILSid($array, $id) + private function containsILSId($array, $id) { foreach ($array as $status) { if ($status['item_id'] == $this->_idMapper[$id] @@ -1487,7 +1528,7 @@ class FincILS extends PAIA implements LoggerAwareInterface * * @return string $ilsRecordId */ - protected function _getILSRecordId($id, $ilsIdentifier = null) + protected function getILSRecordId($id, $ilsIdentifier = null) { // override ilsIdentifier with the ilsIdentifier set in ILS driver config if ($ilsIdentifier == null) { @@ -1496,9 +1537,8 @@ class FincILS extends PAIA implements LoggerAwareInterface //get the ILS-specific recordId if ($ilsIdentifier != "default") { - try { - $ilsRecordId = $this->_getRecord($id) + $ilsRecordId = $this->getRecord($id) ->getILSIdentifier($ilsIdentifier); } catch (\Exception $e) { $this->debug($e); @@ -1516,9 +1556,10 @@ class FincILS extends PAIA implements LoggerAwareInterface $isils = implode("|", $this->isil); foreach ($ilsRecordId as $recordId) { if (preg_match( - "/^\((" . $isils . ")\)(.*)$/", $recordId, $match - ) - ) { + "/^\((" . $isils . ")\)(.*)$/", + $recordId, + $match + )) { $recordId = (isset($match[2]) && strlen($match[2] > 0)) ? $match[2] : null; $this->_idMapper[$id] = $recordId; @@ -1546,7 +1587,7 @@ class FincILS extends PAIA implements LoggerAwareInterface * * @return array $ilsRecordIds */ - private function _getILSRecordIds($ids, $ilsIdentifier = null) + private function getILSRecordIds($ids, $ilsIdentifier = null) { $ilsRecordIds = []; @@ -1557,7 +1598,7 @@ class FincILS extends PAIA implements LoggerAwareInterface if (is_array($ids)) { foreach ($ids as $id) { - $ilsRecordIds[] = $this->_getILSRecordId($id, $ilsIdentifier); + $ilsRecordIds[] = $this->getILSRecordId($id, $ilsIdentifier); } return $ilsRecordIds; @@ -1574,7 +1615,7 @@ class FincILS extends PAIA implements LoggerAwareInterface * * @return string $fincId if ilsIdentifier is configured, otherwise $ilsId */ - private function _getFincId($ilsId, $ilsIdentifier = null) + private function getFincId($ilsId, $ilsIdentifier = null) { // override ilsIdentifier with the ilsIdentifier set in ILS driver config if ($ilsIdentifier == null) { @@ -1625,7 +1666,7 @@ class FincILS extends PAIA implements LoggerAwareInterface * @return void * @throws ILSException */ - private function _testILSConnections() + private function testILSConnections() { try { // test DAIA service diff --git a/module/finc/src/finc/ILS/Driver/FincTheca.php b/module/finc/src/finc/ILS/Driver/FincTheca.php index 9ffc16537cfa25f22d6e0d45ae74c279d33b5ccf..3fe62b8c2b59aa7c3eeac98e21752489a4b8cdcc 100644 --- a/module/finc/src/finc/ILS/Driver/FincTheca.php +++ b/module/finc/src/finc/ILS/Driver/FincTheca.php @@ -1,17 +1,53 @@ <?php - +/** + * Finc Theca ILS driver + * + * PHP version 7 + * + * Copyright (C) Leipzig University Library 2018. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * @category Finc + * @package FincILSDriver + * @author Dorian Merz <merz@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org Main Site + */ namespace finc\ILS\Driver; /** - * Class FincTheca + * Finc Theca ILS driver + * + * @category Finc + * @package FincILSDriver + * @author Dorian Merz <merz@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org Main Site * @deprecated Remove when Bibliotheca support ends - * @package finc\ILS\Driver */ -class FincTheca extends FincILS { - +class FincTheca extends FincILS +{ private $identifier_type = 'ppn'; private $daiaIdPrefixBase; + /** + * Init + * + * @return void + * @access public + */ public function init() { parent::init(); @@ -20,14 +56,23 @@ class FincTheca extends FincILS { } } + /** + * Get status + * + * @param string $id + * + * @return array|mixed + * @access public + */ public function getStatus($id) { $result = []; + try { $result = parent::getStatus($id); } catch (\Exception $e) { - } + if (empty($result)) { $result = $this->getStatusViaMediennummer($id); } @@ -35,15 +80,18 @@ class FincTheca extends FincILS { } /** - * @param $record_id String Finc-ID of record, used to retrieve Mediennummer + * @param string $record_id Finc-ID of record, used to retrieve Mediennummer + * * @return array|mixed + * @access protected */ - protected function getStatusViaMediennummer($record_id) { + protected function getStatusViaMediennummer($record_id) + { $result = []; if ($ilsRecordId = $this->_getRecord($record_id)->tryMethod('getMediennummer')) { $this->identifier_type = 'mediennr'; $result = parent::doGetStatus($ilsRecordId); - foreach($result as &$item) { + foreach ($result as &$item) { //fix-up IDs $item['id'] = $record_id; } @@ -51,6 +99,14 @@ class FincTheca extends FincILS { return $result; } + /** + * Get statuses + * + * @param array $ids + * + * @return array + * @access public + */ public function getStatuses($ids) { $results = parent::getStatuses($ids); @@ -59,7 +115,9 @@ class FincTheca extends FincILS { $missing = array_flip($ids); foreach ($results as $items) { $item = current($items); - if (isset($missing[$item['id']])) unset($missing[$item['id']]); + if (isset($missing[$item['id']])) { + unset($missing[$item['id']]); + } } foreach (array_keys($missing) as $missing_id) { $results[] = $this->getStatusViaMediennummer($missing_id); @@ -68,6 +126,14 @@ class FincTheca extends FincILS { return $results; } + /** + * Generate uri + * + * @param string $id + * + * @return string + * @access protected + */ protected function generateURI($id) { if (isset($this->daiaIdPrefixBase)) { @@ -79,13 +145,24 @@ class FincTheca extends FincILS { return parent::generateMultiURIs($id); } + /** + * Get item barcode + * + * @param array $item + * + * @return null + * @access protected + */ protected function getItemBarcode($item) { $matches = []; - if (preg_match('/^'.$this->daiaIdPrefixBase.':'.$this->identifier_type.':\w+:(\w+)$/',$item['id'],$matches)) { + if (preg_match( + '/^' . $this->daiaIdPrefixBase . ':' . $this->identifier_type . ':\w+:(\w+)$/', + $item['id'], + $matches + )) { return $matches[1]; } return null; } - -} \ No newline at end of file +} diff --git a/module/finc/src/finc/ILS/Driver/LiberoDingTrait.php b/module/finc/src/finc/ILS/Driver/LiberoDingTrait.php index 82e1e38a8fd9d74d869b2495fe721a03ca0d8526..3e640872c0aaa139047b73ad5edf646a69935196 100644 --- a/module/finc/src/finc/ILS/Driver/LiberoDingTrait.php +++ b/module/finc/src/finc/ILS/Driver/LiberoDingTrait.php @@ -27,8 +27,9 @@ * @link https://vufind.org/wiki/development:plugins:ils_drivers Wiki */ namespace finc\ILS\Driver; -use VuFind\Exception\ILS as ILSException, - Zend\Log\LoggerAwareInterface as LoggerAwareInterface; + +use VuFind\Exception\ILS as ILSException; +use Zend\Log\LoggerAwareInterface as LoggerAwareInterface; /** * Finc specific LiberoDing trait providing all the functions necessary for @@ -50,7 +51,7 @@ trait LiberoDingTrait * @return int Connection timeout * @access protected */ - protected function getConnectTimeout ($connectTimeout = 500) + protected function getConnectTimeout($connectTimeout = 500) { return $test = (isset($this->config['LiberoDing']['connectTimeout']) && is_numeric($this->config['LiberoDing']['connectTimeout'])) @@ -194,7 +195,8 @@ trait LiberoDingTrait /** * Get Libero system messages for a given patron * - * @param $patron + * @param array $patron Patron + * * @return bool * @throws \Exception * @throws ILSException @@ -320,10 +322,10 @@ trait LiberoDingTrait try { $result = $this->httpService->get( - $this->getWebScraperUrl() .'setMyProfile.jsp', - $params, - null, - $this->_getLiberoDingRequestHeaders() + $this->getWebScraperUrl() .'setMyProfile.jsp', + $params, + null, + $this->_getLiberoDingRequestHeaders() ); } catch (\Exception $e) { throw new ILSException($e->getMessage()); @@ -332,8 +334,8 @@ trait LiberoDingTrait if (!$result->isSuccess()) { // log error for debugging $this->debug( - 'HTTP status ' . $result->getStatusCode() . - ' received' + 'HTTP status ' . $result->getStatusCode() . + ' received' ); return false; } @@ -411,12 +413,12 @@ trait LiberoDingTrait if ($key == 'disabledInputs') { // map it foreach ($data['disabledInputs'] as $fields) { - if (isset($map[$fields])){ + if (isset($map[$fields])) { $mappeddata['disabled'][$map[$fields]] = true; } } } else { - if (isset($map[$key])){ + if (isset($map[$key])) { $mappeddata[($map[$key])] = $value; } } @@ -431,11 +433,13 @@ trait LiberoDingTrait /** * This method sends a PIN changing request to the LiberoDing. * + * @param string $newPin New pin. * @param array $patron Patron array returned by patronLogin method. * * @return array An associative array + * @throws \Exception */ - public function changeUserPin($newPin,$patron) + public function changeUserPin($newPin, $patron) { $params = $this->_getLiberoDingRequestParams(); $params['memberCode'] = $patron['cat_username']; @@ -474,7 +478,7 @@ trait LiberoDingTrait * @return array Return array of mappings. * @access private */ - private static function _profileDataMapper( $reverse = false ) + private static function _profileDataMapper($reverse = false) { $array = [ "GNAM" => 'firstname', @@ -555,8 +559,10 @@ trait LiberoDingTrait * Check the given result for key errorcode and return the requested resultKey * value * - * @param $result array + * @param array $result Result + * * @return array + * @access private */ private function _getLiberoDingResultBool($result) { @@ -566,7 +572,6 @@ trait LiberoDingTrait if (!is_array($details) || !isset($details["errorcode"]) || $details["errorcode"] != 0) { return false; } - return true; } -} \ No newline at end of file +} diff --git a/module/finc/src/finc/ILS/Driver/PAIA.php b/module/finc/src/finc/ILS/Driver/PAIA.php index 9d8e373f800a3ecdacf2e82df79ce969e5cd7ebb..638dcfbda3762deaeeca59f4da238d6927695909 100644 --- a/module/finc/src/finc/ILS/Driver/PAIA.php +++ b/module/finc/src/finc/ILS/Driver/PAIA.php @@ -73,7 +73,8 @@ class PAIA extends \VuFind\ILS\Driver\PAIA * @param \VuFind\Date\Converter $converter Date converter * @param \Zend\Session\SessionManager $sessionManager Session Manager */ - public function __construct(\VuFind\Date\Converter $converter, + public function __construct( + \VuFind\Date\Converter $converter, \Zend\Session\SessionManager $sessionManager ) { parent::__construct($converter, $sessionManager); @@ -121,7 +122,8 @@ class PAIA extends \VuFind\ILS\Driver\PAIA try { $array_response = $this->paiaPostAsArray( - 'core/'.$patron['cat_username'].'/cancel', $post_data + 'core/'.$patron['cat_username'].'/cancel', + $post_data ); } catch (\Exception $e) { $this->debug($e->getMessage()); @@ -204,7 +206,8 @@ class PAIA extends \VuFind\ILS\Driver\PAIA try { $array_response = $this->paiaPostAsArray( - 'auth/change', $post_data + 'auth/change', + $post_data ); } catch (AuthException $e) { return [ @@ -295,18 +298,18 @@ class PAIA extends \VuFind\ILS\Driver\PAIA // see #11128-45, DM if ($amount = $feeConverter($fee['amount'])) { $result = [ - // fee.amount 1..1 money amount of a single fee + // fee.amount 1..1 money amount of a single fee 'amount' => $amount, 'checkout' => '', - // fee.feetype 0..1 string textual description of the type + // fee.feetype 0..1 string textual description of the type // of service that caused the fee 'fine' => (isset($fee['feetype']) ? $fee['feetype'] : null), 'balance' => $amount, - // fee.date 0..1 date date when the fee was claimed + // fee.date 0..1 date date when the fee was claimed 'createdate' => (isset($fee['date']) ? $this->convertDate($fee['date']) : null), 'duedate' => '', - // fee.edition 0..1 URI edition that caused the fee + // fee.edition 0..1 URI edition that caused the fee 'id' => (isset($fee['edition']) ? $this->getAlternativeItemId($fee['edition']) : ''), ]; @@ -403,6 +406,7 @@ class PAIA extends \VuFind\ILS\Driver\PAIA * * @param array $array Array containing error messages * + * @return void * @throws AuthException * @throws ILSException */ @@ -415,43 +419,50 @@ class PAIA extends \VuFind\ILS\Driver\PAIA $this->last_error = $array; switch ($array['error']) { // cf. http://gbv.github.io/paia/paia.html#request-errors - // error code error_description - // access_denied 403 Wrong or missing credentials to get an access token + // error code error_description + // access_denied 403 Wrong or missing credentials to get an access token case 'access_denied': throw new AuthException( isset($array['error_description']) ? $array['error_description'] : $array['error'], isset($array['code']) ? $array['code'] : '' ); - // not_found 404 Unknown request URL or unknown patron. Implementations SHOULD first check authentication and prefer error invalid_grant or access_denied to prevent leaking patron identifiers. + // not_found 404 + // Unknown request URL or unknown patron. Implementations SHOULD + // first check authentication and prefer error invalid_grant or + // access_denied to prevent leaking patron identifiers. case 'not_found': - - // not_implemented 501 Known but unsupported request URL (for instance a PAIA auth server server may not implement http://example.org/core/change) + // not_implemented 501 + // Known but unsupported request URL (for instance a PAIA auth + // server server may not implement http://example.org/core/change) case 'not_implemented': - - // invalid_request 405 Unexpected HTTP verb - // invalid_request 400 Malformed request (for instance error parsing JSON, unsupported request content type, etc.) - // invalid_request 422 The request parameters could be parsed but they don’t match the request method (for instance missing fields, invalid values, etc.) + // invalid_request 405 Unexpected HTTP verb + // invalid_request 400 Malformed request (for instance error parsing + // JSON, unsupported request content type, etc.) + // invalid_request 422 The request parameters could be parsed but + // they don’t match the request method (for instance missing fields, + // invalid values, etc.) case 'invalid_request': - - // invalid_grant 401 The access token was missing, invalid, or expired + // invalid_grant 401 + // The access token was missing, invalid, or expired case 'invalid_grant': - - // insufficient_scope 403 The access token was accepted but it lacks permission for the request + // insufficient_scope 403 + // The access token was accepted but it lacks permission for the request case 'insufficient_scope': - - // internal_error 500 An unexpected error occurred. This error corresponds to a bug in the implementation of a PAIA auth/core server + // internal_error 500 + // An unexpected error occurred. This error corresponds to a bug in + // the implementation of a PAIA auth/core server case 'internal_error': - - // service_unavailable 503 The request couldn’t be serviced because of a temporary failure + // service_unavailable 503 + // The request couldn’t be serviced because of a temporary failure case 'service_unavailable': - - // bad_gateway 502 The request couldn’t be serviced because of a backend failure (for instance the library system’s database) + // bad_gateway 502 + // The request couldn’t be serviced because of a backend failure + // (for instance the library system’s database) case 'bad_gateway': - - // gateway_timeout 504 The request couldn’t be serviced because of a backend failure' + // gateway_timeout 504 + // The request couldn’t be serviced because of a backend failure' case 'gateway_timeout': - default: throw new ILSException( isset($array['error_description']) @@ -496,7 +507,8 @@ class PAIA extends \VuFind\ILS\Driver\PAIA try { $array_response = $this->paiaPostAsArray( - 'core/'.$patron['cat_username'].'/request', $post_data + 'core/'.$patron['cat_username'].'/request', + $post_data ); } catch (\Exception $e) { $this->debug($e->getMessage()); @@ -576,7 +588,8 @@ class PAIA extends \VuFind\ILS\Driver\PAIA try { $array_response = $this->paiaPostAsArray( - 'core/'.$patron['cat_username'].'/renew', $post_data + 'core/'.$patron['cat_username'].'/renew', + $post_data ); } catch (\Exception $e) { $this->debug($e->getMessage()); @@ -727,7 +740,8 @@ class PAIA extends \VuFind\ILS\Driver\PAIA $result['item_id'] = (isset($doc['item']) ? $doc['item'] : ''); $result['cancel_details'] - = (isset($doc['cancancel']) + = ( + isset($doc['cancancel']) && $doc['cancancel'] && $this->paiaCheckScope(self::SCOPE_WRITE_ITEMS) ) ? $result['item_id'] : ''; @@ -802,7 +816,6 @@ class PAIA extends \VuFind\ILS\Driver\PAIA */ $results[] = $result; - } return $results; } @@ -826,7 +839,8 @@ class PAIA extends \VuFind\ILS\Driver\PAIA $result['item_id'] = (isset($doc['item']) ? $doc['item'] : ''); $result['cancel_details'] - = (isset($doc['cancancel']) + = ( + isset($doc['cancancel']) && $doc['cancancel'] && $this->paiaCheckScope(self::SCOPE_WRITE_ITEMS) ) ? $result['item_id'] : ''; @@ -870,7 +884,6 @@ class PAIA extends \VuFind\ILS\Driver\PAIA */ $results[] = $result; - } return $results; } @@ -890,7 +903,8 @@ class PAIA extends \VuFind\ILS\Driver\PAIA foreach ($items as $doc) { $result = []; // canrenew (0..1) whether a document can be renewed (bool) - $result['renewable'] = (isset($doc['canrenew']) + $result['renewable'] = ( + isset($doc['canrenew']) && $this->paiaCheckScope(self::SCOPE_WRITE_ITEMS) ) ? $doc['canrenew'] : false; @@ -898,7 +912,8 @@ class PAIA extends \VuFind\ILS\Driver\PAIA $result['item_id'] = (isset($doc['item']) ? $doc['item'] : ''); $result['renew_details'] - = (isset($doc['canrenew']) + = ( + isset($doc['canrenew']) && $doc['canrenew'] && $this->paiaCheckScope(self::SCOPE_WRITE_ITEMS) ) ? $result['item_id'] : ''; @@ -1134,7 +1149,8 @@ class PAIA extends \VuFind\ILS\Driver\PAIA } $responseJson = $this->paiaGetRequest( - 'core/' . $patron, $this->getSession()->access_token + 'core/' . $patron, + $this->getSession()->access_token ); try { @@ -1147,8 +1163,15 @@ class PAIA extends \VuFind\ILS\Driver\PAIA return $this->paiaParseUserDetails($patron, $responseArray); } - public function getValidPatronUpdateKeys() { + /** + * Get valid patron keys + * + * @return array + * @access public + */ + public function getValidPatronUpdateKeys() + { return [ 'name'=>'name', 'email'=>'email', @@ -1156,6 +1179,7 @@ class PAIA extends \VuFind\ILS\Driver\PAIA ]; } + /** * update patron information using the PAIA function 'update patron' * see https://gbv.github.io/paia/paia.html#update-patron @@ -1165,31 +1189,37 @@ class PAIA extends \VuFind\ILS\Driver\PAIA * <li>email: new email address of the patron</li> * <li>address: new freeform address of the patron</li> * </ul> - * All of those are optional. Any other key will be ignored. If additional information shall be saved, this can be done - * via the freeform address field. This function here does not make any assumptions on the syntax - * of the address field, it should be field with correctly encoded data. + * All of those are optional. Any other key will be ignored. If additional + * information shall be saved, this can be done via the freeform address field. + * This function here does not make any assumptions on the syntax of the address + * field, it should be field with correctly encoded data. * * @param array $patron current patron profile - * @return array <ul><li>success: (bool) TRUE on success, FALSE on fail</li><li>details: (string) error details on fail</li></ul> + * @return array <ul><li>success: (bool) TRUE on success, + * FALSE on fail</li><li>details: + * (string) error details on fail</li></ul> * @throws ILSException */ - protected function paiaUpdatePatron($values,$patron) { - + protected function paiaUpdatePatron($values, $patron) + { // check if user has appropriate scope if (!$this->paiaCheckScope(self::SCOPE_UPDATE_PATRON)) { - if ( - (isset($values['name']) && !$this->paiaCheckScope(self::SCOPE_UPDATE_PATRON_NAME)) + if ((isset($values['name']) && !$this->paiaCheckScope(self::SCOPE_UPDATE_PATRON_NAME)) || (isset($values['email']) && !$this->paiaCheckScope(self::SCOPE_UPDATE_PATRON_EMAIL)) || (isset($values['address']) && !$this->paiaCheckScope(self::SCOPE_UPDATE_PATRON_ADDRESS)) - ) - throw new ILSException('You are not allowed to update the desired patron information.'); + ) { + throw new ILSException( + 'You are not allowed to update the desired patron information.' + ); + } } try { $array_response = $this->paiaPostAsArray( - 'core/'.$patron['cat_username'], $values + 'core/' . $patron['cat_username'], + $values ); } catch (\Exception $e) { $this->debug($e->getMessage()); @@ -1261,8 +1291,7 @@ class PAIA extends \VuFind\ILS\Driver\PAIA public function checkRequestIsValid($id, $data, $patron) { // TODO: make this more configurable - if ( - isset($patron['status']) && $patron['status'] == 0 + if (isset($patron['status']) && $patron['status'] == 0 && isset($patron['expires']) && $patron['expires'] > date('Y-m-d') && in_array(self::SCOPE_WRITE_ITEMS, $this->getScope()) ) { @@ -1271,7 +1300,14 @@ class PAIA extends \VuFind\ILS\Driver\PAIA return false; } - public function getLastError() { + /** + * Get last error + * + * @return null + * @access public + */ + public function getLastError() + { return $this->last_error; } } diff --git a/module/finc/src/finc/ILS/Logic/Holds.php b/module/finc/src/finc/ILS/Logic/Holds.php index a81b6a21a87162cec024fe7dde2355e194070141..0b7d745c965d079c3d3fff0fcbfe45e036bc4cce 100644 --- a/module/finc/src/finc/ILS/Logic/Holds.php +++ b/module/finc/src/finc/ILS/Logic/Holds.php @@ -101,7 +101,8 @@ class Holds extends \VuFind\ILS\Logic\Holds foreach ((array)$item[$fieldName] as $field) { if (empty($targetRef) || !in_array( - $field, $targetRef + $field, + $targetRef ) ) { $targetRef[] = $field; @@ -139,7 +140,8 @@ class Holds extends \VuFind\ILS\Logic\Holds // Does this ILS Driver handle consortial holdings? $config = $this->catalog->checkFunction( - 'Holds', compact('id', 'patron') + 'Holds', + compact('id', 'patron') ); } catch (ILSException $e) { $patron = false; @@ -148,11 +150,14 @@ class Holds extends \VuFind\ILS\Logic\Holds if (isset($config['consortium']) && $config['consortium'] == true) { $result = $this->catalog->getConsortialHoldings( - $id, $patron ? $patron : null, $ids + $id, + $patron ? $patron : null, + $ids ); } else { $result = $this->catalog->getHolding( - $id, $patron ? $patron : null + $id, + $patron ? $patron : null ); } @@ -160,7 +165,8 @@ class Holds extends \VuFind\ILS\Logic\Holds $blocks = $patron && $this->catalog->checkCapability( - $grb, compact($patron) + $grb, + compact($patron) ) ? $this->catalog->getRequestBlocks($patron) : false; @@ -171,23 +177,36 @@ class Holds extends \VuFind\ILS\Logic\Holds } else { if ($mode == "driver") { $holdings = $this->driverHoldings( - $result, $config, !empty($blocks) + $result, + $config, + !empty($blocks) ); } else { $holdings = $this->generateHoldings( - $result, $mode, $config + $result, + $mode, + $config ); } } $holdings = $this->processStorageRetrievalRequests( - $holdings, $id, $patron, !empty($blocks) + $holdings, + $id, + $patron, + !empty($blocks) ); $holdings = $this->processILLRequests( - $holdings, $id, $patron, !empty($blocks) + $holdings, + $id, + $patron, + !empty($blocks) ); $holdings = $this->processEmailHolds( - $holdings, $id, $patron, !empty($blocks) + $holdings, + $id, + $patron, + !empty($blocks) ); } return [ @@ -208,15 +227,18 @@ class Holds extends \VuFind\ILS\Logic\Holds * @return array Modified holdings */ protected function processEmailHolds( - $holdings, $id, $patron, $requestsBlocked - ) - { + $holdings, + $id, + $patron, + $requestsBlocked + ) { if (!is_array($holdings)) { return $holdings; } $requestConfig = $this->catalog->checkFunction( - 'EmailHold', compact('id', 'patron') + 'EmailHold', + compact('id', 'patron') ); if (!$requestConfig) { diff --git a/module/finc/src/finc/Mailer/Factory.php b/module/finc/src/finc/Mailer/Factory.php index 77d2998a3b02d91567d7a240520718a00b1161a7..eca49ea9ba4bf9c1623c0f9d7d8618d4fb114cac 100644 --- a/module/finc/src/finc/Mailer/Factory.php +++ b/module/finc/src/finc/Mailer/Factory.php @@ -26,8 +26,10 @@ * @link https://vufind.org/wiki/development Wiki */ namespace finc\Mailer; + use Zend\Mail\Transport\InMemory; -use Zend\Mail\Transport\Smtp, Zend\Mail\Transport\SmtpOptions; +use Zend\Mail\Transport\Smtp; +use Zend\Mail\Transport\SmtpOptions; use Zend\ServiceManager\ServiceLocatorInterface; /** diff --git a/module/finc/src/finc/Mailer/Mailer.php b/module/finc/src/finc/Mailer/Mailer.php index 821a436efb25919431187fa8faa8dfa89139124c..d46e43b740ec766aae2bdadc74c7c186c449f7b8 100644 --- a/module/finc/src/finc/Mailer/Mailer.php +++ b/module/finc/src/finc/Mailer/Mailer.php @@ -26,13 +26,14 @@ * @link https://vufind.org/wiki/development Wiki */ namespace finc\Mailer; -use VuFind\Exception\Mail as MailException, - Zend\Mail\Address, - Zend\Mail\AddressList, - Zend\Mail\Message, - Zend\Mime\Message as MimeMessage, - Zend\Mime\Part as MimePart, - Zend\Mime as Mime; + +use VuFind\Exception\Mail as MailException; +use Zend\Mail\Address; +use Zend\Mail\AddressList; +use Zend\Mail\Message; +use Zend\Mime\Message as MimeMessage; +use Zend\Mime\Part as MimePart; +use Zend\Mime as Mime; /** * VuFind Mailer Class @@ -72,12 +73,17 @@ class Mailer extends \VuFind\Mailer\Mailer * @throws MailException * @return void */ - public function sendTextHtml($to, $from, $reply, $subject, $body_html, - $body_text + public function sendTextHtml( + $to, + $from, + $reply, + $subject, + $body_html, + $body_text ) { if ($to instanceof AddressList) { $recipients = $to; - } else if ($to instanceof Address) { + } elseif ($to instanceof Address) { $recipients = new AddressList(); $recipients->add($to); } else { @@ -150,9 +156,10 @@ class Mailer extends \VuFind\Mailer\Mailer $message->getHeaders() ->get('content-type') ->setType('multipart/alternative'); + $this->getTransport()->send($message); } catch (\Exception $e) { throw new MailException($e->getMessage()); } } -} \ No newline at end of file +} diff --git a/module/finc/src/finc/Recommend/EbscoResults.php b/module/finc/src/finc/Recommend/EbscoResults.php index fce9d9dab7565bffb392b78a442a2d7a8900e5e7..0aaf556bf342571d4760d05ec33109ed01703494 100644 --- a/module/finc/src/finc/Recommend/EbscoResults.php +++ b/module/finc/src/finc/Recommend/EbscoResults.php @@ -41,8 +41,10 @@ namespace finc\Recommend; * * @codeCoverageIgnore */ -class EbscoResults implements \VuFind\Recommend\RecommendInterface, - \VuFindHttp\HttpServiceAwareInterface, \Zend\Log\LoggerAwareInterface +class EbscoResults implements + \VuFind\Recommend\RecommendInterface, + \VuFindHttp\HttpServiceAwareInterface, + \Zend\Log\LoggerAwareInterface { use \VuFind\Log\LoggerAwareTrait; use \VuFindHttp\HttpServiceAwareTrait; @@ -141,7 +143,8 @@ class EbscoResults implements \VuFind\Recommend\RecommendInterface, } $this->lookfor = urlencode(trim($this->lookfor)); $this->targetUrl = $this->getURL( - 'https://' . $this->baseUrl, strtolower($this->namespace) + 'https://' . $this->baseUrl, + strtolower($this->namespace) ); } @@ -216,8 +219,8 @@ class EbscoResults implements \VuFind\Recommend\RecommendInterface, /** * Sort databases by hits * - * @param array $results Unprocessed array of curl requrest. - * @param string $sortOrder Order of sort. Default: SORT_DESC + * @param array $results Unprocessed array of curl requrest. + * @param mixed $sortOrder Order of sort. Default: SORT_DESC * * @return array $results * @access protected @@ -236,5 +239,4 @@ class EbscoResults implements \VuFind\Recommend\RecommendInterface, } return $results; } - -} \ No newline at end of file +} diff --git a/module/finc/src/finc/Recommend/Factory.php b/module/finc/src/finc/Recommend/Factory.php index d60d0140048d162762c78130eb5cd66be668daef..cfd2e61ca3df05c24b45e5fd69eaabb086a68625 100644 --- a/module/finc/src/finc/Recommend/Factory.php +++ b/module/finc/src/finc/Recommend/Factory.php @@ -55,4 +55,4 @@ class Factory extends \Vufind\Recommend\Factory { return new EbscoResults(); } -} \ No newline at end of file +} diff --git a/module/finc/src/finc/RecordDriver/Factory.php b/module/finc/src/finc/RecordDriver/Factory.php index 96aea9fd2aa946fa2cbe6169f777f8cabfabe70d..0443677521ba0d3967fd55fc0def6b6bec3f3d94 100644 --- a/module/finc/src/finc/RecordDriver/Factory.php +++ b/module/finc/src/finc/RecordDriver/Factory.php @@ -45,7 +45,7 @@ class Factory /** * Factory for SolrDefault record driver. * - * @param ServiceManager $container Service manager. + * @param ContainerInterface $container Service manager. * * @return SolrDefault */ @@ -63,7 +63,7 @@ class Factory /** * Factory for SolrMarc record driver. * - * @param ServiceManager $container Service manager. + * @param ContainerInterface $container Service manager. * * @return SolrMarc */ @@ -86,7 +86,7 @@ class Factory /** * Factory for SolrMarcPDA record driver. * - * @param ServiceManager $container Service manager. + * @param ContainerInterface $container Service manager. * * @return SolrMarcFincPDA */ @@ -109,7 +109,7 @@ class Factory /** * Factory for SolrMarcRemote record driver. * - * @param ServiceManager $container Service manager. + * @param ContainerInterface $container Service manager. * * @return SolrMarcRemote */ @@ -132,7 +132,7 @@ class Factory /** * Factory for SolrAI record driver. * - * @param ServiceManager $container Service manager. + * @param ContainerInterface $container Service manager. * * @return SolrAI */ @@ -148,7 +148,7 @@ class Factory /** * Factory for SolrIS record driver. * - * @param ServiceManager $container Service manager. + * @param ContainerInterface $container Service manager. * * @return SolrIS */ @@ -166,7 +166,7 @@ class Factory /** * Factory for SolrMarcRemoteFinc record driver. * - * @param ServiceManager $container Service manager. + * @param ContainerInterface $container Service manager. * * @return SolrMarcRemoteFinc */ @@ -189,7 +189,7 @@ class Factory /** * Factory for SolrMarcFinc record driver. * - * @param ServiceManager $container Service manager. + * @param ContainerInterface $container Service manager. * * @return SolrMarcFinc */ @@ -212,7 +212,7 @@ class Factory /** * Factory for SolrLido record driver. * - * @param ServiceManager $container Service manager. + * @param ContainerInterface $container Service manager. * * @return SolrLido */ @@ -229,7 +229,7 @@ class Factory /** * Factory for SolrLidoFinc record driver. * - * @param ServiceManager $container Service manager. + * @param ContainerInterface $container Service manager. * * @return SolrLido */ diff --git a/module/finc/src/finc/RecordDriver/SolrAI.php b/module/finc/src/finc/RecordDriver/SolrAI.php index a2284f92d572e060272bcb1918ae713ded5f752a..60b98c78390f43b28b2327837939cbc0c7266afb 100644 --- a/module/finc/src/finc/RecordDriver/SolrAI.php +++ b/module/finc/src/finc/RecordDriver/SolrAI.php @@ -28,6 +28,7 @@ * @link http://vufind.org/wiki/vufind2:record_drivers Wiki */ namespace finc\RecordDriver; + use \VuFindHttp\HttpServiceAwareInterface as HttpServiceAwareInterface; /** @@ -355,27 +356,27 @@ class SolrAI extends SolrDefault implements $genre = $this->getAIRecord('rft.genre'); // Set up parameters based on the format of the record: switch ($genre) { - case "article": - $params = $this->getArticleOpenURLParams(); - break; - case "book": - case "bookitem": - $params = $this->getBookOpenURLParams(); - break; - case "journal": - $params = $this->getJournalOpenURLParams(); - break; - case "conference": - case "document": - case "issue": - case "preprint": - case "proceeding": - case "report": - case "unknown": - default: - $format = $this->getFormats(); - $params = $this->getUnknownFormatOpenURLParams($format); - break; + case "article": + $params = $this->getArticleOpenURLParams(); + break; + case "book": + case "bookitem": + $params = $this->getBookOpenURLParams(); + break; + case "journal": + $params = $this->getJournalOpenURLParams(); + break; + case "conference": + case "document": + case "issue": + case "preprint": + case "proceeding": + case "report": + case "unknown": + default: + $format = $this->getFormats(); + $params = $this->getUnknownFormatOpenURLParams($format); + break; } // Assemble the URL: diff --git a/module/finc/src/finc/RecordDriver/SolrDefault.php b/module/finc/src/finc/RecordDriver/SolrDefault.php index cc5ec8d325953ffb6b8ac9ffeb2c114537256639..d13c83c885ea0dbae76e6d384f2383aef1b27a19 100644 --- a/module/finc/src/finc/RecordDriver/SolrDefault.php +++ b/module/finc/src/finc/RecordDriver/SolrDefault.php @@ -30,6 +30,7 @@ * @link https://vufind.org/wiki/development:plugins:record_drivers Wiki */ namespace finc\RecordDriver; + use Zend\Log\LoggerAwareInterface as LoggerAwareInterface; /** @@ -69,10 +70,11 @@ class SolrDefault extends \VuFind\RecordDriver\SolrDefault implements * (omit to use $mainConfig as $recordConfig) * @param \Zend\Config\Config $searchSettings Search-specific configuration file */ - public function __construct($mainConfig = null, $recordConfig = null, - $searchSettings = null - ) - { + public function __construct( + $mainConfig = null, + $recordConfig = null, + $searchSettings = null + ) { parent::__construct($mainConfig, $recordConfig, $searchSettings); if (isset($this->mainConfig->CustomIndex->indexExtension)) { @@ -90,7 +92,8 @@ class SolrDefault extends \VuFind\RecordDriver\SolrDefault implements * * @return mixed */ - public function getField($field) { + public function getField($field) + { if (isset($this->fields[$field])) { return $this->fields[$field]; } diff --git a/module/finc/src/finc/RecordDriver/SolrDefaultFincTrait.php b/module/finc/src/finc/RecordDriver/SolrDefaultFincTrait.php index 48e1d7084474643bb420bebb818c5a72764d0f64..7981bee042c41bf4352f448525fdc9e2209f2805 100644 --- a/module/finc/src/finc/RecordDriver/SolrDefaultFincTrait.php +++ b/module/finc/src/finc/RecordDriver/SolrDefaultFincTrait.php @@ -31,8 +31,9 @@ * @SuppressWarnings(PHPMD.ExcessivePublicCount) */ namespace finc\RecordDriver; -use VuFindSearch\ParamBag, - VuFindSearch\Query\Query as Query; + +use VuFindSearch\ParamBag; +use VuFindSearch\Query\Query as Query; /** * finc specific model for Solr records based on the stock @@ -93,17 +94,21 @@ trait SolrDefaultFincTrait * @return array Containing local_heading_[facet_]{indexExtension} fields. * @access public */ - public function getLocalHeading() { - + public function getLocalHeading() + { $array = []; if (isset($this->mainConfig->CustomIndex->indexExtension)) { - $array = isset($this->fields['local_heading_' . ($this->mainConfig->CustomIndex->indexExtension)]) ? - $this->fields['local_heading_' . ($this->mainConfig->CustomIndex->indexExtension)] : []; + $array = isset( + $this->fields['local_heading_' . ($this->mainConfig->CustomIndex->indexExtension)] + ) ? $this->fields['local_heading_' . ($this->mainConfig->CustomIndex->indexExtension)] + : []; // Use local_heading_facet field if local_heading field delivers no results at first if (count($array) == 0) { - $array = isset($this->fields['local_heading_facet_' . ($this->mainConfig->CustomIndex->indexExtension)]) ? - $this->fields['local_heading_facet_' . ($this->mainConfig->CustomIndex->indexExtension)] : []; + $array = isset( + $this->fields['local_heading_facet_' . ($this->mainConfig->CustomIndex->indexExtension)] + ) ? $this->fields['local_heading_facet_' . ($this->mainConfig->CustomIndex->indexExtension)] + : []; } } return $array; @@ -111,24 +116,23 @@ trait SolrDefaultFincTrait /** * Custom method to return permissions set for this record in mainConfig - * + * * @return int|null|string */ public function getRecordPermission() { // do we have a RecordPermissions section in config.ini? if (isset($this->mainConfig->RecordPermissions)) { - // let's loop through all set RecordPermissions and evaluate them for the // current record foreach ($this->mainConfig->RecordPermissions->toArray() as $permission => $settings) { - foreach((array) $settings as $value) { + foreach ((array) $settings as $value) { list($methodName, $methodReturn) = explode(':', $value); if (in_array($methodReturn, (array) $this->tryMethod($methodName))) { // as the current permission matches the current record, // return it return $permission; - } + } } } } @@ -251,15 +255,15 @@ trait SolrDefaultFincTrait if (strlen($this->getCleanISSN()) > 0) { return 'Journal'; - } else if (strlen($this->getCleanISBN()) > 0) { + } elseif (strlen($this->getCleanISBN()) > 0) { return 'Book'; - } else if (in_array('Book', $formats)) { + } elseif (in_array('Book', $formats)) { return 'Book'; - } else if (in_array('Article', $formats)) { + } elseif (in_array('Article', $formats)) { return 'Article'; - } else if (in_array('Journal', $formats)) { + } elseif (in_array('Journal', $formats)) { return 'Journal'; - } else if (isset($formats[0])) { + } elseif (isset($formats[0])) { return $formats[0]; } return 'UnknownFormat'; @@ -292,10 +296,18 @@ trait SolrDefaultFincTrait return $params; } - public function getSetMultiPart() { - + /** + * Get set multi part ??? + * + * @return array + * @access public + */ + public function getSetMultiPart() + { $ids = $this->getHierarchyParentID(); - if (empty($ids)) return []; + if (empty($ids)) { + return []; + } $titles = $this->getHierarchyParentTitle(); $result = []; if (count($ids) === count($titles)) { @@ -376,7 +388,7 @@ trait SolrDefaultFincTrait * * @return array */ -/* protected function getFormatIcon() + /* protected function getFormatIcon() { global $configArray; @@ -395,7 +407,6 @@ trait SolrDefaultFincTrait case 'c': break; //return 'part-not-related'; } } - //echo "<pre>"; print_r($format); echo "</pre>"; return $format[0]; } }*/ @@ -498,7 +509,8 @@ trait SolrDefaultFincTrait * * @return string */ - protected function getDefaultOrigName() { + protected function getDefaultOrigName() + { //TODO: make this configurable - aka get value from config! return 'noOrigName'; } @@ -659,14 +671,16 @@ trait SolrDefaultFincTrait ) ]; - $all_empty = TRUE; + $all_empty = true; foreach ($authors as $type => $values) { if (!empty($values)) { - $all_empty = FALSE; + $all_empty = false; break; } } - if ($all_empty) return []; + if ($all_empty) { + return []; + } // deduplicate $dedup = function (&$array1, &$array2) { @@ -797,7 +811,7 @@ trait SolrDefaultFincTrait * * @return int mixed If success return at least one finc id otherwise null. */ - protected function addFincIDToRecord( $array ) + protected function addFincIDToRecord($array) { // record ids $rids = []; @@ -879,14 +893,13 @@ trait SolrDefaultFincTrait */ public function getRelevance() { - $score = isset($this->fields['score']) ? $this->fields['score'] : 0; $maxScore = isset($this->fields['score_maximum']) ? $this->fields['score_maximum'] : 0; if ($score == 0 || $maxScore == 0) { return 0; } - return round( ($score / $maxScore) , 5); + return round(($score / $maxScore), 5); } /** @@ -894,7 +907,8 @@ trait SolrDefaultFincTrait * * @return string */ - public function getRvk() { + public function getRvk() + { return isset($this->fields['rvk_facet']) ? $this->fields['rvk_facet'] : ''; } @@ -1122,10 +1136,14 @@ trait SolrDefaultFincTrait * * @return array */ - private function _filterAuthorDates( $authordata ) + private function _filterAuthorDates($authordata) { $filter = function ($author) { - if (preg_match('/^(\s|.*)(\d{4})\s?-?\s?(\d{4})?$/Uu',$author, $match)) { + if (preg_match( + '/^(\s|.*)(\d{4})\s?-?\s?(\d{4})?$/Uu', + $author, + $match + )) { return (isset($match[3])) ? $match[1] .' *'. $match[2] . '-†'. $match[3] : $match[1] .' *'. $match[2] . '-'; @@ -1180,7 +1198,6 @@ trait SolrDefaultFincTrait // is the record's id indexed as its hierarchy_top_id if (in_array($currId, $hierId)) { - $query = 'hierarchy_top_id:' . $currId; $result = $this->searchService->search('Solr', new Query($query)); if (count($result) === 0) { diff --git a/module/finc/src/finc/RecordDriver/SolrLido.php b/module/finc/src/finc/RecordDriver/SolrLido.php index 146e17de2c37689af9aec34b01180778977fbae0..9cbcc26fb5aaf3d1eb74642594c7a09c8da7d888 100644 --- a/module/finc/src/finc/RecordDriver/SolrLido.php +++ b/module/finc/src/finc/RecordDriver/SolrLido.php @@ -58,12 +58,13 @@ class SolrLido extends SolrLidoNdl * file * @param \VuFind\Date\Converter $dateConverter Date Converter */ - public function __construct($mainConfig = null, $recordConfig = null, - $searchSettings = null, $dateConverter = null - ) - { + public function __construct( + $mainConfig = null, + $recordConfig = null, + $searchSettings = null, + $dateConverter = null + ) { parent::__construct($mainConfig, $recordConfig, $searchSettings); $this->dateConverter = $dateConverter; } - -} \ No newline at end of file +} diff --git a/module/finc/src/finc/RecordDriver/SolrLidoFincTrait.php b/module/finc/src/finc/RecordDriver/SolrLidoFincTrait.php index 226e5bd85d1eb46af4dfbe244ca50ac6b31d6b03..e36fe2d89c2df6f0eb07c03a4dc3b6f76b2b6685 100644 --- a/module/finc/src/finc/RecordDriver/SolrLidoFincTrait.php +++ b/module/finc/src/finc/RecordDriver/SolrLidoFincTrait.php @@ -109,6 +109,4 @@ trait SolrLidoFincTrait } return $results; } - - -} \ No newline at end of file +} diff --git a/module/finc/src/finc/RecordDriver/SolrLidoNdl.php b/module/finc/src/finc/RecordDriver/SolrLidoNdl.php index 078a6b999b4a15f7fedf2f73f41ff08c7245ba8a..82393c5c10a979bac6465f13afcaec955e6d542d 100644 --- a/module/finc/src/finc/RecordDriver/SolrLidoNdl.php +++ b/module/finc/src/finc/RecordDriver/SolrLidoNdl.php @@ -65,10 +65,12 @@ class SolrLidoNdl extends \finc\RecordDriver\SolrDefault * file * @param \VuFind\Date\Converter $dateConverter Date Converter */ - public function __construct($mainConfig = null, $recordConfig = null, - $searchSettings = null, $dateConverter = null - ) - { + public function __construct( + $mainConfig = null, + $recordConfig = null, + $searchSettings = null, + $dateConverter = null + ) { parent::__construct($mainConfig, $recordConfig, $searchSettings); $this->dateConverter = $dateConverter; } @@ -239,12 +241,14 @@ class SolrLidoNdl extends \finc\RecordDriver\SolrDefault $endDateType = 'Y-m'; } $date = $this->dateConverter->convertToDisplayDate( - $startDateType, $startDate + $startDateType, + $startDate ); if ($startDate != $endDate) { $date .= '-' . $this->dateConverter->convertToDisplayDate( - $endDateType, $endDate - ); + $endDateType, + $endDate + ); } } } @@ -268,12 +272,12 @@ class SolrLidoNdl extends \finc\RecordDriver\SolrDefault // Use displayMaterialTech (default) $materials[] = (string)$node->eventMaterialsTech ->displayMaterialsTech; - } else if (isset($node->eventMaterialsTech->materialsTech)) { + } elseif (isset($node->eventMaterialsTech->materialsTech)) { // display label not defined, build from materialsTech $materials = []; - foreach ($node->xpath('eventMaterialsTech/materialsTech') - as $materialsTech - ) { + foreach ($node->xpath( + 'eventMaterialsTech/materialsTech' + ) as $materialsTech) { if ($terms = $materialsTech->xpath('termMaterialsTech/term')) { foreach ($terms as $term) { $label = null; @@ -281,7 +285,7 @@ class SolrLidoNdl extends \finc\RecordDriver\SolrDefault if (isset($attributes->label)) { // Musketti $label = $attributes->label; - } else if (isset($materialsTech->extentMaterialsTech)) { + } elseif (isset($materialsTech->extentMaterialsTech)) { // Siiri $label = $materialsTech->extentMaterialsTech; } @@ -300,8 +304,7 @@ class SolrLidoNdl extends \finc\RecordDriver\SolrDefault if (!$place) { if (isset($node->eventPlace->place->namePlaceSet)) { $eventPlace = []; - foreach ($node->eventPlace->place->namePlaceSet as $namePlaceSet - ) { + foreach ($node->eventPlace->place->namePlaceSet as $namePlaceSet) { if (trim((string)$namePlaceSet->appellationValue) != '') { $eventPlace[] = isset($namePlaceSet) ? trim((string)$namePlaceSet->appellationValue) : ''; @@ -382,9 +385,7 @@ class SolrLidoNdl extends \finc\RecordDriver\SolrDefault ) as $node) { $term = (string)$node->objectWorkTypeWrap->objectWorkType->term; if ($term == 'rakennetun ympäristön kohde') { - foreach ($node->classificationWrap->classification - as $classificationNode - ) { + foreach ($node->classificationWrap->classification as $classificationNode) { $type = null; $attributes = $classificationNode->attributes(); $type = isset($attributes->type) ? $attributes->type : ''; @@ -395,10 +396,8 @@ class SolrLidoNdl extends \finc\RecordDriver\SolrDefault $results[] = (string)$classificationNode->term; } } - } else if ($term == 'arkeologinen kohde') { - foreach ($node->classificationWrap->classification->term - as $classificationNode - ) { + } elseif ($term == 'arkeologinen kohde') { + foreach ($node->classificationWrap->classification->term as $classificationNode) { $label = null; $attributes = $classificationNode->attributes(); $label = isset($attributes->label) ? $attributes->label : ''; @@ -482,7 +481,6 @@ class SolrLidoNdl extends \finc\RecordDriver\SolrDefault $results[] = (string)$node . ' (' . $label . ')'; } else { $results[] = (string)$node; - } } return $results; @@ -782,6 +780,5 @@ class SolrLidoNdl extends \finc\RecordDriver\SolrDefault $this->simpleXML = simplexml_load_string($this->fields['fullrecord']); } return $this->simpleXML; - } } diff --git a/module/finc/src/finc/RecordDriver/SolrMarc.php b/module/finc/src/finc/RecordDriver/SolrMarc.php index 5e39e43218d15f466f2901929d46748244052333..356ffc8eb9cccd4697352e2d005fe5ab20f4ba7d 100644 --- a/module/finc/src/finc/RecordDriver/SolrMarc.php +++ b/module/finc/src/finc/RecordDriver/SolrMarc.php @@ -28,9 +28,10 @@ * @link https://vufind.org/wiki/development:plugins:record_drivers Wiki */ namespace finc\RecordDriver; -use VuFind\Exception\ILS as ILSException, - VuFind\View\Helper\Root\RecordLink, - VuFind\XSLT\Processor as XSLTProcessor; + +use VuFind\Exception\ILS as ILSException; +use VuFind\View\Helper\Root\RecordLink; +use VuFind\XSLT\Processor as XSLTProcessor; /** * Model for MARC records in Solr. @@ -134,7 +135,8 @@ class SolrMarc extends SolrDefault // Remove duplicates and then send back everything we collected: return array_map( - 'unserialize', array_unique(array_map('serialize', $retval)) + 'unserialize', + array_unique(array_map('serialize', $retval)) ); } @@ -159,20 +161,20 @@ class SolrMarc extends SolrDefault $biblioLevel = strtoupper($leader[7]); switch ($biblioLevel) { - case 'M': // Monograph - return "Monograph"; - case 'S': // Serial - return "Serial"; - case 'A': // Monograph Part - return "MonographPart"; - case 'B': // Serial Part - return "SerialPart"; - case 'C': // Collection - return "Collection"; - case 'D': // Collection Part - return "CollectionPart"; - default: - return "Unknown"; + case 'M': // Monograph + return "Monograph"; + case 'S': // Serial + return "Serial"; + case 'A': // Monograph Part + return "MonographPart"; + case 'B': // Serial Part + return "SerialPart"; + case 'C': // Collection + return "Collection"; + case 'D': // Collection Part + return "CollectionPart"; + default: + return "Unknown"; } } @@ -200,7 +202,10 @@ class SolrMarc extends SolrDefault * * @return array */ - protected function getFieldArray($field, $subfields = null, $concat = true, + protected function getFieldArray( + $field, + $subfields = null, + $concat = true, $separator = ' ' ) { // Default to subfield a if nothing is specified. @@ -318,12 +323,12 @@ class SolrMarc extends SolrDefault ->getSubfieldArray($currentField, [$subfield], true, $separator); if (!empty($currentVal)) { switch ($currentField->getIndicator('2')) { - case '1': - $pubResults = array_merge($pubResults, $currentVal); - break; - case '4': - $copyResults = array_merge($copyResults, $currentVal); - break; + case '1': + $pubResults = array_merge($pubResults, $currentVal); + break; + case '4': + $copyResults = array_merge($copyResults, $currentVal); + break; } } } @@ -332,7 +337,7 @@ class SolrMarc extends SolrDefault ? $this->mainConfig->Record->replaceMarc260 : false; if (count($pubResults) > 0) { return $replace260 ? $pubResults : array_merge($results, $pubResults); - } else if (count($copyResults) > 0) { + } elseif (count($copyResults) > 0) { return $replace260 ? $copyResults : array_merge($results, $copyResults); } @@ -502,7 +507,10 @@ class SolrMarc extends SolrDefault * * @return array */ - protected function getSubfieldArray($currentField, $subfields, $concat = true, + protected function getSubfieldArray( + $currentField, + $subfields, + $concat = true, $separator = ' ' ) { // Start building a line of text for the current field @@ -518,11 +526,11 @@ class SolrMarc extends SolrDefault // non-empty: $data = trim($currentSubfield->getData()); if (!empty($data)) { - $matches[] = $data; - } + $matches[] = $data; } } } + } // Send back the data in a different format depending on $concat mode: return $concat && $matches ? [implode($separator, $matches)] : $matches; @@ -766,18 +774,17 @@ class SolrMarc extends SolrDefault // Assign notes based on the relationship type $value = $field->getTag(); switch ($value) { - case '780': - if (in_array($relationshipIndicator, range('0', '7'))) { - $value .= '_' . $relationshipIndicator; - } - break; - case '785': - if (in_array($relationshipIndicator, range('0', '8'))) { - $value .= '_' . $relationshipIndicator; - } - break; + case '780': + if (in_array($relationshipIndicator, range('0', '7'))) { + $value .= '_' . $relationshipIndicator; + } + break; + case '785': + if (in_array($relationshipIndicator, range('0', '8'))) { + $value .= '_' . $relationshipIndicator; + } + break; } - return 'note_' . $value; } @@ -809,47 +816,51 @@ class SolrMarc extends SolrDefault // If reference found, exit loop and go straight to end // If no reference found, check the next link type instead foreach ($linkTypes as $linkType) { - switch (trim($linkType)){ - case 'oclc': - foreach ($linkFields as $current) { - if ($oclc = $this->getIdFromLinkingField($current, 'OCoLC')) { - $link = ['type' => 'oclc', 'value' => $oclc]; + switch (trim($linkType)) { + case 'oclc': + foreach ($linkFields as $current) { + if ($oclc = + $this->getIdFromLinkingField($current, 'OCoLC') + ) { + $link = ['type' => 'oclc', 'value' => $oclc]; + } } - } - break; - case 'dlc': - foreach ($linkFields as $current) { - if ($dlc = $this->getIdFromLinkingField($current, 'DLC', true)) { - $link = ['type' => 'dlc', 'value' => $dlc]; + break; + case 'dlc': + foreach ($linkFields as $current) { + if ($dlc = + $this->getIdFromLinkingField($current, 'DLC', true) + ) { + $link = ['type' => 'dlc', 'value' => $dlc]; + } } - } - break; - case 'id': - foreach ($linkFields as $current) { - if ($bibLink = $this->getIdFromLinkingField($current)) { - $link = ['type' => 'bib', 'value' => $bibLink]; + break; + case 'id': + foreach ($linkFields as $current) { + if ($bibLink = $this->getIdFromLinkingField($current)) { + $link = ['type' => 'bib', 'value' => $bibLink]; + } } - } - break; - case 'isbn': - if ($isbn = $field->getSubfield('z')) { - $link = [ - 'type' => 'isn', 'value' => trim($isbn->getData()), - 'exclude' => $this->getUniqueId() - ]; - } - break; - case 'issn': - if ($issn = $field->getSubfield('x')) { - $link = [ - 'type' => 'isn', 'value' => trim($issn->getData()), - 'exclude' => $this->getUniqueId() - ]; - } - break; - case 'title': - $link = ['type' => 'title', 'value' => $title]; - break; + break; + case 'isbn': + if ($isbn = $field->getSubfield('z')) { + $link = [ + 'type' => 'isn', 'value' => trim($isbn->getData()), + 'exclude' => $this->getUniqueId() + ]; + } + break; + case 'issn': + if ($issn = $field->getSubfield('x')) { + $link = [ + 'type' => 'isn', 'value' => trim($issn->getData()), + 'exclude' => $this->getUniqueId() + ]; + } + break; + case 'title': + $link = ['type' => 'title', 'value' => $title]; + break; } // Exit loop if we have a link if (isset($link)) { @@ -884,7 +895,7 @@ class SolrMarc extends SolrDefault ? $matches[2] : trim(str_replace(range('a', 'z'), '', ($matches[2]))); } - } else if ($prefix == null) { + } elseif ($prefix == null) { // If no prefix was given or found, we presume it is a raw bib record return $text; } @@ -934,7 +945,9 @@ class SolrMarc extends SolrDefault $subfields = str_split($split[1]); } $result = $this->getSubfieldArray( - $currentField, $subfields, true + $currentField, + $subfields, + true ); $matches[$i][$key] = count($result) > 0 ? (string)$result[0] : ''; @@ -965,7 +978,9 @@ class SolrMarc extends SolrDefault if ($format == 'marc21') { $xml = $this->getMarcRecord()->toXML(); $xml = str_replace( - [chr(27), chr(28), chr(29), chr(30), chr(31)], ' ', $xml + [chr(27), chr(28), chr(29), chr(30), chr(31)], + ' ', + $xml ); $xml = simplexml_load_string($xml); if (!$xml || !isset($xml->record)) { @@ -997,7 +1012,8 @@ class SolrMarc extends SolrDefault * * @return void */ - public function attachILS(\VuFind\ILS\Connection $ils, + public function attachILS( + \VuFind\ILS\Connection $ils, \VuFind\ILS\Logic\Holds $holdLogic, \VuFind\ILS\Logic\TitleHolds $titleHoldLogic ) { @@ -1025,7 +1041,8 @@ class SolrMarc extends SolrDefault public function getRealTimeHoldings() { return $this->hasILS() ? $this->holdLogic->getHoldings( - $this->getUniqueID(), $this->getConsortialIDs() + $this->getUniqueID(), + $this->getConsortialIDs() ) : []; } @@ -1097,7 +1114,9 @@ class SolrMarc extends SolrDefault // When indexing over HTTP, SolrMarc may use entities instead of // certain control characters; we should normalize these: $marc = str_replace( - ['#29;', '#30;', '#31;'], ["\x1D", "\x1E", "\x1F"], $marc + ['#29;', '#30;', '#31;'], + ["\x1D", "\x1E", "\x1F"], + $marc ); $marc = new \File_MARC($marc, \File_MARC::SOURCE_STRING); } @@ -1119,7 +1138,8 @@ class SolrMarc extends SolrDefault public function getRDFXML() { return XSLTProcessor::process( - 'record-rdf-mods.xsl', trim($this->getMarcRecord()->toXML()) + 'record-rdf-mods.xsl', + trim($this->getMarcRecord()->toXML()) ); } diff --git a/module/finc/src/finc/RecordDriver/SolrMarcFinc.php b/module/finc/src/finc/RecordDriver/SolrMarcFinc.php index 637cf41c2459c8aa3d421c01a96af9946a083088..299e373a232578a1b0a359ae735619628c13bc3d 100644 --- a/module/finc/src/finc/RecordDriver/SolrMarcFinc.php +++ b/module/finc/src/finc/RecordDriver/SolrMarcFinc.php @@ -71,10 +71,11 @@ class SolrMarcFinc extends SolrMarc * (omit to use $mainConfig as $recordConfig) * @param \Zend\Config\Config $searchSettings Search-specific configuration file */ - public function __construct($mainConfig = null, $recordConfig = null, - $searchSettings = null - ) - { + public function __construct( + $mainConfig = null, + $recordConfig = null, + $searchSettings = null + ) { parent::__construct($mainConfig, $recordConfig, $searchSettings); // get the isil set in InstitutionInfo in config.ini @@ -85,6 +86,5 @@ class SolrMarcFinc extends SolrMarc } else { $this->debug('InstitutionInfo setting: isil is missing.'); } - } -} \ No newline at end of file +} diff --git a/module/finc/src/finc/RecordDriver/SolrMarcFincPDA.php b/module/finc/src/finc/RecordDriver/SolrMarcFincPDA.php index 2696652beb73b456d77ce49300498a3a1b05181d..69778cb46471f2c4e6f649f140055b7e30bbbcf1 100644 --- a/module/finc/src/finc/RecordDriver/SolrMarcFincPDA.php +++ b/module/finc/src/finc/RecordDriver/SolrMarcFincPDA.php @@ -66,8 +66,8 @@ class SolrMarcFincPDA extends SolrMarcFinc implements try { $response = $this->httpService->get($ecbEuroUrl); } catch (\Exception $e) { - $this->debug("Could not retrieve Euro exchange rate from url:" . - $ecbEuroUrl . "\nExited with exception: " . + $this->debug("Could not retrieve Euro exchange rate from url:" . + $ecbEuroUrl . "\nExited with exception: " . $e->getMessage()); } @@ -97,4 +97,4 @@ class SolrMarcFincPDA extends SolrMarcFinc implements { return false; } -} \ No newline at end of file +} diff --git a/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php b/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php index 3848c9a7768c3995391a7eecb3759d449eb076be..94b31f8c1b52254a766a1620c95120aa38d040bd 100644 --- a/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php +++ b/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php @@ -27,6 +27,7 @@ * @link http://vufind.org/wiki/vufind2:record_drivers Wiki */ namespace finc\RecordDriver; + use VuFindSearch\Query\Query as Query; /** @@ -104,7 +105,7 @@ trait SolrMarcFincTrait if (true === in_array($isil, $this->isil)) { $isISIL = true; } - } else if (!$this->_isEBLRecord()) { + } elseif (!$this->_isEBLRecord()) { $isISIL = true; } @@ -144,7 +145,8 @@ trait SolrMarcFincTrait // If url doesn't exist as key so far write // to return variable. if (!in_array( - ['url' => $address, 'desc' => $desc], $retVal + ['url' => $address, 'desc' => $desc], + $retVal ) ) { $retVal[] = ['url' => $address, 'desc' => $desc]; @@ -172,7 +174,8 @@ trait SolrMarcFincTrait return ( count( array_intersect( - $values, $this->mainConfig->Ebl->product_sigel->toArray() + $values, + $this->mainConfig->Ebl->product_sigel->toArray() ) ) > 0 ) ? true : false; @@ -200,9 +203,9 @@ trait SolrMarcFincTrait { // loop through all existing LocalMarcFieldOfLibrary if ($fields = $this->getMarcRecord()->getFields( - $this->getLocalMarcFieldOfLibrary()) - ) { - foreach($fields as $field) { + $this->getLocalMarcFieldOfLibrary() + )) { + foreach ($fields as $field) { // return the first occurance of $m if ($field->getSubfield('m')) { return $field->getSubfield('m')->getData(); @@ -309,7 +312,8 @@ trait SolrMarcFincTrait */ public function getSupplements() { - //return $this->_getFieldArray('770', array('i','t')); // has been originally 'd','h','n','x' but only 'i' and 't' for ubl requested; + // return $this->_getFieldArray('770', array('i','t')); + // has been originally 'd','h','n','x' but only 'i' and 't' for ubl requested; $array = []; $supplement = $this->getMarcRecord()->getFields('770'); // if not return void value @@ -413,8 +417,9 @@ trait SolrMarcFincTrait * of the given field. fieldIterator is used if no Linkage in subfield 6 is * found. * - * @param $field + * @param string $field Solr field * @param int|bool $fieldIterator + * * @return array|bool */ protected function getLinkedField($field, $fieldIterator = false) @@ -557,7 +562,9 @@ trait SolrMarcFincTrait // Build objects to represent each set of data; these will // transform seamlessly into strings in the view layer. $retval[] = new \VuFind\RecordDriver\Response\PublicationDetails( - $place, $name, $date + $place, + $name, + $date ); // Build the publication details with additional graphical notations @@ -606,7 +613,7 @@ trait SolrMarcFincTrait // 249$a and 249$v are repeatable if ($subfields = $field->getSubfields('a')) { $vs = $field->getSubfields('v'); - foreach ($subfields as $i=>$a) { + foreach ($subfields as $i => $a) { $title .= '. ' . $a->getData(); if (isset($vs[$i])) { $title .= ' / ' . $vs[$i]->getData(); @@ -648,14 +655,14 @@ trait SolrMarcFincTrait #return preg_replace( # $titleRegexPattern, '', trim($string) #); - return rtrim($string," \t\n\r\0\x0B".'.:-/'); + return rtrim($string, " \t\n\r\0\x0B".'.:-/'); }; if ($fields = $this->getMarcRecord()->getFields('505')) { foreach ($fields as $field) { if ($subfields = $field->getSubfields('t')) { $rs = $field->getSubfields('r'); - foreach ($subfields as $i=>$subfield) { + foreach ($subfields as $i => $subfield) { // each occurance of $t gets $a pretached if it exists if (isset($rs[$i])) { $workPartTitles[] = @@ -685,7 +692,7 @@ trait SolrMarcFincTrait $workTitles = []; $truncateTrail = function ($string) { - return rtrim($string," \t\n\r\0\x0B".'.:-/'); + return rtrim($string, " \t\n\r\0\x0B".'.:-/'); }; if ($fields = $this->getMarcRecord()->getFields('700')) { @@ -839,7 +846,7 @@ trait SolrMarcFincTrait return []; } - /** + /** * Return a local access number for call number. * Marc field depends on library e.g. 986 for GfzK. * Seems to be very extraordinary special case. Refs #7924 @@ -937,7 +944,7 @@ trait SolrMarcFincTrait $namespace = $this->mainConfig->CustomIndex->localMarcFieldOfLibraryNamespace; if (isset($this->mainConfig->CustomIndex->localMarcFieldOfLibraryMapping)) { foreach ($this->mainConfig->CustomIndex->localMarcFieldOfLibraryMapping as $mappingValue) { - list ($ns, $fn) = explode(':', $mappingValue); + list($ns, $fn) = explode(':', $mappingValue); if (trim($ns) == trim($namespace)) { $this->localMarcFieldOfLibrary = $fn; break; @@ -966,7 +973,7 @@ trait SolrMarcFincTrait return []; } - /** + /** * Return a local signature via an consortial defined field with subfield $f. * Marc field depends on library e.g. 986 for GFZK. Refs #8146 * @@ -1148,7 +1155,9 @@ trait SolrMarcFincTrait // we expect the links to be ppns prefixed with an ISIL so // strip the ISIL $ppn = preg_replace( - "/^\(([A-z])+\-([A-z0-9])+\)\s?/", "", $link + "/^\(([A-z])+\-([A-z0-9])+\)\s?/", + "", + $link ); $record_id = null; @@ -1213,7 +1222,6 @@ trait SolrMarcFincTrait $i = 0; foreach ($fields as $field) { - $related = $this->getMarcRecord()->getFields($field); // if no entry break it if ($related) { @@ -1302,16 +1310,21 @@ trait SolrMarcFincTrait { $currency = $this->getFirstFieldValue('365', ['c']); $price = $this->getFirstFieldValue('365', ['b']); - if (!empty($currency) && !empty($price) ) { + if (!empty($currency) && !empty($price)) { // if possible convert it in euro - if (is_array($converted = - json_decode(str_replace( - ['lhs','rhs','error','icc'], - ['"lhs"','"rhs"','"error"','"icc"'], - file_get_contents("http://www.google.com/ig/calculator?q=".$price.$currency."=?EUR") - ),true) + if (is_array( + $converted = json_decode( + str_replace( + ['lhs','rhs','error','icc'], + ['"lhs"','"rhs"','"error"','"icc"'], + file_get_contents( + "http://www.google.com/ig/calculator?q=".$price.$currency."=?EUR" + ) + ), + true + ) )) { - if(empty($converted['error'])){ + if (empty($converted['error'])) { $rhs = explode(' ', trim($converted['rhs'])); return money_format('%.2n', $rhs[0]); } @@ -1362,24 +1375,6 @@ trait SolrMarcFincTrait return $this->getFieldArray('830', ['a', 'v'], false); } - /** - * Get source id of marc record. Alternate method getFirstFieldValue returns - * null by value "0" therefor it doesn't fit properly. - * - * @return string|null - * @access public - */ -/* removed erroneous inheritance, this function is present and working in SolrDefaultFincTrait, DM - public function getSourceID() - { - $source_ids = $this->getMarcRecord()->getFields('980'); - if (!$source_ids) { - return null; - } - return (string)$source_ids[0]->getSubfield('b')->getData(); - } -*/ - /** * Get local classification of UDK. * @@ -1391,7 +1386,6 @@ trait SolrMarcFincTrait { $array = []; if (null != $this->getLocalMarcFieldOfLibrary()) { - $udk = $this->getMarcRecord()->getFields( $this->getLocalMarcFieldOfLibrary() ); @@ -1565,7 +1559,7 @@ trait SolrMarcFincTrait // lets collect the text // https://intern.finc.info/issues/6896#note-7 $text = []; - foreach ($subfields as $subfield => list($l_delim,$r_delim)) { + foreach ($subfields as $subfield => list($l_delim, $r_delim)) { $val = $line->getSubfield($subfield); if ($field == '773' && $subfield == 'a') { if ($line->getIndicator(1) == 1) { @@ -1580,7 +1574,9 @@ trait SolrMarcFincTrait $text[] = $l_delim.$val->getData().$r_delim; } } else { - if (empty($val)) continue; + if (empty($val)) { + continue; + } if ($field == '490') { if ($line->getIndicator(1) == 0) { $text[] = $l_delim.$val->getData().$r_delim; @@ -1655,14 +1651,20 @@ trait SolrMarcFincTrait return $retval; } - public function getAllNotes() { - + /** + * Returns all notes. + * + * @return array + * @access public + */ + public function getAllNotes() + { $notes = array_merge( (array) $this->getGeneralNotes(), - (array)$this->getAdditionalNotes() + (array) $this->getAdditionalNotes() ); foreach ($notes as &$note) { - if (preg_match('/(.*)\.\s*$/',$note,$matches)) { + if (preg_match('/(.*)\.\s*$/', $note, $matches)) { $note = $matches[1]; } } @@ -1702,8 +1704,8 @@ trait SolrMarcFincTrait } return current($result->getRecords())->getUniqueId(); } - $this->debug('Pregmatch pattern in getHierarchyParentID failed for ' . - $value + $this->debug( + 'Pregmatch pattern in getHierarchyParentID failed for ' . $value ); return $value; }; @@ -1713,7 +1715,7 @@ trait SolrMarcFincTrait foreach ($fieldList as $fieldNumbers) { foreach ($fieldNumbers as $fieldNumber) { $fields = $this->getMarcRecord()->getFields($fieldNumber); - foreach($fields as $field) { + foreach ($fields as $field) { if ($field->getSubfield('w')) { $parentID[] = $idRetrieval( $field->getSubfield('w')->getData() @@ -1761,7 +1763,7 @@ trait SolrMarcFincTrait // start with 490 (https://intern.finc.info/issues/8704) $fields = $this->getMarcRecord()->getFields('490'); - foreach($fields as $field) { + foreach ($fields as $field) { if ($field->getIndicator(1) == 0 && $subfield = $field->getSubfield('a') ) { @@ -1772,7 +1774,7 @@ trait SolrMarcFincTrait // now check if 773 is available and LDR 7 != (a || s) $fields = $this->getMarcRecord()->getFields('773'); if ($fields && !in_array($this->getMarcRecord()->getLeader()[7], ['a', 's'])) { - foreach($fields as $field) { + foreach ($fields as $field) { if ($field245 = $this->getMarcRecord()->getField('245')) { $parentTitle[] = ($field245->getSubfield('a') ? $field245->getSubfield('a')->getData() : '') . @@ -1782,7 +1784,7 @@ trait SolrMarcFincTrait } } else { // build the titles differently if LDR 7 == (a || s) - foreach($fields as $field) { + foreach ($fields as $field) { $parentTitle[] = ($field->getSubfield('a') ? $field->getSubfield('a')->getData() : '') . ($field->getSubfield('t') ? ': ' . $field->getSubfield('t')->getData() : '') . @@ -1795,7 +1797,7 @@ trait SolrMarcFincTrait $fieldList = ['800', '810', '811']; foreach ($fieldList as $fieldNumber) { $fields = $this->getMarcRecord()->getFields($fieldNumber); - foreach($fields as $field) { + foreach ($fields as $field) { $parentTitle[] = ($field->getSubfield('a') ? $field->getSubfield('a')->getData() : '') . ($field->getSubfield('t') ? ': ' . $field->getSubfield('t')->getData() : '') . @@ -1806,7 +1808,7 @@ trait SolrMarcFincTrait // handle field 830 differently $fields = $this->getMarcRecord()->getFields('830'); - foreach($fields as $field) { + foreach ($fields as $field) { $parentTitle[] = ($field->getSubfield('a') ? $field->getSubfield('a')->getData() : '') . ($vgSelect($field) ? ' ; ' . $vgSelect($field) : '') @@ -1841,11 +1843,13 @@ trait SolrMarcFincTrait $key = (isset($key) ? $key +1 : 0); $firstindicator = $subjectrow; } - // #5668 #5046 BSZ MARC may contain uppercase subfields but solrmarc set to lowercase them which introduces single char topics - if ($subfields = $field->getSubfields('a')){ + // #5668 #5046 BSZ MARC may contain uppercase subfields but solrmarc set + // to lowercase them which introduces single char topics + if ($subfields = $field->getSubfields('a')) { foreach ($subfields as $subfield) { - if (strlen($subfield->getData()) > 1) + if (strlen($subfield->getData()) > 1) { $retval[$key]['subject'][] = $subfield->getData(); + } } } if ($subfield = $field->getSubfield('t')) { @@ -1902,7 +1906,6 @@ trait SolrMarcFincTrait // check if this field should be skipped if ($skipThisField($result)) { - // Get all the chunks and collect them together: $subfields = $result->getSubfields(); if ($subfields) { @@ -1933,7 +1936,8 @@ trait SolrMarcFincTrait // Remove duplicates and then send back everything we collected: return array_map( - 'unserialize', array_unique(array_map('serialize', $retval)) + 'unserialize', + array_unique(array_map('serialize', $retval)) ); } @@ -1977,7 +1981,6 @@ trait SolrMarcFincTrait */ public function getBarcode() { - $barcodes = []; //$driver = ConnectionManager::connectToCatalog(); @@ -1994,12 +1997,13 @@ trait SolrMarcFincTrait $match = []; $retval = []; foreach ($barcodes as $barcode) { - if (preg_match('/^\((.*)\)(.*)$/', trim($barcode), $match)); - if ( in_array($match[1], $codes) ) { - $retval[] = $match[2]; + if (preg_match('/^\((.*)\)(.*)$/', trim($barcode), $match)) { + if (in_array($match[1], $codes)) { + $retval[] = $match[2]; + } } } // end foreach - if (count($retval) > 0 ) { + if (count($retval) > 0) { return $retval; } } @@ -2037,8 +2041,8 @@ trait SolrMarcFincTrait * and 'scale' * @access public */ - public function getCartographicData() { - + public function getCartographicData() + { // internal vars $retVal = []; $i = 0; @@ -2046,7 +2050,7 @@ trait SolrMarcFincTrait $mapper = ['a' => 'scale', 'c' => 'coordinates']; $fields = $this->getMarcRecord()->getFields('255'); - foreach($fields as $f) { + foreach ($fields as $f) { foreach ($mapper as $subfield => $key) { $sub = $f->getSubField($subfield); if ($sub) { @@ -2095,7 +2099,7 @@ trait SolrMarcFincTrait /** * Get id of related items * - * @params boolean $allow_multiple_results + * @param boolean $allow_multiple_results * * @return string|array * @access protected @@ -2112,21 +2116,22 @@ trait SolrMarcFincTrait /** * Get related records via search index * - * @params int $limit - * @params string $backend_id Search engine + * @param int $limit + * @param string $backend_id Search engine * * @return array * @access protected */ protected function getRelatedRecords($limit, $backend_id = 'Solr') { - $related = $this->getRelatedItems(true); - if (empty($related)) return []; + if (empty($related)) { + return []; + } $query = new Query( - 'isbn' . ':' . implode(' OR ',$related) + 'isbn' . ':' . implode(' OR ', $related) . ' AND NOT id:' . $this->getUniqueID() ); @@ -2209,16 +2214,17 @@ trait SolrMarcFincTrait /** * Get Mediennummer (media number) identifier for Bibliotheca ILS * - * @returns items internal Bibliotheca-ID called "Mediennummer" + * @return array Items internal Bibliotheca-ID called "Mediennummer" * @deprecated Remove when Bibliotheca support ends * @access public */ - public function getMediennummer() { + public function getMediennummer() + { // loop through all existing LocalMarcFieldOfLibrary if ($fields = $this->getMarcRecord()->getFields( - $this->getLocalMarcFieldOfLibrary()) - ) { - foreach($fields as $field) { + $this->getLocalMarcFieldOfLibrary() + )) { + foreach ($fields as $field) { // return the first occurance of $m $field = $field->getSubfield('a'); if ($field) { @@ -2231,8 +2237,14 @@ trait SolrMarcFincTrait } } - public function getTitleUniform() { - + /** + * Get title uniform + * + * @return array + * @access public + */ + public function getTitleUniform() + { $retval = []; foreach (array('130','240') as $pos => $field_name) { if ($field = $this->getMarcRecord()->getField($field_name)) { diff --git a/module/finc/src/finc/RecordDriver/SolrMarcRemote.php b/module/finc/src/finc/RecordDriver/SolrMarcRemote.php index 47cad91a4f41256bfb76717e8dec1c6d840c5d1d..4ad52ee21925e91199d4634e1f0b8d64094a1233 100644 --- a/module/finc/src/finc/RecordDriver/SolrMarcRemote.php +++ b/module/finc/src/finc/RecordDriver/SolrMarcRemote.php @@ -29,8 +29,9 @@ * @link https://vufind.org/wiki/development:plugins:record_drivers Wiki */ namespace finc\RecordDriver; -use VuFindHttp\HttpServiceAwareInterface as HttpServiceAwareInterface, - Zend\Log\LoggerAwareInterface as LoggerAwareInterface; + +use VuFindHttp\HttpServiceAwareInterface as HttpServiceAwareInterface; +use Zend\Log\LoggerAwareInterface as LoggerAwareInterface; /** * Model for MARC records without a fullrecord in Solr. The fullrecord is being @@ -46,7 +47,8 @@ use VuFindHttp\HttpServiceAwareInterface as HttpServiceAwareInterface, * @link https://vufind.org/wiki/configuration:remote_marc_records */ class SolrMarcRemote extends SolrMarc implements - HttpServiceAwareInterface, LoggerAwareInterface + HttpServiceAwareInterface, + LoggerAwareInterface { use \VuFindHttp\HttpServiceAwareTrait; use \VuFind\Log\LoggerAwareTrait; @@ -69,7 +71,9 @@ class SolrMarcRemote extends SolrMarc implements * * @throws \Exception */ - public function __construct($mainConfig = null, $recordConfig = null, + public function __construct( + $mainConfig = null, + $recordConfig = null, $searchSettings = null ) { parent::__construct($mainConfig, $recordConfig, $searchSettings); diff --git a/module/finc/src/finc/RecordDriver/SolrMarcRemoteFinc.php b/module/finc/src/finc/RecordDriver/SolrMarcRemoteFinc.php index b83e619c37856f9ba5dee6bdc2431bc8d3b85ed5..4253a456144d6c16fd444c83ca9e57cef4ffc712 100644 --- a/module/finc/src/finc/RecordDriver/SolrMarcRemoteFinc.php +++ b/module/finc/src/finc/RecordDriver/SolrMarcRemoteFinc.php @@ -73,10 +73,11 @@ class SolrMarcRemoteFinc extends SolrMarcRemote * (omit to use $mainConfig as $recordConfig) * @param \Zend\Config\Config $searchSettings Search-specific configuration file */ - public function __construct($mainConfig = null, $recordConfig = null, - $searchSettings = null - ) - { + public function __construct( + $mainConfig = null, + $recordConfig = null, + $searchSettings = null + ) { parent::__construct($mainConfig, $recordConfig, $searchSettings); if (isset($mainConfig->InstitutionInfo->isil) diff --git a/module/finc/src/finc/RecordTab/AcquisitionPDA.php b/module/finc/src/finc/RecordTab/AcquisitionPDA.php index 5f97c9af3bc7ee6537c90e13b12371be3c5d6da3..f538cb76d3551de5324d0e93e0ddaf1a74625a8e 100644 --- a/module/finc/src/finc/RecordTab/AcquisitionPDA.php +++ b/module/finc/src/finc/RecordTab/AcquisitionPDA.php @@ -60,4 +60,4 @@ class AcquisitionPDA extends \VuFind\RecordTab\AbstractBase { return true; } -} \ No newline at end of file +} diff --git a/module/finc/src/finc/RecordTab/DescriptionLido.php b/module/finc/src/finc/RecordTab/DescriptionLido.php index 00b004fce28cfebe57e41717fb9202b6491b362c..2dc17986fba72d76ed7741874fbcdb556be940ba 100644 --- a/module/finc/src/finc/RecordTab/DescriptionLido.php +++ b/module/finc/src/finc/RecordTab/DescriptionLido.php @@ -60,4 +60,4 @@ class DescriptionLido extends \VuFind\RecordTab\AbstractBase { return true; } -} \ No newline at end of file +} diff --git a/module/finc/src/finc/RecordTab/StaffViewAI.php b/module/finc/src/finc/RecordTab/StaffViewAI.php index e5a97c6e997aea7c7526d781d97443786a2095c9..6f3d75d2de8d34172109135a9810f07c958b2aa0 100644 --- a/module/finc/src/finc/RecordTab/StaffViewAI.php +++ b/module/finc/src/finc/RecordTab/StaffViewAI.php @@ -57,4 +57,4 @@ class StaffViewAI extends \VuFind\RecordTab\AbstractBase { return 'Staff View'; } -} \ No newline at end of file +} diff --git a/module/finc/src/finc/RecordTab/Topics.php b/module/finc/src/finc/RecordTab/Topics.php index f7ad89137da86f32102e69bb789cdec2e2aa804a..493495d1732cb19646c34733f18d60a93d74186d 100644 --- a/module/finc/src/finc/RecordTab/Topics.php +++ b/module/finc/src/finc/RecordTab/Topics.php @@ -57,4 +57,4 @@ class Topics extends \VuFind\RecordTab\AbstractBase { return $this->getRecordDriver()->tryMethod('hasTopics'); } -} \ No newline at end of file +} diff --git a/module/finc/src/finc/Resolver/Driver/Ezb.php b/module/finc/src/finc/Resolver/Driver/Ezb.php index 6be2583c26a0174bd74731797a18de3fdf23f5b0..5ad065432c7ce00f48845b3a683f2bd3a02a7113 100644 --- a/module/finc/src/finc/Resolver/Driver/Ezb.php +++ b/module/finc/src/finc/Resolver/Driver/Ezb.php @@ -36,9 +36,11 @@ */ namespace finc\Resolver\Driver; -use DOMDocument, DOMXpath; +use DOMDocument; +use DOMXpath; use \VuFind\I18n\Translator\TranslatorAwareInterface as TranslatorAwareInterface; use \VuFind\Resolver\Driver\AbstractBase; + /** * EZB Link Resolver Driver * @@ -49,7 +51,7 @@ use \VuFind\Resolver\Driver\AbstractBase; * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link https://vufind.org/wiki/development:plugins:link_resolver_drivers Wiki */ -class Ezb extends AbstractBase implements TranslatorAwareInterface +class Ezb extends AbstractBase implements TranslatorAwareInterface { use \VuFind\I18n\Translator\TranslatorAwareTrait; @@ -205,17 +207,17 @@ class Ezb extends AbstractBase implements TranslatorAwareInterface if (isset($value) && $value !== '') { if ($key == 'rfr_id') { $newKey = 'sid'; - } else if ($key == 'rft.date') { + } elseif ($key == 'rft.date') { $newKey = 'date'; - } else if ($key == 'rft.issn') { + } elseif ($key == 'rft.issn') { $newKey = 'issn'; - } else if ($key == 'rft.volume') { + } elseif ($key == 'rft.volume') { $newKey = 'volume'; - } else if ($key == 'rft.issue') { + } elseif ($key == 'rft.issue') { $newKey = 'issue'; - } else if ($key == 'rft.spage') { + } elseif ($key == 'rft.spage') { $newKey = 'spage'; - } else if ($key == 'rft.pages') { + } elseif ($key == 'rft.pages') { $newKey = 'pages'; } else { $newKey = false; diff --git a/module/finc/src/finc/Rewrite/EblRewrite.php b/module/finc/src/finc/Rewrite/EblRewrite.php index d7a4a3f9515fffe8b55db529aadd18a0fc5850cf..cf4eb276f2a62f6101020af3706c9b3855fbaafb 100644 --- a/module/finc/src/finc/Rewrite/EblRewrite.php +++ b/module/finc/src/finc/Rewrite/EblRewrite.php @@ -71,7 +71,8 @@ class EblRewrite /** * Constructor * - * @param $config + * @param object $config + * * @access public * */ @@ -178,4 +179,4 @@ class EblRewrite { return ($this->time == null) ? time() : $this->time; } -} \ No newline at end of file +} diff --git a/module/finc/src/finc/Rewrite/Factory.php b/module/finc/src/finc/Rewrite/Factory.php index 45c36bc08a7ef0865da470fd200bdc6b8cbb7e43..3b18136411ade74c18899346becdf6c3dcb0e9c8 100644 --- a/module/finc/src/finc/Rewrite/Factory.php +++ b/module/finc/src/finc/Rewrite/Factory.php @@ -52,11 +52,15 @@ class Factory implements FactoryInterface * Create service * * @param ContainerInterface $container Service manager + * @param string $requestedName + * @param mixed $options (array|null) * * @return mixed */ public function __invoke( - ContainerInterface $container, $requestedName, array $options = null + ContainerInterface $container, + $requestedName, + array $options = null ) { // Load configurations: $config = $container->get('VuFind\Config')->get('config'); @@ -66,5 +70,4 @@ class Factory implements FactoryInterface ); return $eblHandler; } - } diff --git a/module/finc/src/finc/Rewrite/PluginFactory.php b/module/finc/src/finc/Rewrite/PluginFactory.php index 4a86a180d41be459b1214b15cb305cb70c6af795..385cb1a66282d1d95726c94ef1d63a4d42891314 100644 --- a/module/finc/src/finc/Rewrite/PluginFactory.php +++ b/module/finc/src/finc/Rewrite/PluginFactory.php @@ -47,4 +47,4 @@ class PluginFactory extends \VuFind\ServiceManager\AbstractPluginFactory { $this->defaultNamespace = 'finc\Rewrite'; } -} \ No newline at end of file +} diff --git a/module/finc/src/finc/Role/PermissionProvider/CatUserType.php b/module/finc/src/finc/Role/PermissionProvider/CatUserType.php index 964de5d70133c933e1d8128df2b304b822724229..8dcdaf0ce3d2d38efb155ebc98edba035cdb29fa 100644 --- a/module/finc/src/finc/Role/PermissionProvider/CatUserType.php +++ b/module/finc/src/finc/Role/PermissionProvider/CatUserType.php @@ -26,6 +26,7 @@ * @link https://vufind.org Main Page */ namespace finc\Role\PermissionProvider; + use VuFind\Auth\ILSAuthenticator; use ZfcRbac\Service\AuthorizationService; diff --git a/module/finc/src/finc/Role/PermissionProvider/Factory.php b/module/finc/src/finc/Role/PermissionProvider/Factory.php index ce83fce04624062fda5fcf9c85c54793c299d1b1..b22572c82178e71d212edcb5cde8ebaf7a042618 100644 --- a/module/finc/src/finc/Role/PermissionProvider/Factory.php +++ b/module/finc/src/finc/Role/PermissionProvider/Factory.php @@ -27,11 +27,8 @@ */ namespace finc\Role\PermissionProvider; -//use Interop\Container\ContainerInterface; - use Zend\ServiceManager\ServiceManager; - /** * Permission Provider Factory Class * diff --git a/module/finc/src/finc/Role/PermissionProvider/IpRangeFoFor.php b/module/finc/src/finc/Role/PermissionProvider/IpRangeFoFor.php index ee4ead8ba2510a601e715952e771d81612d4ef08..134d1a0dad6f9a6697eeb6f36ff4217bb1188263 100644 --- a/module/finc/src/finc/Role/PermissionProvider/IpRangeFoFor.php +++ b/module/finc/src/finc/Role/PermissionProvider/IpRangeFoFor.php @@ -58,8 +58,8 @@ class IpRangeFoFor extends \VuFind\Role\PermissionProvider\IpRange public function getPermissions($options) { // Check if any regex matches.... - $ip = $this->request->getServer()->get('HTTP_X_FORWARDED_FOR') != null - ? $this->request->getServer()->get('HTTP_X_FORWARDED_FOR') + $ip = $this->request->getServer()->get('HTTP_X_FORWARDED_FOR') != null + ? $this->request->getServer()->get('HTTP_X_FORWARDED_FOR') : $this->request->getServer()->get('REMOTE_ADDR'); if ($this->ipAddressUtils->isInRange($ip, (array)$options)) { // Match? Grant to all users (guest or logged in). diff --git a/module/finc/src/finc/Service/Factory.php b/module/finc/src/finc/Service/Factory.php index 96e0e8e5c47a7249ebb67aed191007d39dcb0a79..26f63d3cc441f21cd79a9a4ea1de0c62ed733826 100644 --- a/module/finc/src/finc/Service/Factory.php +++ b/module/finc/src/finc/Service/Factory.php @@ -26,6 +26,7 @@ * @link https://vufind.org/wiki/development Wiki */ namespace finc\Service; + use Zend\ServiceManager\ServiceManager; /** @@ -97,8 +98,10 @@ class Factory public static function getILSHoldLogic(ServiceManager $sm) { return new \finc\ILS\Logic\Holds( - $sm->get('VuFind\ILSAuthenticator'), $sm->get('VuFind\ILSConnection'), - $sm->get('VuFind\HMAC'), $sm->get('VuFind\Config')->get('config') + $sm->get('VuFind\ILSAuthenticator'), + $sm->get('VuFind\ILSConnection'), + $sm->get('VuFind\HMAC'), + $sm->get('VuFind\Config')->get('config') ); } @@ -131,7 +134,11 @@ class Factory ? $config->Cookies->session_name : null; return new \finc\Cookie\CookieManager( - $_COOKIE, $path, $domain, $secure, $session_name + $_COOKIE, + $path, + $domain, + $secure, + $session_name ); } @@ -145,8 +152,8 @@ class Factory public static function getExport(ServiceManager $sm) { return new \finc\Export( - $sm->get('VuFind\Config')->get('config'), - $sm->get('VuFind\Config')->get('export') + $sm->get('VuFind\Config')->get('config'), + $sm->get('VuFind\Config')->get('export') ); } } diff --git a/module/finc/src/finc/Session/ManagerFactory.php b/module/finc/src/finc/Session/ManagerFactory.php index e642cbebf26f53c5500b63e8fb5b2090bebdfd0d..6828c43252ae19c04d2a17d618fc7bc3f621cec2 100644 --- a/module/finc/src/finc/Session/ManagerFactory.php +++ b/module/finc/src/finc/Session/ManagerFactory.php @@ -26,6 +26,7 @@ * @link https://vufind.org/wiki/development Wiki */ namespace finc\Session; + use Zend\ServiceManager\ServiceLocatorInterface; /** diff --git a/module/finc/src/finc/View/Helper/Root/BranchInfo.php b/module/finc/src/finc/View/Helper/Root/BranchInfo.php index 6e42b1c6813efd1f0db123ce95b1a4e84c740838..433c1d729a660b8023068b8b21ff31be6c00ff2f 100644 --- a/module/finc/src/finc/View/Helper/Root/BranchInfo.php +++ b/module/finc/src/finc/View/Helper/Root/BranchInfo.php @@ -39,7 +39,7 @@ use Zend\ServiceManager\ServiceLocatorInterface; * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link https://vufind.org/wiki/development Wiki */ -class BranchInfo extends AbstractHelper +class BranchInfo extends AbstractHelper { /** * YAML branches filename. @@ -77,18 +77,21 @@ class BranchInfo extends AbstractHelper } /** - * @param $branchID - * @return string + * Get branch info + * + * @param int $branchID Identifier of branch + * + * @return string|null */ public function getBranchInfo($branchID) { $yamlData = $this->loadBranches(); if (isset($yamlData) && isset($yamlData[$branchID])) { - return $this->getView() - ->render('Helpers/branchinfo.phtml', - ['info' => $yamlData[$branchID]] - ); + return $this->getView()->render( + 'Helpers/branchinfo.phtml', + ['info' => $yamlData[$branchID]] + ); } return null; } -} \ No newline at end of file +} diff --git a/module/finc/src/finc/View/Helper/Root/Citation.php b/module/finc/src/finc/View/Helper/Root/Citation.php index daa6761f032c5df443a0152150b2255dcbf6eab1..b855634ccfec24a1afdc7291338b1d4c725fc251 100644 --- a/module/finc/src/finc/View/Helper/Root/Citation.php +++ b/module/finc/src/finc/View/Helper/Root/Citation.php @@ -61,8 +61,9 @@ class Citation extends \VuFind\View\Helper\Root\Citation if (empty($primary)) { $additionalAuthors = $driver->tryMethod('getAdditionalAuthors'); if (!empty($additionalAuthors)) { - foreach ($additionalAuthors as $author) + foreach ($additionalAuthors as $author) { $authors[] = $author['name']; + } } } $secondary = $driver->tryMethod('getSecondaryAuthors'); @@ -115,8 +116,15 @@ class Citation extends \VuFind\View\Helper\Root\Citation */ protected function cleanNameDates($str) { - $fincDateStrip = function ($string) { - if (preg_match('/^(\s|.*)\s(fl.\s|d.\s|ca.\s|\*)*\s?(\d{4})\??(\sor\s\d\d?)?\s?(-|–)?\s?(ca.\s|after\s|†)?(\d{1,4})?(.|,)?$/Uu', $string, $match)) { + $cleanDatesRegex = + '/^(\s|.*)\s(fl.\s|d.\s|ca.\s|\*)*\s?(\d{4})\??(\sor\s\d\d?)?\s?' + . '(-|–)?\s?(ca.\s|after\s|†)?(\d{1,4})?(.|,)?$/Uu'; + $fincDateStrip = function ($string, $regex) { + if (preg_match( + $regex, + $string, + $match + )) { return (isset($match[1])) ? trim($match[1]) : $string; } return $string; @@ -130,7 +138,9 @@ class Citation extends \VuFind\View\Helper\Root\Citation return $string; }; - return parent::cleanNameDates($fincGallicaStrip($fincDateStrip($str))); + return parent::cleanNameDates($fincGallicaStrip( + $fincDateStrip($str, $cleanDatesRegex) + )); } /** @@ -187,7 +197,7 @@ class Citation extends \VuFind\View\Helper\Root\Citation $ellipsis = false; foreach ($this->details['authors'] as $author) { $author = $this->abbreviateName($author); - $author = preg_replace('/[\(|\.]/','',$author); + $author = preg_replace('/[\(|\.]/', '', $author); $author = $this->cleanNameDates($author); if (($i + 1 == count($this->details['authors'])) && ($i > 0) @@ -329,7 +339,8 @@ class Citation extends \VuFind\View\Helper\Root\Citation return isset($this->details['primaryauthor']) && is_array($this->details['primaryauthor']) ? $this->stripPunctuation( - $this->cleanNameDates($this->details['primaryauthor'])) + $this->cleanNameDates($this->details['primaryauthor']) + ) : false; } @@ -460,9 +471,12 @@ class Citation extends \VuFind\View\Helper\Root\Citation foreach ($series as $serie) { if (is_array($serie)) { $seriesStr = ( - isset($serie['name']) && !empty($serie['name']) + isset( + $serie['name'] + ) && !empty($serie['name']) ? trim($this->stripPunctuation($serie['name'])) : '' - ) . (isset($serie['name']) && !empty($serie['name']) + ) . ( + isset($serie['name']) && !empty($serie['name']) && isset($serie['number']) && !empty($serie['number']) ? ' ; ' . $serie['number'] : '' ); @@ -491,7 +505,8 @@ class Citation extends \VuFind\View\Helper\Root\Citation if (strlen($this->details['pubDate']) > 4) { try { return $this->dateConverter->convertFromDisplayDate( - 'Y', $this->details['pubDate'] + 'Y', + $this->details['pubDate'] ); } catch (\Exception $e) { // Ignore date errors -- no point in dying here: @@ -509,7 +524,8 @@ class Citation extends \VuFind\View\Helper\Root\Citation * * @return boolean */ - public function isArticle() { + public function isArticle() + { return !empty($this->details['journal']) ? true : false; } -} \ No newline at end of file +} diff --git a/module/finc/src/finc/View/Helper/Root/ExternalCatalogueLink.php b/module/finc/src/finc/View/Helper/Root/ExternalCatalogueLink.php index ca324ba38e40d1270ee35fe20c2e39a5561930c9..e650605d4d91d8e6989108adfab2b429606725a2 100644 --- a/module/finc/src/finc/View/Helper/Root/ExternalCatalogueLink.php +++ b/module/finc/src/finc/View/Helper/Root/ExternalCatalogueLink.php @@ -73,9 +73,9 @@ class ExternalCatalogueLink extends \Zend\View\Helper\AbstractHelper * @param array $extCatConf External catalogue link configuration */ public function __construct( - $config, $extCatConf = [] - ) - { + $config, + $extCatConf = [] + ) { $this->config = $config; $this->extCatConf = $extCatConf; } @@ -163,8 +163,8 @@ class ExternalCatalogueLink extends \Zend\View\Helper\AbstractHelper { foreach ($filter as $driverMethod => $val) { $resType = gettype($res = $this->driver->tryMethod( - ($this->cleanDriverMethod($driverMethod))) - ); + ($this->cleanDriverMethod($driverMethod)) + )); if (false === $this->isFilterExclusive($driverMethod)) { switch ($resType) { case "string": @@ -173,18 +173,20 @@ class ExternalCatalogueLink extends \Zend\View\Helper\AbstractHelper } else { return ($res == $val) ? true : false; } + // no break case "array": if (is_array($val)) { return (count(array_intersect($res, $val)) > 0) ? true : false; } else { return (in_array($val, $res)) ? true : false; } + // no break default: return false; } - // @to-do check if is valid that exclusive filter is poorly the - // negative opposite. Beware of immediately return. } else { + // @to-do check if is valid that exclusive filter is poorly the + // negative opposite. Beware of immediately return. switch ($resType) { case "string": if (is_array($val)) { @@ -192,12 +194,14 @@ class ExternalCatalogueLink extends \Zend\View\Helper\AbstractHelper } else { return ($res == $val) ? false : true; } + // no break case "array": if (is_array($val)) { return (count(array_intersect($res, $val)) > 0) ? false : true; } else { return (in_array($val, $res)) ? false : true; } + // no break default: return false; } @@ -213,10 +217,10 @@ class ExternalCatalogueLink extends \Zend\View\Helper\AbstractHelper * @return boolean * @access protected */ - protected function isFilterExclusive($driverMethod) - { - return (0 < preg_match('/^\-(.*)$/', $driverMethod)) ? true : false; - } + protected function isFilterExclusive($driverMethod) + { + return (0 < preg_match('/^\-(.*)$/', $driverMethod)) ? true : false; + } /** * Clean driver method from additional functions for call of RecordDriver @@ -231,8 +235,5 @@ class ExternalCatalogueLink extends \Zend\View\Helper\AbstractHelper $match = []; return (0 < preg_match('/^\-(.*)$/', $driverMethod, $match)) ? $match[1] : $driverMethod; - } - - -} \ No newline at end of file +} diff --git a/module/finc/src/finc/View/Helper/Root/Factory.php b/module/finc/src/finc/View/Helper/Root/Factory.php index 76937f65d1615c2e73c07483ae03cb8c246c3e31..51b9bd83a577290a26949aa0f10de5d41911e67e 100644 --- a/module/finc/src/finc/View/Helper/Root/Factory.php +++ b/module/finc/src/finc/View/Helper/Root/Factory.php @@ -205,5 +205,4 @@ class Factory empty($externalAccessLinks) ? [] : $externalAccessLinks ); } - } diff --git a/module/finc/src/finc/View/Helper/Root/InterlibraryLoanLink.php b/module/finc/src/finc/View/Helper/Root/InterlibraryLoanLink.php index 28cc57c1d47c9064030539659259fa00ce87d77a..aa640023af779f10544ad05a5436ddab7c81b416 100644 --- a/module/finc/src/finc/View/Helper/Root/InterlibraryLoanLink.php +++ b/module/finc/src/finc/View/Helper/Root/InterlibraryLoanLink.php @@ -44,7 +44,7 @@ class InterlibraryLoanLink extends AbstractHelper /** * Given a record driver, generate a URL for interlibrary loans to SWB. * - * @param \VuFind\RecordDriver\AbstractBase $driver Host Record. + * @param \VuFind\RecordDriver\AbstractBase $driver Host record * * @return string */ @@ -63,7 +63,16 @@ class InterlibraryLoanLink extends AbstractHelper return $url_default; } - public function getBossLink($driver) { + /** + * ??? + * + * @param \VuFind\RecordDriver\AbstractBase $driver Host record + * + * @return string + * @access public + */ + public function getBossLink($driver) + { $url = "https://fernleihe.boss.bsz-bw.de/Search/Results?isil[]=DE-15&hiddenFilters[]=-consortium%3AFL"; $signifiers = []; foreach (['issn', 'isbn'] as $signifier) { @@ -77,11 +86,14 @@ class InterlibraryLoanLink extends AbstractHelper $url .= "&join=OR"; $i = 0; while ($i < count($signifiers)) { - $url .= "&type$i"."[]=ISN&lookfor$i"."[]=".preg_replace('/[^0-9]/','',$signifiers[$i]); + $url .= "&type$i" . "[]=ISN&lookfor$i" . "[]=" . preg_replace( + '/[^0-9]/', + '', + $signifiers[$i] + ); $i++; } } return $url; } } - diff --git a/module/finc/src/finc/View/Helper/Root/OpenUrl.php b/module/finc/src/finc/View/Helper/Root/OpenUrl.php index b90c1e54d957ac4fda27c9444ca27598359d920e..787a92ee61fd4db9eb4d98b8083689f828c00e8a 100644 --- a/module/finc/src/finc/View/Helper/Root/OpenUrl.php +++ b/module/finc/src/finc/View/Helper/Root/OpenUrl.php @@ -94,14 +94,16 @@ class OpenUrl extends \Zend\View\Helper\AbstractHelper * @param array $openUrlRules VuFind OpenURL rules * @param \Zend\Config\Config $config VuFind OpenURL config */ - public function __construct(\VuFind\View\Helper\Root\Context $context, - $openUrlRules, $config = null + public function __construct( + \VuFind\View\Helper\Root\Context $context, + $openUrlRules, + $config = null ) { $this->context = $context; $this->openUrlRules = $openUrlRules; $this->config = $config; if (isset($this->config->General->active_resolvers)) { - $resolvers = explode(',',$this->config->General->active_resolvers); + $resolvers = explode(',', $this->config->General->active_resolvers); foreach ($resolvers as $resolver) { if (isset($this->config->$resolver)) { $this->activeResolvers[] = $resolver; @@ -256,12 +258,14 @@ class OpenUrl extends \Zend\View\Helper\AbstractHelper $this->addImageBasedParams($imagebased, $params); // Render the subtemplate: - $views[] = $this->context->__invoke($this->getView())->renderInContext( - 'Helpers/openurl.phtml', $params - ); + $views[] = + $this->context->__invoke($this->getView())->renderInContext( + 'Helpers/openurl.phtml', + $params + ); } } - return implode("\n",$views); + return implode("\n", $views); } /** diff --git a/module/finc/src/finc/View/Helper/Root/Permission.php b/module/finc/src/finc/View/Helper/Root/Permission.php index 080d9613b88f8da4804894eb29fd4f6028245e7e..1186717e4a7c857f09e22147bf9c5bf3fc4f451c 100644 --- a/module/finc/src/finc/View/Helper/Root/Permission.php +++ b/module/finc/src/finc/View/Helper/Root/Permission.php @@ -66,12 +66,12 @@ class Permission extends \Zend\View\Helper\AbstractHelper /** * Checks if a given permission is granted - * + * * @param string $permission Permission to be checked - * + * * @return bool */ - public function checkPermission ($permission) + public function checkPermission($permission) { if (!($user = $this->isLoggedIn())) { return false; diff --git a/module/finc/src/finc/View/Helper/Root/Record.php b/module/finc/src/finc/View/Helper/Root/Record.php index d54f2d31179631d7f15d4e42c375f8d2b4a5c6eb..e635a5f71ec9108c54864b104812c189ddac958d 100644 --- a/module/finc/src/finc/View/Helper/Root/Record.php +++ b/module/finc/src/finc/View/Helper/Root/Record.php @@ -88,13 +88,12 @@ class Record extends \VuFind\View\Helper\Root\Record * @access public */ public function __construct( - $config = null, + $config, \Zend\View\Helper\Url $helper, \VuFind\Auth\Manager $manager, $rewrite, $resolverConfig - ) - { + ) { parent::__construct($config); $this->url = $helper; $this->manager = $manager; @@ -127,7 +126,8 @@ class Record extends \VuFind\View\Helper\Root\Record public function getRecordIconClass($value, $classfile = 'record-icon-class') { return $this->renderTemplate( - $classfile . '.phtml', ['value' => $value] + $classfile . '.phtml', + ['value' => $value] ); } @@ -171,14 +171,14 @@ class Record extends \VuFind\View\Helper\Root\Record $replaceId = null; // get identifier of record id type switch ($recordType) { - case "id": - $replaceId = $this->driver->getUniqueID(); - break; - case "ppn": - $replaceId = $this->driver->tryMethod('getRID'); - break; - default: - $replaceId = null; + case "id": + $replaceId = $this->driver->getUniqueID(); + break; + case "ppn": + $replaceId = $this->driver->tryMethod('getRID'); + break; + default: + $replaceId = null; } foreach ($accessUrl as $institution => $urlPattern) { // source_id filter @@ -197,8 +197,8 @@ class Record extends \VuFind\View\Helper\Root\Record ? $replaceId : null; break; }; - } + // institution filter if (true === in_array($institution, $institutions) && !empty($replaceId) @@ -221,8 +221,9 @@ class Record extends \VuFind\View\Helper\Root\Record */ public function getLink($type, $lookfor) { - $lookfor = ($type == 'author' - ? $this->removeAuthorDates($lookfor) : $lookfor + $lookfor = ( + $type == 'author' + ? $this->removeAuthorDates($lookfor) : $lookfor ); return parent::getLink($type, $lookfor); } @@ -269,16 +270,17 @@ class Record extends \VuFind\View\Helper\Root\Record * * @return mixed */ - public function removeAuthorDates( $author ) + public function removeAuthorDates($author) { $match = []; - if (preg_match('/^(\s|.*)\s(fl.\s|d.\s|ca.\s|\*)*\s?(\d{4})\??(\sor\s\d\d?)?\s?(-|–)?\s?(ca.\s|after\s|†)?(\d{1,4})?(.|,)?$/Uu', $author, $match)) - { + $regex = + '/^(\s|.*)\s(fl.\s|d.\s|ca.\s|\*)*\s?(\d{4})\??(\sor\s\d\d?)?\s?' + . '(-|–)?\s?(ca.\s|after\s|†)?(\d{1,4})?(.|,)?$/Uu'; + if (preg_match($regex, $author, $match)) { $author = (isset($match[1])) ? trim($match[1]) : $author; } // delete unnormalized characters of gallica ressource with source_id:20 - if (preg_match('/(.*)(\d.*)/Uus', $author, $match)) - { + if (preg_match('/(.*)(\d.*)/Uus', $author, $match)) { $author = (isset($match[1])) ? trim($match[1]) : $author; } return $author; @@ -333,10 +335,9 @@ class Record extends \VuFind\View\Helper\Root\Record // is remove pattern than suppress link refs #10834 if (isset($r['remove'])) { if (0 != preg_match( - '/' . addcslashes($r['remove'], '/') . '/i', - trim($link['url']) - ) - ) { + '/' . addcslashes($r['remove'], '/') . '/i', + trim($link['url']) + )) { unset($link); return; } @@ -346,17 +347,16 @@ class Record extends \VuFind\View\Helper\Root\Record if (isset($r['search']) && isset($r['replace'])) { // check if pattern exists. if at least one match than continue if (0 != preg_match( - '/' . $r['pattern'] . '/i', trim($link['url']) - ) - ) { + '/' . $r['pattern'] . '/i', + trim($link['url']) + )) { // prepare search pattern // should be free of conflicting meta characters $pattern = str_replace(['.'], ['\.'], $r['search']); $pattern = '/(' . $pattern . ')/i'; // replace it only one time - $link['url'] - = preg_replace( + $link['url'] = preg_replace( $pattern, trim($r['replace']), trim($link['url']), @@ -374,15 +374,13 @@ class Record extends \VuFind\View\Helper\Root\Record if (isset($r['method']) && method_exists($this, $r['method'])) { /* && $count > 0) { @todo fix */ if (0 != preg_match( - '/' . $r['pattern'] . '/i', trim($link['url']) - ) - ) { + '/' . $r['pattern'] . '/i', + trim($link['url']) + )) { $link['url'] = $this->$r['method']($link['url']); } } // end if isset method - } // end if isset pattern - } // end foreach return $link; } @@ -400,7 +398,9 @@ class Record extends \VuFind\View\Helper\Root\Record if (false === ($user = $this->manager->isLoggedIn())) { $id = $this->driver->getUniqueId(); return $this->url->__invoke( - 'record-ebllink', [], ['query' => ['link' => $link, 'id' => $id]] + 'record-ebllink', + [], + ['query' => ['link' => $link, 'id' => $id]] ); } $url = $this->rewrite->resolveLink($link, $user); @@ -434,20 +434,28 @@ class Record extends \VuFind\View\Helper\Root\Record $highlightedTitle = $this->driver->tryMethod('getHighlightedTitle'); $titleRegexPattern = '/(\s[\/\.:]\s*)*$/'; - $shortTitle = preg_replace( - $titleRegexPattern, '', trim($this->driver->tryMethod('getShortTitle')) + $shortTitle = preg_replace( + $titleRegexPattern, + '', + trim($this->driver->tryMethod('getShortTitle')) ); - $subTitle = preg_replace( - $titleRegexPattern, '', trim($this->driver->tryMethod('getSubTitle')) + $subTitle = preg_replace( + $titleRegexPattern, + '', + trim($this->driver->tryMethod('getSubTitle')) ); $sectionTitle = preg_replace( - $titleRegexPattern, '', trim($this->driver->tryMethod('getTitleSection')) + $titleRegexPattern, + '', + trim($this->driver->tryMethod('getTitleSection')) ); $title = (!empty($shortTitle) ? $shortTitle : preg_replace( - $titleRegexPattern, '', trim($this->driver->tryMethod('getTitle')) - )) . - (!empty($subTitle) ? ': ' . $subTitle : '') . - (!empty($sectionTitle) ? ', ' . $sectionTitle : ''); + $titleRegexPattern, + '', + trim($this->driver->tryMethod('getTitle')) + )) . + (!empty($subTitle) ? ': ' . $subTitle : '') . + (!empty($sectionTitle) ? ', ' . $sectionTitle : ''); if (!empty($highlightedTitle)) { $highlight = $this->getView()->plugin('highlight'); @@ -463,8 +471,14 @@ class Record extends \VuFind\View\Helper\Root\Record return $transEsc('Title not available'); } - public function getOnlineEditions() { - + /** + * Get online editions + * + * @return array + * @access public + */ + public function getOnlineEditions() + { $online_keys = array( "Online-Ausg.", "Online-Ausg.:", @@ -475,7 +489,8 @@ class Record extends \VuFind\View\Helper\Root\Record $onlineEditions = []; $recordLinkHelper = $this->getView()->RecordLink(); foreach ($this->driver->tryMethod('getAdditionals') as $add) { - if (isset($add['identifier']) && in_array($add['identifier'],$online_keys)) { + if (isset($add['identifier']) + && in_array($add['identifier'], $online_keys)) { if (isset($add['id'])) { $link = $recordLinkHelper->getTabUrl($add['id'], 'Holdings'); if (!empty($link)) { @@ -487,5 +502,4 @@ class Record extends \VuFind\View\Helper\Root\Record } return $onlineEditions; } - -} \ No newline at end of file +} diff --git a/module/finc/src/finc/View/Helper/Root/RecordDataFormatterFactory.php b/module/finc/src/finc/View/Helper/Root/RecordDataFormatterFactory.php index 176918827685f039bf43f0c0f030f609dc4c8d96..b6b8c99c5c10b6c32178e92a74ce703e8d5a0a48 100644 --- a/module/finc/src/finc/View/Helper/Root/RecordDataFormatterFactory.php +++ b/module/finc/src/finc/View/Helper/Root/RecordDataFormatterFactory.php @@ -55,21 +55,25 @@ class RecordDataFormatterFactory $helper = new RecordDataFormatter(); $helper->setDefaults( - 'collection-info', [$this, 'getDefaultCollectionInfoSpecs'] + 'collection-info', + [$this, 'getDefaultCollectionInfoSpecs'] ); $helper->setDefaults( - 'collection-record', [$this, 'getDefaultCollectionRecordSpecs'] + 'collection-record', + [$this, 'getDefaultCollectionRecordSpecs'] ); $helper->setDefaults('core', [$this, 'getDefaultCoreSpecs']); $helper->setDefaults( - 'description', [$this, 'getDefaultDescriptionSpecs'] + 'description', + [$this, 'getDefaultDescriptionSpecs'] ); $helper->setDefaults('core-ai', [$this, 'getAiCoreSpecs']); $helper->setDefaults('core-lido', [$this, 'getLidoCoreSpecs']); $helper->setDefaults( - 'description-lido', [$this, 'getLidoDescriptionSpecs'] + 'description-lido', + [$this, 'getLidoDescriptionSpecs'] ); $helper->setDefaults('core-marc', [$this, 'getMarcCoreSpecs']); @@ -85,7 +89,9 @@ class RecordDataFormatterFactory { $spec = new RecordDataFormatter\SpecBuilder(); $spec->setTemplateLine( - 'Journal Title', 'getContainerTitle', 'data-containerTitle.phtml' + 'Journal Title', + 'getContainerTitle', + 'data-containerTitle.phtml' ); $spec->setTemplateLine( 'Authors/Corporations', @@ -101,7 +107,9 @@ class RecordDataFormatterFactory ] ); $spec->setLine( - 'Edition', 'getEdition', null, + 'Edition', + 'getEdition', + null, ['prefix' => '<span property="bookEdition">', 'suffix' => '</span>'] ); $spec->setTemplateLine( @@ -110,11 +118,15 @@ class RecordDataFormatterFactory 'data-jTitle.phtml' ); $spec->setLine( - 'Format', 'getFormats', 'RecordHelper', + 'Format', + 'getFormats', + 'RecordHelper', ['helperMethod' => 'getFormatList'] ); $spec->setTemplateLine( - 'Language', 'getLanguages', 'data-transEscCommaSepLang.phtml' + 'Language', + 'getLanguages', + 'data-transEscCommaSepLang.phtml' ); $spec->setTemplateLine( 'Published', @@ -122,19 +134,28 @@ class RecordDataFormatterFactory 'data-publicationDetails.phtml' ); $spec->setLine( - 'Series', 'getSeries', null, ['recordLink' => 'series'] + 'Series', + 'getSeries', + null, + ['recordLink' => 'series'] ); $spec->setTemplateLine( - 'Subjects', 'getAllSubjectHeadings', 'data-allSubjectHeadings.phtml' + 'Subjects', + 'getAllSubjectHeadings', + 'data-allSubjectHeadings.phtml' ); $spec->setTemplateLine( - 'child_records', 'getChildRecordCount', 'data-childRecords.phtml', + 'child_records', + 'getChildRecordCount', + 'data-childRecords.phtml', ['allowZero' => false] ); /* finc: remove 'Online Access' in record-details #13770 - VE */ /* $spec->setTemplateLine('Online Access', true, 'data-onlineAccess.phtml'); */ $spec->setTemplateLine( - 'Related Items', 'getAllRecordLinks', 'data-allRecordLinks.phtml' + 'Related Items', + 'getAllRecordLinks', + 'data-allRecordLinks.phtml' ); $spec->setTemplateLine('Tags', true, 'data-tags.phtml'); return $spec->getArray(); @@ -162,28 +183,42 @@ class RecordDataFormatterFactory ] ); $spec->setTemplateLine( - 'Title', 'getTitleDetails', 'data-titleDetails.phtml' + 'Title', + 'getTitleDetails', + 'data-titleDetails.phtml' ); $spec->setTemplateLine( - 'Dates of publication', 'getDateSpan', 'data-escapeHtml.phtml' + 'Dates of publication', + 'getDateSpan', + 'data-escapeHtml.phtml' ); $spec->setTemplateLine( - 'Summary', 'getSummary', 'data-escapeHtml.phtml' + 'Summary', + 'getSummary', + 'data-escapeHtml.phtml' ); $spec->setTemplateLine( - 'Published', 'getPublicationDetails', 'data-publicationDetails.phtml' + 'Published', + 'getPublicationDetails', + 'data-publicationDetails.phtml' ); $spec->setLine( - 'Edition', 'getEdition', null, + 'Edition', + 'getEdition', + null, ['prefix' => '<span property="bookEdition">', 'suffix' => '</span>'] ); $spec->setTemplateLine( - 'Subjects', 'getAllSubjectHeadings', 'data-allSubjectHeadings.phtml' + 'Subjects', + 'getAllSubjectHeadings', + 'data-allSubjectHeadings.phtml' ); /* finc: remove 'Online Access' in record-details #13770 - VE */ /* $spec->setTemplateLine('Online Access', true, 'data-onlineAccess.phtml'); */ $spec->setTemplateLine( - 'Item Description', 'getGeneralNotes', 'data-escapeHtml.phtml' + 'Item Description', + 'getGeneralNotes', + 'data-escapeHtml.phtml' ); $spec->setTemplateLine( 'Production Credits', @@ -196,10 +231,14 @@ class RecordDataFormatterFactory 'data-hierarchyParentTitle.phtml' ); $spec->setTemplateLine( - 'ISBN', 'getISBNs', 'data-isbn.phtml' + 'ISBN', + 'getISBNs', + 'data-isbn.phtml' ); $spec->setTemplateLine( - 'ISSN', 'getISSNs', 'data-issn.phtml' + 'ISSN', + 'getISSNs', + 'data-issn.phtml' ); $spec->setTemplateLine( 'Notes', @@ -210,18 +249,24 @@ class RecordDataFormatterFactory ] ); $spec->setLine( - 'Format', 'getFormats', 'RecordHelper', + 'Format', + 'getFormats', + 'RecordHelper', ['helperMethod' => 'getFormatList'] ); $spec->setTemplateLine( - 'Language', 'getLanguages', 'data-transEscCommaSepLang.phtml' + 'Language', + 'getLanguages', + 'data-transEscCommaSepLang.phtml' ); $spec->setTemplateLine( 'Additionals', 'getAdditionals', 'data-additionals.phtml', [ - 'labelFunction' => function() { return null; } + 'labelFunction' => function () { + return null; + } ] ); return $spec->getArray(); @@ -250,17 +295,25 @@ class RecordDataFormatterFactory ] ); $spec->setTemplateLine( - 'Language', 'getLanguages', 'data-transEscCommaSepLang.phtml' + 'Language', + 'getLanguages', + 'data-transEscCommaSepLang.phtml' ); $spec->setLine( - 'Format', 'getFormats', 'RecordHelper', + 'Format', + 'getFormats', + 'RecordHelper', ['helperMethod' => 'getFormatList'] ); $spec->setTemplateLine( - 'Access', 'getAccessRestrictions', 'data-escapeHtml.phtml' + 'Access', + 'getAccessRestrictions', + 'data-escapeHtml.phtml' ); $spec->setTemplateLine( - 'Related Items', 'getRelationshipNotes', 'data-escapeHtml.phtml' + 'Related Items', + 'getRelationshipNotes', + 'data-escapeHtml.phtml' ); return $spec->getArray(); } @@ -274,16 +327,26 @@ class RecordDataFormatterFactory { $spec = new RecordDataFormatter\SpecBuilder(); $spec->setTemplateLine( - 'Published in', 'getContainerTitle', 'data-containerTitle.phtml' + 'Published in', + 'getContainerTitle', + 'data-containerTitle.phtml' ); $spec->setLine( - 'New Title', 'getNewerTitles', null, ['recordLink' => 'title'] + 'New Title', + 'getNewerTitles', + null, + ['recordLink' => 'title'] ); $spec->setLine( - 'Previous Title', 'getPreviousTitles', null, ['recordLink' => 'title'] + 'Previous Title', + 'getPreviousTitles', + null, + ['recordLink' => 'title'] ); $spec->setTemplateLine( - 'Authors/Corporations', 'getDeduplicatedAuthors', 'data-authors.phtml', + 'Authors/Corporations', + 'getDeduplicatedAuthors', + 'data-authors.phtml', [ 'useCache' => true, 'context' => [ @@ -294,16 +357,24 @@ class RecordDataFormatterFactory ] ); $spec->setTemplateLine( - 'Title', 'getTitleDetails', 'data-titleDetails.phtml' + 'Title', + 'getTitleDetails', + 'data-titleDetails.phtml' ); $spec->setTemplateLine( - 'Title Uniform', 'getTitleUniform', 'data-titleUniform.phtml', + 'Title Uniform', + 'getTitleUniform', + 'data-titleUniform.phtml', [ - 'labelFunction' => function() { return null; } + 'labelFunction' => function () { + return null; + } ] ); $spec->setLine( - 'Edition', 'getEdition', null, + 'Edition', + 'getEdition', + null, ['prefix' => '<span property="bookEdition">', 'suffix' => '</span>'] ); $spec->setLine( @@ -312,11 +383,15 @@ class RecordDataFormatterFactory 'data-escapeHtmlCommaSep.phtml' ); $spec->setLine( - 'Format', 'getFormats', 'RecordHelper', + 'Format', + 'getFormats', + 'RecordHelper', ['helperMethod' => 'getFormatList'] ); $spec->setTemplateLine( - 'Language', 'getLanguages', 'data-transEscCommaSepLang.phtml' + 'Language', + 'getLanguages', + 'data-transEscCommaSepLang.phtml' ); $spec->setTemplateLine( 'Published', @@ -329,23 +404,31 @@ class RecordDataFormatterFactory 'data-hierarchyParentTitle.phtml' ); $spec->setTemplateLine( - 'Subjects', 'getAllSubjectHeadings', 'data-allSubjectHeadings.phtml' + 'Subjects', + 'getAllSubjectHeadings', + 'data-allSubjectHeadings.phtml' ); $spec->setTemplateLine( - 'child_records', 'getChildRecordCount', 'data-childRecords.phtml', + 'child_records', + 'getChildRecordCount', + 'data-childRecords.phtml', ['allowZero' => false] ); /* finc: remove 'Online Access' in record-details #13770 - VE */ /* $spec->setTemplateLine('Online Access', true, 'data-onlineAccess.phtml'); */ $spec->setTemplateLine( - 'Related Items', 'getAllRecordLinks', 'data-allRecordLinks.phtml' + 'Related Items', + 'getAllRecordLinks', + 'data-allRecordLinks.phtml' ); $spec->setTemplateLine( 'Additionals', 'getAdditionals', 'data-additionals.phtml', [ - 'labelFunction' => function() { return null; } + 'labelFunction' => function () { + return null; + } ] ); $spec->setTemplateLine( @@ -358,7 +441,6 @@ class RecordDataFormatterFactory 'getOtherRelationshipEntry', 'data-otherRelationshipEntry.phtml', [ - ] ); $spec->setTemplateLine( @@ -382,13 +464,19 @@ class RecordDataFormatterFactory { $spec = new RecordDataFormatter\SpecBuilder(); $spec->setTemplateLine( - 'Summary', 'getSummary', 'data-escapeHtml.phtml' + 'Summary', + 'getSummary', + 'data-escapeHtml.phtml' ); $spec->setTemplateLine( - 'Dates of publication', 'getDateSpan', 'data-escapeHtml.phtml' + 'Dates of publication', + 'getDateSpan', + 'data-escapeHtml.phtml' ); $spec->setTemplateLine( - 'Item Description', 'getGeneralNotes', 'data-escapeHtml.phtml' + 'Item Description', + 'getGeneralNotes', + 'data-escapeHtml.phtml' ); $spec->setTemplateLine( 'Physical Description', @@ -401,16 +489,24 @@ class RecordDataFormatterFactory 'data-escapeHtml.phtml' ); $spec->setTemplateLine( - 'Playing Time', 'getPlayingTimes', 'data-escapeHtml.phtml' + 'Playing Time', + 'getPlayingTimes', + 'data-escapeHtml.phtml' ); $spec->setTemplateLine( - 'Format', 'getSystemDetails', 'data-escapeHtml.phtml' + 'Format', + 'getSystemDetails', + 'data-escapeHtml.phtml' ); $spec->setTemplateLine( - 'Audience', 'getTargetAudienceNotes', 'data-escapeHtml.phtml' + 'Audience', + 'getTargetAudienceNotes', + 'data-escapeHtml.phtml' ); $spec->setTemplateLine( - 'Awards', 'getAwards', 'data-escapeHtml.phtml' + 'Awards', + 'getAwards', + 'data-escapeHtml.phtml' ); $spec->setTemplateLine( 'Production Credits', @@ -418,28 +514,44 @@ class RecordDataFormatterFactory 'data-escapeHtml.phtml' ); $spec->setTemplateLine( - 'Bibliography', 'getBibliographyNotes', 'data-escapeHtml.phtml' + 'Bibliography', + 'getBibliographyNotes', + 'data-escapeHtml.phtml' ); $spec->setTemplateLine( - 'ISBN', 'getISBNs', 'data-isbn.phtml' + 'ISBN', + 'getISBNs', + 'data-isbn.phtml' ); $spec->setTemplateLine( - 'ISSN', 'getISSNs', 'data-issn.phtml' + 'ISSN', + 'getISSNs', + 'data-issn.phtml' ); $spec->setTemplateLine( - 'DOI', 'getCleanDOI', 'data-escapeHtml.phtml' + 'DOI', + 'getCleanDOI', + 'data-escapeHtml.phtml' ); $spec->setTemplateLine( - 'EISSN', 'getEISSNs', 'data-escapeHtml.phtml' + 'EISSN', + 'getEISSNs', + 'data-escapeHtml.phtml' ); $spec->setTemplateLine( - 'Related Items', 'getRelationshipNotes', 'data-escapeHtml.phtml' + 'Related Items', + 'getRelationshipNotes', + 'data-escapeHtml.phtml' ); $spec->setTemplateLine( - 'Access', 'getAccessRestrictions', 'data-escapeHtml.phtml' + 'Access', + 'getAccessRestrictions', + 'data-escapeHtml.phtml' ); $spec->setTemplateLine( - 'Finding Aid', 'getFindingAids', 'data-escapeHtml.phtml' + 'Finding Aid', + 'getFindingAids', + 'data-escapeHtml.phtml' ); $spec->setTemplateLine( 'Publication_Place', @@ -447,7 +559,9 @@ class RecordDataFormatterFactory 'data-escapeHtml.phtml' ); $spec->setTemplateLine( - 'Author Notes', true, 'data-authorNotes.phtml' + 'Author Notes', + true, + 'data-authorNotes.phtml' ); $spec->setTemplateLine( 'Call Number', @@ -474,7 +588,9 @@ class RecordDataFormatterFactory { $spec = new RecordDataFormatter\SpecBuilder(); $spec->setTemplateLine( - 'Originators', 'getDeduplicatedAuthors', 'data-authors.phtml', + 'Originators', + 'getDeduplicatedAuthors', + 'data-authors.phtml', [ 'useCache' => true, 'labelFunction' => function ($data) { @@ -491,7 +607,9 @@ class RecordDataFormatterFactory ] ); $spec->setTemplateLine( - 'Corporate Originator', 'getDeduplicatedAuthors', 'data-authors.phtml', + 'Corporate Originator', + 'getDeduplicatedAuthors', + 'data-authors.phtml', [ 'useCache' => true, 'labelFunction' => function ($data) { @@ -508,7 +626,9 @@ class RecordDataFormatterFactory ] ); $spec->setTemplateLine( - 'Other Originators', 'getDeduplicatedAuthors', 'data-authors.phtml', + 'Other Originators', + 'getDeduplicatedAuthors', + 'data-authors.phtml', [ 'useCache' => true, 'context' => [ @@ -521,50 +641,66 @@ class RecordDataFormatterFactory ] ); $spec->setTemplateLine( - 'Subject Detail', 'getSubjectDetails', 'data-escapeHtml.phtml', + 'Subject Detail', + 'getSubjectDetails', + 'data-escapeHtml.phtml', [ 'context' => ['class' => 'recordSubjects'] ] ); $spec->setTemplateLine( - 'Subject Place', 'getSubjectPlaces', 'data-escapeHtml.phtml', + 'Subject Place', + 'getSubjectPlaces', + 'data-escapeHtml.phtml', [ 'context' => ['class' => 'recordSubjects'] ] ); $spec->setTemplateLine( - 'Subject Date', 'getSubjectDates', 'data-escapeHtml.phtml', + 'Subject Date', + 'getSubjectDates', + 'data-escapeHtml.phtml', [ 'context' => ['class' => 'recordSubjects'] ] ); $spec->setTemplateLine( - 'Subject Actor', 'getSubjectActors', 'data-escapeHtml.phtml', + 'Subject Actor', + 'getSubjectActors', + 'data-escapeHtml.phtml', [ 'context' => ['class' => 'recordSubjects'] ] ); $spec->setTemplateLine( - 'Institution', 'getInstitutions', 'data-institutions.phtml', + 'Institution', + 'getInstitutions', + 'data-institutions.phtml', [ 'context' => ['class' => 'recordInstitution'] ] ); $spec->setTemplateLine( - 'Inventory ID', 'getIdentifier', 'data-escapeHtml.phtml', + 'Inventory ID', + 'getIdentifier', + 'data-escapeHtml.phtml', [ 'context' => ['class' => 'recordIdentifier'] ] ); $spec->setTemplateLine( - 'Inventory ID', 'getIdentifier', 'data-escapeHtml.phtml', + 'Inventory ID', + 'getIdentifier', + 'data-escapeHtml.phtml', [ 'context' => ['class' => 'recordIdentifier'] ] ); $spec->setTemplateLine( - 'Measurements', 'getMeasurements', 'data-escapeHtml.phtml', + 'Measurements', + 'getMeasurements', + 'data-escapeHtml.phtml', [ 'context' => ['class' => 'recordMeasurements'] ] @@ -578,13 +714,17 @@ class RecordDataFormatterFactory ] ); $spec->setTemplateLine( - 'Collection', 'getCollections', 'data-escapeHtml.phtml', + 'Collection', + 'getCollections', + 'data-escapeHtml.phtml', [ 'context' => ['class' => 'recordCollection'] ] ); $spec->setLine( - 'Object type', 'getFormats', 'RecordHelper', + 'Object type', + 'getFormats', + 'RecordHelper', ['helperMethod' => 'getFormatList'] ); $spec->setTemplateLine( @@ -596,37 +736,54 @@ class RecordDataFormatterFactory ] ); $spec->setTemplateLine( - 'Other ID', 'getLocalIdentifiers', 'data-escapeHtml.phtml', + 'Other ID', + 'getLocalIdentifiers', + 'data-escapeHtml.phtml', [ 'context' => ['class' => 'recordIdentifiers'] ] ); $spec->setTemplateLine( - 'Events', true, 'data-events.phtml', + 'Events', + true, + 'data-events.phtml', [ - 'labelFunction' => function() { return null; } + 'labelFunction' => function () { + return null; + } ] ); // , context: "recordEvents" $spec->setTemplateLine( - 'Language', 'getLanguages','data-transEscCommaSepLang.phtml' + 'Language', + 'getLanguages', + 'data-transEscCommaSepLang.phtml' ); $spec->setTemplateLine( - 'Time of origin', 'getDateSpan', 'data-dateSpan.phtml' + 'Time of origin', + 'getDateSpan', + 'data-dateSpan.phtml' ); - $spec->setTemplateLine('Edition', 'getEdition', 'data-escapeHtml.phtml', + $spec->setTemplateLine( + 'Edition', + 'getEdition', + 'data-escapeHtml.phtml', [ 'prefix' => '<span property="bookEdition">', 'suffix' => '</span>' ] ); $spec->setTemplateLine( - 'Subjects', 'getAllSubjectHeadings', 'data-allSubjectHeadings.phtml' + 'Subjects', + 'getAllSubjectHeadings', + 'data-allSubjectHeadings.phtml' ); /* finc: remove 'Online Access' in record-details #13770 -VE */ /* $spec->setTemplateLine('Online Access', true, 'data-onlineAccess.phtml'); */ $spec->setTemplateLine( - 'Related Items', 'getAllRecordLinks', 'data-allRecordLinks.phtml' + 'Related Items', + 'getAllRecordLinks', + 'data-allRecordLinks.phtml' ); return $spec->getArray(); } @@ -640,10 +797,14 @@ class RecordDataFormatterFactory { $spec = new RecordDataFormatter\SpecBuilder(); $spec->setTemplateLine( - 'Time of origin', 'getDateSpan', 'data-dateSpan.phtml' + 'Time of origin', + 'getDateSpan', + 'data-dateSpan.phtml' ); $spec->setTemplateLine( - 'Access', 'getAccessNote','data-accessNote.phtml' + 'Access', + 'getAccessNote', + 'data-accessNote.phtml' ); return $spec->getArray(); } @@ -657,13 +818,19 @@ class RecordDataFormatterFactory { $spec = new RecordDataFormatter\SpecBuilder(); $spec->setTemplateLine( - 'Published in', 'getContainerTitle', 'data-containerTitle.phtml' + 'Published in', + 'getContainerTitle', + 'data-containerTitle.phtml' ); $spec->setLine( - 'New Title', 'getNewerTitles', 'data-linkViaFincId.phtml' + 'New Title', + 'getNewerTitles', + 'data-linkViaFincId.phtml' ); $spec->setLine( - 'Previous Title', 'getPreviousTitles', 'data-linkViaFincId.phtml' + 'Previous Title', + 'getPreviousTitles', + 'data-linkViaFincId.phtml' ); $spec->setTemplateLine( 'Authors/Corporations', @@ -679,16 +846,24 @@ class RecordDataFormatterFactory ] ); $spec->setTemplateLine( - 'Title', 'getTitleDetails', 'data-titleDetails.phtml' + 'Title', + 'getTitleDetails', + 'data-titleDetails.phtml' ); $spec->setTemplateLine( - 'Title Uniform', 'getTitleUniform', 'data-titleUniform.phtml', + 'Title Uniform', + 'getTitleUniform', + 'data-titleUniform.phtml', [ - 'labelFunction' => function() { return null; } + 'labelFunction' => function () { + return null; + } ] ); $spec->setLine( - 'Edition', 'getEdition', null, + 'Edition', + 'getEdition', + null, ['prefix' => '<span property="bookEdition">', 'suffix' => '</span>'] ); $spec->setLine( @@ -697,11 +872,15 @@ class RecordDataFormatterFactory 'data-escapeHtmlCommaSep.phtml' ); $spec->setLine( - 'Format', 'getFormats', 'RecordHelper', + 'Format', + 'getFormats', + 'RecordHelper', ['helperMethod' => 'getFormatList'] ); $spec->setTemplateLine( - 'Language', 'getLanguages', 'data-transEscCommaSepLang.phtml' + 'Language', + 'getLanguages', + 'data-transEscCommaSepLang.phtml' ); $spec->setTemplateLine( 'Published', @@ -719,23 +898,31 @@ class RecordDataFormatterFactory 'data-hierarchyParentTitle.phtml' ); $spec->setTemplateLine( - 'Subjects', 'getAllSubjectHeadings', 'data-allSubjectHeadings.phtml' + 'Subjects', + 'getAllSubjectHeadings', + 'data-allSubjectHeadings.phtml' ); $spec->setTemplateLine( - 'child_records', 'getChildRecordCount', 'data-childRecords.phtml', + 'child_records', + 'getChildRecordCount', + 'data-childRecords.phtml', ['allowZero' => false] ); /* finc: remove 'Online Access' in record-details #13770 - VE */ /* $spec->setTemplateLine('Online Access', true, 'data-onlineAccess.phtml'); */ $spec->setTemplateLine( - 'Related Items', 'getAllRecordLinks', 'data-allRecordLinks.phtml' + 'Related Items', + 'getAllRecordLinks', + 'data-allRecordLinks.phtml' ); $spec->setTemplateLine( 'Local Subjects', 'getLocalSubjects', 'data-localSubjects.phtml', [ - 'labelFunction' => function() { return 'Subject'; } + 'labelFunction' => function () { + return 'Subject'; + } ] ); $spec->setTemplateLine( @@ -748,7 +935,9 @@ class RecordDataFormatterFactory 'getOtherRelationshipEntry', 'data-otherRelationshipEntry.phtml', [ - 'labelFunction' => function() { return null; } + 'labelFunction' => function () { + return null; + } ] ); $spec->setTemplateLine( @@ -762,6 +951,4 @@ class RecordDataFormatterFactory $spec->setTemplateLine('Tags', true, 'data-tags.phtml'); return $spec->getArray(); } - - } diff --git a/module/finc/src/finc/View/Helper/Root/RecordLink.php b/module/finc/src/finc/View/Helper/Root/RecordLink.php index 53fd5f7820aec28b079f0d360fd5ef28c17b2ea5..4162fa982ebf4812e5ed97ae3c0da70be8960566 100644 --- a/module/finc/src/finc/View/Helper/Root/RecordLink.php +++ b/module/finc/src/finc/View/Helper/Root/RecordLink.php @@ -28,10 +28,10 @@ */ namespace finc\View\Helper\Root; -use VuFindSearch\Query\Query as Query, - VuFind\Record\Loader as Loader, - VuFind\Record\Router as Router, - VuFindSearch\Service as SearchService; +use VuFindSearch\Query\Query as Query; +use VuFind\Record\Loader as Loader; +use VuFind\Record\Router as Router; +use VuFindSearch\Service as SearchService; /** * Record link view helper @@ -71,7 +71,7 @@ class RecordLink extends \VuFind\View\Helper\Root\RecordLink * * @param \VuFind\Record\Router $router Record router * @param \VuFind\Record\Loader $loader Record loader - * @param \VuFindSearch\Service $ss Search service + * @param SearchService $ss Search service */ public function __construct( Router $router, diff --git a/module/finc/src/finc/View/Helper/Root/ResultFeed.php b/module/finc/src/finc/View/Helper/Root/ResultFeed.php index 6eebc54b7a8b9f32cd3cdabd0899967bcc23da8e..29bb1d2fff9719665c15fa30ce928956cdb83591 100644 --- a/module/finc/src/finc/View/Helper/Root/ResultFeed.php +++ b/module/finc/src/finc/View/Helper/Root/ResultFeed.php @@ -26,8 +26,9 @@ * @link https://vufind.org/wiki/development Wiki */ namespace finc\View\Helper\Root; -use DateTime, - Zend\Feed\Writer\Feed; + +use DateTime; +use Zend\Feed\Writer\Feed; /** * "Results as feed" view helper diff --git a/module/finc/src/finc/XSLT/Processor.php b/module/finc/src/finc/XSLT/Processor.php index fb4b3ecd29a39c4f0c0a621249538a5214167d69..f575cde8efacb235eb39b362bbc7a0f47d107423 100644 --- a/module/finc/src/finc/XSLT/Processor.php +++ b/module/finc/src/finc/XSLT/Processor.php @@ -26,7 +26,9 @@ * @link https://vufind.org/wiki/ Wiki */ namespace finc\XSLT; -use DOMDocument, XSLTProcessor; + +use DOMDocument; +use XSLTProcessor; /** * VuFind XSLT wrapper diff --git a/module/finc/tests/bootstrap.php b/module/finc/tests/bootstrap.php index 16fcfc6117386c4948f11a0a99c05aca2d3e95b3..a03458275c1d520c2a3d245360b0c8fdfe9699d9 100644 --- a/module/finc/tests/bootstrap.php +++ b/module/finc/tests/bootstrap.php @@ -90,7 +90,8 @@ class Bootstrap } } $zf2ModulePaths = implode(PATH_SEPARATOR, $zf2ModulePaths) . PATH_SEPARATOR; - $zf2ModulePaths .= getenv('ZF2_MODULES_TEST_PATHS') ?: (defined('ZF2_MODULES_TEST_PATHS') ? ZF2_MODULES_TEST_PATHS : ''); + $zf2ModulePaths .= getenv('ZF2_MODULES_TEST_PATHS') + ?: (defined('ZF2_MODULES_TEST_PATHS') ? ZF2_MODULES_TEST_PATHS : ''); static::initAutoloader(); // use ModuleManager to load this module and it's dependencies $baseConfig = [ @@ -210,4 +211,4 @@ define('APPLICATION_PATH', realpath(dirname(__DIR__) . '/../..')); define('FINC_TESTS_PATH', __DIR__); chdir(APPLICATION_PATH); -Bootstrap::init(); \ No newline at end of file +Bootstrap::init(); diff --git a/module/finc/tests/unit-tests/src/fincTest/RecordDriver/SolrMarcFincTestCase.php b/module/finc/tests/unit-tests/src/fincTest/RecordDriver/SolrMarcFincTestCase.php index b6b9c07650b2a34187fac31c3c752e5876767ca6..886eb7aecb2ba0bb3418ce78c8af9fa49a6523cd 100644 --- a/module/finc/tests/unit-tests/src/fincTest/RecordDriver/SolrMarcFincTestCase.php +++ b/module/finc/tests/unit-tests/src/fincTest/RecordDriver/SolrMarcFincTestCase.php @@ -27,8 +27,10 @@ * @link http://www.swissbib.org */ namespace fincTest\RecordDriver; + use VuFindTest\Unit\TestCase as VuFindTestCase; use finc\RecordDriver\SolrMarcFinc as SolrMarcFincDriver; + /** * SolrMarcTestCase * @@ -78,4 +80,4 @@ class SolrMarcFincTestCase extends VuFindTestCase true ); } -} \ No newline at end of file +} diff --git a/module/finc/tests/unit-tests/src/fincTest/RecordDriver/SolrMarcNewerPreviousTest.php b/module/finc/tests/unit-tests/src/fincTest/RecordDriver/SolrMarcNewerPreviousTest.php index 1956ff66922796cb56a38e18fec268a4eca84d6c..2392bbe3e04b7b946fc6c2a84c5403b43c03a556 100644 --- a/module/finc/tests/unit-tests/src/fincTest/RecordDriver/SolrMarcNewerPreviousTest.php +++ b/module/finc/tests/unit-tests/src/fincTest/RecordDriver/SolrMarcNewerPreviousTest.php @@ -89,4 +89,3 @@ class SolrMarcNewerPreviousTest extends SolrMarcFincTestCase $this->assertEquals('0002795235', $id); } } - diff --git a/module/finc/tests/unit-tests/src/fincTest/View/Helper/Root/ExternalCatalogueLinkTest.php b/module/finc/tests/unit-tests/src/fincTest/View/Helper/Root/ExternalCatalogueLinkTest.php index b00b0ec82abf63d5736d3dcff92ade4b79d83310..f9a6557cb94b42314da6e0c7c902bbede0be67ad 100644 --- a/module/finc/tests/unit-tests/src/fincTest/View/Helper/Root/ExternalCatalogueLinkTest.php +++ b/module/finc/tests/unit-tests/src/fincTest/View/Helper/Root/ExternalCatalogueLinkTest.php @@ -28,8 +28,8 @@ */ namespace FincTest\View\Helper\Root; -use finc\View\Helper\Root\ExternalCatalogueLink, - Zend\Config\Config; +use finc\View\Helper\Root\ExternalCatalogueLink; +use Zend\Config\Config; /** * External Catalogue Link Test Class @@ -55,9 +55,9 @@ class ExternalCatalogueLinkTest extends \VuFindTest\Unit\ViewHelperTestCase //fwrite(STDERR, print_r($driver, true)); $externalCatalogue = $this->getExternalCatalogueLink( - [], - $this->getFixture('testexternallink1.json', 'externallink') - )->__invoke($this->getMockDriver()); + [], + $this->getFixture('testexternallink1.json', 'externallink') + )->__invoke($this->getMockDriver()); $links = $externalCatalogue->getLinks(); $expectedArray = [ @@ -73,17 +73,17 @@ class ExternalCatalogueLinkTest extends \VuFindTest\Unit\ViewHelperTestCase $this->assertEquals(json_encode($expectedArray), json_encode($links)); $externalCatalogue = $this->getExternalCatalogueLink( - [], - $this->getFixture('testexternallink1.json', 'externallink') - )->__invoke( - $this->getMockDriver( - 'VuFind\RecordDriver\SolrDefault', - '0008964455', - '265768233', - '79', - ['DE-D13', 'DE-540'] - ) - ); + [], + $this->getFixture('testexternallink1.json', 'externallink') + )->__invoke( + $this->getMockDriver( + 'VuFind\RecordDriver\SolrDefault', + '0008964455', + '265768233', + '79', + ['DE-D13', 'DE-540'] + ) + ); $links = $externalCatalogue->getLinks(); fwrite(STDERR, print_r($links, true)); $expectedArray = [ @@ -112,8 +112,7 @@ class ExternalCatalogueLinkTest extends \VuFindTest\Unit\ViewHelperTestCase $record_id = '265768233', $source_id = "0", $institutions = ["DE-14", "DE-D13"] - ) - { + ) { $driver = $this->getMockBuilder($class) ->disableOriginalConstructor()->getMock(); $driver->expects($this->any())->method('getUniqueID') @@ -177,8 +176,8 @@ class ExternalCatalogueLinkTest extends \VuFindTest\Unit\ViewHelperTestCase . 'ExternalCatalogueLinks.json'; $rules = json_decode(file_get_contents($json), true); } - $externalCatalogueLink - = new ExternalCatalogueLink(new Config($config), $rules); + $externalCatalogueLink = + new ExternalCatalogueLink(new Config($config), $rules); return $externalCatalogueLink; } diff --git a/tests/finc/.php_cs b/tests/finc/.php_cs new file mode 100644 index 0000000000000000000000000000000000000000..2c82e17e1cf92a14c716999c5a501ec5eba06f19 --- /dev/null +++ b/tests/finc/.php_cs @@ -0,0 +1,15 @@ +<?php + +$baseDir = realpath(__DIR__ . '/../../'); +$finder = PhpCsFixer\Finder::create()->in("$baseDir/module/finc/src"); +$cacheDir = "$baseDir/data/cache/.php_cs_cache"; + +if (!is_dir($cacheDir)) { + mkdir($cacheDir); +} + +return PhpCsFixer\Config::create() + ->setCacheFile("$cacheDir/.code.cache") + ->setRiskyAllowed(true) + ->setRules(['@PSR2' => true]) + ->setFinder($finder); diff --git a/tests/finc/phpcs.xml b/tests/finc/phpcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..59d7e42200f68f59613d2ed58c30bb4772bfbed0 --- /dev/null +++ b/tests/finc/phpcs.xml @@ -0,0 +1,15 @@ +<?xml version="1.0"?> +<ruleset name="finc cs ruleset" namespace="finc\PHPCS"> + <description>finc coding standards.</description> + <file>../../module/finc/src/</file> + <arg name="extensions" value="php"/> + <rule ref="PSR2" /> + <rule ref="PEAR.Commenting.ClassComment" /> + <rule ref="PEAR.Commenting.FileComment" /> + <rule ref="Squiz.Commenting.FunctionComment.Missing"/> + <rule ref="Squiz.Commenting.FunctionComment.MissingParamTag"/> + <rule ref="Squiz.Commenting.FunctionComment.MissingParamName"/> + <rule ref="Squiz.Commenting.FunctionComment.ParamNameNoMatch"/> + <rule ref="Squiz.Commenting.FunctionComment.IncorrectTypeHint"/> + <rule ref="Squiz.Commenting.FunctionComment.MissingReturn"/> +</ruleset>