private function displayStats()
 {
     global $wgOut;
     if (empty($this->mGroup)) {
         $wgOut->addHTML(wfMsg('transstats-select-group'));
         return true;
     }
     if (empty($this->mLanglist)) {
         $data['total'] = MessageGroupStatistics::forGroup($this->mGroup);
     } else {
         foreach ($this->mLanglist as $lang) {
             $data['total'][$lang] = MessageGroupStatistics::forItem($this->mGroup, $lang);
         }
     }
     if (empty($data)) {
         $wgOut->addHTML(wfMsg('transstats-error'));
         return true;
     }
     $displayData = array();
     foreach ($data['total'] as $type => $row) {
         $processed = $this->processRow($row, $type);
         if ($processed) {
             $displayData[$type] = $processed;
         }
     }
     $headers = array(wfMsg('transstats-language'), wfMsg('transstats-translated'), wfMsg('transstats-percentage'));
     $attribs = array('class' => 'wikitable');
     $table = Xml::buildTable($displayData, $attribs, $headers);
     $this->renderHeader();
     $wgOut->addHTML($table);
     $this->renderFooter();
     return true;
 }
 private function displayStats()
 {
     global $wgOut;
     if (empty($this->mGroup)) {
         $wgOut->addHTML(wfMsg('transstats-select-group'));
         return true;
     }
     $data['total'] = MessageGroupStatistics::forGroup($this->mGroup);
     // need to get child groups for this meta group
     if (!empty($this->mBreakdown)) {
         $data[] = MessageGroupStatistics::forGroup($this->mBreakdown);
     }
     if (empty($data)) {
         $wgOut->addHTML(wfMsg('transstats-error'));
         return true;
     }
     foreach ($data['total'] as $type => &$row) {
         $this->processRow($row, $type);
     }
     $headers = array(wfMsg('transstats-language'), wfMsg('transstats-translated'), wfMsg('transstats-untranslated'));
     $attribs = array('class' => 'wikitable');
     $table = Xml::buildTable($data['total'], $attribs, $headers);
     $this->renderHeader();
     $wgOut->addHTML($table);
     $this->renderFooter();
     return true;
 }
 /**
  * HTML for language statistics
  * Copied and adaped from groupStatistics.php by Nikerabbit
  * @param integer $code A language code (default empty, example: 'en').
  * @param bool $suppressComplete If completely translated groups should be suppressed
  * @return string HTML
  */
 function getGroupStats($code, $suppressComplete = false, $suppressEmpty = false)
 {
     global $wgLang;
     # fetch the actual stats first
     $stats = MessageGroupStatistics::forLanguage($code);
     $out = '';
     # FIXME: provide some sensible header for what is being displayed.
     $out .= '<!-- ' . $code . " -->\n";
     $out .= '<!-- ' . TranslateUtils::getLanguageName($code, false) . " -->\n";
     # Create table header
     $out .= $this->heading();
     $out .= $this->blockstart();
     $out .= $this->element(wfMsg('translate-page-group', true));
     $out .= $this->element(wfMsg('translate-total', true));
     $out .= $this->element(wfMsg('translate-untranslated', true));
     $out .= $this->element(wfMsg('translate-percentage-complete', true));
     $out .= $this->element(wfMsg('translate-percentage-fuzzy', true));
     $out .= $this->blockend();
     # Get statistics for the message groups
     foreach ($stats as $id => $group) {
         $total = $group['gs_total'];
         $fuzzy = $group['gs_fuzzy'];
         $translated = $group['gs_translated'];
         // Skip if $suppressEmpty and no translations
         if ($suppressEmpty && empty($translated)) {
             continue;
         }
         // Skip if $suppressComplete and complete
         if ($suppressComplete && !$fuzzy && $translated == $total) {
             continue;
         }
         $translatedPercentage = wfMsg('percent', $wgLang->formatNum(round(100 * $translated / $total, 2)));
         $fuzzyPercentage = wfMsg('percent', $wgLang->formatNum(round(100 * $fuzzy / $total, 2)));
         $translateTitle = SpecialPage::getTitleFor('Translate');
         $pageParameters = "group=" . $id . "&language=" . $code;
         $g = MessageGroups::getGroup($id);
         $translateGroupLink = RequestContext::getMain()->getSkin()->makeKnownLinkObj($translateTitle, $g->getLabel(), $pageParameters);
         $out .= $this->blockstart();
         $out .= $this->element($translateGroupLink);
         $out .= $this->element($total);
         $out .= $this->element($total - $translated);
         $out .= $this->element($translatedPercentage, false, $this->getBackgroundColour($translated, $total));
         $out .= $this->element($fuzzyPercentage, false, $this->getBackgroundColour($fuzzy, $total, true));
         $out .= $this->blockend();
     }
     $out .= $this->footer();
     return $out;
 }
示例#4
0
<?php

include '../../../maintenance/commandLine.inc';
include $IP . '/extensions/Translate/MessageGroups.php';
$gs = new MessageGroupStatistics();
$gs->populateStats();