summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-08-06 04:22:19 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-08-06 04:22:19 +0000
commitfe077220bf08ac7ad466e6fdfe88197c6d4ed56e (patch)
tree1e8d8eab876246fc57a1e6c414fe763570690bf6 /lib
parentadd90bc902ce762626fe72d408f42d705d3f9de7 (diff)
downloadampache-fe077220bf08ac7ad466e6fdfe88197c6d4ed56e.tar.gz
ampache-fe077220bf08ac7ad466e6fdfe88197c6d4ed56e.tar.bz2
ampache-fe077220bf08ac7ad466e6fdfe88197c6d4ed56e.zip
broke a ton of stuff, but added some hotness... yes that is an excuse
Diffstat (limited to 'lib')
-rw-r--r--lib/class/ajax.class.php36
-rw-r--r--lib/class/metadata.class.php39
-rw-r--r--lib/class/stats.class.php3
-rw-r--r--lib/general.lib.php12
-rw-r--r--lib/ui.lib.php19
5 files changed, 73 insertions, 36 deletions
diff --git a/lib/class/ajax.class.php b/lib/class/ajax.class.php
index 441d9a47..5185538a 100644
--- a/lib/class/ajax.class.php
+++ b/lib/class/ajax.class.php
@@ -42,8 +42,17 @@ class Ajax {
*/
public static function observe($source,$method,$action) {
+ $non_quoted = array('document','window');
+
+ if (in_array($source,$non_quoted)) {
+ $source_txt = $source;
+ }
+ else {
+ $source_txt = "'$source'";
+ }
+
$observe = "<script type=\"text/javascript\"><!--\n";
- $observe .= "\tEvent.observe('$source','$method',function(){" . $action . ";});\n";
+ $observe .= "\tEvent.observe($source_txt,'$method',function(){" . $action . ";});\n";
$observe .= "--></script>\n";
return $observe;
@@ -59,11 +68,20 @@ class Ajax {
$url = Config::get('ajax_url') . $action;
+ $non_quoted = array('document','window');
+
+ if (in_array($source,$non_quoted)) {
+ $source_txt = $source;
+ }
+ else {
+ $source_txt = "'$source'";
+ }
+
if ($post) {
- $ajax_string = "ajaxPost('$url','$post','$source')";
+ $ajax_string = "ajaxPost('$url','$post',$source_txt)";
}
else {
- $ajax_string = "ajaxPut('$url','$source')";
+ $ajax_string = "ajaxPut('$url',$source_txt)";
}
return $ajax_string;
@@ -112,5 +130,17 @@ class Ajax {
} // text
+ /**
+ * run
+ * This runs the specified action no questions asked
+ */
+ public static function run($action) {
+
+ echo "<script type=\"text/javascript\"><!--\n";
+ echo "$action";
+ echo "\n--></script>";
+
+ } // run
+
} // end Ajax class
?>
diff --git a/lib/class/metadata.class.php b/lib/class/metadata.class.php
index 01db6072..f5e80626 100644
--- a/lib/class/metadata.class.php
+++ b/lib/class/metadata.class.php
@@ -33,12 +33,49 @@ class metadata {
* constructor
* We don't use this, as its really a static class
*/
- private __construct() {
+ private function __construct() {
// Rien a faire
} // constructor
+ /**
+ * recommend_similar
+ * This takes the input and returns an array of objects construct_from_array()'d
+ */
+ public static function recommend_similar($type,$id,$limit='') {
+
+ // For now it's only mystrands
+ OpenStrands::set_auth_token(Config::get('mystrands_developer_key'));
+ $openstrands = new OpenStrands($GLOBALS['user']->prefs['mystrands_user'],$GLOBALS['user']->prefs['mystrands_pass']);
+
+ // Make sure auth worked
+ if (!$openstrands) { return false; }
+
+ switch ($type) {
+ case 'artist':
+ $artist = new Artist($id);
+ $seed = array('name'=>array($artist->name));
+ $results = $openstrands->recommend_artists($seed,$limit);
+ break;
+ }
+
+ foreach ($results as $item) {
+ switch ($type) {
+ case 'artist':
+ $data['name'] = $item['ArtistName'];
+ $data['uid'] = $item['__attributes']['ArtistID'];
+ $data['mystrands_url'] = $item['URI'];
+ $data['links'] = "<a target=\"_blank\" href=\"" . $item['URI'] . "\">" . get_user_icon('mystrands','','MyStrands Link') . "</a>";
+ $objects[] = Artist::construct_from_array($data);
+ break;
+ } // end switch on type
+ } // end foreach
+
+ return $objects;
+
+ } // recommend_similar
+
} // metadata
?>
diff --git a/lib/class/stats.class.php b/lib/class/stats.class.php
index 6add04c5..9847da39 100644
--- a/lib/class/stats.class.php
+++ b/lib/class/stats.class.php
@@ -179,7 +179,6 @@ class Stats {
while ($r = Dba::fetch_row($db_results)) {
$object = new $object_name($r['0']);
- $object->format();
$items[] = $object;
} // end while results
@@ -187,5 +186,5 @@ class Stats {
} // get_newest
-} //Stats class
+} // Stats class
?>
diff --git a/lib/general.lib.php b/lib/general.lib.php
index 5ce40831..408a4a99 100644
--- a/lib/general.lib.php
+++ b/lib/general.lib.php
@@ -489,18 +489,6 @@ function get_global_popular($type) {
} // get_global_popular
-/**
- * show_info_box
- * This shows the basic box that popular and newest stuff goes into
- */
-function show_info_box ($title, $type, $items) {
-
- $web_path = Config::get('web_path');
- $popular_threshold = Config::get('popular_threshold');
- require Config::get('prefix') . '/templates/show_box.inc.php';
-
-} // show_info_box
-
/*!
@function get_file_extension
@discussion returns all characters after the last "." in $filename
diff --git a/lib/ui.lib.php b/lib/ui.lib.php
index a6b03629..82cd0334 100644
--- a/lib/ui.lib.php
+++ b/lib/ui.lib.php
@@ -404,23 +404,6 @@ function show_all_popular() {
} // show_all_popular
/**
- * Show All Recent
- * This function shows all of the possible "Newest" tables. The number of newest is pulled from the users
- * popular threshold
- * @package Web Interface
- * @catagory Display
- * @author Karl Vollmer
- */
-function show_all_recent($limit='') {
-
- $artists = Stats::get_newest('artist',$limit);
- $albums = Stats::get_newest('album',$limit);
-
- require_once Config::get('prefix') . '/templates/show_all_recent.inc.php';
-
-} // show_all_recent
-
-/**
* show_local_catalog_info
* Shows the catalog stats
* @package Web INterface
@@ -968,7 +951,7 @@ function show_user_select($name,$selected='',$style='') {
* This function requires the top part of the box
* it takes title as an optional argument
*/
-function show_box_top($title='') {
+function show_box_top($title='',$class='') {
require Config::get('prefix') . '/templates/show_box_top.inc.php';