/** * Adds video to database. */ function addVideo() { $id = checkVideoExists(); $addVideo = new addVideo(); $playlistClass = new Playlist(); $playlist = $playlistClass->getMatchedPlaylist($id); $addVideo->addVideoByID($id, $playlist); }
public function executeCreate(sfWebRequest $request) { $playlist = Doctrine::getTable('Playlist')->findOneByTitle($request->getPostParameter("title")); if ($playlist == NULL) { $playlist = new Playlist(); $playlist->title = $request->getPostParameter("title"); $playlist->save(); echo $playlist->getId(); } else { echo 'error'; } exit; }
public function run() { $model = new Playlist(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Playlist'])) { $model->attributes = $_POST['Playlist']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function parse($content) { $data = $this->content2Data($content); $version = 3; $mediaSequence = 0; extract($data); // to $version, $mediaSequence, $targetDuration $playlist = new Playlist(); foreach ($data['playlist'] as $index => $row) { $mediaSegment = new Segment($row['uri'], $row['duration'], $mediaSequence + $index, !empty($row['isDiscontinuity'])); $playlist->add($mediaSegment); } return new M3U8($playlist, $version, $targetDuration, null, $allowCache, $hasEndlist); }
private function admin() { $today = strtotime('today'); $month = strtotime('first day of this month'); $last30 = strtotime('-30 days'); // Users statistics $users['today'] = number_format(User::whereGt('reg_date', $today)->count()); $users['month'] = number_format(User::whereGt('reg_date', $month)->count()); $users['last30'] = number_format(User::whereGt('reg_date', $last30)->count()); $users['total'] = number_format(User::count()); View::set('users', $users); // Playlists statistics $playlists['today'] = number_format(Playlist::whereGt('date', $today)->count()); $playlists['month'] = number_format(Playlist::whereGt('date', $month)->count()); $playlists['last30'] = number_format(Playlist::whereGt('date', $last30)->count()); $playlists['total'] = number_format(Playlist::count()); View::set('playlists', $playlists); // Tracks statistics $tracks = number_format(Track::count()); View::set('tracks', $tracks); // Tags statistics $tags = number_format(Tag::count()); View::set('tags', $tags); // Comments statistics $comments = number_format(Comment::count()); View::set('comments', $comments); // Likes $likes = number_format(PlaylistLike::count()); View::set('likes', $likes); // Reports $reports = number_format(Report::count()); View::set('reports', $reports); View::show('admin/admin'); }
function testAddAndRemovePlaylist() { // Create a playlist $playlist = new Playlist(); $playlist->create("Scheduler Unit Test " . uniqid()); $result = $playlist->addAudioClip($this->storedFile->getId()); $result = $playlist->addAudioClip($this->storedFile2->getId()); $result = $playlist->addAudioClip($this->storedFile2->getId()); $i = new ScheduleGroup(); $this->groupIdCreated = $i->add('2010-11-11 01:30:23', null, $playlist->getId()); if (PEAR::isError($this->groupIdCreated)) { $this->fail("Failed to create scheduled item: " . $this->groupIdCreated->getMessage()); } $group = new ScheduleGroup($this->groupIdCreated); if ($group->count() != 3) { $this->fail("Wrong number of items added."); } $items = $group->getItems(); if (!is_array($items) || $items[1]["starts"] != "2010-11-11 01:30:34.231") { $this->fail("Wrong start time for 2nd item."); } $result = $group->remove(); if ($result != 1) { $this->fail("Did not remove item."); } Playlist::Delete($playlist->getId()); }
private function showPlaylistItem(Playlist $item) { $donwloadLink = 'index.php?web&action=' . ViewPlaylistWebPageAction::getActionName() . '&subaction=' . ViewPlaylistWebPageAction::SUBACTION_PLAYLIST_DOWNLOAD . '&download=' . base64_encode($item->getFilename()) . '&PHPSESID=' . session_id(); $itemLink = 'index.php?web&action=' . ViewPlaylistWebPageAction::getActionName() . '&subaction=' . ViewPlaylistWebPageAction::SUBACTION_PLAYLIST_OPEN . '&playlist=' . base64_encode($item->getFilename()) . '&PHPSESID=' . session_id(); $deleteLink = 'index.php?web&action=' . ViewPlaylistWebPageAction::getActionName() . '&subaction=' . ViewPlaylistWebPageAction::SUBACTION_PLAYLIST_DELETE . '&path=' . base64_encode($item->getFilename()) . '&PHPSESID=' . session_id(); $itemName = $item->getName() != null ? $item->getName() . " (" . utf8_decode($item->getFilename()) . ")" : utf8_decode($item->getFilename()); echo ' <td width="24px"><img width="22px" height="22px" src="../resources/playlist/video.png" style="border:0px;" /></td>' . "\n"; echo ' <td><a href="' . $itemLink . '">' . htmlentities($itemName) . '</a></td>' . "\n"; echo ' <td width="24px"><a href="' . $donwloadLink . '" target="_blank"><img width="22px" height="22px" src="../resources/playlist/video_down.png" style="border:0px;" alt="Donwload Playlist" title="Donwload Playlist" /></a></td>' . "\n"; echo ' <td width="24px"><a href="' . $itemLink . '"><img width="22px" height="22px" src="../resources/playlist/view.png" style="border:0px;" alt="Open Playlist" title="Open Playlist" /></a></td>' . "\n"; echo ' <td width="24px"><img width="22px" height="22px" src="../resources/playlist/edit.png" style="border:0px;" alt="Edit Playlist" title="Edit Playlist" /></td>' . "\n"; echo ' <td width="24px"><a href="' . $deleteLink . '"><img width="22px" height="22px" src="../resources/playlist/remove.png" style="border:0px;" alt="Remove Playlist" title="Remove Playlist" onclick="return confirm(\'Are you sure to delete playlist ' . htmlentities(utf8_decode($item->getFilename())) . '?\');" /></a></td>' . "\n"; }
/** * Add a music clip or playlist to the schedule. * * @param int $p_showInstance * ID of the show. * @param $p_datetime * In the format YYYY-MM-DD HH:MM:SS.mmmmmm * @param $p_audioFileId * (optional, either this or $p_playlistId must be set) DB ID of the audio file * @param $p_playlistId * (optional, either this of $p_audioFileId must be set) DB ID of the playlist * @param $p_options * Does nothing at the moment. * * @return int|PEAR_Error * Return PEAR_Error if the item could not be added. * Error code 555 is a scheduling conflict. */ public function add($p_showInstance, $p_datetime, $p_audioFileId = null, $p_playlistId = null, $p_options = null) { global $CC_CONFIG, $CC_DBC; if (!is_null($p_audioFileId)) { // Schedule a single audio track // Load existing track $track = StoredFile::Recall($p_audioFileId); if (is_null($track)) { return new PEAR_Error("Could not find audio track."); } // Check if there are any conflicts with existing entries $metadata = $track->getMetadata(); $length = $metadata['MDATA_KEY_DURATION']; if (empty($length)) { return new PEAR_Error("Length is empty."); } // Insert into the table $this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')"); $sql = "INSERT INTO " . $CC_CONFIG["scheduleTable"] . " (instance_id, starts, ends, clip_length, group_id, file_id, cue_out)" . " VALUES ({$p_showInstance}, TIMESTAMP '{$p_datetime}', " . " (TIMESTAMP '{$p_datetime}' + INTERVAL '{$length}')," . " '{$length}'," . " {$this->groupId}, {$p_audioFileId}, '{$length}')"; $result = $CC_DBC->query($sql); if (PEAR::isError($result)) { //var_dump($sql); return $result; } } elseif (!is_null($p_playlistId)) { // Schedule a whole playlist // Load existing playlist $playlist = Playlist::Recall($p_playlistId); if (is_null($playlist)) { return new PEAR_Error("Could not find playlist."); } // Check if there are any conflicts with existing entries $length = trim($playlist->getLength()); //var_dump($length); if (empty($length)) { return new PEAR_Error("Length is empty."); } // Insert all items into the schedule $this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')"); $itemStartTime = $p_datetime; $plItems = $playlist->getContents(); //var_dump($plItems); foreach ($plItems as $row) { $trackLength = $row["cliplength"]; //var_dump($trackLength); $sql = "INSERT INTO " . $CC_CONFIG["scheduleTable"] . " (instance_id, playlist_id, starts, ends, group_id, file_id," . " clip_length, cue_in, cue_out, fade_in, fade_out)" . " VALUES ({$p_showInstance}, {$p_playlistId}, TIMESTAMP '{$itemStartTime}', " . " (TIMESTAMP '{$itemStartTime}' + INTERVAL '{$trackLength}')," . " '{$this->groupId}', '{$row['file_id']}', '{$trackLength}', '{$row['cuein']}'," . " '{$row['cueout']}', '{$row['fadein']}','{$row['fadeout']}')"; $result = $CC_DBC->query($sql); if (PEAR::isError($result)) { //var_dump($sql); return $result; } $itemStartTime = $CC_DBC->getOne("SELECT TIMESTAMP '{$itemStartTime}' + INTERVAL '{$trackLength}'"); } } RabbitMq::PushSchedule(); return $this->groupId; }
public static function getAllofCurrentUser() { self::$_items = array(); $models = self::model()->findAll('uid=' . Yii::app()->user->id); foreach ($models as $model) { self::$_items[$model->id] = $model->name; } return self::$_items; }
function index() { $userid = $this->session->userdata('userid'); $this->load->static_model('Playlist'); $playlists = Playlist::getUsersPlaylists($userid); $data = array('userid' => $userid, 'user' => $userid ? new User($userid) : NULL, 'playlists' => $playlists, 'page_title' => "Register"); $this->load->view("common/header.php", $data); $this->load->view("register/register_view.php"); $this->load->view("common/footer.php"); }
public function is_logged() { $user = Session::get('user'); if (isset($user)) { $playlist = Playlist::get_for_display($user->get_id_user_lif()); Session::put('playlist', $playlist); return $user; } else { return false; } }
/** * Add a playlist * * @param playlist_name str: new playlist name * @param scan_id int: the scan id for a service scanner * @param service_name str: the name of the service this playlist comes from eg.itunes * @param service_unique_id str: any metadata key string to make the playlist more unique * @return int: insert row id */ public function addPlaylist($playlist_name, $scan_id = 0, $service_name = null, $service_unique_id = null) { $playlist = new Playlist(); if ($scan_id > 0) { $playlist->scan_id = (int) $scan_id; } if (strlen($service_name) > 0) { $playlist->service_name = $service_name; } if (strlen($service_unique_id) > 0) { $playlist->service_unique_id = $service_unique_id; } $playlist->name = $playlist_name; $playlist->mtime = time(); $playlist->save(); $id = $playlist->getId(); $playlist->free(); unset($playlist); return (int) $id; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. */ public function loadModel() { if ($this->_model === null) { if (isset($_GET['id'])) { $this->_model = Playlist::model()->findbyPk($_GET['id']); } if ($this->_model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } } return $this->_model; }
function setup() { global $CC_CONFIG, $CC_DBC; // Clear the files table $sql = "DELETE FROM " . $CC_CONFIG["filesTable"]; $CC_DBC->query($sql); // Add a file $values = array("filepath" => dirname(__FILE__) . "/test10001.mp3"); $this->storedFile = StoredFile::Insert($values, false); // Add a file $values = array("filepath" => dirname(__FILE__) . "/test10002.mp3"); $this->storedFile2 = StoredFile::Insert($values, false); // Clear the schedule table $sql = "DELETE FROM " . $CC_CONFIG["scheduleTable"]; $CC_DBC->query($sql); // Create a playlist $playlist = new Playlist(); $playlist->create("Scheduler Unit Test"); $result = $playlist->addAudioClip($this->storedFile->getId()); $result = $playlist->addAudioClip($this->storedFile2->getId()); $result = $playlist->addAudioClip($this->storedFile2->getId()); // Schedule it $i = new ScheduleGroup(); $this->groupIdCreated = $i->add('2010-11-11 01:30:23', null, $playlist->getId()); }
public static function generateId($length) { $idExists = true; while ($idExists) { $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $id = ''; for ($i = 0; $i < $length; $i++) { $id .= $chars[rand(0, strlen($chars) - 1)]; } $idExists = Playlist::exists(array('id' => $id)); } return $id; }
/** * Feed playlists */ public function feedPlaylists() { $rows = $this->hasMany('UserRelation', 'follower')->where('active', 1)->select('leader')->findArray(); if (!$rows) { return false; } // A little eager loading $following = array(); foreach ($rows as $item) { $following[] = $item['leader']; } return Playlist::tableAlias('p')->selectMany('p.*', 'username')->join('user', 'u.id = user_id', 'u')->where('p.published', 1)->whereIn('user_id', $following)->orderByDesc('p.id')->paginate(); }
function index() { $userid = $this->session->userdata('userid'); $playlists = null; $user = null; if ($userid) { $this->load->static_model('Playlist'); $playlists = Playlist::getUsersPlaylists($userid); $user = new User($userid); } $data = array('userid' => $userid, 'user' => $user, 'playlists' => $playlists, 'page_title' => "Welcome."); $this->load->view("common/header.php", $data); $this->load->view("register/activation_confirmation_view.php"); $this->load->view("common/footer.php"); }
public function action_index() { $user = $this->is_logged(); if ($user === false) { return Redirect::to_action('login'); } else { $song_count = Song::count(); $album_count = Album::count(); $band_count = band::count(); $playlist_count = Playlist::count(); $user_count = User_lif::count(); $best_year_song = DB::query('SELECT date_song, count(*) as count FROM song GROUP BY date_song HAVING count ORDER BY count DESC LIMIT 1'); $max_in_playlist = DB::query('SELECT count(s.id_song) as count, b.name_band, s.`title_song` FROM song s JOIN songplaylist so ON s.id_song = so.id_song JOIN songalbum son ON s.id_song = son.id_song JOIN album a ON son.id_album = a.id_album JOIN band b ON a.id_band = b.id_band GROUP BY s.title_song HAVING count ORDER BY count DESC LIMIT 3'); //var_dump($best_year_song); } return View::make('stats.index')->with('song_count', $song_count)->with('album_count', $album_count)->with('best_year_song', $best_year_song)->with('playlist_count', $playlist_count)->with('user_count', $user_count)->with('max_in_playlist', $max_in_playlist)->with('band_count', $band_count); }
private function explore() { // Get some tags to show as options $tags = Tag::select('name')->limit(30)->findArray(); View::set('tags', $tags); // No tags selected if (empty($_GET['t']) || !Validate::tags($_GET['t'])) { $rows = Playlist::join('user', 'user_id = u.id', 'u')->selectMany('playlist.*', 'username')->where('published', 1)->paginate(); Base::eagerLoadingPlaylistTags($rows); View::set('playlists', $rows); View::show('explore'); } // Separate tags by spaces $tags = trim($_GET['t']); $tags = explode('/', $tags, 4); $tags = array_slice($tags, 0, 3); // Url for selected tags $selectedTagsUrl = implode('/', $tags); // Beautifys the title Tags $selectedTags = array(); foreach ($tags as $key => $item) { // Removes empty tags if (empty($item)) { unset($tags[$key]); continue; } $aux = array(); $aux['name'] = $item; // When one clicked will remove that tag from the query unset($tags[$key]); $aux['href'] = '/' . implode('/', $tags); $tags[$key] = $item; $selectedTags[] = $aux; } $playlists = Playlist::filter('byTags', $tags)->join('user', 'p.user_id = u.id', 'u')->selectMany('p.*', 'username'); $count = $playlists->countDistinct('p.id'); $playlists = $playlists->groupBy('p.id')->paginate($count); Base::eagerLoadingPlaylistTags($playlists); // View preparations View::set('playlists', $playlists); View::set('selectedTags', $selectedTags); View::set('selectedTagsUrl', $selectedTagsUrl); View::show('explore'); }
function search($page = 0, $display = 26) { $searchBy = $_POST["search_by"]; $term = $_POST["search_term"]; $userid = $this->session->userdata('userid'); $tracks = array(); try { if ($searchBy == "name") { $returned = Track::searchTrackName($term, $userid, $page * $display, $display); } else { if ($searchBy == "genre") { $returned = Track::searchByGenre($term, $userid, $page * $display, $display); } else { if ($searchBy == "artist") { $returned = Track::searchByArtist($term, $userid, $page * $display, $display); } else { if ($searchBy == "playlist") { $this->load->static_model("Playlist"); $returned = Playlist::searchByName($term, $userid, $page * $display, $display); } else { echo json_encode(array("error" => "The search criteria is not recognized")); return; } } } } } catch (Exception $e) { echo json_encode(array("error" => $e->getMessage())); return; } $tracks = $returned['tracks']; $num_rows = $returned['rows']; if ($num_rows > $display) { $num_pages = ceil($num_rows / $display); } else { $num_pages = 1; } $newTracks = array(); foreach ($tracks as $track) { $newTracks[] = $track->toArray(); } $result = array("tracks" => $newTracks, "cur_page" => $page, "num_pages" => $num_pages); echo json_encode($result); }
private function home() { $this->welcome(); // Staff picks $staffPicks = Playlist::filter('byTags', 'staff')->select('p.*'); $count = $staffPicks->countDistinct('p.id'); $staffPicks = $staffPicks->groupBy('p.id')->orderByDesc('p.id')->paginate($count); Base::eagerLoadingPlaylistTags($staffPicks); View::set('staff_picks', $staffPicks); // Home tags $tags = Base::$g['home_tags']; if (!empty($tags)) { $tags = explode(', ', $tags); foreach ($tags as $key => $tag) { $playlists = Playlist::filter('byTags', $tag)->select('p.*'); $count = $playlists->countDistinct('p.id'); if (!$count) { unset($tags[$key]); continue; } $playlists = $playlists->groupBy('p.id')->orderByDesc('p.id')->paginate($count); Base::eagerLoadingPlaylistTags($playlists); $tags[$key] = $playlists; $tags[$key]['title'] = $tag; } View::set('home_tags_playlists', $tags); } // New playlists $newPlaylists = Playlist::orderByDesc('id')->where('published', 1)->paginate(); Base::eagerLoadingPlaylistTags($newPlaylists); View::set('new_playlists', $newPlaylists); if (LOGGED) { $user = Base::$g['logged']; // Liked playlists $likedPlaylists = $user->likedPlaylists(); Base::eagerLoadingPlaylistTags($likedPlaylists); View::set('liked_playlists', $likedPlaylists); // Stream $feedPlaylists = $user->feedPlaylists(); Base::eagerLoadingPlaylistTags($feedPlaylists); View::set('feed_playlists', $feedPlaylists); } View::show('home'); }
function playlist_new() { global $user; if (!empty($_POST)) { $playlist = new Playlist(); $playlist->title = $_POST['title']; $playlist->creator = $user->uid; $playlist->save(); } else { $output = '<div class="grid_4 prefix_5 suffix_5">'; $output .= '<form actiom="./" method="post">'; $output .= '<label for="title">Playlist Title</label>'; $output .= '<input type="text" id="title" name="title"/>'; $output .= '<input type="submit"/>'; $output .= '</form>'; $output .= '</div>'; print $output; } }
case 'playlist': $playlist = new Playlist($_REQUEST['playlist_id']); $songs = $playlist->get_songs(); foreach ($songs as $song) { $media_ids[] = array('object_type' => 'song', 'object_id' => $song); } break; case 'smartplaylist': $playlist = new Search('song', $_REQUEST['playlist_id']); $items = $playlist->get_items(); foreach ($items as $item) { $media_ids[] = array('object_type' => $item['object_type'], 'object_id' => $item['object_id']); } break; case 'playlist_random': $playlist = new Playlist($_REQUEST['playlist_id']); $media_ids = $playlist->get_random_items(); break; case 'random': $matchlist = array(); if ($_REQUEST['genre'][0] != '-1') { $matchlist['genre'] = $_REQUEST['genre']; } if ($_REQUEST['catalog'] != '-1') { $matchlist['catalog'] = $_REQUEST['catalog']; } /* Setup the options array */ $options = array('limit' => $_REQUEST['random'], 'random_type' => $_REQUEST['random_type'], 'size_limit' => $_REQUEST['size_limit']); $media_ids = get_random_songs($options, $matchlist); break; case 'democratic':
/** * show_objects * This takes an array of objects * and requires the correct template based on the * type that we are currently browsing * * @param int[] $object_ids */ public function show_objects($object_ids = null, $argument = null) { if ($this->is_simple() || !is_array($object_ids)) { $object_ids = $this->get_saved(); } else { $this->save_objects($object_ids); } // Limit is based on the user's preferences if this is not a // simple browse because we've got too much here if ($this->get_start() >= 0 && count($object_ids) > $this->get_start() && !$this->is_simple()) { $object_ids = array_slice($object_ids, $this->get_start(), $this->get_offset(), true); } else { if (!count($object_ids)) { $this->set_total(0); } } // Load any additional object we need for this $extra_objects = $this->get_supplemental_objects(); $browse = $this; foreach ($extra_objects as $class_name => $id) { ${$class_name} = new $class_name($id); } $match = ''; // Format any matches we have so we can show them to the masses if ($filter_value = $this->get_filter('alpha_match')) { $match = ' (' . $filter_value . ')'; } elseif ($filter_value = $this->get_filter('starts_with')) { $match = ' (' . $filter_value . ')'; /*} elseif ($filter_value = $this->get_filter('regex_match')) { $match = ' (' . $filter_value . ')'; } elseif ($filter_value = $this->get_filter('regex_not_match')) { $match = ' (' . $filter_value . ')';*/ } elseif ($filter_value = $this->get_filter('catalog')) { // Get the catalog title $catalog = Catalog::create_from_id(intval($filter_value)); $match = ' (' . $catalog->name . ')'; } $type = $this->get_type(); // Update the session value only if it's allowed on the current browser if ($this->get_update_session()) { $_SESSION['browse_current_' . $type]['start'] = $browse->get_start(); } // Set the correct classes based on type $class = "box browse_" . $type; $argument_param = $argument ? '&argument=' . scrub_in($argument) : ''; debug_event('browse', 'Show objects called for type {' . $type . '}', '5'); $limit_threshold = $this->get_threshold(); // Switch on the type of browsing we're doing switch ($type) { case 'song': $box_title = T_('Songs') . $match; Song::build_cache($object_ids, $limit_threshold); $box_req = AmpConfig::get('prefix') . '/templates/show_songs.inc.php'; break; case 'album': Album::build_cache($object_ids); $box_title = T_('Albums') . $match; if (is_array($argument)) { $allow_group_disks = $argument['group_disks']; if ($argument['title']) { $box_title = $argument['title']; } } else { $allow_group_disks = false; } $box_req = AmpConfig::get('prefix') . '/templates/show_albums.inc.php'; break; case 'user': $box_title = T_('Users') . $match; $box_req = AmpConfig::get('prefix') . '/templates/show_users.inc.php'; break; case 'artist': $box_title = T_('Artists') . $match; Artist::build_cache($object_ids, true, $limit_threshold); $box_req = AmpConfig::get('prefix') . '/templates/show_artists.inc.php'; break; case 'live_stream': require_once AmpConfig::get('prefix') . '/templates/show_live_stream.inc.php'; $box_title = T_('Radio Stations') . $match; $box_req = AmpConfig::get('prefix') . '/templates/show_live_streams.inc.php'; break; case 'playlist': Playlist::build_cache($object_ids); $box_title = T_('Playlists') . $match; $box_req = AmpConfig::get('prefix') . '/templates/show_playlists.inc.php'; break; case 'playlist_song': $box_title = T_('Playlist Songs') . $match; $box_req = AmpConfig::get('prefix') . '/templates/show_playlist_songs.inc.php'; break; case 'playlist_localplay': $box_title = T_('Current Playlist'); $box_req = AmpConfig::get('prefix') . '/templates/show_localplay_playlist.inc.php'; UI::show_box_bottom(); break; case 'smartplaylist': $box_title = T_('Smart Playlists') . $match; $box_req = AmpConfig::get('prefix') . '/templates/show_searches.inc.php'; break; case 'catalog': $box_title = T_('Catalogs'); $box_req = AmpConfig::get('prefix') . '/templates/show_catalogs.inc.php'; break; case 'shoutbox': $box_title = T_('Shoutbox Records'); $box_req = AmpConfig::get('prefix') . '/templates/show_manage_shoutbox.inc.php'; break; case 'tag': Tag::build_cache($object_ids); $box_title = T_('Tag Cloud'); $box_req = AmpConfig::get('prefix') . '/templates/show_tagcloud.inc.php'; break; case 'video': Video::build_cache($object_ids); $video_type = 'video'; $box_title = T_('Videos'); $box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php'; break; case 'democratic': $box_title = T_('Democratic Playlist'); $box_req = AmpConfig::get('prefix') . '/templates/show_democratic_playlist.inc.php'; break; case 'wanted': $box_title = T_('Wanted Albums'); $box_req = AmpConfig::get('prefix') . '/templates/show_wanted_albums.inc.php'; break; case 'share': $box_title = T_('Shared Objects'); $box_req = AmpConfig::get('prefix') . '/templates/show_shared_objects.inc.php'; break; case 'song_preview': $box_title = T_('Songs'); $box_req = AmpConfig::get('prefix') . '/templates/show_song_previews.inc.php'; break; case 'channel': $box_title = T_('Channels'); $box_req = AmpConfig::get('prefix') . '/templates/show_channels.inc.php'; break; case 'broadcast': $box_title = T_('Broadcasts'); $box_req = AmpConfig::get('prefix') . '/templates/show_broadcasts.inc.php'; break; case 'license': $box_title = T_('Media Licenses'); $box_req = AmpConfig::get('prefix') . '/templates/show_manage_license.inc.php'; break; case 'tvshow': $box_title = T_('TV Shows'); $box_req = AmpConfig::get('prefix') . '/templates/show_tvshows.inc.php'; break; case 'tvshow_season': $box_title = T_('Seasons'); $box_req = AmpConfig::get('prefix') . '/templates/show_tvshow_seasons.inc.php'; break; case 'tvshow_episode': $box_title = T_('Episodes'); $video_type = $type; $box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php'; break; case 'movie': $box_title = T_('Movies'); $video_type = $type; $box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php'; break; case 'clip': $box_title = T_('Clips'); $video_type = $type; $box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php'; break; case 'personal_video': $box_title = T_('Personal Videos'); $video_type = $type; $box_req = AmpConfig::get('prefix') . '/templates/show_videos.inc.php'; break; case 'label': $box_title = T_('Labels'); $box_req = AmpConfig::get('prefix') . '/templates/show_labels.inc.php'; break; case 'pvmsg': $box_title = T_('Private Messages'); $box_req = AmpConfig::get('prefix') . '/templates/show_pvmsgs.inc.php'; break; default: // Rien a faire break; } // end switch on type Ajax::start_container($this->get_content_div(), 'browse_content'); if ($this->get_show_header()) { if (isset($box_req) && isset($box_title)) { UI::show_box_top($box_title, $class); } } if (isset($box_req)) { require $box_req; } if ($this->get_show_header()) { if (isset($box_req)) { UI::show_box_bottom(); } echo '<script type="text/javascript">'; echo Ajax::action('?page=browse&action=get_filters&browse_id=' . $this->id . $argument_param, ''); echo ';</script>'; } else { if (!$this->get_use_pages()) { $this->show_next_link($argument); } } Ajax::end_container(); }
break; } $artist = new Artist($artist_id); $songs = $artist->get_songs(); foreach ($songs as $song_id) { $GLOBALS['user']->playlist->add_object($song_id, 'song'); } $results['rightbar'] = UI::ajax_include('rightbar.inc.php'); break; case 'playlist': $playlist_id = Random::playlist(); if (!$playlist_id) { $results['rfc3514'] = '0x1'; break; } $playlist = new Playlist($playlist_id); $items = $playlist->get_items(); foreach ($items as $item) { $GLOBALS['user']->playlist->add_object($item['object_id'], $item['object_type']); } $results['rightbar'] = UI::ajax_include('rightbar.inc.php'); break; case 'advanced_random': $object_ids = Random::advanced('song', $_POST); // First add them to the active playlist if (is_array($object_ids)) { foreach ($object_ids as $object_id) { $GLOBALS['user']->playlist->add_object($object_id, 'song'); } } $results['rightbar'] = UI::ajax_include('rightbar.inc.php');
/** * constructor */ public function __construct($id = null, $searchtype = 'song') { $this->searchtype = $searchtype; if ($id) { $info = $this->get_info($id); foreach ($info as $key => $value) { $this->{$key} = $value; } $this->rules = unserialize($this->rules); } // Define our basetypes $this->basetypes['numeric'][] = array('name' => 'gte', 'description' => T_('is greater than or equal to'), 'sql' => '>='); $this->basetypes['numeric'][] = array('name' => 'lte', 'description' => T_('is less than or equal to'), 'sql' => '<='); $this->basetypes['numeric'][] = array('name' => 'equal', 'description' => T_('is'), 'sql' => '<=>'); $this->basetypes['numeric'][] = array('name' => 'ne', 'description' => T_('is not'), 'sql' => '<>'); $this->basetypes['numeric'][] = array('name' => 'gt', 'description' => T_('is greater than'), 'sql' => '>'); $this->basetypes['numeric'][] = array('name' => 'lt', 'description' => T_('is less than'), 'sql' => '<'); $this->basetypes['boolean'][] = array('name' => 'true', 'description' => T_('is true')); $this->basetypes['boolean'][] = array('name' => 'false', 'description' => T_('is false')); $this->basetypes['text'][] = array('name' => 'contain', 'description' => T_('contains'), 'sql' => 'LIKE', 'preg_match' => array('/^/', '/$/'), 'preg_replace' => array('%', '%')); $this->basetypes['text'][] = array('name' => 'notcontain', 'description' => T_('does not contain'), 'sql' => 'NOT LIKE', 'preg_match' => array('/^/', '/$/'), 'preg_replace' => array('%', '%')); $this->basetypes['text'][] = array('name' => 'start', 'description' => T_('starts with'), 'sql' => 'LIKE', 'preg_match' => '/$/', 'preg_replace' => '%'); $this->basetypes['text'][] = array('name' => 'end', 'description' => T_('ends with'), 'sql' => 'LIKE', 'preg_match' => '/^/', 'preg_replace' => '%'); $this->basetypes['text'][] = array('name' => 'equal', 'description' => T_('is'), 'sql' => '='); $this->basetypes['text'][] = array('name' => 'sounds', 'description' => T_('sounds like'), 'sql' => 'SOUNDS LIKE'); $this->basetypes['text'][] = array('name' => 'notsounds', 'description' => T_('does not sound like'), 'sql' => 'NOT SOUNDS LIKE'); $this->basetypes['boolean_numeric'][] = array('name' => 'equal', 'description' => T_('is'), 'sql' => '<=>'); $this->basetypes['boolean_numeric'][] = array('name' => 'ne', 'description' => T_('is not'), 'sql' => '<>'); $this->basetypes['boolean_subsearch'][] = array('name' => 'equal', 'description' => T_('is'), 'sql' => ''); $this->basetypes['boolean_subsearch'][] = array('name' => 'ne', 'description' => T_('is not'), 'sql' => 'NOT'); $this->basetypes['date'][] = array('name' => 'lt', 'description' => T_('before'), 'sql' => '<'); $this->basetypes['date'][] = array('name' => 'gt', 'description' => T_('after'), 'sql' => '>'); $this->basetypes['multiple'] = array_merge($this->basetypes['text'], $this->basetypes['numeric']); switch ($searchtype) { case 'song': $this->types[] = array('name' => 'anywhere', 'label' => T_('Any searchable text'), 'type' => 'text', 'widget' => array('input', 'text')); $this->types[] = array('name' => 'title', 'label' => T_('Title'), 'type' => 'text', 'widget' => array('input', 'text')); $this->types[] = array('name' => 'album', 'label' => T_('Album'), 'type' => 'text', 'widget' => array('input', 'text')); $this->types[] = array('name' => 'artist', 'label' => T_('Artist'), 'type' => 'text', 'widget' => array('input', 'text')); $this->types[] = array('name' => 'composer', 'label' => T_('Composer'), 'type' => 'text', 'widget' => array('input', 'text')); $this->types[] = array('name' => 'comment', 'label' => T_('Comment'), 'type' => 'text', 'widget' => array('input', 'text')); $this->types[] = array('name' => 'label', 'label' => T_('Label'), 'type' => 'text', 'widget' => array('input', 'text')); $this->types[] = array('name' => 'tag', 'label' => T_('Tag'), 'type' => 'text', 'widget' => array('input', 'text')); $this->types[] = array('name' => 'album_tag', 'label' => T_('Album tag'), 'type' => 'text', 'widget' => array('input', 'text')); $this->types[] = array('name' => 'file', 'label' => T_('Filename'), 'type' => 'text', 'widget' => array('input', 'text')); $this->types[] = array('name' => 'year', 'label' => T_('Year'), 'type' => 'numeric', 'widget' => array('input', 'text')); $this->types[] = array('name' => 'time', 'label' => T_('Length (in minutes)'), 'type' => 'numeric', 'widget' => array('input', 'text')); if (AmpConfig::get('ratings')) { $this->types[] = array('name' => 'rating', 'label' => T_('Rating'), 'type' => 'numeric', 'widget' => array('select', array('1 Star', '2 Stars', '3 Stars', '4 Stars', '5 Stars'))); } if (AmpConfig::get('show_played_times')) { $this->types[] = array('name' => 'played_times', 'label' => T_('# Played'), 'type' => 'numeric', 'widget' => array('input', 'text')); } $this->types[] = array('name' => 'bitrate', 'label' => T_('Bitrate'), 'type' => 'numeric', 'widget' => array('select', array('32', '40', '48', '56', '64', '80', '96', '112', '128', '160', '192', '224', '256', '320'))); $this->types[] = array('name' => 'played', 'label' => T_('Played'), 'type' => 'boolean', 'widget' => array('input', 'hidden')); $this->types[] = array('name' => 'added', 'label' => T_('Added'), 'type' => 'date', 'widget' => array('input', 'text')); $this->types[] = array('name' => 'updated', 'label' => T_('Updated'), 'type' => 'date', 'widget' => array('input', 'text')); $catalogs = array(); foreach (Catalog::get_catalogs() as $catid) { $catalog = Catalog::create_from_id($catid); $catalog->format(); $catalogs[$catid] = $catalog->f_name; } $this->types[] = array('name' => 'catalog', 'label' => T_('Catalog'), 'type' => 'boolean_numeric', 'widget' => array('select', $catalogs)); $playlists = array(); foreach (Playlist::get_playlists() as $playlistid) { $playlist = new Playlist($playlistid); $playlist->format(); $playlists[$playlistid] = $playlist->f_name; } $this->types[] = array('name' => 'playlist', 'label' => T_('Playlist'), 'type' => 'boolean_numeric', 'widget' => array('select', $playlists)); $this->types[] = array('name' => 'playlist_name', 'label' => T_('Playlist Name'), 'type' => 'text', 'widget' => array('input', 'text')); $playlists = array(); foreach (Search::get_searches() as $playlistid) { // Slightly different from the above so we don't instigate // a vicious loop. $playlists[$playlistid] = Search::get_name_byid($playlistid); } $this->types[] = array('name' => 'smartplaylist', 'label' => T_('Smart Playlist'), 'type' => 'boolean_subsearch', 'widget' => array('select', $playlists)); $metadataFields = array(); $metadataFieldRepository = new \Lib\Metadata\Repository\MetadataField(); foreach ($metadataFieldRepository->findAll() as $metadata) { $metadataFields[$metadata->getId()] = $metadata->getName(); } $this->types[] = array('name' => 'metadata', 'label' => T_('Metadata'), 'type' => 'multiple', 'subtypes' => $metadataFields, 'widget' => array('subtypes', array('input', 'text'))); $licenses = array(); foreach (License::get_licenses() as $license_id) { $license = new License($license_id); $licenses[$license_id] = $license->name; } if (AmpConfig::get('licensing')) { $this->types[] = array('name' => 'license', 'label' => T_('Music License'), 'type' => 'boolean_numeric', 'widget' => array('select', $licenses)); } break; case 'album': $this->types[] = array('name' => 'title', 'label' => T_('Title'), 'type' => 'text', 'widget' => array('input', 'text')); $this->types[] = array('name' => 'artist', 'label' => T_('Artist'), 'type' => 'text', 'widget' => array('input', 'text')); $this->types[] = array('name' => 'year', 'label' => T_('Year'), 'type' => 'numeric', 'widget' => array('input', 'text')); $this->types[] = array('name' => 'image width', 'label' => T_('Image Width'), 'type' => 'numeric', 'widget' => array('input', 'text')); $this->types[] = array('name' => 'image height', 'label' => T_('Image Height'), 'type' => 'numeric', 'widget' => array('input', 'text')); if (AmpConfig::get('ratings')) { $this->types[] = array('name' => 'rating', 'label' => T_('Rating'), 'type' => 'numeric', 'widget' => array('select', array('1 Star', '2 Stars', '3 Stars', '4 Stars', '5 Stars'))); } $catalogs = array(); foreach (Catalog::get_catalogs() as $catid) { $catalog = Catalog::create_from_id($catid); $catalog->format(); $catalogs[$catid] = $catalog->f_name; } $this->types[] = array('name' => 'catalog', 'label' => T_('Catalog'), 'type' => 'boolean_numeric', 'widget' => array('select', $catalogs)); $this->types[] = array('name' => 'tag', 'label' => T_('Tag'), 'type' => 'text', 'widget' => array('input', 'text')); break; case 'video': $this->types[] = array('name' => 'filename', 'label' => T_('Filename'), 'type' => 'text', 'widget' => array('input', 'text')); break; case 'artist': $this->types[] = array('name' => 'name', 'label' => T_('Name'), 'type' => 'text', 'widget' => array('input', 'text')); $this->types[] = array('name' => 'yearformed', 'label' => T_('Year'), 'type' => 'numeric', 'widget' => array('input', 'text')); $this->types[] = array('name' => 'placeformed', 'label' => T_('Place'), 'type' => 'text', 'widget' => array('input', 'text')); $this->types[] = array('name' => 'tag', 'label' => T_('Tag'), 'type' => 'text', 'widget' => array('input', 'text')); break; case 'playlist': $this->types[] = array('name' => 'name', 'label' => T_('Name'), 'type' => 'text', 'widget' => array('input', 'text')); break; case 'label': $this->types[] = array('name' => 'name', 'label' => T_('Name'), 'type' => 'text', 'widget' => array('input', 'text')); $this->types[] = array('name' => 'category', 'label' => T_('Category'), 'type' => 'text', 'widget' => array('input', 'text')); break; case 'user': $this->types[] = array('name' => 'username', 'label' => T_('Username'), 'type' => 'text', 'widget' => array('input', 'text')); break; } // end switch on searchtype }
<?php session_start(); ob_start(); include "./common.php"; $error = ''; $action_name = 'add'; $action_value = _('Add'); Admin::checkAuth(); Admin::checkAccess(AdminAccess::ACCESS_VIEW); foreach (@$_POST as $key => $value) { $_POST[$key] = trim($value); } $id = @intval($_GET['id']); $playlist = new Playlist(); $item = $playlist->getById($_GET['playlist_id']); if (empty($item)) { echo 'wtf?'; exit; } $time = 0; if (!empty($_POST)) { $time = intval($_POST['hh']) * 60 + intval($_POST['mm']); } if (@$_POST['add']) { Admin::checkAccess(AdminAccess::ACCESS_CREATE); $playlist->addRecord(array('time' => $time, 'video_id' => $_POST['video_id'], 'playlist_id' => $_GET['playlist_id'])); header("Location: playlist.php?playlist_id=" . @$_GET['playlist_id']); exit; } if (!empty($id)) {
<div> <form method="post" id="edit_channel_<?php echo $libitem->id; ?> " class="edit_dialog_content"> <table class="tabledata" cellspacing="0" cellpadding="0"> <tr> <td class="edit_dialog_content_header"><?php echo T_('Stream Source'); ?> </td> <td><select name="object_id" autofocus> <?php $playlists = Playlist::get_playlists(); foreach ($playlists as $playlist_id) { $playlist = new Playlist($playlist_id); $playlist->format(); echo "<option value='" . $playlist->id . "'"; if ($playlist->id == $libitem->object_id) { echo " selected"; } echo ">" . $playlist->f_name . "</option>"; } ?> </select></td> </tr> <tr> <td class="edit_dialog_content_header"><?php echo T_('Name'); ?> </td>
if (!$browse->get_use_pages()) { $browse->set_start(0); } ob_start(); $browse->show_objects(null, $argument); $results[$browse->get_content_div()] = ob_get_clean(); break; case 'toggle_tag': $type = $_SESSION['tagcloud_type'] ? $_SESSION['tagcloud_type'] : 'song'; $browse->set_type($type); break; case 'delete_object': switch ($_REQUEST['type']) { case 'playlist': // Check the perms we need to on this $playlist = new Playlist($_REQUEST['id']); if (!$playlist->has_access()) { exit; } // Delete it! $playlist->delete(); $key = 'playlist_row_' . $playlist->id; break; case 'smartplaylist': $playlist = new Search($_REQUEST['id'], 'song'); if (!$playlist->has_access()) { exit; } $playlist->delete(); $key = 'smartplaylist_row_' . $playlist->id; break;
* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ define('AJAX_INCLUDE', '1'); require_once '../lib/init.php'; debug_event('refresh_reordered.server.php', 'Called for action: {' . $_REQUEST['action'] . '}', '5'); /* Switch on the action passed in */ switch ($_REQUEST['action']) { case 'refresh_playlist_medias': $playlist = new Playlist($_REQUEST['id']); $playlist->format(); $object_ids = $playlist->get_items(); $browse = new Browse(); $browse->set_type('playlist_media'); $browse->add_supplemental_object('playlist', $playlist->id); $browse->set_static_content(true); $browse->show_objects($object_ids); $browse->store(); break; case 'refresh_album_songs': $browse = new Browse(); $browse->set_show_header(true); $browse->set_type('song'); $browse->set_simple_browse(true); $browse->set_filter('album', $_REQUEST['id']);