@static

@param null|array $appInfo

@return null|string
192621
private static function _formatAppInfo($appInfo)
    {
        if ($appInfo !== null) {
            $string = $appInfo['name'];
            if ($appInfo['version'] !== null) {
                $string .= '/' . $appInfo['version'];
            }
            if ($appInfo['url'] !== null) {
                $string .= ' (' . $appInfo['url'] . ')';
            }
            return $string;
        } else {
            return null;
        }
    }
1117884
protected function checkIsNullField($app, $field, $value = null)
    {
        return ! is_null($app->$field) ? $app->$field : $value;
    }
1176150
public function getSiteInfo(int $appId) : array
    {
        Assert::that($appId)->greaterThan(0, 'The $appId has to be positive');
        return (array)$this->master->doRequest(
            'GET',
            sprintf(
                '/admin/WEBAPI/Endpoints/v1_0/PluginService/{KEY}/SiteInfo/%s',
                $appId
            )
        );
    }
204570
public function create($app = NULL) : String
    {
        $searchWord = '';

        if( Method::post() )
        {
            $keyword   = Method::post('ML_UPDATE_KEYWORD_HIDDEN');
            $languages = explode(',', Method::post('ML_LANGUAGES'));
            $words     = Method::post('ML_UPDATE_WORDS');

            // SEARCH
            if( Method::post('ML_SEARCH_SUBMIT') )
            {
                $searchWord = Method::post('ML_SEARCH');
            }

            // ADD LANGUAGE
            if( Method::post('ML_ADD_ALL_LANGUAGE_SUBMIT') )
            {
                (new Insert)->do(Method::post('ML_ADD_LANGUAGE'), 'example', 'Example');
            }

            // ALL DELETE
            if( Method::post('ML_ALL_DELETE_SUBMIT') )
            {
                $allDelete = Method::post('ML_ALL_DELETE_HIDDEN');
                (new Delete)->all($allDelete);
            }

            // ADD
            if( Method::post('ML_ADD_KEYWORD_SUBMIT') )
            {
                $addWords   = Method::post('ML_ADD_WORDS');
                $addKeyword = Method::post('ML_ADD_KEYWORD');

                if( is_numeric($addKeyword) )
                {
                    $addKeyword = 'Wrong Keyword! Only String.';
                }

                if( ! empty($languages) ) foreach( $languages as $key => $lang )
                {
                    (new Insert)->do($lang, $addKeyword, $addWords[$key]);
                }
            }

            // UPDATE
            if( Method::post('ML_UPDATE_KEYWORD_SUBMIT') )
            {
                if( ! empty($languages) ) foreach( $languages as $key => $lang )
                {
                    (new Update)->do($lang, $keyword, $words[$key]);
                }
            }

            // DELETE
            if( Method::post('ML_DELETE_SUBMIT') )
            {
                if( ! empty($languages) ) foreach( $languages as $key => $lang )
                {
                    (new Delete)->do($lang, $keyword);
                }
            }
        }

        $config = $this->gridConfig;

        $attributes         = $config['attributes'];
        $pagcon             = $config['pagination'];
        $title              = $this->getLang['ml:titleLabel'];
        $confirmMessage     = $this->getLang['ml:confirmLabel'];
        $process            = $this->getLang['ml:processLabel'];
        $keywords           = $this->getLang['ml:keywordsLabel'];

        $confirmBox = ' onsubmit="return confirm(\''.$confirmMessage.'\');"';

        $data = (new Select)->all($app);

        $languageCount = count($data);

        $formClass = Singleton::class('ZN\Hypertext\Form');

        $table  = $this->_styleElement();
        $table .= '<table id="ML_TABLE"'.Hypertext::attributes($attributes['table']).'>';
        $table .= '<thead>';
        $table .= '<tr><th colspan="'.($languageCount + 4).'">'.$title.'</th></tr>';
        $table .= '<tr><th>S/L</th>';
        $table .= '<td colspan="'.($languageCount + 3).'">';
        $table .= '<form name="ML_SEARCH_ADD_LANGUAGE_FORM" method="post">';
        $table .= $formClass->attr($attributes['textbox'])->placeholder($this->getLang['ml:searchPlaceHolder'])->text('ML_SEARCH');
        $table .= $formClass->attr($attributes['add'])->submit('ML_SEARCH_SUBMIT', $this->getLang['ml:searchButton']);
        $table .= $formClass->attr($attributes['textbox'])->placeholder($this->getLang['ml:addLanguagePlaceHolder'])->text('ML_ADD_LANGUAGE');
        $table .= $formClass->attr($attributes['add'])->submit('ML_ADD_ALL_LANGUAGE_SUBMIT', $this->getLang['ml:addButton']).'</td>';
        $table .= '</form>';
        $table .= '</tr>';
        $table .= '<tr><th>#</th><td><strong>'.$keywords.'</strong></td>';

        $words = [];
        $formObjects = '';

        $languages   = implode(',', $arrayKeys = array_keys($data));
        $mlLanguages = (string) $formClass->hidden('ML_LANGUAGES', $languages);

        foreach( $data as $lang => $values )
        {
            $upperLang = strtoupper($lang);

            $table .= '<form name="ML_TOP_FORM_'.$upperLang.'" method="post"'.$confirmBox.'>';
            $table .= '<td><strong>'.$upperLang.$formClass->hidden('ML_ALL_DELETE_HIDDEN', $lang).$formClass->attr($attributes['delete'])->submit('ML_ALL_DELETE_SUBMIT', $this->getLang['ml:deleteButton']).'</strong></td>';
            $table .= '</form>';
            
            foreach( $values as $key => $val )
            {
                $words[$key][$lang] = $val;
            }

            $formObjects .= '<td>'.$formClass->attr($attributes['textbox'])->placeholder($upperLang)->text('ML_ADD_WORDS[]').'</td>';
        }

        $table .= '<td><strong>'.$process.'</strong></td>';
        $table .= '</tr>';
        $table .= '</thead>';
        $table .= '<tbody>';
        $table .= '<tr>';
        $table .= '<form name="ML_TOP_FORM" method="post">';
        $table .= '<th>N</th>';
        $table .= '<td>'.$mlLanguages.$formClass->attr($attributes['textbox'])->placeholder($this->getLang['ml:keywordPlaceHolder'])->text('ML_ADD_KEYWORD').'</td>';
        $table .= $formObjects;
        $table .= '<td>'.$formClass->attr($attributes['add'])->submit('ML_ADD_KEYWORD_SUBMIT', $this->getLang['ml:addButton']).' '.$formClass->attr($attributes['clear'])->reset('ML_ADD_KEYWORD_RESET', $this->getLang['ml:clearButton']).'</td>';
        $table .= '</form>';
        $table .= '</tr>';

        $limit     = $this->limit;
        $start     = (int) URI::segment(-1);
        $totalRows = count($words);
        $index     = 1;

        if( ! empty($searchWord) )
        {
            $newWords = [];

            foreach( $words as $key => $val )
            {
                if( stristr($key, $searchWord) )
                {
                    $newWords[$key] = $val;
                }
                else
                {
                    $newValues = [];

                    foreach( $val as $k => $v )
                    {
                        if( stristr($v, $searchWord) )
                        {
                            $newValues = array_merge($newValues, $val);
                        }
                    }

                    if( ! empty($newValues) )
                    {
                        $newWords[$key] = $newValues;
                    }
                }
            }

            $words = $newWords;
        }

        if( empty($searchWord) )
        {
            $words = array_slice($words, $start, $limit);
        }
      
        foreach( $words as $key => $val )
        {
            $table .= '<tr>';
            $table .= '<form name="ML_'.strtoupper($key).'_FORM" method="post"'.$confirmBox.'>';
            $table .= '<th>'.$index++.'</th>';
            $table .= '<td>'.$formClass->hidden('ML_UPDATE_KEYWORD_HIDDEN', $key).$key.'</td>';

            foreach( $arrayKeys as $i )
            {
                $table .= '<td>'.$formClass->attr($attributes['textbox'])->text('ML_UPDATE_WORDS[]', ( ! empty($val[$i]) ? $val[$i] : '' )).'</td>';
            }

            $table .= '<td>'.$mlLanguages.$formClass->attr($attributes['update'])->submit('ML_UPDATE_KEYWORD_SUBMIT', $this->getLang['ml:updateButton']);
            $table .= ' ';
            $table .= $formClass->attr($attributes['delete'])->submit('ML_DELETE_SUBMIT', $this->getLang['ml:deleteButton']).'</td>';
            $table .= '</form>';
            $table .= '</tr>';
        }

        if( empty($this->url) )
        {
            $paginationUrl = CURRENT_CFPATH;
        }
        else
        {
            $paginationUrl = $this->url;
        }

        if( empty($searchWord) )
        {
            $pagination = Singleton::class('ZN\Pagination\Paginator')
                                   ->style($pagcon['style'])
                                   ->css($pagcon['class'])
                                   ->start($start)
                                   ->totalRows($totalRows)
                                   ->limit($limit)
                                   ->url($paginationUrl)
                                   ->create();
        }
        else
        {
            $pagination = NULL;
        }

        if( ! empty($pagination) && ! empty($totalRows) )
        {
            $table .= '<tr><th>P</th><td colspan="'.($languageCount + 3).'">'.$pagination.'</td></tr>';
        }

        $table .= '</tbody>';
        $table .= '</table>';

        return $table;
    }
