@param array $defaults
@param array $details

@return string
505872
private function generateButton($defaults, $details = []): string
    {
        $button = '<button name="%name%" title="%title%" type="%type%" class="%class%" style="%style%" %attr%>%prompt%<span%icon%></span></button>';

        if (isset($details['class'])) {
            $defaults['class'] = $details['class'];
            unset($details['class']);
        }

        if (isset($details['mergeClass']) && isset($defaults['class']))
                $defaults['class'] .= ' ' . $details['mergeClass'];

        if (isset($details['icon'])) {
            if (is_array($details['icon'])) {
                $icon = '';
                foreach($details['icon'] as $name=>$value)
                    $icon .= $name . '="' . $value . '" ';
                $defaults['icon'] = ' ' . trim($icon);
            }
            unset($details['icon']);
        } else {
            $icon = '';
            if (preg_match('#^far | far | far$#', $defaults['class'], $matches) > 0) {
                $icon .= 'far ';
                $defaults['class'] = str_replace($matches, '', $defaults['class']);
            }

            if (preg_match('#^fas | fas | fas$#', $defaults['class'], $matches) > 0) {
                $icon .= 'fas ';
                $defaults['class'] = str_replace($matches, '', $defaults['class']);
            }

            if (preg_match('#^fal | fal | fal$#', $defaults['class'], $matches) > 0) {
                $icon .= 'fal ';
                $defaults['class'] = str_replace($matches, '', $defaults['class']);
            }

            if (preg_match('#^fab | fab | fab$#', $defaults['class'], $matches) > 0) {
                $icon .= 'fab ';
                $defaults['class'] = str_replace($matches, '', $defaults['class']);
            }

            if (preg_match_all('#fa-([\S][\w-]*)#', $defaults['class'], $matches) > 0) {
                foreach($matches[0] as $match)
                    $icon .= $match . ' ';
                $defaults['class'] = str_replace($matches[0], '', $defaults['class']);
            }

            $defaults['icon'] = ' class="' . trim($icon) . '"';
        }

        $defaults['class'] = trim(str_replace('  ', ' ', $defaults['class']));

        if (! empty($details['additional']))
            $details['attr'] = $details['additional'];

        if (isset($details['attr']) && is_array($details['attr']))
        {
            $attr            = $details['attr'];
            $details['attr'] = '';
            foreach ($attr as $name => $value)
                $details['attr'] .= $name . '="' . $value . '" ';
            $details['attr'] = trim($details['attr']);
        }

        if (isset($details['disabled']) && $details['disabled'])
            $details['attr'] =  isset($details['attr']) ? $details['attr'] . ' disabled' : 'disabled';

        if (!empty($details['windowOpen']))
        {
            if (isset($details['windowOpen']['route_params']))
            {
                $details['windowOpen']['route'] = $this->router->generate($details['windowOpen']['route'], $details['windowOpen']['route_params']) ;
            }
            $target                = empty($details['windowOpen']['target']) ? '_self' : $details['windowOpen']['target'] ;
            $route                 = 'onClick="window.open(\'' . $details['windowOpen']['route'] . '\',\'' . $target . '\'';
            $route                 = empty($details['windowOpen']['params']) ? $route . ')"' : $route . ',\'' . $details['windowOpen']['params'] . '\')"';
            $details['attr'] = empty($details['attr']) ? $route : trim($details['attr'] . ' ' . $route);
        }

        if (!empty($details['javascript']))
        {
            $target = '';
            if (!empty($details['javascript']['options']))
            {
                foreach ($details['javascript']['options'] as $option)
                    $target .= '\'' . $option . '\',';
            }
            $target = trim($target, ',');

            $route                 = 'onClick="' . $details['javascript']['function'] . '(' . $target . ');"';
            $details['attr'] = empty($details['attr']) ? $route : trim($details['attr'] . ' ' . $route);
        }

        if (!empty($details['disabled']) && $details['disabled'])
            $details['attr'] = empty($details['attr']) ? 'disabled' : trim($details['attr'] . ' disabled');

        if (!isset($defaults['name']))
            $defaults['name'] = '';

        foreach ($defaults as $q => $w)
        {
            if ($q == 'attr')
                $details['attr'] = empty($details['attr']) ? $w : trim($details['attr'] . ' ' . $w);
            if (isset($details[$q]))
                $defaults[$q] = $details[$q];
            if ($q == 'name')
                $details['attr'] = empty($details['attr']) ? '' : trim($details['attr'] . ' ' . $w);
            if (empty($defaults[$q]))
            {
                unset($defaults[$q]);
                $button = str_replace(array($q . '="%' . $q . '%"', '%' . $q . '%'), '', $button);
            }
            else
            {
                if (in_array($q, ['title', 'prompt']))
                    if (is_array($defaults[$q]))
                        $defaults[$q] = $this->trans($defaults[$q]['message'], $defaults[$q]['params'], empty($details['transDomain']) ? $this->getTransDomain() : $details['transDomain']);
                    else
                        $defaults[$q] = $this->trans($defaults[$q], [], empty($details['transDomain']) ? $this->getTransDomain() : $details['transDomain']);
                $button = str_replace('%' . $q . '%', $defaults[$q], $button);
            }
        }

        if (isset($details['collectionName']))
            $button = str_replace('collection', $details['collectionName'], $button);

        if (isset($details['colour']))
            $button = str_replace(['btn-default', 'btn-success', 'btn-info', 'btn-warning', 'btn-danger', 'btn-primary', 'btn-link', 'btn-light', 'btn-dark'], 'btn-' . $details['colour'], $button);

        return $button;
    }
