/** * 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; }
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; } }