Merge pull request #195 from DakuTree/master

API/Theme compatability.
This commit is contained in:
Shish 2012-03-30 07:15:53 -07:00
commit 036939eea4
6 changed files with 61 additions and 30 deletions

View File

@ -97,29 +97,50 @@ class ShimmieApi extends Extension {
if($event->page_matches("api/shimmie/get_user")) { if($event->page_matches("api/shimmie/get_user")) {
$query = $user->id; $query = $user->id;
$type = "id";
if($event->count_args() == 1) { if($event->count_args() == 1) {
$query = $event->get_arg(0); $query = $event->get_arg(0);
} }
if(isset($_GET['name'])) { elseif(isset($_GET['id'])) {
$query = $_GET['name'];
}
if(isset($_GET['id'])) {
$query = $_GET['id']; $query = $_GET['id'];
} }
elseif(isset($_GET['name'])) {
$query = $_GET['name'];
$type = "name";
}
$all = $database->get_row( $all = $database->get_row(
"SELECT id,name,joindate,class FROM users WHERE name=? OR id=?", "SELECT id,name,joindate,class FROM users WHERE ".$type."=?",
array($_GET['name'], int_escape($_GET['id']))); array($query));
if(!empty($all)){
//FIXME?: For some weird reason, get_all seems to return twice. Unsetting second value to make things look nice.. //FIXME?: For some weird reason, get_all seems to return twice. Unsetting second value to make things look nice..
// - it returns data as eg array(0=>1234, 'id'=>1234, 1=>'bob', 'name'=>bob, ...); // - it returns data as eg array(0=>1234, 'id'=>1234, 1=>'bob', 'name'=>bob, ...);
for($i=0; $i<4; $i++) unset($all[$i]); for($i=0; $i<4; $i++) unset($all[$i]);
$all['uploadcount'] = Image::count_images(array("user_id=".$all['id'])); $all['uploadcount'] = Image::count_images(array("user_id=".$all['id']));
$all['uploadperday'] = sprintf("%.1f", ($all['uploadcount'] / (((time() - strtotime($all['joindate'])) / 86400) + 1)));
$all['commentcount'] = $database->get_one( $all['commentcount'] = $database->get_one(
"SELECT COUNT(*) AS count FROM comments WHERE owner_id=:owner_id", "SELECT COUNT(*) AS count FROM comments WHERE owner_id=:owner_id",
array("owner_id"=>$all['id'])); array("owner_id"=>$all['id']));
$all['commentperday'] = sprintf("%.1f", ($all['commentcount'] / (((time() - strtotime($all['joindate'])) / 86400) + 1)));
if(isset($_GET['recent'])){
$recent = $database->get_all(
"SELECT * FROM images WHERE owner_id=? ORDER BY id DESC LIMIT 0, 5",
array($all['id']));
$i = 0;
foreach($recent as $all['recentposts'][$i]){
unset($all['recentposts'][$i]['owner_id']); //We already know the owners id..
unset($all['recentposts'][$i]['owner_ip']);
for($x=0; $x<14; $x++) unset($all['recentposts'][$i][$x]);
if(empty($all['recentposts'][$i]['author'])) unset($all['recentposts'][$i]['author']);
if($all['recentposts'][$i]['notes'] > 0) $all['recentposts'][$i]['has_notes'] = "Y";
else $all['recentposts'][$i]['has_notes'] = "N";
unset($all['recentposts'][$i]['notes']);
$i += 1;
}
}
}
$page->set_data(json_encode($all)); $page->set_data(json_encode($all));
} }
} }

View File