1135901
private String getAppPrefix( AppInfo appInfo )
    {
        /// @TODO scope is ignored in key
        return String.format( "%s.%s.", appInfo.getProviderName(), appInfo.getAppName() );
    }
1291341
public static function getSmartyInstance(string $appFullName = null):\Smarty
    {
        if (self::$instance == null) {
            if (self::$appCall != $appFullName) {
                self::$appCall = $appFullName;
                ;
                new SmartyEngineTemplate();
            }
        }
        return (self::$instance);
    }
221087
private function loadModule(InstallInfo $installInfo)
    {
        $installPath = Path::makeAbsolute($installInfo->getInstallPath(), $this->rootDir);
        $moduleFile = null;
        $loadError = null;

        // Catch and log exceptions so that single modules cannot break
        // the whole repository
        try {
            $moduleFile = $this->loadModuleFile($installPath);
        } catch (InvalidConfigException $loadError) {
        } catch (UnsupportedVersionException $loadError) {
        } catch (FileNotFoundException $loadError) {
        } catch (NoDirectoryException $loadError) {
        }

        $loadErrors = $loadError ? array($loadError) : array();

        return new Module($moduleFile, $installPath, $installInfo, $loadErrors);
    }
1323837
public static function getService(string $appName = null) : ServiceLocator
    {
        if ($appName == null) {
            return self::getDefault();
        }

        if (! self::exist($appName)) {
            throw new \RuntimeException(
                sprintf(
                    'Service %s has not found.',
                    $appName
                ),
                E_WARNING
            );
        }

        return self::$serviceCollections[$appName];
    }
