Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sun, Feb 2, 8:36 PM

in-portal

Index: trunk/kernel/units/phrases/phrases_config.php
===================================================================
--- trunk/kernel/units/phrases/phrases_config.php (revision 2209)
+++ trunk/kernel/units/phrases/phrases_config.php (revision 2210)
@@ -1,128 +1,130 @@
<?php
$config = Array(
'Prefix' => 'phrases',
'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'PhrasesEventHandler','file'=>'phrases_event_handler.php','build_event'=>'OnBuild'),
'TagProcessorClass' => Array('class'=>'kDBTagProcessor','file'=>'','build_event'=>'OnBuild'),
'AutoLoad' => true,
'Hooks' => Array(
Array(
'Mode' => hBEFORE,
'Conditional' => false,
'HookToPrefix' => 'phrases',
'HookToSpecial' => '',
'HookToEvent' => Array('OnCreate'),
'DoPrefix' => 'phrases',
'DoSpecial' => '',
'DoEvent' => 'OnBeforePhraseCreate',
),
Array(
'Mode' => hAFTER,
'Conditional' => false,
'HookToPrefix' => 'phrases',
'HookToSpecial' => '',
'HookToEvent' => Array('OnBeforeItemCreate','OnBeforeItemUpdate'),
'DoPrefix' => 'phrases',
'DoSpecial' => '',
'DoEvent' => 'OnSetLastUpdated',
),
),
'QueryString' => Array(
1 => 'id',
2 => 'page',
3 => 'event',
4 => 'label',
),
'IDField' => 'PhraseId',
'StatusField' => Array('Type'),
'TitleField' => 'Phrase',
'TitlePresets' => Array(
'default' => Array( 'new_status_labels' => Array('phrases'=>'!la_title_Adding_Phrase!'),
'edit_status_labels' => Array('phrases'=>'!la_title_Editing_Phrase!'),
'new_titlefield' => Array('phrases'=>'!la_title_New_Phrase!'),
),
'phrase_edit' => Array('prefixes' => Array('phrases'), 'format' => '#phrases_status# - #phrases_titlefield#'),
),
'FilterMenu' => Array(
'Groups' => Array(
Array('mode' => 'AND', 'filters' => Array('show_front','show_admin','show_both'), 'type' => WHERE_FILTER),
),
'Filters' => Array(
'show_front' => Array('label' =>'la_PhraseType_Front', 'on_sql' => '', 'off_sql' => '%1$s.PhraseType != 0' ),
'show_admin' => Array('label' => 'la_PhraseType_Admin', 'on_sql' => '', 'off_sql' => '%1$s.PhraseType != 1' ),
'show_both' => Array('label' => 'la_PhraseType_Both', 'on_sql' => '', 'off_sql' => '%1$s.PhraseType != 2' ),
)
),
'TableName' => TABLE_PREFIX.'Phrase',
'CalculatedFields' => Array(
'' => Array(
- 'PrimaryValue' => 'pri.Translation',
+ 'PrimaryTranslation' => 'pri.Translation',
),
),
'ListSQLs' => Array( ''=>' SELECT %1$s.* %2$s
FROM %1$s
LEFT JOIN '.TABLE_PREFIX.'Phrase pri ON (%1$s.Phrase = pri.Phrase) AND (pri.LanguageId = 1)'),
- 'ItemSQLs' => Array( ''=>'SELECT *, 0 AS PrimaryValue FROM %s',),
+ 'ItemSQLs' => Array( ''=>' SELECT %1$s.* %2$s
+ FROM %1$s
+ LEFT JOIN '.TABLE_PREFIX.'Phrase pri ON (%1$s.Phrase = pri.Phrase) AND (pri.LanguageId = 1)',),
'ListSortings' => Array(
'' => Array(
'Sorting' => Array('Phrase' => 'asc'),
)
),
'ForeignKey' => 'LanguageId',
'ParentTableKey' => 'LanguageId',
'ParentPrefix' => 'lang',
'AutoDelete' => true,
'AutoClone' => true,
'Fields' => Array(
'Phrase' => Array('type' => 'string','required'=>1,'unique'=>Array('LanguageId'),'not_null' => '1','default' => ''),
'Translation' => Array('type' => 'string','required'=>1,'not_null' => '1','default' => ''),
'PhraseType' => Array('type' => 'int','required'=>1,'formatter'=>'kOptionsFormatter','options'=>Array(0=>'la_PhraseType_Front',1=>'la_PhraseType_Admin',2=>'la_PhraseType_Both'), 'use_phrases' => 1, 'not_null' => '1','default' => '0'),
'PhraseId' => Array('type' => 'int','not_null' => '1','default' => ''),
'LanguageId' => Array('type' => 'int','not_null' => '1','default' => '0'),
'LastChanged' => Array('type' => 'int', 'formatter'=>'kDateFormatter', 'not_null' => '1','default' => '0'),
'LastChangeIP' => Array('type' => 'string','not_null' => '1','default' => ''),
'Module' => Array('type' => 'string', 'formatter'=>'kOptionsFormatter', 'options'=>Array(''=>''), 'options_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'Modules ORDER BY Name', 'option_key_field'=>'Name', 'option_title_field'=>'Name', 'not_null' => '1','default' => 'In-Portal'),
),
'VirtualFields' => Array(
- 'PrimaryValue' => Array(),
+ 'PrimaryTranslation' => Array(),
'LangFile' => Array(),
'ImportOverwrite' => Array(),
),
'Grids' => Array(
'Default' => Array(
'Icons' => Array('default'=>'icon16_language_var.gif'),
'Fields' => Array(
'Phrase' => Array( 'title'=>'la_col_Label', 'data_block' => 'grid_checkbox_td'),
'Translation' => Array( 'title'=>'la_col_Translation' ),
- 'PrimaryValue' => Array( 'title'=>'la_col_PrimaryValue' ),
+ 'PrimaryTranslation' => Array( 'title'=>'la_col_PrimaryValue' ),
'PhraseType' => Array( 'title'=>'la_col_PhraseType' ),
'LastChanged' => Array( 'title'=>'la_col_LastChanged' ),
'Module' => Array( 'title'=>'la_col_Module' ),
),
),
),
);
?>
\ No newline at end of file
Property changes on: trunk/kernel/units/phrases/phrases_config.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.3
\ No newline at end of property
+1.4
\ No newline at end of property
Index: trunk/kernel/units/phrases/phrases_event_handler.php
===================================================================
--- trunk/kernel/units/phrases/phrases_event_handler.php (revision 2209)
+++ trunk/kernel/units/phrases/phrases_event_handler.php (revision 2210)
@@ -1,69 +1,75 @@
<?php
class PhrasesEventHandler extends InpDBEventHandler
{
/**
* Forces new label in case if issued from get link
*
* @param kEvent $event
*/
function OnNew(&$event)
{
parent::OnNew($event);
$label = $this->Application->GetVar('phrases_label');
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject( $label ? Array('live_table'=>true) : Array() );
if($label)
{
$object->SetDBField('Phrase',$label);
$object->SetDBField('LanguageId', $this->Application->GetVar('m_lang') );
$object->SetDBField('PhraseType',1);
+
+ $primary_language = $this->Application->GetDefaultLanguageId();
+ $live_table = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $sql = 'SELECT Translation FROM %s WHERE Phrase = %s';
+ $primary_value = $this->Conn->GetOne( sprintf($sql, $live_table, $this->Conn->qstr($label) ) );
+ $object->SetDBField('PrimaryTranslation', $primary_value);
}
$last_module = $this->Application->GetVar('last_module');
if($last_module) $object->SetDBField('Module', $last_module);
}
/**
* Forces create to use live table
*
* @param kEvent $event
*/
function OnBeforePhraseCreate(&$event)
{
$edit_direct = $this->Application->GetVar($event->Prefix.'_label');
if($edit_direct)
{
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject();
if( $this->Application->GetVar('m_lang') != $this->Application->GetVar('lang_id') )
{
$object->SwitchToLive();
}
}
}
/**
* Save phrase change date & ip translation was made from
*
* @param kEvent $event
*/
function OnSetLastUpdated(&$event)
{
$object =& $event->getObject();
$prev_translation = $this->Conn->GetOne('SELECT Translation FROM '.$object->TableName.' WHERE '.$object->IDField.' = '.(int)$object->GetId() );
if( $prev_translation != $object->GetDBField('Translation') )
{
$ip_address = getenv('HTTP_X_FORWARDED_FOR') ? getenv('HTTP_X_FORWARDED_FOR') : getenv('REMOTE_ADDR');
$object->SetDBField('LastChanged_date', time() );
$object->SetDBField('LastChanged_time', time() );
$object->SetDBField('LastChangeIP', $ip_address);
}
setcookie('last_module', $object->GetDBField('Module') );
}
}
?>
\ No newline at end of file
Property changes on: trunk/kernel/units/phrases/phrases_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.3
\ No newline at end of property
+1.4
\ No newline at end of property
Index: trunk/kernel/admin_templates/regional/phrases_edit.tpl
===================================================================
--- trunk/kernel/admin_templates/regional/phrases_edit.tpl (revision 2209)
+++ trunk/kernel/admin_templates/regional/phrases_edit.tpl (revision 2210)
@@ -1,71 +1,72 @@
<inp2:m_set nobody="yes"/>
<inp2:m_include t="incs/header"/>
<body topmargin="0" leftmargin="8" marginheight="0" marginwidth="8" bgcolor="#FFFFFF">
<inp2:m_ParseBlock name="section_header" icon="icon46_conf_regional" title="!la_title_RegionalSettings!"/>
<inp2:m_ParseBlock name="blue_bar" prefix="phrases" title_preset="phrase_edit" module="in-portal" icon="icon46_conf_regional"/>
<!-- ToolBar --->
<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<td>
<script type="text/javascript">
a_toolbar = new ToolBar();
a_toolbar.AddButton( new ToolBarButton('select', '<inp2:m_phrase label="la_ToolTip_Save"/>', function() {
submit_event('phrases','<inp2:phrases_SaveEvent/>');
}
) );
a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel"/>', function() {
submit_event('phrases','OnCancel');
}
) );
// a_toolbar.AddButton( new ToolBarSeparator('sep1') );
//
// a_toolbar.AddButton( new ToolBarButton('prev', '<inp2:m_phrase label="la_ToolTip_Prev"/>', function() {
// go_to_id('phrases', '<inp2:phrases_PrevId/>');
// }
// ) );
// a_toolbar.AddButton( new ToolBarButton('next', '<inp2:m_phrase label="la_ToolTip_Next"/>', function() {
// go_to_id('phrases', '<inp2:phrases_NextId/>');
// }
// ) );
a_toolbar.Render();
// <inp2:m_if prefix="phrases" function="IsSingle"/>
// a_toolbar.HideButton('prev');
// a_toolbar.HideButton('next');
// a_toolbar.HideButton('sep1');
// <inp2:m_else/>
// <inp2:m_if prefix="phrases" function="IsLast"/>
// a_toolbar.DisableButton('next');
// <inp2:m_endif/>
// <inp2:m_if prefix="phrases" function="IsFirst"/>
// a_toolbar.DisableButton('prev');
// <inp2:m_endif/>
// <inp2:m_endif/>
</script>
</td>
</tr>
</tbody>
</table>
<inp2:phrases_SaveWarning name="grid_save_warning"/>
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder">
<inp2:m_ParseBlock name="subsection" title="!la_section_General!"/>
<input type="hidden" id="phrases_label" name="phrases_label" value="<inp2:m_get name="phrases_label"/>">
<inp2:m_ParseBlock name="inp_edit_hidden" prefix="phrases" field="LanguageId"/>
+ <inp2:m_ParseBlock name="inp_label" prefix="phrases" field="PrimaryTranslation" title="!la_fld_PrimaryTranslation!"/>
<inp2:m_ParseBlock name="inp_edit_box" prefix="phrases" field="Phrase" title="!la_fld_Phrase!" size="60"/>
<inp2:m_ParseBlock name="inp_edit_box" prefix="phrases" field="Translation" title="!la_fld_Translation!" size="60"/>
<inp2:m_ParseBlock name="inp_edit_radio" prefix="phrases" field="PhraseType" title="!la_fld_PhraseType!"/>
<inp2:m_ParseBlock name="inp_edit_options" prefix="phrases" field="Module" title="!la_fld_Module!"/>
</table>
<inp2:m_include t="incs/footer"/>
\ No newline at end of file
Property changes on: trunk/kernel/admin_templates/regional/phrases_edit.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.3
\ No newline at end of property
+1.4
\ No newline at end of property
Index: trunk/core/units/phrases/phrases_config.php
===================================================================
--- trunk/core/units/phrases/phrases_config.php (revision 2209)
+++ trunk/core/units/phrases/phrases_config.php (revision 2210)
@@ -1,128 +1,130 @@
<?php
$config = Array(
'Prefix' => 'phrases',
'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'PhrasesEventHandler','file'=>'phrases_event_handler.php','build_event'=>'OnBuild'),
'TagProcessorClass' => Array('class'=>'kDBTagProcessor','file'=>'','build_event'=>'OnBuild'),
'AutoLoad' => true,
'Hooks' => Array(
Array(
'Mode' => hBEFORE,
'Conditional' => false,
'HookToPrefix' => 'phrases',
'HookToSpecial' => '',
'HookToEvent' => Array('OnCreate'),
'DoPrefix' => 'phrases',
'DoSpecial' => '',
'DoEvent' => 'OnBeforePhraseCreate',
),
Array(
'Mode' => hAFTER,
'Conditional' => false,
'HookToPrefix' => 'phrases',
'HookToSpecial' => '',
'HookToEvent' => Array('OnBeforeItemCreate','OnBeforeItemUpdate'),
'DoPrefix' => 'phrases',
'DoSpecial' => '',
'DoEvent' => 'OnSetLastUpdated',
),
),
'QueryString' => Array(
1 => 'id',
2 => 'page',
3 => 'event',
4 => 'label',
),
'IDField' => 'PhraseId',
'StatusField' => Array('Type'),
'TitleField' => 'Phrase',
'TitlePresets' => Array(
'default' => Array( 'new_status_labels' => Array('phrases'=>'!la_title_Adding_Phrase!'),
'edit_status_labels' => Array('phrases'=>'!la_title_Editing_Phrase!'),
'new_titlefield' => Array('phrases'=>'!la_title_New_Phrase!'),
),
'phrase_edit' => Array('prefixes' => Array('phrases'), 'format' => '#phrases_status# - #phrases_titlefield#'),
),
'FilterMenu' => Array(
'Groups' => Array(
Array('mode' => 'AND', 'filters' => Array('show_front','show_admin','show_both'), 'type' => WHERE_FILTER),
),
'Filters' => Array(
'show_front' => Array('label' =>'la_PhraseType_Front', 'on_sql' => '', 'off_sql' => '%1$s.PhraseType != 0' ),
'show_admin' => Array('label' => 'la_PhraseType_Admin', 'on_sql' => '', 'off_sql' => '%1$s.PhraseType != 1' ),
'show_both' => Array('label' => 'la_PhraseType_Both', 'on_sql' => '', 'off_sql' => '%1$s.PhraseType != 2' ),
)
),
'TableName' => TABLE_PREFIX.'Phrase',
'CalculatedFields' => Array(
'' => Array(
- 'PrimaryValue' => 'pri.Translation',
+ 'PrimaryTranslation' => 'pri.Translation',
),
),
'ListSQLs' => Array( ''=>' SELECT %1$s.* %2$s
FROM %1$s
LEFT JOIN '.TABLE_PREFIX.'Phrase pri ON (%1$s.Phrase = pri.Phrase) AND (pri.LanguageId = 1)'),
- 'ItemSQLs' => Array( ''=>'SELECT *, 0 AS PrimaryValue FROM %s',),
+ 'ItemSQLs' => Array( ''=>' SELECT %1$s.* %2$s
+ FROM %1$s
+ LEFT JOIN '.TABLE_PREFIX.'Phrase pri ON (%1$s.Phrase = pri.Phrase) AND (pri.LanguageId = 1)',),
'ListSortings' => Array(
'' => Array(
'Sorting' => Array('Phrase' => 'asc'),
)
),
'ForeignKey' => 'LanguageId',
'ParentTableKey' => 'LanguageId',
'ParentPrefix' => 'lang',
'AutoDelete' => true,
'AutoClone' => true,
'Fields' => Array(
'Phrase' => Array('type' => 'string','required'=>1,'unique'=>Array('LanguageId'),'not_null' => '1','default' => ''),
'Translation' => Array('type' => 'string','required'=>1,'not_null' => '1','default' => ''),
'PhraseType' => Array('type' => 'int','required'=>1,'formatter'=>'kOptionsFormatter','options'=>Array(0=>'la_PhraseType_Front',1=>'la_PhraseType_Admin',2=>'la_PhraseType_Both'), 'use_phrases' => 1, 'not_null' => '1','default' => '0'),
'PhraseId' => Array('type' => 'int','not_null' => '1','default' => ''),
'LanguageId' => Array('type' => 'int','not_null' => '1','default' => '0'),
'LastChanged' => Array('type' => 'int', 'formatter'=>'kDateFormatter', 'not_null' => '1','default' => '0'),
'LastChangeIP' => Array('type' => 'string','not_null' => '1','default' => ''),
'Module' => Array('type' => 'string', 'formatter'=>'kOptionsFormatter', 'options'=>Array(''=>''), 'options_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'Modules ORDER BY Name', 'option_key_field'=>'Name', 'option_title_field'=>'Name', 'not_null' => '1','default' => 'In-Portal'),
),
'VirtualFields' => Array(
- 'PrimaryValue' => Array(),
+ 'PrimaryTranslation' => Array(),
'LangFile' => Array(),
'ImportOverwrite' => Array(),
),
'Grids' => Array(
'Default' => Array(
'Icons' => Array('default'=>'icon16_language_var.gif'),
'Fields' => Array(
'Phrase' => Array( 'title'=>'la_col_Label', 'data_block' => 'grid_checkbox_td'),
'Translation' => Array( 'title'=>'la_col_Translation' ),
- 'PrimaryValue' => Array( 'title'=>'la_col_PrimaryValue' ),
+ 'PrimaryTranslation' => Array( 'title'=>'la_col_PrimaryValue' ),
'PhraseType' => Array( 'title'=>'la_col_PhraseType' ),
'LastChanged' => Array( 'title'=>'la_col_LastChanged' ),
'Module' => Array( 'title'=>'la_col_Module' ),
),
),
),
);
?>
\ No newline at end of file
Property changes on: trunk/core/units/phrases/phrases_config.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.3
\ No newline at end of property
+1.4
\ No newline at end of property
Index: trunk/core/units/phrases/phrases_event_handler.php
===================================================================
--- trunk/core/units/phrases/phrases_event_handler.php (revision 2209)
+++ trunk/core/units/phrases/phrases_event_handler.php (revision 2210)
@@ -1,69 +1,75 @@
<?php
class PhrasesEventHandler extends InpDBEventHandler
{
/**
* Forces new label in case if issued from get link
*
* @param kEvent $event
*/
function OnNew(&$event)
{
parent::OnNew($event);
$label = $this->Application->GetVar('phrases_label');
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject( $label ? Array('live_table'=>true) : Array() );
if($label)
{
$object->SetDBField('Phrase',$label);
$object->SetDBField('LanguageId', $this->Application->GetVar('m_lang') );
$object->SetDBField('PhraseType',1);
+
+ $primary_language = $this->Application->GetDefaultLanguageId();
+ $live_table = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $sql = 'SELECT Translation FROM %s WHERE Phrase = %s';
+ $primary_value = $this->Conn->GetOne( sprintf($sql, $live_table, $this->Conn->qstr($label) ) );
+ $object->SetDBField('PrimaryTranslation', $primary_value);
}
$last_module = $this->Application->GetVar('last_module');
if($last_module) $object->SetDBField('Module', $last_module);
}
/**
* Forces create to use live table
*
* @param kEvent $event
*/
function OnBeforePhraseCreate(&$event)
{
$edit_direct = $this->Application->GetVar($event->Prefix.'_label');
if($edit_direct)
{
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject();
if( $this->Application->GetVar('m_lang') != $this->Application->GetVar('lang_id') )
{
$object->SwitchToLive();
}
}
}
/**
* Save phrase change date & ip translation was made from
*
* @param kEvent $event
*/
function OnSetLastUpdated(&$event)
{
$object =& $event->getObject();
$prev_translation = $this->Conn->GetOne('SELECT Translation FROM '.$object->TableName.' WHERE '.$object->IDField.' = '.(int)$object->GetId() );
if( $prev_translation != $object->GetDBField('Translation') )
{
$ip_address = getenv('HTTP_X_FORWARDED_FOR') ? getenv('HTTP_X_FORWARDED_FOR') : getenv('REMOTE_ADDR');
$object->SetDBField('LastChanged_date', time() );
$object->SetDBField('LastChanged_time', time() );
$object->SetDBField('LastChangeIP', $ip_address);
}
setcookie('last_module', $object->GetDBField('Module') );
}
}
?>
\ No newline at end of file
Property changes on: trunk/core/units/phrases/phrases_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.3
\ No newline at end of property
+1.4
\ No newline at end of property

Event Timeline