From b010709e2d8bd1f5df5b839d7e36a579373e6597 Mon Sep 17 00:00:00 2001 From: Artanis Date: Fri, 13 Jul 2007 19:11:45 +0000 Subject: [PATCH] 0.3.0 git-svn-id: file:///home/shish/svn/shimmie2/trunk@274 7f39781d-f577-437e-ae19-be835c7a54ca --- contrib/link_image/_style.css | 14 +-- contrib/link_image/link_image.html.php | 83 ----------------- contrib/link_image/main.php | 118 ++++++++++--------------- contrib/link_image/readme.txt | 15 ++-- contrib/link_image/theme.php | 71 +++++++++++++++ 5 files changed, 129 insertions(+), 172 deletions(-) delete mode 100644 contrib/link_image/link_image.html.php create mode 100644 contrib/link_image/theme.php diff --git a/contrib/link_image/_style.css b/contrib/link_image/_style.css index a2a1d978..472620f6 100644 --- a/contrib/link_image/_style.css +++ b/contrib/link_image/_style.css @@ -3,39 +3,39 @@ **/ /* * * Link to Image * * */ -#link_to_image { +#Link_to_Image { /* allows borders to encompass the content; */ overflow:hidden; } -#link_to_image fieldset { +#Link_to_Image fieldset { width: 32%; float:left; min-width:25em; } -#link_to_image input, #link_to_image label { +#Link_to_Image input, #Link_to_Image label { display:block; width:66%; float:left; margin-bottom:2.5px; } -#link_to_image label { +#Link_to_Image label { width:30%; text-align:left; padding-right:2%; cursor:pointer; } -#link_to_image input { +#Link_to_Image input { font-size:0.7em; font-family:courier, fixed, monospace; } -#link_to_image br { +#Link_to_Image br { clear:both; } -#link_to_image label:hover { +#Link_to_Image label:hover { border-bottom:1px dashed; } \ No newline at end of file diff --git a/contrib/link_image/link_image.html.php b/contrib/link_image/link_image.html.php deleted file mode 100644 index a13bd6c9..00000000 --- a/contrib/link_image/link_image.html.php +++ /dev/null @@ -1,83 +0,0 @@ -post_link = $post; - $this->image_src = $img; - $this->thumb_src = $thumb; - $this->text_link = $text; - } - - public function getHTML () { - $html = ""; - -/* Rearrange or add to the code sections here. (BEGINNER) * - * Please do not edit anything outside the following section. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - $html .= ""; -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - - return $html; - } - -/* Section Construction (INTERMEDIATE) * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - private function BBCode() { - return $this->section("BBCode", - $this->link_code("Text Link", $this->ubb_url($this->post_link, $this->text_link), "ubb_text-link"). - $this->link_code("Thumbnail Link",$this->ubb_url($this->post_link, $this->ubb_img($this->thumb_src)),"ubb_thumb-link"). - $this->link_code("Inline Image", $this->ubb_img($this->image_src), "ubb_full-img")); - } - - private function HTML() { - return $this->section("HTML", - $this->link_code("Text Link", $this->html_url($this->post_link, $this->text_link), "html_text-link"). - $this->link_code("Thumbnail Link", $this->html_url($this->post_link,$this->html_img($this->thumb_src)), "html_thumb-link"). - $this->link_code("Inline Image", $this->html_img($this->image_src), "html_full-image")); - } - - private function PlainText() { - return $this->section("Plain Text", - $this->link_code("Post URL",$this->post_link,"text_post-link"). - $this->link_code("Thumbnail URL",$this->thumb_src,"text_thumb-url"). - $this->link_code("Image URL",$this->image_src,"text_image-src")); - } - - private function section ($legend, $content) { - return "
$legend$content
\n\n"; - } - -/* Text and Textbox Construction (ADVANCED) * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - private function ubb_url($link,$content) { - if ($content == NULL) { $content=$link; } - return "[url=".$link."]".$content."[/url]"; - } - private function ubb_img($src) { - return "[img]".$src."[/img]"; - } - - private function html_url($link,$content) { - if ($content == NULL) { $content=$link; } - return "".$content.""; - } - private function html_img($src) { - return ""; - } - - private function link_code($label,$content,$id=NULL) { - $control = "\n"; - $control .= "\n"; - $control .= "
\n"; - return $control; - } -} -?> \ No newline at end of file diff --git a/contrib/link_image/main.php b/contrib/link_image/main.php index 90695b2d..f5b2d595 100644 --- a/contrib/link_image/main.php +++ b/contrib/link_image/main.php @@ -1,72 +1,44 @@ -get_string("data_href"); - $page->add_header("",0); - $page->add_block(new Block("Link to Image", $this->get_html($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. - if ($config->get_string("ext_link-img_text-link_format") == "") { - $config->set_string("ext_link-img_text-link_format", '$title - $id ($ext $size $filesize)'); - } - } - } - - private function get_html($image) { - global $config; - - $thumb_src = $image->get_thumb_link(); - $image_src = $image->get_image_link(); - $post_link = $image->get_short_link(); - $text_link = $this->parse_link_template($config->get_string("ext_link-img_text-link_format"),$image); - - $html = ""; - - if($this->get_HTML_PHP()) { - $html_gen = new LinkImageHTML($post_link, $image_src, $thumb_src, $text_link); - $html = $html_gen->getHTML(); - } - - return $html; - } - -/* This function would do better generalized in the Extension class instead * - * of repeated in every extension. And probaly renamed, too... * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - private function get_HTML_PHP() { - global $config; - $theme = $config->get_string("theme"); - - if(file_exists("themes/$theme/link_image.html.php")) { - //$html .= "Using theme version"; - include "themes/$theme/link_image.html.php"; - } else if(file_exists("ext/link_image/link_image.html.php")) { - include "ext/link_image/link_image.html.php"; - //$html .= "Using default generation in absense of themed generation."; - } else { - echo "[Link to Image] Error: link_image.html.php not found at either ext/link_image/link_image.html.php nor themes/$theme/link_image.html.php.
". - "Please restore the default file to the former location, and copy it over to the latter if you wish to edit the html output of this extension."; - return false; - } - return true; - } -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - - +theme)) $this->theme = get_theme_object("link_image", "LinkImageTheme"); + if(is_a($event, 'DisplayingImageEvent')) { + global $page; + global $config; + $data_href = $config->get_string("data_href"); + $page->add_header("",0); + + $this->theme->links_block($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. + if ($config->get_string("ext_link-img_text-link_format") == "") { + $config->set_string("ext_link-img_text-link_format", + '$title - $id ($ext $size $filesize)'); + } + } + } + private function data($image) { + global $config; + + $text_link = $this->parse_link_template($config->get_string("ext_link-img_text-link_format"),$image); + $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); + } + private function parse_link_template($tmpl, $img) { //shamelessly copied from image.class.php global $config; @@ -93,7 +65,7 @@ class LinkImage extends Extension { $tmpl = str_replace('$title', $config->get_string("title"), $tmpl); return $tmpl; - } -} -add_event_listener(new LinkImage()); -?> + } +} +add_event_listener(new LinkImage()); +?> diff --git a/contrib/link_image/readme.txt b/contrib/link_image/readme.txt index 997b67cc..6051103a 100644 --- a/contrib/link_image/readme.txt +++ b/contrib/link_image/readme.txt @@ -25,23 +25,20 @@ To reset to the default, simply clear the current setting. Link to Image will th To leave the setting blank for any reason, leave a space (' ') in it. -= Theming = -Link to Image now has a prototype theme engine built into it. All HTML generation has been moved to a seperate file. -To use this, copy link_image.html.php from {{{ext/link_image/}}} to {{{themes/$theme/}}}. You may then change the html output of Link to Image by editing this copy as it will be used in preference of the default. - = 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. - 4. If you use .htaccess to make NiceURLs, make sure that a it allows access to the {{{ext/ folder}}}, or else Link to Image will not be able to access {{{ext/link_image/style.css}}}. - * http://trac.shishnet.org/shimmie2/wiki/NiceURLs - Nice URLs - * Recent changes to .htaccess (with its addition to the SVN) may make this step unnessasary. -= Change Log = += 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 - 20071510 == +== 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. diff --git a/contrib/link_image/theme.php b/contrib/link_image/theme.php new file mode 100644 index 00000000..c0d483e6 --- /dev/null +++ b/contrib/link_image/theme.php @@ -0,0 +1,71 @@ +add_block( new Block( + "Link to Image", + "
". + "BBCode". + $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"). + "
". + + "
". + "HTML". + $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"). + "
". + + "
". + "Plain Text". + $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"). + "
", + "main", + 50)); + } + + private function url ($url,$content,$type) { + if ($content == NULL) {$content=$url;} + + switch ($type) { + case "html": + $text = "".$content.""; + break; + case "ubb": + $text = "[url=".$url."]".$content."[/url]"; + break; + default: + $text = $link." - ".$content; + } + return $text; + } + + private function img ($src,$type) { + switch ($type) { + case "html": + $text = ""; + break; + case "ubb": + $text = "[img]".$src."[/img]"; + break; + default: + $text = $src; + } + return $text; + } + + private function link_code($label,$content,$id=NULL) { + return "\n". + "\n
\n"; + } +} +?>