Пример #1
0
function create_music($params)
{
    $limit = 50;
    if (array_key_exists('limit', $params)) {
        $limit = $params['limit'];
    }
    $res = '';
    $query = sprintf('SELECT id,title,track,artist,album,comment,year,genre,filename,date FROM TbMsHearing ORDER BY date DESC LIMIT %s', $limit);
    $result = my_mysql_query($query);
    $res .= multi_accordion_start();
    while ($row = $result->fetch_assoc()) {
        $header = $row['title'] . ' / ' . $row['album'] . ' / ' . $row['artist'];
        $body = '';
        $body .= '<ul>';
        $body .= '<li>id: ' . $row['id'] . '</li>';
        $body .= '<li>title: ' . $row['title'] . '</li>';
        $body .= '<li>track: ' . $row['track'] . '</li>';
        $body .= '<li>artist: ' . $row['artist'] . '</li>';
        $body .= '<li>album: ' . $row['album'] . '</li>';
        $body .= '<li>comment: ' . $row['comment'] . '</li>';
        $body .= '<li>year: ' . $row['year'] . '</li>';
        $body .= '<li>genre: ' . $row['genre'] . '</li>';
        $body .= '<li>filename: ' . $row['filename'] . '</li>';
        $body .= '<li>date: ' . $row['date'] . '</li>';
        $body .= '</ul>';
        $res .= multi_accordion_entry($header, $body);
    }
    my_mysql_free_result($result);
    $res .= multi_accordion_end();
    return $res;
}
Пример #2
0
function create_works($params)
{
    // debugging aid that was removed...
    //error_log(var_export($params,true),0);
    // TODO: throw error if type param does not exist
    $type = $params['type'];
    if (array_key_exists('limit', $params)) {
        $limit = $params['limit'];
    } else {
        $limit = 100000;
        // limitless
    }
    if (array_key_exists('order', $params)) {
        $limit = $params['order'];
    } else {
        $order = 'DESC';
    }
    $res = '';
    // collecting other table data ...
    $honorifics = my_mysql_query_hash('SELECT * FROM TbIdHonorific', 'id');
    $contrib = my_mysql_query_hash('SELECT * FROM TbWkWorkContrib', 'id');
    $types = my_mysql_query_hash('SELECT * FROM TbWkWorkType', 'id');
    $locations = my_mysql_query_hash('SELECT * FROM TbLocation', 'id');
    $devices = my_mysql_query_hash('SELECT * FROM TbDevice', 'id');
    $languages = my_mysql_query_hash('SELECT * FROM TbLanguage', 'id');
    $persons = my_mysql_query_hash('SELECT * FROM TbIdPerson', 'id');
    $personexternal = my_mysql_query_hash('SELECT * FROM TbIdPersonExternal', 'id');
    $organizations = my_mysql_query_hash('SELECT * FROM TbOrganization', 'id');
    $external = my_mysql_query_hash('SELECT * FROM TbExternalType', 'id');
    $workexternal = my_mysql_query_hash('SELECT * FROM TbWkWorkExternal', 'id');
    $contribtype = my_mysql_query_hash('SELECT * FROM TbWkWorkContribType', 'id');
    #$works=my_mysql_query_hash('SELECT * FROM TbWkWork','id');
    # create a hash table of lists of contributors
    $work_contrib = array();
    $role_contrib = array();
    $work_contrib_org = array();
    $role_contrib_org = array();
    foreach ($contrib as $id => $row) {
        $workId = $row['workId'];
        $personId = $row['personId'];
        $organizationId = $row['organizationId'];
        $typeId = $row['typeId'];
        if ($personId != NULL) {
            if (!isset($work_contrib[$workId])) {
                $work_contrib[$workId] = array();
                $role_contrib[$workId] = array();
            }
            $work_contrib[$workId][] = $personId;
            $role_contrib[$workId][] = $typeId;
        }
        if ($organizationId != NULL) {
            if (!isset($work_contrib_org[$workId])) {
                $work_contrib_org[$workId] = array();
                $role_contrib_org[$workId] = array();
            }
            $work_contrib_org[$workId][] = $organizationId;
            $role_contrib_org[$workId][] = $typeId;
        }
    }
    # create a hash table of external ids for works
    $workexternal_externalid = array();
    $workexternal_externalcode = array();
    foreach ($workexternal as $id => $row) {
        $workId = $row['workId'];
        $externalId = $row['externalId'];
        $externalCode = $row['externalCode'];
        $workexternal_externalid[$workId][] = $externalId;
        $workexternal_externalcode[$workId][] = $externalCode;
    }
    # create a hash table of external ids for people
    $personexternal_externalid = array();
    $personexternal_externalcode = array();
    # create an empty entry for every person
    foreach ($persons as $id => $row) {
        $personexternal_externalid[$id] = array();
        $personexternal_externalcode[$id] = array();
    }
    # fill with external ids
    foreach ($personexternal as $id => $row) {
        $personId = $row['personId'];
        $externalId = $row['externalId'];
        $externalCode = $row['externalCode'];
        $personexternal_externalid[$personId][] = $externalId;
        $personexternal_externalcode[$personId][] = $externalCode;
    }
    // sending query
    switch ($type) {
        case 'audio':
            $add = 'TbWkWorkType.isAudio=1';
            break;
        case 'video':
            $add = 'TbWkWorkType.isVideo=1';
            break;
        case 'text':
            $add = 'TbWkWorkType.isText=1';
            break;
        default:
            $add = 'TbWkWorkType.name=\'' . $type . '\'';
            break;
    }
    #$query=sprintf('SELECT TbWkWork.id,TbWkWork.name,TbWkWork.length,TbWkWork.size,TbWkWork.chapters,TbWkWork.typeId,TbWkWork.languageId,TbWkWorkView.startViewDate,TbWkWorkView.endViewDate,TbWkWorkViewPerson.viewerId,TbWkWorkView.locationId,TbWkWorkView.deviceId,TbWkWorkView.langId,TbWkWorkReview.ratingId,TbWkWorkReview.review,TbWkWorkReview.reviewDate FROM TbWkWorkViewPerson,TbWkWork,TbWkWorkType,TbWkWorkReview,TbWkWorkView WHERE TbWkWork.typeId=TbWkWorkType.id AND TbWkWorkViewPerson.viewId=TbWkWorkView.id AND TbWkWorkReview.workId=TbWkWork.id AND TbWkWorkView.workId=TbWkWork.id AND %s ORDER BY TbWkWorkView.endViewDate %s LIMIT %s',$add,$order,$limit);
    $query = sprintf('SELECT TbWkWork.id,TbWkWork.name,TbWkWork.length,TbWkWork.size,TbWkWork.chapters,TbWkWork.typeId,TbWkWork.languageId,TbWkWorkView.startViewDate,TbWkWorkView.endViewDate,TbWkWorkViewPerson.viewerId,TbWkWorkView.locationId,TbWkWorkView.deviceId,TbWkWorkView.langId,TbWkWorkReview.ratingId,TbWkWorkReview.review,TbWkWorkReview.reviewDate FROM TbWkWorkViewPerson,TbWkWorkType,TbWkWork LEFT JOIN TbWkWorkView ON TbWkWorkView.workId=TbWkWork.id LEFT JOIN TbWkWorkReview ON TbWkWorkReview.workId=TbWkWork.id WHERE TbWkWork.typeId=TbWkWorkType.id AND TbWkWorkViewPerson.viewId=TbWkWorkView.id AND %s ORDER BY TbWkWorkView.endViewDate %s LIMIT %s', $add, $order, $limit);
    $result = my_mysql_query($query);
    $res .= multi_accordion_start();
    $body = '';
    // printing table rows
    $currid = NULL;
    while ($row = $result->fetch_assoc()) {
        // finish the previous entry if that is the case
        if ($currid != $row['id']) {
            if ($currid != NULL) {
                $body .= '</ul>';
                $res .= multi_accordion_entry($header, $body);
            }
        }
        if ($row['typeId'] != NULL) {
            $s_type = $types[$row['typeId']]['name'];
        } else {
            $s_type = get_na_string();
        }
        if ($row['languageId'] != NULL) {
            $s_language = $languages[$row['languageId']]['name'];
        } else {
            $s_language = get_na_string();
        }
        if ($row['locationId'] != NULL) {
            $s_location = $locations[$row['locationId']]['name'];
        } else {
            $s_location = get_na_string();
        }
        if ($row['deviceId'] != NULL) {
            $s_device = $devices[$row['deviceId']]['name'];
        } else {
            $s_device = get_na_string();
        }
        if ($row['langId'] != NULL) {
            $s_lang = $languages[$row['langId']]['name'];
        } else {
            $s_lang = get_na_string();
        }
        if ($row['viewerId'] != NULL) {
            $s_viewer = get_full_name($persons[$row['viewerId']], $honorifics);
        } else {
            $s_viewer = get_na_string();
        }
        if ($row['size'] != NULL) {
            $s_size = formatSize($row['size']);
        }
        if ($row['length'] != NULL) {
            $s_length = formatTimeperiod($row['length']);
        }
        if ($row['name'] != NULL) {
            $header = $row['name'];
        } else {
            $header = 'No Name';
        }
        # append contributors to the header...(do not include organizations)
        if (isset($work_contrib[$row['id']])) {
            $cont_array = array();
            foreach ($work_contrib[$row['id']] as $personId) {
                $cont_array[] = get_full_name($persons[$personId], $honorifics);
            }
            if (count($cont_array) > 0) {
                $header .= ' / ' . join($cont_array, ', ');
            }
        }
        if ($currid != $row['id']) {
            $currid = $row['id'];
            $body = '';
            $body .= '<ul>';
            if ($row['id'] != NULL) {
                $body .= '<li>id: ' . $row['id'] . '</li>';
            }
            if ($row['name'] != NULL) {
                $body .= '<li>name: ' . $row['name'] . '</li>';
            }
            if ($row['length'] != NULL) {
                $body .= '<li>length: ' . $s_length . '</li>';
            }
            if ($row['size'] != NULL) {
                $body .= '<li>size: ' . $s_size . '</li>';
            }
            if ($row['chapters'] != NULL) {
                $body .= '<li>chapters: ' . $row['chapters'] . '</li>';
            }
            if ($row['typeId'] != NULL) {
                $body .= '<li>type: ' . $s_type . '</li>';
            }
            if ($row['languageId'] != NULL) {
                $body .= '<li>language: ' . $s_language . '</li>';
            }
            # contributor stuff
            if (isset($work_contrib[$row['id']])) {
                $j = 0;
                foreach ($work_contrib[$row['id']] as $personId) {
                    $name = get_full_name($persons[$personId], $honorifics);
                    $roleid = $role_contrib[$row['id']][$j];
                    $role_name = $contribtype[$roleid]['name'];
                    $body .= '<li>' . $role_name . ': ' . $name;
                    $j++;
                    $e = 0;
                    foreach ($personexternal_externalid[$personId] as $externalid) {
                        $externalcode = $personexternal_externalcode[$personId][$e];
                        $externalname = $external[$externalid]['name'];
                        $externalidname = $external[$externalid]['idname'];
                        $link = get_external_href($externalname, $externalcode);
                        $link = '<a href=\'' . $link . '\'>' . $externalidname . ': ' . $externalcode . '</a>';
                        $body .= ' ' . $link;
                        $e++;
                    }
                    $body .= '</li>';
                }
            }
            if (isset($work_contrib_org[$row['id']])) {
                $j = 0;
                foreach ($work_contrib_org[$row['id']] as $organizationId) {
                    $name = $organizations[$organizationId]['name'];
                    $url = $organizations[$organizationId]['url'];
                    $roleid = $role_contrib_org[$row['id']][$j];
                    $role_name = $contribtype[$roleid]['name'];
                    $body .= '<li>' . $role_name . ': ' . '<a href=\'' . $url . '\'>' . $name . '</a></li>';
                    $j++;
                }
            }
            # external stuff
            $j = 0;
            if (isset($workexternal_externalid[$row['id']])) {
                foreach ($workexternal_externalid[$row['id']] as $externalid) {
                    $externalcode = $workexternal_externalcode[$row['id']][$j];
                    $externalname = $external[$externalid]['name'];
                    $externalidname = $external[$externalid]['idname'];
                    $link = get_external_href($externalname, $externalcode);
                    $link = '<a href=\'' . $link . '\'>' . $externalidname . ': ' . $externalcode . '</a>';
                    $body .= '<li>' . $link . '</li>';
                    $j++;
                }
            }
        }
        # view stuff
        if ($row['startViewDate'] != NULL) {
            $body .= '<li>start view date: ' . $row['startViewDate'] . '</li>';
        }
        if ($row['endViewDate'] != NULL) {
            $body .= '<li>end view date: ' . $row['endViewDate'] . '</li>';
        }
        if ($row['viewerId'] != NULL) {
            $body .= '<li>viewer: ' . $s_viewer . '</li>';
        }
        if ($row['locationId'] != NULL) {
            $body .= '<li>location: ' . $s_location . '</li>';
        }
        if ($row['deviceId'] != NULL) {
            $body .= '<li>device: ' . $s_device . '</li>';
        }
        if ($row['langId'] != NULL) {
            $body .= '<li>lang: ' . $s_lang . '</li>';
        }
        # review stuff
        if ($row['ratingId'] != NULL) {
            $body .= '<li>rating: ' . $row['ratingId'] . '</li>';
        }
        if ($row['review'] != NULL) {
            $body .= '<li>review: ' . $row['review'] . '</li>';
        }
        if ($row['reviewDate'] != NULL) {
            $body .= '<li>review date: ' . $row['reviewDate'] . '</li>';
        }
    }
    if ($currid != NULL) {
        $body .= '</ul>';
        $res .= multi_accordion_entry($header, $body);
    }
    my_mysql_free_result($result);
    $res .= multi_accordion_end();
    return $res;
}
Пример #3
0
function create_lilypond($params)
{
    $res = '';
    // sending query
    $query = sprintf('SELECT id,uuid,title,subtitle,composer,poet,style,piece,copyright,pages,idyoutube,epdfs FROM TbMsLilypond order by title asc');
    $result = my_mysql_query($query);
    $res .= multi_accordion_start();
    while ($row = $result->fetch_assoc()) {
        $id = $row['id'];
        $s_uuid = $row['uuid'];
        $s_title = val_or_na($row['title']);
        $s_subtitle = val_or_na($row['subtitle']);
        $s_composer = val_or_na($row['composer']);
        $s_poet = val_or_na($row['poet']);
        $s_style = val_or_na($row['style']);
        $s_piece = val_or_na($row['piece']);
        $s_copyright = val_or_na($row['copyright']);
        $s_pages = val_or_na($row['pages']);
        $s_epdfs = val_or_na($row['epdfs']);
        $link_ly = link_to_direct('GetRsBlob.php?slug=' . $s_uuid . '-ly');
        $link_pdf = link_to_direct('GetRsBlob.php?slug=' . $s_uuid . '-pdf');
        $link_ps = link_to_direct('GetRsBlob.php?slug=' . $s_uuid . '-ps');
        $link_midi = link_to_direct('GetRsBlob.php?slug=' . $s_uuid . '-midi');
        $link_wav = link_to_direct('GetRsBlob.php?slug=' . $s_uuid . '-wav');
        $link_mp3 = link_to_direct('GetRsBlob.php?slug=' . $s_uuid . '-mp3');
        $link_ogg = link_to_direct('GetRsBlob.php?slug=' . $s_uuid . '-ogg');
        $s_a_ly = '<a href=' . $link_ly . '>ly</a>';
        $s_a_pdf = '<a href=' . $link_pdf . '>pdf</a>';
        $s_a_ps = '<a href=' . $link_ps . '>ps</a>';
        $s_a_midi = '<a href=' . $link_midi . '>midi</a>';
        $s_a_wav = '<a href=' . $link_wav . '>wav</a>';
        $s_a_mp3 = '<a href=' . $link_mp3 . '>mp3</a>';
        $s_a_ogg = '<a href=' . $link_ogg . '>ogg</a>';
        $s_idyoutube = $row['idyoutube'];
        $header = $s_title;
        if ($row['composer'] != NULL) {
            $header .= ' / ' . $s_composer;
        }
        if ($row['poet'] != NULL && $s_poet != $s_composer) {
            $header .= ', ' . $s_poet;
        }
        $body = '';
        $body .= '<ul>';
        if ($row['id'] != NULL) {
            $body .= '<li>id: ' . $id . '</li>';
        }
        if ($row['title'] != NULL) {
            $body .= '<li>title: ' . $s_title . '</li>';
        }
        if ($row['subtitle'] != NULL) {
            $body .= '<li>subtitle: ' . $s_subtitle . '</li>';
        }
        if ($row['composer'] != NULL) {
            $body .= '<li>composer: ' . $s_composer . '</li>';
        }
        if ($row['poet'] != NULL) {
            $body .= '<li>poet: ' . $s_poet . '</li>';
        }
        if ($row['style'] != NULL) {
            $body .= '<li>style: ' . $s_style . '</li>';
        }
        if ($row['piece'] != NULL) {
            $body .= '<li>piece: ' . $s_piece . '</li>';
        }
        if ($row['copyright'] != NULL) {
            $body .= '<li>copyright: ' . $s_copyright . '</li>';
        }
        if ($row['pages'] != NULL) {
            $body .= '<li>pages: ' . $s_pages . '</li>';
        }
        if ($row['epdfs'] != NULL) {
            $body .= '<li>epdfs: ' . $s_epdfs . '</li>';
        }
        $links = array();
        # TODO: only add the links if I have the blobs...
        array_push($links, $s_a_ly);
        array_push($links, $s_a_pdf);
        array_push($links, $s_a_ps);
        array_push($links, $s_a_midi);
        array_push($links, $s_a_wav);
        array_push($links, $s_a_mp3);
        array_push($links, $s_a_ogg);
        # lets look and add links to the pngs...
        for ($i = 0; $i < $s_pages; $i++) {
            $j = $i + 1;
            $link = link_to_direct('GetRsBlob.php?slug=' . $s_uuid . '-png' . $j);
            $link = '<a href=\'' . $link . '\'>png' . $j . '</a>';
            array_push($links, $link);
        }
        for ($i = 0; $i < $s_epdfs; $i++) {
            $link = link_to_direct('GetRsBlob.php?slug=' . $s_uuid . '-epdf' . $i);
            $link = '<a href=\'' . $link . '\'>epdf' . $i . '</a>';
            array_push($links, $link);
        }
        $body .= '<li>links: ' . join(', ', $links) . '</li>';
        $body .= '<li>uuid: ' . $s_uuid . '</li>';
        $body .= '</ul>';
        # lets put a link to play the audio, currently it looks like the
        # audio plugin can only play mp3 so that's the only link that we
        # put...
        $body .= 'You can play the automatically generated mp3 file here...<br/>';
        $body .= get_audio_player($link_mp3, $row['title'], $row['composer'], $row['poet']);
        if ($row['idyoutube'] != NULL) {
            $body .= 'Here is a youtube performance of this song that I like...<br/>';
            $body .= embed_youtube($s_idyoutube, 0.5);
        }
        $res .= multi_accordion_entry($header, $body);
    }
    my_mysql_free_result($result);
    $res .= multi_accordion_end();
    return $res;
}