Commit eff9bbf8 authored by Fabrice Gangler's avatar Fabrice Gangler 🎨
Browse files

REFACATOR: image carto WIP

parent 253ce1ac
......@@ -21,11 +21,12 @@ class SoftwareHelper extends ListItemHelper
'software' =>
'<li {{attrsColumn}}>
<div {{attrsBlock}}>
{{LinkItem}}
<div class="size-logo">
{{LinkImage}}
</div>
{{softwareName}}
<a class="linkItem" title="{{linkTitle}}" href="#">
<div class="size-logo">
{{LinkImage}}
</div>
{{softwareName}}
</a>
<p {{attrsDescription}}>{{softwareDescription}}</p>
<div class="rating-unit">{{review_average}}</div>
</div>
......@@ -44,7 +45,8 @@ class SoftwareHelper extends ListItemHelper
$result = null;
if (!empty($software)) {
$logo = $this->displayLogoLink($software);
// $logo = $this->displayLogoLink($software);
$logo = $this->displayLogo($software, true);
$attrsColumn = $this->templater()->formatAttributes(['class' => 'col-xs-12 col-sm-6 col-md-3 col-lg-3']);
$attrsBlock = $this->templater()->formatAttributes(['class' => 'software-unit-home backgroundUnit',
......@@ -56,20 +58,12 @@ class SoftwareHelper extends ListItemHelper
'attrsColumn' => $attrsColumn,
'attrsBlock' => $attrsBlock,
'review_average' => $this->Rating->display($software->average_review),
'softwareName' =>
$this->Html->link(
$this->Text->truncate($software->softwarename, 35, ['ellipsis' => '...', 'exact' => false]),
[
'language' => $selectedLanguage,
'prefix' => false,
'controller' => 'softwares',
"action" => $software->id
],
[
'escape' => false,
'title' => __d("Softwares", "software.softwareName") . $software->softwarename
]
),
'linkTitle' => __d("Softwares", "Software name : ") .' '. $software->softwarename,
'softwareName' => $this->Text->truncate(
$software->softwarename,
35,
['ellipsis' => '...', 'exact' => false]
),
'LinkImage' => $logo,
'attrsDescription' => $this
->templater()
......@@ -96,6 +90,47 @@ class SoftwareHelper extends ListItemHelper
return $result;
}
/**
* Return a link with containing the software'logo if it get one, placeholder otherwise
*
* @param $software
* @return mixed
*/
public function displayLogo($software, $emptyAlt = false)
{
// This helper is used all the time.
// But, the $selectedLanguage variable is not available.
// We force its creation by using a translation string that is always available.
if (!isset($selectedLanguage)) {
$selectedLanguage = __d("default", "lang.id"); // "fr" or "en"
}
$alt = $software->softwarename;
if ($emptyAlt === true) {
$alt = '';
}
return !$this->hasLogo($software) || is_null($software->photo) || empty($software->photo) ?
$this->Html->image(
"logos/placeholder_software.svg",
[
"alt" => $alt,
"class" => "img-responsive",
"loading" => "lazy"
]
)
:
$this->Html->image(
$software->logo_directory . DS . $software->photo,
[
"alt" => $alt,
"class" => "img-responsive",
"loading" => "lazy"
]
);
}
/**
* Return a link with containing the software'logo if it get one, placeholder otherwise
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment