<?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($J1_hF) { $this->addVariables(array('server' => $J1_hF)); return $this; } public function viewWithModel($Beeb4, $Hd3GJ = 'id', $GQmMQ = 'title') { $this->hookRendering(function (AbstractField $VWt5t, $nsWl0, $R80S9) use($Beeb4, $Hd3GJ, $GQmMQ) { switch ($VWt5t->renderMode()) { case FieldRenderMode::DETAIL: case FieldRenderMode::GRID: goto v0uTN; v0uTN: $gwXrh = $nsWl0[$VWt5t->name()]; goto gtGlt; gtGlt: $Jd1Wg = ModelUtil::get($Beeb4, array($Hd3GJ => $gwXrh)); goto DUFhY; DUFhY: if ($Jd1Wg) { $gwXrh = $Jd1Wg[$GQmMQ]; } goto M6qPU; M6qPU: return AutoRenderedFieldValue::make($gwXrh); goto dthdt; dthdt: } }); return $this; } public static function handleModel($Beeb4, $Hd3GJ = 'id', $GQmMQ = 'title', $zlK8N = array()) { goto KCN3J; mChjv: $feJuE = $lpymm->orderBy($zlK8N['sort'][0], $zlK8N['sort'][1])->limit(10)->get(array($Hd3GJ, $GQmMQ))->toArray(); goto MHYtp; RP65Z: if ($LDRBW) { $lpymm = $lpymm->where($GQmMQ, 'like', '%' . $LDRBW . '%'); } goto mChjv; KCN3J: if (!isset($zlK8N['sort'])) { $zlK8N['sort'] = array('id', 'desc'); } goto ruyXn; MHYtp: $C87JF = array(); goto J3M0f; hamcQ: $gwXrh = $Zxpx_->getInteger('value'); goto MGDKC; sWG80: $lpymm = ModelUtil::model($Beeb4); goto IgBI5; MGDKC: $LDRBW = $Zxpx_->getTrimString('keywords'); goto sWG80; IgBI5: if ($gwXrh) { $lpymm = $lpymm->where($Hd3GJ, $gwXrh); } goto RP65Z; ruyXn: $Zxpx_ = InputPackage::buildFromInput(); goto hamcQ; J3M0f: foreach ($feJuE as $Jd1Wg) { $C87JF[] = array('value' => $Jd1Wg[$Hd3GJ], 'label' => $Jd1Wg[$GQmMQ]); } goto Hs_GT; Hs_GT: return Response::generateSuccessData(array('options' => $C87JF)); goto pOi8N; pOi8N: } }