Files
grzanieplus.pl/plugins/stLanguagePlugin/lib/stLanguageModelTranslatorProgressBarTaskClass.php
2025-03-12 17:06:23 +01:00

70 lines
1.6 KiB
PHP

<?php
class stLanguageModelTranslatorProgressBarTask extends stProgressBarTask
{
protected $initilized = false;
public function initialize()
{
if (false === $this->initilized)
{
$databaseManager = new sfDatabaseManager();
$databaseManager->initialize();
sfLoader::loadPluginConfig();
$this->initilized = true;
}
}
public function execute($offset)
{
$c = $this->getCriteria();
$c->setLimit(1);
$c->setOffset($offset);
foreach (LanguagePeer::doSelect($c) as $language)
{
$message = $this->getI18N()->__('%lang% wersja językowa', [
'%lang%' => $language->getName(),
]);
$this->setMessage($message);
if ($language->hasToUpdateModelTranslations())
{
$language->loadModelTranslations();
$language->save();
}
$offset++;
}
return $offset;
}
public function getTitle()
{
return $this->getI18N()->__('Aktualizacja wersji językowych');
}
public function count()
{
$this->initialize();
return LanguagePeer::doCount($this->getCriteria());
}
public function finished()
{
$message = $this->getI18N()->__('Aktualizacja wersji językowych zakończona pomyślnie');
$this->setMessage($message);
}
protected function getCriteria(): Criteria
{
$c = new Criteria();
$c->add(LanguagePeer::ACTIVE, true);
return $c;
}
}