public function addNewPage($page_index, $photo_id) { $style = Style::findOne(['id' => $this->style_id, 'delete' => 0]); $mapTemplates = $this->getMapTemplates(); $pages = [['photos' => [['file_key' => $photo_id, 'pos_dx' => 0, 'pos_dy' => 0, 'scale' => 1]]]]; foreach ($pages as $key => $page) { $pages[$key]['svg'] = $this->renderSvgPage($pages[$key], $mapTemplates, $style); $pages[$key]['svg_thumb'] = $this->renderSvgPage($pages[$key], $mapTemplates, $style, UserUrl::IMAGE_SMALL); $pages[$key]['json'] = $this->renderJsonPage($pages[$key], $mapTemplates, $style); $pages[$key]['action'] = 'print'; $pages[$key]['flyleaf'] = false; } Utils::array_insert($this->data['pages'], $pages[0], intval($page_index)); if ($this->save()) { $backgroundUrl = UserUrl::stylePaddedPassepartout(true, $style->id) . DIRECTORY_SEPARATOR . UserUrl::imageFile($style->padded_passepartout_key, UserUrl::IMAGE_ORIGINAL); return ['response' => ['status' => true, 'page_index' => $page_index, 'pages' => Utils::pages_filter($this->data['pages']), 'background_url' => $backgroundUrl]]; } else { return ['error' => ['msg' => Yii::t('app', 'Не удалось записать в базу-данных')]]; } }