当前位置: 首页>>代码示例>>PHP>>正文


PHP PMF_String::preg_replace方法代码示例

本文整理汇总了PHP中PMF_String::preg_replace方法的典型用法代码示例。如果您正苦于以下问题:PHP PMF_String::preg_replace方法的具体用法?PHP PMF_String::preg_replace怎么用?PHP PMF_String::preg_replace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PMF_String的用法示例。


在下文中一共展示了PMF_String::preg_replace方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setRelationLinks

 /**
  * Verlinkt einen Artikel dynamisch mit der Suche �ber die �bergebenen Schl�sselw�rter
  *
  * @param    string     $strHighlight
  * @param    string     $strSource
  * @param    integer    $intCount
  * @return   string
  * @author   Marco Enders <marco@minimarco.de>
  * @author   Thorsten Rinne <thorsten@phpmyfaq.de>
  */
 public function setRelationLinks($strHighlight, $strSource, $intCount = 0)
 {
     global $in_content;
     $x = 0;
     $arrMatch = array();
     PMF_String::preg_match_all('/(<a[^<>]*?>.*?<\\/a>)|(<.*?>)/is', $strSource, $arrMatch);
     $strSource = PMF_String::preg_replace('/(<a[^<>]*?>.*?<\\/a>)|(<.*?>)/is', '~+*# replaced html #*+~', $strSource);
     $x = $x + PMF_String::preg_match('/(' . preg_quote($strHighlight) . ')/ims', $strSource);
     $strSource = PMF_String::preg_replace('/(' . preg_quote($strHighlight) . ')/ims', '<a href="index.php?action=search&search=' . $strHighlight . '" title="Insgesamt ' . $intCount . ' Artikel zu diesem Schlagwort (' . $strHighlight . ') vorhanden. Jetzt danach suchen..." class="relation">$1</a>', $strSource);
     foreach ($arrMatch[0] as $html) {
         $strSource = PMF_String::preg_replace('/' . preg_quote('~+*# replaced html #*+~') . '/', $html, $strSource, 1);
     }
     if ($x == 0) {
         $in_content = false;
     } else {
         $in_content = true;
     }
     return $strSource;
 }
开发者ID:noon,项目名称:phpMyFAQ,代码行数:29,代码来源:Relation.php

示例2: _checkContent

 /**
  * This function checks the content
  *
  * @param  string $content Content to check
  * 
  * @return string
  */
 private function _checkContent($content)
 {
     // Security measure: avoid the injection of php/shell-code
     $search = array('#<\\?php#i', '#\\{$\\{#', '#<\\?#', '#<\\%#', '#`#', '#<script[^>]+php#mi');
     $phppattern1 = "&lt;?php";
     $phppattern2 = "&lt;?";
     $replace = array($phppattern1, '', $phppattern2, '', '');
     // Hack: Backtick Fix
     $content = str_replace('`', '&acute;', $content);
     foreach ($content as $var => $val) {
         if (is_array($val)) {
             foreach ($val as $key => $value) {
                 $content[$var][$key] = PMF_String::preg_replace($search, $replace, $value);
             }
         } else {
             $content[$var] = PMF_String::preg_replace($search, $replace, $val);
         }
     }
     return $content;
 }
开发者ID:jr-ewing,项目名称:phpMyFAQ,代码行数:27,代码来源:Template.php

示例3: makeShorterText

 /**
  * Shortens a string for a given number of words
  * 
  * @param  string  $str  String  
  * @param  integer $char Characters
  * 
  * @return string
  * 
  * @todo This function doesn't work with Chinese, Japanese and Korean
  *       because they don't have spaces as word delimiters
  */
 public static function makeShorterText($str, $char)
 {
     $str = PMF_String::preg_replace('/\\s+/u', ' ', $str);
     $arrStr = explode(' ', $str);
     $shortStr = '';
     $num = count($arrStr);
     if ($num > $char) {
         for ($j = 0; $j <= $char; $j++) {
             $shortStr .= $arrStr[$j] . ' ';
         }
         $shortStr .= '...';
     } else {
         $shortStr = $str;
     }
     return $shortStr;
 }
