2021-12-14 18:32:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2019-05-28 16:59:38 +00:00
|
|
|
class NotesTheme extends Themelet
|
|
|
|
{
|
2021-03-14 23:43:50 +00:00
|
|
|
public function note_button(int $image_id): string
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
return '
|
2012-02-09 15:00:33 +00:00
|
|
|
<!-- <a href="#" id="addnotelink" >Add a note</a> -->
|
|
|
|
<form action="" method="">
|
|
|
|
<input type="button" id="addnote" value="Add Note">
|
|
|
|
<input type="hidden" name="image_id" value="'.$image_id.'">
|
|
|
|
</form>
|
|
|
|
';
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2021-03-14 23:43:50 +00:00
|
|
|
public function request_button(int $image_id): string
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
return make_form(make_link("note/add_request")) . '
|
2009-11-24 14:07:18 +00:00
|
|
|
<input id="noterequest" type="submit" value="Add Note Request">
|
|
|
|
<input type="hidden" name="image_id" value="'.$image_id.'">
|
|
|
|
</form>
|
|
|
|
';
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2021-03-14 23:43:50 +00:00
|
|
|
public function nuke_notes_button(int $image_id): string
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
return make_form(make_link("note/nuke_notes")) . '
|
2012-02-09 15:00:33 +00:00
|
|
|
<input id="noterequest" type="submit" value="Nuke Notes" onclick="return confirm_action(\'Are you sure?\')">
|
2009-11-24 14:07:18 +00:00
|
|
|
<input type="hidden" name="image_id" value="'.$image_id.'">
|
|
|
|
</form>
|
|
|
|
';
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2021-03-14 23:43:50 +00:00
|
|
|
public function nuke_requests_button(int $image_id): string
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
return make_form(make_link("note/nuke_requests")) . '
|
2009-11-24 14:07:18 +00:00
|
|
|
<input id="noterequest" type="submit" value="Nuke Requests" onclick="return confirm_action()">
|
|
|
|
<input type="hidden" name="image_id" value="'.$image_id.'">
|
|
|
|
</form>
|
|
|
|
';
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2016-05-18 13:36:50 +00:00
|
|
|
|
2021-03-14 23:43:50 +00:00
|
|
|
public function search_notes_page(Page $page): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{ //IN DEVELOPMENT, NOT FULLY WORKING
|
|
|
|
$html = '<form method="GET" action="'.make_link("post/list/note=").'">
|
2012-02-09 15:00:33 +00:00
|
|
|
<input placeholder="Search Notes" type="text" name="search"/>
|
2009-11-24 14:07:18 +00:00
|
|
|
<input type="submit" style="display: none;" value="Find"/>
|
|
|
|
</form>';
|
2016-05-18 13:36:50 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$page->set_title(html_escape("Search Note"));
|
|
|
|
$page->set_heading(html_escape("Search Note"));
|
|
|
|
$page->add_block(new Block("Search Note", $html, "main", 10));
|
|
|
|
}
|
|
|
|
|
|
|
|
// check action POST on form
|
2021-03-14 23:43:50 +00:00
|
|
|
public function display_note_system(Page $page, int $image_id, array $recovered_notes, bool $adminOptions): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
$base_href = get_base_href();
|
|
|
|
|
2020-10-24 22:46:32 +00:00
|
|
|
$page->add_html_header("<script defer src='$base_href/ext/notes/lib/jquery.imgnotes-1.0.min.js' type='text/javascript'></script>");
|
|
|
|
$page->add_html_header("<script defer src='$base_href/ext/notes/lib/jquery.imgareaselect-1.0.0-rc1.min.js' type='text/javascript'></script>");
|
2019-05-28 16:59:38 +00:00
|
|
|
$page->add_html_header("<link rel='stylesheet' type='text/css' href='$base_href/ext/notes/lib/jquery.imgnotes-1.0.min.css' />");
|
|
|
|
|
|
|
|
$to_json = [];
|
|
|
|
foreach ($recovered_notes as $note) {
|
|
|
|
$parsedNote = $note["note"];
|
|
|
|
$parsedNote = str_replace("\n", "\\n", $parsedNote);
|
|
|
|
$parsedNote = str_replace("\r", "\\r", $parsedNote);
|
|
|
|
|
|
|
|
$to_json[] = [
|
|
|
|
'x1' => $note["x1"],
|
|
|
|
'y1' => $note["y1"],
|
|
|
|
'height' => $note["height"],
|
|
|
|
'width' => $note["width"],
|
|
|
|
'note' => $parsedNote,
|
|
|
|
'note_id' => $note["id"],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
$html = "<script type='text/javascript'>notes = ".json_encode($to_json)."</script>";
|
|
|
|
|
|
|
|
$html .= "
|
2009-11-24 14:07:18 +00:00
|
|
|
<div id='noteform'>
|
2010-09-22 11:56:19 +00:00
|
|
|
".make_form(make_link("note/add_note"))."
|
2009-11-24 14:07:18 +00:00
|
|
|
<input type='hidden' name='image_id' value='".$image_id."' />
|
|
|
|
<input name='note_x1' type='hidden' value='' id='NoteX1' />
|
|
|
|
<input name='note_y1' type='hidden' value='' id='NoteY1' />
|
|
|
|
<input name='note_height' type='hidden' value='' id='NoteHeight' />
|
|
|
|
<input name='note_width' type='hidden' value='' id='NoteWidth' />
|
2016-05-18 13:36:50 +00:00
|
|
|
|
2009-11-24 14:07:18 +00:00
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<td colspan='2'>
|
|
|
|
<textarea name='note_text' id='NoteNote' ></textarea>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><input type='submit' value='Add Note' /></td>
|
|
|
|
<td><input type='button' value='Cancel' id='cancelnote' /></td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
2016-05-18 13:36:50 +00:00
|
|
|
|
2009-11-24 14:07:18 +00:00
|
|
|
</form>
|
|
|
|
</div>
|
2014-04-06 19:47:01 +00:00
|
|
|
<div id='noteEditForm'>
|
2010-09-22 11:56:19 +00:00
|
|
|
".make_form(make_link("note/edit_note"))."
|
2014-04-06 19:47:01 +00:00
|
|
|
<input type='hidden' name='image_id' value='".$image_id."' />
|
|
|
|
<input type='hidden' name='note_id' id='EditNoteID' value='' />
|
|
|
|
<input name='note_x1' type='hidden' value='' id='EditNoteX1' />
|
|
|
|
<input name='note_y1' type='hidden' value='' id='EditNoteY1' />
|
|
|
|
<input name='note_height' type='hidden' value='' id='EditNoteHeight' />
|
|
|
|
<input name='note_width' type='hidden' value='' id='EditNoteWidth' />
|
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<td colspan='2'>
|
|
|
|
<textarea name='note_text' id='EditNoteNote' ></textarea>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><input type='submit' value='Save Note' /></td>
|
|
|
|
<td><input type='button' value='Cancel' id='EditCancelNote' /></td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</form>";
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
if ($adminOptions) {
|
|
|
|
$html .= "
|
2010-09-22 11:56:19 +00:00
|
|
|
".make_form(make_link("note/delete_note"))."
|
2014-04-06 19:47:01 +00:00
|
|
|
<input type='hidden' name='image_id' value='".$image_id."' />
|
|
|
|
<input type='hidden' name='note_id' value='' id='DeleteNoteNoteID' />
|
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<td><input type='submit' value='Delete note' /></td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</form>
|
2009-11-24 14:07:18 +00:00
|
|
|
";
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2009-11-24 14:07:18 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$html .= "</div>";
|
2009-11-24 14:07:18 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$page->add_block(new Block(null, $html, "main", 1, 'note_system'));
|
|
|
|
}
|
2016-05-18 13:36:50 +00:00
|
|
|
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
public function display_note_list($images, $pageNumber, $totalPages)
|
|
|
|
{
|
|
|
|
global $page;
|
|
|
|
$pool_images = '';
|
|
|
|
foreach ($images as $pair) {
|
|
|
|
$image = $pair[0];
|
2009-11-24 14:07:18 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$thumb_html = $this->build_thumb_html($image);
|
2009-11-24 14:07:18 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$pool_images .= '<span class="thumb">'.
|
|
|
|
' <a href="$image_link">'.$thumb_html.'</a>'.
|
|
|
|
'</span>';
|
|
|
|
}
|
|
|
|
$this->display_paginator($page, "note/list", null, $pageNumber, $totalPages);
|
2016-05-18 13:36:50 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$page->set_title("Notes");
|
|
|
|
$page->set_heading("Notes");
|
|
|
|
$page->add_block(new Block("Notes", $pool_images, "main", 20));
|
|
|
|
}
|
2009-11-24 14:07:18 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
public function display_note_requests($images, $pageNumber, $totalPages)
|
|
|
|
{
|
|
|
|
global $page;
|
2016-05-18 13:36:50 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$pool_images = '';
|
|
|
|
foreach ($images as $pair) {
|
|
|
|
$image = $pair[0];
|
2016-05-18 13:36:50 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$thumb_html = $this->build_thumb_html($image);
|
2016-05-18 13:36:50 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$pool_images .= '<span class="thumb">'.
|
|
|
|
' <a href="$image_link">'.$thumb_html.'</a>'.
|
|
|
|
'</span>';
|
|
|
|
}
|
|
|
|
$this->display_paginator($page, "requests/list", null, $pageNumber, $totalPages);
|
2009-11-24 14:07:18 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$page->set_title("Note Requests");
|
|
|
|
$page->set_heading("Note Requests");
|
|
|
|
$page->add_block(new Block("Note Requests", $pool_images, "main", 20));
|
|
|
|
}
|
2009-11-24 14:07:18 +00:00
|
|
|
|
2021-03-14 23:43:50 +00:00
|
|
|
private function get_history(array $histories): string
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
global $user;
|
2016-05-18 13:36:50 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$html = "<table id='poolsList' class='zebra'>".
|
|
|
|
"<thead><tr>".
|
2020-10-26 15:22:03 +00:00
|
|
|
"<th>Post</th>".
|
2019-05-28 16:59:38 +00:00
|
|
|
"<th>Note</th>".
|
|
|
|
"<th>Body</th>".
|
|
|
|
"<th>Updater</th>".
|
|
|
|
"<th>Date</th>";
|
2009-11-24 14:07:18 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
if (!$user->is_anonymous()) {
|
|
|
|
$html .= "<th>Action</th>";
|
|
|
|
}
|
2016-05-18 13:36:50 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$html .= "</tr></thead>".
|
|
|
|
"<tbody>";
|
2014-03-30 12:26:48 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
foreach ($histories as $history) {
|
|
|
|
$image_link = "<a href='".make_link("post/view/".$history['image_id'])."'>".$history['image_id']."</a>";
|
|
|
|
$history_link = "<a href='".make_link("note/history/".$history['note_id'])."'>".$history['note_id'].".".$history['review_id']."</a>";
|
|
|
|
$user_link = "<a href='".make_link("user/".$history['user_name'])."'>".$history['user_name']."</a>";
|
|
|
|
$revert_link = "<a href='".make_link("note/revert/".$history['note_id']."/".$history['review_id'])."'>Revert</a>";
|
2014-03-30 12:26:48 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$html .= "<tr>".
|
|
|
|
"<td>".$image_link."</td>".
|
|
|
|
"<td>".$history_link."</td>".
|
|
|
|
"<td style='text-align:left;'>".$history['note']."</td>".
|
|
|
|
"<td>".$user_link."</td>".
|
|
|
|
"<td>".autodate($history['date'])."</td>";
|
2014-03-30 12:26:48 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
if (!$user->is_anonymous()) {
|
|
|
|
$html .= "<td>".$revert_link."</td>";
|
|
|
|
}
|
|
|
|
}
|
2014-03-30 12:26:48 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$html .= "</tr></tbody></table>";
|
2014-03-30 12:26:48 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
return $html;
|
|
|
|
}
|
2014-03-30 12:26:48 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
public function display_histories($histories, $pageNumber, $totalPages)
|
|
|
|
{
|
|
|
|
global $page;
|
2014-03-30 12:26:48 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$html = $this->get_history($histories);
|
2014-03-30 12:26:48 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$page->set_title("Note Updates");
|
|
|
|
$page->set_heading("Note Updates");
|
|
|
|
$page->add_block(new Block("Note Updates", $html, "main", 10));
|
2014-03-30 12:26:48 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages);
|
|
|
|
}
|
2014-03-30 12:26:48 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
public function display_history($histories, $pageNumber, $totalPages)
|
|
|
|
{
|
|
|
|
global $page;
|
|
|
|
|
|
|
|
$html = $this->get_history($histories);
|
|
|
|
|
|
|
|
$page->set_title("Note History");
|
|
|
|
$page->set_heading("Note History");
|
|
|
|
$page->add_block(new Block("Note History", $html, "main", 10));
|
2014-03-30 12:26:48 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages);
|
|
|
|
}
|
2019-08-02 20:05:49 +00:00
|
|
|
|
2021-03-14 23:43:50 +00:00
|
|
|
public function get_help_html(): string
|
2019-08-02 20:05:49 +00:00
|
|
|
{
|
2020-10-26 15:22:03 +00:00
|
|
|
return '<p>Search for posts with notes.</p>
|
2019-08-02 20:05:49 +00:00
|
|
|
<div class="command_example">
|
|
|
|
<pre>note=noted</pre>
|
2020-10-26 15:22:03 +00:00
|
|
|
<p>Returns posts with a note matching "noted".</p>
|
2020-10-24 22:46:32 +00:00
|
|
|
</div>
|
2019-08-02 20:05:49 +00:00
|
|
|
<div class="command_example">
|
|
|
|
<pre>notes>0</pre>
|
2020-10-26 15:22:03 +00:00
|
|
|
<p>Returns posts with 1 or more notes.</p>
|
2019-08-02 20:05:49 +00:00
|
|
|
</div>
|
|
|
|
<p>Can use <, <=, >, >=, or =.</p>
|
|
|
|
<div class="command_example">
|
|
|
|
<pre>notes_by=username</pre>
|
2020-10-26 15:22:03 +00:00
|
|
|
<p>Returns posts with note(s) by "username".</p>
|
2019-08-02 20:05:49 +00:00
|
|
|
</div>
|
|
|
|
<div class="command_example">
|
|
|
|
<pre>notes_by_user_id=123</pre>
|
2020-10-26 15:22:03 +00:00
|
|
|
<p>Returns posts with note(s) by user 123.</p>
|
2019-08-02 20:05:49 +00:00
|
|
|
</div>
|
|
|
|
';
|
|
|
|
}
|
2014-04-26 07:56:06 +00:00
|
|
|
}
|