public function actionTranslate() { if (!Yii::app()->request->isPostRequest) { throw new CHttpException(403, 'Forbidden'); } if (empty($_POST) || !array_key_exists('form', $_POST) || !array_key_exists('text_id', $_POST['form']) || !array_key_exists('text_translate', $_POST['form']) || !is_array($_POST['form']['text_translate'])) { throw new CHttpException(403, 'Forbidden'); } $text = Translate::model()->findByPk($_POST['form']['text_id']); if ($text == NULL) { throw new CHttpException(403, 'Forbidden'); } $isChange = FALSE; $textTranslated = $_POST['form']['text_translate']; $langs = Langs::model()->findAll(); foreach ($langs as $lang) { if (array_key_exists($lang->alias, $textTranslated)) { $translateLang = TranslateLang::model()->find('translate__id=:translate__id AND lang=:lang', array(':translate__id' => $text->id, ':lang' => $lang->alias)); if ($translateLang == NULL) { $translateLang = new TranslateLang(); $translateLang->translate__id = $text->id; $translateLang->lang = $lang->alias; } if ($translateLang->translate != $textTranslated[$translateLang->lang]) { $isChange = TRUE; $translateLang->translate = $textTranslated[$translateLang->lang]; if (!$translateLang->save()) { Yii::trace('TRANSLATE EDIT SAVE FATAL ERROR. CODE#1: ' . var_export($translateLang->getErrors(), TRUE)); throw new CException('Ошибка сохранения перевода', E_USER_ERROR); } } } } if ((bool) $isChange) { if ($text->object_type == Translate::OBJECT_TYPE_STATIC_JAVASCRIPT) { Translate::fileRegenerateJavascript(); } else { Translate::fileRegenerate(); } } echo CJSON::encode(array('result' => $isChange, 'texts' => $textTranslated)); }
public static function langRestore($id) { $deleteLang = self::model()->findByPk($id); if ($deleteLang == NULL) { Yii::app()->user->setFlash('error', 'Удаленный язык не найден'); return FALSE; } if ((bool) $deleteLang->is_restored) { Yii::app()->user->setFlash('error', 'Удаленный язык уже восстановлен'); return FALSE; } $langExist = Langs::model()->findByPk($deleteLang->lang__id); if ($langExist != NULL) { Yii::app()->user->setFlash('error', 'Удаленный язык уже восстановлен'); return FALSE; } $langExist = Langs::model()->find('alias=:alias', array(':alias' => $deleteLang->alias)); if ($langExist != NULL) { Yii::app()->user->setFlash('error', 'Язык с псевдонимом удаленного языка уже создан'); return FALSE; } $restoreLang = new Langs(); $restoreLang->id = $deleteLang->lang__id; $restoreLang->alias = $deleteLang->alias; $restoreLang->is_default = $deleteLang->is_default; $restoreLang->is_enabled = $deleteLang->is_enabled; $restoreLang->attachment__id_active = $deleteLang->attachment__id_active; $restoreLang->attachment__id_nonactive = $deleteLang->attachment__id_nonactive; $restoreLangLang = new LangsLang(); $restoreLangLang->lang = Yii::app()->language; $restoreLangLang->langs__id = $deleteLang->lang__id; $restoreLangLang->title = $deleteLang->title; $deleteLang->is_restored = (int) TRUE; if (!$restoreLang->save()) { Yii::trace('RESTORING LANG FATAL ERROR. CODE#1: ' . var_export($restoreLang->getErrors(), TRUE)); throw new CException('Ошибка восстановления языка', E_USER_ERROR); } if (!$restoreLangLang->save()) { Yii::trace('RESTORING LANG FATAL ERROR. CODE#2: ' . var_export($restoreLangLang->getErrors(), TRUE)); throw new CException('Ошибка восстановления языка', E_USER_ERROR); } if (!$deleteLang->save()) { Yii::trace('RESTORING LANG FATAL ERROR. CODE#2: ' . var_export($deleteLang->getErrors(), TRUE)); throw new CException('Ошибка восстановления языка', E_USER_ERROR); } Yii::app()->user->setFlash('success', 'Язык успешно восстановлен'); return TRUE; }
case 'timestamp': $cfg['etc'][$item->module][$item->name] = strtotime($item->value); if ((int) $item->assign) { TPL::add(strtoupper($item->name), formatDateTime($cfg['etc'][$item->module][$item->name])); } break; default: $cfg['etc'][$item->module][$item->name] = $item->value; if ((int) $item->assign) { TPL::add(strtoupper($item->name), $cfg['etc'][$item->module][$item->name]); } break; } } } // Configure the template system if (defined('TEMPLATE_DIRPATH')) { TPL::$dirpath = TEMPLATE_DIRPATH; } else { TPL::$dirpath = './styles/' . $cfg['etc']['core']['site_style'] . '/'; } // Init the language system if (defined('IN_SYS') && IN_SYS) { Langs::$dirpath = './langs/' . $cfg['etc']['core']['site_lang'] . '/'; } else { Langs::$dirpath = './langs/' . $cfg['etc']['core']['acp_lang'] . '/'; } define('SITE_ROOT_PATH', $cfg['etc']['core']['SITE_ROOT_PATH']); TPL::add('HTTP_REFERER', $_SERVER['HTTP_REFERER']); // Init the modules Modules::load();
$info['author'] = '{L_UNKNOWN}'; } if (!isset($info['preview'])) { $preview = false; $info['preview'] = './styles/.acp/media/images/style_preview.png'; } if ($style == $cfg['etc']['core']['site_style']) { TPL::add('MODULE_CONFIG:SITE_STYLE_NAME', strlen($info['name']) > 24 ? mb_substr($info['name'], 0, 24, 'UTF-8') . '...' : $info['name']); } $f_styles[] = array('STYLE_CODENAME' => $style, 'STYLE_NAME' => $info['name'], 'STYLE_AUTHOR' => $info['author'], 'STYLE_AUTHOR_LINK' => $info['author_link'], 'STYLE_PREVIEW' => $info['preview'], 'conds' => array('STYLE_ACTIVE' => $style == $cfg['etc']['core']['site_style'] ? true : false, 'STYLE_AUTHOR_LINK' => isset($info['author_link']) ? true : false, 'STYLE_PREVIEW' => $preview)); } TPL::assignAsLoop('MODULE_CONFIG:SITE_STYLE', $f_styles); } } Modules::$modules->{$GLOBALS['MODULE_NAME']} = new module_core(); Langs::load('core'); if (defined('IN_SYS') && IN_SYS || defined('IN_ACP') && IN_ACP) { TPL::addTpl('header'); if (!isset($_GET['c'])) { TPL::addTpl('homepage'); } TPL::modify('self::addTpl(\'footer\');self::$output .= self::$loadedTpls[\'footer\'];'); } if (defined('IN_ACP') && IN_ACP) { Modules::$modules->menu->menu->acp->main->addItem('./acp.php', '{L_ACP_HOME}', array('ACTIVE' => !isset($_GET['c']))); Modules::$modules->menu->menu->acp->main->addItem('./', '{L_INDEX}', array('ACTIVE' => false)); if (permission('core', 'modules', 'show')) { Modules::$modules->menu->menu->acp->main->addItem('./acp.php?c=modules', '{L_MODULES}', array('ACTIVE' => isset($_GET['c']) && $_GET['c'] == 'modules')); } if (permission('core', 'config', 'edit')) { Modules::$modules->menu->menu->acp->main->addItem('./acp.php?c=config&module=core', '{L_SITE_CONFIG}', array('ACTIVE' => isset($_GET['c'], $_GET['module']) && $_GET['c'] == 'config' && $_GET['module'] == 'core'));
public static function fileRegenerateJavascript() { $path = Yii::app()->basePath . '/../js/translate/app_translate.js'; $directory = Yii::app()->basePath . '/../js/translate'; if (!file_exists($directory)) { if (!mkdir($directory, self::FILE_MODE, true)) { trigger_error('Не удалось создать директорию для хранения транслита. Проверьте права.', E_USER_ERROR); } @chmod($directory, self::FILE_MODE); } $langsModel = Langs::model()->findAll(); $result = array(); foreach ($langsModel as $langModel) { $translatesLang = TranslateLang::model()->findAll(array('condition' => 'lang=:lang AND text != ""', 'params' => array(':lang' => $langModel->alias), 'with' => array('translateModel' => array('joinType' => 'INNER JOIN', 'condition' => 'object_type=:object_type_javascript', 'params' => array(':object_type_javascript' => self::OBJECT_TYPE_STATIC_JAVASCRIPT))))); foreach ($translatesLang as $translate) { $result[$translate->lang . '_' . $translate->translateModel->text] = $translate->translate; } } $predata = 'var app_js_translate = new Object;' . "\n"; $body = ''; foreach ($result as $key => $dataset) { $body .= "\t" . "app_js_translate['" . $key . "']" . "\t" . '=' . "\t" . "'" . $dataset . "';" . "\n"; } file_put_contents($path, $predata . $body); }
} core::s('tpl')->assignLoop('GROUP_PERMISSIONS-' . $perm->module_codename . '-' . $perm->codename, $f_values); } core::s('tpl')->assignLoop('GROUP_PERMISSIONS', $f_permissions_modules); foreach ($f_permissions as $module_codename => $loop) { core::s('tpl')->assignLoop('GROUP_PERMISSIONS-' . $module_codename, $loop); } } } } Modules::$modules->auth = new module_auth(); TPL::modify(' if(/*!$_SESSION[\'logged\'] && */strpos(self::$output,\'{AUTH_CHALLENGE}\')) Modules::$modules->auth->getChallenge();'); if (!defined('IN_SYS') || !IN_SYS) { Langs::load('auth'); } if (defined('IN_AUTHBOX') && IN_AUTHBOX) { TPL::addTpl('authbox'); TPL::add('AUTHBOX_ACTION', './auth.php'); } /*$sql = new SQLObject(); $sql->exec(" INSERT INTO " . $sql->table('auth_users') . " (user_username,user_password_hash,user_email,AUTHKEY) VALUES ('Look Smog','" . hash('sha256','91a0a61d') . "','*****@*****.**','')"); $sql->last_insert_rowid();*/ if (defined('IN_AUTH') && IN_AUTH) { if (isset($_GET['logout'])) { Modules::$modules->auth->logout();