public function __destruct() { LabsDB::purgeConnections(); }
public static function purgeConnections() { // PDO doesn't have an explicit close method. // Just dereference them. self::$dbConnections = array(); }
/** * @return array */ public function getWikiInfo() { return LabsDB::getDbInfo($this->dbname); }
function kfGetAllWikiOptionHtml($options = array()) { new kfLogSection(__FUNCTION__); // Options $defaultOptions = array('group' => true, 'current' => null, 'exclude' => array()); $options = $options + $defaultOptions; $wikiInfos = LabsDB::getAllWikiInfos(); $optionsHtml = ''; $optionsHtmlGroups = array(); foreach ($wikiInfos as $wikiInfo) { if (in_array($wikiInfo['dbname'], $options['exclude'])) { continue; } $hostname = parse_url($wikiInfo['url'], PHP_URL_HOST); if (!$hostname) { kfLog("Unable to parse hostname of {$wikiInfo['dbname']}: '{$wikiInfo['url']}'"); continue; } $optionHtml = Html::element('option', array('value' => $wikiInfo['dbname'], 'selected' => $wikiInfo['dbname'] === $options['current'], 'data-url' => $hostname), $hostname); if ($options['group']) { if (!isset($optionsHtmlGroups[$wikiInfo['family']])) { $optionsHtmlGroups[$wikiInfo['family']] = ''; } $optionsHtmlGroups[$wikiInfo['family']] .= $optionHtml; } else { $optionsHtml .= $optionHtml; } } if ($options['group']) { foreach ($optionsHtmlGroups as $family => $groupHtml) { $optionsHtml .= Html::openElement('optgroup', array('label' => $family)) . $groupHtml . '</optgroup>'; } } return $optionsHtml; }