197430
protected function getFieldNameForDisplay($details)
    {
        $tableUniqueId = $details['TABLE_SCHEMA'] . '.' . $details['TABLE_NAME'];
        if ($details['COLUMN_COMMENT'] != '') {
            return $details['COLUMN_COMMENT'];
        } elseif (isset($this->advCache['tableStructureLocales'][$tableUniqueId][$details['COLUMN_NAME']])) {
            return $this->advCache['tableStructureLocales'][$tableUniqueId][$details['COLUMN_NAME']];
        }
        return $details['COLUMN_NAME'];
    }
949326
protected function collectValues(array $values, array $defaults = [])
    {
        foreach ($values as $value) {
            $defaults = $this->collectValue($value, $defaults);
        }

        return $defaults;
    }
1362074
public static function set( $configs, $defaults = null ) {
		$defaults = $defaults ? $defaults : self::get();

		/**
		 * Allow the default configs to be filtered.
		 *
		 * @since 2.8.0
		 *
		 * @param array $defaults
		 */
		$defaults = apply_filters( 'Boldgrid\Library\Configs\set', $defaults );

		// Check if local library file is added.
		$localPath = dirname( __DIR__ ) . '/library.local.php';
		if ( file_exists( $localPath ) && is_readable( $localPath ) ) {
			$local = include_once $localPath;
			$defaults = wp_parse_args( $local, $defaults );
		}

		// Check if constant is added.
		if ( defined( 'BGLIB_CONFIGS' ) ) {
			$localPath = ABSPATH . BGLIB_CONFIGS;
			if ( file_exists( $localPath ) && is_readable( $localPath ) ) {
				$local = include_once $localPath;
				$defaults = wp_parse_args( $local, $defaults );
			}
		}

		return self::$configs = wp_parse_args( $configs, $defaults );
	}
