@EXT\Route("/import", name="claro_agenda_import")
@EXT\Template("ClarolineAgendaBundle:tool:import_ics_modal_form.html.twig")

@return array
547447
public function importsEventsIcsAction()
    {
        $form = $this->createForm(new ImportAgendaType());
        $form->handleRequest($this->request);

        if ($form->isValid()) {
            $events = $this->agendaManager->importEvents($form->get('file')->getData());

            return new JsonResponse($events, 200);
        }

        return ['form' => $form->createView()];
    }
960875
public function actionImport()
    {
        $filename = Architect::$configPath . DIRECTORY_SEPARATOR . Craft::$app->request->getQueryParam('file');
        $fileContents = '';
        if (is_file($filename)) {
            $fileContents = file_get_contents($filename);
        }
        return $this->renderTemplate('architect/import', [ 'importData' => $fileContents, 'invalidJSON' => false ]);
    }
1216298
private function getRenderContext()
    {
        $bundled = array_filter(
            $this->app['extensions']->all(),
            function (ResolvedExtension $ext) {
                return $ext->isBundled();
            }
        );

        return [
            'messages'       => $this->app['extend.ping']->getMessages(),
            'enabled'        => $this->app['extend.enabled'],
            'writeable'      => $this->app['extend.writeable'],
            'online'         => $this->app['extend.online'],
            'extensionsPath' => $this->app['path_resolver']->resolve('extensions'),
            'site'           => $this->app['extend.site'],
            'extendVersion'  => Bolt\Version::forComposer(),
            'bundled'        => $bundled,
        ];
    }
424468
public function indexAction ()
    {
        $layoutGroups = array_map(
            function ($elementType)
            {
                return [
                    "title"       => ucfirst($elementType) . "s",
                    "elementType" => $elementType,
                    "elements"    => $this->elementTypesModel->getListedElements($elementType),
                ];
            },
            $this->elementTypesModel->getAllElementTypes()
        );


        return $this->twig->render("@core/index.twig", [
            "layoutGroups" => $layoutGroups,
            "downloads"    => $this->downloadModel->getAllDownloads(),
        ]);
    }
1000266
protected function getColumns(): array
    {
        $link = config('cortex.foundation.route.locale_prefix')
            ? '"<a href=\""+routes.route(\'managerarea.roles.edit\', {role: full.id, locale: \''.$this->request->segment(1).'\'})+"\">"+data+"</a>"'
            : '"<a href=\""+routes.route(\'managerarea.roles.edit\', {role: full.id})+"\">"+data+"</a>"';

        return [
            'title' => ['title' => trans('cortex/auth::common.title'), 'render' => $link, 'responsivePriority' => 0],
            'name' => ['title' => trans('cortex/auth::common.name')],
            'created_at' => ['title' => trans('cortex/auth::common.created_at'), 'render' => "moment(data).format('YYYY-MM-DD, hh:mm:ss A')"],
            'updated_at' => ['title' => trans('cortex/auth::common.updated_at'), 'render' => "moment(data).format('YYYY-MM-DD, hh:mm:ss A')"],
        ];
    }
