/** * Renders all sub-entries of one entry * * @access protected * * @param integer $number: The number of the entry * @param string $template: Parsed template subpart * * @return string The rendered entries ready for output */ protected function getSubEntries($number, $template) { $content = ''; foreach ($this->list[$number]['subparts'] as $subpart) { $markerArray['###SUBMETADATA###'] = ''; $markerArray['###SUBTHUMBNAIL###'] = ''; $markerArray['###SUBPREVIEW###'] = ''; $imgAlt = ''; foreach ($this->metadata as $index_name => $metaConf) { $parsedValue = ''; $fieldwrap = $this->parseTS($metaConf['wrap']); do { $value = @array_shift($subpart['metadata'][$index_name]); // Link title to pageview. if ($index_name == 'title') { // Get title of parent document if needed. if (empty($value) && $this->conf['getTitle']) { $superiorTitle = tx_dlf_document::getTitle($subpart['uid'], TRUE); if (!empty($superiorTitle)) { $value = '[' . $superiorTitle . ']'; } } // Set fake title if still not present. if (empty($value)) { $value = $this->pi_getLL('noTitle'); } $imgAlt = htmlspecialchars($value); $additionalParams = array('id' => $subpart['uid'], 'page' => $subpart['page']); $conf = array('useCacheHash' => 1, 'parameter' => $this->conf['targetPid'], 'additionalParams' => \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl($this->prefixId, $additionalParams, '', TRUE, FALSE)); $value = $this->cObj->typoLink(htmlspecialchars($value), $conf); // Translate name of holding library. } elseif ($index_name == 'owner' && !empty($value)) { $value = htmlspecialchars(tx_dlf_helper::translate($value, 'tx_dlf_libraries', $this->conf['pages'])); // Translate document type. } elseif ($index_name == 'type' && !empty($value)) { $_value = $value; $value = htmlspecialchars(tx_dlf_helper::translate($value, 'tx_dlf_structures', $this->conf['pages'])); // Add page number for single pages. if ($_value == 'page') { $value .= ' ' . intval($subpart['page']); } // Translate ISO 639 language code. } elseif ($index_name == 'language' && !empty($value)) { $value = htmlspecialchars(tx_dlf_helper::getLanguageName($value)); } elseif (!empty($value)) { $value = htmlspecialchars($value); } $value = $this->cObj->stdWrap($value, $fieldwrap['value.']); if (!empty($value)) { $parsedValue .= $value; } } while (count($subpart['metadata'][$index_name])); if (!empty($parsedValue)) { $field = $this->cObj->stdWrap(htmlspecialchars($metaConf['label']), $fieldwrap['key.']); $field .= $parsedValue; $markerArray['###SUBMETADATA###'] .= $this->cObj->stdWrap($field, $fieldwrap['all.']); } } // Add thumbnail. if (!empty($subpart['thumbnail'])) { $markerArray['###SUBTHUMBNAIL###'] = '<img alt="' . $imgAlt . '" src="' . $subpart['thumbnail'] . '" />'; } // Add preview. if (!empty($subpart['preview'])) { $markerArray['###SUBPREVIEW###'] = $subpart['preview']; } $content .= $this->cObj->substituteMarkerArray($template['subentry'], $markerArray); } return $this->cObj->substituteSubpart($this->cObj->getSubpart($this->template, '###SUBTEMPLATE###'), '###SUBENTRY###', $content, TRUE); }
/** * Creates an array for a HMENU entry of a facet value. * * @param string $field: The facet's index_name * @param string $value: The facet's value * @param integer $count: Number of hits for this facet * @param array $search: The parameters of the current search query * @param string &$state: The state of the parent item * * @return array The array for the facet's menu entry */ protected function getFacetsMenuEntry($field, $value, $count, $search, &$state) { $entryArray = array(); // Translate value. if ($field == 'owner_faceting') { // Translate name of holding library. $entryArray['title'] = htmlspecialchars(tx_dlf_helper::translate($value, 'tx_dlf_libraries', $this->conf['pages'])); } elseif ($field == 'type_faceting') { // Translate document type. $entryArray['title'] = htmlspecialchars(tx_dlf_helper::translate($value, 'tx_dlf_structures', $this->conf['pages'])); } elseif ($field == 'collection_faceting') { // Translate name of collection. $entryArray['title'] = htmlspecialchars(tx_dlf_helper::translate($value, 'tx_dlf_collections', $this->conf['pages'])); } elseif ($field == 'language_faceting') { // Translate ISO 639 language code. $entryArray['title'] = htmlspecialchars(tx_dlf_helper::getLanguageName($value)); } else { $entryArray['title'] = htmlspecialchars($value); } $entryArray['count'] = $count; $entryArray['doNotLinkIt'] = 0; // Check if facet is already selected. $index = array_search($field . ':("' . tx_dlf_solr::escapeQuery($value) . '")', $search['params']['fq']); if ($index !== FALSE) { // Facet is selected, thus remove it from filter. unset($search['params']['fq'][$index]); $search['params']['fq'] = array_values($search['params']['fq']); $entryArray['ITEM_STATE'] = 'CUR'; $state = 'ACTIFSUB'; //Reset facets if ($this->conf['resetFacets']) { //remove ($count) for selected facet in template $entryArray['count'] = FALSE; //build link to delete selected facet $entryArray['_OVERRIDE_HREF'] = $this->pi_linkTP_keepPIvars_url(array('query' => $search['query'], 'fq' => $search['params']['fq'])); $entryArray['title'] = sprintf($this->pi_getLL('resetFacet', ''), $entryArray['title']); } } else { // Facet is not selected, thus add it to filter. $search['params']['fq'][] = $field . ':("' . tx_dlf_solr::escapeQuery($value) . '")'; $entryArray['ITEM_STATE'] = 'NO'; } $entryArray['_OVERRIDE_HREF'] = $this->pi_linkTP_keepPIvars_url(array('query' => $search['query'], 'fq' => $search['params']['fq'])); return $entryArray; }
/** * Prepares the metadata array for output * * @access protected * * @param array $metadataArray: The metadata array * * @return string The metadata array ready for output */ protected function printMetadata(array $metadataArray) { // Load template file. if (!empty($this->conf['templateFile'])) { $this->template = $this->cObj->getSubpart($this->cObj->fileResource($this->conf['templateFile']), '###TEMPLATE###'); } else { $this->template = $this->cObj->getSubpart($this->cObj->fileResource('EXT:dlf/plugins/metadata/template.tmpl'), '###TEMPLATE###'); } $output = ''; $subpart['block'] = $this->cObj->getSubpart($this->template, '###BLOCK###'); // Get list of metadata to show. $metaList = array(); $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_dlf_metadata.index_name AS index_name,tx_dlf_metadata.is_listed AS is_listed,tx_dlf_metadata.wrap AS wrap', 'tx_dlf_metadata', 'tx_dlf_metadata.pid=' . intval($this->conf['pages']) . tx_dlf_helper::whereClause('tx_dlf_metadata'), '', 'tx_dlf_metadata.sorting', ''); while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { if ($this->conf['showFull'] || $resArray['is_listed']) { $metaList[$resArray['index_name']] = array('wrap' => $resArray['wrap'], 'label' => tx_dlf_helper::translate($resArray['index_name'], 'tx_dlf_metadata', $this->conf['pages'])); } } // Save original data array. $cObjData = $this->cObj->data; // Parse the metadata arrays. foreach ($metadataArray as $metadata) { $markerArray['###METADATA###'] = ''; // Reset content object's data array. $this->cObj->data = $cObjData; // Load all the metadata values into the content object's data array. foreach ($metadata as $index_name => $value) { if (is_array($value)) { $this->cObj->data[$index_name] = implode($this->conf['separator'], $value); } else { $this->cObj->data[$index_name] = $value; } } // Process each metadate. foreach ($metaList as $index_name => $metaConf) { $parsedValue = ''; $fieldwrap = $this->parseTS($metaConf['wrap']); do { $value = @array_shift($metadata[$index_name]); if ($index_name == 'title') { // Get title of parent document if needed. if (empty($value) && $this->conf['getTitle'] && $this->doc->parentId) { $superiorTitle = tx_dlf_document::getTitle($this->doc->parentId, TRUE); if (!empty($superiorTitle)) { $value = '[' . $superiorTitle . ']'; } } if (!empty($value)) { $value = htmlspecialchars($value); // Link title to pageview. if ($this->conf['linkTitle'] && $metadata['_id']) { $details = $this->doc->getLogicalStructure($metadata['_id']); $value = $this->pi_linkTP($value, array($this->prefixId => array('id' => $this->doc->uid, 'page' => !empty($details['points']) ? intval($details['points']) : 1)), TRUE, $this->conf['targetPid']); } } } elseif ($index_name == 'owner' && !empty($value)) { // Translate name of holding library. $value = htmlspecialchars(tx_dlf_helper::translate($value, 'tx_dlf_libraries', $this->conf['pages'])); } elseif ($index_name == 'type' && !empty($value)) { // Translate document type. $value = htmlspecialchars(tx_dlf_helper::translate($value, 'tx_dlf_structures', $this->conf['pages'])); } elseif ($index_name == 'collection' && !empty($value)) { // Translate collection. $value = htmlspecialchars(tx_dlf_helper::translate($value, 'tx_dlf_collections', $this->conf['pages'])); } elseif ($index_name == 'language' && !empty($value)) { // Translate ISO 639 language code. $value = htmlspecialchars(tx_dlf_helper::getLanguageName($value)); } elseif (!empty($value)) { // Sanitize value for output. $value = htmlspecialchars($value); } // Hook for getting a customized value (requested by SBB). foreach ($this->hookObjects as $hookObj) { if (method_exists($hookObj, 'printMetadata_customizeMetadata')) { $hookObj->printMetadata_customizeMetadata($value); } } $value = $this->cObj->stdWrap($value, $fieldwrap['value.']); if (!empty($value)) { $parsedValue .= $value; } } while (count($metadata[$index_name])); if (!empty($parsedValue)) { $field = $this->cObj->stdWrap(htmlspecialchars($metaConf['label']), $fieldwrap['key.']); $field .= $parsedValue; $markerArray['###METADATA###'] .= $this->cObj->stdWrap($field, $fieldwrap['all.']); } } $output .= $this->cObj->substituteMarkerArray($subpart['block'], $markerArray); } return $this->cObj->substituteSubpart($this->template, '###BLOCK###', $output, TRUE); }