1
0

Add functionality for a random image block

This commit is contained in:
Tim Almdal 2009-12-22 18:53:24 -08:00
parent 35a76f3c5b
commit ab3655ff37
7 changed files with 65 additions and 22 deletions

View File

@ -76,6 +76,17 @@ class G3_Client_Controller extends Template_Controller {
print $this->_get_detail($response->resource);
}
public function block($type) {
switch ($type) {
case "random":
print $this->_get_image_block();
break;
default:
print "";
}
$this->auto_render = false;
}
private function _get_album_tree($resource) {
$v = new View("tree_part.html");
$v->element = (object)array("title" => $resource->title, "path" => $resource->path);
@ -93,6 +104,8 @@ class G3_Client_Controller extends Template_Controller {
$v = new View("main.html");
$v->album_tree = $this->_get_album_tree($resource);
$v->detail = $this->_get_detail($resource);
$v->image_block = $this->_get_image_block();
$v->tag_block = " ";
return $v;
}
@ -105,4 +118,17 @@ class G3_Client_Controller extends Template_Controller {
}
return $v;
}
private function _get_image_block() {
$response = G3Remote::instance()->get_resource("image_block/random");
if ($response->status == "OK") {
$v = new View("image_block.html");
$v->path = $response->resource->path;
$v->src = $response->resource->thumb_url;
$v->title = $response->resource->title;
} else {
$v = "";
}
return $v;
}
} // End G3 Client Controller

View File

@ -48,8 +48,8 @@ class G3Remote {
public function get_access_token($user, $password) {
$request = "{$this->_gallery3_site}/access_key";
list ($response_status, $response_headers, $response_body) =
url_connection::get($request, array("user" => $user, "password" => $password));
if (url_connection::success($response_status)) {
G3Remote::_get($request, array("user" => $user, "password" => $password));
if (G3Remote::_success($response_status)) {
$response = json_decode($response_body);
if ($response->status == "OK") {
$this->_access_token = $response->token;

View File

@ -38,3 +38,12 @@
<?= $detail ?>
</div>
</div>
<div id="right">
<div id="image_block">
<?= $image_block ?>
</div>
<div id="tag_block">
<?= $tag_block ?>
</div>
</div>

View File

@ -1,15 +0,0 @@
<?php defined('SYSPATH') OR die('No direct access allowed.'); ?>
<div class="box">
<p><?php echo __('This is the default Kohana index page. You may also access this page as')?> <code><?php echo html::anchor('welcome/index', 'welcome/index') ?></code>.</p>
<p>
<?php echo __('To change what gets displayed for this page, edit')?> <code>application/controllers/welcome.php</code>.<br />
<?php echo __('To change this text, edit')?> <code>application/views/welcome_content.php</code>.
</p>
</div>
<ul>
<?php foreach ($links as $title => $url): ?>
<li><?php echo ($title === 'License') ? html::file_anchor($url, html::chars(__($title))) : html::anchor($url, html::chars(__($title))) ?></li>
<?php endforeach ?>
</ul>

View File

@ -9,7 +9,7 @@
}
#wc-header div {
background-image: url(g3_web.png);
background-image: url(images/g3_web.png);
background-repeat: no-repeat;
height: 90px;
}
@ -127,7 +127,7 @@ span.error {
left: 230px;
padding: 10px;
position: absolute;
right: 20px;
right: 229px;
top: 11px;
}
@ -151,12 +151,12 @@ span.error {
#wc-body #center .wc-thumb-grid-cell {
border: 1px solid transparent;
float: left;
height: 200px;
line-height: 220px;
height: 150px;
line-height: 170px;
margin: 2px;
padding: 7px;
text-align: center;
width: 200px;
width: 150px;
}
#wc-body #center .wc-thumb-grid-cell img {
@ -171,6 +171,29 @@ span.error {
vertical-align: middle;
}
#wc-body #right {
background-color: #222222;
border: 3px inset;
bottom: 20px;
margin: 0;
padding: 5px;
position: absolute;
right: 20px;
top: 11px;
width: 191px;
}
#wc-body #right #image_block img {
padding: 5px 7px;
width: 175px;
}
#wc-body #right #image_block p,
#wc-body #right #image_block h3 {
color: #FF9933;
text-align: center;
}
.ui-icon-left .ui-icon {
float: left;
margin-right: 0.2em;

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB