Your IP : 216.73.216.240
<?php
/*
* @package Tech Fry Library
* @license https://www.gnu.org/licenses/gpl-3.0.en.html
*/
namespace TechFry\Library\View\Sky;
defined('_JEXEC') or die;
// Display List (ul/ol) or Linked List with Icons
class Linklist extends Bootstrap
{
public $ul_class;
public $li_class;
public $a_class;
public $target;
public $class_options = array('link_class', 'link_color', 'link_opacity', 'link_opacity_hover');
public function display()
{
// item - url, title, icon, aria_label
// config - type, list_class, list_item_class, link_class, link_color, link_opacity, link_opacity_hover,
// icon_class, icon_size, icon_color, icon_rotate, icon_animate
$this->data = (array) $this->data;
$type = $this->config['type'] ?? '';
switch ($type)
{
case 'list' :
$this->ul_class = 'list-unstyled ';
break;
case 'inline' :
$this->ul_class = 'list-inline ';
$this->li_class = 'list-inline-item ';
break;
case 'listgroup' :
$listgroup = new Listgroup($this->data, $this->config);
return $listgroup->display();
break;
case 'nav' :
$this->ul_class = 'nav ';
$this->li_class = 'nav-item ';
$this->a_class = 'nav-link ';
break;
}
// Class on ul tag
$this->ul_class .= $this->config['list_class'] ?? '';
// Class on li tag
$this->li_class .= $this->config['list_item_class'] ?? '';
// Class on a tag
$this->a_class .= $this->get_class();
$this->target = isset($this->config['link_target']) && $this->config['link_target'] ? '_blank' : '_self';
$list_items = [];
foreach ($this->data as $item)
{
$list_items[] = $this->get_item($item);
}
$htmltag = $this->config['htmltag'] ?? 'ul';
if ($htmltag == 'ul')
{
$output = $this->html->ul($list_items, array('class' => $this->ul_class), array('class' => $this->li_class));
}
elseif ($htmltag == 'ol')
{
$output = $this->html->ol($list_items, array('class' => $this->ul_class), array('class' => $this->li_class));
}
return $output;
}
public function get_item($item)
{
// $item can be array or string
if (is_scalar($item))
{
return $item;
}
$item = (array) $item;
$icon = new Icon([], $this->config);
$output = '';
if (isset($item['icon']) && $item['icon'])
{
$icon->reset_data($item['icon']);
$output .= $icon->display() . ' ';
}
if (isset($item['title']) && $item['title'])
{
$output .= $item['title'];
}
if (isset($item['url']) && $item['url'])
{
$aria_label = $item['aria_label'] ?? '';
$attribs = array(
'title' => $item['title'],
'class' => $this->a_class,
'target' => $this->target,
'aria_label' => $aria_label,
'href' => $item['url'],
);
$output = $this->html->a($output, $attribs);
}
return $output;
}
}