<?php
 class vB_Library_Language extends vB_Library { public function getLanguages(int $languageid = 0, bool $baseonly = false) : array { $bf_misc_languageoptions = vB::getDatastore()->getValue('bf_misc_languageoptions'); $languages = vB::getDbAssertor()->getRows('fetchLanguages', [ 'baseonly' => $baseonly, 'direction' => $bf_misc_languageoptions['direction'], 'languageid' => $languageid, ], false, 'languageid' ); if (count($languages) == 0) { throw new vB_Exception_Api('invalid_language_specified'); } if ($languageid) { return reset($languages); } return $languages; } public function getLanguageCache() : array { $languages = vB::getDatastore()->getValue('languagecache'); if (!$languages) { $languages = $this->buildLanguageCache(); } return $languages; } public function buildLanguageCache() : array { $languagecache = $this->getLanguages(); vB::getDatastore()->buildSerialized('languagecache', $languagecache); return $languagecache; } public function rebuildAllLanguages() : void { $this->rebuildLanguage(-1); } public function rebuildLanguage(int $languageid) : void { require_once(DIR . '/includes/adminfunctions.php'); require_once(DIR . '/includes/adminfunctions_language.php'); build_language($languageid); } } 