summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2009-03-08 03:54:04 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2009-03-08 03:54:04 +0000
commit2799c89f58d389ac659c0bc414a86cb1454afd75 (patch)
tree16392f16aec13dafb97768f894312974d83e87f2
parent059f6d4d5cde3a66b3c1a998ce123e7eb88e7a98 (diff)
downloadampache-2799c89f58d389ac659c0bc414a86cb1454afd75.tar.gz
ampache-2799c89f58d389ac659c0bc414a86cb1454afd75.tar.bz2
ampache-2799c89f58d389ac659c0bc414a86cb1454afd75.zip
add length to the video browse, put in some stuff for the now playing table up the config version in prep for another alpha
-rw-r--r--config/ampache.cfg.php.dist2
-rw-r--r--lib/class/query.class.php77
-rw-r--r--lib/class/stream.class.php6
-rw-r--r--lib/class/update.class.php22
-rw-r--r--lib/class/video.class.php1
-rw-r--r--lib/init.php2
-rw-r--r--play/index.php2
-rw-r--r--templates/header.inc.php2
-rw-r--r--templates/show_video_row.inc.php1
-rw-r--r--templates/show_videos.inc.php4
10 files changed, 83 insertions, 36 deletions
diff --git a/config/ampache.cfg.php.dist b/config/ampache.cfg.php.dist
index 873e82d1..e079eb3c 100644
--- a/config/ampache.cfg.php.dist
+++ b/config/ampache.cfg.php.dist
@@ -7,7 +7,7 @@
; if this config file is up to date
; this is compared against a value hard-coded
; into the init script
-config_version = 9
+config_version = 10
;###################
; Path Vars #
diff --git a/lib/class/query.class.php b/lib/class/query.class.php
index 2fa20656..daf7bc25 100644
--- a/lib/class/query.class.php
+++ b/lib/class/query.class.php
@@ -33,12 +33,11 @@ class Query {
public static $total_objects;
public static $type;
- // Boolean if this is a simple browse method (use different paging code)
- public static $simple_browse;
-
// Static Content, this is defaulted to false, if set to true then when we can't
// apply any filters that would change the result set.
public static $static_content = false;
+
+ // Private cache information
private static $_cache = array();
private static $_state = array();
@@ -52,7 +51,6 @@ class Query {
} // __construct
-
/**
* set_filter
* This saves the filter data we pass it into the session
@@ -87,7 +85,6 @@ class Query {
self::$_state['filter'][self::$type][$key] = $value;
break;
case 'min_count':
-
case 'unplayed':
case 'rated':
@@ -136,7 +133,7 @@ class Query {
self::reset_select();
self::reset_having();
self::reset_supplemental_objects();
- self::set_simple_browse(0);
+ self::set_is_simple(0);
self::set_start(0);
} // reset
@@ -147,7 +144,7 @@ class Query {
*/
public static function reset_base() {
- self::$_state['base'][self::$type] = false;
+ self::$_state['base'][self::$type] = NULL;
} // reset_base
@@ -230,7 +227,7 @@ class Query {
public static function get_total($objects=false) {
// If they pass something then just return that
- if (is_array($objects) and !self::is_simple_browse()) {
+ if (is_array($objects) and !self::is_simple()) {
return count($objects);
}
@@ -239,7 +236,7 @@ class Query {
return self::$_state['total'][self::$type];
}
- $db_results = Dba::query(self::get_base_sql() . self::get_filter_sql() . self::get_sort_sql());
+ $db_results = Dba::read(self::get_sql(false));
$num_rows = Dba::num_rows($db_results);
self::$_state['total'][self::$type] = $num_rows;
@@ -436,16 +433,16 @@ class Query {
} // set_start
/**
- * set_simple_browse
+ * set_is_simple
* This sets the current browse object to a 'simple' browse method
* which means use the base query provided and expand from there
*/
- public static function set_simple_browse($value) {
+ public static function set_is_simple($value) {
$value = make_bool($value);
self::$_state['simple'][self::$type] = $value;
- } // set_simple_browse
+ } // set_is_simple
/**
* set_static_content
@@ -468,14 +465,14 @@ class Query {
} // set_static_content
/**
- * is_simple_browse
+ * is_simple
* this returns true or false if the current browse type is set to static
*/
- public static function is_simple_browse() {
+ public static function is_simple() {
return self::$_state['simple'][self::$type];
- } // is_simple_browse
+ } // is_simple
/**
* load_start
@@ -499,7 +496,7 @@ class Query {
return self::$_cache['browse'][self::$type];
}
- if (!self::is_simple_browse()) {
+ if (!self::is_simple()) {
// If not then we're going to need to read from the database :(
$sid = session_id() . '::' . self::$type;
@@ -714,7 +711,7 @@ class Query {
*/
private static function get_limit_sql() {
- if (!self::is_simple_browse()) { return ''; }
+ if (!self::is_simple()) { return ''; }
$sql = ' LIMIT ' . intval(self::$start) . ',' . intval(self::$offset);
@@ -763,7 +760,7 @@ class Query {
* every time we get the objects because it depends on the filters and the
* type of object we are currently browsing
*/
- public static function get_sql() {
+ public static function get_sql($limit=true) {
$sql = self::get_base_sql();
@@ -774,7 +771,7 @@ class Query {
$join_sql = self::get_join_sql();
$having_sql = self::get_having_sql();
$order_sql = self::get_sort_sql();
- $limit_sql = self::get_limit_sql();
+ $limit_sql = $limit ? self::get_limit_sql() : '';
$final_sql = $sql . $join_sql . $filter_sql . $having_sql . $order_sql . $limit_sql;
@@ -846,7 +843,7 @@ class Query {
$filter_sql = " `song`.`addition_time` >= '" . Dba::escape($value) . "' AND ";
break;
case 'add_lt':
- $filter_sql = " `song`.`addition_time` <= '" . Dba::escape($value) . "` AND ";
+ $filter_sql = " `song`.`addition_time` <= '" . Dba::escape($value) . "' AND ";
break;
case 'update_gt':
$filter_sql = " `song`.`update_time` >= '" . Dba::escape($value) . "' AND ";
@@ -879,10 +876,22 @@ class Query {
case 'artist':
$filter_sql = " `artist`.`id` = '". Dba::escape($value) . "' AND ";
break;
- case 'add':
+ case 'add_lt':
self::set_join('left','`song`','`song`.`album`','`album`.`id`');
- case 'update':
+ $filter_sql = " `song`.`addition_time` <= '" . Dba::escape($value) . "' AND ";
+ break;
+ case 'add_gt':
+ self::set_join('left','`song`','`song`.`album`','`album`.`id`');
+ $filter_sql = " `song`.`addition_time` >= '" . Dba::escape($value) . "' AND ";
+ break;
+ case 'update_lt':
self::set_join('left','`song`','`song`.`album`','`album`.`id`');
+ $filter_sql = " `song`.`update_time` <= '" . Dba::escape($value) . "' AND ";
+ break;
+ case 'update_gt':
+ self::set_join('left','`song`','`song`.`album`','`album`.`id`');
+ $filter_sql = " `song`.`update_time` >= '" . Dba::escape($value) . "' AND ";
+ break;
default:
// Rien a faire
break;
@@ -899,6 +908,22 @@ class Query {
case 'starts_with':
$filter_sql = " `artist`.`name` LIKE '" . Dba::escape($value) . "%' AND ";
break;
+ case 'add_lt':
+ self::set_join('left','`song`','`song`.`artist`','`artist`.`id`');
+ $filter_sql = " `song`.`addition_time` <= '" . Dba::escape($value) . "' AND ";
+ break;
+ case 'add_gt':
+ self::set_join('left','`song`','`song`.`artist`','`artist`.`id`');
+ $filter_sql = " `song`.`addition_time` >= '" . Dba::escape($value) . "' AND ";
+ break;
+ case 'update_lt':
+ self::set_join('left','`song`','`song`.`artist`','`artist`.`id`');
+ $filter_sql = " `song`.`update_time` <= '" . Dba::escape($value) . "' AND ";
+ break;
+ case 'update_gt':
+ self::set_join('left','`song`','`song`.`artist`','`artist`.`id`');
+ $filter_sql = " `song`.`update_time` >= '" . Dba::escape($value) . "' AND ";
+ break;
default:
// Rien a faire
break;
@@ -1092,18 +1117,15 @@ class Query {
// There are two ways to do this.. the easy way...
// and the vollmer way, hopefully we don't have to
// do it the vollmer way
- if (self::is_simple_browse()) {
- debug_event('resort_objects','is_simple_browse','4');
+ if (self::is_simple()) {
$sql = self::get_sql();
}
else {
- debug_event('resort_objects','not is_simple_browse','4');
// First pull the objects
$objects = self::get_saved();
// If there's nothing there don't do anything
if (!count($objects)) {
- debug_event('resort_objects','no objects found','4');
return false;
}
$type = self::$type;
@@ -1131,8 +1153,7 @@ class Query {
$sql = $sql . self::get_join_sql() . $where_sql . $order_sql;
} // if not simple
- debug_event('resort_objects','final sql: ' . $sql,'4');
- $db_results = Dba::query($sql);
+ $db_results = Dba::read($sql);
while ($row = Dba::fetch_assoc($db_results)) {
$results[] = $row['id'];
diff --git a/lib/class/stream.class.php b/lib/class/stream.class.php
index 0c16dd4e..505bda49 100644
--- a/lib/class/stream.class.php
+++ b/lib/class/stream.class.php
@@ -719,15 +719,15 @@ class Stream {
* This fucntion is used by the /play/index.php song
* primarily, but could be used by other people
*/
- public static function insert_now_playing($song_id,$uid,$song_length,$sid) {
+ public static function insert_now_playing($song_id,$uid,$length,$sid,$type) {
- $time = time()+$song_length;
+ $time = time()+$length;
$session_id = Dba::escape($sid);
// Do a replace into ensuring that this client always only has a single row
$sql = "REPLACE INTO `now_playing` (`id`,`song_id`, `user`, `expire`)" .
" VALUES ('$session_id','$song_id', '$uid', '$time')";
- $db_result = Dba::query($sql);
+ $db_result = Dba::write($sql);
} // insert_now_playing
diff --git a/lib/class/update.class.php b/lib/class/update.class.php
index 87b1a76f..e287b4ea 100644
--- a/lib/class/update.class.php
+++ b/lib/class/update.class.php
@@ -315,6 +315,10 @@ class Update {
$version[] = array('version'=>'350007','description'=>$update_string);
+ $update_string = '- Modify Now Playing table to handle Videos';
+
+ //$version[] = array('version'=>'350008','description'=>$update_string);
+
return $version;
@@ -1697,6 +1701,24 @@ class Update {
} // update_350007
+ /**
+ * update_350008
+ * Change song_id references to be object so they are a little more general
+ * add a type to now playing table so that we can handle different playing information
+ */
+ public static function update_350008() {
+
+ $sql = "ALTER TABLE `now_playing` ALTER `song_id` `object_id` INT( 11 ) UNSIGNED NOT NULL";
+ $db_results = Dba::write($sql);
+
+ $sql = "ALTER TABLE `now_playing` ADD `object_type` VARCHAR ( 255 ) NOT NULL AFTER `object_id`";
+ $db_results = Dba::write($sql);
+
+
+ //self::set_version('db_version','350008');
+
+ } // update_350008
+
} // end update class
?>
diff --git a/lib/class/video.class.php b/lib/class/video.class.php
index 81e6ba7b..44c7ae4f 100644
--- a/lib/class/video.class.php
+++ b/lib/class/video.class.php
@@ -63,6 +63,7 @@ class Video extends database_object implements media {
$this->f_codec = $this->video_codec . ' / ' . $this->audio_codec;
$this->f_resolution = $this->resolution_x . 'x' . $this->resolution_y;
$this->f_tags = '';
+ $this->f_length = floor($this->time/60) . ' ' . _('minutes');
} // format
diff --git a/lib/init.php b/lib/init.php
index cf32e674..565f2cc5 100644
--- a/lib/init.php
+++ b/lib/init.php
@@ -88,7 +88,7 @@ if (!count($results)) {
/** This is the version.... fluf nothing more... **/
$results['version'] = '3.5-Alpha2 '. $svn_version;
-$results['int_config_version'] = '9';
+$results['int_config_version'] = '10';
$results['raw_web_path'] = $results['web_path'];
$results['web_path'] = $http_type . $_SERVER['HTTP_HOST'] . $results['web_path'];
diff --git a/play/index.php b/play/index.php
index d98ca31e..d3a3579b 100644
--- a/play/index.php
+++ b/play/index.php
@@ -319,7 +319,7 @@ else {
} // else not downsampling
// Put this song in the now_playing table
-Stream::insert_now_playing($media->id,$uid,$media->time,$sid);
+Stream::insert_now_playing($media->id,$uid,$media->time,$sid,get_class($media));
if ($start > 0) {
diff --git a/templates/header.inc.php b/templates/header.inc.php
index 230b266a..5fb07994 100644
--- a/templates/header.inc.php
+++ b/templates/header.inc.php
@@ -58,7 +58,7 @@ if (Config::get('use_rss')) { ?>
<?php show_box_top('','box box_headerbox'); ?>
<?php require_once Config::get('prefix') . '/templates/show_search_bar.inc.php'; ?>
<?php require_once Config::get('prefix') . '/templates/show_playtype_switch.inc.php'; ?>
- <span id="loginInfo"><?php echo $GLOBALS['user']->fullname; ?> [<a href="<?php echo Config::get('web_path'); ?>/logout.php"><?php echo _('Log out'); ?></a>]</span>
+ <span id="loginInfo"><a href="<?php echo Config::get('web_path'); ?>/preferences.php?tab=account"><?php echo $GLOBALS['user']->fullname; ?></a> [<a href="<?php echo Config::get('web_path'); ?>/logout.php"><?php echo _('Log out'); ?></a>]</span>
<?php show_box_bottom(); ?>
</div> <!-- End headerbox -->
</div><!-- End header -->
diff --git a/templates/show_video_row.inc.php b/templates/show_video_row.inc.php
index 5618a60d..1b650360 100644
--- a/templates/show_video_row.inc.php
+++ b/templates/show_video_row.inc.php
@@ -25,4 +25,5 @@
<td class="cel_title"><?php echo $video->f_title; ?></td>
<td class="cel_codec"><?php echo $video->f_codec; ?></td>
<td class="cel_resolution"><?php echo $video->f_resolution; ?></td>
+<td class="cel_length"><?php echo $video->f_length; ?></td>
<td class="cel_tags"><?php $video->f_tags; ?></td>
diff --git a/templates/show_videos.inc.php b/templates/show_videos.inc.php
index b58f741d..63a8d8ed 100644
--- a/templates/show_videos.inc.php
+++ b/templates/show_videos.inc.php
@@ -28,6 +28,7 @@ $web_path = Config::get('web_path');
<col id="col_title" />
<col id="col_codec" />
<col id="col_resolution" />
+ <col id="col_length" />
<col id="col_tags" />
</colgroup>
<tr class="th-top">
@@ -35,6 +36,7 @@ $web_path = Config::get('web_path');
<th class="cel_title"><?php echo _('Title'); ?></th>
<th class="cel_codec"><?php echo _('Codec'); ?></th>
<th class="cel_resolution"><?php echo _('Resolution'); ?></th>
+ <th class="cel_length"><?php echo _('Length'); ?></th>
<th class="cel_tags"><?php echo _('Tags'); ?></th>
</tr>
<?php
@@ -49,7 +51,7 @@ foreach ($object_ids as $video_id) {
<?php } //end foreach ?>
<?php if (!count($object_ids)) { ?>
<tr class="<?php echo flip_class(); ?>">
- <td colspan="5"><span class="fatalerror"><?php echo _('Not Enough Data'); ?></span></td>
+ <td colspan="6"><span class="fatalerror"><?php echo _('Not Enough Data'); ?></span></td>
</tr>
<?php } ?>
<tr class="th-bottom">