Create HTML link element from data item

@param  \stdClass $item
@return string
766736
public function itemToString(\stdClass $item)
    {

    	$attributes = (array) $item;

        if (isset($attributes['type']) &&
                (($attributes['type'] == 'text/css') || ($attributes['type'] == 'text/less'))) {

            // This is a stylesheet, consider extension and compile .less to .css
            if (($attributes['type'] == 'text/less') || \MUtil_String::endsWith($attributes['href'], '.less', true)) {
                $this->compile($this->view, $attributes['href'], false);

                // Modify object, not the derived array
                $item->type = 'text/css';
                $item->href = substr($attributes['href'], 0, -4) . 'css';
            }
        }

        if (isset($this->view->currentVersion)) {
            $version = $this->view->currentVersion;

            if (property_exists($item, 'href')) {
                $item->href = $item->href . '?' . $version;
            }
        }
        
        return \Zend_View_Helper_HeadLink::itemToString($item);
    }
1273691
protected function renderItem($item)
    {
        $this->validateItems($item);
        $template = ArrayHelper::getValue($item, 'template', $this->linkTemplate);
        $url = Url::to(ArrayHelper::getValue($item, 'url', '#'));
        if (empty($item['top'])) {
            if (empty($item['items'])) {
                $template = str_replace('{icon}', $this->indItem . '{icon}', $template);
            } else {
                $template = '<a href="{url}" class="kv-toggle">{icon}{label}</a>';
                $openOptions = ($item['active']) ? ['class' => 'opened'] : ['class' => 'opened', 'style' => 'display:none'];
                $closeOptions = ($item['active']) ? ['class' => 'closed', 'style' => 'display:none'] : ['class' => 'closed'];
                $indicator = Html::tag('span', $this->indMenuOpen, $openOptions) . Html::tag('span', $this->indMenuClose, $closeOptions);
                $template = str_replace('{icon}', $indicator . '{icon}', $template);
            }
        }
        $icon = empty($item['icon']) ? '' : '<span class="' . $this->iconPrefix . $item['icon'] . '"></span> &nbsp;';
        unset($item['icon'], $item['top']);
        return strtr($template, [
            '{url}' => $url,
            '{label}' => $item['label'],
            '{icon}' => $icon
        ]);
    }
1204453
public function renderItem($item)
    {
        if (is_string($item)) {
            return $item;
        }
        if (!isset($item['label'])) {
            throw new InvalidConfigException("The 'label' option is required.");
        }
        $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
        $label = $encodeLabel ? Html::encode($item['label']) : $item['label'];
        $options = ArrayHelper::getValue($item, 'options', []);
        $items = ArrayHelper::getValue($item, 'items');
        $url = ArrayHelper::getValue($item, 'url', '#');
        $linkOptions = ArrayHelper::getValue($item, 'linkOptions', []);

        //HACK
        $label = "<span>".$label."</span>";
        $icon = isset($item['icon'])?$item['icon']:"";
        if(!empty($icon)){
            $label = "<i class='".$icon."'></i> ".$label;
        }
        $badge = isset($item['badge'])?$item['badge']:"";
        $badgeClass = isset($item['badgeClass'])?$item['badgeClass']:"";
        if(!empty($badge)){
            $label = $label." <small class='badge ".@$badgeClass."'>".$badge."</small>";
        }

        if (isset($item['active'])) {
            $active = ArrayHelper::remove($item, 'active', false);
        } else {
            $active = $this->isItemActive($item);
        }

        if ($items !== null) {
            $linkOptions['data-toggle'] = 'dropdown';
            Html::addCssClass($options, 'treeview');
            Html::addCssClass($linkOptions, 'dropdown-toggle');
            $label .= ' ' . Html::tag('i', '', ['class' => 'fa pull-right fa-angle-left']);
            if (is_array($items)) {
                if ($this->activateItems) {
                    $items = $this->isChildActive($items, $active);
                }
                $items = DropdownSide::widget([
                    'items' => $items,
                    'encodeLabels' => $this->encodeLabels,
                    'clientOptions' => false,
                    'view' => $this->getView(),
                ]);
            }
        }

        if ($this->activateItems && $active) {
            Html::addCssClass($options, 'active');
        }

        return Html::tag('li', Html::a($label, $url, $linkOptions) . $items, $options);
    }
225116
public static function menuLink($item)
    {
        $app = \JFactory::getApplication();
        $menu = $app->getMenu();
        $item = $menu->getItem($item);

        return \JRoute::_($item->link . '&Itemid=' . $item->id);
    }
702082
public function renderContent($item)
    {
        $options = ArrayHelper::merge($this->contentOptions, ArrayHelper::getValue($item, 'contentOptions', []));

        $encode = ArrayHelper::getValue($options, 'encode', true);
        $content = $encode ? Html::encode($item['content']) : $item['content'];

        Html::addCssClass($options, 'content');
        if ($item['active']) {
            Html::addCssClass($options, 'active');
        }
        return Html::tag('div', $content, $options);
    }
