Пример #1
0
 /**
  * @access private
  */
 function getElements(&$elements)
 {
     $podcast_values = get_object_vars($this);
     foreach ($podcast_values as $key => $value) {
         if (in_array($key, array('enclosure_url', 'enclosure_length', 'enclosure_type'))) {
             continue;
         }
         if (strlen($value)) {
             $elements['itunes:' . $key] = MG_escape($value);
         }
     }
 }
Пример #2
0
function MG_getMP3Items(&$album_data)
{
    global $_TABLES, $_MG_CONF;
    $retval = '';
    if (isset($album_data['album_id'])) {
        $aid = $album_data['album_id'];
        if ($album_data['access'] >= 1) {
            $albumCover = MG_getAlbumCover($aid);
            if ($albumCover != '') {
                if (substr($albumCover, 0, 3) == 'tn_') {
                    $offset = 3;
                } else {
                    $offset = 0;
                }
                foreach ($_MG_CONF['validExtensions'] as $ext) {
                    if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $albumCover[$offset] . '/' . $albumCover . $ext)) {
                        $image = $_MG_CONF['mediaobjects_url'] . '/tn/' . $albumCover[$offset] . '/' . $albumCover . $ext;
                        break;
                    }
                }
            } else {
                $image = '';
            }
            if ($album_data['tn_attached'] == 1) {
                foreach ($_MG_CONF['validExtensions'] as $ext) {
                    if (file_exists($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $aid . $ext)) {
                        $image = $_MG_CONF['mediaobjects_url'] . '/covers/cover_' . $aid . $ext;
                        break;
                    }
                }
            }
            $sql = MG_buildMediaSql(array('album_id' => $aid, 'fields' => array('media_type', 'media_filename', 'media_mime_ext', 'media_tn_attached', 'media_title', 'artist', 'album', 'media_id'), 'where' => "m.media_type = 2 AND m.mime_type = 'audio/mpeg'"));
            $result = DB_query($sql);
            while ($row = DB_fetchArray($result)) {
                if ($row['media_type'] == 0) {
                    $PhotoURL = MG_getFileUrl($src, $row['media_filename']);
                } else {
                    $PhotoURL = MG_getFileUrl('orig', $row['media_filename'], $row['media_mime_ext']);
                }
                if ($row['media_tn_attached'] == 1) {
                    foreach ($_MG_CONF['validExtensions'] as $ext) {
                        if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext)) {
                            $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext;
                            $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext;
                            break;
                        }
                    }
                } else {
                    $media_thumbnail = '';
                }
                if ($media_thumbnail != '') {
                    if (!file_exists($media_thumbnail_file)) {
                        $medai_thumbnail = '';
                    }
                }
                $retval .= "        <track>\n";
                $retval .= "            <title>" . MG_escape($row['media_title']) . "</title>\n";
                $retval .= "            <annotation>" . MG_escape($row['media_title']) . "</annotation>\n";
                if ($row['artist'] != '') {
                    $retval .= "            <creator>" . MG_escape($row['artist']) . "</creator>\n";
                }
                if ($row['album'] != '') {
                    $retval .= "            <album>" . MG_escape($row['album']) . "</album>\n";
                }
                $retval .= "            <identifier>" . $row['media_id'] . "</identifier>\n";
                $retval .= "            <location>" . $PhotoURL . "</location>\n";
                if ($media_thumbnail != '') {
                    $retval .= "            <image>" . $media_thumbnail . "</image>\n";
                } else {
                    if ($image != '') {
                        $retval .= "            <image>" . $image . "</image>\n";
                    }
                }
                $retval .= "        </track>\n";
            }
        }
        return $retval;
    }
}