开发者ID:jr-ewing,项目名称:phpMyFAQ,代码行数:27,代码来源:Utils.php

示例4: setHTMLMessage

 /**
  * Set an HTML message providing also a plain text alternative message,
  * if not already set using the $messageAlt property.
  * Besides it is possible to put resources as inline attachments
  *
  * @param  string $message     HTML message.
  * @param  bool   $sanitize Strip out potentially unsecured HTML tags. Defaults to false.
  * @param  bool   $inline   Add images as inline attachments. Defaults to false.
  *
  * @return void
  */
 public function setHTMLMessage($message, $sanitize = false, $inline = false)
 {
     // No Javascript at all
     // 1/2. <script blahblahblah>blahblahblah</tag>
     $message = PMF_String::preg_replace('/(<script[^>]*>.*<\\/script>)|<script[^\\/]*\\/>|<script[^\\/]*>/is', '', $message);
     // Cleanup potentially dangerous HTML tags:
     if ($sanitize) {
         // 1/2. <tag blahblahblah>blahblahblah</tag>
         $message = PMF_String::preg_replace('/<(applet|embed|head|meta|object|style|title)[^>]*>.*<\\/\\1>/is', '', $message);
         // 2/2. <tag blahblahblah />
         $message = PMF_String::preg_replace('/<(applet|embed|head|meta|object|style|title)[^\\/]*\\/>/is', '', $message);
     }
     if ($inline) {
         trigger_error("<strong>Mail Class</strong>: inline option is not implemented yet.", E_USER_ERROR);
     }
     // Set the HTML text as the main message
     $this->message = trim($message);
     // If no alternative text has been provided yet, use just
     // the HTML message stripping any HTML tag
     if (empty($this->messageAlt)) {
         $this->messageAlt = trim(strip_tags($this->message));
     }
 }
开发者ID:kapljr,项目名称:Jay-Kaplan-Farmingdale-BCS-Projects,代码行数:34,代码来源:Mail.php

示例5: preg_replace

 /**
  * Search and replace by a regexp
  * @param string|array $pattern
  * @param string|array $replacement
  * @param string|array $subject
  * @param int $limit
  * @param int &$count
  * 
  * @return array|string|null
  */
 public static function preg_replace($pattern, $replacement, $subject, $limit = -1, &$count = 0)
 {
     return self::$instance->preg_replace($pattern, $replacement, $subject, $limit, $count);
 }
开发者ID:noon,项目名称:phpMyFAQ,代码行数:14,代码来源:String.php

示例6: renderUrl

 /**
  * Render url for a given page
  *
  * @param string  $url  url
  * @param integer $page page number
  *
  * @return string
  */
 protected function renderUrl($url, $page)
 {
     if ($this->useRewrite) {
         $url = sprintf($this->rewriteUrl, $page);
     } else {
         $cleanedUrl = PMF_String::preg_replace(array('$&(amp;|)' . $this->pageParamName . '=(\\d+)$'), '', $url);
         $url = sprintf('%s&amp;%s=%d', $cleanedUrl, $this->pageParamName, $page);
     }
     return $url;
 }
开发者ID:kapljr,项目名称:Jay-Kaplan-Farmingdale-BCS-Projects,代码行数:18,代码来源:Pagination.php

示例7: renderUrl

 /**
  * Render url for a given page
  * 
  * @param string  $url  url
  * @param integer $page page number
  * 
  * @return string
  */
 protected function renderUrl($url, $page)
 {
     $cleanedUrl = PMF_String::preg_replace(array('$&(amp;|)' . $this->pageParamName . '=(\\d+)$'), '', $url);
     $url = sprintf('%s&amp;%s=%d', $cleanedUrl, $this->pageParamName, $page);
     $link = new PMF_Link($url);
     $link->itemTitle = $this->seoName;
     return $link->toString();
 }
开发者ID:atlcurling,项目名称:tkt,代码行数:16,代码来源:Pagination.php

