Add fields to a table row
@param array $source
@param array $spec
@param array $dest
@access protected
@return void
2843
protected function addFields($source,$spec,&$dest)
    {
        if (isset($spec['fields']))
        {
            foreach ($spec['fields'] as $f)
            {
                if(isset($f['temporary']) && $f['temporary'] === true)
                {
                    if(!in_array($f['fieldName'], $this->temporaryFields))
                    {
                        $this->temporaryFields[] = $f['fieldName'];
                    }
                }
                if(isset($f['predicates']))
                {
                    foreach ($f['predicates'] as $p)
                    {
                        if (is_string($p) && isset($source[$p]))
                        {
                            // Predicate is referenced directly
                            $this->generateValues($source, $f, $p, $dest);
                        } else
                        {
                            // Get a list of functions to run over a predicate - reverse it
                            $predicateFunctions = $this->getPredicateFunctions($p);
                            $predicateFunctions = array_reverse($predicateFunctions);

                            foreach($predicateFunctions as $function => $functionOptions)
                            {
                                // If we've got values then we're the innermost function, so we need to get the values
                                if($function == 'predicates')
                                {
                                    foreach($functionOptions as $v)
                                    {
                                        $v = trim($v);
                                        if (isset($source[$v]))
                                        {
                                            $this->generateValues($source, $f, $v, $dest);
                                        }
                                    }
                                // Otherwise apply a modifier
                                }
                                else
                                {
                                    if(isset($dest[$f['fieldName']]))
                                    {
                                        $dest[$f['fieldName']] = $this->applyModifier($function, $dest[$f['fieldName']], $functionOptions);
                                    }
                                }
                            }
                        }
                    }
                }

                // Allow URI linking to the ID
                if(isset($f['value']))
                {
                    if($f['value'] == '_link_' || $f['value'] == 'link' )
                    {
                        if($f['value'] == '_link_')
                        {
                            $this->warningLog("Table spec value '_link_' is deprecated", $f);
                        }
                        // If value exists, set as array
                        if(isset($dest[$f['fieldName']]))
                        {
                            if(!is_array($dest[$f['fieldName']]))
                            {
                                $dest[$f['fieldName']] = array($dest[$f['fieldName']]);
                            }
                            $dest[$f['fieldName']][] = $this->labeller->qname_to_alias($source['_id']['r']);
                        } else {
                            $dest[$f['fieldName']] = $this->labeller->qname_to_alias($source['_id']['r']);
                        }
                    }
                }
            }
        }
    }
1310962
public function addSelectFromTable($table, $fields)
    {
        $fieldExpressions = array_map(function ($item) use ($table) {
            return Convert::symbol2sql("{$table}.{$item}");
        }, $fields);

        $this->query->addSelect($fieldExpressions);

        return $this;
    }
562416
public function addUnit(SpecificationUnit $specUnit, $or_union_name = null)
    {
        if($or_union_name === null)
        {
            $this->free[] = $specUnit;
        }
        else
        {
            $this->check_or_union($or_union_name);

            $this->or_union[$or_union_name][] =  $specUnit;
        }

        $this->fields_paths[] = $specUnit->getFieldName();
    }
217846
protected function createSingle(array $source)
    {
        $data = [];
        /** @var FieldDescriptor $field */
        foreach ($this->getDescriptor()->getFields() as $field) {
            if (array_key_exists($field->getField(), $source)) {
                $data[$field->getName()] = $source[$field->getField()];
            }
        }
        $class = $this->getDescriptor()->className();
        return new $class($data);
    }
988894
public function addOption($spec, string $desc = null, string $key = null): Option
    {
        $option = $this->getOptionCollection();

        return $option->add($spec, $desc, $key);
    }
619763
public function addFields($term, $mode = 'edit')
    {
        // Check mode
        $mode = in_array($mode, ['add', 'edit']) ? $mode : 'edit';

        // Check fields
        if (empty($this->fields)) {
            return;
        }

        // Get current
        $term = is_object($term) ? $term : get_term($term);

        // Get fields
        foreach ($this->fields as $field) {
            if (!$field) {
                continue;
            }

            // Build contents
            $ctn = (array) $field->getModel()->getContents();
            $hasId = (boolean) $field->getModel()->getHasId();

            // Check fields
            if (empty($ctn)) {
                continue;
            }

            // Does the field have an ID
            if ($hasId && (!isset($ctn['id']) || empty($ctn['id']))) {
                continue;
            }

            // Display field
            $field->render($ctn, [
                'structure' => '%TERM%-%SLUG%',
                'template'  => 'term-'.$mode,
                'term'      => $term,
            ]);
        }
    }
770195
function add( $specString, $description , $key = null ) 
    {
        $spec = $this->specs->add($specString,$description,$key);
        return $spec;
    }
