source url editor
git-svn-id: file:///home/shish/svn/shimmie2/trunk@412 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
19ef368480
commit
f36c783868
@ -256,6 +256,11 @@ class Database {
|
||||
$this->execute("UPDATE tags SET count = count + 1 WHERE tag = ?", array($tag));
|
||||
}
|
||||
}
|
||||
|
||||
public function set_source($image_id, $source) {
|
||||
if(empty($source)) $source = null;
|
||||
$this->execute("UPDATE images SET source=? WHERE id=?", array($source, $image_id));
|
||||
}
|
||||
// }}}
|
||||
// images {{{
|
||||
public function get_images($start, $limit, $tags=array()) {
|
||||
|
17
core/events/sourceset.event.php
Normal file
17
core/events/sourceset.event.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/*
|
||||
* SourceSetEvent:
|
||||
* $image_id
|
||||
* $source
|
||||
*
|
||||
*/
|
||||
class SourceSetEvent extends Event {
|
||||
var $image_id;
|
||||
var $source;
|
||||
|
||||
public function SourceSetEvent($image_id, $source) {
|
||||
$this->image_id = $image_id;
|
||||
$this->source = $source;
|
||||
}
|
||||
}
|
||||
?>
|
@ -14,6 +14,7 @@ class TagEdit extends Extension {
|
||||
$i_image_id = int_escape($_POST['image_id']);
|
||||
$query = $_POST['query'];
|
||||
send_event(new TagSetEvent($i_image_id, $_POST['tags']));
|
||||
send_event(new SourceSetEvent($i_image_id, $_POST['source']));
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/$i_image_id", $query));
|
||||
}
|
||||
@ -32,15 +33,16 @@ class TagEdit extends Extension {
|
||||
}
|
||||
}
|
||||
|
||||
if(is_a($event, 'DisplayingImageEvent')) {
|
||||
$this->theme->display_editor($event->page, $event->image);
|
||||
}
|
||||
|
||||
if(is_a($event, 'TagSetEvent')) {
|
||||
global $database;
|
||||
$database->set_tags($event->image_id, $event->tags);
|
||||
}
|
||||
|
||||
if(is_a($event, 'SourceSetEvent')) {
|
||||
global $database;
|
||||
$database->set_source($event->image_id, $event->source);
|
||||
}
|
||||
|
||||
if(is_a($event, 'ImageDeletionEvent')) {
|
||||
global $database;
|
||||
$database->delete_tags_from_image($event->image->id);
|
||||
|
@ -1,40 +1,6 @@
|
||||
<?php
|
||||
|
||||
class TagEditTheme extends Themelet {
|
||||
/*
|
||||
* Display a form to edit tags for $image
|
||||
* The form should link to tag_edit/set, with the following set:
|
||||
* POST[image_id]
|
||||
* POST[query] = when redirecting to post/view, what the search string should be set to
|
||||
* POST[tags]
|
||||
*
|
||||
* Note $image->get_tag_list()
|
||||
*/
|
||||
public function display_editor($page, $image) {
|
||||
global $database;
|
||||
|
||||
if(isset($_GET['search'])) {
|
||||
$h_query = "search=".url_escape($_GET['search']);
|
||||
}
|
||||
else {
|
||||
$h_query = "";
|
||||
}
|
||||
|
||||
$h_tags = html_escape($image->get_tag_list());
|
||||
$i_image_id = int_escape($image->id);
|
||||
|
||||
$html = "
|
||||
<p><form action='".make_link("tag_edit/set")."' method='POST'>
|
||||
<input type='hidden' name='image_id' value='$i_image_id'>
|
||||
<input type='hidden' name='query' value='$h_query'>
|
||||
<input type='text' size='50' name='tags' value='$h_tags'>
|
||||
<input type='submit' value='Set'>
|
||||
</form>
|
||||
";
|
||||
|
||||
$page->add_block(new Block(null, $html, "main", 5));
|
||||
}
|
||||
|
||||
/*
|
||||
* Display a form which links to tag_edit/replace with POST[search]
|
||||
* and POST[replace] set appropriately
|
||||
|
@ -13,7 +13,6 @@ class ViewTheme extends Themelet {
|
||||
}
|
||||
|
||||
|
||||
|
||||
var $pin = null;
|
||||
|
||||
private function build_pin($image_id) {
|
||||
@ -82,8 +81,36 @@ class ViewTheme extends Themelet {
|
||||
$html .= " (<a href='http://$h_source'>source</a>)";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
global $config;
|
||||
global $user;
|
||||
if($config->get_bool("tag_edit_anon") || ($user->id != $config->get_int("anon_id"))) {
|
||||
$html .= " (<a href=\"javascript: toggle('imgdata')\">edit</a>)";
|
||||
|
||||
if(isset($_GET['search'])) {$h_query = "search=".url_escape($_GET['search']);}
|
||||
else {$h_query = "";}
|
||||
|
||||
$h_tags = html_escape($image->get_tag_list());
|
||||
$i_image_id = int_escape($image->id);
|
||||
|
||||
$html .= "
|
||||
<div id='imgdata'><form action='".make_link("tag_edit/set")."' method='POST'>
|
||||
<input type='hidden' name='image_id' value='$i_image_id'>
|
||||
<input type='hidden' name='query' value='$h_query'>
|
||||
<table style='width: 500px;'>
|
||||
<tr><td width='50px'>Tags</td><td width='300px'><input type='text' name='tags' value='$h_tags'></td></tr>
|
||||
<tr><td>Source</td><td><input type='text' name='source' value='$h_source'></td></tr>
|
||||
<tr><td> </td><td><input type='submit' value='Set'></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
";
|
||||
}
|
||||
|
||||
|
||||
$html .= "<p>".$this->build_pin($image->id);
|
||||
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
@ -50,10 +50,8 @@ TD {
|
||||
border-top: none;
|
||||
}
|
||||
#body SELECT {width: 150px;}
|
||||
/*
|
||||
TD INPUT {width: 100%;}
|
||||
TD SELECT {width: 100%;}
|
||||
*/
|
||||
TD>INPUT {width: 100%;}
|
||||
TD>SELECT {width: 100%;}
|
||||
|
||||
#footer {
|
||||
clear: both;
|
||||
|
@ -87,6 +87,31 @@ class ViewTheme extends Themelet {
|
||||
$html .= " (<a href='http://$h_source'>source</a>)";
|
||||
}
|
||||
}
|
||||
|
||||
global $config;
|
||||
global $user;
|
||||
if($config->get_bool("tag_edit_anon") || ($user->id != $config->get_int("anon_id"))) {
|
||||
$html .= " (<a href=\"javascript: toggle('imgdata')\">edit</a>)";
|
||||
|
||||
if(isset($_GET['search'])) {$h_query = "search=".url_escape($_GET['search']);}
|
||||
else {$h_query = "";}
|
||||
|
||||
$h_tags = html_escape($image->get_tag_list());
|
||||
$i_image_id = int_escape($image->id);
|
||||
|
||||
$html .= "
|
||||
<div id='imgdata'><form action='".make_link("tag_edit/set")."' method='POST'>
|
||||
<input type='hidden' name='image_id' value='$i_image_id'>
|
||||
<input type='hidden' name='query' value='$h_query'>
|
||||
<table style='width: 500px;'>
|
||||
<tr><td width='50px'>Tags</td><td width='300px'><input type='text' name='tags' value='$h_tags'></td></tr>
|
||||
<tr><td>Source</td><td><input type='text' name='source' value='$h_source'></td></tr>
|
||||
<tr><td> </td><td><input type='submit' value='Set'></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
";
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
@ -43,10 +43,8 @@ TD {
|
||||
background: #DDD;
|
||||
}
|
||||
#body SELECT {width: 150px;}
|
||||
/*
|
||||
TD INPUT {width: 100%;}
|
||||
TD SELECT {width: 100%;}
|
||||
*/
|
||||
TD>INPUT {width: 100%;}
|
||||
TD>SELECT {width: 100%;}
|
||||
|
||||
#footer {
|
||||
clear: both;
|
||||
|
Loading…
x
Reference in New Issue
Block a user