namespace Combodo\iTop\Renderer\Console\FieldRenderer; use Combodo\iTop\Form\Field\StringField; use \Dict; use Combodo\iTop\Renderer\FieldRenderer; use Combodo\iTop\Renderer\RenderingOutput; class ConsoleSimpleFieldRenderer extends FieldRenderer { public function Render() { $oOutput = new RenderingOutput(); $sFieldClass = get_class($this->oField); if ($sFieldClass == 'Combodo\\iTop\\Form\\Field\\HiddenField') { $oOutput->AddHtml(''); } else { $oOutput->AddHtml('
'); } switch ($sFieldClass) { case 'Combodo\\iTop\\Form\\Field\\StringField': $oOutput->AddHtml(' | '); if ($this->oField->GetReadOnly()) { $oOutput->AddHtml(''); $oOutput->AddHtml(''.htmlentities($this->oField->GetCurrentValue(), ENT_QUOTES, 'UTF-8').''); } else { $oOutput->AddHtml(''); } $oOutput->AddHtml(''); $oOutput->AddHtml(' | '); break; case 'Combodo\\iTop\\Form\\Field\\SelectField': $oOutput->AddHtml(''); if ($this->oField->GetReadOnly()) { $aChoices = $this->oField->GetChoices(); $sCurrentLabel = isset($aChoices[$this->oField->GetCurrentValue()]) ? $aChoices[$this->oField->GetCurrentValue()] : '' ; $oOutput->AddHtml(''); $oOutput->AddHtml(''.htmlentities($sCurrentLabel, ENT_QUOTES, 'UTF-8').''); } else { $oOutput->AddHtml(''); } $oOutput->AddHtml(''); $oOutput->AddHtml(' | '); break; case 'Combodo\\iTop\\Form\\Field\\SelectObjectField': $oOutput->AddHtml(''); if ($this->oField->GetReadOnly()) { $oSearch = \DBSearch::FromOQL($this->oField->GetOqlQuery()); $oSearch->AddCondition('id', $this->oField->GetCurrentValue()); $oSet = new DBObjectSet($oSearch); $oObject = $oSet->Fetch(); if ($oObject) { $sCurrentLabel = $oObject->Get('friendlyname'); } else { $sCurrentLabel = ''; } $oOutput->AddHtml(''); $oOutput->AddHtml(''.htmlentities($sCurrentLabel, ENT_QUOTES, 'UTF-8').''); } else { $oSearch = \DBSearch::FromOQL($this->oField->GetOqlQuery()); $oSet = new \DBObjectSet($oSearch); $oSet->OptimizeColumnLoad(array($oSearch->GetClassAlias() => array('friendlyname'))); $oOutput->AddHtml(''); } $oOutput->AddHtml(''); $oOutput->AddHtml(' | '); break; } $oOutput->AddHtml('