365802
public function addColumn($formatters, $name = null, $descr = null)
    {
        if ($name === null) {
            $name = $formatters;
            $formatters = 'text';
        }
        if ($formatters === null) {
            $formatters = 'text';
        }

        if ($descr === null) {
            $descr = ucwords(str_replace('_', ' ', $name));
        }
        if (is_array($descr)) {
            $descr['descr'] = $this->app->_($descr['descr']);
        } else {
            $descr = $this->app->_($descr);
        }

        $this->columns[$name] = array('type' => $formatters);

        if (is_array($descr)) {
            $this->columns[$name] = array_merge($this->columns[$name], $descr);
        } else {
            $this->columns[$name]['descr'] = $descr;
        }

        if ($this->columns[$name]['icon']) {
            if ($this->columns[$name]['icon'][0] != '<') {
                $this->columns[$name]['icon'] = '<i class="icon-'.
                    $this->columns[$name]['icon'].'"></i>&nbsp;';
            } else {
                throw $this->exception('obsolete way of using icon. Do not specify HTML code, but juts the icon');
            }
        }

        $this->last_column = $name;

        if (!is_string($formatters) && is_callable($formatters)) {
            $this->columns[$name]['fx'] = $formatters;

            return $this;
        }

        // TODO call addFormatter instead!
        $subtypes = explode(',', $formatters);
        foreach ($subtypes as $subtype) {
            if (strpos($subtype, '\\') || strpos($subtype, '/')) {

                // add-on functionality:
                // http://agiletoolkit.org/codepad/gui/grid#codepad_gui_grid_view_example_7_ex
                if (!$this->elements[$subtype.'_'.$name]) {
                    $addon = $this->app->normalizeClassName($subtype, 'Controller_Grid_Format');
                    $this->elements[$subtype.'_'.$name] = $this->add($addon);
                }

                $addon = $this->getElement($subtype.'_'.$name);
                if (!$addon instanceof Controller_Grid_Format) {
                    throw $this->exception('Grid formatter class should extend Controller_Grid_Format class')
                        ->addMoreInfo('formater', $subtype);
                }
                $addon->initField($name, $descr);

                return $addon;
            } elseif (!$this->hasMethod($m = 'init_'.$subtype)) {
                if (!$this->hasMethod($m = 'format_'.$subtype)) {
                    // exception if formatter doesn't exist
                    throw $this->exception('No such formatter')
                        ->addMoreInfo('formater', $subtype);
                }
            } else {
                // execute formatter init_*
                $this->$m($name, $descr);
            }
        }

        return $this;
    }
241296
public function setSource($source): void
    {
        if (!\is_array($source) && !($source instanceof \ArrayAccess)) {
            throw new Grid\GridException('Source of `ArraySource` should be array or implement ArrayAccess interface');
        }
        parent::setSource($source);
    }
1007894
public function setOrder($field, $desc = null)
    {
        if (!$field instanceof Field) {
            if (is_object($field)) {
                $this->_dsql()->order($field, $desc);

                return $this;
            }

            if (is_string($field) && strpos($field, ',') !== false) {
                $field = explode(',', $field);
            }
            if (is_array($field)) {
                if (!is_null($desc)) {
                    throw $this->exception('If first argument is array, second argument must not be used');
                }

                foreach (array_reverse($field) as $o) {
                    $this->setOrder($o);
                }

                return $this;
            }

            if (is_null($desc) && is_string($field) && strpos($field, ' ') !== false) {
                list($field, $desc) = array_map('trim', explode(' ', trim($field), 2));
            }

            /** @type Field $field */
            $field = $this->getElement($field);
        }

        $this->_dsql()->order($field, $desc);

        return $this;
    }
738381
protected function flattenArray(array $source, array &$dest)
    {
        foreach ($source as $elm) {
            if (is_array($elm)) {
                $this->flattenArray($elm, $dest);
            } else {
                $dest[] = $elm;
            }
        }
    }
262948
private function findFieldsInTableSpec($fieldName, $spec)
    {
        $fields = [];
        if(is_array($spec) && !empty($spec))
        {
            if(array_key_exists($fieldName, $spec))
            {
                $fields = $spec[$fieldName];
            }

            if(isset($spec['joins']))
            {
                foreach($spec['joins'] as $join)
                {
                    $fields = array_merge($fields, $this->findFieldsInTableSpec($fieldName, $join));
                }
            }
        }
        return $fields;
    }
28998
public function add_field($field, $table, $alias = null) {
        $field = self::resolve_field($field, $table);
        if (!empty($alias)) {
            $field .= ' AS ' . $alias;
        }
        $this->fields[] = $field;
    }
1365573
function(dest_container, source_container, property_name, parent_widget_name) {

		var name,
			dest = dest_container[property_name],
			source = source_container[property_name],
			new_name;

		for (name in source) {

			if (!(name in dest)) {

				dest[name] = source[name];

			} else {

				new_name = parent_widget_name + '$' + name;
				if (Lava.schema.DEBUG && (new_name in dest)) Lava.t();
				dest[new_name] = source[name];

			}

		}

	}
1194250
private function ifCountExistsWithoutTTLThrowException($spec)
    {
        if (array_key_exists("ttl",$spec))
        {
            return; // ttl exists
        }
        else
        {
            if (array_key_exists("joins",$spec))
            {
                // recurse
                foreach($spec['joins'] as $join)
                {
                    $this->ifCountExistsWithoutTTLThrowException($join);
                }
            }
            if (array_key_exists("counts",$spec))
            {
                throw new \Tripod\Exceptions\ConfigException("Aggregate function counts exists in spec, but no TTL defined");
            }
            else
            {
                return;
            }
        }
    }
1023900
public function BuildClassBody($tableColumnsMetadata) {
        $this->AddConstants($tableColumnsMetadata);
        $this->AddFields($tableColumnsMetadata);
        $this->AddSetters($tableColumnsMetadata);
        $this->AddGetters($tableColumnsMetadata);
    }
996835
public static function copyRecDir($source, $dest) {
    if (!is_dir($dest)) {
      self::mkdirRec($dest);
    }
    $dir = opendir($source);
    while ($file = readdir($dir)) {
      if ($file == "." || $file == "..") {
        continue;
      }
      self::copyRec("$source/$file", "$dest/$file");
    }
    closedir($dir);
  }