<commit_before><?php

/**
 * flexContent
 *
 * @author Team phpManufaktur <<EMAIL>>
 * @link https://addons.phpmanufaktur.de/flexContent
 * @copyright 2013 <NAME> <<EMAIL>>
 * @license MIT License (MIT) http://www.opensource.org/licenses/MIT
 */

namespace phpManufaktur\flexContent\Control\Admin;

use Silex\Application;
use phpManufaktur\flexContent\Control\Configuration;
use phpManufaktur\Basic\Control\Pattern\Alert;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;

class Admin extends Alert
{

    protected static $usage = null;
    protected static $usage_param = null;
    protected static $config = null;

    /**
     * Initialize the class with the needed parameters
     *
     * @param Application $app
     */
    protected function initialize(Application $app)
    {
        parent::initialize($app);

        $cms = $this->app['request']->get('usage');
        self::$usage = is_null($cms) ? 'framework' : $cms;
        self::$usage_param = (self::$usage != 'framework') ? '?usage='.self::$usage : '';
        // set the locale from the CMS locale
        if (self::$usage != 'framework') {
            $app['translator']->setLocale($this->app['session']->get('CMS_LOCALE', 'en'));
        }
        $Configuration = new Configuration($app);
        self::$config = $Configuration->getConfiguration();
    }