@ -27,6 +27,14 @@ class Tag_HistoryTheme extends Themelet {
$setter = "<a href='".make_link("user/".url_escape($name))."'>".html_escape($name)."</a>$h_ip"; $setter = "<a href='".make_link("user/".url_escape($name))."'>".html_escape($name)."</a>$h_ip";
$selected = ($n == 2) ? " checked" : ""; $selected = ($n == 2) ? " checked" : "";
$current_tags = explode(" ", $current_tags);
$taglinks = array();
foreach($current_tags as $tag){
$taglinks[] = "<a href='".make_link("post/list/".$tag."/1")."'>".$tag."</a>";
}
$current_tags = implode(" ", $taglinks);
$history_list .= " $history_list .= "
<li> <li>
<input type='radio' name='revert' id='$current_id' value='$current_id'$selected> <input type='radio' name='revert' id='$current_id' value='$current_id'$selected>

View File

@ -1,10 +1,14 @@
$(function() { $(function() {
var blocked_tags = ($.cookie("ui-blocked-tags") || $.cookie("blocked-tags") || "").split(" "); var blocked_tags = ($.cookie("ui-blocked-tags") || $.cookie("blocked-tags") || "").split(" ");
var themecheck = $(".thumb[data-tags~='tagme']").parent().attr('class');
var needs_refresh = false; var needs_refresh = false;
for(i in blocked_tags) { for(i in blocked_tags) {
var tag = blocked_tags[i]; var tag = blocked_tags[i];
if(tag) { if(tag) {
$(".thumb[data-tags~='"+tag+"']").hide(); $(".thumb[data-tags~='"+tag+"']").hide();
if(themecheck == "thumbblock") {
$(".thumb[data-tags~='tagme']").parent().height(0); //required for lite theme
}
needs_refresh = true; needs_refresh = true;
} }
} }

View File

@ -70,7 +70,7 @@ a.tab:hover, a.tab:active, .tab-selected {
-moz-border-radius:4px; -moz-border-radius:4px;
-webkit-border-radius:4px; -webkit-border-radius:4px;
} }
.highlighted { .lazy{
background:none repeat scroll 0 0 #CEDFF0; background:none repeat scroll 0 0 #CEDFF0;
padding:4px; padding:4px;
border:1px solid #C3D2E0; border:1px solid #C3D2E0;

View File

@ -6,28 +6,26 @@ class Themelet extends BaseThemelet {
*/ */
public function build_thumb_html(Image $image, $query=null) { public function build_thumb_html(Image $image, $query=null) {
global $config; global $config;
$i_id = int_escape($image->id); $i_id = (int) $image->id;
$h_view_link = make_link("post/view/$i_id", $query); $h_view_link = make_link('post/view/'.$i_id, $query);
$h_thumb_link = $image->get_thumb_link(); $h_thumb_link = $image->get_thumb_link();
$h_tip = html_escape($image->get_tooltip()); $h_tip = html_escape($image->get_tooltip());
$h_tags = strtolower($image->get_tag_list());
$base = get_base_href();
// If file is flash or svg then sets thumbnail to max size. // If file is flash or svg then sets thumbnail to max size.
if($image->ext == 'swf' || $image->ext == 'svg') { if($image->ext === 'swf' || $image->ext === 'svg'){
$tsize = get_thumbnail_size($config->get_int('thumb_width'), $config->get_int('thumb_height')); $tsize = get_thumbnail_size($config->get_int('thumb_width'), $config->get_int('thumb_height'));
} }
else { else{
$tsize = get_thumbnail_size($image->width, $image->height); $tsize = get_thumbnail_size($image->width, $image->height);
} }
return " return '<center><div class="thumbblock">'.
<center><div class='thumbblock'> '<a href="'.$h_view_link.'" class="thumb" data-tags="'.$h_tags.'">'.
'<img id="thumb_'.$i_id.'" title="'.$h_tip.'" alt="'.$h_tip.'" height="'.$tsize[1].'" width="'.$tsize[0].'" class="lazy" data-original="'.$h_thumb_link.'" src="'.$base.'/lib/static/grey.gif">'.
<a href='$h_view_link' style='position: relative; display: block; height: {$tsize[1]}px; width: {$tsize[0]}px;'> '<noscript><img id="thumb_'.$i_id.'" title="'.$h_tip.'" alt="'.$h_tip.'" height="'.$tsize[1].'" width="'.$tsize[0].'" src="'.$h_thumb_link.'"></noscript>'.
<img id='thumb_$i_id' title='$h_tip' alt='$h_tip' class='highlighted' style='height: {$tsize[1]}px; width: {$tsize[0]}px;' src='$h_thumb_link'> "</a></div></center>\n";
</a>
</div></center>
";
} }

View File

@ -13,7 +13,7 @@ class CustomViewImageTheme extends ViewImageTheme {
$page->add_html_header("<meta property=\"og:url\" content=\"".make_http(make_link("post/view/{$image->id}"))."\">"); $page->add_html_header("<meta property=\"og:url\" content=\"".make_http(make_link("post/view/{$image->id}"))."\">");
$page->add_block(new Block("Navigation", $this->build_navigation($image), "left", 0)); $page->add_block(new Block("Navigation", $this->build_navigation($image), "left", 0));
$page->add_block(new Block("Statistics", $this->build_stats($image), "left", 15)); $page->add_block(new Block("Statistics", $this->build_stats($image), "left", 15));
$page->add_block(new Block(null, $this->build_info($image, $editor_parts), "main", 10)); $page->add_block(new Block(null, $this->build_info($image, $editor_parts), "main", 11));
$page->add_block(new Block(null, $this->build_pin($image), "main", 11)); $page->add_block(new Block(null, $this->build_pin($image), "main", 11));
} }