diff --git a/Classes/Controller/AliasesController.php b/Classes/Controller/AliasesController.php index fd2c7d72..cfd64eb2 100644 --- a/Classes/Controller/AliasesController.php +++ b/Classes/Controller/AliasesController.php @@ -160,6 +160,7 @@ protected function doesAliasExistsForAnotherRecord($aliasValue) { $query->equals('valueAlias', $aliasValue), $query->equals('tablename', $alias->getTablename()), $query->equals('lang', $alias->getLang()), + $query->equals('pageId', $alias->getPageId()), $query->logicalNot($query->equals('uid', (int)$alias->getUid())) ))); @@ -258,6 +259,7 @@ protected function processSelectedAlias($selectedAlias) { $query->matching(count($conditons) > 1 ? $query->logicalAnd($conditons) : reset($conditons)); $query->setOrderings(array( 'valueId' => QueryInterface::ORDER_ASCENDING, + 'pageId' => QueryInterface::ORDER_ASCENDING, 'lang' => QueryInterface::ORDER_ASCENDING, )); diff --git a/Classes/Decoder/UrlDecoder.php b/Classes/Decoder/UrlDecoder.php index 04db5120..4ed084ca 100644 --- a/Classes/Decoder/UrlDecoder.php +++ b/Classes/Decoder/UrlDecoder.php @@ -282,14 +282,15 @@ protected function checkMissingSlash() { * * @param array $configuration * @param string $value + * @param int $pageId * @return int|string */ - protected function convertAliasToId(array $configuration, $value) { + protected function convertAliasToId(array $configuration, $value, $pageId) { $result = (string)$value; // First, test if there is an entry in cache for the alias if ($configuration['useUniqueCache']) { - $cachedId = $this->getFromAliasCacheByAliasValue($configuration, $value); + $cachedId = $this->getFromAliasCacheByAliasValue($configuration, $value, $pageId); if (MathUtility::canBeInterpretedAsInteger($cachedId)) { $result = (int)$cachedId; } @@ -757,7 +758,7 @@ protected function decodeUrlParameterBlockUsingLookupTable(array $configuration, $result = FALSE; if (isset($configuration['lookUpTable'])) { - $value = $this->convertAliasToId($configuration['lookUpTable'], $getVarValue); + $value = $this->convertAliasToId($configuration['lookUpTable'], $getVarValue, $requestVariables['id']); if (!MathUtility::canBeInterpretedAsInteger($value) && $value === $getVarValue) { if ($configuration['lookUpTable']['enable404forInvalidAlias']) { $this->throw404('Could not map alias "' . $value . '" to an id.'); diff --git a/Classes/Domain/Model/Alias.php b/Classes/Domain/Model/Alias.php index 48cae949..0d653fab 100644 --- a/Classes/Domain/Model/Alias.php +++ b/Classes/Domain/Model/Alias.php @@ -48,6 +48,9 @@ class Alias extends AbstractEntity { /** @var int */ protected $valueId; + /** @var int */ + protected $pageId; + /** * @return int */ @@ -146,6 +149,20 @@ public function setValueId($valueId) { $this->valueId = $valueId; } + /** + * @return int + */ + public function getPageId() { + return $this->pageId; + } + + /** + * @param int $pageId + */ + public function setPageId($pageId) { + $this->pageId = $pageId; + } + /** * @return string */ diff --git a/Classes/EncodeDecoderBase.php b/Classes/EncodeDecoderBase.php index d1ca912d..e2f687f7 100644 --- a/Classes/EncodeDecoderBase.php +++ b/Classes/EncodeDecoderBase.php @@ -173,14 +173,16 @@ abstract protected function initializeConfiguration(); * * @param array $configuration * @param string $aliasValue + * @param int $pageId * @return int ID integer. If none is found: false */ - protected function getFromAliasCacheByAliasValue(array $configuration, $aliasValue) { + protected function getFromAliasCacheByAliasValue(array $configuration, $aliasValue, $pageId) { $row = $this->databaseConnection->exec_SELECTgetSingleRow('value_id', 'tx_realurl_uniqalias', 'value_alias=' . $this->databaseConnection->fullQuoteStr($aliasValue, 'tx_realurl_uniqalias') . ' AND field_alias=' . $this->databaseConnection->fullQuoteStr($configuration['alias_field'], 'tx_realurl_uniqalias') . ' AND field_id=' . $this->databaseConnection->fullQuoteStr($configuration['id_field'], 'tx_realurl_uniqalias') . ' AND tablename=' . $this->databaseConnection->fullQuoteStr($configuration['table'], 'tx_realurl_uniqalias') . + (intval($pageId) > 0 ? ' AND page_id=' . intval($pageId) : '') . ' AND (expire=0 OR expire>' . time() . ')'); return (is_array($row) ? (int)$row['value_id'] : false); diff --git a/Classes/Encoder/UrlEncoder.php b/Classes/Encoder/UrlEncoder.php index ac4d5957..c6195c5d 100644 --- a/Classes/Encoder/UrlEncoder.php +++ b/Classes/Encoder/UrlEncoder.php @@ -477,7 +477,7 @@ protected function createUniqueAlias(array $configuration, $newAliasValue, $idVa $testNewAliasValue = $newAliasValue; while ($counter < $maxTry) { // If the test-alias did NOT exist, it must be unique and we break out - $foundId = $this->getFromAliasCacheByAliasValue($configuration, $testNewAliasValue); + $foundId = $this->getFromAliasCacheByAliasValue($configuration, $testNewAliasValue, $this->urlParameters['id']); if (!$foundId || $foundId == $idValue) { $uniqueAlias = $testNewAliasValue; break; @@ -1080,6 +1080,7 @@ protected function getFromAliasCache(array $configuration, $getVarValue, $langua ' AND field_id=' . $this->databaseConnection->fullQuoteStr($configuration['id_field'], 'tx_realurl_uniqalias') . ' AND tablename=' . $this->databaseConnection->fullQuoteStr($configuration['table'], 'tx_realurl_uniqalias') . ' AND lang=' . intval($languageUid) . + ' AND page_id=' . intval($this->urlParameters['id']) . ($onlyThisAlias ? ' AND value_alias=' . $this->databaseConnection->fullQuoteStr($onlyThisAlias, 'tx_realurl_uniqalias') : ' AND expire=0'), '', 'expire' ); @@ -1467,6 +1468,7 @@ protected function storeInAliasCache(array $configuration, $newAliasValue, $idVa AND field_id=' . $this->databaseConnection->fullQuoteStr($configuration['id_field'], 'tx_realurl_uniqalias') . ' AND tablename=' . $this->databaseConnection->fullQuoteStr($configuration['table'], 'tx_realurl_uniqalias') . ' AND lang=' . intval($languageUid) . ' + AND page_id=' . intval($this->urlParameters['id']) . ' AND expire=0', array('expire' => time() + 24 * 3600 * ($configuration['expireDays'] ? $configuration['expireDays'] : 60))); // Store new alias @@ -1476,7 +1478,8 @@ protected function storeInAliasCache(array $configuration, $newAliasValue, $idVa 'field_id' => $configuration['id_field'], 'value_alias' => $uniqueAlias, 'value_id' => $idValue, - 'lang' => $languageUid + 'lang' => $languageUid, + 'page_id' => $this->urlParameters['id'] ); $this->databaseConnection->exec_INSERTquery('tx_realurl_uniqalias', $insertArray); $aliasRecordId = $this->databaseConnection->sql_insert_id(); diff --git a/Configuration/TCA/tx_realurl_uniqalias.php b/Configuration/TCA/tx_realurl_uniqalias.php index 6015ea10..9c289663 100644 --- a/Configuration/TCA/tx_realurl_uniqalias.php +++ b/Configuration/TCA/tx_realurl_uniqalias.php @@ -83,6 +83,13 @@ 'eval' => 'required', ) ), + 'page_id' => array( + 'label' => 'LLL:EXT:realurl/Resources/Private/Language/locallang_db.xlf:tx_realurl_uniqalias.page_id', + 'config' => array( + 'type' => 'input', + 'eval' => 'required', + ) + ), ), 'types' => array( 'types' => array( diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index c69f7a3a..516f4567 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -63,6 +63,9 @@ Field value: + + Page id: + Alias successfully updated. @@ -111,6 +114,9 @@ Language + + Page id + Expires diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf index d7aa227e..3cb2f2e1 100644 --- a/Resources/Private/Language/locallang_db.xlf +++ b/Resources/Private/Language/locallang_db.xlf @@ -60,6 +60,9 @@ Field id: + + Page id: + RealURL URL Data diff --git a/Resources/Private/Templates/Aliases/Edit.html b/Resources/Private/Templates/Aliases/Edit.html index 4b8aa798..9cdccf5e 100644 --- a/Resources/Private/Templates/Aliases/Edit.html +++ b/Resources/Private/Templates/Aliases/Edit.html @@ -28,6 +28,12 @@

+ +
+

{alias.pageId}

+
+
diff --git a/Resources/Private/Templates/Aliases/Index.html b/Resources/Private/Templates/Aliases/Index.html index 69278fe2..38bc3db0 100644 --- a/Resources/Private/Templates/Aliases/Index.html +++ b/Resources/Private/Templates/Aliases/Index.html @@ -77,6 +77,7 @@

+ @@ -107,6 +108,7 @@

{alias.valueId} {d:languageFromId(language: alias.lang)} + {alias.pageId} diff --git a/ext_tables.sql b/ext_tables.sql index bb4175fb..58f6164e 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -11,6 +11,7 @@ CREATE TABLE tx_realurl_uniqalias ( value_id int(11) DEFAULT '0' NOT NULL, lang int(11) DEFAULT '0' NOT NULL, expire int(11) DEFAULT '0' NOT NULL, + page_id INT(11) DEFAULT '0' NOT NULL, PRIMARY KEY (uid), KEY parent (pid),