Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions controller/admin/toxid_setup_main.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function render()
$this->_aViewData['bToxidRedirect301ToStartpage'] = $oConf->getShopConfVar('bToxidRedirect301ToStartpage');
$this->_aViewData['toxidCacheTtl'] = $oConf->getShopConfVar('toxidCacheTtl');
$this->_aViewData['toxidError404Link'] = $oConf->getShopConfVar('toxidError404Link');
$this->_aViewData['aToxidNotFoundUrl'] = $oConf->getShopConfVar('aToxidNotFoundUrl');

return parent::render();
}
Expand Down Expand Up @@ -50,5 +51,6 @@ public function save()
$oConf->saveShopConfVar('bl', 'toxidDontRewriteUrls', $aParams['toxidDontRewriteUrls'], $sShopId, self::CONFIG_MODULE_NAME);
$oConf->saveShopConfVar('bl', 'bToxidDontPassPostVarsToCms', $aParams['bToxidDontPassPostVarsToCms'], $sShopId, self::CONFIG_MODULE_NAME);
$oConf->saveShopConfVar('bl', 'bToxidRedirect301ToStartpage', $aParams['bToxidRedirect301ToStartpage'], $sShopId, self::CONFIG_MODULE_NAME);
$oConf->saveShopConfVar('arr', 'aToxidNotFoundUrl', $aParams['aToxidNotFoundUrl'], $sShopId, self::CONFIG_MODULE_NAME);
}
}
38 changes: 36 additions & 2 deletions core/toxidcurl.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ class toxidCurl
* @var string
*/
protected $_sFileExtensionValuesForNoRewrite = null;
/**
* stores not found url by active language
*
* @var array
*/
protected $_aNotFoundUrl = null;
private $_initialized = false;
private $smartyParser;
/**
Expand Down Expand Up @@ -375,6 +381,8 @@ protected function _getRemoteContent($sUrl)
$sUrl = rtrim($sUrl, '&') . "&{$params}";
}

$sUrl = rtrim($sUrl, '&?');

curl_setopt($curl_handle, CURLOPT_URL, $sUrl);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
if (!$this->isToxidCurlPage()) {
Expand Down Expand Up @@ -586,14 +594,36 @@ protected function _getFileExtensionValuesForNoRewrite()
return $this->_sFileExtensionValuesForNoRewrite;
}

/**
* returns typo3 URL for not found page
*
* @param int $iLangId
* @param bool $blReset reset object value, and get url again
*
* @return null|string
*/
protected function _getToxidNotFoundUrl($iLangId = null, $blReset = false)
{
if ($this->_aNotFoundUrl === null || $blReset) {
$this->_aNotFoundUrl = $this->getConfig()->getConfigParam('aToxidNotFoundUrl');
}

if ($iLangId === null) {
$iLangId = oxRegistry::getLang()->getBaseLanguage();
}

return array_key_exists($iLangId, (array)$this->_aNotFoundUrl) ? $this->_aNotFoundUrl[$iLangId] : null;
}

