1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-04 18:29:40 +02:00

Tags requests improved. Ability to edit/delete tags depending on user rights. (Fix #135) (Fix #127)

This commit is contained in:
SUTJael 2014-02-18 19:32:16 +01:00
parent e2b3b1ed51
commit 5f5460708a
31 changed files with 226 additions and 238 deletions

View file

@ -70,7 +70,7 @@ switch ($_REQUEST['action']) {
$browse->set_sort('count','ASC');
// This one's a doozy
$browse->set_simple_browse(false);
$browse->save_objects(Tag::get_tags(AmpConfig::get('offset_limit')));
$browse->save_objects(Tag::get_tags(/*AmpConfig::get('offset_limit')*/)); // Should add a pager?
$object_ids = $browse->get_saved();
$keys = array_keys($object_ids);
Tag::build_cache($keys);

View file

@ -367,10 +367,8 @@ class Album extends database_object
$this->year = "N/A";
}
$tags = Tag::get_top_tags('album',$this->id);
$this->tags = $tags;
$this->f_tags = Tag::get_display($tags, $this->id, 'album');
$this->tags = Tag::get_top_tags('album', $this->id);
$this->f_tags = Tag::get_display($this->tags, $this->id, 'album');
} // format

View file

@ -288,9 +288,9 @@ class Artist extends database_object
$this->f_time = ltrim($hours . ':' . $min . ':' . $sec,'0:');
$this->tags = Tag::get_top_tags('artist',$this->id);
$this->tags = Tag::get_top_tags('artist', $this->id);
$this->f_tags = Tag::get_display($this->tags, $this->id, 'artist');
$this->f_tags = Tag::get_display($this->tags,$this->id,'artist');
$this->object_cnt = $extra_info['object_cnt'];
return true;

View file