示例8: printf

        // show category name in actual language
        print '<td>';
        if ($cat['lang'] != $LANGCODE) {
            // translate category
            printf('<a href="%s?action=translatecategory&amp;cat=%s&amp;trlang=%s" title="%s"><span title="%s" class="icon-share"></span></a></a>', $currentLink, $cat['id'], $LANGCODE, $PMF_LANG['ad_categ_translate'], $PMF_LANG['ad_categ_translate']);
        }
        printf("&nbsp;%s<strong>%s</strong>", $indent, $catname);
        print "</td>\n";
        // get languages in use for categories
        $id_languages = $category->getCategoryLanguagesTranslated($cat["id"]);
        foreach ($all_lang as $lang => $language) {
            if ($language == $currentLanguage) {
                continue;
            }
            if (array_key_exists($language, $id_languages)) {
                $spokenLanguage = PMF_String::preg_replace('/\\(.*\\)/', '', $id_languages[$language]);
                printf('<td title="%s: %s">', $PMF_LANG['ad_categ_titel'], $spokenLanguage);
                printf('<span title="%s: %s" class="label label-success"><i class="icon-check icon-white"></i></span></td>', $PMF_LANG['ad_categ_titel'], $spokenLanguage);
            } else {
                printf('<td><a href="%s?action=translatecategory&amp;cat=%s&amp;trlang=%s" title="%s">', $currentLink, $cat['id'], $lang, $PMF_LANG['ad_categ_translate']);
                printf('<span title="%s" class="label label-inverse"><i class="icon-share icon-white"></i></span></a>', $PMF_LANG['ad_categ_translate']);
            }
            print "</td>\n";
        }
        print "</tr>\n";
    }
    ?>
        </tbody>
        </table>
<?php 
    printf('<p>%s</p>', $PMF_LANG['ad_categ_remark_overview']);
开发者ID:kapljr,项目名称:Jay-Kaplan-Farmingdale-BCS-Projects,代码行数:31,代码来源:category.showstructure.php

示例9: getHighlightedBannedWords

/**
 * This function returns the passed content with HTML hilighted banned words.
 *
 * @param   string  $content
 * @return  string
 * @access  public
 * @author  Matteo Scaramuccia <matteo@phpmyfaq.de>
 */
function getHighlightedBannedWords($content)
{
    $bannedHTMLHiliWords = array();
    $bannedWords = getBannedWords();
    // Build the RegExp array
    foreach ($bannedWords as $word) {
        $bannedHTMLHiliWords[] = "/(" . quotemeta($word) . ")/ism";
    }
    // Use the CSS "highlight" class to highlight the banned words
    if (count($bannedHTMLHiliWords) > 0) {
        return PMF_String::preg_replace($bannedHTMLHiliWords, "<span class=\"highlight\">\\1</span>", $content);
    } else {
        return $content;
    }
}
开发者ID:atlcurling,项目名称:tkt,代码行数:23,代码来源:functions.php

示例10: renderUrl

 /**
  * Render url for a given page
  * 
  * @param string  $url  url
  * @param integer $page page number
  * 
  * @return string
  */
 protected function renderUrl($url, $page)
 {
     switch ($this->urlStyle) {
         case self::URL_STYLE_REWRITE:
             $cleanedUrl = PMF_String::preg_replace(array('$/' . $this->pageParamName . '/(\\d+)$', '$//$'), "", $this->baseUrl);
             $url = "{$cleanedUrl}/{$this->pageParamName}/{$page}";
             break;
         case self::URL_STYLE_DEFAULT:
         default:
             $cleanedUrl = PMF_String::preg_replace(array('$&(amp;|)' . $this->pageParamName . '=(\\d+)$'), "", $this->baseUrl);
             $url = "{$cleanedUrl}&amp;{$this->pageParamName}={$page}";
             break;
     }
     return $url;
 }
开发者ID:nosch,项目名称:phpMyFAQ,代码行数:23,代码来源:Pagination.php

