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


PHP Wikia::isVarSet方法代码示例

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


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

示例1: storeInRecentChanges

 /**
  * Store custom data in rc_params field as JSON encoded table prefixed with extra string.
  * To pass in extra key-value pairs, pass in 'data' as an associative array.
  *
  * @see http://www.mediawiki.org/wiki/Logging_table#log_params
  *
  * @author Maciej Brencz <macbre@wikia-inc.com>
  */
 public static function storeInRecentChanges(RecentChange $rc, $data = array())
 {
     wfProfileIn(__METHOD__);
     /* @var $wgParser Parser */
     global $wgParser;
     // If we have existing data packed into rc_params, make sure it is preserved.
     if (isset($rc->mAttribs['rc_params'])) {
         $unpackedData = self::unpackData($rc->mAttribs['rc_params']);
         if (is_array($unpackedData)) {
             foreach ($unpackedData as $key => $val) {
                 // Give preference to the data array that was passed into the function.
                 if (!isset($data[$key])) {
                     $data[$key] = $val;
                 }
             }
         }
     }
     // summary generated by MW: store auto-summary type
     if (Wikia::isVarSet('AutoSummaryType')) {
         $data['autosummaryType'] = Wikia::getVar('AutoSummaryType');
     }
     switch ($rc->getAttribute('rc_type')) {
         // existing article
         case RC_EDIT:
             // rollback: store ID of the revision rollback is made to
             if (Wikia::isVarSet('RollbackedRevId')) {
                 $data['rollback'] = true;
                 $data['revId'] = Wikia::getVar('RollbackedRevId');
             }
             // edit from view mode
             if (Wikia::isVarSet('EditFromViewMode')) {
                 $data['viewMode'] = 1;
                 if (Wikia::isVarSet('EditFromViewMode') == 'CategorySelect') {
                     $data['CategorySelect'] = 1;
                 }
             }
             // section edit: store section name and modified summary
             if (self::$editedSectionName !== false) {
                 // store section name
                 $data['sectionName'] = self::$editedSectionName;
                 // edit summary
                 $comment = trim($rc->getAttribute('rc_comment'));
                 // summary has changed - store modified summary
                 if (!preg_match('#^/\\*(.*)\\*/$#', $comment)) {
                     // remove /* Section title */
                     $comment = preg_replace('#/\\*(.*)\\*/#', '', $comment);
                     // remove all wikitext
                     $comment = trim($wgParser->stripSectionName($comment));
                     if ($comment != '') {
                         $data['summary'] = $comment;
                     }
                 }
             }
             break;
             // new article
         // new article
         case RC_NEW:
             $content = $wgParser->getOutput()->getText();
             // remove [edit] section links
             $content = preg_replace('#<span class="editsection">(.*)</a>]</span>#', '', $content);
             // remove <script> tags (RT #46350)
             $content = preg_replace('#<script[^>]+>(.*)<\\/script>#', '', $content);
             // remove text between tags (RT #141394) and get rid of photo attribution (BugId:23871)
             $content = ActivityFeedHelper::filterTextBetweenTags($content);
             // remove HTML tags
             $content = trim(strip_tags($content));
             // store first 150 characters of parsed content
             $data['intro'] = mb_substr($content, 0, 150);
             $data['intro'] = strtr($data['intro'], array('&nbsp;' => ' ', '&amp;' => '&'));
             break;
     }
     //allow to alter $data by other extensions (eg. Article Comments)
     wfRunHooks('MyHome:BeforeStoreInRC', array(&$rc, &$data));
     // encode data to be stored in rc_params
     if (!empty($data)) {
         $rc->mAttribs['rc_params'] = self::packData($data);
     }
     Wikia::setVar('rc', $rc);
     Wikia::setVar('rc_data', $data);
     wfProfileOut(__METHOD__);
     return true;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:90,代码来源:MyHome.class.php


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