<?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 N2PIp; WoHhr: $this->canSort = $this->grid->canSort(); goto t5zZK; wYm0T: $this->index = null; goto ztjWv; t5zZK: $this->canCopy = $this->grid->canCopy() && $this->grid->canAdd(); goto QySi1; ztjWv: $this->canShow = $this->grid->canShow(); goto NZwkw; NZwkw: $this->canEdit = $this->grid->canEdit(); goto fPNIO; N2PIp: $this->item = null; goto wYm0T; fPNIO: $this->canDelete = $this->grid->canDelete(); goto WoHhr; NUGph: return $this; goto dl09z; QySi1: $this->resetOperates(); goto NUGph; dl09z: } public function setField($acdQI) { $this->field = $acdQI; } public function getField() { return $this->field; } public function resetOperates() { goto E0OZ1; bbkev: $this->appendOperates = array(); goto zdg3x; yZnY1: $this->prependOperates = array(); goto bbkev; E0OZ1: $this->onlyOperate = null; goto yZnY1; zdg3x: } public function only($IouSv) { $this->onlyOperate = $IouSv; return $this; } public function push($IouSv) { $this->appendOperates[] = $IouSv; return $this; } public function prepend($IouSv) { if (is_array($IouSv)) { $this->prependOperates = array_merge($IouSv, $this->prependOperates); } else { $this->prependOperates[] = $IouSv; } } public function render() { goto KPIuJ; TTqRj: $this->operates = array_merge($this->operates, $this->prependOperates); goto ShfyS; abiG8: if ($this->canShow() && $this->grid->urlShow()) { $this->operates[] = TextAction::primary(L('Show'), 'data-show'); } goto kBTu0; zIQ23: $this->operates = array(); goto TTqRj; r3rl5: return join('', $this->operates); goto rVixl; DIp7V: if ($this->canCopy()) { $this->operates[] = TextAction::muted(L('Copy'), 'data-add-button data-add-copy-button'); } goto tlpJV; tlpJV: $this->operates = array_merge($this->operates, $this->appendOperates); goto r3rl5; ShfyS: if ($this->canSort() && $this->grid->urlSort()) { goto JyMTV; dLZFM: $this->operates[] = TextAction::primary('<i class="iconfont icon-direction-down"></i>', 'data-sort="down"'); goto hZM6s; hZM6s: $this->operates[] = TextAction::primary('<i class="iconfont icon-bottom"></i>', 'data-sort="bottom"'); goto k2j4X; p4zO2: $this->operates[] = TextAction::primary('<i class="iconfont icon-direction-up"></i>', 'data-sort="up"'); goto dLZFM; JyMTV: $this->operates[] = TextAction::primary('<i class="iconfont icon-top"></i>', 'data-sort="top"'); goto p4zO2; k2j4X: } goto abiG8; KPIuJ: if (null !== $this->onlyOperate) { return $this->onlyOperate; } goto zIQ23; kBTu0: if ($this->canEdit() && $this->grid->urlEdit()) { goto vKtYu; vKtYu: $a11Vh = $this->grid->textEdit(); goto Trrtn; zvlx8: if ($this->grid->editBlankPage()) { $this->operates[] = TextLink::primary($a11Vh, $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($a11Vh, 'data-edit'); } goto DFEIB; Trrtn: if (empty($a11Vh)) { $a11Vh = L('Edit'); } goto zvlx8; DFEIB: } goto bJWJK; bJWJK: if ($this->canDelete() && $this->grid->urlDelete()) { $this->operates[] = TextAction::danger(L('Delete'), 'data-delete'); } goto DIp7V; rVixl: } }