/** * Method for to create a info readme file about the album * * @param array $items album items */ public function createInfoFile($items) { $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Starting for create info text file.', 'priority' => JLog::INFO, 'section' => 'site'))); $PJContent = "Album Infos:\r\n"; $PJContent .= base64_decode(JRequest::getVar('name')) . ", " . base64_decode(JRequest::getVar('artist')) . "\r\n"; $PJContent .= "------------------------------------------------------------------------------\r\n"; foreach ($items as $i => $item) { if (JFile::exists($item->pathatlocal . DIRECTORY_SEPARATOR . $item->file)) { $PJContent .= $item->artist . ", " . $item->album . " - " . $item->tracknumber . " - " . $item->title . " (" . PlayJoomHelper::Playtime($item->length) . ")\r\n"; } else { $dispatcher->trigger('onEventLogging', array(array('method' => __METHOD__ . ":" . __LINE__, 'message' => 'Track ' . $item->title . ' isn´t available!', 'priority' => JLog::WARNING, 'section' => 'site'))); } } $PJContent .= "\r\n"; $PJContent .= "\r\n"; $About = array('artist' => JRequest::getVar('artist'), 'album' => JRequest::getVar('name'), 'type' => JRequest::getVar('type')); require_once JPATH_COMPONENT . '/apis/lastfm.php'; $ContentExist = PlayJoomLastfmHelper::CheckLastfmContent('album', $About); if ($ContentExist == true) { $PJContent .= "About the album:\r\n"; $PJContent .= "------------------------------------------------------------------------------\r\n"; $PJContent .= PlayJoomLastfmHelper::GetLastfmContent('album', $About)->album->wiki->content; $PJContent .= "------------------------------------------------------------------------------\r\n"; } $ContentExist = PlayJoomLastfmHelper::CheckLastfmContent('artist', $About); if ($ContentExist == true) { $PJContent .= "About the artist / band:\r\n"; $PJContent .= "------------------------------------------------------------------------------\r\n"; $PJContent .= PlayJoomLastfmHelper::GetLastfmContent('artist', $About)->artist->bio->content; $PJContent .= "------------------------------------------------------------------------------\r\n"; } $PJContent .= "\r\n"; $PJContent .= "\r\n"; $PJContent .= "------------------------------------------------------------------------------\r\n"; $PJContent .= "Archiv created by PlayJoom Server.\r\n"; $PJContent .= PlayJoomHelper::GetInstallInfo("description", "playjoom.xml") . "\r\n"; $PJContent .= "\r\n"; $PJContent .= "\r\n"; $PJContent .= "Version: " . PlayJoomHelper::GetInstallInfo("version", "playjoom.xml") . "\r\n"; $PJContent .= "copyright: " . PlayJoomHelper::GetInstallInfo("copyright", "playjoom.xml") . "\r\n"; $PJContent .= "web: " . PlayJoomHelper::GetInstallInfo("authorUrl", "playjoom.xml") . "\r\n"; $this->data[] = $PJContent; }
function display($tpl = null) { // Assign data to the view $this->info = $this->get('Info'); //Get setting values from xml file $app = JFactory::getApplication(); $params = $app->getParams(); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode('<br />', $errors)); return false; } $this->assignRef('params', $params); //load external data if (JRequest::getVar('source') == 'lastfm') { $About = array('artist' => JRequest::getVar('artist'), 'album' => JRequest::getVar('album'), 'genre' => JRequest::getVar('genre'), 'type' => JRequest::getVar('type')); require_once JPATH_COMPONENT . '/apis/lastfm.php'; $getLastFMContent = PlayJoomLastfmHelper::GetLastfmContent(JRequest::getVar('type'), $About); $this->assignRef('lastFMRequest', $getLastFMContent); } // Display the view parent::display($tpl); }
public static function checkInfoAbout($type, $AboutInfo, $params) { if ($params->get('info_source', 'owndb') == 'wiki') { require_once JPATH_COMPONENT . '/apis/wiki.php'; } if ($params->get('info_source', 'owndb') == 'lastfm') { require_once JPATH_COMPONENT . '/apis/lastfm.php'; } $db = JFactory::getDBO(); $query = $db->getQuery(true); switch ($type) { case "album": $About = base64_decode($AboutInfo['album']); $query->select('title,album_release,label,production,infotxt'); $query->from('#__jpalbums'); $query->where('title = "' . $About . '"'); $db->setQuery($query); $checkResult = $db->loadObject(); if ($db->loadObject() && $checkResult->infotxt != '') { return array('source' => 'db', 'album' => $About, 'artist' => null, 'genre' => null); } else { /* * wiki source */ if ($params->get('info_source', 'owndb') == 'wiki') { $PageID = PlayJoomWikiHelper::CheckWikiContent($About, 'de'); if ($PageID['pageid'] != '') { return array('source' => 'wiki', 'album' => $PageID['pageid'], 'artist' => null, 'genre' => null); } else { return array('source' => null, 'artist' => null, 'album' => null, 'genre' => null); } } else { if ($params->get('info_source', 'owndb') == 'lastfm') { $ContentExist = PlayJoomLastfmHelper::CheckLastfmContent($type, $AboutInfo); if ($ContentExist == true) { return array('source' => 'lastfm', 'album' => $About, 'artist' => base64_decode($AboutInfo['artist']), 'genre' => null); } else { return array('source' => null, 'artist' => null, 'album' => null, 'genre' => null); } } } } break; case "artist": $About = base64_decode($AboutInfo['artist']); $query->select('name,formation,members,infotxt'); $query->from('#__jpartists'); $query->where('name = "' . $About . '"'); $db->setQuery($query); $checkResult = $db->loadObject(); if ($db->loadObject() && $checkResult->infotxt != '') { return array('source' => 'db', 'artist' => $About, 'album' => null, 'genre' => null); } else { /* * wiki source */ if ($params->get('info_source', 'owndb') == 'wiki') { $PageID = PlayJoomWikiHelper::CheckWikiContent($About, 'de'); if ($PageID['pageid'] != '') { return array('source' => 'wiki', 'artist' => $PageID['pageid'], 'album' => null, 'genre' => null); } else { return array('source' => null, 'artist' => null, 'album' => null, 'genre' => null); } } else { if ($params->get('info_source', 'owndb') == 'lastfm') { $ContentExist = PlayJoomLastfmHelper::CheckLastfmContent($type, $AboutInfo); if ($ContentExist == true) { return array('source' => 'lastfm', 'album' => $About, 'artist' => base64_decode($AboutInfo['artist']), 'genre' => null); } else { return array('source' => null, 'artist' => null, 'album' => null, 'genre' => null); } } } } break; case "genre": $About = base64_decode($AboutInfo['genre']); $query->select('title,description'); $query->from('#__categories'); $query->where('extension = "com_playjoom"'); $query->where('title = "' . $About . '"'); $db->setQuery($query); $checkResult = $db->loadObject(); if ($db->loadObject() && $checkResult->description != '') { return array('source' => 'db', 'album' => null, 'artist' => null, 'genre' => $About); } else { /* * wiki source */ if ($params->get('info_source', 'owndb') == 'wiki') { $PageID = PlayJoomWikiHelper::CheckWikiContent($About, 'de'); if ($PageID['pageid'] != '') { return array('source' => 'wiki', 'value' => $PageID['pageid']); } else { return array('source' => null, 'artist' => null, 'album' => null, 'genre' => null); } } else { if ($params->get('info_source', 'owndb') == 'lastfm') { } } } break; case "track": $query->select('title,description'); $query->from('#__jpaudiotracks'); $query->where('id = "' . $about . '"'); $db->setQuery($query); $checkResult = $db->loadObject(); if ($db->loadObject() && $checkResult->description != '') { return array('source' => 'db', 'value' => 'true'); } else { return null; } break; default: return null; } }
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; } } }