<?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 t8tqI; JbxHK: $this->index = null; goto u0NKt; b7VEH: return $this; goto BE71B; u0NKt: $this->canShow = $this->grid->canShow(); goto HO1Ny; t8tqI: $this->item = null; goto JbxHK; v2m1a: $this->canDelete = $this->grid->canDelete(); goto UHjkO; xWSXT: $this->canCopy = $this->grid->canCopy() && $this->grid->canAdd(); goto P9C2Q; P9C2Q: $this->resetOperates(); goto b7VEH; UHjkO: $this->canSort = $this->grid->canSort(); goto xWSXT; HO1Ny: $this->canEdit = $this->grid->canEdit(); goto v2m1a; BE71B: } public function setField($Mk6lP) { $this->field = $Mk6lP; } public function getField() { return $this->field; } public function resetOperates() { goto WFKIu; WFKIu: $this->onlyOperate = null; goto JQxyx; JQxyx: $this->prependOperates = array(); goto j93Ba; j93Ba: $this->appendOperates = array(); goto pPl0R; pPl0R: } public function only($frI43) { $this->onlyOperate = $frI43; return $this; } public function push($frI43) { $this->appendOperates[] = $frI43; return $this; } public function prepend($frI43) { if (is_array($frI43)) { $this->prependOperates = array_merge($frI43, $this->prependOperates); } else { $this->prependOperates[] = $frI43; } } public function render() { goto pR6ST; hyS8v: if ($this->canEdit() && $this->grid->urlEdit()) { goto ShuMi; ShuMi: $Hv_MO = $this->grid->textEdit(); goto E8jUS; E8jUS: if (empty($Hv_MO)) { $Hv_MO = L('Edit'); } goto CFnrG; CFnrG: if ($this->grid->editBlankPage()) { $this->operates[] = TextLink::primary($Hv_MO, $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($Hv_MO, 'data-edit'); } goto Cztx8; Cztx8: } goto BShhc; Y942u: if ($this->canShow() && $this->grid->urlShow()) { $this->operates[] = TextAction::primary(L('Show'), 'data-show'); } goto hyS8v; HXcRW: $this->operates = array_merge($this->operates, $this->prependOperates); goto fLi0D; pR6ST: if (null !== $this->onlyOperate) { return $this->onlyOperate; } goto LveV9; LveV9: $this->operates = array(); goto HXcRW; fLi0D: if ($this->canSort() && $this->grid->urlSort()) { goto X3Ig6; lB00Z: $this->operates[] = TextAction::primary('<i class="iconfont icon-direction-up"></i>', 'data-sort="up"'); goto Z7lty; X3Ig6: $this->operates[] = TextAction::primary('<i class="iconfont icon-top"></i>', 'data-sort="top"'); goto lB00Z; Z7lty: $this->operates[] = TextAction::primary('<i class="iconfont icon-direction-down"></i>', 'data-sort="down"'); goto VJdwq; VJdwq: $this->operates[] = TextAction::primary('<i class="iconfont icon-bottom"></i>', 'data-sort="bottom"'); goto LffFN; LffFN: } goto Y942u; jZPgC: return join('', $this->operates); goto HrFEJ; BShhc: if ($this->canDelete() && $this->grid->urlDelete()) { $this->operates[] = TextAction::danger(L('Delete'), 'data-delete'); } goto uzG5z; uzG5z: if ($this->canCopy()) { $this->operates[] = TextAction::muted(L('Copy'), 'data-add-button data-add-copy-button'); } goto oFBsx; oFBsx: $this->operates = array_merge($this->operates, $this->appendOperates); goto jZPgC; HrFEJ: } }