<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Field; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Input\InputPackage; use ModStart\Core\Input\Response; use ModStart\Field\Concern\CanCascadeFields; use ModStart\Field\Type\FieldRenderMode; class SelectRemote extends AbstractField { use CanCascadeFields; protected function setup() { $this->addVariables(array('server' => '')); } public function server($GyeYJ) { $this->addVariables(array('server' => $GyeYJ)); return $this; } public function viewWithModel($oAD_e, $tPnOV = 'id', $rK_k5 = 'title') { $this->hookRendering(function (AbstractField $Lgjfa, $ZpLX1, $ouMWs) use($oAD_e, $tPnOV, $rK_k5) { switch ($Lgjfa->renderMode()) { case FieldRenderMode::DETAIL: case FieldRenderMode::GRID: goto K1Dsb; K1Dsb: $wvO30 = $ZpLX1[$Lgjfa->name()]; goto Ju_Sh; YLmDt: if ($FN3l1) { $wvO30 = $FN3l1[$rK_k5]; } goto s0Ofe; Ju_Sh: $FN3l1 = ModelUtil::get($oAD_e, array($tPnOV => $wvO30)); goto YLmDt; s0Ofe: return AutoRenderedFieldValue::make($wvO30); goto ydnz5; ydnz5: } }); return $this; } public static function handleModel($oAD_e, $tPnOV = 'id', $rK_k5 = 'title', $oK4I3 = array()) { goto TKSaJ; L3Gvr: if ($wvO30) { $hAzJ1 = $hAzJ1->where($tPnOV, $wvO30); } goto QMLnI; Xu3ja: return Response::generateSuccessData(array('options' => $ZNmAK)); goto XKrza; QMLnI: if ($hnXpY) { $hAzJ1 = $hAzJ1->where($rK_k5, 'like', '%' . $hnXpY . '%'); } goto kCz67; hICpn: $ZNmAK = array(); goto BngDN; kCz67: $J2nWJ = $hAzJ1->orderBy($oK4I3['sort'][0], $oK4I3['sort'][1])->limit(10)->get(array($tPnOV, $rK_k5))->toArray(); goto hICpn; JpbJj: $wvO30 = $HoUFw->getInteger('value'); goto jsEfs; BngDN: foreach ($J2nWJ as $FN3l1) { $ZNmAK[] = array('value' => $FN3l1[$tPnOV], 'label' => $FN3l1[$rK_k5]); } goto Xu3ja; jsEfs: $hnXpY = $HoUFw->getTrimString('keywords'); goto kN9t1; TKSaJ: if (!isset($oK4I3['sort'])) { $oK4I3['sort'] = array('id', 'desc'); } goto yj2xx; kN9t1: $hAzJ1 = ModelUtil::model($oAD_e); goto L3Gvr; yj2xx: $HoUFw = InputPackage::buildFromInput(); goto JpbJj; XKrza: } }