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


PHP TranslateUtils::cacheFile方法代码示例

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


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

示例1: getCacheFileName

 /**
  * Returns full path the the cache file.
  * @return string
  */
 protected function getCacheFileName()
 {
     return TranslateUtils::cacheFile("translate_groupcache-{$this->group->getId()}-{$this->code}.cdb");
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:8,代码来源:MessageGroupCache.php

示例2: store

 protected function store(array $array)
 {
     $file = TranslateUtils::cacheFile($this->filename);
     file_put_contents($file, serialize($array));
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:5,代码来源:MessageIndex.php

示例3: writeChanges

 /**
  * Writes change array as a serialized file into a known place.
  * @param array $array Array of changes as returned by processGroup
  * indexed by message group id.
  * @todo does not belong to this class.
  */
 public static function writeChanges($array)
 {
     // This method is almost identical with MessageIndex::store
     /* This will overwrite the previous cache file if any. Once the cache
      * file is processed with Special:ManageMessageGroups, it is
      * renamed so that it wont be processed again. */
     $file = TranslateUtils::cacheFile(SpecialManageGroups::CHANGEFILE);
     $cache = CdbWriter::open($file);
     $keys = array_keys($array);
     $cache->set('#keys', serialize($keys));
     foreach ($array as $key => $value) {
         $value = serialize($value);
         $cache->set($key, $value);
     }
     $cache->close();
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:22,代码来源:ExternalMessageSourceStateComparator.php

示例4: processSubmit

 protected function processSubmit()
 {
     $req = $this->getRequest();
     $out = $this->getOutput();
     $jobs = array();
     $jobs[] = MessageIndexRebuildJob::newJob();
     $changefile = TranslateUtils::cacheFile(self::CHANGEFILE);
     $reader = CdbReader::open($changefile);
     $groups = unserialize($reader->get('#keys'));
     $postponed = array();
     foreach ($groups as $groupId) {
         $group = MessageGroups::getGroup($groupId);
         $changes = unserialize($reader->get($groupId));
         foreach ($changes as $code => $subchanges) {
             foreach ($subchanges as $type => $messages) {
                 foreach ($messages as $index => $params) {
                     $id = self::changeId($groupId, $code, $type, $params['key']);
                     if ($req->getVal($id) === null) {
                         // We probably hit the limit with number of post parameters.
                         $postponed[$groupId][$code][$type][$index] = $params;
                         continue;
                     }
                     if ($type === 'deletion' || $req->getCheck("i/{$id}")) {
                         continue;
                     }
                     $fuzzy = $req->getCheck("f/{$id}") ? 'fuzzy' : false;
                     $key = $params['key'];
                     $title = Title::makeTitleSafe($group->getNamespace(), "{$key}/{$code}");
                     $jobs[] = MessageUpdateJob::newJob($title, $params['content'], $fuzzy);
                 }
             }
             if (!isset($postponed[$groupId][$code])) {
                 $cache = new MessageGroupCache($groupId, $code);
                 $cache->create();
             }
         }
     }
     JobQueueGroup::singleton()->push($jobs);
     $reader->close();
     rename($changefile, $changefile . '-' . wfTimestamp());
     if (count($postponed)) {
         $changefile = TranslateUtils::cacheFile(self::CHANGEFILE);
         $writer = CdbWriter::open($changefile);
         $keys = array_keys($postponed);
         $writer->set('#keys', serialize($keys));
         foreach ($postponed as $groupId => $changes) {
             $writer->set($groupId, serialize($changes));
         }
         $writer->close();
         $this->showChanges(true, $this->getLimit());
     } else {
         $out->addWikiMsg('translate-smg-submitted');
     }
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:54,代码来源:SpecialManageGroups.php

示例5: getOldCacheFileName

 /**
  * Returns full path to the old cache file location.
  * @return string
  */
 protected function getOldCacheFileName()
 {
     $cacheFileName = "translate_groupcache-{$this->group->getId()}-{$this->code}.cdb";
     return TranslateUtils::cacheFile($cacheFileName);
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:9,代码来源:MessageGroupCache.php

示例6: getReader

 protected function getReader()
 {
     if ($this->reader) {
         return $this->reader;
     }
     $file = TranslateUtils::cacheFile($this->filename);
     if (!file_exists($file)) {
         // Create an empty index to allow rebuild
         $this->store(array());
         $this->index = $this->rebuild();
     }
     return $this->reader = CdbReader::open($file);
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:13,代码来源:MessageIndex.php


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