mirror of
https://github.com/joomla-extensions/weblinks.git
synced 2025-01-27 14:28:30 +00:00
Remove un-used helpers
This commit is contained in:
parent
922e4353eb
commit
1a415435af
@ -1,192 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
JTable::addIncludePath(__DIR__ . '/../tables');
|
||||
|
||||
/**
|
||||
* Content associations helper.
|
||||
*
|
||||
* @since __DEPLOY_VERSION__
|
||||
*/
|
||||
class WeblinksAssociationsHelper extends JAssociationExtensionHelper
|
||||
{
|
||||
/**
|
||||
* The extension name
|
||||
*
|
||||
* @var array $extension
|
||||
*
|
||||
* @since __DEPLOY_VERSION__
|
||||
*/
|
||||
protected $extension = 'com_weblinks';
|
||||
|
||||
/**
|
||||
* Array of item types
|
||||
*
|
||||
* @var array $itemTypes
|
||||
*
|
||||
* @since __DEPLOY_VERSION__
|
||||
*/
|
||||
protected $itemTypes = array('weblink', 'category');
|
||||
|
||||
/**
|
||||
* Has the extension association support
|
||||
*
|
||||
* @var boolean $associationsSupport
|
||||
*
|
||||
* @since __DEPLOY_VERSION__
|
||||
*/
|
||||
protected $associationsSupport = true;
|
||||
|
||||
/**
|
||||
* Get the associated items for an item
|
||||
*
|
||||
* @param string $typeName The item type
|
||||
* @param int $id The id of item for which we need the associated items
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since __DEPLOY_VERSION__
|
||||
*/
|
||||
public function getAssociations($typeName, $id)
|
||||
{
|
||||
$type = $this->getType($typeName);
|
||||
|
||||
$context = $this->extension . '.item';
|
||||
$catidField = 'catid';
|
||||
|
||||
if ($typeName === 'category')
|
||||
{
|
||||
$context = 'com_categories.item';
|
||||
$catidField = '';
|
||||
}
|
||||
|
||||
// Get the associations.
|
||||
$associations = JLanguageAssociations::getAssociations(
|
||||
$this->extension,
|
||||
$type['tables']['a'],
|
||||
$context,
|
||||
$id,
|
||||
'id',
|
||||
'alias',
|
||||
$catidField
|
||||
);
|
||||
|
||||
return $associations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get item information
|
||||
*
|
||||
* @param string $typeName The item type
|
||||
* @param int $id The id of item for which we need the associated items
|
||||
*
|
||||
* @return JTable|null
|
||||
*
|
||||
* @since __DEPLOY_VERSION__
|
||||
*/
|
||||
public function getItem($typeName, $id)
|
||||
{
|
||||
if (empty($id))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$table = null;
|
||||
|
||||
switch ($typeName)
|
||||
{
|
||||
case 'weblink':
|
||||
$table = JTable::getInstance('Weblink', 'WeblinksTable');
|
||||
break;
|
||||
|
||||
case 'category':
|
||||
$table = JTable::getInstance('Category');
|
||||
break;
|
||||
}
|
||||
|
||||
if (empty($table))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$table->load($id);
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about the type
|
||||
*
|
||||
* @param string $typeName The item type
|
||||
*
|
||||
* @return array Array of item types
|
||||
*
|
||||
* @since __DEPLOY_VERSION__
|
||||
*/
|
||||
public function getType($typeName = '')
|
||||
{
|
||||
$fields = $this->getFieldsTemplate();
|
||||
$tables = array();
|
||||
$joins = array();
|
||||
$support = $this->getSupportTemplate();
|
||||
$title = '';
|
||||
|
||||
if (in_array($typeName, $this->itemTypes))
|
||||
{
|
||||
switch ($typeName)
|
||||
{
|
||||
case 'weblink':
|
||||
|
||||
$support['state'] = true;
|
||||
$support['acl'] = true;
|
||||
$support['checkout'] = true;
|
||||
$support['category'] = true;
|
||||
$support['save2copy'] = true;
|
||||
|
||||
$tables = array(
|
||||
'a' => '#__weblinks'
|
||||
);
|
||||
|
||||
$title = 'weblink';
|
||||
break;
|
||||
|
||||
case 'category':
|
||||
$fields['created_user_id'] = 'a.created_user_id';
|
||||
$fields['ordering'] = 'a.lft';
|
||||
$fields['level'] = 'a.level';
|
||||
$fields['catid'] = '';
|
||||
$fields['state'] = 'a.published';
|
||||
|
||||
$support['state'] = true;
|
||||
$support['acl'] = true;
|
||||
$support['checkout'] = true;
|
||||
$support['level'] = true;
|
||||
|
||||
$tables = array(
|
||||
'a' => '#__categories'
|
||||
);
|
||||
|
||||
$title = 'category';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'fields' => $fields,
|
||||
'support' => $support,
|
||||
'tables' => $tables,
|
||||
'joins' => $joins,
|
||||
'title' => $title
|
||||
);
|
||||
}
|
||||
}
|
@ -1,94 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
JLoader::register('WeblinksHelper', JPATH_ADMINISTRATOR . '/components/com_weblinks/helpers/weblinks.php');
|
||||
|
||||
/**
|
||||
* Weblink HTML helper class.
|
||||
*
|
||||
* @since __DELPOY_VERSION__
|
||||
*/
|
||||
abstract class JHtmlWeblink
|
||||
{
|
||||
/**
|
||||
* Get the associated language flags
|
||||
*
|
||||
* @param integer $weblinkid The item id to search associations
|
||||
*
|
||||
* @return string The language HTML
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @since ___DEPLOY_VERSION__
|
||||
*/
|
||||
public static function association($weblinkid)
|
||||
{
|
||||
// Defaults
|
||||
$html = '';
|
||||
$associations = JLanguageAssociations::getAssociations('com_weblinks', '#__weblinks', 'com_weblinks.item', $weblinkid);
|
||||
|
||||
// Get the associations
|
||||
if ($associations)
|
||||
{
|
||||
foreach ($associations as $tag => $associated)
|
||||
{
|
||||
$associations[$tag] = (int) $associated->id;
|
||||
}
|
||||
|
||||
// Get the associated weblinks items
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('c.id, c.title as title')
|
||||
->select('l.sef as lang_sef, lang_code')
|
||||
->from('#__weblinks as c')
|
||||
->select('cat.title as category_title')
|
||||
->join('LEFT', '#__categories as cat ON cat.id=c.catid')
|
||||
->where('c.id IN (' . implode(',', array_values($associations)) . ')')
|
||||
->join('LEFT', '#__languages as l ON c.language=l.lang_code')
|
||||
->select('l.image')
|
||||
->select('l.title as language_title');
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$items = $db->loadObjectList('id');
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
throw new Exception($e->getMessage(), 500, $e);
|
||||
}
|
||||
|
||||
if ($items)
|
||||
{
|
||||
foreach ($items as &$item)
|
||||
{
|
||||
$text = strtoupper($item->lang_sef);
|
||||
$url = JRoute::_('index.php?option=com_weblinks&task=weblink.edit&id=' . (int) $item->id);
|
||||
|
||||
$tooltip = htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8') . '<br />' . JText::sprintf('JCATEGORY_SPRINTF', $item->category_title);
|
||||
$classes = 'hasPopover label label-association label-' . $item->lang_sef;
|
||||
|
||||
$item->link = '<a href="' . $url . '" title="' . $item->language_title . '" class="' . $classes
|
||||
. '" data-content="' . $tooltip . '" data-placement="top">'
|
||||
. $text . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
JHtml::_('bootstrap.popover');
|
||||
|
||||
$html = JLayoutHelper::render('joomla.content.associations', $items);
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user