<?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 Jg3_G; An5jD: $this->canShow = $this->grid->canShow(); goto xNF3T; lT0LE: $this->index = null; goto An5jD; TxExP: $this->resetOperates(); goto Eenqj; xNF3T: $this->canEdit = $this->grid->canEdit(); goto ny9oN; Eenqj: return $this; goto O3m9F; x1r4Q: $this->canCopy = $this->grid->canCopy() && $this->grid->canAdd(); goto TxExP; ny9oN: $this->canDelete = $this->grid->canDelete(); goto hLNR5; hLNR5: $this->canSort = $this->grid->canSort(); goto x1r4Q; Jg3_G: $this->item = null; goto lT0LE; O3m9F: } public function setField($E8QRJ) { $this->field = $E8QRJ; } public function getField() { return $this->field; } public function resetOperates() { goto eBu3y; ych0V: $this->prependOperates = array(); goto AEB26; eBu3y: $this->onlyOperate = null; goto ych0V; AEB26: $this->appendOperates = array(); goto fBwLk; fBwLk: } public function only($nmQ19) { $this->onlyOperate = $nmQ19; return $this; } public function push($nmQ19) { $this->appendOperates[] = $nmQ19; return $this; } public function prepend($nmQ19) { if (is_array($nmQ19)) { $this->prependOperates = array_merge($nmQ19, $this->prependOperates); } else { $this->prependOperates[] = $nmQ19; } } public function render() { goto ARLn1; HK3iQ: if ($this->canEdit() && $this->grid->urlEdit()) { goto lR5RF; lR5RF: $zf1v3 = $this->grid->textEdit(); goto e3MA8; lxwNJ: if ($this->grid->editBlankPage()) { $this->operates[] = TextLink::primary($zf1v3, $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($zf1v3, 'data-edit'); } goto gv3Q9; e3MA8: if (empty($zf1v3)) { $zf1v3 = L('Edit'); } goto lxwNJ; gv3Q9: } goto yAiRK; Ltuti: if ($this->canSort() && $this->grid->urlSort()) { goto IMHco; iSX2b: $this->operates[] = TextAction::primary('<i class="iconfont icon-bottom"></i>', 'data-sort="bottom"'); goto Ga617; q86Pc: $this->operates[] = TextAction::primary('<i class="iconfont icon-direction-up"></i>', 'data-sort="up"'); goto rQI_q; IMHco: $this->operates[] = TextAction::primary('<i class="iconfont icon-top"></i>', 'data-sort="top"'); goto q86Pc; rQI_q: $this->operates[] = TextAction::primary('<i class="iconfont icon-direction-down"></i>', 'data-sort="down"'); goto iSX2b; Ga617: } goto cadJ2; DIVoy: return join('', $this->operates); goto meLil; cadJ2: if ($this->canShow() && $this->grid->urlShow()) { $this->operates[] = TextAction::primary(L('Show'), 'data-show'); } goto HK3iQ; JqC3q: if ($this->canCopy()) { $this->operates[] = TextAction::muted(L('Copy'), 'data-add-button data-add-copy-button'); } goto Jx3pX; yAiRK: if ($this->canDelete() && $this->grid->urlDelete()) { $this->operates[] = TextAction::danger(L('Delete'), 'data-delete'); } goto JqC3q; atw77: $this->operates = array(); goto HW2nu; ARLn1: if (null !== $this->onlyOperate) { return $this->onlyOperate; } goto atw77; HW2nu: $this->operates = array_merge($this->operates, $this->prependOperates); goto Ltuti; Jx3pX: $this->operates = array_merge($this->operates, $this->appendOperates); goto DIVoy; meLil: } }