1345231
public static function get_site_info($defaults = []) {
        global $CFG, $DB;
        require_once($CFG->libdir . '/badgeslib.php');
        require_once($CFG->dirroot . "/course/lib.php");

        $siteinfo = array();
        $cleanhuburl = clean_param(HUB_MOODLEORGHUBURL, PARAM_ALPHANUMEXT);
        foreach (self::FORM_FIELDS as $field) {
            $siteinfo[$field] = get_config('hub', 'site_'.$field.'_' . $cleanhuburl);
            if ($siteinfo[$field] === false) {
                $siteinfo[$field] = array_key_exists($field, $defaults) ? $defaults[$field] : null;
            }
        }

        // Statistical data.
        $siteinfo['courses'] = $DB->count_records('course') - 1;
        $siteinfo['users'] = $DB->count_records('user', array('deleted' => 0));
        $siteinfo['enrolments'] = $DB->count_records('role_assignments');
        $siteinfo['posts'] = $DB->count_records('forum_posts');
        $siteinfo['questions'] = $DB->count_records('question');
        $siteinfo['resources'] = $DB->count_records('resource');
        $siteinfo['badges'] = $DB->count_records_select('badge', 'status <> ' . BADGE_STATUS_ARCHIVED);
        $siteinfo['issuedbadges'] = $DB->count_records('badge_issued');
        $siteinfo['participantnumberaverage'] = average_number_of_participants();
        $siteinfo['modulenumberaverage'] = average_number_of_courses_modules();

        // Version and url.
        $siteinfo['moodlerelease'] = $CFG->release;
        $siteinfo['url'] = $CFG->wwwroot;

        // Mobile related information.
        $siteinfo['mobileservicesenabled'] = 0;
        $siteinfo['mobilenotificationsenabled'] = 0;
        $siteinfo['registereduserdevices'] = 0;
        $siteinfo['registeredactiveuserdevices'] = 0;
        if (!empty($CFG->enablewebservices) && !empty($CFG->enablemobilewebservice)) {
            $siteinfo['mobileservicesenabled'] = 1;
            $siteinfo['registereduserdevices'] = $DB->count_records('user_devices');
            $airnotifierextpath = $CFG->dirroot . '/message/output/airnotifier/externallib.php';
            if (file_exists($airnotifierextpath)) { // Maybe some one uninstalled the plugin.
                require_once($airnotifierextpath);
                $siteinfo['mobilenotificationsenabled'] = \message_airnotifier_external::is_system_configured();
                $siteinfo['registeredactiveuserdevices'] = $DB->count_records('message_airnotifier_devices', array('enable' => 1));
            }
        }

        // Analytics related data follow.
        $siteinfo['analyticsenabledmodels'] = \core_analytics\stats::enabled_models();
        $siteinfo['analyticspredictions'] = \core_analytics\stats::predictions();
        $siteinfo['analyticsactions'] = \core_analytics\stats::actions();
        $siteinfo['analyticsactionsnotuseful'] = \core_analytics\stats::actions_not_useful();

        // IMPORTANT: any new fields in siteinfo have to be added to the constant CONFIRM_NEW_FIELDS.

        return $siteinfo;
    }
1266677
public function render($contents = [], $details = [], $renderView = true, $context = 'field')
    {
        // Merge datum
        $contents = array_merge($this->getModel()->getContents(), $contents);
        $details = array_merge($this->getModel()->getDetails(), $details);

        // Get context
        $class = $this->getClass();
        $context = strtolower($class['name']);

        // Get template to extends
        $template = isset($details['template']) ? $details['template'] : '';
        $contents['template_path'] = $this->setExtendedTemplate($template);

        // Get vars and tpl data
        $this->getVars($contents, $details);
        $tpl = [
            'hasId' => $this->getModel()->getHasId(),
            'template' => $this->getModel()->getTemplate(),
            'vars' => $this->getModel()->getVars(),
            'context' => $context
        ];

        // Set error
        $error = sprintf(Translate::t('field.errors.no_template_found'), $tpl['context'], $tpl['template']);
        $tpl['vars']['error'] = isset($tpl['vars']['error']) ? $tpl['vars']['error'] : $error;

        // Render view or return values
        if ($renderView) {
            Render::view($tpl['template'], $tpl['vars'], $tpl['context']);
        } else {
            return $tpl;
        }
    }
729412
public function isSamePayPalUser($details)
    {
        $userData = array();
        $userData[] = \OxidEsales\Eshop\Core\Str::getStr()->html_entity_decode($this->oxuser__oxfname->value);
        $userData[] = \OxidEsales\Eshop\Core\Str::getStr()->html_entity_decode($this->oxuser__oxlname->value);

        $compareData = array();
        $compareData[] = $details->getFirstName();
        $compareData[] = $details->getLastName();

        return (($userData == $compareData) && $this->isSameAddressPayPalUser($details));
    }
