Add extra column meta to existing

Examples

$store1->columnMeta(array(
"age"=>array(
"name"=>"Age"
)
));

@param DataStore $settings The additional settings for column

@return DataStore New datastore containing results.
350400
public function columnMeta($settings)
    {
        foreach ($settings as $cName=>$cMeta) {
            if (isset($this->metaData["columns"]) && $this->metaData["columns"][$cName]) {
                $this->metaData["columns"][$cName] = array_merge(
                    $this->metaData["columns"][$cName],
                    $cMeta
                );
            }
        }
        return $this;
    }
913354
private function initializeDatabase(array $settings)
    {
        if (!isset($settings['dsn']) || !$settings['dsn']) {
            $settings['charset'] = isset($settings['charset']) ? $settings['charset'] : 'utf8';
            $settings['dsn'] = sprintf(
                '%s:host=%s;dbname=%s;charset=%s',
                $settings['driver'],
                $settings['host'],
                $settings['name'],
                $settings['charset']
            );
        }

        return $settings;
    }
773309
public function settings(array $settings = null)
    {
        if ($settings !== null) {
            $this->settings = $settings;
        }

        return $this->settings;
    }
576666
public function addSettings($section, array $settings = []): PageInterface
    {
        $currentSettings = $this->repository()->getSettings()->all();

        if (is_array($section)) {
            $settings = array_merge($currentSettings, $section);
        } else {
            $settings = array_merge($currentSettings, [$section => $settings]);
        }

        $this->repository()->setSettings($settings);

        // Set a default page view for handling
        // the settings. A user can still overwrite
        // the view.
        if ('page' === $this->ui()->getViewPath()) {
            $this->ui()->setView('options');
        }

        return $this;
    }
682841
public function addColumn($columns)
    {
        unset($columns['date']);

        foreach ($this->data as $id => $field) {
            if (isset($field->show_admin_column) && $field->show_admin_column) {
                $columns[$id] = $field->label;
            }
        }

        $columns['date'] = __('Date');

        return $columns;
    }
961732
protected function buildInsertSet(
        /*# string */ $prefix,
        array $settings
    )/*# : string */ {
        if (empty($this->set_data)) {
            return '';
        }

        $cols = [];
        foreach (array_keys($this->set_col) as $col) {
            $cols[] = $this->quote($col, $settings);
        }
        return $settings['seperator'] . '(' . join(', ', $cols) . ')';
    }
233296
protected function addModelSettings(array &$settings)
    {
        $settings['elementClass']  = 'Date';
        $settings['dateFormat']    = $this->getDateFormat();
        $settings['storageFormat'] = $this->getStorageFormat();
        $settings['type']          = $this->type;
    }
1251475
private function addMetadata(array $values)
    {
        foreach ($values as $domain => $keys) {
            foreach ($keys as $key => $value) {
                $this->setMetadata($key, $value, $domain);
            }
        }
    }
1340132
protected function combineSettings(array $settings)/*# : array */
    {
        return array_replace(
            $this->getBuilder()->getSettings(), // builder settings
            $this->getBuilder()->getDialect()->dialectSettings(), // dialect
            $settings,  // user settings
            $this->getSettings() // statement settings
        );
    }
816221
protected function buildCol(
        /*# string */ $prefix,
        array $settings
    )/*# : string */ {
        $clause = &$this->getClause('COL');
        if ($this instanceof SelectStatementInterface && empty($clause)) {
            $clauseParts = ['*'];
        } else {
            $clauseParts = [];
        }
        return $this->buildClause('COL', $prefix, $settings, $clauseParts);
    }
291914
public function addConfigSettings(array $settings) {
        $this->config = $this->arrayMergeRecursiveOverwrite(
            $this->config,
            $settings
        );

        return $this;
    }
30820
protected function addResource(ResourceSettings $settings)
    {
        $settings = $this->prepareResourceSettings($settings);

        if ($settings === null) {
            return false;
        }

        return $settings->url === null && $this->mergeResources && $settings->compile
            ? $this->addLocalResource($settings)
            : $this->addRemoteResource($settings);
    }
66668
public function setSettings(array $settings)
    {
        $this->settings = array_merge($this->settings, $settings);
        
        if (isset($settings['templates_path'])) {
            $this->view->templatesPath = $this->settings['templates_path'];
        }
        
        return $this;
    }
1326238
private function createContainer($settings)
    {
        if (is_string($settings)) {
            return $this->createContainerFromString($settings);
        }

        if (is_array($settings)) {
            return $this->createContainerFromArray($settings);
        }

        throw new WrongServicesConfigurationException(
            sprintf('`services` must be either string or an array, but `%s` given.', gettype($settings))
        );
    }
