Пример #1
0
 /**
  * Will change the href value from <a> in the input string and turn it into an onclick event that will open a new window with the URL
  *
  * @param string $str The string to process. This should be a string already wrapped/including a <a> tag which will be modified to contain an onclick handler. Only the attributes "href" and "onclick" will be left.
  * @param string $winName Window name for the pop-up window
  * @param string $winParams Window parameters, see the default list for inspiration
  * @return string The processed input string, modified IF a <a> tag was found
  */
 public function pi_openAtagHrefInJSwindow($str, $winName = '', $winParams = 'width=670,height=500,status=0,menubar=0,scrollbars=1,resizable=1')
 {
     if (preg_match('/(.*)(<a[^>]*>)(.*)/i', $str, $match)) {
         $aTagContent = GeneralUtility::get_tag_attributes($match[2]);
         $onClick = 'vHWin=window.open(' . GeneralUtility::quoteJSvalue($this->frontendController->baseUrlWrap($aTagContent['href'])) . ',' . GeneralUtility::quoteJSvalue($winName ?: md5($aTagContent['href'])) . ',' . GeneralUtility::quoteJSvalue($winParams) . ');vHWin.focus();return false;';
         $match[2] = '<a href="#" onclick="' . htmlspecialchars($onClick) . '">';
         $str = $match[1] . $match[2] . $match[3];
     }
     return $str;
 }