function excerpt($string, $len = 50, $truncateStr = '...', $wholeWords = true) { return LsString::excerpt($string, $len, $truncateStr, $wholeWords); }
static function convertValueForDisplay($value, $field, $excerpt = 40) { if (is_null($value)) { return 'NULL'; } if (!($mod = self::loadModification($field))) { return $value; } $table = Doctrine::getTable($mod['object_model']); $columns = $table->getColumns(); if ($mod['object_model'] == 'Entity') { if (!array_key_exists($field['field_name'], $columns)) { if ($extensionName = EntityTable::getExtensionNameByFieldName($field['field_name'])) { $table = Doctrine::getTable($extensionName); } } } elseif ($mod['object_model'] == 'Relationship') { if (!array_key_exists($field['field_name'], $columns)) { $table = Doctrine::getTable(RelationshipTable::getCategoryNameByFieldName($field['field_name'])); } } if ($alias = self::getFieldNameAlias($field)) { $class = $table->getRelation($alias)->getClass(); if ($record = Doctrine::getTable($class)->find($value, Doctrine::HYDRATE_ARRAY)) { if ($class == 'Entity') { sfLoader::loadHelpers('Ls'); return entity_link($record, null); } elseif ($class == 'sfGuardUser') { sfLoader::loadHelpers('Ls'); return user_link($record); } return $record; } } if (in_array($field['field_name'], array('start_date', 'end_date'))) { return Dateable::convertForDisplay($value); } $def = $table->getColumnDefinition($field['field_name']); switch ($def['type']) { case 'integer': return (double) $value; break; case 'boolean': return $value ? 'yes' : 'no'; break; } if ($excerpt) { $short = LsString::excerpt($value, $excerpt); return $short == $value ? $value : '<span title="' . strip_tags($value) . '">' . $short . '</span>'; } return $value; }
public function convertValueForDisplay($value) { if (is_null($value)) { return '<span class="text_small">NULL</span>'; } if (!($record = $this->Modification->getObject(true))) { return $value; } $table = $record->getTable(); if ($record instanceof Entity) { $data = $record->getData(); if (!array_key_exists($this->field_name, $data)) { if ($extensionName = EntityTable::getExtensionNameByFieldName($this->field_name)) { $table = Doctrine::getTable($extensionName); } } } elseif ($record instanceof Relationship) { $data = $record->getData(); if (!array_key_exists($this->field_name, $data)) { $table = Doctrine::getTable(RelationshipTable::getCategoryNameByFieldName($this->field_name)); } } if ($alias = $this->getFieldNameAlias()) { $class = $table->getRelation($alias)->getClass(); if ($record = Doctrine::getTable($class)->find($value)) { if ($record instanceof Entity) { sfLoader::loadHelpers('Ls'); return entity_link($record, null); } return $record; } } if (in_array($this->field_name, array('start_date', 'end_date'))) { return Dateable::convertForDisplay($value); } $def = $table->getColumnDefinition($this->field_name); switch ($def['type']) { case 'integer': return (string) $value; break; case 'boolean': return $value ? 'yes' : 'no'; break; } return LsString::excerpt($value); }