Request via notice markup.

@since 160712 License key utils.

@param string $app_slug App slug.

@return string Empty = dequeue entirely.
544996
public function requestViaNoticeMarkup(string $app_slug): string
    {
        if (!($App = $this->s::getAppsBySlug()[$app_slug] ?? null)) {
            return ''; // Dequeue entirely.
        }
        return $App->c::getTemplate('s-core/admin/notices/license-key-request.php')->parse();
    }
1010551
public static function appPath(?string $app = null): ?string
    {
        self::initialize();
        if ($app === null) {
            $app = '*';
        }
        if (isset(self::$repositories[$app])) {
            return call_user_func([self::$repositories[$app], 'getPath']);
        }
        return null;
    }
729087
public static function isAppRegistered(?string $app = null): bool
    {
        self::initialize();
        if ($app === null) {
            $app = '*';
        }
        return isset(self::$repositories[$app]);
    }
34841
public function installedData(string $slug, string $key): string
    {
        if (!$slug || !$key) { // Either empty?
            return ''; // Not possible.
        }
        switch ($key) {
            case 'basename':
                $key = 'Basename';
                break;
            case 'name':
                $key = 'Name';
                break;
            case 'version':
                $key = 'Version';
                break;
            case 'description':
                $key = 'Description';
                break;
            case 'url':
                $key = 'PluginURI';
                break;
            case 'text_domain':
                $key = 'TextDomain';
                break;
            case 'author':
                $key = 'Author';
                break;
            case 'author_url':
                $key = 'AuthorURI';
                break;
            default: // Default case.
                return ''; // Unknown key.
        }
        $installed_plugins = $this->s::allInstalledPlugins(); // « Cached statically.
        return !empty($installed_plugins[$slug][$key]) ? (string) $installed_plugins[$slug][$key] : '';
    }
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;
    }
403254
public function slug($slug = null)
    {
        if (null === $slug) {
            return $this->slug;
        }

        $this->slug = $slug;

        return $this;
    }
207598
protected function appInstancesReloadReady()
    {
        $ready = true;

        foreach (Daemon::$appInstances as $k => $app) {
            foreach ($app as $name => $appInstance) {
                if (!$appInstance->handleStatus($this->graceful ? AppInstance::EVENT_GRACEFUL_SHUTDOWN : AppInstance::EVENT_SHUTDOWN)) {
                    $this->log(__METHOD__ . ': waiting for ' . $k . ':' . $name);
                    $ready = false;
                }
            }
        }
        return $ready;
    }
1034922
protected function show($slug)
    {
        $calendar = $this->repository->scopeQuery(function($query) use ($slug) {
            return $query->orderBy('id','DESC')
                         ->where('slug', $slug);
        })->first(['*']);

        return $this->theme->of('calendar::public.calendar.show', compact('calendar'))->render();
    }
1061039
public function widget($slug)
    {
        $widget = app(WidgetRepository::class)->getBySlug($slug);

        if ($widget) {
            if (Gate::allows('cms', Auth::user())) {
                $widget->content .= '<a href="'.url(config('cms.backend-route-prefix', 'cms').'/widgets/'.$widget->id.'/edit').'" class="btn btn-sm ml-2 btn-outline-secondary"><span class="fa fa-edit"></span> Edit</a>';
            }

            if (config('app.locale') !== config('cms.default-language') && $widget->translation(config('app.locale'))) {
                return $widget->translationData(config('app.locale'))->content;
            } else {
                return $widget->content;
            }
        }

        return '';
    }
95093
public function get_slug( $config_name, $suffix = '-' ) {
		if ( ! isset( self::$_slugs[ $this->app->plugin_name ][ $config_name ] ) ) {
			$default = $this->app->slug_name . $suffix;
			$slug    = $this->app->get_config( 'slug', $config_name, $default );
			if ( empty( $slug ) ) {
				$slug = $default;
			}
			self::$_slugs[ $this->app->plugin_name ][ $config_name ] = $slug;
		}

		return self::$_slugs[ $this->app->plugin_name ][ $config_name ];
	}
113731
public static function notice($slug, $type = null)
    {
        ob_start();
        self::template($slug, 'notice');

        $result = null;
        if ($type == null) {
            $result = ob_get_flush();
        } else {
            $result = array(
                'message' => ob_get_flush(),
                'type'    => $type,
            );
        }

        return $result;
    }
939498
private static function sign(string $request_body)
    {
        $app_key = self::$app_key;
        $sign = strtoupper(md5($request_body.'&app_key='.$app_key));

        return $sign;
    }
366779
protected function _get($slug = '')
    {
        // Build a url from the slug that was passed in
        $url = $this->urlFromRoute($slug);
        // Send a post request to the API
        $response = $this->orm->uniRequest->get($url, $this->orm->headers);
        // If the token has expired
        if ($response->code == 401) {
            if (isset($response->body->message)) {
                if ($response->body->message == 'Token has expired') {
                    // Authenticate again
                    $this->orm->authenticate();
                    // Try the request again
                    return $this->_get($slug);
                }
            }
            // Return the response
            return $response;
        } else {
            // Return the response
            return $response;
        }
    }
1329647
protected function getExistingSlugs($slug)
    {
        return static::where($this->slugOptions->slugField, 'LIKE', "{$slug}%")
            ->withoutGlobalScopes()// ignore scopes
            ->withTrashed()// trashed, when entry gets activated again
            ->orderBy($this->slugOptions->slugField)
            ->get()
            ->pluck($this->slugOptions->slugField);
    }
760638
protected function checkValidSlug($slug)
    {
        if (preg_match_all('#^([a-z,A-Z,0-9,\-,_]*)(.+)?$#', $slug, $matches)
            && (strlen($matches[2][0]) > 0)
        ) {
            throw new \RuntimeException(
                sprintf(
                    'Error: prefix "%s" is invalid. It must only contain letters, numbers, underscores and hyphens. ' .
                    'Found problem near: "%s"',
                    $slug,
                    $matches[2][0]
                )
            );
        }
    }
1079499
public function register(Application $app)
    {
        Assertion::isInstanceOf($app, \Alchemy\Phrasea\Application::class);

        $app['setup.validate-config'] = $app->protect(function (Request $request) use ($app) {
            if (0 === strpos($request->getPathInfo(), '/setup')) {
                if (!$app['phraseanet.configuration-tester']->isInstalled()) {
                    if (!$app['phraseanet.configuration-tester']->isBlank()) {
                        if ('setup_upgrade_instructions' !== $app['request']->attributes->get('_route')) {
                            return $app->redirectPath('setup_upgrade_instructions');
                        }
                    }
                } elseif (!$app['phraseanet.configuration-tester']->isBlank()) {
                    return $app->redirectPath('homepage');
                }
            } else {
                if (false === strpos($request->getPathInfo(), '/include/minify')) {
                    $app['firewall']->requireSetup();
                }
            }
        });
    }
300096
function checkSlugInCategories($slug){
        $repet=true;
        $counter=1;
        $newSlug=$slug;

        while ($repet)
        {
            if(Categories::where('slug',$newSlug)->where('model_type',$this->type)->first())
            {
                $newSlug=$slug.'-'.$counter;
                $counter++;
            }
            else
                $repet=false;
        }

        return $newSlug;
    }