Load project specific respondent model or general Gems model otherwise

@param boolean $detail When true more information needed for individual item display is added to the model.
@return \Gems_Model_RespondentModel
540735
public function getRespondentModel($detailed)
    {
        static $isDetailed;
        static $model;

        if ($model && ($isDetailed === $detailed)) {
            return $model;
        }

        $isDetailed = $detailed;
        $model      = $this->createRespondentModel();

        if ($detailed) {
            $model->applyDetailSettings();
        } else {
            $model->applyBrowseSettings();
        }

        return $model;
    }
795102
public function include($includes)
	{
		$model = $this;

		(function() use ($includes, $model): void
		{
			$this->including($includes)->loadIncludes([$model]);
		})->bindTo($this->builder(), Query::class)();

		return $this;
	}
978818
public function setRequired(bool $required) : Component
    {
        if ($required) {
            $this->getTag()->setAttribute('required', 'required');
        } else {
            $this->getTag()->removeAttribute('required');
        }

        return parent::setRequired($required);
    }
921890
public static function listBuckets($detailed = false)
        {
            $rest = new S3Request('GET', '', '', self::$endpoint);
            $rest = $rest->getResponse();

            if ($rest->error === false && $rest->code !== 200) {
                $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
            }

            if ($rest->error !== false) {
                self::__triggerError(sprintf("S3::listBuckets(): [%s] %s", $rest->error['code'],
                $rest->error['message']), __FILE__, __LINE__);

                return false;
            }

            $results = array();
            if (!isset($rest->body->Buckets)) {
                return $results;
            }

            if ($detailed) {
                if (isset($rest->body->Owner, $rest->body->Owner->ID, $rest->body->Owner->DisplayName)) {
                    $results['owner'] = array(
                        'id' => (string)$rest->body->Owner->ID,
                        'name' => (string)$rest->body->Owner->ID
                    );
                }

                $results['buckets'] = array();

                foreach ($rest->body->Buckets->Bucket as $b) {
                    $results['buckets'][] = array(
                        'name' => (string)$b->Name,
                        'time' => strtotime((string)$b->CreationDate)
                    );
                }
            } else {
                foreach ($rest->body->Buckets->Bucket as $b) {
                    $results[] = (string)$b->Name;
                }
            }

            return $results;
        }
1011905
protected function getModels($refresh = false)
    {
        if ($this->_models === null || $refresh) {
            $this->_models = [];
            if (isset($this->module->panels['profiling']->data['messages'])) {
                $this->_models = Yii::getLogger()->calculateTimings($this->module->panels['profiling']->data['messages']);
            }
        }
        return $this->_models;
    }
883929
protected function loadBasicPaymentMethodClass()
    {

        if (!class_exists("Icepay_Api_Basic"))
            return $this;

        $this->pm_class = Icepay_Api_Basic::getInstance()
                ->readFolder()
                ->getClassByPaymentMethodCode($this->data->ic_paymentmethod);

        if (count($this->pm_class->getSupportedIssuers()) == 1) {
            $this->setIssuer(current($this->pm_class->getSupportedIssuers()));
        }
        return $this;
    }
502040
public function LoadModel($mdlname=''){
		if(empty($mdlname)){
			bimport('mvc.model');
			return new BModel();
			}
		$fn=BCOMPONENTSAPPLICATIONPATH.$this->componentname.DIRECTORY_SEPARATOR.'models'.DIRECTORY_SEPARATOR.$mdlname.'.php';
		if(!file_exists($fn)){
			$fn=BCOMPONENTSFRAMEWORKPATH.$this->componentname.DIRECTORY_SEPARATOR.'models'.DIRECTORY_SEPARATOR.$mdlname.'.php';
			}
		$class='Model_'.$this->componentname.'_'.$mdlname;
		if(!file_exists($fn)){
			echo('File "'.$fn.'" does not exist!');
			return NULL;
			}
		require_once($fn);
		$model=new $class;
		$model->controller=$this;
		return $model;
		}
340299
private function flattenDetail($detail): string
    {
        if (is_array($detail)) {
            return join(', ', $detail);
        } elseif (is_object($detail) && !method_exists($detail, '__toString')) {
            return get_class($detail);
        }

        return (string) $detail;
    }