27533
public function dbRemoval(array $Settings)
    {
        $ID = isset($Settings["Name"]) ? $Settings["Name"] : null;
        $Expiry = isset($Settings["Expiry"]) ? $Settings["Expiry"] : -(24 * 60 * 60);
        $TS = time() - $Expiry;

        /* Compute the paths */
        $Database = $this->CacheFolder . "/" . $this->CacheDB;
        $Index = $this->CacheFolder . "/" . $this->CacheIndex;
        $DatabaseTemp = $this->CacheFolder . "/" . $this->CacheDB . ".tmp";
        $IndexTemp = $this->CacheFolder . "/" . $this->CacheIndex . ".tmp";

        /* Single file removal */
        if ($ID != null) {
            /* Retrieve object informations */
            $Object = $this->isInCache($ID, true);

            /* If it's not in the cache DB, go away */
            if (!$Object) {
                return(0);
            }
        }

        /* Create the temporary files */
        if (!file_exists($DatabaseTemp)) {
            touch($DatabaseTemp);
        }
        if (!file_exists($IndexTemp)) {
            touch($IndexTemp);
        }

        /* Open the file handles */
        $IndexHandle = @fopen($Index, "r");
        $IndexTempHandle = @fopen($IndexTemp, "w");
        $DBHandle = @fopen($Database, "r");
        $DBTempHandle = @fopen($DatabaseTemp, "w");

        /* Remove the selected ID from the database */
        while (!feof($IndexHandle)) {
            $Entry = fgets($IndexHandle, 4096);
            $Entry = str_replace("\r", "", $Entry);
            $Entry = str_replace("\n", "", $Entry);
            $Settings = preg_split("/,/", $Entry);

            if ($Entry != "") {
                $PicID = $Settings[0];
                $DBPos = $Settings[1];
                $PicSize = $Settings[2];
                $GeneratedTS = $Settings[3];
                $Hits = $Settings[4];

                if ($Settings[0] != $ID && $GeneratedTS > $TS) {
                    $CurrentPos = ftell($DBTempHandle);
                    fwrite(
                        $IndexTempHandle,
                        sprintf(
                            "%s,%s,%s,%s,%s\r\n",
                            $PicID,
                            $CurrentPos,
                            $PicSize,
                            $GeneratedTS,
                            $Hits
                        )
                    );

                    fseek($DBHandle, $DBPos);
                    $Picture = fread($DBHandle, $PicSize);
                    fwrite($DBTempHandle, $Picture);
                }
            }
        }

        /* Close the handles */
        fclose($IndexHandle);
        fclose($IndexTempHandle);
        fclose($DBHandle);
        fclose($DBTempHandle);

        /* Remove the prod files */
        unlink($Database);
        unlink($Index);

        /* Swap the temp & prod DB */
        rename($DatabaseTemp, $Database);
        rename($IndexTemp, $Index);
    }
534971
public function setup(Model $model, $settings = array()) {
        if (!$settings) {
            return;
        }

        if (!isset($this->_columns[$model->alias])) {
            $this->_columns[$model->alias] = array();
        }

        foreach ($settings as $field => $attachment) {
            $attachment = Set::merge($this->_defaultSettings, $attachment + array(
                'dbColumn' => $field
            ));

            // Fix dbColumn if they set it to empty
            if (!$attachment['dbColumn']) {
                $attachment['dbColumn'] = $field;
            }

            $columns = array($attachment['dbColumn'] => $field);

            // Set defaults if not defined
            if (!$attachment['tempDir']) {
                $attachment['tempDir'] = TMP;
            }

            if (!$attachment['uploadDir']) {
                $attachment['finalPath'] = $attachment['finalPath'] ?: '/files/uploads/';
                $attachment['uploadDir'] = WWW_ROOT . $attachment['finalPath'];
            }

            // Merge transform settings with defaults
            if ($attachment['transforms']) {
                foreach ($attachment['transforms'] as $dbColumn => $transform) {
                    $transform = Set::merge($this->_transformSettings, $transform + array(
                        'uploadDir' => $attachment['uploadDir'],
                        'finalPath' => $attachment['finalPath'],
                        'dbColumn' => $dbColumn
                    ));

                    if ($transform['self']) {
                        $transform['dbColumn'] = $attachment['dbColumn'];
                    }

                    $columns[$transform['dbColumn']] = $field;
                    $attachment['transforms'][$dbColumn] = $transform;
                }
            }

            $this->settings[$model->alias][$field] = $attachment;
            $this->_columns[$model->alias] += $columns;
        }
    }
1107238
protected function addModelSettings(array &$settings)
    {
        $empty = $this->util->getTranslated()->getEmptyDropdownArray();

        $settings['elementClass'] = 'Select';
        $settings['multiOptions'] = $empty + $this->getLookup();
    }