Esempio n. 1
0
	protected function getPotTime() {
		$defs = new MessageGroupCache( $this->group );
		return $defs->exists() ? $defs->getTimestamp() : wfTimestampNow();
	}
Esempio n. 2
0
 public function execute($par)
 {
     global $wgRequest;
     $this->out->setPageTitle(htmlspecialchars(wfMsg('translate-managegroups')));
     $group = $wgRequest->getText('group');
     $group = MessageGroups::getGroup($group);
     if (!$group instanceof FileBasedMessageGroup) {
         $group = null;
     }
     if ($group) {
         if ($wgRequest->getBool('rebuildall', false) && $wgRequest->wasPosted() && $this->user->isAllowed('translate-manage') && $this->user->matchEditToken($wgRequest->getVal('token'))) {
             $languages = explode(',', $wgRequest->getText('codes'));
             foreach ($languages as $code) {
                 $cache = new MessageGroupCache($group, $code);
                 $cache->create();
             }
         }
         $code = $wgRequest->getText('language', 'en');
         // Go to English for undefined codes.
         $codes = array_keys(Language::getLanguageNames(false));
         if (!in_array($code, $codes)) {
             $code = 'en';
         }
         if ($wgRequest->getVal('from') !== 'main') {
             $this->importForm($group, $code);
             return;
         }
     }
     // Main list
     global $wgLang, $wgOut;
     $groups = MessageGroups::singleton()->getGroups();
     TranslateUtils::addSpecialHelpLink($wgOut, 'Help:Extension:Translate/Group_management');
     $wgOut->wrapWikiMsg('<h2>$1</h2>', 'translate-manage-listgroups');
     $separator = wfMsg('word-separator');
     $languages = array_keys(Language::getLanguageNames(false));
     foreach ($groups as $group) {
         if (!$group instanceof FileBasedMessageGroup) {
             continue;
         }
         wfDebug(__METHOD__ . ": {$group->getId()}\n");
         $id = $group->getId();
         $link = $this->skin->link($this->getTitle(), $group->getLabel(), array('id' => "mw-group-{$id}"), array('group' => $id));
         $out = $link . $separator;
         $cache = new MessageGroupCache($group);
         if ($cache->exists()) {
             $timestamp = wfTimestamp(TS_MW, $cache->getTimestamp());
             $out .= wfMsg('translate-manage-cacheat', $wgLang->date($timestamp), $wgLang->time($timestamp));
             $modified = array();
             foreach ($languages as $code) {
                 $cache = new MessageGroupCache($group, $code);
                 if (!$cache->isValid()) {
                     $modified[] = $code;
                 }
             }
             if (count($modified)) {
                 $out = '[' . implode(",", $modified) . '] ' . $out;
                 if (!in_array('en', $modified) && $this->user->isAllowed('translate-manage')) {
                     $out .= $this->rebuildButton($group, $modified, 'main');
                 }
             } else {
                 // @todo FIXME: should be in CSS file.
                 $out = Html::rawElement('span', array('style' => 'color:grey'), $out);
             }
         } else {
             $out .= wfMsg('translate-manage-newgroup');
         }
         $wgOut->addHtml($out);
         $wgOut->addHtml('<hr>');
     }
     $wgOut->wrapWikiMsg('<h2>$1</h2>', 'translate-manage-listgroups-old');
     $wgOut->addHTML('<ul>');
     foreach ($groups as $group) {
         if ($group instanceof FileBasedMessageGroup) {
             continue;
         }
         $wgOut->addHtml(Xml::element('li', null, $group->getLabel()));
     }
     $wgOut->addHTML('</ul>');
 }