/**
* Handles HTTP status codes for toxid response
*
* @param $sUrl
* @param $notFound404
*
* @return array
*/
protected function getRemoteContentAndHandleStatusCodes($sUrl)
private function getRemoteContentAndHandleStatusCodes($sUrl, $notFound404 = false)
{
$aPage = $this->_getRemoteContent($sUrl);
switch ($aPage['info']['http_code']) {
Expand All @@ -603,6 +633,10 @@ protected function getRemoteContentAndHandleStatusCodes($sUrl)
oxRegistry::getUtils()->showMessageAndExit('');
break;
case 404:
if($this->_getToxidNotFoundUrl() && !$notFound404) {
$aPage = $this->getRemoteContentAndHandleStatusCodes($this->_getToxidNotFoundUrl(), true);
break;
}
$this->handleError(404, $aPage['info']['url']);
break;
case 301:
Expand Down Expand Up @@ -712,7 +746,7 @@ private function getConfig()
* @param integer $statusCode
* @param string $sUrl
*/
protected function handleError($statusCode, $sUrl = '')
private function handleError($statusCode, $sUrl = '')
{
$this->cmsAvailable = false;

Expand Down
3 changes: 2 additions & 1 deletion views/admin/de/toxid_admin_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
'TOXID_SOURCE_SSL' => 'CMS SSL-URL',
'TOXID_SEO_SNIPPET' => 'URL Identifier / SEO-Snippet',
'TOXID_SEARCH_URL' => 'URL zum Aufruf der Suche (optional)',
'TOXID_NOT_FOUND_URL' => 'Not found URL (optional)',
'TOXID_PARAM' => 'TOXID URL-Parameter',
'TOXID_DONT_REWRITE' => 'URLs nicht umschreiben - Aufrufe führen auf externe CMS-Seite',
'TOXID_DONT_PASSTHROUGH' => 'POST-Parameter <b><u>nicht</u></b> an CMS durchreichen',
'TOXID_DONT_REWRITE_REL_URLS' => 'URLs für bestimmte "rel" Attributwerte nicht umschreiben (kommaseparierte Liste)',
'TOXID_DONT_REWRITE_URLS_WITH_FILE_EXTENSIONS' => 'URLs für bestimmte Dateiendungen nicht umschreiben (kommaseparierte Liste)',
'TOXID_ERROR_404_LINK' => 'User will be redirected to this URL on 404 error (optional)',
'TOXID_ERROR_404_LINK' => 'User will be redirected to this URL on 404 error, when no other 404 url is specified for specific language (optional)',
'TOXID_REWRITE_URLENCODED' => 'URLs die "url encoded" sind umschreiben (URL muss sich im "src" attribut befindet)',
'TOXID_REDIRECT_301_TO_STARTPAGE' => 'Auf Startseite weiterleiten wenn das CMS den HTTP-Statuscode 301 liefert',
'TOXID_LOOKING_FOR' => 'gesucht!',
Expand Down
3 changes: 2 additions & 1 deletion views/admin/en/toxid_admin_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
'TOXID_SOURCE_SSL' => 'CMS SSL-URL',
'TOXID_SEO_SNIPPET' => 'URL Identifier / SEO-Snippet',
'TOXID_SEARCH_URL' => 'URL to call the searchpage (optional)',
'TOXID_NOT_FOUND_URL' => 'Not found URL (optional)',
'TOXID_PARAM' => 'TOXID URL parameter',
'TOXID_DONT_REWRITE' => 'Don\'t rewrite the URLs - Users will linked to the external site.',
'TOXID_DONT_PASSTHROUGH' => '<b><u>Don\'t</u></b> pass POST parameters to CMS',
'TOXID_DONT_REWRITE_REL_URLS' => 'Don\'t rewrite the URLs for particular "rel" attribute values (comma-separated list)',
'TOXID_DONT_REWRITE_URLS_WITH_FILE_EXTENSIONS' => 'Don\'t rewrite the URLs for particular file extensions (comma-separated list)',
'TOXID_ERROR_404_LINK' => 'User will be redirected to this URL on 404 error (optional)',
'TOXID_ERROR_404_LINK' => 'User will be redirected to this URL on 404 error, when no other 404 url is specified for specific language (optional)',
'TOXID_REWRITE_URLENCODED' => 'Rewrite URLs that are "url encoded" (URL must be contained in the "src" attribute)',
'TOXID_REDIRECT_301_TO_STARTPAGE' => 'Redirect to home page if the CMS returns the HTTP status code 301',
'TOXID_LOOKING_FOR' => 'Support us with PayPal!',
Expand Down
8 changes: 8 additions & 0 deletions views/admin/tpl/toxid_setup_main.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ function _groupExp(el) {
<input type="text" name="editval[aToxidCurlSeoSnippets][[{ $lang }]]" value="[{$aToxidCurlSeoSnippets.$lang}]">
</td>
</tr>
<tr>
<td valign="top" class="edittext">
[{oxmultilang ident="TOXID_NOT_FOUND_URL"}]:
</td>
<td valign="top" class="edittext">
<input type="text" name="editval[aToxidNotFoundUrl][[{ $lang }]]" value="[{$aToxidNotFoundUrl.$lang}]">
</td>
</tr>
</table>
</fieldset>
[{/foreach}]
Expand Down