244313
public function import()
    {
        $result = [
            'languages' => ['new' => 0, 'updated' => 0],
            'languageSources' => ['new' => 0, 'updated' => 0],
            'languageTranslations' => ['new' => 0, 'updated' => 0],
        ];

        $data = $this->parseImportFile();

        /** @var Language[] $languages */
        $languages = Language::find()->indexBy('language_id')->all();

        foreach ($data['languages'] as $importedLanguage) {
            if (isset($languages[$importedLanguage['language_id']])) {
                $language = $languages[$importedLanguage['language_id']];
            } else {
                $language = new Language();
            }

            //cast integers
            $importedLanguage['status'] = (int) $importedLanguage['status'];

            $language->attributes = $importedLanguage;
            if (count($language->getDirtyAttributes())) {
                $saveType = $language->isNewRecord ? 'new' : 'updated';
                if ($language->save()) {
                    ++$result['languages'][$saveType];
                } else {
                    $this->throwInvalidModelException($language);
                }
            }
        }

        /** @var LanguageSource[] $languageSources */
        $languageSources = LanguageSource::find()->indexBy('id')->all();

        /** @var LanguageTranslate[] $languageTranslations */
        $languageTranslations = LanguageTranslate::find()->all();

        /*
         *  Create 2 dimensional array for current and imported translation, first index by LanguageSource->id
         *  and than indexed by LanguageTranslate->language.
         *  E.g.: [
         *      id => [
         *          language => LanguageTranslate (for $languageTranslations) / Array (for $importedLanguageTranslations)
         *          ...
         *      ]
         *      ...
         * ]
         */
        $languageTranslations = ArrayHelper::map($languageTranslations, 'language', function ($languageTranslation) {
            return $languageTranslation;
        }, 'id');
        $importedLanguageTranslations = ArrayHelper::map($data['languageTranslations'], 'language', function ($languageTranslation) {
            return $languageTranslation;
        }, 'id');

        foreach ($data['languageSources'] as $importedLanguageSource) {
            $languageSource = null;

            //check if id exist and if category and messages are matching
            if (isset($languageSources[$importedLanguageSource['id']]) &&
                ($languageSources[$importedLanguageSource['id']]->category == $importedLanguageSource['category']) &&
                ($languageSources[$importedLanguageSource['id']]->message == $importedLanguageSource['message'])
            ) {
                $languageSource = $languageSources[$importedLanguageSource['id']];
            }

            if (is_null($languageSource)) {
                //no match by id, search by message
                foreach ($languageSources as $languageSourceSearch) {
                    if (($languageSourceSearch->category == $importedLanguageSource['category']) &&
                        ($languageSourceSearch->message == $importedLanguageSource['message'])
                    ) {
                        $languageSource = $languageSourceSearch;
                        break;
                    }
                }
            }

            if (is_null($languageSource)) {
                //still no match, create new
                $languageSource = new LanguageSource([
                    'category' => $importedLanguageSource['category'],
                    'message' => $importedLanguageSource['message'],
                ]);

                if ($languageSource->save()) {
                    ++$result['languageSources']['new'];
                } else {
                    $this->throwInvalidModelException($languageSource);
                }
            }

            //do we have translations for the current source?
            if (isset($importedLanguageTranslations[$importedLanguageSource['id']])) {
                //loop through the translations for the current source
                foreach ($importedLanguageTranslations[$importedLanguageSource['id']] as $importedLanguageTranslation) {
                    $languageTranslate = null;

                    //is there already a translation for this souce
                    if (isset($languageTranslations[$languageSource->id]) &&
                        isset($languageTranslations[$languageSource->id][$importedLanguageTranslation['language']])
                    ) {
                        $languageTranslate = $languageTranslations[$languageSource->id][$importedLanguageTranslation['language']];
                    }

                    //no translation found, create a new one
                    if (is_null($languageTranslate)) {
                        $languageTranslate = new LanguageTranslate();
                    }

                    $languageTranslate->attributes = $importedLanguageTranslation;

                    //overwrite the id because the $languageSource->id might be different from the $importedLanguageTranslation['id']
                    $languageTranslate->id = $languageSource->id;

                    if (count($languageTranslate->getDirtyAttributes())) {
                        $saveType = $languageTranslate->isNewRecord ? 'new' : 'updated';
                        if ($languageTranslate->save()) {
                            ++$result['languageTranslations'][$saveType];
                        } else {
                            $this->throwInvalidModelException($languageTranslate);
                        }
                    }
                }
            }
        }

        return $result;
    }
