Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add thumbnail to wall summary

  • Loading branch information...
commit c017672134a96e5a95968bfbb1e6f90184870053 1 parent 574e4b8
@birtles birtles authored
View
33 wall/lib/walls.inc
@@ -145,14 +145,17 @@ function getCurrentWallTimeForDuration($duration) {
}
class Wall {
- private $_id = null;
+ private $_id = null;
+ private $_design = null;
private $metadata = null;
- private $design = null;
private $sessions = null;
private $email = null;
private $dirtyFields = array();
- static private $hiddenFields = array('passcode');
+ static private $hiddenFields = array('passcode');
+ static private $virtualFields = array('id', 'passcodeLen',
+ 'wallUrl', 'editorUrl',
+ 'design', 'thumbnail');
public function __construct($id, $email, $metadata) {
$this->_id = intval($id);
@@ -185,6 +188,13 @@ class Wall {
case 'passcodeLen':
return strlen($this->metadata['passcode']);
+
+ case 'design':
+ return $this->getDesign();
+
+ case 'thumbnail':
+ $design = $this->getDesign();
+ return $design ? $design->thumbnail : null;
}
return null;
@@ -210,6 +220,13 @@ class Wall {
case 'passcodeLen':
return isset($this->metadata['passcode']);
+
+ case 'design':
+ return $this->getDesign() !== null;
+
+ case 'thumbnail':
+ $design = $this->getDesign();
+ return $design ? $design->thumbnail !== null : false;
}
return false;
@@ -229,7 +246,7 @@ class Wall {
// Reject read-only/virtual fields
// (XXX Might be better to handle each acceptable field below when we
// sanitize and if it's not recognized, throw there)
- if (in_array($name, array('id', 'passcodeLen', 'wallUrl', 'editorUrl')))
+ if (in_array($name, self::$virtualFields))
throw new KeyedException('unknown-field');
// Sanitize values
@@ -339,6 +356,7 @@ class Wall {
'duration', 'defaultDuration',
'ownerEmail', 'passcodeLen',
'designId',
+ 'thumbnail',
'status', 'latestSession');
$result = array();
@@ -493,6 +511,13 @@ class Wall {
return false;
return $this->email == $this->ownerEmail;
}
+
+ private function getDesign() {
+ if ($this->_design === null && $this->designId) {
+ $this->_design = DesignGallery::getById($this->designId);
+ }
+ return $this->_design;
+ }
}
class Walls {
View
4 wall/public/wall-maker/css/wall-maker.css
@@ -353,6 +353,10 @@ label.manage-title:after {
#wall-info .message {
width: 80%;
}
+#wall-summary > div {
+ display: inline-block;
+ vertical-align: top;
+}
/*
* Management screen wall summmary
View
19 wall/public/wall-maker/index.html.php
@@ -123,14 +123,17 @@ class="button left arrow">戻る</a><br>
<div id="wall-info" aria-hidden="true">
<form name="manageWall">
<section id="wall-summary">
- <div class="autosave"><input type="text" id="manage-name"
- name="name"></div>
- <ul>
- <li><label class="manage-title">壁URL</label><label
- id="manage-wallUrl" class="manage-value"></label></li>
- <li><label class="manage-title">エディタURL</label><label
- id="manage-editorUrl" class="manage-value"></label></li>
- </ul>
+ <div id="wall-thumbnail"></div>
+ <div>
+ <div class="autosave"><input type="text" id="manage-name"
+ name="name"></div>
+ <ul>
+ <li><label class="manage-title">壁URL</label><label
+ id="manage-wallUrl" class="manage-value"></label></li>
+ <li><label class="manage-title">エディタURL</label><label
+ id="manage-editorUrl" class="manage-value"></label></li>
+ </ul>
+ </div>
</section>
<hr>
<div class="message" aria-hidden="true">
View
19 wall/public/wall-maker/js/manage-wall.js
@@ -157,6 +157,9 @@ var ManageWallController =
// Basic data
$("manage-name").value = wall.name;
+ // Set thumbnail
+ this.updateThumbnail(wall.thumbnail);
+
// Make up links
this.updateShortenableLink($('manage-wallUrl'), wall.wallUrl,
wall.wallUrlShort);
@@ -209,6 +212,22 @@ var ManageWallController =
// Characters
},
+ updateThumbnail: function(url) {
+ var container = $('wall-thumbnail');
+
+ // Empty container
+ while (container.hasChildNodes())
+ container.removeChild(container.lastChild);
+
+ if (!url)
+ return;
+
+ // Create image
+ var img = document.createElement('img');
+ img.setAttribute("src", url);
+ container.appendChild(img);
+ },
+
updateShortenableLink: function(linkContainer, url, shortUrl) {
// Empty container
while (linkContainer.hasChildNodes()) {
View
4 wall/tests/api/TestGetWall.php
@@ -70,6 +70,10 @@ function testGetWall() {
"Unexpected shortened editor URL format: "
. $editorUrlShort);
+ // Check thumbnail
+ $this->assertEqual(@substr($wall['thumbnail'], -strlen("test.jpg")),
+ "test.jpg");
+
// Tidy up by removing the wall
$this->removeWall($wallId);
}
Please sign in to comment.
Something went wrong with that request. Please try again.