1010088
public function showDetail($ids) {
		if (URequest::isAjax ()) {
			$instance = $this->getModelInstance ( $ids );
			$viewer = $this->_getModelViewer ();
			$hasElements = false;
			$model = $this->model;
			$fkInstances = CRUDHelper::getFKIntances ( $instance, $model );
			$semantic = $this->jquery->semantic ();
			$grid = $semantic->htmlGrid ( "detail" );
			if (sizeof ( $fkInstances ) > 0) {
				$wide = intval ( 16 / sizeof ( $fkInstances ) );
				if ($wide < 4)
					$wide = 4;
				foreach ( $fkInstances as $member => $fkInstanceArray ) {
					$element = $viewer->getFkMemberElementDetails ( $member, $fkInstanceArray ["objectFK"], $fkInstanceArray ["fkClass"], $fkInstanceArray ["fkTable"] );
					if (isset ( $element )) {
						$grid->addCol ( $wide )->setContent ( $element );
						$hasElements = true;
					}
				}
				if ($hasElements) {
					echo $grid;
					$url = $this->_getFiles ()->getDetailClickURL ( $this->model );
					if (UString::isNotNull ( $url )) {
						$this->detailClick ( $url );
					}
				}
				echo $this->jquery->compile ( $this->view );
			}
		} else {
			$this->jquery->execAtLast ( "$('tr[data-ajax={$ids}]').trigger('click');" );
			$this->index ();
		}
	}
316700
public function route($name, $details = [])
    {
        $this->route     = route($name, $details);
        $this->routeName = $name;

        return $this;
    }
1175363
public static function getConfig($task, array $defaults = array())
    {
        if (self::$config === null) {
            self::$config = file_exists(self::CONFIG_FILE) ? Yaml::parse(file_get_contents(self::CONFIG_FILE)) : [];
        }

        return isset(self::$config[$task]) ? self::$config[$task] : $defaults;
    }
1090436
protected function getRequestOptions(array $defaults = []) {

        $defaults = array_merge($this->getDefaultOptions(), $defaults);

        $page = $this->hasRequestParameter('page') ? $this->getRequestParameter('page') : $defaults['page'];
        $rows = $this->hasRequestParameter('rows') ? $this->getRequestParameter('rows') : $defaults['rows'];
        $sortBy = $this->hasRequestParameter('sortby') ? $this->getRequestParameter('sortby') : $defaults['sortby'];
        $sortOrder = $this->hasRequestParameter('sortorder') ? $this->getRequestParameter('sortorder') : $defaults['sortorder'];
        $filter = $this->hasRequestParameter('filter') ? $this->getRequestParameter('filter') : $defaults['filter'];
        $filterquery = $this->hasRequestParameter('filterquery') ? $this->getRequestParameter('filterquery') : $defaults['filter'];
        $periodStart = $this->hasRequestParameter('periodStart') ? $this->getRequestParameter('periodStart') : $defaults['periodStart'];
        $periodEnd = $this->hasRequestParameter('periodEnd') ? $this->getRequestParameter('periodEnd') : $defaults['periodEnd'];
        $detailed = $this->hasRequestParameter('detailed') ? $this->getRequestParameter('detailed') : 'false';
        $detailed = filter_var($detailed, FILTER_VALIDATE_BOOLEAN);

        return array(
            'page' => $page,
            'rows' => $rows,
            'sortBy' => $sortBy,
            'sortOrder' => $sortOrder,
            'filter' => $filter ? $filter : $filterquery,
            'periodStart' => $periodStart,
            'detailed' => $detailed,
            'periodEnd' => $periodEnd
        );

    }
1203631
protected function initDefaults($defaults)
    {
        if (!$defaults) {
            return;
        }

        $defaults = $this->fetchParameters($defaults);
        $this->initDefaultsInConfigArray($defaults);
    }
