Ejemplo n.º 1
0
?>
%;
                                    top:<?php 
echo $selected_cover->window_offset_y / 2.6;
?>
%;
                                    width:<?php 
echo $selected_cover->window_width / 7.1;
?>
%;
                                    height:<?php 
echo $selected_cover->window_height / 2.6;
?>
%;
                                    background-size: contain; background-image: url('<?php 
echo UserUrl::photobookWindowText(true, $model->id, $model->user_id) . "/" . UserUrl::imageFile($model->id, UserUrl::IMAGE_ORIGINAL, 'png') . '?r=' . rand(0, 99999999);
?>
'); "></div>

                            </div>


                            <div class="cover" style="position: absolute; left:50%; width: 50%; height: 100%; "></div>



                        </div>
                    </div>
                </div>
            </div>
Ejemplo n.º 2
0
 public function updateCoverWindowImageText($field_name, $value)
 {
     $this->{$field_name} = $value;
     /*if(!$this->save()){
     
                 return ['error'=>['msg'=>Yii::t('app', 'Ошибка записи в базу-данных')]];
             }*/
     //$this->loadById($this->id);
     $style = Style::findOne(['id' => $this->style_id]);
     if (empty($style)) {
         return ['error' => ['msg' => Yii::t('app', 'Стиль для фотокниги не найден')]];
     }
     $font = Font::findOne(['id' => $style->font_id]);
     if (empty($font)) {
         return ['error' => ['msg' => Yii::t('app', 'Шрифт для фотокниги не найден')]];
     }
     $cover = Cover::findOne(['id' => $this->cover_id]);
     if (empty($cover)) {
         return ['error' => ['msg' => Yii::t('app', 'Обложка для фотокниги не найден')]];
     }
     $font_path = UserUrl::font(false) . DIRECTORY_SEPARATOR . UserUrl::fontFile($font->file);
     $line_1 = !empty($this->title_line_1) ? $this->title_line_1 : ' ';
     $line_2 = !empty($this->title_line_2) ? $this->title_line_2 : ' ';
     $line_3 = !empty($this->title_line_3) ? $this->title_line_3 : ' ';
     $line_4 = !empty($this->title_line_3) ? $this->title_line_4 : ' ';
     $this->name = $line_1 . " " . $line_2 . " " . $line_3;
     $this->save();
     $text = $line_1 . "\n" . $line_2 . "\n" . $line_3;
     $text_image_content = Utils::makeTextImage($text, $cover->window_width, $cover->window_height, '#000000', $font_path, 2, 72);
     $text_image_path = UserUrl::photobookWindowText(false, $this->id, $this->user_id) . DIRECTORY_SEPARATOR . UserUrl::imageFile($this->id, UserUrl::IMAGE_ORIGINAL, 'png');
     $text_image_url = UserUrl::photobookWindowText(true, $this->id, $this->user_id) . "/" . UserUrl::imageFile($this->id, UserUrl::IMAGE_ORIGINAL, 'png');
     $user_pb_path = UserUrl::photobook(false, $this->id, $this->user_id);
     if (file_exists($user_pb_path)) {
         Yii::getLogger()->log('updateCoverWindowImageText exists user_pb_path:' . $user_pb_path, YII_DEBUG);
     } else {
         Yii::getLogger()->log('updateCoverWindowImageText NOT exists user_pb_path:' . $user_pb_path, YII_DEBUG);
     }
     // UserUrl::createNonexistentDirInPath(UserUrl::photobookWindowText(, 'pb'.DIRECTORY_SEPARATOR.$photobook_id)
     file_put_contents($text_image_path, $text_image_content);
     $file_tmp = new UploadedFile();
     $file_tmp->tempName = $text_image_path;
     $name = AlphaId::id($this->user_id) . '/pb/' . AlphaId::id($this->id) . '/window_text/' . UserUrl::imageFile($this->id, UserUrl::IMAGE_ORIGINAL, 'png');
     Yii::$app->resourceManager->save($file_tmp, $name);
     unlink($text_image_path);
     $tracing_text = $line_1 . "\n" . $line_2 . "\n" . $line_3 . "\n" . " " . "\n" . " " . "\n" . " " . "\n" . " " . "\n" . " " . $line_4;
     $tracing_text_image_content = Utils::makeTextImage($tracing_text, 350, 250, '#000000', $font_path, 15, 72);
     $tracing_text_image_path = UserUrl::photobookTracingText(false, $this->id, $this->user_id) . DIRECTORY_SEPARATOR . UserUrl::imageFile($this->id, UserUrl::IMAGE_ORIGINAL, 'png');
     $tracing_text_image_url = UserUrl::photobookTracingText(true, $this->id, $this->user_id) . DIRECTORY_SEPARATOR . UserUrl::imageFile($this->id, UserUrl::IMAGE_ORIGINAL, 'png');
     file_put_contents($tracing_text_image_path, $tracing_text_image_content);
     $file_tmp = new UploadedFile();
     $file_tmp->tempName = $tracing_text_image_path;
     $name = AlphaId::id($this->user_id) . '/pb/' . AlphaId::id($this->id) . '/tracing/' . UserUrl::imageFile($this->id, UserUrl::IMAGE_ORIGINAL, 'png');
     Yii::$app->resourceManager->save($file_tmp, $name);
     unlink($tracing_text_image_path);
     return ['response' => ['status' => true, 'value' => $value, 'text_image_url' => $text_image_url, 'tracing_text_image_url' => $tracing_text_image_url, 'window_offset_x' => $cover->window_offset_x, 'window_offset_y' => $cover->window_offset_y, 'window_width' => $cover->window_width, 'window_height' => $cover->window_height, 'font_path' => $font_path, 'text' => $text, 'name' => $this->name]];
 }