1313271
public function getRoundModel($detailed, $action)
    {
        $model = parent::getRoundModel($detailed, $action);

        // Add information about surveys and groups
        $model->addLeftTable('gems__surveys', array('gro_id_survey' => 'gsu_id_survey'));
        $model->addLeftTable('gems__groups', array('gsu_id_primary_group' => 'ggp_id_group'));
        $model->addLeftTable('gems__track_fields', array('gro_id_relationfield = gtf_id_field'), 'gtf', false);

        $model->addColumn(new \Zend_Db_Expr('COALESCE(gtf_field_name, ggp_name)'), 'ggp_name');
        $model->set('ggp_name', 'label', $this->_('Assigned to'));

        // Reset display order to class specific order
        $model->resetOrder();
        if (! $detailed) {
            $model->set('gro_id_order');
        }
        $model->set('gro_id_track');
        $model->set('gro_id_survey');
        $model->set('gro_round_description');
        if ($detailed) {
            $model->set('gro_id_order');
        }
        $model->set('gro_icon_file');

        // Calculate valid from
        if ($detailed) {
            $html = \MUtil_Html::create()->h4($this->_('Valid from calculation'));
            $model->set('valid_after',
                    'default', $html,
                    'label', ' ',
                    'elementClass', 'html',
                    'value', $html
                    );
        }
        $model->set('gro_valid_after_source',
                'label', $this->_('Date source'),
                'default', self::TOKEN_TABLE,
                'elementClass', 'Radio',
                'escape', false,
                'required', true,
                'onchange', 'this.form.submit();',
                'multiOptions', $this->getSourceList(true, false, false)
                );
        $model->set('gro_valid_after_id',
                'label', $this->_('Round used'),
                'onchange', 'this.form.submit();'
                );

        if ($detailed) {
            $periodUnits = $this->util->getTranslated()->getPeriodUnits();

            $model->set('gro_valid_after_field',
                    'label', $this->_('Date used'),
                    'default', 'gto_valid_from',
                    'onchange', 'this.form.submit();'
                    );
            $model->set('gro_valid_after_length',
                    'label', $this->_('Add to date'),
                    'description', $this->_('Can be negative'),
                    'required', false,
                    'filter', 'Int'
                    );
            $model->set('gro_valid_after_unit',
                    'label', $this->_('Add to date unit'),
                    'multiOptions', $periodUnits
                    );
        } else {
            $model->set('gro_valid_after_source',
                    'label', $this->_('Source'),
                    'tableDisplay', 'small'
                    );
            $model->set('gro_valid_after_id', 'label', $this->_('Round'),
                    'multiOptions', $this->getRoundTranslations(),
                    'tableDisplay', 'small'
                    );
            $model->setOnLoad('gro_valid_after_id', array($this, 'displayRoundId'));
            $model->set('gro_valid_after_field',
                    'label', $this->_('Date calculation'),
                    'tableHeaderDisplay', 'small'
                    );
            $model->setOnLoad('gro_valid_after_field', array($this, 'displayDateCalculation'));
            $model->set('gro_valid_after_length');
            $model->set('gro_valid_after_unit');
        }

        if ($detailed) {
            // Calculate valid until
            $html = \MUtil_Html::create()->h4($this->_('Valid for calculation'));
            $model->set('valid_for',
                    'label', ' ',
                    'default', $html,
                    'elementClass', 'html',
                    'value', $html
                    );
        }

        $model->set('gro_valid_for_source',
                'label', $this->_('Date source'),
                'default', self::TOKEN_TABLE,
                'elementClass', 'Radio',
                'escape', false,
                'required', true,
                'onchange', 'this.form.submit();',
                'multiOptions', $this->getSourceList(false, false, false)
                );
        $model->set('gro_valid_for_id',
                'label', $this->_('Round used'),
                'default', '',
                'onchange', 'this.form.submit();'
                );

        if ($detailed) {
            $model->set('gro_valid_for_field',
                    'label', $this->_('Date used'),
                    'default', 'gto_valid_from',
                    'onchange', 'this.form.submit();'
                    );
            $model->set('gro_valid_for_length',
                    'label', $this->_('Add to date'),
                    'description', $this->_('Can be negative'),
                    'required', false,
                    'default', 2,
                    'filter', 'Int'
                    );
            $model->set('gro_valid_for_unit',
                    'label', $this->_('Add to date unit'),
                    'multiOptions', $periodUnits
                    );

            // Continue with last round level items
            $model->set('gro_condition');
            $model->set('condition_display');
            $model->set('gro_active');
            $model->set('gro_changed_event');
        } else {
            $model->set('gro_valid_for_source',
                    'label', $this->_('Source'),
                    'tableDisplay', 'small'
                    );
            $model->set('gro_valid_for_id',
                    'label', $this->_('Round'),
                    'multiOptions', $this->getRoundTranslations(),
                    'tableDisplay', 'small'
                    );
            $model->setOnLoad('gro_valid_for_id', array($this, 'displayRoundId'));
            $model->set('gro_valid_for_field',
                    'label', $this->_('Date calculation'),
                    'tableHeaderDisplay', 'small'
                    );
            $model->setOnLoad('gro_valid_for_field', array($this, 'displayDateCalculation'));
            $model->set('gro_valid_for_length');
            $model->set('gro_valid_for_unit');
        }

        return $model;
    }
162543
protected function loadModel($id = null)
	{
		/** @var BaseActiveRecord $modelClass */
		$modelClass = $this->modelClass();
		if($id) {
			$this->modelInstance = $modelClass::findOne($id);
		} else {
			$this->modelInstance = new $modelClass();
		}
		$this->modelInstance->load($this->attributes, '');
		return $this->modelInstance;
	}
179756
public function render(Model $model, $source)
    {
        $value = $this->resolveModelSource($model, $source);

        if (null === $value) {
            return null;
        }

        if ($value) {
            return cms_trans('common.boolean.true');
        }

        return cms_trans('common.boolean.false');
    }
