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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
||
/* 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
@@ -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; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lower case