public static function onCCK_Field_LinkBeforeRenderContent($process, &$fields, &$storages, &$config = array()) { $itemId = @$process['itemId']; $name = $process['name']; $fieldname = $process['fieldname']; $location = $process['location']; if (isset($process['pk']) && $process['pk']) { $pk = $process['pk']; } else { $pk = isset($fields[$fieldname]) ? (int) $fields[$fieldname]->value : 0; } if (!$pk) { if (isset($process['matches']) && count($process['matches'][1])) { parent::g_setCustomVars($process, $fields, $name); } return; } if ($itemId == '-2') { $itemId = JFactory::getApplication()->input->get('Itemid'); $fieldname2 = $process['fieldname2']; if (isset($fields[$fieldname2])) { $itemId = (int) $fields[$fieldname2]->value; } } elseif ($itemId == '-3') { $itemId = JFactory::getApplication()->input->get('Itemid'); $itemIds = $process['fieldnames']; $items = explode('||', $itemIds); if (count($items)) { foreach ($items as $item) { if ($item != '') { $parts = explode('=', $item); if ($parts[1]) { $checks = json_decode($parts[0], true); $count = count($checks); $found = 0; if ($count) { foreach ($checks as $k => $v) { if (isset($fields[$k]) && $fields[$k]->value == $v) { $found++; } } } if ($found == $count) { $itemId = $parts[1]; break; } } } } } } $fields[$name]->link = JCck::callFunc_Array('plgCCK_Storage_Location' . $location, 'getRoute', array($pk, $process['sef'], $itemId, $config)); $target = $fields[$name]->typo_target; if ($fields[$name]->link) { if ($process['vars']) { $fields[$name]->link .= strpos($fields[$name]->link, '?') !== false ? '&' . $process['vars'] : '?' . $process['vars']; } if ($process['custom']) { $fields[$name]->link .= $process['custom'][0] == '#' ? $process['custom'] : (strpos($fields[$name]->link, '?') !== false ? '&' . $process['custom'] : '?' . $process['custom']); } JCckPluginLink::g_setHtml($fields[$name], $target); } if ($fields[$name]->typo) { $html = isset($fields[$name]->html) ? $fields[$name]->html : ''; if (strpos($fields[$name]->typo, $fields[$name]->{$target}) === false) { $fields[$name]->typo = $html; } else { $fields[$name]->typo = str_replace($fields[$name]->{$target}, $html, $fields[$name]->typo); } } if (isset($process['matches']) && count($process['matches'][1])) { parent::g_setCustomVars($process, $fields, $name); } }
public static function onCCK_Field_LinkBeforeRenderContent($process, &$fields, &$storages, &$config = array()) { $name = $process['name']; $fieldname = $process['fieldname']; $location = $process['location']; $pk = isset($fields[$fieldname]) ? (int) $fields[$fieldname]->value : 0; if (!$pk) { if (count($process['matches'][1])) { parent::g_setCustomVars($process, $fields, $name); } return; } $fields[$name]->link = JCck::callFunc_Array('plgCCK_Storage_Location' . $location, 'getRoute', array($pk, $process['sef'], $process['itemId'], $config)); $target = $fields[$name]->typo_target; if ($fields[$name]->link) { if ($process['vars']) { $fields[$name]->link .= strpos($fields[$name]->link, '?') !== false ? '&' . $process['vars'] : '?' . $process['vars']; } if ($process['custom']) { $fields[$name]->link .= $process['custom'][0] == '#' ? $process['custom'] : (strpos($fields[$name]->link, '?') !== false ? '&' . $process['custom'] : '?' . $process['custom']); } JCckPluginLink::g_setHtml($fields[$name], $target); } if ($fields[$name]->typo) { $fields[$name]->typo = str_replace($fields[$name]->{$target}, $fields[$name]->html, $fields[$name]->typo); } if (isset($process['matches']) && count($process['matches'][1])) { parent::g_setCustomVars($process, $fields, $name); } }