1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-05-26 12:48:11 +03:00

Вынос js и текстовок из шаблона fix #628

This commit is contained in:
Mzhelskiy Maxim 2015-03-21 11:42:26 +07:00
parent 9b02891c0c
commit a4e1c21f82
3 changed files with 67 additions and 11 deletions

View file

@ -33,10 +33,12 @@ class HookMain extends Hook
public function RegisterHook()
{
$this->AddHook('init_action', 'InitAction', __CLASS__, 1000);
$this->AddHook('start_action', 'StartAction', __CLASS__, 1000);
}
/**
* Обработка хука инициализации экшенов
* Может выполняться несколько раз, например, при использовании внутренних реврайтов
*/
public function InitAction()
{
@ -47,15 +49,76 @@ class HookMain extends Hook
if (!$oUserCurrent and Config::Get('general.close') and !Router::CheckIsCurrentAction((array)Config::Get('general.close_exceptions'))) {
Router::Action('auth/login');
}
$this->LoadDefaultJsVar();
}
/**
* Обработка запуска экшена
* Выполняется всегда только один раз
*/
public function StartAction()
{
$this->LoadDefaultJsVarAndLang();
/**
* Запуск обработки сборщика
*/
$this->Ls_SenderRun();
}
public function LoadDefaultJsVar()
/**
* Загрузка необходимых переменных и текстовок в шаблон
*/
public function LoadDefaultJsVarAndLang()
{
$this->Viewer_AssignJs('recaptcha.site_key', Config::Get('module.validate.recaptcha.site_key'));
/**
* Загружаем JS переменные
*/
$this->Viewer_AssignJs(
array(
'recaptcha.site_key' => Config::Get('module.validate.recaptcha.site_key'),
'comment_max_tree' => Config::Get('module.comment.max_tree'),
'comment_show_form' => Config::Get('module.comment.show_form'),
'topic_max_blog_count' => Config::Get('module.topic.max_blog_count'),
'block_stream_show_tip' => Config::Get('block.stream.show_tip'),
'poll_max_answers' => Config::Get('module.poll.max_answers'),
)
);
/**
* Загрузка языковых текстовок
*/
$this->Lang_AddLangJs(array(
'comments.comments_declension',
'comments.unsubscribe',
'comments.subscribe',
'comments.folding.unfold',
'comments.folding.fold',
'comments.folding.unfold_all',
'comments.folding.fold_all',
'poll.notices.error_answers_max',
'blog.blog',
'favourite.add',
'favourite.remove',
'field.geo.select_city',
'field.geo.select_region',
'blog.add.fields.type.note_open',
'blog.add.fields.type.note_close',
'common.success.add',
'common.success.remove',
'pagination.notices.first',
'pagination.notices.last',
'user.actions.unfollow',
'user.actions.follow',
'user.friends.status.added',
'user.friends.status.notfriends',
'user.friends.status.pending',
'user.friends.status.rejected',
'user.friends.status.sent',
'user.friends.status.linked',
'blog.blocks.navigator.blog',
'user.settings.profile.notices.error_max_userfields',
'common.remove_confirm',
'more.empty',
'validate.tags.count'
));
}
}

View file

@ -24,14 +24,7 @@
{block 'layout_head' append}
<script>
ls.lang.load({json var = $aLangJs});
ls.lang.load({lang_load name="comments.comments_declension, comments.unsubscribe, comments.subscribe, comments.folding.unfold, comments.folding.fold, comments.folding.unfold_all, comments.folding.fold_all, poll.notices.error_answers_max, blog.blog, favourite.add, favourite.remove, field.geo.select_city, field.geo.select_region, blog.add.fields.type.note_open, blog.add.fields.type.note_close, common.success.add, common.success.remove, pagination.notices.first, pagination.notices.last, user.actions.unfollow, user.actions.follow, user.friends.status.added, user.friends.status.notfriends, user.friends.status.pending, user.friends.status.rejected, user.friends.status.sent, user.friends.status.linked, blog.blocks.navigator.blog, user.settings.profile.notices.error_max_userfields, common.remove_confirm, more.empty, validate.tags.count"});
ls.registry.set({json var = $aVarsJs});
ls.registry.set('comment_max_tree', {json var=Config::Get('module.comment.max_tree')});
ls.registry.set('comment_show_form', {json var=Config::Get('module.comment.show_form')});
ls.registry.set('topic_max_blog_count', {json var=Config::Get('module.topic.max_blog_count')});
ls.registry.set('block_stream_show_tip', {json var=Config::Get('block.stream.show_tip')});
ls.registry.set('poll_max_answers', {json var=Config::Get('module.poll.max_answers')});
</script>
{**

@ -1 +1 @@
Subproject commit 02a946708f5b3c0c21c0f7b251a2e26b2ea9f057
Subproject commit ef81022a97a3233a18d6a87c08c5160daab3c007