added author=<name> search tag.

This commit is contained in:
NaGeL 2012-01-17 22:43:16 +01:00
parent e46c22a228
commit 46776bf853

View File

@ -43,6 +43,14 @@ class Artists implements Extension {
if ($event instanceof PageRequestEvent) if ($event instanceof PageRequestEvent)
$this->handle_commands($event); $this->handle_commands($event);
if($event instanceof SearchTermParseEvent) {
$matches = array();
if(preg_match("/^author=(.*)$/", $event->term, $matches)) {
$char = $matches[1];
$event->add_querylet(new Querylet("Author = :author_char", array("author_char"=>$char)));
}
}
} }
public function try_install() { public function try_install() {
@ -130,7 +138,10 @@ class Artists implements Extension {
} }
$database->execute("UPDATE images SET author = ? WHERE id = ?" $database->execute("UPDATE images SET author = ? WHERE id = ?"
, array($artistName, $event->image->id)); , array(
$artistName
, $event->image->id
));
} }
public function handle_commands($event) public function handle_commands($event)
{ {
@ -457,7 +468,9 @@ class Artists implements Extension {
global $database; global $database;
$result = $database->get_one("SELECT COUNT(1) FROM artist_alias WHERE artist_id = ? AND alias = ?", array( $result = $database->get_one("SELECT COUNT(1) FROM artist_alias WHERE artist_id = ? AND alias = ?", array(
$artistID, $alias)); $artistID
, $alias
));
return ($result != 0); return ($result != 0);
} }
@ -617,7 +630,12 @@ class Artists implements Extension {
global $database; global $database;
$database->execute("UPDATE artists SET name = ?, notes = ?, updated = now(), user_id = ? WHERE id = ? " $database->execute("UPDATE artists SET name = ?, notes = ?, updated = now(), user_id = ? WHERE id = ? "
, array( $name, $notes, $userID, $artistID )); , array(
$name
, $notes
, $userID
, $artistID
));
// ALIAS MATCHING SECTION // ALIAS MATCHING SECTION
$i = 0; $i = 0;
@ -708,7 +726,11 @@ class Artists implements Extension {
global $database; global $database;
$database->execute("UPDATE artist_alias SET alias = ?, updated = now(), user_id = ? WHERE id = ? " $database->execute("UPDATE artist_alias SET alias = ?, updated = now(), user_id = ? WHERE id = ? "
, array( $alias, $userID, $aliasID )); , array(
$alias
, $userID
, $aliasID
));
} }
private function update_url() private function update_url()
@ -733,7 +755,11 @@ class Artists implements Extension {
global $database; global $database;
$database->execute("UPDATE artist_urls SET url = ?, updated = now(), user_id = ? WHERE id = ?" $database->execute("UPDATE artist_urls SET url = ?, updated = now(), user_id = ? WHERE id = ?"
, array( $url, $userID, $urlID )); , array(
$url
, $userID
, $urlID
));
} }
private function update_member() private function update_member()
@ -759,7 +785,11 @@ class Artists implements Extension {
global $database; global $database;
$database->execute("UPDATE artist_members SET name = ?, updated = now(), user_id = ? WHERE id = ?" $database->execute("UPDATE artist_members SET name = ?, updated = now(), user_id = ? WHERE id = ?"
, array( $memberName, $userID, $memberID )); , array(
$memberName
, $userID
, $memberID
));
} }
/* /*
@ -831,7 +861,11 @@ class Artists implements Extension {
(user_id, name, notes, created, updated) (user_id, name, notes, created, updated)
VALUES VALUES
(?, ?, ?, now(), now())", (?, ?, ?, now(), now())",
array( $user->id, $name, $notes )); array(
$user->id
, $name
, $notes
));
$result = $database->get_row("SELECT LAST_INSERT_ID() AS artistID", array()); $result = $database->get_row("SELECT LAST_INSERT_ID() AS artistID", array());
@ -845,7 +879,9 @@ class Artists implements Extension {
global $database; global $database;
$result = $database->get_one("SELECT COUNT(1) FROM artists WHERE name = ?" $result = $database->get_one("SELECT COUNT(1) FROM artists WHERE name = ?"
, array($name)); , array(
$name
));
return ($result != 0); return ($result != 0);
} }
@ -909,7 +945,9 @@ class Artists implements Extension {
private function get_artist_id($name){ private function get_artist_id($name){
global $database; global $database;
$artistID = $database->get_row("SELECT id FROM artists WHERE name = ?" $artistID = $database->get_row("SELECT id FROM artists WHERE name = ?"
, array( $name )); , array(
$name
));
return $artistID['id']; return $artistID['id'];
} }
@ -918,7 +956,9 @@ class Artists implements Extension {
global $database; global $database;
$artistID = $database->get_row("SELECT artist_id FROM artist_alias WHERE alias = ?" $artistID = $database->get_row("SELECT artist_id FROM artist_alias WHERE alias = ?"
, array( $alias )); , array(
$alias
));
return $artistID["artist_id"]; return $artistID["artist_id"];
} }
@ -932,7 +972,9 @@ class Artists implements Extension {
global $database; global $database;
$database->execute("DELETE FROM artists WHERE id = ? " $database->execute("DELETE FROM artists WHERE id = ? "
, array( $artistID )); , array(
$artistID
));
} }
@ -1056,7 +1098,11 @@ class Artists implements Extension {
global $database; global $database;
$database->execute("INSERT INTO artist_urls (artist_id, created, updated, url, user_id) VALUES (?, now(), now(), ?, ?)" $database->execute("INSERT INTO artist_urls (artist_id, created, updated, url, user_id) VALUES (?, now(), now(), ?, ?)"
, array( $artistID, $url, $userID )); , array(
$artistID
, $url
, $userID
));
} }
private function add_alias() private function add_alias()
@ -1086,7 +1132,11 @@ class Artists implements Extension {
global $database; global $database;
$database->execute("INSERT INTO artist_alias (artist_id, created, updated, alias, user_id) VALUES (?, now(), now(), ?, ?)" $database->execute("INSERT INTO artist_alias (artist_id, created, updated, alias, user_id) VALUES (?, now(), now(), ?, ?)"
, array( $artistID, $alias, $userID )); , array(
$artistID
, $alias
, $userID
));
} }
private function add_members() private function add_members()
@ -1115,7 +1165,11 @@ class Artists implements Extension {
global $database; global $database;
$database->execute("INSERT INTO artist_members (artist_id, name, created, updated, user_id) VALUES (?, ?, now(), now(), ?)" $database->execute("INSERT INTO artist_members (artist_id, name, created, updated, user_id) VALUES (?, ?, now(), now(), ?)"
, array( $artistID, $member, $userID )); , array(
$artistID
, $member
, $userID
));
} }
private function member_exists($artistID, $member) private function member_exists($artistID, $member)
@ -1125,7 +1179,10 @@ class Artists implements Extension {
global $database; global $database;
$result = $database->get_one("SELECT COUNT(1) FROM artist_members WHERE artist_id = ? AND name = ?" $result = $database->get_one("SELECT COUNT(1) FROM artist_members WHERE artist_id = ? AND name = ?"
, array( $artistID, $member )); , array(
$artistID
, $member
));
return ($result != 0); return ($result != 0);
} }
@ -1136,7 +1193,10 @@ class Artists implements Extension {
global $database; global $database;
$result = $database->get_one("SELECT COUNT(1) FROM artist_urls WHERE artist_id = ? AND url = ?" $result = $database->get_one("SELECT COUNT(1) FROM artist_urls WHERE artist_id = ? AND url = ?"
, array( $artistID, $url )); , array(
$artistID
, $url
));
return ($result != 0); return ($result != 0);
} }