HEX
Server: Apache/2.4.6 (CentOS) mpm-itk/2.4.7-04 mod_fcgid/2.3.9 PHP/5.4.16
System: Linux dvm.vladweb.ru 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: region-gk.ru (1016)
PHP: 7.3.33
Disabled: NONE
Upload Files
File: /home/temp/yarusvl.ru/adminx/core/TranslationAdmin.php
<?php

require_once('api/Mgc.php');

class TranslationAdmin extends Mgc {

    /*Работа с переводом*/
    public function fetch() {
        $languages = $this->languages->get_languages();

        $locked_theme = is_file('tpls/'.$this->settings->theme.'/locked');
        $this->design->assign('locked_theme', $locked_theme);

        $translation = new stdClass();
        if(!$locked_theme && $this->request->method('post')) {
            // id - предыдущий label
            $translation->id    = $this->request->post('id');
            $translation->label = trim($this->request->post('label'));
            $translation->label = str_replace(" ", '_', $translation->label);
            
            if($languages){
                foreach($languages as $lang) {
                    $field = 'lang_'.$lang->label;
                    $translation->$field = $this->request->post($field);
                    $translation->values[$lang->id] = $translation->$field;
                }
            }
            $exist = $this->translations->get_translation($translation->label);
            
            $mgc_object = $this->{$translation->label};
            if(!$translation->label) {
                $this->design->assign('message_error', 'label_empty');
            } elseif($exist && $exist->id!=$translation->id) {
                $this->design->assign('message_error', 'label_exists');
            } elseif(!empty($mgc_object)) {
                $this->design->assign('message_error', 'label_is_class');
            } else {
                /*Добавление/Удаление перевода*/
                if(empty($translation->id)) {
                    $this->design->assign('message_success', 'added');
                } else {
                    $this->design->assign('message_success', 'updated');
                }
                $translation->id = $this->translations->update_translation($translation->id, $translation);
            }
        } else {
            $translation->id = $this->request->get('id');
            if(!empty($translation->id)) {
                $translation = $this->translations->get_translation($translation->id);
            }
        }
        
        $this->design->assign('languages', $languages);
        
        $this->design->assign('translation', $translation);
        return $this->design->fetch('translation.tpl');
    }
    
}