Attached Files |
admin interface language changing.patch [^] (14,843 bytes) 2009-10-05 08:36
[Show Content]
Index: core/kernel/languages/phrases_cache.php
===================================================================
RCS file: /www/cvs/kernel4_dev/kernel4/languages/phrases_cache.php,v
retrieving revision 1.19.2.6
diff -u -r1.19.2.6 phrases_cache.php
--- core/kernel/languages/phrases_cache.php 24 Sep 2009 14:52:36 -0000 1.19.2.6
+++ core/kernel/languages/phrases_cache.php 5 Oct 2009 12:24:53 -0000
@@ -109,12 +109,17 @@
}
else {
if ($this->Application->IsAdmin()) {
- $id_field = $this->Application->getUnitOption('lang', 'IDField');
- $table_name = $this->Application->getUnitOption('lang', 'TableName');
- $sql = 'SELECT '.$id_field.'
- FROM '.$table_name.'
- WHERE AdminInterfaceLang = 1';
- $this->LanguageId = $this->Conn->GetOne($sql);
+ $language_id = $this->Application->Session->GetField('Language');
+
+ if (!$language_id) {
+ // when admin is not logged in
+ $sql = 'SELECT ' . $this->Application->getUnitOption('lang', 'IDField') . '
+ FROM ' . $this->Application->getUnitOption('lang', 'TableName') . '
+ WHERE AdminInterfaceLang = 1';
+ $language_id = $this->Conn->GetOne($sql);
+ }
+
+ $this->LanguageId = $language_id;
}
else {
$this->LanguageId = $this->Application->GetVar('m_lang');
Index: core/units/users/users_event_handler.php
===================================================================
RCS file: /www/cvs/kernel.X/core/units/users/users_event_handler.php,v
retrieving revision 1.87.2.33
diff -u -r1.87.2.33 users_event_handler.php
--- core/units/users/users_event_handler.php 24 Sep 2009 14:53:24 -0000 1.87.2.33
+++ core/units/users/users_event_handler.php 5 Oct 2009 12:48:04 -0000
@@ -248,6 +248,8 @@
$this->Application->SetVar('u.current_id', $user_id);
$this->Application->StoreVar('user_id', $user_id);
+ $this->Application->LoadPersistentVars();
+
if ($super_admin) {
$this->Application->StoreVar('super_admin', 1);
}
Index: custom/admin_templates/incs/in-portal.tpl
===================================================================
RCS file: /www/cvs/intexsys/custom/admin_templates/incs/Attic/in-portal.tpl,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 in-portal.tpl
--- custom/admin_templates/incs/in-portal.tpl 25 Sep 2009 11:11:46 -0000 1.1.2.1
+++ custom/admin_templates/incs/in-portal.tpl 5 Oct 2009 12:31:49 -0000
@@ -6,4 +6,45 @@
<inp2:m_DefineElement name="inp_checkbox_phrase">
<input type="checkbox" <inp2:m_param name="checked"/> id="<inp2:{$prefix}_InputName field="$field"/>_<inp2:m_param name="key"/>" value="<inp2:m_param name="key"/>" onclick="update_checkbox_options(/^<inp2:{$prefix}_InputName field="$field" as_preg="1"/>_([0-9A-Za-z-]+)/, '<inp2:{$prefix}_InputName field="$field"/>');"><label for="<inp2:{$prefix}_InputName field="$field"/>_<inp2:m_param name="key"/>"><inp2:m_phrase label="$option"/></label> <br/>
+</inp2:m_DefineElement>
+
+<inp2:m_DefineElement name="ml_selector" prefix="" field="Translated">
+ <inp2:m_if check="lang_IsMultiLanguage">
+ <td align="right" style="padding-right: 5px;">
+ <table width="100%" cellpadding="0" cellspacing="0">
+ <tr>
+ <td align="right">
+ <inp2:m_phrase name="la_fld_Language"/>:
+ <select name="language" onchange="submit_event('<inp2:m_param name='prefix'/>', 'OnPreSaveAndChangeLanguage');">
+ <inp2:m_DefineElement name="lang_elem">
+ <option value="<inp2:Field name='LanguageId'/>" <inp2:m_if check="SelectedLanguage" type="data">selected="selected"</inp2:m_if> ><inp2:Field name="LocalName" no_special='no_special' /></option>
+ </inp2:m_DefineElement>
+ <inp2:lang_PrintList render_as="lang_elem"/>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td align="right">
+ <inp2:m_if check="lang_IsPrimaryLanguage">
+ <input type="hidden" id="<inp2:{$prefix}_InputName field='$field'/>" name="<inp2:{$prefix}_InputName field='$field'/>" value="1">
+ <input type="checkbox" disabled id="_cb_<inp2:{$prefix}_InputName field='$field'/>" name="_cb_<inp2:{$prefix}_InputName field='$field'/>" checked="checked"/>
+ <inp2:m_else/>
+ <input type="hidden" id="<inp2:{$prefix}_InputName field='$field'/>" name="<inp2:{$prefix}_InputName field='$field'/>" value="<inp2:{$prefix}_Field field='$field'/>">
+ <input type="checkbox" id="_cb_<inp2:{$prefix}_InputName field='$field'/>" name="_cb_<inp2:{$prefix}_InputName field='$field'/>" <inp2:{$prefix}_Field field="$field" checked="checked"/> onchange="update_checkbox(this, document.getElementById('<inp2:{$prefix}_InputName field='$field'/>'));" />
+ </inp2:m_if>
+ <label for="_cb_<inp2:{$prefix}_InputName field='$field'/>"><inp2:m_Phrase label="la_Translated"/></label>
+ </td>
+ </tr>
+ <tr>
+ <td align="right" style="vertical-align: bottom; padding: 2px 0px 5px 2px;">
+ <span style="color: red">*</span> <span class="req-note"><inp2:m_Phrase name="la_text_RequiredFields"/></span>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <inp2:m_else/>
+ <td align="right" style="vertical-align: bottom; padding: 2px 5px 5px 2px;">
+ <span style="color: red">*</span> <span class="req-note"><inp2:m_Phrase name="la_text_RequiredFields"/></span>
+ </td>
+ </inp2:m_if>
</inp2:m_DefineElement>
\ No newline at end of file
Index: custom/install/install_schema.sql
===================================================================
RCS file: /www/cvs/intexsys/custom/install/install_schema.sql,v
retrieving revision 1.1.1.1.2.1
diff -u -r1.1.1.1.2.1 install_schema.sql
--- custom/install/install_schema.sql 25 Sep 2009 11:11:42 -0000 1.1.1.1.2.1
+++ custom/install/install_schema.sql 5 Oct 2009 13:15:06 -0000
@@ -40,3 +40,7 @@
# ===== SQLs above this line already on DEV ========================================================================================================
# place here only sql queries, that were executed on prod server !!!
+
+ALTER TABLE `int_PortalUser`
+ ADD `AdminLanguage` INT(11) NULL DEFAULT NULL,
+ ADD INDEX (`AdminLanguage`);
\ No newline at end of file
Index: custom/units/sections/e_user_eh.php
===================================================================
RCS file: /www/cvs/intexsys/custom/units/sections/e_user_eh.php,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 e_user_eh.php
--- custom/units/sections/e_user_eh.php 24 Sep 2009 15:23:23 -0000 1.1.1.1
+++ custom/units/sections/e_user_eh.php 5 Oct 2009 13:24:40 -0000
@@ -9,43 +9,6 @@
class EUserEventHandler extends UsersEventHandler {
/**
- * Allows to override standart permission mapping
- *
- */
- function mapPermissions()
- {
- parent::mapPermissions();
-
- $permissions = Array (
- # admin
- 'OnCustomEvent1' => Array ('self' => true),
-
- # front
- 'OnCustomEvent2' => Array ('self' => true),
- );
-
- $this->permMapping = array_merge($this->permMapping, $permissions);
- }
-
- /**
- * Permission exceptions
- *
- * @param kEvent $event
- */
- function CheckPermission(&$event)
- {
- $skip_permissions_check_events = Array (
- 'OnAnotherCustomEvent',
- );
-
- if ( in_array($event->Name, $skip_permissions_check_events) ) {
- return true;
- }
-
- return parent::CheckPermission($event);
- }
-
- /**
* Updates structure config
*
* @param kEvent $event
@@ -56,133 +19,56 @@
# 1. Regular Fields from /core/units/users/users_config.php
$fields = $this->Application->getUnitOption($event->Prefix, 'Fields'); #get regular fields
-// $fields['Status']['default'] = 1; #add/edit configuration (make default = 1)
+ $fields['AdminLanguage'] = Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Language ORDER BY PackName', 'option_key_field' => 'LanguageId', 'option_title_field' => 'LocalName',
+ 'default' => NULL
+ );
$this->Application->setUnitOption($event->Prefix, 'Fields', $fields); #save regular fields
-
- # 2. Virtual Fields from /core/units/users/users_config.php
- $virtual_fields = $this->Application->getUnitOption($event->Prefix, 'VirtualFields'); #get virtual fields
-// $virtual_fields['FullName']['default'] = ''; #add/edit configuration
- $this->Application->setUnitOption($event->Prefix, 'VirtualFields', $virtual_fields); #save virtual fields
}
/**
- * Sets custom query for the list
+ * Checks user data and logs it in if allowed
*
- * @param kEvent $event
- */
- function SetCustomQuery(&$event)
- {
- parent::SetCustomQuery($event);
-
- $object =& $event->getObject();
- /* @var $object kDBList */
-
- # identifying event based on special and setting filter
- if ( $event->Special == 'custom-special' ) {
-// $object->addFilter('primary_filter', '%1$s.Status = ' . STATUS_DISABLED);
- }
-
- # identifying event based not admin condition and setting filter
- if ( !$this->Application->IsAdmin() ) {
-// $object->addFilter('status_filter', '%1$s.Status = ' . STATUS_ACTIVE);
- }
- }
-
- /**
- * Before new item created
- *
- * @param kEvent $event
- */
- function OnBeforeItemCreate(&$event)
- {
- parent::OnBeforeItemCreate($event);
-
-
- }
-
- /**
- * Before existing item updated
+ * OnLogin is called from u:autoLoginUser and password is supplied
+ * OnLogin is called from u:OnAutoLoginUser supplying cookie with encoded username & password
*
* @param kEvent $event
*/
- function OnBeforeItemUpdate(&$event)
+ function OnLogin(&$event)
{
- parent::OnBeforeItemUpdate($event);
+ parent::OnLogin($event);
+ if ($event->status != erSUCCESS || !$this->Application->IsAdmin()) {
+ return ;
+ }
- }
-
- /**
- * Before item deleted
- *
- * @param kEvent $event
- */
- function OnBeforeItemDelete(&$event)
- {
- parent::OnBeforeItemDelete($event);
-
-
- }
-
- /**
- * After item loaded
- *
- * @param kEvent $event
- */
- function OnBeforeItemLoad(&$event)
- {
- parent::OnBeforeItemLoad($event);
-
-
- }
-
-
- /**
- * After new item created
- *
- * @param kEvent $event
- */
- function OnAfterItemCreate(&$event)
- {
- parent::OnAfterItemCreate($event);
-
-
- }
-
- /**
- * After existing item updated
- *
- * @param kEvent $event
- */
- function OnAfterItemUpdate(&$event)
- {
- parent::OnAfterItemUpdate($event);
-
-
- }
-
- /**
- * After item deleted
- *
- * @param kEvent $event
- */
- function OnAfterItemDelete(&$event)
- {
- parent::OnAfterItemDelete($event);
-
+ $is_root = $this->Application->RecallVar('user_id') == -1;
- }
+ $object =& $this->Application->recallObject('u.current');
+ /* @var $object kDBItem */
- /**
- * After item loaded
- *
- * @param kEvent $event
- */
- function OnAfterItemLoad(&$event)
- {
- parent::OnAfterItemLoad($event);
+ $user_language_id = $is_root ? $this->Application->RecallPersistentVar('AdminLanguage') : $object->GetDBField('AdminLanguage');
+ $sql = 'SELECT LanguageId, IF(LanguageId = ' . (int)$user_language_id . ', 2, AdminInterfaceLang) AS SortKey
+ FROM ' . TABLE_PREFIX . 'Language
+ WHERE Enabled = 1
+ HAVING SortKey <> 0
+ ORDER BY SortKey DESC';
+ $language_info = $this->Conn->GetRow($sql);
+ $language_id = $language_info && $language_info['LanguageId'] ? $language_info['LanguageId'] : $user_language_id;
+
+ if ($user_language_id != $language_id) {
+ // first admin login OR language was delelted or disabled
+ if ($is_root) {
+ $this->Application->StorePersistentVar('AdminLanguage', $language_id);
+ }
+ else {
+ $object->SetDBField('AdminLanguage', $language_id);
+ $object->Update();
+ }
+ }
+ $this->Application->Session->SetField('Language', $language_id);
}
-
}
\ No newline at end of file
Index: custom/units/sections/sections_config.php
===================================================================
RCS file: /www/cvs/intexsys/custom/units/sections/sections_config.php,v
retrieving revision 1.1.1.1.2.2
diff -u -r1.1.1.1.2.2 sections_config.php
--- custom/units/sections/sections_config.php 25 Sep 2009 11:28:14 -0000 1.1.1.1.2.2
+++ custom/units/sections/sections_config.php 5 Oct 2009 12:45:49 -0000
@@ -33,6 +33,11 @@
Array ('pseudo' => 'formsubs_EventHandler', 'class' => 'EFormSubmissionEventHandler', 'file' => 'e_form_submission_eh.php'),
Array ('pseudo' => 'formsubs_TagProcessor', 'class' => 'EFormSubmissionTagProcessor', 'file' => 'e_form_submission_tp.php'),
+
+ Array ('pseudo' => 'lang_EventHandler', 'class' => 'ELanguageEventHandler', 'file' => 'e_language_eh.php'),
+ Array ('pseudo' => 'lang_TagProcessor', 'class' => 'ELanguageTagProcessor', 'file' => 'e_language_tp.php'),
+
+ Array ('pseudo' => 'u_EventHandler', 'class' => 'EUserEventHandler', 'file' => 'e_user_eh.php'),
),
# Replace/substiture any admin default templates with custom ones
--- e_language_eh.php
+++ e_language_eh.php
@@ -0,0 +1,30 @@
+<?php
+
+ class ELanguageEventHandler extends LanguagesEventHandler {
+
+ function OnChangeLanguage(&$event)
+ {
+ if (!$this->Application->IsAdmin()) {
+ // language changing on Front-End stays without changes
+ parent::OnChangeLanguage($event);
+ }
+
+ // set new language for this session
+ $language_id = $this->Application->GetVar('language');
+ $this->Application->Session->SetField('Language', $language_id);
+
+ // remember last user language in administrative console
+ if ($this->Application->RecallVar('user_id') == -1) {
+ $this->Application->StorePersistentVar('AdminLanguage', $language_id);
+ }
+ else {
+ $object =& $this->Application->recallObject('u.current');
+ /* @var $object kDBItem */
+
+ $object->SetDBField('AdminLanguage', $language_id);
+ $object->Update();
+ }
+
+ $this->Application->SetVar('skip_last_template', 1);
+ }
+ }
--- e_language_tp.php
+++ e_language_tp.php
@@ -0,0 +1,16 @@
+<?php
+
+ class ELanguageTagProcessor extends LanguagesTagProcessor {
+
+ function SelectedLanguage($params)
+ {
+ if (array_key_exists('type', $params) && $params['type'] == 'data') {
+ // when using language selector on editing forms, that act as before
+ return parent::SelectedLanguage($params);
+ }
+
+ $object =& $this->getObject($params);
+
+ return $object->GetDBField('LanguageId') == $this->Application->Phrases->LanguageId;
+ }
+ }
admin login screen language incorrect_v2.patch [^] (2,850 bytes) 2009-10-12 05:46
[Show Content]
Index: kernel/application.php
===================================================================
--- kernel/application.php (revision 12677)
+++ kernel/application.php (working copy)
@@ -533,22 +533,26 @@
return $path;
}
- function GetDefaultLanguageId()
+ function GetDefaultLanguageId($init = false)
{
- static $language_id = 0;
+ static $language_info = Array ();
- if ($language_id > 0) {
- return $language_id;
+ $language_key = ($this->IsAdmin() && $init) || (count($language_info) == 1) ? 'Admin' : 'Front';
+
+ if (array_key_exists($language_key, $language_info) && $language_info[$language_key] > 0) {
+ return $language_info[$language_key];
}
$table = $this->getUnitOption('lang', 'TableName');
$id_field = $this->getUnitOption('lang', 'IDField');
- $sql = 'SELECT '.$id_field.'
+ $sql = 'SELECT '.$id_field.', IF(AdminInterfaceLang, "Admin", "Front") AS LanguageKey
FROM '.$table.'
- WHERE (PrimaryLang = 1) AND (Enabled = 1)';
- $language_id = $this->Conn->GetOne($sql);
+ WHERE (AdminInterfaceLang = 1 OR PrimaryLang = 1) AND (Enabled = 1)';
+ $language_info = $this->Conn->GetCol($sql, 'LanguageKey');
+ $language_id = $language_info && array_key_exists($language_key, $language_info) ? $language_info[$language_key] : false;
+
if (!$language_id && defined('IS_INSTALL') && IS_INSTALL) {
$language_id = 1;
}
Index: kernel/languages/phrases_cache.php
===================================================================
--- kernel/languages/phrases_cache.php (revision 12677)
+++ kernel/languages/phrases_cache.php (working copy)
@@ -109,12 +109,7 @@
}
else {
if ($this->Application->IsAdmin()) {
- $id_field = $this->Application->getUnitOption('lang', 'IDField');
- $table_name = $this->Application->getUnitOption('lang', 'TableName');
- $sql = 'SELECT '.$id_field.'
- FROM '.$table_name.'
- WHERE AdminInterfaceLang = 1';
- $this->LanguageId = $this->Conn->GetOne($sql);
+ $this->LanguageId = $this->Application->Session->GetField('Language');
}
else {
$this->LanguageId = $this->Application->GetVar('m_lang');
Index: kernel/session/inp_session.php
===================================================================
--- kernel/session/inp_session.php (revision 12677)
+++ kernel/session/inp_session.php (working copy)
@@ -115,7 +115,7 @@
{
$fields_hash = Array (
'PortalUserId' => $this->Application->IsAdmin() ? 0 : -2, // Guest
- 'Language' => $this->Application->GetDefaultLanguageId(),
+ 'Language' => $this->Application->GetDefaultLanguageId(true),
'Theme' => $this->Application->GetDefaultThemeId(),
'IpAddress' => $_SERVER['REMOTE_ADDR'], // getenv('REMOTE_ADDR') won't work on IIS, so use $_SERVER instead
'GroupId' => $this->Application->ConfigValue('User_GuestGroup'),
admin_interface_language_change_fix_v3.patch [^] (20,564 bytes) 2009-11-18 07:21
[Show Content]
Index: core/admin_templates/catalog/advanced_view.tpl
===================================================================
--- core/admin_templates/catalog/advanced_view.tpl (revision 12940)
+++ core/admin_templates/catalog/advanced_view.tpl (working copy)
@@ -29,7 +29,7 @@
menuMgr.timeout = 500;
menuMgr.flowOverFormElement = true;
- Request.progressText = '<inp2:m_phrase name="la_title_Loading" escape="1"/>';
+ Request.progressText = '<inp2:m_phrase name="la_title_Loading" no_editing="1" escape="1"/>';
Catalog.prototype.AfterInit = function() {
this.switchTab();
Index: core/admin_templates/catalog/catalog.tpl
===================================================================
--- core/admin_templates/catalog/catalog.tpl (revision 12940)
+++ core/admin_templates/catalog/catalog.tpl (working copy)
@@ -31,7 +31,7 @@
menuMgr.timeout = 500;
menuMgr.flowOverFormElement = true;
- Request.progressText = '<inp2:m_phrase name="la_title_Loading" escape="1"/>';
+ Request.progressText = '<inp2:m_phrase name="la_title_Loading" no_editing="1" escape="1"/>';
var $is_catalog = true;
var $Catalog = new Catalog('<inp2:m_Link template="#TEMPLATE_NAME#" m_cat_id="#CATEGORY_ID#" no_amp="1"/>', 'catalog_', 'Catalog');
$Catalog.TabByCategory = <inp2:m_if check="m_GetConfig" name="Catalog_PreselectModuleTab">true<inp2:m_else/>false</inp2:m_if>;
Index: core/admin_templates/catalog/item_selector/item_selector_toolbar.tpl
===================================================================
--- core/admin_templates/catalog/item_selector/item_selector_toolbar.tpl (revision 12940)
+++ core/admin_templates/catalog/item_selector/item_selector_toolbar.tpl (working copy)
@@ -8,7 +8,7 @@
menuMgr.timeout = 500;
menuMgr.flowOverFormElement = true;
- Request.progressText = '<inp2:m_phrase name="la_title_Loading" escape="1"/>';
+ Request.progressText = '<inp2:m_phrase name="la_title_Loading" no_editing="1" escape="1"/>';
var a_toolbar = new ToolBar();
a_toolbar.AddButton( new ToolBarButton('select', '<inp2:m_phrase label="la_ToolTip_Save" escape="1"/>', function() {
Index: core/admin_templates/catalog_tab.tpl
===================================================================
--- core/admin_templates/catalog_tab.tpl (revision 12940)
+++ core/admin_templates/catalog_tab.tpl (working copy)
@@ -55,17 +55,17 @@
<inp2:m_if check="m_Get" name="type" equals_to="item_selector">
<a href="javascript:$Catalog.go_to_cat(<inp2:m_get name="c_id"/>, '<inp2:GetModulePrefix/>');" title="<inp2:m_Phrase name='la_alt_GoInside' html_escape='1'/>"><inp2:Field field="$field" grid="$grid" format="$format"/></a>
<inp2:m_else/>
- <a href="<inp2:ItemEditLink/>" title="<inp2:m_Phrase name='la_Text_Edit'/>" onclick="return direct_edit('<inp2:m_param name="PrefixSpecial"/>', this.href);"><inp2:Field field="$field" grid="$grid" format="$format"/></a>
+ <a href="<inp2:ItemEditLink/>" title="<inp2:m_Phrase name='la_Text_Edit' no_editing='1'/>" onclick="return direct_edit('<inp2:m_param name="PrefixSpecial"/>', this.href);"><inp2:Field field="$field" grid="$grid" format="$format"/></a>
</inp2:m_if>
<!--##<span class="small-statistics">(<inp2:SubCatCount/> / <inp2:ItemCount/>)</span>##-->
<inp2:m_if check="BrowseModeAvailable" pass_params="1">
- <a href="<inp2:PageBrowseLink/>" title="<inp2:m_Phrase name='la_alt_Browse' html_escape='1'/>"><img src="<inp2:m_TemplatesBase/>/img/ic_browse_mode.gif" width="8" height="7" alt="<inp2:m_Phrase name='la_alt_Browse' html_escape='1'/>" border="0"/></a>
+ <a href="<inp2:PageBrowseLink/>" title="<inp2:m_Phrase name='la_alt_Browse' no_editing='1'/>"><img src="<inp2:m_TemplatesBase/>/img/ic_browse_mode.gif" width="8" height="7" alt="<inp2:m_Phrase name='la_alt_Browse' html_escape='1'/>" border="0"/></a>
</inp2:m_if>
<inp2:m_if check="Field" field="IsSystem" db="db">
- <span class="field-required" title="<inp2:m_Phrase name='la_System'/>"> *</span>
+ <span class="field-required" title="<inp2:m_Phrase name='la_System' no_editing='1'/>"> *</span>
</inp2:m_if>
</inp2:m_DefineElement>
Index: core/admin_templates/categories/categories_edit_permissions.tpl
===================================================================
--- core/admin_templates/categories/categories_edit_permissions.tpl (revision 12940)
+++ core/admin_templates/categories/categories_edit_permissions.tpl (working copy)
@@ -14,7 +14,7 @@
<script type="text/javascript" src="js/ajax.js"></script>
<script type="text/javascript" src="js/catalog.js"></script>
<script type="text/javascript">
- Request.progressText = '<inp2:m_phrase name="la_title_Loading" escape="1"/>';
+ Request.progressText = '<inp2:m_phrase name="la_title_Loading" no_editing="1" escape="1"/>';
Catalog.prototype.AfterInit = function () {
Grids['g'].SelectFirst();
Index: core/admin_templates/incs/form_blocks.tpl
===================================================================
--- core/admin_templates/incs/form_blocks.tpl (revision 12940)
+++ core/admin_templates/incs/form_blocks.tpl (working copy)
@@ -597,23 +597,23 @@
<script type="text/javascript">
function CategorySelector() {
- }
+ }
CategorySelector.getField = function ($field) {
return jq('<inp2:{$prefix}_InputName field="#FIELD_NAME#"/>'.replace('#FIELD_NAME#', $field));
}
-
+
CategorySelector.disableCategory = function ($field) {
var $field_id = this.getField($field);
-
+
$('#' + $field_id).val('');
$('#' + $field_id + '_path, #' + $field_id + '_disable_link').hide();
}
-
+
$(document).ready(
function() {
var $field_id = CategorySelector.getField('<inp2:m_Param name="field" js_escape="1"/>');
-
+
$('#' + $field_id + '_disable_link').click(
function ($e) {
CategorySelector.disableCategory('<inp2:m_Param name="field" js_escape="1"/>');
@@ -1050,7 +1050,7 @@
<inp2:m_phrase name="la_fld_Language"/>:
<select name="language" onchange="submit_event('<inp2:m_param name='prefix'/>', 'OnPreSaveAndChangeLanguage');">
<inp2:m_DefineElement name="lang_elem">
- <option value="<inp2:Field name='LanguageId'/>" <inp2:m_if check="SelectedLanguage">selected="selected"</inp2:m_if> ><inp2:Field name="LocalName" no_special='no_special' /></option>
+ <option value="<inp2:Field name='LanguageId'/>" <inp2:m_if check="SelectedLanguage" type="data">selected="selected"</inp2:m_if> ><inp2:Field name="LocalName" no_special='no_special' /></option>
</inp2:m_DefineElement>
<inp2:lang_PrintList render_as="lang_elem"/>
</select>
Index: core/admin_templates/login.tpl
===================================================================
--- core/admin_templates/login.tpl (revision 12940)
+++ core/admin_templates/login.tpl (working copy)
@@ -149,7 +149,7 @@
</tr>
<tr>
<td colspan="2" align="center" style="padding: 5px 15px 10px 15px;">
- <input type="submit" name="login_button" value="<inp2:m_phrase name="la_Login"/>" class="kx-login-button roundbutton"></td>
+ <input type="submit" name="login_button" value="<inp2:m_phrase name='la_Login' no_editing='1'/>" class="kx-login-button roundbutton"></td>
</tr>
</table>
<inp2:m_else/>
Index: core/admin_templates/reviews/reviews.tpl
===================================================================
--- core/admin_templates/reviews/reviews.tpl (revision 12940)
+++ core/admin_templates/reviews/reviews.tpl (working copy)
@@ -21,7 +21,7 @@
menuMgr.timeout = 500;
menuMgr.flowOverFormElement = true;
- Request.progressText = '<inp2:m_phrase name="la_title_Loading" escape="1"/>';
+ Request.progressText = '<inp2:m_phrase name="la_title_Loading" no_editing="1" escape="1"/>';
Catalog.prototype.AfterInit = function() {
this.switchTab();
Index: core/admin_templates/users/user_edit_items.tpl
===================================================================
--- core/admin_templates/users/user_edit_items.tpl (revision 12940)
+++ core/admin_templates/users/user_edit_items.tpl (working copy)
@@ -21,7 +21,7 @@
menuMgr.timeout = 500;
menuMgr.flowOverFormElement = true;
- Request.progressText = '<inp2:m_phrase name="la_title_Loading" escape="1"/>';
+ Request.progressText = '<inp2:m_phrase name="la_title_Loading" no_editing="1" escape="1"/>';
Catalog.prototype.AfterInit = function () {
this.switchTab(); // refresh current item tab
Index: core/install/install_schema.sql
===================================================================
--- core/install/install_schema.sql (revision 12940)
+++ core/install/install_schema.sql (working copy)
@@ -250,6 +250,7 @@
PwResetConfirm varchar(255) DEFAULT NULL,
PwRequestTime int(11) unsigned DEFAULT NULL,
MinPwResetDelay int(11) NOT NULL DEFAULT '1800',
+ AdminLanguage int(11) DEFAULT NULL,
PRIMARY KEY (PortalUserId),
UNIQUE KEY ResourceId (ResourceId),
UNIQUE KEY Login (Login),
@@ -257,7 +258,8 @@
KEY `Status` (`Status`),
KEY Modified (Modified),
KEY dob (dob),
- KEY IsBanned (IsBanned)
+ KEY IsBanned (IsBanned),
+ KEY AdminLanguage (AdminLanguage)
);
CREATE TABLE PortalUserCustomData (
Index: core/install/upgrades.sql
===================================================================
--- core/install/upgrades.sql (revision 12940)
+++ core/install/upgrades.sql (working copy)
@@ -1612,4 +1612,8 @@
UPDATE Phrase SET Phrase = 'lu_btn_SendPassword' WHERE Phrase = 'LU_BTN_SENDPASSWORD';
ALTER TABLE Category DROP IsIndex;
-DELETE FROM Phrase WHERE Phrase IN ('la_CategoryIndex', 'la_Container', 'la_fld_IsIndex');
\ No newline at end of file
+DELETE FROM Phrase WHERE Phrase IN ('la_CategoryIndex', 'la_Container', 'la_fld_IsIndex');
+
+ALTER TABLE PortalUser
+ ADD AdminLanguage INT(11) NULL DEFAULT NULL,
+ ADD INDEX (AdminLanguage);
Index: core/kernel/application.php
===================================================================
--- core/kernel/application.php (revision 12940)
+++ core/kernel/application.php (working copy)
@@ -569,22 +569,30 @@
return $path;
}
- function GetDefaultLanguageId()
+ function GetDefaultLanguageId($init = false)
{
- static $language_id = 0;
+ static $language_info = null;
- if ($language_id > 0) {
- return $language_id;
+ if (!isset($language_info)) {
+ // cache primary language info first
+ $table = $this->getUnitOption('lang', 'TableName');
+ $id_field = $this->getUnitOption('lang', 'IDField');
+
+ $sql = 'SELECT ' . $id_field . ', IF(AdminInterfaceLang, "Admin", "Front") AS LanguageKey
+ FROM ' . $table . '
+ WHERE (AdminInterfaceLang = 1 OR PrimaryLang = 1) AND (Enabled = 1)';
+ $language_info = $this->Conn->GetCol($sql, 'LanguageKey');
}
- $table = $this->getUnitOption('lang', 'TableName');
- $id_field = $this->getUnitOption('lang', 'IDField');
+ $language_key = ($this->isAdmin && $init) || count($language_info) == 1 ? 'Admin' : 'Front';
- $sql = 'SELECT '.$id_field.'
- FROM '.$table.'
- WHERE (PrimaryLang = 1) AND (Enabled = 1)';
- $language_id = $this->Conn->GetOne($sql);
+ if (array_key_exists($language_key, $language_info) && $language_info[$language_key] > 0) {
+ // get from cache
+ return $language_info[$language_key];
+ }
+ $language_id = $language_info && array_key_exists($language_key, $language_info) ? $language_info[$language_key] : false;
+
if (!$language_id && defined('IS_INSTALL') && IS_INSTALL) {
$language_id = 1;
}
Index: core/kernel/languages/phrases_cache.php
===================================================================
--- core/kernel/languages/phrases_cache.php (revision 12940)
+++ core/kernel/languages/phrases_cache.php (working copy)
@@ -116,12 +116,7 @@
}
else {
if ($this->Application->isAdmin) {
- $id_field = $this->Application->getUnitOption('lang', 'IDField');
- $table_name = $this->Application->getUnitOption('lang', 'TableName');
- $sql = 'SELECT '.$id_field.'
- FROM '.$table_name.'
- WHERE AdminInterfaceLang = 1';
- $this->LanguageId = $this->Conn->GetOne($sql);
+ $this->LanguageId = $this->Application->Session->GetField('Language');
}
else {
$this->LanguageId = $this->Application->GetVar('m_lang');
@@ -256,7 +251,7 @@
function LoadPhraseByLabel($label, $original_label, $allow_editing = true, $use_admin = false)
{
- if (!$allow_editing && !array_key_exists($label, $this->_missingPhrases) && array_key_exists($label, $this->Phrases)) {
+ if (!$allow_editing && !$use_admin && !array_key_exists($label, $this->_missingPhrases) && array_key_exists($label, $this->Phrases)) {
// label is aready translated, but it's version without on the fly translation code is requested
$this->Phrases['NE:' . $label] = $this->Phrases[$label];
Index: core/kernel/nparser/nparser.php
===================================================================
--- core/kernel/nparser/nparser.php (revision 12940)
+++ core/kernel/nparser/nparser.php (working copy)
@@ -70,8 +70,8 @@
parent::kBase();
if (defined('EDITING_MODE') && (EDITING_MODE == EDITING_MODE_DESIGN)) {
- $this->_btnPhrases['design'] = $this->Application->Phrase('la_btn_EditDesign', false);
- $this->_btnPhrases['block'] = $this->Application->Phrase('la_btn_EditBlock', false);
+ $this->_btnPhrases['design'] = $this->Application->Phrase('la_btn_EditDesign', false, true);
+ $this->_btnPhrases['block'] = $this->Application->Phrase('la_btn_EditBlock', false, true);
}
}
Index: core/kernel/session/inp_session.php
===================================================================
--- core/kernel/session/inp_session.php (revision 12940)
+++ core/kernel/session/inp_session.php (working copy)
@@ -115,7 +115,7 @@
{
$fields_hash = Array (
'PortalUserId' => $this->Application->isAdmin ? 0 : -2, // Guest
- 'Language' => $this->Application->GetDefaultLanguageId(),
+ 'Language' => $this->Application->GetDefaultLanguageId(true),
'Theme' => $this->Application->GetDefaultThemeId(),
'IpAddress' => $_SERVER['REMOTE_ADDR'], // getenv('REMOTE_ADDR') won't work on IIS, so use $_SERVER instead
'GroupId' => $this->Application->ConfigValue('User_GuestGroup'),
Index: core/units/languages/languages_event_handler.php
===================================================================
--- core/units/languages/languages_event_handler.php (revision 12940)
+++ core/units/languages/languages_event_handler.php (working copy)
@@ -236,23 +236,40 @@
$object->SetDBField('CopyFromLanguage', $primary_lang_id);
}
-
function OnChangeLanguage(&$event)
{
- $this->Application->SetVar('m_lang', $this->Application->GetVar('language'));
+ $language_id = $this->Application->GetVar('language');
if ($this->Application->isAdmin) {
+ // set new language for this session
+ $this->Application->Session->SetField('Language', $language_id);
+
+ // remember last user language in administrative console
+ if ($this->Application->RecallVar('user_id') == -1) {
+ $this->Application->StorePersistentVar('AdminLanguage', $language_id);
+ }
+ else {
+ $object =& $this->Application->recallObject('u.current');
+ /* @var $object kDBItem */
+
+ $object->SetDBField('AdminLanguage', $language_id);
+ $object->Update();
+ }
+
// without this language change in admin will cause erase of last remembered tree section
$this->Application->SetVar('skip_last_template', 1);
}
- elseif (MOD_REWRITE) {
- $mod_rewrite_helper =& $this->Application->recallObject('ModRewriteHelper');
- /* @var $mod_rewrite_helper kModRewriteHelper */
+ else {
+ // changing language on Front-End
+ $this->Application->SetVar('m_lang', $language_id);
- $mod_rewrite_helper->removePages();
+ if (MOD_REWRITE) {
+ $mod_rewrite_helper =& $this->Application->recallObject('ModRewriteHelper');
+ /* @var $mod_rewrite_helper kModRewriteHelper */
+
+ $mod_rewrite_helper->removePages();
+ }
}
-
- //$this->Application->LinkVar('language', 'm_lang');
}
/**
Index: core/units/languages/languages_tag_processor.php
===================================================================
--- core/units/languages/languages_tag_processor.php (revision 12940)
+++ core/units/languages/languages_tag_processor.php (working copy)
@@ -84,7 +84,14 @@
function SelectedLanguage($params)
{
$object =& $this->getObject($params);
- return $object->GetDBField('LanguageId') == $this->Application->GetVar('m_lang');
+ /* @var $object kDBList */
+
+ if (array_key_exists('type', $params) && $params['type'] == 'data') {
+ // when using language selector on editing forms
+ return $object->GetDBField('LanguageId') == $this->Application->GetVar('m_lang');
+ }
+
+ return $object->GetDBField('LanguageId') == $this->Application->Phrases->LanguageId;
}
/**
Index: core/units/users/users_config.php
===================================================================
--- core/units/users/users_config.php (revision 12940)
+++ core/units/users/users_config.php (working copy)
@@ -390,6 +390,11 @@
'PwResetConfirm' => Array('type' => 'string','default' => null),
'PwRequestTime' => Array('type' => 'int','default' => null),
'MinPwResetDelay' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array(300 => '5', 600 => '10', 900 => '15', 1800 => '30', 3600 => '60'), 'use_phrases' => 0, 'not_null' => '1', 'default' => 1800),
+ 'AdminLanguage' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Language ORDER BY PackName', 'option_key_field' => 'LanguageId', 'option_title_field' => 'LocalName',
+ 'default' => NULL
+ ),
),
'VirtualFields' => Array(
Index: core/units/users/users_event_handler.php
===================================================================
--- core/units/users/users_event_handler.php (revision 12940)
+++ core/units/users/users_event_handler.php (working copy)
@@ -255,6 +255,7 @@
$this->Application->HandleEvent($dummy, 'session-log:OnStartSession');
$this->processLoginRedirect($event, $password);
+ $this->_processInterfaceLanguage($event);
return true;
}
else {
@@ -325,6 +326,7 @@
if (!$remember_login_cookie) {
$this->processLoginRedirect($event, $password);
+ $this->_processInterfaceLanguage($event);
}
}
else {
@@ -343,6 +345,46 @@
}
/**
+ * Sets correct interface language after sucessful login, based on user settings
+ *
+ * @param kEvent $event
+ */
+ function _processInterfaceLanguage(&$event)
+ {
+ if (($event->status != erSUCCESS) || !$this->Application->isAdmin) {
+ return ;
+ }
+
+ $is_root = $this->Application->RecallVar('user_id') == -1;
+
+ $object =& $this->Application->recallObject('u.current');
+ /* @var $object kDBItem */
+
+ $user_language_id = $is_root ? $this->Application->RecallPersistentVar('AdminLanguage') : $object->GetDBField('AdminLanguage');
+
+ $sql = 'SELECT LanguageId, IF(LanguageId = ' . (int)$user_language_id . ', 2, AdminInterfaceLang) AS SortKey
+ FROM ' . TABLE_PREFIX . 'Language
+ WHERE Enabled = 1
+ HAVING SortKey <> 0
+ ORDER BY SortKey DESC';
+ $language_info = $this->Conn->GetRow($sql);
+ $language_id = $language_info && $language_info['LanguageId'] ? $language_info['LanguageId'] : $user_language_id;
+
+ if ($user_language_id != $language_id) {
+ // first admin login OR language was delelted or disabled
+ if ($is_root) {
+ $this->Application->StorePersistentVar('AdminLanguage', $language_id);
+ }
+ else {
+ $object->SetDBField('AdminLanguage', $language_id);
+ $object->Update();
+ }
+ }
+
+ $this->Application->Session->SetField('Language', $language_id);
+ }
+
+ /**
* [HOOK] Auto-Logins Front-End user when "Remember Login" cookie is found
*
* @param kEvent $event
admin_interface_language_change_fix_v4.patch [^] (29,296 bytes) 2009-12-22 05:01
[Show Content]
Index: admin_templates/catalog/advanced_view.tpl
===================================================================
--- admin_templates/catalog/advanced_view.tpl (revision 12969)
+++ admin_templates/catalog/advanced_view.tpl (working copy)
@@ -29,7 +29,7 @@
menuMgr.timeout = 500;
menuMgr.flowOverFormElement = true;
- Request.progressText = '<inp2:m_phrase name="la_title_Loading" escape="1"/>';
+ Request.progressText = '<inp2:m_phrase name="la_title_Loading" no_editing="1" escape="1"/>';
Catalog.prototype.AfterInit = function() {
this.switchTab();
Index: admin_templates/catalog/catalog.tpl
===================================================================
--- admin_templates/catalog/catalog.tpl (revision 12969)
+++ admin_templates/catalog/catalog.tpl (working copy)
@@ -31,7 +31,7 @@
menuMgr.timeout = 500;
menuMgr.flowOverFormElement = true;
- Request.progressText = '<inp2:m_phrase name="la_title_Loading" escape="1"/>';
+ Request.progressText = '<inp2:m_phrase name="la_title_Loading" no_editing="1" escape="1"/>';
var $is_catalog = true;
var $Catalog = new Catalog('<inp2:m_Link template="#TEMPLATE_NAME#" m_cat_id="#CATEGORY_ID#" no_amp="1"/>', 'catalog_', 'Catalog');
$Catalog.TabByCategory = <inp2:m_if check="m_GetConfig" name="Catalog_PreselectModuleTab">true<inp2:m_else/>false</inp2:m_if>;
Index: admin_templates/catalog/item_selector/item_selector_toolbar.tpl
===================================================================
--- admin_templates/catalog/item_selector/item_selector_toolbar.tpl (revision 12969)
+++ admin_templates/catalog/item_selector/item_selector_toolbar.tpl (working copy)
@@ -8,7 +8,7 @@
menuMgr.timeout = 500;
menuMgr.flowOverFormElement = true;
- Request.progressText = '<inp2:m_phrase name="la_title_Loading" escape="1"/>';
+ Request.progressText = '<inp2:m_phrase name="la_title_Loading" no_editing="1" escape="1"/>';
var a_toolbar = new ToolBar();
a_toolbar.AddButton( new ToolBarButton('select', '<inp2:m_phrase label="la_ToolTip_Save" escape="1"/>', function() {
Index: admin_templates/catalog_tab.tpl
===================================================================
--- admin_templates/catalog_tab.tpl (revision 12969)
+++ admin_templates/catalog_tab.tpl (working copy)
@@ -55,17 +55,17 @@
<inp2:m_if check="m_Get" name="type" equals_to="item_selector">
<a href="javascript:$Catalog.go_to_cat(<inp2:m_get name="c_id"/>, '<inp2:GetModulePrefix/>');" title="<inp2:m_Phrase name='la_alt_GoInside' html_escape='1'/>"><inp2:Field field="$field" grid="$grid" format="$format"/></a>
<inp2:m_else/>
- <a href="<inp2:ItemEditLink/>" title="<inp2:m_Phrase name='la_Text_Edit'/>" onclick="return direct_edit('<inp2:m_param name="PrefixSpecial"/>', this.href);"><inp2:Field field="$field" grid="$grid" format="$format"/></a>
+ <a href="<inp2:ItemEditLink/>" title="<inp2:m_Phrase name='la_Text_Edit' no_editing='1'/>" onclick="return direct_edit('<inp2:m_param name="PrefixSpecial"/>', this.href);"><inp2:Field field="$field" grid="$grid" format="$format"/></a>
</inp2:m_if>
<!--##<span class="small-statistics">(<inp2:SubCatCount/> / <inp2:ItemCount/>)</span>##-->
<inp2:m_if check="BrowseModeAvailable" pass_params="1">
- <a href="<inp2:PageBrowseLink/>" title="<inp2:m_Phrase name='la_alt_Browse' html_escape='1'/>"><img src="<inp2:m_TemplatesBase/>/img/ic_browse_mode.gif" width="8" height="7" alt="<inp2:m_Phrase name='la_alt_Browse' html_escape='1'/>" border="0"/></a>
+ <a href="<inp2:PageBrowseLink/>" title="<inp2:m_Phrase name='la_alt_Browse' no_editing='1'/>"><img src="<inp2:m_TemplatesBase/>/img/ic_browse_mode.gif" width="8" height="7" alt="<inp2:m_Phrase name='la_alt_Browse' html_escape='1'/>" border="0"/></a>
</inp2:m_if>
<inp2:m_if check="Field" field="IsSystem" db="db">
- <span class="field-required" title="<inp2:m_Phrase name='la_System'/>"> *</span>
+ <span class="field-required" title="<inp2:m_Phrase name='la_System' no_editing='1'/>"> *</span>
</inp2:m_if>
</inp2:m_DefineElement>
Index: admin_templates/categories/categories_edit_permissions.tpl
===================================================================
--- admin_templates/categories/categories_edit_permissions.tpl (revision 12969)
+++ admin_templates/categories/categories_edit_permissions.tpl (working copy)
@@ -14,7 +14,7 @@
<script type="text/javascript" src="js/ajax.js"></script>
<script type="text/javascript" src="js/catalog.js"></script>
<script type="text/javascript">
- Request.progressText = '<inp2:m_phrase name="la_title_Loading" escape="1"/>';
+ Request.progressText = '<inp2:m_phrase name="la_title_Loading" no_editing="1" escape="1"/>';
Catalog.prototype.AfterInit = function () {
Grids['g'].SelectFirst();
Index: admin_templates/incs/form_blocks.tpl
===================================================================
--- admin_templates/incs/form_blocks.tpl (revision 12969)
+++ admin_templates/incs/form_blocks.tpl (working copy)
@@ -16,7 +16,7 @@
<!--## <tr<inp2:m_ifnot check="m_ModuleEnabled" module="Proj-Base"> style="background: url(<inp2:adm_SectionInfo section="$section" parent="$parent" info="module_path"/>img/logo_bg.gif) no-repeat top right; height: 55px;"</inp2:m_ifnot>> ##-->
<tr>
<td valign="top" class="admintitle" align="left" <!--##style="padding-top: 10px; padding-bottom: 10px;"##-->>
- <img width="46" height="46" src="<inp2:adm_SectionInfo section='$section' parent='$parent' info='module_path'/>img/icons/icon46_<inp2:adm_SectionInfo section='$section' parent='$parent' info='icon'/>.png" align="absmiddle" title="<inp2:adm_SectionInfo section='$section' parent='$parent' info='label'/>" alt=""/><inp2:adm_SectionInfo section="$section" parent="$parent" info="label"/>
+ <img width="46" height="46" src="<inp2:adm_SectionInfo section='$section' parent='$parent' info='module_path'/>img/icons/icon46_<inp2:adm_SectionInfo section='$section' parent='$parent' info='icon'/>.png" align="absmiddle" title="<inp2:adm_SectionInfo section='$section' parent='$parent' info='label' no_editing='1'/>" alt=""/><inp2:adm_SectionInfo section="$section" parent="$parent" info="label"/>
</td>
<inp2:m_if check="m_Param" name="additional_title_render_as">
<inp2:m_RenderElement name="$additional_title_render_as" pass_params="1"/>
@@ -597,23 +597,23 @@
<script type="text/javascript">
function CategorySelector() {
- }
+ }
CategorySelector.getField = function ($field) {
return jq('<inp2:{$prefix}_InputName field="#FIELD_NAME#"/>'.replace('#FIELD_NAME#', $field));
}
-
+
CategorySelector.disableCategory = function ($field) {
var $field_id = this.getField($field);
-
+
$('#' + $field_id).val('');
$('#' + $field_id + '_path, #' + $field_id + '_disable_link').hide();
}
-
+
$(document).ready(
function() {
var $field_id = CategorySelector.getField('<inp2:m_Param name="field" js_escape="1"/>');
-
+
$('#' + $field_id + '_disable_link').click(
function ($e) {
CategorySelector.disableCategory('<inp2:m_Param name="field" js_escape="1"/>');
@@ -1050,7 +1050,7 @@
<inp2:m_phrase name="la_fld_Language"/>:
<select name="language" onchange="submit_event('<inp2:m_param name='prefix'/>', 'OnPreSaveAndChangeLanguage');">
<inp2:m_DefineElement name="lang_elem">
- <option value="<inp2:Field name='LanguageId'/>" <inp2:m_if check="SelectedLanguage">selected="selected"</inp2:m_if> ><inp2:Field name="LocalName" no_special='no_special' /></option>
+ <option value="<inp2:Field name='LanguageId'/>" <inp2:m_if check="SelectedLanguage" type="data">selected="selected"</inp2:m_if> ><inp2:Field name="LocalName" no_special='no_special' /></option>
</inp2:m_DefineElement>
<inp2:lang_PrintList render_as="lang_elem"/>
</select>
Index: admin_templates/login.tpl
===================================================================
--- admin_templates/login.tpl (revision 12969)
+++ admin_templates/login.tpl (working copy)
@@ -149,7 +149,7 @@
</tr>
<tr>
<td colspan="2" align="center" style="padding: 5px 15px 10px 15px;">
- <input type="submit" name="login_button" value="<inp2:m_phrase name="la_Login"/>" class="kx-login-button roundbutton"></td>
+ <input type="submit" name="login_button" value="<inp2:m_phrase name='la_Login' no_editing='1'/>" class="kx-login-button roundbutton"></td>
</tr>
</table>
<inp2:m_else/>
Index: admin_templates/reviews/reviews.tpl
===================================================================
--- admin_templates/reviews/reviews.tpl (revision 12969)
+++ admin_templates/reviews/reviews.tpl (working copy)
@@ -21,7 +21,7 @@
menuMgr.timeout = 500;
menuMgr.flowOverFormElement = true;
- Request.progressText = '<inp2:m_phrase name="la_title_Loading" escape="1"/>';
+ Request.progressText = '<inp2:m_phrase name="la_title_Loading" no_editing="1" escape="1"/>';
Catalog.prototype.AfterInit = function() {
this.switchTab();
Index: admin_templates/users/user_edit_items.tpl
===================================================================
--- admin_templates/users/user_edit_items.tpl (revision 12969)
+++ admin_templates/users/user_edit_items.tpl (working copy)
@@ -21,7 +21,7 @@
menuMgr.timeout = 500;
menuMgr.flowOverFormElement = true;
- Request.progressText = '<inp2:m_phrase name="la_title_Loading" escape="1"/>';
+ Request.progressText = '<inp2:m_phrase name="la_title_Loading" no_editing="1" escape="1"/>';
Catalog.prototype.AfterInit = function () {
this.switchTab(); // refresh current item tab
Index: install/install_schema.sql
===================================================================
--- install/install_schema.sql (revision 12969)
+++ install/install_schema.sql (working copy)
@@ -250,6 +250,7 @@
PwResetConfirm varchar(255) DEFAULT NULL,
PwRequestTime int(11) unsigned DEFAULT NULL,
MinPwResetDelay int(11) NOT NULL DEFAULT '1800',
+ AdminLanguage int(11) DEFAULT NULL,
PRIMARY KEY (PortalUserId),
UNIQUE KEY ResourceId (ResourceId),
UNIQUE KEY Login (Login),
@@ -257,7 +258,8 @@
KEY `Status` (`Status`),
KEY Modified (Modified),
KEY dob (dob),
- KEY IsBanned (IsBanned)
+ KEY IsBanned (IsBanned),
+ KEY AdminLanguage (AdminLanguage)
);
CREATE TABLE PortalUserCustomData (
Index: install/upgrades.sql
===================================================================
--- install/upgrades.sql (revision 12969)
+++ install/upgrades.sql (working copy)
@@ -1612,6 +1612,8 @@
UPDATE Phrase SET Phrase = 'lu_btn_SendPassword' WHERE Phrase = 'LU_BTN_SENDPASSWORD';
ALTER TABLE Category DROP IsIndex;
-DELETE FROM Phrase WHERE Phrase IN ('la_CategoryIndex', 'la_Container', 'la_fld_IsIndex');
+DELETE FROM Phrase WHERE Phrase IN ('la_CategoryIndex', 'la_Container', 'la_fld_IsIndex', 'lu_text_Redirecting', 'lu_title_Redirecting', 'lu_zip_code');
-DELETE FROM Phrase WHERE Phrase IN ('lu_text_Redirecting', 'lu_title_Redirecting', 'lu_zip_code');
\ No newline at end of file
+ALTER TABLE PortalUser
+ ADD AdminLanguage INT(11) NULL DEFAULT NULL,
+ ADD INDEX (AdminLanguage);
Index: kernel/application.php
===================================================================
--- kernel/application.php (revision 12969)
+++ kernel/application.php (working copy)
@@ -245,13 +245,12 @@
{
static $instance = false;
- if(!$instance)
- {
- safeDefine('APPLICATION_CLASS', 'kApplication');
- $class = APPLICATION_CLASS;
+ if (!$instance) {
+ $class = defined('APPLICATION_CLASS') ? APPLICATION_CLASS : 'kApplication';
$instance = new $class();
$instance->Application =& $instance;
}
+
return $instance;
}
@@ -566,22 +565,30 @@
return $path;
}
- function GetDefaultLanguageId()
+ function GetDefaultLanguageId($init = false)
{
- static $language_id = 0;
+ static $language_info = null;
- if ($language_id > 0) {
- return $language_id;
+ if (!isset($language_info)) {
+ // cache primary language info first
+ $table = $this->getUnitOption('lang', 'TableName');
+ $id_field = $this->getUnitOption('lang', 'IDField');
+
+ $sql = 'SELECT ' . $id_field . ', IF(AdminInterfaceLang, "Admin", "Front") AS LanguageKey
+ FROM ' . $table . '
+ WHERE (AdminInterfaceLang = 1 OR PrimaryLang = 1) AND (Enabled = 1)';
+ $language_info = $this->Conn->GetCol($sql, 'LanguageKey');
}
- $table = $this->getUnitOption('lang', 'TableName');
- $id_field = $this->getUnitOption('lang', 'IDField');
+ $language_key = ($this->isAdmin && $init) || count($language_info) == 1 ? 'Admin' : 'Front';
- $sql = 'SELECT '.$id_field.'
- FROM '.$table.'
- WHERE (PrimaryLang = 1) AND (Enabled = 1)';
- $language_id = $this->Conn->GetOne($sql);
+ if (array_key_exists($language_key, $language_info) && $language_info[$language_key] > 0) {
+ // get from cache
+ return $language_info[$language_key];
+ }
+ $language_id = $language_info && array_key_exists($language_key, $language_info) ? $language_info[$language_key] : false;
+
if (!$language_id && defined('IS_INSTALL') && IS_INSTALL) {
$language_id = 1;
}
Index: kernel/db/db_event_handler.php
===================================================================
--- kernel/db/db_event_handler.php (revision 12969)
+++ kernel/db/db_event_handler.php (working copy)
@@ -533,18 +533,21 @@
}
trigger_error('ItemLoad Permission Failed for prefix ['.$event->getPrefixSpecial().'] in <strong>'.($status_checked ? 'checkItemStatus' : 'CheckPermission').'</strong>', E_USER_WARNING);
- $redirect_template = $this->Application->isAdmin ? 'no_permission' : $this->Application->ConfigValue('NoPermissionTemplate');
+ $template = $this->Application->isAdmin ? 'no_permission' : $this->Application->ConfigValue('NoPermissionTemplate');
- $redirect_params = $this->Application->HttpQuery->getRedirectParams(true);
- $redirect_params['no_amp'] = 1;
- $next_template = $this->Application->HREF('', '', $redirect_params);
+ if (MOD_REWRITE) {
+ $redirect_params = Array (
+ 'm_cat_id' => 0,
+ 'next_template' => urlencode('external:' . $_SERVER['REQUEST_URI']),
+ );
+ }
+ else {
+ $redirect_params = Array (
+ 'next_template' => $this->Application->GetVar('t'),
+ );
+ }
- $redirect_params = Array (
- 'm_cat_id' => 0,
- 'next_template' => urlencode('external:' . $next_template),
- );
-
- $this->Application->Redirect($redirect_template, $redirect_params);
+ $this->Application->Redirect($template, $redirect_params);
}
}
@@ -1351,7 +1354,7 @@
function OnEdit(&$event)
{
$this->setTempWindowID($event);
- $this->StoreSelectedIDs($event);
+ $ids = $this->StoreSelectedIDs($event);
$var_name = $event->getPrefixSpecial().'_file_pending_actions'.$this->Application->GetVar('m_wid');
$this->Application->RemoveVar($var_name);
@@ -1360,7 +1363,9 @@
$temp->PrepareEdit();
- $event->redirect = false;
+ $event->SetRedirectParam('m_lang', $this->Application->GetDefaultLanguageId());
+ $event->SetRedirectParam($event->getPrefixSpecial() . '_id', array_shift($ids));
+ $event->SetRedirectParam('pass', 'all,' . $event->getPrefixSpecial());
}
/**
@@ -1610,6 +1615,7 @@
{
$this->setTempWindowID($event);
$this->clearSelectedIDs($event);
+ $this->Application->SetVar('m_lang', $this->Application->GetDefaultLanguageId());
$object =& $event->getObject( Array('skip_autoload' => true) );
@@ -1617,10 +1623,10 @@
$temp->PrepareEdit();
$object->setID(0);
- $this->Application->SetVar($event->getPrefixSpecial().'_id',0);
+ $this->Application->SetVar($event->getPrefixSpecial().'_id', 0);
$this->Application->SetVar($event->getPrefixSpecial().'_PreCreate', 1);
- $event->redirect=false;
+ $event->redirect = false;
}
/**
Index: kernel/languages/phrases_cache.php
===================================================================
--- kernel/languages/phrases_cache.php (revision 12969)
+++ kernel/languages/phrases_cache.php (working copy)
@@ -116,12 +116,7 @@
}
else {
if ($this->Application->isAdmin) {
- $id_field = $this->Application->getUnitOption('lang', 'IDField');
- $table_name = $this->Application->getUnitOption('lang', 'TableName');
- $sql = 'SELECT '.$id_field.'
- FROM '.$table_name.'
- WHERE AdminInterfaceLang = 1';
- $this->LanguageId = $this->Conn->GetOne($sql);
+ $this->LanguageId = $this->Application->Session->GetField('Language');
}
else {
$this->LanguageId = $this->Application->GetVar('m_lang');
@@ -256,7 +251,7 @@
function LoadPhraseByLabel($label, $original_label, $allow_editing = true, $use_admin = false)
{
- if (!$allow_editing && !array_key_exists($label, $this->_missingPhrases) && array_key_exists($label, $this->Phrases)) {
+ if (!$allow_editing && !$use_admin && !array_key_exists($label, $this->_missingPhrases) && array_key_exists($label, $this->Phrases)) {
// label is aready translated, but it's version without on the fly translation code is requested
$this->Phrases['NE:' . $label] = $this->Phrases[$label];
Index: kernel/nparser/nparser.php
===================================================================
--- kernel/nparser/nparser.php (revision 12969)
+++ kernel/nparser/nparser.php (working copy)
@@ -77,8 +77,8 @@
parent::kBase();
if (defined('EDITING_MODE') && (EDITING_MODE == EDITING_MODE_DESIGN)) {
- $this->_btnPhrases['design'] = $this->Application->Phrase('la_btn_EditDesign', false);
- $this->_btnPhrases['block'] = $this->Application->Phrase('la_btn_EditBlock', false);
+ $this->_btnPhrases['design'] = $this->Application->Phrase('la_btn_EditDesign', false, true);
+ $this->_btnPhrases['block'] = $this->Application->Phrase('la_btn_EditBlock', false, true);
}
}
Index: kernel/processors/main_processor.php
===================================================================
--- kernel/processors/main_processor.php (revision 12969)
+++ kernel/processors/main_processor.php (working copy)
@@ -768,24 +768,20 @@
if ((!$this->Application->LoggedIn() || !$group_access) && $condition) {
$redirect_params = $this->Application->HttpQuery->getRedirectParams(true);
- $redirect_params['no_amp'] = 1;
if (array_key_exists('pass_category', $params)) {
$redirect_params['pass_category'] = $params['pass_category'];
}
- if (array_key_exists('expired', $redirect_params)) {
- $session_expired = $redirect_params['expired'];
- unset($redirect_params['expired']);
+ if (MOD_REWRITE) {
+ // TODO: $next_t variable is ignored !!! (is anyone using m_RequireLogin tag with "next_template" parameter?)
+ $redirect_params = Array (
+ 'm_cat_id' => 0,
+ 'next_template' => urlencode('external:' . $_SERVER['REQUEST_URI']),
+ );
}
-
- $redirect_params = Array (
- 'm_cat_id' => 0,
- 'next_template' => urlencode('external:' . $this->Application->HREF($t, '', $redirect_params)),
- );
-
- if (isset($session_expired) && $session_expired) {
- $redirect_params['expired'] = $session_expired;
+ else {
+ $redirect_params['next_template'] = $t;
}
if ( $this->Application->LoggedIn() && !$group_access) {
Index: kernel/session/inp_session.php
===================================================================
--- kernel/session/inp_session.php (revision 12969)
+++ kernel/session/inp_session.php (working copy)
@@ -115,7 +115,7 @@
{
$fields_hash = Array (
'PortalUserId' => $this->Application->isAdmin ? 0 : -2, // Guest
- 'Language' => $this->Application->GetDefaultLanguageId(),
+ 'Language' => $this->Application->GetDefaultLanguageId(true),
'Theme' => $this->Application->GetDefaultThemeId(),
'IpAddress' => $_SERVER['REMOTE_ADDR'], // getenv('REMOTE_ADDR') won't work on IIS, so use $_SERVER instead
'GroupId' => $this->Application->ConfigValue('User_GuestGroup'),
Index: units/admin/admin_tag_processor.php
===================================================================
--- units/admin/admin_tag_processor.php (revision 12969)
+++ units/admin/admin_tag_processor.php (working copy)
@@ -178,7 +178,9 @@
$res = $section_data['label'];
if ($section != 'in-portal:root') {
// don't translate label for top section, because it's already translated
- $res = $this->Application->Phrase($res);
+ $no_editing = array_key_exists('no_editing', $params) ? $params['no_editing'] : false;
+
+ $res = $this->Application->Phrase($res, !$no_editing);
}
break;
Index: units/helpers/permissions_helper.php
===================================================================
--- units/helpers/permissions_helper.php (revision 12969)
+++ units/helpers/permissions_helper.php (working copy)
@@ -264,14 +264,14 @@
function finalizePermissionCheck(&$event, $perm_status)
{
if (!$perm_status) {
- $t = $this->Application->GetVar('t');
- $redirect_params = $this->Application->HttpQuery->getRedirectParams(true);
- $redirect_params['no_amp'] = 1;
- $next_template = $this->Application->HREF($t, '', $redirect_params);
+ if (MOD_REWRITE) {
+// $event->SetRedirectParam('m_cat_id', 0); // category means nothing on admin login screen
+ $event->SetRedirectParam('next_template', urlencode('external:' . $_SERVER['REQUEST_URI']));
+ }
+ else {
+ $event->SetRedirectParam('next_template', $this->Application->GetVar('t'));
+ }
- $event->SetRedirectParam('m_cat_id', 0); // category means nothing on admin login screen
- $event->SetRedirectParam('next_template', urlencode('external:' . $next_template));
-
if ($this->Application->isDebugMode()) {
// for debugging purposes
$event->SetRedirectParam('section', $event->getSection());
@@ -462,10 +462,16 @@
$redirect_params['pass_category'] = $params['pass_cateogry'];
}
- $redirect_params = Array (
- 'm_cat_id' => 0, // category means nothing on admin login screen
- 'next_template' => urlencode('external:' . $this->Application->HREF($t, '', $redirect_params)),
- );
+ if (MOD_REWRITE) {
+ // TODO: $next_t variable is ignored !!! (is anyone using m_RequireLogin tag with "next_template" parameter?)
+ $redirect_params = Array (
+ 'm_cat_id' => 0, // category means nothing on admin login screen
+ 'next_template' => urlencode('external:' . $_SERVER['REQUEST_URI']),
+ );
+ }
+ else {
+ $redirect_params['next_template'] = $t;
+ }
if ($this->Application->isAdmin) {
$redirect_params['m_wid'] = ''; // remove wid, otherwise parent window may add wid to its name breaking all the frameset (for <a> targets)
Index: units/languages/languages_event_handler.php
===================================================================
--- units/languages/languages_event_handler.php (revision 12969)
+++ units/languages/languages_event_handler.php (working copy)
@@ -237,23 +237,43 @@
$object->SetDBField('CopyFromLanguage', $primary_lang_id);
}
-
function OnChangeLanguage(&$event)
{
- $this->Application->SetVar('m_lang', $this->Application->GetVar('language'));
+ $language_id = $this->Application->GetVar('language');
if ($this->Application->isAdmin) {
+ // admin data only
+ $this->Application->SetVar('m_lang', $language_id);
+
+ // set new language for this session (admin interface only)
+ $this->Application->Session->SetField('Language', $language_id);
+
+ // remember last user language in administrative console
+ if ($this->Application->RecallVar('user_id') == -1) {
+ $this->Application->StorePersistentVar('AdminLanguage', $language_id);
+ }
+ else {
+ $object =& $this->Application->recallObject('u.current');
+ /* @var $object kDBItem */
+
+ $object->SetDBField('AdminLanguage', $language_id);
+ $object->Update();
+ }
+
// without this language change in admin will cause erase of last remembered tree section
$this->Application->SetVar('skip_last_template', 1);
}
- elseif (MOD_REWRITE) {
- $mod_rewrite_helper =& $this->Application->recallObject('ModRewriteHelper');
- /* @var $mod_rewrite_helper kModRewriteHelper */
+ else {
+ // changing language on Front-End
+ $this->Application->SetVar('m_lang', $language_id);
- $mod_rewrite_helper->removePages();
+ if (MOD_REWRITE) {
+ $mod_rewrite_helper =& $this->Application->recallObject('ModRewriteHelper');
+ /* @var $mod_rewrite_helper kModRewriteHelper */
+
+ $mod_rewrite_helper->removePages();
+ }
}
-
- //$this->Application->LinkVar('language', 'm_lang');
}
/**
Index: units/languages/languages_tag_processor.php
===================================================================
--- units/languages/languages_tag_processor.php (revision 12969)
+++ units/languages/languages_tag_processor.php (working copy)
@@ -84,7 +84,14 @@
function SelectedLanguage($params)
{
$object =& $this->getObject($params);
- return $object->GetDBField('LanguageId') == $this->Application->GetVar('m_lang');
+ /* @var $object kDBList */
+
+ if (array_key_exists('type', $params) && $params['type'] == 'data') {
+ // when using language selector on editing forms
+ return $object->GetDBField('LanguageId') == $this->Application->GetVar('m_lang');
+ }
+
+ return $object->GetDBField('LanguageId') == $this->Application->Phrases->LanguageId;
}
/**
Index: units/users/users_config.php
===================================================================
--- units/users/users_config.php (revision 12969)
+++ units/users/users_config.php (working copy)
@@ -390,6 +390,11 @@
'PwResetConfirm' => Array('type' => 'string','default' => null),
'PwRequestTime' => Array('type' => 'int','default' => null),
'MinPwResetDelay' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array(300 => '5', 600 => '10', 900 => '15', 1800 => '30', 3600 => '60'), 'use_phrases' => 0, 'not_null' => '1', 'default' => 1800),
+ 'AdminLanguage' => Array (
+ 'type' => 'int',
+ 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM ' . TABLE_PREFIX . 'Language ORDER BY PackName', 'option_key_field' => 'LanguageId', 'option_title_field' => 'LocalName',
+ 'default' => NULL
+ ),
),
'VirtualFields' => Array(
Index: units/users/users_event_handler.php
===================================================================
--- units/users/users_event_handler.php (revision 12969)
+++ units/users/users_event_handler.php (working copy)
@@ -255,6 +255,7 @@
$this->Application->HandleEvent($dummy, 'session-log:OnStartSession');
$this->processLoginRedirect($event, $password);
+ $this->_processInterfaceLanguage($event);
return true;
}
else {
@@ -325,6 +326,7 @@
if (!$remember_login_cookie) {
$this->processLoginRedirect($event, $password);
+ $this->_processInterfaceLanguage($event);
}
}
else {
@@ -343,6 +345,47 @@
}
/**
+ * Sets correct interface language after sucessful login, based on user settings
+ *
+ * @param kEvent $event
+ */
+ function _processInterfaceLanguage(&$event)
+ {
+ if (($event->status != erSUCCESS) || !$this->Application->isAdmin) {
+ return ;
+ }
+
+ $is_root = $this->Application->RecallVar('user_id') == -1;
+
+ $object =& $this->Application->recallObject('u.current');
+ /* @var $object kDBItem */
+
+ $user_language_id = $is_root ? $this->Application->RecallPersistentVar('AdminLanguage') : $object->GetDBField('AdminLanguage');
+
+ $sql = 'SELECT LanguageId, IF(LanguageId = ' . (int)$user_language_id . ', 2, AdminInterfaceLang) AS SortKey
+ FROM ' . TABLE_PREFIX . 'Language
+ WHERE Enabled = 1
+ HAVING SortKey <> 0
+ ORDER BY SortKey DESC';
+ $language_info = $this->Conn->GetRow($sql);
+ $language_id = $language_info && $language_info['LanguageId'] ? $language_info['LanguageId'] : $user_language_id;
+
+ if ($user_language_id != $language_id) {
+ // first admin login OR language was delelted or disabled
+ if ($is_root) {
+ $this->Application->StorePersistentVar('AdminLanguage', $language_id);
+ }
+ else {
+ $object->SetDBField('AdminLanguage', $language_id);
+ $object->Update();
+ }
+ }
+
+ $event->SetRedirectParam('m_lang', $language_id); // data
+ $this->Application->Session->SetField('Language', $language_id); // interface
+ }
+
+ /**
* [HOOK] Auto-Logins Front-End user when "Remember Login" cookie is found
*
* @param kEvent $event
|