BryanDavis has uploaded a new change for review. https://gerrit.wikimedia.org/r/266079
Change subject: Cleanup code style of list.php ...................................................................... Cleanup code style of list.php Apply MediaWiki coding style to list.php Change-Id: Ifee54298b5a05d572fd481e173bce20866a49986 --- M www/content/list.php 1 file changed, 124 insertions(+), 114 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/labs/toollabs refs/changes/79/266079/1 diff --git a/www/content/list.php b/www/content/list.php index de61f58..314e0f3 100644 --- a/www/content/list.php +++ b/www/content/list.php @@ -1,125 +1,135 @@ - <h1>Wikimedia Tool Labs</h1> - <p>Welcome to the Tool Labs project, the home of community-maintained external tools supporting Wikimedia projects and their users. On this page you can find a complete list of hosted tools along with any additional information provided by the tool maintainers. Labs users who have been granted access to the Tools project may also create a new tool or add/remove maintainers to or from a tool that they manage.</p> +<h1>Wikimedia Tool Labs</h1> +<p>Welcome to the Tool Labs project, the home of community-maintained external tools supporting Wikimedia projects and their users. On this page you can find a complete list of hosted tools along with any additional information provided by the tool maintainers. Labs users who have been granted access to the Tools project may also create a new tool or add/remove maintainers to or from a tool that they manage.</p> - <h2>Useful links</h2> - <ul> - <li><a href="https://wikitech.wikimedia.org/wiki/Nova_Resource:Tools">Tools project page on wikitech</a> (find out more about the Tools project)</li> - <li><a href="https://wikitech.wikimedia.org/w/index.php?title=Special:UserLogin&returnto=Main+Page&type=signup">Create a Labs account</a> (you must have a Labs account to access the Tools project)</li> - <li><a href="https://wikitech.wikimedia.org/wiki/Special:NovaKey">Add a public SSH key</a> (you’ll need this to access Labs servers using SSH)</li> - <li><a href="https://wikitech.wikimedia.org/wiki/Special:FormEdit/Tools_Access_Request">Request access to the Tools project</a> (Join us!)</li> - <li><a href="https://wikitech.wikimedia.org/w/index.php?title=Special:NovaServiceGroup&action=addservicegroup&projectname=tools">Create New Tool</a></li> - <li><a href="http://git.wikimedia.org/summary/labs%2Ftoollabs.git">Source code repository of this web</a></li> - </ul> +<h2>Useful links</h2> +<ul> +<li><a href="https://wikitech.wikimedia.org/wiki/Nova_Resource:Tools">Tools project page on wikitech</a> (find out more about the Tools project)</li> +<li><a href="https://wikitech.wikimedia.org/w/index.php?title=Special:UserLogin&returnto=Main+Page&type=signup">Create a Labs account</a> (you must have a Labs account to access the Tools project)</li> +<li><a href="https://wikitech.wikimedia.org/wiki/Special:NovaKey">Add a public SSH key</a> (you’ll need this to access Labs servers using SSH)</li> +<li><a href="https://wikitech.wikimedia.org/wiki/Special:FormEdit/Tools_Access_Request">Request access to the Tools project</a> (Join us!)</li> +<li><a href="https://wikitech.wikimedia.org/w/index.php?title=Special:NovaServiceGroup&action=addservicegroup&projectname=tools">Create New Tool</a></li> +<li><a href="http://git.wikimedia.org/summary/labs%2Ftoollabs.git">Source code repository of this web</a></li> +</ul> - <h2>Hosted tools</h2> +<h2>Hosted tools</h2> - <table id="thebigtable" class="tablesorter"> - <thead> - <tr> - <th>Tool</th> - <th>Maintainers</th> - <th>Notes</th> - </tr> - </thead> - <tbody> +<table id="thebigtable" class="tablesorter"> +<thead> +<tr> +<th>Tool</th> +<th>Maintainers</th> +<th>Notes</th> +</tr> +</thead> +<tbody> <?php - function describe($t) { - if(array_key_exists('description', $t)) { - global $purifier; - print $purifier->purify($t['description']); - if(array_key_exists('author', $t)) - print "<br/><i>Author(s): " . $purifier->purify($t['author']) . "</i>"; - if(array_key_exists('repository', $t)) - print "<br/><a href=\"" . htmlspecialchars($t['repository']) . "\">Source</a>"; - } - } +function describe( $t ) { + if ( array_key_exists( 'description', $t ) ) { + global $purifier; + echo $purifier->purify( $t['description'] ); + if ( array_key_exists( 'author', $t ) ) { + echo '<br/><i>Author(s): ', $purifier->purify( $t['author'] ), '</i>'; + } + if ( array_key_exists( 'repository', $t ) ) { + echo '<br/><a href="', htmlspecialchars( $t['repository'] ), '">Source</a>'; + } + } +} - # Query list of active web services. - $active_proxy = file_get_contents('/etc/active-proxy'); - $active_proxies_json = file_get_contents('http://' . $active_proxy . ':8081/list'); - $tooldyn = array(); - if ($active_proxies_json == false) { - error_log('Cannot retrieve list of active proxies from http://' . $active_proxy . ':8081/list'); - } else { - $active_proxies = json_decode($active_proxies_json, true); - foreach ($active_proxies as $key => $value) { - if(array_key_exists('status', $value) && $value['status'] == 'active') { - $tooldyn[$key] = 1; - } - } - } +// Query list of active web services. +$active_proxy = file_get_contents( '/etc/active-proxy' ); +$active_proxies_json = file_get_contents( 'http://' . $active_proxy . ':8081/list' ); +$tooldyn = array(); +if ( $active_proxies_json === false ) { + error_log( 'Cannot retrieve list of active proxies from http://' . $active_proxy . ':8081/list' ); +} else { + $active_proxies = json_decode( $active_proxies_json, true ); + foreach ( $active_proxies as $key => $value ) { + if ( array_key_exists( 'status', $value) && + $value['status'] == 'active' ) { + $tooldyn[$key] = 1; + } + } +} - $ini = parse_ini_file("/data/project/admin/replica.my.cnf"); - $db = new mysqli("tools.labsdb", $ini['user'], $ini['password'], "toollabs_p"); - - $res = $db->query("SELECT * FROM users"); - while($row = $res->fetch_assoc()) { - $users[$row['name']] = $row; - } - $res->free(); - - $res = $db->query("SELECT * FROM tools ORDER BY name ASC"); - while($row = $res->fetch_assoc()): +$ini = parse_ini_file( '/data/project/admin/replica.my.cnf' ); +$db = new mysqli( 'tools.labsdb', $ini['user'], $ini['password'], 'toollabs_p' ); - $tool = $row['name']; - if($row['toolinfo'] != '' && !is_null(json_decode($row['toolinfo'], true))) { - $json = json_decode($row['toolinfo'], true); - } else { - $json = array( - "description" => $row['description'], - ); - } +$res = $db->query( 'SELECT * FROM users' ); +while ( $row = $res->fetch_assoc() ) { + $users[$row['name']] = $row; +} +$res->free(); - if(array_key_exists(0, $json) && !array_key_exists(1, $json)) { - $json = $json[0]; - } +$res = $db->query( 'SELECT * FROM tools ORDER BY name ASC' ); +while ( $row = $res->fetch_assoc() ) { + $tool = $row['name']; + if ( $row['toolinfo'] != '' && + !is_null( json_decode( $row['toolinfo'], true ) ) + ) { + $json = json_decode( $row['toolinfo'], true ); + } else { + $json = array( 'description' => $row['description'] ); + } + + if ( array_key_exists( 0, $json ) && !array_key_exists( 1, $json ) ) { + $json = $json[0]; + } ?> - <tr class="tool" id="toollist-<?= $tool ?>"> - <td class="tool-name"><?php - - if(array_key_exists('url', $json)) { - print "<a class=\"tool-web\" href=\"" . $json['url'] . "\">$tool</a>"; - } elseif(array_key_exists($tool, $tooldyn) && !array_key_exists(0, $json)) { - print "<a class=\"tool-web\" href=\"/$tool/\">$tool</a>"; - } else { - print $tool; - } - +<tr class="tool" id="toollist-<?= htmlspecialchars( $tool ) ?>"> +<td class="tool-name"> +<?php + if ( array_key_exists( 'url', $json ) ) { + echo '<a class="tool-web" href="', htmlspecialchars( $json['url'] ), '">', htmlspecialchars( $tool ), '</a>'; + } elseif ( array_key_exists( $tool, $tooldyn ) && + !array_key_exists( 0, $json ) + ) { + echo '<a class="tool-web" href="/', urlencode( $tool ), '/">', htmlspecialchars( $tool ), '</a>'; + } else { + echo htmlspecialchars( $tool ); + } ?> - <span class="mw-editsection"> - [<a href="https://wikitech.wikimedia.org/w/index.php?title=Special:NovaServiceGroup&action=managemembers&projectname=tools&servicegroupname=tools.<?=$tool?>">manage</a> maintainers] - </span> - </td> - <td class="tool-maintainers"><?php - foreach(explode(' ', $row['maintainers']) as $maint): - if(array_key_exists($maint, $users)): - $maint = htmlspecialchars($users[$maint]['wikitech']); - ?><a href="https://wikitech.wikimedia.org/wiki/User:<?= $maint ?>"><?= ucfirst($maint) ?></a><?php - endif; - endforeach; -?></td> - <td class="tool-desc"><?php - if(array_key_exists(1, $json)) { - $first = " first"; - foreach($json as $sub) { - echo "<div class=\"subtool$first\"><span class=\"subtool-name\">"; - if(array_key_exists('url', $sub)) - echo "<a href=\"" . htmlspecialchars($sub['url']) . "\">"; - echo htmlspecialchars($sub['title']); - if(array_key_exists('url', $sub)) - echo "</a>"; - echo "</span><span class=\"subtool-desc\">"; - describe($sub); - echo "</span></div>"; - $first = ''; - } - } else { - describe($json); - } - ?></td> - </tr> -<?php endwhile; - $res->free(); +<span class="mw-editsection">[<a href="https://wikitech.wikimedia.org/w/index.php?title=Special:NovaServiceGroup&action=managemembers&projectname=tools&servicegroupname=tools.<?= urlencode( $tool )?>">manage</a> maintainers]</span> +</td> +<td class="tool-maintainers"> +<?php + foreach ( explode (' ', $row['maintainers'] ) as $maint ) { + if ( array_key_exists( $maint, $users ) ) { + $maint = $users[$maint]['wikitech']; ?> - </tbody> - </table> + <a href="https://wikitech.wikimedia.org/wiki/User:<?= urlencode( $maint ) ?>"><?= htmlspecialchars( ucfirst($maint) ) ?></a> +<?php + } // end if + } // end foreach +?> +</td> +<td class="tool-desc"> +<?php + if ( array_key_exists( 1, $json ) ) { + $first = ' first'; + foreach ( $json as $sub ) { + echo '<div class="subtool', $first, '"><span class="subtool-name">'; + if ( array_key_exists( 'url', $sub ) ) { + echo "<a href=\"" . htmlspecialchars( $sub['url'] ) . "\">"; + } + echo htmlspecialchars( $sub['title'] ); + if ( array_key_exists( 'url', $sub ) ) { + echo '</a>'; + } + echo '</span><span class="subtool-desc">'; + describe( $sub ); + echo '</span></div>'; + $first = ''; + } + } else { + describe( $json ); + } +?> +</td> +</tr> +<?php +} // end while +$res->free(); +?> +</tbody> +</table> -- To view, visit https://gerrit.wikimedia.org/r/266079 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifee54298b5a05d572fd481e173bce20866a49986 Gerrit-PatchSet: 1 Gerrit-Project: labs/toollabs Gerrit-Branch: master Gerrit-Owner: BryanDavis <bda...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits