<?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($GBwzV) { $this->addVariables(array('server' => $GBwzV)); return $this; } public function viewWithModel($tkusQ, $Hx0sQ = 'id', $zafNU = 'title') { $this->hookRendering(function (AbstractField $Mk6lP, $yFnpO, $dtpXv) use($tkusQ, $Hx0sQ, $zafNU) { switch ($Mk6lP->renderMode()) { case FieldRenderMode::DETAIL: case FieldRenderMode::GRID: goto mdEOe; PlLvI: return AutoRenderedFieldValue::make($mdHu1); goto KPGJu; mdEOe: $mdHu1 = $yFnpO[$Mk6lP->name()]; goto vUo5A; vUo5A: $ZMPsd = ModelUtil::get($tkusQ, array($Hx0sQ => $mdHu1)); goto b6Eg0; b6Eg0: if ($ZMPsd) { $mdHu1 = $ZMPsd[$zafNU]; } goto PlLvI; KPGJu: } }); return $this; } public static function handleModel($tkusQ, $Hx0sQ = 'id', $zafNU = 'title', $pFM9U = array()) { goto bUsKT; yYZze: return Response::generateSuccessData(array('options' => $Tpa5t)); goto Jo4Go; pZLp8: $TG2we = InputPackage::buildFromInput(); goto vl_H7; cObUi: $qeoqS = ModelUtil::model($tkusQ); goto fr_Mt; ytbvs: $PcG4B = $qeoqS->orderBy($pFM9U['sort'][0], $pFM9U['sort'][1])->limit(10)->get(array($Hx0sQ, $zafNU))->toArray(); goto qPKC1; qPKC1: $Tpa5t = array(); goto tK6gY; LPHKQ: $l15kG = $TG2we->getTrimString('keywords'); goto cObUi; fr_Mt: if ($mdHu1) { $qeoqS = $qeoqS->where($Hx0sQ, $mdHu1); } goto J2ee8; J2ee8: if ($l15kG) { $qeoqS = $qeoqS->where($zafNU, 'like', '%' . $l15kG . '%'); } goto ytbvs; vl_H7: $mdHu1 = $TG2we->getInteger('value'); goto LPHKQ; bUsKT: if (!isset($pFM9U['sort'])) { $pFM9U['sort'] = array('id', 'desc'); } goto pZLp8; tK6gY: foreach ($PcG4B as $ZMPsd) { $Tpa5t[] = array('value' => $ZMPsd[$Hx0sQ], 'label' => $ZMPsd[$zafNU]); } goto yYZze; Jo4Go: } }