635204
protected function getVars($content, $details = [])
    {
        // Build defaults
        $defaults = [
            'id' => '',
            'title' => Translate::t('map.title', [], 'mapfield'),
            'default' => '',
            'description' => '',
            'can_upload' => current_user_can('upload_files'),
            'url' => $this->getMarkerAssets(),
            'options' => $this->getMapsOptions(),
            'types' => $this->getMapsTypes(),

            // texts
            't_delete_item' => Translate::t('map.delete_selection', [], 'mapfield'),
            't_item_globals' => Translate::t('map.globals', [], 'mapfield'),
            't_item_configs' => Translate::t('map.configurations', [], 'mapfield'),
            't_item_customs' => Translate::t('map.customizations', [], 'mapfield'),
            't_item_preview' => Translate::t('map.preview', [], 'mapfield'),

            't_address' => Translate::t('map.address.title', [], 'mapfield'),
            't_address_description' => Translate::t('map.address.description', [], 'mapfield'),

            't_marker' => Translate::t('map.marker.title', [], 'mapfield'),
            't_marker_add' => Translate::t('map.marker.add', [], 'mapfield'),
            't_marker_cannot_upload' => Translate::t('map.marker.cannot_upload', [], 'mapfield'),

            't_width' => Translate::t('map.width.title', [], 'mapfield'),
            't_width_description' => Translate::t('map.width.description', [], 'mapfield'),

            't_height' => Translate::t('map.height.title', [], 'mapfield'),
            't_height_description' => Translate::t('map.height.description', [], 'mapfield'),

            't_zoom' => Translate::t('map.zoom.title', [], 'mapfield'),
            't_zoom_description' => Translate::t('map.zoom.description', [], 'mapfield'),

            't_type' => Translate::t('map.type.title', [], 'mapfield'),
            't_type_description' => Translate::t('map.type.description', [], 'mapfield'),

            't_options' => Translate::t('map.options.title', [], 'mapfield'),
            't_options_select' => Translate::t('map.options.select', [], 'mapfield'),
            't_options_description' => Translate::t('map.options.description', [], 'mapfield'),

            't_json' => Translate::t('map.json.title', [], 'mapfield'),
            't_json_yes' => Translate::t('map.json.yes', [], 'mapfield'),
            't_json_no' => Translate::t('map.json.no', [], 'mapfield'),
            't_json_description' => Translate::t('map.json.description', [], 'mapfield'),

            't_update' => Translate::t('map.update', [], 'mapfield'),
        ];

        // Build defaults data
        $vars = array_merge($defaults, $content);

        // Retrieve field value
        $vars['val'] = $this->getValue($content['id'], $details, $vars['default']);

        // Update vars
        $this->getModel()->setVars($vars);
    }
1228044
public function geocode($details)
    {
        $geo = $this->createGeocoder();

        try {
            $coords = $geo->geocode($details)->first()->getCoordinates();

            return [
                'lat' => $coords->getLatitude(),
                'lng' => $coords->getLongitude()
            ];
        } catch (Exception $e) {
            $this->logger->error('Error geocoding details', [
                'exception_message' => $e->getMessage(),
                'submitted_details' => $details
            ]);

            return [
                'lat' => null,
                'lng' => null
            ];
        }
    }
753870
public function addColumn($defaults = null)
    {
        $c = parent::addColumn($defaults);

        return $c->add([$this->formLayout, 'form' => $this->form]);
    }
596446
public function details($details, $parameters = array())
    {
        $this->message['details'] = $this->container->translate($details, $parameters);
        return $this;
    }
112061
public function processDefaults($data, $defaults = [])
	{
		if(is_array($defaults))
		{
			// Replace default values with given values.
			$defaults = $data + $defaults;
			
			// Iterate each default key set.
			foreach($defaults as $key => $value)
			{
				if( ! isset($data[$key]))
				{
					// If value is not false, use that directly otherwise compute it.
					if($value !== false && empty($data[$key]))
					{
						$data[$key] = $value;
					}
					// Otherwise, do some custom processing.
					elseif(empty($data[$key]))
					{
						switch($key)
						{
							default:
							break;
						}
					}
				}
			}
		}

		return $data;
	}