<?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($RlLfN) { $this->addVariables(array('server' => $RlLfN)); return $this; } public function viewWithModel($loNjC, $youLk = 'id', $JBEUQ = 'title') { $this->hookRendering(function (AbstractField $Ldet7, $P1uVJ, $C6OV7) use($loNjC, $youLk, $JBEUQ) { switch ($Ldet7->renderMode()) { case FieldRenderMode::DETAIL: case FieldRenderMode::GRID: goto brlB2; aI3po: $IgPyb = ModelUtil::get($loNjC, array($youLk => $cBDsM)); goto YCmrF; YCmrF: if ($IgPyb) { $cBDsM = $IgPyb[$JBEUQ]; } goto aR2rj; aR2rj: return AutoRenderedFieldValue::make($cBDsM); goto h1eEv; brlB2: $cBDsM = $P1uVJ[$Ldet7->name()]; goto aI3po; h1eEv: } }); return $this; } public static function handleModel($loNjC, $youLk = 'id', $JBEUQ = 'title', $mattM = array()) { goto w8rta; CffRg: $d5ixK = $nYIOS->orderBy($mattM['sort'][0], $mattM['sort'][1])->limit(10)->get(array($youLk, $JBEUQ))->toArray(); goto mp3ke; lQHzt: return Response::generateSuccessData(array('options' => $Ho5Xg)); goto QHbp9; GfuGb: if ($R5QVI) { $nYIOS = $nYIOS->where($JBEUQ, 'like', '%' . $R5QVI . '%'); } goto CffRg; ZNhhq: $nYIOS = ModelUtil::model($loNjC); goto LhDUQ; LhDUQ: if ($cBDsM) { $nYIOS = $nYIOS->where($youLk, $cBDsM); } goto GfuGb; mp3ke: $Ho5Xg = array(); goto PNgNl; Zrto3: $R5QVI = $vfMTB->getTrimString('keywords'); goto ZNhhq; PNgNl: foreach ($d5ixK as $IgPyb) { $Ho5Xg[] = array('value' => $IgPyb[$youLk], 'label' => $IgPyb[$JBEUQ]); } goto lQHzt; twLtK: $vfMTB = InputPackage::buildFromInput(); goto Ov_pN; Ov_pN: $cBDsM = $vfMTB->getInteger('value'); goto Zrto3; w8rta: if (!isset($mattM['sort'])) { $mattM['sort'] = array('id', 'desc'); } goto twLtK; QHbp9: } }