<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Grid\Concerns; use ModStart\Field\AbstractField; use ModStart\Field\Display; use ModStart\Grid\Displayer\ItemOperate; use ModStart\Grid\Grid; use ModStart\Support\Concern\HasSetting; trait HasItemOperate { private $itemOperate; private $hookItemOperateRendering; private function setupItemOperate() { $this->itemOperate = new ItemOperate($this); } private function prepareItemOperateField() { if ($this->canEdit || $this->canShow || $this->canDelete || $this->hookItemOperateRendering) { goto s2pdm; OIwmT: $this->pushField($Q2vn5); goto bDpoC; s2pdm: $Q2vn5 = new Display('_operate', array(L('Operate'))); goto YCYIj; YCYIj: $Q2vn5->hookRendering(function (AbstractField $Q2vn5, $Nrp0b, $XIWRg) { $this->itemOperate->reset()->item($Nrp0b)->index($XIWRg); $this->itemOperate->setField($Q2vn5); if ($this->hookItemOperateRendering) { call_user_func($this->hookItemOperateRendering, $this->itemOperate); } return $this->itemOperate->render(); }); goto OIwmT; bDpoC: } } public function disableItemOperate() { goto xY8Bz; Z8rPt: $this->canShow = false; goto q4VvF; xY8Bz: $this->canEdit = false; goto Z8rPt; q4VvF: $this->canDelete = false; goto GEHNp; GEHNp: $this->hookItemOperateRendering = false; goto n3ZM5; n3ZM5: return $this; goto I34va; I34va: } public function hookItemOperateRendering($l2aoe = null) { goto Ag2rl; FDtTb: $this->hookItemOperateRendering = $l2aoe; goto OHiax; OHiax: return $this; goto gDAlT; Ag2rl: if (null === $l2aoe) { return $this->hookItemOperateRendering; } goto FDtTb; gDAlT: } }