<?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 xfZtC; EOT7M: $this->canEdit = $this->grid->canEdit(); goto jJFri; bSDzR: $this->index = null; goto nAwjL; vjz_5: $this->canCopy = $this->grid->canCopy() && $this->grid->canAdd(); goto IPkBr; jJFri: $this->canDelete = $this->grid->canDelete(); goto RgABg; IPkBr: $this->resetOperates(); goto TdMIF; nAwjL: $this->canShow = $this->grid->canShow(); goto EOT7M; TdMIF: return $this; goto rylTl; xfZtC: $this->item = null; goto bSDzR; RgABg: $this->canSort = $this->grid->canSort(); goto vjz_5; rylTl: } public function setField($VWt5t) { $this->field = $VWt5t; } public function getField() { return $this->field; } public function resetOperates() { goto Tcslg; kwLuU: $this->prependOperates = array(); goto q3RmC; Tcslg: $this->onlyOperate = null; goto kwLuU; q3RmC: $this->appendOperates = array(); goto hFbZm; hFbZm: } public function only($IakfY) { $this->onlyOperate = $IakfY; return $this; } public function push($IakfY) { $this->appendOperates[] = $IakfY; return $this; } public function prepend($IakfY) { if (is_array($IakfY)) { $this->prependOperates = array_merge($IakfY, $this->prependOperates); } else { $this->prependOperates[] = $IakfY; } } public function render() { goto kljsF; kljsF: if (null !== $this->onlyOperate) { return $this->onlyOperate; } goto vG22m; vG22m: $this->operates = array(); goto mfEUN; XqNkm: if ($this->canEdit() && $this->grid->urlEdit()) { goto trk2m; trk2m: $HLmQj = $this->grid->textEdit(); goto Lvl8y; jEbSW: if ($this->grid->editBlankPage()) { $this->operates[] = TextLink::primary($HLmQj, $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($HLmQj, 'data-edit'); } goto oiLBy; Lvl8y: if (empty($HLmQj)) { $HLmQj = L('Edit'); } goto jEbSW; oiLBy: } goto aeBre; OLqxf: if ($this->canShow() && $this->grid->urlShow()) { $this->operates[] = TextAction::primary(L('Show'), 'data-show'); } goto XqNkm; c95ca: if ($this->canSort() && $this->grid->urlSort()) { goto ZONyn; Z0_5I: $this->operates[] = TextAction::primary('<i class="iconfont icon-direction-down"></i>', 'data-sort="down"'); goto j0sEt; ZONyn: $this->operates[] = TextAction::primary('<i class="iconfont icon-top"></i>', 'data-sort="top"'); goto i6HeA; j0sEt: $this->operates[] = TextAction::primary('<i class="iconfont icon-bottom"></i>', 'data-sort="bottom"'); goto TSPu8; i6HeA: $this->operates[] = TextAction::primary('<i class="iconfont icon-direction-up"></i>', 'data-sort="up"'); goto Z0_5I; TSPu8: } goto OLqxf; mfEUN: $this->operates = array_merge($this->operates, $this->prependOperates); goto c95ca; m0e75: if ($this->canCopy()) { $this->operates[] = TextAction::muted(L('Copy'), 'data-add-button data-add-copy-button'); } goto cBtT7; dSO2f: return join('', $this->operates); goto DHpoY; aeBre: if ($this->canDelete() && $this->grid->urlDelete()) { $this->operates[] = TextAction::danger(L('Delete'), 'data-delete'); } goto m0e75; cBtT7: $this->operates = array_merge($this->operates, $this->appendOperates); goto dSO2f; DHpoY: } }