<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Grid\Displayer; use Illuminate\Database\Eloquent\Model; 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 $operates = array(); protected $onlyOperate = null; protected $prependOperates = array(); protected $appendOperates = array(); protected $fluentAttributes = array('item', 'index', 'canShow', 'canEdit', 'canDelete', 'canSort'); public function reset() { goto BfHRG; a3YeT: $this->canSort = $this->grid->canSort(); goto hTbOY; DJy_4: $this->canEdit = $this->grid->canEdit(); goto SLtfq; neKg9: $this->canShow = $this->grid->canShow(); goto DJy_4; SLtfq: $this->canDelete = $this->grid->canDelete(); goto a3YeT; hnqOh: $this->index = null; goto neKg9; BfHRG: $this->item = null; goto hnqOh; MJUlX: return $this; goto aQXFU; hTbOY: $this->resetOperates(); goto MJUlX; aQXFU: } public function setField($Q2vn5) { $this->field = $Q2vn5; } public function getField() { return $this->field; } public function resetOperates() { goto MHrHY; MHrHY: $this->onlyOperate = null; goto xxvw6; xxvw6: $this->prependOperates = array(); goto D9VW0; D9VW0: $this->appendOperates = array(); goto wzsDp; wzsDp: } public function only($PP1jh) { $this->onlyOperate = $PP1jh; return $this; } public function push($PP1jh) { $this->appendOperates[] = $PP1jh; return $this; } public function prepend($PP1jh) { if (is_array($PP1jh)) { $this->prependOperates = array_merge($PP1jh, $this->prependOperates); } else { $this->prependOperates[] = $PP1jh; } } public function render() { goto kxtO9; ZCO3_: $this->operates = array_merge($this->operates, $this->prependOperates); goto K_Hmr; K_Hmr: if ($this->canSort() && $this->grid->urlSort()) { goto DQVpg; bzRrH: $this->operates[] = TextAction::primary('<i class="iconfont icon-direction-down"></i>', 'data-sort="down"'); goto cMq0L; m4s6x: if ($H8s1B) { $this->field->width(400); } goto q7Hvm; YTmIz: $this->operates[] = TextAction::primary('<i class="iconfont icon-direction-up"></i>', 'data-sort="up"'); goto bzRrH; cMq0L: $this->operates[] = TextAction::primary('<i class="iconfont icon-bottom"></i>', 'data-sort="bottom"'); goto m4s6x; DQVpg: $this->operates[] = TextAction::primary('<i class="iconfont icon-top"></i>', 'data-sort="top"'); goto YTmIz; q7Hvm: } goto jOsf2; jOsf2: if ($this->canShow() && $this->grid->urlShow()) { $this->operates[] = TextAction::primary(L('Show'), 'data-show'); } goto HR5JG; sLFs9: return join('', $this->operates); goto LVyRi; dO9Xg: if (null !== $this->onlyOperate) { return $this->onlyOperate; } goto egKUR; asBsZ: if ($this->canDelete() && $this->grid->urlDelete()) { $this->operates[] = TextAction::danger(L('Delete'), 'data-delete'); } goto Mcspd; kxtO9: $H8s1B = empty($this->field->width()); goto RSPQ1; egKUR: $this->operates = array(); goto ZCO3_; RSPQ1: if ($H8s1B) { $this->field->width(200); } goto dO9Xg; HR5JG: if ($this->canEdit() && $this->grid->urlEdit()) { if ($this->grid->editBlankPage()) { $this->operates[] = TextLink::primary(L('Edit'), $this->grid->urlEdit() . '?_id=' . $this->item->{$this->grid->getRepositoryKeyName()}); } else { $this->operates[] = TextAction::primary(L('Edit'), 'data-edit'); } } goto asBsZ; Mcspd: $this->operates = array_merge($this->operates, $this->appendOperates); goto sLFs9; LVyRi: } }