<?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 SKugu; SKugu: $rZfgs = new Display('_operate', array(L('Operate'))); goto rkU9Y; NoZfy: if ($this->hookItemOperateFieldBuild) { call_user_func($this->hookItemOperateFieldBuild, $rZfgs); } goto gSHBC; gSHBC: $this->pushField($rZfgs); goto WjhJv; rkU9Y: $rZfgs->hookRendering(function (AbstractField $rZfgs, $Esk0p, $EqYVi) { $this->itemOperate->reset()->item($Esk0p)->index($EqYVi); $this->itemOperate->setField($rZfgs); if ($this->hookItemOperateRendering) { call_user_func($this->hookItemOperateRendering, $this->itemOperate); } return $this->itemOperate->render(); }); goto NoZfy; WjhJv: } } public function disableItemOperate() { goto bdDGa; vhaNi: $this->canDelete = false; goto JykrH; bdDGa: $this->canEdit = false; goto KPDqL; nOFJM: return $this; goto ryFUE; KPDqL: $this->canShow = false; goto vhaNi; JykrH: $this->hookItemOperateRendering = false; goto nOFJM; ryFUE: } public function hookItemOperateRendering($b9NqF = null) { goto CA3rr; CA3rr: if (null === $b9NqF) { return $this->hookItemOperateRendering; } goto TDXnd; dxn2Z: return $this; goto zAVsf; TDXnd: $this->hookItemOperateRendering = $b9NqF; goto dxn2Z; zAVsf: } public function hookItemOperateFieldBuild($b9NqF = null) { goto B1tl4; gt3WS: return $this; goto sGEaJ; M65ig: $this->hookItemOperateFieldBuild = $b9NqF; goto gt3WS; B1tl4: if (null === $b9NqF) { return $this->hookItemOperateFieldBuild; } goto M65ig; sGEaJ: } public function operateFixed($yJ9JB) { $this->hookItemOperateFieldBuild(function (AbstractField $rZfgs) use($yJ9JB) { $rZfgs->gridFixed($yJ9JB); }); return $this; } }