Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix list view icons with custom links #2026

Merged
merged 2 commits into from May 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,32 @@
<?php
/**
* Layout: element custom details link on icon
*
* @package Joomla
* @subpackage Fabrik
* @copyright Copyright (C) 2005-2016 Media A-Team, Inc. - All rights reserved.
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
* @since 3.3.3
*/

// No direct access
defined('_JEXEC') or die('Restricted access');
$d = $displayData;

?>
<a data-loadmethod="<?php echo $d->loadMethod;?>"
class="<?php echo $d->class; ?> fabrikTip"
data-list="<?php echo $d->dataList; ?>"
data-isajax="<?php echo $d->isAjax; ?>"
data-rowid="<?php echo $d->rowId; ?>"
data-iscustom="<?php if ($d->isCustom) echo '1'; else echo '0'; ?>"
href="<?php echo $d->link; ?>"
<?php if ($d->target !== '') : ?>
target="<?php echo $d->target; ?>"
<?php endif; ?>
opts='<?php echo $d->opts; ?>'
title="<?php echo $d->title; ?>"
data-trigger="hover"
>
<?php echo $d->data; ?>
</a>
23 changes: 21 additions & 2 deletions components/com_fabrik/models/list.php
Expand Up @@ -2320,12 +2320,23 @@ public function _addLink($data, &$elementModel, $row, $repeatCounter = 0)
$rowId = $this->getSlug($row);
$isAjax = $this->isAjaxLinks() ? '1' : '0';
$isCustom = $customLink !== '';
$isIcon = FALSE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lower case


/* Check if the data component is html, if it is an icon lnk and image parse it out */
if (class_exists('DOMDocument')) {
$html = new DOMDocument;
$html->loadHTML($data);
$a = $html->getElementsByTagName('a')->item(0);
$img = $html->getElementsByTagName('img')->item(0);
if (isset($html) && isset($a) && isset($img))
$isIcon = TRUE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put {} around the body. I know it's not technically required for a single statement.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lower case

}

$paths = array(
COM_FABRIK_FRONTEND . '/views/list/tmpl/' . $this->getTmpl() . '/layouts/element/' . $elementModel->getFullName(true, false)
);

$layout = $this->getLayout('element.fabrik-element-custom-link', $paths);
$layout = $isIcon ? $this->getLayout('element.fabrik-element-custom-icon-link', $paths) : $this->getLayout('element.fabrik-element-custom-link', $paths);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid long lines, or PHP Storm will perpetually bitch at me about it. So only use inline condition for short stuff. Put this in a normal if/else.

$displayData = new stdClass;
$displayData->loadMethod = $loadMethod;
$displayData->dataList = $dataList;
Expand All @@ -2335,8 +2346,16 @@ public function _addLink($data, &$elementModel, $row, $repeatCounter = 0)
$displayData->class = $class;
$displayData->link = $link;
$displayData->rowId = $rowId;
$displayData->data = $data;
$displayData->target = $target;

if ($isIcon) {
$displayData->data_original = $a->nodeValue;
$displayData->opts = $a->getAttribute('opts');
$displayData->data = $a->ownerDocument->saveHTML($img);
$displayData->title = $a->getAttribute('title');
} else {
$displayData->data = $data;
}
$data = $layout->render($displayData);

return $data;
Expand Down