@ -141,11 +141,11 @@ class Broadcast extends database_object
return null;
}
public function show_action_buttons($tags_list = "")
public function show_action_buttons()
{
if ($this->id) {
if ($GLOBALS['user']->has_access('75')) {
echo "<a id=\"edit_broadcast_ " . $this->id . "\" onclick=\"showEditDialog('broadcast_row', '" . $this->id . "', 'edit_broadcast_" . $this->id . "', '" . T_('Broadcast edit') . "', '" . $tags_list . "', 'broadcast_row_', 'refresh_broadcast')\">" . UI::get_icon('edit', T_('Edit')) . "</a>";
echo "<a id=\"edit_broadcast_ " . $this->id . "\" onclick=\"showEditDialog('broadcast_row', '" . $this->id . "', 'edit_broadcast_" . $this->id . "', '" . T_('Broadcast edit') . "', 'broadcast_row_', 'refresh_broadcast')\">" . UI::get_icon('edit', T_('Edit')) . "</a>";
echo " <a href=\"" . AmpConfig::get('web_path') . "/broadcast.php?action=show_delete&id=" . $this->id ."\">" . UI::get_icon('delete', T_('Delete')) . "</a>";
}
}

View file

@ -147,13 +147,13 @@ class Channel extends database_object
return $ftype;
}
public function show_action_buttons($tags_list = "")
public function show_action_buttons()
{
if ($this->id) {
if ($GLOBALS['user']->has_access('75')) {
echo Ajax::button('?page=index&action=start_channel&id=' . $this->id,'run', T_('Start Channel'),'channel_start_' . $this->id);
echo " " . Ajax::button('?page=index&action=stop_channel&id=' . $this->id,'stop', T_('Stop Channel'),'channel_stop_' . $this->id);
echo " <a id=\"edit_channel_ " . $this->id . "\" onclick=\"showEditDialog('channel_row', '" . $this->id . "', 'edit_channel_" . $this->id . "', '" . T_('Channel edit') . "', '" . $tags_list . "', 'channel_row_', 'refresh_channel')\">" . UI::get_icon('edit', T_('Edit')) . "</a>";
echo " <a id=\"edit_channel_ " . $this->id . "\" onclick=\"showEditDialog('channel_row', '" . $this->id . "', 'edit_channel_" . $this->id . "', '" . T_('Channel edit') . "', 'channel_row_', 'refresh_channel')\">" . UI::get_icon('edit', T_('Edit')) . "</a>";
echo " <a href=\"" . AmpConfig::get('web_path') . "/channel.php?action=show_delete&id=" . $this->id ."\">" . UI::get_icon('delete', T_('Delete')) . "</a>";
}
}
@ -161,7 +161,7 @@ class Channel extends database_object
public function format()
{
$this->tags = Tag::get_top_tags('channel',$this->id);
$this->tags = Tag::get_top_tags('channel', $this->id);
$this->f_tags = Tag::get_display($this->tags, $this->id, 'channel');
}

View file

@ -92,10 +92,7 @@ abstract class database_object
public static function get_from_cache($index,$id)
{
// Check if the object is set
if (isset(self::$object_cache[$index])
&& isset(self::$object_cache[$index][$id])
) {
if (isset(self::$object_cache[$index]) && isset(self::$object_cache[$index][$id])) {
self::$cache_hit++;
return self::$object_cache[$index][$id];
}
@ -108,7 +105,7 @@ abstract class database_object
* add_to_cache
* This adds the specified object to the specified index in the cache
*/
public static function add_to_cache($index,$id,$data)
public static function add_to_cache($index, $id, $data)
{
if (!self::$_enabled) { return false; }

View file

@ -853,10 +853,8 @@ class Song extends database_object implements media
$this->f_track = $this->track;
// Get the top tags
$tags = Tag::get_top_tags('song',$this->id);
$this->tags = $tags;
$this->f_tags = Tag::get_display($tags,$this->id,'song');
$this->tags = Tag::get_top_tags('song', $this->id);
$this->f_tags = Tag::get_display($this->tags, $this->id, 'song');
// Format the size
$this->f_size = UI::format_bytes($this->size);

View file

@ -247,7 +247,7 @@ class Stream
$personal_info_id = Preference::id_from_name('allow_personal_info_now');
if ($personal_info_id) {
$current_user = $GLOBALS['user']->id;
$sql .= "WHERE (`now_playing`.`user` IN (SELECT `user` FROM `user_preference` WHERE ((`preference`='$personal_info_id' AND `value`='1') OR `user`='$current_user'))) ";
$sql .= "WHERE (`np`.`user` IN (SELECT `user` FROM `user_preference` WHERE ((`preference`='$personal_info_id' AND `value`='1') OR `user`='$current_user'))) ";
}
}

View file

@ -31,11 +31,6 @@ class Tag extends database_object
public $id;
public $name;
// constructed
public $weight=0;
public $count=0;
public $owner=0;
/**
* constructor
* This takes a tag id and returns all of the relevent information
@ -66,65 +61,6 @@ class Tag extends database_object
} // construct_from_name
/**
* format
* This makes the tag presentable to the great humans that use this program, other life forms
* will just have to fend for themselves
*/
public function format($type=0,$object_id=0)
{
if ($type AND !self::validate_type($type)) { return false; }
if ($type) {
$this->set_object($type,$object_id);
}
$size = 3 + ($this->weight-1) - ($this->count-1);
if (abs($size) > 4) { $size = 4; }
if (abs($size) < 1) { $size = 1; }
if ($this->owner == $GLOBALS['user']->id) {
$action = '?page=tag&action=remove_tag&type=' . scrub_out($type) . '&tag_id=' . intval($this->id) . '&object_id=' . intval($object_id);
$class = "hover-remove ";
} else {
$action = '?page=tag&action=add_tag&type=' . scrub_out($type) . '&tag_id=' . intval($this->id) . '&object_id=' . intval($object_id);
$class = "hover-add ";
}
$class .= 'tag_size' . $size;
$this->f_class = $class;
$this->f_name = Ajax::text($action,$this->name,'modify_tag_' . $this->id . '_' . $object_id,'',$class);
} // format
/**
* set_object
* This associates the tag with a specified object, we try to get the
* data from the map cache, otherwise I guess we'll just have to look it
* up.
*/
public function set_object($type,$object_id)
{
if (parent::is_cached('tag_top_' . $type,$object_id)) {
$data = parent::get_from_cache('tag_top_' . $type,$object_id);
} else {
$data = self::get_top_tags($type,$object_id);
}
// If nothing is found, then go ahead and return false
if (!is_array($data) OR !count($data)) { return false; }
$this->weight = count($data[$this->id]['users']);
if (in_array($GLOBALS['user']->id,$data[$this->id]['users'])) {
$this->owner = $GLOBALS['user']->id;
}
$this->count = count($data);
} // set_object
/**
* build_cache
* This takes an array of object ids and caches all of their information
@ -134,13 +70,13 @@ class Tag extends database_object
{
if (!is_array($ids) OR !count($ids)) { return false; }
$idlist = '(' . implode(',',$ids) . ')';
$idlist = '(' . implode(',', $ids) . ')';
$sql = "SELECT * FROM `tag` WHERE `id` IN $idlist";
$db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) {
parent::add_to_cache('tag',$row['id'],$row);
parent::add_to_cache('tag', $row['id'], $row);
}
return true;
@ -150,21 +86,23 @@ class Tag extends database_object
* build_map_cache
* This builds a cache of the mappings for the specified object, no limit is given
*/
public static function build_map_cache($type,$ids)
public static function build_map_cache($type, $ids)
{
if (!is_array($ids) OR !count($ids)) { return false; }
$type = self::validate_type($type);
$idlist = '(' . implode(',',$ids) . ')';
$sql = "SELECT `tag_map`.`id`,`tag_map`.`tag_id`,`tag_map`.`object_id`,`tag_map`.`user` FROM `tag_map` " .
"WHERE `tag_map`.`object_type`='$type' AND `tag_map`.`object_id` IN $idlist ";
$sql = "SELECT `tag_map`.`id`,`tag_map`.`tag_id`, `tag`.`name`,`tag_map`.`object_id`,`tag_map`.`user` FROM `tag` " .
"LEFT JOIN `tag_map` ON `tag_map`.`tag_id`=`tag`.`id` " .
"WHERE `tag_map`.`object_type`='$type' AND `tag_map`.`object_id` IN $idlist";
$db_results = Dba::read($sql);
$tags = array();
while ($row = Dba::fetch_assoc($db_results)) {
$tags[$row['object_id']][$row['tag_id']]['users'][] = $row['user'];
$tags[$row['object_id']][$row['tag_id']] = array('user'=>$row['user'], 'id'=>$row['tag_id'], 'name'=>$row['name']);
$tag_map[$row['object_id']] = array('id'=>$row['id'],'tag_id'=>$row['tag_id'],'user'=>$row['user'],'object_type'=>$type,'object_id'=>$row['object_id']);
}
@ -188,7 +126,7 @@ class Tag extends database_object
* This is a wrapper function, it figures out what we need to add, be it a tag
* and map, or just the mapping
*/
public static function add($type,$id,$value,$user=false)
public static function add($type, $id, $value, $user=false)
{
// Validate the tag type
if (!self::validate_type($type)) { return false; }
@ -234,12 +172,28 @@ class Tag extends database_object
$db_results = Dba::write($sql);
$insert_id = Dba::insert_id();
parent::add_to_cache('tag_name',$value,$insert_id);
parent::add_to_cache('tag_name', $value, $insert_id);
return $insert_id;
} // add_tag
/**
* update
* Update the name of the tag
*/
public function update($name)
{
//debug_event('tag.class', 'Updating tag {'.$this->id.'} with name {'.$name.'}...', '5');
if (!strlen($name)) { return false; }
$name = Dba::escape($name);
$sql = 'UPDATE `tag` SET `name` = ? WHERE `id` = ?';
Dba::write($sql, array($name, $this->id));
} // add_tag
/**
* add_tag_map
* This adds a specific tag to the map for specified object
@ -294,6 +248,25 @@ class Tag extends database_object
$db_results = Dba::write($sql);
}
/**
* delete
*
* Delete the tag and all maps
*/
public function delete()
{
$sql = "DELETE FROM `tag_map` WHERE `tag_map`.`tag_id`='".$this->id."'";
$db_results = Dba::write($sql);
$sql = "DELETE FROM `tag` WHERE `tag`.`id`='".$this->id."'";
$db_results = Dba::write($sql);
// Call the garbage collector to clean everything
Tag::gc();
parent::clear_cache();
}
/**
* tag_exists
* This checks to see if a tag exists, this has nothing to do with objects or maps
@ -325,11 +298,6 @@ class Tag extends database_object
{
if (!self::validate_type($type)) { return false; }
if (parent::is_cached('tag_map_' . $type,$object_id)) {
$data = parent::get_from_cache('tag_map_' . $type,$object_id);
return $data['id'];
}
$object_id = Dba::escape($object_id);
$tag_id = Dba::escape($tag_id);
$user = Dba::escape($user);
@ -340,8 +308,6 @@ class Tag extends database_object
$results = Dba::fetch_assoc($db_results);
parent::add_to_cache('tag_map_' . $type,$results['id'],$results);
return $results['id'];
} // tag_map_exists
@ -352,28 +318,25 @@ class Tag extends database_object
*/
public static function get_top_tags($type, $object_id, $limit = 10)
{
//debug_event('tag.class', 'Getting tags for type {'.$type.'} object_id {'.$object_id.'}...', '5');
if (!self::validate_type($type)) { return false; }
if (parent::is_cached('tag_top_' . $type,$object_id)) {
return parent::get_from_cache('tag_top_' . $type,$object_id);
}
$object_id = intval($object_id);
$limit = intval($limit);
$sql = "SELECT `tag_id`, `user` FROM `tag_map` " .
"WHERE `object_type`='$type' AND `object_id`='$object_id' " .
"LIMIT $limit";
$limit = intval($limit);
$sql = "SELECT `tag_map`.`id`, `tag_map`.`tag_id`, `tag`.`name`, `tag_map`.`user` FROM `tag` " .
"LEFT JOIN `tag_map` ON `tag_map`.`tag_id`=`tag`.`id` " .
"WHERE `tag_map`.`object_type`='$type' AND `tag_map`.`object_id`='$object_id' ".
"GROUP BY `tag`.`name` LIMIT $limit";
$db_results = Dba::read($sql);
$results = array();
while ($row = Dba::fetch_assoc($db_results)) {
$results[$row['tag_id']]['users'][] = $row['user'];
$results[$row['id']] = array('user'=>$row['user'], 'id'=>$row['tag_id'], 'name'=>$row['name']);
}
parent::add_to_cache('tag_top_' . $type,$object_id,$results);
return $results;
} // get_top_tags
@ -381,7 +344,7 @@ class Tag extends database_object
/**
* get_object_tags
* Display all tags that apply to maching target type of the specified id
* UNUSED
*
*/
public static function get_object_tags($type, $id)
{
@ -401,7 +364,6 @@ class Tag extends database_object
}
return $results;
} // get_object_tags
/**
@ -430,42 +392,39 @@ class Tag extends database_object
}
return $results;
} // get_tag_objects
/**
* get_tags
* This is a non-object non type depedent function that just returns tags
* This is a non-object non type dependent function that just returns tags
* we've got, it can take filters (this is used by the tag cloud)
*/
public static function get_tags($limit = 0)
{
/*debug_event('tag.class.php', 'Get tags list called...', '5');
if (parent::is_cached('tags_list', 0)) {
//debug_event('tag.class.php', 'Get tags list called...', '5');
if (parent::is_cached('tags_list', 'no_name')) {
//debug_event('tag.class.php', 'Tags list found into cache memory!', '5');
return parent::get_from_cache('tags_list', 0);
}*/
$sql = "SELECT `tag_map`.`tag_id`,COUNT(`tag_map`.`object_id`) AS `count` " .
"FROM `tag_map` " .
"LEFT JOIN `tag` ON `tag`.`id`=`tag_map`.`tag_id` " .
"GROUP BY `tag`.`name` ORDER BY `count` DESC ";
if ($limit > 0) {
$sql .= " LIMIT $limit";
return parent::get_from_cache('tags_list', 'no_name');
}
$db_results = Dba::read($sql);
$results = array();
while ($row = Dba::fetch_assoc($db_results)) {
if ($row['count'] > $top) { $top = $row['count']; }
$results[$row['tag_id']] = array('id'=>$row['tag_id'],'count'=>$row['count']);
$count+= $row['count'];
$sql = "SELECT `tag_map`.`tag_id`, `tag`.`name`, COUNT(`tag_map`.`object_id`) AS `count` " .
"FROM `tag_map` " .
"LEFT JOIN `tag` ON `tag`.`id`=`tag_map`.`tag_id` " .
"GROUP BY `tag`.`name` ORDER BY `count` DESC ";
if ($limit > 0) {
$sql .= " LIMIT $limit";
}
//parent::add_to_cache('tags_list', 0, $results);
$db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) {
$results[$row['tag_id']] = array('id'=>$row['tag_id'], 'name'=>$row['name'], 'count'=>$row['count']);
}
parent::add_to_cache('tags_list', 'no_name', $results);
return $results;
} // get_tags
@ -478,17 +437,21 @@ class Tag extends database_object
*/
public static function get_display($tags)
{
//debug_event('tag.class.php', 'Get display tags called...', '5');
if (!is_array($tags)) { return ''; }
$results = '';
// Iterate through the tags, format them according to type and element id
foreach ($tags as $tag_id=>$value) {
$tag = new Tag($tag_id);
$results .= $tag->name . ', ';
/*debug_event('tag.class.php', $tag_id, '5');
foreach ($value as $vid=>$v) {
debug_event('tag.class.php', $vid.' = {'.$v.'}', '5');
}*/
$results .= $value['name'] . ', ';
}
$results = rtrim($results,', ');
$results = rtrim($results, ', ');
return $results;
@ -506,8 +469,8 @@ class Tag extends database_object
$editedTags = explode(",", $tags_comma);
foreach ($ctags as $ctid => $ctv) {
if ($ctid != '') {
$ctag = new Tag($ctid);
if ($ctv['id'] != '') {
$ctag = new Tag($ctv['id']);
debug_event('tag.class', 'Processing tag {'.$ctag->name.'}...', '5');
$found = false;
@ -561,61 +524,6 @@ class Tag extends database_object
} // count
/**
* filter_with_prefs
* This filters the tags based on the users preference
*/
public static function filter_with_prefs($l)
{
$colors = array('#0000FF','#00FF00', '#FFFF00', '#00FFFF','#FF00FF','#FF0000');
$prefs = 'tag company';
$ulist = explode(' ', $prefs);
$req = '';
foreach ($ulist as $i) {
$req .= "'" . Dba::escape($i) . "',";
}
$req = rtrim($req, ',');
$sql = 'SELECT `id`,`username` FROM `user` WHERE ';
if ($prefs=='all') {
$sql .= '1';
} else {
$sql .= 'username in ('.$req.')';
}
$db_results = Dba::read($sql);
$uids=array();
$usernames = array();
$p = 0;
while ($r = Dba::fetch_assoc($db_results)) {
$usernames[$r['id']] = $r['username'];
$uids[$r['id']] = $colors[$p];
$p++;
if ($p == sizeof($colors)) {
$p = 0;
}
}
$res = array();
foreach ($l as $i) {
if ($GLOBALS['user']->id == $i['user']) {
$res[] = $i;
} elseif (isset($uids[$i['user']])) {
$i['color'] = $uids[$i['user']];
$i['username'] = $usernames[$i['user']];
$res[] = $i;
}
}
return $res;
} // filter_with_prefs
/**
* remove_map
* This will only remove tag maps for the current user
@ -651,16 +559,4 @@ class Tag extends database_object
} // validate_type
/**
* clean_tag
* This takes a string and makes it Tagish
*/
public static function clean_tag($value)
{
$tag = preg_replace("/[^\w\_\-\s\&]/u", "", $value);
return $tag;
} // clean_tag
} // end of Tag class

View file

@ -143,7 +143,13 @@ function handleBroadcastAction(url, id) {
/* Edit modal dialog for artists, albums and songs */
/***************************************************/
function showEditDialog(edit_type, edit_id, edit_form_id, edit_title, edit_tag_choices, refresh_row_prefix, refresh_action) {
var tag_choices;
function setTagsChoices(choices) {
tag_choices = choices;
}
function showEditDialog(edit_type, edit_id, edit_form_id, edit_title, refresh_row_prefix, refresh_action) {
var parent = this;
parent.editFormId = 'form#' + edit_form_id;
parent.contentUrl = jsAjaxServer + '/show_edit.server.php?action=show_edit_object&id=' + edit_id + '&type=' + edit_type;
@ -155,8 +161,8 @@ function showEditDialog(edit_type, edit_id, edit_form_id, edit_title, edit_tag_c
// Convert choices string ("tag0,tag1,tag2,...") to choices array
parent.editTagChoices = new Array();
if (edit_tag_choices != null && edit_tag_choices != '') {
var splitted = edit_tag_choices.split(',');
if (tag_choices != null && tag_choices != '') {
var splitted = tag_choices.split(',');
var i;
for (i = 0; i < splitted.length; ++i) {
parent.editTagChoices.push($.trim(splitted[i]));

View file

@ -97,6 +97,8 @@ switch ($_REQUEST['action']) {
break;
/* Controls the editing of objects */
case 'edit_object':
debug_event('ajax_server', "Editing object...", '5');
// Scrub the data
foreach ($_POST as $key => $data) {
$_POST[$key] = unhtmlentities(scrub_in($data));
@ -184,6 +186,10 @@ switch ($_REQUEST['action']) {
$broadcast = new Broadcast($_POST['id']);
$broadcast->update($_POST);
break;
case 'tag_row':
$tag = new Tag($_POST['id']);
$tag->update($_POST['name']);
break;
default:
$key = 'rfc3514';
echo xoutput_from_array(array($key=>'0x1'));

View file

@ -69,4 +69,8 @@ switch ($_REQUEST['action']) {
$broadcast->format();
require AmpConfig::get('prefix') . '/templates/show_broadcast_row.inc.php';
break;
case 'refresh_tag':
$tag = new Tag($_REQUEST['id']);
echo $tag->name;
break;
} // switch on the action

View file

@ -78,6 +78,9 @@ switch ($_REQUEST['action']) {
$broadcast = new Broadcast($_GET['id']);
$broadcast->format();
break;
case 'tag_row':
$tag = new Tag($_GET['id']);
break;
default:
exit();
} // end switch on type

View file

@ -37,8 +37,15 @@ switch ($_REQUEST['action']) {
debug_event('tag.ajax', 'Adding new tag by name...', '5');
Tag::add($_GET['type'],$_GET['object_id'],$_GET['tag_name'], false);
break;
case 'remove_tag':
debug_event('tag.ajax', 'Removing tag...', '5');
case 'delete':
debug_event('tag.ajax', 'Deleting tag...', '5');
$tag = new Tag($_GET['tag_id']);
$tag->delete();
header('Location: ' . AmpConfig::get('web_path') . '/browse.php?action=tag');
exit;
break;
case 'remove_tag_map':
debug_event('tag.ajax', 'Removing tag map...', '5');
$tag = new Tag($_GET['tag_id']);
$tag->remove_map($_GET['type'],$_GET['object_id']);
break;

View file

@ -76,7 +76,7 @@ if (Art::is_enabled()) {
</a>
<?php } ?>
<?php if (Access::check('interface','50')) { ?>
<a id="<?php echo 'edit_album_'.$album->id ?>" onclick="showEditDialog('album_row', '<?php echo $album->id ?>', '<?php echo 'edit_album_'.$album->id ?>', '<?php echo T_('Album edit') ?>', '<?php echo $tags_list ?>', 'album_', 'refresh_album')">
<a id="<?php echo 'edit_album_'.$album->id ?>" onclick="showEditDialog('album_row', '<?php echo $album->id ?>', '<?php echo 'edit_album_'.$album->id ?>', '<?php echo T_('Album edit') ?>', 'album_', 'refresh_album')">
<?php echo UI::get_icon('edit', T_('Edit')); ?>
</a>
<?php } ?>

View file

@ -21,9 +21,11 @@
*/
$web_path = AmpConfig::get('web_path');
$tags_list = Tag::get_display(Tag::get_tags());
$thcount = 8;
?>
<script type="text/javascript">
setTagsChoices('<?php echo Tag::get_display(Tag::get_tags()); ?>');
</script>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<table class="tabledata" cellpadding="0" cellspacing="0">
<tr class="th-top">

View file

@ -58,7 +58,7 @@
</a>
<?php } ?>
<?php if (Access::check('interface','50')) { ?>
<a id="<?php echo 'edit_artist_'.$artist->id ?>" onclick="showEditDialog('artist_row', '<?php echo $artist->id ?>', '<?php echo 'edit_artist_'.$artist->id ?>', '<?php echo T_('Artist edit') ?>', '<?php echo $tags_list ?>', 'artist_', 'refresh_artist')">
<a id="<?php echo 'edit_artist_'.$artist->id ?>" onclick="showEditDialog('artist_row', '<?php echo $artist->id ?>', '<?php echo 'edit_artist_'.$artist->id ?>', '<?php echo T_('Artist edit') ?>', 'artist_', 'refresh_artist')">
<?php echo UI::get_icon('edit', T_('Edit')); ?>
</a>
<?php } ?>

View file

@ -23,9 +23,11 @@
session_start();
$web_path = AmpConfig::get('web_path');
$tags_list = Tag::get_display(Tag::get_tags());
$thcount = 8;
?>
<script type="text/javascript">
setTagsChoices('<?php echo Tag::get_display(Tag::get_tags()); ?>');
</script>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<table class="tabledata" cellpadding="0" cellspacing="0">
<tr class="th-top">

View file

@ -32,4 +32,4 @@
<td class="cel_genre"><?php echo $broadcast->f_tags; ?></td>
<td class="cel_started"><?php echo ($broadcast->started ? T_('Yes') : T_('No')); ?></td>
<td class="cel_listeners"><?php echo $broadcast->listeners; ?></td>
<td class="cel_action"><?php $broadcast->show_action_buttons($tags_list); ?></td>
<td class="cel_action"><?php $broadcast->show_action_buttons(); ?></td>

View file

@ -20,8 +20,10 @@
*
*/
$tags_list = Tag::get_display(Tag::get_tags());
?>
<script type="text/javascript">
setTagsChoices('<?php echo Tag::get_display(Tag::get_tags()); ?>');
</script>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php' ?>
<table class="tabledata" cellpadding="0" cellspacing="0">
<tr class="th-top">

View file

@ -45,4 +45,4 @@
<?php echo $channel->get_stream_proxy_url(); ?>
</td>
<td class="cel_state"><div id="channel_state_<?php echo $channel->id; ?>"><?php echo $channel->get_channel_state(); ?></div></td>
<td class="cel_action"><?php $channel->show_action_buttons($tags_list); ?></td>
<td class="cel_action"><?php $channel->show_action_buttons(); ?></td>

View file

@ -20,8 +20,10 @@
*
*/
$tags_list = Tag::get_display(Tag::get_tags());
?>
<script type="text/javascript">
setTagsChoices('<?php echo Tag::get_display(Tag::get_tags()); ?>');
</script>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php' ?>
<table class="tabledata" cellpadding="0" cellspacing="0">
<tr class="th-top">

View file

@ -0,0 +1,34 @@
<?php
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* Copyright 2001 - 2013 Ampache.org
*
* 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.
*
*/
?>
<div>
<form method="post" id="edit_tag_<?php echo $tag->id; ?>" class="edit_dialog_content">
<table class="tabledata" cellspacing="0" cellpadding="0">
<tr>
<td class="edit_dialog_content_header"><?php echo T_('Name') ?></td>
<td><input type="text" name="name" value="<?php echo scrub_out($tag->name); ?>" /></td>
</tr>
</table>
<input type="hidden" name="id" value="<?php echo $tag->id; ?>" />
<input type="hidden" name="type" value="tag_row" />
</form>
</div>

View file

@ -38,7 +38,7 @@
<td class="cel_codec"><?php echo $radio->codec; ?></td>
<td class="cel_action">
<?php if (Access::check('interface','50')) { ?>
<a id="<?php echo 'edit_live_stream_'.$radio->id ?>" onclick="showEditDialog('live_stream_row', '<?php echo $radio->id ?>', '<?php echo 'edit_live_stream_'.$radio->id ?>', '<?php echo T_('Live Stream edit') ?>', '', 'live_stream_', 'refresh_livestream')">
<a id="<?php echo 'edit_live_stream_'.$radio->id ?>" onclick="showEditDialog('live_stream_row', '<?php echo $radio->id ?>', '<?php echo 'edit_live_stream_'.$radio->id ?>', '<?php echo T_('Live Stream edit') ?>', 'live_stream_', 'refresh_livestream')">
<?php echo UI::get_icon('edit', T_('Edit')); ?>
</a>
<?php } ?>

View file

@ -54,7 +54,7 @@
<a href="<?php echo AmpConfig::get('web_path'); ?>/share.php?action=show_create&type=playlist&id=<?php echo $playlist->id; ?>"><?php echo UI::get_icon('share', T_('Share')); ?></a>
<?php } ?>
<?php if ($playlist->has_access()) { ?>
<a id="<?php echo 'edit_playlist_'.$playlist->id ?>" onclick="showEditDialog('playlist_row', '<?php echo $playlist->id ?>', '<?php echo 'edit_playlist_'.$playlist->id ?>', '<?php echo T_('Playlist edit') ?>', '', 'playlist_row_', 'refresh_playlist')">
<a id="<?php echo 'edit_playlist_'.$playlist->id ?>" onclick="showEditDialog('playlist_row', '<?php echo $playlist->id ?>', '<?php echo 'edit_playlist_'.$playlist->id ?>', '<?php echo T_('Playlist edit') ?>', 'playlist_row_', 'refresh_playlist')">
<?php echo UI::get_icon('edit', T_('Edit')); ?>
</a>
<?php echo Ajax::button('?page=browse&action=delete_object&type=playlist&id='.$playlist->id, 'delete', T_('Delete'), 'delete_playlist_'.$playlist->id, '', '', T_('Do you really want to delete the playlist?')); ?>

View file

@ -49,7 +49,7 @@
</a>
<?php } ?>
<?php if ($playlist->has_access()) { ?>
<a id="<?php echo 'edit_playlist_'.$playlist->id ?>" onclick="showEditDialog('smartplaylist_row', '<?php echo $playlist->id ?>', '<?php echo 'edit_playlist_'.$playlist->id ?>', '<?php echo T_('Smart Playlist edit') ?>', '<?php echo $tags_list ?>', 'smartplaylist_row_', 'refresh_smartplaylist')">
<a id="<?php echo 'edit_playlist_'.$playlist->id ?>" onclick="showEditDialog('smartplaylist_row', '<?php echo $playlist->id ?>', '<?php echo 'edit_playlist_'.$playlist->id ?>', '<?php echo T_('Smart Playlist edit') ?>', 'smartplaylist_row_', 'refresh_smartplaylist')">
<?php echo UI::get_icon('edit', T_('Edit')); ?>
</a>
<?php echo Ajax::button('?page=browse&action=delete_object&type=smartplaylist&id=' . $playlist->id,'delete', T_('Delete'),'delete_playlist_' . $playlist->id); ?>

View file

@ -20,8 +20,10 @@
*
*/
$tags_list = Tag::get_display(Tag::get_tags());
?>
<script type="text/javascript">
setTagsChoices('<?php echo Tag::get_display(Tag::get_tags()); ?>');
</script>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php' ?>
<table class="tabledata" cellpadding="0" cellspacing="0">
<tr class="th-top">

View file

@ -67,7 +67,7 @@
<?php if (Access::check_function('download')) { ?>
<a href="<?php echo AmpConfig::get('web_path'); ?>/stream.php?action=download&song_id=<?php echo $song->id; ?>"><?php echo UI::get_icon('download', T_('Download')); ?></a><?php } ?>
<?php if (Access::check('interface','75')) { ?>
<a id="<?php echo 'edit_song_'.$song->id ?>" onclick="showEditDialog('song_row', '<?php echo $song->id ?>', '<?php echo 'edit_song_'.$song->id ?>', '<?php echo T_('Song edit') ?>', '<?php echo $tags_list ?>', 'song_', 'refresh_song')">
<a id="<?php echo 'edit_song_'.$song->id ?>" onclick="showEditDialog('song_row', '<?php echo $song->id ?>', '<?php echo 'edit_song_'.$song->id ?>', '<?php echo T_('Song edit') ?>', 'song_', 'refresh_song')">
<?php echo UI::get_icon('edit', T_('Edit')); ?>
</a>
<?php $icon = $song->enabled ? 'disable' : 'enable'; ?>

View file

@ -21,9 +21,11 @@
*/
$web_path = AmpConfig::get('web_path');
$tags_list = Tag::get_display(Tag::get_tags());
$thcount = 8;
?>
<script type="text/javascript">
setTagsChoices('<?php echo Tag::get_display(Tag::get_tags()); ?>');
</script>
<?php if ($browse->get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?>
<table id="reorder_songs_table" class="tabledata" cellpadding="0" cellspacing="0">
<tr class="th-top">

View file

@ -20,15 +20,27 @@
*
*/
$web_path = AmpConfig::get('web_path');
?>
<?php Ajax::start_container('tag_filter'); ?>
<?php foreach ($object_ids as $data) {
$tag = new Tag($data['id']);
$tag->format();
?>
<span id="click_<?php echo intval($tag->id); ?>" class="<?php echo $tag->f_class; ?>"><?php echo $tag->name; ?></span>
<?php echo Ajax::observe('click_' . intval($tag->id),'click',Ajax::action('?page=tag&action=add_filter&browse_id=' . $browse2->id . '&tag_id=' . intval($tag->id),'')); ?>
<?php foreach ($object_ids as $data) { ?>
<div class="tag_button">
<span id="click_tag_<?php echo $data['id']; ?>"><?php echo $data['name']; ?></span>
<?php echo Ajax::observe('click_tag_' . $data['id'], 'click', Ajax::action('?page=tag&action=add_filter&browse_id=' . $browse2->id . '&tag_id=' . $data['id'], '')); ?>
</div>
<?php if (Access::check('interface', '50')) { ?>
<div class="tag_actions">
<ul>
<li>
<a class="tag_edit" id="<?php echo 'edit_tag_'.$data['id'] ?>" onclick="showEditDialog('tag_row', '<?php echo $data['id'] ?>', '<?php echo 'edit_tag_'.$data['id'] ?>', '<?php echo T_('Tag edit') ?>', 'click_tag_', 'refresh_tag')">
<?php echo UI::get_icon('edit', T_('Edit')); ?>
</a>
</li>
<li>
<a class="tag_delete" href="<?php echo AmpConfig::get('ajax_url') ?>?page=tag&action=delete&tag_id=<?php echo $data['id']; ?>" onclick="return confirm('<?php echo T_('Do you really want to delete the tag?'); ?>');"><?php echo UI::get_icon('delete', T_('Delete')); ?></a>
</li>
</ul>
</div>
<?php } ?>
<?php } ?>
<?php if (!count($object_ids)) { ?>
<span class="fatalerror"><?php echo T_('Not Enough Data'); ?></span>

View file

@ -1161,14 +1161,25 @@ span.fatalerror {
display: block;
}
.box-content #tag_filter span {
color: #fff;
.box-content #tag_filter div {
float: left;
padding: 4px 10px 4px;
margin: 10px;
height: 32px;
}
.box-content #tag_filter .tag_button {
margin: 20px 0 0 15px;
font-size: 14px;
text-align: center;
vertical-align: middle;
color: #fff;
text-align: center;
}
.box-content #tag_filter .tag_actions {
margin: 15px 0 0 -8px;
}
.box-content #tag_filter span {
padding: 8px 10px 8px;
cursor: pointer;
background-color: #5f5f5f;
background-image: -moz-linear-gradient(top,#6d6d6d,#4a4a4a);
@ -1205,6 +1216,10 @@ span.fatalerror {
background-repeat:repeat-x;
}
.box-content #tag_filter li{
height: 16px;
}
/***********************************************
Content (inline edit)
***********************************************/