- md5
- 829efd8153124c62a900049993a0860b
- sha1
- 0eaad2f3f609eba3e13db10158b9a82222b1baac
- sha256
- 33729b1a05d12ee57b41e9362ff170c6532ddcb0f44621ac14bc8a067dff0562
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
<?php
/**
* @package Joomla.Libraries
* @subpackage helper
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Utitlity class for associations in multilang
*
* @package Joomla.Libraries
* @subpackage Language
* @since 3.1
*/
class JLanguageAssociations
{
/**
* Get the associations.
*
* @param string $extension The name of the component.
* @param string $tablename The name of the table.
* @param string $context The context
* @param integer $id The primary key value.
* @param string $pk The name of the primary key in the given $table.
* @param string $aliasField If the table has an alias field set it here. Null to not use it
* @param string $catField If the table has a catid field set it here. Null to not use it
*
* @return array The associated items
*
* @since 3.1
*/
public static function getAssociations($extension, $tablename, $context, $id, $pk = 'id', $aliasField = 'alias', $catField = 'catid')
{
$associations = array();
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('c2.language'))
->from($db->quoteName($tablename, 'c'))
->join('INNER', $db->quoteName('#__associations', 'a') . ' ON a.id = c.id AND a.context=' . $db->quote($context))
->join('INNER', $db->quoteName('#__associations', 'a2') . ' ON a.key = a2.key')
->join('INNER', $db->quoteName($tablename, 'c2') . ' ON a2.id = c2.' . $db->quoteName($pk));
// Use alias field ?
if (!empty($aliasField))
{
$query->select(
$query->concatenate(
array(
$db->quoteName('c2.' . $pk),
$db->quoteName('c2.' . $aliasField)
),
':'
) . ' AS ' . $db->quoteName($pk)
);
}
else
{
$query->select($db->quoteName('c2.' . $pk));
}
// Use catid field ?
if (!empty($catField))
{
$query->join('INNER', $db->quoteName('#__categories', 'ca') . ' ON ' . $db->quoteName('c2.' . $catField) . ' = ca.id AND ca.extension = ' . $db->quote($extension))
->select(
$query->concatenate(
array('ca.id', 'ca.alias'),
':'
) . ' AS ' . $db->quoteName($catField)
);
}
$query->where('c.id =' . (int) $id);
$db->setQuery($query);
try
{
$items = $db->loadObjectList('language');
}
catch (runtimeException $e)
{
throw new Exception($e->getMessage(), 500);
return false;
}
if ($items)
{
foreach ($items as $tag => $item)
{
$associations[$tag] = $item;
}
}
return $associations;
}
}
The same content is in 2 releases, Joomla 3.1.0 to 3.1.1. See them all, or every version of this file.