/** * The main method of the PlugIn * * @access public * * @param string $content: The PlugIn content * @param array $conf: The PlugIn configuration * * @return string The content that is displayed on the website */ public function main($content, $conf) { $this->init($conf); // Merge configuration with conf array of toolbox. $this->conf = tx_dlf_helper::array_merge_recursive_overrule($this->cObj->data['conf'], $this->conf); // Load current document. $this->loadDocument(); if ($this->doc === NULL || $this->doc->numPages < 1 || empty($this->conf['fileGrpFulltext'])) { // Quit without doing anything if required variables are not set. return $content; } else { // Set default values if not set. // page may be integer or string (physical page attribute) if ((int) $this->piVars['page'] > 0 || empty($this->piVars['page'])) { $this->piVars['page'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1); } else { $this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalPages); } $this->piVars['double'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0); } // 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/toolbox/tools/fulltext/template.tmpl'), '###TEMPLATE###'); } $fullTextFile = $this->doc->physicalPagesInfo[$this->doc->physicalPages[$this->piVars['page']]]['files'][$this->conf['fileGrpFulltext']]; if (!empty($fullTextFile)) { $markerArray['###FULLTEXT_SELECT###'] = '<a class="select switchoff" id="tx-dlf-tools-fulltext" title="" data-dic="fulltext-on:' . $this->pi_getLL('fulltext-on', '', TRUE) . ';fulltext-off:' . $this->pi_getLL('fulltext-off', '', TRUE) . '"></a>'; } else { $markerArray['###FULLTEXT_SELECT###'] = $this->pi_getLL('fulltext-not-available', '', TRUE); } $content .= $this->cObj->substituteMarkerArray($this->template, $markerArray); return $this->pi_wrapInBaseClass($content); }
/** * The main method of the PlugIn * * @access public * * @param string $content: The PlugIn content * @param array $conf: The PlugIn configuration * * @return string The content that is displayed on the website */ public function main($content, $conf) { $this->init($conf); // Turn cache on. $this->setCache(TRUE); // Quit without doing anything if required configuration variables are not set. if (empty($this->conf['pages'])) { if (TYPO3_DLOG) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_statistics->main(' . $content . ', [data])] Incomplete plugin configuration', $this->extKey, SYSLOG_SEVERITY_WARNING, $conf); } return $content; } // Get description. $content .= $this->pi_RTEcssText($this->conf['description']); // Check for selected collections. if ($this->conf['collections']) { // Include only selected collections. $resultTitles = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('tx_dlf_documents.uid AS uid', 'tx_dlf_documents', 'tx_dlf_relations', 'tx_dlf_collections', 'AND tx_dlf_documents.pid=' . intval($this->conf['pages']) . ' AND tx_dlf_collections.pid=' . intval($this->conf['pages']) . ' AND tx_dlf_documents.partof=0 AND tx_dlf_collections.uid IN (' . $GLOBALS['TYPO3_DB']->cleanIntList($this->conf['collections']) . ') AND tx_dlf_relations.ident=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('docs_colls', 'tx_dlf_relations') . tx_dlf_helper::whereClause('tx_dlf_documents') . tx_dlf_helper::whereClause('tx_dlf_collections'), 'tx_dlf_documents.uid', '', ''); $resultVolumes = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('tx_dlf_documents.uid AS uid', 'tx_dlf_documents', 'tx_dlf_relations', 'tx_dlf_collections', 'AND tx_dlf_documents.pid=' . intval($this->conf['pages']) . ' AND tx_dlf_collections.pid=' . intval($this->conf['pages']) . ' AND NOT tx_dlf_documents.uid IN (SELECT DISTINCT tx_dlf_documents.partof FROM tx_dlf_documents WHERE NOT tx_dlf_documents.partof=0' . tx_dlf_helper::whereClause('tx_dlf_documents') . ') AND tx_dlf_collections.uid IN (' . $GLOBALS['TYPO3_DB']->cleanIntList($this->conf['collections']) . ') AND tx_dlf_relations.ident=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('docs_colls', 'tx_dlf_relations') . tx_dlf_helper::whereClause('tx_dlf_documents') . tx_dlf_helper::whereClause('tx_dlf_collections'), 'tx_dlf_documents.uid', '', ''); } else { // Include all collections. $resultTitles = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_dlf_documents.uid AS uid', 'tx_dlf_documents', 'tx_dlf_documents.pid=' . intval($this->conf['pages']) . ' AND tx_dlf_documents.partof=0' . tx_dlf_helper::whereClause('tx_dlf_documents'), '', '', ''); $resultVolumes = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_dlf_documents.uid AS uid', 'tx_dlf_documents', 'tx_dlf_documents.pid=' . intval($this->conf['pages']) . ' AND NOT tx_dlf_documents.uid IN (SELECT DISTINCT tx_dlf_documents.partof FROM tx_dlf_documents WHERE NOT tx_dlf_documents.partof=0' . tx_dlf_helper::whereClause('tx_dlf_documents') . ')' . tx_dlf_helper::whereClause('tx_dlf_documents'), '', '', ''); } $countTitles = $GLOBALS['TYPO3_DB']->sql_num_rows($resultTitles); $countVolumes = $GLOBALS['TYPO3_DB']->sql_num_rows($resultVolumes); // Set replacements. $replace = array('key' => array('###TITLES###', '###VOLUMES###'), 'value' => array($countTitles . ($countTitles > 1 ? $this->pi_getLL('titles', '', TRUE) : $this->pi_getLL('title', '', TRUE)), $countVolumes . ($countVolumes > 1 ? $this->pi_getLL('volumes', '', TRUE) : $this->pi_getLL('volume', '', TRUE)))); // Apply replacements. $content = str_replace($replace['key'], $replace['value'], $content); return $this->pi_wrapInBaseClass($content); }
/** * The main method of the PlugIn * * @access public * * @param string $content: The PlugIn content * @param array $conf: The PlugIn configuration * * @return string The content that is displayed on the website */ public function main($content, $conf) { $this->init($conf); // Merge configuration with conf array of toolbox. $this->conf = tx_dlf_helper::array_merge_recursive_overrule($this->cObj->data['conf'], $this->conf); // Load current document. $this->loadDocument(); if ($this->doc === NULL || $this->doc->numPages < 1 || empty($this->conf['fileGrpDownload'])) { // Quit without doing anything if required variables are not set. return $content; } else { // Set default values if not set. // page may be integer or string (physical page attribute) if ((int) $this->piVars['page'] > 0 || empty($this->piVars['page'])) { $this->piVars['page'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1); } else { $this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalPages); } $this->piVars['double'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0); } // 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/toolbox/tools/pdf/template.tmpl'), '###TEMPLATE###'); } // Get single page downloads. $markerArray['###PAGE###'] = $this->getPageLink(); // Get work download. $markerArray['###WORK###'] = $this->getWorkLink(); $content .= $this->cObj->substituteMarkerArray($this->template, $markerArray); return $this->pi_wrapInBaseClass($content); }
/** * Main function of the script. * * @access public * * @return void */ public function main() { switch ((string) $this->cli_args['_DEFAULT'][1]) { // (Re-)Index a single document. case 'index': // Add command line arguments. $this->cli_options[] = array('-doc UID/URL', 'UID or URL of the document.'); $this->cli_options[] = array('-pid UID', 'UID of the page the document should be added to.'); $this->cli_options[] = array('-core UID', 'UID of the Solr core the document should be added to.'); // Check the command line arguments. $this->cli_validateArgs(); // Get the document... $doc =& tx_dlf_document::getInstance($this->cli_args['-doc'][0], $this->cli_args['-pid'][0], TRUE); if ($doc->ready) { // ...and save it to the database... if (!$doc->save(intval($this->cli_args['-pid'][0]), intval($this->cli_args['-core'][0]))) { $this->cli_echo('ERROR: Document ' . $this->cli_args['-doc'][0] . ' not saved and indexed.' . LF, TRUE); exit(1); } } else { $this->cli_echo('ERROR: Document ' . $this->cli_args['-doc'][0] . ' could not be loaded.' . LF, TRUE); exit(1); } break; // Re-index all documents of a collection. // Re-index all documents of a collection. case 'reindex': // Add command line arguments. $this->cli_options[] = array('-coll UID', 'UID of the collection.'); $this->cli_options[] = array('-pid UID', 'UID of the page the document should be added to.'); $this->cli_options[] = array('-core UID', 'UID of the Solr core the document should be added to.'); // Check the command line arguments. $this->cli_validateArgs(); // Get the collection. $result = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('tx_dlf_documents.uid AS uid', 'tx_dlf_documents', 'tx_dlf_relations', 'tx_dlf_collections', 'AND tx_dlf_collections.uid=' . intval($this->cli_args['-coll'][0]) . ' AND tx_dlf_collections.pid=' . intval($this->cli_args['-pid'][0]) . ' AND tx_dlf_relations.ident=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('docs_colls', 'tx_dlf_relations') . tx_dlf_helper::whereClause('tx_dlf_documents') . tx_dlf_helper::whereClause('tx_dlf_collections'), '', '', ''); while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { // Get the document... $doc =& tx_dlf_document::getInstance($resArray['uid'], $this->cli_args['-pid'][0], TRUE); if ($doc->ready) { // ...and save it to the database... if (!$doc->save(intval($this->cli_args['-pid'][0]), intval($this->cli_args['-core'][0]))) { $this->cli_echo('ERROR: Document ' . $resArray['uid'] . ' not saved and indexed.' . LF, TRUE); exit(1); } } else { $this->cli_echo('ERROR: Document ' . $resArray['uid'] . ' could not be loaded.' . LF, TRUE); exit(1); } } break; default: $this->cli_help(); break; } exit(0); }
/** * The main method of the PlugIn * * @access public * * @param string $content: The PlugIn content * @param array $conf: The PlugIn configuration * * @return void */ public function main($content = '', $conf = array()) { if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('encrypted') != '' && \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('hashed') != '') { $core = tx_dlf_helper::decrypt(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('encrypted'), \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('hashed')); } if (!empty($core)) { $url = trim(tx_dlf_solr::getSolrUrl($core), '/') . '/suggest/?q=' . tx_dlf_solr::escapeQuery(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('q')); if ($stream = fopen($url, 'r')) { $content .= stream_get_contents($stream); fclose($stream); } } echo $content; }
/** * The main method of the PlugIn * * @access public * * @param string $content: The PlugIn content * @param array $conf: The PlugIn configuration * * @return string The content that is displayed on the website */ public function main($content, $conf) { $this->init($conf); // Merge configuration with conf array of toolbox. $this->conf = tx_dlf_helper::array_merge_recursive_overrule($this->cObj->data['conf'], $this->conf); // Load current document. $this->loadDocument(); // 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/toolbox/tools/imagemanipulation/template.tmpl'), '###TEMPLATE###'); } $markerArray['###IMAGEMANIPULATION_SELECT###'] = '<span class="tx-dlf-tools-imagetools" id="tx-dlf-tools-imagetools" data-dic="imagemanipulation-on:' . $this->pi_getLL('imagemanipulation-on', '', TRUE) . ';imagemanipulation-off:' . $this->pi_getLL('imagemanipulation-off', '', TRUE) . ';reset:' . $this->pi_getLL('reset', '', TRUE) . ';saturation:' . $this->pi_getLL('saturation', '', TRUE) . ';hue:' . $this->pi_getLL('hue', '', TRUE) . ';contrast:' . $this->pi_getLL('contrast', '', TRUE) . ';brightness:' . $this->pi_getLL('brightness', '', TRUE) . '" title="' . $this->pi_getLL('no-support', '', TRUE) . '"></span>'; $content .= $this->cObj->substituteMarkerArray($this->template, $markerArray); return $this->pi_wrapInBaseClass($content); }
/** * The main method of the PlugIn * * @access public * * @param string $content: The PlugIn content * @param array $conf: The PlugIn configuration * * @return string The content that is displayed on the website */ public function main($content, $conf) { $this->init($conf); // Merge configuration with conf array of toolbox. $this->conf = t3lib_div::array_merge_recursive_overrule($this->cObj->data['conf'], $this->conf); // Load current document. $this->loadDocument(); if ($this->doc === NULL || $this->doc->numPages < 1 || empty($this->conf['fileGrpFulltext'])) { // Quit without doing anything if required variables are not set. return $content; } else { // Set default values if not set. // page may be integer or string (physical page attribute) if ((int) $this->piVars['page'] > 0 || empty($this->piVars['page'])) { $this->piVars['page'] = tx_dlf_helper::intInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1); } else { $this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalPages); } $this->piVars['double'] = tx_dlf_helper::intInRange($this->piVars['double'], 0, 1, 0); } // 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/toolbox/tools/fulltext/template.tmpl'), '###TEMPLATE###'); } $fullTextFile = $this->doc->physicalPagesInfo[$this->doc->physicalPages[$this->piVars['page']]]['files'][$this->conf['fileGrpFulltext']]; // Get single page downloads. if (!empty($fullTextFile)) { $markerArray['###FULLTEXT_SELECT###'] = '<a class="select" title="' . $this->pi_getLL('fulltext-select', '', TRUE) . '" onclick="tx_dlf_viewer.toogleFulltextSelect();">' . $this->pi_getLL('fulltext-select', '', TRUE) . '</a>'; } else { $markerArray['###FULLTEXT_SELECT###'] = $this->pi_getLL('fulltext-select', '', TRUE); } $content .= $this->cObj->substituteMarkerArray($this->template, $markerArray); return $this->pi_wrapInBaseClass($content); }
/** * Wrapper function for getting localizations in frontend and backend * * @param string $key: The locallang key to translate * @param boolean $hsc: Should the result be htmlspecialchar()'ed? * @param string $default: Default return value if no translation is available * * @return string The translated string or the given key on failure */ public static function getLL($key, $hsc = FALSE, $default = '') { // Set initial output to default value. $translated = (string) $default; // Load common locallang file. if (empty(self::$locallang)) { $file = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(self::$extKey, 'common/locallang.xml'); if (TYPO3_MODE === 'FE') { self::$locallang = $GLOBALS['TSFE']->readLLfile($file); } elseif (TYPO3_MODE === 'BE') { self::$locallang = $GLOBALS['LANG']->includeLLFile($file, FALSE, TRUE); } elseif (TYPO3_DLOG) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getLL(' . $key . ', ' . $default . ', [' . ($hsc ? 'TRUE' : 'FALSE') . '])] Unexpected TYPO3_MODE "' . TYPO3_MODE . '"', self::$extKey, SYSLOG_SEVERITY_ERROR); } } // Get translation. if (!empty(self::$locallang['default'][$key])) { if (TYPO3_MODE === 'FE') { $translated = $GLOBALS['TSFE']->getLLL($key, self::$locallang); } elseif (TYPO3_MODE === 'BE') { $translated = $GLOBALS['LANG']->getLLL($key, self::$locallang, FALSE); } elseif (TYPO3_DLOG) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_helper->getLL(' . $key . ', ' . $default . ', [' . ($hsc ? 'TRUE' : 'FALSE') . '])] Unexpected TYPO3_MODE "' . TYPO3_MODE . '"', self::$extKey, SYSLOG_SEVERITY_ERROR); } } // Escape HTML characters if applicable. if ($hsc) { $translated = htmlspecialchars($translated); } return $translated; }
/** * Main function of the module * * @access public * * @return void */ public function main() { // Is the user allowed to access this page? $access = is_array($this->pageInfo) || $GLOBALS['BE_USER']->isAdmin(); if ($this->id && $access) { // Increase max_execution_time and max_input_time for large documents. if (!ini_get('safe_mode')) { ini_set('max_execution_time', '0'); ini_set('max_input_time', '-1'); } switch ($this->CMD) { case 'indexFile': if (!empty($this->data['id']) && isset($this->data['core'])) { // Save document to database and index. $doc =& tx_dlf_document::getInstance($this->data['id'], $this->id, TRUE); if ($doc->ready) { $doc->save($this->id, $this->data['core']); } else { $_message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', htmlspecialchars(sprintf(tx_dlf_helper::getLL('flash.fileNotLoaded'), $this->data['id'])), tx_dlf_helper::getLL('flash.error', TRUE), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, TRUE); tx_dlf_helper::addMessage($_message); } } break; case 'reindexDocs': if (isset($this->data['core'])) { if (!empty($this->data['collection'])) { // Get all documents in this collection. $_result = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('tx_dlf_documents.title AS title,tx_dlf_documents.uid AS uid', 'tx_dlf_documents', 'tx_dlf_relations', 'tx_dlf_collections', 'AND tx_dlf_documents.pid=' . intval($this->id) . ' AND tx_dlf_collections.uid=' . intval($this->data['collection']) . ' AND tx_dlf_relations.ident=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('docs_colls', 'tx_dlf_relations') . tx_dlf_helper::whereClause('tx_dlf_documents') . tx_dlf_helper::whereClause('tx_dlf_collections'), 'tx_dlf_documents.uid', '', ''); } else { // Get all documents. $_result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_dlf_documents.title AS title,tx_dlf_documents.uid AS uid', 'tx_dlf_documents', 'tx_dlf_documents.pid=' . intval($this->id) . tx_dlf_helper::whereClause('tx_dlf_documents'), '', '', ''); } // Save them as a list object in user's session. $elements = array(); while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($_result)) { $elements[] = array($resArray['uid'], $resArray['title']); } $this->list = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_dlf_list', $elements); // Start index looping. if (count($this->list) > 0) { $this->indexLoop(); } } break; case 'indexLoop': // Refresh user's session to prevent session timeout. $GLOBALS['BE_USER']->fetchUserSession(); // Get document list from user's session. $this->list = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_dlf_list'); // Continue index looping. if (count($this->list) > 0 && isset($this->data['core'])) { $this->indexLoop(); } else { $_message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', tx_dlf_helper::getLL('flash.seeLog', TRUE), tx_dlf_helper::getLL('flash.done', TRUE), \TYPO3\CMS\Core\Messaging\FlashMessage::OK, TRUE); tx_dlf_helper::addMessage($_message); } break; } $this->markerArray['CONTENT'] .= tx_dlf_helper::renderFlashMessages(); switch ($this->MOD_SETTINGS['function']) { case 'indexFile': $this->markerArray['CONTENT'] .= $this->getFileForm(); break; case 'reindexDoc': $this->markerArray['CONTENT'] .= $this->getDocList(); break; case 'reindexDocs': $this->markerArray['CONTENT'] .= $this->getCollList(); break; } } else { // TODO: Ändern! $this->markerArray['CONTENT'] .= 'You are not allowed to access this page or have not selected a page, yet.'; } $this->printContent(); }
/** * This is the constructor * * @access public * * @param array $elements: Array of documents initially setting up the list * @param array $metadata: Array of initial metadata * * @return void */ public function __construct(array $elements = array(), array $metadata = array()) { if (empty($elements) && empty($metadata)) { // Let's check the user's session. $sessionData = tx_dlf_helper::loadFromSession(get_class($this)); // Restore list from session data. if (is_array($sessionData)) { if (is_array($sessionData[0])) { $this->elements = $sessionData[0]; } if (is_array($sessionData[1])) { $this->metadata = $sessionData[1]; } } } else { // Add metadata to the list. $this->metadata = $metadata; // Add initial set of elements to the list. $this->elements = $elements; } $this->count = count($this->elements); }
/** * Adds the JS files necessary for search form * * @access protected * * @return void */ protected function addSearchFormJS() { // Add javascript to page header. if (tx_dlf_helper::loadJQuery()) { $GLOBALS['TSFE']->additionalHeaderData[$this->prefixId . '_sru'] = '<script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->extKey) . 'plugins/sru/tx_dfgviewer_sru.js"></script>'; } }
/** * Builds a collection's list * * @access protected * * @param integer $id: The collection's UID * * @return void */ protected function showSingleCollection($id) { // Should user-defined collections be shown? if (empty($this->conf['show_userdefined'])) { $additionalWhere = ' AND tx_dlf_collections.fe_cruser_id=0'; } elseif ($this->conf['show_userdefined'] > 0) { $additionalWhere = ' AND NOT tx_dlf_collections.fe_cruser_id=0'; } // Get all documents in collection. $result = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('tx_dlf_collections.index_name AS index_name,tx_dlf_collections.label AS collLabel,tx_dlf_collections.description AS collDesc,tx_dlf_collections.thumbnail AS collThumb,tx_dlf_collections.fe_cruser_id AS userid,tx_dlf_documents.uid AS uid,tx_dlf_documents.metadata_sorting AS metadata_sorting,tx_dlf_documents.volume_sorting AS volume_sorting,tx_dlf_documents.partof AS partof', 'tx_dlf_documents', 'tx_dlf_relations', 'tx_dlf_collections', 'AND tx_dlf_collections.uid=' . intval($id) . ' AND tx_dlf_collections.pid=' . intval($this->conf['pages']) . ' AND tx_dlf_relations.ident=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('docs_colls', 'tx_dlf_relations') . $additionalWhere . tx_dlf_helper::whereClause('tx_dlf_documents') . tx_dlf_helper::whereClause('tx_dlf_collections'), '', 'tx_dlf_documents.title_sorting ASC', ''); $toplevel = array(); $subparts = array(); $listMetadata = array(); // Process results. while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { if (empty($listMetadata)) { $listMetadata = array('label' => htmlspecialchars($resArray['collLabel']), 'description' => $this->pi_RTEcssText($resArray['collDesc']), 'thumbnail' => htmlspecialchars($resArray['collThumb']), 'options' => array('source' => 'collection', 'select' => $id, 'userid' => $resArray['userid'], 'params' => array('fq' => array('collection_faceting:"' . $resArray['index_name'] . '"')), 'core' => '', 'pid' => $this->conf['pages'], 'order' => 'title', 'order.asc' => TRUE)); } // Split toplevel documents from volumes. if ($resArray['partof'] == 0) { // Prepare document's metadata for sorting. $sorting = unserialize($resArray['metadata_sorting']); if (!empty($sorting['type']) && tx_dlf_helper::testInt($sorting['type'])) { $sorting['type'] = tx_dlf_helper::getIndexName($sorting['type'], 'tx_dlf_structures', $this->conf['pages']); } if (!empty($sorting['owner']) && tx_dlf_helper::testInt($sorting['owner'])) { $sorting['owner'] = tx_dlf_helper::getIndexName($sorting['owner'], 'tx_dlf_libraries', $this->conf['pages']); } if (!empty($sorting['collection']) && tx_dlf_helper::testInt($sorting['collection'])) { $sorting['collection'] = tx_dlf_helper::getIndexName($sorting['collection'], 'tx_dlf_collections', $this->conf['pages']); } $toplevel[$resArray['uid']] = array('u' => $resArray['uid'], 's' => $sorting, 'p' => array()); } else { $subparts[$resArray['partof']][$resArray['volume_sorting']] = $resArray['uid']; } } // Add volumes to the corresponding toplevel documents. foreach ($subparts as $partof => $parts) { if (!empty($toplevel[$partof])) { ksort($parts); $toplevel[$partof]['p'] = array_values($parts); } } // Save list of documents. $list = t3lib_div::makeInstance('tx_dlf_list'); $list->reset(); $list->add(array_values($toplevel)); $list->metadata = $listMetadata; $list->save(); // Clean output buffer. t3lib_div::cleanOutputBuffers(); // Send headers. header('Location: ' . t3lib_div::locationHeaderUrl($this->cObj->typoLink_URL(array('parameter' => $this->conf['targetPid'])))); // Flush output buffer and end script processing. ob_end_flush(); exit; }
/** * Processes a search request. * * @access public * * @param string $query: The search query * * @return tx_dlf_list The result list */ public function search($query = '') { // Perform search. $results = $this->service->search((string) $query, 0, $this->limit, $this->params); $this->numberOfHits = count($results->response->docs); $toplevel = array(); $checks = array(); // Get metadata configuration. if ($this->numberOfHits > 0) { $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_dlf_metadata.index_name AS index_name', 'tx_dlf_metadata', 'tx_dlf_metadata.is_sortable=1 AND tx_dlf_metadata.pid=' . intval($this->cPid) . tx_dlf_helper::whereClause('tx_dlf_metadata'), '', '', ''); $sorting = array(); while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { $sorting[$resArray['index_name']] = $resArray['index_name'] . '_sorting'; } } // Keep track of relevance. $i = 0; // Process results. foreach ($results->response->docs as $doc) { // Split toplevel documents from subparts. if ($doc->toplevel == 1) { // Prepare document's metadata for sorting. $docSorting = array(); foreach ($sorting as $index_name => $solr_name) { if (!empty($doc->{$solr_name})) { $docSorting[$index_name] = is_array($doc->{$solr_name}) ? $doc->{$solr_name}[0] : $doc->{$solr_name}; } } // Preserve relevance ranking. if (!empty($toplevel[$doc->uid]['s']['relevance'])) { $docSorting['relevance'] = $toplevel[$doc->uid]['s']['relevance']; } $toplevel[$doc->uid] = array('u' => $doc->uid, 'h' => '', 's' => $docSorting, 'p' => !empty($toplevel[$doc->uid]['p']) ? $toplevel[$doc->uid]['p'] : array()); } else { $toplevel[$doc->uid]['p'][] = array('u' => $doc->id, 'h' => !empty($results->highlighting->{$doc->id}->fulltext) ? $results->highlighting->{$doc->id}->fulltext[0] : ''); if (!in_array($doc->uid, $checks)) { $checks[] = $doc->uid; } } // Add relevance to sorting values. if (empty($toplevel[$doc->uid]['s']['relevance'])) { $toplevel[$doc->uid]['s']['relevance'] = str_pad($i, 6, '0', STR_PAD_LEFT); } $i++; } // Check if the toplevel documents have metadata. foreach ($checks as $check) { if (empty($toplevel[$check]['u'])) { // Get information for toplevel document. $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_dlf_documents.uid AS uid,tx_dlf_documents.metadata_sorting AS metadata_sorting', 'tx_dlf_documents', 'tx_dlf_documents.uid=' . intval($check) . tx_dlf_helper::whereClause('tx_dlf_documents'), '', '', '1'); // Process results. if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); // Prepare document's metadata for sorting. $sorting = unserialize($resArray['metadata_sorting']); if (!empty($sorting['type']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($sorting['type'])) { $sorting['type'] = tx_dlf_helper::getIndexName($sorting['type'], 'tx_dlf_structures', $this->cPid); } if (!empty($sorting['owner']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($sorting['owner'])) { $sorting['owner'] = tx_dlf_helper::getIndexName($sorting['owner'], 'tx_dlf_libraries', $this->cPid); } if (!empty($sorting['collection']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($sorting['collection'])) { $sorting['collection'] = tx_dlf_helper::getIndexName($sorting['collection'], 'tx_dlf_collections', $this->cPid); } // Preserve relevance ranking. if (!empty($toplevel[$check]['s']['relevance'])) { $sorting['relevance'] = $toplevel[$check]['s']['relevance']; } $toplevel[$check] = array('u' => $resArray['uid'], 'h' => '', 's' => $sorting, 'p' => $toplevel[$check]['p']); } else { // Clear entry if there is no (accessible) toplevel document. unset($toplevel[$check]); } } } // Save list of documents. $list = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_dlf_list'); $list->reset(); $list->add(array_values($toplevel)); // Set metadata for search. $list->metadata = array('label' => '', 'description' => '', 'options' => array('source' => 'search', 'engine' => 'solr', 'select' => $query, 'userid' => 0, 'params' => $this->params, 'core' => $this->core, 'pid' => $this->cPid, 'order' => 'relevance', 'order.asc' => TRUE)); return $list; }
/** * This translates an internal "index_name" * * @access public * * @param string $index_name: The internal "index_name" to translate * @param string $table: Get the translation from this table * @param string $pid: Get the translation from this page * * @return string Localized label for $index_name */ public static function translate($index_name, $table, $pid) { // Save parameters for logging purposes. $_index_name = $index_name; $_pid = $pid; // Load labels into static variable for future use. static $labels = array(); // Sanitize input. $pid = max(intval($pid), 0); if (!$pid) { if (TYPO3_DLOG) { t3lib_div::devLog('[tx_dlf_helper->translate(' . $_index_name . ', ' . $table . ', ' . $_pid . ')] Invalid PID "' . $pid . '" for translation', self::$extKey, SYSLOG_SEVERITY_WARNING); } return $index_name; } // Check if "index_name" is an UID. if (tx_dlf_helper::testInt($index_name)) { $index_name = self::getIndexName($index_name, $table, $pid); } /* The $labels already contain the translated content element, but with the index_name of the translated content element itself * and not with the $index_name of the original that we receive here. So we have to determine the index_name of the * associated translated content element. E.g. $labels['title0'] != $index_name = title. */ // First fetch the uid of the received index_name $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', $table, 'pid=' . $pid . ' AND index_name="' . $index_name . '"' . self::whereClause($table), '', '', ''); if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { // Now we use the uid of the l18_parent to fetch the index_name of the translated content element. $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('index_name', $table, 'pid=' . $pid . ' AND l18n_parent=' . $resArray['uid'] . ' AND sys_language_uid=' . intval($GLOBALS['TSFE']->sys_language_content) . self::whereClause($table), '', '', ''); if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { // If there is an translated content element, overwrite the received $index_name. $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); $index_name = $resArray['index_name']; } } // Check if we already got a translation. if (empty($labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$index_name])) { // Check if this table is allowed for translation. if (in_array($table, array('tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures'))) { $additionalWhere = ' AND sys_language_uid IN (-1,0)'; if ($GLOBALS['TSFE']->sys_language_content > 0) { $additionalWhere = ' AND (sys_language_uid IN (-1,0) OR (sys_language_uid=' . intval($GLOBALS['TSFE']->sys_language_content) . ' AND l18n_parent=0))'; } // Get labels from database. $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'pid=' . $pid . $additionalWhere . self::whereClause($table), '', '', ''); if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { // Overlay localized labels if available. if ($GLOBALS['TSFE']->sys_language_content > 0) { $resArray = $GLOBALS['TSFE']->sys_page->getRecordOverlay($table, $resArray, $GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_mode == 'strict' ? 'hideNonTranslated' : ''); } if ($resArray) { $labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$resArray['index_name']] = $resArray['label']; } } } else { if (TYPO3_DLOG) { t3lib_div::devLog('[tx_dlf_helper->translate(' . $_index_name . ', ' . $table . ', ' . $_pid . ')] No translation with PID "' . $pid . '" available in table "' . $table . '" or translation not accessible', self::extKey, SYSLOG_SEVERITY_NOTICE); } } } else { if (TYPO3_DLOG) { t3lib_div::devLog('[tx_dlf_helper->translate(' . $_index_name . ', ' . $table . ', ' . $_pid . ')] No translations available for table "' . $table . '"', self::$extKey, SYSLOG_SEVERITY_WARNING); } } } if (!empty($labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$index_name])) { return $labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$index_name]; } else { return $index_name; } }
/** * Post-processing hook for the process_cmdmap() method. * * @access public * * @param string $command: 'move', 'copy', 'localize', 'inlineLocalizeSynchronize', 'delete' or 'undelete' * @param string $table: The destination table * @param integer $id: The uid of the record * @param mixed $value: The value for the command * @param \TYPO3\CMS\Core\DataHandling\DataHandler $pObj: The parent object * * @return void */ public function processCmdmap_postProcess($command, $table, $id, $value, $pObj) { if (in_array($command, array('move', 'delete', 'undelete')) && $table == 'tx_dlf_documents') { // Get Solr core. $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_dlf_solrcores.uid', 'tx_dlf_solrcores,tx_dlf_documents', 'tx_dlf_solrcores.uid=tx_dlf_documents.solrcore AND tx_dlf_documents.uid=' . intval($id) . tx_dlf_helper::whereClause('tx_dlf_solrcores'), '', '', '1'); if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { list($core) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result); switch ($command) { case 'move': case 'delete': // Establish Solr connection. if ($solr = tx_dlf_solr::getInstance($core)) { // Delete Solr document. $solr->service->deleteByQuery('uid:' . $id); $solr->service->commit(); if ($command == 'delete') { break; } } case 'undelete': // Reindex document. $doc =& tx_dlf_document::getInstance($id); if ($doc->ready) { $doc->save($doc->pid, $core); } else { if (TYPO3_DLOG) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_tcemain->processCmdmap_postProcess(' . $command . ', ' . $table . ', ' . $id . ', ' . $value . ', [' . get_class($pObj) . '])] Failed to re-index document with UID "' . $id . '"', $this->extKey, SYSLOG_SEVERITY_ERROR); } } break; } } } }
/** * 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); }
/** * Generates a navigation link * * @access protected * * @param string $label: The link's text * @param array $overrulePIvars: The new set of plugin variables * @param string $aTagParams: Additional HTML attributes for link tag * * @return string Typolink ready to output */ protected function makeLink($label, array $overrulePIvars = array(), $aTagParams = '') { // Merge plugin variables with new set of values. if (is_array($this->piVars)) { $piVars = $this->piVars; unset($piVars['DATA']); $overrulePIvars = tx_dlf_helper::array_merge_recursive_overrule($piVars, $overrulePIvars); } // Build typolink configuration array. $conf = array('useCacheHash' => 1, 'parameter' => $GLOBALS['TSFE']->id, 'ATagParams' => $aTagParams, 'additionalParams' => t3lib_div::implodeArrayForUrl($this->prefixId, $overrulePIvars, '', TRUE, FALSE), 'title' => $label); return $this->cObj->typoLink($label, $conf); }
/** * This builds a menu array for HMENU * * @access public * * @param string $content: The PlugIn content * @param array $conf: The PlugIn configuration * * @return array HMENU array */ public function makeMenuArray($content, $conf) { $this->init($conf); // Load current document. $this->loadDocument(); if ($this->doc === NULL) { // Quit without doing anything if required variables are not set. return array(); } else { // Set default values for page if not set. $this->piVars['page'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['page'], 1, $this->doc->numPages, 1); $this->piVars['double'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0); } $menuArray = array(); // Does the document have physical pages or is it an external file? if ($this->doc->physicalPages || !\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->doc->uid)) { // Get all logical units the current page is a part of. if (!empty($this->piVars['page']) && $this->doc->physicalPages) { $this->activeEntries = array_merge((array) $this->doc->smLinks['p2l'][$this->doc->physicalPages[0]], (array) $this->doc->smLinks['p2l'][$this->doc->physicalPages[$this->piVars['page']]]); if (!empty($this->piVars['double']) && $this->piVars['page'] < $this->doc->numPages) { $this->activeEntries = array_merge($this->activeEntries, (array) $this->doc->smLinks['p2l'][$this->doc->physicalPages[$this->piVars['page'] + 1]]); } } // Go through table of contents and create all menu entries. foreach ($this->doc->tableOfContents as $entry) { $menuArray[] = $this->getMenuEntry($entry, TRUE); } } else { // Go through table of contents and create top-level menu entries. foreach ($this->doc->tableOfContents as $entry) { $menuArray[] = $this->getMenuEntry($entry, FALSE); } // Get all child documents from database. $whereClause = 'tx_dlf_documents.partof=' . intval($this->doc->uid) . ' AND tx_dlf_documents.structure=tx_dlf_structures.uid AND tx_dlf_structures.pid=' . $this->doc->pid . tx_dlf_helper::whereClause('tx_dlf_documents') . tx_dlf_helper::whereClause('tx_dlf_structures'); if ($this->conf['excludeOther']) { $whereClause .= ' AND tx_dlf_documents.pid=' . intval($this->conf['pages']); } // Build table of contents from database. $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_dlf_documents.uid AS uid,tx_dlf_documents.title AS title,tx_dlf_documents.volume AS volume,tx_dlf_structures.index_name AS type', 'tx_dlf_documents,tx_dlf_structures', $whereClause, '', 'tx_dlf_documents.volume_sorting', ''); if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { $menuArray[0]['ITEM_STATE'] = 'CURIFSUB'; $menuArray[0]['_SUB_MENU'] = array(); while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { $entry = array('label' => $resArray['title'], 'type' => $resArray['type'], 'volume' => $resArray['volume'], 'pagination' => '', 'targetUid' => $resArray['uid']); $menuArray[0]['_SUB_MENU'][] = $this->getMenuEntry($entry, FALSE); } } } return $menuArray; }
/** * Helper to get flexform's items array for plugin "tx_dlf_search" * * @access public * * @param array &$params: An array with parameters * @param t3lib_TCEforms &$pObj: The parent object * * @return void */ public function itemsProcFunc_solrList(&$params, &$pObj) { if ($params['row']['pi_flexform']) { $pi_flexform = t3lib_div::xml2array($params['row']['pi_flexform']); $pages = $pi_flexform['data']['sDEF']['lDEF']['pages']['vDEF']; // There is a strange behavior where the uid from the flexform is prepended by the table's name and appended by its title. // i.e. instead of "18" it reads "pages_18|Title" if (!tx_dlf_helper::testInt($pages)) { $parts = explode('|', $pages); $pages = array_pop(explode('_', $parts[0])); } if ($pages > 0) { $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('label,uid', 'tx_dlf_solrcores', 'pid IN (' . intval($pages) . ',0)' . tx_dlf_helper::whereClause('tx_dlf_solrcores'), '', 'label', ''); if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_row($result)) { $params['items'][] = $resArray; } } } } }
/** * Adds Viewer javascript * * @access protected * * @return string Viewer script tags ready for output */ protected function addViewerJS() { $output = array(); // Add jQuery library. tx_dlf_helper::loadJQuery(); // Add OpenLayers library. $output[] = $this->addOpenLayersJS(); // Add viewer library. $output[] = ' <script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->extKey) . 'plugins/pageview/tx_dlf_utils.js"></script> <script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->extKey) . 'plugins/pageview/tx_dlf_ol3.js"></script> <script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->extKey) . 'plugins/pageview/tx_dlf_pageview_imagemanipulation_control.js"></script> <script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->extKey) . 'plugins/pageview/tx_dlf_pageview_fulltext_control.js"></script> <script type="text/javascript" src="' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->extKey) . 'plugins/pageview/tx_dlf_pageview.js"></script>'; // Add viewer configuration. $output[] = ' <script id="tx-dlf-pageview-initViewer" type="text/javascript"> window.onload = function() { if (dlfUtils.exists(dlfViewer)) { tx_dlf_viewer = new dlfViewer({ controls: ["' . implode('", "', $this->controls) . '"], div: "' . $this->conf['elementId'] . '", fulltexts: ["' . implode('", "', $this->fulltexts) . '"], images: ["' . implode('", "', $this->images) . '"] }) } } </script>'; return implode("\n", $output); }
/** * This is a singleton class, thus the constructor should be private/protected * * @access protected * * @param integer $uid: The UID of the document to parse or URL to XML file * @param integer $pid: If > 0, then only document with this PID gets loaded * * @return void */ protected function __construct($uid, $pid) { // Prepare to check database for the requested document. if (tx_dlf_helper::testInt($uid)) { $whereClause = 'tx_dlf_documents.uid=' . intval($uid) . tx_dlf_helper::whereClause('tx_dlf_documents'); } else { // Cast to string for safety reasons. $location = (string) $uid; // Try to load METS file. if ($this->load($location)) { // Initialize core METS object. $this->init(); if ($this->mets !== NULL) { // Check for METS object @ID. if (!empty($this->mets['OBJID'])) { $this->recordId = (string) $this->mets['OBJID']; } // Get hook objects. $hookObjects = tx_dlf_helper::getHookObjects('common/class.tx_dlf_document.php'); // Apply hooks. foreach ($hookObjects as $hookObj) { if (method_exists($hookObj, 'construct_postProcessRecordId')) { $hookObj->construct_postProcessRecordId($this->xml, $this->recordId); } } } else { // No METS part found. return; } } else { // Loading failed. return; } if (!empty($this->recordId)) { $whereClause = 'tx_dlf_documents.record_id=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->recordId, 'tx_dlf_documents') . tx_dlf_helper::whereClause('tx_dlf_documents'); } else { // There is no record identifier and there should be no hit in the database. $whereClause = '1=-1'; } } // Check for PID if needed. if ($pid) { $whereClause .= ' AND tx_dlf_documents.pid=' . intval($pid); } // Get document PID and location from database. $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_dlf_documents.uid AS uid,tx_dlf_documents.pid AS pid,tx_dlf_documents.record_id AS record_id,tx_dlf_documents.partof AS partof,tx_dlf_documents.thumbnail AS thumbnail,tx_dlf_documents.location AS location', 'tx_dlf_documents', $whereClause, '', '', '1'); if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) { list($this->uid, $this->pid, $this->recordId, $this->parentId, $this->thumbnail, $this->location) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result); $this->thumbnailLoaded = TRUE; // Load XML file if necessary... if ($this->mets === NULL && $this->load($this->location)) { // ...and set some basic properties. $this->init(); } // Do we have a METS object now? if ($this->mets !== NULL) { // Set new location if necessary. if (!empty($location)) { $this->location = $location; } // Document ready! $this->ready = TRUE; } } elseif ($this->mets !== NULL) { // Set location as UID for documents not in database. $this->uid = $location; $this->location = $location; // Document ready! $this->ready = TRUE; } else { if (TYPO3_DLOG) { t3lib_div::devLog('[tx_dlf_document->__construct(' . $uid . ', ' . $pid . ')] No document with UID "' . $uid . '" found or document not accessible', self::$extKey, SYSLOG_SEVERITY_ERROR); } } }
/** * The main method of the PlugIn * * @access public * * @param string $content: The PlugIn content * @param array $conf: The PlugIn configuration * * @return void */ public function main($content, $conf) { $this->init($conf); // Don't cache the output. $this->setCache(FALSE); // Create XML document. $rss = new DOMDocument('1.0', 'utf-8'); // Add mandatory root element. $root = $rss->createElement('rss'); $root->setAttribute('version', '2.0'); // Add channel element. $channel = $rss->createElement('channel'); $channel->appendChild($rss->createElement('title', htmlspecialchars($this->conf['title'], ENT_NOQUOTES, 'UTF-8'))); $channel->appendChild($rss->createElement('link', htmlspecialchars(t3lib_div::locationHeaderUrl($this->pi_linkTP_keepPIvars_url()), ENT_NOQUOTES, 'UTF-8'))); if (!empty($this->conf['description'])) { $channel->appendChild($rss->createElement('description', htmlspecialchars($this->conf['description'], ENT_QUOTES, 'UTF-8'))); } $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_dlf_libraries.label AS label', 'tx_dlf_libraries', 'tx_dlf_libraries.pid=' . intval($this->conf['pages']) . ' AND tx_dlf_libraries.uid=' . intval($this->conf['library']) . tx_dlf_helper::whereClause('tx_dlf_libraries'), '', '', '1'); if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); $channel->appendChild($rss->createElement('copyright', htmlspecialchars($resArray['label'], ENT_NOQUOTES, 'UTF-8'))); } $channel->appendChild($rss->createElement('pubDate', date('r', $GLOBALS['EXEC_TIME']))); $channel->appendChild($rss->createElement('generator', htmlspecialchars($this->conf['useragent'], ENT_NOQUOTES, 'UTF-8'))); // Add item elements. if (!$this->conf['excludeOther'] || empty($this->piVars['collection']) || t3lib_div::inList($this->conf['collections'], $this->piVars['collection'])) { $additionalWhere = ''; // Check for pre-selected collections. if (!empty($this->piVars['collection'])) { $additionalWhere = ' AND tx_dlf_collections.uid=' . intval($this->piVars['collection']); } elseif (!empty($this->conf['collections'])) { $additionalWhere = ' AND tx_dlf_collections.uid IN (' . $GLOBALS['TYPO3_DB']->cleanIntList($this->conf['collections']) . ')'; } $result = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('tx_dlf_documents.uid AS uid,tx_dlf_documents.partof AS partof,tx_dlf_documents.title AS title,tx_dlf_documents.volume AS volume,tx_dlf_documents.author AS author,tx_dlf_documents.record_id AS guid,tx_dlf_documents.tstamp AS tstamp,tx_dlf_documents.crdate AS crdate', 'tx_dlf_documents', 'tx_dlf_relations', 'tx_dlf_collections', 'AND tx_dlf_documents.pid=' . intval($this->conf['pages']) . ' AND tx_dlf_relations.ident=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('docs_colls', 'tx_dlf_relations') . ' AND tx_dlf_collections.pid=' . intval($this->conf['pages']) . $additionalWhere . tx_dlf_helper::whereClause('tx_dlf_documents') . tx_dlf_helper::whereClause('tx_dlf_collections'), 'tx_dlf_documents.uid', 'tx_dlf_documents.tstamp DESC', intval($this->conf['limit'])); if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) { // Add each record as item element. while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { $item = $rss->createElement('item'); $title = ''; // Get title of superior document. if ((empty($resArray['title']) || !empty($this->conf['prependSuperiorTitle'])) && !empty($resArray['partof'])) { $superiorTitle = tx_dlf_document::getTitle($resArray['partof'], TRUE); if (!empty($superiorTitle)) { $title .= '[' . $superiorTitle . ']'; } } // Get title of document. if (!empty($resArray['title'])) { $title .= ' ' . $resArray['title']; } // Set default title if empty. if (empty($title)) { $title = $this->pi_getLL('noTitle'); } // Append volume information. if (!empty($resArray['volume'])) { $title .= ', ' . $this->pi_getLL('volume') . ' ' . $resArray['volume']; } // Is this document new or updated? if ($resArray['crdate'] == $resArray['tstamp']) { $title = $this->pi_getLL('new') . ' ' . trim($title); } else { $title = $this->pi_getLL('update') . ' ' . trim($title); } $item->appendChild($rss->createElement('title', htmlspecialchars($title, ENT_NOQUOTES, 'UTF-8'))); // Add link. $linkConf = array('parameter' => $this->conf['targetPid'], 'forceAbsoluteUrl' => 1, 'additionalParams' => t3lib_div::implodeArrayForUrl($this->prefixId, array('id' => $resArray['uid']), '', TRUE, FALSE)); $item->appendChild($rss->createElement('link', htmlspecialchars($this->cObj->typoLink_URL($linkConf), ENT_NOQUOTES, 'UTF-8'))); // Add author if applicable. if (!empty($resArray['author'])) { $item->appendChild($rss->createElement('author', htmlspecialchars($resArray['author'], ENT_NOQUOTES, 'UTF-8'))); } // Add online publication date. $item->appendChild($rss->createElement('pubDate', date('r', $resArray['crdate']))); // Add internal record identifier. $item->appendChild($rss->createElement('guid', htmlspecialchars($resArray['guid'], ENT_NOQUOTES, 'UTF-8'))); $channel->appendChild($item); } } } $root->appendChild($channel); // Build XML output. $rss->appendChild($root); $content = $rss->saveXML(); // Clean output buffer. t3lib_div::cleanOutputBuffers(); // Send headers. header('HTTP/1.1 200 OK'); header('Cache-Control: no-cache'); header('Content-Length: ' . strlen($content)); header('Content-Type: application/rss+xml; charset=utf-8'); header('Date: ' . date('r', $GLOBALS['EXEC_TIME'])); header('Expires: ' . date('r', $GLOBALS['EXEC_TIME'])); echo $content; // Flush output buffer and end script processing. ob_end_flush(); exit; }
/** * The main method of the PlugIn * * @access public * * @param string $content: The PlugIn content * @param array $conf: The PlugIn configuration * * @return string The content that is displayed on the website */ public function main($content, $conf) { $this->init($conf); // Disable caching for this plugin. $this->setCache(FALSE); // Quit without doing anything if required variables are not set. if (empty($this->conf['solrcore'])) { if (TYPO3_DLOG) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_search->main(' . $content . ', [data])] Incomplete plugin configuration', $this->extKey, SYSLOG_SEVERITY_WARNING, $conf); } return $content; } if (!isset($this->piVars['query']) && empty($this->piVars['extQuery'])) { // Add javascript for search suggestions if enabled and jQuery autocompletion is available. if (!empty($this->conf['suggest'])) { $this->addAutocompleteJS(); } // 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/search/template.tmpl'), '###TEMPLATE###'); } // Configure @action URL for form. $linkConf = array('parameter' => $GLOBALS['TSFE']->id, 'forceAbsoluteUrl' => 1); // Fill markers. $markerArray = array('###ACTION_URL###' => $this->cObj->typoLink_URL($linkConf), '###LABEL_QUERY###' => $this->pi_getLL('label.query'), '###LABEL_SUBMIT###' => $this->pi_getLL('label.submit'), '###FIELD_QUERY###' => $this->prefixId . '[query]', '###QUERY###' => '', '###FULLTEXTSWITCH###' => $this->addFulltextSwitch(), '###FIELD_DOC###' => $this->conf['searchIn'] == 'document' || $this->conf['searchIn'] == 'all' ? $this->addCurrentDocument() : '', '###FIELD_COLL###' => $this->conf['searchIn'] == 'collection' || $this->conf['searchIn'] == 'all' ? $this->addCurrentCollection() : '', '###ADDITIONAL_INPUTS###' => $this->addEncryptedCoreName(), '###FACETS_MENU###' => $this->addFacetsMenu()); // Get additional fields for extended search. $extendedSearch = $this->addExtendedSearch(); // Display search form. $content .= $this->cObj->substituteSubpart($this->cObj->substituteMarkerArray($this->template, $markerArray), '###EXT_SEARCH_ENTRY###', $extendedSearch); return $this->pi_wrapInBaseClass($content); } else { // Instantiate search object. $solr = tx_dlf_solr::getInstance($this->conf['solrcore']); if (!$solr->ready) { if (TYPO3_DLOG) { \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_search->main(' . $content . ', [data])] Apache Solr not available', $this->extKey, SYSLOG_SEVERITY_ERROR, $conf); } return $content; } // Build label for result list. $label = $this->pi_getLL('search', '', TRUE); if (!empty($this->piVars['query'])) { $label .= htmlspecialchars(sprintf($this->pi_getLL('for', ''), $this->piVars['query'])); } // Prepare query parameters. $params = array(); // Set search query. if (!empty($this->conf['fulltext']) && !empty($this->piVars['fulltext'])) { // Search in fulltext field if applicable. $query = 'fulltext:(' . tx_dlf_solr::escapeQuery($this->piVars['query']) . ')'; // Add highlighting for fulltext. $params['hl'] = 'true'; $params['hl.fl'] = 'fulltext'; } else { // Retain given search field if valid. $query = tx_dlf_solr::escapeQueryKeepField($this->piVars['query'], $this->conf['pages']); } // Add extended search query. if (!empty($this->piVars['extQuery']) && is_array($this->piVars['extQuery'])) { $allowedOperators = array('AND', 'OR', 'NOT'); $allowedFields = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->conf['extendedFields'], TRUE); for ($i = 0; $i < count($this->piVars['extQuery']); $i++) { if (!empty($this->piVars['extQuery'][$i])) { if (in_array($this->piVars['extOperator'][$i], $allowedOperators) && in_array($this->piVars['extField'][$i], $allowedFields)) { if (!empty($query)) { $query .= ' ' . $this->piVars['extOperator'][$i] . ' '; } $query .= tx_dlf_indexing::getIndexFieldName($this->piVars['extField'][$i], $this->conf['pages']) . ':(' . tx_dlf_solr::escapeQuery($this->piVars['extQuery'][$i]) . ')'; } } } } // Add filter query for faceting. if (!empty($this->piVars['fq'])) { $params['fq'] = $this->piVars['fq']; } // Add filter query for in-document searching. if ($this->conf['searchIn'] == 'document' || $this->conf['searchIn'] == 'all') { if (!empty($this->piVars['id']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->piVars['id'])) { $params['fq'][] = 'uid:(' . $this->piVars['id'] . ') OR partof:(' . $this->piVars['id'] . ')'; $label .= htmlspecialchars(sprintf($this->pi_getLL('in', ''), tx_dlf_document::getTitle($this->piVars['id']))); } } // Add filter query for in-collection searching. if ($this->conf['searchIn'] == 'collection' || $this->conf['searchIn'] == 'all') { if (!empty($this->piVars['collection']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->piVars['collection'])) { $index_name = tx_dlf_helper::getIndexName($this->piVars['collection'], 'tx_dlf_collections', $this->conf['pages']); $params['fq'][] = 'collection_faceting:("' . tx_dlf_solr::escapeQuery($index_name) . '")'; $label .= sprintf($this->pi_getLL('in', '', TRUE), tx_dlf_helper::translate($index_name, 'tx_dlf_collections', $this->conf['pages'])); } } // Add filter query for collection restrictions. if ($this->conf['collections']) { $collIds = explode(',', $this->conf['collections']); $collIndexNames = array(); foreach ($collIds as $collId) { $collIndexNames[] = tx_dlf_solr::escapeQuery(tx_dlf_helper::getIndexName(intval($collId), 'tx_dlf_collections', $this->conf['pages'])); } // Last value is fake and used for distinction in $this->addCurrentCollection() $params['fq'][] = 'collection_faceting:("' . implode('" OR "', $collIndexNames) . '" OR "FakeValueForDistinction")'; } // Set search parameters. $solr->limit = max(intval($this->conf['limit']), 1); $solr->cPid = $this->conf['pages']; $solr->params = $params; // Perform search. $results = $solr->search($query); $results->metadata = array('label' => $label, 'description' => '<p class="tx-dlf-search-numHits">' . htmlspecialchars(sprintf($this->pi_getLL('hits', ''), $solr->numberOfHits, count($results))) . '</p>', 'thumbnail' => '', 'options' => $results->metadata['options']); $results->save(); // Clean output buffer. \TYPO3\CMS\Core\Utility\GeneralUtility::cleanOutputBuffers(); // Keep some plugin variables. $linkConf['parameter'] = $this->conf['targetPid']; if (!empty($this->piVars['order'])) { $linkConf['additionalParams'] = \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl($this->prefixId, array('order' => $this->piVars['order'], 'asc' => !empty($this->piVars['asc']) ? '1' : '0'), '', TRUE, FALSE); } // Send headers. header('Location: ' . \TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl($this->cObj->typoLink_URL($linkConf))); // Flush output buffer and end script processing. ob_end_flush(); exit; } }
/** * The main method of the PlugIn * * @access public * * @param string $content: The PlugIn content * @param array $conf: The PlugIn configuration * * @return string The content that is displayed on the website */ public function main($content, $conf) { $this->init($conf); // Load current document. $this->loadDocument(); if ($this->doc === NULL || $this->doc->numPages < 1) { // Quit without doing anything if required variables are not set. return $content; } else { // Set default values if not set. // page may be integer or string (physical page attribute) if ((int) $this->piVars['page'] > 0 || empty($this->piVars['page'])) { $this->piVars['page'] = tx_dlf_helper::intInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1); } else { $this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalPages); } $this->piVars['double'] = tx_dlf_helper::intInRange($this->piVars['double'], 0, 1, 0); } // 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/pageview/template.tmpl'), '###TEMPLATE###'); } // Get image data. $this->images[0] = $this->getImageUrl($this->piVars['page']); $this->fulltexts[0] = $this->getAltoUrl($this->piVars['page']); if ($this->piVars['double'] && $this->piVars['page'] < $this->doc->numPages) { $this->images[1] = $this->getImageUrl($this->piVars['page'] + 1); $this->fulltexts[1] = $this->getAltoUrl($this->piVars['page'] + 1); } // Get the controls for the map. $this->controls = $this->getMapControls(); // Fill in the template markers. $markerArray = array('###VIEWER_JS###' => $this->addViewerJS()); $content .= $this->cObj->substituteMarkerArray($this->template, $markerArray); return $this->pi_wrapInBaseClass($content); }
/** * Processes a physical unit for the Solr index * * @access protected * * @param tx_dlf_document &$doc: The METS document * @param integer $page: The page number * @param array $physicalUnit: Array of the physical unit to process * * @return integer 0 on success or 1 on failure */ protected static function processPhysical(tx_dlf_document &$doc, $page, array $physicalUnit) { $errors = 0; // Read extension configuration. $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]); if (!empty($physicalUnit['files'][$extConf['fileGrpFulltext']])) { $file = $doc->getFileLocation($physicalUnit['files'][$extConf['fileGrpFulltext']]); // Load XML file. if (\TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($file) || version_compare(phpversion(), '5.3.3', '<')) { // Set user-agent to identify self when fetching XML data. if (!empty($extConf['useragent'])) { @ini_set('user_agent', $extConf['useragent']); } // Turn off libxml's error logging. $libxmlErrors = libxml_use_internal_errors(TRUE); // disable entity loading $previousValueOfEntityLoader = libxml_disable_entity_loader(TRUE); // Load XML from file. $xml = simplexml_load_string(file_get_contents($file)); // reset entity loader setting libxml_disable_entity_loader($previousValueOfEntityLoader); // Reset libxml's error logging. libxml_use_internal_errors($libxmlErrors); if ($xml === FALSE) { return 1; } } else { return 1; } // Load class. if (!class_exists('Apache_Solr_Document')) { require_once \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:' . self::$extKey . '/lib/SolrPhpClient/Apache/Solr/Document.php'); } // Create new Solr document. $solrDoc = new Apache_Solr_Document(); // Create unique identifier from document's UID and unit's XML ID. $solrDoc->setField('id', $doc->uid . $physicalUnit['id']); $solrDoc->setField('uid', $doc->uid); $solrDoc->setField('pid', $doc->pid); $solrDoc->setField('page', $page); if (!empty($physicalUnit['files'][$extConf['fileGrpThumbs']])) { $solrDoc->setField('thumbnail', $doc->getFileLocation($physicalUnit['files'][$extConf['fileGrpThumbs']])); } $solrDoc->setField('partof', $doc->parentId); $solrDoc->setField('root', $doc->rootId); $solrDoc->setField('sid', $physicalUnit['id']); $solrDoc->setField('toplevel', FALSE); $solrDoc->setField('type', $physicalUnit['type'], self::$fields['fieldboost']['type']); $solrDoc->setField('fulltext', tx_dlf_alto::getRawText($xml)); try { self::$solr->service->addDocument($solrDoc); } catch (Exception $e) { if (!defined('TYPO3_cliMode')) { $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', tx_dlf_helper::getLL('flash.solrException', TRUE) . '<br />' . htmlspecialchars($e->getMessage()), tx_dlf_helper::getLL('flash.error', TRUE), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, TRUE); tx_dlf_helper::addMessage($message); } return 1; } } return $errors; }
/** * Get metadata configuration from database * * @access protected * * @return void */ protected function loadConfig() { $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_dlf_metadata.index_name AS index_name,tx_dlf_metadata.wrap AS wrap,tx_dlf_metadata.is_listed AS is_listed,tx_dlf_metadata.is_sortable AS is_sortable', 'tx_dlf_metadata', '(tx_dlf_metadata.is_listed=1 OR tx_dlf_metadata.is_sortable=1) AND tx_dlf_metadata.pid=' . intval($this->conf['pages']) . tx_dlf_helper::whereClause('tx_dlf_metadata'), '', 'tx_dlf_metadata.sorting ASC', ''); while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { if ($resArray['is_listed']) { $this->metadata[$resArray['index_name']] = array('wrap' => $resArray['wrap'], 'label' => tx_dlf_helper::translate($resArray['index_name'], 'tx_dlf_metadata', $this->conf['pages'])); } if ($resArray['is_sortable']) { $this->sortables[$resArray['index_name']] = tx_dlf_helper::translate($resArray['index_name'], 'tx_dlf_metadata', $this->conf['pages']); } } }
/** * This is a singleton class, thus the constructor should be private/protected * * @access protected * * @param string $core: The name of the core to use * * @return void */ protected function __construct($core) { // Load class. if (!class_exists('Apache_Solr_Service')) { require_once t3lib_div::getFileAbsFileName('EXT:' . self::$extKey . '/lib/SolrPhpClient/Apache/Solr/Service.php'); } // Get Solr credentials. $conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::$extKey]); $host = $conf['solrHost'] ? $conf['solrHost'] : 'localhost'; // Prepend username and password to hostname. if ($conf['solrUser'] && $conf['solrPass']) { $host = $conf['solrUser'] . ':' . $conf['solrPass'] . '@' . $host; } // Set port if not set. $port = tx_dlf_helper::intInRange($conf['solrPort'], 1, 65535, 8180); // Append core name to path. $path = trim($conf['solrPath'], '/') . '/' . $core; // Instantiate Apache_Solr_Service class. $this->service = t3lib_div::makeInstance('Apache_Solr_Service', $host, $port, $path); // Check if connection is established. if ($this->service->ping() !== FALSE) { // Do not collapse single value arrays. $this->service->setCollapseSingleValueArrays = FALSE; // Set core name. $this->core = $core; // Instantiation successful! $this->ready = TRUE; } }
/** * Process verb "ListSets" * * @access protected * * @return string Substitution for subpart "###RESPONSE###" */ protected function verbListSets() { // Check for invalid arguments. if (count($this->piVars) > 1) { if (!empty($this->piVars['resumptionToken'])) { return $this->error('badResumptionToken'); } else { return $this->error('badArgument'); } } // Get set information. $additionalWhere = ''; if (!$this->conf['show_userdefined']) { $additionalWhere = ' AND tx_dlf_collections.fe_cruser_id=0'; } $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_dlf_collections.oai_name AS oai_name,tx_dlf_collections.label AS label', 'tx_dlf_collections', 'tx_dlf_collections.sys_language_uid IN (-1,0) AND NOT tx_dlf_collections.oai_name=\'\' AND tx_dlf_collections.pid=' . intval($this->conf['pages']) . $additionalWhere . tx_dlf_helper::whereClause('tx_dlf_collections'), 'tx_dlf_collections.oai_name', 'tx_dlf_collections.oai_name', ''); if (!$GLOBALS['TYPO3_DB']->sql_num_rows($result)) { return $this->error('noSetHierarchy'); } // Add set list node. $ListSets = $this->oai->createElementNS('http://www.openarchives.org/OAI/2.0/', 'ListSets'); while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { // Add set node. $set = $this->oai->createElementNS('http://www.openarchives.org/OAI/2.0/', 'set'); $set->appendChild($this->oai->createElementNS('http://www.openarchives.org/OAI/2.0/', 'setSpec', htmlspecialchars($resArray['oai_name'], ENT_NOQUOTES, 'UTF-8'))); $set->appendChild($this->oai->createElementNS('http://www.openarchives.org/OAI/2.0/', 'setName', htmlspecialchars($resArray['label'], ENT_NOQUOTES, 'UTF-8'))); $ListSets->appendChild($set); } return $ListSets; }
/** * Sets default plugin variables from typoscript * (stdWrap backport from TYPO3 6.2) * @see http://forge.typo3.org/issues/22045 * * @access public * * @return void */ public function pi_setPiVarDefaults() { if (is_array($this->conf['_DEFAULT_PI_VARS.'])) { foreach ($this->conf['_DEFAULT_PI_VARS.'] as $GPkey => $GPval) { if (strpos($GPkey, '.')) { $GPkey = substr($GPkey, 0, -1); } if (is_array($this->conf['_DEFAULT_PI_VARS.'][$GPkey . '.']['stdWrap.'])) { $GPval = $GPval ? $GPval : ''; $this->conf['_DEFAULT_PI_VARS.'][$GPkey] = $this->cObj->stdWrap($GPval, $this->conf['_DEFAULT_PI_VARS.'][$GPkey . '.']['stdWrap.']); unset($this->conf['_DEFAULT_PI_VARS.'][$GPkey . '.']['stdWrap.']); } } $this->piVars = tx_dlf_helper::array_merge_recursive_overrule($this->conf['_DEFAULT_PI_VARS.'], is_array($this->piVars) ? $this->piVars : array()); } }
/** * Update all outdated metadata configuration records * * @access protected * * @return void */ protected function updateMetadataConfig() { $metadataUids = $this->getMetadataConfig(); if (!empty($metadataUids)) { $data = array(); // Get all old metadata configuration records. $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_dlf_metadata.uid AS uid,tx_dlf_metadata.pid AS pid,tx_dlf_metadata.cruser_id AS cruser_id,tx_dlf_metadata.encoded AS encoded,tx_dlf_metadata.xpath AS xpath,tx_dlf_metadata.xpath_sorting AS xpath_sorting', 'tx_dlf_metadata', 'tx_dlf_metadata.uid IN (' . implode(',', $metadataUids) . ')' . tx_dlf_helper::whereClause('tx_dlf_metadata'), '', '', ''); while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { $newId = uniqid('NEW'); // Copy record to new table. $data['tx_dlf_metadataformat'][$newId] = array('pid' => $resArray['pid'], 'cruser_id' => $resArray['cruser_id'], 'parent_id' => $resArray['uid'], 'encoded' => $resArray['encoded'], 'xpath' => $resArray['xpath'], 'xpath_sorting' => $resArray['xpath_sorting']); // Add reference to old table. $data['tx_dlf_metadata'][$resArray['uid']]['format'] = $newId; } if (!empty($data)) { // Process datamap. $substUids = tx_dlf_helper::processDBasAdmin($data); unset($data); if (!empty($substUids)) { $message = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('update.metadataConfigOkay', TRUE), $GLOBALS['LANG']->getLL('update.metadataConfig', TRUE), t3lib_FlashMessage::OK, FALSE); } else { $message = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('update.metadataConfigNotOkay', TRUE), $GLOBALS['LANG']->getLL('update.metadataConfig', TRUE), t3lib_FlashMessage::WARNING, FALSE); } $this->content .= $message->render(); } } }