<?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 OTuBb; mnCf1: $this->canShow = $this->grid->canShow(); goto HabRr; WLUns: $this->canDelete = $this->grid->canDelete(); goto RDvs4; cyRcF: $this->canCopy = $this->grid->canCopy() && $this->grid->canAdd(); goto O2Ul5; O2Ul5: $this->resetOperates(); goto Qzqsd; OTuBb: $this->item = null; goto ubYeG; RDvs4: $this->canSort = $this->grid->canSort(); goto cyRcF; Qzqsd: return $this; goto H202F; HabRr: $this->canEdit = $this->grid->canEdit(); goto WLUns; ubYeG: $this->index = null; goto mnCf1; H202F: } public function setField($pu1ro) { $this->field = $pu1ro; } public function getField() { return $this->field; } public function resetOperates() { goto iYkgk; yuTm0: $this->appendOperates = array(); goto fXi4W; iYkgk: $this->onlyOperate = null; goto AZBVq; AZBVq: $this->prependOperates = array(); goto yuTm0; fXi4W: } public function only($d14pM) { $this->onlyOperate = $d14pM; return $this; } public function push($d14pM) { $this->appendOperates[] = $d14pM; return $this; } public function prepend($d14pM) { if (is_array($d14pM)) { $this->prependOperates = array_merge($d14pM, $this->prependOperates); } else { $this->prependOperates[] = $d14pM; } } public function render() { goto q9jPz; sbYap: return join('', $this->operates); goto j4Rtw; TnCXL: $this->operates = array_merge($this->operates, $this->prependOperates); goto MkUYI; q9jPz: if (null !== $this->onlyOperate) { return $this->onlyOperate; } goto SIdrl; HtKa6: $this->operates = array_merge($this->operates, $this->appendOperates); goto sbYap; rAZSq: if ($this->canDelete() && $this->grid->urlDelete()) { $this->operates[] = TextAction::danger(L('Delete'), 'data-delete'); } goto bCiAZ; bCiAZ: if ($this->canCopy()) { $this->operates[] = TextAction::muted(L('Copy'), 'data-add-button data-add-copy-button'); } goto HtKa6; a_VCO: if ($this->canShow() && $this->grid->urlShow()) { $this->operates[] = TextAction::primary(L('Show'), 'data-show'); } goto JVZZz; SIdrl: $this->operates = array(); goto TnCXL; MkUYI: if ($this->canSort() && $this->grid->urlSort()) { goto sYvkc; WjuKx: $this->operates[] = TextAction::primary('<i class="iconfont icon-bottom"></i>', 'data-sort="bottom"'); goto tIrhJ; sYvkc: $this->operates[] = TextAction::primary('<i class="iconfont icon-top"></i>', 'data-sort="top"'); goto jmeIN; jmeIN: $this->operates[] = TextAction::primary('<i class="iconfont icon-direction-up"></i>', 'data-sort="up"'); goto Qc9mV; Qc9mV: $this->operates[] = TextAction::primary('<i class="iconfont icon-direction-down"></i>', 'data-sort="down"'); goto WjuKx; tIrhJ: } goto a_VCO; JVZZz: if ($this->canEdit() && $this->grid->urlEdit()) { goto zylbZ; zylbZ: $F7oCU = $this->grid->textEdit(); goto g2fR_; SSEIy: if ($this->grid->editBlankPage()) { $this->operates[] = TextLink::primary($F7oCU, $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($F7oCU, 'data-edit'); } goto A9FXK; g2fR_: if (empty($F7oCU)) { $F7oCU = L('Edit'); } goto SSEIy; A9FXK: } goto rAZSq; j4Rtw: } }