/** * Tests MediaItem->setUrl() */ public function testSetUrl() { $this->MediaItem->setUrl('url'); $this->assertEquals('url', $this->MediaItem->url); }
function MG_indexAll() { global $_USER, $_MG_CONF, $_CONF, $_TABLES, $MG_albums, $LANG_MG00, $LANG_MG01, $LANG_MG02, $LANG_MG03, $themeStyle, $ImageSkin, $sortOrder, $displayColumns, $displayRows, $tnSize, $level, $album_jumpbox; $album_id = 0; if (isset($_GET['aid'])) { $album_id = (int) COM_applyFilter($_GET['aid'], true); } $page = 0; if (isset($_GET['page'])) { $page = (int) COM_applyFilter($_GET['page'], true); } if ($page != 0) { $page = $page - 1; } $lbSlideShow = ''; $errorMessage = ''; $columns_per_page = $displayColumns; $rows_per_page = $displayRows; $media_per_page = $columns_per_page * $rows_per_page; // image frame setup $nFrame = new mgFrame(); $nFrame->constructor($ImageSkin); $imageFrameTemplate = $nFrame->getTemplate(); $frWidth = $nFrame->frame['wHL'] + $nFrame->frame['wHR']; $frHeight = $nFrame->frame['hVT'] + $nFrame->frame['hVB']; $fCSS = $nFrame->getCSS(); // Let's build our admin menu options $showAdminBox = 0; $admin_box = '<form name="adminbox" id="adminbox" action="' . $_MG_CONF['site_url'] . '/admin.php" method="get" style="margin:0;padding:0;">' . LB; $admin_box .= '<div>'; $admin_box .= '<select onchange="javascript:forms[\'adminbox\'].submit();" name="mode">' . LB; $admin_box .= '<option label="' . $LANG_MG01['options'] . '" value="">' . $LANG_MG01['options'] . '</option>' . LB; if (($MG_albums[0]->member_uploads || $MG_albums[0]->access == 3) && (isset($_USER['uid']) && $_USER['uid'] > 1)) { $admin_box .= '<option value="upload">' . $LANG_MG01['add_media'] . '</option>' . LB; $showAdminBox = 1; } if ($MG_albums[0]->owner_id) { $admin_box .= '<option value="albumsort">' . $LANG_MG01['sort_albums'] . '</option>' . LB; $admin_box .= '<option value="globalattr">' . $LANG_MG01['globalattr'] . '</option>' . LB; $admin_box .= '<option value="globalperm">' . $LANG_MG01['globalperm'] . '</option>' . LB; $queue_count = DB_count($_TABLES['mg_media_album_queue']); $admin_box .= '<option value="moderate">' . $LANG_MG01['media_queue'] . ' (' . $queue_count . ')</option>' . LB; $admin_box .= '<option value="wmmanage">' . $LANG_MG01['wm_management'] . '</option>' . LB; $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB; $showAdminBox = 1; } elseif ($MG_albums[0]->access == 3) { $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB; $showAdminBox = 1; } elseif ($_MG_CONF['member_albums'] == 1 && (isset($_USER['uid']) && $_USER['uid'] > 1) && $_MG_CONF['member_album_root'] == 0 && $_MG_CONF['member_create_new']) { $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB; $showAdminBox = 1; } $admin_box .= '</select>' . LB; $admin_box .= '<input type="hidden" name="album_id" value="0"/>' . LB; $admin_box .= ' <input type="submit" value="' . $LANG_MG03['go'] . '"/>' . LB; $admin_box .= '</div>'; $admin_box .= '</form>'; if ($showAdminBox == 0) { $admin_box = ''; } // construct the album jumpbox... $level = 0; $album_jumpbox = '<form name="jumpbox" id="jumpbox" action="' . $_MG_CONF['site_url'] . '/album.php' . '" method="get" style="margin:0;padding:0"><div>'; $album_jumpbox .= $LANG_MG03['jump_to'] . ': <select name="aid" onchange="forms[\'jumpbox\'].submit()">'; $MG_albums[0]->buildJumpBox(0); $album_jumpbox .= '</select>'; $album_jumpbox .= ' <input type="submit" value="' . $LANG_MG03['go'] . '"/>'; $album_jumpbox .= '<input type="hidden" name="page" value="1"/>'; $album_jumpbox .= '</div></form>'; // initialize our variables $total_media = 0; $arrayCounter = 0; $total_object_count = 0; $mediaObject = array(); $begin = $media_per_page * $page; $end = $media_per_page; $MG_media = array(); // loop thru all the albums and build a list of valid albums that the user can see $first = 0; $albumList = getAlbumList($album_id, $first); $orderBy = ' ORDER BY m.media_upload_time ' . $sortOrder; if ($albumList != '') { $sql = "SELECT COUNT(*) AS total FROM {$_TABLES['mg_media_albums']} as ma INNER JOIN " . $_TABLES['mg_media'] . " as m " . " ON ma.media_id=m.media_id WHERE ma.album_id IN (" . $albumList . ") " . $orderBy; $result = DB_query($sql); $row = DB_fetchArray($result); $cCount = $row['total']; } else { $cCount = 0; } if ($albumList != '') { $sql = "SELECT * FROM {$_TABLES['mg_media_albums']} as ma INNER JOIN " . $_TABLES['mg_media'] . " as m " . " ON ma.media_id=m.media_id WHERE ma.album_id IN (" . $albumList . ") " . $orderBy; $sql .= ' LIMIT ' . $begin . ',' . $end; $result = DB_query($sql); $nRows = DB_numRows($result); } else { $nRows = 0; } $mediaRows = 0; $lbss_count = 0; $posCount = 0; if ($nRows > 0) { while ($row = DB_fetchArray($result)) { $media = new MediaItem(); $media->constructor($row, $row['album_id']); $MG_media[$arrayCounter] = $media; $MG_albums[$row['album_id']]->imageFrameTemplate = $imageFrameTemplate; $arrayCounter++; $mediaRows++; } } $total_media = $total_media + $mediaRows; $total_items_in_album = $cCount; $total_pages = ceil($total_items_in_album / $media_per_page); if ($page >= $total_pages) { $page = $total_pages - 1; } $start = $page * $media_per_page; $current_print_page = floor($start / $media_per_page) + 1; $total_print_pages = ceil($total_items_in_album / $media_per_page); if ($current_print_page == 0) { $current_print_page = 1; } if ($total_print_pages == 0) { $total_print_pages = 1; } // now build the admin select... $admin_box = ''; $admin_box = '<form name="adminbox" id="adminbox" action="' . $_MG_CONF['site_url'] . '/admin.php" method="get" style="margin:0;padding:0">'; $admin_box .= '<div><input type="hidden" name="album_id" value="' . $album_id . '"/>'; $admin_box .= '<select name="mode" onchange="forms[\'adminbox\'].submit()">'; $admin_box .= '<option label="' . $LANG_MG01['options'] . '" value="">' . $LANG_MG01['options'] . '</option>'; $admin_box .= '<option value="search">' . $LANG_MG01['search'] . '</option>'; $uploadMenu = 0; $adminMenu = 0; if ($MG_albums[0]->owner_id) { $uploadMenu = 1; $adminMenu = 1; } else { if ($MG_albums[$album_id]->access == 3) { $uploadMenu = 1; $adminMenu = 1; if ($_MG_CONF['member_albums']) { if ($_MG_USERPREFS['active'] != 1) { $uploadMenu = 0; $adminMenu = 0; } else { $uploadMenu = 1; $adminMenu = 1; } } } else { if ($MG_albums[$album_id]->member_uploads == 1 && isset($_USER['uid']) && $_USER['uid'] >= 2) { $uploadMenu = 1; $adminMenu = 0; } } } if ($uploadMenu == 1) { $admin_box .= '<option value="upload">' . $LANG_MG01['add_media'] . '</option>'; } if ($adminMenu == 1) { $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>'; } elseif ($_MG_CONF['member_albums'] == 1 && !empty($_USER['username']) && $_MG_CONF['member_create_new'] == 1 && $_MG_USERPREFS['active'] == 1 && $album_id == $_MG_CONF['member_album_root']) { $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>'; $adminMenu = 1; } // now check for moderation capabilities.... if ($MG_albums[$album_id]->member_uploads == 1 && $MG_albums[$album_id]->moderate == 1) { // check to see if we are in the album_mod_group if (SEC_inGroup($MG_albums[$album_id]->mod_group_id) || $MG_albums[0]->owner_id) { $queue_count = DB_count($_TABLES['mg_media_album_queue'], 'album_id', $album_id); $admin_box .= '<option value="moderate">' . $LANG_MG01['media_queue'] . ' (' . $queue_count . ')</option>'; $adminMenu = 1; } } $admin_box .= '</select>'; $admin_box .= ' <input type="submit" value="' . $LANG_MG03['go'] . '" style="padding:0px;margin:0px;"/>'; $admin_box .= '</div></form>'; if ($uploadMenu == 0 && $adminMenu == 0) { $admin_box = ''; } if ($MG_albums[$album_id]->enable_sort == 1) { $sort_box = '<form name="sortbox" id="sortbox" action="' . $_MG_CONF['site_url'] . '/album.php" method="get" style="margin:0;padding:0"><div>'; $sort_box .= '<input type="hidden" name="aid" value="' . $album_id . '"/>'; $sort_box .= '<input type="hidden" name="page" value="' . $page . '"/>'; $sort_box .= $LANG_MG03['sort_by'] . ' <select name="sort" onchange="forms[\'sortbox\'].submit()">'; $sort_box .= '<option value="0" ' . ($sortOrder == 0 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_default'] . '</option>'; $sort_box .= '<option value="1" ' . ($sortOrder == 1 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_default_asc'] . '</option>'; $sort_box .= '<option value="2" ' . ($sortOrder == 2 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_upload'] . '</option>'; $sort_box .= '<option value="3" ' . ($sortOrder == 3 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_upload_asc'] . '</option>'; $sort_box .= '<option value="4" ' . ($sortOrder == 4 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_capture'] . '</option>'; $sort_box .= '<option value="5" ' . ($sortOrder == 5 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_capture_asc'] . '</option>'; $sort_box .= '<option value="6" ' . ($sortOrder == 6 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_rating'] . '</option>'; $sort_box .= '<option value="7" ' . ($sortOrder == 7 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_rating_asc'] . '</option>'; $sort_box .= '<option value="8" ' . ($sortOrder == 8 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_views'] . '</option>'; $sort_box .= '<option value="9" ' . ($sortOrder == 9 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_views_asc'] . '</option>'; $sort_box .= '<option value="10" ' . ($sortOrder == 10 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_alpha'] . '</option>'; $sort_box .= '<option value="11" ' . ($sortOrder == 11 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_alpha_asc'] . '</option>'; $sort_box .= '</select>'; $sort_box .= ' <input type="submit" value="' . $LANG_MG03['go'] . '"/>'; $sort_box .= '</div></form>'; } else { $sort_box = ''; } $owner_id = $MG_albums[$album_id]->owner_id; if ($owner_id == '' || !isset($MG_albums[$album_id]->owner_id)) { $owner_id = 0; } $ownername = DB_getItem($_TABLES['users'], 'username', "uid=" . (int) $owner_id); $album_last_update = MG_getUserDateTimeFormat($MG_albums[$album_id]->last_update); $T = new Template($_MG_CONF['template_path']); $T->set_file(array('page' => 'index-all.thtml')); //@TODO fix language tag $T->set_var(array('site_url' => $_MG_CONF['site_url'], 'album_title' => "All Photos - Sorted by Post Date", 'table_columns' => $columns_per_page, 'table_column_width' => intval(100 / $columns_per_page) . '%', 'top_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/index.php?aid=' . $album_id, $page + 1, ceil($total_items_in_album / $media_per_page)), 'bottom_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/index.php?aid=' . $album_id, $page + 1, ceil($total_items_in_album / $media_per_page)), 'page_number' => sprintf("%s %d %s %d", $LANG_MG03['page'], $current_print_page, $LANG_MG03['of'], $total_print_pages), 'jumpbox' => $album_jumpbox, 'album_id' => $album_id, 'lbslideshow' => $lbSlideShow, 'album_description' => $MG_albums[$album_id]->display_album_desc ? PLG_replaceTags($MG_albums[$album_id]->description) : '', 'album_id_display' => $MG_albums[0]->owner_id || $_MG_CONF['enable_media_id'] == 1 ? $LANG_MG03['album_id_display'] . $album_id : '', 'select_adminbox' => $admin_box, 'select_sortbox' => $sort_box, 'album_last_update' => $album_last_update[0], 'album_owner' => $ownername, 'media_count' => $MG_albums[$album_id]->getMediaCount(), 'lang_search' => $LANG_MG01['search'], 'table_columns' => $displayColumns)); $T->set_var('select_adminbox', $admin_box); if ($_MG_CONF['rss_full_enabled']) { $feedUrl = MG_getFeedUrl($_MG_CONF['rss_feed_name'] . '.rss'); $rsslink = '<a href="' . $feedUrl . '"' . ' type="application/rss+xml">'; $rsslink .= '<img src="' . MG_getImageFile('feed.png') . '" alt="" style="border:none;"/></a>'; $T->set_var('rsslink', $rsslink); } else { $T->set_var('rsslink', ''); } // completed setting header / footer vars, parse them PLG_templateSetVars('mediagallery', $T); if ($total_media == 0) { $T->set_var(array('lang_no_image' => $LANG_MG03['no_media_objects'])); } // // main processing of the album contents. // $noParse = 0; $needFinalParse = 0; if ($total_media > 0) { $k = 0; $T->set_block('page', 'ImageColumn', 'IColumn'); $T->set_block('page', 'ImageRow', 'IRow'); for ($i = 0; $i < $media_per_page; $i += $columns_per_page) { for ($j = $i; $j < $i + $columns_per_page; $j++) { if ($j >= $total_media) { $k = $i + $columns_per_page - $j; $m = $k % $columns_per_page; for ($z = $m; $z > 0; $z--) { $T->set_var(array('CELL_DISPLAY_IMAGE' => '')); $T->parse('IColumn', 'ImageColumn', true); $needFinalParse = 1; } if ($needFinalParse == 1) { $T->parse('IRow', 'ImageRow', true); $T->set_var('IColumn', ''); } $noParse = 1; break; } $previous_image = $i - 1; if ($previous_image < 0) { $previous_image = -1; } $next_image = $i + 1; if ($next_image >= $total_media - 1) { $next_image = -1; } $z = $j + $start; $celldisplay = $MG_media[$j]->displayThumb($z, 0, $imageFrameTemplate); if ($MG_media[$j]->type == 1) { $PhotoURL = $_MG_CONF['mediaobjects_url'] . '/disp/' . $MG_media[$j]->filename[0] . '/' . $MG_media[$j]->filename . '.jpg'; $T->set_var(array('URL' => $PhotoURL)); } $T->set_var(array('CELL_DISPLAY_IMAGE' => $celldisplay)); $T->parse('IColumn', 'ImageColumn', true); } if ($noParse == 1) { break; } $T->parse('IRow', 'ImageRow', true); $T->set_var('IColumn', ''); } } $T->parse('output', 'page'); $fCSS = $nFrame->getCSS(); if ($fCSS != '') { $outputHandle = outputHandler::getInstance(); $outputHandle->addStyle($fCSS); } $display = MG_siteHeader(strip_tags($MG_albums[$album_id]->title)); $display .= $T->finish($T->get_var('output')); $display .= MG_siteFooter(); echo $display; }
/** * Converts the media item fetched from the database to the MediaItem object. */ private function convertMediaItem($row) { $mediaItem = new MediaItem($row['mime_type'], $row['type'], $row['url']); $mediaItem->setId($row['id']); $mediaItem->setAlbumId($row['album_id']); $mediaItem->setFileSize($row['file_size']); $mediaItem->setDuration($row['duration']); $mediaItem->setCreated($row['created']); $mediaItem->setLastUpdated($row['last_updated']); $mediaItem->setLanguage($row['language']); $mediaItem->setNumComments($row['num_comments']); $mediaItem->setNumViews($row['num_views']); $mediaItem->setNumVotes($row['num_votes']); $mediaItem->setRating($row['rating']); $mediaItem->setStartTime($row['start_time']); $mediaItem->setTitle($row['title']); $mediaItem->setDescription($row['description']); $mediaItem->setTaggedPeople(json_decode($row['tagged_people'])); $mediaItem->setTags(json_decode($row['tags'])); $mediaItem->setThumbnailUrl($row['thumbnail_url']); if (isset($row['address_id'])) { $mediaItem->setLocation($this->getAddress($row['address_id'])); } return $mediaItem; }
public function __construct() { parent::__construct(); $this->mediatype = 'music'; }
function fillMediaItemObject($myrow) { $mediaItem = new MediaItem(); $mediaItem->setMediaItemId($myrow['mediaItemId']); $mediaItem->setFilename($myrow['filename']); $mediaItem->setComment($myrow['comment']); $mediaItem->setMainwidth($myrow['mainwidth']); $mediaItem->setMainheight($myrow['mainheight']); $mediaItem->setThumbwidth($myrow['thumbwidth']); $mediaItem->setThumbheight($myrow['thumbheight']); $mediaItem->setDuration($myrow['duration']); $mediaItem->setBytes($myrow['bytes']); $mediaItem->setMediaeventId($myrow['mediaeventId']); return $mediaItem; }