Skip to content
Snippets Groups Projects
Select Git revision
  • 3fb174cb7d12d3b5c354683ce808937fd5493381
  • main default protected
  • studip-rector
  • ci-opt
  • course-members-export-as-word
  • data-vue-app
  • pipeline-improvements
  • webpack-optimizations
  • rector
  • icon-renewal
  • http-client-and-factories
  • jsonapi-atomic-operations
  • vueify-messages
  • tic-2341
  • 135-translatable-study-areas
  • extensible-sorm-action-parameters
  • sorm-configuration-trait
  • jsonapi-mvv-routes
  • docblocks-for-magic-methods
19 results

I18n_textInput.php

Blame
  • Forked from Stud.IP / Stud.IP
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    I18n_textInput.php 1.43 KiB
    <?php
    
    namespace Studip\Forms;
    
    class I18n_textInput extends Input
    {
        public function render()
        {
            if (!isset($this->attributes['id'])) {
                $id = md5(uniqid());
                $this->attributes['id'] = $id;
            } else {
                $id = $this->attributes['id'];
            }
            if (!is_object($this->value)) {
                $value = $this->value;
            } else {
                $value = [\I18NString::getDefaultLanguage() => $this->value->original()];
                $value = json_encode(array_merge($value, $this->value->toArray()));
            }
            $template = $GLOBALS['template_factory']->open('forms/i18n_text_input');
            $template->title = $this->title;
            $template->name = $this->name;
            $template->value = $value;
            $template->id = $id;
            $template->required = $this->required;
            $template->attributes = $this->attributes;
            return $template->render();
        }
    
        public function getAllInputNames()
        {
            $all_names = [$this->getName()];
            if (is_object($this->value)) {
                foreach (\Config::get()->CONTENT_LANGUAGES as $lang_id => $language) {
                    if (\I18NString::getDefaultLanguage() !== $lang_id) {
                        $all_names[] = $this->getName() . '_i18n[' . $lang_id . ']';
                    }
                }
            }
            return $all_names;
        }
    
        public function getRequestValue()
        {
            return \Request::i18n($this->name);
        }
    }