本文整理汇总了PHP中PMF_String::preg_replace_callback方法的典型用法代码示例。如果您正苦于以下问题:PHP PMF_String::preg_replace_callback方法的具体用法?PHP PMF_String::preg_replace_callback怎么用?PHP PMF_String::preg_replace_callback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMF_String
的用法示例。
在下文中一共展示了PMF_String::preg_replace_callback方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insertItemsIntoContent
/**
* Fill the passed string with the current Glossary items.
*
* @param string $content Content
*
* @return string
*/
public function insertItemsIntoContent($content = '')
{
if ('' == $content) {
return '';
}
$attributes = array('href', 'src', 'title', 'alt', 'class', 'style', 'id', 'name', 'face', 'size', 'dir', 'rel', 'rev', 'onmouseenter', 'onmouseleave', 'onafterprint', 'onbeforeprint', 'onbeforeunload', 'onhashchange', 'onmessage', 'onoffline', 'ononline', 'onpopstate', 'onpagehide', 'onpageshow', 'onresize', 'onunload', 'ondevicemotion', 'ondeviceorientation', 'onabort', 'onblur', 'oncanplay', 'oncanplaythrough', 'onchange', 'onclick', 'oncontextmenu', 'ondblclick', 'ondrag', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'ondurationchange', 'onemptied', 'onended', 'onerror', 'onfocus', 'oninput', 'oninvalid', 'onkeydown', 'onkeypress', 'onkeyup', 'onload', 'onloadeddata', 'onloadedmetadata', 'onloadstart', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onmozfullscreenchange', 'onmozfullscreenerror', 'onpause', 'onplay', 'onplaying', 'onprogress', 'onratechange', 'onreset', 'onscroll', 'onseeked', 'onseeking', 'onselect', 'onshow', 'onstalled', 'onsubmit', 'onsuspend', 'ontimeupdate', 'onvolumechange', 'onwaiting', 'oncopy', 'oncut', 'onpaste', 'onbeforescriptexecute', 'onafterscriptexecute');
foreach ($this->getAllGlossaryItems() as $item) {
$this->definition = $item['definition'];
$item['item'] = preg_quote($item['item'], '/');
$content = PMF_String::preg_replace_callback('/' . '(' . $item['item'] . '="[^"]*")|' . '((' . implode('|', $attributes) . ')="[^"]*' . $item['item'] . '[^"]*")|' . '(\\W+)(' . $item['item'] . ')(\\W+)|' . '^(' . $item['item'] . ')(\\W+)|' . '(\\W+)(' . $item['item'] . ')$' . '/mis', array($this, 'setTooltip'), $content, 1);
}
return $content;
}
示例2: sprintf
// Set the path of the current category
$categoryName = $categoryLayout->renderBreadcrumb($categoryPath);
$changeLanguagePath = PMF_Link::getSystemRelativeUri() . sprintf('?%saction=artikel&cat=%d&id=%d&artlang=%s', $sids, $currentCategory, $id, $LANGCODE);
$oLink = new PMF_Link($changeLanguagePath);
$oLink->itemTitle = $faq->getRecordTitle($record_id, false);
$changeLanguagePath = $oLink->toString();
$highlight = PMF_Filter::filterInput(INPUT_GET, 'highlight', FILTER_SANITIZE_STRIPPED);
if (!is_null($highlight) && $highlight != "/" && $highlight != "<" && $highlight != ">" && PMF_String::strlen($highlight) > 3) {
$highlight = str_replace("'", "´", $highlight);
$highlight = str_replace(array('^', '.', '?', '*', '+', '{', '}', '(', ')', '[', ']'), '', $highlight);
$highlight = preg_quote($highlight, '/');
$searchItems = explode(' ', $highlight);
$attributes = array('href', 'src', 'title', 'alt', 'class', 'style', 'id', 'name', 'face', 'size', 'dir', 'onclick', 'ondblclick', 'onmousedown', 'onmouseup', 'onmouseover', 'onmousemove', 'onmouseout', 'onkeypress', 'onkeydown', 'onkeyup');
foreach ($searchItems as $item) {
$thema = PMF_String::preg_replace_callback('/' . '(' . $item . '="[^"]*")|' . '((' . implode('|', $attributes) . ')="[^"]*' . $item . '[^"]*")|' . '(\\s+)(' . $item . ')(\\s+)' . '/mis', 'highlight_no_links', $thema);
$content = PMF_String::preg_replace_callback('/' . '(' . $item . '="[^"]*")|' . '((' . implode('|', $attributes) . ')="[^"]*' . $item . '[^"]*")|' . '(\\s+)(' . $item . ')(\\s+)' . '/mis', 'highlight_no_links', $content);
}
}
// Hack: Apply the new SEO schema to those HTML anchors to
// other faq records (Internal Links) added with WYSIWYG Editor:
// href="index.php?action=artikel&cat=NNN&id=MMM&artlang=XYZ"
// Search for href attribute links
$oLnk->resetPool();
$oLnk->parse_string($content);
$fixedContent = str_replace('href="#', sprintf('href="index.php?action=artikel&lang=%s&cat=%d&id=%d&artlang=%s#', $LANGCODE, $currentCategory, $record_id, $LANGCODE), $content);
$oLnk->resetPool();
$oLnk->parse_string($fixedContent);
// Search for href attributes only
$linkArray = $oLnk->getUrlpool();
if (isset($linkArray['href'])) {
foreach (array_unique($linkArray['href']) as $_url) {
示例3: setHighlightedString
/**
* Adds a highlighted word to a string
*
* @param string $string String
* @param string $highlight Given word for highlighting
*
* @return string
*/
public static function setHighlightedString($string, $highlight)
{
$attributes = array('href', 'src', 'title', 'alt', 'class', 'style', 'id', 'name', 'face', 'size', 'dir', 'onclick', 'ondblclick', 'onmousedown', 'onmouseup', 'onmouseover', 'onmousemove', 'onmouseout', 'onkeypress', 'onkeydown', 'onkeyup');
return PMF_String::preg_replace_callback('/(' . $highlight . '="[^"]*")|' . '((' . implode('|', $attributes) . ')="[^"]*' . $highlight . '[^"]*")|' . '(' . $highlight . ')/mis', array('PMF_Utils', 'highlightNoLinks'), $string);
}
示例4: preg_replace_callback
/**
* Search and replace by a regexp using a callback
* @param string|array $pattern
* @param function $callback
* @param string|array $subject
* @param int $limit
* @param int &$count
*
* @return array|string
*/
public static function preg_replace_callback($pattern, $callback, $subject, $limit = -1, &$count = 0)
{
return self::$instance->preg_replace_callback($pattern, $callback, $subject, $limit, $count);
}
示例5: insertItemsIntoContent
/**
* Fill the passed string with the current Glossary items.
*
* @param string $content Content
* @return string
*/
public function insertItemsIntoContent($content = '')
{
if ('' == $content) {
return '';
}
$attributes = array('href', 'src', 'title', 'alt', 'class', 'style', 'id', 'name', 'face', 'size', 'dir', 'onclick', 'ondblclick', 'onmousedown', 'onmouseup', 'onmouseover', 'onmousemove', 'onmouseout', 'onkeypress', 'onkeydown', 'onkeyup');
foreach ($this->getAllGlossaryItems() as $item) {
$this->definition = $item['definition'];
$item['item'] = preg_quote($item['item'], '/');
$content = PMF_String::preg_replace_callback('/' . '(' . $item['item'] . '="[^"]*")|' . '((' . implode('|', $attributes) . ')="[^"]*' . $item['item'] . '[^"]*")|' . '(\\W+)(' . $item['item'] . ')(\\W+)|' . '^(' . $item['item'] . ')(\\W+)|' . '(\\W+)(' . $item['item'] . ')$' . '/mis', array($this, 'setAbbreviations'), $content);
}
return $content;
}
示例6: setHighlightedString
/**
* Adds a highlighted word to a string
*
* @param string $string String
* @param string $highlight Given word for highlighting
*
* @return string
*/
public static function setHighlightedString($string, $highlight)
{
$attributes = array('href', 'src', 'title', 'alt', 'class', 'style', 'id', 'name', 'face', 'size', 'dir', 'rel', 'rev', 'onmouseenter', 'onmouseleave', 'onafterprint', 'onbeforeprint', 'onbeforeunload', 'onhashchange', 'onmessage', 'onoffline', 'ononline', 'onpopstate', 'onpagehide', 'onpageshow', 'onresize', 'onunload', 'ondevicemotion', 'ondeviceorientation', 'onabort', 'onblur', 'oncanplay', 'oncanplaythrough', 'onchange', 'onclick', 'oncontextmenu', 'ondblclick', 'ondrag', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'ondurationchange', 'onemptied', 'onended', 'onerror', 'onfocus', 'oninput', 'oninvalid', 'onkeydown', 'onkeypress', 'onkeyup', 'onload', 'onloadeddata', 'onloadedmetadata', 'onloadstart', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onmozfullscreenchange', 'onmozfullscreenerror', 'onpause', 'onplay', 'onplaying', 'onprogress', 'onratechange', 'onreset', 'onscroll', 'onseeked', 'onseeking', 'onselect', 'onshow', 'onstalled', 'onsubmit', 'onsuspend', 'ontimeupdate', 'onvolumechange', 'onwaiting', 'oncopy', 'oncut', 'onpaste', 'onbeforescriptexecute', 'onafterscriptexecute');
return PMF_String::preg_replace_callback('/(' . $highlight . '="[^"]*")|' . '((' . implode('|', $attributes) . ')="[^"]*' . $highlight . '[^"]*")|' . '(' . $highlight . ')/mis', array('PMF_Utils', 'highlightNoLinks'), $string);
}
示例7: searchEngine
/**
* The main search function for the full text search
*
* TODO: add filter for (X)HTML tag names and attributes!
*
* @param string Text/Number (solution id)
* @param string '%' to avoid any category filtering
* @param boolean true to search over all languages
* @param boolean true to disable the results paging
* @param boolean true to use it for Instant Response
* @return string
* @access public
* @author Thorsten Rinne <thorsten@phpmyfaq.de>
* @author Matteo Scaramuccia <matteo@phpmyfaq.de>
* @author Adrianna Musiol <musiol@imageaccess.de>
* @since 2002-09-16
*/
function searchEngine($searchterm, $cat = '%', $allLanguages = true, $hasMore = false, $instantRespnse = false)
{
global $sids, $PMF_LANG, $plr, $LANGCODE, $faq, $current_user, $current_groups, $categoryLayout;
$_searchterm = PMF_htmlentities(stripslashes($searchterm), ENT_QUOTES, 'utf-8');
$seite = 1;
$output = '';
$num = 0;
$searchItems = array();
$langs = true == $allLanguages ? '&langs=all' : '';
$seite = PMF_Filter::filterInput(INPUT_GET, 'seite', FILTER_VALIDATE_INT, 1);
$db = PMF_Db::getInstance();
$faqconfig = PMF_Configuration::getInstance();
$result = getSearchData(htmlentities($searchterm, ENT_COMPAT, 'utf-8'), true, $cat, $allLanguages);
$num = $db->numRows($result);
if (0 == $num) {
$output = $PMF_LANG['err_noArticles'];
}
$confPerPage = $faqconfig->get('main.numberOfRecordsPerPage');
$pages = ceil($num / $confPerPage);
$last = $seite * $confPerPage;
$first = $last - $confPerPage;
if ($last > $num) {
$last = $num;
}
if ($num > 0) {
$output .= '<p>' . $plr->GetMsg('plmsgSearchAmount', $num);
if ($hasMore && $pages > 1) {
$output .= sprintf($PMF_LANG['msgInstantResponseMaxRecords'], $confPerPage);
}
$output .= "</p>\n";
if (!$hasMore && $pages > 1) {
$output .= "<p><strong>" . $PMF_LANG["msgPage"] . $seite . " " . $PMF_LANG["msgVoteFrom"] . " " . $plr->GetMsg('plmsgPagesTotal', $pages) . "</strong></p>";
}
$output .= "<ul class=\"phpmyfaq_ul\">\n";
$faqUser = new PMF_Faq_User();
$faqGroup = new PMF_Faq_Group();
$counter = $displayedCounter = 0;
while (($row = $db->fetchObject($result)) && $displayedCounter < $confPerPage) {
$counter++;
if ($counter <= $first) {
continue;
}
$displayedCounter++;
$b_permission = false;
//Groups Permission Check
if ($faqconfig->get('main.permLevel') == 'medium') {
$perm_group = $faqGroup->fetch($row->id);
foreach ($current_groups as $value) {
if ($value == $perm_group->group_id) {
$b_permission = true;
}
}
}
if ($faqconfig->get('main.permLevel') == 'basic' || $b_permission) {
$perm_user = $faqUser->fetch($row->id);
foreach ($perm_user as $value) {
if ($value == -1) {
$b_permission = true;
break;
} elseif ((int) $value == $current_user) {
$b_permission = true;
break;
} else {
$b_permission = false;
}
}
}
if ($b_permission) {
$rubriktext = $categoryLayout->renderBreadcrumb(array($row->category_id));
$thema = chopString($row->thema, 15);
$content = chopString(strip_tags($row->content), 25);
$searchterm = str_replace(array('^', '.', '?', '*', '+', '{', '}', '(', ')', '[', ']', '"'), '', $searchterm);
$searchterm = preg_quote($searchterm, '/');
$searchItems = explode(' ', $searchterm);
if (PMF_String::strlen($searchItems[0]) > 1) {
foreach ($searchItems as $item) {
if (PMF_String::strlen($item) > 2) {
$thema = PMF_String::preg_replace_callback('/' . '(' . $item . '="[^"]*")|' . '((href|src|title|alt|class|style|id|name|dir|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup)="[^"]*' . $item . '[^"]*")|' . '(' . $item . ')' . '/mis', "highlight_no_links", $thema);
$content = PMF_String::preg_replace_callback('/' . '(' . $item . '="[^"]*")|' . '((href|src|title|alt|class|style|id|name|dir|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup)="[^"]*' . $item . '[^"]*")|' . '(' . $item . ')' . '/mis', "highlight_no_links", $content);
}
}
}
// Print the link to the faq record
//.........这里部分代码省略.........
示例8: count
$faqVisitsCount = count($allVisitsData);
$percentage = 0;
if ($faqVisitsCount > 0) {
$percentage = 100 / $faqVisitsCount;
}
foreach ($allVisitsData as $_r) {
if ($minVisits > $_r['visits']) {
$minVisits = $_r['visits'];
}
if ($maxVisits < $_r['visits']) {
$maxVisits = $_r['visits'];
}
if ($record_id == $_r['id'] && $lang == $_r['lang']) {
$currVisits = $_r['visits'];
}
}
if ($maxVisits - $minVisits > 0) {
$percentage = 100 * ($currVisits - $minVisits) / ($maxVisits - $minVisits);
}
$faqPopularity = $currVisits . '/' . (int) $percentage . '%';
$translationForm = '';
if (count($arrLanguage) < count(PMF_Language::getAvailableLanguages())) {
$translationUrl = sprintf(str_replace('%', '%%', PMF_Link::getSystemRelativeUri('index.php')) . 'index.php?%saction=translate&cat=%s&id=%d&srclang=%s', $sids, $currentCategory, $record_id, $lang);
$translationForm = '
<form action="' . $translationUrl . '" method="post" style="display: inline;">
<img src="images/translate.gif" alt="' . $PMF_LANG['msgTranslate'] . '" title="' . $PMF_LANG['msgTranslate'] . '" width="16" height="16" border="0" /> ' . $PMF_LANG['msgTranslate'] . ' ' . PMF_Language::selectLanguages($LANGCODE, false, $arrLanguage, 'translation') . ' <input class="submit" type="submit" name="submit" value="' . $PMF_LANG['msgTranslateSubmit'] . '" />
</form>';
}
// Set the template variables
$tpl->processTemplate("writeContent", array('writeRubrik' => $categoryName . '<br />', 'solution_id' => $faq->faqRecord['solution_id'], 'writeThema' => $thema, 'writeArticleCategoryHeader' => $PMF_LANG['msgArticleCategories'], 'writeArticleCategories' => $writeMultiCategories, 'writeContent' => PMF_String::preg_replace_callback("/<code([^>]*)>(.*?)<\\/code>/is", 'hilight', $content), 'writeTagHeader' => $PMF_LANG['msg_tags'] . ': ', 'writeArticleTags' => $tagging->getAllLinkTagsById($record_id), 'writeRelatedArticlesHeader' => $PMF_LANG['msg_related_articles'] . ': ', 'writeRelatedArticles' => $relevant->getAllRelatedById($record_id, $faq->faqRecord['title'], $faq->faqRecord['keywords']), 'writePopularity' => $faqPopularity, 'writeDateMsg' => $PMF_LANG['msgLastUpdateArticle'] . $faq->faqRecord['date'], 'writeRevision' => $PMF_LANG['ad_entry_revision'] . ': 1.' . $faq->faqRecord['revision_id'], 'writeAuthor' => $PMF_LANG['msgAuthor'] . ': ' . $faq->faqRecord['author'], 'editThisEntry' => $editThisEntry, 'writeDiggMsgTag' => 'Digg it!', 'link_digg' => sprintf('http://digg.com/submit?phase=2&url=%s', urlencode($diggItUrl)), 'writeFacebookMsgTag' => 'Share on Facebook', 'link_facebook' => sprintf('http://www.facebook.com/sharer.php?u=%s', urlencode($facebookUrl)), 'link_email' => sprintf(str_replace('%', '%%', PMF_Link::getSystemRelativeUri('index.php')) . 'index.php?%saction=send2friend&cat=%d&id=%d&artlang=%s', $sids, $currentCategory, $record_id, $lang), 'link_pdf' => sprintf(str_replace('%', '%%', PMF_Link::getSystemRelativeUri('index.php')) . 'pdf.php?cat=%d&id=%d&artlang=%s', $currentCategory, $record_id, $lang), 'writePDFTag' => $PMF_LANG['msgPDF'], 'writePrintMsgTag' => $PMF_LANG['msgPrintArticle'], 'writeSend2FriendMsgTag' => $PMF_LANG['msgSend2Friend'], 'translationForm' => $translationForm, 'saveVotingPATH' => sprintf(str_replace('%', '%%', PMF_Link::getSystemRelativeUri('index.php')) . 'index.php?%saction=savevoting', $sids), 'saveVotingID' => $record_id, 'saveVotingIP' => $_SERVER['REMOTE_ADDR'], 'msgAverageVote' => $PMF_LANG['msgAverageVote'], 'printVotings' => $faqrating->getVotingResult($record_id), 'switchLanguage' => $switchLanguage, 'msgVoteUseability' => $PMF_LANG['msgVoteUseability'], 'msgVoteBad' => $PMF_LANG['msgVoteBad'], 'msgVoteGood' => $PMF_LANG['msgVoteGood'], 'msgVoteSubmit' => $PMF_LANG['msgVoteSubmit'], 'writeCommentMsg' => $commentMessage, 'msgWriteComment' => $PMF_LANG['msgWriteComment'], 'writeSendAdress' => $_SERVER['PHP_SELF'] . '?' . $sids . 'action=savecomment', 'id' => $record_id, 'lang' => $lang, 'msgCommentHeader' => $PMF_LANG['msgCommentHeader'], 'msgNewContentName' => $PMF_LANG['msgNewContentName'], 'msgNewContentMail' => $PMF_LANG['msgNewContentMail'], 'defaultContentMail' => $user instanceof PMF_User_CurrentUser ? $user->getUserData('email') : '', 'defaultContentName' => $user instanceof PMF_User_CurrentUser ? $user->getUserData('display_name') : '', 'msgYourComment' => $PMF_LANG['msgYourComment'], 'msgNewContentSubmit' => $PMF_LANG['msgNewContentSubmit'], 'captchaFieldset' => printCaptchaFieldset($PMF_LANG['msgCaptcha'], $captcha->printCaptcha('writecomment'), $captcha->caplength), 'writeComments' => $comment->getComments($record_id, PMF_Comment::COMMENT_TYPE_FAQ)));
$tpl->includeTemplate('writeContent', 'index');