示例11: getSEOItemTitle

 /**
  * Returns a search engine optimized title
  *
  * @param string $title
  *
  * @return string
  */
 public function getSEOItemTitle($title = '')
 {
     if ('' === $title) {
         $title = $this->itemTitle;
     }
     $itemTitle = trim($title);
     // Lower the case (aesthetic)
     $itemTitle = PMF_String::strtolower($itemTitle);
     // Use '_' for some other characters for:
     // 1. avoiding regexp match break;
     // 2. improving the reading.
     $itemTitle = str_replace(array('-', "'", '/', '&#39'), '_', $itemTitle);
     // 1. Remove any CR LF sequence
     // 2. Use a '-' for the words separation
     $itemTitle = PMF_String::preg_replace('/\\s/m', '-', $itemTitle);
     // Hack: remove some chars for having a better readable title
     $itemTitle = str_replace(array('+', ',', ';', ':', '.', '?', '!', '"', '(', ')', '[', ']', '{', '}', '<', '>'), '', $itemTitle);
     // Hack: move some chars to "similar" but plain ASCII chars
     $itemTitle = str_replace(array('à', 'è', 'é', 'ì', 'ò', 'ù', 'ä', 'ö', 'ü', 'ß', 'Ä', 'Ö', 'Ü', 'č', 'ę', 'ė', 'į', 'š', 'ų', 'ū', 'ž'), array('a', 'e', 'e', 'i', 'o', 'u', 'ae', 'oe', 'ue', 'ss', 'Ae', 'Oe', 'Ue', 'c', 'e', 'e', 'i', 's', 'u', 'u', 'z'), $itemTitle);
     // Clean up
     $itemTitle = PMF_String::preg_replace('/-[\\-]+/m', '-', $itemTitle);
     return rawurlencode($itemTitle);
 }
开发者ID:ae120,项目名称:phpMyFAQ,代码行数:30,代码来源:Link.php

示例12: foreach

            $templateVars['allLanguages'][] = $language;
        }
    }
    foreach ($category->catTree as $cat) {
        $currentRow = array('catname' => $cat['name'], 'indent' => str_repeat('&nbsp;&nbsp;&nbsp;', $cat['indent']), 'translations' => array(), 'renderTranslateButton' => $cat['lang'] != $LANGCODE, 'translateButtonUrl' => sprintf('?action=translatecategory&cat=%s&trlang=%s', $cat['id'], $LANGCODE));
        // category translated in this language?
        if ($cat['lang'] != $LANGCODE) {
            $currentRow['catname'] .= ' (' . $languageCodes[strtoupper($cat['lang'])] . ')';
        }
        // get languages in use for categories
        $id_languages = $category->getCategoryLanguagesTranslated($cat["id"]);
        foreach ($all_lang as $lang => $language) {
            if ($language == $currentLanguage) {
                continue;
            }
            $currentTranslation = array('isTranslated' => false, 'tooltip' => '');
            if (array_key_exists($language, $id_languages)) {
                $currentTranslation['isTranslated'] = true;
                $currentTranslation['tooltip'] = sprintf('%s: %s', $PMF_LANG['ad_categ_titel'], PMF_String::preg_replace('/\\(.*\\)/', '', $id_languages[$language]));
            } else {
                $currentTranslation['translateButtonUrl'] = sprintf('?action=translatecategory&cat=%s&trlang=%s', $cat['id'], $lang);
                $currentTranslation['tooltip'] = $PMF_LANG['ad_categ_translate'];
            }
            $currentRow['translations'][] = $currentTranslation;
        }
        $templateVars['categoryTable'][] = $currentRow;
    }
    $twig->loadTemplate('category/showstructure.twig')->display($templateVars);
} else {
    require 'noperm.php';
}
开发者ID:maggiofrancesco,项目名称:phpMyFAQ,代码行数:31,代码来源:category.showstructure.php