908000
private function handleApplicationInfoInRequest($params)
	{
		// Only add if allowed
		if ($this->allowApplicationInfo) {
			// add/overwrite applicationInfo adyenLibrary even if it's already set
			$params['applicationInfo']['adyenLibrary']['name'] = $this->service->getClient()->getLibraryName();
			$params['applicationInfo']['adyenLibrary']['version'] = $this->service->getClient()->getLibraryVersion();

			if ($adyenPaymentSource = $this->service->getClient()->getConfig()->getAdyenPaymentSource()) {
				$params['applicationInfo']['adyenPaymentSource']['version'] = $adyenPaymentSource['version'];
				$params['applicationInfo']['adyenPaymentSource']['name'] = $adyenPaymentSource['name'];
			}

			if ($externalPlatform = $this->service->getClient()->getConfig()->getExternalPlatform()) {
				$params['applicationInfo']['externalPlatform']['version'] = $externalPlatform['version'];
				$params['applicationInfo']['externalPlatform']['name'] = $externalPlatform['name'];

				if (!empty($externalPlatform['integrator'])) {
					$params['applicationInfo']['externalPlatform']['integrator'] = $externalPlatform['integrator'];
				}
			}

		} else {
			// remove if exists
			if (isset($params['applicationInfo'])) {
				unset($params['applicationInfo']);
			}
		}

		return $params;
	}
