import of submitted notes extension
This commit is contained in:
parent
325ecb5cbb
commit
9145d7460c
3408
contrib/notes/jquery.js
vendored
Normal file
3408
contrib/notes/jquery.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
386
contrib/notes/jquery.qimgareaselect-0.4.js
Normal file
386
contrib/notes/jquery.qimgareaselect-0.4.js
Normal file
@ -0,0 +1,386 @@
|
||||
/*
|
||||
* imgAreaSelect jQuery plugin
|
||||
* version 0.4
|
||||
*
|
||||
* Copyright (c) 2008 Michal Wojciechowski (odyniec.net)
|
||||
*
|
||||
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
||||
* and GPL (GPL-LICENSE.txt) licenses.
|
||||
*
|
||||
* http://odyniec.net/projects/imgareaselect/
|
||||
*
|
||||
*/
|
||||
|
||||
jQuery.imgAreaSelect = function (img, options) {
|
||||
var $area = jQuery('<div></div>'),
|
||||
$border1 = jQuery('<div></div>'),
|
||||
$border2 = jQuery('<div></div>'),
|
||||
$outLeft = jQuery('<div></div>'),
|
||||
$outTop = jQuery('<div></div>'),
|
||||
$outRight = jQuery('<div></div>'),
|
||||
$outBottom = jQuery('<div></div>'),
|
||||
imgOfs, imgWidth, imgHeight,
|
||||
zIndex = 0, fixed = false,
|
||||
startX, startY, moveX, moveY,
|
||||
resizeMargin = 10, resize = [ ], V = 0, H = 1,
|
||||
d, aspectRatio,
|
||||
x1, x2, y1, y2, x, y,
|
||||
selection = { x1: 0, y1: 0, x2: 0, y2: 0, width: 0, height: 0 };
|
||||
|
||||
var $a = $area.add($border1).add($border2);
|
||||
var $o = $outLeft.add($outTop).add($outRight).add($outBottom);
|
||||
|
||||
function getZIndex()
|
||||
{
|
||||
var $p = jQuery(img);
|
||||
|
||||
while ($p.length && !$p.is('body')) {
|
||||
if (!isNaN($p.css('z-index')) && $p.css('z-index') > zIndex)
|
||||
zIndex = $p.css('z-index');
|
||||
if ($p.css('position') == 'fixed') fixed = true;
|
||||
|
||||
$p = $p.parent();
|
||||
}
|
||||
}
|
||||
|
||||
function areaMouseMove(event)
|
||||
{
|
||||
x = event.pageX - selection.x1 - imgOfs.left;
|
||||
y = event.pageY - selection.y1 - imgOfs.top;
|
||||
|
||||
resize = [ ];
|
||||
|
||||
if (options.resizable) {
|
||||
if (y <= resizeMargin)
|
||||
resize[V] = 'n';
|
||||
else if (y >= selection.height - resizeMargin)
|
||||
resize[V] = 's';
|
||||
if (x <= resizeMargin)
|
||||
resize[H] = 'w';
|
||||
else if (x >= selection.width - resizeMargin)
|
||||
resize[H] = 'e';
|
||||
}
|
||||
|
||||
$border2.css('cursor', resize.length ? resize.join('') + '-resize' :
|
||||
options.movable ? 'move' : '');
|
||||
}
|
||||
|
||||
function areaMouseDown(event)
|
||||
{
|
||||
if (event.which != 1) return false;
|
||||
|
||||
if (options.resizable && resize.length > 0) {
|
||||
jQuery('body').css('cursor', resize.join('') + '-resize');
|
||||
|
||||
x1 = (resize[H] == 'w' ? selection.x2 : selection.x1) + imgOfs.left;
|
||||
y1 = (resize[V] == 'n' ? selection.y2 : selection.y1) + imgOfs.top;
|
||||
|
||||
jQuery(document).mousemove(selectingMouseMove);
|
||||
$border2.unbind('mousemove', areaMouseMove);
|
||||
|
||||
jQuery(document).one('mouseup', function () {
|
||||
resize = [ ];
|
||||
|
||||
jQuery('body').css('cursor', '');
|
||||
|
||||
if (options.autoHide)
|
||||
$a.hide();
|
||||
|
||||
options.onSelectEnd(img, selection);
|
||||
|
||||
jQuery(document).unbind('mousemove', selectingMouseMove);
|
||||
$border2.mousemove(areaMouseMove);
|
||||
});
|
||||
}
|
||||
else if (options.movable) {
|
||||
moveX = selection.x1 + imgOfs.left;
|
||||
moveY = selection.y1 + imgOfs.top;
|
||||
startX = event.pageX;
|
||||
startY = event.pageY;
|
||||
|
||||
jQuery(document)
|
||||
.mousemove(movingMouseMove)
|
||||
.one('mouseup', function () {
|
||||
options.onSelectEnd(img, selection);
|
||||
|
||||
jQuery(document).unbind('mousemove', movingMouseMove);
|
||||
});
|
||||
}
|
||||
else
|
||||
jQuery(img).mousedown(event);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function aspectRatioXY()
|
||||
{
|
||||
x2 = Math.max(imgOfs.left, Math.min(imgOfs.left + imgWidth,
|
||||
x1 + Math.abs(y2 - y1) * aspectRatio * (x2 > x1 ? 1 : -1)));
|
||||
y2 = Math.round(Math.max(imgOfs.top, Math.min(imgOfs.top + imgHeight,
|
||||
y1 + Math.abs(x2 - x1) / aspectRatio * (y2 > y1 ? 1 : -1))));
|
||||
x2 = Math.round(x2);
|
||||
}
|
||||
|
||||
function aspectRatioYX()
|
||||
{
|
||||
y2 = Math.max(imgOfs.top, Math.min(imgOfs.top + imgHeight,
|
||||
y1 + Math.abs(x2 - x1) / aspectRatio * (y2 > y1 ? 1 : -1)));
|
||||
x2 = Math.round(Math.max(imgOfs.left, Math.min(imgOfs.left + imgWidth,
|
||||
x1 + Math.abs(y2 - y1) * aspectRatio * (x2 > x1 ? 1 : -1))));
|
||||
y2 = Math.round(y2);
|
||||
}
|
||||
|
||||
function selectingMouseMove(event)
|
||||
{
|
||||
x2 = !resize.length || resize[H] || aspectRatio ? event.pageX : selection.x2 + imgOfs.left;
|
||||
y2 = !resize.length || resize[V] || aspectRatio ? event.pageY : selection.y2 + imgOfs.top;
|
||||
|
||||
if (options.minWidth && Math.abs(x2 - x1) < options.minWidth) {
|
||||
x2 = x1 - options.minWidth * (x2 < x1 ? 1 : -1);
|
||||
|
||||
if (x2 < imgOfs.left)
|
||||
x1 = imgOfs.left + options.minWidth;
|
||||
else if (x2 > imgOfs.left + imgWidth)
|
||||
x1 = imgOfs.left + imgWidth - options.minWidth;
|
||||
}
|
||||
|
||||
if (options.minHeight && Math.abs(y2 - y1) < options.minHeight) {
|
||||
y2 = y1 - options.minHeight * (y2 < y1 ? 1 : -1);
|
||||
|
||||
if (y2 < imgOfs.top)
|
||||
y1 = imgOfs.top + options.minHeight;
|
||||
else if (y2 > imgOfs.top + imgHeight)
|
||||
y1 = imgOfs.top + imgHeight - options.minHeight;
|
||||
}
|
||||
|
||||
x2 = Math.max(imgOfs.left, Math.min(x2, imgOfs.left + imgWidth));
|
||||
y2 = Math.max(imgOfs.top, Math.min(y2, imgOfs.top + imgHeight));
|
||||
|
||||
if (aspectRatio)
|
||||
if (Math.abs(x2 - x1) / aspectRatio > Math.abs(y2 - y1))
|
||||
aspectRatioYX();
|
||||
else
|
||||
aspectRatioXY();
|
||||
|
||||
if (options.maxWidth && Math.abs(x2 - x1) > options.maxWidth) {
|
||||
x2 = x1 - options.maxWidth * (x2 < x1 ? 1 : -1);
|
||||
if (aspectRatio) aspectRatioYX();
|
||||
}
|
||||
|
||||
if (options.maxHeight && Math.abs(y2 - y1) > options.maxHeight) {
|
||||
y2 = y1 - options.maxHeight * (y2 < y1 ? 1 : -1);
|
||||
if (aspectRatio) aspectRatioXY();
|
||||
}
|
||||
|
||||
selection.x1 = Math.min(x1, x2) - imgOfs.left;
|
||||
selection.x2 = Math.max(x1, x2) - imgOfs.left;
|
||||
selection.y1 = Math.min(y1, y2) - imgOfs.top;
|
||||
selection.y2 = Math.max(y1, y2) - imgOfs.top;
|
||||
selection.width = Math.abs(x2 - x1);
|
||||
selection.height = Math.abs(y2 - y1);
|
||||
|
||||
$a.css({
|
||||
left: (selection.x1 + imgOfs.left) + 'px',
|
||||
top: (selection.y1 + imgOfs.top) + 'px',
|
||||
width: Math.max(selection.width - options.borderWidth * 2, 0) + 'px',
|
||||
height: Math.max(selection.height - options.borderWidth * 2, 0) + 'px'
|
||||
});
|
||||
$outLeft.css({ width: selection.x1 + 'px' });
|
||||
$outTop.css({ left: imgOfs.left + selection.x1 + 'px', width: selection.width + 'px',
|
||||
height: selection.y1 + 'px' });
|
||||
$outRight.css({ left: imgOfs.left + selection.x2 + 'px', width: imgWidth - selection.x2 + 'px' });
|
||||
$outBottom.css({ left: imgOfs.left + selection.x1 + 'px', top: imgOfs.top + selection.y2 + 'px',
|
||||
width: selection.width + 'px', height: imgHeight - selection.y2 + 'px' });
|
||||
|
||||
options.onSelectChange(img, selection);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function movingMouseMove(event)
|
||||
{
|
||||
x1 = Math.max(imgOfs.left, Math.min(moveX + event.pageX - startX,
|
||||
imgOfs.left + imgWidth - selection.width));
|
||||
y1 = Math.max(imgOfs.top, Math.min(moveY + event.pageY - startY,
|
||||
imgOfs.top + imgHeight - selection.height));
|
||||
x2 = x1 + selection.width;
|
||||
y2 = y1 + selection.height;
|
||||
|
||||
selection.x1 = x1 - imgOfs.left;
|
||||
selection.y1 = y1 - imgOfs.top;
|
||||
selection.x2 = x2 - imgOfs.left;
|
||||
selection.y2 = y2 - imgOfs.top;
|
||||
|
||||
$a.css({
|
||||
left: x1 + 'px',
|
||||
top: y1 + 'px',
|
||||
width: Math.max(x2 - x1 - options.borderWidth * 2, 0) + 'px',
|
||||
height: Math.max(y2 - y1 - options.borderWidth * 2, 0) + 'px'
|
||||
});
|
||||
$outLeft.css({ width: selection.x1 + 'px' });
|
||||
$outTop.css({ left: imgOfs.left + selection.x1 + 'px', width: selection.width + 'px',
|
||||
height: selection.y1 + 'px' });
|
||||
$outRight.css({ left: imgOfs.left + selection.x2 + 'px', width: imgWidth - selection.x2 + 'px' });
|
||||
$outBottom.css({ left: imgOfs.left + selection.x1 + 'px', top: imgOfs.top + selection.y2 + 'px',
|
||||
width: selection.width + 'px', height: imgHeight - selection.y2 + 'px' });
|
||||
|
||||
options.onSelectChange(img, selection);
|
||||
event.preventDefault();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function imgMouseDown(event)
|
||||
{
|
||||
if (event.which != 1) return false;
|
||||
|
||||
startX = x1 = event.pageX;
|
||||
startY = y1 = event.pageY;
|
||||
|
||||
resize = [ ];
|
||||
|
||||
$a.css({ width: '0px', height: '0px', left: x1, top: y1 });
|
||||
$outLeft.css({ width: x1 - imgOfs.left + 'px' });
|
||||
$outTop.css({ left: x1 + 'px', height: y1 - imgOfs.top + 'px', width: '0px' });
|
||||
$outRight.css({ left: x1 + 'px', width: imgOfs.left + imgWidth - x1 + 'px' });
|
||||
$outBottom.css({ left: x1 + 'px', top: y1 + 'px', width: '0px', height: imgOfs.top + imgHeight - y1 + 'px' });
|
||||
$a.add($o).show();
|
||||
|
||||
jQuery(document).mousemove(selectingMouseMove);
|
||||
$border2.unbind('mousemove', areaMouseMove);
|
||||
|
||||
selection.x1 = selection.x2 = x1 - imgOfs.left;
|
||||
selection.y1 = selection.y2 = y1 - imgOfs.top;
|
||||
|
||||
options.onSelectStart(img, selection);
|
||||
|
||||
jQuery(document).one('mouseup', function () {
|
||||
if (options.autoHide)
|
||||
$a.add($o).hide();
|
||||
|
||||
options.onSelectEnd(img, selection);
|
||||
|
||||
jQuery(document).unbind('mousemove', selectingMouseMove);
|
||||
$border2.mousemove(areaMouseMove);
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
this.setOptions = function(newOptions)
|
||||
{
|
||||
|
||||
options = jQuery.extend(options, newOptions);
|
||||
|
||||
if (newOptions.x1 != null) {
|
||||
x1 = (selection.x1 = newOptions.x1) + imgOfs.left;
|
||||
y1 = (selection.y1 = newOptions.y1) + imgOfs.top;
|
||||
x2 = (selection.x2 = newOptions.x2) + imgOfs.left;
|
||||
y2 = (selection.y2 = newOptions.y2) + imgOfs.top;
|
||||
selection.width = x2 - x1;
|
||||
selection.height = y2 - y1;
|
||||
|
||||
$a.css({
|
||||
left: x1 + 'px',
|
||||
top: y1 + 'px',
|
||||
width: Math.max(x2 - x1 - options.borderWidth * 2, 0) + 'px',
|
||||
height: Math.max(y2 - y1 - options.borderWidth * 2, 0) + 'px'
|
||||
});
|
||||
$outLeft.css({ width: selection.x1 + 'px' });
|
||||
$outTop.css({ left: x1 + 'px', width: selection.width + 'px', height: selection.y1 + 'px' });
|
||||
$outRight.css({ left: x2 + 'px', width: (imgWidth - selection.x2) + 'px' });
|
||||
$outBottom.css({ left: x1 + 'px', top: y2 + 'px', width: selection.width + 'px', height: (imgHeight - selection.y2) + 'px' });
|
||||
$a.add($o).show();
|
||||
|
||||
options.onSelectChange(img, selection);
|
||||
}
|
||||
|
||||
if (newOptions.hide) {
|
||||
$a.hide();
|
||||
$outLeft.hide();
|
||||
$outRight.hide();
|
||||
$outTop.hide();
|
||||
$outBottom.hide();
|
||||
} else if (newOptions.show) {
|
||||
$a.show();
|
||||
$outLeft.hide();
|
||||
$outRight.hide();
|
||||
$outTop.hide();
|
||||
$outBottom.hide();
|
||||
}
|
||||
|
||||
$a.css({ borderWidth: options.borderWidth + 'px' });
|
||||
$area.css({ backgroundColor: options.selectionColor, opacity: options.selectionOpacity });
|
||||
$border1.css({ borderStyle: 'solid', borderColor: options.borderColor1 });
|
||||
$border2.css({ borderStyle: 'dashed', borderColor: options.borderColor2 });
|
||||
$o.css({ opacity: options.outerOpacity, backgroundColor: options.outerColor });
|
||||
|
||||
aspectRatio = options.aspectRatio && (d = options.aspectRatio.split(/:/)) ?
|
||||
d[0] / d[1] : null;
|
||||
|
||||
if (options.disable || options.enable === false) {
|
||||
$a.unbind('mousemove', areaMouseMove).unbind('mousedown', areaMouseDown);
|
||||
jQuery(img).add($o).unbind('mousedown', imgMouseDown);
|
||||
}
|
||||
else if (options.enable || options.disable === false) {
|
||||
if (options.resizable || options.movable)
|
||||
$a.mousemove(areaMouseMove).mousedown(areaMouseDown);
|
||||
|
||||
//jQuery(img).add($o).mousedown(imgMouseDown);
|
||||
}
|
||||
|
||||
options.enable = options.disable = undefined;
|
||||
};
|
||||
|
||||
imgWidth = jQuery(img).width();
|
||||
imgHeight = jQuery(img).height();
|
||||
imgOfs = jQuery(img).offset();
|
||||
|
||||
if (jQuery.browser.msie)
|
||||
jQuery(img).attr('unselectable', 'on');
|
||||
|
||||
getZIndex();
|
||||
|
||||
$a.add($o).css({ display: 'none', position: fixed ? 'fixed' : 'absolute', overflow: 'hidden', zIndex: zIndex });
|
||||
$area.css({ borderStyle: 'solid' });
|
||||
$outLeft.css({ left: imgOfs.left + 'px', top: imgOfs.top + 'px', height: imgHeight + 'px' });
|
||||
$outTop.css({ top: imgOfs.top + 'px' });
|
||||
$outRight.css({ top: imgOfs.top + 'px', height: imgHeight + 'px' });
|
||||
|
||||
jQuery('body').append($o);
|
||||
jQuery('body').append($a);
|
||||
|
||||
initOptions = {
|
||||
borderColor1: '#000',
|
||||
borderColor2: '#fff',
|
||||
borderWidth: 1,
|
||||
movable: true,
|
||||
resizable: true,
|
||||
selectionColor: '#fff',
|
||||
selectionOpacity: 0.2,
|
||||
outerColor: '#000',
|
||||
outerOpacity: 0.2,
|
||||
onSelectStart: function () {},
|
||||
onSelectChange: function () {},
|
||||
onSelectEnd: function () {}
|
||||
};
|
||||
|
||||
options = jQuery.extend(initOptions, options);
|
||||
this.setOptions(options);
|
||||
};
|
||||
|
||||
jQuery.fn.imgAreaSelect = function (options) {
|
||||
options = options || {};
|
||||
|
||||
this.each(function () {
|
||||
if (jQuery(this).data('imgAreaSelect')){
|
||||
jQuery(this).data('imgAreaSelect').setOptions(options);
|
||||
} else {
|
||||
if (options.enable === undefined && options.disable === undefined)
|
||||
options.enable = true;
|
||||
jQuery(this).data('imgAreaSelect', new jQuery.imgAreaSelect(this, options));
|
||||
|
||||
}
|
||||
});
|
||||
return this;
|
||||
};
|
91
contrib/notes/jquery.rimgnotes-0.2.js
Normal file
91
contrib/notes/jquery.rimgnotes-0.2.js
Normal file
@ -0,0 +1,91 @@
|
||||
/**
|
||||
* imgnotes jQuery plugin
|
||||
* version 0.1
|
||||
*
|
||||
* Copyright (c) 2008 Dr. Tarique Sani <tarique@sanisoft.com>
|
||||
*
|
||||
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
||||
* and GPL (GPL-LICENSE.txt) licenses.
|
||||
*
|
||||
* @URL http://www.sanisoft.com/blog/2008/05/26/img-notes-jquery-plugin/
|
||||
* @Example example.html
|
||||
*
|
||||
**/
|
||||
|
||||
//Wrap in a closure
|
||||
(function($) {
|
||||
|
||||
$.fn.imgNotes = function(n) {
|
||||
|
||||
if(undefined != n){
|
||||
notes = n;
|
||||
}
|
||||
|
||||
image = this;
|
||||
|
||||
imgOffset = $(image).offset();
|
||||
|
||||
$(notes).each(function(){
|
||||
appendnote(this);
|
||||
});
|
||||
|
||||
$(image).hover(
|
||||
function(){
|
||||
$('.note').show();
|
||||
},
|
||||
function(){
|
||||
$('.note').hide();
|
||||
}
|
||||
);
|
||||
|
||||
addnoteevents();
|
||||
|
||||
$(window).resize(function () {
|
||||
$('.note').remove();
|
||||
|
||||
imgOffset = $(image).offset();
|
||||
|
||||
$(notes).each(function(){
|
||||
appendnote(this);
|
||||
});
|
||||
|
||||
addnoteevents();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function addnoteevents() {
|
||||
$('.note').hover(
|
||||
function(){
|
||||
$('.note').show();
|
||||
$(this).next('.notep').show();
|
||||
$(this).next('.notep').css("z-index", 10000);
|
||||
},
|
||||
function(){
|
||||
$('.note').show();
|
||||
$(this).next('.notep').hide();
|
||||
$(this).next('.notep').css("z-index", 0);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function appendnote(note_data){
|
||||
|
||||
note_left = parseInt(imgOffset.left) + parseInt(note_data.x1);
|
||||
note_top = parseInt(imgOffset.top) + parseInt(note_data.y1);
|
||||
note_p_top = note_top + parseInt(note_data.height)+5;
|
||||
|
||||
note_area_div = $("<div class='note'></div>").css({ left: note_left + 'px', top: note_top + 'px', width: note_data.width + 'px', height: note_data.height + 'px' });
|
||||
note_text_div = $('<div class="notep" >'+ note_data.note.replace(/([^>]?)\n/g, '$1<br />\n') + '</div>').css({ left: note_left + 'px', top: note_p_top + 'px'});
|
||||
//added by alpha
|
||||
note_id_div = $('<div class="noteID" >'+note_data.note_id+'</div>').css({ left: note_left + 'px', top: note_p_top + 'px'}).hide();
|
||||
|
||||
$('body').append(note_area_div);
|
||||
$('body').append(note_text_div);
|
||||
//added by alpha
|
||||
$('body').append(note_id_div);
|
||||
}
|
||||
|
||||
// End the closure
|
||||
})(jQuery);
|
610
contrib/notes/main.php
Normal file
610
contrib/notes/main.php
Normal file
@ -0,0 +1,610 @@
|
||||
<?php
|
||||
/**
|
||||
* Name: [Beta] Notes
|
||||
* Author: Sein Kraft <mail@seinkraft.info>
|
||||
* License: GPLv2
|
||||
* Description: Annotate images
|
||||
* Documentation:
|
||||
*/
|
||||
|
||||
class Notes extends SimpleExtension {
|
||||
public function onInitExt($event) {
|
||||
global $config, $database;
|
||||
|
||||
// shortcut to latest
|
||||
if ($config->get_int("ext_notes_version") < 1) {
|
||||
$database->Execute("ALTER TABLE images ADD COLUMN notes INTEGER NOT NULL DEFAULT 0");
|
||||
$database->create_table("notes", "
|
||||
id SCORE_AIPK,
|
||||
enable INTEGER NOT NULL,
|
||||
image_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
user_ip CHAR(15) NOT NULL,
|
||||
date DATETIME NOT NULL,
|
||||
x1 INTEGER NOT NULL,
|
||||
y1 INTEGER NOT NULL,
|
||||
height INTEGER NOT NULL,
|
||||
width INTEGER NOT NULL,
|
||||
note TEXT NOT NULL,
|
||||
INDEX (image_id),
|
||||
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE
|
||||
");
|
||||
|
||||
$database->create_table("note_request", "
|
||||
id SCORE_AIPK,
|
||||
image_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
date DATETIME NOT NULL,
|
||||
INDEX (image_id),
|
||||
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE
|
||||
");
|
||||
|
||||
$database->create_table("note_histories", "
|
||||
id SCORE_AIPK,
|
||||
note_enable INTEGER NOT NULL,
|
||||
note_id INTEGER NOT NULL,
|
||||
review_id INTEGER NOT NULL,
|
||||
image_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
user_ip CHAR(15) NOT NULL,
|
||||
date DATETIME NOT NULL,
|
||||
x1 INTEGER NOT NULL,
|
||||
y1 INTEGER NOT NULL,
|
||||
height INTEGER NOT NULL,
|
||||
width INTEGER NOT NULL,
|
||||
note TEXT NOT NULL,
|
||||
INDEX (image_id),
|
||||
FOREIGN KEY (note_id) REFERENCES notes(id) ON DELETE CASCADE
|
||||
");
|
||||
|
||||
$config->set_int("notesNotesPerPage", 20);
|
||||
$config->set_int("notesRequestsPerPage", 20);
|
||||
$config->set_int("notesHistoriesPerPage", 20);
|
||||
|
||||
$config->set_int("ext_notes_version", 1);
|
||||
log_info("notes", "extension installed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function onPageRequest($event) {
|
||||
global $page, $user;
|
||||
if($event->page_matches("note")) {
|
||||
|
||||
switch($event->get_arg(0)) {
|
||||
case "list": //index
|
||||
{
|
||||
$this->get_notes_list($event); // This should show images like post/list but i don't know how do that.
|
||||
break;
|
||||
}
|
||||
case "requests": // The same as post/list but only for note_request table.
|
||||
{
|
||||
$this->get_notes_requests($event); // This should shouw images like post/list but i don't know how do that.
|
||||
break;
|
||||
}
|
||||
case "search":
|
||||
{
|
||||
if(!$user->is_anonymous())
|
||||
$this->theme->search_notes_page($page);
|
||||
break;
|
||||
}
|
||||
case "updated": //Thinking how biuld this function.
|
||||
{
|
||||
$this->get_histories($event);
|
||||
break;
|
||||
}
|
||||
case "history": //Thinking how biuld this function.
|
||||
{
|
||||
$this->get_history($event);
|
||||
break;
|
||||
}
|
||||
case "revert":
|
||||
{
|
||||
$noteID = $event->get_arg(1);
|
||||
$reviewID = $event->get_arg(2);
|
||||
if(!$user->is_anonymous()){
|
||||
$this->revert_history($noteID, $reviewID);
|
||||
}
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("note/updated"));
|
||||
break;
|
||||
}
|
||||
case "add_note":
|
||||
{
|
||||
if(!$user->is_anonymous())
|
||||
$this->add_new_note();
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/".$_POST["image_id"]));
|
||||
break;
|
||||
}
|
||||
case "add_request":
|
||||
{
|
||||
if(!$user->is_anonymous())
|
||||
$this->add_note_request();
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/".$_POST["image_id"]));
|
||||
break;
|
||||
}
|
||||
case "nuke_notes":
|
||||
{
|
||||
if($user->is_admin())
|
||||
$this->nuke_notes();
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/".$_POST["image_id"]));
|
||||
break;
|
||||
}
|
||||
case "nuke_requests":
|
||||
{
|
||||
if($user->is_admin())
|
||||
$this->nuke_requests();
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/".$_POST["image_id"]));
|
||||
break;
|
||||
}
|
||||
case "edit_note":
|
||||
{
|
||||
if (!$user->is_anonymous()) {
|
||||
$this->update_note();
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/".$_POST["image_id"]));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "delete_note":
|
||||
{
|
||||
if ($user->is_admin()) {
|
||||
$this->delete_note();
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/".$_POST["image_id"]));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("note/list"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE LOAD THE NOTES IN THE IMAGE
|
||||
*/
|
||||
public function onDisplayingImage($event) {
|
||||
global $page, $user;
|
||||
|
||||
//display form on image event
|
||||
$notes = $this->get_notes($event->image->id);
|
||||
$this->theme->display_note_system($page, $event->image->id, $notes, $user->is_admin());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE ADD THE BUTTONS ON SIDEBAR
|
||||
*/
|
||||
public function onImageAdminBlockBuilding($event) {
|
||||
global $user;
|
||||
if(!$user->is_anonymous()) {
|
||||
$event->add_part($this->theme->note_button($event->image->id));
|
||||
$event->add_part($this->theme->request_button($event->image->id));
|
||||
if($user->is_admin()) {
|
||||
$event->add_part($this->theme->nuke_notes_button($event->image->id));
|
||||
$event->add_part($this->theme->nuke_requests_button($event->image->id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE ADD QUERYLETS TO ADD SEARCH SYSTEM
|
||||
*/
|
||||
public function onSearchTermParse($event) {
|
||||
$matches = array();
|
||||
if(preg_match("/note=(.*)/i", $event->term, $matches)) {
|
||||
$notes = int_escape($matches[1]);
|
||||
$event->add_querylet(new Querylet("images.id IN (SELECT image_id FROM notes WHERE note = $notes)"));
|
||||
}
|
||||
else if(preg_match("/notes(<|>|<=|>=|=)(\d+)/", $event->term, $matches)) {
|
||||
$cmp = $matches[1];
|
||||
$notes = $matches[2];
|
||||
$event->add_querylet(new Querylet("images.id IN (SELECT id FROM images WHERE notes $cmp $notes)"));
|
||||
}
|
||||
else if(preg_match("/notes_by=(.*)/i", $event->term, $matches)) {
|
||||
global $database;
|
||||
$user = User::by_name($matches[1]);
|
||||
if(!is_null($user)) {
|
||||
$user_id = $user->id;
|
||||
}
|
||||
else {
|
||||
$user_id = -1;
|
||||
}
|
||||
|
||||
$event->add_querylet(new Querylet("images.id IN (SELECT image_id FROM notes WHERE user_id = $user_id)"));
|
||||
}
|
||||
else if(preg_match("/notes_by_userno=([0-9]+)/i", $event->term, $matches)) {
|
||||
$user_id = int_escape($matches[1]);
|
||||
$event->add_querylet(new Querylet("images.id IN (SELECT image_id FROM notes WHERE user_id = $user_id)"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE GET ALL NOTES FOR DISPLAYED IMAGE
|
||||
*/
|
||||
private function get_notes($imageID) {
|
||||
global $database;
|
||||
|
||||
return $database->get_all(
|
||||
"SELECT * ".
|
||||
"FROM notes ".
|
||||
"WHERE enable = ? AND image_id = ? ".
|
||||
"ORDER BY date ASC"
|
||||
, array('1', $imageID));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE ADD A NOTE TO DATABASE
|
||||
*/
|
||||
private function add_new_note() {
|
||||
global $database, $user;
|
||||
|
||||
$imageID = int_escape($_POST["image_id"]);
|
||||
$user_id = $user->id;
|
||||
$noteX1 = int_escape($_POST["note_x1"]);
|
||||
$noteY1 = int_escape($_POST["note_y1"]);
|
||||
$noteHeight = int_escape($_POST["note_height"]);
|
||||
$noteWidth = int_escape($_POST["note_width"]);
|
||||
$noteText = html_escape($_POST["note_text"]);
|
||||
|
||||
$database->execute("
|
||||
INSERT INTO notes
|
||||
(enable, image_id, user_id, user_ip, date, x1, y1, height, width, note)
|
||||
VALUES
|
||||
(?, ?, ?, ?, now(), ?, ?, ?, ?, ?)",
|
||||
array(1, $imageID, $user_id, $_SERVER['REMOTE_ADDR'], $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText));
|
||||
|
||||
$result = $database->get_row("SELECT LAST_INSERT_ID() AS noteID", array());
|
||||
$noteID = $result["noteID"];
|
||||
|
||||
log_info("notes", "Note added {$noteID} by {$user->name}");
|
||||
|
||||
$database->Execute("UPDATE images SET notes=(SELECT COUNT(*) FROM notes WHERE image_id=?) WHERE id=?", array($imageID, $imageID));
|
||||
|
||||
$this->add_history(1, $noteID, $imageID, $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE ADD A REQUEST TO DATABASE
|
||||
*/
|
||||
private function add_note_request() {
|
||||
global $database, $user;
|
||||
|
||||
$image_id = int_escape($_POST["image_id"]);
|
||||
$user_id = $user->id;
|
||||
|
||||
$database->execute("
|
||||
INSERT INTO note_request
|
||||
(image_id, user_id, date)
|
||||
VALUES
|
||||
(?, ?, now())",
|
||||
array($image_id, $user_id));
|
||||
|
||||
$result = $database->get_row("SELECT LAST_INSERT_ID() AS requestID", array());
|
||||
|
||||
log_info("notes", "Note requested {$result["requestID"]} by {$user->name}");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE EDIT THE NOTE
|
||||
*/
|
||||
private function update_note()
|
||||
{
|
||||
$imageID = $_POST["image_id"];
|
||||
$noteID = $_POST["note_id"];
|
||||
$noteX1 = $_POST["note_x1"];
|
||||
$noteY1 = $_POST["note_y1"];
|
||||
$noteHeight = $_POST["note_height"];
|
||||
$noteWidth = $_POST["note_width"];
|
||||
$noteText = $_POST["note_text"];
|
||||
|
||||
// validate parameters
|
||||
if(is_null($imageID) || !is_numeric($imageID))
|
||||
return;
|
||||
|
||||
if(is_null($noteID) || !is_numeric($noteID))
|
||||
return;
|
||||
|
||||
if(is_null($noteX1) || !is_numeric($noteX1))
|
||||
return;
|
||||
|
||||
if(is_null($noteY1) || !is_numeric($noteY1))
|
||||
return;
|
||||
|
||||
if(is_null($noteHeight) || !is_numeric($noteHeight))
|
||||
return;
|
||||
|
||||
if(is_null($noteWidth) || !is_numeric($noteWidth))
|
||||
return;
|
||||
|
||||
if(is_null($noteText) || strlen($noteText) == 0)
|
||||
return;
|
||||
|
||||
global $database;
|
||||
$database->execute("UPDATE notes ".
|
||||
"SET x1 = ?, ".
|
||||
"y1 = ?, ".
|
||||
"height = ?, ".
|
||||
"width = ?,".
|
||||
"note = ? ".
|
||||
"WHERE image_id = ? AND id = ?", array($noteX1, $noteY1, $noteHeight, $noteWidth, $noteText, $imageID, $noteID));
|
||||
|
||||
$this->add_history(1, $noteID, $imageID, $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE DELETE THE NOTE
|
||||
*/
|
||||
private function delete_note()
|
||||
{
|
||||
$imageID = $_POST["image_id"];
|
||||
$noteID = $_POST["note_id"];
|
||||
|
||||
// validate parameters
|
||||
if(is_null($imageID) || !is_numeric($imageID))
|
||||
return;
|
||||
|
||||
if(is_null($noteID) || !is_numeric($noteID))
|
||||
return;
|
||||
|
||||
global $database;
|
||||
|
||||
$database->execute("UPDATE notes ".
|
||||
"SET enable = ? ".
|
||||
"WHERE image_id = ? AND id = ?", array(0, $imageID, $noteID));
|
||||
|
||||
log_info("notes", "Note deleted {$noteID} by {$user->name}");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE DELETE ALL NOTES FROM IMAGE
|
||||
*/
|
||||
private function nuke_notes() {
|
||||
global $database;
|
||||
$image_id = int_escape($_POST["image_id"]);
|
||||
$database->execute("DELETE FROM notes WHERE image_id = ?", array($image_id));
|
||||
log_info("notes", "Notes deleted from {$image_id} by {$user->name}");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE DELETE ALL REQUESTS FOR IMAGE
|
||||
*/
|
||||
private function nuke_requests() {
|
||||
global $database;
|
||||
$image_id = int_escape($_POST["image_id"]);
|
||||
|
||||
$database->execute("DELETE FROM note_request WHERE image_id = ?", array($image_id));
|
||||
|
||||
log_info("notes", "Requests deleted from {$image_id} by {$user->name}");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE ALL IMAGES THAT HAVE NOTES
|
||||
*/
|
||||
private function get_notes_list($event) {
|
||||
$pageNumber = $event->get_arg(1);
|
||||
if(is_null($pageNumber) || !is_numeric($pageNumber))
|
||||
$pageNumber = 0;
|
||||
else if ($pageNumber <= 0)
|
||||
$pageNumber = 0;
|
||||
else
|
||||
$pageNumber--;
|
||||
|
||||
global $config;
|
||||
|
||||
$notesPerPage = $config->get_int('notesNotesPerPage');
|
||||
|
||||
|
||||
//$result = $database->get_all("SELECT * FROM pool_images WHERE pool_id=?", array($poolID));
|
||||
global $database;
|
||||
$get_notes = "
|
||||
SELECT DISTINCT image_id ".
|
||||
"FROM notes ".
|
||||
"WHERE enable = ? ".
|
||||
"ORDER BY date DESC LIMIT ?, ?";
|
||||
|
||||
$result = $database->Execute($get_notes, array(1, $pageNumber * $notesPerPage, $notesPerPage));
|
||||
|
||||
$totalPages = ceil($database->db->GetOne("SELECT COUNT(*) FROM notes") / $notesPerPage);
|
||||
|
||||
$images = array();
|
||||
while(!$result->EOF) {
|
||||
$image = Image::by_id($result->fields["image_id"]);
|
||||
$images[] = array($image);
|
||||
$result->MoveNext();
|
||||
}
|
||||
|
||||
$this->theme->display_note_list($images, $pageNumber + 1, $totalPages);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE GET ALL NOTE REQUESTS
|
||||
*/
|
||||
private function get_notes_requests($event) {
|
||||
$pageNumber = $event->get_arg(1);
|
||||
if(is_null($pageNumber) || !is_numeric($pageNumber))
|
||||
$pageNumber = 0;
|
||||
else if ($pageNumber <= 0)
|
||||
$pageNumber = 0;
|
||||
else
|
||||
$pageNumber--;
|
||||
|
||||
global $config;
|
||||
|
||||
$requestsPerPage = $config->get_int('notesRequestsPerPage');
|
||||
|
||||
|
||||
//$result = $database->get_all("SELECT * FROM pool_images WHERE pool_id=?", array($poolID));
|
||||
global $database;
|
||||
$get_requests = "
|
||||
SELECT DISTINCT image_id ".
|
||||
"FROM note_request ".
|
||||
"ORDER BY date DESC LIMIT ?, ?";
|
||||
|
||||
$result = $database->Execute($get_requests, array($pageNumber * $requestsPerPage, $requestsPerPage));
|
||||
|
||||
$totalPages = ceil($database->db->GetOne("SELECT COUNT(*) FROM note_request") / $requestsPerPage);
|
||||
|
||||
$images = array();
|
||||
while(!$result->EOF) {
|
||||
$image = Image::by_id($result->fields["image_id"]);
|
||||
$images[] = array($image);
|
||||
$result->MoveNext();
|
||||
}
|
||||
|
||||
$this->theme->display_note_requests($images, $pageNumber + 1, $totalPages);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE ADD HISTORY TO TRACK THE CHANGES OF THE NOTES FOR THE IMAGES.
|
||||
*/
|
||||
private function add_history($noteEnable, $noteID, $imageID, $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText){
|
||||
global $user, $database;
|
||||
|
||||
$userID = $user->id;
|
||||
|
||||
$reviewID = $database->db->GetOne("SELECT COUNT(*) FROM note_histories WHERE note_id = ?", array($noteID));
|
||||
$reviewID = $reviewID + 1;
|
||||
|
||||
$database->execute("
|
||||
INSERT INTO note_histories
|
||||
(note_enable, note_id, review_id, image_id, user_id, user_ip, date, x1, y1, height, width, note)
|
||||
VALUES
|
||||
(?, ?, ?, ?, ?, ?, now(), ?, ?, ?, ?, ?)",
|
||||
array($noteEnable, $noteID, $reviewID, $imageID, $userID, $_SERVER['REMOTE_ADDR'], $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE GET ALL HISTORIES.
|
||||
*/
|
||||
private function get_histories($event){
|
||||
$pageNumber = $event->get_arg(1);
|
||||
if(is_null($pageNumber) || !is_numeric($pageNumber))
|
||||
$pageNumber = 0;
|
||||
else if ($pageNumber <= 0)
|
||||
$pageNumber = 0;
|
||||
else
|
||||
$pageNumber--;
|
||||
|
||||
global $config;
|
||||
|
||||
$histiriesPerPage = $config->get_int('notesHistoriesPerPage');
|
||||
|
||||
//ORDER BY IMAGE & DATE
|
||||
global $database;
|
||||
$histories = $database->get_all("SELECT h.note_id, h.review_id, h.image_id, h.date, h.note, u.name AS user_name ".
|
||||
"FROM note_histories AS h ".
|
||||
"INNER JOIN users AS u ".
|
||||
"ON u.id = h.user_id ".
|
||||
"ORDER BY date DESC LIMIT ?, ?",
|
||||
array($pageNumber * $histiriesPerPage, $histiriesPerPage));
|
||||
|
||||
$totalPages = ceil($database->db->GetOne("SELECT COUNT(*) FROM note_histories") / $histiriesPerPage);
|
||||
|
||||
$this->theme->display_histories($histories, $pageNumber + 1, $totalPages);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* HERE WE THE HISTORY FOR A SPECIFIC NOTE.
|
||||
*/
|
||||
private function get_history($event){
|
||||
$noteID = $event->get_arg(1);
|
||||
$pageNumber = $event->get_arg(2);
|
||||
if(is_null($pageNumber) || !is_numeric($pageNumber))
|
||||
$pageNumber = 0;
|
||||
else if ($pageNumber <= 0)
|
||||
$pageNumber = 0;
|
||||
else
|
||||
$pageNumber--;
|
||||
|
||||
global $config;
|
||||
|
||||
$histiriesPerPage = $config->get_int('notesHistoriesPerPage');
|
||||
|
||||
global $database;
|
||||
$histories = $database->get_all("SELECT h.note_id, h.review_id, h.image_id, h.date, h.note, u.name AS user_name ".
|
||||
"FROM note_histories AS h ".
|
||||
"INNER JOIN users AS u ".
|
||||
"ON u.id = h.user_id ".
|
||||
"WHERE note_id = ? ".
|
||||
"ORDER BY date DESC LIMIT ?, ?",
|
||||
array($noteID, $pageNumber * $histiriesPerPage, $histiriesPerPage));
|
||||
|
||||
$totalPages = ceil($database->db->GetOne("SELECT COUNT(*) FROM note_histories WHERE note_id = ?", array($noteID)) / $histiriesPerPage);
|
||||
|
||||
$this->theme->display_history($histories, $pageNumber + 1, $totalPages);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* HERE GO BACK IN HISTORY AND SET THE OLD NOTE. IF WAS REMOVED WE READD IT.
|
||||
*/
|
||||
private function revert_history($noteID, $reviewID){
|
||||
global $user, $database;
|
||||
|
||||
$history = $database->get_row("SELECT * FROM note_histories WHERE note_id = ? AND review_id = ?",array($noteID, $reviewID));
|
||||
|
||||
$noteEnable = $history['note_enable'];
|
||||
$noteID = $history['note_id'];
|
||||
$imageID = $history['image_id'];
|
||||
$userID = $user->id;
|
||||
$noteX1 = $history['x1'];
|
||||
$noteY1 = $history['y1'];
|
||||
$noteHeight = $history['height'];
|
||||
$noteWidth = $history['width'];
|
||||
$noteText = $history['note'];
|
||||
|
||||
$database->execute("UPDATE notes ".
|
||||
"SET enable = ?, ".
|
||||
"x1 = ?, ".
|
||||
"y1 = ?, ".
|
||||
"height = ?, ".
|
||||
"width = ?,".
|
||||
"note = ? ".
|
||||
"WHERE image_id = ? AND id = ?", array(1, $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText, $imageID, $noteID));
|
||||
|
||||
$this->add_history($noteEnable, $noteID, $imageID, $noteX1, $noteY1, $noteHeight, $noteWidth, $noteText);
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
35
contrib/notes/style.css
Normal file
35
contrib/notes/style.css
Normal file
@ -0,0 +1,35 @@
|
||||
.note {
|
||||
display: none;
|
||||
background-color: #fffdef;
|
||||
border: #412a21 1px solid;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
|
||||
filter:alpha(opacity=50);
|
||||
-moz-opacity:0.5;
|
||||
-khtml-opacity: 0.5;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.notep {
|
||||
display: none;
|
||||
color: #412a21;
|
||||
background-color: #fffdef;
|
||||
border: #412a21 1px solid;
|
||||
font-size: 8pt;
|
||||
margin-top: 0px;
|
||||
padding: 2px;
|
||||
position: absolute;
|
||||
width: 175px;
|
||||
}
|
||||
|
||||
#noteform, #noteEditForm {
|
||||
display: none;
|
||||
position: absolute;
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
#noteform textarea, #noteEditForm textarea {
|
||||
width: 100%;
|
||||
}
|
374
contrib/notes/theme.php
Normal file
374
contrib/notes/theme.php
Normal file
@ -0,0 +1,374 @@
|
||||
<?php
|
||||
class NotesTheme extends Themelet {
|
||||
public function note_button($image_id) {
|
||||
return '
|
||||
<script type="text/javascript">
|
||||
function confirm_action() {
|
||||
var r=confirm("Are You Sure?");
|
||||
if (r==true) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- <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>
|
||||
';
|
||||
}
|
||||
public function request_button($image_id) {
|
||||
return '
|
||||
|
||||
<form action="'.make_link("note/add_request").'" method="POST">
|
||||
<input id="noterequest" type="submit" value="Add Note Request">
|
||||
<input type="hidden" name="image_id" value="'.$image_id.'">
|
||||
</form>
|
||||
';
|
||||
}
|
||||
public function nuke_notes_button($image_id) {
|
||||
return '
|
||||
<form action="'.make_link("note/nuke_notes").'" method="POST" ">
|
||||
<input id="noterequest" type="submit" value="Nuke Notes" onclick="return confirm_action()">
|
||||
<input type="hidden" name="image_id" value="'.$image_id.'">
|
||||
</form>
|
||||
';
|
||||
}
|
||||
public function nuke_requests_button($image_id) {
|
||||
return '
|
||||
|
||||
<form action="'.make_link("note/nuke_requests").'" method="POST">
|
||||
<input id="noterequest" type="submit" value="Nuke Requests" onclick="return confirm_action()">
|
||||
<input type="hidden" name="image_id" value="'.$image_id.'">
|
||||
</form>
|
||||
';
|
||||
}
|
||||
|
||||
public function search_notes_page(Page $page) { //IN DEVELOPMENT, NOT FULLY WORKING
|
||||
$html = '<form method="GET" action="/furpiledbeta/post/list/note=">
|
||||
<input id="search_input" type="text" name="search"/>
|
||||
<input type="submit" style="display: none;" value="Find"/>
|
||||
</form>';
|
||||
|
||||
$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
|
||||
public function display_note_system(Page $page, $image_id, $recovered_notes, $adminOptions) {
|
||||
$html = "<script type='text/javascript'>
|
||||
|
||||
notes = [";
|
||||
|
||||
foreach($recovered_notes as $note)
|
||||
{
|
||||
$parsedNote = $note["note"];
|
||||
$parsedNote = str_replace("\n", "\\n", $parsedNote);
|
||||
$parsedNote = str_replace("\r", "\\r", $parsedNote);
|
||||
|
||||
$html .= "{'x1':'".$note["x1"]."', ".
|
||||
"'y1':'".$note["y1"]."',".
|
||||
"'height':'".$note["height"]."',".
|
||||
"'width':'".$note["width"]."',".
|
||||
"'note':'".$parsedNote."',".
|
||||
"'note_id':'".$note["id"].
|
||||
"'},";
|
||||
}
|
||||
if (count($recovered_notes) > 0)
|
||||
{
|
||||
substr($html, 0, strlen($html) - 1); // remove final comma
|
||||
}
|
||||
|
||||
$html .= "];
|
||||
";
|
||||
|
||||
$html .= "$(document).ready(function() {
|
||||
$('#main_image').imgNotes(); //If your notes data is is not named notes pass it
|
||||
|
||||
$('#cancelnote').click(function(){
|
||||
$('#main_image').imgAreaSelect({ hide: true });
|
||||
$('#noteform').hide();
|
||||
});
|
||||
|
||||
$('#EditCancelNote').click(function() {
|
||||
$('#main_image').imgAreaSelect({ hide: true });
|
||||
$('#noteEditForm').hide();
|
||||
});
|
||||
|
||||
$('#addnote').click(function(){
|
||||
$('#noteEditForm').hide();
|
||||
$('#main_image').imgAreaSelect({ onSelectChange: showaddnote, x1: 120, y1: 90, x2: 280, y2: 210 });
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.note').click(function() {
|
||||
$('#noteform').hide();
|
||||
var imgOffset = $('#main_image').offset();
|
||||
|
||||
var x1 = parseInt(this.style.left) - imgOffset.left;
|
||||
var y1 = parseInt(this.style.top) - imgOffset.top;
|
||||
var width = parseInt(this.style.width);
|
||||
var height = parseInt(this.style.height);
|
||||
var text = $(this).next('.notep').text().replace(/([^>]?)\\n{2}/g, '$1\\n');
|
||||
var id = $(this).next('.notep').next('.noteID').text();
|
||||
|
||||
$('#main_image').imgAreaSelect({ onSelectChange: showeditnote, x1: x1, y1: y1, x2: x1 + width, y2: y1 + height });
|
||||
setEditNoteData(x1, y1, width, height, text, id);
|
||||
});
|
||||
});
|
||||
|
||||
function showaddnote (img, area) {
|
||||
imgOffset = $(img).offset();
|
||||
form_left = parseInt(imgOffset.left) + parseInt(area.x1);
|
||||
form_top = parseInt(imgOffset.top) + parseInt(area.y1) + parseInt(area.height)+5;
|
||||
|
||||
$('#noteform').css({ left: form_left + 'px', top: form_top + 'px'});
|
||||
|
||||
$('#noteform').show();
|
||||
|
||||
$('#noteform').css('z-index', 10000);
|
||||
$('#NoteX1').val(area.x1);
|
||||
$('#NoteY1').val(area.y1);
|
||||
$('#NoteHeight').val(area.height);
|
||||
$('#NoteWidth').val(area.width);
|
||||
}
|
||||
function showeditnote (img, area) {
|
||||
imgOffset = $(img).offset();
|
||||
form_left = parseInt(imgOffset.left) + area.x1;
|
||||
form_top = parseInt(imgOffset.top) + area.y2;
|
||||
|
||||
$('#noteEditForm').css({ left: form_left + 'px', top: form_top + 'px'});
|
||||
|
||||
$('#noteEditForm').show();
|
||||
|
||||
$('#noteEditForm').css('z-index', 10000);
|
||||
$('#EditNoteX1').val(area.x1);
|
||||
$('#EditNoteY1').val(area.y1);
|
||||
$('#EditNoteHeight').val(area.height);
|
||||
$('#EditNoteWidth').val(area.width);
|
||||
}
|
||||
function setEditNoteData(x1, y1, width, height, text, id)
|
||||
{
|
||||
$('#EditNoteX1').val(x1);
|
||||
$('#EditNoteY1').val(y1);
|
||||
$('#EditNoteHeight').val(height);
|
||||
$('#EditNoteWidth').val(width);
|
||||
$('#EditNoteNote').text(text);
|
||||
$('#EditNoteID').val(id);
|
||||
$('#DeleteNoteNoteID').val(id);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div id='noteform'>
|
||||
<form id='NoteAddForm' action='".make_link("note/add_note")."' method='POST'>
|
||||
<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' />
|
||||
|
||||
<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>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
<div id='noteEditForm'>
|
||||
<form id='NoteEditForm' action='".make_link("note/edit_note")."' method='POST'>
|
||||
<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>";
|
||||
|
||||
if($adminOptions)
|
||||
$html .= "
|
||||
<form id='NoteDeleteForm' action='".make_link("note/delete_note")."' method='POST'>
|
||||
<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>
|
||||
";
|
||||
|
||||
$html .= "</div>";
|
||||
|
||||
$page->add_block(new Block(null, $html, "main", 1));
|
||||
}
|
||||
|
||||
|
||||
public function display_note_list($images, $pageNumber, $totalPages) {
|
||||
global $page;
|
||||
$pool_images = '';
|
||||
foreach($images as $pair) {
|
||||
$image = $pair[0];
|
||||
|
||||
$thumb_html = $this->build_thumb_html($image);
|
||||
|
||||
$pool_images .= '<span class="thumb">'.
|
||||
'<a href="$image_link">'.$thumb_html.'</a>'.
|
||||
'</span>';
|
||||
|
||||
|
||||
}
|
||||
$this->display_paginator($page, "note/list", null, $pageNumber, $totalPages);
|
||||
|
||||
$page->set_title("Notes");
|
||||
$page->set_heading("Notes");
|
||||
$page->add_block(new Block("Notes", $pool_images, "main", 20));
|
||||
}
|
||||
|
||||
public function display_note_requests($images, $pageNumber, $totalPages) {
|
||||
global $page;
|
||||
$pool_images = '';
|
||||
foreach($images as $pair) {
|
||||
$image = $pair[0];
|
||||
|
||||
$thumb_html = $this->build_thumb_html($image);
|
||||
|
||||
$pool_images .= '<span class="thumb">'.
|
||||
'<a href="$image_link">'.$thumb_html.'</a>'.
|
||||
'</span>';
|
||||
|
||||
|
||||
}
|
||||
$this->display_paginator($page, "requests/list", null, $pageNumber, $totalPages);
|
||||
|
||||
$page->set_title("Note Requests");
|
||||
$page->set_heading("Note Requests");
|
||||
$page->add_block(new Block("Note Requests", $pool_images, "main", 20));
|
||||
}
|
||||
|
||||
public function display_histories($histories, $pageNumber, $totalPages) {
|
||||
global $user, $page;
|
||||
|
||||
$html = "<table id='poolsList' class='zebra'>".
|
||||
"<thead><tr>".
|
||||
"<th>Image</th>".
|
||||
"<th>Note</th>".
|
||||
"<th>Body</th>".
|
||||
"<th>Updater</th>".
|
||||
"<th>Date</th>";
|
||||
|
||||
|
||||
if(!$user->is_anonymous()){
|
||||
$html .= "<th>Action</th>";
|
||||
}
|
||||
|
||||
$html .= "</tr></thead>".
|
||||
"<tbody>";
|
||||
|
||||
$n = 0;
|
||||
foreach($histories as $history) {
|
||||
$oe = ($n++ % 2 == 0) ? "even" : "odd";
|
||||
|
||||
$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>";
|
||||
|
||||
$html .= "<tr class='$oe'>".
|
||||
"<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>";
|
||||
|
||||
if(!$user->is_anonymous()){
|
||||
$html .= "<td>".$revert_link."</td>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$html .= "</tr></tbody></table>";
|
||||
|
||||
$page->set_title("Note Updates");
|
||||
$page->set_heading("Note Updates");
|
||||
$page->add_block(new Block("Note Updates", $html, "main", 10));
|
||||
|
||||
$this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages);
|
||||
}
|
||||
|
||||
public function display_history($histories, $pageNumber, $totalPages) {
|
||||
global $user, $page;
|
||||
|
||||
$html = "<table id='poolsList' class='zebra'>".
|
||||
"<thead><tr>".
|
||||
"<th>Image</th>".
|
||||
"<th>Note</th>".
|
||||
"<th>Body</th>".
|
||||
"<th>Updater</th>".
|
||||
"<th>Date</th>";
|
||||
|
||||
|
||||
if(!$user->is_anonymous()){
|
||||
$html .= "<th>Action</th>";
|
||||
}
|
||||
|
||||
$html .= "</tr></thead>".
|
||||
"<tbody>";
|
||||
|
||||
$n = 0;
|
||||
foreach($histories as $history) {
|
||||
$oe = ($n++ % 2 == 0) ? "even" : "odd";
|
||||
|
||||
$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>";
|
||||
|
||||
$html .= "<tr class='$oe'>".
|
||||
"<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>";
|
||||
|
||||
if(!$user->is_anonymous()){
|
||||
$html .= "<td>".$revert_link."</td>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$html .= "</tr></tbody></table>";
|
||||
|
||||
$page->set_title("Note History");
|
||||
$page->set_heading("Note History");
|
||||
$page->add_block(new Block("Note History", $html, "main", 10));
|
||||
|
||||
$this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user