<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Grid\Displayer; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\View; use ModStart\Field\AbstractField; use ModStart\Widget\TextAction; use ModStart\Widget\TextLink; class ItemOperate extends AbstractDisplayer { protected $field; protected $item; protected $index; protected $canShow; protected $canEdit; protected $canDelete; protected $canSort; protected $canCopy; protected $operates = array(); protected $onlyOperate = null; protected $prependOperates = array(); protected $appendOperates = array(); protected $fluentAttributes = array('item', 'index', 'canShow', 'canEdit', 'canDelete', 'canSort', 'canCopy'); public function reset() { goto JyzGw; JyzGw: $this->item = null; goto jBtOT; Qfqx1: $this->resetOperates(); goto CZJK3; QLoTy: $this->canSort = $this->grid->canSort(); goto Zaa3W; Dox3T: $this->canDelete = $this->grid->canDelete(); goto QLoTy; jBtOT: $this->index = null; goto NYVPa; Zaa3W: $this->canCopy = $this->grid->canCopy() && $this->grid->canAdd(); goto Qfqx1; CZJK3: return $this; goto JyJdC; NYVPa: $this->canShow = $this->grid->canShow(); goto Oe_u_; Oe_u_: $this->canEdit = $this->grid->canEdit(); goto Dox3T; JyJdC: } public function setField($rZfgs) { $this->field = $rZfgs; } public function getField() { return $this->field; } public function resetOperates() { goto Xtswl; J2PqI: $this->prependOperates = array(); goto grlVS; grlVS: $this->appendOperates = array(); goto d5Sab; Xtswl: $this->onlyOperate = null; goto J2PqI; d5Sab: } public function only($teviB) { $this->onlyOperate = $teviB; return $this; } public function push($teviB) { $this->appendOperates[] = $teviB; return $this; } public function prepend($teviB) { if (is_array($teviB)) { $this->prependOperates = array_merge($teviB, $this->prependOperates); } else { $this->prependOperates[] = $teviB; } } public function render() { goto WPadX; upe6Z: return join('', $this->operates); goto H4hfd; D4dAc: if ($this->canShow() && $this->grid->urlShow()) { $this->operates[] = TextAction::primary(L('Show'), 'data-show'); } goto jBzxa; jBzxa: if ($this->canEdit() && $this->grid->urlEdit()) { goto MkSiI; JZekl: if ($this->grid->editBlankPage()) { $this->operates[] = TextLink::primary($uYHmK, $this->grid->urlEdit() . '?_id=' . $this->item->{$this->grid->getRepositoryKeyName()}, modstart_admin_is_tab() ? 'data-tab-open data-refresh-grid-on-close' : ''); } else { $this->operates[] = TextAction::primary($uYHmK, 'data-edit'); } goto Qmz8l; TbTkv: if (empty($uYHmK)) { $uYHmK = L('Edit'); } goto JZekl; MkSiI: $uYHmK = $this->grid->textEdit(); goto TbTkv; Qmz8l: } goto ICtlg; fxq1z: if ($this->canSort() && $this->grid->urlSort()) { goto TpzP5; TpzP5: $this->operates[] = TextAction::primary('<i class="iconfont icon-top"></i>', 'data-sort="top"'); goto F_t8F; fLYtm: $this->operates[] = TextAction::primary('<i class="iconfont icon-direction-down"></i>', 'data-sort="down"'); goto fhXVC; fhXVC: $this->operates[] = TextAction::primary('<i class="iconfont icon-bottom"></i>', 'data-sort="bottom"'); goto z0YFU; F_t8F: $this->operates[] = TextAction::primary('<i class="iconfont icon-direction-up"></i>', 'data-sort="up"'); goto fLYtm; z0YFU: } goto D4dAc; WPadX: if (null !== $this->onlyOperate) { return $this->onlyOperate; } goto gTiPq; IQg3P: $this->operates = array_merge($this->operates, $this->prependOperates); goto fxq1z; VY0Mn: $this->operates = array_merge($this->operates, $this->appendOperates); goto upe6Z; gTiPq: $this->operates = array(); goto IQg3P; p3Dia: if ($this->canCopy()) { $this->operates[] = TextAction::muted(L('Copy'), 'data-add-button data-add-copy-button'); } goto VY0Mn; ICtlg: if ($this->canDelete() && $this->grid->urlDelete()) { $this->operates[] = TextAction::danger(L('Delete'), 'data-delete'); } goto p3Dia; H4hfd: } }