コード例 #1
0
ファイル: Piwik.php プロジェクト: jlehmus/NDL-VuFind2
 /**
  * Get Custom Variables for a Record Page
  *
  * @param VuFind\RecordDriver\AbstractBase $recordDriver Record driver
  *
  * @return array Associative array of custom variables
  */
 protected function getRecordPageCustomVars($recordDriver)
 {
     if (!$this->customVars) {
         return [];
     }
     $vars = parent::getRecordPageCustomVars($recordDriver);
     $source = $recordDriver->getSourceIdentifier();
     $sourceMap = ['Solr' => 'Local', 'Primo' => 'PCI', 'MetaLib' => 'MetaLib'];
     $vars['RecordIndex'] = isset($sourceMap[$source]) ? $sourceMap[$source] : $source;
     if ($source == 'Primo') {
         $vars['PCIRecordSource'] = $recordDriver->getSource();
         unset($vars['RecordInstitution']);
         if ($type = $recordDriver->getType()) {
             $vars['RecordFormat'] = $type;
         }
         foreach (['RecordFormat', 'RecordData', 'RecordSource'] as $var) {
             if (isset($vars[$var])) {
                 $vars["PCI{$var}"] = $vars[$var];
                 unset($vars[$var]);
             }
         }
     } else {
         if ($source == 'MetaLib') {
             $vars['MetaLibRecordSource'] = $recordDriver->getSource();
             $vars['MetaLibRecordData'] = $vars['RecordData'];
             unset($vars['RecordFormat']);
             unset($vars['RecordData']);
             unset($vars['RecordInstitution']);
         } else {
             $format = $formats = $recordDriver->tryMethod('getFormats');
             if (is_array($formats)) {
                 $format = isset($formats[1]) ? $formats[1] : $formats[0];
             }
             $format = urldecode($format);
             $format = rtrim($format, '/');
             $format = preg_replace('/^\\d\\//', '', $format);
             $vars['RecordFormat'] = $format;
         }
     }
     return $vars;
 }
コード例 #2
0
ファイル: Piwik.php プロジェクト: bbeckman/NDL-VuFind2
 /**
  * Get Custom Variables for a Record Page
  *
  * @param VuFind\RecordDriver\AbstractBase $recordDriver Record driver
  *
  * @return array Associative array of custom variables
  */
 protected function getRecordPageCustomVars($recordDriver)
 {
     if (!$this->customVars) {
         return [];
     }
     $vars = parent::getRecordPageCustomVars($recordDriver);
     $source = $recordDriver->getSourceIdentifier();
     $sourceMap = ['Solr' => 'Local', 'Primo' => 'PCI', 'MetaLib' => 'MetaLib'];
     $vars['RecordIndex'] = isset($sourceMap[$source]) ? $sourceMap[$source] : $source;
     $vars['Language'] = $this->translator->getLocale();
     if ($source == 'Primo') {
         $vars['PCIRecordSource'] = $recordDriver->getSource();
         unset($vars['RecordInstitution']);
         if ($type = $recordDriver->getType()) {
             $vars['RecordFormat'] = $type;
         }
         foreach (['RecordFormat', 'RecordData', 'RecordSource'] as $var) {
             if (isset($vars[$var])) {
                 $vars["PCI{$var}"] = $vars[$var];
                 unset($vars[$var]);
             }
         }
     } else {
         if ($source == 'MetaLib') {
             $vars['MetaLibRecordSource'] = $recordDriver->getSource();
             $vars['MetaLibRecordData'] = $vars['RecordData'];
             unset($vars['RecordFormat']);
             unset($vars['RecordData']);
             unset($vars['RecordInstitution']);
         } else {
             $format = $formats = $recordDriver->tryMethod('getFormats');
             if (is_array($formats)) {
                 $format = end($formats);
                 if (false === $format) {
                     $format = '';
                 }
             }
             $format = rtrim($format, '/');
             $format = preg_replace('/^\\d\\//', '', $format);
             $vars['RecordFormat'] = $format;
             $fields = $recordDriver->getRawData();
             $online = !empty($fields['online_boolean']);
             $vars['RecordAvailableOnline'] = $online ? 'yes' : 'no';
             $vars['RecordData' . ($online ? 'Online' : 'Offline')] = $vars['RecordData'];
         }
     }
     return $vars;
 }