예제 #1
0
 function __PrepareLinks(&$data)
 {
     $add_param = CAjax::GetSessionParam($this->componentID);
     $regexp_links = '/(<a[^>]*?>.*?<\\/a>)/is' . BX_UTF_PCRE_MODIFIER;
     $regexp_params = '/([\\w\\-]+)\\s*=\\s*([\\"\'])(.*?)\\2/is' . BX_UTF_PCRE_MODIFIER;
     $this->_checkPcreLimit($data);
     $arData = preg_split($regexp_links, $data, -1, PREG_SPLIT_DELIM_CAPTURE);
     $cData = count($arData);
     if ($cData < 2) {
         return;
     }
     $arIgnoreAttributes = array('onclick' => true, 'target' => true);
     $arSearch = array($add_param . '&', $add_param, 'AJAX_CALL=Y&', 'AJAX_CALL=Y');
     $bDataChanged = false;
     for ($iData = 1; $iData < $cData; $iData += 2) {
         if (!preg_match('/^<a([^>]*?)>(.*?)<\\/a>$/is' . BX_UTF_PCRE_MODIFIER, $arData[$iData], $match)) {
             continue;
         }
         $params = $match[1];
         if (!preg_match_all($regexp_params, $params, $arLinkParams)) {
             continue;
         }
         $strAdditional = ' ';
         $url_key = -1;
         $bIgnoreLink = false;
         foreach ($arLinkParams[0] as $pkey => $value) {
             if ($value == '') {
                 continue;
             }
             $param_name = strtolower($arLinkParams[1][$pkey]);
             if ($param_name === 'href') {
                 $url_key = $pkey;
             } elseif (isset($arIgnoreAttributes[$param_name])) {
                 $bIgnoreLink = true;
                 break;
             } else {
                 $strAdditional .= $value . ' ';
             }
         }
         if ($url_key >= 0 && !$bIgnoreLink) {
             $url = str_replace('&amp;', '&', $arLinkParams[3][$url_key]);
             $url = str_replace($arSearch, '', $url);
             if ($this->__isAjaxURL($url)) {
                 $real_url = $url;
                 $pos = strpos($url, '#');
                 if ($pos !== false) {
                     $real_url = substr($real_url, 0, $pos);
                 }
                 $real_url .= strpos($url, '?') === false ? '?' : '&';
                 $real_url .= $add_param;
                 $url_str = CAjax::GetLinkEx($real_url, $url, $match[2], 'comp_' . $this->componentID, $strAdditional, true, $this->bShadow);
                 $arData[$iData] = $url_str;
                 $bDataChanged = true;
             }
         }
     }
     if ($bDataChanged) {
         $data = implode('', $arData);
     }
 }
예제 #2
0
 public static function GetLink($url, $text, $container_id, $additional = '')
 {
     return CAjax::GetLinkEx($url, false, htmlspecialcharsbx($text), htmlspecialcharsbx($container_id), $additional);
 }