    /**
     * Get the toolbar for all backend dialogs
     *
     * @param string $active dialog
     * @return array
     */
    public function getToolbar($active) {
        $toolbar = array();
        foreach (self::$config['nav_tabs']['order'] as $tab) {
            switch ($tab) {
                case 'list':
                    $toolbar[$tab] = array(
                        'name' => 'list',
                        'text' => 'List',
                        'hint' => 'List of all flexContent articles',
                        'link' => FRAMEWORK_URL.'/flexcontent/editor/list'.self::$usage_param,
                        'active' => ($active == 'list')
                    );
                    break;
                case 'edit':
                    $toolbar[$tab] = array(
                        'name' => 'edit',
                        'text' => 'Edit',
                        'hint' => 'Create or edit a flexContent article',
                        'link' => FRAMEWORK_URL.'/flexcontent/editor/edit'.self::$usage_param,
                        'active' => ($active == 'edit')
                    );
                    break;
                case 'tags':
                    $toolbar[$tab] = array(
                        'name' => 'tags',
                        'text' => 'Hashtags',
                        'hint' => 'Create or edit hashtags',
                        'link' => FRAMEWORK_URL.'/flexcontent/editor/buzzword/list'.self::$usage_param,
                        'active' => ($active == 'tags')
                    );
                    break;
                case 'categories':
                    $toolbar[$tab] = array(
                        'name' => 'categories',
                        'text' => 'Categories',
                        'hint' => 'Create or edit categories',
                        'link' => FRAMEWORK_URL.'/flexcontent/editor/category/list'.self::$usage_param,
                        'active' => ($active == 'categories')
                    );
                    break;
                case 'rss':
                    $toolbar[$tab] = array(
                        'name' => 'rss',
                        'text' => 'RSS',
                        'hint' => 'Organize RSS Feeds for the flexContent articles',
                        'link' => FRAMEWORK_URL.'/flexcontent/editor/rss/channel/list'.self::$usage_param,
                        'active' => ($active == 'rss')
                    );
                    break;
                case 'import':
                    $toolbar[$tab] = array(
                        'name' => 'import',
                        'text' => 'Import',
                        'hint' => 'Import WYSIWYG and Blog contents',
                        'link' => FRAMEWORK_URL.'/flexcontent/editor/import/list'.self::$usage_param,
                        'active' => ($active == 'import')
                    );
                    break;
                case 'about':
                    $toolbar[$tab] = array(
                        'name' => 'about',
                        'text' => 'About',
                        'hint' => 'Information about the flexContent extension',
                        'link' => FRAMEWORK_URL.'/flexcontent/editor/about'.self::$usage_param,
                        'active' => ($active == 'about')
                    );
                    break;
            }
        }

        if (!self::$config['admin']['import']['enabled']) {
            // show the import only, if enabled!
            unset($toolbar['import']);
        }

        if (!self::$config['rss']['enabled']) {
            // show the rss only, if enabled!
            unset($toolbar['rss']);
        }
<commit_msg>extended translation functions for localeEditor<commit_after><?php

/**
 * flexContent
 *
 * @author Team phpManufaktur <<EMAIL>>
 * @link https://addons.phpmanufaktur.de/flexContent
 * @copyright 2013 <NAME> <<EMAIL>>
 * @license MIT License (MIT) http://www.opensource.org/licenses/MIT
 */

namespace phpManufaktur\flexContent\Control\Admin;

use Silex\Application;
use phpManufaktur\flexContent\Control\Configuration;
use phpManufaktur\Basic\Control\Pattern\Alert;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;

class Admin extends Alert
{

    protected static $usage = null;
    protected static $usage_param = null;
    protected static $config = null;

    /**
     * Initialize the class with the needed parameters
     *
     * @param Application $app
     */
    protected function initialize(Application $app)
    {
        parent::initialize($app);

        $cms = $this->app['request']->get('usage');
        self::$usage = is_null($cms) ? 'framework' : $cms;
        self::$usage_param = (self::$usage != 'framework') ? '?usage='.self::$usage : '';
        // set the locale from the CMS locale
        if (self::$usage != 'framework') {
            $app['translator']->setLocale($this->app['session']->get('CMS_LOCALE', 'en'));
        }
        $Configuration = new Configuration($app);
        self::$config = $Configuration->getConfiguration();
    }

    /**
     * Get the toolbar for all backend dialogs
     *
     * @param string $active dialog
     * @return array
     */
    public function getToolbar($active) {
        $toolbar = array();
        foreach (self::$config['nav_tabs']['order'] as $tab) {
            switch ($tab) {
                case 'list':
                    $toolbar[$tab] = array(
                        'name' => 'list',
                        'text' => $this->app['translator']->trans('List'),
                        'hint' => $this->app['translator']->trans('List of all flexContent articles'),
                        'link' => FRAMEWORK_URL.'/flexcontent/editor/list'.self::$usage_param,
                        'active' => ($active == 'list')
                    );
                    break;
                case 'edit':
                    $toolbar[$tab] = array(
                        'name' => 'edit',
                        'text' => $this->app['translator']->trans('Edit'),
                        'hint' => $this->app['translator']->trans('Create or edit a flexContent article'),
                        'link' => FRAMEWORK_URL.'/flexcontent/editor/edit'.self::$usage_param,
                        'active' => ($active == 'edit')
                    );
                    break;
                case 'tags':
                    $toolbar[$tab] = array(
                        'name' => 'tags',
                        'text' => $this->app['translator']->trans('Hashtags'),
                        'hint' => $this->app['translator']->trans('Create or edit hashtags'),
                        'link' => FRAMEWORK_URL.'/flexcontent/editor/buzzword/list'.self::$usage_param,
                        'active' => ($active == 'tags')
                    );
                    break;
                case 'categories':
                    $toolbar[$tab] = array(
                        'name' => 'categories',
                        'text' => $this->app['translator']->trans('Categories'),
                        'hint' => $this->app['translator']->trans('Create or edit categories'),
                        'link' => FRAMEWORK_URL.'/flexcontent/editor/category/list'.self::$usage_param,
                        'active' => ($active == 'categories')
                    );
                    break;
                case 'rss':
                    $toolbar[$tab] = array(
                        'name' => 'rss',
                        'text' => $this->app['translator']->trans('RSS'),
                        'hint' => $this->app['translator']->trans('Organize RSS Feeds for the flexContent articles'),
                        'link' => FRAMEWORK_URL.'/flexcontent/editor/rss/channel/list'.self::$usage_param,
                        'active' => ($active == 'rss')
                    );
                    break;
                case 'import':
                    $toolbar[$tab] = array(
                        'name' => 'import',
                        'text' => $this->app['translator']->trans('Import'),
                        'hint' => $this->app['translator']->trans('Import WYSIWYG and Blog contents'),
                        'link' => FRAMEWORK_URL.'/flexcontent/editor/import/list'.self::$usage_param,
                        'active' => ($active == 'import')
                    );
                    break;
                case 'about':
                    $toolbar[$tab] = array(
                        'name' => 'about',
                        'text' => $this->app['translator']->trans('About'),
                        'hint' => $this->app['translator']->trans('Information about the flexContent extension'),
                        'link' => FRAMEWORK_URL.'/flexcontent/editor/about'.self::$usage_param,
                        'active' => ($active == 'about')
                    );
                    break;
            }
        }

        if (!self::$config['admin']['import']['enabled']) {
            // show the import only, if enabled!
            unset($toolbar['import']);
        }

        if (!self::$config['rss']['enabled']) {
            // show the rss only, if enabled!
            unset($toolbar['rss']);
        }

{'fraction_non_alphanumeric': 0.151106111736033, 'fraction_numerical': 0.0007499062617172854, 'mean_word_length': 1.4656806101224866, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 123, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2722656', 'n_tokens_mistral': 2787, 'n_tokens_neox': 2637, 'n_words': 544}