/** * Returns only translation subpages. * @return Array of titles. */ protected function getTranslationPages() { if ( $this->singleLanguage() ) { return array( $this->title ); } if ( !isset( $this->translationPages ) ) { $this->translationPages = $this->page->getTranslationPages(); } return $this->translationPages; }
/** * Creates jobs needed to create or update all translation pages. * @param TranslatablePage $page * @return Job[] * @since 2013-01-28 */ public static function getRenderJobs(TranslatablePage $page) { $jobs = array(); $titles = $page->getTranslationPages(); foreach ($titles as $t) { $jobs[] = TranslateRenderJob::newJob($t); } return $jobs; }
public static function updateTranslationPage(TranslatablePage $page, $code, $user, $flags, $summary) { $source = $page->getTitle(); $target = Title::makeTitle($source->getNamespace(), $source->getDBkey() . "/{$code}"); // We don't know and don't care $flags &= ~EDIT_NEW & ~EDIT_UPDATE; // Update the target page $job = TranslateRenderJob::newJob($target); $job->setUser($user); $job->setSummary($summary); $job->setFlags($flags); $job->run(); // Regenerate translation caches $page->getTranslationPercentages('force'); // Invalidate caches $pages = $page->getTranslationPages(); foreach ($pages as $title) { $wikiPage = WikiPage::factory($title); $wikiPage->doPurge(); } // And the source page itself too $wikiPage = WikiPage::factory($page->getTitle()); $wikiPage->doPurge(); }
public function setupRenderJobs( TranslatablePage $page ) { $titles = $page->getTranslationPages(); $this->addInitialRenderJob( $page, $titles ); $jobs = array(); foreach ( $titles as $t ) { self::superDebug( __METHOD__, 'renderjob', $t ); $jobs[] = RenderJob::newJob( $t ); } if ( count( $jobs ) < 10 ) { self::superDebug( __METHOD__, 'renderjob-immediate' ); foreach ( $jobs as $j ) { $j->run(); } } else { // Use the job queue self::superDebug( __METHOD__, 'renderjob-delayed' ); Job::batchInsert( $jobs ); } }