<?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 h0tIr; SrTiv: $Lgjfa->hookRendering(function (AbstractField $Lgjfa, $ZpLX1, $ouMWs) { $this->itemOperate->reset()->item($ZpLX1)->index($ouMWs); $this->itemOperate->setField($Lgjfa); if ($this->hookItemOperateRendering) { call_user_func($this->hookItemOperateRendering, $this->itemOperate); } return $this->itemOperate->render(); }); goto hEUop; Vyx_N: $this->pushField($Lgjfa); goto ihJVS; h0tIr: $Lgjfa = new Display('_operate', array(L('Operate'))); goto SrTiv; hEUop: if ($this->hookItemOperateFieldBuild) { call_user_func($this->hookItemOperateFieldBuild, $Lgjfa); } goto Vyx_N; ihJVS: } } public function disableItemOperate() { goto YpcuP; TIlFa: $this->hookItemOperateRendering = false; goto HjXWg; Tc6Kr: $this->canShow = false; goto Pj1eO; HjXWg: return $this; goto fK1rs; Pj1eO: $this->canDelete = false; goto TIlFa; YpcuP: $this->canEdit = false; goto Tc6Kr; fK1rs: } public function hookItemOperateRendering($aCnQE = null) { goto G4Nc1; G4Nc1: if (null === $aCnQE) { return $this->hookItemOperateRendering; } goto Wz2PZ; rhjSX: return $this; goto pEdJY; Wz2PZ: $this->hookItemOperateRendering = $aCnQE; goto rhjSX; pEdJY: } public function hookItemOperateFieldBuild($aCnQE = null) { goto BjqqL; BjqqL: if (null === $aCnQE) { return $this->hookItemOperateFieldBuild; } goto d4vml; tetyi: return $this; goto Xoba2; d4vml: $this->hookItemOperateFieldBuild = $aCnQE; goto tetyi; Xoba2: } public function operateFixed($Bi4d3) { $this->hookItemOperateFieldBuild(function (AbstractField $Lgjfa) use($Bi4d3) { $Lgjfa->gridFixed($Bi4d3); }); return $this; } }