/** * Constructor. * * @param string $name Name of the attribute (unique within a node, and * corresponds to the name of the datetime field * in the database where the stamp is stored. * @param int $flags Flags for the attribute * @param array $extra Array of extra options. these options will be numbered from 2^7 (128) to 2^x. */ public function __construct($name, $flags = 0, $extra = []) { $flags = ($flags | self::AF_HIDE_SEARCH) ^ self::AF_SEARCHABLE; $this->m_extra = $extra; parent::__construct($name, $flags); }
public function getSearchCondition(Query $query, $table, $value, $searchmode, $fieldname = '') { // If we are accidentally mistaken for a relation and passed an array // we only take our own attribute value from the array if ($this->m_searchmode) { $searchmode = $this->m_searchmode; } $expression = '(' . str_replace('[table]', $table, $this->m_expression) . ')'; if ($this->getSearchType() == 'date') { $attr = new DateAttribute($this->fieldName()); return $attr->getSearchCondition($query, $table, $value, $searchmode, $expression); } if ($this->getSearchType() == 'number') { $attr = new NumberAttribute($this->fieldName()); $value = $attr->processSearchValue($value, $searchmode); if ($searchmode == 'between') { return $attr->getBetweenCondition($query, $expression, $value); } if (isset($value['from']) && $value['from'] != '') { $value = $value['from']; } else { if (isset($value['to']) && $value['to'] != '') { $value = $value['to']; } else { return ''; } } } $func = $searchmode . 'Condition'; if (method_exists($query, $func) && $value !== '' && $value !== null) { return $query->{$func}($expression, $this->escapeSQL($value)); } return ''; }
/** * overrides the display function to put the currencysymbol in front of the input field. * * The regular Attribute uses PHP's nl2br() and htmlspecialchars() * methods to prepare a value for display, unless $mode is "cvs". * * @param array $record The record that holds the value for this attribute * @param string $mode The display mode ("view" for viewpages, or "list" * for displaying in recordlists, "edit" for * displaying in editscreens, "add" for displaying in * add screens. "csv" for csv files. Applications can * use additional modes. * * @return string HTML String */ public function display($record, $mode) { $result = empty($this->m_currencysymbol) ? '' : $this->getCurrencySymbolDisplay() . ' '; $result .= parent::display($record, $mode); return $result; }