@ -142,16 +130,14 @@ abstract class AbstractPlugin extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
if (!$this->doc->ready) {
// Destroy the incomplete object.
$this->doc = NULL;
if (TYPO3_DLOG)
{
if (TYPO3_DLOG) {
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\AbstractPlugin->loadDocument()] Failed to load document with UID "'.$this->piVars['id'].'"', $this->extKey, SYSLOG_SEVERITY_ERROR);
}
} else {
// Set configuration PID.
$this->doc->cPid = $this->conf['pages'];
}
} elseif (!empty($this->piVars['recordId']))
{
} elseif (!empty($this->piVars['recordId'])) {
// Get UID of document with given record identifier.
$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'tx_dlf_documents.uid',
@ -162,8 +148,7 @@ abstract class AbstractPlugin extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
'',
'1'
);
if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) == 1)
{
if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) == 1) {
list ($this->piVars['id']) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
// Set superglobal $_GET array and unset variables to avoid infinite looping.
@ -171,14 +156,12 @@ abstract class AbstractPlugin extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
// Try to load document.
$this->loadDocument();
} else {
if (TYPO3_DLOG)
{
if (TYPO3_DLOG) {
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\AbstractPlugin->loadDocument()] Failed to load document with record ID "'.$this->piVars['recordId'].'"', $this->extKey, SYSLOG_SEVERITY_ERROR);
}
}
} else {
if (TYPO3_DLOG)
{
if (TYPO3_DLOG) {
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\AbstractPlugin->loadDocument()] Invalid UID "'.$this->piVars['id'].'" or PID "'.$this->conf['pages'].'" for document loading', $this->extKey, SYSLOG_SEVERITY_ERROR);
}
}
@ -207,14 +190,11 @@ abstract class AbstractPlugin extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
*
* @return string HTML content wrapped, ready to return to the parent object.
*/
public function pi_wrapInBaseClass($content)
{
if (!$GLOBALS['TSFE']->config['config']['disableWrapInBaseClass'])
{
public function pi_wrapInBaseClass($content) {
if (!$GLOBALS['TSFE']->config['config']['disableWrapInBaseClass']) {
// Use get_class($this) instead of $this->prefixId for content wrapping because $this->prefixId is the same for all plugins.
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\DocumentList->current()] Invalid position "'.$this->position.'" for list element', $this->extKey, SYSLOG_SEVERITY_NOTICE);
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\DocumentList->getRecord([data])] No UID of list element to fetch full record', $this->extKey, SYSLOG_SEVERITY_NOTICE, $element);
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\DocumentList->move('.$_position.', '.$_steps.')] Invalid position "'.$position.'" for element moving', $this->extKey, SYSLOG_SEVERITY_WARNING);
// Check if moving given amount of steps is possible.
if (($position + $steps) <0
|| ($position + $steps) >= $this->count)
{
if (TYPO3_DLOG)
{
|| ($position + $steps) >= $this->count) {
if (TYPO3_DLOG) {
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\DocumentList->move('.$_position.', '.$_steps.')] Invalid steps "'.$steps.'" for moving element at position "'.$position.'"', $this->extKey, SYSLOG_SEVERITY_WARNING);
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\DocumentList->offsetGet('.$offset.')] Invalid offset "'.$offset.'" for list element', $this->extKey, SYSLOG_SEVERITY_NOTICE);
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\DocumentList->remove('.$_position.')] Invalid position "'.$position.'" for element removing', $this->extKey, SYSLOG_SEVERITY_WARNING);
* @return array The indizes of the removed elements
*/
public function removeRange($position, $length)
{
public function removeRange($position, $length) {
// Save parameter for logging purposes.
$_position = $position;
$position = intval($position);
if ($position <0
|| $position >= $this->count)
{
if (TYPO3_DLOG)
{
|| $position >= $this->count) {
if (TYPO3_DLOG) {
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\DocumentList->remove('.$_position.')] Invalid position "'.$position.'" for element removing', $this->extKey, SYSLOG_SEVERITY_WARNING);
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\DocumentList->sort('.$by.', ['.($asc ? 'TRUE' : 'FALSE').'])] Sorted list elements do not match unsorted elements', $this->extKey, SYSLOG_SEVERITY_ERROR);
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\DocumentList->__get('.$var.')] There is no getter function for property "'.$var.'"', $this->extKey, SYSLOG_SEVERITY_WARNING);
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\DocumentList->__set('.$var.', [data])] There is no setter function for property "'.$var.'"', $this->extKey, SYSLOG_SEVERITY_WARNING, $value);
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\DocumentTypeCheck->loadDocument()] Failed to load document with UID "'.$this->piVars['id'].'"', $this->extKey, SYSLOG_SEVERITY_WARNING);
}
}
} elseif (!empty($this->piVars['recordId']))
{
} elseif (!empty($this->piVars['recordId'])) {
// Get UID of document with given record identifier.
$result = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'tx_dlf_documents.uid',
@ -168,8 +154,7 @@ class DocumentTypeCheck
'',
'1'
);
if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) == 1)
{
if ($GLOBALS['TYPO3_DB']->sql_num_rows($result) == 1) {
list ($this->piVars['id']) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\DocumentTypeCheck->loadDocument()] Failed to load document with record ID "'.$this->piVars['recordId'].'"', $this->extKey, SYSLOG_SEVERITY_WARNING);
* @return mixed The decrypted value or NULL on error
*/
public static function decrypt($encrypted, $hash)
{
public static function decrypt($encrypted, $hash) {
$decrypted = NULL;
// Check for PHP extension "mcrypt".
if (!extension_loaded('mcrypt'))
{
if (TYPO3_DLOG)
{
if (!extension_loaded('mcrypt')) {
if (TYPO3_DLOG) {
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\Helper->decrypt('.$encrypted.', '.$hash.')] PHP extension "mcrypt" not available', self::$extKey, SYSLOG_SEVERITY_WARNING);
}
return;
}
if (empty($encrypted)
|| empty($hash))
{
if (TYPO3_DLOG)
{
|| empty($hash)) {
if (TYPO3_DLOG) {
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\Helper->decrypt('.$encrypted.', '.$hash.')] Invalid parameters given for decryption', self::$extKey, SYSLOG_SEVERITY_ERROR);
}
return;
}
if (empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']))
{
if (TYPO3_DLOG)
{
if (empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
if (TYPO3_DLOG) {
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\Helper->decrypt('.$encrypted.', '.$hash.')] No encryption key set in TYPO3 configuration', self::$extKey, SYSLOG_SEVERITY_ERROR);
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\Helper->decrypt('.$encrypted.', '.$hash.')] Invalid hash "'.$hash.'" given for decryption', self::$extKey, SYSLOG_SEVERITY_WARNING);
}
return;
@ -199,21 +174,16 @@ class Helper
*
* @return array Array with encrypted string and control hash
*/
public static function encrypt($string)
{
public static function encrypt($string) {
// Check for PHP extension "mcrypt".
if (!extension_loaded('mcrypt'))
{
if (TYPO3_DLOG)
{
if (!extension_loaded('mcrypt')) {
if (TYPO3_DLOG) {
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\Helper->encrypt('.$string.')] PHP extension "mcrypt" not available', self::$extKey, SYSLOG_SEVERITY_WARNING);
}
return;
}
if (empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']))
{
if (TYPO3_DLOG)
{
if (empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
if (TYPO3_DLOG) {
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\Helper->encrypt('.$string.')] No encryption key set in TYPO3 configuration', self::$extKey, SYSLOG_SEVERITY_ERROR);
}
return;
@ -234,8 +204,7 @@ class Helper
*/
public static function getBeUser() {
if (TYPO3_MODE === 'FE'
|| TYPO3_MODE === 'BE')
{
|| TYPO3_MODE === 'BE') {
// Initialize backend session with CLI user's rights.
* @return \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication Instance of \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication or NULL on failure
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\Helper->getIndexName('.$_uid.', '.$table.', '.$_pid.')] No "index_name" with UID "'.$uid.'" and PID "'.$pid.'" found in table "'.$table.'"', self::$extKey, SYSLOG_SEVERITY_WARNING);
}
return '';
@ -393,24 +346,20 @@ class Helper
*
* @return string "uid" for the given index_name
*/
public static function getIdFromIndexName($index_name, $table, $pid = -1)
{
public static function getIdFromIndexName($index_name, $table, $pid = -1) {
\TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[\Kitodo\Dlf\Common\Helper->getIdFromIndexName('.$_index_name.', '.$table.', '.$_pid.')] No UID for given "index_name" "'.$index_name.'" and PID "'.$pid.'" found in table "'.$table.'"', self::$extKey, SYSLOG_SEVERITY_WARNING);
}
return '';
@ -447,48 +394,38 @@ class Helper
*
* @return string Localized full name of language or unchanged input