<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Grid\Concerns; use ModStart\Field\AbstractField; use ModStart\Field\Display; use ModStart\Grid\Displayer\ItemOperate; use ModStart\Support\Concern\HasSetting; trait HasItemOperate { private $itemOperate; private $hookItemOperateRendering; private $hookItemOperateFieldBuild; private function setupItemOperate() { $this->itemOperate = new ItemOperate($this); } private function prepareItemOperateField() { if ($this->canEdit || $this->canShow || $this->canDelete || $this->hookItemOperateRendering) { goto vaZgA; hmk4i: $VWt5t->hookRendering(function (AbstractField $VWt5t, $nsWl0, $R80S9) { $this->itemOperate->reset()->item($nsWl0)->index($R80S9); $this->itemOperate->setField($VWt5t); if ($this->hookItemOperateRendering) { call_user_func($this->hookItemOperateRendering, $this->itemOperate); } return $this->itemOperate->render(); }); goto f9MfV; f9MfV: if ($this->hookItemOperateFieldBuild) { call_user_func($this->hookItemOperateFieldBuild, $VWt5t); } goto uwwJ2; uwwJ2: $this->pushField($VWt5t); goto Xaj9r; vaZgA: $VWt5t = new Display('_operate', array(L('Operate'))); goto hmk4i; Xaj9r: } } public function disableItemOperate() { goto hxsos; hxsos: $this->canEdit = false; goto itLM7; itLM7: $this->canShow = false; goto vRn9Z; DredE: return $this; goto OvO8x; vRn9Z: $this->canDelete = false; goto YxdIk; YxdIk: $this->hookItemOperateRendering = false; goto DredE; OvO8x: } public function hookItemOperateRendering($R6Imz = null) { goto bWZ_0; p98Wn: $this->hookItemOperateRendering = $R6Imz; goto FYJl7; FYJl7: return $this; goto yHyFo; bWZ_0: if (null === $R6Imz) { return $this->hookItemOperateRendering; } goto p98Wn; yHyFo: } public function hookItemOperateFieldBuild($R6Imz = null) { goto Thr_x; Thr_x: if (null === $R6Imz) { return $this->hookItemOperateFieldBuild; } goto nDa0j; RGvKN: return $this; goto WzOjN; nDa0j: $this->hookItemOperateFieldBuild = $R6Imz; goto RGvKN; WzOjN: } public function operateFixed($wNTYA) { $this->hookItemOperateFieldBuild(function (AbstractField $VWt5t) use($wNTYA) { $VWt5t->gridFixed($wNTYA); }); return $this; } }