906466
protected function get_ns($path,$app_dir) {
        //base filename of the controller
        $class = basename($path, '.php');
        preg_match("/(?<=$app_dir).*?(?=$class)/s", $path, $match);
        return str_replace("/","\\",$app_dir.$match[0]);
    }
366085
protected static function normalizeUserInfo(?string $userInfo): ?string
    {
        if ($userInfo === null) {
            return null;
        }

        if (!static::isValidUserInfo($userInfo)) {
            $message = sprintf('Invalid user info: %s', $userInfo);
            throw new DomainException($message);
        }

        return static::encodeUserInfo(static::decode($userInfo, static::UNRESERVED_SET));
    }
800970
public function getInitApps($app)
    {
        if ($app) {
            return isset($this->initApps[$app]) ? $this->initApps[$app] : null;
        }
        return $this->initApps;
    }
305833
public function getInfo($only = null)
    {
        if (empty($only)) {
            $uri = 'asterisk/info';
        } else {
            $uri = "asterisk/info?only=$only";
        }
        $response = $this->client->getEndpoint()->get($uri);

        return new AsteriskInfo(\GuzzleHttp\json_decode($response->getBody()));
    }
818246
protected function getPhpInfo(): string
	{
		ob_start();
		phpinfo();
		$result = ob_get_contents();
		ob_end_clean();

		$result = preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $result);
		$result = preg_replace('/,\s*/', ', ', $result);
		return $result;
	}
