public function testGetWebsitesByDataType() { require_once TEST_FILES . 'config/sources.php'; $obj = new _Project(); $this->integer(count($obj->getWebsitesByDataType($sites, 'lang')))->isEqualTo(4); $this->integer(count($obj->getWebsitesByDataType($sites, 'raw')))->isEqualTo(1); }
<?php namespace Langchecker; use Transvision\Json; $json_data = []; // $filename is set in /inc/init.php $current_filename = $filename != '' ? $filename : 'snippets.lang'; $string_id = isset($_GET['stringid']) ? Utils::secureText($_GET['stringid']) : false; $supported_file = false; // Search which website has the requested file foreach (Project::getWebsitesByDataType($sites, 'lang') as $site) { if (in_array($current_filename, Project::getWebsiteFiles($site))) { $current_website = $site; $supported_file = true; break; } } if (!$supported_file) { // File is not managed, throw error http_response_code(400); die("File {$current_filename} is not supported. Check the file name and try again."); } $reference_locale = Project::getReferenceLocale($current_website); $reference_data = LangManager::loadSource($current_website, $reference_locale, $current_filename); if (!$string_id) { // Display list of links to strings header("Content-type:text/html; charset=utf-8"); echo "<ul>\n"; foreach ($reference_data['strings'] as $current_string => $value) { $string_hash = sha1($current_string);
<?php namespace Langchecker; use Transvision\Json; $output_array = []; $lang_based_sites = Project::getWebsitesByDataType($sites, 'lang'); if ($website != '' && $filename != '') { if (isset($lang_based_sites[$website])) { $current_website = $lang_based_sites[$website]; $current_filename = $filename; if (in_array($current_filename, Project::getWebsiteFiles($current_website))) { $output_array = array_values(Project::getSupportedLocales($current_website, $current_filename, $langfiles_subsets)); } } } elseif ($project != '') { switch ($project) { case 'locamotion': $output_array = $locamotion_locales; break; case 'marketplacebadge': $output_array = $marketplacebadge_locales; break; case 'slogans': $output_array = $slogans_locales; break; case 'snippets': $output_array = $snippets_locales; break; case 'snippets_main': $output_array = $snippets_main_locales;