Commit 8994033a authored by Aster's avatar Aster Committed by waltermazza
Browse files

General Bug Fixes and Improvements

parent de7a22c5
{
"name": "arter/amos-translation",
"description": "AMOS Translation",
"keywords": [
"amos",
"yii2",
"translation"
],
"keywords": ["amos", "yii2", "translation"],
"homepage": "http://www.arter.it/",
"type": "component",
"license": "BSD-3-Clause",
......@@ -18,7 +14,7 @@
"minimum-stability": "dev",
"require": {
"php": ">=5.5.0",
"arter/amos-core": ">=1.9.50",
"arter/amos-core":">=1.9.50",
"arter/amos-dashboard": ">=1.8.15",
"arter/amos-workflow": "*",
"lajax/yii2-translate-manager": "1.*"
......@@ -34,4 +30,4 @@
"arter\\amos\\translation\\": "src"
}
}
}
\ No newline at end of file
}
......@@ -4,7 +4,7 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
......@@ -210,7 +210,7 @@ class AmosTranslation extends AmosModule implements BootstrapInterface
public $components = [];
public $dbTranslation = 'db';
public $dbSource = 'db';
public $defaultTypeAttributesToTranslate = ['string', 'text'];
public $defaultTypeAttributesToTranslate = ['string', 'text', 'char'];
public $systemBlackListAttributes = ['id', 'status', 'created_at', 'updated_at', 'deleted_at', 'created_by', 'updated_by',
'deleted_by'];
......@@ -280,12 +280,13 @@ class AmosTranslation extends AmosModule implements BootstrapInterface
}
$this->generateTranslationTables();
$this->generateTranslationModels();
$this->name = 'Traduzioni';
}
public function getWidgetIcons()
{
return [
widgets\icons\WidgetIconTranslation::className(),
// widgets\icons\WidgetIconTranslation::className(),
widgets\icons\WidgetIconTrContents::className(),
widgets\icons\WidgetIconTrPlatform::className(),
//widgets\icons\WidgetIconTrLanguage::className(),//will to ability when the view of the translate of platform are completed
......@@ -630,7 +631,7 @@ class AmosTranslation extends AmosModule implements BootstrapInterface
$files = [];
$workflow = 'AmosTranslationWorkflow';
$enableWorkflow = false;
if (\Yii::$app->db->getTableSchema(models\TranslationConf::tableName(), false) !== null) {
if (\Yii::$app->db->getTableSchema(models\TranslationConf::tableName()) !== null) {
$verifyModels = models\TranslationConf::find();
if ($force == false) {
$verifyModels->andWhere(['model_generated' => 0]);
......@@ -655,7 +656,7 @@ class AmosTranslation extends AmosModule implements BootstrapInterface
$modelClass = StringHelper::basename($namespace)."Translation";
$table = $namespace::tableName();
$tableTranslation = "{$table}__translation";
$tableSchema = \Yii::$app->{$this->dbTranslation}->getTableSchema($tableTranslation);
$tableSchema = \Yii::$app->{$this->dbTranslation}->getTableSchema($tableTranslation, true);
if (!empty($tableSchema)) {
$generator = new components\Generator();
......@@ -708,17 +709,17 @@ class AmosTranslation extends AmosModule implements BootstrapInterface
$result = false;
try {
$connection = \Yii::$app->{$this->dbTranslation};
//$connection->enableQueryCache = false;
//$connection->enableSchemaCache = false;
// $connection->enableQueryCache = false;
// $connection->enableSchemaCache = true;
$table = $classname::tableName();
if (\Yii::$app->{$this->dbTranslation}->getTableSchema("{$table}__translation") === NULL) {
if (\Yii::$app->{$this->dbTranslation}->getTableSchema("{$table}__translation", false) === NULL) {
$sql .= "CREATE TABLE `{$table}__translation` (
`{$table}_id` int(11) NOT NULL,
`{$this->languageField}` VARCHAR(255) NOT NULL,";
$tableSchema = \Yii::$app->{$this->dbSource}->getTableSchema($table);
$tableSchema = \Yii::$app->{$this->dbSource}->getTableSchema($table, true);
if (!empty($this->defaultTypeAttributesToTranslate) && !empty($tableSchema)) {
foreach ((array) $tableSchema->columns as $key => $value) {
......@@ -774,8 +775,8 @@ class AmosTranslation extends AmosModule implements BootstrapInterface
{
$table = $classname::tableName();
$tableSchema = \Yii::$app->{$this->dbSource}->getTableSchema($table);
$tableSchemaTranslation = \Yii::$app->{$this->dbTranslation}->getTableSchema("{$table}__translation");
$tableSchema = \Yii::$app->{$this->dbSource}->getTableSchema($table, true);
$tableSchemaTranslation = \Yii::$app->{$this->dbTranslation}->getTableSchema("{$table}__translation", true);
$attributes = $this->getModelAttributes($classname);
$attributesTranslation = $this->getModelAttributes("{$classname}Translation", true);
......@@ -786,7 +787,7 @@ class AmosTranslation extends AmosModule implements BootstrapInterface
{
$table = $classname::tableName();
$db = ($translation ? $this->dbTranslation : $this->dbSource);
$tableSchema = \Yii::$app->{$db}->getTableSchema($table);
$tableSchema = \Yii::$app->{$db}->getTableSchema($table, true);
$attributes = [];
if (!empty($this->defaultTypeAttributesToTranslate) && !empty($tableSchema)) {
foreach ((array) $tableSchema->columns as $key => $value) {
......
......@@ -4,11 +4,11 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package arter\amos\translation\assets
* @package arter\amos\chat
* @category CategoryName
* @author Elite Division S.r.l.
*/
......
......@@ -4,11 +4,11 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package arter\amos\translation\behaviors
* @package arter\amos\translation
* @category CategoryName
* @author Elite Division S.r.l.
*/
......@@ -142,7 +142,7 @@ class TranslateableBehavior extends Behavior
$this->setLanguage(\Yii::$app->language);
$this->populateTranslations();
$this->getTranslation($this->getLanguage());
if ($this->forceTranslation) {
if ($this->forceTranslation && !empty(\Yii::$app->controller)) {
$viewPath = \Yii::$app->controller->getViewPath();
$currentAction = (!empty($viewPath) ? trim($viewPath) : '').DIRECTORY_SEPARATOR.(!empty(\Yii::$app->controller->action->id)
? trim(\Yii::$app->controller->action->id) : '');
......@@ -225,7 +225,11 @@ class TranslateableBehavior extends Behavior
$language = $this->getLanguage();
foreach ($this->getTranslation($language)->attributes as $key => $attribute) {
$originalAttributes = $this->owner->attributes;
$beta_language = \Yii::$app->user->can('CONTENT_TRANSLATOR') ? true : false;
$beta_language = false;
if(\Yii::$app instanceof \yii\web\Application)
{
$beta_language = \Yii::$app->user->can('CONTENT_TRANSLATOR') ? true : false;
}
$allLanguage = $module->getAvailableLanguages($beta_language);
if (!empty($attribute) && array_key_exists($key, $originalAttributes) && in_array($key,
$this->translationAttributes) && !in_array($key, $blackListAttributes)) {
......
......@@ -4,11 +4,11 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package arter\amos\translation\bootstrap
* @package arter\amos\translation
* @category CategoryName
* @author Elite Division S.r.l.
*/
......@@ -91,6 +91,10 @@ class EventActiveRecordBootstrap extends \yii\db\ActiveRecord
$translationModule = \Yii::$app->getModule('translation');
$path = \Yii::getAlias('@'.str_replace('\\', '/', $translationModule->modelNs)).'/'."{$translationModule->fileNameDbConfFields}".'.php';
if(!is_writable($path)) {
throw new \Exception("La Directory {$path} non esiste o non è scrivibile, bisogna correggere manualmente il problema");
}
try {
if (!file_exists($path)) {
......
......@@ -4,11 +4,11 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package arter\amos\translation\bootstrap
* @package arter\amos\translation
* @category CategoryName
* @author Elite Division S.r.l.
*/
......
......@@ -4,12 +4,11 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
*
* @package arter\amos\translation\components
* @package arter\amos\translation
* @category CategoryName
* @author Elite Division S.r.l.
*/
......
......@@ -5,12 +5,11 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
*
* @package arter\amos\translation\components\default
* @package arter\amos\translation
* @category CategoryName
* @author Elite Division S.r.l.
*/
......
......@@ -4,11 +4,11 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package arter\amos\translation\config
* @package arter\amos\translation
* @category CategoryName
* @author Elite Division S.r.l.
*/
......
......@@ -8,11 +8,12 @@
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package arter\amos\translation\controllers
* @package arter
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace arter\amos\translation\controllers;
use arter\amos\translation\utility\TranslationUtility;
......
......@@ -8,11 +8,12 @@
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package arter\amos\translation\controllers
* @package arter
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace arter\amos\translation\controllers;
use Yii;
......
......@@ -8,11 +8,12 @@
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package arter\amos\translation\controllers
* @package arter
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace arter\amos\translation\controllers;
use arter\amos\core\helpers\BreadcrumbHelper;
......
......@@ -4,7 +4,7 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
......
......@@ -4,7 +4,7 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
......
......@@ -4,7 +4,7 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
......
......@@ -4,7 +4,7 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
......
......@@ -4,7 +4,7 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
......
......@@ -4,7 +4,7 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
......
......@@ -4,7 +4,7 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
......
......@@ -4,7 +4,7 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment