<?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 gKE7z; h5DOz: $this->canShow = $this->grid->canShow(); goto K4dBN; X2dBW: return $this; goto ycw7j; gKE7z: $this->item = null; goto Nxk6d; wjrt7: $this->canCopy = $this->grid->canCopy() && $this->grid->canAdd(); goto A38Lu; K4dBN: $this->canEdit = $this->grid->canEdit(); goto uGYmZ; A38Lu: $this->resetOperates(); goto X2dBW; v7P6U: $this->canSort = $this->grid->canSort(); goto wjrt7; uGYmZ: $this->canDelete = $this->grid->canDelete(); goto v7P6U; Nxk6d: $this->index = null; goto h5DOz; ycw7j: } public function setField($Lgjfa) { $this->field = $Lgjfa; } public function getField() { return $this->field; } public function resetOperates() { goto mJaFe; NKPzN: $this->appendOperates = array(); goto fjKmb; mJaFe: $this->onlyOperate = null; goto YOqlH; YOqlH: $this->prependOperates = array(); goto NKPzN; fjKmb: } public function only($k47c4) { $this->onlyOperate = $k47c4; return $this; } public function push($k47c4) { $this->appendOperates[] = $k47c4; return $this; } public function prepend($k47c4) { if (is_array($k47c4)) { $this->prependOperates = array_merge($k47c4, $this->prependOperates); } else { $this->prependOperates[] = $k47c4; } } public function render() { goto E4rlL; hNE36: if ($this->canSort() && $this->grid->urlSort()) { goto Wf_GO; uz0lO: $this->operates[] = TextAction::primary('<i class="iconfont icon-direction-up"></i>', 'data-sort="up"'); goto E4Zn4; Wf_GO: $this->operates[] = TextAction::primary('<i class="iconfont icon-top"></i>', 'data-sort="top"'); goto uz0lO; E4Zn4: $this->operates[] = TextAction::primary('<i class="iconfont icon-direction-down"></i>', 'data-sort="down"'); goto T2bU5; T2bU5: $this->operates[] = TextAction::primary('<i class="iconfont icon-bottom"></i>', 'data-sort="bottom"'); goto EIoXG; EIoXG: } goto FoB3r; b30Iz: $this->operates = array(); goto wBsdT; vmW1P: $this->operates = array_merge($this->operates, $this->appendOperates); goto p9t0O; p9t0O: return join('', $this->operates); goto uaQUR; D8YxC: if ($this->canCopy()) { $this->operates[] = TextAction::muted(L('Copy'), 'data-add-button data-add-copy-button'); } goto vmW1P; Fnuq4: if ($this->canDelete() && $this->grid->urlDelete()) { $this->operates[] = TextAction::danger(L('Delete'), 'data-delete'); } goto D8YxC; E4rlL: if (null !== $this->onlyOperate) { return $this->onlyOperate; } goto b30Iz; FoB3r: if ($this->canShow() && $this->grid->urlShow()) { $this->operates[] = TextAction::primary(L('Show'), 'data-show'); } goto b2aWf; b2aWf: if ($this->canEdit() && $this->grid->urlEdit()) { goto GG8X2; GG8X2: $jIo9u = $this->grid->textEdit(); goto RTmTO; Asw1w: if ($this->grid->editBlankPage()) { $this->operates[] = TextLink::primary($jIo9u, $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($jIo9u, 'data-edit'); } goto OIv6O; RTmTO: if (empty($jIo9u)) { $jIo9u = L('Edit'); } goto Asw1w; OIv6O: } goto Fnuq4; wBsdT: $this->operates = array_merge($this->operates, $this->prependOperates); goto hNE36; uaQUR: } }