mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-03 17:59:21 +02:00
move over to query class as backend for browse
This commit is contained in:
parent
1dff2461c7
commit
04bcb58be9
5 changed files with 122 additions and 986 deletions
10
browse.php
10
browse.php
|
@ -44,18 +44,17 @@ switch ($_REQUEST['action']) {
|
||||||
case 'song':
|
case 'song':
|
||||||
Browse::set_type($_REQUEST['action']);
|
Browse::set_type($_REQUEST['action']);
|
||||||
Browse::reset();
|
Browse::reset();
|
||||||
Browse::set_simple_browse(1);
|
Browse::set_simple_browse(true);
|
||||||
break;
|
break;
|
||||||
} // end switch
|
} // end switch
|
||||||
|
|
||||||
show_header();
|
show_header();
|
||||||
Browse::set_filter_from_request($_REQUEST);
|
|
||||||
switch($_REQUEST['action']) {
|
switch($_REQUEST['action']) {
|
||||||
case 'file':
|
case 'file':
|
||||||
break;
|
break;
|
||||||
case 'album':
|
case 'album':
|
||||||
Browse::set_sort('name','ASC');
|
Browse::set_sort('name','ASC');
|
||||||
$album_ids = Browse::get_objects();
|
|
||||||
Browse::show_objects();
|
Browse::show_objects();
|
||||||
break;
|
break;
|
||||||
case 'tag':
|
case 'tag':
|
||||||
|
@ -69,17 +68,14 @@ switch($_REQUEST['action']) {
|
||||||
break;
|
break;
|
||||||
case 'artist':
|
case 'artist':
|
||||||
Browse::set_sort('name','ASC');
|
Browse::set_sort('name','ASC');
|
||||||
$artist_ids = Browse::get_objects();
|
|
||||||
Browse::show_objects();
|
Browse::show_objects();
|
||||||
break;
|
break;
|
||||||
case 'song':
|
case 'song':
|
||||||
Browse::set_sort('title','ASC');
|
Browse::set_sort('title','ASC');
|
||||||
$song_ids = Browse::get_objects();
|
|
||||||
Browse::show_objects();
|
Browse::show_objects();
|
||||||
break;
|
break;
|
||||||
case 'live_stream':
|
case 'live_stream':
|
||||||
Browse::set_sort('name','ASC');
|
Browse::set_sort('name','ASC');
|
||||||
$live_stream_ids = Browse::get_objects();
|
|
||||||
Browse::show_objects();
|
Browse::show_objects();
|
||||||
break;
|
break;
|
||||||
case 'catalog':
|
case 'catalog':
|
||||||
|
@ -88,12 +84,10 @@ switch($_REQUEST['action']) {
|
||||||
case 'playlist':
|
case 'playlist':
|
||||||
Browse::set_sort('type','ASC');
|
Browse::set_sort('type','ASC');
|
||||||
Browse::set_filter('playlist_type','1');
|
Browse::set_filter('playlist_type','1');
|
||||||
$playlist_ids = Browse::get_objects();
|
|
||||||
Browse::show_objects();
|
Browse::show_objects();
|
||||||
break;
|
break;
|
||||||
case 'video':
|
case 'video':
|
||||||
Browse::set_sort('title','ASC');
|
Browse::set_sort('title','ASC');
|
||||||
$video_ids = Browse::get_objects();
|
|
||||||
Browse::show_objects();
|
Browse::show_objects();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -122,7 +122,7 @@ class Query {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* reset
|
* reset
|
||||||
* Reset everything
|
* Reset everything, this should only be called when we are starting fresh
|
||||||
*/
|
*/
|
||||||
public static function reset() {
|
public static function reset() {
|
||||||
|
|
||||||
|
@ -132,7 +132,6 @@ class Query {
|
||||||
self::reset_join();
|
self::reset_join();
|
||||||
self::reset_select();
|
self::reset_select();
|
||||||
self::reset_having();
|
self::reset_having();
|
||||||
self::reset_supplemental_objects();
|
|
||||||
self::set_is_simple(0);
|
self::set_is_simple(0);
|
||||||
self::set_start(0);
|
self::set_start(0);
|
||||||
|
|
||||||
|
@ -188,16 +187,6 @@ class Query {
|
||||||
|
|
||||||
} // reset_filters
|
} // reset_filters
|
||||||
|
|
||||||
/**
|
|
||||||
* reset_supplemental_objects
|
|
||||||
* This clears any sup objects we've added, normally called on every set_type
|
|
||||||
*/
|
|
||||||
public static function reset_supplemental_objects() {
|
|
||||||
|
|
||||||
self::$_state[self::$type]['supplemental'] = array();
|
|
||||||
|
|
||||||
} // reset_supplemental_objects
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* reset_total
|
* reset_total
|
||||||
* This resets the total for the browse type
|
* This resets the total for the browse type
|
||||||
|
@ -219,6 +208,26 @@ class Query {
|
||||||
|
|
||||||
} // get_filter
|
} // get_filter
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get_start
|
||||||
|
* This returns the current value of the start
|
||||||
|
*/
|
||||||
|
public static function get_start() {
|
||||||
|
|
||||||
|
return self::$start;
|
||||||
|
|
||||||
|
} // get_start
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get_offset
|
||||||
|
* This returns the current offset
|
||||||
|
*/
|
||||||
|
public static function get_offset() {
|
||||||
|
|
||||||
|
return self::$offset;
|
||||||
|
|
||||||
|
} // get_offset
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get_total
|
* get_total
|
||||||
* This returns the toal number of obejcts for this current sort type. If it's already cached used it!
|
* This returns the toal number of obejcts for this current sort type. If it's already cached used it!
|
||||||
|
@ -386,6 +395,16 @@ class Query {
|
||||||
|
|
||||||
} // set_sort
|
} // set_sort
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set_offset
|
||||||
|
* This sets the current offset of this query
|
||||||
|
*/
|
||||||
|
public static function set_offset($offset) {
|
||||||
|
|
||||||
|
self::$offset = abs($offset);
|
||||||
|
|
||||||
|
} // set_offset
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set_select
|
* set_select
|
||||||
* This appends more information to the select part of the SQL statement, we're going to move to the
|
* This appends more information to the select part of the SQL statement, we're going to move to the
|
||||||
|
@ -549,33 +568,6 @@ class Query {
|
||||||
|
|
||||||
} // get_objects
|
} // get_objects
|
||||||
|
|
||||||
/**
|
|
||||||
* get_supplemental_objects
|
|
||||||
* This returns an array of 'class','id' for additional objects that need to be
|
|
||||||
* created before we start this whole browsing thing
|
|
||||||
*/
|
|
||||||
public static function get_supplemental_objects() {
|
|
||||||
|
|
||||||
$objects = self::$_state['supplemental'][self::$type];
|
|
||||||
|
|
||||||
if (!is_array($objects)) { $objects = array(); }
|
|
||||||
|
|
||||||
return $objects;
|
|
||||||
|
|
||||||
} // get_supplemental_objects
|
|
||||||
|
|
||||||
/**
|
|
||||||
* add_supplemental_object
|
|
||||||
* This will add a suplemental object that has to be created
|
|
||||||
*/
|
|
||||||
public static function add_supplemental_object($class,$uid) {
|
|
||||||
|
|
||||||
self::$_state['supplemental'][self::$type][$class] = intval($uid);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
} // add_supplemental_object
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set_base_sql
|
* set_base_sql
|
||||||
* This saves the base sql statement we are going to use.
|
* This saves the base sql statement we are going to use.
|
||||||
|
@ -1165,6 +1157,33 @@ class Query {
|
||||||
|
|
||||||
} // resort_objects
|
} // resort_objects
|
||||||
|
|
||||||
|
/**
|
||||||
|
* save_objects
|
||||||
|
* This takes the full array of object ides, often passed into show and then
|
||||||
|
* if nessecary it saves them into the session
|
||||||
|
*/
|
||||||
|
public static function save_objects($object_ids) {
|
||||||
|
|
||||||
|
// Saving these objects has two operations, one hold it in
|
||||||
|
// a local variable and then second hold it in a row in the tmp_browse
|
||||||
|
// table
|
||||||
|
self::$_cache['browse'][self::$type] = $object_ids;
|
||||||
|
|
||||||
|
// Only do this if it's a not a simple browse
|
||||||
|
if (!self::is_simple()) {
|
||||||
|
$sid = session_id() . '::' . self::$type;
|
||||||
|
$data = Dba::escape(serialize($object_ids));
|
||||||
|
|
||||||
|
$sql = "REPLACE INTO `tmp_browse` SET `data`='$data', `sid`='$sid'";
|
||||||
|
$db_results = Dba::write($sql);
|
||||||
|
|
||||||
|
self::$total_objects = count($object_ids);
|
||||||
|
} // save it
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} // save_objects
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* _auto_init
|
* _auto_init
|
||||||
* this function reloads information back from the session
|
* this function reloads information back from the session
|
||||||
|
@ -1173,19 +1192,18 @@ class Query {
|
||||||
public static function _auto_init() {
|
public static function _auto_init() {
|
||||||
|
|
||||||
self::$offset = Config::get('offset_limit') ? Config::get('offset_limit') : '25';
|
self::$offset = Config::get('offset_limit') ? Config::get('offset_limit') : '25';
|
||||||
self::$_state = $_SESSION['browse'];
|
self::$_state = &$_SESSION['browse'];
|
||||||
|
|
||||||
} // _auto_init
|
} // _auto_init
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Desctruction
|
* get_state
|
||||||
* This is run on object destrunction, done here to allow for changes
|
* This is a debug only function
|
||||||
* later
|
|
||||||
*/
|
*/
|
||||||
public function __destruct() {
|
public static function get_state() {
|
||||||
|
|
||||||
$_SESSION['browse'] = self::$_state;
|
return self::$_state;
|
||||||
|
|
||||||
} // destructor
|
} // get_state
|
||||||
|
|
||||||
} // query
|
} // query
|
||||||
|
|
|
@ -97,7 +97,7 @@ switch ($_REQUEST['action']) {
|
||||||
Browse::set_start($_REQUEST['start']);
|
Browse::set_start($_REQUEST['start']);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
Browse::show_objects(false);
|
Browse::show_objects();
|
||||||
$results['browse_content'] = ob_get_clean();
|
$results['browse_content'] = ob_get_clean();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
// Pull these variables out to allow shorthand (easier for lazy programmers)
|
// Pull these variables out to allow shorthand (easier for lazy programmers)
|
||||||
$limit = Config::get('offset_limit') ? Config::get('offset_limit') : '25';
|
$limit = Config::get('offset_limit') ? Config::get('offset_limit') : '25';
|
||||||
$start = Browse::$start;
|
$start = Browse::get_start();
|
||||||
$total = Browse::$total_objects;
|
$total = Browse::$total_objects;
|
||||||
$uid = Config::get('list_header_uid');
|
$uid = Config::get('list_header_uid');
|
||||||
$sides = 5;
|
$sides = 5;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue