コード例 #1
0
ファイル: web_index.php プロジェクト: jingyexu/ezcast
/**
 * Removes an asset bookmark from the user's bookmarks list
 * @global type $input
 * @global type $repository_path
 * @global type $user_files_path
 */
function bookmark_delete()
{
    global $input;
    global $repository_path;
    global $user_files_path;
    $bookmark_album = $input['album'];
    $bookmark_asset = $input['asset'];
    $bookmark_timecode = $input['timecode'];
    // init paths
    ezmam_repository_path($repository_path);
    user_prefs_repository_path($user_files_path);
    if ($input['tab'] == 'custom') {
        // remove from personal bookmarks
        user_prefs_asset_bookmark_delete($_SESSION['user_login'], $bookmark_album, $bookmark_asset, $bookmark_timecode);
    } else {
        // removes from table of contents
        if (acl_user_is_logged() && acl_has_album_moderation($bookmark_album)) {
            toc_asset_bookmark_delete($bookmark_album, $bookmark_asset, $bookmark_timecode);
        }
    }
    // lvl, action, album, asset, timecode
    trace_append(array($_SESSION['asset'] == '' ? '2' : '3', 'bookmark_delete', $bookmark_album, $bookmark_asset, $bookmark_timecode));
    log_append('remove_asset_bookmark', 'bookmark removed : album -' . $bookmark_album . ' asset - ' . $bookmark_asset . ' timecode - ' . $bookmark_timecode);
    if ($input['source'] == 'assets') {
        $input['token'] = ezmam_album_token_get($bookmark_album);
        view_album_assets(false);
    } else {
        view_asset_details(false);
    }
}
コード例 #2
0
ファイル: lib_toc.php プロジェクト: jingyexu/ezcast
/**
 * Adds a bookmark in the bookmarks file (table of contents)
 * @param type $album the album the bookmark is intended to
 * @param type $asset the asset the bookmark is intended to
 * @param type $timecode the specific time code of the bookmark
 * @param type $title the title of the bookmark
 * @param type $description the description of the bookmark
 * @param type $keywords the keywords of the bookmark
 * @param type $level the level of the bookmark
 * @return boolean true if the bookmark has been added to the table of contents;
 * false otherwise
 */
function toc_asset_bookmark_add($album, $asset, $timecode, $title = '', $description = '', $keywords = '', $level = '1', $type = '')
{
    // Sanity check
    if (!ezmam_album_exists($album)) {
        return false;
    }
    if (!ezmam_asset_exists($album, $asset)) {
        return false;
    }
    if (!isset($timecode) || $timecode == '' || $timecode < 0) {
        return false;
    }
    // 1) set the repository path
    $toc_path = ezmam_repository_path();
    if ($toc_path === false) {
        return false;
    }
    // set user's file path
    $toc_path = $toc_path . '/' . $album;
    // remove the previous same bookmark if it existed yet
    toc_asset_bookmark_delete($album, $asset, $timecode);
    // Get the bookmarks list
    $bookmarks_list = toc_album_bookmarks_list_get($album);
    $count = count($bookmarks_list);
    $index = 0;
    if ($count > 0) {
        $index = -1;
        $asset_ref = $bookmarks_list[0]['asset'];
        $timecode_ref = $bookmarks_list[0]['timecode'];
        // loop while the asset is older than the reference asset
        while ($index < $count && $asset > $asset_ref) {
            ++$index;
            $asset_ref = $bookmarks_list[$index]['asset'];
            $timecode_ref = $bookmarks_list[$index]['timecode'];
        }
        // if the asset already contains bookmarks, loop while
        // timecode is bigger than reference timecode
        while ($index < $count && $asset == $asset_ref && $timecode > $timecode_ref) {
            ++$index;
            $timecode_ref = $bookmarks_list[$index]['timecode'];
            $asset_ref = $bookmarks_list[$index]['asset'];
        }
        if ($index < 0) {
            // no bookmarks yet
            $index = 0;
        }
        if ($index > $count) {
            // bookmark is in last position in the table of contents
            --$index;
        }
    }
    // extract keywords from the description
    $keywords_array = get_keywords($description);
    // and save them as keywords
    foreach ($keywords_array as $keyword) {
        if (strlen($keywords) > 0) {
            $keywords .= ', ';
        }
        $keywords .= $keyword;
    }
    // surround every url by '*' for url recognition in EZplayer
    $description = surround_url($description);
    // add a bookmark at the specified index in the albums list
    array_splice($bookmarks_list, $index, 0, array(null));
    $bookmarks_list[$index] = array('album' => $album, 'asset' => $asset, 'timecode' => $timecode, 'title' => $title, 'description' => $description, 'keywords' => $keywords, 'level' => $level, 'type' => $type);
    return assoc_array2xml_file($bookmarks_list, $toc_path . "/_bookmarks.xml", "bookmarks", "bookmark");
}