public static function LanguageMethod($Type, $About = array()) { $dispatcher = JDispatcher::getInstance(); $XmlStructure = null; //Get language $lang = JFactory::getLanguage(); $localset = $lang->getLocale(); $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Localset for language is ' . $localset['4'] . '.', 'priority' => JLog::INFO, 'section' => 'site'))); //Get config for LastFM API $GetConf = PlayJoomHelper::getConfig('LastFM', JPATH_COMPONENT . '/playjoom.conf.php'); $Url = $GetConf->get('lastFM_Url'); //Set values $AboutAlbum = base64_decode($About['album']); $AboutArtist = base64_decode($About['artist']); $Methods = PlayJoomLastfmHelper::getAPIMethod($Type) . '&api_key=' . $GetConf->get('lastFM_ApiKey') . '&artist=' . urlencode($AboutArtist) . '&album=' . urlencode($AboutAlbum) . '&lang=' . $localset['4']; if ($Methods && $Url) { $Xml = new DomDocument(); $Xml->preserveWhiteSpace = false; $Xml->formatOutput = true; if (@$Xml->load($Url . '?method=' . $Methods) === false) { $Xml = null; $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'No valid xml content for method ' . $Methods . ' $Xml=null', 'priority' => JLog::WARNING, 'section' => 'site'))); } else { $Xml = simplexml_load_file($Url . '?method=' . $Methods, 'SimpleXMLElement', LIBXML_NOCDATA); $XmlStructure = PlayJoomLastfmHelper::getXmlStructure($Type, $Xml); } } else { $XmlStructure = null; } if ($XmlStructure != '') { return $Methods; } else { $Methods = PlayJoomLastfmHelper::getAPIMethod($Type) . '&api_key=' . $GetConf->get('lastFM_ApiKey') . '&artist=' . urlencode($AboutArtist) . '&album=' . urlencode($AboutAlbum); if ($Methods && $Url) { $Xml = new DomDocument(); $Xml->preserveWhiteSpace = false; $Xml->formatOutput = true; $Xml->validateOnParse = true; if (@$Xml->load($Url . '?method=' . $Methods) === false) { $Xml = null; } else { $Xml = simplexml_load_file($Url . '?method=' . $Methods, 'SimpleXMLElement', LIBXML_NOCDATA); $XmlStructure = PlayJoomLastfmHelper::getXmlStructure($Type, $Xml); } } else { $XmlStructure = null; } if ($XmlStructure) { return $Methods; } else { return false; } } }