Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 42c20ae6

Přidáno uživatelem Jan Šedivý před téměř 6 roky(ů)

Re #7575 , Re #7572 Refaktoring importu/exportu

Zobrazit rozdíly:

app/AdminModule/component/Transliteration/TransliterationGrid.php
15 15
use App\Utils\DataGrid\DataGrid;
16 16
use Nette\Database\Table\ActiveRow;
17 17
use Nette\Database\Table\Selection;
18
use Tracy\Debugger;
18 19
use Ublaboo\DataGrid\Exception\DataGridException;
19 20

  
20 21
class TransliterationGrid extends DataGrid
......
249 250
    private function exportData($dataSource, $grid)
250 251
    {
251 252
        $exportData = [];
252
        /** @var ActiveRow $activeRow */
253
        foreach ($dataSource as $activeRow)
253

  
254
        try
254 255
        {
255
            $lines = $this->lineRepository->getAllLinesForTransliteration($activeRow->getPrimary());
256
            $chapterLines = [];
257
            foreach ($lines as $line)
256
            /** @var ActiveRow $activeRow */
257
            foreach ($dataSource as $activeRow)
258 258
            {
259
                $chapterLines[$line->object_type][$line->surface_type][] = array('transliteration' => $line->transliteration, 'line_number' => $line->line_number);
259
                //Přeskočí transliterace které nejsou přiřazené k žádné knížce
260
                if(!$activeRow->ref('id_book'))
261
                {
262
                    continue;
263
                }
264
                $lines = $this->lineRepository->getAllLinesForTransliteration($activeRow->getPrimary());
265
                $chapterLines = [];
266
                foreach ($lines as $line)
267
                {
268
                    $chapterLines[$line->object_type][$line->surface_type][] = array('transliteration' => $line->transliteration, 'line_number' => $line->line_number);
269
                }
270
                $exportData[] = [
271
                    'bookName' => $activeRow->ref('id_book')->book_abrev,
272
                    'chapter' => $activeRow->chapter,
273
                    'transliterationData' => $chapterLines
274
                ];
260 275
            }
261
            $exportData[] = [
262
                'bookName' => $activeRow->ref('id_book')->book_abrev,
263
                'chapter' => $activeRow->chapter,
264
                'transliterationData' => $chapterLines
265
            ];
266
        }
267 276

  
268
        $uniqueBooks = array_unique(array_map(function ($i) { return $i['bookName']; }, $exportData));
277
            $uniqueBooks = array_unique(array_map(function ($i) { return $i['bookName']; }, $exportData));
278

  
279
            $currentDate = new \DateTime();
280
            $exportFileName =  'text-export-' .
281
                $currentDate->format('Y-m-d-H-i-s') .
282
                self::EXPORT_FILE_TYPE;
269 283

  
270
        $currentDate = new \DateTime();
271
        $exportFileName =  'text-export-' .
272
            $currentDate->format('Y-m-d-H-i-s') .
273
            self::EXPORT_FILE_TYPE;
274
        try
275
        {
276 284
            if (!file_exists(self::EXPORT_FILE_PATH)) {
277 285
                mkdir(self::EXPORT_FILE_PATH, 0777, true);
278 286
            }
......
321 329
        catch (\Exception $e)
322 330
        {
323 331
            $this->presenter->flashMessage('There was an error creating the export file', EFlashMessage::ERROR);
332
            Debugger::log($e, 'export-error');
324 333
        }
325 334

  
326 335
        $this->presenter->flashMessage('There was an error downloading the export file', EFlashMessage::ERROR);

Také k dispozici: Unified diff