Skip to content

Commit

Permalink
Locale: fix error with translations generation script.
Browse files Browse the repository at this point in the history
  • Loading branch information
dasgarner committed Sep 12, 2024
1 parent ce03c27 commit 229def3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 12 deletions.
19 changes: 9 additions & 10 deletions bin/locale.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

Check warning on line 1 in bin/locale.php

View workflow job for this annotation

GitHub Actions / phpcs

A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 42 and the first side effect is on line 39.

/*
* Copyright (C) 2023 Xibo Signage Ltd
* Copyright (C) 2024 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
Expand Down Expand Up @@ -29,14 +29,16 @@

use Slim\Flash\Messages;
use Slim\Views\Twig;
use Slim\Views\TwigExtension;
use Twig\TwigFilter;
use Xibo\Service\ConfigService;
use Xibo\Twig\ByteFormatterTwigExtension;
use Xibo\Twig\DateFormatTwigExtension;
use Xibo\Twig\TransExtension;
use Xibo\Twig\TwigMessages;

error_reporting(E_ALL);
ini_set('display_errors', 1);

define('PROJECT_ROOT', realpath(__DIR__ . '/..'));
require_once PROJECT_ROOT . '/vendor/autoload.php';

Expand All @@ -57,8 +59,6 @@
$view->addExtension(new TwigMessages(new Messages($storage)));

foreach (glob(PROJECT_ROOT . '/views/*.twig') as $file) {
echo var_export($file, true) . PHP_EOL;

$view->getEnvironment()->load(str_replace(PROJECT_ROOT . '/views/', '', $file));
}

Expand Down Expand Up @@ -137,7 +137,7 @@ function __($original)
}
if (!empty($setting->helpText)) {
// replaces any single quote within the value with a backslash followed by a single quote
$helpText = addslashes($setting->helpText);
$helpText = addslashes(trim($setting->helpText));
$content .= 'echo __(\''.$helpText.'\');' . PHP_EOL;
}

Expand All @@ -153,7 +153,7 @@ function __($original)
// Properties translation
foreach ($module->properties as $property) {
if (!empty($property->title)) {
$content .= 'echo __(\''.$property->title.'\');' . PHP_EOL;
$content .= 'echo __(\''.addslashes(trim($property->title)).'\');' . PHP_EOL;
}
if (!empty($property->helpText)) {
// replaces any single quote within the value with a backslash followed by a single quote
Expand All @@ -167,7 +167,7 @@ function __($original)
// Property rule test message
$message = $test->message;
if (!empty($message)) {
$content .= 'echo __(\''.$message.'\');' . PHP_EOL;
$content .= 'echo __(\''.addslashes(trim($message)).'\');' . PHP_EOL;
}
}
}
Expand All @@ -190,11 +190,11 @@ function __($original)
// Properties Translation
foreach ($moduleTemplate->properties as $property) {
if (!empty($property->title)) {
$content .= 'echo __(\''.$property->title.'\');' . PHP_EOL;
$content .= 'echo __(\''.addslashes(trim($property->title)).'\');' . PHP_EOL;
}
if (!empty($property->helpText)) {
// replaces any single quote within the value with a backslash followed by a single quote
$helpText = addslashes($property->helpText);
$helpText = addslashes(trim($property->helpText));
$content .= 'echo __(\''.$helpText.'\');' . PHP_EOL;
}

Expand All @@ -219,6 +219,5 @@ function __($original)
}
}

$content .= '?>';
file_put_contents($file, $content);
echo 'moduletranslate.file created and data written successfully.';
32 changes: 30 additions & 2 deletions lib/Service/NullLogService.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
* Copyright (C) 2024 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
Expand Down Expand Up @@ -83,9 +83,12 @@ public function audit($entity, $entityId, $message, $object)
}

/**
* @param $sql
* @param $params
* @param false $logAsError
* @inheritdoc
*/
public function sql($sql, $params)
public function sql($sql, $params, $logAsError = false)
{
//
}
Expand Down Expand Up @@ -209,4 +212,29 @@ public function setLevel($level)
{
//
}

public function getUserId(): ?int
{
return null;
}

public function getSessionHistoryId(): ?int
{
return null;
}

public function getRequestId(): ?int
{
return null;
}

public function setSessionHistoryId($sessionHistoryId)
{
//
}

public function setRequestId($requestId)
{
//
}
}

0 comments on commit 229def3

Please sign in to comment.