Initial upload to Launchpad.

This commit is contained in:
Sebastian Meyer 2011-03-09 16:36:27 +01:00
commit 65ccaf31ce
113 changed files with 29319 additions and 0 deletions

View File

@ -0,0 +1,119 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*/
if (!defined('TYPO3_cliMode')) {
die('You cannot run this script directly!');
}
/**
* CLI script for the 'dlf' extension.
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @copyright Copyright (c) 2010, Sebastian Meyer, SLUB Dresden
* @version $Id: class.tx_dlf_cli.php 481 2010-12-22 18:22:54Z smeyer $
* @package TYPO3
* @subpackage tx_dlf
* @access public
*/
class tx_dlf_cli extends t3lib_cli {
public $cli_help = array (
'name' => 'Command Line Interface for the Digital Library Framework',
'synopsis' => '###OPTIONS###',
'description' => '',
'examples' => '/PATH/TO/TYPO3/cli_dispatch.phpsh dlf TASK -ARG1=VALUE1 -ARG2=VALUE2',
'options' => '',
'license' => 'GNU GPL - free software!',
'author' => 'Sebastian Meyer <sebastian.meyer@slub-dresden.de>',
);
/**
* Main function of the script.
*
* @access public
*
* @return void
*/
public function main() {
switch ((string) $this->cli_args['_DEFAULT'][1]) {
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], 0, TRUE);
// ...save it to the database...
if (!$doc->save(intval($this->cli_args['-pid'][0]), $this->cli_args['-core'][0])) {
$this->cli_echo('ERROR: Document '.$this->cli_args['-doc'][0].' not saved and indexed'.LF);
return 1;
}
break;
default:
$this->cli_help();
break;
}
return 0;
}
public function __construct() {
// Run parent constructor.
parent::t3lib_cli();
}
}
$SOBE = t3lib_div::makeInstance('tx_dlf_cli');
$SOBE->main();
?>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,62 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*/
/**
* Base class 'tx_dlf_format' for the 'dlf' extension.
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @copyright Copyright (c) 2010, Sebastian Meyer, SLUB Dresden
* @version $Id: class.tx_dlf_document.php 104 2010-06-12 21:12:03Z smeyer $
* @package TYPO3
* @subpackage tx_dlf
* @access public
* @abstract
*/
interface tx_dlf_format {
/**
* This extracts metadata from XML
*
* @access public
*
* @param SimpleXMLElement $xml: The XML to extract the metadata from
* @param array &$metadata: The metadata array to fill
*
* @return void
*/
public function extractMetadata(SimpleXMLElement $xml, array &$metadata);
}
/* No xclasses for interfaces!
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/common/class.tx_dlf_format.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/common/class.tx_dlf_format.php']);
}
*/
?>

View File

@ -0,0 +1,846 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*/
/**
* Helper class 'tx_dlf_helper' for the 'dlf' extension.
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @copyright Copyright (c) 2010, Sebastian Meyer, SLUB Dresden
* @version $Id: class.tx_dlf_helper.php 499 2010-12-23 12:40:24Z smeyer $
* @package TYPO3
* @subpackage tx_dlf
* @access public
*/
class tx_dlf_helper {
/**
* The extension key
*
* @var string
* @access public
*/
public static $extKey = 'dlf';
/**
* Searches the array recursively for a given value and returns the corresponding key if successful
* @see http://php.net/array_search
*
* @access public
*
* @param mixed $needle: The searched value
* @param array $haystack: The array to search in
* @param boolean $strict: Check needle's type, too?
*
* @return mixed Returns the needle's key if found and FALSE otherwise
*/
public static function array_search_recursive($needle, $haystack, $strict = FALSE) {
foreach ($haystack as $key => $value) {
$current = $key;
if (($strict && $value === $needle) || (!$strict && $value == $needle) || (is_array($value) && self::array_search_recursive($needle, $value, $strict) !== FALSE)) {
return $current;
}
}
return FALSE;
}
/**
* Check if given identifier is a valid identifier of the German National Library
* @see http://support.d-nb.de/iltis/onlineRoutinen/Pruefziffernberechnung.htm
*
* @access public
*
* @param string $id: The identifier to check
* @param string $type: What type is the identifier supposed to be?
* Possible values: PPN, IDN, PND, ZDB, SWD, GKD
*
* @return boolean Is $id a valid GNL identifier of the given $type?
*/
public static function checkIdentifier($id, $type) {
$digits = substr($id, 0, 8);
$checksum = 0;
for ($i = 0; $i < strlen($digits); $i++) {
$checksum += (9 - $i) * intval(substr($digits, $i, 1));
}
$checksum = (11 - ($checksum % 11)) % 11;
switch (strtoupper($type)) {
case 'PPN':
case 'IDN':
case 'PND':
if ($checksum == 10) {
$checksum = 'X';
}
if (!preg_match('/[0-9]{8}[0-9X]{1}/i', $id)) {
return FALSE;
} elseif (strtoupper(substr($id, -1, 1)) != $checksum) {
return FALSE;
}
break;
case 'ZDB':
if ($checksum == 10) {
$checksum = 'X';
}
if (!preg_match('/[0-9]{8}-[0-9X]{1}/i', $id)) {
return FALSE;
} elseif (strtoupper(substr($id, -1, 1)) != $checksum) {
return FALSE;
}
break;
case 'SWD':
$checksum = 11 - $checksum;
if (!preg_match('/[0-9]{8}-[0-9]{1}/i', $id)) {
return FALSE;
} elseif ($checksum == 10) {
return self::checkIdentifier(($digits + 1).substr($id, -2, 2), 'SWD');
} elseif (substr($id, -1, 1) != $checksum) {
return FALSE;
}
break;
case 'GKD':
$checksum = 11 - $checksum;
if ($checksum == 10) {
$checksum = 'X';
}
if (!preg_match('/[0-9]{8}-[0-9X]{1}/i', $id)) {
return FALSE;
} elseif (strtoupper(substr($id, -1, 1)) != $checksum) {
return FALSE;
}
break;
}
return TRUE;
}
/**
* Get a backend user object (even in frontend mode)
*
* @access public
*
* @return t3lib_beUserAuth Instance of t3lib_beUserAuth or NULL on failure
*/
public static function getBeUser() {
if (TYPO3_MODE === 'FE') {
// TODO: Anpassen! (aus typo3/init.php übernommen)
$userObj = t3lib_div::makeInstance('t3lib_beUserAuth');
$userObj->start();
$userObj->backendCheckLogin();
return $userObj;
} elseif (TYPO3_MODE === 'BE') {
return $GLOBALS['BE_USER'];
} else {
trigger_error('Unexpected TYPO3_MODE', E_USER_WARNING);
return;
}
}
/**
* Get the "index_name" for an UID
*
* @access public
*
* @param integer $uid: The UID of the record
* @param string $table: Get the "index_name" from this table
* @param string $pid: Get the "index_name" from this page
*
* @return string "index_name" for the given UID
*/
public static function getIndexName($uid, $table, $pid) {
$uid = max(intval($uid), 0);
$pid = max(intval($pid), 0);
if (!$uid || !$pid || !in_array($table, array ('tx_dlf_collections', 'tx_dlf_libraries', 'tx_dlf_metadata', 'tx_dlf_structures'))) {
trigger_error('At least one argument is not valid', E_USER_WARNING);
return '';
}
$_result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
$table.'.index_name AS index_name',
$table,
$table.'.uid='.$uid.' AND '.$table.'.pid='.$pid.self::whereClause($table),
'',
'',
'1'
);
if ($GLOBALS['TYPO3_DB']->sql_num_rows($_result) > 0) {
$resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($_result);
return $resArray['index_name'];
}
trigger_error('No "index_name" with UID '.$uid.' found for PID '.$pid.' in table '.$table, E_USER_WARNING);
return '';
}
/**
* Get language name from 'static_info_tables'
* TODO: 3-stellige Sprachcodes
*
* @access public
*
* @param string $code: ISO 3166-2 language code
*
* @return string Localized full name of language or unchanged input
*/
public static function getLanguageName($code) {
$code = strtoupper(trim($code));
if (!preg_match('/^[A-Z]{2}$/', $code) || !t3lib_extMgm::isLoaded('static_info_tables')) {
trigger_error('Invalid language code or extension "static_info_tables" not loaded', E_USER_WARNING);
return $code;
}
if (!$GLOBALS['TSFE']->lang || !t3lib_extMgm::isLoaded('static_info_tables_'.$GLOBALS['TSFE']->lang)) {
$field = 'lg_name_en';
} else {
$field = 'lg_name_'.$GLOBALS['TSFE']->lang;
}
$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'static_languages.'.$field.' AS '.$field,
'static_languages',
'static_languages.lg_iso_2='.$GLOBALS['TYPO3_DB']->fullQuoteStr($code, 'static_languages'),
'',
'',
'1'
);
if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) {
$resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
return $resArray[$field];
} else {
trigger_error('Language code not found in extension "static_info_tables"', E_USER_WARNING);
return $code;
}
}
/**
* Get the URN of an object
* @see http://www.persistent-identifier.de/?link=316
*
* @access public
*
* @param string $base: The namespace and base URN
* @param string $id: The object's identifier
*
* @return string Uniform Resource Name as string
*/
public static function getURN($base, $id) {
$concordance = array(
'0' => 1,
'1' => 2,
'2' => 3,
'3' => 4,
'4' => 5,
'5' => 6,
'6' => 7,
'7' => 8,
'8' => 9,
'9' => 41,
'a' => 18,
'b' => 14,
'c' => 19,
'd' => 15,
'e' => 16,
'f' => 21,
'g' => 22,
'h' => 23,
'i' => 24,
'j' => 25,
'k' => 42,
'l' => 26,
'm' => 27,
'n' => 13,
'o' => 28,
'p' => 29,
'q' => 31,
'r' => 12,
's' => 32,
't' => 33,
'u' => 11,
'v' => 34,
'w' => 35,
'x' => 36,
'y' => 37,
'z' => 38,
'-' => 39,
':' => 17,
);
$urn = strtolower($base.$id);
if (preg_match('/[^a-z0-9:-]/', $urn)) {
trigger_error('Invalid chars in URN', E_USER_WARNING);
return '';
}
$digits = '';
for ($i = 0; $i < strlen($urn); $i++) {
$digits .= $concordance[substr($urn, $i, 1)];
}
$checksum = 0;
for ($i = 0; $i < strlen($digits); $i++) {
$checksum += ($i + 1) * intval(substr($digits, $i, 1));
}
$checksum = substr(intval($checksum / intval(substr($digits, -1, 1))), -1, 1);
return $base.$id.$checksum;
}
/**
* Check if given ID is a valid Pica Production Number (PPN)
*
* @access public
*
* @param string $ppn: The identifier to check
*
* @return boolean Is $id a valid PPN?
*/
public static function isPPN($id) {
return self::checkIdentifier($id, 'PPN');
}
/**
* Check if given internal "index_name" is translatable
*
* @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 boolean Is $index_name translatable?
*/
public static function isTranslatable($index_name, $table, $pid = 0) {
return self::translate($index_name, $table, $pid, TRUE);
}
/**
* Load value from user's session.
*
* @access public
*
* @param string $key: Session key for retrieval
*
* @return mixed Session value for given key or NULL on failure
*/
public static function loadFromSession($key) {
// Cast to string for security reasons.
$key = (string) $key;
if (!$key) {
trigger_error('No session key given', E_USER_WARNING);
return;
}
if (TYPO3_MODE === 'FE') {
return $GLOBALS['TSFE']->fe_user->getKey('ses', $key);
} elseif (TYPO3_MODE === 'BE') {
return $GLOBALS['BE_USER']->getSessionData($key);
} else {
trigger_error('Unexpected TYPO3_MODE', E_USER_WARNING);
return;
}
}
/**
* Process a data and/or command map with TYPO3 core engine.
*
* @access public
*
* @return array Array of substituted "NEW..." identifiers and their actual UIDs.
*/
public static function processDB(array $data = array (), array $cmd = array (), $reverseOrder = FALSE) {
// Instantiate TYPO3 core engine.
$tce = t3lib_div::makeInstance('t3lib_TCEmain');
// Set some configuration variables.
$tce->stripslashes_values = FALSE;
// Load data and command arrays.
$tce->start($data, $cmd, self::getBeUser());
// Process command map first if default order is reversed.
if ($cmd && $reverseOrder) {
$tce->process_cmdmap();
}
// Process data map.
if ($data) {
$tce->process_datamap();
}
// Process command map if processing order is not reversed.
if ($cmd && !$reverseOrder) {
$tce->process_cmdmap();
}
return $tce->substNEWwithIDs;
}
/**
* Save given value to user's session.
*
* @access public
*
* @param string $value: Value to save
* @param string $key: Session key for retrieval
*
* @return boolean TRUE on success, FALSE on failure
*/
public static function saveToSession($value, $key) {
// Cast to string for security reasons.
$key = (string) $key;
if (!$key) {
trigger_error('No session key given', E_USER_WARNING);
return FALSE;
}
if (TYPO3_MODE === 'FE') {
$GLOBALS['TSFE']->fe_user->setKey('ses', $key, $value);
$GLOBALS['TSFE']->fe_user->storeSessionData();
return TRUE;
} elseif (TYPO3_MODE === 'BE') {
$GLOBALS['BE_USER']->setAndSaveSessionData($key, $value);
return TRUE;
} else {
trigger_error('Unexpected TYPO3_MODE', E_USER_WARNING);
return FALSE;
}
}
/**
* This validates a METS file against its schemas
* TODO: nicht funktionstüchtig!
*
* @access public
*
* @param SimpleXMLElement $xml:
*
* @return void
*/
public static function schemaValidate(SimpleXMLElement $xml) {
$_libxmlErrors = libxml_use_internal_errors(TRUE);
// Get schema locations.
$xml->registerXPathNamespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$_schemaLocations = $xml->xpath('//*[@xsi:schemaLocation]');
foreach ($_schemaLocations as $_schemaLocation) {
$_schemas = explode(' ', (string) $_schemaLocation->attributes('http://www.w3.org/2001/XMLSchema-instance')->schemaLocation);
for ($i = 1; $i <= count($_schemas); $i++) {
if ($_schemas[$i] == 'http://www.loc.gov/METS/') {
$schema['mets'] = $_schemas[$i + 1];
} elseif ($_schemas[$i] == 'http://www.loc.gov/mods/v3') {
$schema['mods'] = $_schemas[$i + 1];
}
}
}
// TODO: Error-Handling (keine Schemas gefunden)
// Validate METS part against schema.
$dom = new DOMDocument('1.0', 'UTF-8');
$dom->appendChild($dom->importNode(dom_import_simplexml($this->mets), TRUE));
$dom->schemaValidate($schema['mets']);
// TODO: Error-Handling (invalider METS-Part)
// libxml_get_last_error() || libxml_get_errors() || libxml_clear_errors()
// Validate dmdSec parts against schema.
foreach ($this->dmdSec as $dmdSec) {
switch ($dmdSec['type']) {
case 'MODS':
$dom = new DOMDocument('1.0', 'UTF-8');
$dom->appendChild($dom->importNode(dom_import_simplexml($dmdSec['xml']), TRUE));
$dom->schemaValidate($schema['mods']);
// TODO: Error-Handling (invalider MODS-Part)
// libxml_get_last_error() || libxml_get_errors() || libxml_clear_errors()
break;
}
}
libxml_use_internal_errors($_libxmlErrors);
}
/**
* 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
* @param boolean $checkOnly: Don't translate, only check for translation
*
* @return mixed Translated label or boolean value if $checkOnly is set
*/
public static function translate($index_name, $table, $pid, $checkOnly = FALSE) {
static $labels = array ();
$pid = max(intval($pid), 0);
if (!$pid) {
trigger_error('No PID given for translations', E_USER_WARNING);
return $index_name;
}
// Check if "index_name" is an UID.
if (t3lib_div::testInt($index_name)) {
$index_name = self::getIndexName($index_name, $table, $pid);
}
// 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 {
trigger_error('There are no entries with PID '.$pid.' in table '.$table.' or you are not allowed to access them', E_USER_ERROR);
exit;
}
} else {
trigger_error('The table '.$table.' is not allowed for translation', E_USER_ERROR);
exit;
}
}
if (!empty($labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$index_name])) {
if ($checkOnly) {
return TRUE;
} else {
return $labels[$table][$pid][$GLOBALS['TSFE']->sys_language_content][$index_name];
}
} else {
if ($checkOnly) {
return FALSE;
} else {
return $index_name;
}
}
}
/**
* This returns the additional WHERE clause of a table based on its TCA configuration
*
* @access public
*
* @param string $table: Table name as defined in TCA
*
* @return string Additional WHERE clause
*/
public static function whereClause($table) {
if (TYPO3_MODE === 'FE') {
// Tables "tx_dlf_solrcores" and "tx_dlf_formats" always have PID 0.
if (in_array($table, array ('tx_dlf_solrcores', 'tx_dlf_formats'))) {
return t3lib_BEfunc::deleteClause($table);
}
// $GLOBALS['TSFE']->sys_page is not always available in frontend.
if (is_object($GLOBALS['TSFE']->sys_page)) {
return $GLOBALS['TSFE']->sys_page->enableFields($table);
} else {
$t3lib_pageSelect = t3lib_div::makeInstance('t3lib_pageSelect');
$GLOBALS['TSFE']->includeTCA();
return $t3lib_pageSelect->enableFields($table);
}
} elseif (TYPO3_MODE === 'BE') {
return t3lib_BEfunc::deleteClause($table);
} else {
trigger_error('Unexpected TYPO3_MODE', E_USER_ERROR);
exit;
}
}
/**
* This is a static class, thus no instances should be created
*
* @access protected
*/
protected function __construct() {}
}
/* No xclasses for static classes!
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/common/class.tx_dlf_helper.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/common/class.tx_dlf_helper.php']);
}
*/
?>

View File

@ -0,0 +1,540 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*/
/**
* Indexing class 'tx_dlf_indexing' for the 'dlf' extension.
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @copyright Copyright (c) 2010, Sebastian Meyer, SLUB Dresden
* @version $Id: class.tx_dlf_indexing.php 487 2010-12-22 19:55:15Z smeyer $
* @package TYPO3
* @subpackage tx_dlf
* @access public
*/
class tx_dlf_indexing {
/**
* The extension key
*
* @var string
* @access public
*/
public static $extKey = 'dlf';
/**
* Array of facets
* @see loadIndexConf()
*
* @var array
* @access protected
*/
protected static $facets = array ();
/**
* Array of fields' boost values
* @see loadIndexConf()
*
* @var array
* @access protected
*/
protected static $fieldboost = array ();
/**
* Array of indexed metadata
* @see loadIndexConf()
*
* @var array
* @access protected
*/
protected static $indexed = array ();
/**
* List of already processed documents
*
* @var array
* @access protected
*/
protected static $processedDocs = array ();
/**
* Instance of Apache_Solr_Service class
*
* @var Apache_Solr_Service
* @access protected
*/
protected static $solr;
/**
* Array of sortable metadata
* @see loadIndexConf()
*
* @var array
* @access protected
*/
protected static $sortables = array ();
/**
* Array of stored metadata
* @see loadIndexConf()
*
* @var array
* @access protected
*/
protected static $stored = array ();
/**
* Array of tokenized metadata
* @see loadIndexConf()
*
* @var array
* @access protected
*/
protected static $tokenized = array ();
/**
* Array of toplevel structure elements
* @see loadIndexConf()
*
* @var array
* @access protected
*/
protected static $toplevel = array ();
/**
* Insert given document into Solr index
*
* @access public
*
* @param tx_dlf_document &$doc: The document to index
* @param integer $core: UID of the Solr core to use
*
* @return void
*/
public static function addToIndex(tx_dlf_document &$doc, $core = 1) {
if (in_array($doc->uid, self::$processedDocs)) {
return 0;
} elseif (self::solrConnect($core, $doc->pid)) {
$errors = 0;
// Handle multi-volume documents.
if ($doc->parentid) {
$errors = self::addToIndex(tx_dlf_document::getInstance($doc->parentid, 0, TRUE), $core);
}
try {
// Add document to list of processed documents.
self::$processedDocs[] = $doc->uid;
// Index every logical unit as separate Solr document.
foreach ($doc->tableOfContents as $logicalUnit) {
if (!$errors) {
$errors = self::process($doc, $logicalUnit);
} else {
break;
}
}
self::$solr->commit();
// Get document title from database.
$_result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'tx_dlf_documents.title AS title',
'tx_dlf_documents',
'tx_dlf_documents.uid='.intval($doc->uid).tx_dlf_helper::whereClause('tx_dlf_documents'),
'',
'',
'1'
);
$resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($_result);
if (!defined('TYPO3_cliMode')) {
$_message = t3lib_div::makeInstance(
't3lib_FlashMessage',
htmlspecialchars(sprintf($GLOBALS['LANG']->getLL('flash.documentIndexed'), $resArray['title'], $doc->uid)),
$GLOBALS['LANG']->getLL('flash.done', TRUE),
t3lib_FlashMessage::OK,
TRUE
);
t3lib_FlashMessageQueue::addMessage($_message);
}
return $errors;
} catch (Exception $e) {
if (!defined('TYPO3_cliMode')) {
$_message = t3lib_div::makeInstance(
't3lib_FlashMessage',
$GLOBALS['LANG']->getLL('flash.solrException', TRUE).'<br />'.htmlspecialchars($e->getMessage()),
$GLOBALS['LANG']->getLL('flash.error', TRUE),
t3lib_FlashMessage::ERROR,
TRUE
);
t3lib_FlashMessageQueue::addMessage($_message);
}
trigger_error('Apache Solr exception thrown: '.$e->getMessage(), E_USER_ERROR);
return 1;
}
} else {
if (!defined('TYPO3_cliMode')) {
$_message = t3lib_div::makeInstance(
't3lib_FlashMessage',
$GLOBALS['LANG']->getLL('flash.solrNoConnection', TRUE),
$GLOBALS['LANG']->getLL('flash.error', TRUE),
t3lib_FlashMessage::ERROR,
TRUE
);
t3lib_FlashMessageQueue::addMessage($_message);
}
trigger_error('Could not connect to Apache Solr server', E_USER_ERROR);
return 1;
}
}
/**
* Load indexing configuration
*
* @access protected
*
* @param integer $pid: The configuration page's UID
*
* @return void
*/
protected static function loadIndexConf($pid) {
// Get the list of toplevel structures.
$_result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'tx_dlf_structures.index_name AS index_name',
'tx_dlf_structures',
'tx_dlf_structures.toplevel=1 AND tx_dlf_structures.pid='.intval($pid).tx_dlf_helper::whereClause('tx_dlf_structures'),
'',
'',
''
);
while ($_toplevel = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($_result)) {
self::$toplevel[] = $_toplevel['index_name'];
}
// Get the metadata indexing options.
$_result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'tx_dlf_metadata.index_name AS index_name,tx_dlf_metadata.tokenized AS tokenized,tx_dlf_metadata.stored AS stored,tx_dlf_metadata.indexed AS indexed,tx_dlf_metadata.is_listed AS is_listed,tx_dlf_metadata.boost AS boost',
'tx_dlf_metadata',
'tx_dlf_metadata.pid='.intval($pid).tx_dlf_helper::whereClause('tx_dlf_metadata'),
'',
'',
''
);
while ($_indexing = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($_result)) {
if ($_indexing['tokenized']) {
self::$tokenized[] = $_indexing['index_name'];
}
if ($_indexing['stored'] || $_indexing['is_listed']) {
self::$stored[] = $_indexing['index_name'];
}
if ($_indexing['indexed']) {
self::$indexed[] = $_indexing['index_name'];
}
if ($_indexing['boost'] > 0.0) {
self::$fieldboost[$_indexing['index_name']] = $_indexing['boost'];
} else {
self::$fieldboost[$_indexing['index_name']] = FALSE;
}
}
}
/**
* Processes a logical unit (and its children) for the Solr index
*
* @access protected
*
* @param tx_dlf_document &$doc: The METS document
* @param array $logicalUnit: Array of the logical unit to process
*
* @return void
*/
protected static function process(tx_dlf_document &$doc, array $logicalUnit) {
$errors = 0;
// Get metadata for logical unit.
$metadata = $doc->metadataArray[$logicalUnit['id']];
if (!empty($metadata)) {
// Load class.
if (!class_exists('Apache_Solr_Document')) {
require_once(t3lib_div::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.$logicalUnit['id']);
$solrDoc->setField('uid', $doc->uid);
$solrDoc->setField('pid', $doc->pid);
$solrDoc->setField('page', $logicalUnit['points'][0]);
$solrDoc->setField('partof', $doc->parentid);
$solrDoc->setField('sid', $logicalUnit['id']);
$solrDoc->setField('toplevel', in_array($logicalUnit['type'], self::$toplevel));
$solrDoc->setField('type', $logicalUnit['type'], self::$fieldboost['type']);
unset ($metadata['type']);
$solrDoc->setField('title', $metadata['title'][0], self::$fieldboost['title']);
unset ($metadata['title']);
$solrDoc->setField('title_sorting', $metadata['title_sorting'][0]);
unset ($metadata['title_sorting']);
$solrDoc->setField('author', $metadata['author'], self::$fieldboost['author']);
$solrDoc->setField('author_faceting', $metadata['author']);
unset ($metadata['author']);
if (!empty($metadata['author_sorting'][0])) {
$solrDoc->setField('author_sorting', $metadata['author_sorting'][0]);
}
unset ($metadata['author_sorting']);
$solrDoc->setField('year', $metadata['year'], self::$fieldboost['year']);
$solrDoc->setField('year_faceting', $metadata['year']);
unset ($metadata['year']);
if (!empty($metadata['year_sorting'][0])) {
$solrDoc->setField('year_sorting', $metadata['year_sorting'][0]);
}
unset ($metadata['year_sorting']);
$solrDoc->setField('place', $metadata['place'], self::$fieldboost['place']);
$solrDoc->setField('place_faceting', $metadata['place']);
unset ($metadata['place']);
if (!empty($metadata['place_sorting'][0])) {
$solrDoc->setField('place_sorting', $metadata['place_sorting'][0]);
}
unset ($metadata['place_sorting']);
foreach ($metadata as $index_name => $data) {
if (!empty($data)) {
$suffix = (in_array($index_name, self::$tokenized) ? 't' : 'u');
$suffix .= (in_array($index_name, self::$stored) ? 's' : 'u');
$suffix .= (in_array($index_name, self::$indexed) ? 'i' : 'u');
$solrDoc->setField($index_name.'_'.$suffix, $data, self::$fieldboost[$index_name]);
// Add sortable fields to index.
$solrDoc->setField($index_name.'_sorting', $data[0]);
// Add facets to index.
$solrDoc->setField($index_name.'_faceting', $data);
}
}
try {
self::$solr->addDocument($solrDoc);
} catch (Exception $e) {
if (!defined('TYPO3_cliMode')) {
$_message = t3lib_div::makeInstance(
't3lib_FlashMessage',
$GLOBALS['LANG']->getLL('flash.solrException', TRUE).'<br />'.htmlspecialchars($e->getMessage()),
$GLOBALS['LANG']->getLL('flash.error', TRUE),
t3lib_FlashMessage::ERROR,
TRUE
);
t3lib_FlashMessageQueue::addMessage($_message);
}
return 1;
}
}
// Check for child elements...
if (!empty($logicalUnit['children'])) {
foreach ($logicalUnit['children'] as $child) {
if (!$errors) {
// ...and process them, too.
$errors = self::process($doc, $child);
} else {
break;
}
}
}
return $errors;
}
/**
* Connects to Solr server.
*
* @access protected
*
* @param integer $core: UID of the Solr core
* @param integer $pid: UID of the configuration page
*
* @return boolean TRUE on success or FALSE on failure
*/
protected static function solrConnect($core, $pid) {
if (!self::$solr) {
// Connect to Solr server.
if (self::$solr = tx_dlf_solr::solrConnect($core)) {
// Load indexing configuration.
self::loadIndexConf($pid);
} else {
return FALSE;
}
}
return TRUE;
}
/**
* This is a static class, thus no instances should be created
*
* @access protected
*/
protected function __construct() {}
}
/* No xclasses for static classes!
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/common/class.tx_dlf_indexing.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/common/class.tx_dlf_indexing.php']);
}
*/
?>

View File

@ -0,0 +1,416 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*/
/**
* Document class 'tx_dlf_list' for the 'dlf' extension.
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @copyright Copyright (c) 2010, Sebastian Meyer, SLUB Dresden
* @version $Id: class.tx_dlf_list.php 15 2010-01-19 17:07:03Z smeyer $
* @package TYPO3
* @subpackage tx_dlf
* @access public
*/
class tx_dlf_list implements t3lib_Singleton {
/**
* This holds the documents in sorted order
*
* @var array
* @access protected
*/
protected $elements = array ();
/**
* This holds the number of documents in the list
*
* @var integer
* @access protected
*/
protected $count = 0;
/**
* This holds the list's metadata
*
* @var array
* @access protected
*/
protected $metadata = array ();
/**
* This adds an array of elements at the given position to the list
*
* @access public
*
* @param array $elements: Array of elements to add to list
* @param integer $position: Numeric position for including
*
* @return void
*/
public function add(array $elements, $position = -1) {
$position = intval($position);
if ($position < 0 || $position > $this->count) {
$position = $this->count;
}
array_splice($this->elements, $position, 0, $elements);
$this->count = count($this->elements);
}
/**
* This removes the element at the given position from the list
*
* @access public
*
* @param integer $position: Numeric position for removing
*
* @return mixed The removed element
*/
public function remove($position) {
$position = intval($position);
if ($position < 0 || $position >= $this->count) {
trigger_error('No valid list position for removal', E_USER_WARNING);
return;
}
$removed = array_splice($this->elements, $position, 1);
$this->count = count($this->elements);
return $removed[0];
}
/**
* This moves the element at the given position up
*
* @access public
*
* @param integer $position: Numeric position for moving
*
* @return void
*/
public function moveUp($position) {
$position = intval($position);
if ($position < 1 || $position >= $this->count) {
trigger_error('No valid list position for moving up', E_USER_WARNING);
return;
}
array_splice($this->elements, $position - 1, 0, $this->elements[$position]);
array_splice($this->elements, $position + 1, 1);
}
/**
* This moves the element at the given position down
*
* @access public
*
* @param integer $position: Numeric position for moving
*
* @return void
*/
public function moveDown($position) {
$position = intval($position);
if ($position < 0 || $position >= ($this->count - 1)) {
trigger_error('No valid list position for moving down', E_USER_WARNING);
return;
}
array_splice($this->elements, $position + 2, 0, $this->elements[$position]);
array_splice($this->elements, $position, 1);
}
/**
* This empties the current list
*
* @access public
*
* @return void
*/
public function reset() {
$this->elements = array ();
$this->metadata = array ();
$this->count = 0;
}
/**
* This saves the current list
*
* @access public
*
* @param integer $pid: PID for saving in database
*
* @return void
*/
public function save($pid = 0) {
$pid = max(intval($pid), 0);
// If no PID is given, save to the user's session instead
if ($pid > 0) {
// TODO: Liste in Datenbank speichern (inkl. Sichtbarkeit, Beschreibung, etc.)
} else {
tx_dlf_helper::saveToSession(array ($this->elements, $this->metadata), get_class($this));
}
}
/**
* This returns $this->count via __get()
*
* @access protected
*
* @return integer The number of elements in the list
*/
protected function _getCount() {
return $this->count;
}
/**
* This returns $this->elements via __get()
*
* @access protected
*
* @return array The documents in sorted order
*/
protected function _getElements() {
return $this->elements;
}
/**
* This returns $this->metadata via __get()
*
* @access protected
*
* @return array The list's metadata
*/
protected function _getMetadata() {
return $this->metadata;
}
/**
* This sets $this->metadata via __set()
*
* @access protected
*
* @param array $metadata: Array of new metadata
*
* @return void
*/
protected function _setMetadata(array $metadata = array ()) {
$this->metadata = $metadata;
}
/**
* 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 (!$elements && !$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);
}
/**
* This magic method is invoked each time a clone is called on the object variable
* (This method is defined as private/protected because singleton objects should not be cloned)
*
* @access protected
*
* @return void
*/
protected function __clone() {}
/**
* This magic method is called each time an invisible property is referenced from the object
*
* @access public
*
* @param string $var: Name of variable to get
*
* @return mixed Value of $this->$var
*/
public function __get($var) {
$_method = '_get'.ucfirst($var);
if (!property_exists($this, $var) || !method_exists($this, $_method)) {
trigger_error('There is no get function for property '.$var, E_USER_ERROR);
return;
} else {
return $this->$_method();
}
}
/**
* This magic method is called each time an invisible property is referenced from the object
*
* @access public
*
* @param string $var: Name of variable to set
* @param mixed $value: New value of variable
*
* @return void
*/
public function __set($var, $value) {
$_method = '_set'.ucfirst($var);
if (!property_exists($this, $var) || !method_exists($this, $_method)) {
trigger_error('There is no set function for property '.$var, E_USER_ERROR);
} else {
$this->$_method($value);
}
}
/**
* This magic method is executed prior to any serialization of the object
* @see __wakeup()
*
* @access public
*
* @return array Properties to be serialized
*/
public function __sleep() {
return array ('elements', 'metadata');
}
/**
* This magic method is executed after the object is deserialized
* @see __sleep()
*
* @access public
*
* @return void
*/
public function __wakeup() {
$this->count = count($this->elements);
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/common/class.tx_dlf_list.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/common/class.tx_dlf_list.php']);
}
?>

View File

@ -0,0 +1,231 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*/
/**
* Metadata format class 'tx_dlf_mods' for the 'dlf' extension.
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @copyright Copyright (c) 2010, Sebastian Meyer, SLUB Dresden
* @version $Id: class.tx_dlf_document.php 104 2010-06-12 21:12:03Z smeyer $
* @package TYPO3
* @subpackage tx_dlf
* @access public
*/
class tx_dlf_mods implements tx_dlf_format {
/**
* This extracts the essential MODS metadata from XML
*
* @access public
*
* @param SimpleXMLElement $xml: The XML to extract the metadata from
* @param array &$metadata: The metadata array to fill
*
* @return void
*/
public function extractMetadata(SimpleXMLElement $xml, array &$metadata) {
$xml->registerXPathNamespace('mods', 'http://www.loc.gov/mods/v3');
// Get "title" and "title_sorting".
if (($title = $xml->xpath('./mods:titleInfo/mods:title'))) {
$metadata['title'][0] = $metadata['title_sorting'][0] = (string) $title[0];
// Prepend any "nonSort" parts to the title.
if (($nonSort = $xml->xpath('./mods:titleInfo/mods:nonSort'))) {
$metadata['title'][0] = (string) $nonSort[0].' '.$metadata['title'][0];
}
}
// Get "author" and "author_sorting".
$authors = $xml->xpath('./mods:name[./mods:role/mods:roleTerm[@type="code"][@authority="marcrelator"]="aut"]');
// Get "author" and "author_sorting" again if that was to sophisticated.
if (!$authors) {
// Get all names which do not have any role term assigned and assume these are authors.
$authors = $xml->xpath('./mods:name[not(./mods:role)]');
}
if ($authors) {
for ($i = 0; $i < count($authors); $i++) {
$authors[$i]->registerXPathNamespace('mods', 'http://www.loc.gov/mods/v3');
// Check if there are separate family and given names.
if (($nameParts = $authors[$i]->xpath('./mods:namePart'))) {
$name = array ();
$j = 4;
foreach ($nameParts as $namePart) {
if (isset($namePart['type']) && (string) $namePart['type'] == 'family') {
$name[0] = (string) $namePart;
} elseif (isset($namePart['type']) && (string) $namePart['type'] == 'given') {
$name[1] = (string) $namePart;
} elseif (isset($namePart['type']) && (string) $namePart['type'] == 'termsOfAddress') {
$name[2] = (string) $namePart;
} elseif (isset($namePart['type']) && (string) $namePart['type'] == 'date') {
$name[3] = (string) $namePart;
} else {
$name[$j] = (string) $namePart;
}
$j++;
}
ksort($name);
$metadata['author'][$i] = trim(implode(', ', $name));
if (!$metadata['author_sorting'][0]) {
$metadata['author_sorting'][0] = trim(implode(', ', $name));
}
}
// Check if there is a display form.
if (($displayForm = $authors[$i]->xpath('./mods:displayForm'))) {
$metadata['author'][$i] = (string) $displayForm[0];
if (!$metadata['author_sorting'][0]) {
$metadata['author_sorting'][0] = (string) $displayForm[0];
}
}
}
}
// Get "place" and "place_sorting".
$places = $xml->xpath('./mods:originInfo[not(./mods:edition="[Electronic ed.]")]/mods:place/mods:placeTerm');
// Get "place" and "place_sorting" again if that was to sophisticated.
if (!$places) {
// Get all places and assume these are places of publication.
$places = $xml->xpath('./mods:originInfo/mods:place/mods:placeTerm');
}
if ($places) {
foreach ($places as $place) {
$metadata['place'][] = (string) $place;
if (!$metadata['place_sorting'][0]) {
$metadata['place_sorting'][0] = preg_replace('/[[:punct:]]/', '', (string) $place);
}
}
}
// Get "year_sorting".
if (($years_sorting = $xml->xpath('./mods:originInfo[not(./mods:edition="[Electronic ed.]")]/mods:dateOther[@type="order"][@encoding="w3cdtf"]'))) {
foreach ($years_sorting as $year_sorting) {
$metadata['year_sorting'][0] = intval($year_sorting);
}
}
// Get "year" and "year_sorting" if not specified separately.
$years = $xml->xpath('./mods:originInfo[not(./mods:edition="[Electronic ed.]")]/mods:dateIssued[@keyDate="yes"]');
// Get "year" and "year_sorting" again if that was to sophisticated.
if (!$years) {
// Get all dates and assume these are dates of publication.
$years = $xml->xpath('./mods:originInfo/mods:dateIssued');
}
if ($years) {
foreach ($years as $year) {
$metadata['year'][] = (string) $year;
if (!$metadata['year_sorting'][0]) {
$year_sorting = str_ireplace('x', '5', preg_replace('/[^\d.x]/i', '', (string) $year));
if (strpos($year_sorting, '.') || strlen($year_sorting) < 3) {
$year_sorting = ((intval(trim($year_sorting, '.')) - 1) * 100) + 50;
}
$metadata['year_sorting'][0] = intval($year_sorting);
}
}
}
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/common/class.tx_dlf_mods.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/common/class.tx_dlf_mods.php']);
}
?>

View File

@ -0,0 +1,229 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*/
/**
* Base class 'tx_dlf_module' for the 'dlf' extension.
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @copyright Copyright (c) 2010, Sebastian Meyer, SLUB Dresden
* @version $Id: index.php 38 2010-04-16 15:39:41Z smeyer $
* @package TYPO3
* @subpackage tx_dlf
* @access public
* @abstract
*/
abstract class tx_dlf_module extends t3lib_SCbase {
public $extKey = 'dlf';
public $prefixId = 'tx_dlf';
/**
* Holds the path to this module relative to 'EXT:dlf/modules/' and with trailing slash
*
* @var string
* @access protected
*/
protected $modPath = '';
/**
* Holds the page record if access granted or FALSE if access denied
*
* @var mixed
* @access protected
*/
protected $pageInfo;
/**
* Holds the module's button array
*
* @var array
* @access protected
*/
protected $buttonArray = array ();
/**
* Holds the module's marker array
*
* @var array
* @access protected
*/
protected $markerArray = array ();
/**
* Holds the module's subpart array
*
* @var array
* @access protected
*/
protected $subpartArray = array ();
/**
* Holds the TYPO3_CONF_VARS array of this extension
*
* @var array
* @access protected
*/
protected $conf = array ();
/**
* Holds the submitted form's data
*
* @var array
* @access protected
*/
protected $data;
/**
* Initializes the backend module by setting internal variables, initializing the menu.
*
* @access public
*
* @return void
*/
public function __construct() {
$GLOBALS['BE_USER']->modAccess($GLOBALS['MCONF'], 1);
$GLOBALS['LANG']->includeLLFile('EXT:dlf/modules/'.$this->modPath.'locallang.xml');
$this->setMOD_MENU();
parent::init();
$this->conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]);
$this->pageInfo = t3lib_BEfunc::readPageAccess($this->id, $this->perms_clause);
$this->doc = t3lib_div::makeInstance('template');
$this->doc->setModuleTemplate('EXT:dlf/modules/'.$this->modPath.'template.tmpl');
$this->doc->getPageRenderer()->addCssFile(t3lib_extMgm::extRelPath($this->extKey) . 'res/backend.css');
$this->doc->backPath = $GLOBALS['BACK_PATH'];
$this->data = t3lib_div::_GPmerged($this->prefixId);
}
/**
* Sets the module's MOD_MENU configuration.
*
* @access protected
*
* @return void
*/
protected function setMOD_MENU() {
// Set $this->MOD_MENU array here or leave empty.
/* Example code:
$this->MOD_MENU = array (
'function' => array (
'1' => $GLOBALS['LANG']->getLL('function1'),
'2' => $GLOBALS['LANG']->getLL('function2'),
'3' => $GLOBALS['LANG']->getLL('function3'),
)
); */
}
/**
* Main function of the module.
*
* @access public
*
* @abstract
*
* @return void
*/
abstract public function main();
/**
* Outputs all contents.
*
* @access protected
*
* @return void
*/
protected function printContent() {
$this->doc->JScode .= '
<script type="text/javascript">
script_ended = 0;
function jumpToUrl(URL) {
document.location = URL;
}
</script>
';
$this->doc->postCode .= '
<script type="text/javascript">
script_ended = 1;
if (top.fsMod) top.fsMod.recentIds["web"] = '.intval($this->id).';
</script>
';
$this->content .= $this->doc->startPage($GLOBALS['LANG']->getLL('title'));
if (empty($this->buttonArray['SHORTCUT'])) {
$this->buttonArray['SHORTCUT'] = $this->doc->makeShortcutIcon('id', implode(',', array_keys($this->MOD_MENU)), $this->MCONF['name']);
}
if (empty($this->markerArray['CSH'])) {
$this->markerArray['CSH'] = t3lib_BEfunc::cshItem('_MOD_'.$GLOBALS['MCONF']['name'], 'csh', $GLOBALS['BACK_PATH'], '', TRUE);
}
if (empty($this->markerArray['MOD_MENU'])) {
$this->markerArray['MOD_MENU'] = t3lib_BEfunc::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
}
$this->content .= $this->doc->moduleBody($this->pageInfo, $this->buttonArray, $this->markerArray, $this->subpartArray);
$this->content .= $this->doc->endPage();
echo $this->content;
}
}
/* No xclasses for abstract classes!
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/common/class.tx_dlf_module.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/common/class.tx_dlf_module.php']);
}
*/
?>

View File

@ -0,0 +1,304 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*/
/**
* Base class 'tx_dlf_plugin' for the 'dlf' extension.
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @copyright Copyright (c) 2010, Sebastian Meyer, SLUB Dresden
* @version $Id: class.tx_dlf_plugin.php 430 2010-12-02 21:19:02Z smeyer $
* @package TYPO3
* @subpackage tx_dlf
* @access public
* @abstract
*/
abstract class tx_dlf_plugin extends tslib_pibase {
public $extKey = 'dlf';
public $prefixId = 'tx_dlf';
public $scriptRelPath = 'common/class.tx_dlf_plugin.php';
// Plugins are cached by default (@see setCache()).
public $pi_USER_INT_obj = FALSE;
public $pi_checkCHash = TRUE;
/**
* This holds the current document
*
* @var tx_dlf_document
* @access protected
*/
protected $doc;
/**
* This holds the plugin's parsed template
*
* @var string
* @access protected
*/
protected $template = '';
/**
* Checks $this->piVars array for common required fields and sets some default values
*
* @access protected
*
* @param boolean $dontSetDefaults: If TRUE only checks for required fields are performed
*
* @return boolean TRUE on success or FALSE when required fields are missing
*/
protected function checkPIvars($dontSetDefaults = FALSE) {
if (!$dontSetDefaults) {
// Set default values for some fields if not set.
$this->piVars['page'] = (!empty($this->piVars['page']) ? max(intval($this->piVars['page']), 1) : 1);
}
// Check for required fields.
return !empty($this->piVars['id']);
}
/**
* All the needed configuration values are stored in class variables
* Priority: Flexforms > TS-Templates > Extension Configuration > ext_localconf.php
*
* @access protected
*
* @param array $conf: configuration array from TS-Template
*
* @return void
*/
protected function init(array $conf) {
// Read general TS configuration
$generalConf = $GLOBALS['TSFE']->tmpl->setup['plugin.'][$this->prefixId.'.'];
if (is_array($generalConf)) {
$conf = t3lib_div::array_merge_recursive_overrule($generalConf, $conf);
}
// Read extension configuration
$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]);
if (is_array($extConf)) {
$conf = t3lib_div::array_merge_recursive_overrule($extConf, $conf);
}
// Read TYPO3_CONF_VARS configuration
$varsConf = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey];
if (is_array($varsConf)) {
$conf = t3lib_div::array_merge_recursive_overrule($varsConf, $conf);
}
// Read FlexForm configuration
$this->pi_initPIflexForm();
if ($this->cObj->data['pi_flexform']['data']) {
foreach ($this->cObj->data['pi_flexform']['data'] as $sheetName => $sheet) {
foreach ($sheet as $langName => $lang) {
foreach (array_keys($lang) as $key) {
$flexFormConf[$key] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], $key, $sheetName, $langName);
if (!$flexFormConf[$key]) {
unset($flexFormConf[$key]);
}
}
}
}
if (is_array($flexFormConf)) {
$conf = t3lib_div::array_merge_recursive_overrule($conf, $flexFormConf);
}
}
$this->conf = $conf;
// Set default plugin variables.
$this->pi_setPiVarDefaults();
// Load translation files.
$this->pi_loadLL();
}
/**
* Loads the current document into $this->doc
*
* @access protected
*
* @return void
*/
protected function loadDocument() {
// Check for required fields.
if ($this->checkPIvars(TRUE)) {
// Should we exclude documents from other pages than $this->conf['pages']?
$pid = (!empty($this->conf['excludeOther']) ? intval($this->conf['pages']) : 0);
// Get instance of tx_dlf_document.
$this->doc = tx_dlf_document::getInstance($this->piVars['id'], $pid);
} else {
trigger_error('Required parameters are not set', E_USER_ERROR);
}
}
/**
* The main method of the PlugIn
*
* @access public
*
* @param string $content: The PlugIn content
* @param array $conf: The PlugIn configuration
*
* @abstract
*
* @return string The content that is displayed on the website
*/
abstract public function main($content, $conf);
/**
* Wraps the input string in a tag with the class attribute set to the class name
*
* @access public
*
* @param string $content: HTML content to wrap in the div-tags with the "main class" of the plugin
*
* @return string HTML content wrapped, ready to return to the parent object.
*/
public function pi_wrapInBaseClass($content) {
// Use get_class($this) instead of $this->prefixId for content wrapping because $this->prefixId is the same for all plugins.
$content = '<div class="'.str_replace('_', '-', get_class($this)).'">'.$content.'</div>';
if (!$GLOBALS['TSFE']->config['config']['disablePrefixComment']) {
$content = "\n\n<!-- BEGIN: Content of extension '".$this->extKey."', plugin '".get_class($this)."' -->\n\n".$content."\n\n<!-- END: Content of extension '".$this->extKey."', plugin '".get_class($this)."' -->\n\n";
}
return $content;
}
/**
* Parses a string into a typoscript array
*
* @access protected
*
* @param string $string: The string to parse
*
* @return array The resulting typoscript array
*/
protected function parseTS($string = '') {
$parser = t3lib_div::makeInstance('t3lib_TSparser');
$parser->parse($string);
return $parser->setup;
}
/**
* Sets some configuration variables if the plugin is cached.
*
* @access protected
*
* @param boolean $cache: Should the plugin be cached?
*
* @return void
*/
protected function setCache($cache = TRUE) {
if ($cache) {
// Set cObject type to "USER" (default).
$this->pi_USER_INT_obj = FALSE;
$this->pi_checkCHash = TRUE;
if (count($this->piVars)) {
// Check cHash or disable caching.
$GLOBALS['TSFE']->reqCHash();
}
} else {
// Set cObject type to "USER_INT".
$this->pi_USER_INT_obj = TRUE;
$this->pi_checkCHash = FALSE;
// Plugins are of type "USER" by default, so convert it to "USER_INT".
$this->cObj->convertToUserIntObject();
}
}
}
/* No xclasses for abstract classes!
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/common/class.tx_dlf_plugin.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/common/class.tx_dlf_plugin.php']);
}
*/
?>

View File

@ -0,0 +1,171 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*/
/**
* Solr class 'tx_dlf_solr' for the 'dlf' extension.
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @copyright Copyright (c) 2010, Sebastian Meyer, SLUB Dresden
* @version $Id: class.tx_dlf_solr.php 481 2010-12-22 18:22:54Z smeyer $
* @package TYPO3
* @subpackage tx_dlf
* @access public
*/
class tx_dlf_solr {
/**
* The extension key
*
* @var string
* @access public
*/
public static $extKey = 'dlf';
/**
* Get SolrPhpClient service object and establish connection to Solr server
* @see EXT:dlf/lib/SolrPhpClient/Apache/Solr/Service.php
*
* @access public
*
* @param mixed $core: Name or UID of the core to load
*
* @return mixed Instance of Apache_Solr_Service or NULL on failure
*/
public static function solrConnect($core = 1) {
// 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 = t3lib_div::intInRange($conf['solrPort'], 1, 65535, 8180);
// Get core name if UID is given.
if (t3lib_div::testInt($core)) {
$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'tx_dlf_solrcores.index_name AS index_name',
'tx_dlf_solrcores',
'tx_dlf_solrcores.uid='.intval($core).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);
} else {
trigger_error('Could not find Solr core with UID '.$core, E_USER_ERROR);
return;
}
}
// Append core name to path.
$path = trim($conf['solrPath'], '/').'/'.$core;
// Instantiate Apache_Solr_Service class.
$solr = t3lib_div::makeInstance('Apache_Solr_Service', $host, $port, $path);
// Check if connection is established.
if ($solr->ping()) {
return $solr;
} else {
trigger_error('Could not connect to Solr server with core "'.$core.'"', E_USER_ERROR);
return;
}
}
/**
* Get next unused Solr core number
*
* @access public
*
* @param integer $start: Number to start with
*
* @return integer First unused core number found
*/
public static function solrGetCoreNumber($start = 0) {
$start = max(intval($start), 0);
// Check if core already exists.
if (self::solrConnect('dlfCore'.$start) === NULL) {
return $start;
} else {
return self::solrGetCoreNumber($start + 1);
}
}
/**
* This is a static class, thus no instances should be created
*
* @access protected
*/
protected function __construct() {}
}
/* No xclasses for static classes!
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/common/class.tx_dlf_solr.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/common/class.tx_dlf_solr.php']);
}
*/
?>

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

30
dlf/ext_autoload.php Normal file
View File

@ -0,0 +1,30 @@
<?php
$extensionPath = t3lib_extMgm::extPath('dlf');
return array (
'tx_dlf_cli' => $extensionPath.'cli/class.tx_dlf_cli.php',
'tx_dlf_document' => $extensionPath.'common/class.tx_dlf_document.php',
'tx_dlf_format' => $extensionPath.'common/class.tx_dlf_format.php',
'tx_dlf_helper' => $extensionPath.'common/class.tx_dlf_helper.php',
'tx_dlf_indexing' => $extensionPath.'common/class.tx_dlf_indexing.php',
'tx_dlf_list' => $extensionPath.'common/class.tx_dlf_list.php',
'tx_dlf_mods' => $extensionPath.'common/class.tx_dlf_mods.php',
'tx_dlf_module' => $extensionPath.'common/class.tx_dlf_module.php',
'tx_dlf_plugin' => $extensionPath.'common/class.tx_dlf_plugin.php',
'tx_dlf_solr' => $extensionPath.'common/class.tx_dlf_solr.php',
'tx_dlf_em' => $extensionPath.'hooks/class.tx_dlf_em.php',
'tx_dlf_hacks' => $extensionPath.'hooks/class.tx_dlf_hacks.php',
'tx_dlf_tceforms' => $extensionPath.'hooks/class.tx_dlf_tceforms.php',
'tx_dlf_tcemain' => $extensionPath.'hooks/class.tx_dlf_tcemain.php',
'tx_dlf_modindexing' => $extensionPath.'modules/indexing/index.php',
'tx_dlf_collection' => $extensionPath.'plugins/collection/class.tx_dlf_collection.php',
'tx_dlf_metadata' => $extensionPath.'plugins/metadata/class.tx_dlf_metadata.php',
'tx_dlf_navigation' => $extensionPath.'plugins/navigation/class.tx_dlf_navigation.php',
'tx_dlf_oai' => $extensionPath.'plugins/oai/class.tx_dlf_oai.php',
'tx_dlf_pageview' => $extensionPath.'plugins/pageview/class.tx_dlf_pageview.php',
'tx_dlf_search' => $extensionPath.'plugins/search/class.tx_dlf_search.php',
'tx_dlf_toc' => $extensionPath.'plugins/toc/class.tx_dlf_toc.php'
);
?>

23
dlf/ext_conf_template.txt Normal file
View File

@ -0,0 +1,23 @@
# cat=Basic; type=string; label=DLF User-Agent: (default is "Digital Library Framework")
useragent = Digital Library Framework
# cat=Basic; type=string; label=Additional METS fileGrps: comma-separated list of @USE attribute values (default is "MIN,MAX")
fileGrps = MIN,MAX
# cat=Solr; type=user[EXT:dlf/hooks/class.tx_dlf_em.php:tx_dlf_em->checkSolrConnection]; label=Solr Connection
solrConnect = 0
# cat=Solr; type=string; label=Solr Server Host: (default is "localhost")
solrHost = localhost
# cat=Solr; type=int[0-65535]; label=Solr Server Port: (default is "8180")
solrPort = 8180
# cat=Solr; type=string; label=Solr Server Path: (default is "/solr/")
solrPath = /solr/
# cat=Solr; type=string; label=Solr Server User: (default is "")
solrUser =
# cat=Solr; type=string; label=Solr Server Password: (default is "")
solrPass =

68
dlf/ext_emconf.php Normal file
View File

@ -0,0 +1,68 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
########################################################################
# Extension Manager/Repository config file for ext: "dlf"
#
# Auto generated 01-12-2008 15:36
#
# Manual updates:
# Only the data in the array - anything else is removed by next write.
# "version" and "dependencies" must not be touched!
########################################################################
$EM_CONF[$_EXTKEY] = array(
'title' => 'Digital Library Framework',
'description' => 'Base classes, plugins and modules of the Digital Library Framework. The DLF is a toolset for building a METS-based Digital Library.',
'category' => 'fe',
'author' => 'Sebastian Meyer',
'author_email' => 'sebastian.meyer@slub-dresden.de',
'author_company' => '<br /><a href="http://www.slub-dresden.de/en/" target="_blank">Saxon State and University Library Dresden &lt;www.slub-dresden.de&gt;</a>',
'shy' => '',
'priority' => '',
'module' => '',
'state' => 'stable',
'internal' => '',
'uploadfolder' => TRUE,
'createDirs' => '',
'modify_tables' => '',
'clearCacheOnLoad' => FALSE,
'lockType' => '',
'version' => '0.0.0',
'constraints' => array(
'depends' => array(
'php' => '5.3.0-',
'typo3' => '4.3.0-',
'static_info_tables' => '',
),
'conflicts' => array(
),
'suggests' => array(
'realurl' => '',
),
),
'_md5_values_when_last_written' => '',
);
?>

BIN
dlf/ext_icon.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 612 B

54
dlf/ext_localconf.php Normal file
View File

@ -0,0 +1,54 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
if (!defined ('TYPO3_MODE')) die ('Access denied.');
// Register plugins.
t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/collection/class.tx_dlf_collection.php', '_collection', 'list_type', TRUE);
t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/listview/class.tx_dlf_listview.php', '_listview', 'list_type', FALSE);
t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/metadata/class.tx_dlf_metadata.php', '_metadata', 'list_type', TRUE);
t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/navigation/class.tx_dlf_navigation.php', '_navigation', 'list_type', TRUE);
t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/oai/class.tx_dlf_oai.php', '_oai', 'list_type', FALSE);
t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/pageview/class.tx_dlf_pageview.php', '_pageview', 'list_type', TRUE);
t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/search/class.tx_dlf_search.php', '_search', 'list_type', TRUE);
t3lib_extMgm::addPItoST43($_EXTKEY, 'plugins/toc/class.tx_dlf_toc.php', '_toc', 'list_type', TRUE);
// Register hooks.
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'EXT:'.$_EXTKEY.'/hooks/class.tx_dlf_tcemain.php:tx_dlf_tcemain';
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'][] = 'EXT:'.$_EXTKEY.'/hooks/class.tx_dlf_tcemain.php:tx_dlf_tcemain';
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['dlf/common/class.tx_dlf_document.php']['hookClass'][] = 'EXT:'.$_EXTKEY.'/hooks/class.tx_dlf_hacks.php:tx_dlf_hacks';
// Register command line scripts.
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['cliKeys'][$_EXTKEY] = array ('EXT:'.$_EXTKEY.'/cli/class.tx_dlf_cli.php', '_CLI_dlf');
?>

309
dlf/ext_tables.php Normal file
View File

@ -0,0 +1,309 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
if (!defined ('TYPO3_MODE')) die ('Access denied.');
// Register database tables.
$TCA['tx_dlf_documents'] = array (
'ctrl' => array (
'title' => 'LLL:EXT:dlf/locallang_db.xml:tx_dlf_documents',
'label' => 'title',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'default_sortby' => 'ORDER BY title_sorting',
'delete' => 'deleted',
'enablecolumns' => array (
'disabled' => 'hidden',
'fe_group' => 'fe_group',
),
'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'tca.php',
'iconfile' => t3lib_extMgm::extRelPath($_EXTKEY).'res/icon_txdlfdocuments.png',
'rootLevel' => 0,
'dividers2tabs' => 2,
),
'feInterface' => array (
'fe_admin_fieldList' => '',
)
);
$TCA['tx_dlf_structures'] = array (
'ctrl' => array (
'title' => 'LLL:EXT:dlf/locallang_db.xml:tx_dlf_structures',
'label' => 'label',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'default_sortby' => 'ORDER BY label',
'delete' => 'deleted',
'enablecolumns' => array (
'disabled' => 'hidden',
),
'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'tca.php',
'iconfile' => t3lib_extMgm::extRelPath($_EXTKEY).'res/icon_txdlfstructures.png',
'rootLevel' => 0,
'dividers2tabs' => 2,
),
'feInterface' => array (
'fe_admin_fieldList' => '',
)
);
$TCA['tx_dlf_metadata'] = array (
'ctrl' => array (
'title' => 'LLL:EXT:dlf/locallang_db.xml:tx_dlf_metadata',
'label' => 'label',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'sortby' => 'sorting',
'delete' => 'deleted',
'enablecolumns' => array (
'disabled' => 'hidden',
),
'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'tca.php',
'iconfile' => t3lib_extMgm::extRelPath($_EXTKEY).'res/icon_txdlfmetadata.png',
'rootLevel' => 0,
'dividers2tabs' => 2,
),
'feInterface' => array (
'fe_admin_fieldList' => '',
)
);
$TCA['tx_dlf_formats'] = array (
'ctrl' => array (
'title' => 'LLL:EXT:dlf/locallang_db.xml:tx_dlf_formats',
'label' => 'type',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'default_sortby' => 'ORDER BY type',
'delete' => 'deleted',
'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'tca.php',
'iconfile' => t3lib_extMgm::extRelPath($_EXTKEY).'res/icon_txdlfformats.png',
'rootLevel' => 1,
'dividers2tabs' => 2,
),
'feInterface' => array (
'fe_admin_fieldList' => '',
)
);
$TCA['tx_dlf_solrcores'] = array (
'ctrl' => array (
'title' => 'LLL:EXT:dlf/locallang_db.xml:tx_dlf_solrcores',
'label' => 'label',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'default_sortby' => 'ORDER BY label',
'delete' => 'deleted',
'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'tca.php',
'iconfile' => t3lib_extMgm::extRelPath($_EXTKEY).'res/icon_txdlfsolrcores.png',
'rootLevel' => 1,
'dividers2tabs' => 2,
),
'feInterface' => array (
'fe_admin_fieldList' => '',
)
);
$TCA['tx_dlf_collections'] = array (
'ctrl' => array (
'title' => 'LLL:EXT:dlf/locallang_db.xml:tx_dlf_collections',
'label' => 'label',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'fe_cruser_id' => 'fe_cruser_id',
'fe_admin_lock' => 'fe_admin_lock',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'default_sortby' => 'ORDER BY label',
'delete' => 'deleted',
'enablecolumns' => array (
'disabled' => 'hidden',
'fe_group' => 'fe_group',
),
'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'tca.php',
'iconfile' => t3lib_extMgm::extRelPath($_EXTKEY).'res/icon_txdlfcollections.png',
'rootLevel' => 0,
'dividers2tabs' => 2,
),
'feInterface' => array (
'fe_admin_fieldList' => 'label,description,documents',
)
);
$TCA['tx_dlf_libraries'] = array (
'ctrl' => array (
'title' => 'LLL:EXT:dlf/locallang_db.xml:tx_dlf_libraries',
'label' => 'label',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'default_sortby' => 'ORDER BY label',
'delete' => 'deleted',
'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'tca.php',
'iconfile' => t3lib_extMgm::extRelPath($_EXTKEY).'res/icon_txdlflibraries.png',
'rootLevel' => 0,
'dividers2tabs' => 2,
),
'feInterface' => array (
'fe_admin_fieldList' => '',
)
);
// Register plugins.
t3lib_div::loadTCA('tt_content');
// Register static typoscript.
t3lib_extMgm::addStaticFile($_EXTKEY,'typoscript/', 'DLF (Base Configuration)');
// Plugin "collection".
$TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_collection'] = 'layout,select_key,pages,recursive';
$TCA['tt_content']['types']['list']['subtypes_addlist'][$_EXTKEY.'_collection'] = 'pi_flexform';
t3lib_extMgm::addPlugin(array('LLL:EXT:dlf/locallang_db.xml:tt_content.dlf_collection', $_EXTKEY.'_collection'), 'list_type');
t3lib_extMgm::addPiFlexFormValue($_EXTKEY.'_collection', 'FILE:EXT:'.$_EXTKEY.'/plugins/collection/flexform.xml');
// Plugin "listview".
$TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_listview'] = 'layout,select_key,pages,recursive';
$TCA['tt_content']['types']['list']['subtypes_addlist'][$_EXTKEY.'_listview'] = 'pi_flexform';
t3lib_extMgm::addPlugin(array('LLL:EXT:dlf/locallang_db.xml:tt_content.dlf_listview', $_EXTKEY.'_listview'), 'list_type');
t3lib_extMgm::addPiFlexFormValue($_EXTKEY.'_listview', 'FILE:EXT:'.$_EXTKEY.'/plugins/listview/flexform.xml');
// Plugin "metadata".
$TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_metadata'] = 'layout,select_key,pages,recursive';
$TCA['tt_content']['types']['list']['subtypes_addlist'][$_EXTKEY.'_metadata'] = 'pi_flexform';
t3lib_extMgm::addPlugin(array('LLL:EXT:dlf/locallang_db.xml:tt_content.dlf_metadata', $_EXTKEY.'_metadata'), 'list_type');
t3lib_extMgm::addPiFlexFormValue($_EXTKEY.'_metadata', 'FILE:EXT:'.$_EXTKEY.'/plugins/metadata/flexform.xml');
// Plugin "navigation".
$TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_navigation'] = 'layout,select_key,pages,recursive';
$TCA['tt_content']['types']['list']['subtypes_addlist'][$_EXTKEY.'_navigation'] = 'pi_flexform';
t3lib_extMgm::addPlugin(array('LLL:EXT:dlf/locallang_db.xml:tt_content.dlf_navigation', $_EXTKEY.'_navigation'), 'list_type');
t3lib_extMgm::addPiFlexFormValue($_EXTKEY.'_navigation', 'FILE:EXT:'.$_EXTKEY.'/plugins/navigation/flexform.xml');
// Plugin "oai".
$TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_oai'] = 'layout,select_key,pages,recursive';
$TCA['tt_content']['types']['list']['subtypes_addlist'][$_EXTKEY.'_oai'] = 'pi_flexform';
t3lib_extMgm::addPlugin(array('LLL:EXT:dlf/locallang_db.xml:tt_content.dlf_oai', $_EXTKEY.'_oai'), 'list_type');
t3lib_extMgm::addPiFlexFormValue($_EXTKEY.'_oai', 'FILE:EXT:'.$_EXTKEY.'/plugins/oai/flexform.xml');
// Plugin "pageview".
$TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_pageview'] = 'layout,select_key,pages,recursive';
$TCA['tt_content']['types']['list']['subtypes_addlist'][$_EXTKEY.'_pageview'] = 'pi_flexform';
t3lib_extMgm::addPlugin(array('LLL:EXT:dlf/locallang_db.xml:tt_content.dlf_pageview', $_EXTKEY.'_pageview'), 'list_type');
t3lib_extMgm::addPiFlexFormValue($_EXTKEY.'_pageview', 'FILE:EXT:'.$_EXTKEY.'/plugins/pageview/flexform.xml');
// Plugin "search".
$TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_search'] = 'layout,select_key,pages,recursive';
$TCA['tt_content']['types']['list']['subtypes_addlist'][$_EXTKEY.'_search'] = 'pi_flexform';
t3lib_extMgm::addPlugin(array('LLL:EXT:dlf/locallang_db.xml:tt_content.dlf_search', $_EXTKEY.'_search'), 'list_type');
t3lib_extMgm::addPiFlexFormValue($_EXTKEY.'_search', 'FILE:EXT:'.$_EXTKEY.'/plugins/search/flexform.xml');
// Plugin "table of contents".
$TCA['tt_content']['types']['list']['subtypes_excludelist'][$_EXTKEY.'_toc'] = 'layout,select_key,pages,recursive';
$TCA['tt_content']['types']['list']['subtypes_addlist'][$_EXTKEY.'_toc'] = 'pi_flexform';
t3lib_extMgm::addPlugin(array('LLL:EXT:dlf/locallang_db.xml:tt_content.dlf_toc', $_EXTKEY.'_toc'), 'list_type');
t3lib_extMgm::addStaticFile($_EXTKEY,'plugins/toc/', 'Table of Contents');
t3lib_extMgm::addPiFlexFormValue($_EXTKEY.'_toc', 'FILE:EXT:'.$_EXTKEY.'/plugins/toc/flexform.xml');
// Register modules.
if (TYPO3_MODE == 'BE') {
// Add modules after "web".
if (!isset($TBE_MODULES['txdlfmodules'])) {
$modules = array();
foreach($TBE_MODULES as $key => $val) {
if ($key == 'web') {
$modules[$key] = $val;
$modules['txdlfmodules'] = '';
} else {
$modules[$key] = $val;
}
}
$TBE_MODULES = $modules;
unset($modules);
}
// Main "dlf" module.
t3lib_extMgm::addModule('txdlfmodules', '', '', t3lib_extMgm::extPath($_EXTKEY).'modules/');
// Module "indexing".
t3lib_extMgm::addModule('txdlfmodules', 'txdlfindexing', '', t3lib_extMgm::extPath($_EXTKEY).'modules/indexing/');
t3lib_extMgm::addLLrefForTCAdescr('_MOD_txdlfmodules_txdlfindexing','EXT:dlf/modules/indexing/locallang_mod.xml');
}
?>

223
dlf/ext_tables.sql Normal file
View File

@ -0,0 +1,223 @@
--
-- Table structure for table 'tx_dlf_documents'
--
CREATE TABLE tx_dlf_documents (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
tstamp int(11) DEFAULT '0' NOT NULL,
crdate int(11) DEFAULT '0' NOT NULL,
cruser_id int(11) DEFAULT '0' NOT NULL,
deleted tinyint(4) DEFAULT '0' NOT NULL,
hidden tinyint(4) DEFAULT '0' NOT NULL,
fe_group varchar(100) DEFAULT '' NOT NULL,
prod_id tinytext NOT NULL,
location text NOT NULL,
record_id tinytext NOT NULL,
opac_id tinytext NOT NULL,
union_id tinytext NOT NULL,
urn tinytext NOT NULL,
purl tinytext NOT NULL,
title text NOT NULL,
title_sorting text NOT NULL,
author tinytext NOT NULL,
author_sorting tinytext NOT NULL,
year tinytext NOT NULL,
year_sorting tinytext NOT NULL,
place tinytext NOT NULL,
place_sorting tinytext NOT NULL,
metadata longtext NOT NULL,
structure int(11) DEFAULT '0' NOT NULL,
partof int(11) DEFAULT '0' NOT NULL,
volume_sorting int(11) DEFAULT '0' NOT NULL,
collections int(11) DEFAULT '0' NOT NULL,
owner int(11) DEFAULT '0' NOT NULL,
solrcore int(11) DEFAULT '0' NOT NULL,
status tinyint(4) unsigned DEFAULT '0' NOT NULL,
PRIMARY KEY (uid),
KEY parent (pid)
);
--
-- Table structure for table 'tx_dlf_structures'
--
CREATE TABLE tx_dlf_structures (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
tstamp int(11) DEFAULT '0' NOT NULL,
crdate int(11) DEFAULT '0' NOT NULL,
cruser_id int(11) DEFAULT '0' NOT NULL,
deleted tinyint(4) DEFAULT '0' NOT NULL,
sys_language_uid int(11) DEFAULT '0' NOT NULL,
l18n_parent int(11) DEFAULT '0' NOT NULL,
l18n_diffsource mediumblob NOT NULL,
hidden tinyint(4) DEFAULT '0' NOT NULL,
toplevel tinyint(4) DEFAULT '0' NOT NULL,
label tinytext NOT NULL,
index_name tinytext NOT NULL,
oai_name tinytext NOT NULL,
status tinyint(4) unsigned DEFAULT '0' NOT NULL,
PRIMARY KEY (uid),
KEY parent (pid)
);
--
-- Table structure for table 'tx_dlf_metadata'
--
CREATE TABLE tx_dlf_metadata (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
tstamp int(11) DEFAULT '0' NOT NULL,
crdate int(11) DEFAULT '0' NOT NULL,
cruser_id int(11) DEFAULT '0' NOT NULL,
deleted tinyint(4) DEFAULT '0' NOT NULL,
sys_language_uid int(11) DEFAULT '0' NOT NULL,
l18n_parent int(11) DEFAULT '0' NOT NULL,
l18n_diffsource mediumblob NOT NULL,
hidden tinyint(4) DEFAULT '0' NOT NULL,
sorting int(11) DEFAULT '0' NOT NULL,
label tinytext NOT NULL,
index_name tinytext NOT NULL,
encoded int(11) DEFAULT '0' NOT NULL,
xpath text NOT NULL,
default_value text NOT NULL,
wrap text NOT NULL,
tokenized tinyint(4) DEFAULT '0' NOT NULL,
stored tinyint(4) DEFAULT '0' NOT NULL,
indexed tinyint(4) DEFAULT '0' NOT NULL,
boost float(4,2) DEFAULT '1.00' NOT NULL,
is_sortable tinyint(4) DEFAULT '0' NOT NULL,
is_facet tinyint(4) DEFAULT '0' NOT NULL,
is_listed tinyint(4) DEFAULT '0' NOT NULL,
status tinyint(4) unsigned DEFAULT '0' NOT NULL,
PRIMARY KEY (uid),
KEY parent (pid)
);
--
-- Table structure for table 'tx_dlf_formats'
--
CREATE TABLE tx_dlf_formats (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
tstamp int(11) DEFAULT '0' NOT NULL,
crdate int(11) DEFAULT '0' NOT NULL,
cruser_id int(11) DEFAULT '0' NOT NULL,
deleted tinyint(4) DEFAULT '0' NOT NULL,
type tinytext NOT NULL,
other_type tinyint(4) DEFAULT '0' NOT NULL,
root tinytext NOT NULL,
namespace text NOT NULL,
class text NOT NULL,
PRIMARY KEY (uid),
KEY parent (pid)
);
--
-- Table structure for table 'tx_dlf_solrcores'
--
CREATE TABLE tx_dlf_solrcores (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
tstamp int(11) DEFAULT '0' NOT NULL,
crdate int(11) DEFAULT '0' NOT NULL,
cruser_id int(11) DEFAULT '0' NOT NULL,
deleted tinyint(4) DEFAULT '0' NOT NULL,
label tinytext NOT NULL,
index_name tinytext NOT NULL,
PRIMARY KEY (uid),
KEY parent (pid)
);
--
-- Table structure for table 'tx_dlf_collections'
--
CREATE TABLE tx_dlf_collections (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
tstamp int(11) DEFAULT '0' NOT NULL,
crdate int(11) DEFAULT '0' NOT NULL,
cruser_id int(11) DEFAULT '0' NOT NULL,
fe_cruser_id int(11) DEFAULT '0' NOT NULL,
fe_admin_lock tinyint(4) DEFAULT '0' NOT NULL,
deleted tinyint(4) DEFAULT '0' NOT NULL,
sys_language_uid int(11) DEFAULT '0' NOT NULL,
l18n_parent int(11) DEFAULT '0' NOT NULL,
l18n_diffsource mediumblob NOT NULL,
hidden tinyint(4) DEFAULT '0' NOT NULL,
fe_group varchar(100) DEFAULT '' NOT NULL,
label text NOT NULL,
index_name tinytext NOT NULL,
oai_name tinytext NOT NULL,
description text NOT NULL,
documents int(11) DEFAULT '0' NOT NULL,
owner int(11) DEFAULT '0' NOT NULL,
status tinyint(4) unsigned DEFAULT '0' NOT NULL,
PRIMARY KEY (uid),
KEY parent (pid)
);
--
-- Table structure for table 'tx_dlf_libraries'
--
CREATE TABLE tx_dlf_libraries (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
tstamp int(11) DEFAULT '0' NOT NULL,
crdate int(11) DEFAULT '0' NOT NULL,
cruser_id int(11) DEFAULT '0' NOT NULL,
deleted tinyint(4) DEFAULT '0' NOT NULL,
sys_language_uid int(11) DEFAULT '0' NOT NULL,
l18n_parent int(11) DEFAULT '0' NOT NULL,
l18n_diffsource mediumblob NOT NULL,
label tinytext NOT NULL,
index_name tinytext NOT NULL,
website tinytext NOT NULL,
contact tinytext NOT NULL,
image mediumblob NOT NULL,
oai_label tinytext NOT NULL,
oai_base int(11) DEFAULT '0' NOT NULL,
opac_label tinytext NOT NULL,
opac_base tinytext NOT NULL,
union_label tinytext NOT NULL,
union_base tinytext NOT NULL,
PRIMARY KEY (uid),
KEY parent (pid)
);
--
-- Table structure for table 'tx_dlf_tokens'
--
CREATE TABLE tx_dlf_tokens (
uid int(11) NOT NULL auto_increment,
tstamp int(11) DEFAULT '0' NOT NULL,
token tinytext NOT NULL,
options longtext NOT NULL,
ident varchar(30) DEFAULT '' NOT NULL,
PRIMARY KEY (uid)
);
--
-- Table structure for table 'tx_dlf_relations'
--
CREATE TABLE tx_dlf_relations (
uid int(11) NOT NULL auto_increment,
uid_local int(11) DEFAULT '0' NOT NULL,
uid_foreign int(11) DEFAULT '0' NOT NULL,
tablenames varchar(30) DEFAULT '' NOT NULL,
sorting int(11) DEFAULT '0' NOT NULL,
sorting_foreign int(11) DEFAULT '0' NOT NULL,
ident varchar(30) DEFAULT '' NOT NULL,
PRIMARY KEY (uid),
KEY uid_local (uid_local),
KEY uid_foreign (uid_foreign)
);

View File

@ -0,0 +1,40 @@
--
-- Table structure for table 'tx_dlf_formats'
--
CREATE TABLE tx_dlf_formats (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
tstamp int(11) DEFAULT '0' NOT NULL,
crdate int(11) DEFAULT '0' NOT NULL,
cruser_id int(11) DEFAULT '0' NOT NULL,
deleted tinyint(4) DEFAULT '0' NOT NULL,
type tinytext NOT NULL,
other_type tinyint(4) DEFAULT '0' NOT NULL,
root tinytext NOT NULL,
namespace text NOT NULL,
class text NOT NULL,
PRIMARY KEY (uid),
KEY parent (pid)
);
INSERT INTO tx_dlf_formats VALUES ('', '0', '0', '0', '0', '0', 'MODS', '0', 'mods', 'http://www.loc.gov/mods/v3', 'tx_dlf_mods');
--
-- Table structure for table 'tx_dlf_solrcores'
--
CREATE TABLE tx_dlf_solrcores (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
tstamp int(11) DEFAULT '0' NOT NULL,
crdate int(11) DEFAULT '0' NOT NULL,
cruser_id int(11) DEFAULT '0' NOT NULL,
deleted tinyint(4) DEFAULT '0' NOT NULL,
label tinytext NOT NULL,
index_name tinytext NOT NULL,
PRIMARY KEY (uid),
KEY parent (pid)
);
INSERT INTO tx_dlf_solrcores VALUES ('', '0', '0', '0', '0', '0', 'Default Core', 'dlfCore0');

View File

@ -0,0 +1,134 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*/
/**
* Hooks and helper for the extension manager.
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @copyright Copyright (c) 2010, Sebastian Meyer, SLUB Dresden
* @version $Id: class.tx_dlf_em.php 317 2010-10-08 11:58:14Z smeyer $
* @package TYPO3
* @subpackage tx_dlf
* @access public
*/
class tx_dlf_em {
/**
* Check if a connection to a Solr server could be established with the given credentials.
*
* @access public
*
* @param array &$params: An array with parameters
* @param t3lib_tsStyleConfig &$pObj: The parent object
*
* @return string Message informing the user of success or failure
*/
public function checkSolrConnection(&$params, &$pObj) {
// Get Solr credentials.
$conf = t3lib_div::_POST('data');
if (empty($conf)) {
$conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dlf']);
}
// Prepend username and password to hostname.
if ($conf['solrUser'] && $conf['solrPass']) {
$host = $conf['solrUser'].':'.$conf['solrPass'].'@'.($conf['solrHost'] ? $conf['solrHost'] : 'localhost');
} else {
$host = ($conf['solrHost'] ? $conf['solrHost'] : 'localhost');
}
// Set port if not set.
$port = (intval($conf['solrPort']) > 0 ? intval($conf['solrPort']) : 8180);
// Trim path and append trailing slash.
$path = (trim($conf['solrPath'], '/') ? trim($conf['solrPath'], '/').'/' : '');
// Build request URI.
$url = 'http://'.$host.':'.$port.'/'.$path.'admin/cores';
// Set user-agent.
$useragent = ($conf['useragent'] ? $conf['useragent'] : ini_get('user_agent'));
$context = stream_context_create(array (
'http' => array (
'method' => 'GET',
'user_agent' => $useragent
)
));
// Try to connect to Solr server.
$response = @simplexml_load_string(file_get_contents($url, FALSE, $context));
// Check status code.
if ($response) {
$status = $response->xpath('//lst[@name="responseHeader"]/int[@name="status"]');
if (is_array($status)) {
$message = t3lib_div::makeInstance(
't3lib_FlashMessage',
'The status code returned by Apache Solr is <strong>'.htmlspecialchars((string) $status[0]).'</strong>.',
'Connection established!',
($status[0] == 0 ? t3lib_FlashMessage::OK : t3lib_FlashMessage::WARNING),
FALSE
);
return $message->render();
}
}
$message = t3lib_div::makeInstance(
't3lib_FlashMessage',
'Apache Solr was not reachable with the given details.',
'Connection failed!',
t3lib_FlashMessage::ERROR,
FALSE
);
return $message->render();
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/hooks/class.tx_dlf_em.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/hooks/class.tx_dlf_em.php']);
}
?>

View File

@ -0,0 +1,111 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*/
/**
* Hooks and hacks for Goobi.Production.
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @copyright Copyright (c) 2010, Sebastian Meyer, SLUB Dresden
* @version $Id: class.tx_dlf_hacks.php 470 2010-12-21 17:49:01Z smeyer $
* @package TYPO3
* @subpackage tx_dlf
* @access public
*/
class tx_dlf_hacks {
/**
* Hook for the __construct() method of dlf/common/class.tx_dlf_document.php
* When using Goobi.Production the record identifier is saved only in MODS, but not
* in METS. To get it anyway, we have to do some magic.
*
* @access public
*
* @param SimpleXMLElement &$xml: The XML object
* @param mixed &$record_id: The record identifier
*
* @return void
*/
public function construct_postProcessRecordId(SimpleXMLElement &$xml, &$record_id) {
if (!$record_id) {
$xml->registerXPathNamespace('mods', 'http://www.loc.gov/mods/v3');
if (($_divs = $xml->xpath('//mets:structMap[@TYPE="LOGICAL"]//mets:div[@DMDID]'))) {
$_smLinks = $xml->xpath('//mets:structLink/mets:smLink');
if ($_smLinks) {
foreach ($_smLinks as $_smLink) {
$_links[(string) $_smLink->attributes('http://www.w3.org/1999/xlink')->from][] = (string) $_smLink->attributes('http://www.w3.org/1999/xlink')->to;
}
foreach ($_divs as $_div) {
if (!empty($_links[(string) $_div['ID']])) {
$_id = (string) $_div['DMDID'];
break;
}
}
}
if (empty($_id)) {
$_id = (string) $_divs[0]['DMDID'];
}
$_recordId = $xml->xpath('//mets:dmdSec[@ID="'.$_id.'"]//mods:mods/mods:recordInfo/mods:recordIdentifier');
if ($_recordId) {
$record_id = $_recordId[0];
}
}
}
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/hooks/class.tx_dlf_hacks.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/hooks/class.tx_dlf_hacks.php']);
}
?>

View File

@ -0,0 +1,157 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*/
/**
* Hooks and helper for the 't3lib_TCEforms' library.
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @copyright Copyright (c) 2010, Sebastian Meyer, SLUB Dresden
* @version $Id: class.tx_dlf_tcemain.php 101 2010-06-01 13:29:40Z smeyer $
* @package TYPO3
* @subpackage tx_dlf
* @access public
*/
class tx_dlf_tceforms {
/**
* Helper to get flexform's items array for plugin "tx_dlf_collection"
*
* @access public
*
* @param array &$params: An array with parameters
* @param t3lib_TCEforms &$pObj: The parent object
*
* @return void
*/
public function itemsProcFunc_collectionList(&$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 (!t3lib_div::testInt($pages)) {
$_parts = explode('|', $pages);
$pages = array_pop(explode('_', $_parts[0]));
}
if ($pages > 0) {
$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'label,uid',
'tx_dlf_collections',
'pid='.intval($pages).' AND (sys_language_uid IN (-1,0) OR l18n_parent=0)'.tx_dlf_helper::whereClause('tx_dlf_collections'),
'',
'label',
''
);
if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) {
while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_row($result)) {
$params['items'][] = $resArray;
}
}
}
}
}
/**
* Helper to get flexform's items array for plugin "tx_dlf_oai"
*
* @access public
*
* @param array &$params: An array with parameters
* @param t3lib_TCEforms &$pObj: The parent object
*
* @return void
*/
public function itemsProcFunc_libraryList(&$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 (!t3lib_div::testInt($pages)) {
$_parts = explode('|', $pages);
$pages = array_pop(explode('_', $_parts[0]));
}
if ($pages > 0) {
$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'label,uid',
'tx_dlf_libraries',
'pid='.intval($pages).' AND (sys_language_uid IN (-1,0) OR l18n_parent=0)'.tx_dlf_helper::whereClause('tx_dlf_libraries'),
'',
'label',
''
);
if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) > 0) {
while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_row($result)) {
$params['items'][] = $resArray;
}
}
}
}
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/hooks/class.tx_dlf_tceforms.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/hooks/class.tx_dlf_tceforms.php']);
}
?>

View File

@ -0,0 +1,274 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*/
/**
* Hooks and helper for the 't3lib_TCEmain' library.
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @copyright Copyright (c) 2010, Sebastian Meyer, SLUB Dresden
* @version $Id: class.tx_dlf_tcemain.php 472 2010-12-22 08:57:35Z smeyer $
* @package TYPO3
* @subpackage tx_dlf
* @access public
*/
class tx_dlf_tcemain {
/**
* Post-processing hook for the process_datamap() method.
*
* @access public
*
* @param string $status: 'new' or 'update'
* @param string $table: The destination table
* @param integer $id: The uid of the record
* @param array &$fieldArray: Array of field values
* @param t3lib_TCEmain $pObj: The parent object
*
* @return void
*/
public function processDatamap_postProcessFieldArray($status, $table, $id, &$fieldArray, $pObj) {
if ($status == 'new') {
switch ($table) {
// Field post-processing for table "tx_dlf_documents".
case 'tx_dlf_documents':
if (empty($fieldArray['title_sorting']) && !empty($fieldArray['title'])) {
$fieldArray['title_sorting'] = $fieldArray['title'];
}
if (empty($fieldArray['author_sorting']) && !empty($fieldArray['author'])) {
$fieldArray['author_sorting'] = $fieldArray['author'];
}
if (empty($fieldArray['year_sorting']) && !empty($fieldArray['year'])) {
$fieldArray['year_sorting'] = str_ireplace('x', '5', preg_replace('/[^\d.x]/i', '', (string) $fieldArray['year']));
if (strpos($fieldArray['year_sorting'], '.') || strlen($fieldArray['year_sorting']) < 3) {
$fieldArray['year_sorting'] = ((intval(trim($fieldArray['year_sorting'], '.')) - 1) * 100) + 50;
}
}
if (empty($fieldArray['place_sorting']) && !empty($fieldArray['place'])) {
$fieldArray['place_sorting'] = preg_replace('/[[:punct:]]/', '', (string) $fieldArray['place']);
}
break;
// Field post-processing for tables "tx_dlf_collections", "tx_dlf_libraries", "tx_dlf_metadata" and "tx_dlf_structures".
case 'tx_dlf_collections':
case 'tx_dlf_libraries':
case 'tx_dlf_metadata':
case 'tx_dlf_structures':
if (empty($fieldArray['index_name']) && !empty($fieldArray['label'])) {
$fieldArray['index_name'] = $fieldArray['label'];
}
if (empty($fieldArray['label']) && !empty($fieldArray['index_name'])) {
$fieldArray['label'] = $fieldArray['index_name'];
}
break;
// Field post-processing for table "tx_dlf_solrcores".
case 'tx_dlf_solrcores':
// Get number of existing cores.
$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'*',
'tx_dlf_solrcores',
'',
'',
'',
''
);
// Get first unused core number.
$coreNumber = tx_dlf_solr::solrGetCoreNumber($GLOBALS['TYPO3_DB']->sql_num_rows($result));
// Get Solr credentials.
$conf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dlf']);
// Prepend username and password to hostname.
if ($conf['solrUser'] && $conf['solrPass']) {
$host = $conf['solrUser'].':'.$conf['solrPass'].'@'.($conf['solrHost'] ? $conf['solrHost'] : 'localhost');
} else {
$host = ($conf['solrHost'] ? $conf['solrHost'] : 'localhost');
}
// Set port if not set.
$port = (intval($conf['solrPort']) > 0 ? intval($conf['solrPort']) : 8180);
// Trim path and append trailing slash.
$path = (trim($conf['solrPath'], '/') ? trim($conf['solrPath'], '/').'/' : '');
// Build request.
// @see http://wiki.apache.org/solr/CoreAdmin
$url = 'http://'.$host.':'.$port.'/'.$path.'admin/cores?action=CREATE&name=dlfCore'.$coreNumber.'&instanceDir=.&dataDir=dlfCore'.$coreNumber;
$context = stream_context_create(array (
'http' => array (
'method' => 'GET',
'user_agent' => ($conf['useragent'] ? $conf['useragent'] : ini_get('user_agent'))
)
));
$response = @simplexml_load_string(file_get_contents($url, FALSE, $context));
// Process response.
if ($response) {
$status = $response->xpath('//lst[@name="responseHeader"]/int[@name="status"]');
if ($status && $status[0] == 0) {
$fieldArray['index_name'] = 'dlfCore'.$coreNumber;
return;
}
}
trigger_error('Could not create new Solr core "dlfCore'.$coreNumber.'"', E_USER_WARNING);
$fieldArray = NULL;
break;
}
}
}
/**
* 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 t3lib_TCEmain $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.index_name AS index_name',
'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);
// Establish Solr connection.
if ($solr = tx_dlf_solr::solrConnect($core)) {
switch ($command) {
case 'move':
// Delete and reindex document.
$solr->deleteByQuery('uid:'.$id);
$solr->commit();
$doc = tx_dlf_document::getInstance($id);
$doc->save($doc->pid, $core);
break;
case 'delete':
// Delete Solr document.
$solr->deleteByQuery('uid:'.$id);
$solr->commit();
break;
case 'undelete':
// Reindex document.
$doc = tx_dlf_document::getInstance($id);
$doc->save($doc->pid, $core);
break;
}
}
}
}
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/hooks/class.tx_dlf_tcemain.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/hooks/class.tx_dlf_tcemain.php']);
}
?>

View File

@ -0,0 +1,367 @@
<?php
/**
* Copyright (c) 2007-2011, Servigistics, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of Servigistics, Inc. nor the names of
* its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
* @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
* @version $Id: Document.php 54 2011-02-04 16:29:18Z donovan.jimenez $
*
* @package Apache
* @subpackage Solr
* @author Donovan Jimenez <djimenez@conduit-it.com>
*/
/**
* Holds Key / Value pairs that represent a Solr Document along with any associated boost
* values. Field values can be accessed by direct dereferencing such as:
* <code>
* ...
* $document->title = 'Something';
* echo $document->title;
* ...
* </code>
*
* Additionally, the field values can be iterated with foreach
*
* <code>
* foreach ($document as $fieldName => $fieldValue)
* {
* ...
* }
* </code>
*/
class Apache_Solr_Document implements IteratorAggregate
{
/**
* SVN Revision meta data for this class
*/
const SVN_REVISION = '$Revision: 54 $';
/**
* SVN ID meta data for this class
*/
const SVN_ID = '$Id: Document.php 54 2011-02-04 16:29:18Z donovan.jimenez $';
/**
* Document boost value
*
* @var float
*/
protected $_documentBoost = false;
/**
* Document field values, indexed by name
*
* @var array
*/
protected $_fields = array();
/**
* Document field boost values, indexed by name
*
* @var array array of floats
*/
protected $_fieldBoosts = array();
/**
* Clear all boosts and fields from this document
*/
public function clear()
{
$this->_documentBoost = false;
$this->_fields = array();
$this->_fieldBoosts = array();
}
/**
* Get current document boost
*
* @return mixed will be false for default, or else a float
*/
public function getBoost()
{
return $this->_documentBoost;
}
/**
* Set document boost factor
*
* @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false
*/
public function setBoost($boost)
{
$boost = (float) $boost;
if ($boost > 0.0)
{
$this->_documentBoost = $boost;
}
else
{
$this->_documentBoost = false;
}
}
/**
* Add a value to a multi-valued field
*
* NOTE: the solr XML format allows you to specify boosts
* PER value even though the underlying Lucene implementation
* only allows a boost per field. To remedy this, the final
* field boost value will be the product of all specified boosts
* on field values - this is similar to SolrJ's functionality.
*
* <code>
* $doc = new Apache_Solr_Document();
*
* $doc->addField('foo', 'bar', 2.0);
* $doc->addField('foo', 'baz', 3.0);
*
* // resultant field boost will be 6!
* echo $doc->getFieldBoost('foo');
* </code>
*
* @param string $key
* @param mixed $value
* @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false
*/
public function addField($key, $value, $boost = false)
{
if (!isset($this->_fields[$key]))
{
// create holding array if this is the first value
$this->_fields[$key] = array();
}
else if (!is_array($this->_fields[$key]))
{
// move existing value into array if it is not already an array
$this->_fields[$key] = array($this->_fields[$key]);
}
if ($this->getFieldBoost($key) === false)
{
// boost not already set, set it now
$this->setFieldBoost($key, $boost);
}
else if ((float) $boost > 0.0)
{
// multiply passed boost with current field boost - similar to SolrJ implementation
$this->_fieldBoosts[$key] *= (float) $boost;
}
// add value to array
$this->_fields[$key][] = $value;
}
/**
* Handle the array manipulation for a multi-valued field
*
* @param string $key
* @param string $value
* @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false
*
* @deprecated Use addField(...) instead
*/
public function setMultiValue($key, $value, $boost = false)
{
$this->addField($key, $value, $boost);
}
/**
* Get field information
*
* @param string $key
* @return mixed associative array of info if field exists, false otherwise
*/
public function getField($key)
{
if (isset($this->_fields[$key]))
{
return array(
'name' => $key,
'value' => $this->_fields[$key],
'boost' => $this->getFieldBoost($key)
);
}
return false;
}
/**
* Set a field value. Multi-valued fields should be set as arrays
* or instead use the addField(...) function which will automatically
* make sure the field is an array.
*
* @param string $key
* @param mixed $value
* @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false
*/
public function setField($key, $value, $boost = false)
{
$this->_fields[$key] = $value;
$this->setFieldBoost($key, $boost);
}
/**
* Get the currently set field boost for a document field
*
* @param string $key
* @return float currently set field boost, false if one is not set
*/
public function getFieldBoost($key)
{
return isset($this->_fieldBoosts[$key]) ? $this->_fieldBoosts[$key] : false;
}
/**
* Set the field boost for a document field
*
* @param string $key field name for the boost
* @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false
*/
public function setFieldBoost($key, $boost)
{
$boost = (float) $boost;
if ($boost > 0.0)
{
$this->_fieldBoosts[$key] = $boost;
}
else
{
$this->_fieldBoosts[$key] = false;
}
}
/**
* Return current field boosts, indexed by field name
*
* @return array
*/
public function getFieldBoosts()
{
return $this->_fieldBoosts;
}
/**
* Get the names of all fields in this document
*
* @return array
*/
public function getFieldNames()
{
return array_keys($this->_fields);
}
/**
* Get the values of all fields in this document
*
* @return array
*/
public function getFieldValues()
{
return array_values($this->_fields);
}
/**
* IteratorAggregate implementation function. Allows usage:
*
* <code>
* foreach ($document as $key => $value)
* {
* ...
* }
* </code>
*/
public function getIterator()
{
$arrayObject = new ArrayObject($this->_fields);
return $arrayObject->getIterator();
}
/**
* Magic get for field values
*
* @param string $key
* @return mixed
*/
public function __get($key)
{
if (isset($this->_fields[$key]))
{
return $this->_fields[$key];
}
return null;
}
/**
* Magic set for field values. Multi-valued fields should be set as arrays
* or instead use the addField(...) function which will automatically
* make sure the field is an array.
*
* @param string $key
* @param mixed $value
*/
public function __set($key, $value)
{
$this->setField($key, $value);
}
/**
* Magic isset for fields values. Do not call directly. Allows usage:
*
* <code>
* isset($document->some_field);
* </code>
*
* @param string $key
* @return boolean
*/
public function __isset($key)
{
return isset($this->_fields[$key]);
}
/**
* Magic unset for field values. Do not call directly. Allows usage:
*
* <code>
* unset($document->some_field);
* </code>
*
* @param string $key
*/
public function __unset($key)
{
unset($this->_fields[$key]);
unset($this->_fieldBoosts[$key]);
}
}

View File

@ -0,0 +1,50 @@
<?php
/**
* Copyright (c) 2007-2011, Servigistics, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of Servigistics, Inc. nor the names of
* its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
* @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
* @version $Id: Exception.php 54 2011-02-04 16:29:18Z donovan.jimenez $
*
* @package Apache
* @subpackage Solr
* @author Donovan Jimenez <djimenez@conduit-it.com>
*/
class Apache_Solr_Exception extends Exception
{
/**
* SVN Revision meta data for this class
*/
const SVN_REVISION = '$Revision: 54 $';
/**
* SVN ID meta data for this class
*/
const SVN_ID = '$Id: Exception.php 54 2011-02-04 16:29:18Z donovan.jimenez $';
}

View File

@ -0,0 +1,89 @@
<?php
/**
* Copyright (c) 2007-2011, Servigistics, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of Servigistics, Inc. nor the names of
* its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
* @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
* @version $Id: $
*
* @package Apache
* @subpackage Solr
* @author Timo Schmidt <timo.schmidt@aoemedia.de>, Donovan Jimenez <djimenez@conduit-it.com>
*/
/**
* Convenience class that implements the transport implementation. Can be extended by
* real implementations to do some of the common book keeping
*/
abstract class Apache_Solr_HttpTransport_Abstract implements Apache_Solr_HttpTransport_Interface
{
/**
* Our default timeout value for requests that don't specify a timeout
*
* @var float
*/
private $_defaultTimeout = false;
/**
* Get the current default timeout setting (initially the default_socket_timeout ini setting)
* in seconds
*
* @return float
*/
public function getDefaultTimeout()
{
// lazy load the default timeout from the ini settings
if ($this->_defaultTimeout === false)
{
$this->_defaultTimeout = (int) ini_get('default_socket_timeout');
// double check we didn't get 0 for a timeout
if ($this->_defaultTimeout <= 0)
{
$this->_defaultTimeout = 60;
}
}
return $this->_defaultTimeout;
}
/**
* Set the current default timeout for all HTTP requests
*
* @param float $timeout
*/
public function setDefaultTimeout($timeout)
{
$timeout = (float) $timeout;
if ($timeout >= 0)
{
$this->_defaultTimeout = $timeout;
}
}
}

View File

@ -0,0 +1,198 @@
<?php
/**
* Copyright (c) 2007-2011, Servigistics, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of Servigistics, Inc. nor the names of
* its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
* @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
* @version $Id: $
*
* @package Apache
* @subpackage Solr
* @author Timo Schmidt <timo.schmidt@aoemedia.de>, Donovan Jimenez <djimenez@conduit-it.com>
*/
// Require Apache_Solr_HttpTransport_Abstract
require_once(dirname(__FILE__) . '/Abstract.php');
/**
* A Curl based HTTP transport. Uses a single curl session for all requests.
*/
class Apache_Solr_HttpTransport_Curl extends Apache_Solr_HttpTransport_Abstract
{
/**
* SVN Revision meta data for this class
*/
const SVN_REVISION = '$Revision:$';
/**
* SVN ID meta data for this class
*/
const SVN_ID = '$Id:$';
/**
* Curl Session Handle
*
* @var resource
*/
private $_curl;
/**
* Initializes a curl session
*/
public function __construct()
{
// initialize a CURL session
$this->_curl = curl_init();
// set common options that will not be changed during the session
curl_setopt_array($this->_curl, array(
// return the response body from curl_exec
CURLOPT_RETURNTRANSFER => true,
// get the output as binary data
CURLOPT_BINARYTRANSFER => true,
// we do not need the headers in the output, we get everything we need from curl_getinfo
CURLOPT_HEADER => false
));
}
/**
* Closes a curl session
*/
function __destruct()
{
// close our curl session
curl_close($this->_curl);
}
public function performGetRequest($url, $timeout = false)
{
// check the timeout value
if ($timeout === false || $timeout <= 0.0)
{
// use the default timeout
$timeout = $this->getDefaultTimeout();
}
// set curl GET options
curl_setopt_array($this->_curl, array(
// make sure we're returning the body
CURLOPT_NOBODY => false,
// make sure we're GET
CURLOPT_HTTPGET => true,
// set the URL
CURLOPT_URL => $url,
// set the timeout
CURLOPT_TIMEOUT => $timeout
));
// make the request
$responseBody = curl_exec($this->_curl);
// get info from the transfer
$statusCode = curl_getinfo($this->_curl, CURLINFO_HTTP_CODE);
$contentType = curl_getinfo($this->_curl, CURLINFO_CONTENT_TYPE);
return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody);
}
public function performHeadRequest($url, $timeout = false)
{
// check the timeout value
if ($timeout === false || $timeout <= 0.0)
{
// use the default timeout
$timeout = $this->getDefaultTimeout();
}
// set curl HEAD options
curl_setopt_array($this->_curl, array(
// this both sets the method to HEAD and says not to return a body
CURLOPT_NOBODY => true,
// set the URL
CURLOPT_URL => $url,
// set the timeout
CURLOPT_TIMEOUT => $timeout
));
// make the request
$responseBody = curl_exec($this->_curl);
// get info from the transfer
$statusCode = curl_getinfo($this->_curl, CURLINFO_HTTP_CODE);
$contentType = curl_getinfo($this->_curl, CURLINFO_CONTENT_TYPE);
return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody);
}
public function performPostRequest($url, $postData, $contentType, $timeout = false)
{
// check the timeout value
if ($timeout === false || $timeout <= 0.0)
{
// use the default timeout
$timeout = $this->getDefaultTimeout();
}
// set curl POST options
curl_setopt_array($this->_curl, array(
// make sure we're returning the body
CURLOPT_NOBODY => false,
// make sure we're POST
CURLOPT_POST => true,
// set the URL
CURLOPT_URL => $url,
// set the post data
CURLOPT_POSTFIELDS => $postData,
// set the content type
CURLOPT_HTTPHEADER => array("Content-Type: {$contentType}"),
// set the timeout
CURLOPT_TIMEOUT => $timeout
));
// make the request
$responseBody = curl_exec($this->_curl);
// get info from the transfer
$statusCode = curl_getinfo($this->_curl, CURLINFO_HTTP_CODE);
$contentType = curl_getinfo($this->_curl, CURLINFO_CONTENT_TYPE);
return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody);
}
}

View File

@ -0,0 +1,196 @@
<?php
/**
* Copyright (c) 2007-2011, Servigistics, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of Servigistics, Inc. nor the names of
* its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
* @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
* @version $Id: $
*
* @package Apache
* @subpackage Solr
* @author Timo Schmidt <timo.schmidt@aoemedia.de>, Donovan Jimenez <djimenez@conduit-it.com>
*/
// Require Apache_Solr_HttpTransport_Abstract
require_once(dirname(__FILE__) . '/Abstract.php');
/**
* An alternative Curl HTTP transport that opens and closes a curl session for
* every request. This isn't the recommended way to use curl, but some version of
* PHP have memory issues.
*/
class Apache_Solr_HttpTransport_CurlNoReuse extends Apache_Solr_HttpTransport_Abstract
{
/**
* SVN Revision meta data for this class
*/
const SVN_REVISION = '$Revision:$';
/**
* SVN ID meta data for this class
*/
const SVN_ID = '$Id:$';
public function performGetRequest($url, $timeout = false)
{
// check the timeout value
if ($timeout === false || $timeout <= 0.0)
{
// use the default timeout
$timeout = $this->getDefaultTimeout();
}
$curl = curl_init();
// set curl GET options
curl_setopt_array($curl, array(
// return the response body from curl_exec
CURLOPT_RETURNTRANSFER => true,
// get the output as binary data
CURLOPT_BINARYTRANSFER => true,
// we do not need the headers in the output, we get everything we need from curl_getinfo
CURLOPT_HEADER => false,
// set the URL
CURLOPT_URL => $url,
// set the timeout
CURLOPT_TIMEOUT => $timeout
));
// make the request
$responseBody = curl_exec($curl);
// get info from the transfer
$statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE);
// close our curl session - we're done with it
curl_close($curl);
return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody);
}
public function performHeadRequest($url, $timeout = false)
{
// check the timeout value
if ($timeout === false || $timeout <= 0.0)
{
// use the default timeout
$timeout = $this->getDefaultTimeout();
}
$curl = curl_init();
// set curl HEAD options
curl_setopt_array($curl, array(
// return the response body from curl_exec
CURLOPT_RETURNTRANSFER => true,
// get the output as binary data
CURLOPT_BINARYTRANSFER => true,
// we do not need the headers in the output, we get everything we need from curl_getinfo
CURLOPT_HEADER => false,
// this both sets the method to HEAD and says not to return a body
CURLOPT_NOBODY => true,
// set the URL
CURLOPT_URL => $url,
// set the timeout
CURLOPT_TIMEOUT => $timeout
));
// make the request
$responseBody = curl_exec($curl);
// get info from the transfer
$statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE);
// close our curl session - we're done with it
curl_close($curl);
return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody);
}
public function performPostRequest($url, $postData, $contentType, $timeout = false)
{
// check the timeout value
if ($timeout === false || $timeout <= 0.0)
{
// use the default timeout
$timeout = $this->getDefaultTimeout();
}
$curl = curl_init();
// set curl POST options
curl_setopt_array($curl, array(
// return the response body from curl_exec
CURLOPT_RETURNTRANSFER => true,
// get the output as binary data
CURLOPT_BINARYTRANSFER => true,
// we do not need the headers in the output, we get everything we need from curl_getinfo
CURLOPT_HEADER => false,
// make sure we're POST
CURLOPT_POST => true,
// set the URL
CURLOPT_URL => $url,
// set the post data
CURLOPT_POSTFIELDS => $postData,
// set the content type
CURLOPT_HTTPHEADER => array("Content-Type: {$contentType}"),
// set the timeout
CURLOPT_TIMEOUT => $timeout
));
// make the request
$responseBody = curl_exec($curl);
// get info from the transfer
$statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE);
// close our curl session - we're done with it
curl_close($curl);
return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody);
}
}

View File

@ -0,0 +1,216 @@
<?php
/**
* Copyright (c) 2007-2011, Servigistics, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of Servigistics, Inc. nor the names of
* its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
* @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
* @version $Id: $
*
* @package Apache
* @subpackage Solr
* @author Donovan Jimenez <djimenez@conduit-it.com>
*/
// Require Apache_Solr_HttpTransport_Abstract
require_once(dirname(__FILE__) . '/Abstract.php');
/**
* HTTP Transport implemenation that uses the builtin http URL wrappers and file_get_contents
*/
class Apache_Solr_HttpTransport_FileGetContents extends Apache_Solr_HttpTransport_Abstract
{
/**
* SVN Revision meta data for this class
*/
const SVN_REVISION = '$Revision: $';
/**
* SVN ID meta data for this class
*/
const SVN_ID = '$Id: $';
/**
* Reusable stream context resources for GET and POST operations
*
* @var resource
*/
private $_getContext, $_headContext, $_postContext;
/**
* Initializes our reuseable get and post stream contexts
*/
public function __construct()
{
$this->_getContext = stream_context_create();
$this->_headContext = stream_context_create();
$this->_postContext = stream_context_create();
}
public function performGetRequest($url, $timeout = false)
{
// set the timeout if specified
if ($timeout !== FALSE && $timeout > 0.0)
{
// timeouts with file_get_contents seem to need
// to be halved to work as expected
$timeout = (float) $timeout / 2;
stream_context_set_option($this->_getContext, 'http', 'timeout', $timeout);
}
else
{
// use the default timeout pulled from default_socket_timeout otherwise
stream_context_set_option($this->_getContext, 'http', 'timeout', $this->getDefaultTimeout());
}
// $http_response_headers will be updated by the call to file_get_contents later
// see http://us.php.net/manual/en/wrappers.http.php for documentation
// Unfortunately, it will still create a notice in analyzers if we don't set it here
$http_response_header = null;
$responseBody = @file_get_contents($url, false, $this->_getContext);
return $this->_getResponseFromParts($responseBody, $http_response_header);
}
public function performHeadRequest($url, $timeout = false)
{
stream_context_set_option($this->_headContext, array(
'http' => array(
// set HTTP method
'method' => 'HEAD',
// default timeout
'timeout' => $this->getDefaultTimeout()
)
)
);
// set the timeout if specified
if ($timeout !== FALSE && $timeout > 0.0)
{
// timeouts with file_get_contents seem to need
// to be halved to work as expected
$timeout = (float) $timeout / 2;
stream_context_set_option($this->_headContext, 'http', 'timeout', $timeout);
}
// $http_response_headers will be updated by the call to file_get_contents later
// see http://us.php.net/manual/en/wrappers.http.php for documentation
// Unfortunately, it will still create a notice in analyzers if we don't set it here
$http_response_header = null;
$responseBody = @file_get_contents($url, false, $this->_headContext);
return $this->_getResponseFromParts($responseBody, $http_response_header);
}
public function performPostRequest($url, $rawPost, $contentType, $timeout = false)
{
stream_context_set_option($this->_postContext, array(
'http' => array(
// set HTTP method
'method' => 'POST',
// Add our posted content type
'header' => "Content-Type: $contentType",
// the posted content
'content' => $rawPost,
// default timeout
'timeout' => $this->getDefaultTimeout()
)
)
);
// set the timeout if specified
if ($timeout !== FALSE && $timeout > 0.0)
{
// timeouts with file_get_contents seem to need
// to be halved to work as expected
$timeout = (float) $timeout / 2;
stream_context_set_option($this->_postContext, 'http', 'timeout', $timeout);
}
// $http_response_header will be updated by the call to file_get_contents later
// see http://us.php.net/manual/en/wrappers.http.php for documentation
// Unfortunately, it will still create a notice in analyzers if we don't set it here
$http_response_header = null;
$responseBody = @file_get_contents($url, false, $this->_postContext);
// reset content of post context to reclaim memory
stream_context_set_option($this->_postContext, 'http', 'content', '');
return $this->_getResponseFromParts($responseBody, $http_response_header);
}
private function _getResponseFromParts($rawResponse, $httpHeaders)
{
//Assume 0, false as defaults
$status = 0;
$contentType = false;
//iterate through headers for real status, type, and encoding
if (is_array($httpHeaders) && count($httpHeaders) > 0)
{
//look at the first headers for the HTTP status code
//and message (errors are usually returned this way)
//
//HTTP 100 Continue response can also be returned before
//the REAL status header, so we need look until we find
//the last header starting with HTTP
//
//the spec: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.1
//
//Thanks to Daniel Andersson for pointing out this oversight
while (isset($httpHeaders[0]) && substr($httpHeaders[0], 0, 4) == 'HTTP')
{
// we can do a intval on status line without the "HTTP/1.X " to get the code
$status = intval(substr($httpHeaders[0], 9));
// remove this from the headers so we can check for more
array_shift($httpHeaders);
}
//Look for the Content-Type response header and determine type
//and encoding from it (if possible - such as 'Content-Type: text/plain; charset=UTF-8')
foreach ($httpHeaders as $header)
{
// look for the header that starts appropriately
if (strncasecmp($header, 'Content-Type:', 13) == 0)
{
$contentType = substr($header, 13);
break;
}
}
}
return new Apache_Solr_HttpTransport_Response($status, $contentType, $rawResponse);
}
}

View File

@ -0,0 +1,94 @@
<?php
/**
* Copyright (c) 2007-2011, Servigistics, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of Servigistics, Inc. nor the names of
* its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
* @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
* @version $Id: $
*
* @package Apache
* @subpackage Solr
* @author Timo Schmidt <timo.schmidt@aoemedia.de>, Donovan Jimenez <djimenez@conduit-it.com>
*/
// require Apache_Solr_HttpTransport_Response
require_once(dirname(__FILE__) . '/Response.php');
/**
* Interface that all Transport (HTTP Requester) implementations must implement. These
* Implementations can then be plugged into the Service instance in order to user their
* the desired method for making HTTP requests
*/
interface Apache_Solr_HttpTransport_Interface
{
/**
* Get the current default timeout for all HTTP requests
*
* @return float
*/
public function getDefaultTimeout();
/**
* Set the current default timeout for all HTTP requests
*
* @param float $timeout
*/
public function setDefaultTimeout($timeout);
/**
* Perform a GET HTTP operation with an optional timeout and return the response
* contents, use getLastResponseHeaders to retrieve HTTP headers
*
* @param string $url
* @param float $timeout
* @return Apache_Solr_HttpTransport_Response HTTP response
*/
public function performGetRequest($url, $timeout = false);
/**
* Perform a HEAD HTTP operation with an optional timeout and return the response
* headers - NOTE: head requests have no response body
*
* @param string $url
* @param float $timeout
* @return Apache_Solr_HttpTransport_Response HTTP response
*/
public function performHeadRequest($url, $timeout = false);
/**
* Perform a POST HTTP operation with an optional timeout and return the response
* contents, use getLastResponseHeaders to retrieve HTTP headers
*
* @param string $url
* @param string $rawPost
* @param string $contentType
* @param float $timeout
* @return Apache_Solr_HttpTransport_Response HTTP response
*/
public function performPostRequest($url, $rawPost, $contentType, $timeout = false);
}

View File

@ -0,0 +1,255 @@
<?php
/**
* Copyright (c) 2007-2011, Servigistics, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of Servigistics, Inc. nor the names of
* its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
* @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
* @version $Id: $
*
* @package Apache
* @subpackage Solr
* @author Donovan Jimenez <djimenez@conduit-it.com>
*/
/**
* Represents the required pieces of an HTTP response provided by HTTP transport
* implementations and then consumed by the Apache_Solr_Response class which provides
* decoding
*/
class Apache_Solr_HttpTransport_Response
{
/**
* Status Messages indexed by Status Code
* Obtained from: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
*
* @var array
*/
static private $_defaultStatusMessages = array(
// Specific to PHP Solr Client
0 => "Communication Error",
// Informational 1XX
100 => "Continue",
101 => "Switching Protocols",
// Successful 2XX
200 => "OK",
201 => "Created",
202 => "Accepted",
203 => "Non-Authoritative Information",
204 => "No Content",
205 => "Reset Content",
206 => "Partial Content",
// Redirection 3XX
300 => "Multiple Choices",
301 => "Moved Permanently",
302 => "Found",
303 => "See Other",
304 => "Not Modified",
305 => "Use Proxy",
307 => "Temporary Redirect",
// Client Error 4XX
400 => "Bad Request",
401 => "Unauthorized",
402 => "Payment Required",
403 => "Forbidden",
404 => "Not Found",
405 => "Method Not Allowed",
406 => "Not Acceptable",
407 => "Proxy Authentication Required",
408 => "Request Timeout",
409 => "Conflict",
410 => "Gone",
411 => "Length Required",
412 => "Precondition Failed",
413 => "Request Entity Too Large",
414 => "Request-URI Too Long",
415 => "Unsupported Media Type",
416 => "Request Range Not Satisfiable",
417 => "Expectation Failed",
// Server Error 5XX
500 => "Internal Server Error",
501 => "Not Implemented",
502 => "Bad Gateway",
503 => "Service Unavailable",
504 => "Gateway Timeout",
505 => "HTTP Version Not Supported"
);
/**
* Get the HTTP status message based on status code
*
* @return string
*/
public static function getDefaultStatusMessage($statusCode)
{
$statusCode = (int) $statusCode;
if (isset(self::$_defaultStatusMessages[$statusCode]))
{
return self::$_defaultStatusMessages[$statusCode];
}
return "Unknown Status";
}
/**
* The response's HTTP status code
*
* @var integer
*/
private $_statusCode;
/**
* The response's HTTP status message
*
* @var string
*/
private $_statusMessage;
/**
* The response's mime type
*
* @var string
*/
private $_mimeType;
/**
* The response's character encoding
*
* @var string
*/
private $_encoding;
/**
* The response's data
*
* @var string
*/
private $_responseBody;
/**
* Construct a HTTP transport response
*
* @param integer $statusCode The HTTP status code
* @param string $contentType The VALUE of the Content-Type HTTP header
* @param string $responseBody The body of the HTTP response
*/
public function __construct($statusCode, $contentType, $responseBody)
{
// set the status code, make sure its an integer
$this->_statusCode = (int) $statusCode;
// lookup up status message based on code
$this->_statusMessage = self::getDefaultStatusMessage($this->_statusCode);
// set the response body, it should always be a string
$this->_responseBody = (string) $responseBody;
// parse the content type header value for mimetype and encoding
// first set default values that will remain if we can't find
// what we're looking for in the content type
$this->_mimeType = "text/plain";
$this->_encoding = "UTF-8";
if ($contentType)
{
// now break apart the header to see if there's character encoding
$contentTypeParts = explode(';', $contentType, 2);
if (isset($contentTypeParts[0]))
{
$this->_mimeType = trim($contentTypeParts[0]);
}
if (isset($contentTypeParts[1]))
{
// we have a second part, split it further
$contentTypeParts = explode('=', $contentTypeParts[1]);
if (isset($contentTypeParts[1]))
{
$this->_encoding = trim($contentTypeParts[1]);
}
}
}
}
/**
* Get the status code of the response
*
* @return integer
*/
public function getStatusCode()
{
return $this->_statusCode;
}
/**
* Get the status message of the response
*
* @return string
*/
public function getStatusMessage()
{
return $this->_statusMessage;
}
/**
* Get the mimetype of the response body
*
* @return string
*/
public function getMimeType()
{
return $this->_mimeType;
}
/**
* Get the charset encoding of the response body.
*
* @return string
*/
public function getEncoding()
{
return $this->_encoding;
}
/**
* Get the raw response body
*
* @return string
*/
public function getBody()
{
return $this->_responseBody;
}
}

View File

@ -0,0 +1,79 @@
<?php
/**
* Copyright (c) 2007-2011, Servigistics, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of Servigistics, Inc. nor the names of
* its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
* @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
* @version $Id: HttpTransportException.php 54 2011-02-04 16:29:18Z donovan.jimenez $
*
* @package Apache
* @subpackage Solr
* @author Donovan Jimenez <djimenez@conduit-it.com>
*/
class Apache_Solr_HttpTransportException extends Apache_Solr_Exception
{
/**
* SVN Revision meta data for this class
*/
const SVN_REVISION = '$Revision: 54 $';
/**
* SVN ID meta data for this class
*/
const SVN_ID = '$Id: HttpTransportException.php 54 2011-02-04 16:29:18Z donovan.jimenez $';
/**
* Response for which exception was generated
*
* @var Apache_Solr_Response
*/
private $_response;
/**
* HttpTransportException Constructor
*
* @param Apache_Solr_Response $response
*/
public function __construct(Apache_Solr_Response $response)
{
parent::__construct("'{$response->getHttpStatus()}' Status: {$response->getHttpStatusMessage()}", $response->getHttpStatus());
$this->_response = $response;
}
/**
* Get the response for which this exception was generated
*
* @return Apache_Solr_Response
*/
public function getResponse()
{
return $this->_response;
}
}

View File

@ -0,0 +1,50 @@
<?php
/**
* Copyright (c) 2007-2011, Servigistics, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of Servigistics, Inc. nor the names of
* its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
* @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
* @version $Id: InvalidArgumentException.php 54 2011-02-04 16:29:18Z donovan.jimenez $
*
* @package Apache
* @subpackage Solr
* @author Donovan Jimenez <djimenez@conduit-it.com>
*/
class Apache_Solr_InvalidArgumentException extends Apache_Solr_Exception
{
/**
* SVN Revision meta data for this class
*/
const SVN_REVISION = '$Revision: 54 $';
/**
* SVN ID meta data for this class
*/
const SVN_ID = '$Id: InvalidArgumentException.php 54 2011-02-04 16:29:18Z donovan.jimenez $';
}

View File

@ -0,0 +1,50 @@
<?php
/**
* Copyright (c) 2007-2011, Servigistics, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of Servigistics, Inc. nor the names of
* its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
* @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
* @version $Id: NoServiceAvailableException.php 54 2011-02-04 16:29:18Z donovan.jimenez $
*
* @package Apache
* @subpackage Solr
* @author Donovan Jimenez <djimenez@conduit-it.com>
*/
class Apache_Solr_NoServiceAvailableException extends Apache_Solr_Exception
{
/**
* SVN Revision meta data for this class
*/
const SVN_REVISION = '$Revision: 54 $';
/**
* SVN ID meta data for this class
*/
const SVN_ID = '$Id: NoServiceAvailableException.php 54 2011-02-04 16:29:18Z donovan.jimenez $';
}

View File

@ -0,0 +1,50 @@
<?php
/**
* Copyright (c) 2007-2011, Servigistics, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of Servigistics, Inc. nor the names of
* its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
* @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
* @version $Id: ParserException.php 54 2011-02-04 16:29:18Z donovan.jimenez $
*
* @package Apache
* @subpackage Solr
* @author Donovan Jimenez <djimenez@conduit-it.com>
*/
class Apache_Solr_ParserException extends Apache_Solr_Exception
{
/**
* SVN Revision meta data for this class
*/
const SVN_REVISION = '$Revision: 54 $';
/**
* SVN ID meta data for this class
*/
const SVN_ID = '$Id: ParserException.php 54 2011-02-04 16:29:18Z donovan.jimenez $';
}

View File

@ -0,0 +1,247 @@
<?php
/**
* Copyright (c) 2007-2011, Servigistics, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of Servigistics, Inc. nor the names of
* its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
* @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
* @version $Id: Response.php 54 2011-02-04 16:29:18Z donovan.jimenez $
*
* @package Apache
* @subpackage Solr
* @author Donovan Jimenez <djimenez@conduit-it.com>
*/
require_once(dirname(__FILE__) . '/ParserException.php');
/**
* Represents a Solr response. Parses the raw response into a set of stdClass objects
* and associative arrays for easy access.
*
* Currently requires json_decode which is bundled with PHP >= 5.2.0, Alternatively can be
* installed with PECL. Zend Framework also includes a purely PHP solution.
*/
class Apache_Solr_Response
{
/**
* SVN Revision meta data for this class
*/
const SVN_REVISION = '$Revision: 54 $';
/**
* SVN ID meta data for this class
*/
const SVN_ID = '$Id: Response.php 54 2011-02-04 16:29:18Z donovan.jimenez $';
/**
* Holds the raw response used in construction
*
* @var Apache_Solr_HttpTransport_Response HTTP response
*/
protected $_response;
/**
* Whether the raw response has been parsed
*
* @var boolean
*/
protected $_isParsed = false;
/**
* Parsed representation of the data
*
* @var mixed
*/
protected $_parsedData;
/**
* Data parsing flags. Determines what extra processing should be done
* after the data is initially converted to a data structure.
*
* @var boolean
*/
protected $_createDocuments = true,
$_collapseSingleValueArrays = true;
/**
* Constructor. Takes the raw HTTP response body and the exploded HTTP headers
*
* @return Apache_Solr_HttpTransport_Response HTTP response
* @param boolean $createDocuments Whether to convert the documents json_decoded as stdClass instances to Apache_Solr_Document instances
* @param boolean $collapseSingleValueArrays Whether to make multivalued fields appear as single values
*/
public function __construct(Apache_Solr_HttpTransport_Response $response, $createDocuments = true, $collapseSingleValueArrays = true)
{
$this->_response = $response;
$this->_createDocuments = (bool) $createDocuments;
$this->_collapseSingleValueArrays = (bool) $collapseSingleValueArrays;
}
/**
* Get the HTTP status code
*
* @return integer
*/
public function getHttpStatus()
{
return $this->_response->getStatusCode();
}
/**
* Get the HTTP status message of the response
*
* @return string
*/
public function getHttpStatusMessage()
{
return $this->_response->getStatusMessage();
}
/**
* Get content type of this Solr response
*
* @return string
*/
public function getType()
{
return $this->_response->getMimeType();
}
/**
* Get character encoding of this response. Should usually be utf-8, but just in case
*
* @return string
*/
public function getEncoding()
{
return $this->_response->getEncoding();
}
/**
* Get the raw response as it was given to this object
*
* @return string
*/
public function getRawResponse()
{
return $this->_response->getBody();
}
/**
* Magic get to expose the parsed data and to lazily load it
*
* @param string $key
* @return mixed
*/
public function __get($key)
{
if (!$this->_isParsed)
{
$this->_parseData();
$this->_isParsed = true;
}
if (isset($this->_parsedData->$key))
{
return $this->_parsedData->$key;
}
return null;
}
/**
* Magic function for isset function on parsed data
*
* @param string $key
* @return boolean
*/
public function __isset($key)
{
if (!$this->_isParsed)
{
$this->_parseData();
$this->_isParsed = true;
}
return isset($this->_parsedData->$key);
}
/**
* Parse the raw response into the parsed_data array for access
*
* @throws Apache_Solr_ParserException If the data could not be parsed
*/
protected function _parseData()
{
//An alternative would be to use Zend_Json::decode(...)
$data = json_decode($this->_response->getBody());
// check that we receive a valid JSON response - we should never receive a null
if ($data === null)
{
throw new Apache_Solr_ParserException('Solr response does not appear to be valid JSON, please examine the raw response with getRawResponse() method');
}
//if we're configured to collapse single valued arrays or to convert them to Apache_Solr_Document objects
//and we have response documents, then try to collapse the values and / or convert them now
if (($this->_createDocuments || $this->_collapseSingleValueArrays) && isset($data->response) && is_array($data->response->docs))
{
$documents = array();
foreach ($data->response->docs as $originalDocument)
{
if ($this->_createDocuments)
{
$document = new Apache_Solr_Document();
}
else
{
$document = $originalDocument;
}
foreach ($originalDocument as $key => $value)
{
//If a result is an array with only a single
//value then its nice to be able to access
//it as if it were always a single value
if ($this->_collapseSingleValueArrays && is_array($value) && count($value) <= 1)
{
$value = array_shift($value);
}
$document->$key = $value;
}
$documents[] = $document;
}
$data->response->docs = $documents;
}
$this->_parsedData = $data;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,914 @@
<?php
/**
* Copyright (c) 2007-2011, Servigistics, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of Servigistics, Inc. nor the names of
* its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
* @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
* @version $Id: Balancer.php 54 2011-02-04 16:29:18Z donovan.jimenez $
*
* @package Apache
* @subpackage Solr
* @author Donovan Jimenez <djimenez@conduit-it.com>, Dan Wolfe
*/
// See Issue #1 (http://code.google.com/p/solr-php-client/issues/detail?id=1)
// Doesn't follow typical include path conventions, but is more convenient for users
require_once(dirname(dirname(__FILE__)) . '/Service.php');
require_once(dirname(dirname(__FILE__)) . '/NoServiceAvailableException.php');
/**
* Reference Implementation for using multiple Solr services in a distribution. Functionality
* includes:
* routing of read / write operations
* failover (on selection) for multiple read servers
*/
class Apache_Solr_Service_Balancer
{
/**
* SVN Revision meta data for this class
*/
const SVN_REVISION = '$Revision: 54 $';
/**
* SVN ID meta data for this class
*/
const SVN_ID = '$Id: Balancer.php 54 2011-02-04 16:29:18Z donovan.jimenez $';
protected $_createDocuments = true;
protected $_readableServices = array();
protected $_writeableServices = array();
protected $_currentReadService = null;
protected $_currentWriteService = null;
protected $_readPingTimeout = 2;
protected $_writePingTimeout = 4;
// Configuration for server selection backoff intervals
protected $_useBackoff = false; // Set to true to use more resillient write server selection
protected $_backoffLimit = 600; // 10 minute default maximum
protected $_backoffEscalation = 2.0; // Rate at which to increase backoff period
protected $_defaultBackoff = 2.0; // Default backoff interval
/**
* Escape a value for special query characters such as ':', '(', ')', '*', '?', etc.
*
* NOTE: inside a phrase fewer characters need escaped, use {@link Apache_Solr_Service::escapePhrase()} instead
*
* @param string $value
* @return string
*/
static public function escape($value)
{
return Apache_Solr_Service::escape($value);
}
/**
* Escape a value meant to be contained in a phrase for special query characters
*
* @param string $value
* @return string
*/
static public function escapePhrase($value)
{
return Apache_Solr_Service::escapePhrase($value);
}
/**
* Convenience function for creating phrase syntax from a value
*
* @param string $value
* @return string
*/
static public function phrase($value)
{
return Apache_Solr_Service::phrase($value);
}
/**
* Constructor. Takes arrays of read and write service instances or descriptions
*
* @param array $readableServices
* @param array $writeableServices
*/
public function __construct($readableServices = array(), $writeableServices = array())
{
//setup readable services
foreach ($readableServices as $service)
{
$this->addReadService($service);
}
//setup writeable services
foreach ($writeableServices as $service)
{
$this->addWriteService($service);
}
}
public function setReadPingTimeout($timeout)
{
$this->_readPingTimeout = $timeout;
}
public function setWritePingTimeout($timeout)
{
$this->_writePingTimeout = $timeout;
}
public function setUseBackoff($enable)
{
$this->_useBackoff = $enable;
}
/**
* Generates a service ID
*
* @param string $host
* @param integer $port
* @param string $path
* @return string
*/
protected function _getServiceId($host, $port, $path)
{
return $host . ':' . $port . $path;
}
/**
* Adds a service instance or service descriptor (if it is already
* not added)
*
* @param mixed $service
*
* @throws Apache_Solr_InvalidArgumentException If service descriptor is not valid
*/
public function addReadService($service)
{
if ($service instanceof Apache_Solr_Service)
{
$id = $this->_getServiceId($service->getHost(), $service->getPort(), $service->getPath());
$this->_readableServices[$id] = $service;
}
else if (is_array($service))
{
if (isset($service['host']) && isset($service['port']) && isset($service['path']))
{
$id = $this->_getServiceId((string)$service['host'], (int)$service['port'], (string)$service['path']);
$this->_readableServices[$id] = $service;
}
else
{
throw new Apache_Solr_InvalidArgumentException('A Readable Service description array does not have all required elements of host, port, and path');
}
}
}
/**
* Removes a service instance or descriptor from the available services
*
* @param mixed $service
*
* @throws Apache_Solr_InvalidArgumentException If service descriptor is not valid
*/
public function removeReadService($service)
{
$id = '';
if ($service instanceof Apache_Solr_Service)
{
$id = $this->_getServiceId($service->getHost(), $service->getPort(), $service->getPath());
}
else if (is_array($service))
{
if (isset($service['host']) && isset($service['port']) && isset($service['path']))
{
$id = $this->_getServiceId((string)$service['host'], (int)$service['port'], (string)$service['path']);
}
else
{
throw new Apache_Solr_InvalidArgumentException('A Readable Service description array does not have all required elements of host, port, and path');
}
}
else if (is_string($service))
{
$id = $service;
}
if ($id && isset($this->_readableServices[$id]))
{
unset($this->_readableServices[$id]);
}
}
/**
* Adds a service instance or service descriptor (if it is already
* not added)
*
* @param mixed $service
*
* @throws Apache_Solr_InvalidArgumentException If service descriptor is not valid
*/
public function addWriteService($service)
{
if ($service instanceof Apache_Solr_Service)
{
$id = $this->_getServiceId($service->getHost(), $service->getPort(), $service->getPath());
$this->_writeableServices[$id] = $service;
}
else if (is_array($service))
{
if (isset($service['host']) && isset($service['port']) && isset($service['path']))
{
$id = $this->_getServiceId((string)$service['host'], (int)$service['port'], (string)$service['path']);
$this->_writeableServices[$id] = $service;
}
else
{
throw new Apache_Solr_InvalidArgumentException('A Writeable Service description array does not have all required elements of host, port, and path');
}
}
}
/**
* Removes a service instance or descriptor from the available services
*
* @param mixed $service
*
* @throws Apache_Solr_InvalidArgumentException If service descriptor is not valid
*/
public function removeWriteService($service)
{
$id = '';
if ($service instanceof Apache_Solr_Service)
{
$id = $this->_getServiceId($service->getHost(), $service->getPort(), $service->getPath());
}
else if (is_array($service))
{
if (isset($service['host']) && isset($service['port']) && isset($service['path']))
{
$id = $this->_getServiceId((string)$service['host'], (int)$service['port'], (string)$service['path']);
}
else
{
throw new Apache_Solr_InvalidArgumentException('A Readable Service description array does not have all required elements of host, port, and path');
}
}
else if (is_string($service))
{
$id = $service;
}
if ($id && isset($this->_writeableServices[$id]))
{
unset($this->_writeableServices[$id]);
}
}
/**
* Iterate through available read services and select the first with a ping
* that satisfies configured timeout restrictions (or the default)
*
* @return Apache_Solr_Service
*
* @throws Apache_Solr_NoServiceAvailableException If there are no read services that meet requirements
*/
protected function _selectReadService($forceSelect = false)
{
if (!$this->_currentReadService || !isset($this->_readableServices[$this->_currentReadService]) || $forceSelect)
{
if ($this->_currentReadService && isset($this->_readableServices[$this->_currentReadService]) && $forceSelect)
{
// we probably had a communication error, ping the current read service, remove it if it times out
if ($this->_readableServices[$this->_currentReadService]->ping($this->_readPingTimeout) === false)
{
$this->removeReadService($this->_currentReadService);
}
}
if (count($this->_readableServices))
{
// select one of the read services at random
$ids = array_keys($this->_readableServices);
$id = $ids[rand(0, count($ids) - 1)];
$service = $this->_readableServices[$id];
if (is_array($service))
{
//convert the array definition to a client object
$service = new Apache_Solr_Service($service['host'], $service['port'], $service['path']);
$this->_readableServices[$id] = $service;
}
$service->setCreateDocuments($this->_createDocuments);
$this->_currentReadService = $id;
}
else
{
throw new Apache_Solr_NoServiceAvailableException('No read services were available');
}
}
return $this->_readableServices[$this->_currentReadService];
}
/**
* Iterate through available write services and select the first with a ping
* that satisfies configured timeout restrictions (or the default)
*
* @return Apache_Solr_Service
*
* @throws Apache_Solr_NoServiceAvailableException If there are no write services that meet requirements
*/
protected function _selectWriteService($forceSelect = false)
{
if($this->_useBackoff)
{
return $this->_selectWriteServiceSafe($forceSelect);
}
if (!$this->_currentWriteService || !isset($this->_writeableServices[$this->_currentWriteService]) || $forceSelect)
{
if ($this->_currentWriteService && isset($this->_writeableServices[$this->_currentWriteService]) && $forceSelect)
{
// we probably had a communication error, ping the current read service, remove it if it times out
if ($this->_writeableServices[$this->_currentWriteService]->ping($this->_writePingTimeout) === false)
{
$this->removeWriteService($this->_currentWriteService);
}
}
if (count($this->_writeableServices))
{
// select one of the read services at random
$ids = array_keys($this->_writeableServices);
$id = $ids[rand(0, count($ids) - 1)];
$service = $this->_writeableServices[$id];
if (is_array($service))
{
//convert the array definition to a client object
$service = new Apache_Solr_Service($service['host'], $service['port'], $service['path']);
$this->_writeableServices[$id] = $service;
}
$this->_currentWriteService = $id;
}
else
{
throw new Apache_Solr_NoServiceAvailableException('No write services were available');
}
}
return $this->_writeableServices[$this->_currentWriteService];
}
/**
* Iterate through available write services and select the first with a ping
* that satisfies configured timeout restrictions (or the default). The
* timeout period will increase until a connection is made or the limit is
* reached. This will allow for increased reliability with heavily loaded
* server(s).
*
* @return Apache_Solr_Service
*
* @throws Apache_Solr_NoServiceAvailableException If there are no write services that meet requirements
*/
protected function _selectWriteServiceSafe($forceSelect = false)
{
if (!$this->_currentWriteService || !isset($this->_writeableServices[$this->_currentWriteService]) || $forceSelect)
{
if (count($this->_writeableServices))
{
$backoff = $this->_defaultBackoff;
do {
// select one of the read services at random
$ids = array_keys($this->_writeableServices);
$id = $ids[rand(0, count($ids) - 1)];
$service = $this->_writeableServices[$id];
if (is_array($service))
{
//convert the array definition to a client object
$service = new Apache_Solr_Service($service['host'], $service['port'], $service['path']);
$this->_writeableServices[$id] = $service;
}
$this->_currentWriteService = $id;
$backoff *= $this->_backoffEscalation;
if($backoff > $this->_backoffLimit)
{
throw new Apache_Solr_NoServiceAvailableException('No write services were available. All timeouts exceeded.');
}
} while($this->_writeableServices[$this->_currentWriteService]->ping($backoff) === false);
}
else
{
throw new Apache_Solr_NoServiceAvailableException('No write services were available');
}
}
return $this->_writeableServices[$this->_currentWriteService];
}
/**
* Set the create documents flag. This determines whether {@link Apache_Solr_Response} objects will
* parse the response and create {@link Apache_Solr_Document} instances in place.
*
* @param boolean $createDocuments
*/
public function setCreateDocuments($createDocuments)
{
$this->_createDocuments = (bool) $createDocuments;
// set on current read service
if ($this->_currentReadService)
{
$service = $this->_selectReadService();
$service->setCreateDocuments($createDocuments);
}
}
/**
* Get the current state of teh create documents flag.
*
* @return boolean
*/
public function getCreateDocuments()
{
return $this->_createDocuments;
}
/**
* Raw Add Method. Takes a raw post body and sends it to the update service. Post body
* should be a complete and well formed "add" xml document.
*
* @param string $rawPost
* @return Apache_Solr_Response
*
* @throws Apache_Solr_HttpTransportException If an error occurs during the service call
*/
public function add($rawPost)
{
$service = $this->_selectWriteService();
do
{
try
{
return $service->add($rawPost);
}
catch (Apache_Solr_HttpTransportException $e)
{
if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR
{
throw $e;
}
}
$service = $this->_selectWriteService(true);
} while ($service);
return false;
}
/**
* Add a Solr Document to the index
*
* @param Apache_Solr_Document $document
* @param boolean $allowDups
* @param boolean $overwritePending
* @param boolean $overwriteCommitted
* @return Apache_Solr_Response
*
* @throws Apache_Solr_HttpTransportException If an error occurs during the service call
*/
public function addDocument(Apache_Solr_Document $document, $allowDups = false, $overwritePending = true, $overwriteCommitted = true)
{
$service = $this->_selectWriteService();
do
{
try
{
return $service->addDocument($document, $allowDups, $overwritePending, $overwriteCommitted);
}
catch (Apache_Solr_HttpTransportException $e)
{
if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR
{
throw $e;
}
}
$service = $this->_selectWriteService(true);
} while ($service);
return false;
}
/**
* Add an array of Solr Documents to the index all at once
*
* @param array $documents Should be an array of Apache_Solr_Document instances
* @param boolean $allowDups
* @param boolean $overwritePending
* @param boolean $overwriteCommitted
* @return Apache_Solr_Response
*
* @throws Apache_Solr_HttpTransportException If an error occurs during the service call
*/
public function addDocuments($documents, $allowDups = false, $overwritePending = true, $overwriteCommitted = true)
{
$service = $this->_selectWriteService();
do
{
try
{
return $service->addDocuments($documents, $allowDups, $overwritePending, $overwriteCommitted);
}
catch (Apache_Solr_HttpTransportException $e)
{
if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR
{
throw $e;
}
}
$service = $this->_selectWriteService(true);
} while ($service);
return false;
}
/**
* Send a commit command. Will be synchronous unless both wait parameters are set
* to false.
*
* @param boolean $waitFlush
* @param boolean $waitSearcher
* @return Apache_Solr_Response
*
* @throws Apache_Solr_HttpTransportException If an error occurs during the service call
*/
public function commit($optimize = true, $waitFlush = true, $waitSearcher = true, $timeout = 3600)
{
$service = $this->_selectWriteService();
do
{
try
{
return $service->commit($optimize, $waitFlush, $waitSearcher, $timeout);
}
catch (Apache_Solr_HttpTransportException $e)
{
if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR
{
throw $e;
}
}
$service = $this->_selectWriteService(true);
} while ($service);
return false;
}
/**
* Raw Delete Method. Takes a raw post body and sends it to the update service. Body should be
* a complete and well formed "delete" xml document
*
* @param string $rawPost
* @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception)
* @return Apache_Solr_Response
*
* @throws Apache_Solr_HttpTransportException If an error occurs during the service call
*/
public function delete($rawPost, $timeout = 3600)
{
$service = $this->_selectWriteService();
do
{
try
{
return $service->delete($rawPost, $timeout);
}
catch (Apache_Solr_HttpTransportException $e)
{
if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR
{
throw $e;
}
}
$service = $this->_selectWriteService(true);
} while ($service);
return false;
}
/**
* Create a delete document based on document ID
*
* @param string $id
* @param boolean $fromPending
* @param boolean $fromCommitted
* @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception)
* @return Apache_Solr_Response
*
* @throws Apache_Solr_HttpTransportException If an error occurs during the service call
*/
public function deleteById($id, $fromPending = true, $fromCommitted = true, $timeout = 3600)
{
$service = $this->_selectWriteService();
do
{
try
{
return $service->deleteById($id, $fromPending, $fromCommitted, $timeout);
}
catch (Apache_Solr_HttpTransportException $e)
{
if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR
{
throw $e;
}
}
$service = $this->_selectWriteService(true);
} while ($service);
return false;
}
/**
* Create and post a delete document based on multiple document IDs.
*
* @param array $ids Expected to be utf-8 encoded strings
* @param boolean $fromPending
* @param boolean $fromCommitted
* @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception)
* @return Apache_Solr_Response
*
* @throws Apache_Solr_HttpTransportException If an error occurs during the service call
*/
public function deleteByMultipleIds($ids, $fromPending = true, $fromCommitted = true, $timeout = 3600)
{
$service = $this->_selectWriteService();
do
{
try
{
return $service->deleteByMultipleId($ids, $fromPending, $fromCommitted, $timeout);
}
catch (Apache_Solr_HttpTransportException $e)
{
if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR
{
throw $e;
}
}
$service = $this->_selectWriteService(true);
} while ($service);
return false;
}
/**
* Create a delete document based on a query and submit it
*
* @param string $rawQuery
* @param boolean $fromPending
* @param boolean $fromCommitted
* @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception)
* @return Apache_Solr_Response
*
* @throws Apache_Solr_HttpTransportException If an error occurs during the service call
*/
public function deleteByQuery($rawQuery, $fromPending = true, $fromCommitted = true, $timeout = 3600)
{
$service = $this->_selectWriteService();
do
{
try
{
return $service->deleteByQuery($rawQuery, $fromPending, $fromCommitted, $timeout);
}
catch (Apache_Solr_HttpTransportException $e)
{
if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR
{
throw $e;
}
}
$service = $this->_selectWriteService(true);
} while ($service);
return false;
}
/**
* Use Solr Cell to extract document contents. See {@link http://wiki.apache.org/solr/ExtractingRequestHandler} for information on how
* to use Solr Cell and what parameters are available.
*
* NOTE: when passing an Apache_Solr_Document instance, field names and boosts will automatically be prepended by "literal." and "boost."
* as appropriate. Any keys from the $params array will NOT be treated this way. Any mappings from the document will overwrite key / value
* pairs in the params array if they have the same name (e.g. you pass a "literal.id" key and value in your $params array but you also
* pass in a document isntance with an "id" field" - the document's value(s) will take precedence).
*
* @param string $file Path to file to extract data from
* @param array $params optional array of key value pairs that will be sent with the post (see Solr Cell documentation)
* @param Apache_Solr_Document $document optional document that will be used to generate post parameters (literal.* and boost.* params)
* @param string $mimetype optional mimetype specification (for the file being extracted)
*
* @return Apache_Solr_Response
*
* @throws Apache_Solr_InvalidArgumentException if $file, $params, or $document are invalid.
*/
public function extract($file, $params = array(), $document = null, $mimetype = 'application/octet-stream')
{
$service = $this->_selectWriteService();
do
{
try
{
return $service->extract($file, $params, $document, $mimetype);
}
catch (Apache_Solr_HttpTransportException $e)
{
if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR
{
throw $e;
}
}
$service = $this->_selectWriteService(true);
} while ($service);
return false;
}
/**
* Use Solr Cell to extract document contents. See {@link http://wiki.apache.org/solr/ExtractingRequestHandler} for information on how
* to use Solr Cell and what parameters are available.
*
* NOTE: when passing an Apache_Solr_Document instance, field names and boosts will automatically be prepended by "literal." and "boost."
* as appropriate. Any keys from the $params array will NOT be treated this way. Any mappings from the document will overwrite key / value
* pairs in the params array if they have the same name (e.g. you pass a "literal.id" key and value in your $params array but you also
* pass in a document isntance with an "id" field" - the document's value(s) will take precedence).
*
* @param string $data Data that will be passed to Solr Cell
* @param array $params optional array of key value pairs that will be sent with the post (see Solr Cell documentation)
* @param Apache_Solr_Document $document optional document that will be used to generate post parameters (literal.* and boost.* params)
* @param string $mimetype optional mimetype specification (for the file being extracted)
*
* @return Apache_Solr_Response
*
* @throws Apache_Solr_InvalidArgumentException if $file, $params, or $document are invalid.
*
* @todo Should be using multipart/form-data to post parameter values, but I could not get my implementation to work. Needs revisisted.
*/
public function extractFromString($data, $params = array(), $document = null, $mimetype = 'application/octet-stream')
{
$service = $this->_selectWriteService();
do
{
try
{
return $service->extractFromString($data, $params, $document, $mimetype);
}
catch (Apache_Solr_HttpTransportException $e)
{
if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR
{
throw $e;
}
}
$service = $this->_selectWriteService(true);
} while ($service);
return false;
}
/**
* Send an optimize command. Will be synchronous unless both wait parameters are set
* to false.
*
* @param boolean $waitFlush
* @param boolean $waitSearcher
* @param float $timeout Maximum expected duration of the optimize operation on the server (otherwise, will throw a communication exception)
* @return Apache_Solr_Response
*
* @throws Apache_Solr_HttpTransportException If an error occurs during the service call
*/
public function optimize($waitFlush = true, $waitSearcher = true, $timeout = 3600)
{
$service = $this->_selectWriteService();
do
{
try
{
return $service->optimize($waitFlush, $waitSearcher, $timeout);
}
catch (Apache_Solr_HttpTransportException $e)
{
if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR
{
throw $e;
}
}
$service = $this->_selectWriteService(true);
} while ($service);
return false;
}
/**
* Simple Search interface
*
* @param string $query The raw query string
* @param int $offset The starting offset for result documents
* @param int $limit The maximum number of result documents to return
* @param array $params key / value pairs for query parameters, use arrays for multivalued parameters
* @param string $method The HTTP method (Apache_Solr_Service::METHOD_GET or Apache_Solr_Service::METHOD::POST)
* @return Apache_Solr_Response
*
* @throws Apache_Solr_HttpTransportException If an error occurs during the service call
*/
public function search($query, $offset = 0, $limit = 10, $params = array(), $method = Apache_Solr_Service::METHOD_GET)
{
$service = $this->_selectReadService();
do
{
try
{
return $service->search($query, $offset, $limit, $params, $method);
}
catch (Apache_Solr_HttpTransportException $e)
{
if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR
{
throw $e;
}
}
$service = $this->_selectReadService(true);
} while ($service);
return false;
}
}

View File

@ -0,0 +1,26 @@
Copyright (c) 2007-2011, Servigistics, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Servigistics, Inc. nor the names of
its contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

View File

@ -0,0 +1 @@
See http://code.google.com/p/solr-php-client/

231
dlf/locallang_db.xml Normal file
View File

@ -0,0 +1,231 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3locallang>
<meta type="array">
<type>database</type>
<description>Language labels for database tables/fields belonging to extension 'dlf'</description>
</meta>
<data type="array">
<languageKey index="default" type="array">
<label index="tx_dlf_documents">Documents</label>
<label index="tx_dlf_documents.prod_id">Production Identifier</label>
<label index="tx_dlf_documents.location">Location of METS file (URI)</label>
<label index="tx_dlf_documents.record_id">Record Identifier</label>
<label index="tx_dlf_documents.opac_id">OPAC/Local Identifier</label>
<label index="tx_dlf_documents.union_id">Union Catalog/Foreign Identifier</label>
<label index="tx_dlf_documents.urn">Uniform Resource Name (URN)</label>
<label index="tx_dlf_documents.purl">Persistent Uniform Resource Locator (PURL)</label>
<label index="tx_dlf_documents.title">Title</label>
<label index="tx_dlf_documents.title_sorting">Title (Sorting)</label>
<label index="tx_dlf_documents.author">Author</label>
<label index="tx_dlf_documents.author_sorting">Author (Sorting)</label>
<label index="tx_dlf_documents.year">Year of Publication</label>
<label index="tx_dlf_documents.year_sorting">Year of Publication (Sorting)</label>
<label index="tx_dlf_documents.place">Place of Publication</label>
<label index="tx_dlf_documents.place_sorting">Place of Publication</label>
<label index="tx_dlf_documents.structure">Typ of Document</label>
<label index="tx_dlf_documents.partof">Part of ...</label>
<label index="tx_dlf_documents.partof.none">none</label>
<label index="tx_dlf_documents.volume_sorting">Number of Volume (Sorting)</label>
<label index="tx_dlf_documents.collections">Collections</label>
<label index="tx_dlf_documents.owner">Owner</label>
<label index="tx_dlf_documents.solrcore">Solr Core</label>
<label index="tx_dlf_documents.solrcore.none">none</label>
<label index="tx_dlf_documents.status">Status</label>
<label index="tx_dlf_documents.status.default">default</label>
<label index="tx_dlf_documents.tab1">Titledata</label>
<label index="tx_dlf_documents.tab2">Identifier</label>
<label index="tx_dlf_documents.tab3">Access</label>
<label index="tx_dlf_structures">Structures</label>
<label index="tx_dlf_structures.toplevel">Toplevel Unit?</label>
<label index="tx_dlf_structures.label">Display Label</label>
<label index="tx_dlf_structures.index_name">Index Name</label>
<label index="tx_dlf_structures.oai_name">OAI Mapping</label>
<label index="tx_dlf_structures.status">Status</label>
<label index="tx_dlf_structures.status.default">default</label>
<label index="tx_dlf_structures.tab1">General</label>
<label index="tx_dlf_structures.tab2">Translation</label>
<label index="tx_dlf_structures.tab3">Access</label>
<label index="tx_dlf_metadata">Metadata</label>
<label index="tx_dlf_metadata.label">Display Label</label>
<label index="tx_dlf_metadata.index_name">Index Name</label>
<label index="tx_dlf_metadata.encoded">Encoding</label>
<label index="tx_dlf_metadata.encoded.none">none</label>
<label index="tx_dlf_metadata.xpath">XPath (relative to //dmdSec/mdWrap/xmlData/root and with namespace)</label>
<label index="tx_dlf_metadata.default_value">Default Value</label>
<label index="tx_dlf_metadata.wrap">TypoScript-Wrap</label>
<label index="tx_dlf_metadata.tokenized">Tokenize in Search Index?</label>
<label index="tx_dlf_metadata.stored">Store in Search Index?</label>
<label index="tx_dlf_metadata.indexed">Index in Search Index?</label>
<label index="tx_dlf_metadata.boost">Field boost</label>
<label index="tx_dlf_metadata.is_sortable">Prepare for sorting?</label>
<label index="tx_dlf_metadata.is_facet">Prepare for faceting?</label>
<label index="tx_dlf_metadata.is_listed">Show in titledata?</label>
<label index="tx_dlf_metadata.status">Status</label>
<label index="tx_dlf_metadata.status.default">default</label>
<label index="tx_dlf_metadata.tab1">General</label>
<label index="tx_dlf_metadata.tab2">Translation</label>
<label index="tx_dlf_metadata.tab3">Access</label>
<label index="tx_dlf_formats">Data Formats</label>
<label index="tx_dlf_formats.type">METS Name</label>
<label index="tx_dlf_formats.other_type">Is it @MDTYPE="OTHER" in METS?</label>
<label index="tx_dlf_formats.root">Root Element</label>
<label index="tx_dlf_formats.namespace">Namespace URI</label>
<label index="tx_dlf_formats.class">Class Name</label>
<label index="tx_dlf_formats.tab1">General</label>
<label index="tx_dlf_solrcores">Solr Cores</label>
<label index="tx_dlf_solrcores.label">Display Label</label>
<label index="tx_dlf_solrcores.index_name">Solr Name</label>
<label index="tx_dlf_solrcores.tab1">General</label>
<label index="tx_dlf_collections">Collections</label>
<label index="tx_dlf_collections.label">Display Label</label>
<label index="tx_dlf_collections.index_name">Index Name</label>
<label index="tx_dlf_collections.oai_name">OAI Mapping</label>
<label index="tx_dlf_collections.description">Description</label>
<label index="tx_dlf_collections.documents">Documents</label>
<label index="tx_dlf_collections.owner">Owner</label>
<label index="tx_dlf_collections.owner.none">none</label>
<label index="tx_dlf_collections.fe_cruser_id">Frontend User</label>
<label index="tx_dlf_collections.fe_cruser_id.none">none</label>
<label index="tx_dlf_collections.fe_admin_lock">Disallow frontend editing?</label>
<label index="tx_dlf_collections.status">Status</label>
<label index="tx_dlf_collections.status.default">default</label>
<label index="tx_dlf_collections.tab1">General</label>
<label index="tx_dlf_collections.tab2">Translation</label>
<label index="tx_dlf_collections.tab3">Access</label>
<label index="tx_dlf_libraries">Libraries</label>
<label index="tx_dlf_libraries.label">Name</label>
<label index="tx_dlf_libraries.index_name">Index Name</label>
<label index="tx_dlf_libraries.website">Website</label>
<label index="tx_dlf_libraries.contact">Contact</label>
<label index="tx_dlf_libraries.image">Logo</label>
<label index="tx_dlf_libraries.oai_label">Open Archives Interface (OAI) Label</label>
<label index="tx_dlf_libraries.oai_base">Open Archives Interface (OAI) Plugin Page</label>
<label index="tx_dlf_libraries.opac_label">Online Public Access Catalog (OPAC) Label</label>
<label index="tx_dlf_libraries.opac_base">Online Public Access Catalog (OPAC) Base URL</label>
<label index="tx_dlf_libraries.union_label">Union Catalog Label</label>
<label index="tx_dlf_libraries.union_base">Union Catalog Base URL</label>
<label index="tx_dlf_libraries.tab1">General</label>
<label index="tx_dlf_libraries.tab2">Translation</label>
<label index="tx_dlf_libraries.tab3">Catalogs</label>
<label index="tt_content.dlf_collection">DLF: Collection</label>
<label index="tt_content.dlf_listview">DLF: List View</label>
<label index="tt_content.dlf_metadata">DLF: Metadata</label>
<label index="tt_content.dlf_navigation">DLF: Navigation</label>
<label index="tt_content.dlf_oai">DLF: OAI-PMH Interface</label>
<label index="tt_content.dlf_pageview">DLF: Page View</label>
<label index="tt_content.dlf_search">DLF: Search</label>
<label index="tt_content.dlf_toc">DLF: Table of Contents</label>
</languageKey>
<languageKey index="de" type="array">
<label index="tx_dlf_documents">Dokumente</label>
<label index="tx_dlf_documents.prod_id">Production Identifikator</label>
<label index="tx_dlf_documents.location">Speicherort der METS-Datei (URI)</label>
<label index="tx_dlf_documents.record_id">Datensatz Identifikator</label>
<label index="tx_dlf_documents.opac_id">OPAC/Lokaler Identifikator</label>
<label index="tx_dlf_documents.union_id">Verbundkatalog/Fremder Identifikator</label>
<label index="tx_dlf_documents.urn">Uniform Resource Name (URN)</label>
<label index="tx_dlf_documents.purl">Persistent Uniform Resource Locator (PURL)</label>
<label index="tx_dlf_documents.title">Titel</label>
<label index="tx_dlf_documents.title_sorting">Titel (Sortierung)</label>
<label index="tx_dlf_documents.author">Autor</label>
<label index="tx_dlf_documents.author_sorting">Autor (Sortierung)</label>
<label index="tx_dlf_documents.year">Erscheinungsjahr</label>
<label index="tx_dlf_documents.year_sorting">Erscheinungsjahr (Sortierung)</label>
<label index="tx_dlf_documents.place">Erscheinungsort</label>
<label index="tx_dlf_documents.place_sorting">Erscheinungsort (Sortierung)</label>
<label index="tx_dlf_documents.structure">Dokumententyp</label>
<label index="tx_dlf_documents.partof">Übergeordnete Einheit</label>
<label index="tx_dlf_documents.partof.none">keine</label>
<label index="tx_dlf_documents.volume_sorting">Bandnummer (Sortierung)</label>
<label index="tx_dlf_documents.collections">Sammlungen</label>
<label index="tx_dlf_documents.owner">Besitzer</label>
<label index="tx_dlf_documents.solrcore">Solr Kern</label>
<label index="tx_dlf_documents.solrcore.none">keiner</label>
<label index="tx_dlf_documents.status">Status</label>
<label index="tx_dlf_documents.status.default">Standard</label>
<label index="tx_dlf_documents.tab1">Titeldaten</label>
<label index="tx_dlf_documents.tab2">Identifier</label>
<label index="tx_dlf_documents.tab3">Zugriff</label>
<label index="tx_dlf_structures">Strukturelemente</label>
<label index="tx_dlf_structures.toplevel">Toplevel-Element?</label>
<label index="tx_dlf_structures.label">Anzeigeform</label>
<label index="tx_dlf_structures.index_name">Index-Bezeichnung</label>
<label index="tx_dlf_structures.oai_name">OAI-Mapping</label>
<label index="tx_dlf_structures.status">Status</label>
<label index="tx_dlf_structures.status.default">Standard</label>
<label index="tx_dlf_structures.tab1">Allgemein</label>
<label index="tx_dlf_structures.tab2">Übersetzung</label>
<label index="tx_dlf_structures.tab3">Zugriff</label>
<label index="tx_dlf_metadata">Metadaten</label>
<label index="tx_dlf_metadata.label">Anzeigeform</label>
<label index="tx_dlf_metadata.index_name">Index-Bezeichnung</label>
<label index="tx_dlf_metadata.encoded">Datenformat</label>
<label index="tx_dlf_metadata.encoded.none">keines</label>
<label index="tx_dlf_metadata.xpath">XPath (relativ zu //dmdSec/mdWrap/xmlData/root und mit Namensraum)</label>
<label index="tx_dlf_metadata.default_value">Standardwert</label>
<label index="tx_dlf_metadata.wrap">TypoScript-Wrap</label>
<label index="tx_dlf_metadata.tokenized">Im Suchindex in Tokens zerlegen?</label>
<label index="tx_dlf_metadata.stored">Im Suchindex speichern?</label>
<label index="tx_dlf_metadata.indexed">Im Suchindex indizieren?</label>
<label index="tx_dlf_metadata.boost">Feldwertigkeit</label>
<label index="tx_dlf_metadata.is_sortable">Sortierbar machen?</label>
<label index="tx_dlf_metadata.is_facet">Facettierbar machen?</label>
<label index="tx_dlf_metadata.is_listed">In Titeldaten anzeigen?</label>
<label index="tx_dlf_metadata.status">Status</label>
<label index="tx_dlf_metadata.status.default">Standard</label>
<label index="tx_dlf_metadata.tab1">Allgemein</label>
<label index="tx_dlf_metadata.tab2">Übersetzung</label>
<label index="tx_dlf_metadata.tab3">Zugriff</label>
<label index="tx_dlf_formats">Datenformate</label>
<label index="tx_dlf_formats.type">Bezeichnung in METS</label>
<label index="tx_dlf_formats.other_type">@MDTYPE="OTHER" in METS?</label>
<label index="tx_dlf_formats.root">Root-Element</label>
<label index="tx_dlf_formats.namespace">Namensraum URI</label>
<label index="tx_dlf_formats.class">Klassenname</label>
<label index="tx_dlf_formats.tab1">Allgemein</label>
<label index="tx_dlf_solrcores">Solr Kerne</label>
<label index="tx_dlf_solrcores.label">Anzeigeform</label>
<label index="tx_dlf_solrcores.index_name">Solr-Bezeichnung</label>
<label index="tx_dlf_solrcores.tab1">General</label>
<label index="tx_dlf_collections">Sammlungen</label>
<label index="tx_dlf_collections.label">Anzeigeform</label>
<label index="tx_dlf_collections.index_name">Index-Bezeichnung</label>
<label index="tx_dlf_collections.oai_name">OAI-Mapping</label>
<label index="tx_dlf_collections.description">Beschreibung</label>
<label index="tx_dlf_collections.documents">Dokumente</label>
<label index="tx_dlf_collections.owner">Besitzer</label>
<label index="tx_dlf_collections.owner.none">keiner</label>
<label index="tx_dlf_collections.fe_cruser_id">Frontend-Benutzer</label>
<label index="tx_dlf_collections.fe_cruser_id.none">keiner</label>
<label index="tx_dlf_collections.fe_admin_lock">Frontend-Bearbeitung verbieten?</label>
<label index="tx_dlf_collections.status">Status</label>
<label index="tx_dlf_collections.status.default">Standard</label>
<label index="tx_dlf_collections.tab1">Allgemein</label>
<label index="tx_dlf_collections.tab2">Übersetzung</label>
<label index="tx_dlf_collections.tab3">Zugriff</label>
<label index="tx_dlf_libraries">Mandanten</label>
<label index="tx_dlf_libraries.label">Name</label>
<label index="tx_dlf_libraries.index_name">Index-Bezeichnung</label>
<label index="tx_dlf_libraries.website">Webseite</label>
<label index="tx_dlf_libraries.contact">Kontakt</label>
<label index="tx_dlf_libraries.image">Logo</label>
<label index="tx_dlf_libraries.oai_label">Open Archives Interface (OAI) Bezeichnung</label>
<label index="tx_dlf_libraries.oai_base">Open Archives Interface (OAI) Plugin</label>
<label index="tx_dlf_libraries.opac_label">Online Public Access Catalog (OPAC) Bezeichnung</label>
<label index="tx_dlf_libraries.opac_base">Online Public Access Catalog (OPAC) URL</label>
<label index="tx_dlf_libraries.union_label">Verbundkatalog Bezeichnung</label>
<label index="tx_dlf_libraries.union_base">Verbundkatalog URL</label>
<label index="tx_dlf_libraries.tab1">Allgemein</label>
<label index="tx_dlf_libraries.tab2">Übersetzung</label>
<label index="tx_dlf_libraries.tab3">Kataloge</label>
<label index="tt_content.dlf_collection">DLF: Kollektion</label>
<label index="tt_content.dlf_listview">DLF: Listenansicht</label>
<label index="tt_content.dlf_metadata">DLF: Metadaten</label>
<label index="tt_content.dlf_navigation">DLF: Navigation</label>
<label index="tt_content.dlf_oai">DLF: OAI-PMH-Schnittstelle</label>
<label index="tt_content.dlf_pageview">DLF: Seitenansicht</label>
<label index="tt_content.dlf_search">DLF: Suche</label>
<label index="tt_content.dlf_toc">DLF: Inhaltsverzeichnis</label>
</languageKey>
</data>
</T3locallang>

49
dlf/modules/conf.php Normal file
View File

@ -0,0 +1,49 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
$MCONF['name'] = 'txdlfmodules';
$MCONF['access'] = 'user,group';
$MCONF['script'] = '_DISPATCH';
$MCONF['defaultMod'] = 'txdlfdocuments';
// Check path to typo3/ directory (depending on local/global installation of extension)
// TODO: This is quite ugly and should be changed to something nicer!
if (file_exists(dirname(__FILE__).'/../../../../'.TYPO3_mainDir.'alt_db_navframe.php')) {
$MCONF['navFrameScript'] = '../../../../'.TYPO3_mainDir.'alt_db_navframe.php';
} elseif (file_exists(dirname(__FILE__).'/../../../alt_db_navframe.php')) {
$MCONF['navFrameScript'] = '../../../alt_db_navframe.php';
}
$MLANG['default']['tabs_images']['tab'] = '../res/icon_txdlfmodules.png';
$MLANG['default']['ll_ref'] = 'LLL:EXT:dlf/modules/locallang_mod.xml';
?>

View File

@ -0,0 +1,35 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
$MCONF['name'] = 'txdlfmodules_txdlfindexing';
$MCONF['access'] = 'user,group';
$MCONF['script'] = '_DISPATCH';
$MLANG['default']['tabs_images']['tab'] = '../../res/icon_txdlfindexing.png';
$MLANG['default']['ll_ref'] = 'LLL:EXT:dlf/modules/indexing/locallang_mod.xml';
?>

View File

@ -0,0 +1,422 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*/
/**
* Module 'indexing' for the 'dlf' extension.
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @copyright Copyright (c) 2010, Sebastian Meyer, SLUB Dresden
* @version $Id: index.php 38 2010-04-16 15:39:41Z smeyer $
* @package TYPO3
* @subpackage tx_dlf
* @access public
*/
class tx_dlf_modIndexing extends tx_dlf_module {
protected $modPath = 'indexing/';
protected $buttonArray = array (
'SHORTCUT' => '',
);
protected $markerArray = array (
'CSH' => '',
'MOD_MENU' => '',
'CONTENT' => '',
);
/**
* This holds a list of documents to index
*
* @var tx_dlf_list
* @access protected
*/
protected $list;
/**
* Builds HTML form for selecting a collection
*
* @access protected
*
* @return string The HTML output
*/
protected function getCollList() {
// Get all available Solr cores.
$_cores = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'tx_dlf_solrcores.label AS label,tx_dlf_solrcores.uid AS uid',
'tx_dlf_solrcores',
'tx_dlf_solrcores.pid=0'.tx_dlf_helper::whereClause('tx_dlf_solrcores'),
'',
'',
''
);
// Get all available collections.
$_collections = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'tx_dlf_collections.label AS label,tx_dlf_collections.uid AS uid',
'tx_dlf_collections',
'tx_dlf_collections.fe_cruser_id=0 AND tx_dlf_collections.pid='.intval($this->id).tx_dlf_helper::whereClause('tx_dlf_collections'),
'',
'tx_dlf_collections.label ASC',
''
);
// TODO: Ändern!
$this->doc->form = '<form name="'.$this->prefixId.'[form]" id="tx-dlf-modIndexing-form" action="" method="post">';
$form = '<label for="tx-dlf-modIndexing-id">Kollektion:</label>';
$form .= '<select id="tx-dlf-modIndexing-collection" name="'.$this->prefixId.'[collection]">';
$form .= '<option value="0">Alle</option>';
while ($_collection = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($_collections)) {
$form .= '<option value="'.$_collection['uid'].'">'.htmlspecialchars($_collection['label']).'</option>';
}
$form .= '</select><br />';
$form .= '<select id="tx-dlf-modIndexing-core" name="'.$this->prefixId.'[core]">';
while ($_core = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($_cores)) {
$form .= '<option value="'.$_core['uid'].'">'.htmlspecialchars($_core['label']).'</option>';
}
$form .= '</select><br />';
$form .= '<input type="hidden" name="CMD" value="reindexDocs" />';
$form .= '<input type="submit" name="'.$this->prefixId.'[submit]" value="'.$GLOBALS['LANG']->getLL('form.submit').'" />';
return $form;
}
/**
* Builds HTML form for selecting a file
*
* @access protected
*
* @return string The HTML output
*/
protected function getFileForm() {
// Get all available Solr cores.
$_cores = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'tx_dlf_solrcores.label AS label,tx_dlf_solrcores.uid AS uid',
'tx_dlf_solrcores',
'tx_dlf_solrcores.pid=0'.tx_dlf_helper::whereClause('tx_dlf_solrcores'),
'',
'',
''
);
// TODO: Ändern!
$this->doc->form = '<form name="'.$this->prefixId.'[form]" id="tx-dlf-modIndexing-form" action="" method="post">';
$form = '<label for="tx-dlf-modIndexing-id">METS-Datei:</label>';
$form .= '<input type="text" id="tx-dlf-modIndexing-id" name="'.$this->prefixId.'[id]" value="" /><br />';
$form .= '<select id="tx-dlf-modIndexing-core" name="'.$this->prefixId.'[core]">';
while ($_core = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($_cores)) {
$form .= '<option value="'.$_core['uid'].'">'.htmlspecialchars($_core['label']).'</option>';
}
$form .= '</select><br />';
$form .= '<input type="hidden" name="CMD" value="indexFile" />';
$form .= '<input type="submit" name="'.$this->prefixId.'[submit]" value="'.$GLOBALS['LANG']->getLL('form.submit').'" />';
return $form;
}
/**
* Iterates through list of documents and indexes them
*
* @access protected
*
* @return void
*/
protected function indexLoop() {
// Get document from list.
list ($uid, $title) = $this->list->remove(0);
$this->list->save();
// Save document to database and index.
$doc = tx_dlf_document::getInstance($uid, 0, TRUE);
if (!$doc->save($doc->pid, $this->data['core'])) {
$_message = t3lib_div::makeInstance(
't3lib_FlashMessage',
htmlspecialchars(sprintf($GLOBALS['LANG']->getLL('flash.documentNotSaved'), $title, $uid)),
$GLOBALS['LANG']->getLL('flash.error', TRUE),
t3lib_FlashMessage::ERROR,
TRUE
);
t3lib_FlashMessageQueue::addMessage($_message);
}
// Give feedback about progress.
$_message = t3lib_div::makeInstance(
't3lib_FlashMessage',
htmlspecialchars(sprintf($GLOBALS['LANG']->getLL('flash.documentsToGo'), $this->list->count)),
$GLOBALS['LANG']->getLL('flash.running', TRUE),
t3lib_FlashMessage::INFO,
TRUE
);
$this->markerArray['CONTENT'] .= $_message->render();
// Start next loop.
$this->markerArray['CONTENT'] .= '<script type="text/javascript">window.location.href=unescape("'.t3lib_div::rawUrlEncodeJS(t3lib_div::locationHeaderUrl(t3lib_div::linkThisScript(array ('id' => $this->id, 'CMD' => 'indexLoop', $this->prefixId => array ('core' => $this->data['core']), 'random' => uniqid())))).'");</script>';
$this->printContent();
exit;
}
/**
* 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']) && !empty($this->data['core'])) {
// Save document to database and index.
$doc = tx_dlf_document::getInstance($this->data['id'], 0, TRUE);
if (!$doc->save($this->id, $this->data['core'])) {
$_message = t3lib_div::makeInstance(
't3lib_FlashMessage',
htmlspecialchars(sprintf($GLOBALS['LANG']->getLL('flash.fileNotSaved'), $this->data['id'])),
$GLOBALS['LANG']->getLL('flash.error', TRUE),
t3lib_FlashMessage::ERROR,
FALSE
);
t3lib_FlashMessageQueue::addMessage($_message);
}
}
break;
case 'reindexDocs':
if (!empty($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.partof=0 AND tx_dlf_documents.pid='.intval($this->id).' AND tx_dlf_collections.uid='.intval($this->data['collection']).tx_dlf_helper::whereClause('tx_dlf_documents').tx_dlf_helper::whereClause('tx_dlf_collections'),
'',
'',
''
);
} 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.partof=0 AND 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 = t3lib_div::makeInstance('tx_dlf_list', $elements);
// Start index looping.
if ($this->list->count) {
$this->indexLoop();
}
}
break;
case 'indexLoop':
// Refresh user's session to prevent session timeout.
$_beuser = tx_dlf_helper::getBeUser();
$_beuser->fetchUserSession();
// Get document list from user's session.
$this->list = t3lib_div::makeInstance('tx_dlf_list');
// Continue index looping.
if ($this->list->count && !empty($this->data['core'])) {
$this->indexLoop();
} else {
$_message = t3lib_div::makeInstance(
't3lib_FlashMessage',
$GLOBALS['LANG']->getLL('flash.seeLog', TRUE),
$GLOBALS['LANG']->getLL('flash.done', TRUE),
t3lib_FlashMessage::OK,
TRUE
);
t3lib_FlashMessageQueue::addMessage($_message);
}
break;
}
$this->markerArray['CONTENT'] .= t3lib_FlashMessageQueue::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();
}
/**
* Sets the module's MOD_MENU configuration
*
* @access protected
*
* @return void
*/
protected function setMOD_MENU() {
$this->MOD_MENU = array (
'function' => array (
'indexFile' => $GLOBALS['LANG']->getLL('function.indexFile'),
//'reindexDoc' => $GLOBALS['LANG']->getLL('function.reindexDoc'),
'reindexDocs' => $GLOBALS['LANG']->getLL('function.reindexDocs'),
)
);
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/modules/indexing/index.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/modules/indexing/index.php']);
}
$SOBE = t3lib_div::makeInstance('tx_dlf_modIndexing');
$SOBE->main();
?>

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3locallang>
<meta type="array">
<type>module</type>
<description>Language labels for module txdlfindexing</description>
</meta>
<data type="array">
<languageKey index="default" type="array">
<label index="title">Document Indexing</label>
<label index="function.indexFile">Index file</label>
<label index="function.reindexDoc">Index document</label>
<label index="function.reindexDocs">Index collection</label>
<label index="form.submit">Start indexing</label>
<label index="flash.attention">Attention!</label>
<label index="flash.done">Done!</label>
<label index="flash.error">Error!</label>
<label index="flash.running">Please wait...</label>
<label index="flash.newCollection">New collection "%s" [%u] added to database.</label>
<label index="flash.newLibrary">New library "%s" [%u] added to database.</label>
<label index="flash.documentIndexed">Document "%s" [%u] saved and indexed.</label>
<label index="flash.documentNotSaved">Document "%s" [%u] could not be indexed.</label>
<label index="flash.documentsToGo">%u documents to go.</label>
<label index="flash.fileNotSaved">File "%s" could not be saved.</label>
<label index="flash.solrException">Apache Solr exception thrown:</label>
<label index="flash.solrNoConnection">Could not connect to Apache Solr server.</label>
<label index="flash.seeLog">See administration log for more details.</label>
</languageKey>
<languageKey index="de" type="array">
<label index="title">Dokumentindexierung</label>
<label index="function.indexFile">Datei indexieren</label>
<label index="function.reindexDoc">Dokument indexieren</label>
<label index="function.reindexDocs">Sammlung indexieren</label>
<label index="form.submit">Indexierung starten</label>
<label index="flash.attention">Achtung!</label>
<label index="flash.done">Fertig!</label>
<label index="flash.error">Fehler!</label>
<label index="flash.running">Indexierung läuft...</label>
<label index="flash.newCollection">Neue Sammlung "%s" [%u] zur Datenbank hinzugefügt.</label>
<label index="flash.newLibrary">Neue Bibliothek "%s" [%u] zur Datenbank hinzugefügt.</label>
<label index="flash.documentIndexed">Dokument "%s" [%u] gespeichert und indexiert.</label>
<label index="flash.documentNotSaved">Dokument "%s" [%u] konnte nicht gespeichert werden.</label>
<label index="flash.documentsToGo">Verbleibende Dokumente zur Indexierung: %u</label>
<label index="flash.fileNotSaved">Datei "%s" konnte nicht indexiert werden.</label>
<label index="flash.solrException">Apache Solr meldet Ausnahmefehler:</label>
<label index="flash.solrNoConnection">Verbindung zu Apache Solr Server konnte nicht hergestellt werden.</label>
<label index="flash.seeLog">Alle Details des Indexierungslaufs stehen im Administrationsprotokoll.</label>
</languageKey>
</data>
</T3locallang>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3locallang>
<meta type="array">
<type>module</type>
<description>Language labels for module txdlfindexing</description>
</meta>
<data type="array">
<languageKey index="default" type="array">
<label index="mlang_tabs_tab">Indexing</label>
<label index="mlang_labels_tabdescr">This module allows you to index your digitized documents.</label>
<label index="mlang_labels_tablabel">Document Indexing</label>
<label index="csh.description">This module allows you to index your digitized documents.</label>
<label index="csh.alttitle">Document Indexing</label>
</languageKey>
<languageKey index="de" type="array">
<label index="mlang_tabs_tab">Indexierung</label>
<label index="mlang_labels_tabdescr">Dieses Modul erlaubt Ihnen die Indexierung Ihrer digitalisierten Dokumente.</label>
<label index="mlang_labels_tablabel">Dokumentindexierung</label>
<label index="csh.description">Dieses Modul erlaubt Ihnen die Indexierung Ihrer digitalisierten Dokumente.</label>
<label index="csh.alttitle">Dokumentindexierung</label>
</languageKey>
</data>
</T3locallang>

View File

@ -0,0 +1,32 @@
<!-- ###FULLDOC### begin -->
<div class="typo3-fullDoc">
<!-- Page header with buttons, path details and csh -->
<div id="typo3-docheader">
<div id="typo3-docheader-row1">
<div class="buttonsleft">###BUTTONLIST_LEFT###</div>
<div class="buttonsright">###BUTTONLIST_RIGHT###</div>
</div>
<div id="typo3-docheader-row2">
<div class="docheader-row2-left"><div class="docheader-csh">###CSH######MOD_MENU###</div></div>
<div class="docheader-row2-right">###PAGEPATH######PAGEINFO###</div>
</div>
</div>
<!-- Content of module, for instance listing, info or editing -->
<div id="typo3-docbody">
<div id="typo3-inner-docbody">
###CONTENT###
</div>
</div>
</div>
<!-- ###FULLDOC### end -->
<!-- ###BUTTON_GROUP_WRAP### -->
<div class="buttongroup">###BUTTONS###</div>
<!-- ###BUTTON_GROUP_WRAP### -->
<!-- ###BUTTON_GROUPS_LEFT### -->
<!-- ###BUTTON_GROUPS_LEFT### -->
<!-- ###BUTTON_GROUPS_RIGHT### -->
<!-- ###BUTTON_GROUP1### -->###SHORTCUT###<!-- ###BUTTON_GROUP1### -->
<!-- ###BUTTON_GROUPS_RIGHT### -->

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3locallang>
<meta type="array">
<type>module</type>
<description>Language labels for module txdlfmodules</description>
</meta>
<data type="array">
<languageKey index="default" type="array">
<label index="mlang_tabs_tab">Digital Library Framework</label>
<label index="mlang_labels_tabdescr">These modules allow you to manage your digitized documents and collections.</label>
<label index="mlang_labels_tablabel">DLF Base Modules</label>
</languageKey>
<languageKey index="de" type="array">
<label index="mlang_tabs_tab">Digital Library Framework</label>
<label index="mlang_labels_tabdescr">Diese Module erlauben Ihnen die Verwaltung Ihrer digitalisierten Dokumente und Sammlungen.</label>
<label index="mlang_labels_tablabel">DLF Basismodule</label>
</languageKey>
</data>
</T3locallang>

View File

@ -0,0 +1,301 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*/
/**
* Plugin 'DLF: Collection' for the 'dlf' extension.
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @copyright Copyright (c) 2010, Sebastian Meyer, SLUB Dresden
* @version $Id: class.tx_dlf_collection.php 505 2011-03-07 16:25:45Z smeyer $
* @package TYPO3
* @subpackage tx_dlf
* @access public
*/
class tx_dlf_collection extends tx_dlf_plugin {
public $scriptRelPath = 'plugins/collection/class.tx_dlf_collection.php';
/**
* 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);
// Quit without doing anything if required configuration variables are not set.
if (!$this->conf['pages']) {
return $content;
}
// 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/collection/template.tmpl'), '###TEMPLATE###');
}
if (!empty($this->piVars['collection'])) {
$this->showSingleCollection(intval($this->piVars['collection']));
} else {
$content .= $this->showCollectionList();
}
return $this->pi_wrapInBaseClass($content);
}
/**
* Builds a collection list
*
* @access protected
*
* @return string The list of collections ready to output
*/
protected function showCollectionList() {
$additionalWhere = '';
$orderBy = 'tx_dlf_collections.label';
if ($this->conf['collections']) {
if (count(explode(',', $this->conf['collections'])) == 1) {
$this->showSingleCollection(intval(trim($this->conf['collections'], ' ,')));
}
$additionalWhere .= ' AND tx_dlf_collections.uid IN ('.trim($this->conf['collections'], ' ,').')';
$orderBy = 'FIELD(tx_dlf_collections.uid, '.trim($this->conf['collections'], ' ,').')';
}
if ($this->conf['show_userdefined']) {
$additionalWhere .= ' AND NOT tx_dlf_collections.fe_cruser_id=0';
} else {
$additionalWhere .= ' AND tx_dlf_collections.fe_cruser_id=0';
}
$result = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query(
'tx_dlf_collections.uid AS uid,tx_dlf_collections.label AS label,COUNT(tx_dlf_documents.uid) AS count',
'tx_dlf_documents',
'tx_dlf_relations',
'tx_dlf_collections',
'AND tx_dlf_collections.pid='.intval($this->conf['pages']).' AND tx_dlf_documents.partof=0'.$additionalWhere.tx_dlf_helper::whereClause('tx_dlf_documents').tx_dlf_helper::whereClause('tx_dlf_collections'),
'tx_dlf_collections.label',
$orderBy,
''
);
$count = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
$output = '';
if ($count == 1) {
$resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
$this->showSingleCollection(intval($resArray['uid']));
} elseif ($count > 1) {
while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
$title = htmlspecialchars($resArray['label']);
$markerArray[$resArray['uid']]['###COUNT###'] = htmlspecialchars($resArray['count'].$this->pi_getLL('titles', '', FALSE));
$additionalParams = array ('collection' => $resArray['uid']);
// Merge plugin variables with new set of values.
if (is_array($this->piVars)) {
$piVars = $this->piVars;
unset($piVars['DATA']);
$additionalParams = t3lib_div::array_merge_recursive_overrule($piVars, $additionalParams);
}
// Build typolink configuration array.
$conf = array ();
$conf['useCacheHash'] = 1;
$conf['parameter'] = $GLOBALS['TSFE']->id;
$conf['title'] = $markerArray['###COUNT###'];
$conf['additionalParams'] = t3lib_div::implodeArrayForUrl($this->prefixId, $additionalParams, '', TRUE, FALSE);
$markerArray[$resArray['uid']]['###TITLE###'] = $this->cObj->typoLink($title, $conf);
}
$entry = $this->cObj->getSubpart($this->template, '###ENTRY###');
foreach ($markerArray as $_markerArray) {
$output .= $this->cObj->substituteMarkerArray($entry, $_markerArray);
}
return $this->cObj->substituteSubpart($this->template, '###ENTRY###', $output, TRUE);
}
return $output;
}
/**
* Builds a collection's list
*
* @access protected
*
* @param integer $id: The collection's UID
*
* @return void
*/
protected function showSingleCollection($id) {
$orderBy = 'tx_dlf_documents.title_sorting';
if (!empty($this->piVars['order'])) {
switch ($this->piVars['order']) {
case 'title':
case 'author':
case 'place':
case 'year':
$orderBy = 'tx_dlf_documents.'.$this->piVars['order'].'_sorting ASC';
break;
case '-title':
case '-author':
case '-place':
case '-year':
$orderBy = 'tx_dlf_documents.'.substr($this->piVars['order'], 1).'_sorting DESC';
break;
}
}
$result = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query(
'tx_dlf_collections.label AS collLabel,tx_dlf_collections.description AS collDesc,tx_dlf_documents.uid AS uid,tx_dlf_documents.title AS title,tx_dlf_documents.author AS author,tx_dlf_documents.place AS place,tx_dlf_documents.year AS year,tx_dlf_documents.structure AS type',
'tx_dlf_documents',
'tx_dlf_relations',
'tx_dlf_collections',
'AND tx_dlf_documents.partof=0 AND tx_dlf_collections.uid='.$GLOBALS['TYPO3_DB']->fullQuoteStr($id, 'tx_dlf_collections').' AND tx_dlf_collections.pid='.$GLOBALS['TYPO3_DB']->fullQuoteStr($this->conf['pages'], 'tx_dlf_collections').$additionalWhere.tx_dlf_helper::whereClause('tx_dlf_documents').tx_dlf_helper::whereClause('tx_dlf_collections'),
'',
$orderBy,
''
);
$_list = array ();
while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
if (empty($_metadata)) {
$_metadata = array (
'uid' => $id,
'label' => $resArray['collLabel'],
'description' => $this->pi_RTEcssText($resArray['collDesc']),
'options' => array (
'orderBy' => $this->piVars['order']
)
);
}
$_list[] = array (
'uid' => $resArray['uid'],
'page' => 1,
'title' => array ($resArray['title']),
'author' => array ($resArray['author']),
'year' => array ($resArray['year']),
'place' => array ($resArray['place']),
'type' => array (tx_dlf_helper::getIndexName($resArray['type'], 'tx_dlf_structures', $this->conf['pages'])),
'subparts' => array ()
);
}
$list = t3lib_div::makeInstance('tx_dlf_list');
$list->reset();
$list->add($_list);
$list->metadata = $_metadata;
$list->save();
header('Location: '.t3lib_div::locationHeaderUrl($this->pi_getPageLink($this->conf['targetPid'])));
exit;
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/collection/class.tx_dlf_collection.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/collection/class.tx_dlf_collection.php']);
}
?>

View File

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3DataStructure>
<meta>
<langDisable>1</langDisable>
</meta>
<sheets>
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>LLL:EXT:dlf/plugins/collection/locallang.xml:tt_content.pi_flexform.sheet_general</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<pages>
<TCEforms>
<onChange>reload</onChange>
<exclude>1</exclude>
<label>LLL:EXT:lang/locallang_general.xml:LGL.startingpoint</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
</config>
</TCEforms>
</pages>
<collections>
<TCEforms>
<displayCond>FIELD:pages:REQ:true</displayCond>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/collection/locallang.xml:tt_content.pi_flexform.collections</label>
<config>
<type>select</type>
<items type="array"></items>
<itemsProcFunc>tx_dlf_tceforms->itemsProcFunc_collectionList</itemsProcFunc>
<size>5</size>
<autoSizeMax>15</autoSizeMax>
<maxitems>1024</maxitems>
<minitems>0</minitems>
</config>
</TCEforms>
</collections>
<show_userdefined>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/collection/locallang.xml:tt_content.pi_flexform.show_userdefined</label>
<config>
<type>check</type>
<default>0</default>
</config>
</TCEforms>
</show_userdefined>
<targetPid>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/collection/locallang.xml:tt_content.pi_flexform.targetPid</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
</config>
</TCEforms>
</targetPid>
<templateFile>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/collection/locallang.xml:tt_content.pi_flexform.templateFile</label>
<config>
<type>group</type>
<internal_type>file_reference</internal_type>
<allowed>tmpl,tpl,html,htm,txt</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>
<disable_controls>upload</disable_controls>
</config>
</TCEforms>
</templateFile>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3locallang>
<meta type="array">
<type>module</type>
<description>Language labels for plugin tx_dlf_collection</description>
</meta>
<data type="array">
<languageKey index="default" type="array">
<label index="tt_content.pi_flexform.sheet_general">Options</label>
<label index="tt_content.pi_flexform.collections">Show only these collections</label>
<label index="tt_content.pi_flexform.show_userdefined">Show user-defined collections?</label>
<label index="tt_content.pi_flexform.targetPid">Target page (with "DLF: List View" plugin)</label>
<label index="tt_content.pi_flexform.templateFile">Template file</label>
<label index="titles"> titles</label>
</languageKey>
<languageKey index="de" type="array">
<label index="tt_content.pi_flexform.sheet_general">Einstellungen</label>
<label index="tt_content.pi_flexform.collections">Nur diese Kollektionen anzeigen</label>
<label index="tt_content.pi_flexform.show_userdefined">Benutzerdefinierte Kollektionen anzeigen?</label>
<label index="tt_content.pi_flexform.targetPid">Zielseite (mit Plugin "DLF: Listenansicht")</label>
<label index="tt_content.pi_flexform.templateFile">HTML-Template</label>
<label index="titles"> Titel</label>
</languageKey>
</data>
</T3locallang>

View File

@ -0,0 +1,9 @@
<!-- ###TEMPLATE### -->
<ul>
<!-- ###ENTRY### -->
<li>
###TITLE### <span>(###COUNT###)</span>
</li>
<!-- ###ENTRY### -->
</ul>
<!-- ###TEMPLATE### -->

View File

@ -0,0 +1,311 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*/
/**
* Plugin 'DLF: List View' for the 'dlf' extension.
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @copyright Copyright (c) 2010, Sebastian Meyer, SLUB Dresden
* @version $Id: class.tx_dlf_collection.php 402 2010-11-09 02:29:58Z smeyer $
* @package TYPO3
* @subpackage tx_dlf
* @access public
*/
class tx_dlf_listview extends tx_dlf_plugin {
public $scriptRelPath = 'plugins/listview/class.tx_dlf_listview.php';
/**
* This holds the list
*
* @var tx_dlf_list
* @access protected
*/
protected $list;
/**
* Array of labels for the metadata
*
* @var array
* @access protected
*/
protected $labels = array ();
/**
* Array of sorted metadata
*
* @var array
* @access protected
*/
protected $metadata = array ();
/**
* Renders the page browser
*
* @access protected
*
* @return string The rendered page browser ready for output
*/
protected function getPagebrowser() {
// Get overall number of pages.
$maxPages = intval(ceil($this->list->count / $this->conf['limit']));
// Return empty pagebrowser if there is just one page.
if ($maxPages < 2) {
return '';
}
$output = ($this->piVars['pointer'] > 0 ? $this->pi_linkTP_keepPIvars($this->pi_getLL('firstPage', '&lt;'), array ('pointer' => $this->piVars['pointer'] - 1), TRUE) : $this->pi_getLL('firstPage', '&lt;'));
$output .= $this->pi_getLL('separator', ' - ');
$i = 0;
while ($i < $maxPages) {
$output .= ($this->piVars['pointer'] != $i ? $this->pi_linkTP_keepPIvars(sprintf($this->pi_getLL('page', '%d'), $i + 1), array ('pointer' => $i), TRUE) : sprintf($this->pi_getLL('page', '%d'), $i + 1));
$output .= $this->pi_getLL('separator', ' - ');
$i++;
}
$output .= ($this->piVars['pointer'] < $maxPages - 1 ? $this->pi_linkTP_keepPIvars($this->pi_getLL('lastPage', '&gt;'), array ('pointer' => $this->piVars['pointer'] + 1), TRUE) : $this->pi_getLL('lastPage', '&gt;'));
return $output;
}
/**
* Renders one entry of the list
*
* @access protected
*
* @param integer $number: The number of the entry
* @param string $template: Parsed template subpart
*
* @return string The rendered entry ready for output
*/
protected function getEntry($number, $template) {
$markerArray['###NUMBER###'] = $number + 1;
$markerArray['###METADATA###'] = '';
$subpart = '';
foreach ($this->metadata as $_index_name => $_wrap) {
if (!empty($this->list->elements[$number][$_index_name]) && !empty($this->labels[$_index_name])) {
$fieldwrap = $this->parseTS($_wrap);
$field = $this->cObj->stdWrap(htmlspecialchars($this->labels[$_index_name]), $fieldwrap['key.']);
foreach ($this->list->elements[$number][$_index_name] as $_value) {
// Link title to pageview.
if ($_index_name == 'title') {
$_value = $this->pi_linkTP(htmlspecialchars($_value), array ($this->prefixId => array ('id' => $this->list->elements[$number]['uid'], 'page' => $this->list->elements[$number]['page'], 'pointer' => $this->piVars['pointer'])), TRUE, $this->conf['targetPid']);
} elseif ($_index_name == 'type' ) {
$_value = $this->pi_getLL($_value, tx_dlf_helper::translate($_value, 'tx_dlf_structures', $this->conf['pages']), FALSE);
} else {
$_value = htmlspecialchars($_value);
}
$field .= $this->cObj->stdWrap($_value, $fieldwrap['value.']);
}
$markerArray['###METADATA###'] .= $this->cObj->stdWrap($field, $fieldwrap['all.']);
}
}
// if (!empty($this->list->elements[$number]['subparts'])) {
//
// foreach ($this->list->elements[$number]['subparts'] as $_subpart) {
//
// $subpart = $this->getSubEntry($_subpart, $template);
return $this->cObj->substituteMarkerArray($this->cObj->substituteSubpart($template['entry'], '###SUBTEMPLATE###', $subpart, TRUE), $markerArray);
}
/**
* Renders one sub-entry of the list
*
* @access protected
*
* @param integer $number: The number of the entry
* @param string $template: Parsed template subpart
*
* @return string The rendered entry ready for output
*/
protected function getSubEntry($number, $template) {
}
/**
* Get metadata configuration from database
*
* @access protected
*
* @return void
*/
protected function loadConfig() {
$this->labels = array (
'title' => $this->pi_getLL('title', tx_dlf_helper::translate('title', 'tx_dlf_metadata', $this->conf['pages']), TRUE),
'author' => $this->pi_getLL('author', tx_dlf_helper::translate('author', 'tx_dlf_metadata', $this->conf['pages']), TRUE),
'year' => $this->pi_getLL('year', tx_dlf_helper::translate('year', 'tx_dlf_metadata', $this->conf['pages']), TRUE),
'place' => $this->pi_getLL('place', tx_dlf_helper::translate('place', 'tx_dlf_metadata', $this->conf['pages']), TRUE),
'type' => $this->pi_getLL('type', tx_dlf_helper::translate('type', 'tx_dlf_metadata', $this->conf['pages']), TRUE)
);
$_result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'tx_dlf_metadata.index_name AS index_name,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 ASC',
''
);
while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($_result)) {
if (in_array($resArray['index_name'], array_keys($this->labels))) {
$this->metadata[$resArray['index_name']] = $resArray['wrap'];
}
}
}
/**
* 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);
// Don't cache the output.
$this->setCache(FALSE);
// Load the list.
$this->list = t3lib_div::makeInstance('tx_dlf_list');
// 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/listview/template.tmpl'), '###TEMPLATE###');
}
$subpartArray['entry'] = $this->cObj->getSubpart($this->template, '###ENTRY###');
// Set some variable defaults.
if (!empty($this->piVars['pointer']) && (($this->piVars['pointer'] * $this->conf['limit']) + 1) <= $this->list->count) {
$this->piVars['pointer'] = max(intval($this->piVars['pointer']), 0);
} else {
$this->piVars['pointer'] = 0;
}
$this->loadConfig();
for ($i = $this->piVars['pointer'] * $this->conf['limit']; $i < ($this->piVars['pointer'] + 1) * $this->conf['limit']; $i++) {
if (empty($this->list->elements[$i])) {
break;
} else {
$content .= $this->getEntry($i, $subpartArray);
}
}
$markerArray['###LISTTITLE###'] = htmlspecialchars($this->list->metadata['label']);
$markerArray['###LISTDESCRIPTION###'] = $this->list->metadata['description'];
if ($i) {
$markerArray['###COUNT###'] = htmlspecialchars(sprintf($this->pi_getLL('count'), ($this->piVars['pointer'] * $this->conf['limit']) + 1, $i, $this->list->count));
} else {
$markerArray['###COUNT###'] = $this->pi_getLL('nohits', '', TRUE);
}
$markerArray['###PAGEBROWSER###'] = $this->getPageBrowser();
$content = $this->cObj->substituteMarkerArray($this->cObj->substituteSubpart($this->template, '###ENTRY###', $content, TRUE), $markerArray);
return $this->pi_wrapInBaseClass($content);
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/listview/class.tx_dlf_listview.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/listview/class.tx_dlf_listview.php']);
}
?>

View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3DataStructure>
<meta>
<langDisable>1</langDisable>
</meta>
<sheets>
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>LLL:EXT:dlf/plugins/listview/locallang.xml:tt_content.pi_flexform.sheet_general</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<pages>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:lang/locallang_general.xml:LGL.startingpoint</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
</config>
</TCEforms>
</pages>
<limit>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/listview/locallang.xml:tt_content.pi_flexform.limit</label>
<config>
<type>input</type>
<eval>required,num,int</eval>
<default>25</default>
</config>
</TCEforms>
</limit>
<targetPid>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/listview/locallang.xml:tt_content.pi_flexform.targetPid</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
</config>
</TCEforms>
</targetPid>
<templateFile>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/listview/locallang.xml:tt_content.pi_flexform.templateFile</label>
<config>
<type>group</type>
<internal_type>file_reference</internal_type>
<allowed>tmpl,tpl,html,htm,txt</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>
<disable_controls>upload</disable_controls>
</config>
</TCEforms>
</templateFile>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3locallang>
<meta type="array">
<type>module</type>
<description>Language labels for plugin tx_dlf_collection</description>
</meta>
<data type="array">
<languageKey index="default" type="array">
<label index="tt_content.pi_flexform.sheet_general">Options</label>
<label index="tt_content.pi_flexform.limit">Documents per page</label>
<label index="tt_content.pi_flexform.targetPid">Target page (with "DLF: Page View" plugin)</label>
<label index="tt_content.pi_flexform.templateFile">Template file</label>
<label index="nohits">Nothing found.</label>
<label index="count">Entries %d to %d of %d.</label>
<label index="firstPage">&lt;</label>
<label index="lastPage">&gt;</label>
<label index="page">%d</label>
<label index="separator"> - </label>
<label index="orderBy">Order by: </label>
</languageKey>
<languageKey index="de" type="array">
<label index="tt_content.pi_flexform.sheet_general">Einstellungen</label>
<label index="tt_content.pi_flexform.limit">Dokumente pro Seite</label>
<label index="tt_content.pi_flexform.targetPid">Zielseite (mit Plugin "DLF: Seitenansicht")</label>
<label index="tt_content.pi_flexform.templateFile">HTML-Template</label>
<label index="nohits">Keine Treffer.</label>
<label index="count">Einträge %d bis %d von %d.</label>
<label index="firstPage">&lt;</label>
<label index="lastPage">&gt;</label>
<label index="page">%d</label>
<label index="separator"> - </label>
<label index="orderBy">Sortieren nach: </label>
</languageKey>
</data>
</T3locallang>

View File

@ -0,0 +1,30 @@
<!-- ###TEMPLATE### -->
<h2>###LISTTITLE###</h2>
###LISTDESCRIPTION###
<p class="tx-dlf-sortinfo">###COUNT###</p>
<p class="tx-dlf-pagebrowser">###PAGEBROWSER###</p>
<ol class="tx-dlf-abstracts">
<!-- ###ENTRY### -->
<li value="###NUMBER###">
<dl>
###METADATA###
</dl>
<div class="floatclear"></div>
<!-- ###SUBTEMPLATE### -->
<span class="tx-dlf-morevolumes">weitere Bände</span>
<span class="tx-dlf-hidevolumes">Bände ausblenden</span>
<ol class="tx-dlf-volume">
<!-- ###SUBENTRY### -->
<li>
<dl>
###SUBMETADATA###
</dl>
<div class="floatclear"></div>
</li>
<!-- ###SUBENTRY### -->
</ol>
<!-- ###SUBTEMPLATE### -->
</li>
<!-- ###ENTRY### -->
</ol>
<!-- ###TEMPLATE### -->

View File

@ -0,0 +1,267 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*/
/**
* Plugin 'DLF: Metadata' for the 'dlf' extension.
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @copyright Copyright (c) 2010, Sebastian Meyer, SLUB Dresden
* @version $Id: class.tx_dlf_metadata.php 499 2010-12-23 12:40:24Z smeyer $
* @package TYPO3
* @subpackage tx_dlf
* @access public
*/
class tx_dlf_metadata extends tx_dlf_plugin {
public $scriptRelPath = 'plugins/metadata/class.tx_dlf_metadata.php';
/**
* 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);
// Quit without doing anything if required piVars are not set.
if (!$this->checkPIvars()) {
return $content;
}
// Load current document.
$this->loadDocument();
$metadata = array ();
if ($this->conf['rootline'] < 2) {
// Get current structure's @ID.
$_ids = array ();
foreach ($this->doc->smLinks as $_id => $_values) {
if (!empty($this->doc->physicalPages[$this->piVars['page']]) && in_array($this->doc->physicalPages[$this->piVars['page']]['id'], $_values)) {
$_count = count($this->doc->mets->xpath('./mets:structMap[@TYPE="LOGICAL"]//mets:div[@ID="'.$_id.'"]/ancestor::*'));
$_ids[$_count][] = $_id;
}
}
ksort($_ids);
reset($_ids);
// Check if we should display all metadata up to the root.
if ($this->conf['rootline'] == 1) {
foreach ($_ids as $_id) {
foreach ($_id as $id) {
$_data = $this->doc->getMetadata($id, $this->conf['pages']);
$_data['_id'] = $id;
$_data['type'][0] = $this->pi_getLL($_data['type'][0], tx_dlf_helper::translate($_data['type'][0], 'tx_dlf_structures', $this->conf['pages']), FALSE);
$metadata[] = $_data;
}
}
} else {
$_id = array_pop($_ids);
foreach ($_id as $id) {
$_data = $this->doc->getMetadata($id, $this->conf['pages']);
$_data['_id'] = $id;
$_data['type'][0] = $this->pi_getLL($_data['type'][0], tx_dlf_helper::translate($_data['type'][0], 'tx_dlf_structures', $this->conf['pages']), FALSE);
$metadata[] = $_data;
}
}
}
// Prepend metadata output with titledata?
if (empty($metadata)) {
$_data = $this->doc->getTitleData($this->conf['pages']);
$_data['_id'] = '';
$_data['type'][0] = $this->pi_getLL($_data['type'][0], tx_dlf_helper::translate($_data['type'][0], 'tx_dlf_structures', $this->conf['pages']), FALSE);
array_unshift($metadata, $_data);
}
if (empty($metadata)) {
trigger_error('No metadata found', E_USER_WARNING);
return $content;
}
$content .= $this->printMetadata($metadata);
return $this->pi_wrapInBaseClass($content);
}
/**
* Prepares the metadata array for output
*
* @access protected
*
* @param array $metadata: The metadata array
*
* @return string The metadata array ready for output
*/
protected function printMetadata(array $metadata) {
// 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###');
ksort($metadata);
// 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'] || (!$this->conf['showFull'] && $resArray['is_listed'])) {
$metaList[$resArray['index_name']] = $resArray['wrap'];
}
}
// Parse the metadata arrays.
foreach ($metadata as $_metadata) {
$markerArray['###METADATA###'] = '';
foreach ($metaList as $_index_name => $_wrap) {
if (!empty($_metadata[$_index_name]) && tx_dlf_helper::isTranslatable($_index_name, 'tx_dlf_metadata', $this->conf['pages'])) {
$fieldwrap = $this->parseTS($_wrap);
$field = $this->cObj->stdWrap(htmlspecialchars($this->pi_getLL($_index_name, tx_dlf_helper::translate($_index_name, 'tx_dlf_metadata', $this->conf['pages']), FALSE)), $fieldwrap['key.']);
foreach ($_metadata[$_index_name] as $_value) {
// Link title to pageview.
if ($_index_name == 'title') {
if ($_metadata['_id']) {
$details = $this->doc->getLogicalStructure($_metadata['_id']);
}
$_value = $this->pi_linkTP(htmlspecialchars($_value), array ($this->prefixId => array ('id' => $this->doc->uid, 'page' => (!empty($details['points']) ? intval($details['points'][0]) : 1))), TRUE, $this->conf['targetPid']);
// Translate name of holding library.
} elseif ($_index_name == 'owner') {
$_value = htmlspecialchars(tx_dlf_helper::translate($_value, 'tx_dlf_libraries', $this->conf['pages']));
} else {
$_value = htmlspecialchars($_value);
}
$field .= $this->cObj->stdWrap($_value, $fieldwrap['value.']);
}
$markerArray['###METADATA###'] .= $this->cObj->stdWrap($field, $fieldwrap['all.']);
}
}
$output .= $this->cObj->substituteMarkerArray($subpart['block'], $markerArray);
}
return $this->cObj->substituteSubpart($this->template, '###BLOCK###', $output, TRUE);
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/metadata/class.tx_dlf_metadata.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/metadata/class.tx_dlf_metadata.php']);
}
?>

View File

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3DataStructure>
<meta>
<langDisable>1</langDisable>
</meta>
<sheets>
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>LLL:EXT:dlf/plugins/metadata/locallang.xml:tt_content.pi_flexform.sheet_general</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<pages>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:lang/locallang_general.xml:LGL.startingpoint</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
</config>
</TCEforms>
</pages>
<excludeOther>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/metadata/locallang.xml:tt_content.pi_flexform.excludeOther</label>
<config>
<type>check</type>
<default>1</default>
</config>
</TCEforms>
</excludeOther>
<targetPid>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/metadata/locallang.xml:tt_content.pi_flexform.targetPid</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
</config>
</TCEforms>
</targetPid>
<showFull>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/metadata/locallang.xml:tt_content.pi_flexform.showFull</label>
<config>
<type>check</type>
<default>1</default>
</config>
</TCEforms>
</showFull>
<rootline>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/metadata/locallang.xml:tt_content.pi_flexform.rootline</label>
<config>
<type>select</type>
<items type="array">
<numIndex index="0" type="array">
<numIndex index="0">LLL:EXT:dlf/plugins/metadata/locallang.xml:tt_content.pi_flexform.rootline.none</numIndex>
<numIndex index="1">0</numIndex>
</numIndex>
<numIndex index="1" type="array">
<numIndex index="0">LLL:EXT:dlf/plugins/metadata/locallang.xml:tt_content.pi_flexform.rootline.all</numIndex>
<numIndex index="1">1</numIndex>
</numIndex>
<numIndex index="2" type="array">
<numIndex index="0">LLL:EXT:dlf/plugins/metadata/locallang.xml:tt_content.pi_flexform.rootline.titledata</numIndex>
<numIndex index="1">2</numIndex>
</numIndex>
</items>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
<default>0</default>
</config>
</TCEforms>
</rootline>
<templateFile>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/metadata/locallang.xml:tt_content.pi_flexform.templateFile</label>
<config>
<type>group</type>
<internal_type>file_reference</internal_type>
<allowed>tmpl,tpl,html,htm,txt</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>
<disable_controls>upload</disable_controls>
</config>
</TCEforms>
</templateFile>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3locallang>
<meta type="array">
<type>module</type>
<description>Language labels for plugin tx_dlf_metadata</description>
</meta>
<data type="array">
<languageKey index="default" type="array">
<label index="tt_content.pi_flexform.sheet_general">Options</label>
<label index="tt_content.pi_flexform.excludeOther">Show only documents from the selected page</label>
<label index="tt_content.pi_flexform.targetPid">Target page (with "DLF: Page View" plugin)</label>
<label index="tt_content.pi_flexform.showFull">Show all available metadata</label>
<label index="tt_content.pi_flexform.rootline">Show metadata of superior structures</label>
<label index="tt_content.pi_flexform.rootline.none">none</label>
<label index="tt_content.pi_flexform.rootline.all">all</label>
<label index="tt_content.pi_flexform.rootline.titledata">titledata only</label>
<label index="tt_content.pi_flexform.templateFile">Template file</label>
</languageKey>
<languageKey index="de" type="array">
<label index="tt_content.pi_flexform.sheet_general">Einstellungen</label>
<label index="tt_content.pi_flexform.excludeOther">Nur Dokumente der ausgewählten Seite anzeigen</label>
<label index="tt_content.pi_flexform.targetPid">Zielseite (mit Plugin "DLF: Seitenansicht")</label>
<label index="tt_content.pi_flexform.showFull">Alle verfügbaren Metadaten anzeigen</label>
<label index="tt_content.pi_flexform.rootline">Metadaten übergeordneter Strukturen anzeigen</label>
<label index="tt_content.pi_flexform.rootline.none">keine</label>
<label index="tt_content.pi_flexform.rootline.all">alle</label>
<label index="tt_content.pi_flexform.rootline.titledata">nur Titeldaten</label>
<label index="tt_content.pi_flexform.templateFile">HTML-Template</label>
</languageKey>
</data>
</T3locallang>

View File

@ -0,0 +1,7 @@
<!-- ###TEMPLATE### -->
<!-- ###BLOCK### -->
<dl>
###METADATA###
</dl>
<!-- ###BLOCK### -->
<!-- ###TEMPLATE### -->

View File

@ -0,0 +1,246 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*/
/**
* Plugin 'DLF: Navigation' for the 'dlf' extension.
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @copyright Copyright (c) 2010, Sebastian Meyer, SLUB Dresden
* @version $Id: class.tx_dlf_pageview.php 108 2010-06-15 17:32:37Z smeyer $
* @package TYPO3
* @subpackage tx_dlf
* @access public
*/
class tx_dlf_navigation extends tx_dlf_plugin {
public $scriptRelPath = 'plugins/navigation/class.tx_dlf_navigation.php';
/**
* 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);
// Quit without doing anything if required piVars are not set.
if (!$this->checkPIvars()) {
return $content;
}
$this->loadDocument();
// Check if this document has any images.
if ($this->doc->numPages < 1) {
return $content;
} else {
$this->piVars['page'] = min($this->piVars['page'], $this->doc->numPages);
}
// 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/navigation/template.tmpl'), '###TEMPLATE###');
}
// Set class prefix.
$prefix = str_replace('_', '-', get_class($this));
// Link to first page.
if ($this->piVars['page'] > 1) {
$markerArray['###FIRST###'] = $this->makeLink($this->pi_getLL('firstPage', '', TRUE), $prefix.'-first', array ('page' => 1));
} else {
$markerArray['###FIRST###'] = $this->makeLink($this->pi_getLL('firstPage', '', TRUE), $prefix.'-first');
}
// Link back X pages.
if ($this->piVars['page'] > $this->conf['pageStep']) {
$markerArray['###BACK###'] = $this->makeLink(sprintf($this->pi_getLL('backXPages', '', TRUE), $this->conf['pageStep']), $prefix.'-back', array ('page' => $this->piVars['page'] - $this->conf['pageStep']));
} else {
$markerArray['###BACK###'] = $this->makeLink(sprintf($this->pi_getLL('backXPages', '', TRUE), $this->conf['pageStep']), $prefix.'-back');
}
// Link to previous page.
if ($this->piVars['page'] > 1) {
$markerArray['###PREVIOUS###'] = $this->makeLink($this->pi_getLL('prevPage', '', TRUE), $prefix.'-previous', array ('page' => $this->piVars['page'] - 1));
} else {
$markerArray['###PREVIOUS###'] = $this->makeLink($this->pi_getLL('prevPage', '', TRUE), $prefix.'-previous');
}
// Build page selector.
$_uniqId = uniqid($prefix.'-');
$markerArray['###PAGESELECT###'] = '<form action="'.$this->pi_getPageLink($GLOBALS['TSFE']->id).'" class="'.$prefix.'-pageselect" method="get"><div><input type="hidden" name="id" value="'.$GLOBALS['TSFE']->id.'" />';
foreach ($this->piVars as $piVar => $value) {
if ($piVar != 'page') {
$markerArray['###PAGESELECT###'] .= '<input type="hidden" name="'.$this->prefixId.'['.$piVar.']" value="'.$value.'" />';
}
}
$markerArray['###PAGESELECT###'] .= '<label for="'.$_uniqId.'">'.$this->pi_getLL('selectPage', '', TRUE).'</label><select id="'.$_uniqId.'" name="'.$this->prefixId.'[page]" onchange="javascript:this.form.submit();">';
for ($i = 1; $i <= $this->doc->numPages; $i++) {
$markerArray['###PAGESELECT###'] .= '<option value="'.$i.'"'.($this->piVars['page'] == $i ? ' selected="selected"' : '').'>['.$i.']'.($this->doc->physicalPages[$i]['label'] ? ' - '.htmlspecialchars($this->doc->physicalPages[$i]['label']) : '').'</option>';
}
$markerArray['###PAGESELECT###'] .= '</select></div></form>';
// Link to next page.
if ($this->piVars['page'] < $this->doc->numPages) {
$markerArray['###NEXT###'] = $this->makeLink($this->pi_getLL('nextPage', '', TRUE), $prefix.'-next', array ('page' => $this->piVars['page'] + 1));
} else {
$markerArray['###NEXT###'] = $this->makeLink($this->pi_getLL('nextPage', '', TRUE), $prefix.'-next');
}
// Link forward X pages.
if ($this->piVars['page'] <= ($this->doc->numPages - $this->conf['pageStep'])) {
$markerArray['###FORWARD###'] = $this->makeLink(sprintf($this->pi_getLL('forwardXPages', '', TRUE), $this->conf['pageStep']), $prefix.'-forward', array ('page' => $this->piVars['page'] + $this->conf['pageStep']));
} else {
$markerArray['###FORWARD###'] = $this->makeLink(sprintf($this->pi_getLL('forwardXPages', '', TRUE), $this->conf['pageStep']), $prefix.'-forward');
}
// Link to last page.
if ($this->piVars['page'] < $this->doc->numPages) {
$markerArray['###LAST###'] = $this->makeLink($this->pi_getLL('lastPage', '', TRUE), $prefix.'-last', array ('page' => $this->doc->numPages));
} else {
$markerArray['###LAST###'] = $this->makeLink($this->pi_getLL('lastPage', '', TRUE), $prefix.'-last');
}
$content .= $this->cObj->substituteMarkerArray($this->template, $markerArray);
return $this->pi_wrapInBaseClass($content);
}
/**
* Generates a navigation link
*
* @access protected
*
* @param string $label: The link's text
* @param string $class: The link's class
* @param array $overrulePIvars: The new set of plugin variables
* If this is empty no link is generated.
*
* @return string Typolink ready to output
*/
protected function makeLink($label, $class = '', array $overrulePIvars = array ()) {
if ($overrulePIvars) {
// Merge plugin variables with new set of values.
if (is_array($this->piVars)) {
$piVars = $this->piVars;
unset($piVars['DATA']);
$overrulePIvars = t3lib_div::array_merge_recursive_overrule($piVars, $overrulePIvars);
}
// Build typolink configuration array.
$conf = array ();
$conf['useCacheHash'] = 1;
$conf['parameter'] = $GLOBALS['TSFE']->id.' - '.($class != '' ? $class : '-').' '.$label;
$conf['additionalParams'] = t3lib_div::implodeArrayForUrl($this->prefixId, $overrulePIvars, '', TRUE, FALSE);
return $this->cObj->typoLink($label, $conf);
} else {
if ($class != '') {
$class = ' class="'.$class.'"';
}
return '<span'.$class.'>'.$label.'</span>';
}
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/navigation/class.tx_dlf_navigation.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/navigation/class.tx_dlf_navigation.php']);
}
?>

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3DataStructure>
<meta>
<langDisable>1</langDisable>
</meta>
<sheets>
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>LLL:EXT:dlf/plugins/navigation/locallang.xml:tt_content.pi_flexform.sheet_general</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<pageStep>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/navigation/locallang.xml:tt_content.pi_flexform.pageStep</label>
<config>
<type>input</type>
<eval>required,num,int</eval>
<default>5</default>
</config>
</TCEforms>
</pageStep>
<templateFile>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/navigation/locallang.xml:tt_content.pi_flexform.templateFile</label>
<config>
<type>group</type>
<internal_type>file_reference</internal_type>
<allowed>tmpl,tpl,html,htm,txt</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>
<disable_controls>upload</disable_controls>
</config>
</TCEforms>
</templateFile>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3locallang>
<meta type="array">
<type>module</type>
<description>Language labels for plugin tx_dlf_navigation</description>
</meta>
<data type="array">
<languageKey index="default" type="array">
<label index="tt_content.pi_flexform.sheet_general">Options</label>
<label index="tt_content.pi_flexform.pageStep">How many pages should be skipped by "fast-forward" and "rewind" buttons?</label>
<label index="tt_content.pi_flexform.templateFile">Template file</label>
<label index="firstPage">First Page</label>
<label index="backXPages">Back %d Pages</label>
<label index="prevPage">Previous Page</label>
<label index="selectPage">Page</label>
<label index="nextPage">Next Page</label>
<label index="forwardXPages">Forward %d Pages</label>
<label index="lastPage">Last Page</label>
</languageKey>
<languageKey index="de" type="array">
<label index="tt_content.pi_flexform.sheet_general">Einstellungen</label>
<label index="tt_content.pi_flexform.pageStep">Wieviele Seiten sollen mit den Schnellblätter-Tasten übersprungen werden?</label>
<label index="tt_content.pi_flexform.templateFile">HTML-Template</label>
<label index="firstPage">Erste Seite</label>
<label index="backXPages">%d Seiten zurück</label>
<label index="prevPage">Vorherige Seite</label>
<label index="selectPage">Seite</label>
<label index="nextPage">Nächste Seite</label>
<label index="forwardXPages">%d Seiten weiter</label>
<label index="lastPage">Letzte Seite</label>
</languageKey>
</data>
</T3locallang>

View File

@ -0,0 +1,18 @@
<!-- ###TEMPLATE### -->
###FIRST###
###BACK###
###PREVIOUS###
###PAGESELECT###
###NEXT###
###FORWARD###
###LAST###
<div class="tx-dlf-zoomcontainer">
<div id="tx-dlf-zoomslider"></div>
<div class="tx-dlf-zoomin"></div>
<div class="tx-dlf-zoomout"></div>
</div>
<div class="tx-dlf-textpages-switch">
<a title="Text der linken Seite anzeigen" class="tx-dlf-leftpagetext">Text linke Seite</a>
<span class="tx-dlf-rightpagetext">Text rechte Seite</span>
</div>
<!-- ###TEMPLATE### -->

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,110 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3DataStructure>
<meta>
<langDisable>1</langDisable>
</meta>
<sheets>
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>LLL:EXT:dlf/plugins/oai/locallang.xml:tt_content.pi_flexform.sheet_general</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<pages>
<TCEforms>
<onChange>reload</onChange>
<exclude>1</exclude>
<label>LLL:EXT:lang/locallang_general.xml:LGL.startingpoint</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
</config>
</TCEforms>
</pages>
<library>
<TCEforms>
<displayCond>FIELD:pages:REQ:true</displayCond>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/oai/locallang.xml:tt_content.pi_flexform.library</label>
<config>
<type>select</type>
<items type="array"></items>
<itemsProcFunc>tx_dlf_tceforms->itemsProcFunc_libraryList</itemsProcFunc>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>
</config>
</TCEforms>
</library>
<limit>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/oai/locallang.xml:tt_content.pi_flexform.limit</label>
<config>
<type>input</type>
<eval>required,num,int</eval>
<default>5</default>
</config>
</TCEforms>
</limit>
<expired>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/oai/locallang.xml:tt_content.pi_flexform.expired</label>
<config>
<type>input</type>
<eval>required,num,int</eval>
<default>1800</default>
</config>
</TCEforms>
</expired>
<show_userdefined>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/oai/locallang.xml:tt_content.pi_flexform.show_userdefined</label>
<config>
<type>check</type>
<default>0</default>
</config>
</TCEforms>
</show_userdefined>
<templateFile>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/oai/locallang.xml:tt_content.pi_flexform.templateFile</label>
<config>
<type>group</type>
<internal_type>file_reference</internal_type>
<allowed>tmpl,tpl,html,htm,txt</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>
<disable_controls>upload</disable_controls>
</config>
</TCEforms>
</templateFile>
<stylesheet>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/oai/locallang.xml:tt_content.pi_flexform.stylesheet</label>
<config>
<type>group</type>
<internal_type>file_reference</internal_type>
<allowed>xsl,xslt</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>
<disable_controls>upload</disable_controls>
</config>
</TCEforms>
</stylesheet>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3locallang>
<meta type="array">
<type>module</type>
<description>Language labels for plugin tx_dlf_oai</description>
</meta>
<data type="array">
<languageKey index="default" type="array">
<label index="tt_content.pi_flexform.sheet_general">Options</label>
<label index="tt_content.pi_flexform.library">Providing library</label>
<label index="tt_content.pi_flexform.limit">Records per request</label>
<label index="tt_content.pi_flexform.expired">Expiration time for resumption token (seconds)</label>
<label index="tt_content.pi_flexform.show_userdefined">Show user-defined collections?</label>
<label index="tt_content.pi_flexform.templateFile">Template file</label>
<label index="tt_content.pi_flexform.stylesheet">Transformation stylesheet</label>
<label index="badArgument">The request includes illegal arguments, is missing required arguments, or values for arguments have an illegal syntax.</label>
<label index="badResumptionToken">The value of the resumptionToken argument is invalid or expired.</label>
<label index="badVerb">Value of the verb argument is not a legal OAI-PMH verb or the verb argument is missing.</label>
<label index="cannotDisseminateFormat">The metadata format identified by the value given for the metadataPrefix argument is not supported by the item or by the repository.</label>
<label index="idDoesNotExist">The value of the identifier argument is unknown or illegal in this repository.</label>
<label index="noRecordsMatch">The combination of the values of the from, until, set and metadataPrefix arguments results in an empty list.</label>
<label index="noMetadataFormats">There are no metadata formats available for the specified item.</label>
<label index="noSetHierarchy">The repository does not support sets or the value of the set argument is invalid.</label>
</languageKey>
<languageKey index="de" type="array">
<label index="tt_content.pi_flexform.sheet_general">Einstellungen</label>
<label index="tt_content.pi_flexform.library">Mandant</label>
<label index="tt_content.pi_flexform.limit">Datensätze pro Abfrage</label>
<label index="tt_content.pi_flexform.expired">Gültigkeitsdauer des Resumption Tokens (Sekunden)</label>
<label index="tt_content.pi_flexform.show_userdefined">Benutzerdefinierte Kollektionen anzeigen?</label>
<label index="tt_content.pi_flexform.templateFile">HTML-Template</label>
<label index="tt_content.pi_flexform.stylesheet">XSL-Stylesheet</label>
<label index="badArgument">Die Anfrage enthält ungültige Parameter, es fehlen benötigte Parameter oder Parameter haben ungültige Werte.</label>
<label index="badResumptionToken">Das "resumptionToken" ist ungültig oder abgelaufen.</label>
<label index="badVerb">Der Parameter "verb" fehlt oder hat keinen gültigen OAI-PMH-Wert.</label>
<label index="cannotDisseminateFormat">Das im Parameter "metadataPrefix" angegebene Format wird vom gewünschten Datensatz oder dem Repository nicht unterstützt.</label>
<label index="idDoesNotExist">Der im Parameter "identifier" angegebene Wert existiert nicht im Repository.</label>
<label index="noRecordsMatch">Die Anfrage ergab eine leere Treffermenge.</label>
<label index="noMetadataFormats">Für den gewünschten Datensatz werden keine Datenformate unterstützt.</label>
<label index="noSetHierarchy">Das Repository unterstützt keine Sets oder der Wert des Parameters "set" ist ungültig.</label>
</languageKey>
</data>
</T3locallang>

View File

@ -0,0 +1,101 @@
<!-- ###TEMPLATE### -->
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="###STYLESHEET###" ?>
<OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/
http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
<responseDate>###RESPONSEDATE###</responseDate>
<request###REQUEST###>###BASE_URL###</request>
<!-- ###RESPONSE### -->
<!-- ###ERROR### -->
<error code="###ERROR_CODE###">###ERROR_MESSAGE###</error>
<!-- ###ERROR### -->
<!-- ###IDENTIFY### -->
<Identify>
<repositoryName>###IDENTIFY_NAME###</repositoryName>
<baseURL>###IDENTIFY_URL###</baseURL>
<protocolVersion>2.0</protocolVersion>
<earliestDatestamp>###IDENTIFY_DATE###</earliestDatestamp>
<deletedRecord>transient</deletedRecord>
<granularity>YYYY-MM-DDThh:mm:ssZ</granularity>
<adminEmail>###IDENTIFY_MAIL###</adminEmail>
</Identify>
<!-- ###IDENTIFY### -->
<!-- ###GETRECORD### -->
<GetRecord>
<record>
<header###RECORD_DELETED###>
<identifier>###RECORD_IDENTIFIER###</identifier>
<datestamp>###RECORD_DATESTAMP###</datestamp>
<!-- ###RECORD_SETSPEC_ITEM### -->
<setSpec>###RECORD_SETSPEC###</setSpec>
<!-- ###RECORD_SETSPEC_ITEM### -->
</header>
<!-- ###RECORD_METADATA### -->
<metadata>
###RECORD_XML###
</metadata>
<!-- ###RECORD_METADATA### -->
</record>
</GetRecord>
<!-- ###GETRECORD### -->
<!-- ###LISTMETADATAFORMATS### -->
<ListMetadataFormats>
<!-- ###LISTMETADATAFORMATS_ITEM### -->
<metadataFormat>
<metadataPrefix>###LISTMETADATAFORMATS_PREFIX###</metadataPrefix>
<schema>###LISTMETADATAFORMATS_SCHEMA###</schema>
<metadataNamespace>###LISTMETADATAFORMATS_NAMESPACE###</metadataNamespace>
</metadataFormat>
<!-- ###LISTMETADATAFORMATS_ITEM### -->
</ListMetadataFormats>
<!-- ###LISTMETADATAFORMATS### -->
<!-- ###LISTSETS### -->
<ListSets>
<!-- ###LISTSETS_ITEM### -->
<set>
<setSpec>###LISTSETS_SPEC###</setSpec>
<setName>###LISTSETS_NAME###</setName>
</set>
<!-- ###LISTSETS_ITEM### -->
</ListSets>
<!-- ###LISTSETS### -->
<!-- ###LISTIDENTIFIERS### -->
<ListIdentifiers>
<!-- ###LISTIDENTIFIERS_ITEM### -->
<header###RECORD_DELETED###>
<identifier>###RECORD_IDENTIFIER###</identifier>
<datestamp>###RECORD_DATESTAMP###</datestamp>
<!-- ###RECORD_SETSPEC_ITEM### -->
<setSpec>###RECORD_SETSPEC###</setSpec>
<!-- ###RECORD_SETSPEC_ITEM### -->
</header>
<!-- ###LISTIDENTIFIERS_ITEM### -->
###RESUMPTIONTOKEN###
</ListIdentifiers>
<!-- ###LISTIDENTIFIERS### -->
<!-- ###LISTRECORDS### -->
<ListRecords>
<!-- ###LISTRECORDS_ITEM### -->
<record>
<header###RECORD_DELETED###>
<identifier>###RECORD_IDENTIFIER###</identifier>
<datestamp>###RECORD_DATESTAMP###</datestamp>
<!-- ###RECORD_SETSPEC_ITEM### -->
<setSpec>###RECORD_SETSPEC###</setSpec>
<!-- ###RECORD_SETSPEC_ITEM### -->
</header>
<!-- ###RECORD_METADATA### -->
<metadata>
###RECORD_XML###
</metadata>
<!-- ###RECORD_METADATA### -->
</record>
<!-- ###LISTRECORDS_ITEM### -->
###RESUMPTIONTOKEN###
</ListRecords>
<!-- ###LISTRECORDS### -->
<!-- ###RESPONSE### -->
</OAI-PMH>
<!-- ###TEMPLATE### -->

View File

@ -0,0 +1,648 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
XSL Transform to convert OAI 2.0 responses into XHTML
By Christopher Gutteridge, University of Southampton
Edited by Sebastian Meyer, Saxon State Library
-->
<!--
Copyright (c) 2000-2004 University of Southampton, UK. SO17 1BJ.
EPrints 2 is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
EPrints 2 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 EPrints 2; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-->
<!--
All the elements really needed for EPrints are done but if
you want to use this XSL for other OAI archive you may want
to make some minor changes or additions.
Not Done
The 'about' section of 'record'
The 'compression' part of 'identify'
The optional attributes of 'resumptionToken'
The optional 'setDescription' container of 'set'
All the links just link to oai_dc versions of records.
-->
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:oai="http://www.openarchives.org/OAI/2.0/"
>
<xsl:output method="html"/>
<xsl:template name="style">
td.value {
vertical-align: top;
padding-left: 1em;
padding: 3px;
}
td.key {
background-color: #e0e0ff;
padding: 3px;
text-align: right;
border: 1px solid #c0c0c0;
white-space: nowrap;
font-weight: bold;
vertical-align: top;
}
.dcdata td.key {
background-color: #ffffe0;
}
body {
margin: 1em 2em 1em 2em;
}
h1, h2, h3 {
font-family: sans-serif;
clear: left;
}
h1 {
padding-bottom: 4px;
margin-bottom: 0px;
}
h2 {
margin-bottom: 0.5em;
}
h3 {
margin-bottom: 0.3em;
font-size: medium;
}
.link {
border: 1px outset #88f;
background-color: #c0c0ff;
padding: 1px 4px 1px 4px;
font-size: 80%;
text-decoration: none;
font-weight: bold;
font-family: sans-serif;
color: black;
}
.link:hover {
color: red;
}
.link:active {
color: red;
border: 1px inset #88f;
background-color: #a0a0df;
}
.oaiRecord, .oaiRecordTitle {
background-color: #f0f0ff;
border-style: solid;
border-color: #d0d0d0;
}
h2.oaiRecordTitle {
background-color: #e0e0ff;
font-size: medium;
font-weight: bold;
padding: 10px;
border-width: 2px 2px 0px 2px;
margin: 0px;
}
.oaiRecord {
margin-bottom: 3em;
border-width: 2px;
padding: 10px;
}
.results {
margin-bottom: 1.5em;
}
ul.quicklinks {
margin-top: 2px;
padding: 4px;
text-align: left;
border-bottom: 2px solid #ccc;
border-top: 2px solid #ccc;
clear: left;
}
ul.quicklinks li {
font-size: 80%;
display: inline;
list-stlye: none;
font-family: sans-serif;
}
p.intro {
font-size: 80%;
}
<xsl:call-template name='xmlstyle' />
</xsl:template>
<xsl:variable name='identifier' select="substring-before(concat(substring-after(/oai:OAI-PMH/oai:request,'identifier='),'&amp;'),'&amp;')" />
<xsl:template match="/">
<html>
<head>
<title>OAI 2.0 Request Results</title>
<style><xsl:call-template name="style"/></style>
</head>
<body>
<h1>OAI 2.0 Request Results</h1>
<xsl:call-template name="quicklinks"/>
<p class="intro">You are viewing an HTML version of the XML OAI response. To see the underlying XML use your web browsers view source option. More information about this XSLT is at the <a href="#moreinfo">bottom of the page</a>.</p>
<xsl:apply-templates select="/oai:OAI-PMH" />
<xsl:call-template name="quicklinks"/>
<h2><a name="moreinfo">About the XSLT</a></h2>
<p>An XSLT file has converted the <a href="http://www.openarchives.org">OAI-PMH 2.0</a> responses into XHTML which looks nice in a browser which supports XSLT such as Mozilla, Firebird and Internet Explorer. The XSLT file was created by <a href="http://www.ecs.soton.ac.uk/people/cjg">Christopher Gutteridge</a> at the University of Southampton as part of the <a href="http://software.eprints.org">GNU EPrints system</a>, and is freely redistributable under the <a href="http://www.gnu.org">GPL</a>.</p><p>If you want to use the XSL file on your own OAI interface you may but due to the way XSLT works you must install the XSL file on the same server as the OAI script, you can't just link to this copy.</p><p>For more information or to download the XSL file please see the <a href="http://software.eprints.org/xslt.php">OAI to XHTML XSLT homepage</a>.</p>
</body>
</html>
</xsl:template>
<xsl:template name="quicklinks">
<ul class="quicklinks">
<li><a href="?verb=Identify">Identify</a> | </li>
<li><a href="?verb=ListRecords&amp;metadataPrefix=oai_dc">ListRecords</a> | </li>
<li><a href="?verb=ListSets">ListSets</a> | </li>
<li><a href="?verb=ListMetadataFormats">ListMetadataFormats</a> | </li>
<li><a href="?verb=ListIdentifiers&amp;metadataPrefix=oai_dc">ListIdentifiers</a></li>
</ul>
</xsl:template>
<xsl:template match="/oai:OAI-PMH">
<table class="values">
<tr><td class="key">Datestamp of response</td>
<td class="value"><xsl:value-of select="oai:responseDate"/></td></tr>
<tr><td class="key">Request URL</td>
<td class="value"><xsl:value-of select="oai:request"/></td></tr>
</table>
<!-- verb: [<xsl:value-of select="oai:request/@verb" />]<br /> -->
<xsl:choose>
<xsl:when test="oai:error">
<h2>OAI Error(s)</h2>
<p>The request could not be completed due to the following error or errors.</p>
<div class="results">
<xsl:apply-templates select="oai:error"/>
</div>
</xsl:when>
<xsl:otherwise>
<p>Request was of type <xsl:value-of select="oai:request/@verb"/>.</p>
<div class="results">
<xsl:apply-templates select="oai:Identify" />
<xsl:apply-templates select="oai:GetRecord"/>
<xsl:apply-templates select="oai:ListRecords"/>
<xsl:apply-templates select="oai:ListSets"/>
<xsl:apply-templates select="oai:ListMetadataFormats"/>
<xsl:apply-templates select="oai:ListIdentifiers"/>
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- ERROR -->
<xsl:template match="/oai:OAI-PMH/oai:error">
<table class="values">
<tr><td class="key">Error Code</td>
<td class="value"><xsl:value-of select="@code"/></td></tr>
</table>
<p class="error"><xsl:value-of select="." /></p>
</xsl:template>
<!-- IDENTIFY -->
<xsl:template match="/oai:OAI-PMH/oai:Identify">
<table class="values">
<tr><td class="key">Repository Name</td>
<td class="value"><xsl:value-of select="oai:repositoryName"/></td></tr>
<tr><td class="key">Base URL</td>
<td class="value"><xsl:value-of select="oai:baseURL"/></td></tr>
<tr><td class="key">Protocol Version</td>
<td class="value"><xsl:value-of select="oai:protocolVersion"/></td></tr>
<tr><td class="key">Earliest Datestamp</td>
<td class="value"><xsl:value-of select="oai:earliestDatestamp"/></td></tr>
<tr><td class="key">Deleted Record Policy</td>
<td class="value"><xsl:value-of select="oai:deletedRecord"/></td></tr>
<tr><td class="key">Granularity</td>
<td class="value"><xsl:value-of select="oai:granularity"/></td></tr>
<xsl:apply-templates select="oai:adminEmail"/>
</table>
<xsl:apply-templates select="oai:description"/>
<!--no warning about unsupported descriptions -->
</xsl:template>
<xsl:template match="/oai:OAI-PMH/oai:Identify/oai:adminEmail">
<tr><td class="key">Admin Email</td>
<td class="value"><xsl:value-of select="."/></td></tr>
</xsl:template>
<!--
Identify / Unsupported Description
-->
<xsl:template match="oai:description/*" priority="-100">
<h2>Unsupported Description Type</h2>
<p>The XSL currently does not support this type of description.</p>
<div class="xmlSource">
<xsl:apply-templates select="." mode='xmlMarkup' />
</div>
</xsl:template>
<!--
Identify / OAI-Identifier
-->
<xsl:template match="id:oai-identifier" xmlns:id="http://www.openarchives.org/OAI/2.0/oai-identifier">
<h2>OAI-Identifier</h2>
<table class="values">
<tr><td class="key">Scheme</td>
<td class="value"><xsl:value-of select="id:scheme"/></td></tr>
<tr><td class="key">Repository Identifier</td>
<td class="value"><xsl:value-of select="id:repositoryIdentifier"/></td></tr>
<tr><td class="key">Delimiter</td>
<td class="value"><xsl:value-of select="id:delimiter"/></td></tr>
<tr><td class="key">Sample OAI Identifier</td>
<td class="value"><xsl:value-of select="id:sampleIdentifier"/></td></tr>
</table>
</xsl:template>
<!--
Identify / EPrints
-->
<xsl:template match="ep:eprints" xmlns:ep="http://www.openarchives.org/OAI/1.1/eprints">
<h2>EPrints Description</h2>
<h3>Content</h3>
<xsl:apply-templates select="ep:content"/>
<xsl:if test="ep:submissionPolicy">
<h3>Submission Policy</h3>
<xsl:apply-templates select="ep:submissionPolicy"/>
</xsl:if>
<h3>Metadata Policy</h3>
<xsl:apply-templates select="ep:metadataPolicy"/>
<h3>Data Policy</h3>
<xsl:apply-templates select="ep:dataPolicy"/>
<xsl:if test="ep:content">
<h3>Content</h3>
<xsl:apply-templates select="ep:content"/>
</xsl:if>
<xsl:apply-templates select="ep:comment"/>
</xsl:template>
<xsl:template match="ep:content|ep:dataPolicy|ep:metadataPolicy|ep:submissionPolicy" xmlns:ep="http://www.openarchives.org/OAI/1.1/eprints">
<xsl:if test="ep:text">
<p><xsl:value-of select="ep:text" /></p>
</xsl:if>
<xsl:if test="ep:URL">
<div><a href="{ep:URL}"><xsl:value-of select="ep:URL" /></a></div>
</xsl:if>
</xsl:template>
<xsl:template match="ep:comment" xmlns:ep="http://www.openarchives.org/OAI/1.1/eprints">
<h3>Comment</h3>
<div><xsl:value-of select="."/></div>
</xsl:template>
<!--
Identify / Friends
-->
<xsl:template match="fr:friends" xmlns:fr="http://www.openarchives.org/OAI/2.0/friends/">
<h2>Friends</h2>
<ul>
<xsl:apply-templates select="fr:baseURL"/>
</ul>
</xsl:template>
<xsl:template match="fr:baseURL" xmlns:fr="http://www.openarchives.org/OAI/2.0/friends/">
<li><xsl:value-of select="."/>
<xsl:text> </xsl:text>
<a class="link" href="{.}?verb=Identify">Identify</a></li>
</xsl:template>
<!--
Identify / Branding
-->
<xsl:template match="br:branding" xmlns:br="http://www.openarchives.org/OAI/2.0/branding/">
<h2>Branding</h2>
<xsl:apply-templates select="br:collectionIcon"/>
<xsl:apply-templates select="br:metadataRendering"/>
</xsl:template>
<xsl:template match="br:collectionIcon" xmlns:br="http://www.openarchives.org/OAI/2.0/branding/">
<h3>Icon</h3>
<xsl:choose>
<xsl:when test="link!=''">
<a href="{br:link}"><img src="{br:url}" alt="{br:title}" width="{br:width}" height="{br:height}" border="0" /></a>
</xsl:when>
<xsl:otherwise>
<img src="{br:url}" alt="{br:title}" width="{br:width}" height="{br:height}" border="0" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="br:metadataRendering" xmlns:br="http://www.openarchives.org/OAI/2.0/branding/">
<h3>Metadata Rendering Rule</h3>
<table class="values">
<tr><td class="key">URL</td>
<td class="value"><xsl:value-of select="."/></td></tr>
<tr><td class="key">Namespace</td>
<td class="value"><xsl:value-of select="@metadataNamespace"/></td></tr>
<tr><td class="key">Mime Type</td>
<td class="value"><xsl:value-of select="@mimetype"/></td></tr>
</table>
</xsl:template>
<!--
Identify / Gateway
-->
<xsl:template match="gw:gateway" xmlns:gw="http://www.openarchives.org/OAI/2.0/gateway/x">
<h2>Gateway Information</h2>
<table class="values">
<tr><td class="key">Source</td>
<td class="value"><xsl:value-of select="gw:source"/></td></tr>
<tr><td class="key">Description</td>
<td class="value"><xsl:value-of select="gw:gatewayDescription"/></td></tr>
<xsl:apply-templates select="gw:gatewayAdmin"/>
<xsl:if test="gw:gatewayURL">
<tr><td class="key">URL</td>
<td class="value"><xsl:value-of select="gw:gatewayURL"/></td></tr>
</xsl:if>
<xsl:if test="gw:gatewayNotes">
<tr><td class="key">Notes</td>
<td class="value"><xsl:value-of select="gw:gatewayNotes"/></td></tr>
</xsl:if>
</table>
</xsl:template>
<xsl:template match="gw:gatewayAdmin" xmlns:gw="http://www.openarchives.org/OAI/2.0/gateway/">
<tr><td class="key">Admin</td>
<td class="value"><xsl:value-of select="."/></td></tr>
</xsl:template>
<!-- GetRecord -->
<xsl:template match="oai:GetRecord">
<xsl:apply-templates select="oai:record" />
</xsl:template>
<!-- ListRecords -->
<xsl:template match="oai:ListRecords">
<xsl:apply-templates select="oai:record" />
<xsl:apply-templates select="oai:resumptionToken" />
</xsl:template>
<!-- ListIdentifiers -->
<xsl:template match="oai:ListIdentifiers">
<xsl:apply-templates select="oai:header" />
<xsl:apply-templates select="oai:resumptionToken" />
</xsl:template>
<!-- ListSets -->
<xsl:template match="oai:ListSets">
<xsl:apply-templates select="oai:set" />
<xsl:apply-templates select="oai:resumptionToken" />
</xsl:template>
<xsl:template match="oai:set">
<h2>Set</h2>
<table class="values">
<tr><td class="key">setName</td>
<td class="value"><xsl:value-of select="oai:setName"/></td></tr>
<xsl:apply-templates select="oai:setSpec" />
</table>
</xsl:template>
<!-- ListMetadataFormats -->
<xsl:template match="oai:ListMetadataFormats">
<xsl:choose>
<xsl:when test="$identifier">
<p>This is a list of metadata formats available for the record "<xsl:value-of select='$identifier' />". Use these links to view the metadata: <xsl:apply-templates select="oai:metadataFormat/oai:metadataPrefix" /></p>
</xsl:when>
<xsl:otherwise>
<p>This is a list of metadata formats available from this archive.</p>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates select="oai:metadataFormat" />
</xsl:template>
<xsl:template match="oai:metadataFormat">
<h2>Metadata Format</h2>
<table class="values">
<tr><td class="key">metadataPrefix</td>
<td class="value"><xsl:value-of select="oai:metadataPrefix"/></td></tr>
<tr><td class="key">metadataNamespace</td>
<td class="value"><xsl:value-of select="oai:metadataNamespace"/></td></tr>
<tr><td class="key">schema</td>
<td class="value"><a href="{oai:schema}"><xsl:value-of select="oai:schema"/></a></td></tr>
</table>
</xsl:template>
<xsl:template match="oai:metadataPrefix">
<xsl:text> </xsl:text><a class="link" href="?verb=GetRecord&amp;metadataPrefix={.}&amp;identifier={$identifier}"><xsl:value-of select='.' /></a>
</xsl:template>
<!-- record object -->
<xsl:template match="oai:record">
<h2 class="oaiRecordTitle">OAI Record: <xsl:value-of select="oai:header/oai:identifier"/></h2>
<div class="oaiRecord">
<xsl:apply-templates select="oai:header" />
<xsl:apply-templates select="oai:metadata" />
<xsl:apply-templates select="oai:about" />
</div>
</xsl:template>
<xsl:template match="oai:header">
<h3>OAI Record Header</h3>
<table class="values">
<tr><td class="key">OAI Identifier</td>
<td class="value">
<xsl:value-of select="oai:identifier"/>
<xsl:text> </xsl:text><a class="link" href="?verb=GetRecord&amp;metadataPrefix=oai_dc&amp;identifier={oai:identifier}">oai_dc</a>
<xsl:text> </xsl:text><a class="link" href="?verb=ListMetadataFormats&amp;identifier={oai:identifier}">formats</a>
</td></tr>
<tr><td class="key">Datestamp</td>
<td class="value"><xsl:value-of select="oai:datestamp"/></td></tr>
<xsl:apply-templates select="oai:setSpec" />
</table>
<xsl:if test="@status='deleted'">
<p>This record has been deleted.</p>
</xsl:if>
</xsl:template>
<xsl:template match="oai:about">
<p>"about" part of record container not supported by the XSL</p>
</xsl:template>
<xsl:template match="oai:metadata">
&#160;
<div class="metadata">
<xsl:apply-templates select="*" />
</div>
</xsl:template>
<!-- oai setSpec object -->
<xsl:template match="oai:setSpec">
<tr><td class="key">setSpec</td>
<td class="value"><xsl:value-of select="."/>
<xsl:text> </xsl:text><a class="link" href="?verb=ListIdentifiers&amp;metadataPrefix=oai_dc&amp;set={.}">Identifiers</a>
<xsl:text> </xsl:text><a class="link" href="?verb=ListRecords&amp;metadataPrefix=oai_dc&amp;set={.}">Records</a>
</td></tr>
</xsl:template>
<!-- oai resumptionToken -->
<xsl:template match="oai:resumptionToken">
<p>There are more results.</p>
<table class="values">
<tr><td class="key">resumptionToken:</td>
<td class="value"><xsl:value-of select="."/>
<xsl:text> </xsl:text>
<a class="link" href="?verb={/oai:OAI-PMH/oai:request/@verb}&amp;resumptionToken={.}">Resume</a></td></tr>
</table>
</xsl:template>
<!-- unknown metadata format -->
<xsl:template match="oai:metadata/*" priority='-100'>
<h3>Unknown Metadata Format</h3>
<div class="xmlSource">
<xsl:apply-templates select="." mode='xmlMarkup' />
</div>
</xsl:template>
<!-- oai_dc record -->
<xsl:template match="oai_dc:dc" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" >
<div class="dcdata">
<h3>Dublin Core Metadata (oai_dc)</h3>
<table class="dcdata">
<xsl:apply-templates select="*" />
</table>
</div>
</xsl:template>
<xsl:template match="dc:title" xmlns:dc="http://purl.org/dc/elements/1.1/">
<tr><td class="key">Title</td><td class="value"><xsl:value-of select="."/></td></tr></xsl:template>
<xsl:template match="dc:creator" xmlns:dc="http://purl.org/dc/elements/1.1/">
<tr><td class="key">Author or Creator</td><td class="value"><xsl:value-of select="."/></td></tr></xsl:template>
<xsl:template match="dc:subject" xmlns:dc="http://purl.org/dc/elements/1.1/">
<tr><td class="key">Subject and Keywords</td><td class="value"><xsl:value-of select="."/></td></tr></xsl:template>
<xsl:template match="dc:description" xmlns:dc="http://purl.org/dc/elements/1.1/">
<tr><td class="key">Description</td><td class="value"><xsl:value-of select="."/></td></tr></xsl:template>
<xsl:template match="dc:publisher" xmlns:dc="http://purl.org/dc/elements/1.1/">
<tr><td class="key">Publisher</td><td class="value"><xsl:value-of select="."/></td></tr></xsl:template>
<xsl:template match="dc:contributor" xmlns:dc="http://purl.org/dc/elements/1.1/">
<tr><td class="key">Other Contributor</td><td class="value"><xsl:value-of select="."/></td></tr></xsl:template>
<xsl:template match="dc:date" xmlns:dc="http://purl.org/dc/elements/1.1/">
<tr><td class="key">Date</td><td class="value"><xsl:value-of select="."/></td></tr></xsl:template>
<xsl:template match="dc:type" xmlns:dc="http://purl.org/dc/elements/1.1/">
<tr><td class="key">Resource Type</td><td class="value"><xsl:value-of select="."/></td></tr></xsl:template>
<xsl:template match="dc:format" xmlns:dc="http://purl.org/dc/elements/1.1/">
<tr><td class="key">Format</td><td class="value"><xsl:value-of select="."/></td></tr></xsl:template>
<xsl:template match="dc:identifier" xmlns:dc="http://purl.org/dc/elements/1.1/">
<tr><td class="key">Resource Identifier</td><td class="value"><xsl:value-of select="."/></td></tr></xsl:template>
<xsl:template match="dc:source" xmlns:dc="http://purl.org/dc/elements/1.1/">
<tr><td class="key">Source</td><td class="value"><xsl:value-of select="."/></td></tr></xsl:template>
<xsl:template match="dc:language" xmlns:dc="http://purl.org/dc/elements/1.1/">
<tr><td class="key">Language</td><td class="value"><xsl:value-of select="."/></td></tr></xsl:template>
<xsl:template match="dc:relation" xmlns:dc="http://purl.org/dc/elements/1.1/">
<tr><td class="key">Relation</td><td class="value">
<xsl:choose>
<xsl:when test='starts-with(.,"http" )'>
<xsl:choose>
<xsl:when test='string-length(.) &gt; 50'>
<a class="link" href="{.}">URL</a>
<i> URL not shown as it is very long.</i>
</xsl:when>
<xsl:otherwise>
<a href="{.}"><xsl:value-of select="."/></a>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</td></tr></xsl:template>
<xsl:template match="dc:coverage" xmlns:dc="http://purl.org/dc/elements/1.1/">
<tr><td class="key">Coverage</td><td class="value"><xsl:value-of select="."/></td></tr></xsl:template>
<xsl:template match="dc:rights" xmlns:dc="http://purl.org/dc/elements/1.1/">
<tr><td class="key">Rights Management</td><td class="value"><xsl:value-of select="."/></td></tr></xsl:template>
<!-- XML Pretty Maker -->
<xsl:template match="node()" mode='xmlMarkup'>
<div class="xmlBlock">
&lt;<span class="xmlTagName"><xsl:value-of select='name(.)' /></span><xsl:apply-templates select="@*" mode='xmlMarkup'/>&gt;<xsl:apply-templates select="node()" mode='xmlMarkup' />&lt;/<span class="xmlTagName"><xsl:value-of select='name(.)' /></span>&gt;
</div>
</xsl:template>
<xsl:template match="text()" mode='xmlMarkup'><span class="xmlText"><xsl:value-of select='.' /></span></xsl:template>
<xsl:template match="@*" mode='xmlMarkup'>
<xsl:text> </xsl:text><span class="xmlAttrName"><xsl:value-of select='name()' /></span>="<span class="xmlAttrValue"><xsl:value-of select='.' /></span>"
</xsl:template>
<xsl:template name="xmlstyle">
.xmlSource {
font-size: 70%;
border: solid #c0c0a0 1px;
background-color: #ffffe0;
padding: 2em 2em 2em 0em;
}
.xmlBlock {
padding-left: 2em;
}
.xmlTagName {
color: #800000;
font-weight: bold;
}
.xmlAttrName {
font-weight: bold;
}
.xmlAttrValue {
color: #0000c0;
}
</xsl:template>
</xsl:stylesheet>

View File

@ -0,0 +1,251 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*/
/**
* Plugin 'DLF: Pageview' for the 'dlf' extension.
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @copyright Copyright (c) 2010, Sebastian Meyer, SLUB Dresden
* @version $Id: class.tx_dlf_pageview.php 417 2010-11-12 08:43:05Z smeyer $
* @package TYPO3
* @subpackage tx_dlf
* @access public
*/
class tx_dlf_pageview extends tx_dlf_plugin {
public $scriptRelPath = 'plugins/pageview/class.tx_dlf_pageview.php';
/**
* Adds JavaScript for the viewer
*
* @access protected
*
* @return void
*/
protected function addJS() {
// Add JavaScript files to header.
$GLOBALS['TSFE']->additionalHeaderData[$this->prefixId.'_olJS'] = ' <script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'plugins/pageview/dlfOL.js"></script>';
// Add localization file for OpenLayers.
if ($GLOBALS['TSFE']->lang) {
$_langFile = t3lib_extMgm::siteRelPath($this->extKey).'lib/OpenLayers/lib/OpenLayers/Lang/'.strtolower($GLOBALS['TSFE']->lang).'.js';
if (file_exists($_langFile)) {
$GLOBALS['TSFE']->additionalHeaderData[$this->prefixId.'_olJS_lang'] = ' <script type="text/javascript" src="'.$_langFile.'"></script>';
} else {
trigger_error('There is no localization for OpenLayers for language '.$GLOBALS['TSFE']->lang, E_USER_NOTICE);
}
}
$GLOBALS['TSFE']->additionalHeaderData[$this->prefixId.'_olJS_viewer'] = ' <script type="text/javascript" src="'.t3lib_extMgm::siteRelPath($this->extKey).'plugins/pageview/viewer.js"></script>';
// Set "onbeforeunload" handler on body tag.
// $GLOBALS['TSFE']->pSetup['bodyTagAdd'] = 'onbeforeunload="javascript:dlfViewer.saveData();"';
}
/**
* Gets the required information about an image
*
* @access protected
*
* @param integer $page: The page number (defaults to $this->piVars['page'])
*
* @return string The JSON encoded image data
*/
protected function getImageData($page = 0) {
// Cast to integer for security reasons.
$page = intval($page);
// Set default value if not set.
if (!$page && $this->piVars['page']) {
$page = $this->piVars['page'];
}
$imageData = array ();
$_fileGrps = array_merge(array ('THUMBS', 'DEFAULT'), t3lib_div::trimExplode(',', $this->conf['fileGrps']));
foreach ($_fileGrps as $_fileGrp) {
$_fileGrp = strtolower($_fileGrp);
if (!empty($this->doc->physicalPages[$page]['files'][$_fileGrp])) {
$_fileGrpUrl = $this->doc->getFileLocation($this->doc->physicalPages[$page]['files'][$_fileGrp]);
$_fileGrpSize = getimagesize($_fileGrpUrl);
$imageData[] = array (
'width' => $_fileGrpSize[0],
'height' => $_fileGrpSize[1],
'url' => $_fileGrpUrl
);
}
}
return $imageData;
}
/**
* 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);
// Quit without doing anything if required piVars are not set.
if (!$this->checkPIvars()) {
return $content;
}
$this->loadDocument();
// Check if this document has any images.
if ($this->doc->numPages < 1) {
return $content;
} else {
$this->piVars['page'] = min($this->piVars['page'], $this->doc->numPages);
}
// Disable caching for this plugin.
$this->setCache(FALSE);
$content .= $this->showViewer();
return $this->pi_wrapInBaseClass($content);
}
/**
* Initializes the viewer
*
* @access protected
*
* @return string Viewer code ready for output
*/
protected function showViewer() {
$this->addJS();
// Set plugin variable defaults.
// $this->piVars['double'] = (!empty($this->piVars['double']) ? 1 : 0);
// $this->piVars['showOcrOverlay'] = (!empty($this->piVars['showOcrOverlay']) ? 1 : 0);
// Configure double-page layout.
// if ($this->piVars['double']) {
//
// // Check if current page is the last one.
// if ($this->piVars['page'] = $this->doc->numPages) {
//
// if ($this->doc->numPages > 1) {
//
// $this->piVars['page'] = $this->piVars['page'] - 1;
//
// } else {
//
// // The document has just one page.
// $this->piVars['double'] = 0;
//
// }
//
// }
//
// }
// Build HTML code.
$viewer = '<div id="tx-dlf-map"><div id="tx-dlf-lefttarget"></div><div id="tx-dlf-righttarget"></div></div>';
// Get values for viewer initialization.
$imageDataLeft = $this->getImageData();
// $imageDataRight = ($this->piVars['double'] ? $this->getImageData($this->piVars['page'] + 1) : array ());
//
// $doublePageView = $this->piVars['double'];
//
// $userName = (!empty($GLOBALS['TSFE']->fe_user->user['name']) ? $GLOBALS['TSFE']->fe_user->user['name'] : (!empty($GLOBALS['TSFE']->fe_user->user['username']) ? $GLOBALS['TSFE']->fe_user->user['username'] : ''));
//
// $userId = (!empty($GLOBALS['TSFE']->fe_user->user['uid']) ? $GLOBALS['TSFE']->fe_user->user['uid'] : 0);
//
// $options = array ('showOcrOverlay' => $this->piVars['showOcrOverlay']);
$addImages = array ();
foreach ($imageDataLeft as $imageData) {
$addImages[] = 'dlfViewer.addImage('.$imageData['width'].','.$imageData['height'].',"'.$imageData['url'].'");';
}
$viewer .= '
<script type="text/javascript">
/* <![CDATA[ */
dlfViewer = new Viewer();
'.implode("\n ", $addImages).'
dlfViewer.run();
/* ]]> */
</script>';
return $viewer;
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/pageview/class.tx_dlf_pageview.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/pageview/class.tx_dlf_pageview.php']);
}
?>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,829 @@
function Viewer() {
this.docId = 0;
this.pageId = 1;
this.imagesLeft = [];
this.imagesRight = [];
this.wordCoordLeft = [];
this.wordCoordRight = [];
this.annotationsLeft = [];
this.annotationsRight = [];
this.scale = 0;
this.doublePageView = false;
this.annotationLayer = null;
this.annotationLayer2 = null;
this.ocrSelectionLayer = null;
this.ocrOverlayLayer = null;
this.map = null;
this.pyramid = null;
this.ovMap = null;
this.highlightLayer = null;
this.teiDataUrl = "getTEI.php?index=";
this.annotationDataUrl = "getAnnotations.php?index=";
this.annotationUploadUrl = "uploadAnnotations.php?index=";
// Configurable options (@see Viewer.prototype.init)
this.imageDataLeft = "";
this.imageDataRight = "";
this.userName = "";
this.userId = 0;
this.notificationId = "tx-dlf-notifications";
this.hlButtonId = "highlightButton";
this.searchKeyId = "searchKey";
this.fuzzyBoxId = "fuzzyBox";
this.partBoxId = "partBox";
this.options = {
showOcrOverlay: false,
layerSwitcher: true
};
}
/**
* Initializes the viewer
* @param {Object} imageDataLeft: Image data for the left image
* @param {Object} imageDataRight: Image data for the right image
* @param {Object} userName: User's common name
* @param {Object} userId: User's UID in TYPO3
* @param {Object} options: JSON encoded array of additional options
*/
Viewer.prototype.init = function(imageDataLeft, imageDataRight, userName, userId, options){
if (location.search != '') {
var params = location.search.slice(1).split("&");
var param;
for (var i = 0; i < params.length; i++) {
param = params[i].split("=");
if (unescape(param[0]) == "tx_dlf[id]") {
this.docId = parseInt(unescape(param[1]));
}
if (unescape(param[0]) == "tx_dlf[page]") {
this.pageId = parseInt(unescape(param[1]));
}
}
}
this.imageDataLeft = imageDataLeft;
this.imageDataRight = imageDataRight;
this.doublePageView = (imageDataRight.url !== undefined);
this.userName = userName;
this.userId = userId;
this.notificationId = "tx-dlf-notifications";
this.hlButtonId = "highlightButton";
this.searchKeyId = "searchKey";
this.fuzzyBoxId = "fuzzyBox";
this.partBoxId = "partBox";
for (var i in options) {
var value = options[i];
if (value !== undefined) {
this.options[i] = Boolean(parseInt(value));
}
}
this.run();
}
/***
* Loads image data from JSON
* @param {Object} imageData: The image's data in JSON format
*/
Viewer.prototype.loadImages = function(imageData){
// var format = new OpenLayers.Format.JSON({});
// var data = format.read(imageData);
var images = [];
if (imageData != null) {
for (var i in imageData) {
images.push({
size: new OpenLayers.Size(imageData[i].width, imageData[i].height),
url: imageData[i].url
});
}
}
return images;
}
/**
* Loads annotation data from JSON
* @param {Object} annotationData: The annotation's data in JSON format
* @param {Object} baseHeight wird benötigt um die Koordinaten vom TEI auf die Map umzurechnen
* der Koordinatenursprung liegt für die OCR links oben, bei OL ist er links unten
*/
Viewer.prototype.loadAnnotations = function(url, baseHeight){
var request = OpenLayers.Request.GET({
url: url,
async: false
});
var format = new OpenLayers.Format.GeoJSON({});
if (request.responseText.length > 0) {
var annotations = format.read(request.responseText);
}
var offset = new OpenLayers.Pixel(0, 0);
for (var i in annotations) {
annotations[i].geometry.resize(1 / this.scale, offset, 1);
annotations[i].flipY(baseHeight);
}
return annotations;
}
/**
* Fügt eine Annotation dem Layer hinzu
* @param {Object} annotations
* @param {Object} offset wird verwendet wenn die Annotation zu einer rechten Seite gehört, dann wird sie verschoben
*/
Viewer.prototype.addAnnotations = function(annotations, offset){
if ((annotations != null)) {
for (var i in annotations) {
var annotation = annotations[i].clone();
annotation.shift(offset);
this.annotationLayer.addFeatures(annotation);
}
}
}
/**
* Zeigt dem Nutzer eine Nachricht an
* @param {Object} message
*/
Viewer.prototype.showNotification = function(message){
document.getElementById(this.notificationId).textContent = message;
}
/**
* Zeigt das Popup für ein Feature an
* @param {Object} feature
*/
Viewer.prototype.showPopup = function(feature){
popupHTML = dlfViewer.generatePopupCode(feature);
if (!feature.popup) {
//icon will be overridden by the rules
var icon = new OpenLayers.Icon("img/marker-blue.png", new OpenLayers.Size(10, 10), new OpenLayers.Pixel(0, 0));
var offset = this.getOffset(feature.geometry.getBounds().getCenterLonLat());
lonlat = feature.geometry.getBounds().getCenterLonLat();
feature.popup = new OpenLayers.Popup.FramedCloud("fpopup_" + feature.id, lonlat, new OpenLayers.Size(300, 200), popupHTML, icon, true, this.popUpClosed);
} else {
feature.popup.setContentHTML(dlfViewer.generatePopupCode(feature));
feature.popup.show();
}
feature.popup.temporary = (feature.layer.id == this.ocrSelectionLayer.id);
this.map.addPopup(feature.popup);
select.unselectAll();
}
/**
* Bestimmt wie groß der Offset für eine bestimmte Position ist
* Wenn ein Feature bei lonlat 700px steht es also zum rechten Blatt gehört, und die linke Seite 500px breit ist
* so wird 500 zurückgebenen
* @param {Object} lonlat
*/
Viewer.prototype.getOffset = function(lonlat){
var offset = new OpenLayers.Pixel(0, 0);
if (lonlat.lat > this.pyramid.grid[0].bounds.right) {
offset = this.pyramid.getBaseOffsetRight();
}
return offset;
}
/**
* Callback der ausgelöst wird, wenn eine Annotation ausgewählt wurde
*/
Viewer.prototype.onAnnotationSelected = function onAnnotationSelected(){
if (this.selectedFeatures.length > 0) {
var feature = this.selectedFeatures[0];
dlfViewer.showPopup(feature);
}
}
/**
* Callback der ausgelöst wird, wenn eine Annotation hinzugefügt wurde
* @param {Object} evt
*/
Viewer.prototype.onAnnotationAdded = function(evt){
var feature = evt.feature;
var text = "";
if (!feature.attributes.annotationId) {
var annotationId="newAnnotation_"+OpenLayers.Util.createUniqueID();
} else {
var annotationId=feature.attributes.annotationId;
}
feature.attributes = {
text: text,
userName: dlfViewer.userName,
userId: dlfViewer.userId,
annotationId: annotationId
};
dlfViewer.drawPoint.deactivate();
dlfViewer.drawPolygon.deactivate();
dlfViewer.drawPolygon2.deactivate();
dlfViewer.showPopup(feature);
dlfViewer.annotationLayer.redraw();
}
/**
* Callback der ausgelöst wird, wenn der Nutzer einen Teil des Texts mit einem Polygon markiert hat
* @param {Object} evt
*/
Viewer.prototype.onOcrSelectionAdded = function(evt){
var feature = evt.feature;
var text = "";
if ((feature.geometry instanceof OpenLayers.Geometry.Polygon) && (feature.layer.id == dlfViewer.ocrSelectionLayer.id)) {
var wordCoord = dlfViewer.wordCoordLeft;
var offset = dlfViewer.pyramid.getBaseOffsetRight();
if (dlfViewer.doublePageView && (feature.geometry.getCentroid().x > offset.x)) {
wordCoord = dlfViewer.wordCoordRight;
}
if (wordCoord.length > 0) {
var centerPoly = feature.geometry.getCentroid();
for (var i = 0; i < wordCoord.length; i++) {
centerWord = new OpenLayers.Geometry.Point((wordCoord[i].coords[0] + wordCoord[i].coords[2]) / 2, dlfViewer.size_disp.h - (wordCoord[i].coords[1] + wordCoord[i].coords[3]) / 2);
if (dlfViewer.doublePageView && (centerPoly.x > offset.x)) {
centerWord.x += offset.x;
}
if (feature.geometry.containsPoint(centerWord)) {
text += wordCoord[i].word + " ";
}
}
}
}
feature.attributes = {
text: text,
userName: dlfViewer.userName,
userId: dlfViewer.userId
};
dlfViewer.drawPoint.deactivate();
dlfViewer.drawPolygon.deactivate();
dlfViewer.drawPolygon2.deactivate();
dlfViewer.showPopup(feature);
}
/**
* Generiert innerHTML für das Popup eines Features
* @param {Object} feature
*/
Viewer.prototype.generatePopupCode = function(feature){
var popupHTML;
if (feature.layer.id == this.ocrSelectionLayer.id) {
popupHTML = '<textarea id="txt_' + feature.id + '" style="width:285px; height: 120px;">' + feature.attributes.text + '</textarea><br>';
} else if (feature.attributes.userId != this.userId) {
popupHTML = feature.attributes.userName + " meint: <br>";
popupHTML += '<textarea id="txt_' + feature.id + '" style="width:285px; height: 120px;">' + feature.attributes.text + '</textarea><br>';
} else {
popupHTML = feature.attributes.userName + " meint: <br>";
popupHTML += '<textarea id="txt_' + feature.id + '" style="width:285px; height: 120px;">' + feature.attributes.text + '</textarea><br>';
popupHTML += '<div style="text-align:right;"><input id="txtBtnDelete_' + feature.id + '" type="button" value="' + OpenLayers.Lang.translate('delete') + '" onclick="deleteAnnotation(\'' + feature.id + '\');">';
popupHTML += '<input id="txtBtnSave_' + feature.id + '" type="button" value="' + OpenLayers.Lang.translate('ok') + '" onclick="dlfViewer.updateAnnotation(\'' + feature.id + '\');"></div>';
}
return popupHTML;
}
/**
* Update der Annotation nachdem ihr Text geändert wurde
* @param {Object} id
*/
Viewer.prototype.updateAnnotation = function(id){
var feature = dlfViewer.annotationLayer.getFeatureById(id);
//Caution XSS
text = OpenLayers.Util.trim(OpenLayers.Util.stripHTML(document.getElementById("txt_" + id).value));
feature.attributes.text = text;
feature.popup.hide();
}
/**
* Löschen der Annotation
* @param {Object} id
*/
function deleteAnnotation(id){
var annotation = dlfViewer.annotationLayer.getFeatureById(id);
annotation.popup.toggle();
dlfViewer.annotationLayer.removeFeatures(annotation);
dlfViewer.annotationLayer.destroyFeatures(annotation);
}
/**
* Löschen des Features, wenn es nur dazu dient markierten OCR-TExt anzuzeigen
*/
Viewer.prototype.popUpClosed = function(){
//checks is the popup is a temporary one
if (this.temporary) {
var feature = dlfViewer.ocrSelectionLayer.getFeatureById(this.id);
this.hide();
dlfViewer.ocrSelectionLayer.removeFeatures(feature);
dlfViewer.ocrSelectionLayer.destroyFeatures(feature);
} else {
this.hide();
}
}
/**
* Update der Ansicht, die events werden vom annotationLayer entfernt. Weil sonst das hinzufügen der Annotationen (z.b. für die ein
* geblendete rechte Seite) dazu führt, dass automatisch die Popups geöffnet werden
*
*/
Viewer.prototype.updatePageView = function(){
this.annotationLayer.events.remove('featureadded');
this.annotationLayer.events.remove('featureselected');
this.ocrSelectionLayer.events.remove('featureadded');
if (!this.doublePageView) {
this.annotationsLeft = [];
this.annotationsRight = [];
var offset = this.pyramid.getBaseOffsetRight();
if (offset.x == 0) {
offset.x = this.pyramid.grid[0].bounds.right;
}
for (var i in this.annotationLayer.features) {
var centroid = this.annotationLayer.features[i].geometry.getCentroid();
if (centroid.x > offset.x) {
var annotation = this.annotationLayer.features[i].clone();
annotation.shift(new OpenLayers.Pixel(-offset.x, -offset.y));
this.annotationsRight.push(annotation);
} else {
this.annotationsLeft.push(this.annotationLayer.features[i].clone());
}
}
this.annotationLayer.destroyFeatures();
}
if (this.doublePageView) {
if (this.imagesRight.length < 1) {
this.imagesRight = this.loadImages(this.imageDataRight);
// loading images failes
if (this.imagesRight.length < 1) {
this.doublePageView = false;
this.showNotification(OpenLayers.Lang.translate('noImageFile'));
} else {
this.imagesRight.sort(this.pyramidSort);
for (var i = 1; i < this.imagesRight.length; i++) {
this.pyramid.addImageToPyramid(this.imagesRight[i].url, this.imagesRight[i].size, new OpenLayers.Bounds(0, 0, this.imagesRight[1].size.w, this.imagesRight[1].size.h), "right");
}
this.ovMap.layers[0].addTile(this.imagesRight[0].url, this.imagesRight[0].size, 'right');
}
}
if (this.wordCoordRight.length < 1) {
this.wordCoordRight = this.loadTEI(this.teiDataUrl + (this.pageId + 1), this.scale);
if (this.wordCoordRight.length > 0) {
document.getElementById(this.hlButtonId).disabled = false;
}
}
}
this.pyramid.setDoublePageView(this.doublePageView);
this.ovMap.setDoublePageView(this.doublePageView);
this.map.zoomToMaxExtent();
//add annotations
if (!this.doublePageView) {
this.addAnnotations(this.annotationsLeft, new OpenLayers.Pixel(0, 0));
}
offset = this.pyramid.getBaseOffsetRight();
if (this.doublePageView) {
if (this.annotationsRight.length < 1) {
this.annotationsRight = this.loadAnnotations(this.annotationDataUrl + (this.pageId + 1), this.pyramid.getBaseHeightRight());
}
this.addAnnotations(this.annotationsRight, offset);
}
this.annotationLayer.events.register('featureadded', this.annotationLayer, this.onAnnotationAdded);
this.annotationLayer.events.register('featureselected', this.annotationLayer, this.onAnnotationSelected);
this.ocrSelectionLayer.events.register('featureadded', this.ocrSelectionLayer, this.onOcrSelectionAdded);
}
/**
* Wird verwendet um die Bilder entsprechend ihrer Größe zu sortieren, bevor sie der ImagePyramid hinzugefügt werden
* @param {Object} a
* @param {Object} b
*/
Viewer.prototype.pyramidSort = function(a, b){
return a.size.h - b.size.h;
}
/**
* Umstellen zwischen Einzel- und Doppelseitenansicht
*/
Viewer.prototype.toggleDoublePageView = function(){
this.doublePageView = !(this.doublePageView && this.doublePageView);
this.updatePageView();
this.highlight()
}
/**
* Fügt Bilddaten hinzu
* @param {Object} width
* @param {Object} height
* @param {Object} url
* @param {Object} position
*/
Viewer.prototype.addImage = function(width, height, url, position){
if (position.toUpperCase() == "LEFT") {
this.imagesLeft.push({
size: new OpenLayers.Size(width, height),
url: url
});
}
if (position.toUpperCase() == "RIGHT") {
this.imagesRight.push({
size: new OpenLayers.Size(width, height),
url: url
});
}
}
/**
* Lädt die TEI Daten nach, scale wird verwendet um die Koordinaten der Wörter auf die Skale der ImagePyramid umzurechnen
* Der genau umgedrehte Schritt passiert in exportAnnotationsToJSON
* @param {Object} url
* @param {Object} scale
*/
Viewer.prototype.loadTEI = function(url, scale){
var request = OpenLayers.Request.GET({
url: url,
async: false
});
var format = new OpenLayers.Format.TEI({
scale: scale
});
if (request.responseText.length > 0) {
var wordCoords = format.read(request.responseText);
}
return wordCoords;
}
/**
* Hebt ein Wort hervor
* @param {Object} wordCoords Array mit Wörtern und deren Koordinaten
* @param {Object} offset gibt an um wieviel Pixel die Highlightbox verschoben wird (rechte Seite)
*/
Viewer.prototype.highlightWord = function(wordCoords, offset){
var key = document.getElementById(this.searchKeyId).value;
var fuzzy = document.getElementById(this.fuzzyBoxId).checked;
var part = document.getElementById(this.partBoxId).checked;
var errorRate = 0;
var eps1 = 0;
var eps2 = 0.25;
if (fuzzy) {
errorRate = 0.3;
}
var similar = 0;
var hits = 0;
var eq = 0;
var value;
for (var i = 0; i < wordCoords.length; i++) {
value = wordCoords[i].word;
if (part || fuzzy) {
position = this.compareStrings(key.toUpperCase(), value.toUpperCase(), part, errorRate);
} else {
position = value.toUpperCase() == key.toUpperCase();
if (position == false) {
position = -1;
} else {
position = 0;
}
}
if (position >= 0) {
if ((position > 0) && (value[0].toUpperCase() == value[0])) {
eps1 = 0.5;
} else {
eps1 = 0;
}
ext = wordCoords[i].coords;
w1 = Math.round(ext[0] + (position + eps1) / value.length * (ext[2] - ext[0]));
w2 = Math.round(w1 + (key.length + eps2) * (ext[2] - ext[0]) / value.length);
bounds = new OpenLayers.Bounds(w1 + offset.x, this.map.baseLayer.extent.top - ext[1] + offset.y, w2 + offset.x, this.map.baseLayer.extent.top - ext[3] + offset.y);
box = new OpenLayers.Feature.Vector(bounds.toGeometry());
this.highlightLayer.addFeatures(box);
}
}
this.map.zoomToMaxExtent();
}
/**
* Wrapper
*/
Viewer.prototype.highlight = function(){
this.highlightLayer.destroyFeatures();
if (this.wordCoordLeft.length > 0) {
this.highlightWord(this.wordCoordLeft, new OpenLayers.Pixel(0, 0));
}
if ((this.doublePageView) && (this.wordCoordRight.length > 0)) {
this.highlightWord(this.wordCoordRight, this.pyramid.getBaseOffsetRight());
}
}
/**
* returns -1 if the two strings are not similar
* @param {Object} a der Key nach dem gematcht wird
* @param {Object} b ein Wort
* @param {Object} part darf a teilstück von b sein
* @param {Object} errorRate wieviel prozent der buchstaben von a dürfen im schlimmsten fall nicht mit b übereinstimmen
*/
Viewer.prototype.compareStrings = function(a, b, part, errorRate){
var shorter;
if (!part && (a.length != b.length)) {
return -1;
}
//no fuzzy
if (part && (errorRate == 0)) {
return b.indexOf(a);
}
// fuzzy
if (a.length <= b.length) {
shorter = a;
} else {
return -1;
}
var d = 0;
var index = 0;
var dOpt = b.length;
for (var i = 0; i <= b.length - a.length; i++) {
d = 0;
for (var j = 0; j < a.length; j++) {
if (a[j] != b[j + i]) {
d++;
}
}
if (d < dOpt) {
dOpt = d;
index = i;
if (d == 0) {
break;
}
}
}
if (dOpt > errorRate * a.length) {
return -1;
}
return index;
}
/**
* exportiert die annotationen als JSON und sendet diese an die entsprechende PHP-Datei
*/
Viewer.prototype.exportAnnotationsToJSON = function(){
var dataLeft = [];
var dataRight = [];
var offset = this.pyramid.getBaseOffsetRight();
if (offset.x == 0) {
offset.x = this.pyramid.grid[0].bounds.right;
}
for (var i in this.annotationLayer.features) {
var centroid = this.annotationLayer.features[i].geometry.getCentroid();
if (centroid.x <= offset.x) {
this.annotationLayer.features[i].flipY(this.pyramid.getBaseHeightLeft());
this.annotationLayer.features[i].geometry.resize(this.scale, new OpenLayers.Pixel(0, 0), 1);
dataLeft.push(this.annotationLayer.features[i]);
} else {
this.annotationLayer.features[i].shift(new OpenLayers.Pixel(-offset.x, -offset.y));
this.annotationLayer.features[i].flipY(this.pyramid.getBaseHeightRight());
this.annotationLayer.features[i].geometry.resize(this.scale, new OpenLayers.Pixel(0, 0), 1);
dataRight.push(this.annotationLayer.features[i]);
}
}
if ((!this.doublePageView) && (this.annotationsRight)) {
for (var i in this.annotationsRight) {
var x = this.pyramid.getBaseHeightRight();
this.annotationsRight[i].flipY(this.pyramid.getBaseHeightRight());
this.annotationsRight[i].geometry.resize(this.scale, new OpenLayers.Pixel(0, 0), 1);
dataRight.push(this.annotationsRight[i]);
}
}
var formater = new OpenLayers.Format.GeoJSON();
if (dataLeft.length > 0) {
var annotationJSONLeft = formater.write(dataLeft, true, this.imagesLeft[this.imagesLeft.length - 1].url);
var request = OpenLayers.Request.POST({
url: this.annotationUploadUrl,
data: annotationJSONLeft,
headers: {
"Content-Type": "text/plain"
},
callback: this.showServerResponse
});
document.getElementById('output').value = annotationJSONLeft;
}
if (dataRight.length > 0) {
var annotationJSONRight = formater.write(dataRight, true, this.imagesRight[this.imagesRight.length - 1].url);
var request = OpenLayers.Request.POST({
url: this.annotationUploadUrl,
data: annotationJSONRight,
headers: {
"Content-Type": "text/plain"
},
});
}
return;
}
/**
* Zeigt ein Overlay mit OCR-Text an, diese Funktion wird nur aufgerufen wenn eine Zoomstufe erreicht ist die groß genug ist,
* siehe oben. Die Worte werden nur in dem aktuell betrachteten Bereich angezeigt.
* eps .. ist ein parameter der anzeigt, wieviel Prozent auch noch neben dem Rand angezeigt werden
* @param {Object} mapBounds .. gibt den aktuellen sichtbereich an
*/
Viewer.prototype.updateOcrOverlayLayer = function(mapBounds){
eps = 0.01;
mapBounds = new OpenLayers.Bounds((1 - eps) * mapBounds.left, (1 - eps) * mapBounds.bottom, (1 + eps) * mapBounds.right, (1 + eps) * mapBounds.top);
dlfViewer.ocrOverlayLayer.destroyFeatures();
wordCoord = dlfViewer.wordCoordLeft;
offset = dlfViewer.pyramid.getBaseOffsetRight();
if (dlfViewer.doublePageView && ((mapBounds.right + mapBounds.left) / 2 > offset.x)) {
wordCoord = dlfViewer.wordCoordRight;
} else {
offset = new OpenLayers.Pixel(0, 0);
}
for (var i = 0; i < wordCoord.length; i++) {
ext = wordCoord[i].coords;
bounds = new OpenLayers.Bounds(ext[0] + offset.x, dlfViewer.size_disp.h - (ext[1] + offset.y), ext[2] + offset.x, dlfViewer.size_disp.h - (ext[3] + offset.y));
center = bounds.getCenterLonLat();
if ((mapBounds.bottom < center.lat) && (mapBounds.top > center.lat) && (mapBounds.left < center.lon) && (mapBounds.right > center.lon)) {
box = new OpenLayers.Feature.Vector(bounds.toGeometry());
box.attributes = {
text: wordCoord[i].word
};
dlfViewer.ocrOverlayLayer.addFeatures(box);
}
}
}
/**
* Hauptroutine
*/
Viewer.prototype.run = function(){
//Loading Images, TEI
this.imagesLeft = this.loadImages(this.imageDataLeft);
if (this.imagesLeft.length < 1) {
this.showNotification(OpenLayers.Lang.translate('noImageFile'));
return;
}
this.imagesLeft.sort(this.pyramidSort);
var size_orig = new OpenLayers.Size(this.imagesLeft[this.imagesLeft.length - 1].size.w, this.imagesLeft[this.imagesLeft.length - 1].size.h);
this.size_disp = new OpenLayers.Size(this.imagesLeft[1].size.w, this.imagesLeft[1].size.h);
this.scale = size_orig.w / this.size_disp.w;
// if (this.wordCoordLeft < 1) {
// document.getElementById(this.hlButtonId).disabled = true;
// } else {
// document.getElementById(this.hlButtonId).disabled = false;
// }
// creating map and add layers
var options = {
maxExtent: new OpenLayers.Bounds(0, 0, this.size_disp.w, this.size_disp.h),
controls: [new OpenLayers.Control.Navigation()],
numZoomLevels: 7,
fractionalZoom: true
};
this.map = new OpenLayers.Map('dlfViewer', options);
var bounds = new OpenLayers.Bounds(0, 0, this.size_disp.w, this.size_disp.h);
var scale = size_orig.w / this.size_disp.w;
//create pyramid and add images to it
this.pyramid = new OpenLayers.Layer.ImagePyramid(OpenLayers.Lang.translate('actualPage'), null, bounds, this.size_disp);
for (var i = 1; i < (this.imagesLeft.length); i++) {
this.pyramid.addImageToPyramid(this.imagesLeft[i].url, this.imagesLeft[i].size, new OpenLayers.Bounds(0, 0, this.imagesLeft[1].size.w, this.imagesLeft[1].size.h), "left");
}
this.pyramid.adjustSizes();
//Create the hightlighting-layer
this.highlightLayer = new OpenLayers.Layer.Vector(OpenLayers.Lang.translate('highlightLayer'));
// create overviewmap
var thumbnailSize = this.imagesLeft[0].size;
var thumbnailExtent = new OpenLayers.Bounds(0, 0, thumbnailSize.w, thumbnailSize.h)
var thumbnail = new OpenLayers.Layer.ExtendedImage('Thumbnail', this.imagesLeft[0].url, thumbnailExtent, thumbnailSize);
thumbnail.addTile(this.imagesLeft[0].url, this.imagesLeft[0].size, 'left');
var controlOptions = {
layers: [thumbnail],
'size': thumbnailSize,
isSuitableOverview: function(){
return true;
},
mapOptions: {
maxExtent: thumbnailExtent,
autopan: true,
minRatio: 16,
maxRatio: 64
}
};
this.ovMap = new OpenLayers.Control.OverviewMap(controlOptions);
var style = new OpenLayers.Style({name: "default"});
var ruleOwnAnnotation = new OpenLayers.Rule({
filter: new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: "userId",
value: this.userId,
}),
symbolizer: {
//externalGraphic: "img/marker-gold.png",
pointRadius: 7,
fillColor: "#ffd700",
fillOpacity: 0.7,
strokeColor: "#ffd700",
strokeWidth: 2
}
});
var ruleOtherAnnotation = new OpenLayers.Rule({
filter: new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.NOT_EQUAL_TO,
property: "userId",
value: this.userId,
}),
symbolizer: {
//externalGraphic: "img/marker-blue.png",
pointRadius: 7,
fillColor: "#8da8f6",
fillOpacity: 0.7,
strokeColor: "#8da8f6",
strokeWidth: 2
}
});
style.addRules([ruleOwnAnnotation,ruleOtherAnnotation]);
var styleMap=new OpenLayers.StyleMap({"default":style});
this.annotationLayer = new OpenLayers.Layer.Vector(OpenLayers.Lang.translate('annotations'), {
styleMap: styleMap
});
this.ocrSelectionLayer = new OpenLayers.Layer.Vector(OpenLayers.Lang.translate('ocrSelection'));
if (this.options['showOcrOverlay']) {
//Create editable Vectorlayer and Vector styles
var overlayStyle = new OpenLayers.StyleMap({
"default": new OpenLayers.Style({
fillColor: "#AAA",
strokeColor: "#777",
label: "${text}",
fontColor: "yellow",
fontWeight: "bold",
fillOpacity: 0.8
}),
});
this.ocrOverlayLayer = new OpenLayers.Layer.Vector(OpenLayers.Lang.translate('ocrOverlay'), {
styleMap: overlayStyle
});
}
//Create a select feature control
select = new OpenLayers.Control.SelectFeature([this.annotationLayer, this.ocrSelectionLayer], {
clickout: true,
toggle: false,
multiple: false,
hover: false,
});
//Create drawPoint
this.drawPoint = new OpenLayers.Control.DrawFeature(this.annotationLayer, OpenLayers.Handler.Point, {
'displayClass': 'olControlDrawFeaturePoint'
});
this.drawPolygon = new OpenLayers.Control.DrawFeature(this.annotationLayer, OpenLayers.Handler.Polygon, {
'displayClass': 'olControlDrawFeaturePolygon'
});
//this is used to select an area with text, the ocr-text is displayed in a popup
this.drawPolygon2 = new OpenLayers.Control.DrawFeature(this.ocrSelectionLayer, OpenLayers.Handler.Polygon, {
'displayClass': 'olControlDrawFeaturePolygon2'
});
customPanel = new OpenLayers.Control.Panel({});
customPanel.addControls([this.drawPoint, this.drawPolygon, this.drawPolygon2]);
var loadingPanel = new OpenLayers.Control.LoadingPanel();
var container = document.getElementById("zoomPanel");
var zoomPanel = new OpenLayers.Control.ZoomPanel({
div: container
});
var container = document.getElementById("panPanel");
var panPanel = new OpenLayers.Control.PanPanel({
div: container
});
this.map.addLayers([this.pyramid, this.highlightLayer, this.annotationLayer, this.ocrSelectionLayer]);
this.map.setBaseLayer(this.pyramid);
if (this.options['showOcrOverlay']) {
this.map.addLayer(this.ocrOverlayLayer);
this.ocrOverlayLayer.events.register("visibilitychanged", this.ocrOverlayLayer, function(evt){
if (dlfViewer.ocrOverlayLayer.visibility && (dlfViewer.map.zoom > 1)) {
dlfViewer.updateOcrOverlayLayer(dlfViewer.map.calculateBounds());
} else {
dlfViewer.ocrOverlayLayer.destroyFeatures();
}
});
this.ocrOverlayLayer.events.register("movestart", this.ocrOverlayLayer, function(evt){
dlfViewer.ocrOverlayLayer.destroyFeatures();
});
this.ocrOverlayLayer.events.register("moveend", this.ocrOverlayLayer, function(evt){
dlfViewer.ocrOverlayLayer.destroyFeatures();
OpenLayers.Console.log("dlfViewer.map.calculateBounds: " + dlfViewer.map.calculateBounds());
if (dlfViewer.ocrOverlayLayer.visibility && (dlfViewer.map.zoom > 1)) {
dlfViewer.updateOcrOverlayLayer(dlfViewer.map.calculateBounds());
} else {
dlfViewer.ocrOverlayLayer.destroyFeatures();
}
});
}
this.map.addControl(zoomPanel);
this.map.addControl(panPanel);
this.map.addControl(new OpenLayers.Control.MousePosition());
this.map.addControl(customPanel);
this.map.addControl(loadingPanel);
if (this.options['layerSwitcher']) {
this.map.addControl(new OpenLayers.Control.LayerSwitcher({
activeColor: "white"
}));
}
this.map.addControl(select);
this.map.addControl(this.ovMap);
this.map.addControl(new OpenLayers.Control.DragFeature(this.annotationLayer));
this.ovMap.maximizeControl();
this.map.zoomToMaxExtent();
//add annotations for left side
this.annotationsLeft = this.loadAnnotations(this.annotationDataUrl + this.pageId, this.pyramid.getBaseHeightLeft());
this.addAnnotations(this.annotationsLeft, new OpenLayers.Pixel(0, 0));
select.activate();
if (this.doublePageView) {
this.updatePageView();
}
this.annotationLayer.events.register('featureadded', this.annotationLayer, this.onAnnotationAdded);
this.annotationLayer.events.register('featureselected', this.annotationLayer, this.onAnnotationSelected);
this.ocrSelectionLayer.events.register('featureadded', this.ocrSelectionLayer, this.onOcrSelectionAdded);
// align navigationPanel
h = document.getElementById("dlfViewer").offsetWidth;
h2 = document.getElementById("navigationPanel").offsetWidth;
document.getElementById("navigationPanel").style.left = Math.round((h - h2) / 2) + "px";
}

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3DataStructure>
<meta>
<langDisable>1</langDisable>
</meta>
<sheets>
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>LLL:EXT:dlf/plugins/pageview/locallang.xml:tt_content.pi_flexform.sheet_general</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<pages>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:lang/locallang_general.xml:LGL.startingpoint</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
</config>
</TCEforms>
</pages>
<excludeOther>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/pageview/locallang.xml:tt_content.pi_flexform.excludeOther</label>
<config>
<type>check</type>
<default>1</default>
</config>
</TCEforms>
</excludeOther>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3locallang>
<meta type="array">
<type>module</type>
<description>Language labels for plugin tx_dlf_pageview</description>
</meta>
<data type="array">
<languageKey index="default" type="array">
<label index="tt_content.pi_flexform.sheet_general">Options</label>
<label index="tt_content.pi_flexform.excludeOther">Show only documents from the selected page</label>
</languageKey>
<languageKey index="de" type="array">
<label index="tt_content.pi_flexform.sheet_general">Einstellungen</label>
<label index="tt_content.pi_flexform.excludeOther">Nur Dokumente der ausgewählten Seite anzeigen</label>
</languageKey>
</data>
</T3locallang>

View File

@ -0,0 +1,111 @@
function Viewer(){
this.images = [];
this.map = null;
}
Viewer.prototype.addImage = function(width, height, url){
this.images.push({
size: new OpenLayers.Size(width, height),
url: url
});
}
Viewer.prototype.Zoom = function(z){
this.map.zoomTo(z);
}
Viewer.prototype.saveData = function(){
this.setCookie("zoom", this.map.getZoom());
this.setCookie("lat", this.map.center.lat);
this.setCookie("lon", this.map.center.lon);
}
Viewer.prototype.setCookie = function(name, value){
var cookie_string = name + "=" + escape(value);
var expires = new Date();
expires.setTime(expires.getTime() + (30 * 24 * 60 * 60 * 1000));
cookie_string += "; path=/ ; expires=" + expires.toGMTString();
document.cookie = cookie_string;
}
Viewer.prototype.getCookie = function(cookie_name){
var results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');
if (results) {
return (unescape(results[2]));
} else {
return null;
}
}
Viewer.prototype.run = function(){
this.images.sort(function(a, b){
return a.size.h - b.size.h;
});
var size_orig = new OpenLayers.Size(this.images[this.images.length - 1].size.w, this.images[this.images.length - 1].size.h);
var size_disp = new OpenLayers.Size(this.images[1].size.w, this.images[1].size.h);
var options = {
maxExtent: new OpenLayers.Bounds(0, 0, size_disp.w, size_disp.h),
controls: [new OpenLayers.Control.Navigation()],
numZoomLevels: 7,
fractionalZoom: true
};
this.map = new OpenLayers.Map("tx-dlf-map", options);
var bounds = new OpenLayers.Bounds(0, 0, size_disp.w, size_disp.h);
var scale = size_orig.w / size_disp.w;
pyramid = new OpenLayers.Layer.ImagePyramid("tx-dlf-image", null, bounds, size_disp);
for (var i = 1; i < this.images.length; i++) {
pyramid.addImageToPyramid(this.images[i].url, this.images[i].size, bounds, "left");
}
this.map.addLayer(pyramid);
var thumbnailSize = this.images[0].size;
var thumbnailExtent = new OpenLayers.Bounds(0, 0, thumbnailSize.w, thumbnailSize.h)
var thumbnail = new OpenLayers.Layer.Image("tx-dlf-thumbnail", this.images[0].url, thumbnailExtent, thumbnailSize);
var controlOptions = {
layers: [thumbnail],
'size': thumbnailSize,
isSuitableOverview: function(){
return true;
},
mapOptions: {
maxExtent: thumbnailExtent,
autopan: true,
minRatio: 16,
maxRatio: 64
}
};
// ovMap = new OpenLayers.Control.OverviewMap(controlOptions);
// this.map.addControl(ovMap);
// ovMap.maximizeControl();
// var loadingPanel = new OpenLayers.Control.LoadingPanel();
// this.map.addControl(loadingPanel);
// var container = document.getElementById("tx-dlf-zoomPanel");
// var zoomPanel = new OpenLayers.Control.ZoomPanel({
// div: container
// });
// var container = document.getElementById("tx-dlf-panPanel");
// var panPanel = new OpenLayers.Control.PanPanel({
// div: container
// });
// this.map.addControl(zoomPanel);
// this.map.addControl(panPanel);
// var zoom = parseInt(this.getCookie("zoom"));
// if (!zoom) {
// this.map.zoomToMaxExtent();
// }
// else {
// var lon = parseInt(this.getCookie("lon"));
// var lat = parseInt(this.getCookie("lat"));
// if (lon && lat) {
// var center = new OpenLayers.LonLat(lon, lat);
// this.map.setCenter(center, zoom, false, false);
// }else{
// this.map.zoomTo(zoom);
// }
// }
this.map.setCenter(new OpenLayers.LonLat(0, 0), null, false, false);
this.map.zoomToMaxExtent();
// h = document.getElementById("tx-dlf-map").offsetWidth;
// h2 = document.getElementById("tx-dlf-navigationPanel").offsetWidth;
// document.getElementById("tx-dlf-navigationPanel").style.left = Math.round((h - h2) / 2) + "px";
}

View File

@ -0,0 +1,141 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*/
/**
* Plugin 'DLF: Search' for the 'dlf' extension.
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @copyright Copyright (c) 2010, Sebastian Meyer, SLUB Dresden
* @version $Id: class.tx_dlf_search.php 490 2010-12-22 20:23:17Z smeyer $
* @package TYPO3
* @subpackage tx_dlf
* @access public
*/
class tx_dlf_search extends tx_dlf_plugin {
public $scriptRelPath = 'plugins/search/class.tx_dlf_search.php';
/**
* 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);
if (empty($this->piVars['query'])) {
// 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###');
}
// Fill markers.
$markerArray = array (
'###ACTION_URL###' => $this->pi_getPageLink($GLOBALS['TSFE']->id),
'###LABEL_QUERY###' => $this->pi_getLL('label.query'),
'###LABEL_SUBMIT###' => $this->pi_getLL('label.submit'),
'###FIELD_QUERY###' => $this->prefixId.'[query]',
'###QUERY###' => '',
);
// Display search form.
$content .= $this->cObj->substituteMarkerArray($this->template, $markerArray);
return $this->pi_wrapInBaseClass($content);
} else {
$solr = tx_dlf_solr::solrConnect($this->conf['solrcore']);
$query = $solr->search($this->piVars['query'], 0, $this->conf['limit'], array ());
$_list = array ();
$_metadata = array (
'uid' => 0,
'label' => sprintf($this->pi_getLL('searchfor', ''), $this->piVars['query']),
'description' => '',
'options' => array ()
);
foreach ($query->response->docs as $doc) {
$_list[] = array (
'uid' => $doc->uid,
'page' => $doc->page,
'title' => array ($doc->title),
'author' => array ($doc->author),
'year' => array ($doc->year),
'place' => array ($doc->place),
'type' => array ($doc->type),
'subparts' => array ()
);
}
$list = t3lib_div::makeInstance('tx_dlf_list');
$list->reset();
$list->add($_list);
$list->metadata = $_metadata;
$list->save();
header('Location: '.t3lib_div::locationHeaderUrl($this->pi_getPageLink($this->conf['targetPid'])));
exit;
}
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/search/class.tx_dlf_search.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/search/class.tx_dlf_search.php']);
}
?>

View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3DataStructure>
<meta>
<langDisable>1</langDisable>
</meta>
<sheets>
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>LLL:EXT:dlf/plugins/search/locallang.xml:tt_content.pi_flexform.sheet_general</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<solrcore>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/search/locallang.xml:tt_content.pi_flexform.solrcore</label>
<config>
<type>select</type>
<foreign_table>tx_dlf_solrcores</foreign_table>
<foreign_table_where>AND tx_dlf_solrcores.pid=0 ORDER BY tx_dlf_solrcores.label</foreign_table_where>
<default>1</default>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
</config>
</TCEforms>
</solrcore>
<limit>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/search/locallang.xml:tt_content.pi_flexform.limit</label>
<config>
<type>input</type>
<eval>required,num,int</eval>
<default>500</default>
</config>
</TCEforms>
</limit>
<targetPid>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/search/locallang.xml:tt_content.pi_flexform.targetPid</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
</config>
</TCEforms>
</targetPid>
<templateFile>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/search/locallang.xml:tt_content.pi_flexform.templateFile</label>
<config>
<type>group</type>
<internal_type>file_reference</internal_type>
<allowed>tmpl,tpl,html,htm,txt</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>
<disable_controls>upload</disable_controls>
</config>
</TCEforms>
</templateFile>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3locallang>
<meta type="array">
<type>module</type>
<description>Language labels for plugin tx_dlf_search</description>
</meta>
<data type="array">
<languageKey index="default" type="array">
<label index="tt_content.pi_flexform.sheet_general">Options</label>
<label index="tt_content.pi_flexform.solrcore">Solr Core</label>
<label index="tt_content.pi_flexform.limit">Maximum results</label>
<label index="tt_content.pi_flexform.targetPid">Target page (with "DLF: List View" plugin)</label>
<label index="tt_content.pi_flexform.templateFile">Template file</label>
<label index="label.query">Search for:</label>
<label index="label.submit">Search</label>
<label index="searchfor">Search for: "%s"</label>
</languageKey>
<languageKey index="de" type="array">
<label index="tt_content.pi_flexform.sheet_general">Einstellungen</label>
<label index="tt_content.pi_flexform.solrcore">Solr Kern</label>
<label index="tt_content.pi_flexform.limit">Maximale Ergebnismenge</label>
<label index="tt_content.pi_flexform.targetPid">Zielseite (mit Plugin "DLF: Listenansicht")</label>
<label index="tt_content.pi_flexform.templateFile">HTML-Template</label>
<label index="label.query">Suchen nach:</label>
<label index="label.submit">Suchen</label>
<label index="searchfor">Suche nach: "%s"</label>
</languageKey>
</data>
</T3locallang>

View File

@ -0,0 +1,7 @@
<!-- ###TEMPLATE### -->
<form action="###ACTION_URL###" method="post" enctype="multipart/form-data">
<label for="###FIELD_QUERY###">###LABEL_QUERY###</label>
<input type="text" id="###FIELD_QUERY###" name="###FIELD_QUERY###" value="###QUERY###" />
<input type="submit" value="###LABEL_SUBMIT###" />
</form>
<!-- ###TEMPLATE### -->

View File

@ -0,0 +1,288 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script 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.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*/
/**
* Plugin 'DLF: Viewer' for the 'dlf' extension.
*
* @author Sebastian Meyer <sebastian.meyer@slub-dresden.de>
* @copyright Copyright (c) 2010, Sebastian Meyer, SLUB Dresden
* @version $Id: class.tx_dlf_toc.php 487 2010-12-22 19:55:15Z smeyer $
* @package TYPO3
* @subpackage tx_dlf
* @access public
*/
class tx_dlf_toc extends tx_dlf_plugin {
public $scriptRelPath = 'plugins/toc/class.tx_dlf_toc.php';
/**
* This builds an array for one menu entry
*
* @access protected
*
* @param array $entry: The entry's array from tx_dlf_document->getLogicalStructure
* @param boolean $recursive: Whether to include the child entries
*
* @return array HMENU array for menu entry
*/
protected function getMenuEntry($entry, $recursive = FALSE) {
$entryArray = array ();
// Set "title", "type" and "pagination" from $entry array.
$entryArray['title'] = $entry['label'];
$entryArray['type'] = $this->pi_getLL($entry['type'], tx_dlf_helper::translate($entry['type'], 'tx_dlf_structures', $this->conf['pages']), FALSE);
$entryArray['pagination'] = $entry['pagination'];
$entryArray['doNotLinkIt'] = 0;
$entryArray['_OVERRIDE_HREF'] = '';
$entryArray['ITEM_STATE'] = 'NO';
// Build menu links based on the $entry['points'] array.
if (!empty($entry['points'][0]) && t3lib_div::testInt($entry['points'][0])) {
$entryArray['_OVERRIDE_HREF'] = $this->pi_linkTP_keepPIvars_url(array ('page' => $entry['points'][0]), TRUE, FALSE, $this->conf['targetPid']);
} elseif (!empty($entry['points'][0]) && is_string($entry['points'][0])) {
$_doc = tx_dlf_document::getInstance($entry['points'][0], ($this->conf['excludeOther'] ? $this->conf['pages'] : 0));
$entryArray['_OVERRIDE_HREF'] = $this->pi_linkTP_keepPIvars_url(array ('id' => ($_doc->pid ? $_doc->uid : $entry['points'][0]), 'page' => 1), TRUE, FALSE, $this->conf['targetPid']);
} elseif (!empty($entry['points']['doc'])) {
$entryArray['_OVERRIDE_HREF'] = $this->pi_linkTP_keepPIvars_url(array ('id' => $entry['points']['doc'], 'page' => 1), TRUE, FALSE, $this->conf['targetPid']);
} else {
$entryArray['doNotLinkIt'] = 1;
}
// Set "ITEM_STATE" to "CUR" if this entry points to current page.
if (!empty($this->piVars['page']) && in_array($this->piVars['page'], $entry['points'])) {
$entryArray['ITEM_STATE'] = 'CUR';
}
// Build sub-menu if available and called recursively.
if ($recursive == TRUE && !empty($entry['children'])) {
// Build sub-menu only if one of this conditions apply:
// 1. "expAll" is set for menu
// 2. Current menu node is in rootline
// 3. Current menu node points to another file
// 4. There are no physical pages in the current METS file
if (!empty($this->conf['menuConf.']['expAll']) || $entryArray['ITEM_STATE'] == 'CUR' || is_string($entry['points'][0]) || !$this->doc->physicalPages) {
$entryArray['_SUB_MENU'] = array ();
foreach ($entry['children'] as $_child) {
// Set "ITEM_STATE" to "ACT" if this entry points to current page and has sub-entries pointing to the same page.
if (!empty($this->piVars['page']) && in_array($this->piVars['page'], $_child['points'])) {
$entryArray['ITEM_STATE'] = 'ACT';
}
$entryArray['_SUB_MENU'][] = $this->getMenuEntry($_child, TRUE);
}
}
// Append "IFSUB" to "ITEM_STATE" if this entry has sub-entries.
$entryArray['ITEM_STATE'] = ($entryArray['ITEM_STATE'] == 'NO' ? 'IFSUB' : $entryArray['ITEM_STATE'].'IFSUB');
}
return $entryArray;
}
/**
* 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);
// Check for typoscript configuration to prevent fatal error.
if (empty($this->conf['menuConf.'])) {
trigger_error('No typoscript configuration for table of contents available', E_USER_ERROR);
return $content;
}
// Quit without doing anything if required piVars are not set.
if (!$this->checkPIvars()) {
return $content;
}
// 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/toc/template.tmpl'), '###TEMPLATE###');
}
$_TSconfig = array ();
$_TSconfig['special'] = 'userfunction';
$_TSconfig['special.']['userFunc'] = 'tx_dlf_toc->makeMenuArray';
$_TSconfig = t3lib_div::array_merge_recursive_overrule($this->conf['menuConf.'], $_TSconfig);
$markerArray['###TOCMENU###'] = $this->cObj->HMENU($_TSconfig);
$content .= $this->cObj->substituteMarkerArray($this->template, $markerArray);
return $this->pi_wrapInBaseClass($content);
}
/**
* 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);
// Quit without doing anything if required piVars are not set.
if (!$this->checkPIvars()) {
return array ();
}
// Load current document.
$this->loadDocument();
$menuArray = array ();
// Does the document have physical pages or is it an external file?
if ($this->doc->physicalPages || !t3lib_div::testInt($this->doc->uid)) {
// 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_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'] .= 'IFSUB';
$menuArray[0]['_SUB_MENU'] = array ();
while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
$_entry = array (
'label' => $resArray['title'],
'type' => $resArray['type'],
'pagination' => '',
'points' => array ('doc' => $resArray['uid'])
);
$menuArray[0]['_SUB_MENU'][] = $this->getMenuEntry($_entry, FALSE);
}
}
}
return $menuArray;
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/toc/class.tx_dlf_toc.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dlf/plugins/toc/class.tx_dlf_toc.php']);
}
?>

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3DataStructure>
<meta>
<langDisable>1</langDisable>
</meta>
<sheets>
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>LLL:EXT:dlf/plugins/toc/locallang.xml:tt_content.pi_flexform.sheet_general</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<pages>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:lang/locallang_general.xml:LGL.startingpoint</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
</config>
</TCEforms>
</pages>
<excludeOther>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/toc/locallang.xml:tt_content.pi_flexform.excludeOther</label>
<config>
<type>check</type>
<default>1</default>
</config>
</TCEforms>
</excludeOther>
<targetPid>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/toc/locallang.xml:tt_content.pi_flexform.targetPid</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>1</minitems>
</config>
</TCEforms>
</targetPid>
<templateFile>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/plugins/toc/locallang.xml:tt_content.pi_flexform.templateFile</label>
<config>
<type>group</type>
<internal_type>file_reference</internal_type>
<allowed>tmpl,tpl,html,htm,txt</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>
<disable_controls>upload</disable_controls>
</config>
</TCEforms>
</templateFile>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3locallang>
<meta type="array">
<type>module</type>
<description>Language labels for plugin tx_dlf_toc</description>
</meta>
<data type="array">
<languageKey index="default" type="array">
<label index="tt_content.pi_flexform.sheet_general">Options</label>
<label index="tt_content.pi_flexform.excludeOther">Show only documents from the selected page</label>
<label index="tt_content.pi_flexform.targetPid">Target page (with "DLF: Page View" plugin)</label>
<label index="tt_content.pi_flexform.templateFile">Template file</label>
</languageKey>
<languageKey index="de" type="array">
<label index="tt_content.pi_flexform.sheet_general">Einstellungen</label>
<label index="tt_content.pi_flexform.excludeOther">Nur Dokumente der ausgewählten Seite anzeigen</label>
<label index="tt_content.pi_flexform.targetPid">Zielseite (mit Plugin "DLF: Seitenansicht")</label>
<label index="tt_content.pi_flexform.templateFile">HTML-Template</label>
</languageKey>
</data>
</T3locallang>

27
dlf/plugins/toc/setup.txt Normal file
View File

@ -0,0 +1,27 @@
plugin.tx_dlf_toc.menuConf {
expAll = 0
1 = TMENU
1.noBlur = 1
1.wrap = <ul>|</ul>
1.NO = 1
1.NO.stdWrap.crop = 55 | &nbsp;... | 1
1.NO.stdWrap.ifEmpty.field = type
1.NO.stdWrap.dataWrap = <span class="tx-dlf-toc-title">|</span> <span class="tx-dlf-toc-pagination">{field:pagination}</span>
1.NO.doNotLinkIt.field = doNotLinkIt
1.NO.ATagTitle.field = type
1.NO.wrapItemAndSub = <li class="tx-dlf-toc-no">|</li>
1.IFSUB < .1.NO
1.IFSUB.wrapItemAndSub = <li class="tx-dlf-toc-no tx-dlf-toc-ifsub">|</li>
1.CUR < .1.NO
1.CUR.wrapItemAndSub = <li class="tx-dlf-toc-cur">|</li>
1.CURIFSUB < .1.NO
1.CURIFSUB.wrapItemAndSub = <li class="tx-dlf-toc-cur tx-dlf-toc-ifsub">|</li>
1.ACT < .1.NO
1.ACT.wrapItemAndSub = <li class="tx-dlf-toc-act">|</li>
1.ACTIFSUB < .1.NO
1.ACTIFSUB.wrapItemAndSub = <li class="tx-dlf-toc-act tx-dlf-toc-ifsub">|</li>
2 < .1
3 < .2
4 < .3
5 < .4
}

View File

@ -0,0 +1,11 @@
<!-- ###TEMPLATE### -->
<div class="tx-dlf-toc tx-dlf-window tx-dlf-leftwin tx-dlf-open">
<div class="tx-dlf-minimize"></div>
<div class="tx-dlf-wincontainer">
<h3 class="tx-dlf-windowhead">Inhaltsverzeichnis<span class="tx-dlf-moveit"></span></h3>
<div class="tx-dlf-wincontent tx-dlf-scrollbar">
###TOCMENU###
</div>
</div>
</div>
<!-- ###TEMPLATE### -->

4
dlf/repository/.htaccess Normal file
View File

@ -0,0 +1,4 @@
<IfModule mod_access.c>
Order deny,allow
Deny from all
</IfModule>

View File

@ -0,0 +1 @@
See http://lucene.apache.org/solr/

Binary file not shown.

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Set the path to the Solr war file as "docBase". -->
<Context docBase="/home/solr/apache-solr-1.4.1-dlf.war" debug="0" crossContext="true">
<!-- Specify the Solr home directory as "value". -->
<Environment name="solr/home" type="java.lang.String" value="/home/solr" override="true"/>
</Context>

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
If this file is found in the config directory, it will only be
loaded once at startup. If it is found in Solr's data directory,
it will be re-loaded every commit.
-->
<elevate>
<!--
EXAMPLE: When searching for "foo bar", the result set should
mention the documents with ids 1 + 2 first and exclude the
document with id 3.
<query text="foo bar">
<doc id="1" />
<doc id="2" />
<doc id="3" exclude="true" />
</query>
-->
</elevate>

View File

@ -0,0 +1,15 @@
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#-----------------------------------------------------------------------
# Use a protected word file to protect against the stemmer reducing two
# unrelated words to the same base word.

View File

@ -0,0 +1,176 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
Changelog:
2010-12-24 - Sebastian Meyer <sebastian.meyer@slub-dresden.de>
Initial schema for the DLF application.
-->
<schema name="dlf" version="1.2">
<types>
<!-- Commented field types are not used by DLF, but may be needed for other applications. -->
<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true" />
<fieldType name="boolean" class="solr.BoolField" sortMissingLast="true" omitNorms="true" />
<!-- <fieldtype name="binary" class="solr.BinaryField" /> -->
<fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" positionIncrementGap="0" />
<!-- <fieldType name="float" class="solr.TrieFloatField" precisionStep="0" omitNorms="true" positionIncrementGap="0" /> -->
<!-- <fieldType name="long" class="solr.TrieLongField" precisionStep="0" omitNorms="true" positionIncrementGap="0" /> -->
<!-- <fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" omitNorms="true" positionIncrementGap="0" /> -->
<!-- Use dates of the form 1995-12-31Z23:59:49Z for this field. -->
<fieldType name="date" class="solr.TrieDateField" precisionStep="0" omitNorms="true" positionIncrementGap="0" />
<!-- Use tokenized numeric fields for faster range queries. -->
<!-- <fieldType name="tint" class="solr.TrieIntField" precisionStep="8" omitNorms="true" positionIncrementGap="0" /> -->
<!-- <fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8" omitNorms="true" positionIncrementGap="0" /> -->
<!-- <fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" omitNorms="true" positionIncrementGap="0" /> -->
<!-- <fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" omitNorms="true" positionIncrementGap="0" /> -->
<!-- <fieldType name="tdate" class="solr.TrieDateField" precisionStep="6" omitNorms="true" positionIncrementGap="0" /> -->
<!-- A text field that only splits on whitespace for exact matching of words. -->
<fieldType name="standard" class="solr.TextField" positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.StandardTokenizerFactory" />
<filter class="solr.StandardFilterFactory" />
<filter class="solr.LowerCaseFilterFactory" />
</analyzer>
</fieldType>
<fieldType name="fulltext" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory" />
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
<!-- For more precise, but less flexible matching, set generateWordParts="0" and generateNumberParts="0". -->
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="1" />
<filter class="solr.ReversedWildcardFilterFactory" withOriginal="true" maxPosAsterisk="3" maxPosQuestion="2" maxFractionAsterisk="0.33" />
<filter class="solr.LowerCaseFilterFactory" />
<filter class="solr.TrimFilterFactory" />
<filter class="solr.SnowballPorterFilterFactory" language="German" protected="protwords.txt" />
<!-- <filter class="solr.GermanStemFilterFactory" /> -->
<filter class="solr.RemoveDuplicatesTokenFilterFactory" />
<!-- <filter class="solr.PatternReplaceFilterFactory" pattern="([^a-z])" replacement="" replace="all" /> -->
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory" />
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true" />
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
<!-- For more precise, but less flexible matching, set generateWordParts="0" and generateNumberParts="0". -->
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1" />
<filter class="solr.LowerCaseFilterFactory" />
<filter class="solr.TrimFilterFactory" />
<filter class="solr.SnowballPorterFilterFactory" language="German" protected="protwords.txt" />
<!-- <filter class="solr.GermanStemFilterFactory" /> -->
<filter class="solr.RemoveDuplicatesTokenFilterFactory" />
<!-- <filter class="solr.PatternReplaceFilterFactory" pattern="([^a-z])" replacement="" replace="all" /> -->
</analyzer>
</fieldType>
</types>
<fields>
<!--
Valid attributes for fields:
name: mandatory - the name for the field
type: mandatory - the name of a previously defined type from the
<types> section
indexed: true if this field should be indexed (searchable or sortable)
stored: true if this field should be retrievable
compressed: [false] if this field should be stored using gzip compression
(this will only apply if the field type is compressable; among
the standard field types, only TextField and StrField are)
multiValued: true if this field may contain multiple values per document
omitNorms: (expert) set to true to omit the norms associated with
this field (this disables length normalization and index-time
boosting for the field, and saves some memory). Only full-text
fields or fields that need an index-time boost need norms.
termVectors: [false] set to true to store the term vector for a given field.
When using MoreLikeThis, fields used for similarity should be
stored for best performance.
termPositions: Store position information with the term vector.
This will increase storage costs.
termOffsets: Store offset information with the term vector. This
will increase storage costs.
default: a value that should be used if no value is specified
when adding a document.
required: true if this field is mandatory
-->
<!-- The mandatory and special fields are defined here, all other fields are dynamic fields. -->
<!-- Unique identifier for the document in the index. -->
<field name="id" type="string" indexed="true" stored="true" required="true" />
<!-- Unique identifier for the document (or its top-level parent) in the TYPO3 database. -->
<field name="uid" type="int" indexed="true" stored="true" required="true" default="0" />
<!-- PageID for the document (or its top-level parent) in the TYPO3 database. -->
<field name="pid" type="int" indexed="true" stored="false" required="true" default="0" />
<!-- Image number where this document starts. -->
<field name="page" type="int" indexed="false" stored="true" required="true" default="1" />
<!-- Unique identifier for the parent document in the TYPO3 database. Only if this is a multi-volume work! -->
<field name="partof" type="int" indexed="true" stored="true" required="true" default="0" />
<!-- XML ID of this document in the METS file. This is only unique within the METS file! -->
<field name="sid" type="string" indexed="false" stored="true" required="true" default="" />
<!-- If it is a top-level document, leave this as default "true". -->
<field name="toplevel" type="boolean" indexed="true" stored="true" required="true" default="true" />
<!-- Type of document (eg. monograph, chapter, etc.) -->
<field name="type" type="string" indexed="true" stored="true" required="true" default="" />
<!-- Next four fields are used for displaying search hits. -->
<field name="title" type="standard" indexed="true" stored="true" required="true" default="" multiValued="false" />
<field name="author" type="standard" indexed="true" stored="true" multiValued="true" />
<field name="year" type="standard" indexed="true" stored="true" multiValued="true" />
<field name="place" type="standard" indexed="true" stored="true" multiValued="true" />
<!-- For sorting purposes, the year of publication should be handled as an integer. -->
<field name="year_sorting" type="int" indexed="true" stored="false" multiValued="false" />
<!-- CatchAll field. See <copyField> below. -->
<field name="default" type="standard" indexed="true" stored="false" required="true" default="" multiValued="true" />
<field name="timestamp" type="date" indexed="true" stored="true" required="true" default="NOW" multiValued="false" />
<!--
The following dynamic fields define all possible field variants.
The mapping between metadata fields and index fields is defined in TYPO3.
-->
<!-- tokenized, stored, indexed -->
<dynamicField name="*_tsi" type="standard" stored="true" indexed="true" multiValued="true" />
<!-- tokenized, stored, unindexed -->
<dynamicField name="*_tsu" type="standard" stored="true" indexed="false" multiValued="true" />
<!-- tokenized, unstored, indexed -->
<dynamicField name="*_tui" type="standard" stored="false" indexed="true" multiValued="true" />
<!-- tokenized, unstored, unindexed (this is ignored by Lucene) -->
<dynamicField name="*_tuu" type="standard" stored="false" indexed="false" multiValued="true" />
<!-- untokenized, stored, indexed -->
<dynamicField name="*_usi" type="string" stored="true" indexed="true" multiValued="true" />
<!-- untokenized, stored, unindexed -->
<dynamicField name="*_usu" type="string" stored="true" indexed="false" multiValued="true" />
<!-- untokenized, unstored, indexed -->
<dynamicField name="*_uui" type="string" stored="false" indexed="true" multiValued="true" />
<!-- untokenized, unstored, unindexed (this is ignored by Lucene) -->
<dynamicField name="*_uuu" type="string" stored="false" indexed="false" multiValued="true" />
<!-- "*_faceting" and "*_sorting" should always be used in addition to one of the other fields. -->
<dynamicField name="*_faceting" type="string" stored="false" indexed="true" multiValued="true" />
<dynamicField name="*_sorting" type="standard" stored="false" indexed="true" multiValued="false" />
</fields>
<uniqueKey>id</uniqueKey>
<defaultSearchField>default</defaultSearchField>
<solrQueryParser defaultOperator="AND" />
<copyField source="type" dest="default" />
<copyField source="title" dest="default" />
<copyField source="author" dest="default" />
<copyField source="year" dest="default" />
<copyField source="place" dest="default" />
<copyField source="*_tsi" dest="default" />
<copyField source="*_tui" dest="default" />
<copyField source="*_usi" dest="default" />
<copyField source="*_uui" dest="default" />
</schema>

View File

@ -0,0 +1,502 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
Changelog:
2010-12-24 - Sebastian Meyer <sebastian.meyer@slub-dresden.de>
Initial configuration for the DLF application.
-->
<!--
For more details about configurations options that may appear in this
file, see http://wiki.apache.org/solr/SolrConfigXml.
Specifically, the Solr Config can support XInclude, which may make it easier to manage
the configuration. See https://issues.apache.org/jira/browse/SOLR-1167
-->
<config>
<!--
Set this to "false" if you want Solr to continue working even if there
is an error in your configuration.
You may want to set this to "false" in a production environment, but to
"true" for testing purposes.
-->
<abortOnConfigurationError>${solr.abortOnConfigurationError:false}</abortOnConfigurationError>
<!--
Here you should mention all directories containing plugin files, which
are used in solrconfig.xml or schema.xml. Everything contained in the
optional "./lib" directory under the Solr home path is always included,
so the following is just an example which does not make any sense.
If you are using Solr only in conjunction with DLF you can leave this
unchanged because you will not need any other than the standard plugins.
-->
<!-- <lib dir="./lib" /> -->
<!--
Specify the directory where Lucene should save its index files. Please
notice that using a NFS mount here is possible but not recommended!
-->
<dataDir>${solr.core.dataDir}</dataDir>
<indexDefaults>
<!--
Set this to "false" if you want Lucene to split the index in multiple
files. Updating will be slightly faster, but searching a bit slower.
-->
<useCompoundFile>true</useCompoundFile>
<!--
Specify the allowed number of index segments before segments are merged
together. Higher values will result in faster indexing and less system
load, but slower searches.
-->
<mergeFactor>15</mergeFactor>
<!--
Specify how many documents or memory should be buffered before the data
is written to a segment file. Whatever limit is reached first will result
in a flush.
-->
<maxBufferedDocs>500</maxBufferedDocs>
<ramBufferSizeMB>64</ramBufferSizeMB>
<!--
Specify how many documents may be in one segment and how many tokens may
be in one field. The latter should not be too low because excess tokens
will be discarded.
-->
<maxMergeDocs>2147483647</maxMergeDocs>
<maxFieldLength>10000</maxFieldLength>
<!-- Specify the timeouts for writing to the index and commiting changes. -->
<writeLockTimeout>1000</writeLockTimeout>
<commitLockTimeout>10000</commitLockTimeout>
<!--
Set this to "true" if you want to enable auto-commiting. This is not
recommended as it significally slows indexing speed.
-->
<luceneAutoCommit>false</luceneAutoCommit>
<!--
Specify how Lucene should merge index segments. The given values are
Lucene's standard since version 2.3, so just leave this unchanged as long
as you do not need backwards compatibility for some reasons.
-->
<mergePolicy class="org.apache.lucene.index.LogByteSizeMergePolicy" />
<mergeScheduler class="org.apache.lucene.index.ConcurrentMergeScheduler" />
<!--
Specify which file locking mechanism Lucene should use. The options are:
single = use no file locking at all (not recommended!)
native = use the system's standard locking method
simple = use a plain file for locking
-->
<lockType>native</lockType>
</indexDefaults>
<!-- Here you can override some default settings from above for a specific index. -->
<mainIndex>
<!--
If true, unlock any held write or commit locks on startup.
This defeats the locking mechanism that allows multiple
processes to safely access a lucene index, and should be
used with care.
This is not needed if lock type is 'none' or 'single'
-->
<unlockOnStartup>false</unlockOnStartup>
<!--
If true, IndexReaders will be reopened (often more efficient) instead
of closed and then opened.
-->
<reopenReaders>true</reopenReaders>
<!-- Here you can change the deletion policy. This should be left unchanged! -->
<deletionPolicy class="solr.SolrDeletionPolicy">
<str name="maxCommitsToKeep">1</str>
<str name="maxOptimizedCommitsToKeep">0</str>
<!-- <str name="maxCommitAge">30MINUTES</str> -->
<!-- <str name="maxCommitAge">1DAY</str> -->
</deletionPolicy>
<!--
To aid in advanced debugging, you may turn on IndexWriter debug logging.
Setting to true will set the file that the underlying Lucene IndexWriter
will write its debug infostream to.
-->
<infoStream file="INFOSTREAM.txt">false</infoStream>
</mainIndex>
<!--
Enables JMX if and only if an existing MBeanServer is found, use this
if you want to configure JMX through JVM parameters. Remove this to disable
exposing Solr configuration and statistics to JMX.
If you want to connect to a particular server, specify the agentId
e.g. <jmx agentId="myAgent" />
If you want to start a new MBeanServer, specify the serviceUrl
e.g <jmx serviceUrl="service:jmx:rmi:///jndi/rmi://localhost:9999/solr"/>
For more details see http://wiki.apache.org/solr/SolrJmx
-->
<jmx />
<updateHandler class="solr.DirectUpdateHandler2">
<!--
Perform a <commit/> automatically under certain conditions:
maxDocs - number of updates since last commit is greater than this
maxTime - oldest uncommited update (in ms) is this long ago
Instead of enabling autoCommit, consider using "commitWithin"
when adding documents. http://wiki.apache.org/solr/UpdateXmlMessages
-->
<!-- <autoCommit>
<maxDocs>10000</maxDocs>
<maxTime>1000</maxTime>
</autoCommit> -->
<!--
The RunExecutableListener executes an external command from a
hook such as postCommit or postOptimize.
exe - the name of the executable to run
dir - dir to use as the current working directory. default="."
wait - the calling thread waits until the executable returns. default="true"
args - the arguments to pass to the program. default=nothing
env - environment variables to set. default=nothing
-->
<!-- A postCommit event is fired after every commit or optimize command. -->
<!-- <listener event="postCommit" class="solr.RunExecutableListener">
<str name="exe">solr/bin/snapshooter</str>
<str name="dir">.</str>
<bool name="wait">true</bool>
<arr name="args"><str>arg1</str><str>arg2</str></arr>
<arr name="env"> <str>MYVAR=val1</str> </arr>
</listener> -->
<!-- A postOptimize event is fired only after every optimize command. -->
<!-- <listener event="postOptimize" class="solr.RunExecutableListener">
<str name="exe">snapshooter</str>
<str name="dir">solr/bin</str>
<bool name="wait">true</bool>
</listener> -->
</updateHandler>
<query>
<!--
Maximum number of clauses in a boolean query... in the past, this affected
range or prefix queries that expanded to big boolean queries - built in Solr
query parsers no longer create queries with this limitation.
An exception is thrown if exceeded.
-->
<maxBooleanClauses>1024</maxBooleanClauses>
<!--
Cache used by SolrIndexSearcher for filters (DocSets),
unordered sets of *all* documents that match a query.
When a new searcher is opened, its caches may be prepopulated
or "autowarmed" using data from caches in the old searcher.
autowarmCount is the number of items to prepopulate. For LRUCache,
the autowarmed items will be the most recently accessed items.
Parameters:
class - the SolrCache implementation LRUCache or FastLRUCache
size - the maximum number of entries in the cache
initialSize - the initial capacity (number of entries) of the cache.
autowarmCount - the number of entries to prepopulate from and old cache.
-->
<filterCache class="solr.FastLRUCache" size="512" initialSize="512" autowarmCount="0" />
<!--
queryResultCache caches results of searches - ordered lists of
document ids (DocList) based on a query, a sort, and the range
of documents requested.
-->
<queryResultCache class="solr.LRUCache" size="512" initialSize="512" autowarmCount="0" />
<!--
documentCache caches Lucene Document objects (the stored fields for each document).
Since Lucene internal document ids are transient, this cache will not be autowarmed.
-->
<documentCache class="solr.LRUCache" size="512" initialSize="512" autowarmCount="0" />
<!--
If true, stored fields that are not requested will be loaded lazily.
This can result in a significant speed improvement if the usual case is to
not load all stored fields, especially if the skipped fields are large compressed text fields.
-->
<enableLazyFieldLoading>true</enableLazyFieldLoading>
<!--
An optimization that attempts to use a filter to satisfy a search.
If the requested sort does not include score, then the filterCache
will be checked for a filter matching the query. If found, the filter
will be used as the source of document ids, and then the sort will be
applied to that.
-->
<useFilterForSortedQuery>true</useFilterForSortedQuery>
<!--
An optimization for use with the queryResultCache. When a search
is requested, a superset of the requested number of document ids
are collected. For example, if a search for a particular query
requests matching documents 10 through 19, and queryWindowSize is 50,
then documents 0 through 49 will be collected and cached. Any further
requests in that range can be satisfied via the cache.
-->
<queryResultWindowSize>20</queryResultWindowSize>
<!--
Maximum number of documents to cache for any entry in the queryResultCache.
-->
<queryResultMaxDocsCached>500</queryResultMaxDocsCached>
<!--
QuerySenderListener takes an array of NamedList and executes a
local query request for each NamedList in sequence.
-->
<listener event="newSearcher" class="solr.QuerySenderListener">
<arr name="queries">
<!--
<lst><str name="q">solr</str><str name="start">0</str><str name="rows">10</str></lst>
<lst><str name="q">rocks</str><str name="start">0</str><str name="rows">10</str></lst>
<lst><str name="q">static newSearcher warming query from solrconfig.xml</str></lst>
-->
</arr>
</listener>
<listener event="firstSearcher" class="solr.QuerySenderListener">
<arr name="queries">
<!--
<lst><str name="q">solr rocks</str><str name="start">0</str><str name="rows">10</str></lst>
<lst><str name="q">static firstSearcher warming query from solrconfig.xml</str></lst>
-->
</arr>
</listener>
<useColdSearcher>true</useColdSearcher>
<maxWarmingSearchers>10</maxWarmingSearchers>
</query>
<!--
Let the dispatch filter handler /select?qt=XXX
handleSelect=true will use consistent error handling for /select and /update
handleSelect=false will use solr1.1 style error formatting
-->
<requestDispatcher handleSelect="true" >
<!--Make sure your system has some authentication before enabling remote streaming! -->
<requestParsers enableRemoteStreaming="false" multipartUploadLimitInKB="2048000" />
<httpCaching lastModifiedFrom="dirLastMod" etagSeed="Solr">
<cacheControl>max-age=30, public</cacheControl>
</httpCaching>
</requestDispatcher>
<!--
requestHandler plugins... incoming queries will be dispatched to the
correct handler based on the path or the qt (query type) param.
Names starting with a '/' are accessed with a path equal to the
registered name. Names without a leading '/' are accessed with:
http://host/app/select?qt=name
If no qt is defined, the requestHandler that declares default="true"
will be used.
-->
<requestHandler name="standard" class="solr.SearchHandler" default="true">
<!-- default values for query parameters -->
<lst name="defaults">
<str name="echoParams">explicit</str>
</lst>
</requestHandler>
<!--
DisMaxRequestHandler allows easy searching across multiple fields
for simple user-entered phrases. It's implementation is now
just the standard SearchHandler with a default query type
of "dismax".
see http://wiki.apache.org/solr/DisMaxRequestHandler
-->
<requestHandler name="dismax" class="solr.SearchHandler" >
<lst name="defaults">
<str name="defType">dismax</str>
<str name="echoParams">explicit</str>
<float name="tie">0.01</float>
<str name="qf">text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4</str>
<str name="pf">text^0.2 features^1.1 name^1.5 manu^1.4 manu_exact^1.9</str>
<str name="bf">popularity^0.5 recip(price,1,1000,1000)^0.3</str>
<str name="fl">id,name,price,score</str>
<str name="mm">2&lt;-1 5&lt;-2 6&lt;90%</str>
<int name="ps">100</int>
<str name="q.alt">*:*</str>
<!-- example highlighter config, enable per-query with hl=true -->
<str name="hl.fl">text features name</str>
<!-- for this field, we want no fragmenting, just highlighting -->
<str name="f.name.hl.fragsize">0</str>
<!-- instructs Solr to return the field itself if no query terms are found -->
<str name="f.name.hl.alternateField">name</str>
<!-- defined below -->
<str name="f.text.hl.fragmenter">regex</str>
</lst>
</requestHandler>
<!--
Note how you can register the same handler multiple times with
different names (and different init parameters)
This is just an example which is not used by DLF!
-->
<requestHandler name="partitioned" class="solr.SearchHandler" >
<lst name="defaults">
<str name="defType">dismax</str>
<str name="echoParams">explicit</str>
<str name="qf">text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0</str>
<str name="mm">2&lt;-1 5&lt;-2 6&lt;90%</str>
<!--
This is an example of using Date Math to specify a constantly
moving date range in a config...
-->
<str name="bq">incubationdate_dt:[* TO NOW/DAY-1MONTH]^2.2</str>
</lst>
<!--
In addition to defaults, "appends" params can be specified
to identify values which should be appended to the list of
multi-val params from the query (or the existing "defaults").
In this example, the param "fq=instock:true" will be appended to
any query time fq params the user may specify, as a mechanism for
partitioning the index, independent of any user selected filtering
that may also be desired (perhaps as a result of faceted searching).
NOTE: there is *absolutely* nothing a client can do to prevent these
"appends" values from being used, so don't use this mechanism unless
you are sure you always want it.
-->
<lst name="appends">
<str name="fq">inStock:true</str>
</lst>
<!--
"invariants" are a way of letting the Solr maintainer lock down
the options available to Solr clients. Any params values specified
here are used regardless of what values may be specified in either
the query, the "defaults", or the "appends" params.
In this example, the facet.field and facet.query params are fixed,
limiting the facets clients can use. Faceting is not turned on by
default - but if the client does specify facet=true in the request,
these are the only facets they will be able to see counts for;
regardless of what other facet.field or facet.query params they
may specify.
NOTE: there is *absolutely* nothing a client can do to prevent these
"invariants" values from being used, so don't use this mechanism
unless you are sure you always want it.
-->
<lst name="invariants">
<str name="facet.field">cat</str>
<str name="facet.field">manu_exact</str>
<str name="facet.query">price:[* TO 500]</str>
<str name="facet.query">price:[500 TO *]</str>
</lst>
</requestHandler>
<!--
a search component that enables you to configure the top results for
a given query regardless of the normal lucene scoring.
-->
<searchComponent name="elevator" class="solr.QueryElevationComponent" >
<!-- pick a fieldType to analyze queries -->
<str name="queryFieldType">string</str>
<str name="config-file">elevate.xml</str>
</searchComponent>
<!-- a request handler utilizing the elevator component -->
<requestHandler name="/elevate" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
<str name="echoParams">explicit</str>
</lst>
<arr name="last-components">
<str>elevator</str>
</arr>
</requestHandler>
<!--
Update request handler.
Note: Since solr1.1 requestHandlers requires a valid content type header if posted in
the body. For example, curl now requires: -H 'Content-type:text/xml; charset=utf-8'
The response format differs from solr1.1 formatting and returns a standard error code.
To enable solr1.1 behavior, remove the /update handler or change its path
-->
<requestHandler name="/update" class="solr.XmlUpdateRequestHandler" />
<requestHandler name="/update/javabin" class="solr.BinaryUpdateRequestHandler" />
<!-- CSV update handler, loaded on demand -->
<requestHandler name="/update/csv" class="solr.CSVRequestHandler" startup="lazy" />
<requestHandler name="/admin/" class="org.apache.solr.handler.admin.AdminHandlers" />
<!-- ping/healthcheck -->
<requestHandler name="/admin/ping" class="PingRequestHandler">
<lst name="defaults">
<str name="qt">standard</str>
<str name="q">solrpingquery</str>
<str name="echoParams">all</str>
</lst>
</requestHandler>
<highlighting>
<!-- Configure the standard fragmenter -->
<fragmenter name="gap" class="org.apache.solr.highlight.GapFragmenter" default="true">
<lst name="defaults">
<int name="hl.fragsize">100</int>
</lst>
</fragmenter>
<!-- A regular-expression-based fragmenter (f.i., for sentence extraction) -->
<fragmenter name="regex" class="org.apache.solr.highlight.RegexFragmenter">
<lst name="defaults">
<!-- slightly smaller fragsizes work better because of slop -->
<int name="hl.fragsize">70</int>
<!-- allow 50% slop on fragment sizes -->
<float name="hl.regex.slop">0.5</float>
<!-- a basic sentence pattern -->
<str name="hl.regex.pattern">[-\w ,/\n\"']{20,200}</str>
</lst>
</fragmenter>
<!-- Configure the standard formatter -->
<formatter name="html" class="org.apache.solr.highlight.HtmlFormatter" default="true">
<lst name="defaults">
<str name="hl.simple.pre"><![CDATA[<span class="sword">]]></str>
<str name="hl.simple.post"><![CDATA[</span>]]></str>
</lst>
</formatter>
</highlighting>
<!--
XSLT response writer transforms the XML output by any xslt file found
in Solr's conf/xslt directory. Changes to xslt files are checked for
every xsltCacheLifetimeSeconds.
-->
<queryResponseWriter name="xslt" class="org.apache.solr.request.XSLTResponseWriter">
<int name="xsltCacheLifetimeSeconds">86400</int>
</queryResponseWriter>
<!-- config for the admin interface -->
<admin>
<defaultQuery>DLF</defaultQuery>
</admin>
</config>

View File

@ -0,0 +1,52 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#-----------------------------------------------------------------------
#Standard english stop words taken from Lucene's StopAnalyzer
a
an
and
are
as
at
be
but
by
for
if
in
into
is
it
no
not
of
on
or
s
such
t
that
the
their
then
there
these
they
this
to
was
will
with

View File

@ -0,0 +1,18 @@
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#-----------------------------------------------------------------------
# synonym mappings can be used for spelling correction too
# Syntax:
# "synonym1" => "synonym2"

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="true">
<cores adminPath="/admin/cores" shareSchema="true">
<core name="dlfCore0" instanceDir="./" dataDir="dlfCore0" />
</cores>
</solr>

Some files were not shown because too many files have changed in this diff Show More