/** * {@inheritdoc} */ public function renderAllFields($mode, $filterFields = array(), $readOnlyFields = array()) { self::$logger->debug('>>renderAllFields(fields=[' . var_export($fields, true) . '])'); $json = json_encode(array_diff($this->BO->toArray(), $filterFields)); self::$logger->debug('<<renderAllFields [JSON]'); return $json; }
/** * A static method that attempts to return a SearchProviderInterface instance * based on the name of the provider class supplied. * * @param $providerName The class name of the provider class, should be fully-qualified. * * @throws Alpha\Exception\IllegalArguementException; * * @return Alpha\Util\Search\SearchProviderInterface * * @since 1.2.3 */ public static function getInstance($providerName) { if (self::$logger == null) { self::$logger = new Logger('SearchProviderFactory'); } self::$logger->debug('>>getInstance(providerName=[' . $providerName . '])'); global $config; if (class_exists($providerName)) { $instance = new $providerName(); if (!$instance instanceof SearchProviderInterface) { throw new IllegalArguementException('The class [' . $providerName . '] does not implement the expected SearchProviderInterface interface!'); } self::$logger->debug('<<getInstance: [Object ' . $providerName . ']'); return $instance; } else { throw new IllegalArguementException('The class [' . $providerName . '] is not defined anywhere!'); } self::$logger->debug('<<getInstance'); }
/** * {@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; }