<?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 rmUL9; rmUL9: $Mk6lP = new Display('_operate', array(L('Operate'))); goto HRSKp; HRSKp: $Mk6lP->hookRendering(function (AbstractField $Mk6lP, $yFnpO, $dtpXv) { $this->itemOperate->reset()->item($yFnpO)->index($dtpXv); $this->itemOperate->setField($Mk6lP); if ($this->hookItemOperateRendering) { call_user_func($this->hookItemOperateRendering, $this->itemOperate); } return $this->itemOperate->render(); }); goto i4PXv; N8uE5: $this->pushField($Mk6lP); goto CMlmU; i4PXv: if ($this->hookItemOperateFieldBuild) { call_user_func($this->hookItemOperateFieldBuild, $Mk6lP); } goto N8uE5; CMlmU: } } public function disableItemOperate() { goto LiopN; q1ifF: return $this; goto J8YaR; Ou7xN: $this->canDelete = false; goto aXIK6; TlQKP: $this->canShow = false; goto Ou7xN; LiopN: $this->canEdit = false; goto TlQKP; aXIK6: $this->hookItemOperateRendering = false; goto q1ifF; J8YaR: } public function hookItemOperateRendering($yeJzO = null) { goto rGafj; rGafj: if (null === $yeJzO) { return $this->hookItemOperateRendering; } goto Hw4P3; Hw4P3: $this->hookItemOperateRendering = $yeJzO; goto iSGlj; iSGlj: return $this; goto sUV6w; sUV6w: } public function hookItemOperateFieldBuild($yeJzO = null) { goto ifTLd; ifTLd: if (null === $yeJzO) { return $this->hookItemOperateFieldBuild; } goto or4j3; ZS8QL: return $this; goto d8DM8; or4j3: $this->hookItemOperateFieldBuild = $yeJzO; goto ZS8QL; d8DM8: } public function operateFixed($uS0Mx) { $this->hookItemOperateFieldBuild(function (AbstractField $Mk6lP) use($uS0Mx) { $Mk6lP->gridFixed($uS0Mx); }); return $this; } }