/**
* Replace string with tags that reference fields
*
* @param string $text Text to process
*
* @return string Text with tags replace
*/
protected function parseFieldTags($text)
{
$ret = $text;
// Replace [ITEM:ID] in the URL with the item's key value (usually:
// the auto-incrementing numeric ID)
$keyfield = $this->item->getKeyName();
$replace = $this->item->{$keyfield};
$ret = str_replace('[ITEM:ID]', $replace, $ret);
// Replace the [ITEMID] in the URL with the current Itemid parameter
$ret = str_replace('[ITEMID]', $this->form->getContainer()->input->getInt('Itemid', 0), $ret);
// Replace other field variables in the URL
$fields = $this->item->getTableFields();
foreach ($fields as $fielddata) {
$fieldname = $fielddata->Field;
if (empty($fieldname)) {
$fieldname = $fielddata->column_name;
}
$search = '[ITEM:' . strtoupper($fieldname) . ']';
$replace = $this->item->{$fieldname};
if (!is_string($replace)) {
continue;
}
$ret = str_replace($search, $replace, $ret);
}
return $ret;
}