function makeList($items, $nsnames, $nscolors, $wi, $ui, $namespace, $redirects, $limit) { global $wt; #print_r($nsnames); $lang = $wi->lang; $wiki = $wi->wiki; $domain = $wi->domain; $rowLimit = $limit; //( $namespace == "all" ) ? 100 : 5000; $result = new stdClass($filter = null, $namespaces = null, $list = null); $currentNamespace = "-1"; $currentNumber = 0; foreach ($items as $i => $item) { $page = str_replace("_", " ", $item["page_title"]); $date = date("Y-m-d", strtotime($item["timestamp"])); $ns = $item["namespace"]; $prefix = $ns ? $nsnames["names"][$ns] . ":" : ""; $pageurl = rawurlencode(str_replace(" ", "_", $prefix . $item["page_title"])); $redirect = $item["page_is_redirect"] == 1 ? "<small> · (redirect)</small>" : ""; $deleted = $item["type"] == "arc" ? "<small style='color:red' > · ({#deleted#}) </small>" : ""; //create a new header if namespace changes if ($ns != $currentNamespace) { $result->list .= "<tr ><td colspan=22 ><h3 id={$ns} >" . $nsnames["names"][$ns] . "</h3></td></tr>"; $result->namespaces[$ns]["name"] = $nsnames["names"][$ns]; $currentNamespace = $ns; $currentNumber = 0; $currentLimit = false; } if (!isset($result->namespaces[$ns]["num"])) { $result->namespaces[$ns]["num"] = 0; } if (!isset($result->namespaces[$ns]["redir"])) { $result->namespaces[$ns]["redir"] = 0; } if (!isset($result->namespaces[$ns]["deleted"])) { $result->namespaces[$ns]["deleted"] = 0; } $result->namespaces[$ns]["num"] += 1; if ($redirect) { $result->namespaces[$ns]["redir"] += 1; } if ($deleted) { $result->namespaces[$ns]["deleted"] += 1; } $currentNumber++; if ($currentNumber > $rowLimit) { if ($currentLimit) { continue; } $newlimit = 10 * $limit; $result->list .= ' <tr><td colspan=22 style="padding-left:50px; "> <a href="//' . XTOOLS_BASE_WEB_DIR . "/pages/?user={$ui->userUrl}&lang={$lang}&wiki={$wiki}&namespace={$ns}&redirects={$redirects}&limit={$newlimit}" . '" ><strong>-{#more#}-</strong></a> </td></tr> '; $currentLimit = true; } else { $result->list .= "\n\t\t\t\t\t<tr>\n\t\t\t\t\t<td>{$currentNumber}.</td>\n\t\t\t\t\t<td style='max-width:50%; white-space:wrap; word-wrap:break-word' ><a href=\"//{$domain}/wiki/{$pageurl}?redirect=no\" >{$page}</a> {$redirect} {$deleted}</td>\n\t\t\t\t\t<td style='white-space: nowrap; font-size:95%; padding-right:10px;' >{$date}</td>\n\t\t\t\t\t<td style='white-space: nowrap' ><a href=\"//{$domain}/w/index.php?title=Special:Log&type=&page={$pageurl}\" ><small>log</small></a> · </td>\n\t\t\t\t\t<td style='white-space: nowrap' ><a href=\"//" . XTOOLS_BASE_WEB_DIR . "/articleinfo/?lang={$lang}&wiki={$wiki}&page={$pageurl}\" ><small>page history</small></a> · </td>\n\t\t\t\t\t<td style='white-space: nowrap' ><a href=\"//" . XTOOLS_BASE_WEB_DIR . "/topedits/?lang={$lang}&wiki={$wiki}&user={$ui->userUrl}&page={$pageurl}\" ><small>topedits</small></a></td>\n\t\t\t\t\t\n\t\t\t\t\t</tr>\n\t\t\t\t"; } } $result->filterns = $namespace; $result->filterredir = $redirects; $result->total = count($items); unset($items, $nsnames); //make serialized lists for graphics & toptable $sum["num"] = 0; $sum["redir"] = 0; $sum["deleted"] = 0; $chLabels = array(); $chValues = array(); $chColors = array(); foreach ($result->namespaces as $num => $ns) { $result->listnamespaces .= ' <tr> <td style="padding-right:10px"> <span class=legendicon style="background-color:' . $nscolors[$num] . '"> </span> <a href="#' . $num . '" >' . $ns["name"] . '</a> </td> <td class=tdnum >' . $ns["num"] . '</td> <td class=tdnum >' . $ns["redir"] . '</td> <td class=tdnum >' . $ns["deleted"] . '</td> </tr> '; $sum["num"] += isset($ns["num"]) ? $ns["num"] : 0; $sum["redir"] += isset($ns["redir"]) ? $ns["redir"] : 0; $sum["deleted"] += isset($ns["deleted"]) ? $ns["deleted"] : 0; $chValues[$num] = $ns["num"]; } $result->listnamespaces .= ' <tr> <td style="border-top:3px double silver;" ></td> <td class=tdnum style="border-top:3px double silver" ><strong>' . $wt->numFmt($sum["num"], 0, true) . '</strong></td> <td class=tdnum style="border-top:3px double silver" >' . $wt->numFmt($sum["redir"], 0, true) . '</td> <td class=tdnum style="border-top:3px double silver" >' . $wt->numFmt($sum["deleted"], 0, true) . '</td> </tr> '; $result->nschart = '<img height="140px" src="' . xGraph::makePieGoogle($chValues) . '" alt="some graph" />'; return $result; }
$redis->setex($hash, $ttl, serialize($cnt)); } } else { $cnt = unserialize($lc); unset($lc); $perflog->add('CNT', 0, 'from Redis'); } if ($cnt->error) { $perflog->stack[] = $cnt->error; $wt->toDie('error. ec::index::cnt -> ' . $cnt->error); } require_once 'Graph.php'; //Output stuff $wt->content = getPageTemplate("result"); //Make Graphs $graphNS = xGraph::makePieGoogle($cnt->getNamespaceTotals()); $legendNS = xGraph::makeLegendTable($cnt->getNamespaceTotals(), $cnt->getNamespaces()); $graphMonths = xGraph::makeHorizontalBar("month", $cnt->getMonthTotals(), 800, $cnt->getNamespaces()); $graphYears = xGraph::makeHorizontalBar("year", $cnt->getMonthTotals(), 800, $cnt->getNamespaces()); $gcolor1 = '99CCFF'; $gcolor2 = '99CC00'; $msgBytes = $I18N->msg('bytes'); $gminorpct = $cnt->mMinorEditsByte / $cnt->mLive * 100; $mdata = array($cnt->mMinorEditsByte, $cnt->mLive - $cnt->mMinorEditsByte); $mlabels = array("< 20 {$msgBytes} · " . $wt->numFmt($gminorpct, 1) . '%', "≥ 20 {$msgBytes} · " . $wt->numFmt(100 - $gminorpct, 1) . '%'); $mcolors = is_numeric($cnt->mMinorEditsByte) ? array($gcolor1, $gcolor2) : array('cccccc', 'cccccc'); $graphminorbyte = '<img alt="bla" src="' . xGraph::makeMiniPie($mdata, $mlabels, $mcolors, $wi->lang) . '" />'; $wt->assign('graphminorbyte', $graphminorbyte); $gminorpct = $cnt->mEditsSummary / $cnt->mLive * 100; $mdata = array($cnt->mLive - $cnt->mEditsSummary, $cnt->mEditsSummary); $mlabels = array($I18N->msg('no_summary') . ' · ' . $wt->numFmt(100 - $gminorpct, 1) . '%', $I18N->msg('with_summary') . ' · ' . $wt->numFmt($gminorpct, 1) . '%');