/** * {@inheritdoc} */ public function renderAllFields($mode, $filterFields = array(), $readOnlyFields = array()) { self::$logger->debug('>>renderAllFields(mode=[' . $mode . '], filterFields=[' . var_export($filterFields, true) . '], readOnlyFields=[' . var_export($readOnlyFields, true) . '])'); $html = ''; // get the class attributes $properties = array_keys($this->BO->getDataLabels()); $orignalMode = $mode; foreach ($properties as $propName) { if (!in_array($propName, $this->BO->getDefaultAttributes()) && !in_array($propName, $filterFields)) { // render readonly fields in the supplied array if (in_array($propName, $readOnlyFields)) { $mode = 'view'; } else { $mode = $orignalMode; } if (!is_object($this->BO->getPropObject($propName))) { continue; } $reflection = new ReflectionClass($this->BO->getPropObject($propName)); $propClass = $reflection->getShortName(); // exclude non-Relation transient attributes from create and edit screens if ($propClass != 'Relation' && ($mode == 'edit' || $mode == 'create') && in_array($propName, $this->BO->getTransientAttributes())) { continue; } switch (mb_strtoupper($propClass)) { case 'INTEGER': if ($mode == 'view') { $html .= $this->renderDefaultField($propName, $this->BO->getDataLabel($propName), 'view', $this->BO->get($propName)); } else { $html .= $this->renderIntegerField($propName, $this->BO->getDataLabel($propName), $mode, $this->BO->get($propName)); } break; case 'DOUBLE': if ($mode == 'view') { $html .= $this->renderDefaultField($propName, $this->BO->getDataLabel($propName), 'view', $this->BO->get($propName)); } else { $html .= $this->renderDoubleField($propName, $this->BO->getDataLabel($propName), $mode, $this->BO->get($propName)); } break; case 'DATE': if ($mode == 'view') { $value = $this->BO->get($propName); if ($value == '0000-00-00') { $value = ''; } $html .= $this->renderDefaultField($propName, $this->BO->getDataLabel($propName), 'view', $value); } else { $date = new DateBox($this->BO->getPropObject($propName), $this->BO->getDataLabel($propName), $propName); $html .= $date->render(); } break; case 'TIMESTAMP': if ($mode == 'view') { $value = $this->BO->get($propName); if ($value == '0000-00-00 00:00:00') { $value = ''; } $html .= $this->renderDefaultField($propName, $this->BO->getDataLabel($propName), 'view', $value); } else { $timestamp = new DateBox($this->BO->getPropObject($propName), $this->BO->getDataLabel($propName), $propName); $html .= $timestamp->render(); } break; case 'STRING': $html .= $this->renderStringField($propName, $this->BO->getDataLabel($propName), $mode, $this->BO->get($propName)); break; case 'TEXT': $html .= $this->renderTextField($propName, $this->BO->getDataLabel($propName), $mode, $this->BO->get($propName)); break; case 'BOOLEAN': if ($mode == 'view') { $html .= $this->renderDefaultField($propName, $this->BO->getDataLabel($propName), 'view', $this->BO->get($propName)); } else { $html .= $this->renderBooleanField($propName, $this->BO->getDataLabel($propName), $mode, $this->BO->get($propName)); } break; case 'ENUM': if ($mode == 'view') { $html .= $this->renderDefaultField($propName, $this->BO->getDataLabel($propName), 'view', $this->BO->get($propName)); } else { $enum = $this->BO->getPropObject($propName); $html .= $this->renderEnumField($propName, $this->BO->getDataLabel($propName), $mode, $enum->getOptions(), $this->BO->get($propName)); } break; case 'DENUM': if ($mode == 'view') { $html .= $this->renderDefaultField($propName, $this->BO->getDataLabel($propName), 'view', $this->BO->getPropObject($propName)->getDisplayValue()); } else { $denum = $this->BO->getPropObject($propName); $html .= $this->renderDEnumField($propName, $this->BO->getDataLabel($propName), $mode, $denum->getOptions(), $this->BO->get($propName)); } break; case 'RELATION': $html .= $this->renderRelationField($propName, $this->BO->getDataLabel($propName), $mode, $this->BO->get($propName)); break; default: $html .= $this->renderDefaultField($propName, $this->BO->getDataLabel($propName), $mode, $this->BO->get($propName)); break; } } } self::$logger->debug('<<renderAllFields [' . $html . ']'); return $html; }
/** * Setter for the record for this controller. * * @param Alpha\Model\ActiveRecord $record * * @since 1.0 */ public function setRecord($record) { self::$logger->debug('>>setRecord(record=[' . var_export($record, true) . '])'); $this->record = $record; // if the record has tags, use these as the meta keywords for this controller if ($this->record->isTagged()) { $tags = $this->record->getPropObject('tags')->getRelatedObjects(); $keywords = ''; if (count($tags) > 0) { foreach ($tags as $tag) { $keywords .= ',' . $tag->get('content'); } } $this->setKeywords(mb_substr($keywords, 1)); } self::$logger->debug('<<setRecord'); }