783702
public function loadModalAsync(string $modal, $method, $options, string $text = null): self
    {
        $this->render(function ($datum) use ($modal, $method, $options, $text) {
            $attributes = [];
            $options = Arr::wrap($options);

            foreach ($options as $option) {
                if (method_exists($datum, 'getContent')) {
                    $attributes[] = $datum->getContent($option);
                    continue;
                }

                $attributes[] = $datum->getAttribute($option);
            }

            $text = $datum->getContent($text) ?: $text;

            return view('platform::partials.td.async', [
                'modal'      => $modal,
                'attributes' => $attributes,
                'text'       => $text,
                'method'     => $method,
                'title'      => $this->title,
                'route'      => $this->asyncRoute,
            ]);
        });

        return $this;
    }
228124
protected function loadSite()
    {

        $this->title = 'Model';
        $this->url = 'model';

        $this->modelNew = new AppModelNewSite($this);
        $this->modelEdit = new AppModelEditSite($this);
        $this->modelData = new AppModelDataSite($this);
        $this->modelAdmin = new AppModelAdminSite($this);
        $this->modelDelete = new AppModelDeleteSite($this);

        $this->fieldNew = new AppModelFieldNewSite($this);
        $this->fieldEdit = new AppModelFieldEditSite($this);
        $this->fieldDelete = new AppModelFieldDeleteSite($this);
        $this->fieldSortable = new AppModelFieldSortableSite($this);

        $this->modelIndex = new AppModelIndexSite($this);
        $this->modelIndexNew = new AppModelIndexNewSite($this);
        $this->modelIndexDelete = new AppModelIndexDeleteSite($this);

        $this->modelDefaultTypeNew = new DefaultTypeNewSite($this);
        $this->modelDefaultTypeDelete = new DefaultTypeDeleteSite($this);

        $this->modelDefaultOrderTypeNew = new DefaultOrderTypeNewSite($this);
        $this->modelDefaultOrderTypeDelete = new DefaultOrderTypeDeleteSite($this);

        /*
        $this->modelActionNew = new  ModelActionNewSite($this);
        $this->modelActionDelete = new ModelActionDeleteSite($this);*/

    }
874866
public function getMeta($key = false, $model = false)
    {
        if ($key === false) {
            return $this->meta()->get();
        }
        if ($meta = $this->meta()->whereKey($key)->first()) {
            return ($model == false) ? $meta->value : $meta;
        }

        return false;
    }
381843
public function loadTemplate($tpl, $data = array(), $viewData = true)
    {
        $viewData && $data = $data + $this->viewData;
        if(substr_count($tpl,'::') ) {
            return view($tpl, $data);
        }
        return view('hstcms::manage.'.$tpl, $data);
    }
668772
private function loadSource(Model\Source $sourceModel, array $sourceData)
    {
        $sourceModel
        ->setId($sourceData['id'])
        ->setMethod(new Model\Method($sourceData['class'], $sourceData['method'], $sourceData['args']))
        ->setLazyLoading($sourceData['lazyLoading'])
        ->setSupplySeveralFields($sourceData['supplySeveralFields'])
        ->setOnFail($sourceData['onFail'])
        ->setExceptionClass($sourceData['exceptionClass'])
        ->setBadReturnValue($sourceData['badReturnValue'])
        ->setFallbackSourceId($sourceData['fallbackSourceId'])
        ->setDepends($sourceData['depends'])
        ;

        if (isset($sourceData['preprocessor']['method'])) {
            $sourceModel->addPreprocessor(
                new Model\Method(
                    $sourceData['preprocessor']['class'],
                    $sourceData['preprocessor']['method'],
                    $sourceData['preprocessor']['args']
                )
            );
        } elseif (isset($sourceData['preprocessors'])) {
            foreach ($sourceData['preprocessors'] as $preprocessor) {
                $sourceModel->addPreprocessor(
                    new Model\Method(
                        $preprocessor['class'],
                        $preprocessor['method'],
                        $preprocessor['args']
                    )
                );
            }
        }

        if (isset($sourceData['processor']['method'])) {
            $sourceModel->addProcessor(
                new Model\Method(
                    $sourceData['processor']['class'],
                    $sourceData['processor']['method'],
                    $sourceData['processor']['args']
                )
            );
        } elseif (isset($sourceData['processors'])) {
            foreach ($sourceData['processors'] as $processor) {
                $sourceModel->addProcessor(
                    new Model\Method(
                        $processor['class'],
                        $processor['method'],
                        $processor['args']
                    )
                );
            }
        }

        return $sourceModel;
    }
404264
public function getServerVersion($details = false)
    {
        $url = Urls::URL_ADMIN_VERSION;

        if ($details) {
            $url = UrlHelper::appendParamsUrl($url, ['details' => true]);
        }

        $response = $this->getConnection()->get($url);
        $data     = $response->getJson();

        if ($details) {
            return $data;
        }

        return $data['version'];
    }