protected function clearMetadata()
 {
     // remove the entries from metadata table.
     $groupId = $this->page->getMessageGroupId();
     TranslateMetadata::set($groupId, 'prioritylangs', false);
     TranslateMetadata::set($groupId, 'priorityforce', false);
     TranslateMetadata::set($groupId, 'priorityreason', false);
     // remove the page from aggregate groups, if present in any of them.
     $groups = MessageGroups::getAllGroups();
     foreach ($groups as $group) {
         if ($group instanceof AggregateMessageGroup) {
             $subgroups = TranslateMetadata::get($group->getId(), 'subgroups');
             if ($subgroups !== false) {
                 $subgroups = explode(',', $subgroups);
                 $subgroups = array_flip($subgroups);
                 if (isset($subgroups[$groupId])) {
                     unset($subgroups[$groupId]);
                     $subgroups = array_flip($subgroups);
                     TranslateMetadata::set($group->getId(), 'subgroups', implode(',', $subgroups));
                 }
             }
         }
     }
 }
 /**
  * @param WebRequest $request
  * @param TranslatablePage $page
  */
 protected function handlePriorityLanguages(WebRequest $request, TranslatablePage $page)
 {
     // new priority languages
     $npLangs = rtrim(trim($request->getVal('prioritylangs')), ',');
     $npForce = $request->getCheck('forcelimit') ? 'on' : 'off';
     $npReason = trim($request->getText('priorityreason'));
     // Normalize
     $npLangs = array_map('trim', explode(',', $npLangs));
     $npLangs = array_unique($npLangs);
     // Remove invalid language codes.
     $languages = Language::fetchLanguageNames();
     foreach ($npLangs as $index => $language) {
         if (!array_key_exists($language, $languages)) {
             unset($npLangs[$index]);
         }
     }
     $npLangs = implode(',', $npLangs);
     if ($npLangs === '') {
         $npLangs = false;
         $npForce = false;
         $npReason = false;
     }
     $groupId = $page->getMessageGroupId();
     // old priority languages
     $opLangs = TranslateMetadata::get($groupId, 'prioritylangs');
     $opForce = TranslateMetadata::get($groupId, 'priorityforce');
     $opReason = TranslateMetadata::get($groupId, 'priorityreason');
     TranslateMetadata::set($groupId, 'prioritylangs', $npLangs);
     TranslateMetadata::set($groupId, 'priorityforce', $npForce);
     TranslateMetadata::set($groupId, 'priorityreason', $npReason);
     if ($opLangs !== $npLangs || $opForce !== $npForce || $opReason !== $npReason) {
         $params = array('languages' => $npLangs, 'force' => $npForce, 'reason' => $npReason);
         $entry = new ManualLogEntry('pagetranslation', 'prioritylanguages');
         $entry->setPerformer($this->getUser());
         $entry->setTarget($page->getTitle());
         $entry->setParameters($params);
         $entry->setComment($npReason);
         $logid = $entry->insert();
         $entry->publish($logid);
     }
 }
	public function showSuccess( TranslatablePage $page ) {
		global $wgOut, $wgLang;

		$titleText = $page->getTitle()->getPrefixedText();
		$num = $wgLang->formatNum( $page->getParse()->countSections() );
		$link = SpecialPage::getTitleFor( 'Translate' )->getFullUrl(
			array( 'group' => $page->getMessageGroupId() ) );

		$wgOut->addWikiMsg( 'tpt-saveok', $titleText, $num, $link );
	}