[ext | tagger]

git-svn-id: file:///home/shish/svn/shimmie2/trunk@493 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
Artanis 2007-09-26 07:23:16 +00:00
parent de599ea131
commit aa2d6537de
3 changed files with 118 additions and 12 deletions

View file

@ -5,10 +5,14 @@ class tagger extends Extension {
public function receive_event ($event) {
if(is_null($this->theme))
$this->theme = get_theme_object("tagger", "taggerTheme");
if(is_a($event,"DisplayingImageEvent")) {
//show tagger box
global $database;
global $page;
global $config;
$base_href = $config->get_string('base_href');
$tags = $database->Execute("
SELECT tag
@ -18,6 +22,15 @@ class tagger extends Extension {
$this->theme->build($page, $tags);
}
if(is_a($event,"PageRequestEvent") && $event->page_name == "about"
&& $event->get_arg(0) == "tagger")
{
global $page;
$this->theme->show_about($page);
}
}
}
add_event_listener( new tagger());

View file

@ -29,6 +29,56 @@ function addTagById(id) {
addTag(tag.value);
}
function tagger_filter(id) {
var filter = byId(id);
var e;
search = filter.value;
if (search.length == 1)
search = " "+search;
tag_links = getElementsByTagNames('div',byId('tagger_body'));
for (x in tag_links) {
tag_id = tag_links[x].id;
tag = " "+tag_id.replace(/tagger_tag_/,"");
e = byId(tag_id);
if (!tag.match(search)) {
e.style.display = 'none';
} else {
e.style.display = '';
}
}
}
// Quirksmode.org //
// http://www.quirksmode.org/dom/getElementsByTagNames.html //
function getElementsByTagNames(list,obj) {
if (!obj) var obj = document;
var tagNames = list.split(',');
var resultArray = new Array();
for (var i=0;i<tagNames.length;i++) {
var tags = obj.getElementsByTagName(tagNames[i]);
for (var j=0;j<tags.length;j++) {
resultArray.push(tags[j]);
}
}
var testNode = resultArray[0];
if (!testNode) return [];
if (testNode.sourceIndex) {
resultArray.sort(function (a,b) {
return a.sourceIndex - b.sourceIndex;
});
}
else if (testNode.compareDocumentPosition) {
resultArray.sort(function (a,b) {
return 3 - (a.compareDocumentPosition(b) & 6);
});
}
return resultArray;
}
// End //
// Drag Code //
//*****************************************************************************
// Do not remove this notice.
@ -187,3 +237,4 @@ function dragStop(event) {
document.removeEventListener("mouseup", dragStop, true);
}
}
// End //

View file

@ -1,20 +1,42 @@
<?php
class taggerTheme extends Themelet {
public function build ($page, $tags) {
$html = "<div id='tagger_window' style='top:100px;left:800px;'>";
$html .= "<div id='tagger_titlebar' title='Drag to move' onmousedown='dragStart(event,\"tagger_window\");'>";
$html .= "Tagger";
$html .= "</div>";
$html .= "<div id='tagger_body' style='height:300px;'>";
$html .= "<input type='text' id='custTag' value=''></input><input type='button' value='Add' onclick='addTagById(\"custTag\")'></input><br/>";
$tag_html = "";
foreach ($tags as $tag) {
$tag_name = $this->trimTag($tag['tag'],32);
$html .= "<a style='cursor:pointer;' onclick='addTag(\"".$tag['tag']."\");'title='Add \"".$tag['tag']."\" to the tag list'>".$tag_name."</a><br/>";
$tag_name = $tag['tag'];
$tag_trunc = $this->trimTag($tag_name,32);
$tag_html .= "<div id='tagger_tag_".$tag_name."'>"."
<a style='cursor:pointer;' onclick='addTag(&quot;".$tag_name."&quot;);' ".
"title='Add &quot;".$tag_name."&quot; to the tag list'>".$tag_trunc."</a>".
"</div>";
}
$html .= "</div></div>";
$url_more = make_link("about/tagger");
$html = <<<EOD
<span style="font-size:.7em;">Collapse this block to hide Tagger.</span>
<br/>
<h4>Use</h4>
<ul>
<li>Click the links to add the tag to the list, when done, press Set to save the tags.</li>
<li>Type in the filter box to remove tags you aren&#39;t looking for.</li>
<li>Enter tags not on the list in the second box. Tags must have 2 uses to display in the list.</li>
<li><a href='$url_more'>More</a></li>
</ul>
<div id="tagger_window" style="top:100px;left:800px;">
<div id="tagger_titlebar" title="'Drag to move" onmousedown="dragStart(event,&quot;tagger_window&quot;);">
Tagger
</div>
<div id="tagger_body" style="height:300px;">
<input type="text" id="tagger_filter" onkeyup="tagger_filter(&quot;tagger_filter&quot;)" size="12"></input>
<hr/>
<input type="text" id="custTag" value="" size='12'></input>
<input type="button" value="Add" onclick="addTagById(&quot;custTag&quot;)"></input>
<hr/>
$tag_html
</div>
</div>
EOD;
$page->add_block( new Block("Tagger",
"<span style='font-size:.8em;'>Collapse this block to hide Tagger.</span><br/><br/>Use: Click the links to add the tag to the list, when done, press Set to save the tags.".$html,
"".$html,
"left",
0));
}
@ -26,5 +48,25 @@ class taggerTheme extends Themelet {
}
return $s;
}
public function show_about ($event) {
global $page;
$html = <<<EOD
<h4>Author</h4>
Erik Youngren (Artanis) artanis.00@gmail.com
<h4>Use</h4>
<ul>
<li>Click the links to add the tag to the image&#39;s tag list, when done, press Set to save the tags.</li>
<li>Type in the filter box to remove tags you aren&#39;t looking for.<ul>
<li>Single letter filters will only match the first letter of the tags.</li>
<li>2 or more will match that letter combination anywhere in the tag. Starting a
filter with a space (' ') will prevent this behaviour.</li>
</ul></li>
<li>Enter tags not on the list in the second box. Tags must have 2 uses to display in the list.</li>
</ul>
EOD;
$page->add_block( new Block("About Tagger", $html,"main"));
}
}
?>