Poster.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\index\controller;
  3. use app\common\controller\Frontend;
  4. /**
  5. * 我的海报
  6. */
  7. class Poster extends Frontend
  8. {
  9. protected $layout = 'default';
  10. protected $noNeedRight = ["*"];
  11. // Child模型对象
  12. protected $model = null;
  13. public function _initialize()
  14. {
  15. parent::_initialize();
  16. $this->model = new \app\admin\model\Poster;
  17. $posterLog = new \app\admin\model\PosterLog;
  18. }
  19. /**
  20. * 我的海报列表
  21. *
  22. * @param string $token Token
  23. * @param integer $page 页码
  24. */
  25. public function index()
  26. {
  27. $where = array(
  28. 'status' => 'normal'
  29. );
  30. $list = $this->model->where($where)->order('weigh DESC')->paginate(1);
  31. foreach ($list as $row) {
  32. $row->visible(['id', 'title', 'bg_image', 'data']);
  33. }
  34. $this->view->assign('list', $list);
  35. $this->view->assign('title', "我的海报");
  36. return $this->view->fetch();
  37. }
  38. /**
  39. * 生成海报
  40. * @author Created by Xing <464401240@qq.com>
  41. */
  42. public function getposter($poster_id = null)
  43. {
  44. $poster = $this->model->get($poster_id);
  45. if (!$poster) {
  46. $this->error(__('未找到海报' . $poster_id));
  47. }
  48. $image = new \addons\poster\library\Image();
  49. $imgurl = $image->createPosterImage($poster, $this->auth->getUser());
  50. if (!$imgurl) {
  51. $this->error('生成海报出错');
  52. }
  53. $this->success('', '', '/' . $imgurl);
  54. }
  55. }