856333
protected function createFormField($item)
    {
        $required = ($item['required'] === true) ? ", 'required' => 'required'" : "";

        return $this->wrapField(
            $item,
            "{!! Form::" . $this->typeLookup[$item['type']] . "('" . $item['name'] . "', null, ['class' => 'form-control'$required]) !!}"
        );
    }
193558
public function createMenuNode($data) {
		$cls = $this->itemClass;
		$node = $cls::create($data, $this);
		$this->items[$node->ID] = $node;
		return $node;
	}
326989
protected function parseTemplate(array $item) {
        /**
         * Check if a title has been assigned to the element
         */
        if (isset($item['title'])) {
            $this->htmlOptions['linkOptions']['title'] = $item['title'];
        }
        /**
         * Parse the template
         */
        $replace = Html::a(Html::img($item['src'], $this->htmlOptions['thumbnailOptions']), $item['href'], $this->htmlOptions['linkOptions']);
        $template = str_replace('{item}', $replace, $this->template);
        return $template;
    }
337866
protected function getRenderedItem($item) {

        //@todo make getRenderedItem language dependent
        $lang = \common_session_SessionManager::getSession()->getDataLanguage();
        $qtiItem = Service::singleton()->getDataItemByRdfItem($item, $lang, true);
        if ($qtiItem) {
            $contentVariableElements = array_merge($this->getModalFeedbacks($qtiItem), $this->getRubricBlocks($qtiItem));

            /** @var AssetService $assetService */
            $assetService = ServiceManager::getServiceManager()->get(AssetService::SERVICE_ID);

            $taoBaseUrl = $assetService->getJsBaseWww( 'tao' );
            $qtiBaseUrl = $assetService->getJsBaseWww( 'taoQtiItem' );

            $taoLibUrl = $taoBaseUrl.'js/';
            $taoQtiItemLibUrl = $qtiBaseUrl.'js/';

            $xhtml = $qtiItem->toXHTML(array(
                'contentVariableElements' => $contentVariableElements,
                //  'js' => array($qtiBaseUrl.'js/preview/qtiViewSelector.js'),
                'js_var' => array('view' => $this->getRequestView()),
                // 'css' => array($qtiBaseUrl.'css/preview/qtiViewSelector.css'),
                'path' => array(
                    'tao' => $taoLibUrl,
                    'taoQtiItem' => $taoQtiItemLibUrl
                ),
                'client_config_url' => $this->getClientConfigUrl()

            ));
        } else {
            \common_Logger::i('Try to preview an empty item', [$item->getUri()]);
            $xhtml = '';
        }

        return $xhtml;
    }
24327
public function createItem($label = null, $href = null)
    {
        $link = new Link($label, $href);
        $link->attributes->addAttributeClass('dropdown-item');

        $this->childNodes->push($link);

        return $this->childNodes->last();
    }
293020
public function getViewUrlFor($item)
    {
        if (is_object($item)) {
            $id = $item->getid();
        } else {
            $id = $item['id'];
        }
        $params = ['id' => $id];
        $params = array_merge($params, $this->getExtraParameters());

        return [
            'path' => $this->getPathByConvention($this::SUFFIX_VIEW),
            'params' => $params,
        ];
    }
1358097
protected function renderMenuItem($item)
	{
		if(isset($item['url']))
		{
			$label=$this->linkLabelWrapper===null ? $item['label'] : CHtml::tag($this->linkLabelWrapper, $this->linkLabelWrapperHtmlOptions, $item['label']);
			return CHtml::link($label,$item['url'],isset($item['linkOptions']) ? $item['linkOptions'] : array());
		}
		else
			return CHtml::tag('span',isset($item['linkOptions']) ? $item['linkOptions'] : array(), $item['label']);
	}
124716
public function fromItem(Item $item)
    {
        return Comment::createFromArray(array_filter([
            'id' => $item->getId(),
            'source' => $item->get('source'),
            'parent' => $item->get('parent'),
            'author_uuid' => $item->get('author_uuid'),
            'author_name' => $item->get('author_name'),
            'author_email' => $item->get('author_email'),
            'author_avatar' => $item->get('author_avatar'),
            'author_role' => $item->get('author_role'),
            'thumb' => $item->get('thumb'),
            'rating' => $item->get('rating'),
            'content' => $item->get('content'),
            'state' => $item->get('state'),
            'created_at' =>  $item->get('created_at'),
        ]));
    }
