123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?php
- namespace Poster\Lib;
- use Dever;
- use Dever\Support\Img as Handle;
- class Manage
- {
- public function update_api()
- {
- $id = Dever::input('id');
- $left = Dever::input('left');
- $top = Dever::input('top');
- if ($id) {
- $data['where_id'] = $id;
- if (!$left) {
- $left = 0;
- }
- if (!$top) {
- $top = 0;
- }
- $data['position'] = $left . ',' . $top;
- Dever::db('poster/model')->update($data);
- }
- return $id;
- }
- public function template()
- {
- $id = Dever::input('search_option_template_id');
- $info = Dever::db('poster/template')->find($id);
- if ($info['create'] == 1) {
- # 生成空白背景图
- $filename = 'background_' . $info['id'];
- $file = Dever::pathDay('upload/poster', false) . $filename . '.jpg';
- $img = new Handle();
- $img->create($file, $info['width'], $info['height'], 1);
- $info['background'] = Dever::pic($file);
- }
- $info['background'] = $info['background'] . '?v=' . time();
- $info['background'] = "background-image:url('".$info['background']."');";
- return $info;
- }
- public function model()
- {
- $where['template_id'] = Dever::input('search_option_template_id');
- $data = Dever::db('poster/model')->select($where);
- if ($data) {
- foreach ($data as $k => $v) {
- $data[$k]['content'] = '';
- $data[$k]['style'] = 'display:none;position:absolute;';
-
- if ($v['type'] == 1) {
-
- $data[$k]['content'] = '<img src="'.$v['value_pic'].'" style="width: '.$v['width'].'px;height:'.$v['height'].'px;">';
- $data[$k]['style'] .= 'width: '.$v['width'].'px;height:'.$v['height'].'px;';
- } else {
- if (!$v['value']) {
- $v['value'] = $v['name'];
- }
- $data[$k]['content'] = $v['value'];
- $data[$k]['style'] .= 'width: '.$v['text_width'].'px;';
- if ($v['color']) {
- $data[$k]['style'] .= 'color:' . $v['color'] . ';';
- }
- if ($v['size']) {
- $data[$k]['style'] .= 'font-size:' . $v['size'] . 'px;';
- }
- if ($v['fonts']) {
- //$data[$k]['style'] .= 'font-size:' . $v['size'] . ';';
- }
- }
- $edit_link = Dever::url('project/database/update&project=poster&table=model&where_id=' . $v['id'], 'manage');
- $del_link = Dever::url('database.delete_action&project=poster&table=model&where_id=' . $v['id'], 'manage');
- $data[$k]['content'] .= '<ul class="custom-context-menu hidden"><li class="edit" onclick="fastEdit($(this), \''.$edit_link.'\', \'编辑\', \'\')">编辑</li><li class="del" onclick="del_act(\''.$del_link.'\')">删除</li></ul>';
- $p = explode(',', $v['position']);
- $data[$k]['style'] .= 'left:'.$p[0].'px;top:'.$p[1].'px;';
- }
- }
- return $data;
- }
- }
|