Added getLink function to Model

This commit is contained in:
marcdeb1 2018-10-10 13:25:48 +02:00
parent 0d1bd292fe
commit 1505548a3a
2 changed files with 11 additions and 19 deletions

View file

@ -5,7 +5,14 @@ namespace App\Model\Entity;
use Cake\ORM\Entity;
class Claim extends Entity {
function getLink() {
$link = $this->Name;
if (isset($this->Publisher->Name)) {
$link = $this->Publisher->Name . '/' . $link;
}
$link = 'lbry://' . $link;
return $link;
}
}
?>

View file

@ -40,11 +40,6 @@
$a = ['purple', 'orange', 'blue', 'teal', 'green', 'yellow'];
$autoThumbText = '';
$rawLink = $claim->Name;
if (isset($claim->Publisher->Name)) {
$rawLink = $claim->Publisher->Name . '/' . $rawLink;
}
$rawLink = 'lbry://' . $rawLink;
if ($claim->ClaimType == 1) { $autoThumbText = strtoupper(substr($claim->Name, 1, min( strlen($claim->Name), 10 ))); } else {
$str = str_replace(' ', '', (strlen(trim($claim->Title)) > 0) ? $claim->Title : $claim->Name);
$autoThumbText = strtoupper(mb_substr($str, 0, min( strlen($str), 10 )));
@ -141,7 +136,7 @@ if (strlen(trim($desc)) == 0) {
<div class="value half-width"><?php echo strlen(trim($claim->Language)) > 0 ? ($claim->Language == 'en' ? 'English' : '') : '<em>Unspecified</em>' ?></div>
</div>
<?php endif; ?>
<a href="<?php echo $rawLink ?>" class="open-lbry-link">Open in LBRY</a>
<a href="<?php echo $claim->getLink() ?>" class="open-lbry-link">Open in LBRY</a>
</div>
<div class="clear"></div>
@ -162,11 +157,6 @@ if (strlen(trim($desc)) == 0) {
}
$autoThumbText = '';
$rawLink = $claim->Name;
if (isset($claim->Publisher->Name)) {
$rawLink = $claim->Publisher->Name . '/' . $rawLink;
}
$rawLink = 'lbry://' . $rawLink;
$cost = '';
if (isset($claim->Price) && $claim->Price > 0) {
$cost = $this->Amount->formatCurrency($claim->Price) . ' LBC';
@ -218,7 +208,7 @@ if (strlen(trim($desc)) == 0) {
<div class="metadata">
<div class="title" title="<?php echo $claim->ClaimType == 1 ? $claim->Name : ((strlen(trim($claim->Title)) > 0) ? $claim->Title : '') ?>"><?php echo $claim->ClaimType == 1 ? $claim->Name : ((strlen(trim($claim->Title)) > 0) ? $claim->Title : '<em>No Title</em>') ?></div>
<div class="link" title="<?php echo $rawLink ?>"><a href="<?php echo $rawLink ?>" rel="nofollow"><?php echo $rawLink ?></a></div>
<div class="link" title="<?php echo $claim->getLink() ?>"><a href="<?php echo $claim->getLink() ?>" rel="nofollow"><?php echo $claim->getLink() ?></a></div>
<div class="desc"><?php echo strlen(trim($claim->Description)) > 0 ? $claim->Description : '<em>No description available</em>' ?></div>
@ -285,11 +275,6 @@ if (strlen(trim($desc)) == 0) {
$row++;
}
$autoThumbText = '';
$rawLink = $claim->Name;
if (isset($claim->Publisher->Name)) {
$rawLink = $claim->Publisher->Name . '/' . $rawLink;
}
$rawLink = 'lbry://' . $rawLink;
$cost = '';
if (isset($claim->Price) && $claim->Price > 0) {
$cost = $this->Amount->formatCurrency($claim->Price) . ' LBC';
@ -341,7 +326,7 @@ if (strlen(trim($desc)) == 0) {
<div class="metadata">
<div class="title" title="<?php echo $claim->ClaimType == 1 ? $claim->Name : ((strlen(trim($claim->Title)) > 0) ? $claim->Title : '') ?>"><?php echo $claim->ClaimType == 1 ? $claim->Name : ((strlen(trim($claim->Title)) > 0) ? $claim->Title : '<em>No Title</em>') ?></div>
<div class="link" title="<?php echo $rawLink ?>"><a href="<?php echo $rawLink ?>" rel="nofollow"><?php echo $rawLink ?></a></div>
<div class="link" title="<?php echo $claim->getLink() ?>"><a href="<?php echo $claim->getLink() ?>" rel="nofollow"><?php echo $claim->getLink() ?></a></div>
<div class="desc"><?php echo strlen(trim($claim->Description)) > 0 ? $claim->Description : '<em>No description available</em>' ?></div>