Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 2291856

Browse files
committed
parameter handling and versioning
1 parent 6426aa9 commit 2291856

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

system/modules/short_urls/dca/tl_short_urls.php

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'config' => array
2020
(
2121
'dataContainer' => 'Table',
22-
/*'ptable' => 'tl_page',*/
22+
'enableVersioning' => true,
2323
'sql' => array
2424
(
2525
'keys' => array
@@ -100,7 +100,7 @@
100100
'exclude' => true,
101101
'search' => true,
102102
'inputType' => 'text',
103-
'eval' => array('maxlength'=>255, 'mandatory'=>true,'tl_class'=>'w50'),
103+
'eval' => array('maxlength'=>255, 'mandatory'=>true, 'decodeEntities'=>true, 'tl_class'=>'w50'),
104104
'load_callback' => array(array('tl_short_urls', 'loadName')),
105105
'save_callback' => array( array('tl_short_urls', 'validateName') ),
106106
'sql' => "varchar(255) NOT NULL default ''"
@@ -174,6 +174,20 @@ class tl_short_urls extends Backend
174174
*/
175175
public function loadName($varValue, DataContainer $dc)
176176
{
177+
// check for query parameters
178+
if (strpos($varValue, '?') !== false)
179+
{
180+
$pos = strpos($varValue, '?');
181+
$url = substr($varValue, 0, $pos);
182+
$par = substr($varValue, $pos + 1);
183+
184+
if ($par)
185+
{
186+
parse_str($par, $arrParameters);
187+
return rawurldecode($url) . '?' . http_build_query($arrParameters);
188+
}
189+
}
190+
177191
return rawurldecode($varValue);
178192
}
179193

@@ -187,6 +201,20 @@ public function loadName($varValue, DataContainer $dc)
187201
*/
188202
public function validateName($varValue, DataContainer $dc)
189203
{
204+
// check for query parameters
205+
if (strpos($varValue, '?') !== false)
206+
{
207+
$pos = strpos($varValue, '?');
208+
$url = substr($varValue, 0, $pos);
209+
$par = substr($varValue, $pos + 1);
210+
211+
if ($par)
212+
{
213+
parse_str($par, $arrParameters);
214+
return implode('/', array_map('rawurlencode', explode('/', rawurldecode($url)))) . '?' . http_build_query($arrParameters);
215+
}
216+
}
217+
190218
$varValue = rawurldecode($varValue);
191219
$this->validate($varValue, $dc->activeRecord->domain);
192220
return implode('/', array_map('rawurlencode', explode('/', $varValue)));

0 commit comments

Comments
 (0)