diff options
Diffstat (limited to 'lib/class')
-rw-r--r-- | lib/class/ajax.class.php | 36 | ||||
-rw-r--r-- | lib/class/metadata.class.php | 39 | ||||
-rw-r--r-- | lib/class/stats.class.php | 3 |
3 files changed, 72 insertions, 6 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 ?> |