remove old
git-svn-id: file:///home/shish/svn/shimmie2/branches/branch_2.1@647 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
73a890ff1a
commit
5335aa9418
@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file may not be distributed without its readme.txt
|
|
||||||
**/
|
|
||||||
|
|
||||||
/* * * Link to Image * * */
|
|
||||||
#Link_to_Image {
|
|
||||||
/* allows borders to encompass the content; */
|
|
||||||
overflow:hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
#Link_to_Image fieldset {
|
|
||||||
width: 32%;
|
|
||||||
float:left;
|
|
||||||
min-width:25em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#Link_to_Image input, #Link_to_Image label {
|
|
||||||
display:block;
|
|
||||||
width:66%;
|
|
||||||
float:left;
|
|
||||||
margin-bottom:2.5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#Link_to_Image label {
|
|
||||||
width:30%;
|
|
||||||
text-align:left;
|
|
||||||
padding-right:2%;
|
|
||||||
cursor:pointer;
|
|
||||||
}
|
|
||||||
#Link_to_Image input {
|
|
||||||
font-size:0.7em;
|
|
||||||
font-family:courier, fixed, monospace;
|
|
||||||
}
|
|
||||||
|
|
||||||
#Link_to_Image br {
|
|
||||||
clear:both;
|
|
||||||
}
|
|
||||||
|
|
||||||
#Link_to_Image label:hover {
|
|
||||||
border-bottom:1px dashed;
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
class LinkImage extends Extension {
|
|
||||||
var $theme;
|
|
||||||
|
|
||||||
public function receive_event($event) {
|
|
||||||
if(is_null($this->theme)) $this->theme = get_theme_object("link_image", "LinkImageTheme");
|
|
||||||
if(is_a($event, 'DisplayingImageEvent')) {
|
|
||||||
global $config;
|
|
||||||
$data_href = get_base_href();
|
|
||||||
$event->page->add_header("<link rel='stylesheet' href='$data_href/ext/link_image/_style.css' type='text/css'>",0);
|
|
||||||
|
|
||||||
$this->theme->links_block($event->page,$this->data($event->image));
|
|
||||||
}
|
|
||||||
if(is_a($event, 'SetupBuildingEvent')) {
|
|
||||||
$sb = new SetupBlock("Link to Image");
|
|
||||||
$sb->add_text_option("ext_link-img_text-link_format", "Text Link Format: ");
|
|
||||||
$event->panel->add_block($sb);
|
|
||||||
}
|
|
||||||
if(is_a($event, 'InitExtEvent')) {
|
|
||||||
global $config;
|
|
||||||
//just set default if empty.
|
|
||||||
$config->set_default_string("ext_link-img_text-link_format",
|
|
||||||
'$title - $id ($ext $size $filesize)');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private function data($image) {
|
|
||||||
global $config;
|
|
||||||
|
|
||||||
$text_link = $image->parse_link_template($config->get_string("ext_link-img_text-link_format"));
|
|
||||||
$text_link = $text_link==" "? null : $text_link; // null blank setting so the url gets filled in on the text links.
|
|
||||||
|
|
||||||
return array(
|
|
||||||
'thumb_src' => $image->get_thumb_link(),
|
|
||||||
'image_src' => $image->get_image_link(),
|
|
||||||
'post_link' => $image->get_short_link(),
|
|
||||||
'text_link' => $text_link);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
add_event_listener(new LinkImage());
|
|
||||||
?>
|
|
@ -1,82 +0,0 @@
|
|||||||
Link to Image adds BBCode and HTML link codes to the image view. Offers code for a customizable text link, thumbnail links, and full image inline.
|
|
||||||
|
|
||||||
Author: Erik Youngren <artanis.00@gmail.com>
|
|
||||||
|
|
||||||
License: GPLv2
|
|
||||||
|
|
||||||
Submit a Bug Report or Suggestion for Link to Image:
|
|
||||||
* http://trac.shishnet.org/shimmie2/newticket?owner=artanis.00@gmail.com&component=third%20party%20extensions&keywords=link_to_image
|
|
||||||
|
|
||||||
= Use =
|
|
||||||
There is one option in Board Config: Text Link Format.
|
|
||||||
It takes the following arguments as well as plain text.
|
|
||||||
|| arguments || replacement ||
|
|
||||||
|| $id || The image ID. ||
|
|
||||||
|| $hash || The MD5 hash of the image. ||
|
|
||||||
|| $tags || The image's tag list. ||
|
|
||||||
|| $base || The base HREF as set in Config. ||
|
|
||||||
|| $ext || The image's extension. ||
|
|
||||||
|| $size || The image's display size. ||
|
|
||||||
|| $filesize || The image's size in KB. ||
|
|
||||||
|| $filename || The image's original filename. ||
|
|
||||||
|| $title || The site title as set in Config. ||
|
|
||||||
Link to Image will default this option to '$title - $id ($ext $size $filesize)'.
|
|
||||||
To reset to the default, simply clear the current setting. Link to Image will then fill in the default value after the save.
|
|
||||||
|
|
||||||
To leave the setting blank for any reason, leave a space (' ') in it.
|
|
||||||
|
|
||||||
= Install =
|
|
||||||
1. Copy the folder {{{contrib/link_image/}}} to {{{ext/}}}.
|
|
||||||
2. In the Config panel, make sure Base URL is set (you may as well set Data URL while you're there, if you haven't already.)
|
|
||||||
3. Make sure Image Link, Thumb Link, and Short Link all contain the full path ("http://" and onward,) either by using $base or plain text. Link to Image will not be able to retrieve the correct paths without these variables.
|
|
||||||
|
|
||||||
= Change Log =
|
|
||||||
== Version 0.3.0 ==
|
|
||||||
* Moved Link to Image over to the official theme engine. This functions basically the same as what the prototype was, but it's more thought out and nicer.
|
|
||||||
* Cleaned up the insides a bit.
|
|
||||||
|
|
||||||
== Version 0.2.0 ==
|
|
||||||
* Changed the HTML generation to use a prototype theme engine. All HTML generation is now contained within {{{link_image.html.php}}}, which may be copied to the current theme folder and edited from there.
|
|
||||||
|
|
||||||
== Version 0.1.4 - 20070510 ==
|
|
||||||
* Style changes.
|
|
||||||
* Added output containing only the locations of the thumb, image and post.
|
|
||||||
* Added a link to wikipedia's HTML page, just as BBCode has a wikipedia link.
|
|
||||||
|
|
||||||
== Version 0.1.3b - 20070509 ==
|
|
||||||
* Renamed style.css to _style.css to avoid the auto loader.
|
|
||||||
|
|
||||||
== Version 0.1.3 - 20070508 ==
|
|
||||||
* Created Readme.txt
|
|
||||||
* Merged 0.1.2 into 0.1.2b
|
|
||||||
* Removed uneeded documentation from main.php
|
|
||||||
* Rewrote the css to be unique. Previously used CSS I wrote for elsewhere. Styled to reduce space consumption.
|
|
||||||
* Added code to insert the CSS import.
|
|
||||||
* Updated Nice URLs to allow access to the /ext/ folder. (Why is my stylesheet returning HTML instead of CSS?)
|
|
||||||
* First SVN update.
|
|
||||||
|
|
||||||
== Version 0.1.2b - 20070507 ==
|
|
||||||
(fairly simultaneous with 0.1.2)
|
|
||||||
* shish:
|
|
||||||
* Updated to new extension format
|
|
||||||
* Created folder link_image in trunk/contrib
|
|
||||||
* Renamed link_image.ext.php to main.php and moved to /link_image/
|
|
||||||
* Created style.css {{{ /* 404'd :|*/ }}}.
|
|
||||||
* Documentation (different from mine.)
|
|
||||||
* Changed add_text_option() and added add_label() in SetupBuildingEvent because I was using an edited version of the function that shish didn't know about. It was a wonder that didn't throw massive errors.
|
|
||||||
* Published on SVN.
|
|
||||||
|
|
||||||
== Version 0.1.2 - 20070506 ==
|
|
||||||
* Textboxes now select-all when they gain focus.
|
|
||||||
* Commenting and documentation.
|
|
||||||
|
|
||||||
== Version 0.1.1 - 20070506 ==
|
|
||||||
* Fixed HTML thumbnail link code. (image tag was being html_escaped twice, resulting in "$gt;" and "<" from the first escape becoming "&gt;" and "&lt;") It turns out that html_escape was completely unnecessary, all I had to do was replace the single-quotes around the attributes with escaped double-quotes ('\"'.)
|
|
||||||
|
|
||||||
== Version 0.1.0 - 20070506 ==
|
|
||||||
* Release.
|
|
||||||
|
|
||||||
= Links =
|
|
||||||
* http://trac.shishnet.org/shimmie2/wiki/Contrib/Extensions/LinkToImage - Home
|
|
||||||
* http://forum.shishnet.org/viewtopic.php?p=153 - Discussion
|
|
||||||
* http://trac.shishnet.org/shimmie2/browser/trunk/contrib/link_image - Shimmie2 Trac SVN
|
|
@ -1,71 +0,0 @@
|
|||||||
<?php
|
|
||||||
class LinkImageTheme extends Themelet {
|
|
||||||
public function links_block($page,$data) {
|
|
||||||
|
|
||||||
$thumb_src = $data['thumb_src'];
|
|
||||||
$image_src = $data['image_src'];
|
|
||||||
$post_link = $data['post_link'];
|
|
||||||
$text_link = $data['text_link'];
|
|
||||||
|
|
||||||
$page->add_block( new Block(
|
|
||||||
"Link to Image",
|
|
||||||
"<fieldset>".
|
|
||||||
"<legend><a href='http://en.wikipedia.org/wiki/Bbcode' target='_blank'>BBCode</a></legend>".
|
|
||||||
$this->link_code("Text Link",$this->url($post_link, $text_link,"ubb"),"ubb_text-link").
|
|
||||||
$this->link_code("Thumbnail Link",$this->url($post_link, $this->img($thumb_src,"ubb"),"ubb"),"ubb_thumb-link").
|
|
||||||
$this->link_code("Inline Image", $this->img($image_src,"ubb"), "ubb_full-img").
|
|
||||||
"</fieldset>".
|
|
||||||
|
|
||||||
"<fieldset>".
|
|
||||||
"<legend><a href='http://en.wikipedia.org/wiki/Html' target='_blank'>HTML</a></legend>".
|
|
||||||
$this->link_code("Text Link", $this->url($post_link, $text_link,"html"), "html_text-link").
|
|
||||||
$this->link_code("Thumbnail Link", $this->url($post_link,$this->img($thumb_src,"html"),"html"), "html_thumb-link").
|
|
||||||
$this->link_code("Inline Image", $this->img($image_src,"html"), "html_full-image").
|
|
||||||
"</fieldset>".
|
|
||||||
|
|
||||||
"<fieldset>".
|
|
||||||
"<legend>Plain Text</legend>".
|
|
||||||
$this->link_code("Post URL",$post_link,"text_post-link").
|
|
||||||
$this->link_code("Thumbnail URL",$thumb_src,"text_thumb-url").
|
|
||||||
$this->link_code("Image URL",$image_src,"text_image-src").
|
|
||||||
"</fieldset>",
|
|
||||||
"main",
|
|
||||||
50));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function url ($url,$content,$type) {
|
|
||||||
if ($content == NULL) {$content=$url;}
|
|
||||||
|
|
||||||
switch ($type) {
|
|
||||||
case "html":
|
|
||||||
$text = "<a href=\"".$url."\">".$content."</a>";
|
|
||||||
break;
|
|
||||||
case "ubb":
|
|
||||||
$text = "[url=".$url."]".$content."[/url]";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$text = $link." - ".$content;
|
|
||||||
}
|
|
||||||
return $text;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function img ($src,$type) {
|
|
||||||
switch ($type) {
|
|
||||||
case "html":
|
|
||||||
$text = "<img src=\"$src\" />";
|
|
||||||
break;
|
|
||||||
case "ubb":
|
|
||||||
$text = "[img]".$src."[/img]";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$text = $src;
|
|
||||||
}
|
|
||||||
return $text;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function link_code($label,$content,$id=NULL) {
|
|
||||||
return "<label for='".$id."' title='Click to select the textbox'>$label</label>\n".
|
|
||||||
"<input type='text' readonly='readonly' id='".$id."' name='".$id."' value='".html_escape($content)."' onfocus='this.select();'></input>\n<br/>\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
@ -1,204 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
class Tag_History extends Extension {
|
|
||||||
var $theme;
|
|
||||||
|
|
||||||
public function receive_event($event) {
|
|
||||||
if(is_null($this->theme)) $this->theme = get_theme_object("tag_history", "Tag_HistoryTheme");
|
|
||||||
|
|
||||||
if(is_a($event, 'InitExtEvent')) {
|
|
||||||
// shimmie is being installed so call install to create the table.
|
|
||||||
global $config;
|
|
||||||
if($config->get_int("ext_tag_history_version") < 1) {
|
|
||||||
$this->install();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(is_a($event, 'PageRequestEvent') && ($event->page_name == "tag_history"))
|
|
||||||
{
|
|
||||||
if($event->get_arg(0) == "revert")
|
|
||||||
{
|
|
||||||
// this is a request to revert to a previous version of the tags
|
|
||||||
$this->process_revert_request($_POST['image_id'], $_POST['revert']);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// must be an attempt to view a tag history
|
|
||||||
$image_id = int_escape($event->get_arg(0));
|
|
||||||
$this->theme->display_history_page($event->page, $image_id, $this->build_tag_history($image_id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(is_a($event, 'DisplayingImageEvent'))
|
|
||||||
{
|
|
||||||
// handle displaying a link on the view page
|
|
||||||
$this->theme->display_history_link($event->page, $event->image->id);
|
|
||||||
}
|
|
||||||
if(is_a($event, 'ImageDeletionEvent'))
|
|
||||||
{
|
|
||||||
// handle removing of history when an image is deleted
|
|
||||||
$this->delete_all_tag_history($event->image->id);
|
|
||||||
}
|
|
||||||
if(is_a($event, 'SetupBuildingEvent')) {
|
|
||||||
$sb = new SetupBlock("Tag History");
|
|
||||||
$sb->add_label("Limit to ");
|
|
||||||
$sb->add_int_option("history_limit");
|
|
||||||
$sb->add_label(" entires per image");
|
|
||||||
$event->panel->add_block($sb);
|
|
||||||
}
|
|
||||||
if(is_a($event, 'TagSetEvent')) {
|
|
||||||
$this->add_tag_history($event->image_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function install()
|
|
||||||
{
|
|
||||||
global $database;
|
|
||||||
global $config;
|
|
||||||
$database->Execute("CREATE TABLE tag_histories
|
|
||||||
(
|
|
||||||
id integer NOT NULL auto_increment PRIMARY KEY,
|
|
||||||
image_id integer NOT NULL,
|
|
||||||
tags text NOT NULL
|
|
||||||
)");
|
|
||||||
$config->set_int("ext_tag_history_version", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function process_revert_request($image_id, $revert_id)
|
|
||||||
{
|
|
||||||
// this function is called when a revert request is received
|
|
||||||
global $page;
|
|
||||||
// check for the nothing case
|
|
||||||
if($revert_id=="nothing")
|
|
||||||
{
|
|
||||||
// tried to set it too the same thing so ignore it (might be a bot)
|
|
||||||
// go back to the index page with you
|
|
||||||
$page->set_mode("redirect");
|
|
||||||
$page->set_redirect(make_link());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$revert_id = int_escape($revert_id);
|
|
||||||
$image_id = int_escape($image_id);
|
|
||||||
|
|
||||||
// lets get this revert id assuming it exists
|
|
||||||
$result = $this->get_tag_history_from_revert($revert_id);
|
|
||||||
|
|
||||||
if($result==null)
|
|
||||||
{
|
|
||||||
// there is no history entry with that id so either the image was deleted
|
|
||||||
// while the user was viewing the history, someone is playing with form
|
|
||||||
// variables or we have messed up in code somewhere.
|
|
||||||
die("Error: No tag history with specified id was found.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// lets get the values out of the result
|
|
||||||
$stored_result_id = $result->fields['id'];
|
|
||||||
$stored_image_id = $result->fields['image_id'];
|
|
||||||
$stored_tags = $result->fields['tags'];
|
|
||||||
|
|
||||||
if($image_id!=$stored_image_id)
|
|
||||||
{
|
|
||||||
// wth is going on there ids should be the same otherwise we are trying
|
|
||||||
// to edit another image... banhammer this user... j/k
|
|
||||||
die("Error: Mismatch in history image ids.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// all should be ok so we can revert by firing the SetUserTags event.
|
|
||||||
send_event(new TagSetEvent($image_id, $stored_tags));
|
|
||||||
|
|
||||||
// all should be done now so redirect the user back to the image
|
|
||||||
$page->set_mode("redirect");
|
|
||||||
$page->set_redirect(make_link("post/view/$image_id"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private function build_tag_history($image_id)
|
|
||||||
{
|
|
||||||
// this function is called when user tries to view tag history of an image
|
|
||||||
// check if the image exists
|
|
||||||
global $database;
|
|
||||||
$image = $database->get_image($image_id);
|
|
||||||
if($image==null)return "<strong>No image with the specified id currently exists</strong>";
|
|
||||||
|
|
||||||
// get the current images tags
|
|
||||||
$current_tags = html_escape(implode(' ', $image->get_tag_array()));
|
|
||||||
//$current_tags = $image->cached_tags;
|
|
||||||
|
|
||||||
// get any stored tag histories
|
|
||||||
$result = $this->get_tag_history_from_id($image_id);
|
|
||||||
$html = "<div style='text-align: left'>";
|
|
||||||
$html .= "<br><form enctype='multipart/form-data' action='".make_link("tag_history/revert")."' method='POST'>\n";
|
|
||||||
$html .= "<input type='hidden' name='image_id' value='$image_id'>\n";
|
|
||||||
$html .= "<ul style='list-style-type:none;'>\n";
|
|
||||||
$html .= "<li><input type='radio' name='revert' value='nothing' checked>$current_tags (<strong>current</strong>)<br></li>\n";
|
|
||||||
|
|
||||||
$end_string = "<input type='submit' value='Revert'></ul></form></div>";
|
|
||||||
// check for no stored history
|
|
||||||
if($result==null) return $html.$end_string;
|
|
||||||
|
|
||||||
// process each one
|
|
||||||
while(!$result->EOF)
|
|
||||||
{
|
|
||||||
$fields = $result->fields;
|
|
||||||
$current_id = $fields['id'];
|
|
||||||
$current_tags = $fields['tags'];
|
|
||||||
$html .= "<li><input type='radio' name='revert' value='$current_id'>$current_tags<br></li>\n";
|
|
||||||
$result->MoveNext();
|
|
||||||
}
|
|
||||||
$html .= $end_string;
|
|
||||||
|
|
||||||
// now return the finished html
|
|
||||||
return $html;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get_tag_history_from_revert($revert_id)
|
|
||||||
{
|
|
||||||
global $database;
|
|
||||||
$row = $database->execute( "SELECT * FROM tag_histories WHERE id = ?", array($revert_id));
|
|
||||||
return ($row ? $row : null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get_tag_history_from_id($image_id)
|
|
||||||
{
|
|
||||||
global $database;
|
|
||||||
$row = $database->execute( "SELECT * FROM tag_histories WHERE image_id = ? ORDER BY id DESC", array($image_id));
|
|
||||||
return ($row ? $row : null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function delete_all_tag_history($image_id)
|
|
||||||
{
|
|
||||||
// this function is called when an image has been deleted
|
|
||||||
global $database;
|
|
||||||
$database->execute("DELETE FROM tag_histories WHERE image_id = ?", array($image_id));
|
|
||||||
}
|
|
||||||
|
|
||||||
private function add_tag_history($image_id)
|
|
||||||
{
|
|
||||||
// this function is called just before an images tag are changed
|
|
||||||
global $database;
|
|
||||||
global $config;
|
|
||||||
|
|
||||||
// get the old tags
|
|
||||||
$image = $database->get_image($image_id);
|
|
||||||
$tags = $image->get_tag_array();
|
|
||||||
if(count($tags)==0)return;
|
|
||||||
$tags = implode(' ',$tags);
|
|
||||||
|
|
||||||
// add a history entry
|
|
||||||
$allowed = $config->get_int("history_limit",10);
|
|
||||||
if($allowed<=0)return;
|
|
||||||
$row = $database->execute("INSERT INTO tag_histories(image_id, tags) VALUES (?, ?)", array($image_id, $tags));
|
|
||||||
$entries = $database->db->GetOne("SELECT COUNT(*) FROM `tag_histories` WHERE image_id = ?", array($image_id));
|
|
||||||
|
|
||||||
// if needed remove oldest one
|
|
||||||
if($entries > $allowed)
|
|
||||||
{
|
|
||||||
// TODO: Make these queries better
|
|
||||||
$min_id = $database->db->GetOne("SELECT MIN(id) FROM tag_histories WHERE image_id = ?", array($image_id));
|
|
||||||
$database->execute("DELETE FROM tag_histories WHERE id = ?", array($min_id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
add_event_listener(new Tag_History(), 40); // early, so that old tags can be archived before new ones are set
|
|
||||||
?>
|
|
@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
class Tag_HistoryTheme extends Themelet {
|
|
||||||
public function display_history_page($page, $image_id, $history) {
|
|
||||||
$page_heading = "Tag History: $image_id";
|
|
||||||
$page->set_title("Image $image_id Tag History");
|
|
||||||
$page->set_heading($page_heading);
|
|
||||||
|
|
||||||
$page->add_block(new NavBlock());
|
|
||||||
$page->add_block(new Block("Tag History", $history, "main", 10));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function display_history_link($page, $image_id) {
|
|
||||||
$link = "<a href='".make_link("tag_history/$image_id")."'>Tag History</a>\n";
|
|
||||||
$page->add_block(new Block(null, $link, "main", 5));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
Loading…
x
Reference in New Issue
Block a user