__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
/**
* @package DPCalendar
* @copyright Copyright (C) 2014 Digital Peak GmbH. <https://www.digital-peak.com>
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
*/
namespace DigitalPeak\Component\DPCalendar\Administrator\Controller;
\defined('_JEXEC') or die();
use DigitalPeak\Component\DPCalendar\Administrator\Helper\DPCalendarHelper;
use DigitalPeak\Component\DPCalendar\Administrator\Model\ToolsModel;
use Joomla\CMS\Language\LanguageHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
class TranslateController extends BaseController
{
public function fetch(): void
{
// The resource to fetch
$resource = $this->input->getCmd('resource', '');
if ($resource === '' || $resource === '0') {
echo json_encode([]);
$this->app->close();
}
// The stats data
$data = ['resource' => $resource, 'languages' => []];
// Loop over the local languages
foreach (LanguageHelper::getKnownLanguages() as $language) {
foreach ($this->getModel('Tools', 'Administrator')->getResourceStats($resource) as $tr) {
if ($tr->code != $language['tag']) {
continue;
}
$data['languages'][] = [
'tag' => $tr->code,
'percent' => $tr->translated_percent
];
}
}
// Send the data
echo json_encode($data);
$this->app->close();
}
public function update(): void
{
// The resource to update
$resource = $this->input->getCmd('resource');
if ($resource === '' || $resource === '0') {
return;
}
// Teh local languages
$localLanguages = [];
foreach (LanguageHelper::getKnownLanguages() as $language) {
$localLanguages[$language['tag']] = $language;
}
/** @var ToolsModel $model */
$model = $this->getModel('Tools', 'Administrator');
// The stats
foreach ($model->getResourceStats($resource) as $tr) {
// Ignore empty languages
if ((int)$tr->translated === 0) {
continue;
}
// Ignore en-GB
if ($tr->code === 'en-GB') {
continue;
}
// Check if the code is ok and if we have the language installed locally
if (!\array_key_exists($tr->code, $localLanguages)) {
continue;
}
// Get the content of the language
$content = $model->getResourceStrings($resource, (string)$tr->code);
if (!$content) {
continue;
}
// Compile the path of the file for the actual resource
$path = '';
if (str_contains($resource, 'com_')) {
$path = str_contains($resource, '-admin') ? JPATH_ADMINISTRATOR : JPATH_ROOT;
$path .= '/components/com_dpcalendar/language/' . $tr->code . '/' . $tr->code . '.'
. str_replace(['-', '.admin', '.site'], ['.', '', ''], $resource);
}
if (str_starts_with($resource, 'mod_')) {
$mod = str_replace('-sys', '', $resource);
$path = JPATH_ROOT;
$path .= '/modules/' . $mod . '/language/' . $tr->code . '/' . $tr->code . '.' . $mod;
}
if (str_starts_with($resource, 'plg_')) {
$plugin = $model->getPluginForName(str_replace('-sys', '', $resource));
if ($plugin !== null) {
$path = JPATH_PLUGINS . '/';
$path .= $plugin->folder . '/' . $plugin->element . '/language/' . $tr->code . '/' . $tr->code . '.' . $plugin->name;
}
}
// Check if it is a sys path
$path .= str_contains($resource, '-sys') ? '' : '.sys';
$path .= '.ini';
// When the file doesn't exist, ignore it
if (!is_dir(\dirname($path))) {
mkdir(\dirname($path), 0777, true);
}
// Write the content
file_put_contents($path, $content);
}
// Sent the conformation
DPCalendarHelper::sendMessage(
Text::sprintf('COM_DPCALENDAR_VIEW_TOOLS_TRANSLATE_UPDATE_RESOURCE_SUCCESS', $resource),
false,
['resource' => $resource]
);
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| CaldavController.php | File | 716 B | 0664 |
|
| CountriesController.php | File | 610 B | 0664 |
|
| CountryController.php | File | 714 B | 0664 |
|
| CouponController.php | File | 942 B | 0664 |
|
| CouponsController.php | File | 606 B | 0664 |
|
| DisplayController.php | File | 1.23 KB | 0664 |
|
| EventController.php | File | 9.78 KB | 0664 |
|
| EventsController.php | File | 2.3 KB | 0664 |
|
| ExtcalendarController.php | File | 941 B | 0664 |
|
| ExtcalendarsController.php | File | 2.55 KB | 0664 |
|
| ImportController.php | File | 1.2 KB | 0664 |
|
| LocationController.php | File | 1.94 KB | 0664 |
|
| LocationsController.php | File | 1.16 KB | 0664 |
|
| PluginController.php | File | 1.1 KB | 0664 |
|
| TaxrateController.php | File | 710 B | 0664 |
|
| TaxratesController.php | File | 770 B | 0664 |
|
| TicketsController.php | File | 992 B | 0664 |
|
| TranslateController.php | File | 3.61 KB | 0664 |
|
| VersionController.php | File | 801 B | 0664 |
|