689295
protected function renderItem($item = [])
    {
        $itemOptions = ArrayHelper::getValue($item, 'options', []);

        $headerOptions = ArrayHelper::getValue($item, 'header', []);
        $headerContent = ArrayHelper::remove($headerOptions, 'content');
        $headerTag = ArrayHelper::remove($headerOptions, 'tag', 'div');

        $bodyOptions = ArrayHelper::getValue($item, 'body', []);
        $bodyContent = ArrayHelper::remove($bodyOptions, 'content', []);
        $bodyTag = ArrayHelper::remove($bodyOptions, 'tag', 'div');

        if (!$headerContent && !$bodyContent) {
            return '';
        }

        $html[] = Html::beginTag('li', $itemOptions);
        if ($headerContent) {
            Html::addCssClass($headerOptions, ['header' => 'collapsible-header']);
            $html[] = Html::tag($headerTag, $headerContent, $headerOptions);
        }
        if ($bodyContent) {
            Html::addCssClass($bodyOptions, ['body' => 'collapsible-body']);
            $html[] = Html::tag($bodyTag, $bodyContent, $bodyOptions);
        }
        $html[] = Html::endTag('li');

        return implode("\n", $html);
    }
1001074
public function saveData($item)
    {
        $attributes = $item->dataProperties->getAttributesForSave($item->id);
        if(empty($attributes)) return false;

        $classData = static::getClassData();

        foreach ($attributes as $slug => $values)
        {

            $classData::deleteAll(['item_id' => $item->id, 'property_slug' => $slug]);
            $values = (is_array($values)) ? $values : [$values];

            foreach ($values as $value){

                $value = (is_array($value)) ? array_values($value)[0] : $value;

                $data = new $classData;
                $data->value = $value;
                $data->property_slug = $slug;
                $data->item_id = $item->id;
                if(!empty($value)) $data->save();
            }
        }
    }
1301310
protected function generateItemXmlString(Parts\Item $item, DOMDocument $dom)
    {
        $itemNode = $dom->createElement('item');

        foreach ($item->getState() as $attrName => $attrValue) {
            switch ($attrName) {
                case 'action':
                    if ($attrValue !== null) {
                        $itemNode->setAttribute('action', $attrValue);
                    }
                    break;
                case 'contentId':
                    $this->addNewNotEmptyXmlElement($dom, $itemNode, 'object_id', $attrValue);
                    break;
                case 'locationId':
                    $this->addNewNotEmptyXmlElement($dom, $itemNode, 'node_id', $attrValue);
                    break;
                case 'priority':
                    $this->addNewNotEmptyXmlElement($dom, $itemNode, 'priority', $attrValue);
                    break;
                case 'publicationDate':
                    $this->addNewNotEmptyXmlElement($dom, $itemNode, 'ts_publication', $attrValue);
                    break;
                case 'visibilityDate':
                    $this->addNewNotEmptyXmlElement($dom, $itemNode, 'ts_visible', $attrValue);
                    break;
                case 'hiddenDate':
                    $this->addNewNotEmptyXmlElement($dom, $itemNode, 'ts_hidden', $attrValue);
                    break;
                case 'rotationUntilDate':
                    $this->addNewNotEmptyXmlElement($dom, $itemNode, 'rotation_until', $attrValue);
                    break;
                case 'movedTo':
                    $this->addNewNotEmptyXmlElement($dom, $itemNode, 'moved_to', $attrValue);
                    break;
                case 'attributes':
                    foreach ($attrValue as $arrayItemKey => $arrayItemValue) {
                        $this->addNewNotEmptyXmlElement($dom, $itemNode, $arrayItemKey, $arrayItemValue);
                    }
                    break;
            }
        }

        return $itemNode;
    }
815149
protected function render_navigation_node(navigation_node $item) {
        $content = $item->get_content();
        $title = $item->get_title();
        if ($item->icon instanceof renderable && !$item->hideicon) {
            $icon = $this->render($item->icon);
            $content = $icon.$content; // use CSS for spacing of icons
        }
        if ($item->helpbutton !== null) {
            $content = trim($item->helpbutton).html_writer::tag('span', $content, array('class'=>'clearhelpbutton', 'tabindex'=>'0'));
        }
        if ($content === '') {
            return '';
        }
        if ($item->action instanceof action_link) {
            $link = $item->action;
            if ($item->hidden) {
                $link->add_class('dimmed');
            }
            if (!empty($content)) {
                // Providing there is content we will use that for the link content.
                $link->text = $content;
            }
            $content = $this->render($link);
        } else if ($item->action instanceof moodle_url) {
            $attributes = array();
            if ($title !== '') {
                $attributes['title'] = $title;
            }
            if ($item->hidden) {
                $attributes['class'] = 'dimmed_text';
            }
            $content = html_writer::link($item->action, $content, $attributes);

        } else if (is_string($item->action) || empty($item->action)) {
            $attributes = array('tabindex'=>'0'); //add tab support to span but still maintain character stream sequence.
            if ($title !== '') {
                $attributes['title'] = $title;
            }
            if ($item->hidden) {
                $attributes['class'] = 'dimmed_text';
            }
            $content = html_writer::tag('span', $content, $attributes);
        }
        return $content;
    }