622559
protected function importParams()
    {
        foreach ($this->uri['params'] as $key => $val) {
            if (isset($this->{$key}) && is_bool($this->{$key})) {
                $this->{$key} = (bool)$val;
                continue;
            }
            if (!property_exists($this, $key)) {
                Daemon::log(get_class($this) . ': unrecognized setting \'' . $key . '\'');
                continue;
            }
            $this->{$key} = $val;
        }
        if (property_exists($this, 'port') && !isset($this->port)) {
            if (isset($this->uri['port'])) {
                $this->port = $this->uri['port'];
            } elseif ($this->defaultPort) {
                $this->port = $this->defaultPort;
            }
        }
        if (property_exists($this, 'host') && !isset($this->host)) {
            if (isset($this->uri['host'])) {
                $this->host = $this->uri['host'];
            }
        }
        if (!$this->ctxname) {
            return;
        }
        if (!isset(Daemon::$config->{'TransportContext:' . $this->ctxname})) {
            Daemon::log(get_class($this) . ': undefined transport context \'' . $this->ctxname . '\'');
            return;
        }
        $ctx = Daemon::$config->{'TransportContext:' . $this->ctxname};
        foreach ($ctx as $key => $entry) {
            $value = ($entry instanceof \PHPDaemon\Config\Entry\Generic) ? $entry->value : $entry;
            if (isset($this->{$key}) && is_bool($this->{$key})) {
                $this->{$key} = (bool)$value;
                continue;
            }
            if (!property_exists($this, $key)) {
                Daemon::log(get_class($this) . ': unrecognized setting in transport context \'' . $this->ctxname . '\': \'' . $key . '\'');
                continue;
            }
            $this->{$key} = $value;
        }
    }
151180
protected function getColumns(): array
    {
        $link = config('cortex.foundation.route.locale_prefix')
            ? '"<a href=\""+routes.route(\'adminarea.contacts.edit\', {contact: full.id, locale: \''.$this->request->segment(1).'\'})+"\">"+data+"</a>"'
            : '"<a href=\""+routes.route(\'adminarea.contacts.edit\', {contact: full.id})+"\">"+data+"</a>"';

        return [
            'given_name' => ['title' => trans('cortex/contacts::common.given_name'), 'render' => $link, 'responsivePriority' => 0],
            'family_name' => ['title' => trans('cortex/contacts::common.family_name')],
            'email' => ['title' => trans('cortex/contacts::common.email')],
            'phone' => ['title' => trans('cortex/contacts::common.phone')],
            'country_code' => ['title' => trans('cortex/contacts::common.country'), 'render' => 'full.country_emoji+" "+data'],
            'language_code' => ['title' => trans('cortex/contacts::common.language'), 'visible' => false],
            'source' => ['title' => trans('cortex/contacts::common.source'), 'visible' => false],
            'method' => ['title' => trans('cortex/contacts::common.method'), 'visible' => false],
            'created_at' => ['title' => trans('cortex/contacts::common.created_at'), 'render' => "moment(data).format('YYYY-MM-DD, hh:mm:ss A')"],
            'updated_at' => ['title' => trans('cortex/contacts::common.updated_at'), 'render' => "moment(data).format('YYYY-MM-DD, hh:mm:ss A')"],
        ];
    }
387663
protected function getImportedCommits()
    {
        $environment = $this->getEnvironment();
        $slug = $environment['slug'];
        $branch = $environment['branch'];

        $imported = $this->api->get("/api/v1/$slug/$branch");
        if ($imported === false) {
            throw new Exception('Failed to reach API.');
        }

        return json_decode($imported, true);
    }
144624
public function getExportModes()
    {
        return array(
            'listAuthor' =>         ExportableField::LIST_OF
                                    + ExportableField::AUTHOR,
            'listAuthorObject' =>   ExportableField::LIST_OF
                                    + ExportableField::AUTHOR
                                    + ExportableField::OBJECT,
            'listAuthorToValue' =>  ExportableField::LIST_OF
                                    + ExportableField::AUTHOR
                                    + ExportableField::VALUE,
            'listValue' =>          ExportableField::LIST_OF
                                    + ExportableField::VALUE,
            'getPostdata' =>        ExportableField::POSTDATA
        );
    }
281831
public function getFilters(): array
    {
        return [
            new \Twig_SimpleFilter('toReadableSize', 'Cake\I18n\Number::toReadableSize'),
            new \Twig_SimpleFilter('fromReadableSize', 'Cake\I18n\Number::fromReadableSize'),
            new \Twig_SimpleFilter('toPercentage', 'Cake\I18n\Number::toPercentage'),
            new \Twig_SimpleFilter('number_format', 'Cake\I18n\Number::format'),
            new \Twig_SimpleFilter('formatDelta', 'Cake\I18n\Number::formatDelta'),
            new \Twig_SimpleFilter('currency', 'Cake\I18n\Number::currency'),
            new TwigFilter('toReadableSize', 'Cake\I18n\Number::toReadableSize'),
            new TwigFilter('fromReadableSize', 'Cake\I18n\Number::fromReadableSize'),
            new TwigFilter('toPercentage', 'Cake\I18n\Number::toPercentage'),
            new TwigFilter('format', 'Cake\I18n\Number::format'),
            new TwigFilter('formatDelta', 'Cake\I18n\Number::formatDelta'),
            new TwigFilter('currency', 'Cake\I18n\Number::currency'),
        ];
    }
