Chainquery integration #49
3 changed files with 76 additions and 75 deletions
|
@ -171,7 +171,7 @@ class MainController extends AppController {
|
|||
$this->set('currentPage', $page);
|
||||
$this->set('claims', $claims);
|
||||
} else {
|
||||
$claim = $this->Claims->find()->select($this->Claims)->select(['Claims__publisher' => 'C.name'])->leftJoin(['C' => 'claim'], ['C.claim_id = Claims.publisher_id'])->where(['Claims.claim_id' => $id])->order(['Claims.created_at' => 'DESC'])->first();
|
||||
$claim = $this->Claims->find()->select($this->Claims)->select(['publisher' => 'C.name'])->leftJoin(['C' => 'claim'], ['C.claim_id = Claims.publisher_id'])->where(['Claims.claim_id' => $id])->order(['Claims.created_at' => 'DESC'])->first();
|
||||
if (!$claim) {
|
||||
return $this->redirect('/');
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ class MainController extends AppController {
|
|||
$moreClaims = [];
|
||||
if (isset($claim->publisher) || $claim->claim_type == 1) {
|
||||
// find more claims for the publisher
|
||||
$moreClaims = $this->Claims->find()->select($this->Claims)->select(['publisher' => 'C.name'])->leftJoin(['C' => 'claim'], ['C.claim_id = Claims.publisher_id'])->where(['Claims.claim_type' => 2, 'Claims.id <>' => $claim->id, 'Claims.publisher_id' => isset($claim->publisher) ? $claim->publisher_id : $claim->claim_id])->limit(9)->order(['Claims.fee' => 'DESC', 'RAND()' => 'DESC'])->toArray();
|
||||
$moreClaims = $this->Claims->find()->select($this->Claims)->select(['publisher' => 'C.name'])->leftJoin(['C' => 'claim'], ['C.claim_id = Claims.publisher_id'])->where(['Claims.claim_type' => 1, 'Claims.id <>' => $claim->id, 'Claims.publisher_id' => isset($claim->publisher) ? $claim->publisher_id : $claim->claim_id])->limit(9)->order(['Claims.fee' => 'DESC', 'RAND()' => 'DESC'])->toArray();
|
||||
for ($i = 0; $i < count($moreClaims); $i++) {
|
||||
if ($canConvert && $moreClaims[$i]->fee > 0 && $moreClaims[$i]->fee_currency == 'USD') {
|
||||
$moreClaims[$i]->price = $moreClaims[$i]->fee / $priceInfo->price;
|
||||
|
@ -210,7 +210,6 @@ class MainController extends AppController {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->set('claim', $claim);
|
||||
$this->set('moreClaims', $moreClaims);
|
||||
}
|
||||
|
|
72
src/Template/Element/claimbox.ctp
Normal file
72
src/Template/Element/claimbox.ctp
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
$autoThumbText = $claim->getAutoThumbText();
|
||||
$cost = '';
|
||||
if (isset($claim->Price) && $claim->Price > 0) {
|
||||
$cost = $this->Amount->formatCurrency($claim->Price) . ' LBC';
|
||||
} else if (isset($claim->fee) && strtolower($claim->fee_currency) === 'lbc') {
|
||||
$cost = $this->Amount->formatCurrency($claim->fee) . ' LBC';
|
||||
}
|
||||
$a = ['purple', 'orange', 'blue', 'teal', 'green', 'yellow'];
|
||||
// content type
|
||||
$ctTag = $claim->getContentTag();
|
||||
?>
|
||||
<div data-id="<?php echo $claim->claim_id ?>" class="claim-grid-item<?php if ($idx % 3 == 0): ?> last-item<?php endif; ?><?php if ($last_row): ?> last-row<?php endif; ?>">
|
||||
<?php if (strlen(trim($cost)) > 0): ?>
|
||||
<div class="price-tag"><?php echo $cost ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="tags">
|
||||
<?php if ($ctTag): ?>
|
||||
<div class="content-type"><?php echo strtoupper($ctTag) ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($claim->is_nsfw): ?>
|
||||
<div class="nsfw">NSFW</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div data-autothumb="<?php echo $autoThumbText ?>" class="thumbnail <?php echo $a[mt_rand(0, count($a) - 1)] ?>">
|
||||
<?php if (!$claim->is_nsfw && strlen(trim($claim->thumbnail_url)) > 0): ?>
|
||||
<img src="<?php echo htmlspecialchars($claim->thumbnail_url) ?>" alt="" />
|
||||
<?php else: ?>
|
||||
<div class="autothumb"><?php echo $autoThumbText ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="metadata">
|
||||
<div class="title" title="<?php echo $claim->claim_type == 1 ? $claim->name : ((strlen(trim($claim->title)) > 0) ? $claim->title : '') ?>"><?php echo $claim->claim_type == 1 ? $claim->name : ((strlen(trim($claim->title)) > 0) ? $claim->title : '<em>No Title</em>') ?></div>
|
||||
<div class="link" title="<?php echo $claim->getLbryLink() ?>"><a href="<?php echo $claim->getLbryLink() ?>" rel="nofollow"><?php echo $claim->getLbryLink() ?></a></div>
|
||||
|
||||
<div class="desc"><?php echo strlen(trim($claim->description)) > 0 ? $claim->description : '<em>No description available</em>' ?></div>
|
||||
|
||||
<div class="label half-width">Transaction</div>
|
||||
<div class="label half-width">Created</div>
|
||||
|
||||
<div class="value half-width"><a href="/tx/<?php echo $claim->transaction_hash_id ?>#output-<?php echo $claim->vout ?>" title="<?php echo $claim->transaction_hash_id ?>"><?php echo $claim->transaction_hash_id ?></a></div>
|
||||
<div class="value half-width" title="<?php echo $claim->created_at->format('j M Y H:i:s') ?> UTC">
|
||||
<?php echo \Carbon\Carbon::createFromTimestamp($claim->created_at->format('U'))->diffForHumans(); ?>
|
||||
</div>
|
||||
<div class="clear spacer"></div>
|
||||
|
||||
<?php if ($claim->claim_type == 1): ?>
|
||||
<div class="label half-width">Content Type</div>
|
||||
<div class="label half-width">Language</div>
|
||||
|
||||
<div class="value half-width" title="<?php echo $claim->content_type ?>"><?php echo $claim->content_type ?></div>
|
||||
<div class="value half-width" title="<?php echo $claim->language == 'en' ? 'English' : $claim->language ?>"><?php echo $claim->language == 'en' ? 'English' : $claim->language ?></div>
|
||||
|
||||
<div class="clear spacer"></div>
|
||||
|
||||
<div class="label half-width">Author</div>
|
||||
<div class="label half-width">License</div>
|
||||
|
||||
<!--
|
||||
<div class="value half-width" title="<?php echo strlen(trim($claim->author)) > 0 ? $claim->author : '<em>Unspecified</em>' ?>"><?php echo strlen(trim($claim->author)) > 0 ? $claim->author : '<em>Unspecified</em>' ?></div>
|
||||
<div class="value half-width" title="<?php echo strlen(trim($claim->license)) > 0 ? $claim->license : '' ?>">
|
||||
<?php if (strlen(trim($claim->LicenseUrl)) > 0): ?><a href="<?php echo $claim->LicenseUrl ?>" rel="nofollow" target="_blank"><?php endif; ?>
|
||||
<?php echo strlen(trim($claim->License)) > 0 ? $claim->License : '<em>Unspecified</em>' ?>
|
||||
<?php if (strlen(trim($claim->LicenseUrl))): ?></a><?php endif; ?>
|
||||
</div>
|
||||
-->
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
|
@ -154,7 +154,7 @@ if (strlen(trim($desc)) == 0) {
|
|||
if ($idx % 3 == 0) {
|
||||
$row++;
|
||||
}
|
||||
echo $this->element('claimbox', array('claim' => $claim));
|
||||
echo $this->element('claimbox', array('claim' => $claim, 'idx' => $idx, 'last_row' => $last_row));
|
||||
$idx++;
|
||||
endforeach; ?>
|
||||
<div class="clear"></div>
|
||||
|
@ -185,77 +185,7 @@ if (strlen(trim($desc)) == 0) {
|
|||
if ($idx % 3 == 0) {
|
||||
$row++;
|
||||
}
|
||||
$autoThumbText = $claim->getAutoThumbText();
|
||||
$cost = '';
|
||||
if (isset($claim->Price) && $claim->Price > 0) {
|
||||
$cost = $this->Amount->formatCurrency($claim->Price) . ' LBC';
|
||||
} else if (isset($claim->fee) && strtolower($claim->fee_currency) === 'lbc') {
|
||||
$cost = $this->Amount->formatCurrency($claim->fee) . ' LBC';
|
||||
}
|
||||
|
||||
// content type
|
||||
$ctTag = $claim->getContentTag();
|
||||
?>
|
||||
<div data-id="<?php echo $claim->claim_id ?>" class="claim-grid-item<?php if ($idx % 3 == 0): ?> last-item<?php endif; ?><?php if ($last_row): ?> last-row<?php endif; ?>">
|
||||
<?php if (strlen(trim($cost)) > 0): ?>
|
||||
<div class="price-tag"><?php echo $cost ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="tags">
|
||||
<?php if ($ctTag): ?>
|
||||
<div class="content-type"><?php echo strtoupper($ctTag) ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($claim->is_nsfw): ?>
|
||||
<div class="nsfw">NSFW</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div data-autothumb="<?php echo $autoThumbText ?>" class="thumbnail <?php echo $a[mt_rand(0, count($a) - 1)] ?>">
|
||||
<?php if (!$claim->is_nsfw && strlen(trim($claim->thumbnail_url)) > 0): ?>
|
||||
<img src="<?php echo htmlspecialchars($claim->thumbnail_url) ?>" alt="" />
|
||||
<?php else: ?>
|
||||
<div class="autothumb"><?php echo $autoThumbText ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="metadata">
|
||||
<div class="title" title="<?php echo $claim->claim_type == 1 ? $claim->name : ((strlen(trim($claim->title)) > 0) ? $claim->title : '') ?>"><?php echo $claim->claim_type == 1 ? $claim->name : ((strlen(trim($claim->title)) > 0) ? $claim->title : '<em>No Title</em>') ?></div>
|
||||
<div class="link" title="<?php echo $claim->getLbryLink() ?>"><a href="<?php echo $claim->getLbryLink() ?>" rel="nofollow"><?php echo $claim->getLbryLink() ?></a></div>
|
||||
|
||||
<div class="desc"><?php echo strlen(trim($claim->description)) > 0 ? $claim->description : '<em>No description available</em>' ?></div>
|
||||
|
||||
<div class="label half-width">Transaction</div>
|
||||
<div class="label half-width">Created</div>
|
||||
|
||||
<div class="value half-width"><a href="/tx/<?php echo $claim->transaction_hash ?>#output-<?php echo $claim->vout ?>" title="<?php echo $claim->transaction_hash ?>"><?php echo $claim->transaction_hash ?></a></div>
|
||||
<div class="value half-width" title="<?php echo $claim->created_at->format('j M Y H:i:s') ?> UTC">
|
||||
<?php echo \Carbon\Carbon::createFromTimestamp($claim->created_at->format('U'))->diffForHumans(); ?>
|
||||
</div>
|
||||
<div class="clear spacer"></div>
|
||||
|
||||
<?php if ($claim->claim_type == 2): ?>
|
||||
<div class="label half-width">Content Type</div>
|
||||
<div class="label half-width">Language</div>
|
||||
|
||||
<div class="value half-width" title="<?php echo $claim->content_type ?>"><?php echo $claim->content_type ?></div>
|
||||
<div class="value half-width" title="<?php echo $claim->language == 'en' ? 'English' : $claim->language ?>"><?php echo $claim->language == 'en' ? 'English' : $claim->language ?></div>
|
||||
|
||||
<div class="clear spacer"></div>
|
||||
|
||||
<div class="label half-width">Author</div>
|
||||
<div class="label half-width">License</div>
|
||||
|
||||
<!--
|
||||
<div class="value half-width" title="<?php echo strlen(trim($claim->author)) > 0 ? $claim->author : '<em>Unspecified</em>' ?>"><?php echo strlen(trim($claim->author)) > 0 ? $claim->author : '<em>Unspecified</em>' ?></div>
|
||||
<div class="value half-width" title="<?php echo strlen(trim($claim->license)) > 0 ? $claim->license : '' ?>">
|
||||
<?php if (strlen(trim($claim->LicenseUrl)) > 0): ?><a href="<?php echo $claim->LicenseUrl ?>" rel="nofollow" target="_blank"><?php endif; ?>
|
||||
<?php echo strlen(trim($claim->License)) > 0 ? $claim->License : '<em>Unspecified</em>' ?>
|
||||
<?php if (strlen(trim($claim->LicenseUrl))): ?></a><?php endif; ?>
|
||||
</div>
|
||||
-->
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div><?php
|
||||
echo $this->element('claimbox', array('claim' => $claim, 'idx' => $idx, 'last_row' => $last_row));
|
||||
$idx++;
|
||||
endforeach; ?>
|
||||
<div class="clear"></div>
|
||||
|
|
Loading…
Reference in a new issue