/** * Constructor. * * @param string $name Name of the attribute * @param int $flags Flags for this attribute * @param string $template Display/sort template. * @param array $searchFields Array with fields, in which search will be perform. If ommited, fields from $template will be used */ public function __construct($name, $flags = 0, $template, $searchFields = []) { $flags = $flags | self::AF_HIDE_EDIT | self::AF_HIDE_ADD | self::AF_HIDE_VIEW; parent::__construct($name, $flags); // base class constructor $this->m_template = $template; $parser = new StringParser($template); $this->m_displayfields = $parser->getFields(); if (!count($searchFields)) { $this->m_searchfields = $this->m_displayfields; } else { $this->m_searchfields = $searchFields; } }
/** * Retrieve the list of attributes that are used in the descriptor * definition. * * @return array The names of the attributes forming the descriptor. */ public function descriptorFields() { $fields = []; // See if node has a custom descriptor definition. if ($this->m_descTemplate != null || method_exists($this, 'descriptor_def')) { if ($this->m_descTemplate != null) { $descriptordef = $this->m_descTemplate; } else { $descriptordef = $this->descriptor_def(); } // parse fields from descriptordef $parser = new StringParser($descriptordef); $fields = $parser->getFields(); // There might be fields that have a '.' in them. These fields are // a concatenation of an attributename (probably a relation), and a subfield // (a field of the destination node). // The actual field is the one in front of the '.'. for ($i = 0, $_i = count($fields); $i < $_i; ++$i) { $elems = explode('.', $fields[$i]); if (count($elems) > 1) { // dot found. attribute is the first item. $fields[$i] = $elems[0]; } } } else { // default descriptor.. (default is first attribute of a node) $keys = array_keys($this->m_attribList); $fields[0] = $keys[0]; } return $fields; }