当前位置: 首页>>代码示例>>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;未经允许,请勿转载。