- md5
- 51ff120c2832d8b6e77c9bb2fe5b0674
- sha1
- 8d8a3bba344c6678891ef59988307431b56dca00
- sha256
- f0ae2176d587e3344fc596ed0fad5322e336b12c4796570116fa9be8a8184f50
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Helper;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Access\Access;
use Joomla\CMS\Application\ApplicationHelper;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\LanguageHelper;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Log\Log;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Table\Table;
use Joomla\Registry\Registry;
/**
* Helper for standard content style extensions.
* This class mainly simplifies static helper methods often repeated in individual components
*
* @since 3.1
*/
class ContentHelper
{
/**
* Configure the Linkbar. Must be implemented by each extension.
*
* @param string $vName The name of the active view.
*
* @return void
*
* @since 3.1
*/
public static function addSubmenu($vName)
{
}
/**
* Gets a list of the actions that can be performed.
*
* @param string $component The component name.
* @param string $section The access section name.
* @param integer $id The item ID.
*
* @return CMSObject
*
* @since 3.2
*/
public static function getActions($component = '', $section = '', $id = 0)
{
$assetName = $component;
if ($section && $id)
{
$assetName .= '.' . $section . '.' . (int) $id;
}
$result = new CMSObject;
$user = Factory::getUser();
$actions = Access::getActionsFromFile(
JPATH_ADMINISTRATOR . '/components/' . $component . '/access.xml', '/access/section[@name="component"]/'
);
if ($actions === false)
{
Log::add(
Text::sprintf('JLIB_ERROR_COMPONENTS_ACL_CONFIGURATION_FILE_MISSING_OR_IMPROPERLY_STRUCTURED', $component), Log::ERROR, 'jerror'
);
return $result;
}
foreach ($actions as $action)
{
$result->set($action->name, $user->authorise($action->name, $assetName));
}
return $result;
}
/**
* Gets the current language
*
* @param boolean $detectBrowser Flag indicating whether to use the browser language as a fallback.
*
* @return string The language string
*
* @since 3.1
* @note CmsHelper::getCurrentLanguage is the preferred method
*/
public static function getCurrentLanguage($detectBrowser = true)
{
$app = Factory::getApplication();
$langCode = null;
// Get the languagefilter parameters
if (Multilanguage::isEnabled())
{
$plugin = PluginHelper::getPlugin('system', 'languagefilter');
$pluginParams = new Registry($plugin->params);
if ((int) $pluginParams->get('lang_cookie', 1) === 1)
{
$langCode = $app->input->cookie->getString(ApplicationHelper::getHash('language'));
}
else
{
$langCode = $app->getSession()->get('plg_system_languagefilter.language');
}
}
// No cookie - let's try to detect browser language or use site default
if (!$langCode)
{
if ($detectBrowser)
{
$langCode = LanguageHelper::detectLanguage();
}
else
{
$langCode = ComponentHelper::getParams('com_languages')->get('site', 'en-GB');
}
}
return $langCode;
}
/**
* Gets the associated language ID
*
* @param string $langCode The language code to look up
*
* @return integer The language ID
*
* @since 3.1
* @note CmsHelper::getLanguage() is the preferred method.
*/
public static function getLanguageId($langCode)
{
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select('lang_id')
->from('#__languages')
->where($db->quoteName('lang_code') . ' = ' . $db->quote($langCode));
$db->setQuery($query);
return $db->loadResult();
}
/**
* Gets a row of data from a table
*
* @param Table $table Table instance for a row.
*
* @return array Associative array of all columns and values for a row in a table.
*
* @since 3.1
*/
public function getRowData(Table $table)
{
$data = new CMSHelper;
return $data->getRowData($table);
}
}
The same content is in 2 releases, Joomla 4.0.0-alpha5 to 4.0.0-alpha6. See them all, or every version of this file.