當前位置: 首頁>>代碼示例>>PHP>>正文


PHP EditPage::safeUnicodeInput方法代碼示例

本文整理匯總了PHP中EditPage::safeUnicodeInput方法的典型用法代碼示例。如果您正苦於以下問題:PHP EditPage::safeUnicodeInput方法的具體用法?PHP EditPage::safeUnicodeInput怎麽用?PHP EditPage::safeUnicodeInput使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在EditPage的用法示例。


在下文中一共展示了EditPage::safeUnicodeInput方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: onEditPageImportFormData

 /**
  * Concatenate categories on EditPage POST
  *
  * @param EditPage $editPage
  * @param WebRequest $request
  *
  * @return Boolean because it's a hook
  */
 public static function onEditPageImportFormData($editPage, $request)
 {
     $app = F::app();
     if ($request->wasPosted()) {
         $categories = $editPage->safeUnicodeInput($request, 'categories');
         $categories = CategoryHelper::changeFormat($categories, 'json', 'array');
         // Concatenate categories to article wikitext (if there are any).
         if (!empty($categories)) {
             if (!empty($app->wg->EnableAnswers)) {
                 // don't add categories if the page is a redirect
                 $magicWords = $app->wg->ContLang->getMagicWords();
                 $redirects = $magicWords['redirect'];
                 // first element doesn't interest us
                 array_shift($redirects);
                 // check for localized versions of #REDIRECT
                 foreach ($redirects as $alias) {
                     if (stripos($editPage->textbox1, $alias) === 0) {
                         return true;
                     }
                 }
             }
             // Extract categories from the article, merge them with those passed in, weed out
             // duplicates and finally append them back to the article (BugId:99348).
             $data = CategoryHelper::extractCategoriesFromWikitext($editPage->textbox1, true);
             $categories = CategoryHelper::getUniqueCategories($data['categories'], $categories);
             $categories = CategoryHelper::changeFormat($categories, 'array', 'wikitext');
             // Remove trailing whitespace (BugId:11238)
             $editPage->textbox1 = $data['wikitext'] . rtrim($categories);
         }
     }
     return true;
 }
開發者ID:Tjorriemorrie,項目名稱:app,代碼行數:40,代碼來源:CategorySelectHooksHelper.class.php

示例2: CategorySelectImportFormData

/**
 * Concatenate categories on EditPage POST
 *
 * @param EditPage $editPage
 * @param WebRequest $request
 *
 * @author Maciej Błaszkowski <marooned at wikia-inc.com>
 * @author Lucas Garczewski <tor@wikia-inc.com>
 */
function CategorySelectImportFormData($editPage, $request)
{
    global $wgCategorySelectCategoriesInWikitext, $wgContLang, $wgEnableAnswers;
    if ($request->wasPosted()) {
        $sourceType = $request->getVal('wpCategorySelectSourceType');
        if ($sourceType == 'wiki') {
            $categories = "\n" . trim($editPage->safeUnicodeInput($request, 'csWikitext'));
        } else {
            //json
            $categories = $editPage->safeUnicodeInput($request, 'wpCategorySelectWikitext');
            $categories = CategorySelectChangeFormat($categories, 'json', 'wiki');
            if (trim($categories) == '') {
                $categories = '';
            }
        }
        if ($editPage->preview || $editPage->diff) {
            $data = CategorySelect::SelectCategoryAPIgetData($editPage->textbox1 . $categories);
            $editPage->textbox1 = $data['wikitext'];
            $categories = CategorySelectChangeFormat($data['categories'], 'array', 'wiki');
        } else {
            //saving article
            if (!empty($wgEnableAnswers)) {
                // don't add categories if the page is a redirect
                $magicWords = $wgContLang->getMagicWords();
                $redirects = $magicWords['redirect'];
                array_shift($redirects);
                // first element doesn't interest us
                // check for localized versions of #REDIRECT
                foreach ($redirects as $alias) {
                    if (stripos($editPage->textbox1, $alias) === 0) {
                        return true;
                    }
                }
            }
            // rtrim needed because of BugId:11238
            $editPage->textbox1 .= rtrim($categories);
        }
        $wgCategorySelectCategoriesInWikitext = $categories;
    }
    return true;
}
開發者ID:schwarer2006,項目名稱:wikia,代碼行數:50,代碼來源:CategorySelect.php


注:本文中的EditPage::safeUnicodeInput方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。