示例13: quoted_printable_encode

 function quoted_printable_encode($return = '')
 {
     // Ersetzen der lt. RFC 1521 noetigen Zeichen
     $return = PMF_String::preg_replace('/([^\\t\\x20\\x2E\\041-\\074\\076-\\176])/ie', "sprintf('=%2X',ord('\\1'))", $return);
     $return = PMF_String::preg_replace('!=\\ ([A-F0-9])!', '=0\\1', $return);
     // Einfuegen von QP-Breaks (=\r\n)
     if (PMF_String::strlen($return) > 75) {
         $length = PMF_String::strlen($return);
         $offset = 0;
         do {
             $step = 76;
             $add_mode = $offset + $step < $length ? 1 : 0;
             $auszug = PMF_String::substr($return, $offset, $step);
             if (PMF_String::preg_match('!\\=$!', $auszug)) {
                 $step = 75;
             }
             if (PMF_String::preg_match('!\\=.$!', $auszug)) {
                 $step = 74;
             }
             if (PMF_String::preg_match('!\\=..$!', $auszug)) {
                 $step = 73;
             }
             $auszug = PMF_String::substr($return, $offset, $step);
             $offset += $step;
             $schachtel .= $auszug;
             if (1 == $add_mode) {
                 $schachtel .= '=' . "\r\n";
             }
         } while ($offset < $length);
         $return = $schachtel;
     }
     $return = PMF_String::preg_replace('!\\.$!', '. ', $return);
     return PMF_String::preg_replace('!(\\r\\n|\\r|\\n)$!', '', $return) . "\r\n";
 }
开发者ID:nosch,项目名称:phpMyFAQ,代码行数:34,代码来源:functions.php

示例14: printf

        $cat['lang'] == $LANGCODE ? $catname = $cat['name'] : ($catname = $cat['name'] . ' (' . $languageCodes[strtoupper($cat['lang'])] . ')');
        $cat['lang'] == $LANGCODE ? $desc = "sscDesc" : ($desc = "sscDescNA");
        // show category name in actual language
        printf("<td class=\"%s\">", $desc);
        if ($cat['lang'] != $LANGCODE) {
            // translate category
            printf('<a href="%s?action=translatecategory&amp;cat=%s&amp;trlang=%s" title="%s"><img src="images/translate2.gif" width="13" height="16" border="0" title="%s" alt="%s" /></a>', $currentLink, $cat['id'], $LANGCODE, $PMF_LANG['ad_categ_translate'], $PMF_LANG['ad_categ_translate'], $PMF_LANG['ad_categ_translate']);
        }
        printf("&nbsp;%s<strong>&middot; %s</strong>", $indent, $catname);
        print "</td>\n";
        // get languages in use for categories
        $id_languages = $category->getCategoryLanguagesTranslated($cat["id"]);
        foreach ($all_lang as $lang => $language) {
            if ($language == $actual_language) {
                continue;
            }
            if (array_key_exists($language, $id_languages)) {
                printf("<td class=\"sscDesc\" title=\"%s: %s\"><img src=\"images/ok.gif\" width=\"22\" height=\"18\" border=\"0\" title=\"%s: %s\" alt=\"%s: %s\" /></td>\n", $PMF_LANG["ad_categ_titel"], PMF_String::preg_replace('/\\(.*\\)/', '', $id_languages[$language]), $PMF_LANG["ad_categ_titel"], PMF_String::preg_replace('/\\(.*\\)/', '', $id_languages[$language]), $PMF_LANG["ad_categ_titel"], PMF_String::preg_replace('/\\(.*\\)/', '', $id_languages[$language]));
            } else {
                print "<td class=\"sscDescNA\">";
                printf('<a href="%s?action=translatecategory&amp;cat=%s&amp;trlang=%s" title="%s"><img src="images/translate2.gif" width="13" height="16" border="0" title="%s" alt="%s" /></a>', $currentLink, $cat['id'], $lang, $PMF_LANG['ad_categ_translate'], $PMF_LANG['ad_categ_translate'], $PMF_LANG['ad_categ_translate']);
            }
            print "</td>\n";
        }
        print "</tr>\n";
    }
    print "</table>\n";
    printf('<p>%s</p>', $PMF_LANG['ad_categ_remark_overview']);
} else {
    print $PMF_LANG['err_NotAuth'];
}
开发者ID:noon,项目名称:phpMyFAQ,代码行数:31,代码来源:category.showstructure.php


注:本文中的PMF_String::preg_replace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。