Simplify a little the JSON, a little more to do. re # 73

This commit is contained in:
Sébastien Lucas 2013-06-17 22:23:58 +02:00
parent 23267e37fa
commit 2029ab7d01
5 changed files with 37 additions and 24 deletions

View file

@ -311,8 +311,6 @@ class EntryBook extends Entry
public function getContentArray () {
$entry = array ( "title" => $this->title);
$entry ["coverurl"] = $this->getCover ();
$entry ["thumbnailurl"] = $this->getCoverThumbnail ();
$entry ["book"] = $this->book->getContentArray ();
return $entry;
}

View file

@ -126,9 +126,9 @@ class Book extends Base {
$su = $link->hrefXhtml ();
}
return array ("hasCover" => $this->hasCover,
return array ("id" => $this->id,
"hasCover" => $this->hasCover,
"preferedData" => $preferedData,
"detailUrl" => $this->getDetailUrl (),
"rating" => $this->getRating (),
"pubDate" => $this->getPubDate (),
"languagesName" => $this->getLanguages (),

View file

@ -56,24 +56,28 @@
}
if (!is_null (getURLParam ("complete"))) {
$out ["const"] = array ("version" => VERSION, "i18n" => array (
"coverAlt" => localize("i18n.coversection"),
"authorsTitle" => localize("authors.title"),
"bookwordTitle" => localize("bookword.title"),
"tagsTitle" => localize("tags.title"),
"seriesTitle" => localize("series.title"),
"customizeTitle" => localize ("customize.title"),
"aboutTitle" => localize ("about.title"),
"previousAlt" => localize ("paging.previous.alternate"),
"nextAlt" => localize ("paging.next.alternate"),
"searchAlt" => localize ("search.alternate"),
"sortAlt" => localize ("sort.alternate"),
"homeAlt" => localize ("home.alternate"),
"permalinkAlt" => localize ("permalink.alternate"),
"pubdateTitle" => localize("pubdate.title"),
"languagesTitle" => localize("language.title"),
"contentTitle" => localize("content.summary"),
"sortorderAsc" => localize("search.sortorder.asc"),
"sortorderDesc" => localize("search.sortorder.desc")));
"coverAlt" => localize("i18n.coversection"),
"authorsTitle" => localize("authors.title"),
"bookwordTitle" => localize("bookword.title"),
"tagsTitle" => localize("tags.title"),
"seriesTitle" => localize("series.title"),
"customizeTitle" => localize ("customize.title"),
"aboutTitle" => localize ("about.title"),
"previousAlt" => localize ("paging.previous.alternate"),
"nextAlt" => localize ("paging.next.alternate"),
"searchAlt" => localize ("search.alternate"),
"sortAlt" => localize ("sort.alternate"),
"homeAlt" => localize ("home.alternate"),
"permalinkAlt" => localize ("permalink.alternate"),
"pubdateTitle" => localize("pubdate.title"),
"languagesTitle" => localize("language.title"),
"contentTitle" => localize("content.summary"),
"sortorderAsc" => localize("search.sortorder.asc"),
"sortorderDesc" => localize("search.sortorder.desc")),
"url" => array (
"detailUrl" => "index.php?page=13&id={0}&db={1}",
"coverUrl" => "fetch.php?id={0}&db={1}",
"thumbnailUrl" => "fetch.php?height=70&id={0}&db={1}"));
}
$out ["containsBook"] = 0;

View file

@ -16,7 +16,9 @@
<article class="books">
<span class="cover">
{{? entry.book.hasCover == 1}}
<a data-fancybox-group="group" class="fancycover" href="{{=entry.coverurl}}"><img src="{{=entry.thumbnailurl}}" alt="{{=it.const.i18n.coverAlt}}" /></a>
<a data-fancybox-group="group" class="fancycover" href="{{=strformat (it.const.url.coverUrl, entry.book.id, it.databaseId)}}">
<img src="{{=strformat (it.const.url.thumbnailUrl, entry.book.id, it.databaseId)}}" alt="{{=it.const.i18n.coverAlt}}" />
</a>
{{?}}
</span>
<h2 class="download">
@ -24,7 +26,7 @@
<a href="{{=data.url}}">{{=data.name}}</a><br />
{{~}}
</h2>
<a class="fancydetail" href="{{=entry.book.detailUrl}}">
<a class="fancydetail" href="{{=strformat (it.const.url.detailUrl, entry.book.id, it.databaseId)}}">
<div class="fullclickpopup">
<h2><span class="st">{{=htmlEscape (entry.title)}}</span>
{{? entry.book.pubDate != ""}}<span class="sp">({{=entry.book.pubDate}})</span>{{?}}

View file

@ -14,6 +14,15 @@ function fancyBoxObject (title, type) {
return out;
}
function strformat () {
var s = arguments[0];
for (var i = 0; i < arguments.length - 1; i++) {
var reg = new RegExp("\\{" + i + "\\}", "gm");
s = s.replace(reg, arguments[i + 1]);
}
return s;
}
function getCurrentOption (option) {
return $.cookie (option);
}