mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-05 19:41:55 +02:00
Reworked search
Still has tentacles and should have been integrated into the existing API/Browse implementation better, but it's functional.
This commit is contained in:
parent
91a6eb3a68
commit
a9da6a6fa2
31 changed files with 2100 additions and 717 deletions
29
batch.php
29
batch.php
|
@ -53,6 +53,18 @@ switch ($_REQUEST['action']) {
|
|||
$media_ids = $playlist->get_songs();
|
||||
$name = $playlist->name;
|
||||
break;
|
||||
case 'smartplaylist':
|
||||
$search = new Search('song', $_REQUEST['id']);
|
||||
$sql = $search->to_sql();
|
||||
$sql = $sql['base'] . ' ' . $sql['table_sql'] . ' WHERE ' .
|
||||
$sql['where_sql'];
|
||||
$db_results = Dba::read($sql);
|
||||
$media_ids = array();
|
||||
while ($row = Dba::fetch_assoc($db_results)) {
|
||||
$media_ids[] = $row['id'];
|
||||
}
|
||||
$name = $search->name;
|
||||
break;
|
||||
case 'album':
|
||||
$album = new Album($_REQUEST['id']);
|
||||
$media_ids = $album->get_songs();
|
||||
|
@ -66,7 +78,22 @@ switch ($_REQUEST['action']) {
|
|||
case 'browse':
|
||||
$id = scrub_in($_REQUEST['browse_id']);
|
||||
$browse = new Browse($id);
|
||||
$media_ids = $browse->get_saved();
|
||||
$browse_media_ids = $browse->get_saved();
|
||||
$media_ids = array();
|
||||
foreach ($browse_media_ids as $media_id) {
|
||||
switch ($_REQUEST['type']) {
|
||||
case 'album':
|
||||
$album = new Album($media_id);
|
||||
$media_ids = array_merge($media_ids, $album->get_songs());
|
||||
break;
|
||||
case 'song':
|
||||
$media_ids[] = $media_id;
|
||||
break;
|
||||
case 'video':
|
||||
$media_ids[] = array('Video', $media_id);
|
||||
break;
|
||||
} // switch on type
|
||||
} // foreach media_id
|
||||
$name = 'Batch-' . date("dmY",time());
|
||||
default:
|
||||
// Rien a faire
|
||||
|
|
|
@ -55,6 +55,7 @@ switch ($_REQUEST['action']) {
|
|||
case 'album':
|
||||
case 'artist':
|
||||
case 'playlist':
|
||||
case 'smartplaylist':
|
||||
case 'live_stream':
|
||||
case 'video':
|
||||
case 'song':
|
||||
|
@ -108,6 +109,11 @@ switch($_REQUEST['action']) {
|
|||
$browse->set_filter('playlist_type','1');
|
||||
$browse->show_objects();
|
||||
break;
|
||||
case 'smartplaylist':
|
||||
$browse->set_sort('type', 'ASC');
|
||||
$browse->set_filter('playlist_type','1');
|
||||
$browse->show_objects();
|
||||
break;
|
||||
case 'video':
|
||||
$browse->set_sort('title','ASC');
|
||||
$browse->show_objects();
|
||||
|
|
|
@ -594,11 +594,13 @@ class Api {
|
|||
|
||||
/**
|
||||
* search_songs
|
||||
* This returns the songs and returns... songs
|
||||
* This searches the songs and returns... songs
|
||||
*/
|
||||
public static function search_songs($input) {
|
||||
$array['rule_1'] = 'anywhere';
|
||||
$array['rule_1_input'] = $input['filter'];
|
||||
$array['rule_1_operator'] = 0;
|
||||
|
||||
$array['s_all'] = $input['filter'];
|
||||
ob_end_clean();
|
||||
|
||||
xmlData::set_offset($input['offset']);
|
||||
|
@ -608,7 +610,7 @@ class Api {
|
|||
//Run search references these variables, ooh the huge manatee
|
||||
unset($input['limit'],$input['offset']);
|
||||
|
||||
$results = run_search($array);
|
||||
$results = Search::run($array);
|
||||
|
||||
echo xmlData::songs($results);
|
||||
|
||||
|
|
|
@ -188,6 +188,11 @@ class Browse extends Query {
|
|||
require_once Config::get('prefix') . '/templates/show_localplay_playlist.inc.php';
|
||||
show_box_bottom();
|
||||
break;
|
||||
case 'smartplaylist':
|
||||
show_box_top(_('Smart Playlists') . $match, $class);
|
||||
require_once Config::get('prefix') . '/templates/show_smartplaylists.inc.php';
|
||||
show_box_bottom();
|
||||
break;
|
||||
case 'catalog':
|
||||
show_box_top(_('Catalogs'), $class);
|
||||
require_once Config::get('prefix') . '/templates/show_catalogs.inc.php';
|
||||
|
|
|
@ -46,13 +46,9 @@
|
|||
* @link http://www.ampache.org/
|
||||
* @since Class available since Release 1.0
|
||||
*/
|
||||
class Playlist extends database_object {
|
||||
class Playlist extends playlist_object {
|
||||
|
||||
/* Variables from the database */
|
||||
public $id;
|
||||
public $name;
|
||||
public $user;
|
||||
public $type;
|
||||
public $genre;
|
||||
public $date;
|
||||
|
||||
|
@ -93,45 +89,35 @@ class Playlist extends database_object {
|
|||
|
||||
} // build_cache
|
||||
|
||||
/**
|
||||
* get_playlists
|
||||
* Returns a list of playlists accessible by the current user.
|
||||
*/
|
||||
public static function get_playlists() {
|
||||
$sql = "SELECT `id` from `playlist` WHERE `type`='public' OR " .
|
||||
"`user`='" . $GLOBALS['user']->id . "' ORDER BY `name`";
|
||||
$db_results = Dba::read($sql);
|
||||
|
||||
$results = array();
|
||||
|
||||
while ($row = Dba::fetch_assoc($db_results)) {
|
||||
$results[] = $row['id'];
|
||||
}
|
||||
|
||||
return $results;
|
||||
} // get_playlists
|
||||
|
||||
/**
|
||||
* format
|
||||
* This takes the current playlist object and gussies it up a little
|
||||
* bit so it is presentable to the users
|
||||
*/
|
||||
public function format() {
|
||||
|
||||
$this->f_name = truncate_with_ellipsis($this->name,Config::get('ellipse_threshold_title'));
|
||||
parent::format();
|
||||
$this->f_link = '<a href="' . Config::get('web_path') . '/playlist.php?action=show_playlist&playlist_id=' . $this->id . '">' . $this->f_name . '</a>';
|
||||
|
||||
$this->f_type = ($this->type == 'private') ? get_user_icon('lock',_('Private')) : '';
|
||||
|
||||
$client = new User($this->user);
|
||||
|
||||
$this->f_user = $client->fullname;
|
||||
|
||||
} // format
|
||||
|
||||
/**
|
||||
* has_access
|
||||
* This function returns true or false if the current user
|
||||
* has access to this playlist
|
||||
*/
|
||||
public function has_access() {
|
||||
|
||||
if (!Access::check('interface','25')) {
|
||||
return false;
|
||||
}
|
||||
if ($this->user == $GLOBALS['user']->id) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return Access::check('interface','100');
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
} // has_access
|
||||
|
||||
/**
|
||||
* get_track
|
||||
* Returns the single item on the playlist and all of it's information, restrict
|
||||
|
|
72
lib/class/playlist_object.abstract.php
Normal file
72
lib/class/playlist_object.abstract.php
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
|
||||
/*
|
||||
|
||||
Copyright (c) Ampache.org
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License v2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* playlist_object
|
||||
* Abstracting out functionality needed by both normal and smart playlists
|
||||
*/
|
||||
abstract class playlist_object extends database_object {
|
||||
|
||||
// Database variables
|
||||
public $id;
|
||||
public $name;
|
||||
public $user;
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* format
|
||||
* This takes the current playlist object and gussies it up a little
|
||||
* bit so it is presentable to the users
|
||||
*/
|
||||
public function format() {
|
||||
|
||||
$this->f_name = truncate_with_ellipsis($this->name,Config::get('ellipse_threshold_title'));
|
||||
$this->f_type = ($this->type == 'private') ? get_user_icon('lock',_('Private')) : '';
|
||||
|
||||
$client = new User($this->user);
|
||||
|
||||
$this->f_user = $client->fullname;
|
||||
|
||||
} // format
|
||||
|
||||
/**
|
||||
* has_access
|
||||
* This function returns true or false if the current user
|
||||
* has access to this playlist
|
||||
*/
|
||||
public function has_access() {
|
||||
|
||||
if (!Access::check('interface','25')) {
|
||||
return false;
|
||||
}
|
||||
if ($this->user == $GLOBALS['user']->id) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return Access::check('interface','100');
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
} // has_access
|
||||
|
||||
|
||||
} // end playlist_object
|
|
@ -144,6 +144,10 @@ class Query {
|
|||
'alpha_match',
|
||||
'starts_with'
|
||||
),
|
||||
'smartplaylist' => array(
|
||||
'alpha_match',
|
||||
'starts_with'
|
||||
),
|
||||
'tag' => array(
|
||||
'tag',
|
||||
'object_type',
|
||||
|
@ -194,6 +198,10 @@ class Query {
|
|||
'name',
|
||||
'user'
|
||||
),
|
||||
'smartplaylist' => array(
|
||||
'name',
|
||||
'user'
|
||||
),
|
||||
'shoutbox' => array(
|
||||
'date',
|
||||
'user',
|
||||
|
@ -465,6 +473,7 @@ class Query {
|
|||
case 'video':
|
||||
case 'playlist':
|
||||
case 'playlist_song':
|
||||
case 'smartplaylist':
|
||||
case 'song':
|
||||
case 'flagged':
|
||||
case 'catalog':
|
||||
|
@ -735,6 +744,10 @@ class Query {
|
|||
$this->set_select("`playlist`.`id`");
|
||||
$sql = "SELECT %%SELECT%% FROM `playlist` ";
|
||||
break;
|
||||
case 'smartplaylist':
|
||||
self::set_select('`search`.`id`');
|
||||
$sql = "SELECT %%SELECT%% FROM `search` ";
|
||||
break;
|
||||
case 'flagged':
|
||||
$this->set_select("`flagged`.`id`");
|
||||
$sql = "SELECT %%SELECT%% FROM `flagged` ";
|
||||
|
@ -1127,6 +1140,20 @@ class Query {
|
|||
break;
|
||||
} // end filter
|
||||
break;
|
||||
case 'smartplaylist':
|
||||
switch ($filter) {
|
||||
case 'alpha_match':
|
||||
$filter_sql = " `search`.`name` LIKE '%" . Dba::escape($value) . "%' AND ";
|
||||
break;
|
||||
case 'starts_with':
|
||||
$filter_sql = " `search`.`name` LIKE '" . Dba::escape($value) . "%' AND ";
|
||||
break;
|
||||
case 'playlist_type':
|
||||
$user_id = intval($GLOBALS['user']->id);
|
||||
$filter_sql = " (`search`.`type` = 'public' OR `search`.`user`='$user_id') AND ";
|
||||
break;
|
||||
} // end switch on $filter
|
||||
break;
|
||||
case 'tag':
|
||||
switch ($filter) {
|
||||
case 'alpha_match':
|
||||
|
@ -1251,6 +1278,19 @@ class Query {
|
|||
break;
|
||||
} // end switch
|
||||
break;
|
||||
case 'smartplaylist':
|
||||
switch ($field) {
|
||||
case 'type':
|
||||
$sql = "`search`.`type`";
|
||||
break;
|
||||
case 'name':
|
||||
$sql = "`search`.`name`";
|
||||
break;
|
||||
case 'user':
|
||||
$sql = "`search`.`user`";
|
||||
break;
|
||||
} // end switch on $field
|
||||
break;
|
||||
case 'live_stream':
|
||||
switch ($field) {
|
||||
case 'name':
|
||||
|
|
|
@ -254,120 +254,60 @@ class Random implements media {
|
|||
* This processes the results of a post from a form and returns an
|
||||
* array of song items that were returned from said randomness
|
||||
*/
|
||||
public static function advanced($data) {
|
||||
public static function advanced($type, $data) {
|
||||
|
||||
/* Figure out our object limit */
|
||||
$limit = intval($data['random']);
|
||||
|
||||
// Generate our matchlist
|
||||
if ($data['catalog'] != '-1') {
|
||||
$matchlist['catalog'] = $data['catalog'];
|
||||
}
|
||||
if ($data['genre'][0] != '-1') {
|
||||
$matchlist['genre'] = $data['genre'];
|
||||
}
|
||||
|
||||
/* If they've passed -1 as limit then don't get everything */
|
||||
/* If they've passed -1 as limit then get everything */
|
||||
if ($data['random'] == "-1") { unset($data['random']); }
|
||||
else { $limit_sql = "LIMIT " . Dba::escape($limit); }
|
||||
|
||||
$where = "1=1 ";
|
||||
if (is_array($matchlist)) {
|
||||
foreach ($matchlist as $type => $value) {
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $v) {
|
||||
if (!strlen($v)) { continue; }
|
||||
$v = Dba::escape($v);
|
||||
if ($v != $value[0]) { $where .= " OR $type='$v' "; }
|
||||
else { $where .= " AND ( $type='$v'"; }
|
||||
}
|
||||
$where .= ")";
|
||||
}
|
||||
elseif (strlen($value)) {
|
||||
$value = Dba::escape($value);
|
||||
$where .= " AND $type='$value' ";
|
||||
}
|
||||
} // end foreach
|
||||
} // end if matchlist
|
||||
$search_data = Search::clean_request($data);
|
||||
|
||||
switch ($data['random_type']) {
|
||||
case 'full_album':
|
||||
$query = "SELECT `album`.`id` FROM `song` INNER JOIN `album` ON `song`.`album`=`album`.`id` " .
|
||||
"WHERE $where GROUP BY `song`.`album` ORDER BY RAND() $limit_sql";
|
||||
$db_results = Dba::read($query);
|
||||
while ($row = Dba::fetch_assoc($db_results)) {
|
||||
$albums_where .= " OR `song`.`album`=" . $row['id'];
|
||||
$search_info = false;
|
||||
|
||||
if (count($search_data) > 1) {
|
||||
$search = new Search($type);
|
||||
$search->parse_rules($search_data);
|
||||
$search_info = $search->to_sql();
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'song':
|
||||
$sql = "SELECT `song`.`id`, `size`, `time` " .
|
||||
"FROM `song` ";
|
||||
if ($search_info) {
|
||||
$sql .= $search_info['table_sql'];
|
||||
$sql .= ' WHERE ' . $search_info['where_sql'];
|
||||
}
|
||||
$albums_where = ltrim($albums_where," OR");
|
||||
$sql = "SELECT `song`.`id`,`song`.`size`,`song`.`time` FROM `song` WHERE $albums_where ORDER BY `song`.`album`,`song`.`track` ASC";
|
||||
break;
|
||||
case 'full_artist':
|
||||
$query = "SELECT `artist`.`id` FROM `song` INNER JOIN `artist` ON `song`.`artist`=`artist`.`id` " .
|
||||
"WHERE $where GROUP BY `song`.`artist` ORDER BY RAND() $limit_sql";
|
||||
$db_results = Dba::read($query);
|
||||
while ($row = Dba::fetch_row($db_results)) {
|
||||
$artists_where .= " OR song.artist=" . $row[0];
|
||||
case 'album':
|
||||
$sql = "SELECT `album`.`id`, SUM(`song`.`size`) AS `size`, SUM(`song`.`time`) AS `time` FROM `album` ";
|
||||
if (! $search_info || ! $search_info['join']['song']) {
|
||||
$sql .= "LEFT JOIN `song` ON `song`.`album`=`album`.`id` ";
|
||||
}
|
||||
$artists_where = ltrim($artists_where," OR");
|
||||
$sql = "SELECT song.id,song.size,song.time FROM song WHERE $artists_where ORDER BY RAND()";
|
||||
if ($search_info) {
|
||||
$sql .= $search_info['table_sql'];
|
||||
$sql .= ' WHERE ' . $search_info['where_sql'];
|
||||
}
|
||||
$sql .= ' GROUP BY `album`.`id`';
|
||||
break;
|
||||
case 'unplayed':
|
||||
$uid = Dba::escape($GLOBALS['user']->id);
|
||||
$sql = "SELECT object_id,COUNT(`id`) AS `total` FROM `object_count` WHERE `user`='$uid' GROUP BY `object_id`";
|
||||
$db_results = Dba::read($sql);
|
||||
|
||||
$in_sql = "`id` IN (";
|
||||
|
||||
while ($row = Dba::fetch_assoc($db_results)) {
|
||||
$row['object_id'] = Dba::escape($row['object_id']);
|
||||
$in_sql .= "'" . $row['object_id'] . "',";
|
||||
case 'artist':
|
||||
$sql = "SELECT `artist`.`id`, SUM(`song`.`size`) AS `size`, SUM(`song`.`time`) AS `time` FROM `artist` ";
|
||||
if (! $search_info || ! $search_info['join']['song']) {
|
||||
$sql .= "LEFT JOIN `song` ON `song`.`artist`=`artist`.`id` ";
|
||||
}
|
||||
|
||||
$in_sql = rtrim($in_sql,',') . ')';
|
||||
|
||||
$sql = "SELECT song.id,song.size,song.time FROM song " .
|
||||
"WHERE ($where) AND $in_sql ORDER BY RAND() $limit_sql";
|
||||
if ($search_info) {
|
||||
$sql .= $search_info['table_sql'];
|
||||
$sql .= ' WHERE ' . $search_info['where_sql'];
|
||||
}
|
||||
$sql .= ' GROUP BY `artist`.`id`';
|
||||
break;
|
||||
case 'high_rating':
|
||||
$sql = "SELECT `rating`.`object_id`,`rating`.`rating` FROM `rating` " .
|
||||
"WHERE `rating`.`object_type`='song' ORDER BY `rating` DESC";
|
||||
$db_results = Dba::read($sql);
|
||||
|
||||
// Get all of the ratings for songs
|
||||
while ($row = Dba::fetch_assoc($db_results)) {
|
||||
$results[$row['object_id']][] = $row['rating'];
|
||||
}
|
||||
// Calculate the averages
|
||||
foreach ($results as $key=>$rating_array) {
|
||||
$average = intval(array_sum($rating_array) / count($rating_array));
|
||||
// We have to do this because array_slice doesn't maintain indexes
|
||||
$new_key = $average . $key;
|
||||
$ratings[$new_key] = $key;
|
||||
}
|
||||
|
||||
// Sort it by the value and slice at $limit * 2 so we have a little bit of randomness
|
||||
krsort($ratings);
|
||||
$ratings = array_slice($ratings,0,$limit*2);
|
||||
|
||||
$in_sql = "`song`.`id` IN (";
|
||||
|
||||
// Build the IN query, cause if you're OUT it ain't cool
|
||||
foreach ($ratings as $song_id) {
|
||||
$key = Dba::escape($song_id);
|
||||
$in_sql .= "'$key',";
|
||||
}
|
||||
|
||||
$in_sql = rtrim($in_sql,',') . ')';
|
||||
|
||||
// Apply true limit and order by rand
|
||||
$sql = "SELECT song.id,song.size,song.time FROM song " .
|
||||
"WHERE ($where) AND $in_sql ORDER BY RAND() $limit_sql";
|
||||
break;
|
||||
default:
|
||||
$sql = "SELECT `id`,`size`,`time` FROM `song` WHERE $where ORDER BY RAND() $limit_sql";
|
||||
|
||||
break;
|
||||
} // end switch on type of random play
|
||||
}
|
||||
$sql .= " ORDER BY RAND() $limit_sql";
|
||||
|
||||
// Run the query generated above so we can while it
|
||||
$db_results = Dba::read($sql);
|
||||
|
@ -380,17 +320,23 @@ class Random implements media {
|
|||
// Convert
|
||||
$new_size = ($row['size'] / 1024) / 1024;
|
||||
|
||||
// Only fuzzy 10 times
|
||||
if ($fuzzy_size > 10) { return $results; }
|
||||
// Only fuzzy 100 times
|
||||
if ($fuzzy_size > 100) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Add and check, skip if over don't return incase theres a smaller one commin round
|
||||
if (($size_total + $new_size) > $data['size_limit']) { $fuzzy_size++; continue; }
|
||||
// Add and check, skip if over size
|
||||
if (($size_total + $new_size) > $data['size_limit']) {
|
||||
$fuzzy_size++;
|
||||
continue;
|
||||
}
|
||||
|
||||
$size_total = $size_total + $new_size;
|
||||
$results[] = $row['id'];
|
||||
|
||||
// If we are within 4mb of target then jump ship
|
||||
if (($data['size_limit'] - floor($size_total)) < 4) { return $results; }
|
||||
if (($data['size_limit'] - floor($size_total)) < 4) {
|
||||
break; }
|
||||
} // if size_limit
|
||||
|
||||
// If length really does matter
|
||||
|
@ -398,33 +344,60 @@ class Random implements media {
|
|||
// base on min, seconds are for chumps and chumpettes
|
||||
$new_time = floor($row['time'] / 60);
|
||||
|
||||
if ($fuzzy_time > 10) { return $results; }
|
||||
if ($fuzzy_time > 100) {
|
||||
break;;
|
||||
}
|
||||
|
||||
// If the new one would go voer skip!
|
||||
if (($time_total + $new_time) > $data['length']) { $fuzzy_time++; continue; }
|
||||
// If the new one would go over skip!
|
||||
if (($time_total + $new_time) > $data['length']) {
|
||||
$fuzzy_time++;
|
||||
continue;
|
||||
}
|
||||
|
||||
$time_total = $time_total + $new_time;
|
||||
$results[] = $row['id'];
|
||||
|
||||
// If there are less then 2 min of free space return
|
||||
if (($data['length'] - $time_total) < 2) { return $results; }
|
||||
|
||||
if (($data['length'] - $time_total) < 2) {
|
||||
return $results;
|
||||
}
|
||||
} // if length does matter
|
||||
|
||||
if (!$data['size_limit'] AND !$data['length']) {
|
||||
if (!$data['size_limit'] && !$data['length']) {
|
||||
$results[] = $row['id'];
|
||||
}
|
||||
|
||||
} // end while results
|
||||
|
||||
|
||||
return $results;
|
||||
|
||||
switch ($type) {
|
||||
case 'song':
|
||||
return $results;
|
||||
break;
|
||||
case 'album':
|
||||
$songs = array();
|
||||
foreach ($results as $result) {
|
||||
$album = new Album($result);
|
||||
$songs = array_merge($songs, $album->get_songs());
|
||||
}
|
||||
return $songs;
|
||||
break;
|
||||
case 'artist':
|
||||
$songs = array();
|
||||
foreach ($results as $result) {
|
||||
$artist = new Artist($result);
|
||||
$songs = array_merge($songs, $artist->get_songs());
|
||||
}
|
||||
return $songs;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
} // advanced
|
||||
|
||||
/**
|
||||
* get_type_name
|
||||
* This returns a 'purrty' name for the differnt random types
|
||||
* This returns a 'purrty' name for the different random types
|
||||
*/
|
||||
public static function get_type_name($type) {
|
||||
|
||||
|
|
1033
lib/class/search.class.php
Normal file
1033
lib/class/search.class.php
Normal file
File diff suppressed because it is too large
Load diff
|
@ -371,6 +371,9 @@ class Update {
|
|||
$update_string = '- Modify tmp_browse to allow caching of multiple browses per session.<br />';
|
||||
$version[] = array('version' => '360005','description' => $update_string);
|
||||
|
||||
$update_string = '- Add table for dynamic playlists.<br />';
|
||||
$version[] = array('version' => '360006','description' => $update_string);
|
||||
|
||||
return $version;
|
||||
|
||||
} // populate_version
|
||||
|
@ -1979,5 +1982,24 @@ class Update {
|
|||
self::set_version('db_version','360005');
|
||||
} // update_360005
|
||||
|
||||
/**
|
||||
* update_360006
|
||||
* This adds the table for newsearch/dynamic playlists
|
||||
*/
|
||||
public static function update_360006() {
|
||||
$sql = "CREATE TABLE `search` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`user` int(11) NOT NULL,
|
||||
`type` enum('private','public') CHARACTER SET utf8 DEFAULT NULL,
|
||||
`rules` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
||||
`name` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
|
||||
`logic_operator` varchar(3) CHARACTER SET utf8 DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
|
||||
$db_results = Dba::write($sql);
|
||||
|
||||
self::set_version('db_version','360006');
|
||||
}
|
||||
|
||||
} // end update class
|
||||
?>
|
||||
|
|
|
@ -134,7 +134,6 @@ $results['mysql_db'] = $results['database_name'];
|
|||
define('INIT_LOADED','1');
|
||||
|
||||
// Library and module includes we can't do with the autoloader
|
||||
require_once $prefix . '/lib/search.php';
|
||||
require_once $prefix . '/lib/preferences.php';
|
||||
require_once $prefix . '/lib/log.lib.php';
|
||||
require_once $prefix . '/lib/ui.lib.php';
|
||||
|
@ -143,6 +142,7 @@ require_once $prefix . '/lib/batch.lib.php';
|
|||
require_once $prefix . '/lib/themes.php';
|
||||
require_once $prefix . '/lib/class/localplay.abstract.php';
|
||||
require_once $prefix . '/lib/class/database_object.abstract.php';
|
||||
require_once $prefix . '/lib/class/playlist_object.abstract.php';
|
||||
require_once $prefix . '/lib/class/media.interface.php';
|
||||
require_once $prefix . '/modules/getid3/getid3.php';
|
||||
require_once $prefix . '/modules/nusoap/nusoap.php';
|
||||
|
|
49
lib/javascript/search-data.php
Normal file
49
lib/javascript/search-data.php
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
|
||||
/**
|
||||
|
||||
Copyright (c) Ampache.org
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License v2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
require_once '../init.php';
|
||||
|
||||
function arrayToJSON($array) {
|
||||
$json = '{ ';
|
||||
foreach ($array as $key => $value) {
|
||||
$json .= '"' . $key . '" : ';
|
||||
if (is_array($value)) {
|
||||
$json .= arrayToJSON($value);
|
||||
}
|
||||
else {
|
||||
$json .= '"' . $value . '"';
|
||||
}
|
||||
$json .= ' , ';
|
||||
}
|
||||
$json = rtrim($json, ', ');
|
||||
return $json . ' }';
|
||||
}
|
||||
|
||||
Header('content-type: application/x-javascript');
|
||||
|
||||
$search = new Search($_REQUEST['type']);
|
||||
|
||||
echo 'var types = $H(\'';
|
||||
echo arrayToJSON($search->types) . "'.evalJSON());\n";
|
||||
echo 'var basetypes = $H(\'';
|
||||
echo arrayToJSON($search->basetypes) . "'.evalJSON());\n";
|
||||
echo 'removeIcon = \'<a href="javascript: void(0)">' . get_user_icon('disable', _('Remove')) . '</a>\';';
|
||||
?>
|
168
lib/javascript/search.js
Normal file
168
lib/javascript/search.js
Normal file
|
@ -0,0 +1,168 @@
|
|||
// vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab:
|
||||
//
|
||||
// Copyright (c) Ampache.org
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License v2
|
||||
// as published by the Free Software Foundation.
|
||||
//
|
||||
//
|
||||
// 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 General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
var rowIter = 1;
|
||||
var rowCount = 0;
|
||||
|
||||
var SearchRow = {
|
||||
add: function(ruleType, operator, input) {
|
||||
if (typeof(ruleType) != 'string') {
|
||||
ruleType = 0;
|
||||
}
|
||||
else {
|
||||
types.each(function(i) {
|
||||
if (i.value.name == ruleType) {
|
||||
ruleType = i.key;
|
||||
throw $break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof(operator) != 'string') {
|
||||
operator = 0;
|
||||
}
|
||||
else {
|
||||
$H(basetypes.get(types.get(ruleType).type)).each(function(i) {
|
||||
if (i.value.name == operator) {
|
||||
operator = i.key;
|
||||
throw $break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var row = document.createElement('tr');
|
||||
var cells = new Array();
|
||||
for (var i = 0 ; i < 5 ; i++) {
|
||||
cells[i] = document.createElement('td');
|
||||
}
|
||||
|
||||
cells[0].appendChild(SearchRow.constructOptions(ruleType, rowIter));
|
||||
cells[1].appendChild(SearchRow.constructOperators(ruleType, rowIter, operator));
|
||||
cells[2].appendChild(SearchRow.constructInput(ruleType, rowIter, input));
|
||||
cells[3].innerHTML = removeIcon;
|
||||
|
||||
cells.each(function(i) {
|
||||
row.appendChild(i);
|
||||
});
|
||||
|
||||
$('searchtable').appendChild(row);
|
||||
rowCount++;
|
||||
|
||||
Event.observe(cells[3], 'click', function(e){if(rowCount > 1) { Element.remove(this.parentNode); rowCount--; }});
|
||||
|
||||
rowIter++;
|
||||
},
|
||||
constructInput: function(ruleType, ruleNumber, input) {
|
||||
if (input === null || input === undefined) {
|
||||
input = '';
|
||||
}
|
||||
|
||||
widget = $H(types.get(ruleType).widget);
|
||||
|
||||
var inputNode = document.createElement(widget.get('0'));
|
||||
inputNode.id = 'rule_' + ruleNumber + '_input';
|
||||
inputNode.name = 'rule_' + ruleNumber + '_input';
|
||||
|
||||
switch(widget.get('0')) {
|
||||
case 'input':
|
||||
inputNode.setAttribute('type', widget.get('1'));
|
||||
inputNode.setAttribute('value', input);
|
||||
break;
|
||||
case 'select':
|
||||
$H(widget.get('1')).each(function(i) {
|
||||
var option = document.createElement('option');
|
||||
if ( isNaN(parseInt(i.value)) ) {
|
||||
realvalue = i.key;
|
||||
}
|
||||
else {
|
||||
realvalue = parseInt(i.value);
|
||||
}
|
||||
if ( input == realvalue ) {
|
||||
option.selected = true;
|
||||
}
|
||||
option.value = realvalue;
|
||||
option.innerHTML = i.value;
|
||||
inputNode.appendChild(option);
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
return inputNode;
|
||||
},
|
||||
constructOptions: function(ruleType, ruleNumber) {
|
||||
var optionsNode = document.createElement('select');
|
||||
optionsNode.id = 'rule_' + ruleNumber;
|
||||
optionsNode.name = 'rule_' + ruleNumber;
|
||||
|
||||
types.each(function(i) {
|
||||
var option = document.createElement('option');
|
||||
option.innerHTML = i.value.label;
|
||||
option.value = i.value.name;
|
||||
if ( i.key == ruleType ) {
|
||||
option.selected = true;
|
||||
}
|
||||
optionsNode.appendChild(option);
|
||||
});
|
||||
|
||||
Event.observe(optionsNode, 'change', SearchRow.update);
|
||||
|
||||
return optionsNode;
|
||||
},
|
||||
constructOperators: function(ruleType, ruleNumber, operator) {
|
||||
var operatorNode = document.createElement('select');
|
||||
operatorNode.id = 'rule_' + ruleNumber + '_operator';
|
||||
operatorNode.name = 'rule_' + ruleNumber + '_operator';
|
||||
|
||||
basetype = types.get(ruleType).type;
|
||||
operatorNode.className = 'operator' + basetype;
|
||||
|
||||
$H(basetypes.get(basetype)).each(function(i) {
|
||||
var option = document.createElement('option');
|
||||
option.innerHTML = i.value.description;
|
||||
option.value = i.key;
|
||||
if (i.key == operator) {
|
||||
option.selected = true;
|
||||
}
|
||||
operatorNode.appendChild(option);
|
||||
});
|
||||
|
||||
return operatorNode;
|
||||
},
|
||||
update: function() {
|
||||
var r_findID = /rule_(\d+)/;
|
||||
var targetID = r_findID.exec(this.id)[1];
|
||||
|
||||
var operator = $('rule_' + targetID + '_operator');
|
||||
if (operator.className != 'operator' + types.get(this.selectedIndex).type) {
|
||||
var operator_cell = operator.parentNode;
|
||||
Element.remove(operator);
|
||||
operator_cell.appendChild(SearchRow.constructOperators(this.selectedIndex, targetID));
|
||||
}
|
||||
|
||||
var input = $('rule_' + targetID + '_input');
|
||||
|
||||
if (input.type == 'text') {
|
||||
var oldinput = input.value;
|
||||
}
|
||||
|
||||
var input_cell = input.parentNode;
|
||||
Element.remove(input);
|
||||
input_cell.appendChild(SearchRow.constructInput(this.selectedIndex, targetID, oldinput));
|
||||
}
|
||||
};
|
294
lib/search.php
294
lib/search.php
|
@ -1,294 +0,0 @@
|
|||
<?php
|
||||
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
|
||||
/**
|
||||
* Search Library
|
||||
*
|
||||
* This library handles all the searching!
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: GNU General Public License, version 2 (GPLv2)
|
||||
* Copyright (c) 2001 - 2011 Ampache.org All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License v2
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @category Search
|
||||
* @package Library
|
||||
* @author Karl Vollmer <vollmer@ampache.org>
|
||||
* @copyright 2001 - 2011 Ampache.org
|
||||
* @license http://opensource.org/licenses/gpl-2.0 GPLv2
|
||||
* @version PHP 5.2
|
||||
* @link http://www.ampache.org/
|
||||
* @since File available since Release 1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* run_search
|
||||
* this function actually runs the search, and returns an array of the results. Unlike the previous
|
||||
* function it does not do the display work its self.
|
||||
*/
|
||||
function run_search($data) {
|
||||
|
||||
/* Create an array of the object we need to search on */
|
||||
foreach ($data as $key=>$value) {
|
||||
/* Get the first two chars to check
|
||||
* and see if it's s_
|
||||
*/
|
||||
$prefix = substr($key,0,2);
|
||||
$value = trim($value);
|
||||
|
||||
if ($prefix == 's_' AND strlen($value)) {
|
||||
$true_name = substr($key,2,strlen($key));
|
||||
$search[$true_name] = Dba::escape($value);
|
||||
}
|
||||
|
||||
} // end foreach
|
||||
|
||||
/* Figure out if they want a AND based search or a OR based search */
|
||||
switch($_REQUEST['operator']) {
|
||||
case 'or':
|
||||
$operator = 'OR';
|
||||
break;
|
||||
default:
|
||||
$operator = 'AND';
|
||||
break;
|
||||
} // end switch on operator
|
||||
|
||||
/* Figure out what type of method they would like to use, exact or fuzzy */
|
||||
switch($_REQUEST['method']) {
|
||||
case 'fuzzy':
|
||||
$method = "LIKE '%__%'";
|
||||
break;
|
||||
default:
|
||||
$method = "= '__'";
|
||||
break;
|
||||
} // end switch on method
|
||||
|
||||
$limit = intval($_REQUEST['limit']);
|
||||
|
||||
/* Switch, and run the correct function */
|
||||
switch($_REQUEST['object_type']) {
|
||||
case 'artist':
|
||||
case 'album':
|
||||
case 'song':
|
||||
$function_name = 'search_' . $_REQUEST['object_type'];
|
||||
if (function_exists($function_name)) {
|
||||
$results = call_user_func($function_name,$search,$operator,$method,$limit);
|
||||
return $results;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$results = search_song($search,$operator,$method,$limit);
|
||||
return $results;
|
||||
break;
|
||||
} // end switch
|
||||
|
||||
return array();
|
||||
|
||||
} // run_search
|
||||
|
||||
/**
|
||||
* search_song
|
||||
* This function deals specificly with returning song object for the run_search
|
||||
* function, it assumes that our root table is songs
|
||||
* @package Search
|
||||
* @catagory Search
|
||||
*/
|
||||
function search_song($data,$operator,$method,$limit) {
|
||||
|
||||
/* Generate BASE SQL */
|
||||
|
||||
$where_sql = '';
|
||||
$table_sql = '';
|
||||
$group_sql = ' GROUP BY';
|
||||
$select_sql = ',';
|
||||
$field_sql = '';
|
||||
$order_sql = '';
|
||||
|
||||
if ($limit > 0) {
|
||||
$limit_sql = " LIMIT $limit";
|
||||
}
|
||||
|
||||
foreach ($data as $type=>$value) {
|
||||
|
||||
/* Create correct Value statement based on method */
|
||||
|
||||
$value_string = str_replace("__",$value,$method);
|
||||
|
||||
switch ($type) {
|
||||
case 'all':
|
||||
$additional_soundex = false;
|
||||
|
||||
if (!(strpos($value, '-'))) // if we want a fuzzier search
|
||||
$additional_soundex = true;
|
||||
|
||||
$where_sql = "( MATCH (`artist2`.`name`, `album2`.`name`, `song`.`title`) AGAINST ('$value' IN BOOLEAN MODE)";
|
||||
|
||||
if ($additional_soundex) {
|
||||
$where_sql.= " OR `artist2`.`name` SOUNDS LIKE '$value'";
|
||||
$where_sql.= " OR `album2`.`name` SOUNDS LIKE '$value'";
|
||||
$where_sql.= " OR `song`.`title` SOUNDS LIKE '$value' ";
|
||||
}
|
||||
$where_sql .= ") $operator";
|
||||
|
||||
$table_sql = " LEFT JOIN `album` as `album2` ON `song`.`album`=`album2`.`id`";
|
||||
$table_sql.= " LEFT JOIN `artist` AS `artist2` ON `song`.`artist`=`artist2`.`id`";
|
||||
|
||||
$order_sql = " ORDER BY";
|
||||
|
||||
$order_sql.= " MATCH (`artist2`.`name`) AGAINST ('$value' IN BOOLEAN MODE)";
|
||||
if ($additional_soundex) $order_sql.= " + (SOUNDEX(`artist2`.`name`)=SOUNDEX('$value')) DESC,"; else $order_sql.= " DESC,";
|
||||
|
||||
$order_sql.= " MATCH (`album2`.`name`) AGAINST ('$value' IN BOOLEAN MODE)";
|
||||
if ($additional_soundex) $order_sql.= " + (SOUNDEX(`album2`.`name`)=SOUNDEX('$value')) DESC,"; else $order_sql.= " DESC,";
|
||||
|
||||
$order_sql.= " MATCH (`song`.`title`) AGAINST ('$value' IN BOOLEAN MODE)";
|
||||
if ($additional_soundex) $order_sql.= " + (SOUNDEX(`song`.`title`)=SOUNDEX('$value')) DESC,"; else $order_sql.= " DESC,";
|
||||
|
||||
$order_sql.= " `artist2`.`name`,";
|
||||
$order_sql.= " `album2`.`name`,";
|
||||
$order_sql.= " `song`.`track`,";
|
||||
$order_sql.= " `song`.`title`";
|
||||
break;
|
||||
case 'title':
|
||||
$where_sql .= " `song`.`title` $value_string $operator";
|
||||
break;
|
||||
case 'album':
|
||||
$where_sql .= " `album`.`name` $value_string $operator";
|
||||
$table_sql .= " LEFT JOIN `album` ON `song`.`album`=`album`.`id`";
|
||||
break;
|
||||
case 'artist':
|
||||
$where_sql .= " `artist`.`name` $value_string $operator";
|
||||
$table_sql .= " LEFT JOIN `artist` ON `song`.`artist`=`artist`.`id` ";
|
||||
break;
|
||||
case 'year':
|
||||
if (empty($data["year2"]) && is_numeric($data["year"])) {
|
||||
$where_sql .= " `song`.`year` $value_string $operator";
|
||||
}
|
||||
elseif (!empty($data["year"]) && is_numeric($data["year"]) && !empty($data["year2"]) && is_numeric($data["year2"])) {
|
||||
$where_sql .= " (`song`.`year` BETWEEN ".$data["year"]." AND ".$data["year2"].") $operator";
|
||||
}
|
||||
break;
|
||||
case 'time':
|
||||
if (!empty($data['time2'])) {
|
||||
$where_sql .= " `song`.`time` <= " . Dba::escape(intval($data['time2'])*60) . " $operator";
|
||||
}
|
||||
if (!empty($data['time'])) {
|
||||
$where_sql .= " `song`.`time` >= " . Dba::escape(intval($data['time'])*60) . " $operator";
|
||||
}
|
||||
break;
|
||||
case 'filename':
|
||||
$where_sql .= " `song`.`file` $value_string $operator";
|
||||
break;
|
||||
case 'comment':
|
||||
$table_sql .= ' INNER JOIN `song_data` ON `song`.`id`=`song_data`.`song_id`';
|
||||
$where_sql .= " `song_data`.`comment` $value_string $operator";
|
||||
break;
|
||||
case 'played':
|
||||
/* This is a 0/1 value so bool it */
|
||||
$value = make_bool($value);
|
||||
$where_sql .= " `song`.`played` = '$value' $operator";
|
||||
break;
|
||||
case 'minbitrate':
|
||||
$value = intval($value);
|
||||
$where_sql .= " `song`.`bitrate` >= ('$value'*1000) $operator";
|
||||
break;
|
||||
case 'rating':
|
||||
$value = intval($value);
|
||||
$userid = $GLOBALS['user']->id;
|
||||
$rcomparison = '>=';
|
||||
if ($_REQUEST['s_rating_operator'] == '1') {
|
||||
$rcomparison = '<=';
|
||||
}
|
||||
elseif ($_REQUEST['s_rating_operator'] == '2') {
|
||||
$rcomparison = '<=>';
|
||||
}
|
||||
// Complex SQL follows
|
||||
// We do a join on ratings from the table with a
|
||||
// preference for our own and fall back to the
|
||||
// FLOORed average of everyone's rating if it's
|
||||
// a song we haven't rated.
|
||||
if ($operator == 'AND') {
|
||||
$table_sql .= ' INNER JOIN';
|
||||
}
|
||||
else {
|
||||
$table_sql .= ' LEFT JOIN';
|
||||
}
|
||||
$table_sql .= " (SELECT `object_id`, `rating` FROM `rating` WHERE `object_type`='song' AND `user`='$userid'
|
||||
UNION
|
||||
SELECT `object_id`, FLOOR(AVG(`rating`)) AS 'rating' FROM `rating`
|
||||
WHERE `object_type`='song' AND
|
||||
`object_id` NOT IN (SELECT `object_id` FROM `rating` WHERE `object_type`='song' AND `user`='$userid')
|
||||
GROUP BY `object_id`
|
||||
) AS realrating ON `song`.`id` = `realrating`.`object_id`";
|
||||
|
||||
$where_sql .= " `realrating`.`rating` $rcomparison '$value' $operator";
|
||||
break;
|
||||
case 'tag':
|
||||
|
||||
// Fill it with one value to prevent sql error on no results
|
||||
$ids = array('0');
|
||||
|
||||
$tag_sql = "SELECT `object_id` FROM `tag` LEFT JOIN `tag_map` ON `tag`.`id`=`tag_map`.`tag_id` " .
|
||||
"WHERE `tag_map`.`object_type`='song' AND `tag`.`name` $value_string ";
|
||||
$db_results = Dba::read($tag_sql);
|
||||
|
||||
while ($row = Dba::fetch_assoc($db_results)) {
|
||||
$ids[] = $row['object_id'];
|
||||
}
|
||||
|
||||
$where_sql = " `song`.`id` IN (" . implode(',',$ids) . ") $operator";
|
||||
|
||||
break;
|
||||
default:
|
||||
// Notzing!
|
||||
break;
|
||||
} // end switch on type
|
||||
|
||||
|
||||
} // foreach data
|
||||
|
||||
/* Trim off the extra $method's and ,'s then combine the sucka! */
|
||||
$where_sql = rtrim($where_sql,$operator);
|
||||
$group_sql = rtrim($group_sql,',');
|
||||
$select_sql = rtrim($select_sql,',');
|
||||
|
||||
if ($group_sql == ' GROUP BY') { $group_sql = ''; }
|
||||
|
||||
$base_sql = "SELECT DISTINCT(`song`.`id`) $field_sql $select_sql FROM `song`";
|
||||
|
||||
$sql = $base_sql . $table_sql . " WHERE " . $where_sql . $group_sql . $order_sql . $limit_sql;
|
||||
|
||||
/**
|
||||
* Because we might need this for Dynamic Playlist Action
|
||||
* but we don't trust users to provide this store it in the
|
||||
* session where they can't get to it!
|
||||
*/
|
||||
|
||||
$_SESSION['userdata']['stored_search'] = $sql;
|
||||
|
||||
$db_results = Dba::read($sql);
|
||||
|
||||
$results = array();
|
||||
|
||||
while ($row = Dba::fetch_assoc($db_results)) {
|
||||
$results[] = $row['id'];
|
||||
}
|
||||
|
||||
return $results;
|
||||
|
||||
} // search_songs
|
||||
|
||||
|
||||
?>
|
|
@ -37,18 +37,15 @@ show_header();
|
|||
|
||||
switch ($_REQUEST['action']) {
|
||||
case 'get_advanced':
|
||||
$object_ids = Random::advanced($_POST);
|
||||
$object_ids = Random::advanced($_REQUEST['type'], $_POST);
|
||||
|
||||
// We need to add them to the active playlist
|
||||
foreach ($object_ids as $object_id) {
|
||||
$GLOBALS['user']->playlist->add_object($object_id,'song');
|
||||
$GLOBALS['user']->playlist->add_object($object_id, 'song');
|
||||
}
|
||||
|
||||
case 'advanced':
|
||||
default:
|
||||
require_once Config::get('prefix') . '/templates/show_random.inc.php';
|
||||
/* require_once Config::get('prefix') . '/templates/show_random_rules.inc.php';*/
|
||||
|
||||
break;
|
||||
} // end switch
|
||||
|
||||
|
|
20
search.php
20
search.php
|
@ -39,24 +39,12 @@ show_header();
|
|||
* action switch
|
||||
*/
|
||||
switch ($_REQUEST['action']) {
|
||||
case 'quick_search':
|
||||
/* This needs to be done because we don't know what thing
|
||||
* they used the quick search to search on until after they've
|
||||
* submited it
|
||||
*/
|
||||
$_REQUEST['s_all'] = $_REQUEST['search_string'];
|
||||
|
||||
if (strlen($_REQUEST['search_string']) < 1) {
|
||||
Error::add('keyword',_('Error: No Keyword Entered'));
|
||||
require_once Config::get('prefix') . '/templates/show_search.inc.php';
|
||||
break;
|
||||
}
|
||||
case 'search':
|
||||
$browse = new Browse();
|
||||
require_once Config::get('prefix') . '/templates/show_search.inc.php';
|
||||
require_once Config::get('prefix') . '/templates/show_search_options.inc.php';
|
||||
$results = run_search($_REQUEST);
|
||||
$browse->set_type('song');
|
||||
$results = Search::run($_REQUEST);
|
||||
$browse->set_type($_REQUEST['type']);
|
||||
$browse->show_objects($results);
|
||||
$browse->store();
|
||||
break;
|
||||
|
@ -65,6 +53,10 @@ switch ($_REQUEST['action']) {
|
|||
$playlist = new Playlist($playlist_id);
|
||||
show_confirmation(_('Search Saved'),sprintf(_('Your Search has been saved as a track in %s'), $playlist->name),conf('web_path') . "/search.php");
|
||||
break;
|
||||
case 'save_as_smartplaylist':
|
||||
$playlist = new Search();
|
||||
$playlist->parse_rules(Search::clean_request($_REQUEST));
|
||||
$playlist->save();
|
||||
default:
|
||||
require_once Config::get('prefix') . '/templates/show_search.inc.php';
|
||||
break;
|
||||
|
|
|
@ -99,6 +99,12 @@ switch ($_REQUEST['action']) {
|
|||
$playlist->delete();
|
||||
$key = 'playlist_row_' . $playlist->id;
|
||||
break;
|
||||
case 'smartplaylist':
|
||||
$playlist = new Search('song', $_REQUEST['id']);
|
||||
if (!$playlist->has_access()) { exit; }
|
||||
$playlist->delete();
|
||||
$key = 'playlist_row_' . $playlist->id;
|
||||
break;
|
||||
case 'live_stream':
|
||||
if (!$GLOBALS['user']->has_access('75')) { exit; }
|
||||
$radio = new Radio($_REQUEST['id']);
|
||||
|
|
103
smartplaylist.php
Normal file
103
smartplaylist.php
Normal file
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
|
||||
/*
|
||||
|
||||
Copyright (c) Ampache.org
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; version 2
|
||||
of the License.
|
||||
|
||||
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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
|
||||
require_once 'lib/init.php';
|
||||
|
||||
// We special-case this so we can send a 302 if the delete succeeded
|
||||
if ($_REQUEST['action'] == 'delete_playlist') {
|
||||
// Check rights
|
||||
$playlist = new Search('song', $_REQUEST['playlist_id']);
|
||||
if ($playlist->has_access()) {
|
||||
$playlist->delete();
|
||||
// Go elsewhere
|
||||
header('Location: ' . Config::get('web_path') . '/browse.php?action=smartplaylist');
|
||||
}
|
||||
}
|
||||
|
||||
show_header();
|
||||
|
||||
/* Switch on the action passed in */
|
||||
switch ($_REQUEST['action']) {
|
||||
case 'create_playlist':
|
||||
/* Check rights */
|
||||
if (!Access::check('interface','25')) {
|
||||
access_denied();
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($_REQUEST as $key => $value) {
|
||||
$prefix = substr($key, 0, 4);
|
||||
$value = trim($value);
|
||||
|
||||
if ($prefix == 'rule' && strlen($value)) {
|
||||
$rules[$key] = Dba::escape($value);
|
||||
}
|
||||
}
|
||||
|
||||
switch($_REQUEST['operator']) {
|
||||
case 'or':
|
||||
$operator = 'OR';
|
||||
break;
|
||||
default:
|
||||
$operator = 'AND';
|
||||
break;
|
||||
} // end switch on operator
|
||||
|
||||
$playlist_name = scrub_in($_REQUEST['playlist_name']);
|
||||
|
||||
$playlist = new Search('song');
|
||||
$playlist->parse_rules($data);
|
||||
$playlist->logic_operator = $operator;
|
||||
$playlist->name = $playlist_name;
|
||||
$playlist->save();
|
||||
|
||||
break;
|
||||
case 'delete_playlist':
|
||||
// If we made it here, we didn't have sufficient rights.
|
||||
access_denied();
|
||||
break;
|
||||
case 'show_playlist':
|
||||
$playlist = new Search('song', $_REQUEST['playlist_id']);
|
||||
$playlist->format();
|
||||
require_once Config::get('prefix') . '/templates/show_smartplaylist.inc.php';
|
||||
break;
|
||||
case 'update_playlist':
|
||||
$playlist = new Search('song', $_REQUEST['playlist_id']);
|
||||
if ($playlist->has_access()) {
|
||||
$playlist->parse_rules(Search::clean_request($_REQUEST));
|
||||
$playlist->update();
|
||||
$playlist->format();
|
||||
}
|
||||
else {
|
||||
access_denied();
|
||||
break;
|
||||
}
|
||||
require_once Config::get('prefix') . '/templates/show_smartplaylist.inc.php';
|
||||
break;
|
||||
default:
|
||||
require_once Config::get('prefix') . '/templates/show_smartplaylist.inc.php';
|
||||
break;
|
||||
} // switch on the action
|
||||
|
||||
show_footer();
|
||||
?>
|
45
templates/show_edit_smartplaylist_row.inc.php
Normal file
45
templates/show_edit_smartplaylist_row.inc.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
|
||||
/*
|
||||
|
||||
Copyright (c) 2001 - 2007 Ampache.org
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License v2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
?>
|
||||
<td colspan="6">
|
||||
<form method="post" id="edit_playlist_<?php echo $playlist->id; ?>" action="javascript:void(0);">
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td>
|
||||
<input type="text" name="name" size="25" value="<?php echo scrub_out($playlist->name); ?>" />
|
||||
</td>
|
||||
<td>
|
||||
<?php $name = 'select_' . $playlist->type; ${$name} = ' selected="selected"'; ?>
|
||||
<select name="pl_type">
|
||||
<option value="public"<?php echo $select_public; ?>><?php echo _('Public'); ?></option>
|
||||
<option value="private"<?php echo $select_private; ?>><?php echo _('Private'); ?></option>
|
||||
</select>
|
||||
<td>
|
||||
<input type="hidden" name="id" value="<?php echo $playlist->id; ?>" />
|
||||
<input type="hidden" name="type" value="smartplaylist_row" />
|
||||
<?php echo Ajax::button('?action=edit_object&id=' . $playlist->id . '&type=smartplaylist_row','download',_('Save Changes'),'save_playlist_' . $playlist->id,'edit_playlist_' . $playlist->id); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</td>
|
||||
|
43
templates/show_edit_smartplaylist_title.inc.php
Normal file
43
templates/show_edit_smartplaylist_title.inc.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
|
||||
/*
|
||||
|
||||
Copyright (c) 2001 - 2007 Ampache.org
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License v2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
?>
|
||||
<form method="post" id="edit_playlist_<?php echo $playlist->id; ?>" action="javascript:void(0);">
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td>
|
||||
<input type="text" name="name" size="25" value="<?php echo scrub_out($playlist->name); ?>" />
|
||||
</td>
|
||||
<td>
|
||||
<?php $name = 'select_' . $playlist->type; ${$name} = ' selected="selected"'; ?>
|
||||
<select name="pl_type">
|
||||
<option value="public"<?php echo $select_public; ?>><?php echo _('Public'); ?></option>
|
||||
<option value="private"<?php echo $select_private; ?>><?php echo _('Private'); ?></option>
|
||||
</select>
|
||||
<td>
|
||||
<input type="hidden" name="id" value="<?php echo $playlist->id; ?>" />
|
||||
<input type="hidden" name="type" value="smartplaylist_title" />
|
||||
<?php echo Ajax::button('?action=edit_object&id=' . $playlist->id . '&type=smartplaylist_title','download',_('Save Changes'),'save_playlist_' . $playlist->id,'edit_playlist_' . $playlist->id); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
|
@ -33,80 +33,70 @@
|
|||
|
||||
?>
|
||||
<?php show_box_top(_('Play Random Selection')); ?>
|
||||
<form id="random" method="post" enctype="multipart/form-data" action="<?php echo Config::get('web_path'); ?>/random.php?action=get_advanced">
|
||||
<table class="table-data" cellspacing="0" cellpadding="3">
|
||||
<form id="random" method="post" enctype="multipart/form-data" action="<?php echo Config::get('web_path'); ?>/random.php?action=get_advanced&type=<?php echo $_REQUEST['type'] ? scrub_out($_REQUEST['type']) : 'song'; ?>">
|
||||
<table class="tabledata" cellpadding="3" cellspacing="0">
|
||||
<tr>
|
||||
<td><?php echo _('Item count'); ?></td>
|
||||
<td>
|
||||
<?php $name = 'random_' . scrub_in($_POST['random']); ${$name} = ' selected="selected"'; ?>
|
||||
<select name="random">
|
||||
<option value="1"<?php echo $random_1; ?>>1</option>
|
||||
<option value="5"<?php echo $random_5; ?>>5</option>
|
||||
<option value="10"<?php echo $random_10; ?>>10</option>
|
||||
<option value="20"<?php echo $random_20; ?>>20</option>
|
||||
<option value="30"<?php echo $random_30; ?>>30</option>
|
||||
<option value="50"<?php echo $random_50; ?>>50</option>
|
||||
<option value="100"<?php echo $random_100; ?>>100</option>
|
||||
<option value="500"<?php echo $random_500; ?>>500</option>
|
||||
<option value="1000"<?php echo $random_1000; ?>>1000</option>
|
||||
<option value="-1" ><?php echo _('All'); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
<td><?php if ($_REQUEST['type'] != 'song') { ?><a href="<?php echo Config::get('web_path'); ?>/random.php?action=advanced&type=song"><?php echo _('Songs'); ?></a><?php } else { echo _('Songs'); } ?></td>
|
||||
<td><?php if ($_REQUEST['type'] != 'album') { ?><a href="<?php echo Config::get('web_path'); ?>/random.php?action=advanced&type=album"><?php echo _('Albums'); ?></a><?php } else { echo _('Albums'); } ?></td>
|
||||
<td><?php if ($_REQUEST['type'] != 'artist') { ?><a href="<?php echo Config::get('web_path'); ?>/random.php?action=advanced&type=artist"><?php echo _('Artists'); ?></a><?php } else { echo _('Artists'); } ?></td>
|
||||
</tr>
|
||||
<tr><td> </td></tr>
|
||||
</table>
|
||||
<table class="tabledata" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td><?php echo _('Item count'); ?></td>
|
||||
<td>
|
||||
<?php $name = 'random_' . scrub_in($_POST['random']); ${$name} = ' selected="selected"'; ?>
|
||||
<select name="random">
|
||||
<option value="1"<?php echo $random_1; ?>>1</option>
|
||||
<option value="5"<?php echo $random_5; ?>>5</option>
|
||||
<option value="10"<?php echo $random_10; ?>>10</option>
|
||||
<option value="20"<?php echo $random_20; ?>>20</option>
|
||||
<option value="30"<?php echo $random_30; ?>>30</option>
|
||||
<option value="50"<?php echo $random_50; ?>>50</option>
|
||||
<option value="100"<?php echo $random_100; ?>>100</option>
|
||||
<option value="500"<?php echo $random_500; ?>>500</option>
|
||||
<option value="1000"<?php echo $random_1000; ?>>1000</option>
|
||||
<option value="-1" ><?php echo _('All'); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo _('Length'); ?></td>
|
||||
<td>
|
||||
<?php $name = 'length_' . intval($_POST['length']); ${$name} = ' selected="selected"'; ?>
|
||||
<select name="length">
|
||||
<option value="0"<?php echo $length_0; ?>><?php echo _('Unlimited'); ?></option>
|
||||
<option value="15"<?php echo $length_15; ?>><?php printf(ngettext('%d minute','%d minutes',15), "15"); ?></option>
|
||||
<option value="30"<?php echo $length_30; ?>><?php printf(ngettext('%d minute','%d minutes',30), "30"); ?></option>
|
||||
<option value="60"<?php echo $length_60; ?>><?php printf(ngettext('%d hour','%d hours',1), "1"); ?></option>
|
||||
<option value="120"<?php echo $length_120; ?>><?php printf(ngettext('%d hour','%d hours',2), "2"); ?></option>
|
||||
<option value="240"<?php echo $length_240; ?>><?php printf(ngettext('%d hour','%d hours',4), "4"); ?></option>
|
||||
<option value="480"<?php echo $length_480; ?>><?php printf(ngettext('%d hour','%d hours',8), "8"); ?></option>
|
||||
<option value="960"<?php echo $length_960; ?>><?php printf(ngettext('%d hour','%d hours',16), "16"); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
<td><?php echo _('Length'); ?></td>
|
||||
<td>
|
||||
<?php $name = 'length_' . intval($_POST['length']); ${$name} = ' selected="selected"'; ?>
|
||||
<select name="length">
|
||||
<option value="0"<?php echo $length_0; ?>><?php echo _('Unlimited'); ?></option>
|
||||
<option value="15"<?php echo $length_15; ?>><?php printf(ngettext('%d minute','%d minutes',15), "15"); ?></option>
|
||||
<option value="30"<?php echo $length_30; ?>><?php printf(ngettext('%d minute','%d minutes',30), "30"); ?></option>
|
||||
<option value="60"<?php echo $length_60; ?>><?php printf(ngettext('%d hour','%d hours',1), "1"); ?></option>
|
||||
<option value="120"<?php echo $length_120; ?>><?php printf(ngettext('%d hour','%d hours',2), "2"); ?></option>
|
||||
<option value="240"<?php echo $length_240; ?>><?php printf(ngettext('%d hour','%d hours',4), "4"); ?></option>
|
||||
<option value="480"<?php echo $length_480; ?>><?php printf(ngettext('%d hour','%d hours',8), "8"); ?></option>
|
||||
<option value="960"<?php echo $length_960; ?>><?php printf(ngettext('%d hour','%d hours',16), "16"); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo _('Type'); ?></td>
|
||||
<td>
|
||||
<?php $name = 'type_' . scrub_in($_POST['random_type']); ${$name} = ' selected="selected"'; ?>
|
||||
<select name="random_type">
|
||||
<option value="normal"<?php echo $type_normal; ?>><?php echo _('Standard'); ?></option>
|
||||
<option value="unplayed"<?php echo $type_unplayed; ?>><?php echo _('Less Played'); ?></option>
|
||||
<option value="full_album"<?php echo $type_full_album; ?>><?php echo _('Full Albums'); ?></option>
|
||||
<option value="full_artist"<?php echo $type_full_artist; ?>><?php echo _('Full Artist'); ?></option>
|
||||
<?php if (Config::get('ratings')) { ?>
|
||||
<option value="high_rating"<?php echo $type_high_rating; ?>><?php echo _('Highest Rated'); ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap="nowrap"><?php echo _('From catalog'); ?></td>
|
||||
<td>
|
||||
<?php show_catalog_select('catalog','',$_POST['catalog']); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo _('Size Limit'); ?></td>
|
||||
<td>
|
||||
<?php $name = 'size_' . intval($_POST['size_limit']); ${$name} = ' selected="selected"'; ?>
|
||||
<select name="size_limit">
|
||||
<option value="0"<?php echo $size_0; ?>><?php echo _('Unlimited'); ?></option>
|
||||
<option value="64"<?php echo $size_64; ?>>64MB</option>
|
||||
<option value="128"<?php echo $size_128; ?>>128MB</option>
|
||||
<option value="256"<?php echo $size_256; ?>>256MB</option>
|
||||
<option value="512"<?php echo $size_512; ?>>512MB</option>
|
||||
<option value="1024"<?php echo $size_1024; ?>>1024MB</option>
|
||||
</select>
|
||||
</td>
|
||||
<td><?php echo _('Size Limit'); ?></td>
|
||||
<td>
|
||||
<?php $name = 'size_' . intval($_POST['size_limit']); ${$name} = ' selected="selected"'; ?>
|
||||
<select name="size_limit">
|
||||
<option value="0"<?php echo $size_0; ?>><?php echo _('Unlimited'); ?></option>
|
||||
<option value="64"<?php echo $size_64; ?>>64MB</option>
|
||||
<option value="128"<?php echo $size_128; ?>>128MB</option>
|
||||
<option value="256"<?php echo $size_256; ?>>256MB</option>
|
||||
<option value="512"<?php echo $size_512; ?>>512MB</option>
|
||||
<option value="1024"<?php echo $size_1024; ?>>1024MB</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php require Config::get('prefix') . '/templates/show_rules.inc.php'; ?>
|
||||
|
||||
<div class="formValidation">
|
||||
<input type="submit" value="<?php echo _('Enqueue'); ?>" />
|
||||
<input type="submit" value="<?php echo _('Enqueue'); ?>" />
|
||||
</div>
|
||||
</form>
|
||||
<?php show_box_bottom(); ?>
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
<?php
|
||||
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
|
||||
/**
|
||||
* Show Random Rules
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* LICENSE: GNU General Public License, version 2 (GPLv2)
|
||||
* Copyright (c) 2001 - 2011 Ampache.org All Rights Reserved
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License v2
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @category Template
|
||||
* @package Template
|
||||
* @author Karl Vollmer <vollmer@ampache.org>
|
||||
* @copyright 2001 - 2011 Ampache.org
|
||||
* @license http://opensource.org/licenses/gpl-2.0 GPLv2
|
||||
* @version PHP 5.2
|
||||
* @link http://www.ampache.org/
|
||||
* @since File available since Release 1.0
|
||||
*/
|
||||
|
||||
?>
|
||||
<?php show_box_top(_('Rules')); ?>
|
||||
<table class="tabledata" cellpadding="0" cellspacing="0">
|
||||
<colgroup>
|
||||
<col id="col_field" />
|
||||
<col id="col_operator" />
|
||||
<col id="col_value" />
|
||||
<col id="col_method" />
|
||||
<col id="col_action" />
|
||||
</colgroup>
|
||||
<tr class="th-top">
|
||||
<th class="col_field"><?php echo _('Field'); ?></th>
|
||||
<th class="col_operator"><?php echo _('Operator'); ?></th>
|
||||
<th class="col_value"><?php echo _('Value'); ?></th>
|
||||
<th class="col_method"><?php echo _('Method'); ?></th>
|
||||
<th class="col_action"><?php echo _('Action'); ?></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php show_box_bottom(); ?>
|
67
templates/show_rules.inc.php
Normal file
67
templates/show_rules.inc.php
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
|
||||
/*
|
||||
|
||||
Copyright (c) Ampache.org
|
||||
All Rights Reserved
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License v2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
?>
|
||||
|
||||
<script type="text/javascript" src="<?php echo Config::get('web_path'); ?>/lib/javascript/search.js"></script>
|
||||
<script type="text/javascript" src="<?php echo Config::get('web_path'); ?>/lib/javascript/search-data.php?type=<?php echo $_REQUEST['type'] ? scrub_out($_REQUEST['type']) : 'song'; ?>"></script>
|
||||
|
||||
<?php show_box_top(_('Rules') . "..."); ?>
|
||||
<table class="tabledata" cellpadding="3" cellspacing="0">
|
||||
<tbody id="searchtable">
|
||||
<tr>
|
||||
<td><?php echo _('Match'); ?></td>
|
||||
<td>
|
||||
<select name="operator">
|
||||
<option value="and" <?php if($_REQUEST['operator']=="and") echo "selected=\"selected\""?>><?php echo _('all rules'); ?></option>
|
||||
<option value="or" <?php if($_REQUEST['operator']=="or") echo "selected=\"selected\""?>><?php echo _('any rule'); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a id="addrowbutton" href="javascript:void(0)">
|
||||
<?php echo get_user_icon('add'); ?>
|
||||
<?php echo _('Add Another Rule'); ?>
|
||||
</a>
|
||||
<script type="text/javascript">Event.observe('addrowbutton', 'click', SearchRow.add);</script>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php show_box_bottom(); ?>
|
||||
|
||||
<?php
|
||||
if ($playlist) {
|
||||
$out = $playlist->to_js();
|
||||
}
|
||||
else {
|
||||
$mysearch = new Search($_REQUEST['type']);
|
||||
$mysearch->parse_rules(Search::clean_request($_REQUEST));
|
||||
$out = $mysearch->to_js();
|
||||
}
|
||||
if ($out) {
|
||||
echo $out;
|
||||
}
|
||||
else {
|
||||
echo '<script type="text/javascript">SearchRow.add();</script>';
|
||||
}
|
||||
?>
|
|
@ -37,130 +37,39 @@
|
|||
*/
|
||||
?>
|
||||
<?php show_box_top(_('Search Ampache') . "..."); ?>
|
||||
<form name="search" method="post" action="<?php echo Config::get('web_path'); ?>/search.php" enctype="multipart/form-data" style="Display:inline">
|
||||
<form id="search" name="search" method="post" action="<?php echo Config::get('web_path'); ?>/search.php?type=<?php echo $_REQUEST['type'] ? scrub_out($_REQUEST['type']) : 'song'; ?>" enctype="multipart/form-data" style="Display:inline">
|
||||
<table class="tabledata" cellpadding="3" cellspacing="0">
|
||||
<tr class="<?php echo flip_class(); ?>">
|
||||
<td><?php echo _('Keywords') ?></td>
|
||||
<td>
|
||||
<input type="text" id="s_all" name="s_all" value="<?php echo scrub_out($_REQUEST['s_all']); ?>"/>
|
||||
</td>
|
||||
<td><?php echo _('Comment'); ?></td>
|
||||
<td>
|
||||
<input type="text" id="s_comment" name="s_comment" value="<?php echo scrub_out($_REQUEST['s_comment']); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="<?php echo flip_class(); ?>">
|
||||
<td><?php echo _('Title'); ?></td>
|
||||
<td>
|
||||
<input type="text" id="s_title" name="s_title" value="<?php echo scrub_out($_REQUEST['s_title']); ?>" />
|
||||
</td>
|
||||
<td><?php echo _('Artist'); ?></td>
|
||||
<td>
|
||||
<input type="text" id="s_artist" name="s_artist" value="<?php echo scrub_out($_REQUEST['s_artist']); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="<?php echo flip_class(); ?>">
|
||||
<td><?php echo _('Album'); ?></td>
|
||||
<td>
|
||||
<input type="text" id="s_album" name="s_album" value="<?php echo scrub_out($_REQUEST['s_album']); ?>" />
|
||||
</td>
|
||||
<td><?php echo _('Tag'); ?></td>
|
||||
<td>
|
||||
<input type="text" id="s_tag" name="s_tag" value="<?php echo scrub_out($_REQUEST['s_tag']); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="<?php echo flip_class(); ?>">
|
||||
<td><?php echo _('Year'); ?></td>
|
||||
<td>
|
||||
<input type="text" id="s_year" name="s_year" size="5" value="<?php echo scrub_out($_REQUEST['s_year']); ?>" />
|
||||
-
|
||||
<input type="text" id="s_year2" name="s_year2" size="5" value="<?php echo scrub_out($_REQUEST['s_year2']); ?>" />
|
||||
</td>
|
||||
<td><?php echo _('Filename'); ?></td>
|
||||
<td>
|
||||
<input type="text" id="s_filename" name="s_filename" value="<?php echo scrub_out($_REQUEST['s_filename']); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="<?php echo flip_class(); ?>">
|
||||
<td><?php echo _('Time'); ?></td>
|
||||
<td>
|
||||
<input type="text" id="s_time" name="s_time" size="3" value="<?php echo scrub_out($_REQUEST['s_time']); ?>" />
|
||||
-
|
||||
<input type="text" id="s_time2" name="s_time2" size="3" value="<?php echo scrub_out($_REQUEST['s_time2']); ?>" />
|
||||
<?php echo _('minutes'); ?>
|
||||
</td>
|
||||
<td><?php echo _('Codec'); ?></td>
|
||||
<td>
|
||||
<input type="text" id="s_codec" name="s_codec" size="5" value="<?php echo scrub_out($_REQUEST['s_codec']); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="<?php echo flip_class(); ?>">
|
||||
<td><?php echo _('Played'); ?></td>
|
||||
<td>
|
||||
<select id="s_played" name="s_played" >
|
||||
<option value=""> </option>
|
||||
<option value="1" <?php if($_REQUEST['s_played']=="1") echo "selected=\"selected\""?>><?php echo _('Yes'); ?></option>
|
||||
<option value="0" <?php if($_REQUEST['s_played']=="0") echo "selected=\"selected\""?>><?php echo _('No'); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
<td><?php echo _('Min Bitrate'); ?></td>
|
||||
<td>
|
||||
<select id="s_minbitrate" name="s_minbitrate" >
|
||||
<option value=""> </option>
|
||||
<?php foreach(array(32,40,48,56,64,80,96,112,128,160,192,224,256,320) as $val) { ?>
|
||||
<option value="<?php echo $val?>" <?php if($_REQUEST['s_minbitrate']==$val) echo "selected=\"selected\""?>><?php echo $val?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="<?php echo flip_class(); ?>">
|
||||
<td><?php echo _('Rating'); ?></td>
|
||||
<td>
|
||||
<select id="s_rating_operator" name="s_rating_operator">
|
||||
<option value="0" <?php if($_REQUEST['s_rating_operator']=="0") echo "selected=\"selected\""?>><?php echo _('>='); ?></option>
|
||||
<option value="1" <?php if($_REQUEST['s_rating_operator']=="1") echo "selected=\"selected\""?>><?php echo _('<='); ?></option>
|
||||
<option value="2" <?php if($_REQUEST['s_rating_operator']=="2") echo "selected=\"selected\""?>><?php echo _('='); ?></option>
|
||||
</select>
|
||||
<select id="s_rating" name="s_rating">
|
||||
<option value=""> </option>
|
||||
<option value="1" <?php if($_REQUEST['s_rating']=="1") echo "selected=\"selected\""?>><?php echo _('One Star'); ?></option>
|
||||
<option value="2" <?php if($_REQUEST['s_rating']=="2") echo "selected=\"selected\""?>><?php echo _('Two Stars'); ?></option>
|
||||
<option value="3" <?php if($_REQUEST['s_rating']=="3") echo "selected=\"selected\""?>><?php echo _('Three Stars'); ?></option>
|
||||
<option value="4" <?php if($_REQUEST['s_rating']=="4") echo "selected=\"selected\""?>><?php echo _('Four Stars'); ?></option>
|
||||
<option value="5" <?php if($_REQUEST['s_rating']=="5") echo "selected=\"selected\""?>><?php echo _('Five Stars'); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
<td><?php echo _('Operator'); ?></td>
|
||||
<td>
|
||||
<select name="operator">
|
||||
<option value="and" <?php if($_REQUEST['operator']=="and") echo "selected=\"selected\""?>><?php echo _('AND'); ?></option>
|
||||
<option value="or" <?php if($_REQUEST['operator']=="or") echo "selected=\"selected\""?>><?php echo _('OR'); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="<?php echo flip_class(); ?>">
|
||||
<td><?php echo _('Method'); ?></td>
|
||||
<td>
|
||||
<select name="method">
|
||||
<option value="fuzzy" <?php if($_REQUEST['method']=="fuzzy") echo "selected=\"selected\""?>><?php echo _('Fuzzy'); ?></option>
|
||||
<option value="exact" <?php if($_REQUEST['method']=="exact") echo "selected=\"selected\""?>><?php echo _('Exact'); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
<td><?php echo _('Maximum Results'); ?></td>
|
||||
<td>
|
||||
<select name="limit">
|
||||
<option value="0"><?php echo _('Unlimited'); ?></option>
|
||||
<option value="25" <?php if($_REQUEST['limit']=="25") echo "selected=\"selected\""?>>25</option>
|
||||
<option value="50" <?php if($_REQUEST['limit']=="50") echo "selected=\"selected\""?>>50</option>
|
||||
<option value="100" <?php if($_REQUEST['limit']=="100") echo "selected=\"selected\""?>>100</option>
|
||||
<option value="500" <?php if($_REQUEST['limit']=="500") echo "selected=\"selected\""?>>500</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php if ($_REQUEST['type'] != 'song') { ?><a href="<?php echo Config::get('web_path'); ?>/search.php?type=song"><?php echo _('Songs'); ?></a><?php } else { echo _('Songs'); } ?></td>
|
||||
<td><?php if ($_REQUEST['type'] != 'album') { ?><a href="<?php echo Config::get('web_path'); ?>/search.php?type=album"><?php echo _('Albums'); ?></a><?php } else { echo _('Albums'); } ?></td>
|
||||
<td><?php if ($_REQUEST['type'] != 'artist') { ?><a href="<?php echo Config::get('web_path'); ?>/search.php?type=artist"><?php echo _('Artists'); ?></a><?php } else { echo _('Artists'); } ?></td>
|
||||
<td><?php if ($_REQUEST['type'] != 'video') { ?><a href="<?php echo Config::get('web_path'); ?>/search.php?type=video"><?php echo _('Videos'); ?></a><?php } else { echo _('Videos'); } ?></td>
|
||||
</tr>
|
||||
<tr><td> </td></tr>
|
||||
</table>
|
||||
<table class="tabledata" cellpadding="3" cellspacing="0">
|
||||
<tr>
|
||||
<td><?php echo _('Maximum Results'); ?></td>
|
||||
<td>
|
||||
<select name="limit">
|
||||
<option value="0"><?php echo _('Unlimited'); ?></option>
|
||||
<option value="25" <?php if($_REQUEST['limit']=="25") echo "selected=\"selected\""?>>25</option>
|
||||
<option value="50" <?php if($_REQUEST['limit']=="50") echo "selected=\"selected\""?>>50</option>
|
||||
<option value="100" <?php if($_REQUEST['limit']=="100") echo "selected=\"selected\""?>>100</option>
|
||||
<option value="500" <?php if($_REQUEST['limit']=="500") echo "selected=\"selected\""?>>500</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php require Config::get('prefix') . '/templates/show_rules.inc.php'; ?>
|
||||
|
||||
<div class="formValidation">
|
||||
<input class="button" type="submit" value="<?php echo _('Search'); ?>" />
|
||||
<input type="hidden" name="action" value="search" />
|
||||
<?php if ($_REQUEST['type'] == 'song' || ! $_REQUEST['type']) { ?>
|
||||
<input id="savesearchbutton" class="button" type="submit" value="<?php echo _('Save as Smart Playlist'); ?>" onClick="$('hiddenaction').setValue('save_as_smartplaylist');" />
|
||||
<?php } ?>
|
||||
<input type="hidden" id="hiddenaction" name="action" value="search" />
|
||||
</div>
|
||||
</form>
|
||||
<?php show_box_bottom(); ?>
|
||||
|
|
|
@ -33,13 +33,20 @@
|
|||
|
||||
?>
|
||||
<div id="sb_Subsearch">
|
||||
<form name="search" method="post" action="<?php echo $web_path; ?>/search.php" enctype="multipart/form-data" style="Display:inline">
|
||||
<input type="text" name="search_string" id="searchString"/>
|
||||
<input type="hidden" name="action" value="quick_search" />
|
||||
<input type="hidden" name="method" value="fuzzy" />
|
||||
<form name="search" method="post" action="<?php echo $web_path; ?>/search.php?type=song" enctype="multipart/form-data" style="Display:inline">
|
||||
<input type="text" name="rule_1_input" id="searchString"/>
|
||||
<input type="hidden" name="action" value="search" />
|
||||
<input type="hidden" name="rule_1_operator" value="0" />
|
||||
<input type="hidden" name="object_type" value="song" />
|
||||
<select name="rule_1">
|
||||
<option value="anywhere"><?php echo _('Anywhere')?></option>
|
||||
<option value="title"><?php echo _('Title')?></option>
|
||||
<option value="album"><?php echo _('Album')?></option>
|
||||
<option value="artist"><?php echo _('Artist')?></option>
|
||||
<option value="tag"><?php echo _('Tag')?></option>
|
||||
</select>
|
||||
<input class="button" type="submit" value="<?php echo _('Search'); ?>" id="searchBtn" />
|
||||
<a href="<?php echo $web_path; ?>/search.php" class="button" id="advSearchBtn"><?php echo _('Advanced Search'); ?></a>
|
||||
<a href="<?php echo $web_path; ?>/search.php?type=song" class="button" id="advSearchBtn"><?php echo _('Advanced Search'); ?></a>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
</li>
|
||||
<?php if (Access::check_function('batch_download')) { ?>
|
||||
<li>
|
||||
<a href="<?php echo Config::get('web_path'); ?>/batch.php?action=browse&browse_id=<?php echo $browse->id; ?>"><?php echo get_user_icon('batch_download', _('Batch Download')); ?></a>
|
||||
<a href="<?php echo Config::get('web_path'); ?>/batch.php?action=browse&type=<?php echo scrub_out($_REQUEST['type']); ?>&browse_id=<?php echo $browse->id; ?>"><?php echo get_user_icon('batch_download', _('Batch Download')); ?></a>
|
||||
<?php echo _('Batch Download'); ?>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
|
67
templates/show_smartplaylist.inc.php
Normal file
67
templates/show_smartplaylist.inc.php
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
|
||||
/*
|
||||
Copyright (c) Ampache.org
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License v2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
ob_start();
|
||||
require Config::get('prefix') . '/templates/show_smartplaylist_title.inc.php';
|
||||
$title = ob_get_contents();
|
||||
ob_end_clean();
|
||||
show_box_top('<div id="playlist_row_' . $playlist->id . '">' . $title .
|
||||
'</div>');
|
||||
?>
|
||||
<div id="information_actions">
|
||||
<ul>
|
||||
<?php if (Access::check_function('batch_download')) { ?>
|
||||
<li>
|
||||
<a href="<?php echo Config::get('web_path'); ?>/batch.php?action=search&id=<?php echo $playlist->id; ?>"><?php echo get_user_icon('batch_download', _('Batch Download')); ?></a>
|
||||
<?php echo _('Batch Download'); ?>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<li>
|
||||
<?php echo Ajax::button('?action=basket&type=smartplaylist&id=' . $playlist->id,'add',_('Add All'),'play_playlist'); ?>
|
||||
<?php echo _('Add All'); ?>
|
||||
</li>
|
||||
<?php if ($playlist->has_access()) { ?>
|
||||
<li>
|
||||
<?php echo Ajax::button('?action=show_edit_object&type=smartplaylist_title&id=' . $playlist->id,'edit',_('Edit'),'edit_playlist_' . $playlist->id); ?>
|
||||
<?php echo _('Edit'); ?>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?php echo Config::get('web_path'); ?>/smartplaylist.php?action=delete_playlist&playlist_id=<?php echo $playlist->id; ?>">
|
||||
<?php echo get_user_icon('delete'); ?>
|
||||
</a>
|
||||
<?php echo _('Delete'); ?>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<form id="editplaylist" name="editplaylist" method="post" action="<?php echo Config::get('web_path'); ?>/smartplaylist.php?action=update_playlist&playlist_id=<?php echo $playlist->id; ?>" enctype="multipart/form-data" style="Display:inline">
|
||||
|
||||
<?php require Config::get('prefix') . '/templates/show_rules.inc.php'; ?>
|
||||
|
||||
<div class="formValidation">
|
||||
<input class="button" type="submit" value="<?php echo _('Save Changes'); ?>" />
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<?php show_box_bottom(); ?>
|
39
templates/show_smartplaylist_row.inc.php
Normal file
39
templates/show_smartplaylist_row.inc.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
|
||||
/*
|
||||
|
||||
Copyright (c) 2001 - 2007 Ampache.org
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License v2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
?>
|
||||
<td class="cel_add">
|
||||
<?php echo Ajax::button('?action=basket&type=smartplaylist&id=' . $playlist->id,'add',_('Add'),'add_playlist_' . $playlist->id); ?>
|
||||
</td>
|
||||
<td class="cel_playlist"><?php echo $playlist->f_link; ?></td>
|
||||
<td class="cel_type"><?php echo $playlist->f_type; ?></td>
|
||||
<td class="cel_owner"><?php echo scrub_out($playlist->f_user); ?></td>
|
||||
<td class="cel_action">
|
||||
<?php if (Access::check_function('batch_download')) { ?>
|
||||
<a href="<?php echo Config::get('web_path'); ?>/batch.php?action=smartplaylist&id=<?php echo $playlist->id; ?>">
|
||||
<?php echo get_user_icon('batch_download',_('Batch Download')); ?>
|
||||
</a>
|
||||
<?php } ?>
|
||||
<?php if ($playlist->has_access()) { ?>
|
||||
<?php echo Ajax::button('?action=show_edit_object&type=smartplaylist_row&id=' . $playlist->id,'edit',_('Edit'),'edit_playlist_' . $playlist->id); ?>
|
||||
<?php echo Ajax::button('?page=browse&action=delete_object&type=smartplaylist&id=' . $playlist->id,'delete',_('Delete'),'delete_playlist_' . $playlist->id); ?>
|
||||
<?php } ?>
|
||||
</td>
|
24
templates/show_smartplaylist_title.inc.php
Normal file
24
templates/show_smartplaylist_title.inc.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
|
||||
/*
|
||||
|
||||
Copyright (c) 2001 - 2007 Ampache.org
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License v2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
?>
|
||||
|
||||
<?php echo sprintf(_('%s %s (Smart Playlist)'), $playlist->f_type, $playlist->name); ?>
|
63
templates/show_smartplaylists.inc.php
Normal file
63
templates/show_smartplaylists.inc.php
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
|
||||
/*
|
||||
|
||||
Copyright (c) Ampache.org
|
||||
All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
?>
|
||||
<?php require Config::get('prefix') . '/templates/list_header.inc.php' ?>
|
||||
<table class="tabledata" cellpadding="0" cellspacing="0">
|
||||
<colgroup>
|
||||
<col id="col_add" />
|
||||
<col id="col_playlist" />
|
||||
<col id="col_type" />
|
||||
<col id="col_songs" />
|
||||
<col id="col_owner" />
|
||||
<col id="col_action" />
|
||||
</colgroup>
|
||||
<tr class="th-top">
|
||||
<th class="cel_add"><?php echo _('Add'); ?></th>
|
||||
<th class="cel_playlist"><?php echo Ajax::text('?page=browse&action=set_sort&type=smartplaylist&sort=name',_('Playlist Name'),'playlist_sort_name'); ?></th>
|
||||
<th class="cel_type"> </th>
|
||||
<th class="cel_owner"><?php echo Ajax::text('?page=browse&action=set_sort&type=smartplaylist&sort=user',_('Owner'),'playlist_sort_owner'); ?></th>
|
||||
<th class="cel_action"><?php echo _('Actions'); ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ($object_ids as $playlist_id) {
|
||||
$playlist = new Search('song', $playlist_id);
|
||||
$playlist->format();
|
||||
?>
|
||||
<tr class="<?php echo flip_class(); ?>" id="playlist_row_<?php echo $playlist->id; ?>">
|
||||
<?php require Config::get('prefix') . '/templates/show_smartplaylist_row.inc.php'; ?>
|
||||
</tr>
|
||||
<?php } // end foreach ($playlists as $playlist) ?>
|
||||
<?php if (!count($object_ids)) { ?>
|
||||
<tr class="<?php echo flip_class(); ?>">
|
||||
<td colspan="6"><span class="fatalerror"><?php echo _('Not Enough Data'); ?></span></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<tr class="th-bottom">
|
||||
<th class="cel_add"><?php echo _('Add'); ?></th>
|
||||
<th class="cel_playlist"><?php echo Ajax::text('?page=browse&action=set_sort&type=playlist&sort=name',_('Playlist Name'),'playlist_sort_name_bottom'); ?></th>
|
||||
<th class="cel_type"> </th>
|
||||
<th class="cel_owner"><?php echo Ajax::text('?page=browse&action=set_sort&type=playlist&sort=user',_('Owner'),'playlist_sort_owner_bottom'); ?></th>
|
||||
<th class="cel_action"><?php echo _('Actions'); ?></th>
|
||||
</tr>
|
||||
</table>
|
||||
<?php require Config::get('prefix') . '/templates/list_header.inc.php' ?>
|
|
@ -48,6 +48,7 @@ $ajax_info = Config::get('ajax_url'); $web_path = Config::get('web_path');
|
|||
<li id="sb_browse_bb_Artist"><a href="<?php echo $web_path; ?>/browse.php?action=artist"><?php echo _('Artists'); ?></a></li>
|
||||
<li id="sb_browse_bb_Tags"><a href="<?php echo $web_path; ?>/browse.php?action=tag"><?php echo _('Tag Cloud'); ?></a></li>
|
||||
<li id="sb_browse_bb_Playlist"><a href="<?php echo $web_path; ?>/browse.php?action=playlist"><?php echo _('Playlists'); ?></a></li>
|
||||
<li id="sb_browse_bb_SmartPlaylist"><a href="<?php echo $web_path; ?>/browse.php?action=smartplaylist"><?php echo _('Smart Playlists'); ?></a></li>
|
||||
<li id="sb_browse_bb_RadioStation"><a href="<?php echo $web_path; ?>/browse.php?action=live_stream"><?php echo _('Radio Stations'); ?></a></li>
|
||||
<li id="sb_browse_bb_Video"><a href="<?php echo $web_path; ?>/browse.php?action=video"><?php echo _('Videos'); ?></a></li>
|
||||
</ul>
|
||||
|
@ -77,7 +78,7 @@ $ajax_info = Config::get('ajax_url'); $web_path = Config::get('web_path');
|
|||
<li id="sb_home_random_album"><?php echo Ajax::text('?page=random&action=album',_('Album'),'home_random_album'); ?></li>
|
||||
<li id="sb_home_random_artist"><?php echo Ajax::text('?page=random&action=artist',_('Artist'),'home_random_artist'); ?></li>
|
||||
<li id="sb_home_random_playlist"><?php echo Ajax::text('?page=random&action=playlist',_('Playlist'),'home_random_playlist'); ?></li>
|
||||
<li id="sb_home_random_advanced"><a href="<?php echo $web_path; ?>/random.php?action=advanced"><?php echo _('Advanced'); ?></a></li>
|
||||
<li id="sb_home_random_advanced"><a href="<?php echo $web_path; ?>/random.php?action=advanced&type=song"><?php echo _('Advanced'); ?></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><h4><?php echo _('Information'); ?></h4>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue