Skip to content

Instantly share code, notes, and snippets.

@jover2015
Last active October 27, 2015 07:29
Show Gist options
  • Save jover2015/08e187b07bac61cb5d81 to your computer and use it in GitHub Desktop.
Save jover2015/08e187b07bac61cb5d81 to your computer and use it in GitHub Desktop.
Linksammlung
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
require_once JPATH_SITE . '/components/com_weblinks/helpers/route.php';
require_once JPATH_SITE . '/components/com_weblinks/helpers/category.php';
JHtml::_('behavior.caption');
echo JLayoutHelper::render('joomla.content.categories_default', $this);
echo $this->loadTemplate('items');
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
$class = ' first';
$child_images = false; ?>
<?php foreach ($this->weblinks as $id => $child) :
$child_images = json_decode($child->images);
if (!isset($this->weblinks[$id + 1]))
{
$class = ' last"';
}
?>
<div class="row<?php echo $class; ?>">
<?php $class = ''; ?>
<div class="col-xs-12 col-sm-3">
<?php if($child_images && $child_images->image_first != '') : ?>
<?php if($child_images->image_first_caption != '') : ?>
<figure>
<?php else : ?>
<div class="figure">
<?php endif; ?>
<img src="<?php echo $child_images->image_first; ?>" alt="<?php echo $child_images->image_first_alt; ?>" class="img-circle img-responsive img-thumbnail link-list"/>
<?php if($child_images->image_first_caption != '') : ?>
<figcaption><?php echo $this->escape($child_images->image_first_caption); ?></figcaption>
<?php endif; ?>
<?php if($child_images->image_first_caption != '') : ?>
</figure>
<?php else : ?>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
<div class="col-xs-12 col-sm-9">
<h3 class="item-title link-list"><a target="_blank" title="<?php echo $this->escape($child->title); ?>" href="<?php echo JRoute::_(WeblinksHelperRoute::getWeblinkRoute($child->id, $child->catid)); ?>"><?php echo $this->escape($child->title); ?></a></h3>
<?php if ($child->description) : ?>
<?php echo JHtml::_('content.prepare', $child->description, '', 'com_weblinks.categories'); ?>
<?php endif; ?>
<a target="_blank" title="<?php echo $this->escape($child->title); ?>" href="<?php echo JRoute::_(WeblinksHelperRoute::getWeblinkRoute($child->id, $child->catid)); ?>"><?php echo $this->escape($child->url); ?></a>
</div>
</div>
<?php endforeach; ?>
<?php
/**
* @package Joomla.Site
* @subpackage com_weblinks
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('bootstrap.tooltip');
$class = ' first';
if (count($this->items[$this->parent->id]) > 0 && $this->maxLevelcat != 0) :
?>
<?php foreach ($this->items[$this->parent->id] as $id => $item) :
// Get an instance of the generic articles model
$model = JModelLegacy::getInstance('Category', 'WeblinksModel', array('ignore_request' => true));
// Set application parameters in model
$app = JFactory::getApplication();
$appParams = $app->getParams();
$model->setState('params', $appParams);
// Set the filters based on the module params
$model->setState('list.start', 0);
$model->setState('list.limit', (int) $appParams->get('history_limit', 5));
$model->setState('filter.state', 1);
$model->setState('filter.publish_date', true);
// Access filter
$access = !JComponentHelper::getParams('com_weblinks')->get('show_noauth');
$model->setState('filter.access', $access);
$catid = (int) $item->id;
$model->setState('category.id', $catid);
// Create query object
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('a.alias', '!=', '0');
$case_when1 .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when1 .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $a_id . ' END as slug';
$case_when2 = ' CASE WHEN ';
$case_when2 .= $query->charLength('c.alias', '!=', '0');
$case_when2 .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when2 .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when2 .= ' ELSE ';
$case_when2 .= $c_id . ' END as catslug';
$model->setState(
'list.select',
'a.*, c.published AS c_published,' . $case_when1 . ',' . $case_when2 . ',' . 'DATE_FORMAT(a.created, "%Y-%m-%d") AS created'
);
$model->setState('filter.c.published', 1);
// Filter by language
$model->setState('filter.language', $app->getLanguageFilter());
$childs = $model->getItems();
if ($this->params->get('show_empty_categories_cat') || $item->numitems || count($item->getChildren())) :
if (!isset($this->items[$this->parent->id][$id + 1]))
{
$class = ' last';
}
?>
<div class="link-list category<?php echo $class; ?> clearfix" >
<?php $class = ''; ?>
<h2 class="page-header item-title">
<?php echo $this->escape($item->title); ?>
<?php if ($this->params->get('show_cat_num_articles_cat') == 1) : ?>
<span class="badge badge-info tip hasTooltip" title="<?php echo JHtml::tooltipText('COM_WEBLINKS_NUM_ITEMS'); ?>">
<?php echo $item->numitems; ?>
</span>
<?php endif; ?>
</h2>
<?php if ($this->params->get('show_description') && $item->description != '') : ?>
<div class="category-desc">
<?php echo JHtml::_('content.prepare', $item->description, '', 'com_weblinks.categories'); ?>
</div>
<?php endif; ?>
<?php if (count($childs) > 0) :
$this->weblinks = $childs;
echo $this->loadTemplate('childs');
endif; ?>
</div>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>
/* ANFANG JOVER_WEBLINKS */
.link-list.category .row {
margin-bottom: 2rem;
}
/* ENDE JOVER_WEBLINKS */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment