function plgSh404sefsimilarurls($context, &$rowContent, &$params, $page = 0) { if (!defined('SH404SEF_IS_RUNNING')) { // only do something if sh404sef is up and running return true; } // a little hack on the side : optionnally display the requested url // first get current sef url $shPageInfo =& Sh404sefFactory::getPageInfo(); // replace marker $rowContent->text = str_replace('{%sh404SEF_404_URL%}', htmlspecialchars(JURI::getInstance()->get('_uri'), ENT_COMPAT, 'UTF-8'), $rowContent->text); // now the similar urls $marker = 'sh404sefSimilarUrls'; // quick check for our marker: if (JString::strpos($rowContent->text, $marker) === false) { return true; } // get plugin params $plugin =& JPluginHelper::getPlugin('sh404sefcore', 'sh404sefsimilarurls'); // init params from plugin $pluginParams = new JRegistry(); $pluginParams->loadString($plugin->params); $matches = array(); // regexp to catch plugin requests $regExp = "#{" . $marker . "}#Us"; // search for our marker} if (preg_match_all($regExp, $rowContent->text, $matches, PREG_SET_ORDER) > 0) { // we have at least one match, we can search for similar urls $html = shGetSimilarUrls(JURI::getInstance()->getPath(), $pluginParams); // remove comment, so that nothing shows if (empty($html)) { $rowContent->text = preg_replace('/{sh404sefSimilarUrlsCommentStart}.*{sh404sefSimilarUrlsCommentEnd}/iUs', '', $rowContent->text); } else { // remove the comment markers themselves $rowContent->text = str_replace('{sh404sefSimilarUrlsCommentStart}', '', $rowContent->text); $rowContent->text = str_replace('{sh404sefSimilarUrlsCommentEnd}', '', $rowContent->text); } // now replace instances of the marker by similar urls list $rowContent->text = str_replace($matches[0], $html, $rowContent->text); } return true; }
function plgSh404sefsimilarurls(&$rowContent, &$params, $page = 0) { $marker = 'sh404sefSimilarUrls'; // quick check for our marker: if (JString::strpos($rowContent->text, $marker) === false) { return true; } // get plugin params $plugin =& JPluginHelper::getPlugin('sh404sefcore', 'sh404sefsimilarurls'); // init params from plugin $pluginParams = new JParameter($plugin->params); $matches = array(); // regexp to catch plugin requests $regExp = "#{" . $marker . "}#Us"; // search for our marker} if (preg_match_all($regExp, $rowContent->text, $matches, PREG_SET_ORDER) > 0) { // we have at least one match, we can search for similar urls $html = shGetSimilarUrls($pluginParams); // remove comment, so that nothing shows if (empty($html)) { $rowContent->text = preg_replace('/{sh404sefSimilarUrlsCommentStart}.*{sh404sefSimilarUrlsCommentEnd}/iU', '', $rowContent->text); } else { // remove the comment markers themselves $rowContent->text = str_replace('{sh404sefSimilarUrlsCommentStart}', '', $rowContent->text); $rowContent->text = str_replace('{sh404sefSimilarUrlsCommentEnd}', '', $rowContent->text); } // now replace instances of the marker by similar urls list $rowContent->text = str_replace($matches[0], $html, $rowContent->text); } // a little hack on the side : optionnally display the requested url // first get current sef url $shPageInfo =& shRouter::shPageInfo(); // replace marker $rowContent->text = str_replace('{%sh404SEF_404_URL%}', htmlspecialchars($shPageInfo->URI->getUrl()), $rowContent->text); return true; }