/**
* Builds a list of the help sites which can be used in a select option.
*
* @param string $pathToXml Path to an XML file.
*
* @return array An array of arrays (text, value, selected).
*
* @since 1.5
*/
public static function createSiteList($pathToXml)
{
$list = array();
$xml = false;
if (!empty($pathToXml)) {
$xml = simplexml_load_file($pathToXml);
}
if (!$xml) {
$option['text'] = 'English (GB) help.joomla.org';
$option['value'] = 'https://help.joomla.org';
$list[] = (object) $option;
} else {
$option = array();
foreach ($xml->sites->site as $site) {
$option['text'] = (string) $site;
$option['value'] = (string) $site->attributes()->url;
$list[] = (object) $option;
}
}
return $list;
}