Manage.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. namespace Poster\Lib;
  3. use Dever;
  4. use Dever\Support\Img as Handle;
  5. class Manage
  6. {
  7. public function update_api()
  8. {
  9. $id = Dever::input('id');
  10. $left = Dever::input('left');
  11. $top = Dever::input('top');
  12. if ($id) {
  13. $data['where_id'] = $id;
  14. if (!$left) {
  15. $left = 0;
  16. }
  17. if (!$top) {
  18. $top = 0;
  19. }
  20. $data['position'] = $left . ',' . $top;
  21. Dever::db('poster/model')->update($data);
  22. }
  23. return $id;
  24. }
  25. public function template()
  26. {
  27. $id = Dever::input('search_option_template_id');
  28. $info = Dever::db('poster/template')->find($id);
  29. if ($info['create'] == 1) {
  30. # 生成空白背景图
  31. $filename = 'background_' . $info['id'];
  32. $file = Dever::pathDay('upload/poster', false) . $filename . '.jpg';
  33. $img = new Handle();
  34. $img->create($file, $info['width'], $info['height'], 1);
  35. $info['background'] = Dever::pic($file);
  36. }
  37. $info['background'] = $info['background'] . '?v=' . time();
  38. $info['background'] = "background-image:url('".$info['background']."');";
  39. return $info;
  40. }
  41. public function model()
  42. {
  43. $where['template_id'] = Dever::input('search_option_template_id');
  44. $data = Dever::db('poster/model')->select($where);
  45. if ($data) {
  46. foreach ($data as $k => $v) {
  47. $data[$k]['content'] = '';
  48. $data[$k]['style'] = 'display:none;position:absolute;';
  49. if ($v['type'] == 1) {
  50. $data[$k]['content'] = '<img src="'.$v['value_pic'].'" style="width: '.$v['width'].'px;height:'.$v['height'].'px;">';
  51. $data[$k]['style'] .= 'width: '.$v['width'].'px;height:'.$v['height'].'px;';
  52. } else {
  53. if (!$v['value']) {
  54. $v['value'] = $v['name'];
  55. }
  56. $data[$k]['content'] = $v['value'];
  57. $data[$k]['style'] .= 'width: '.$v['text_width'].'px;';
  58. if ($v['color']) {
  59. $data[$k]['style'] .= 'color:' . $v['color'] . ';';
  60. }
  61. if ($v['size']) {
  62. $data[$k]['style'] .= 'font-size:' . $v['size'] . 'px;';
  63. }
  64. if ($v['fonts']) {
  65. //$data[$k]['style'] .= 'font-size:' . $v['size'] . ';';
  66. }
  67. }
  68. $edit_link = Dever::url('project/database/update&project=poster&table=model&where_id=' . $v['id'], 'manage');
  69. $del_link = Dever::url('database.delete_action&project=poster&table=model&where_id=' . $v['id'], 'manage');
  70. $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>';
  71. $p = explode(',', $v['position']);
  72. $data[$k]['style'] .= 'left:'.$p[0].'px;top:'.$p[1].'px;';
  73. }
  74. }
  75. return $data;
  76. }
  77. }