216104
public function import_from_client() {
        if(!Permission::check('ADMIN')) {
            Security::permissionFailure($this);
            return;
        }
        
        $form=$this->ImportFromClientForm();
        if(Session::get('reloadOnImportDialogClose')) {
            Requirements::javascript(CB_DIR.'/javascript/CodeBank.ImportDialog.js');
            Session::clear('reloadOnImportDialogClose');
        }
        
        return $this->customise(array(
                                    'Content'=>' ',
                                    'Form'=>$form
                                ))->renderWith('CMSDialog');
    }
1122217
public function getAllModules()
	{
		$arrModules = array();

		$strQuery = 'SELECT m.id, m.name, t.name AS theme FROM tl_module m LEFT JOIN tl_theme t ON m.pid=t.id';

		if(\Input::get('table') == 'tl_module' && \Input::get('act') == 'edit')
		{
			$strQuery .= ' WHERE m.id != ?';
		}

		$strQuery .= ' ORDER BY t.name, m.name';

		$objModules = $this->Database->prepare($strQuery)->execute(\Input::get('id'));

		while ($objModules->next())
		{
			$arrModules[$objModules->theme][$objModules->id] = $objModules->name . ' (ID ' . $objModules->id . ')';
		}

		return $arrModules;
	}
1257574
public function setupLanguages(): Collection
    {
        return $this->coreModules()
            ->filter(static function (ModuleInterface $module) {
                return $module instanceof ModuleLanguageInterface && $module->isEnabledByDefault();
            })
            ->sort(static function (ModuleLanguageInterface $x, ModuleLanguageInterface $y) {
                return $x->locale()->endonymSortable() <=> $y->locale()->endonymSortable();
            });
    }
780519
public function getTwigExtras()
    {
        $list = array();
        foreach ($this->getManager()->getModules() as $module) {
            foreach ($module->getTwigExtras() as $extra) {
                $list[] = $extra;
            }
        }
        return $list;
    }
841279
public function initElements()
	{
		//create the element to select the import format
		$formatElt = tao_helpers_form_FormFactory::getElement('importHandler', 'Radiobox');
		$formatElt->setDescription(__('Choose import format'));
		$formatElt->addValidator(tao_helpers_form_FormFactory::getValidator('NotEmpty')); // should never happen anyway
		$importHandlerOptions= array();
		foreach ($this->importHandlers as $importHandler) {
			$importHandlerOptions[get_class($importHandler)] = $importHandler->getLabel();
		}
		$formatElt->setOptions($importHandlerOptions);
		

		$classUriElt = tao_helpers_form_FormFactory::getElement('classUri', 'Hidden');
//		$classUriElt->setValue($class->getUri());
		$this->form->addElement($classUriElt);

		$classUriElt = tao_helpers_form_FormFactory::getElement('id', 'Hidden');
		$this->form->addElement($classUriElt);
		
		$this->form->addElement($formatElt);

		if (!is_null($this->subForm)) {
//			load dynamically the method regarding the selected format
			$this->form->setElements(array_merge($this->form->getElements(), $this->subForm->getElements()));
			foreach ($this->subForm->getGroups() as $key => $group) {
				$this->form->createGroup($key,$group['title'],$group['elements'],$group['options']);
			}
		}
	}
122356
public function onGetNewsModules()
    {
        $modules = [];
        $records = $this->db->fetchAll("SELECT m.id, m.name, t.name AS theme FROM tl_module m LEFT JOIN tl_theme t ON m.pid=t.id WHERE m.type IN ('newslist', 'newsarchive') ORDER BY t.name, m.name");

        foreach ($records as $record) {
            $modules[$record['theme']][$record['id']] = \sprintf('%s (ID %s)', $record['name'], $record['id']);
        }

        return $modules;
    }