116247
final public function get(array $appConfig): array
    {
        $defaults = $this->getSettings();

        $defaults[static::KEY_ROUTES_FOLDER]          = $appConfig[A::KEY_ROUTES_FOLDER];
        $defaults[static::KEY_WEB_CONTROLLERS_FOLDER] = $appConfig[A::KEY_WEB_CONTROLLERS_FOLDER];

        $apiFolder            = $defaults[static::KEY_API_FOLDER] ?? null;
        $valRulesFolder       = $defaults[static::KEY_JSON_VALIDATION_RULES_FOLDER] ?? null;
        $jsonCtrlFolder       = $defaults[static::KEY_JSON_CONTROLLERS_FOLDER] ?? null;
        $schemasFolder        = $defaults[static::KEY_SCHEMAS_FOLDER] ?? null;
        $schemasFileMask      = $defaults[static::KEY_SCHEMAS_FILE_MASK] ?? null;
        $jsonDataValFolder    = $defaults[static::KEY_JSON_VALIDATORS_FOLDER] ?? null;
        $jsonDataValFileMask  = $defaults[static::KEY_JSON_VALIDATORS_FILE_MASK] ?? null;
        $formsValFolder       = $defaults[static::KEY_FORM_VALIDATORS_FOLDER] ?? null;
        $formsValFileMask     = $defaults[static::KEY_FORM_VALIDATORS_FILE_MASK] ?? null;
        $jsonQueryValFolder   = $defaults[static::KEY_QUERY_VALIDATORS_FOLDER] ?? null;
        $jsonQueryValFileMask = $defaults[static::KEY_QUERY_VALIDATORS_FILE_MASK] ?? null;

        assert(
            $apiFolder !== null && empty(glob($apiFolder)) === false,
            "Invalid API folder `$apiFolder`."
        );
        assert(
            $valRulesFolder !== null && empty(glob($valRulesFolder)) === false,
            "Invalid validation rules folder `$valRulesFolder`."
        );
        assert(
            $jsonCtrlFolder !== null && empty(glob($jsonCtrlFolder)) === false,
            "Invalid JSON API controllers' folder `$jsonCtrlFolder`."
        );
        assert(
            $schemasFolder !== null && empty(glob($schemasFolder)) === false,
            "Invalid Schemas folder `$schemasFolder`."
        );
        assert(empty($schemasFileMask) === false, "Invalid Schemas file mask `$schemasFileMask`.");
        assert(
            $jsonDataValFolder !== null && empty(glob($jsonDataValFolder)) === false,
            "Invalid JSON Validators folder `$jsonDataValFolder`."
        );
        assert(empty($jsonDataValFileMask) === false, "Invalid JSON Validators file mask `$jsonDataValFileMask`.");
        assert(
            $formsValFolder !== null && empty(glob($formsValFolder)) === false,
            "Invalid Forms Validators folder `$formsValFolder`."
        );
        assert(empty($formsValFileMask) === false, "Invalid Forms Validators file mask `$formsValFileMask`.");
        assert(
            $jsonQueryValFolder !== null && empty(glob($jsonQueryValFolder)) === false,
            "Invalid Query Validators folder `$jsonQueryValFolder`."
        );
        assert(empty($jsonQueryValFileMask) === false, "Invalid Query Validators file mask `$jsonQueryValFileMask`.");

        $schemasPath         = $schemasFolder . DIRECTORY_SEPARATOR . $schemasFileMask;
        $jsonDataValPath     = $jsonDataValFolder . DIRECTORY_SEPARATOR . $jsonDataValFileMask;
        $formsValidatorsPath = $formsValFolder . DIRECTORY_SEPARATOR . $formsValFileMask;
        $jsonQueryValPath    = $jsonQueryValFolder . DIRECTORY_SEPARATOR . $jsonQueryValFileMask;

        $requireUniqueTypes = $defaults[static::KEY_SCHEMAS_REQUIRE_UNIQUE_TYPES] ?? true;

        $doNotLogExceptions = $defaults[static::KEY_DO_NOT_LOG_EXCEPTIONS_LIST] ?? [];
        unset($defaults[static::KEY_DO_NOT_LOG_EXCEPTIONS_LIST]);

        [$modelToSchemaMap, $typeToSchemaMap] = $this->createSchemaMapping($schemasPath, $requireUniqueTypes);

        return $defaults + [
                static::KEY_DO_NOT_LOG_EXCEPTIONS_LIST__AS_KEYS => array_flip($doNotLogExceptions),

                static::KEY_MODEL_TO_SCHEMA_MAP => $modelToSchemaMap,
                static::KEY_TYPE_TO_SCHEMA_MAP  => $typeToSchemaMap,

                static::KEY_JSON_VALIDATION_RULE_SETS_DATA =>
                    $this->serializeJsonValidationRules($jsonDataValPath, $jsonQueryValPath),

                static::KEY_ATTRIBUTE_VALIDATION_RULE_SETS_DATA =>
                    $this->serializeFormValidationRules($formsValidatorsPath),
            ];
    }
719369
public function calculateFieldsInfo(array $data)
    {
        if (! $this->exists) {
            return null;
        }

        $output = array();

        foreach ($this->_fields as $key => $field) {
            if ($field instanceof FieldInterface) {
                if ($field->toTrackInfo()) {
                    $inVal  = isset($data[$key]) ? $data[$key] : null;
                    $outVal = $field->calculateFieldInfo($inVal, $data);

                    if ($outVal && $field->isLabelInTrackInfo()) {
                        $label = $field->getLabel();
                        if ($label) {
                            $output[] = $label;
                        }
                    }

                    if (is_array($outVal)) {
                        $output = array_merge($output, array_filter($outVal));
                    } elseif ($outVal || ($outVal == 0)) {
                        $output[] = $outVal;
                    }
                }
            }
        }

        return substr(trim(implode(' ', $output)), 0, $this->maxTrackInfoChars);
    }
53847
private function createFile(array $fileInfo = []) {
    $file = new \Nuki\Models\Data\File($fileInfo['tmp_name'], $fileInfo['size']);
    
    $file->setExtension(pathinfo($fileInfo['name'], PATHINFO_EXTENSION));
    $file->setName(pathinfo($fileInfo['name'], PATHINFO_BASENAME));
    
    return $file;
  }