Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sun, Feb 2, 9:55 PM

in-portal

Index: trunk/kernel/units/translator/translator_event_handler.php
===================================================================
--- trunk/kernel/units/translator/translator_event_handler.php (revision 1794)
+++ trunk/kernel/units/translator/translator_event_handler.php (revision 1795)
@@ -1,83 +1,106 @@
<?php
class TranslatorEventHandler extends InpDBEventHandler
{
function OnLoad(&$event)
{
- $obj_prefix = $this->Application->GetVar($event->getPrefixSpecial(true).'_prefix');
+ $field = $this->Application->GetVar($event->getPrefixSpecial(true).'_field');
+
+ if( strpos($field,':') !== false )
+ {
+ list($obj_prefix,$field) = explode(':', $field);
+ }
+ else
+ {
+ $obj_prefix = $this->Application->GetVar($event->getPrefixSpecial(true).'_prefix');
+ }
+
$object = $this->Application->recallObject($obj_prefix);
/*$items_info = $this->Application->GetVar( $obj_prefix );
if($items_info) $field_values = array_shift($items_info);
$object->SetFieldsFromHash($field_values);
$object->Update();*/
- $field = $this->Application->GetVar($event->getPrefixSpecial(true).'_field');
+
$translator =& $this->Application->recallObject($event->getPrefixSpecial());
$def_lang = $this->Application->GetDefaultLanguageId();
$current_lang = $translator->GetDBField('Language');
if (!$current_lang) $current_lang = $this->Application->RecallVar('trans_lang');
if (!$current_lang) $current_lang = $this->Application->GetVar('m_lang');
/*if ($current_lang == $def_lang) {
$current_lang = $def_lang + 1;
}*/
$this->Application->StoreVar('trans_lang', $current_lang); //remember translation language for user friendlyness
$translator->SetId(1);
$translator->SetDBField('Original', $object->GetDBField('l'.$this->Application->GetVar('m_lang').'_'.$field));
$translator->SetDBField('Language', $current_lang);
$translator->SetDBField('SwitchLanguage', $current_lang);
$translator->SetDBField('Translation', $object->GetDBField('l'.$current_lang.'_'.$field));
$cur_lang = $this->Application->recallObject('lang.current');
$cur_lang->Load($current_lang);
$translator->SetDBField('Charset', $cur_lang->GetDBField('Charset'));
$event->redirect = false;
}
function OnSaveAndClose(&$event)
{
$event->CallSubEvent('OnPreSave');
- $this->finalizePopup($event, '', 'in-commerce/products/products_edit');
+
+ // 2. RESTORE SAVED LAST TEMPLATE AS LAST PARAM FOR FINILIZE_POPUP
+ $return_template = $this->Application->RecallVar('return_template');
+ $this->finalizePopup($event, '', $return_template);
}
function OnPreSave(&$event)
{
$translator =& $this->Application->recallObject($event->getPrefixSpecial());
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if($items_info) $field_values = array_shift($items_info);
$translator->SetFieldsFromHash($field_values);
- $object = $this->Application->recallObject($this->Application->GetVar($event->getPrefixSpecial(true).'_prefix'));
$field = $this->Application->GetVar($event->getPrefixSpecial(true).'_field');
+ if( strpos($field,':') !== false )
+ {
+ list($obj_prefix,$field) = explode(':', $field);
+ }
+ else
+ {
+ $obj_prefix = $this->Application->GetVar($event->getPrefixSpecial(true).'_prefix');
+ }
+
+ $object = $this->Application->recallObject($obj_prefix);
+
$lang = $translator->GetDBField('Language');
$object->Fields['l'.$lang.'_'.$field] = Array();
$object->SetDBField('l'.$lang.'_'.$field, $translator->GetDBField('Translation'));
$this->RemoveRequiredFields($object);
$object->Update();
}
function OnChangeLanguage(&$event)
{
$event->CallSubEvent('OnPreSave');
$translator =& $this->Application->recallObject($event->getPrefixSpecial());
$translator->SetDBField('Language', $translator->GetDBField('SwitchLanguage'));
$event->CallSubEvent('OnLoad');
$event->redirect = false;
}
}
?>
\ No newline at end of file
Property changes on: trunk/kernel/units/translator/translator_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property
Index: trunk/kernel/units/custom_values/custom_values_config.php
===================================================================
--- trunk/kernel/units/custom_values/custom_values_config.php (revision 1794)
+++ trunk/kernel/units/custom_values/custom_values_config.php (revision 1795)
@@ -1,104 +1,102 @@
<?php
$config = Array(
'Prefix' => 'cv',
'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'CustomValuesEventHandler','file'=>'custom_value_event_handler.php','build_event'=>'OnBuild'),
'TagProcessorClass' => Array('class'=>'kDBTagProcessor','file'=>'','build_event'=>'OnBuild'),
'AutoLoad' => true,
'Hooks' => Array(
Array(
'Mode' => hAFTER,
'Conditional' => true,
'HookToPrefix' => 'p',
'HookToSpecial' => '',
'HookToEvent' => Array( 'onPreSave' ),
'DoPrefix' => '',
'DoSpecial' => '',
'DoEvent' => 'onPreSave',
),
Array(
'Mode' => hAFTER,
'Conditional' => true,
'HookToPrefix' => 'p',
'HookToSpecial' => '',
'HookToEvent' => Array( 'onPreSave' ),
'DoPrefix' => '',
'DoSpecial' => 'general',
'DoEvent' => 'onPreSave',
),
),
'QueryString' => Array(
1 => 'id',
2 => 'page',
3 => 'event',
),
'TableName' => TABLE_PREFIX.'CustomMetaData',
'IDField' => 'CustomDataId', // in this case idfield doesn't exit in destination table
'ParentTableKey'=> 'ResourceId',
'ForeignKey' => 'ResourceId',
'ParentPrefix' => 'p',
'AutoDelete' => true,
'AutoClone' => true,
'CalculatedFields' => Array(
'' => Array (
'FieldName' => 'cf.FieldName',
'Prompt' => 'cf.Prompt',
'CustomFieldId' => 'cf.CustomFieldId',
'ElementType' => 'cf.ElementType',
'ValueList' => 'cf.ValueList',
'DisplayOrder' => 'cf.DisplayOrder',
'CustomDataId' => '%1$s.CustomDataId',
- 'Value' => '%1$s.Value',
-
)
),
'ListSQLs' => Array(
- '' => ' SELECT #ITEM_RESOURCE_ID# AS ResourceId %2$s
+ '' => ' SELECT %1$s.l1_Value AS l1_Value, #ITEM_RESOURCE_ID# AS ResourceId %2$s
FROM '.TABLE_PREFIX.'CustomField AS cf
LEFT JOIN %1$s ON %1$s.CustomFieldId = cf.CustomFieldId AND ResourceId = #ITEM_RESOURCE_ID#',
), // key - special, value - list select sql
'ItemSQLs' => Array( ''=>'SELECT * FROM %s',
),
'ListSortings' => Array(
'' => Array(
'ForcedSorting' => Array('DisplayOrder' => 'asc', 'FieldName' => 'asc'),
)
),
'Fields' => Array(
'CustomDataId' => Array(),
- 'CustomFieldId' => Array('not_null' => '1', 'default'=>''),
+ 'CustomFieldId' => Array('not_null' => '1', 'default'=>''),
'ResourceId' => Array('not_null' => 1, 'default' => 0),
- 'Value' => Array('not_null' => true, 'default' => ''),
+ 'Value' => Array('not_null' => true, 'formatter' => 'kMultiLanguage', 'default' => ''),
),
'VirtualFields' => Array(
'FieldName' => Array(),
'Prompt' => Array(),
'ElementType' => Array(),
'ValueList' => Array(),
),
'Grids' => Array(
'Default' => Array(
'Icons' => Array('default'=>'icon16_custom.gif'), // icons for each StatusField values, if no matches or no statusfield selected, then "default" icon is used
'Fields' => Array(
'FieldName' => Array( 'title'=>'la_col_FieldName', 'data_block' => 'grid_icon_td'),
- 'Prompt' => Array( 'title'=>'la_col_Prompt', 'data_block' => 'grid_data_label_td' ),
+ 'Prompt' => Array( 'title'=>'la_col_Prompt', 'data_block' => 'grid_data_label_ml_td' ),
'Value' => Array( 'title'=>'la_col_Value', 'data_block' => 'edit_custom_td'),
),
),
),
);
?>
\ No newline at end of file
Property changes on: trunk/kernel/units/custom_values/custom_values_config.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.4
\ No newline at end of property
+1.5
\ No newline at end of property
Index: trunk/kernel/units/custom_values/custom_value_event_handler.php
===================================================================
--- trunk/kernel/units/custom_values/custom_value_event_handler.php (revision 1794)
+++ trunk/kernel/units/custom_values/custom_value_event_handler.php (revision 1795)
@@ -1,96 +1,96 @@
<?php
class CustomValuesEventHandler extends InpDBEventHandler {
function SetCustomQuery(&$event)
{
$object =& $event->getObject();
$top_prefix = $this->Application->GetTopmostPrefix($event->Prefix);
$item_type = $this->Application->getUnitOption($top_prefix, 'ItemType');
$item_resource_id = $this->GetParentResourceId($event);
// there is no ResourceId when creating new item, but we need some id for SQL to work
if (!$item_resource_id) $item_resource_id = 0;
$sql = str_replace('#ITEM_RESOURCE_ID#',$item_resource_id,$object->SelectClause);
$object->setSelectSQL($sql);
$object->removeFilter('parent_filter');
$object->addFilter('itemtype_filter', 'Type = '.$item_type);
if ($event->Special=='general') $object->addFilter('generaltab_filter','OnGeneralTab = 1');
$object->SetPerPage(-1);
}
/**
* Enter description here...
*
* @param kEvent $event
* @return unknown
*/
function GetParentResourceId(&$event)
{
$object = &$event->getObject();
$top_object = $this->Application->RecallObject( $this->Application->GetTopmostPrefix($event->Prefix) );
return $top_object->GetDBField('ResourceId');
}
function OnPreSave(&$event)
{
$object =& $event->getObject();
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if($items_info)
{
+ $lang_id = $this->Application->GetVar('m_lang');
foreach($items_info as $custom_field_id => $values)
{
$set_values = Array(
'CustomFieldId' => $custom_field_id,
- 'Value' => $values['Value'],
+ 'l'.$lang_id.'_Value' => $values['l'.$lang_id.'_Value'],
'ResourceId' => $values['ResourceId'] != 0 ? $values['ResourceId'] : $this->GetParentResourceId($event),
);
// ResourceId will be -1 if we are creating new product, then we get ID directly,
// because it should be already set by parent' event, as we are in hAFTER hook
$id = $values['CustomDataId'];
if ($id) { //if it's already existing custom field record - update id
$object->SetDefaultValues();
$object->Load($id);
$object->SetFieldsFromHash($set_values);
if( $object->Update($id) )
{
$event->status=erSUCCESS;
}
else
{
$event->status=erFAIL;
$event->redirect=false;
break;
}
}
else { //new custom field record - create it and set temp id!
$object->SetDefaultValues();
$object->SetFieldsFromHash($set_values);
if( $object->Create(null, true) )
{
$object->setTempID();
$event->status=erSUCCESS;
}
}
}
}
// this is critical, as the object here is Item, but if something fails, the template could use the same name as grid
// the problem appeared on products general tab, when validation does not go through for product,
// and the templates is getting parsed
$this->Application->removeObject($event->Prefix_Special);
}
-
}
?>
\ No newline at end of file
Property changes on: trunk/kernel/units/custom_values/custom_value_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.4
\ No newline at end of property
+1.5
\ No newline at end of property
Index: trunk/kernel/units/custom_fields/custom_fields_config.php
===================================================================
--- trunk/kernel/units/custom_fields/custom_fields_config.php (revision 1794)
+++ trunk/kernel/units/custom_fields/custom_fields_config.php (revision 1795)
@@ -1,84 +1,83 @@
<?php
$config = Array(
'Prefix' => 'cf',
'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'CustomFieldsEventHandler','file'=>'custom_fields_event_handler.php','build_event'=>'OnBuild'),
'TagProcessorClass' => Array('class'=>'kDBTagProcessor','file'=>'','build_event'=>'OnBuild'),
'AutoLoad' => true,
'hooks' => Array(),
'QueryString' => Array(
1 => 'id',
2 => 'page',
3 => 'event',
4 => 'type',
5 => 'mode',
),
'IDField' => 'CustomFieldId',
'TitleField' => 'FieldName', // field, used in bluebar when editing existing item
'TitlePhrase' => 'la_title_CustomFields',
'TitlePresets' => Array(
'default' => Array( 'new_status_labels' => Array('cf'=>'!la_title_addingCustom!'),
'edit_status_labels' => Array('cf'=>'!la_title_Editing_CustomField!'),
'new_titlefield' => Array('cf'=>'!la_title_NewCustomField!'),
),
'custom_fields_list'=>Array( 'prefixes' => Array('cf_List'),
'format' => "!la_tab_ConfigCustom! (#cf_recordcount#)",
),
'custom_fields_edit'=>Array( 'prefixes' => Array('cf'),
'new_titlefield' => Array('cf'=>'!la_title_NewCustomField!'),
'format' => "#cf_status# '#cf_titlefield#'",
),
),
'TableName' => TABLE_PREFIX.'CustomField',
'ListSQLs' => Array( ''=>'SELECT * FROM %s',
), // key - special, value - list select sql
'ListSortings' => Array(
'' => Array(
'ForcedSorting' => Array('DisplayOrder' => 'asc'),
'Sorting' => Array('FieldName' => 'asc'),
)
),
'ItemSQLs' => Array( ''=>'SELECT * FROM %s',
),
'Fields' => Array(
'CustomFieldId' => Array('type' => 'int','not_null' => '1','default' => ''),
'Type' => Array('type' => 'int','not_null' => '1','default' => '0'),
'FieldName' => Array('required'=>'1', 'type' => 'string','not_null' => 1,'default' => ''),
'FieldLabel' => Array('type' => 'string','default' => ''),
'Heading' => Array('type' => 'string','default' => ''),
'Prompt' => Array('type' => 'string','default' => ''),
'ElementType' => Array('required'=>'1', 'type'=>'string', 'not_null'=>1, 'default'=>'NULL', 'formatter'=>'kOptionsFormatter', 'use_phrases' => 1, 'options'=>Array('' => 'la_EmptyValue', 'select' => 'la_type_select', 'label' => 'la_type_label', 'password' => 'la_type_password','radio' => 'la_type_radio', 'textarea' => 'la_type_textarea', 'text' => 'la_type_text')),
- 'Multilingual' => Array('type' => 'int','default' => '0'),
'ValueList' => Array('type' => 'string','default' => ''),
'DisplayOrder' => Array('type' => 'int','not_null' => '1','default' => '0'),
'OnGeneralTab' => Array('type' => 'int','not_null' => '1','default' => '0'),
),
'VirtualFields' => Array(),
'Grids' => Array(
'Default' => Array(
'Icons' => Array('default'=>'icon16_custom.gif'),
'Fields' => Array(
'CustomFieldId' => Array( 'title'=>'la_prompt_FieldId', 'data_block' => 'grid_checkbox_td' ),
'FieldName' => Array( 'title'=>'la_prompt_FieldName'),
'FieldLabel' => Array( 'title'=>'la_prompt_FieldLabel', 'data_block' => 'cf_grid_data_td' ),
'DisplayOrder' => Array('title' => 'la_prompt_DisplayOrder'),
),
),
),
);
?>
\ No newline at end of file
Property changes on: trunk/kernel/units/custom_fields/custom_fields_config.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.4
\ No newline at end of property
+1.5
\ No newline at end of property
Index: trunk/kernel/admin_templates/incs/script.js
===================================================================
--- trunk/kernel/admin_templates/incs/script.js (revision 1794)
+++ trunk/kernel/admin_templates/incs/script.js (revision 1795)
@@ -1,418 +1,437 @@
var Grids = new Array();
var Toolbars = new Array();
var $Menus = new Array();
var $ViewMenus = new Array();
if(!$fw_menus) var $fw_menus = new Array();
var $env = '';
var submitted = false;
function resort_grid(prefix_special,field,form_action)
{
document.getElementById(prefix_special+'_Sort1').value = field;
submit_event(prefix_special,'OnSetSorting',null,form_action);
}
function direct_sort_grid($prefix_special,$field,$direction,$field_pos)
{
if(!isset($field_pos)) $field_pos = 1;
set_hidden_field($prefix_special+'_Sort'+$field_pos,$field);
set_hidden_field($prefix_special+'_Sort'+$field_pos+'_Dir',$direction);
set_hidden_field($prefix_special+'_SortPos',$field_pos);
submit_event($prefix_special,'OnSetSortingDirect');
}
function reset_sorting($prefix_special)
{
submit_event($prefix_special,'OnResetSorting');
}
function set_per_page($prefix_special,$per_page)
{
set_hidden_field($prefix_special+'_PerPage',$per_page);
submit_event($prefix_special,'OnSetPerPage');
}
function submit_event(prefix_special,event,t,form_action)
{
if (isset(event)) {
set_hidden_field('events['+prefix_special+']', event);
}
if(isset(t)) document.getElementById('t').value = t;
if(isset(form_action)) {
var old_env = '';
if ( !form_action.match(/\?/) ) {
document.getElementById('kernel_form').action.match(/.*(\?.*)/);
old_env = RegExp.$1;
}
document.getElementById('kernel_form').action = form_action+old_env;
}
submit_kernel_form();
}
function show_form_data()
{
var $kf = document.getElementById('kernel_form');
$ret = '';
for(var i in $kf.elements)
{
$elem = $kf.elements[i];
$ret += $elem.id + ' = ' + $elem.value + "\n";
}
alert($ret);
}
function submit_kernel_form()
{
if (submitted) {
return;
}
submitted = true;
var $form = document.getElementById('kernel_form');
if (typeof $form.onsubmit == "function") {
$form.onsubmit();
}
$form.submit();
$form.target = '';
$form.t.value = t;
window.setTimeout(function() {submitted = false}, 500);
}
function set_event(prefix_special, event)
{
var event_field=document.getElementById('events[' + prefix_special + ']');
if(isset(event_field))
{
event_field.value = event;
}
}
function isset(variable)
{
if(variable==null) return false;
return (typeof(variable)=='undefined')?false:true;
}
function print_pre(variable)
{
var s = "";
for (prop in variable) {
s += prop+" => "+variable[prop] + "";
}
alert(s);
}
function go_to_page(prefix_special, page)
{
set_hidden_field(prefix_special+'_Page', page);
submit_event(prefix_special);
}
function go_to_list(prefix_special, tab)
{
document.getElementById(prefix_special+'_GoTab').value = tab;
submit_event(prefix_special,'OnUpdateAndGoToTab',null);
}
function go_to_tab(prefix_special, tab)
{
document.getElementById(prefix_special+'_GoTab').value = tab;
submit_event(prefix_special,'OnPreSaveAndGoToTab',null);
}
function go_to_id(prefix_special, id)
{
document.getElementById(prefix_special+'_GoId').value = id;
submit_event(prefix_special,'OnPreSaveAndGo')
}
// in-portal compatibility functions: begin
function getScriptURL($script_name)
{
var $asid = document.getElementById('sid').value;
return base_url+$script_name+'?env='+( isset($env)&&$env?$env:$asid )+'&en=0';
}
function OpenEditor(extra_env,TargetForm,TargetField)
{
var $url = getScriptURL('admin/editor/editor_new.php');
$url = $url+'&TargetForm='+TargetForm+'&TargetField='+TargetField+'&destform=popup';
if(extra_env.length>0) $url += extra_env;
openwin($url,'html_edit',800,575);
}
function OpenUserSelector(extra_env,TargetForm,TargetField)
{
var $url = getScriptURL('admin/users/user_select.php');
$url += '&destform='+TargetForm+'&Selector=radio&destfield='+TargetField+'&IdField=Login';
if(extra_env.length>0) $url += extra_env;
openwin($url,'user_select',800,575);
return false;
}
function OpenCatSelector(extra_env)
{
var $url = getScriptURL('admin/cat_select.php');
if(extra_env.length>0) $url += extra_env;
openwin($url,'catselect',750,400);
}
function OpenItemSelector(extra_env,$TargetForm)
{
var $url = getScriptURL('admin/relation_select.php') + '&destform='+$TargetForm;
if(extra_env.length>0) $url += extra_env;
openwin($url,'groupselect',750,400);
}
function OpenUserEdit($user_id, $extra_env)
{
var $url = getScriptURL('admin/users/adduser.php') + '&direct_id=' + $user_id;
if( isset($extra_env) ) $url += $extra_env;
window.location.href = $url;
}
function OpenLinkEdit($link_id, $extra_env)
{
var $url = getScriptURL('in-link/admin/addlink.php') + '&item=' + $link_id;
if( isset($extra_env) ) $url += $extra_env;
window.location.href = $url;
}
function OpenHelp($help_link)
{
// $help_link.match('http://(.*).lv/in-commerce/admin(.*)');
// alert(RegExp.$2);
openwin($help_link,'HelpPopup',750,400);
}
// in-portal compatibility functions: end
function PreSaveAndOpenTranslator(prefix,field,t,$width,$height)
{
if(!isset($window_name)) var $window_name = 'select_'+t.replace(/(\/|-)/g, '_');
if(!isset($width)) $width=750;
if(!isset($height)) $height=400;
openwin('',$window_name,$width,$height);
set_hidden_field('translator_wnd_name', $window_name);
set_hidden_field('translator_field', field);
set_hidden_field('translator_t', t);
+ set_hidden_field('translator_prefixes', prefix);
document.kernel_form.target=$window_name;
- submit_event(prefix,'OnPreSaveAndOpenTranslator');
+
+ var split_prefix = prefix.split(',');
+ submit_event(split_prefix[0],'OnPreSaveAndOpenTranslator');
}
+function PreSaveAndOpenTranslatorCV(prefix,field,t,cf_id)
+{
+ if(!isset($window_name)) var $window_name = 'select_'+t.replace(/(\/|-)/g, '_');
+ openwin('',$window_name,750,400);
+ set_hidden_field('translator_wnd_name', $window_name);
+ set_hidden_field('translator_field', field);
+ set_hidden_field('translator_t', t);
+ set_hidden_field('translator_prefixes', prefix);
+ set_hidden_field('translator_cf_id', cf_id);
+ document.kernel_form.target=$window_name;
+
+ var split_prefix = prefix.split(',');
+ submit_event(split_prefix[0],'OnPreSaveAndOpenTranslator');
+}
+
+
function openTranslator(prefix,field,url,wnd)
{
set_hidden_field('trans_prefix', prefix);
set_hidden_field('trans_field', field);
set_hidden_field('events[trans]', 'OnLoad');
var $regex = new RegExp('(.*)\?env=' + document.getElementById('sid').value + '-(.*?):(.*)');
var $t = $regex.exec(url)[2];
document.kernel_form.target = wnd;
submit_event(prefix,'',$t,url);
}
function openSelector($prefix,$url,$window_name,$width,$height,$event)
{
var $regex = new RegExp('(.*)\?env=' + document.getElementById('sid').value + '-(.*?):(.*)');
var $t = $regex.exec($url)[2];
if(!isset($window_name)) var $window_name = 'select_'+$t.replace(/(\/|-)/g, '_');
if(!isset($width)) $width=750;
if(!isset($height)) $height=400;
if(!isset($event)) $event='';
set_hidden_field('m_opener','s');
openwin('',$window_name,$width,$height);
set_hidden_field('main_prefix', $prefix);
document.kernel_form.target=$window_name;
var old_action = document.kernel_form.action;
document.kernel_form.action = $url;
submit_event($prefix,$event,$t);
document.kernel_form.action = old_action;
}
function openwin($url,$name,$width,$height)
{
var $window_params = 'width='+$width+',height='+$height+',status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no';
return window.open($url,$name,$window_params);
}
function opener_action(new_action)
{
document.getElementById('m_opener').value=new_action;
}
function std_precreate_item(prefix_special, edit_template)
{
opener_action('d');
set_hidden_field(prefix_special+'_mode', 't');
submit_event(prefix_special,'OnPreCreate', edit_template)
}
function std_new_item(prefix_special, edit_template)
{
opener_action('d');
submit_event(prefix_special,'OnNew', edit_template)
}
function std_edit_item(prefix_special, edit_template)
{
opener_action('d');
set_hidden_field(prefix_special+'_mode', 't');
submit_event(prefix_special,'OnEdit',edit_template)
}
function std_edit_temp_item(prefix_special, edit_template)
{
opener_action('d');
submit_event(prefix_special,'',edit_template)
}
function std_delete_items(prefix_special)
{
if (inpConfirm('Are you sure you want to delete selected items?'))
submit_event(prefix_special,'OnMassDelete')
}
// sets hidden field value
// if the field does not exist - creates it
function set_hidden_field($field_id, $value)
{
var $field = document.getElementById($field_id);
if($field)
{
$field.value = $value;
return true;
}
$field = document.createElement('INPUT');
$field.type = 'hidden';
$field.name = $field_id;
$field.id = $field_id;
$field.value = $value;
document.kernel_form.appendChild($field);
return false;
}
function search($prefix_special, $grid_name)
{
set_hidden_field('grid_name', $grid_name);
submit_event($prefix_special,'OnSearch');
}
function search_reset($prefix_special)
{
submit_event($prefix_special,'OnSearchReset');
}
function search_keydown($event)
{
if(!$event && window.event) $event = window.event;
if($event.keyCode == 13)
{
var $prefix_special = this.getAttribute('PrefixSpecial');
var $grid = this.getAttribute('Grid');
search($prefix_special,$grid);
}
}
function getRealLeft(el)
{
xPos = el.offsetLeft;
tempEl = el.offsetParent;
while (tempEl != null)
{
xPos += tempEl.offsetLeft;
tempEl = tempEl.offsetParent;
}
return xPos;
}
function getRealTop(el)
{
yPos = el.offsetTop;
tempEl = el.offsetParent;
while (tempEl != null)
{
yPos += tempEl.offsetTop;
tempEl = tempEl.offsetParent;
}
return yPos;
}
function show_viewmenu($toolbar, $button_id)
{
var $img = $toolbar.GetButtonImage($button_id);
var $pos_x = getRealLeft($img) - ((document.all) ? 6 : -2);
var $pos_y = getRealTop($img) + 32;
var $prefix_special = '';
window.triedToWriteMenus = false;
if($ViewMenus.length == 1)
{
$prefix_special = $ViewMenus[$ViewMenus.length-1];
$fw_menus[$prefix_special+'_view_menu']();
$Menus[$prefix_special+'_view_menu'].writeMenus('MenuContainers['+$prefix_special+']');
window.FW_showMenu($Menus[$prefix_special+'_view_menu'], $pos_x, $pos_y);
}
else
{
// prepare menus
for(var $i in $ViewMenus)
{
$prefix_special = $ViewMenus[$i];
$fw_menus[$prefix_special+'_view_menu']();
}
$Menus['mixed'] = new Menu('ViewMenu_mixed');
// merge menus into new one
for(var $i in $ViewMenus)
{
$prefix_special = $ViewMenus[$i];
$Menus['mixed'].addMenuItem( $Menus[$prefix_special+'_view_menu'] );
}
$Menus['mixed'].writeMenus('MenuContainers[mixed]');
window.FW_showMenu($Menus['mixed'], $pos_x, $pos_y);
}
}
function set_window_title($title)
{
var $window = window;
if($window.parent) $window = $window.parent;
$window.document.title = (main_title.length ? main_title + ' - ' : '') + $title;
}
function set_filter($prefix_special, $filter_id, $filter_value)
{
set_hidden_field('filter_id',$filter_id);
set_hidden_field('filter_value',$filter_value);
submit_event($prefix_special,'OnSetFilter');
}
function filters_remove_all($prefix_special)
{
submit_event($prefix_special,'OnRemoveFilters');
}
function filters_apply_all($prefix_special)
{
submit_event($prefix_special,'OnApplyFilters');
}
function RemoveTranslationLink($string)
{
return $string.match(/<a href="(.*)">(.*)<\/a>/) ? RegExp.$2 : $string;
}
function redirect($url)
{
window.location.href = $url;
}
\ No newline at end of file
Property changes on: trunk/kernel/admin_templates/incs/script.js
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property
Index: trunk/kernel/admin_templates/incs/grid_blocks.tpl
===================================================================
--- trunk/kernel/admin_templates/incs/grid_blocks.tpl (revision 1794)
+++ trunk/kernel/admin_templates/incs/grid_blocks.tpl (revision 1795)
@@ -1,249 +1,258 @@
<inp2:m_block name="current_page"/>
<span class="current_page"><inp2:m_param name="page"/></span>
<inp2:m_blockend/>
<inp2:m_block name="page"/>
<a href="javascript:go_to_page('<inp2:m_param name="PrefixSpecial"/>', <inp2:m_param name="page"/>)" class="nav_url"><inp2:m_param name="page"/></a>
<inp2:m_blockend/>
<inp2:m_block name="next_page"/>
<a href="javascript:go_to_page('<inp2:m_param name="PrefixSpecial"/>', <inp2:m_param name="page"/>)" class="nav_url">&gt;</a>
<inp2:m_blockend/>
<inp2:m_block name="prev_page"/>
<a href="javascript:go_to_page('<inp2:m_param name="PrefixSpecial"/>', <inp2:m_param name="page"/>)" class="nav_url">&lt;</a>
<inp2:m_blockend/>
<inp2:m_block name="next_page_split"/>
<a href="javascript:go_to_page('<inp2:m_param name="PrefixSpecial"/>', <inp2:m_param name="page"/>)" class="nav_url">&gt;&gt;</a>
<inp2:m_blockend/>
<inp2:m_block name="prev_page_split"/>
<a href="javascript:go_to_page('<inp2:m_param name="PrefixSpecial"/>', <inp2:m_param name="page"/>)" class="nav_url">&lt;&lt;</a>
<inp2:m_blockend/>
<inp2:m_block name="grid_pagination"/>
<table cellspacing="0" cellpadding="2" width="100%" bgcolor="#E0E0DA" border="0" class="<inp2:m_if prefix="m" function="ParamEquals" name="no_toolbar" value="no_toolbar"/>tableborder_full_kernel<inp2:m_else/>pagination_bar<inp2:m_endif/>">
<tbody>
<tr id="MY_ID">
<td width="100%">
<img height="15" src="img/arrow.gif" width="15" align="absmiddle" border="0">
<b class=text><inp2:m_phrase name="la_Page"/></b>
<inp2:$PrefixSpecial_PrintPages active_block="current_page" split="10" inactive_block="page" prev_page_block="prev_page" next_page_block="next_page" prev_page_split_block="prev_page_split" next_page_split_block="next_page_split" />
</td>
<inp2:m_if prefix="m" function="ParamEquals" param="search" value="on"/>
<td align="right" style="padding-right: 0px;">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td><inp2:m_phrase name="la_Search"/>:&nbsp;</td>
<td><input type="text"
id="<inp2:m_param name="PrefixSpecial"/>_search_keyword"
name="<inp2:m_param name="PrefixSpecial"/>_search_keyword"
value="<inp2:m_recall var="{$PrefixSpecial}_search_keyword" no_null="no_null" special="1"/>"
PrefixSpecial="<inp2:m_param name="PrefixSpecial"/>"
Grid="<inp2:m_param name="grid"/>"
style="border: 1px solid grey;">
</td>
<td>
<script type="text/javascript">
document.getElementById('<inp2:m_param name="PrefixSpecial"/>_search_keyword').onkeydown = search_keydown;
Toolbars['<inp2:m_param name="PrefixSpecial"/>_search'] = new ToolBar('icon16_');
Toolbars['<inp2:m_param name="PrefixSpecial"/>_search'].AddButton( new ToolBarButton('search', '<inp2:m_phrase name="la_ToolTip_Search"/>', function() { search('<inp2:m_param name="PrefixSpecial"/>','<inp2:m_param name="grid"/>') } ) );
Toolbars['<inp2:m_param name="PrefixSpecial"/>_search'].AddButton( new ToolBarButton('search_reset', '<inp2:m_phrase name="la_ToolTip_SearchReset"/>', function() { search_reset('<inp2:m_param name="PrefixSpecial"/>') } ) );
Toolbars['<inp2:m_param name="PrefixSpecial"/>_search'].Render();
</script>
</td>
</tr>
</table>
</td>
<inp2:m_endif/>
<td>
</tr>
</tbody>
</table>
<inp2:m_blockend/>
<inp2:m_block name="grid_column_title"/>
<td nowrap="nowrap">
<a href="javascript:resort_grid('<inp2:m_param name="PrefixSpecial"/>','<inp2:m_param name="sort_field"/>');" class="columntitle_small"><IMG alt="" src="img/list_arrow_<inp2:$PrefixSpecial_order field="$sort_field"/>.gif" border="0" align="absmiddle"><inp2:m_phrase name="$title"/><!-- <inp2:m_param name="title"/> --></a>
</td>
<inp2:m_blockend/>
<inp2:m_block name="grid_column_title_no_sorting"/>
<td nowrap="nowrap">
<inp2:m_phrase label="$title"/>
</td>
<inp2:m_blockend/>
<inp2:m_block name="grid_checkbox_td" />
<td valign="top" class="text">
<table border="0" cellpadding="0" cellspacing="0" class="grid_id_cell">
<tr>
<td><input type="checkbox" name="<inp2:$PrefixSpecial_InputName field="$IdField" IdField="$IdField"/>" id="<inp2:$PrefixSpecial_InputName field="$IdField" IdField="$IdField"/>"></td>
<td><img src="img/itemicons/<inp2:$PrefixSpecial_ItemIcon grid="$grid"/>"></td>
<td><inp2:$PrefixSpecial_field field="$field" no_special="no_special" format="$format"/></td>
</tr>
</table>
</td>
<inp2:m_blockend />
<inp2:m_block name="label_grid_checkbox_td" />
<td valign="top" class="text">
<table border="0" cellpadding="0" cellspacing="0" class="grid_id_cell">
<tr>
<td><input type="checkbox" name="<inp2:$PrefixSpecial_InputName field="$IdField" IdField="$IdField"/>" id="<inp2:$PrefixSpecial_InputName field="$IdField" IdField="$IdField"/>"></td>
<td><img src="img/itemicons/<inp2:$PrefixSpecial_ItemIcon grid="$grid"/>"></td>
<td><inp2:$PrefixSpecial_field field="$field" no_special="no_special" as_label="as_label" format="$format"/></td>
</tr>
</table>
</td>
<inp2:m_blockend />
<inp2:m_block name="grid_icon_td" />
<td valign="top" class="text">
<table border="0" cellpadding="0" cellspacing="0" class="grid_id_cell">
<tr>
<td><img src="img/itemicons/<inp2:$PrefixSpecial_ItemIcon grid="$grid"/>"></td>
<td><inp2:$PrefixSpecial_field field="$field" no_special="no_special" format="$format"/></td>
</tr>
</table>
</td>
<inp2:m_blockend />
<inp2:m_block name="grid_radio_td" />
<td valign="top" class="text">
<table border="0" cellpadding="0" cellspacing="0" class="grid_id_cell">
<tr>
<td><input type="radio" name="<inp2:$PrefixSpecial_InputName field="$IdField" IdField="$IdField"/>" id="<inp2:$PrefixSpecial_InputName field="$IdField" IdField="$IdField"/>"></td>
<td><img src="img/itemicons/<inp2:$PrefixSpecial_ItemIcon grid="$grid"/>"></td>
<td><inp2:$PrefixSpecial_field field="$field" no_special="no_special" format="$format"/></td>
</tr>
</table>
</td>
<inp2:m_blockend />
<inp2:m_block name="grid_data_td" />
<td valign="top" class="text"><inp2:$PrefixSpecial_field field="$field" grid="$grid" no_special="$no_special" format="$format"/></td>
<inp2:m_blockend />
<inp2:m_block name="grid_edit_td" />
<td valign="top" class="text"><input type="text" id="<inp2:$PrefixSpecial_InputName field="$field"/>" name="<inp2:$PrefixSpecial_InputName field="$field"/>" value="<inp2:$PrefixSpecial_field field="$field" grid="$grid" format="$format"/>"></td>
<inp2:m_blockend />
<inp2:m_block name="grid_data_label_td" />
<td valign="top" class="text"><inp2:$PrefixSpecial_field field="$field" grid="$grid" as_label="1" no_special="no_special" format="$format"/></td>
<inp2:m_blockend />
+<inp2:m_block name="grid_data_label_ml_td" />
+ <td valign="top" class="text">
+ <inp2:$PrefixSpecial_field field="$field" grid="$grid" as_label="1" no_special="no_special" format="$format"/>:<br />
+ <a href="javascript:PreSaveAndOpenTranslatorCV('p,cv', 'cv:Value', 'popups/translator', <inp2:$PrefixSpecial_field field="CustomFieldId"/>);" title="<inp2:m_Phrase label="la_Translate"/>"><img src="img/icons/icon24_translate.gif" style="cursor:hand;" border="0"></a>
+ </td>
+<inp2:m_blockend />
+
<inp2:m_block name="viewmenu_sort_block"/>
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'].addMenuItem('<inp2:m_phrase name="$title"/>','direct_sort_grid("<inp2:m_param name="PrefixSpecial"/>","<inp2:m_param name="sort_field"/>","<inp2:$PrefixSpecial_OrderInfo type="direction" pos="1"/>");','<inp2:m_if prefix="$PrefixSpecial" function="IsOrder" field="$sort_field" pos="1"/>2<inp2:m_endif/>');
<inp2:m_blockend/>
<inp2:m_block name="viewmenu_filter_block"/>
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'].addMenuItem('<inp2:m_param name="label"/>','<inp2:m_param name="filter_action"/>','<inp2:m_param name="filter_status"/>');
<inp2:m_blockend/>
<inp2:m_block name="viewmenu_filter_separator"/>
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'].addMenuSeparator();
<inp2:m_blockend/>
<inp2:m_block name="viewmenu_declaration"/>
// define ViewMenu
$fw_menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'] = function()
{
<inp2:m_if prefix="m" function="ParamEquals" name="has_filters" value="has_filters"/>
// filtring menu
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'] = new Menu('<inp2:m_phrase name="la_Text_View"/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'].addMenuItem('All','filters_remove_all("<inp2:m_param name="PrefixSpecial"/>");');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'].addMenuItem('None','filters_apply_all("<inp2:m_param name="PrefixSpecial"/>");');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'].addMenuSeparator();
<inp2:$PrefixSpecial_DrawFilterMenu item_block="viewmenu_filter_block" spearator_block="viewmenu_filter_separator"/>
<inp2:m_endif/>
// sorting menu
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'] = new Menu('<inp2:m_phrase name="la_Text_Sort"/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'].addMenuItem('<inp2:m_phrase name="la_common_ascending"/>','direct_sort_grid("<inp2:m_param name="PrefixSpecial"/>","<inp2:$PrefixSpecial_OrderInfo type="field" pos="1"/>","asc");','<inp2:m_if prefix="$PrefixSpecial" function="IsOrder" direction="asc" pos="1"/>2<inp2:m_endif/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'].addMenuItem('<inp2:m_phrase name="la_common_descending"/>','direct_sort_grid("<inp2:m_param name="PrefixSpecial"/>","<inp2:$PrefixSpecial_OrderInfo type="field" pos="1"/>","desc");','<inp2:m_if prefix="$PrefixSpecial" function="IsOrder" direction="desc" pos="1"/>2<inp2:m_endif/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'].addMenuSeparator();
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'].addMenuItem('<inp2:m_phrase name="la_Text_Default"/>','reset_sorting("<inp2:m_param name="PrefixSpecial"/>");');
<inp2:$PrefixSpecial_IterateGridFields grid="$grid" mode="header" block="viewmenu_sort_block"/>
// per page menu
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'] = new Menu('<inp2:m_phrase name="la_prompt_PerPage"/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'].addMenuItem('10','set_per_page("<inp2:m_param name="PrefixSpecial"/>",10);','<inp2:m_if prefix="$PrefixSpecial" function="PerPageEquals" value="10"/>2<inp2:m_endif/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'].addMenuItem('20','set_per_page("<inp2:m_param name="PrefixSpecial"/>",20);','<inp2:m_if prefix="$PrefixSpecial" function="PerPageEquals" value="20"/>2<inp2:m_endif/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'].addMenuItem('50','set_per_page("<inp2:m_param name="PrefixSpecial"/>",50);','<inp2:m_if prefix="$PrefixSpecial" function="PerPageEquals" value="50"/>2<inp2:m_endif/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'].addMenuItem('100','set_per_page("<inp2:m_param name="PrefixSpecial"/>",100);','<inp2:m_if prefix="$PrefixSpecial" function="PerPageEquals" value="100"/>2<inp2:m_endif/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'].addMenuItem('500','set_per_page("<inp2:m_param name="PrefixSpecial"/>",500);','<inp2:m_if prefix="$PrefixSpecial" function="PerPageEquals" value="500"/>2<inp2:m_endif/>');
// select menu
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_select_menu'] = new Menu('<inp2:m_phrase name="la_Text_Select"/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_select_menu'].addMenuItem('<inp2:m_phrase name="la_Text_All"/>','Grids["<inp2:m_param name="PrefixSpecial"/>"].SelectAll();');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_select_menu'].addMenuItem('<inp2:m_phrase name="la_Text_Unselect"/>','Grids["<inp2:m_param name="PrefixSpecial"/>"].ClearSelection();');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_select_menu'].addMenuItem('<inp2:m_phrase name="la_Text_Invert"/>','Grids["<inp2:m_param name="PrefixSpecial"/>"].InvertSelection();');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'] = new Menu('<inp2:$PrefixSpecial_GetItemName/>');
<inp2:m_if prefix="m" function="ParamEquals" name="has_filters" value="has_filters"/>
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'].addMenuItem( $Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'] );
<inp2:m_endif/>
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'].addMenuItem( $Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'] );
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'].addMenuItem( $Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'] );
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'].addMenuItem( $Menus['<inp2:m_param name="PrefixSpecial"/>'+'_select_menu'] );
}
<inp2:m_blockend/>
<inp2:m_block name="grid_save_warning" />
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="table_border_<inp2:m_if prefix="m" function="ParamEquals" name="no_toolbar" value="no_toolbar"/>nobottom<inp2:m_else/>notop<inp2:m_endif/>">
<tr>
<td valign="top" class="hint_red">
<inp2:m_phrase name="la_Warning_Save_Item"/>
</td>
</tr>
</table>
<inp2:m_blockend/>
<inp2:m_block name="grid" />
<inp2:$PrefixSpecial_SaveWarning name="grid_save_warning" main_prefix="$main_prefix" no_toolbar="$no_toolbar"/>
<inp2:m_if prefix="m" function="RecallEquals" var="{$PrefixSpecial}_search_keyword" value="" inverse="inverse"/>
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="table_border_<inp2:m_if prefix="m" function="ParamEquals" name="no_toolbar" value="no_toolbar"/>nobottom<inp2:m_else/>notop<inp2:m_endif/>">
<tr>
<td valign="top" class="hint_red">
<inp2:m_phrase name="la_Warning_Filter"/>
</td>
</tr>
</table>
<inp2:m_endif/>
<inp2:m_ParamEquals name="NoPagination" value="">
<inp2:m_ParseBlock name="grid_pagination" grid="$grid" PrefixSpecial="$PrefixSpecial" search="$search" no_toolbar="$no_toolbar"/>
</inp2>
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder">
<tr class="subsectiontitle">
<inp2:$PrefixSpecial_IterateGridFields grid="$grid" mode="header" block="$header_block"/>
</tr>
<inp2:m_block name="_row" />
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>" id="<inp2:m_param name="PrefixSpecial"/>_<inp2:$PrefixSpecial_field field="$IdField"/>" sequence="<inp2:m_get param="{$PrefixSpecial}_sequence"/>"><inp2:m_inc param="{$PrefixSpecial}_sequence" by="1"/>
<inp2:$PrefixSpecial_IterateGridFields grid="$grid" mode="data" block="$data_block"/>
</tr>
<inp2:m_blockend />
<inp2:m_set {$PrefixSpecial}_sequence="1"/>
<inp2:$PrefixSpecial_PrintList block="_row" per_page="$per_page" main_special="$main_special"/>
</table>
<inp2:m_if prefix="m" function="GetEquals" name="fw_menu_included" value=""/>
<script type="text/javascript" src="incs/fw_menu.js"></script>
<inp2:m_set fw_menu_included="1"/>
<inp2:m_endif/>
<script type="text/javascript">
- Grids['<inp2:m_param name="PrefixSpecial"/>'] = new Grid('selected_div', ':original', edit, a_toolbar);
- Grids['<inp2:m_param name="PrefixSpecial"/>'].AddItemsByIdMask('tr', /^<inp2:m_param name="PrefixSpecial"/>_([0-9-]+)/, '<inp2:m_param name="PrefixSpecial"/>[$$ID$$][<inp2:m_param name="IdField"/>]');
- Grids['<inp2:m_param name="PrefixSpecial"/>'].InitItems();
+ <inp2:m_if check="m_ParamEquals" name="no_init" value="no_init" inverse="inverse">
+ Grids['<inp2:m_param name="PrefixSpecial"/>'] = new Grid('selected_div', ':original', edit, a_toolbar);
+ Grids['<inp2:m_param name="PrefixSpecial"/>'].AddItemsByIdMask('tr', /^<inp2:m_param name="PrefixSpecial"/>_([0-9-]+)/, '<inp2:m_param name="PrefixSpecial"/>[$$ID$$][<inp2:m_param name="IdField"/>]');
+ Grids['<inp2:m_param name="PrefixSpecial"/>'].InitItems();
+ </inp2:m_if>
<inp2:m_ParseBlock name="viewmenu_declaration" PrefixSpecial="$PrefixSpecial" grid="$grid" has_filters="$has_filters"/>
$ViewMenus = new Array('<inp2:m_param name="PrefixSpecial"/>');
</script>
<input type="hidden" id="<inp2:m_param name="PrefixSpecial"/>_Sort1" name="<inp2:m_param name="PrefixSpecial"/>_Sort1" value="">
<input type="hidden" id="<inp2:m_param name="PrefixSpecial"/>_Sort1_Dir" name="<inp2:m_param name="PrefixSpecial"/>_Sort1_Dir" value="asc">
<inp2:m_blockend />
\ No newline at end of file
Property changes on: trunk/kernel/admin_templates/incs/grid_blocks.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/kernel/admin_templates/incs/custom_blocks.tpl
===================================================================
--- trunk/kernel/admin_templates/incs/custom_blocks.tpl (revision 1794)
+++ trunk/kernel/admin_templates/incs/custom_blocks.tpl (revision 1795)
@@ -1,45 +1,46 @@
<inp2:m_block name="config_edit_text" />
<input type="text" name="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>" value="<inp2:$PrefixSpecial_Field field="$field" />" />
<inp2:m_blockend />
<inp2:m_block name="config_edit_password" />
<input type="password" primarytype="password" name="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>" id="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>" value="" />
<input type="password" name="verify_<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>" id="verify_<inp2:$PrefixSpecial_InputName field="$field" IdField=="$IdField"/>" value="" />
&nbsp;<span class="error" id="error_<inp2:$PrefixSpecial_InputName field="$field"/>"></span>
<inp2:m_blockend />
<inp2:m_block name="config_edit_option" />
<option value="<inp2:m_param name="key"/>"<inp2:m_param name="selected"/>><inp2:m_param name="option"/></option>
<inp2:m_blockend />
<inp2:m_block name="config_edit_select" />
<select name="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>">
<inp2:$PrefixSpecial_PredefinedOptions field="$field" tabindex="$pass_tabindex" block="config_edit_option" selected="selected"/>
</select>
<inp2:m_blockend />
<inp2:m_block name="config_edit_checkbox"/>
<input type="hidden" id="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>" name="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>" value="<inp2:$PrefixSpecial_Field field="$field" db="db"/>">
<input tabindex="<inp2:m_get param="tab_index"/>" type="checkbox" id="_cb_<inp2:m_param name="field"/>" name="_cb_<inp2:m_param name="field"/>" <inp2:$PrefixSpecial_Field field="$field" checked="checked" db="db"/> class="<inp2:m_param name="field_class"/>" onclick="update_checkbox(this, document.getElementById('<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>'))">
<inp2:m_blockend/>
<inp2:m_block name="config_edit_textarea" />
<textarea name="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>" <inp2:m_param name="field_params" />><inp2:$PrefixSpecial_Field field="$field" /></textarea>
<inp2:m_blockend />
<inp2:m_block name="config_radio_item"/>
<input type="radio" <inp2:m_param name="checked"/> name="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>" id="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>_<inp2:m_param name="key"/>" value="<inp2:m_param name="key"/>"><label for="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>_<inp2:m_param name="key"/>"><inp2:m_param name="option"/></label>&nbsp;
<inp2:m_blockend/>
<inp2:m_block name="config_edit_radio"/>
<inp2:$PrefixSpecial_PredefinedOptions field="$field" tabindex="$pass_tabindex" block="config_radio_item" selected="checked"/>
<inp2:m_blockend/>
<inp2:m_block name="edit_custom_td" />
<td valign="top" class="text">
<input type="hidden" name="<inp2:$PrefixSpecial_InputName field="ResourceId" IdField="$IdField"/>" id="<inp2:$PrefixSpecial_InputName field="ResourceId" IdField="$IdField"/>" value="<inp2:$PrefixSpecial_field field="ResourceId" grid="$grid"/>">
<input type="hidden" name="<inp2:$PrefixSpecial_InputName field="CustomDataId" IdField="$IdField"/>" id="<inp2:$PrefixSpecial_InputName field="CustomDataId" IdField="$IdField"/>" value="<inp2:$PrefixSpecial_field field="CustomDataId" grid="$grid"/>">
<!--<input size="40" type="text" name="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>" id="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>" value="<inp2:$PrefixSpecial_field field="$field" grid="$grid"/>">-->
+
<inp2:$PrefixSpecial_ConfigFormElement field="Value" blocks_prefix="config_edit_" element_type_field="ElementType" value_list_field="ValueList" />
</td>
<inp2:m_blockend />
\ No newline at end of file
Property changes on: trunk/kernel/admin_templates/incs/custom_blocks.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property
Index: trunk/admin/install/upgrades/inportal_upgrade_v1.1.0.sql
===================================================================
--- trunk/admin/install/upgrades/inportal_upgrade_v1.1.0.sql (revision 1794)
+++ trunk/admin/install/upgrades/inportal_upgrade_v1.1.0.sql (revision 1795)
@@ -1,22 +1,21 @@
ALTER TABLE SysCache DROP INDEX Expire;
ALTER TABLE Category MODIFY COLUMN Priority INTEGER(11) DEFAULT NULL;
-ALTER TABLE CustomField ADD COLUMN Multilingual TINYINT(4) NOT NULL DEFAULT '0';
ALTER TABLE Phrase ADD COLUMN LastChanged INTEGER(10) UNSIGNED NOT NULL DEFAULT '0';
ALTER TABLE Phrase ADD COLUMN LastChangeIP VARCHAR(15) NOT NULL;
ALTER TABLE Phrase ADD COLUMN Module VARCHAR(30) NOT NULL;
ALTER TABLE PortalUser MODIFY COLUMN State VARCHAR(20) NOT NULL;
ALTER TABLE SearchConfig MODIFY COLUMN ForeignField TEXT;
ALTER TABLE SearchConfig MODIFY COLUMN JoinClause TEXT;
ALTER TABLE Theme ADD COLUMN StylesheetId INTEGER(10) UNSIGNED NOT NULL DEFAULT '0';
ALTER TABLE Phrase ADD KEY LanguageId (LanguageId);
CREATE TABLE Cache (VarName varchar(255) NOT NULL default '', Data longtext, Cached int(11) default NULL, PRIMARY KEY (VarName), KEY Cached (Cached) );
CREATE TABLE StylesheetSelectors (SelectorId int(11) NOT NULL auto_increment, StylesheetId int(11) NOT NULL default '0', Name varchar(255) NOT NULL default '', SelectorName varchar(255) NOT NULL default '', SelectorData text NOT NULL, Description text NOT NULL, Type tinyint(4) NOT NULL default '0', AdvancedCSS text NOT NULL, ParentId int(11) NOT NULL default '0', PRIMARY KEY (SelectorId) );
CREATE TABLE Stylesheets ( StylesheetId int(11) NOT NULL auto_increment, Name varchar(255) NOT NULL default '', Description varchar(255) NOT NULL default '', AdvancedCSS text NOT NULL, LastCompiled int(10) unsigned NOT NULL default '0', Enabled int(11) NOT NULL default '0', PRIMARY KEY (StylesheetId) );
INSERT INTO ConfigurationAdmin VALUES ('Email_As_Login', 'la_Text_General', 'la_use_emails_as_login', 'checkbox', NULL, NULL, 1, 0);
INSERT INTO ConfigurationValues VALUES ('Email_As_Login', '1', 'In-Portal:Users', 'in-portal:configure_users');
ALTER TABLE Language ADD COLUMN UnitSystem TINYINT DEFAULT '1' NOT NULL;
UPDATE Modules SET Version = '1.1.0' WHERE Name = 'In-Portal';
\ No newline at end of file
Property changes on: trunk/admin/install/upgrades/inportal_upgrade_v1.1.0.sql
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.5
\ No newline at end of property
+1.6
\ No newline at end of property
Index: trunk/admin/install/inportal_schema.sql
===================================================================
--- trunk/admin/install/inportal_schema.sql (revision 1794)
+++ trunk/admin/install/inportal_schema.sql (revision 1795)
@@ -1,660 +1,659 @@
CREATE TABLE BanRules (
RuleId int(11) NOT NULL auto_increment,
RuleType tinyint(4) NOT NULL default '0',
ItemField varchar(255) default NULL,
ItemVerb tinyint(4) NOT NULL default '0',
ItemValue varchar(255) NOT NULL default '',
ItemType int(11) NOT NULL default '0',
Priority int(11) NOT NULL default '0',
Status tinyint(4) NOT NULL default '1',
ErrorTag varchar(255) default NULL,
PRIMARY KEY (RuleId)
)
# --------------------------------------------------------
CREATE TABLE Category (
CategoryId int(11) NOT NULL auto_increment,
Type int(11) NOT NULL default '0',
ParentId int(11) NOT NULL default '0',
Name varchar(255) NOT NULL default '',
Description text NOT NULL,
CreatedOn int(11) NOT NULL default '0',
EditorsPick tinyint(4) default NULL,
Status tinyint(4) NOT NULL default '0',
Pop tinyint(4) default NULL,
Priority int(11) NOT NULL default '0',
MetaKeywords varchar(255) default NULL,
CachedDescendantCatsQty int(11) default NULL,
CachedNavbar text NOT NULL,
CreatedById int(11) NOT NULL default '0',
ResourceId int(11) default NULL,
ParentPath text NOT NULL,
MetaDescription varchar(255) default NULL,
HotItem int(11) NOT NULL default '2',
NewItem int(11) NOT NULL default '2',
PopItem int(11) NOT NULL default '2',
Modified int(11) NOT NULL default '0',
ModifiedById int(11) NOT NULL default '0',
PRIMARY KEY (CategoryId),
KEY ParentId (ParentId),
UNIQUE KEY ResourceId (ResourceId),
KEY Modified (Modified),
KEY Priority (Priority),
KEY sorting (Name,Priority)
)
# --------------------------------------------------------
CREATE TABLE CategoryItems (
CategoryId int(11) NOT NULL default '0',
ItemResourceId int(11) NOT NULL default '0',
PrimaryCat tinyint(4) NOT NULL default '0',
KEY CategoryId (CategoryId),
KEY ItemResourceId (ItemResourceId),
KEY PrimaryCat (PrimaryCat)
)
# --------------------------------------------------------
CREATE TABLE ConfigurationAdmin (
VariableName varchar(80) NOT NULL default '',
heading varchar(255) default NULL,
prompt varchar(255) default NULL,
element_type varchar(20) NOT NULL default '',
validation varchar(255) default NULL,
ValueList text default NULL,
DisplayOrder int(11) NOT NULL default '0',
Install int(11) NOT NULL default '1',
PRIMARY KEY (VariableName)
)
# --------------------------------------------------------
CREATE TABLE ConfigurationValues (
VariableName varchar(255) NOT NULL default '',
VariableValue varchar(255) default NULL,
ModuleOwner varchar(20) default 'In-Portal',
Section varchar(255) NOT NULL default '',
PRIMARY KEY (VariableName)
)
# --------------------------------------------------------
CREATE TABLE CountCache (
ListType int(11) NOT NULL default '0',
ItemType int(11) NOT NULL default '-1',
Value int(11) NOT NULL default '0',
CountCacheId int(11) NOT NULL auto_increment,
LastUpdate int(11) NOT NULL default '0',
ExtraId varchar(50) default NULL,
TodayOnly tinyint(4) NOT NULL default '0',
PRIMARY KEY (CountCacheId)
)
# --------------------------------------------------------
CREATE TABLE CustomField (
CustomFieldId int(11) NOT NULL auto_increment,
Type int(11) NOT NULL default '0',
FieldName varchar(255) NOT NULL default '',
FieldLabel varchar(40) default NULL,
Heading varchar(60) default NULL,
Prompt varchar(60) default NULL,
ElementType varchar(50) NOT NULL default '',
ValueList varchar(255) default NULL,
DisplayOrder int(11) NOT NULL default '0',
OnGeneralTab tinyint(4) NOT NULL default '0',
- Multilingual TINYINT(4) NOT NULL DEFAULT '0',
PRIMARY KEY (CustomFieldId),
KEY Type (Type)
)
# --------------------------------------------------------
CREATE TABLE CustomMetaData (
CustomDataId int(11) NOT NULL auto_increment,
ResourceId int(11) NOT NULL default '0',
CustomFieldId int(11) NOT NULL default '0',
Value text NOT NULL,
PRIMARY KEY (CustomDataId),
KEY ResourceId (ResourceId),
KEY CustomFieldId (CustomFieldId)
)
# --------------------------------------------------------
CREATE TABLE EmailMessage (
EmailMessageId int(10) NOT NULL auto_increment,
Template longtext,
MessageType enum('html','text') NOT NULL default 'text',
LanguageId int(11) NOT NULL default '0',
EventId int(11) NOT NULL default '0',
PRIMARY KEY (EmailMessageId)
)
# --------------------------------------------------------
CREATE TABLE EmailQueue (
Subject text NOT NULL,
toaddr text NOT NULL,
fromaddr text NOT NULL,
message blob,
headers blob,
queued timestamp NOT NULL
)
# --------------------------------------------------------
CREATE TABLE EmailSubscribers (
EmailMessageId int(11) NOT NULL default '0',
PortalUserId int(11) NOT NULL default '0'
)
# --------------------------------------------------------
CREATE TABLE Events (
EventId int(11) NOT NULL auto_increment,
Event varchar(40) NOT NULL default '',
Enabled int(11) NOT NULL default '1',
FromUserId int(11) NOT NULL default '0',
Module varchar(40) NOT NULL default '',
Description varchar(255) NOT NULL default '',
Type int(11) NOT NULL default '0',
PRIMARY KEY (EventId)
)
# --------------------------------------------------------
CREATE TABLE Favorites (
FavoriteId int(11) NOT NULL auto_increment,
PortalUserId int(11) NOT NULL default '0',
ResourceId int(11) NOT NULL default '0',
ItemTypeId int(11) NOT NULL default '0',
Modified int(11) NOT NULL default '0',
PRIMARY KEY (FavoriteId),
UNIQUE KEY main (PortalUserId,ResourceId)
)
# --------------------------------------------------------
CREATE TABLE IdGenerator (
lastid int(11) default NULL
)
# --------------------------------------------------------
CREATE TABLE Images (
ImageId int(11) NOT NULL auto_increment,
ResourceId int(11) NOT NULL default '0',
Url varchar(255) NOT NULL default '',
Name varchar(255) NOT NULL default '',
AltName varchar(255) default NULL,
ImageIndex int(11) NOT NULL default '0',
LocalImage tinyint(4) NOT NULL default '1',
LocalPath varchar(240) NOT NULL default '',
Enabled int(11) NOT NULL default '1',
DefaultImg int(11) NOT NULL default '0',
ThumbUrl varchar(255) default NULL,
Priority int(11) NOT NULL default '0',
ThumbPath varchar(255) default NULL,
LocalThumb tinyint(4) NOT NULL default '0',
SameImages tinyint(4) NOT NULL default '0',
PRIMARY KEY (ImageId),
KEY ResourceId (ResourceId)
)
# --------------------------------------------------------
CREATE TABLE ItemRating (
RatingId int(11) NOT NULL auto_increment,
IPAddress varchar(255) NOT NULL default '',
CreatedOn double NOT NULL default '0',
RatingValue int(11) NOT NULL default '0',
ItemId int(11) NOT NULL default '0',
PRIMARY KEY (RatingId)
)
# --------------------------------------------------------
CREATE TABLE ItemReview (
ReviewId int(11) NOT NULL auto_increment,
CreatedOn double NOT NULL default '0',
ReviewText longtext NOT NULL,
IPAddress varchar(255) NOT NULL default '',
ItemId int(11) NOT NULL default '0',
CreatedById int(11) NOT NULL default '0',
ItemType tinyint(4) NOT NULL default '0',
Priority int(11) NOT NULL default '0',
Status tinyint(4) NOT NULL default '0',
TextFormat int(11) NOT NULL default '0',
Module varchar(255) NOT NULL default '',
PRIMARY KEY (ReviewId)
)
# --------------------------------------------------------
CREATE TABLE ItemTypes (
ItemType int(11) NOT NULL default '0',
Module varchar(50) NOT NULL default '',
SourceTable varchar(100) NOT NULL default '',
TitleField varchar(50) default NULL,
CreatorField varchar(255) NOT NULL default '',
PopField varchar(255) default NULL,
RateField varchar(255) default NULL,
LangVar varchar(255) NOT NULL default '',
PrimaryItem int(11) NOT NULL default '0',
EditUrl varchar(255) NOT NULL default '',
ClassName varchar(40) NOT NULL default '',
ItemName varchar(50) NOT NULL default '',
PRIMARY KEY (ItemType),
KEY Module (Module)
)
# --------------------------------------------------------
CREATE TABLE Language (
LanguageId int(11) NOT NULL auto_increment,
PackName varchar(40) NOT NULL default '',
LocalName varchar(40) NOT NULL default '',
Enabled int(11) NOT NULL default '0',
PrimaryLang int(11) NOT NULL default '0',
IconURL varchar(255) default NULL,
DateFormat varchar(50) NOT NULL default '',
TimeFormat varchar(50) NOT NULL default '',
DecimalPoint char(2) NOT NULL default '.',
ThousandSep char(1) NOT NULL default ',',
Charset varchar(20) NOT NULL default '',
UnitSystem tinyint(4) NOT NULL default '1',
PRIMARY KEY (LanguageId)
)
# --------------------------------------------------------
CREATE TABLE Modules (
Name varchar(255) NOT NULL default '',
Path varchar(255) NOT NULL default '',
Var varchar(10) NOT NULL default '',
Version varchar(10) NOT NULL default '',
Loaded tinyint(4) NOT NULL default '1',
LoadOrder tinyint(4) NOT NULL default '0',
TemplatePath varchar(255) NOT NULL default '',
RootCat int(11) NOT NULL default '0',
BuildDate double NOT NULL default '0',
PRIMARY KEY (Name)
)
# --------------------------------------------------------
CREATE TABLE PermCache (
PermCacheId int(11) NOT NULL auto_increment,
CategoryId int(11) NOT NULL default '0',
PermId int(11) NOT NULL default '0',
ACL varchar(255) NOT NULL default '',
DACL varchar(255) NOT NULL default '',
PRIMARY KEY (PermCacheId),
KEY CategoryId (CategoryId),
KEY PermId (PermId)
)
# --------------------------------------------------------
CREATE TABLE PermissionConfig (
PermissionConfigId int(11) NOT NULL auto_increment,
PermissionName varchar(30) NOT NULL default '',
Description varchar(255) NOT NULL default '',
ErrorMessage varchar(255) NOT NULL default '',
ModuleId varchar(20) NOT NULL default '0',
PRIMARY KEY (PermissionConfigId),
KEY PermissionName (PermissionName)
)
# --------------------------------------------------------
CREATE TABLE Permissions (
PermissionId int(11) NOT NULL auto_increment,
Permission varchar(30) NOT NULL default '',
GroupId int(11) default '0',
PermissionValue int(11) NOT NULL default '0',
Type tinyint(4) NOT NULL default '0',
CatId int(11) NOT NULL default '0',
PRIMARY KEY (PermissionId)
)
# --------------------------------------------------------
CREATE TABLE PersistantSessionData (
PortalUserId int(11) NOT NULL default '0',
VariableName varchar(255) NOT NULL default '',
VariableValue text NOT NULL,
KEY UserId (PortalUserId),
KEY VariableName (VariableName)
)
# --------------------------------------------------------
CREATE TABLE Phrase (
Phrase varchar(255) NOT NULL default '',
Translation varchar(255) NOT NULL default '',
PhraseType int(11) NOT NULL default '0',
PhraseId int(11) NOT NULL auto_increment,
LanguageId int(11) NOT NULL default '0',
LastChanged int(10) unsigned NOT NULL default '0',
LastChangeIP varchar(15) NOT NULL default '',
Module varchar(30) NOT NULL default '',
PRIMARY KEY (PhraseId),
KEY LanguageId (LanguageId),
INDEX Phrase_Index (Phrase)
)
# --------------------------------------------------------
CREATE TABLE PhraseCache (
Template varchar(40) NOT NULL default '',
PhraseList text NOT NULL,
CacheDate int(11) NOT NULL default '0',
ThemeId int(11) NOT NULL default '0',
StylesheetId int(10) unsigned NOT NULL default '0',
PRIMARY KEY (Template)
)
# --------------------------------------------------------
CREATE TABLE PortalGroup (
GroupId int(11) NOT NULL auto_increment,
Name varchar(255) NOT NULL default '',
Description varchar(255) default NULL,
CreatedOn double NOT NULL default '0',
System tinyint(4) NOT NULL default '0',
Personal tinyint(4) NOT NULL default '0',
Enabled tinyint(4) NOT NULL default '1',
ResourceId int(11) NOT NULL default '0',
PRIMARY KEY (GroupId),
UNIQUE KEY Name (Name),
UNIQUE KEY ResourceId (ResourceId),
KEY Personal (Personal),
KEY Enabled (Enabled)
)
# --------------------------------------------------------
CREATE TABLE PortalUser (
PortalUserId int(11) NOT NULL auto_increment,
Login varchar(255) default NULL,
Password varchar(255) default NULL,
FirstName varchar(255) default NULL,
LastName varchar(255) default NULL,
Email varchar(255) NOT NULL default '',
CreatedOn double NOT NULL default '0',
Phone varchar(20) default NULL,
Street varchar(255) default NULL,
City varchar(20) default NULL,
State VARCHAR(20) NOT NULL,
Zip varchar(20) default NULL,
Country varchar(20) NOT NULL default '',
ResourceId int(11) NOT NULL default '0',
Status tinyint(4) NOT NULL default '2',
Modified int(11) NOT NULL default '0',
dob double NOT NULL default '0',
tz int(11) default NULL,
ip varchar(20) default NULL,
IsBanned tinyint(1) NOT NULL default '0',
PassResetTime bigint(20),
PwResetConfirm varchar(255),
PwRequestTime bigint(25),
MinPwResetDelay int(11) NOT NULL default '1800',
PRIMARY KEY (PortalUserId),
UNIQUE KEY Login (Login),
UNIQUE KEY ResourceId (ResourceId),
KEY CreatedOn (CreatedOn)
)
# --------------------------------------------------------
CREATE TABLE Relationship (
RelationshipId int(11) NOT NULL auto_increment,
SourceId int(11) default NULL,
TargetId int(11) default NULL,
SourceType tinyint(4) NOT NULL default '0',
TargetType tinyint(4) NOT NULL default '0',
Type int(11) NOT NULL default '0',
Enabled int(11) NOT NULL default '1',
Priority int(11) NOT NULL default '0',
PRIMARY KEY (RelationshipId),
KEY RelSource (SourceId),
KEY RelTarget (TargetId)
)
# --------------------------------------------------------
CREATE TABLE SearchConfig (
TableName varchar(40) NOT NULL default '',
FieldName varchar(40) NOT NULL default '',
SimpleSearch tinyint(4) NOT NULL default '0',
AdvancedSearch tinyint(4) NOT NULL default '0',
Description varchar(255) default NULL,
DisplayName varchar(80) default NULL,
ModuleName varchar(20) default NULL,
ConfigHeader varchar(255) default NULL,
DisplayOrder int(11) NOT NULL default '0',
SearchConfigId int(11) NOT NULL auto_increment,
Priority int(11) NOT NULL default '0',
FieldType varchar(20) NOT NULL default 'text',
ForeignField TEXT,
JoinClause TEXT,
IsWhere text,
IsNotWhere text,
ContainsWhere text,
NotContainsWhere text,
CustomFieldId int(11) NOT NULL default '0',
PRIMARY KEY (SearchConfigId)
)
# --------------------------------------------------------
CREATE TABLE SearchLog (
SearchLogId int(11) NOT NULL auto_increment,
Keyword varchar(255) NOT NULL default '',
Indices bigint(20) NOT NULL default '0',
SearchType int(11) NOT NULL default '0',
PRIMARY KEY (SearchLogId)
)
# --------------------------------------------------------
CREATE TABLE SessionData (
SessionKey varchar(50) NOT NULL default '',
VariableName varchar(255) NOT NULL default '',
VariableValue text NOT NULL,
PRIMARY KEY (`SessionKey`,`VariableName`),
KEY SessionKey (SessionKey),
KEY VariableName (VariableName)
)
# --------------------------------------------------------
CREATE TABLE SpamControl (
ItemResourceId int(11) NOT NULL default '0',
IPaddress varchar(20) NOT NULL default '',
Expire double NOT NULL default '0',
PortalUserId int(11) NOT NULL default '0',
DataType varchar(20) default NULL
)
# --------------------------------------------------------
CREATE TABLE StatItem (
StatItemId int(11) NOT NULL auto_increment,
Module varchar(20) NOT NULL default '',
ValueSQL varchar(255) default NULL,
ResetSQL varchar(255) default NULL,
ListLabel varchar(255) NOT NULL default '',
Priority int(11) NOT NULL default '0',
AdminSummary int(11) NOT NULL default '0',
PRIMARY KEY (StatItemId)
)
# --------------------------------------------------------
CREATE TABLE Theme (
ThemeId int(11) NOT NULL auto_increment,
Name varchar(40) NOT NULL default '',
Enabled int(11) NOT NULL default '1',
Description varchar(255) default NULL,
PrimaryTheme int(11) NOT NULL default '0',
CacheTimeout int(11) NOT NULL default '0',
StylesheetId INTEGER(10) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (ThemeId)
)
# --------------------------------------------------------
CREATE TABLE ThemeFiles (
FileId int(11) NOT NULL auto_increment,
ThemeId int(11) NOT NULL default '0',
FileName varchar(255) NOT NULL default '',
FilePath varchar(255) NOT NULL default '',
Description varchar(255) default NULL,
FileType int(11) NOT NULL default '0',
PRIMARY KEY (FileId),
KEY theme (ThemeId)
)
# --------------------------------------------------------
CREATE TABLE UserGroup (
PortalUserId int(11) NOT NULL default '0',
GroupId int(11) NOT NULL default '0',
PrimaryGroup tinyint(4) NOT NULL default '1',
PRIMARY KEY (PortalUserId,GroupId),
KEY GroupId (GroupId),
KEY PrimaryGroup (PrimaryGroup)
)
# --------------------------------------------------------
CREATE TABLE UserSession (
SessionKey varchar(50) NOT NULL default '',
CurrentTempKey varchar(50) default NULL,
PrevTempKey varchar(50) default NULL,
LastAccessed double NOT NULL default '0',
PortalUserId varchar(255) NOT NULL default '',
Language varchar(255) NOT NULL default '',
Theme varchar(255) NOT NULL default '',
GroupId int(11) NOT NULL default '0',
IpAddress varchar(20) NOT NULL default '0.0.0.0',
Status int(11) NOT NULL default '1',
GroupList varchar(255) default NULL,
tz int(11) default NULL,
PRIMARY KEY (SessionKey),
KEY UserId (PortalUserId),
KEY LastAccessed (LastAccessed)
)
# --------------------------------------------------------
CREATE TABLE SuggestMail (
email varchar(255) NOT NULL default '',
sent double,
PRIMARY KEY (email)
)
# --------------------------------------------------------
CREATE TABLE SysCache (
SysCacheId int(11) NOT NULL auto_increment,
Name varchar(255) NOT NULL default '',
Value mediumtext,
Expire double NOT NULL default '0',
Module varchar(20) default NULL,
Context varchar(255) default NULL,
GroupList varchar(255) NOT NULL default '',
PRIMARY KEY (SysCacheId),
KEY Name (Name)
)
# --------------------------------------------------------
CREATE TABLE TagLibrary (
TagId int(11) NOT NULL auto_increment,
name varchar(255) NOT NULL default '',
description text,
example text,
scope varchar(20) NOT NULL default 'global',
PRIMARY KEY (TagId)
)
# --------------------------------------------------------
CREATE TABLE TagAttributes (
AttrId int(11) NOT NULL auto_increment,
TagId int(11) NOT NULL default '0',
Name varchar(255) NOT NULL default '',
AttrType varchar(20) default NULL,
DefValue varchar(255) default NULL,
Description TEXT,
Required int(11) NOT NULL default '0',
PRIMARY KEY (AttrId)
)
# --------------------------------------------------------
CREATE TABLE EmailLog (
EmailLogId int(11) NOT NULL auto_increment,
fromuser varchar(200) default NULL,
addressto varchar(255) default NULL,
subject varchar(255) default NULL,
timestamp bigint(20) default '0',
event varchar(100) default NULL,
PRIMARY KEY (EmailLogId)
)
# --------------------------------------------------------
CREATE TABLE ImportScripts (
is_id smallint(5) unsigned NOT NULL auto_increment,
is_Module varchar(50) NOT NULL default '',
is_string_id varchar(10) NOT NULL default '',
is_script varchar(100) NOT NULL default '',
is_label varchar(255) NOT NULL default '',
is_field_prefix varchar(50) NOT NULL default '',
is_requred_fields varchar(255) NOT NULL default '',
is_enabled tinyint(1) unsigned NOT NULL default '0',
PRIMARY KEY (is_id)
)
# --------------------------------------------------------
CREATE TABLE Cache (
VarName varchar(255) NOT NULL default '',
Data longtext,
Cached int(11) default NULL,
PRIMARY KEY (VarName),
KEY Cached (Cached)
)
# --------------------------------------------------------
CREATE TABLE StylesheetSelectors (
SelectorId int(11) NOT NULL auto_increment,
StylesheetId int(11) NOT NULL default '0',
Name varchar(255) NOT NULL default '',
SelectorName varchar(255) NOT NULL default '',
SelectorData text NOT NULL,
Description text NOT NULL,
Type tinyint(4) NOT NULL default '0',
AdvancedCSS text NOT NULL,
ParentId int(11) NOT NULL default '0',
PRIMARY KEY (SelectorId)
)
# --------------------------------------------------------
CREATE TABLE Stylesheets (
StylesheetId int(11) NOT NULL auto_increment,
Name varchar(255) NOT NULL default '',
Description varchar(255) NOT NULL default '',
AdvancedCSS text NOT NULL,
LastCompiled int(10) unsigned NOT NULL default '0',
Enabled int(11) NOT NULL default '0',
PRIMARY KEY (StylesheetId)
)
# --------------------------------------------------------
\ No newline at end of file
Property changes on: trunk/admin/install/inportal_schema.sql
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.18
\ No newline at end of property
+1.19
\ No newline at end of property
Index: trunk/core/kernel/db/db_tag_processor.php
===================================================================
--- trunk/core/kernel/db/db_tag_processor.php (revision 1794)
+++ trunk/core/kernel/db/db_tag_processor.php (revision 1795)
@@ -1,1226 +1,1228 @@
<?php
class kDBTagProcessor extends TagProcessor {
/**
* Description
*
* @var DBConnection
* @access public
*/
var $Conn;
function kDBTagProcessor()
{
parent::kBase();
$this->Conn =& $this->Application->GetADODBConnection();
}
function IsNew($params)
{
$object =& $this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix, $params );
return $object->GetID();
}
/**
* Returns view menu name for current prefix
*
* @param Array $params
* @return string
*/
function GetItemName($params)
{
$item_name = $this->Application->getUnitOption($this->Prefix,'ViewMenuPhrase');
return $this->Application->Phrase($item_name);
}
function ViewMenu($params)
{
$block_params = $params;
unset($block_params['block']);
$block_params['name'] = $params['block'];
$list =& $this->GetList($params);
$block_params['PrefixSpecial'] = $list->getPrefixSpecial();
return $this->Application->ParseBlock($block_params);
}
function SearchKeyword($params)
{
$list =& $this->GetList($params);
return $this->Application->RecallVar($list->getPrefixSpecial().'_search_keyword');
}
/**
* Draw filter menu content (for ViewMenu) based on filters defined in config
*
* @param Array $params
* @return string
*/
function DrawFilterMenu($params)
{
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $params['spearator_block'];
$separator = $this->Application->ParseBlock($block_params);
$filter_menu = $this->Application->getUnitOption($this->Prefix,'FilterMenu');
// Params: label, filter_action, filter_status
$block_params['name'] = $params['item_block'];
$view_filter = $this->Application->RecallVar($this->getPrefixSpecial().'_view_filter');
if($view_filter === false)
{
$event_params = Array('prefix'=>$this->Prefix,'special'=>$this->Special,'name'=>'OnRemoveFilters');
$this->Application->HandleEvent( new kEvent($event_params) );
$view_filter = $this->Application->RecallVar($this->getPrefixSpecial().'_view_filter');
}
$view_filter = unserialize($view_filter);
$filters = Array();
$prefix_special = $this->getPrefixSpecial();
foreach($filter_menu['Filters'] as $filter_key => $filter_params)
{
if(!$filter_params)
{
$filters[] = $separator;
continue;
}
$block_params['label'] = addslashes( $this->Application->Phrase($filter_params['label']) );
if( getArrayValue($view_filter,$filter_key) )
{
$submit = 0;
$status = 1;
}
else
{
$submit = 1;
$status = 0;
}
$block_params['filter_action'] = 'set_filter("'.$prefix_special.'","'.$filter_key.'","'.$submit.'");';
$block_params['filter_status'] = $status;
$filters[] = $this->Application->ParseBlock($block_params);
}
return implode('', $filters);
}
function IterateGridFields($params)
{
$mode = $params['mode'];
$def_block = $params['block'];
$grids = $this->Application->getUnitOption($this->Prefix,'Grids');
$grid_config = $grids[$params['grid']]['Fields'];
$std_params['pass_params']='true';
$std_params['PrefixSpecial']=$this->getPrefixSpecial();
$o = '';
foreach ($grid_config as $field => $options) {
$block_params = Array();
$block_params['name'] = isset($options[$mode.'_block']) ? $options[$mode.'_block'] : $def_block;
$block_params['field'] = $field;
$block_params['sort_field'] = isset($options['sort_field']) ? $options['sort_field'] : $field;
$block_params = array_merge($std_params, $block_params, $options);
$o.= $this->Application->ParseBlock($block_params, 1);
}
return $o;
}
/**
* Prints list content using block specified
*
* @param Array $params
* @return string
* @access public
*/
function PrintList($params)
{
// $list =& $this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix.'_List',$params);
$list =& $this->GetList($params);
$id_field = $this->Application->getUnitOption($this->Prefix,'IDField');
$list->Query();
$o = '';
$list->GoFirst();
$block_params=$this->prepareTagParams($params);
$block_params['name'] = $this->SelectParam($params, 'render_as,block');
$block_params['pass_params'] = 'true';
while (!$list->EOL())
{
$this->Application->SetVar( $this->getPrefixSpecial().'_id', $list->GetDBField($id_field) ); // for edit/delete links using GET
$o.= $this->Application->ParseBlock($block_params, 1);
$list->GoNext();
}
$this->Application->SetVar( $this->getPrefixSpecial().'_id', '');
return $o;
}
function InitList($params)
{
$list_name = $params['list_name'];
$names_mapping = $this->Application->GetVar('NamesToSpecialMapping');
if( !getArrayValue($names_mapping,$list_name) )
{
$list =& $this->GetList($params);
}
}
function BuildListSpecial($params)
{
return $this->Special;
}
/**
* Enter description here...
*
* @param unknown_type $params
* @return kDBList
*/
function &GetList($params)
{
$list_name = $this->SelectParam($params, 'list_name,name');
if (!$list_name) {
$list_name = $this->Application->Parser->GetParam('list_name');
}
$requery = getArrayValue($params, 'requery');
if ($list_name && !$requery){
$names_mapping = $this->Application->GetVar('NamesToSpecialMapping');
$special = getArrayValue($names_mapping, $list_name);
if(!$special)
{
$special = $this->BuildListSpecial($params);
}
}
else
{
$special = $this->BuildListSpecial($params);
}
$prefix_special = rtrim($this->Prefix.'.'.$special, '.');
$params['skip_counting'] = true;
$list =& $this->Application->recallObject( $prefix_special, $this->Prefix.'_List',$params);
$list->Query();
$this->Special = $special;
if ($list_name) {
$names_mapping[$list_name] = $special;
$this->Application->SetVar('NamesToSpecialMapping', $names_mapping);
}
return $list;
}
function ListMarker($params)
{
$list =& $this->GetList($params);
return $list->getPrefixSpecial();
}
function SubmitName($params)
{
$list =& $this->GetList($params);
$prefix_special = $list->getPrefixSpecial();
return 'events['.$prefix_special.']['.$params['event'].']';
}
function CombinedSortingDropDownName($params)
{
$list =& $this->GetList($params);
$prefix_special = $list->getPrefixSpecial();
return $prefix_special.'_CombinedSorting';
}
function SortingSelected($params)
{
$list =& $this->GetList($params);
$user_sorting_start = $this->getUserSortIndex();
$sorting = strtolower($list->GetOrderField($user_sorting_start).'|'.$list->GetOrderDirection($user_sorting_start));
if ($sorting == strtolower($params['sorting'])) return $params['selected'];
}
/**
* Prints list content using block specified
*
* @param Array $params
* @return string
* @access public
*/
function PrintList2($params)
{
$per_page = $this->SelectParam($params, 'per_page,max_items');
if ($per_page !== false) $params['per_page'] = $per_page;
$list =& $this->GetList($params);
$o = '';
$direction = (isset($params['direction']) && $params['direction']=="H")?"H":"V";
$columns = (isset($params['columns'])) ? $params['columns'] : 1;
$id_field = (isset($params['id_field'])) ? $params['id_field'] : $this->Application->getUnitOption($this->Prefix, 'IDField');
if ($columns>1 && $direction=="V") {
$list->Records = $this->LinearToVertical($list->Records, $columns, $list->GetPerPage());
$list->SelectedCount=count($list->Records);
ksort($list->Records);
}
$list->GoFirst();
$block_params=$this->prepareTagParams($params);
$block_params['name']=$this->SelectParam($params, 'render_as,block');
$block_params['pass_params']='true';
$block_start_row_params=$this->prepareTagParams($params);
$block_start_row_params['name'] = $this->SelectParam($params, 'row_start_render_as,block_row_start,row_start_block');
$block_end_row_params=$this->prepareTagParams($params);
$block_end_row_params['name'] = $this->SelectParam($params, 'row_end_render_as,block_row_end,row_end_block');
$block_empty_cell_params = $this->prepareTagParams($params);
$block_empty_cell_params['name'] = $this->SelectParam($params, 'empty_cell_render_as,block_empty_cell,empty_cell_block');
$i=0;
$backup_id=$this->Application->GetVar($this->Prefix."_id");
$displayed = array();
while (!$list->EOL())
{
$this->Application->SetVar( $this->getPrefixSpecial().'_id', $list->GetDBField($id_field) ); // for edit/delete links using GET
$this->Application->SetVar( $this->Prefix.'_id', $list->GetDBField($id_field) );
if ($i % $columns == 0) {
$o.= $block_start_row_params['name'] ? $this->Application->ParseBlock($block_start_row_params, 1) : '<tr>';
}
if (!$list->getCurrentRecord()){
$o.= $block_empty_cell_params['name'] ? $this->Application->ParseBlock($block_params, 1) : '<td>&nbsp;</td>';
}
else {
$o.= $this->Application->ParseBlock($block_params, 1);
array_push($displayed, $list->GetDBField($id_field));
}
if (($i+1) % $columns == 0) {
$o.= $block_end_row_params['name'] ? $this->Application->ParseBlock($block_end_row_params, 1) : '</tr>';
}
$list->GoNext();
$i++;
}
$cur_displayed = $this->Application->GetVar($this->Prefix.'_displayed_ids');
if (!$cur_displayed) {
$cur_displayed = Array();
}
else {
$cur_displayed = explode(',', $cur_displayed);
}
$displayed = array_unique(array_merge($displayed, $cur_displayed));
$this->Application->SetVar($this->Prefix.'_displayed_ids', implode(',',$displayed));
$this->Application->SetVar( $this->Prefix.'_id', $backup_id);
$this->Application->SetVar( $this->getPrefixSpecial().'_id', '');
if (isset($params['more_link_render_as'])) {
$block_params = $params;
$params['render_as'] = $params['more_link_render_as'];
$o .= $this->MoreLink($params);
}
return $o;
}
function MoreLink($params)
{
$per_page = $this->SelectParam($params, 'per_page,max_items');
if ($per_page !== false) $params['per_page'] = $per_page;
$list =& $this->GetList($params);
if ($list->PerPage < $list->RecordsCount) {
$block_params = array();
$block_params['name'] = $this->SelectParam($params, 'render_as,block');
return $this->Application->ParseBlock($block_params, 1);
}
}
function NotLastItem($params)
{
$list =& $this->Application->recallObject($this->getPrefixSpecial());
return ($list->CurrentIndex < min($list->PerPage, $list->RecordsCount)-1);
}
function PageLink($params)
{
$t = isset($params['template']) ? $param['template'] : '';
if (!$t) $t = $this->Application->GetVar('t');
if (isset($params['page'])) {
$this->Application->SetVar($this->getPrefixSpecial().'_Page', $params['page']);
}
$pass = Array('pass' => 'all,'.$this->getPrefixSpecial());
// $pass = Array('pass' => 'all');
$http_query =& $this->Application->recallObject('HTTPQuery');
$get = $http_query->Get;
unset($get['env']);
// $pass = array_merge($get, $pass);
return $this->Application->HREF($t, '', $pass);
}
function ColumnWidth($params)
{
$columns = $this->Application->Parser->GetParam('columns');
return round(100/$columns).'%';
}
/**
* Append prefix and special to tag
* params (get them from tagname) like
* they were really passed as params
*
* @param Array $tag_params
* @return Array
* @access protected
*/
function prepareTagParams($tag_params=Array())
{
$ret=$tag_params;
$ret['Prefix']=$this->Prefix;
$ret['Special']=$this->Special;
$ret['PrefixSpecial']=$this->getPrefixSpecial();
return $ret;
}
function GetISO($currency)
{
if ($currency == 'selected') {
$iso = $this->Application->RecallVar('curr_iso');
}
elseif ($currency == 'primary' || $currency == '') {
$iso = $this->Application->GetPrimaryCurrency();
}
else { //explicit currency
$iso = $currency;
}
return $iso;
}
function ConvertCurrency($value, $iso)
{
$converter =& $this->Application->recallObject('kCurrencyRates');
// convery primary currency to selected (if they are the same, converter will just return)
$value = $converter->Convert($value, 'PRIMARY', $iso);
return $value;
}
function AddCurrencySymbol($value, $iso)
{
$this->Application->setUnitOption('curr', 'AutoLoad', false);
$currency =& $this->Application->recallObject('curr.-'.$iso);
if (!$currency->Loaded) {
$currency->Load($iso, 'ISO');
}
$symbol = $currency->GetDBField('Symbol');
if (!$symbol) $symbol = $currency->GetDBField('ISO').'&nbsp;';
if ($currency->GetDBField('SymbolPosition') == 0) {
$value = $symbol.$value;
}
if ($currency->GetDBField('SymbolPosition') == 1) {
$value = $value.$symbol;
}
return $value;
}
/**
* Get's requested field value
*
* @param Array $params
* @return string
* @access public
*/
function Field($params)
{
$field = $this->SelectParam($params, 'name,field');
if( !$this->Application->IsAdmin() ) $params['no_special'] = 'no_special';
$object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params);
if ( getArrayValue($params, 'db') !== false )
{
$value = $object->GetDBField($field);
}
else
{
if (isset($params['currency'])) {
$iso = $this->GetISO($params['currency']);
$original = $object->GetDBField($field);
$value = $this->ConvertCurrency($original, $iso);
$object->SetDBField($field, $value);
$object->Fields[$field]['converted'] = true;
}
$format = getArrayValue($params, 'format');
if( !$format || $format == '$format' )
{
$format = null;
}
else
{
if(preg_match("/_regional_(.*)/", $format, $regs))
{
$lang =& $this->Application->recallObject('lang.current');
$format = $lang->GetDBField($regs[1]);
}
}
$value = $object->GetField($field, $format);
if (isset($params['currency'])) {
$value = $this->AddCurrencySymbol($value, $iso);
$params['no_special'] = 1;
}
}
if( getArrayValue($params,'nl2br' ) ) $value = nl2br($value);
if( !$this->HasParam($params, 'no_special') ) $value = htmlspecialchars($value);
if( getArrayValue($params,'checked' ) ) $value = ($value == 1) ? 'checked' : '';
if( getArrayValue($params,'as_label') ) $value = $this->Application->Phrase($value);
$first_chars = $this->SelectParam($params,'first_chars,cut_first');
if($first_chars)
{
$needs_cut = strlen($value) > $first_chars;
$value = substr($value,0,$first_chars);
if($needs_cut) $value .= ' ...';
}
if ($value != '') $this->Application->Parser->DataExists = true;
if (isset($params['currency'])) {
//restoring value in original currency, for other Field tags to work properly
$object->SetDBField($field, $original);
}
return $value;
}
/**
* Checks if parameter is passed
* Note: works like Tag and line simple method too
*
* @param Array $params
* @param string $param_name
* @return bool
*/
function HasParam($params, $param_name = null)
{
if( !isset($param_name) )
{
$param_name = $this->SelectParam($params, 'name');
$params = $this->Application->Parser->Params;
}
$value = getArrayValue($params, $param_name);
return $value && ($value != '$'.$param_name);
}
function PhraseField($params)
{
$field_label = $this->Field($params);
$translation = $this->Application->Phrase( $field_label );
return $translation;
}
function Error($params)
{
$field = $params['field'];
$object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params);
$msg = $object->GetErrorMsg($field);
return $msg;
}
function HasError($params)
{
if ($params['field'] == 'any') {
$object =& $this->Application->recallObject($this->getPrefixSpecial());
return $object->HasErrors();
}
else {
return $this->Error($params) != '';
}
}
function IsRequired($params)
{
$field = $params['field'];
$object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params);
$options = $object->GetFieldOptions($field);
return getArrayValue($options,'required');
}
function PredefinedOptions($params)
{
$field = $params['field'];
$object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params);
$value = $object->GetDBField($field);
$options = $object->GetFieldOptions($field);
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $this->SelectParam($params, 'render_as,block');
$block_params['field'] = $params['field'];
$block_params['pass_params'] = 'true';
$selected_param_name = getArrayValue($params,'selected_param');
if(!$selected_param_name) $selected_param_name = $params['selected'];
$selected = $params['selected'];
$o = '';
if( $this->HasParam($params,'no_empty') && !getArrayValue($options['options'],'') ) array_shift($options['options']);
foreach ($options['options'] as $key => $val) {
$block_params['key'] = $key;
$block_params['option'] = $val;
$block_params['field_name'] = $this->InputName($params);
$block_params[$selected_param_name] = ( $key == $value ? ' '.$selected : '');
$block_params['PrefixSpecial'] = $this->getPrefixSpecial();
$o .= $this->Application->ParseBlock($block_params, 1);
}
return $o;
}
function Format($params)
{
$field = $params['field'];
$object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params);
$options = $object->GetFieldOptions($field);
$formatter_class = getArrayValue($options,'formatter');
if($formatter_class)
{
$formatter =& $this->Application->recallObject($formatter_class);
$human_format = getArrayValue($params,'human');
$edit_size = getArrayValue($params,'edit_size');
$sample = getArrayValue($params,'sample');
if($sample)
{
return $formatter->GetSample($field, $options, $object);
}
elseif($human_format || $edit_size)
{
$format = $formatter->HumanFormat($options['format']);
return $edit_size ? strlen($format) : $format;
}
}
return $options['format'];
}
/**
* Print grid pagination using
* block names specified
*
* @param Array $params
* @return string
* @access public
*/
function PrintPages($params)
{
$list =& $this->GetList($params);
$prefix_special = $list->getPrefixSpecial();
$total_pages = $list->GetTotalPages();
if ($total_pages) $this->Application->Parser->DataExists = true;
$o = '';
// what are these 2 lines for?
$this->Application->SetVar($prefix_special.'_event','');
$this->Application->SetVar($prefix_special.'_id','');
$current_page = $this->Application->RecallVar($prefix_special.'_Page');
$block_params = $this->prepareTagParams($params);
$split = ( isset($params['split'] ) ? $params['split'] : 10 );
$split_start = $current_page - ceil($split/2);
if ($split_start < 1){
$split_start = 1;
}
$split_end = $split_start + $split-1;
if ($split_end > $total_pages) {
$split_end = $total_pages;
$split_start = max($split_end - $split + 1, 1);
}
if ($current_page > 1){
$prev_block_params = $this->prepareTagParams();
if ($total_pages > $split){
$prev_block_params['page'] = max($current_page-$split, 1);
$prev_block_params['name'] = $this->SelectParam($params, 'prev_page_split_render_as,prev_page_split_block');
if ($prev_block_params['name']){
$o .= $this->Application->ParseBlock($prev_block_params, 1);
}
}
$prev_block_params['name'] = 'page';
$prev_block_params['page'] = $current_page-1;
$prev_block_params['name'] = $this->SelectParam($params, 'prev_page_render_as,block_prev_page,prev_page_block');
if ($prev_block_params['name']) {
$this->Application->SetVar($this->getPrefixSpecial().'_Page', $current_page-1);
$o .= $this->Application->ParseBlock($prev_block_params, 1);
}
}
else {
if ( $no_prev_page_block = $this->SelectParam($params, 'no_prev_page_render_as,block_no_prev_page') ) {
$block_params['name'] = $no_prev_page_block;
$o .= $this->Application->ParseBlock($block_params, 1);
}
}
$separator_params['name'] = $this->SelectParam($params, 'separator_render_as,block_separator');
for ($i = $split_start; $i <= $split_end; $i++)
{
if ($i == $current_page) {
$block = $this->SelectParam($params, 'current_render_as,active_render_as,block_current,active_block');
}
else {
$block = $this->SelectParam($params, 'link_render_as,inactive_render_as,block_link,inactive_block');
}
$block_params['name'] = $block;
$block_params['page'] = $i;
$this->Application->SetVar($this->getPrefixSpecial().'_Page', $i);
$o .= $this->Application->ParseBlock($block_params, 1);
if ($this->SelectParam($params, 'separator_render_as,block_separator')
&& $i < $split_end)
{
$o .= $this->Application->ParseBlock($separator_params, 1);
}
}
if ($current_page < $total_pages){
$next_block_params = $this->prepareTagParams();
$next_block_params['page']=$current_page+1;
$next_block_params['name'] = $this->SelectParam($params, 'next_page_render_as,block_next_page,next_page_block');
if ($next_block_params['name']){
$this->Application->SetVar($this->getPrefixSpecial().'_Page', $current_page+1);
$o .= $this->Application->ParseBlock($next_block_params, 1);
}
if ($total_pages > $split){
$next_block_params['page']=min($current_page+$split, $total_pages);
$next_block_params['name'] = $this->SelectParam($params, 'next_page_split_render_as,next_page_split_block');
if ($next_block_params['name']){
$o .= $this->Application->ParseBlock($next_block_params, 1);
}
}
}
return $o;
}
/**
* Print grid pagination using
* block names specified
*
* @param Array $params
* @return string
* @access public
*/
function PaginationBar($params)
{
return $this->PrintPages($params);
}
/**
* Returns input field name to
* be placed on form (for correct
* event processing)
*
* @param Array $params
* @return string
* @access public
*/
function InputName($params)
{
$prefix_special=$this->getPrefixSpecial();
$object =& $this->Application->recallObject($prefix_special);
if ( $formatter = getArrayValue($object->Fields, $params['field'], 'formatter') ) {
if ( $formatter == 'kMultiLanguage' ) {
$formatter =& $this->Application->recallObject($formatter);
$params['field'] = $formatter->LangFieldName($params['field']);
}
}
if ( $idfield = getArrayValue($params, 'IdField') ) {
$id = $object->GetDBField($idfield);
}
else {
$id = $object->GetID();
}
return $prefix_special.'['.$id.']['.$params['field'].']';
}
/**
* Returns index where 1st changable sorting field begins
*
* @return int
* @access private
*/
function getUserSortIndex()
{
$list_sortings = $this->Application->getUnitOption($this->Prefix, 'ListSortings');
$sorting_prefix = getArrayValue($list_sortings, $this->Special) ? $this->Special : '';
$user_sorting_start = 0;
if ( $forced_sorting = getArrayValue($list_sortings, $sorting_prefix, 'ForcedSorting') ) {
$user_sorting_start = count($forced_sorting);
}
return $user_sorting_start;
}
/**
* Returns order direction for given field
*
*
*
* @param Array $params
* @return string
* @access public
*/
function Order($params)
{
$field = $params['field'];
$user_sorting_start = $this->getUserSortIndex();
$list =& $this->GetList($params);
if ($list->GetOrderField($user_sorting_start) == $field)
{
return strtolower($list->GetOrderDirection($user_sorting_start));
}
elseif($list->GetOrderField($user_sorting_start+1) == $field)
{
return '2_'.strtolower($list->GetOrderDirection($user_sorting_start+1));
}
else
{
return 'no';
}
}
/**
* Get's information of sorting field at "pos" position,
* like sorting field name (type="field") or sorting direction (type="direction")
*
* @param Array $params
* @return mixed
*/
function OrderInfo($params)
{
$user_sorting_start = $this->getUserSortIndex() + --$params['pos'];
$list =& $this->GetList($params);
// $object =& $this->Application->recallObject( $this->getPrefixSpecial() );
if($params['type'] == 'field') return $list->GetOrderField($user_sorting_start);
if($params['type'] == 'direction') return $list->GetOrderDirection($user_sorting_start);
}
/**
* Checks if sorting field/direction matches passed field/direction parameter
*
* @param Array $params
* @return bool
*/
function IsOrder($params)
{
$params['type'] = isset($params['field']) ? 'field' : 'direction';
$value = $this->OrderInfo($params);
if( isset($params['field']) ) return $params['field'] == $value;
if( isset($params['direction']) ) return $params['direction'] == $value;
}
/**
* Returns list perpage
*
* @param Array $params
* @return int
*/
function PerPage($params)
{
$object =& $this->Application->recallObject( $this->getPrefixSpecial() );
return $object->PerPage;
}
/**
* Checks if list perpage matches value specified
*
* @param Array $params
* @return bool
*/
function PerPageEquals($params)
{
$object =& $this->Application->recallObject( $this->getPrefixSpecial() );
return $object->PerPage == $params['value'];
}
function SaveEvent($params)
{
// SaveEvent is set during onbuild, but we may need it before any other tag calls onBuild
$prefix_special = $this->getPrefixSpecial();
$item = $this->Application->recallObject($prefix_special);
return $this->Application->GetVar($prefix_special.'_SaveEvent');
}
function NextId($params)
{
$prefix_special=$this->getPrefixSpecial();
$ids = explode(',', $this->Application->RecallVar($prefix_special.'_selected_ids'));
$item = $this->Application->recallObject($prefix_special);
$cur_id = $item->GetId();
$i = array_search($cur_id,$ids);
if ($i !== false) {
return $i < count($ids)-1 ? $ids[$i+1] : '';
}
return '';
}
function PrevId($params)
{
$prefix_special=$this->getPrefixSpecial();
$ids = explode(',', $this->Application->RecallVar($prefix_special.'_selected_ids'));
$item = $this->Application->recallObject($prefix_special);
$cur_id = $item->GetId();
$i = array_search($cur_id,$ids);
if ($i !== false) {
return $i > 0 ? $ids[$i-1] : '';
}
return '';
}
function IsSingle($params)
{
return ($this->NextId($params) === '' && $this->PrevId($params) === '');
}
function IsLast($params)
{
return ($this->NextId($params) === '');
}
function IsFirst($params)
{
return ($this->PrevId($params) === '');
}
/**
* Checks if field value is equal to proposed one
*
* @param Array $params
* @return bool
*/
function FieldEquals($params)
{
$object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params);
$ret = $object->GetDBField($this->SelectParam($params, 'name,field')) == $params['value'];
// if( getArrayValue($params,'inverse') ) $ret = !$ret;
return $ret;
}
function ItemIcon($params)
{
$object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params);
$grids = $this->Application->getUnitOption($this->Prefix,'Grids');
$icons =& $grids[ $params['grid'] ]['Icons'];
$key = '';
$status_fields = $this->Application->getUnitOption($this->Prefix,'StatusField');
if(!$status_fields) return $icons['default'];
foreach($status_fields as $status_field)
{
$key .= $object->GetDBField($status_field).'_';
}
$key = rtrim($key,'_');
$value = ($key !== false) ? $key : 'default';
return isset($icons[$value]) ? $icons[$value] : $icons['default'];
}
/**
* Generates bluebar title + initializes prefixes used on page
*
* @param Array $params
* @return string
*/
function SectionTitle($params)
{
$title_presets = $this->Application->getUnitOption($this->Prefix,'TitlePresets');
$title_info = getArrayValue($title_presets, $params['title_preset'] );
if($title_info === false) return $params['title'];
if( getArrayValue($title_presets,'default') )
{
// use default labels + custom labels specified in preset used
$title_info = array_merge_recursive2($title_presets['default'], $title_info);
}
$title = $title_info['format'];
// 1. get objects in use for title construction
$objects = Array();
$object_status = Array();
$status_labels = Array();
$prefixes = getArrayValue($title_info,'prefixes');
if($prefixes)
{
foreach($prefixes as $prefix_special)
{
$prefix_data = $this->Application->processPrefix($prefix_special);
$prefix_data['prefix_special'] = rtrim($prefix_data['prefix_special'],'.');
$objects[ $prefix_data['prefix_special'] ] =& $this->Application->recallObject($prefix_data['prefix_special'], $prefix_data['prefix'], $params);
$object_status[ $prefix_data['prefix_special'] ] = $objects[ $prefix_data['prefix_special'] ]->GetID() ? 'edit' : 'new';
// a. set object's status field (adding item/editing item) for each object in title
if( getArrayValue($title_info[ $object_status[ $prefix_data['prefix_special'] ].'_status_labels' ],$prefix_data['prefix_special']) )
{
$status_labels[ $prefix_data['prefix_special'] ] = $title_info[ $object_status[ $prefix_data['prefix_special'] ].'_status_labels' ][ $prefix_data['prefix_special'] ];
$title = str_replace('#'.$prefix_data['prefix_special'].'_status#', $status_labels[ $prefix_data['prefix_special'] ], $title);
}
// b. setting object's titlefield value (in titlebar ONLY) to default in case if object beeing created with no titlefield filled in
if( $object_status[ $prefix_data['prefix_special'] ] == 'new' )
{
$new_value = $this->getInfo( $objects[ $prefix_data['prefix_special'] ], 'titlefield' );
if(!$new_value && getArrayValue($title_info['new_titlefield'],$prefix_data['prefix_special']) ) $new_value = $this->Application->Phrase($title_info['new_titlefield'][ $prefix_data['prefix_special'] ]);
$title = str_replace('#'.$prefix_data['prefix_special'].'_titlefield#', $new_value, $title);
}
}
}
// 2. replace phrases if any found in format string
$title = $this->Application->ReplaceLanguageTags($title,false);
// 3. find and replace any replacement vars
preg_match_all('/#(.*_.*)#/Uis',$title,$rets);
if($rets[1])
{
$replacement_vars = array_keys( array_flip($rets[1]) );
foreach($replacement_vars as $replacement_var)
{
$var_info = explode('_',$replacement_var,2);
$object =& $objects[ $var_info[0] ];
$new_value = $this->getInfo($object,$var_info[1]);
$title = str_replace('#'.$replacement_var.'#', $new_value, $title);
}
}
$cut_first = getArrayValue($params,'cut_first');
if( $cut_first && strlen($title) > $cut_first && !preg_match('/<a href="(.*)">(.*)<\/a>/',$title) ) $title = substr($title, 0, $cut_first).' ...';
return $title;
}
function getInfo(&$object, $info_type)
{
switch ($info_type)
{
case 'titlefield':
$field = $this->Application->getUnitOption($object->Prefix,'TitleField');
return $field !== false ? $object->GetField($field) : 'TitleField Missing';
break;
case 'recordcount':
$of_phrase = $this->Application->Phrase('la_of');
return $object->NoFilterCount != $object->RecordsCount ? $object->RecordsCount.' '.$of_phrase.' '.$object->NoFilterCount : $object->RecordsCount;
break;
default:
break;
}
}
/**
* Parses block depending on its element type.
* For radio and select elements values are taken from 'value_list_field' in key1=value1,key2=value2
* format. key=value can be substituted by <SQL>SELECT f1 AS OptionName, f2 AS OptionValue... FROM <PREFIX>TableName </SQL>
* where prefix is TABLE_PREFIX
*
* @param Array $params
* @return string
*/
function ConfigFormElement($params)
{
$object =& $this->Application->recallObject( $this->getPrefixSpecial() );
$field = $params['field'];
$helper = $this->Application->recallObject('InpCustomFieldsHelper');
$element_type = $object->GetDBField($params['element_type_field']);
if($element_type=='label') $element_type='text';
$params['name']= $params['blocks_prefix'] . $element_type;
switch ($element_type){
case 'select':
case 'radio':
$field_options = $object->GetFieldOptions($field, 'options');
$field_options['options'] = $helper->GetValuesHash( $object->GetDBField($params['value_list_field']) );
$object->SetFieldOptions($field, $field_options);
break;
case 'textarea':
$params['field_params'] = $helper->ParseConfigSQL($object->GetDBField($params['value_list_field']));
break;
case 'password':
case 'text':
case 'checkbox':
default:
break;
}
return $this->Application->ParseBlock($params, 1);
}
/**
* Get's requested custom field value
*
* @param Array $params
* @return string
* @access public
*/
function CustomField($params)
{
$prefix = $this->Prefix;
$object =& $this->Application->recallObject( $prefix );
$field = $this->SelectParam($params, 'name,field');
- $sql = ' SELECT cv.Value FROM '.TABLE_PREFIX.'CustomField cf
+ $lang_id = $this->Application->GetVar('m_lang');
+
+ $sql = ' SELECT cv.l'.$lang_id.'_Value FROM '.TABLE_PREFIX.'CustomField cf
LEFT JOIN '.TABLE_PREFIX.'CustomMetaData cv
ON cf.CustomFieldId = cv.CustomFieldId
WHERE cf.Type = '.$this->Application->getUnitOption($prefix, 'ItemType').'
AND cv.ResourceId = '.$object->GetDBField('ResourceId').'
AND cf.FieldName = "'.$field.'"';
return $this->Conn->GetOne($sql);
}
function CustomFieldLabel($params)
{
$prefix = $this->Prefix;
$object =& $this->Application->recallObject( $prefix );
$field = $this->SelectParam($params, 'name,field');
$sql = ' SELECT FieldLabel FROM '.TABLE_PREFIX.'CustomField WHERE FieldName = "'.$field.'"';
return $this->Application->Phrase($this->Conn->GetOne($sql));
}
/**
* transposes 1-dimensional array elements for vertical alignment according to given columns and per_page parameters
*
* @param array $arr
* @param int $columns
* @param int $per_page
* @return array
*/
function LinearToVertical(&$arr, $columns, $per_page)
{
$rows=$columns;
$cols=min(ceil($per_page/$columns), ceil(sizeof($arr)/$columns));
$imatrix=array();
for ($row=0; $row<$rows; $row++) {
for ($col=0; $col<$cols; $col++){
$imatrix[$col*$rows+$row]=$arr[$row*$cols+$col];
}
}
ksort($imatrix);
reset($imatrix);
return $imatrix;
}
/**
* If data was modfied & is in TempTables mode, then parse block with name passed;
* remove modification mark if not in TempTables mode
*
* @param Array $params
* @return string
* @access public
* @author Alexey
*/
function SaveWarning($params)
{
$main_prefix = getArrayValue($params, 'main_prefix');
if($main_prefix && $main_prefix != '$main_prefix')
{
$top_prefix = $main_prefix;
}
else
{
$top_prefix = $this->Application->GetTopmostPrefix($this->Prefix);
}
$temp_tables = $this->Application->GetVar($top_prefix.'_mode') == 't';
$modified = $this->Application->RecallVar($top_prefix.'_modified');
if($temp_tables && $modified)
{
return $this->Application->ParseBlock($params);
}
$this->Application->RemoveVar($top_prefix.'_modified');
return '';
}
/**
* Returns list record count queries (on all pages)
*
* @param Array $params
* @return int
*/
function TotalRecords($params)
{
$list =& $this->GetList($params);
if (!$list->Counted) $list->CountRecs();
return $list->RecordsCount;
}
}
?>
\ No newline at end of file
Property changes on: trunk/core/kernel/db/db_tag_processor.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.10
\ No newline at end of property
+1.11
\ No newline at end of property
Index: trunk/core/kernel/db/db_event_handler.php
===================================================================
--- trunk/core/kernel/db/db_event_handler.php (revision 1794)
+++ trunk/core/kernel/db/db_event_handler.php (revision 1795)
@@ -1,1423 +1,1428 @@
<?php
define('EH_CUSTOM_PROCESSING_BEFORE',1);
define('EH_CUSTOM_PROCESSING_AFTER',2);
/**
* Note:
* 1. When adressing variables from submit containing
* Prefix_Special as part of their name use
* $event->getPrefixSpecial(true) instead of
* $event->Prefix_Special as usual. This is due PHP
* is converting "." symbols in variable names during
* submit info "_". $event->getPrefixSpecial optional
* 1st parameter returns correct corrent Prefix_Special
* for variables beeing submitted such way (e.g. variable
* name that will be converted by PHP: "users.read_only_id"
* will be submitted as "users_read_only_id".
*
* 2. When using $this->Application-LinkVar on variables submitted
* from form which contain $Prefix_Special then note 1st item. Example:
* LinkVar($event->getPrefixSpecial(true).'_varname',$event->Prefix_Special.'_varname')
*
*/
/**
* EventHandler that is used to process
* any database related events
*
*/
class kDBEventHandler extends kEventHandler {
/**
* Description
*
* @var DBConnection
* @access public
*/
var $Conn;
/**
* Adds ability to address db connection
*
* @return kDBEventHandler
* @access public
*/
function kDBEventHandler()
{
parent::kBase();
$this->Conn =& $this->Application->GetADODBConnection();
}
function mapEvents()
{
$events_map = Array('OnRemoveFilters' => 'FilterAction',
'OnApplyFilters' => 'FilterAction');
$this->eventMethods = array_merge($this->eventMethods, $events_map);
}
/**
* Returns ID of current item to be edited
* by checking ID passed in get/post as prefix_id
* or by looking at first from selected ids, stored.
* Returned id is also stored in Session in case
* it was explicitly passed as get/post
*
* @param kEvent $event
* @return int
*/
function getPassedID(&$event)
{
//$ret = $this->Application->GetLinkedVar($event->getPrefixSpecial(true).'_id', $event->getPrefixSpecial().'_id');
// ?? We don't need to store selected id in session, as long as we have pass=all by default, which
// means that main item id will be passed to all sub-item screens by default
// another prove of that is that sub-items relay on main item '_mode' = 't' for switching to temp tables
// Also having id in session raised problems with the id of deleted item stuck in session
// 1. get id from post (used in admin)
$ret = $this->Application->GetVar($event->getPrefixSpecial(true).'_id');
if($ret) return $ret;
// 2. get id from env (used in front)
$ret = $this->Application->GetVar($event->getPrefixSpecial().'_id');
if($ret) return $ret;
// recall selected ids array and use the first one
$ids=$this->Application->GetVar($event->getPrefixSpecial().'_selected_ids');
if ($ids != '') {
$ids=explode(',',$ids);
if($ids) $ret=array_shift($ids);
}
else { // if selected ids are not yet stored
$this->StoreSelectedIDs($event);
return $this->Application->GetVar($event->getPrefixSpecial(true).'_id'); // StoreSelectedIDs sets this variable
}
return $ret;
}
/**
* Prepares and stores selected_ids string
* in Session and Application Variables
* by getting all checked ids from grid plus
* id passed in get/post as prefix_id
*
* @param kEvent $event
*/
function StoreSelectedIDs(&$event)
{
$ret = Array();
// May be we don't need this part: ?
$passed = $this->Application->GetVar($event->getPrefixSpecial(true).'_id');
if($passed !== false && $passed != '')
{
array_push($ret, $passed);
}
$ids = Array();
// get selected ids from post & save them to session
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if($items_info)
{
$id_field = $this->Application->getUnitOption($event->Prefix,'IDField');
foreach($items_info as $id => $field_values)
{
if( getArrayValue($field_values,$id_field) ) array_push($ids,$id);
}
//$ids=array_keys($items_info);
}
$ret = array_unique(array_merge($ret, $ids));
$this->Application->SetVar($event->getPrefixSpecial().'_selected_ids',implode(',',$ret));
$this->Application->LinkVar($event->getPrefixSpecial().'_selected_ids');
// This is critical - otherwise getPassedID will return last ID stored in session! (not exactly true)
// this smells... needs to be refactored
$first_id = getArrayValue($ret,0);
if($first_id === false) trigger_error('Requested ID for prefix <b>'.$event->getPrefixSpecial().'</b> <span class="debug_error">not passed</span>',E_USER_NOTICE);
$this->Application->SetVar($event->getPrefixSpecial(true).'_id', $first_id);
}
/**
* Returns stored selected ids as an array
*
* @param kEvent $event
* @return array
*/
function getSelectedIDs(&$event)
{
return explode(',', $this->Application->GetVar($event->getPrefixSpecial().'_selected_ids'));
}
/**
* Returs associative array of submitted fields for current item
* Could be used while creating/editing single item -
* meaning on any edit form, except grid edit
*
* @param kEvent $event
*/
function getSubmittedFields(&$event)
{
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
$field_values = $items_info ? array_shift($items_info) : Array();
return $field_values;
}
/**
* Removes any information about current/selected ids
* from Application variables and Session
*
* @param kEvent $event
*/
function clearSelectedIDs(&$event)
{
$prefix_special = $event->getPrefixSpecial();
$ids = $this->Application->RecallVar($prefix_special.'_selected_ids');
$event->setEventParam('ids', $ids);
$this->Application->RemoveVar($prefix_special.'_selected_ids');
$this->Application->SetVar($prefix_special.'_selected_ids', '');
$this->Application->SetVar($prefix_special.'_id', ''); // $event->getPrefixSpecial(true).'_id' too may be
}
/*function SetSaveEvent(&$event)
{
$this->Application->SetVar($event->Prefix_Special.'_SaveEvent','OnUpdate');
$this->Application->LinkVar($event->Prefix_Special.'_SaveEvent');
}*/
/**
* Common builder part for Item & List
*
* @param kDBBase $object
* @param kEvent $event
* @access private
*/
function dbBuild(&$object,&$event)
{
$object->Configure();
$live_table = $event->getEventParam('live_table');
if( $this->UseTempTables($event) && !$live_table )
{
$object->SwitchToTemp();
}
// This strange constuction creates hidden field for storing event name in form submit
// It pass SaveEvent to next screen, otherwise after unsuccsefull create it will try to update rather than create
$current_event = $this->Application->GetVar($event->Prefix_Special.'_event');
// $this->Application->setEvent($event->Prefix_Special, $current_event);
$this->Application->setEvent($event->Prefix_Special, '');
$save_event = $this->UseTempTables($event) && $this->Application->GetTopmostPrefix($event->Prefix) == $event->Prefix ? 'OnSave' : 'OnUpdate';
$this->Application->SetVar($event->Prefix_Special.'_SaveEvent',$save_event);
}
/**
* Builds item (loads if needed)
*
* @param kEvent $event
* @access protected
*/
function OnItemBuild(&$event)
{
$object =& $event->getObject();
$this->dbBuild($object,$event);
$sql = $this->ItemPrepareQuery($event);
$sql = $this->Application->ReplaceLanguageTags($sql);
$object->setSelectSQL($sql);
// 2. loads if allowed
$auto_load = $this->Application->getUnitOption($event->Prefix,'AutoLoad');
if($auto_load) $this->LoadItem($event);
$actions =& $this->Application->recallObject('kActions');
$actions->Set($event->Prefix_Special.'_GoTab', '');
$actions->Set($event->Prefix_Special.'_GoId', '');
}
/**
* Build subtables array from configs
*
* @param kEvent $event
*/
function OnTempHandlerBuild(&$event)
{
$object =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
$object->BuildTables( $event->Prefix, $this->getSelectedIDs($event) );
}
/**
* Enter description here...
*
* @param kEvent $event
* @return unknown
*/
function UseTempTables(&$event)
{
$object = &$event->getObject();
$top_prefix = $this->Application->GetTopmostPrefix($event->Prefix);
return $this->Application->GetVar($top_prefix.'_mode') == 't';
}
function TablePrefix(&$event)
{
return $this->UseTempTables(&$event) ? kTempTablesHandler::GetTempTablePrefix().TABLE_PREFIX : TABLE_PREFIX;
}
function LoadItem(&$event)
{
$object =& $event->getObject();
if ( $event->getEventParam('ByParent') ) {
$parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
$parent_table_key = $this->Application->getUnitOption($event->Prefix, 'ParentTableKey');
$parent_object =& $this->Application->recallObject($parent_prefix);
$id = $parent_object->GetDBField($parent_table_key);
$id_field = $this->Application->getUnitOption($event->Prefix, 'ForeignKey');
}
else {
$id = $this->getPassedID($event);
$id_field = null;
}
if ($object->Load($id, $id_field)) {
$actions =& $this->Application->recallObject('kActions');
$actions->Set($event->Prefix_Special.'_id', $object->GetId());
}
}
/**
* Builds list
*
* @param kEvent $event
* @access protected
*/
function OnListBuild(&$event)
{
//$event->setPseudoClass('_List');
$object =& $event->getObject();
$this->dbBuild($object,$event);
$sql = $this->ListPrepareQuery($event);
$sql = $this->Application->ReplaceLanguageTags($sql);
$object->setSelectSQL($sql);
$object->linkToParent( $this->getMainSpecial($event) );
// $object->linkToParent($special);
$this->AddFilters($event);
$this->SetCustomQuery($event); // new!, use this for dynamic queries based on specials for ex.
$this->SetPagination($event);
$this->SetSorting($event);
$actions =& $this->Application->recallObject('kActions');
$actions->Set('remove_specials['.$event->Prefix_Special.']', '0');
$actions->Set($event->Prefix_Special.'_GoTab', '');
}
/**
* Get's special of main item for linking with subitem
*
* @param kEvent $event
* @return string
*/
function getMainSpecial(&$event)
{
$special = $event->getEventParam('main_special');
if($special === false || $special == '$main_special')
{
$special = $event->Special;
}
return $special;
}
/**
* Apply any custom changes to list's sql query
*
* @param kEvent $event
* @access protected
* @see OnListBuild
*/
function SetCustomQuery(&$event)
{
}
/**
* Set's new perpage for grid
*
* @param kEvent $event
*/
function OnSetPerPage(&$event)
{
$per_page = $this->Application->GetVar($event->getPrefixSpecial(true).'_PerPage');
$this->Application->StoreVar( $event->getPrefixSpecial().'_PerPage', $per_page );
}
/**
* Set's correct page for list
* based on data provided with event
*
* @param kEvent $event
* @access private
* @see OnListBuild
*/
function SetPagination(&$event)
{
// get PerPage (forced -> session -> config -> 10)
$per_page = $event->getEventParam('per_page');
$config_mapping = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping');
if ( $config_mapping ) {
switch ( $per_page ){
case 'short_list' :
$per_page = $this->Application->ConfigValue($config_mapping['ShortListPerPage']);
break;
case 'default' :
$per_page = $this->Application->ConfigValue($config_mapping['PerPage']);
break;
}
}
if(!$per_page)
{
$per_page_var = $event->getPrefixSpecial().'_PerPage';
$per_page = $this->Application->RecallVar($per_page_var);
if(!$per_page)
{
if ( $config_mapping ) {
$per_page = $this->Application->ConfigValue($config_mapping['PerPage']);
}
if(!$per_page) $per_page = 10;
}
}
$object =& $event->getObject();
$object->SetPerPage($per_page);
$this->Application->StoreVarDefault($event->getPrefixSpecial().'_Page', 1);
$page = $this->Application->GetVar($event->getPrefixSpecial().'_Page');
if (!$page) {
$page = $this->Application->GetVar($event->getPrefixSpecial(true).'_Page');
}
if (!$page) {
$page = $this->Application->RecallVar($event->getPrefixSpecial().'_Page');
}
else {
$this->Application->StoreVar($event->getPrefixSpecial().'_Page', $page);
}
// $page = $this->Application->GetLinkedVar($event->getPrefixSpecial(true).'_Page', $event->getPrefixSpecial().'_Page');
if( !$event->getEventParam('skip_counting') )
{
$pages = $object->GetTotalPages();
if($page > $pages)
{
$this->Application->StoreVar($event->getPrefixSpecial().'_Page', 1);
$page = 1;
}
}
$object->SetPage($page);
}
/**
* Set's correct sorting for list
* based on data provided with event
*
* @param kEvent $event
* @access private
* @see OnListBuild
*/
function SetSorting(&$event)
{
$event->setPseudoClass('_List');
$object =& $event->getObject();
$cur_sort1 = $this->Application->RecallVar($event->Prefix_Special.'_Sort1');
$cur_sort1_dir = $this->Application->RecallVar($event->Prefix_Special.'_Sort1_Dir');
$cur_sort2 = $this->Application->RecallVar($event->Prefix_Special.'_Sort2');
$cur_sort2_dir = $this->Application->RecallVar($event->Prefix_Special.'_Sort2_Dir');
$sorting_configs = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping');
$list_sortings = $this->Application->getUnitOption($event->Prefix, 'ListSortings');
$sorting_prefix = getArrayValue($list_sortings, $event->Special) ? $event->Special : '';
$tag_sort_by = $event->getEventParam('sort_by');
if ($tag_sort_by) {
list($by, $dir) = explode(',', $tag_sort_by);
if ($by == 'random') $by = 'RAND()';
$object->AddOrderField($by, $dir);
}
if ($sorting_configs && isset ($sorting_configs['DefaultSorting1Field'])){
$list_sortings[$sorting_prefix]['Sorting'] = Array(
$this->Application->ConfigValue($sorting_configs['DefaultSorting1Field']) => $this->Application->ConfigValue($sorting_configs['DefaultSorting1Dir']),
$this->Application->ConfigValue($sorting_configs['DefaultSorting2Field']) => $this->Application->ConfigValue($sorting_configs['DefaultSorting2Dir']),
);
}
// Use default if not specified
if ( !$cur_sort1 || !$cur_sort1_dir)
{
if ( $sorting = getArrayValue($list_sortings, $sorting_prefix, 'Sorting') ) {
reset($sorting);
$cur_sort1 = key($sorting);
$cur_sort1_dir = current($sorting);
if (next($sorting)) {
$cur_sort2 = key($sorting);
$cur_sort2_dir = current($sorting);
}
}
}
if ( $forced_sorting = getArrayValue($list_sortings, $sorting_prefix, 'ForcedSorting') ) {
foreach ($forced_sorting as $field => $dir) {
$object->AddOrderField($field, $dir);
}
}
if($cur_sort1 != '' && $cur_sort1_dir != '')
{
$object->AddOrderField($cur_sort1, $cur_sort1_dir);
}
if($cur_sort2 != '' && $cur_sort2_dir != '')
{
$object->AddOrderField($cur_sort2, $cur_sort2_dir);
}
}
/**
* Add filters found in session
*
* @param kEvent $event
*/
function AddFilters(&$event)
{
$object =& $event->getObject();
$search_filter = $this->Application->RecallVar($event->getPrefixSpecial().'_search_filter');
if($search_filter)
{
$search_filter = unserialize($search_filter);
foreach($search_filter as $search_field => $filter_params)
{
$filter_type = ($filter_params['type'] == 'having') ? HAVING_FILTER : WHERE_FILTER;
$object->addFilter($search_field, $filter_params['value'], $filter_type, FLT_SEARCH);
}
}
$view_filter = $this->Application->RecallVar($event->getPrefixSpecial().'_view_filter');
if($view_filter)
{
$view_filter = unserialize($view_filter);
$temp_filter =& $this->Application->makeClass('kMultipleFilter');
$filter_menu = $this->Application->getUnitOption($event->Prefix,'FilterMenu');
$group_key = 0; $group_count = count($filter_menu['Groups']);
while($group_key < $group_count)
{
$group_info = $filter_menu['Groups'][$group_key];
$temp_filter->setType( constant('FLT_TYPE_'.$group_info['mode']) );
$temp_filter->clearFilters();
foreach ($group_info['filters'] as $flt_id)
{
$sql_key = getArrayValue($view_filter,$flt_id) ? 'on_sql' : 'off_sql';
if ($filter_menu['Filters'][$flt_id][$sql_key] != '')
{
$temp_filter->addFilter('view_filter_'.$flt_id, $filter_menu['Filters'][$flt_id][$sql_key]);
}
}
$object->addFilter('view_group_'.$group_key, $temp_filter, $group_info['type'] , FLT_VIEW);
$group_key++;
}
}
}
/**
* Set's new sorting for list
*
* @param kEvent $event
* @access protected
*/
function OnSetSorting(&$event)
{
$cur_sort1 = $this->Application->RecallVar($event->Prefix_Special.'_Sort1');
$cur_sort1_dir = $this->Application->RecallVar($event->Prefix_Special.'_Sort1_Dir');
$cur_sort2 = $this->Application->RecallVar($event->Prefix_Special.'_Sort2');
$cur_sort2_dir = $this->Application->RecallVar($event->Prefix_Special.'_Sort2_Dir');
$passed_sort1 = $this->Application->GetVar($event->getPrefixSpecial(true).'_Sort1');
if ($cur_sort1 == $passed_sort1) {
$cur_sort1_dir = $cur_sort1_dir == 'asc' ? 'desc' : 'asc';
}
else {
$cur_sort2 = $cur_sort1;
$cur_sort2_dir = $cur_sort1_dir;
$cur_sort1 = $passed_sort1;
$cur_sort1_dir = 'asc';
}
$this->Application->StoreVar($event->Prefix_Special.'_Sort1', $cur_sort1);
$this->Application->StoreVar($event->Prefix_Special.'_Sort1_Dir', $cur_sort1_dir);
$this->Application->StoreVar($event->Prefix_Special.'_Sort2', $cur_sort2);
$this->Application->StoreVar($event->Prefix_Special.'_Sort2_Dir', $cur_sort2_dir);
}
/**
* Set sorting directly to session
*
* @param kEvent $event
*/
function OnSetSortingDirect(&$event)
{
$combined = $this->Application->GetVar($event->getPrefixSpecial(true).'_CombinedSorting');
if ($combined) {
list($field,$dir) = explode('|',$combined);
$this->Application->StoreVar($event->Prefix_Special.'_Sort1', $field);
$this->Application->StoreVar($event->Prefix_Special.'_Sort1_Dir', $dir);
return;
}
$field_pos = $this->Application->GetVar($event->getPrefixSpecial(true).'_SortPos');
$this->Application->LinkVar( $event->getPrefixSpecial(true).'_Sort'.$field_pos, $event->Prefix_Special.'_Sort'.$field_pos);
$this->Application->LinkVar( $event->getPrefixSpecial(true).'_Sort'.$field_pos.'_Dir', $event->Prefix_Special.'_Sort'.$field_pos.'_Dir');
}
/**
* Reset grid sorting to default (from config)
*
* @param kEvent $event
*/
function OnResetSorting(&$event)
{
$this->Application->RemoveVar($event->Prefix_Special.'_Sort1');
$this->Application->RemoveVar($event->Prefix_Special.'_Sort1_Dir');
$this->Application->RemoveVar($event->Prefix_Special.'_Sort2');
$this->Application->RemoveVar($event->Prefix_Special.'_Sort2_Dir');
}
/**
* Creates needed sql query to load item,
* if no query is defined in config for
* special requested, then use default
* query
*
* @param kEvent $event
* @access protected
*/
function ItemPrepareQuery(&$event)
{
$sqls = $this->Application->getUnitOption($event->Prefix,'ItemSQLs');
return isset($sqls[$event->Special]) ? $sqls[$event->Special] : $sqls[''];
}
/**
* Creates needed sql query to load list,
* if no query is defined in config for
* special requested, then use default
* query
*
* @param kEvent $event
* @access protected
*/
function ListPrepareQuery(&$event)
{
$sqls = $this->Application->getUnitOption($event->Prefix,'ListSQLs');
return isset( $sqls[$event->Special] ) ? $sqls[$event->Special] : $sqls[''];
}
/**
* Apply custom processing to item
*
* @param kEvent $event
*/
function customProcessing(&$event, $type)
{
}
/* Edit Events mostly used in Admin */
/**
* Creates new kDBItem
*
* @param kEvent $event
* @access protected
*/
function OnCreate(&$event)
{
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject();
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if($items_info)
{
list($id,$field_values) = each($items_info);
$object->SetFieldsFromHash($field_values);
}
$this->customProcessing($event,'before');
//look at kDBItem' Create for ForceCreateId description, it's rarely used and is NOT set by default
if( $object->Create($event->getEventParam('ForceCreateId')) )
{
if( $object->IsTempTable() ) $object->setTempID();
$this->customProcessing($event,'after');
$event->status=erSUCCESS;
$event->redirect_params = Array('opener'=>'u');
}
else
{
$event->status=erFAIL;
$event->redirect=false;
$this->Application->SetVar($event->Prefix_Special.'_SaveEvent','OnCreate');
$object->setID($id);
}
}
/**
* Updates kDBItem
*
* @param kEvent $event
* @access protected
*/
function OnUpdate(&$event)
{
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject();
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if($items_info)
{
foreach($items_info as $id => $field_values)
{
$object->Load($id);
$object->SetFieldsFromHash($field_values);
$this->customProcessing($event, 'before');
if( $object->Update($id) )
{
$this->customProcessing($event, 'after');
$event->status=erSUCCESS;
}
else
{
$event->status=erFAIL;
$event->redirect=false;
break;
}
}
}
$event->redirect_params = Array('opener'=>'u');
}
/**
* Delete's kDBItem object
*
* @param kEvent $event
* @access protected
*/
function OnDelete(&$event)
{
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject();
$object->ID = $this->getPassedID($event);
if( $object->Delete() )
{
$event->status = erSUCCESS;
}
else
{
$event->status = erFAIL;
$event->redirect = false;
}
}
/**
* Prepares new kDBItem object
*
* @param kEvent $event
* @access protected
*/
function OnNew(&$event)
{
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject();
$object->setID(0);
$this->Application->SetVar($event->Prefix_Special.'_SaveEvent','OnCreate');
$table_info = $object->getLinkedInfo();
$object->SetDBField($table_info['ForeignKey'], $table_info['ParentId']);
$this->Application->setUnitOption($event->Prefix,'AutoLoad',true);
$event->redirect = false;
}
/**
* Cancel's kDBItem Editing/Creation
*
* @param kEvent $event
* @access protected
*/
function OnCancel(&$event)
{
$event->redirect_params = Array('opener'=>'u');
}
/**
* Deletes all selected items.
* Automatically recurse into sub-items using temp handler, and deletes sub-items
* by calling its Delete method if sub-item has AutoDelete set to true in its config file
*
* @param kEvent $event
*/
function OnMassDelete(&$event)
{
$event->status=erSUCCESS;
$temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
$this->StoreSelectedIDs($event);
$event->setEventParam('ids', $this->getSelectedIDs($event) );
$this->customProcessing($event, 'before');
$ids = $event->getEventParam('ids');
if($ids)
{
$temp->DeleteItems($event->Prefix, $event->Special, $ids);
}
$this->clearSelectedIDs($event);
}
/**
* Prepare temp tables and populate it
* with items selected in the grid
*
* @param kEvent $event
*/
function OnEdit(&$event)
{
$this->StoreSelectedIDs($event);
$temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
$temp->PrepareEdit();
$event->redirect=false;
}
/**
* Saves content of temp table into live and
* redirects to event' default redirect (normally grid template)
*
* @param kEvent $event
*/
function OnSave(&$event)
{
$event->CallSubEvent('OnPreSave');
if ($event->status==erSUCCESS) {
$skip_master=false;
$temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
// newly created item
/*if($this->getPassedID($event) == 0)
{
$master_id = $temp->CopyMasterToOriginal();
$temp->UpdateForeignKeys($master_id); // save linked field values
$skip_master = true; //we've already copied master table to get the id
}*/
$temp->SaveEdit($skip_master);
$this->clearSelectedIDs($event);
$event->redirect_params = Array('opener'=>'u');
$this->Application->RemoveVar($event->getPrefixSpecial().'_modified');
}
}
/**
* Cancels edit
* Removes all temp tables and clears selected ids
*
* @param kEvent $event
*/
function OnCancelEdit(&$event)
{
$temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
$temp->CancelEdit();
$this->clearSelectedIDs($event);
$event->redirect_params = Array('opener'=>'u');
$this->Application->RemoveVar($event->getPrefixSpecial().'_modified');
}
/**
* Saves edited item into temp table
* If there is no id, new item is created in temp table
*
* @param kEvent $event
*/
function OnPreSave(&$event)
{
//$event->redirect = false;
// if there is no id - it means we need to create an item
if (is_object($event->MasterEvent)) {
$event->MasterEvent->setEventParam('IsNew',false);
}
$item_id = $this->getPassedID($event);
if($item_id == '')
{
$event->CallSubEvent('OnPreSaveCreated');
if (is_object($event->MasterEvent)) {
$event->MasterEvent->setEventParam('IsNew',true);
}
return;
}
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject();
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if($items_info)
{
foreach($items_info as $id => $field_values)
{
$object->SetDefaultValues();
$object->Load($id);
$object->SetFieldsFromHash($field_values);
if( $object->Update($id) )
{
$event->status=erSUCCESS;
}
else
{
$event->status=erFAIL;
$event->redirect=false;
break;
}
}
}
}
/**
* Saves edited item in temp table and loads
* item with passed id in current template
* Used in Prev/Next buttons
*
* @param kEvent $event
*/
function OnPreSaveAndGo(&$event)
{
$event->CallSubEvent('OnPreSave');
if ($event->status==erSUCCESS) {
$event->redirect_params[$event->getPrefixSpecial(true).'_id'] = $this->Application->GetVar($event->Prefix_Special.'_GoId');
}
}
/**
* Saves edited item in temp table and goes
* to passed tabs, by redirecting to it with OnPreSave event
*
* @param kEvent $event
*/
function OnPreSaveAndGoToTab(&$event)
{
$event->CallSubEvent('OnPreSave');
if ($event->status==erSUCCESS) {
$event->redirect=$this->Application->GetVar($event->getPrefixSpecial(true).'_GoTab');
}
}
/**
* Saves editable list and goes to passed tab,
* by redirecting to it with empty event
*
* @param kEvent $event
*/
function OnUpdateAndGoToTab(&$event)
{
$event->setPseudoClass('_List');
$event->CallSubEvent('OnUpdate');
if ($event->status==erSUCCESS) {
$event->redirect=$this->Application->GetVar($event->getPrefixSpecial(true).'_GoTab');
}
}
/**
* Prepare temp tables for creating new item
* but does not create it. Actual create is
* done in OnPreSaveCreated
*
* @param kEvent $event
*/
function OnPreCreate(&$event)
{
$this->clearSelectedIDs($event);
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject();
$temp =& $this->Application->recallObject($event->Prefix.'_TempHandler', 'kTempTablesHandler');
$temp->PrepareEdit();
$object->setID(0);
$event->redirect=false;
}
/**
* Creates a new item in temp table and
* stores item id in App vars and Session on succsess
*
* @param kEvent $event
*/
function OnPreSaveCreated(&$event)
{
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if($items_info) $field_values = array_shift($items_info);
$object =& $event->getObject();
$object->SetFieldsFromHash($field_values);
$this->customProcessing($event, 'before');
if( $object->Create() )
{
$this->customProcessing($event, 'after');
$event->redirect_params[$event->getPrefixSpecial(true).'_id'] = $object->GetId();
$event->status=erSUCCESS;
}
else
{
$event->status=erFAIL;
$event->redirect=false;
$object->setID(0);
}
}
/* End of Edit events */
// III. Events that allow to put some code before and after Update,Load,Create and Delete methods of item
/**
* Occurse before loading item, 'id' parameter
* allows to get id of item beeing loaded
*
* @param kEvent $event
* @access public
*/
function OnBeforeItemLoad(&$event)
{
}
/**
* Occurse after loading item, 'id' parameter
* allows to get id of item that was loaded
*
* @param kEvent $event
* @access public
*/
function OnAfterItemLoad(&$event)
{
}
/**
* Occurse before creating item
*
* @param kEvent $event
* @access public
*/
function OnBeforeItemCreate(&$event)
{
}
/**
* Occurse after creating item
*
* @param kEvent $event
* @access public
*/
function OnAfterItemCreate(&$event)
{
}
/**
* Occurse before updating item
*
* @param kEvent $event
* @access public
*/
function OnBeforeItemUpdate(&$event)
{
}
/**
* Occurse after updating item
*
* @param kEvent $event
* @access public
*/
function OnAfterItemUpdate(&$event)
{
}
/**
* Occurse before deleting item, id of item beeing
* deleted is stored as 'id' event param
*
* @param kEvent $event
* @access public
*/
function OnBeforeItemDelete(&$event)
{
}
/**
* Occurse after deleting item, id of deleted item
* is stored as 'id' param of event
*
* @param kEvent $event
* @access public
*/
function OnAfterItemDelete(&$event)
{
}
/**
* Occurs after successful item validation
*
* @param kEvent $event
*/
function OnAfterItemValidate(&$event)
{
}
/**
* Occures after an item has been copied to temp
* Id of copied item is passed as event' 'id' param
*
* @param kEvent $event
*/
function OnAfterCopyToTemp(&$event)
{
}
/**
* Occures before an item is deleted from live table when copying from temp
* (temp handler deleted all items from live and then copy over all items from temp)
* Id of item being deleted is passed as event' 'id' param
*
* @param kEvent $event
*/
function OnBeforeDeleteFromLive(&$event)
{
}
/**
* Occures before an item is copied to live table (after all foreign keys have been updated)
* Id of item being copied is passed as event' 'id' param
*
* @param kEvent $event
*/
function OnBeforeCopyToLive(&$event)
{
}
/**
* !!! NOT FULLY IMPLEMENTED - SEE TEMP HANDLER COMMENTS (search by event name)!!!
* Occures after an item has been copied to live table
* Id of copied item is passed as event' 'id' param
*
* @param kEvent $event
*/
function OnAfterCopyToLive(&$event)
{
}
/**
* Occures before an item is cloneded
* Id of ORIGINAL item is passed as event' 'id' param
* Do not call object' Update method in this event, just set needed fields!
*
* @param kEvent $event
*/
function OnBeforeClone(&$event)
{
}
/**
* Occures after an item has been cloned
* Id of newly created item is passed as event' 'id' param
*
* @param kEvent $event
*/
function OnAfterClone(&$event)
{
}
/**
* Ensures that popup will be closed automatically
* and parent window will be refreshed with template
* passed
*
* @param kEvent $event
* @access public
*/
function finalizePopup(&$event, $main_prefix, $t)
{
$event->redirect = 'incs/close_popup';
// 2. substitute opener
$opener_stack = $this->Application->RecallVar('opener_stack');
$opener_stack = $opener_stack ? unserialize($opener_stack) : Array();
//array_pop($opener_stack);
$new_level = 'index4.php|'.ltrim($this->Application->BuildEnv($t, Array('m_opener' => 'u'), 'all'), ENV_VAR_NAME.'=');
array_push($opener_stack,$new_level);
$this->Application->StoreVar('opener_stack',serialize($opener_stack));
}
/**
* Create search filters based on search query
*
* @param kEvent $event
* @access protected
*/
function OnSearch(&$event)
{
$event->setPseudoClass('_List');
$object =& $event->getObject();
$keyword = $this->Application->GetVar( $event->getPrefixSpecial(true).'_search_keyword');
$this->Application->StoreVar( $event->getPrefixSpecial().'_search_keyword', $keyword);
if(!$keyword)
{
$this->OnSearchReset($event);
return true;
}
$grid_name = $this->Application->GetVar('grid_name');
$grids = $this->Application->getUnitOption($event->Prefix,'Grids');
$search_fields = array_keys($grids[$grid_name]['Fields']);
$search_filter = Array();
foreach($search_fields as $search_field)
{
$filter_type = isset($object->VirtualFields[$search_field]) ? 'having' : 'where';
$field_type = getArrayValue($object->Fields[$search_field],'type');
if(!$field_type) $field_type = 'string'; // default LIKE filter for all fields without type
$keyword = trim($keyword);
$keyword = str_replace(Array('"',"'"),'',$keyword);
$filter_value = '';
$table_name = ($filter_type == 'where') ? '`'.$object->TableName.'`.' : '';
// get field clause by formatter name and/or parameters
$formatter = getArrayValue($object->Fields[$search_field],'formatter');
switch ($formatter)
{
case 'kOptionsFormatter':
$search_keys = Array();
$use_phrases = getArrayValue($object->Fields[$search_field], 'use_phrases');
foreach($object->Fields[$search_field]['options'] as $key => $val)
{
$pattern = '#'.$keyword.'#i';
if ( preg_match($pattern, $use_phrases ? $this->Application->Phrase($val) : $val) ) {
array_push($search_keys, $key);
}
}
if (count($search_keys) > 0) {
$filter_value = $table_name.'`'.$search_field.'` IN ('.implode(',', $search_keys).')';
}
$field_processed = true;
break;
default:
$field_processed = false;
break;
}
// if not already processed by formatter, then get clause by field type
if(!$field_processed)
{
switch($field_type)
{
case 'int':
case 'integer':
case 'numeric':
if( !is_numeric($keyword) ) break;
$filter_value = $table_name.'`'.$search_field.'` = \''.$keyword.'\'';
break;
case 'double':
case 'float':
case 'real':
if( !is_numeric($keyword) ) break;
$filter_value = 'ABS('.$table_name.'`'.$search_field.'` - \''.str_replace(',','.',$keyword).'\') <= 0.0001';
break;
case 'string':
$like_keyword = preg_replace( '/\'(.*)\'/U', '\\1', $this->Conn->qstr( str_replace('\\','\\\\', $keyword) ) );
$keywords = explode(' ', $like_keyword);
foreach($keywords as $keyword_pos => $keyword_value)
{
$keyword_value = trim($keyword_value);
if($keyword_value)
{
$keywords[$keyword_pos] = $table_name.'`'.$search_field.'` LIKE \'%'.$keyword_value.'%\'';
}
else
{
unset($keywords[$keyword_pos]);
}
}
$filter_value = '('.implode(') OR (',$keywords).')';
break;
}
}
if($filter_value) $search_filter[$search_field] = Array('type' => $filter_type, 'value' => $filter_value);
}
$this->Application->StoreVar($event->getPrefixSpecial().'_search_filter', serialize($search_filter) );
}
/**
* Clear search keywords
*
* @param kEvent $event
* @access protected
*/
function OnSearchReset(&$event)
{
$this->Application->RemoveVar($event->getPrefixSpecial().'_search_filter');
$this->Application->RemoveVar($event->getPrefixSpecial().'_search_keyword');
}
/**
* Set's new filter value (filter_id meaning from config)
*
* @param kEvent $event
*/
function OnSetFilter(&$event)
{
$filter_id = $this->Application->GetVar('filter_id');
$filter_value = $this->Application->GetVar('filter_value');
$view_filter = $this->Application->RecallVar($event->getPrefixSpecial().'_view_filter');
$view_filter = $view_filter ? unserialize($view_filter) : Array();
$view_filter[$filter_id] = $filter_value;
$this->Application->StoreVar( $event->getPrefixSpecial().'_view_filter', serialize($view_filter) );
}
/**
* Add/Remove all filters applied to list from "View" menu
*
* @param kEvent $event
*/
function FilterAction(&$event)
{
$view_filter = Array();
$filter_menu = $this->Application->getUnitOption($event->Prefix,'FilterMenu');
switch ($event->Name)
{
case 'OnRemoveFilters':
$filter_value = 1;
break;
case 'OnApplyFilters':
$filter_value = 0;
break;
}
foreach($filter_menu['Filters'] as $filter_key => $filter_params)
{
if(!$filter_params) continue;
$view_filter[$filter_key] = $filter_value;
}
$this->Application->StoreVar( $event->getPrefixSpecial().'_view_filter', serialize($view_filter) );
}
+ /**
+ * Enter description here...
+ *
+ * @param kEvent $event
+ */
function OnPreSaveAndOpenTranslator(&$event)
{
$this->Application->SetVar('allow_translation', true);
$object =& $event->getObject();
$this->RemoveRequiredFields($object);
$event->CallSubEvent('OnPreSave');
if ($event->status == erSUCCESS) {
// $url = $this->Application->HREF($t, '', Array('pass'=>'all', $event->getPrefixSpecial(true).'_id' => $object->GetId()));
// $field = $this->Application->GetVar('translator_field');
$event->redirect = $this->Application->GetVar('translator_t');
- $event->redirect_params = Array('pass'=>'all,trans',
+ $event->redirect_params = Array('pass'=>'all,trans,'.$this->Application->GetVar('translator_prefixes'),
$event->getPrefixSpecial(true).'_id' => $object->GetId(),
'trans_event'=>'OnLoad',
- 'trans_prefix'=>$event->Prefix,
+ 'trans_prefix'=> $this->Application->GetVar('translator_prefixes'),
'trans_field'=>$this->Application->GetVar('translator_field'),
);
//$after_script = "openTranslator('".$event->getPrefixSpecial()."', '".$field."', '".$url."', '".$wnd_name."')";
}
// $this->Application->SetVar('after_script', $after_script);
// $event->redirect = false;
}
function RemoveRequiredFields(&$object)
{
// making all field non-required to achieve successful presave
foreach($object->Fields as $field => $options)
{
if(isset($options['required']))
{
unset($object->Fields[$field]['required']);
}
}
}
}
?>
\ No newline at end of file
Property changes on: trunk/core/kernel/db/db_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.9
\ No newline at end of property
+1.10
\ No newline at end of property
Index: trunk/core/units/translator/translator_event_handler.php
===================================================================
--- trunk/core/units/translator/translator_event_handler.php (revision 1794)
+++ trunk/core/units/translator/translator_event_handler.php (revision 1795)
@@ -1,83 +1,106 @@
<?php
class TranslatorEventHandler extends InpDBEventHandler
{
function OnLoad(&$event)
{
- $obj_prefix = $this->Application->GetVar($event->getPrefixSpecial(true).'_prefix');
+ $field = $this->Application->GetVar($event->getPrefixSpecial(true).'_field');
+
+ if( strpos($field,':') !== false )
+ {
+ list($obj_prefix,$field) = explode(':', $field);
+ }
+ else
+ {
+ $obj_prefix = $this->Application->GetVar($event->getPrefixSpecial(true).'_prefix');
+ }
+
$object = $this->Application->recallObject($obj_prefix);
/*$items_info = $this->Application->GetVar( $obj_prefix );
if($items_info) $field_values = array_shift($items_info);
$object->SetFieldsFromHash($field_values);
$object->Update();*/
- $field = $this->Application->GetVar($event->getPrefixSpecial(true).'_field');
+
$translator =& $this->Application->recallObject($event->getPrefixSpecial());
$def_lang = $this->Application->GetDefaultLanguageId();
$current_lang = $translator->GetDBField('Language');
if (!$current_lang) $current_lang = $this->Application->RecallVar('trans_lang');
if (!$current_lang) $current_lang = $this->Application->GetVar('m_lang');
/*if ($current_lang == $def_lang) {
$current_lang = $def_lang + 1;
}*/
$this->Application->StoreVar('trans_lang', $current_lang); //remember translation language for user friendlyness
$translator->SetId(1);
$translator->SetDBField('Original', $object->GetDBField('l'.$this->Application->GetVar('m_lang').'_'.$field));
$translator->SetDBField('Language', $current_lang);
$translator->SetDBField('SwitchLanguage', $current_lang);
$translator->SetDBField('Translation', $object->GetDBField('l'.$current_lang.'_'.$field));
$cur_lang = $this->Application->recallObject('lang.current');
$cur_lang->Load($current_lang);
$translator->SetDBField('Charset', $cur_lang->GetDBField('Charset'));
$event->redirect = false;
}
function OnSaveAndClose(&$event)
{
$event->CallSubEvent('OnPreSave');
- $this->finalizePopup($event, '', 'in-commerce/products/products_edit');
+
+ // 2. RESTORE SAVED LAST TEMPLATE AS LAST PARAM FOR FINILIZE_POPUP
+ $return_template = $this->Application->RecallVar('return_template');
+ $this->finalizePopup($event, '', $return_template);
}
function OnPreSave(&$event)
{
$translator =& $this->Application->recallObject($event->getPrefixSpecial());
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if($items_info) $field_values = array_shift($items_info);
$translator->SetFieldsFromHash($field_values);
- $object = $this->Application->recallObject($this->Application->GetVar($event->getPrefixSpecial(true).'_prefix'));
$field = $this->Application->GetVar($event->getPrefixSpecial(true).'_field');
+ if( strpos($field,':') !== false )
+ {
+ list($obj_prefix,$field) = explode(':', $field);
+ }
+ else
+ {
+ $obj_prefix = $this->Application->GetVar($event->getPrefixSpecial(true).'_prefix');
+ }
+
+ $object = $this->Application->recallObject($obj_prefix);
+
$lang = $translator->GetDBField('Language');
$object->Fields['l'.$lang.'_'.$field] = Array();
$object->SetDBField('l'.$lang.'_'.$field, $translator->GetDBField('Translation'));
$this->RemoveRequiredFields($object);
$object->Update();
}
function OnChangeLanguage(&$event)
{
$event->CallSubEvent('OnPreSave');
$translator =& $this->Application->recallObject($event->getPrefixSpecial());
$translator->SetDBField('Language', $translator->GetDBField('SwitchLanguage'));
$event->CallSubEvent('OnLoad');
$event->redirect = false;
}
}
?>
\ No newline at end of file
Property changes on: trunk/core/units/translator/translator_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property
Index: trunk/core/units/custom_fields/custom_fields_config.php
===================================================================
--- trunk/core/units/custom_fields/custom_fields_config.php (revision 1794)
+++ trunk/core/units/custom_fields/custom_fields_config.php (revision 1795)
@@ -1,84 +1,83 @@
<?php
$config = Array(
'Prefix' => 'cf',
'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'CustomFieldsEventHandler','file'=>'custom_fields_event_handler.php','build_event'=>'OnBuild'),
'TagProcessorClass' => Array('class'=>'kDBTagProcessor','file'=>'','build_event'=>'OnBuild'),
'AutoLoad' => true,
'hooks' => Array(),
'QueryString' => Array(
1 => 'id',
2 => 'page',
3 => 'event',
4 => 'type',
5 => 'mode',
),
'IDField' => 'CustomFieldId',
'TitleField' => 'FieldName', // field, used in bluebar when editing existing item
'TitlePhrase' => 'la_title_CustomFields',
'TitlePresets' => Array(
'default' => Array( 'new_status_labels' => Array('cf'=>'!la_title_addingCustom!'),
'edit_status_labels' => Array('cf'=>'!la_title_Editing_CustomField!'),
'new_titlefield' => Array('cf'=>'!la_title_NewCustomField!'),
),
'custom_fields_list'=>Array( 'prefixes' => Array('cf_List'),
'format' => "!la_tab_ConfigCustom! (#cf_recordcount#)",
),
'custom_fields_edit'=>Array( 'prefixes' => Array('cf'),
'new_titlefield' => Array('cf'=>'!la_title_NewCustomField!'),
'format' => "#cf_status# '#cf_titlefield#'",
),
),
'TableName' => TABLE_PREFIX.'CustomField',
'ListSQLs' => Array( ''=>'SELECT * FROM %s',
), // key - special, value - list select sql
'ListSortings' => Array(
'' => Array(
'ForcedSorting' => Array('DisplayOrder' => 'asc'),
'Sorting' => Array('FieldName' => 'asc'),
)
),
'ItemSQLs' => Array( ''=>'SELECT * FROM %s',
),
'Fields' => Array(
'CustomFieldId' => Array('type' => 'int','not_null' => '1','default' => ''),
'Type' => Array('type' => 'int','not_null' => '1','default' => '0'),
'FieldName' => Array('required'=>'1', 'type' => 'string','not_null' => 1,'default' => ''),
'FieldLabel' => Array('type' => 'string','default' => ''),
'Heading' => Array('type' => 'string','default' => ''),
'Prompt' => Array('type' => 'string','default' => ''),
'ElementType' => Array('required'=>'1', 'type'=>'string', 'not_null'=>1, 'default'=>'NULL', 'formatter'=>'kOptionsFormatter', 'use_phrases' => 1, 'options'=>Array('' => 'la_EmptyValue', 'select' => 'la_type_select', 'label' => 'la_type_label', 'password' => 'la_type_password','radio' => 'la_type_radio', 'textarea' => 'la_type_textarea', 'text' => 'la_type_text')),
- 'Multilingual' => Array('type' => 'int','default' => '0'),
'ValueList' => Array('type' => 'string','default' => ''),
'DisplayOrder' => Array('type' => 'int','not_null' => '1','default' => '0'),
'OnGeneralTab' => Array('type' => 'int','not_null' => '1','default' => '0'),
),
'VirtualFields' => Array(),
'Grids' => Array(
'Default' => Array(
'Icons' => Array('default'=>'icon16_custom.gif'),
'Fields' => Array(
'CustomFieldId' => Array( 'title'=>'la_prompt_FieldId', 'data_block' => 'grid_checkbox_td' ),
'FieldName' => Array( 'title'=>'la_prompt_FieldName'),
'FieldLabel' => Array( 'title'=>'la_prompt_FieldLabel', 'data_block' => 'cf_grid_data_td' ),
'DisplayOrder' => Array('title' => 'la_prompt_DisplayOrder'),
),
),
),
);
?>
\ No newline at end of file
Property changes on: trunk/core/units/custom_fields/custom_fields_config.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.4
\ No newline at end of property
+1.5
\ No newline at end of property
Index: trunk/core/admin_templates/incs/custom_blocks.tpl
===================================================================
--- trunk/core/admin_templates/incs/custom_blocks.tpl (revision 1794)
+++ trunk/core/admin_templates/incs/custom_blocks.tpl (revision 1795)
@@ -1,45 +1,46 @@
<inp2:m_block name="config_edit_text" />
<input type="text" name="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>" value="<inp2:$PrefixSpecial_Field field="$field" />" />
<inp2:m_blockend />
<inp2:m_block name="config_edit_password" />
<input type="password" primarytype="password" name="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>" id="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>" value="" />
<input type="password" name="verify_<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>" id="verify_<inp2:$PrefixSpecial_InputName field="$field" IdField=="$IdField"/>" value="" />
&nbsp;<span class="error" id="error_<inp2:$PrefixSpecial_InputName field="$field"/>"></span>
<inp2:m_blockend />
<inp2:m_block name="config_edit_option" />
<option value="<inp2:m_param name="key"/>"<inp2:m_param name="selected"/>><inp2:m_param name="option"/></option>
<inp2:m_blockend />
<inp2:m_block name="config_edit_select" />
<select name="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>">
<inp2:$PrefixSpecial_PredefinedOptions field="$field" tabindex="$pass_tabindex" block="config_edit_option" selected="selected"/>
</select>
<inp2:m_blockend />
<inp2:m_block name="config_edit_checkbox"/>
<input type="hidden" id="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>" name="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>" value="<inp2:$PrefixSpecial_Field field="$field" db="db"/>">
<input tabindex="<inp2:m_get param="tab_index"/>" type="checkbox" id="_cb_<inp2:m_param name="field"/>" name="_cb_<inp2:m_param name="field"/>" <inp2:$PrefixSpecial_Field field="$field" checked="checked" db="db"/> class="<inp2:m_param name="field_class"/>" onclick="update_checkbox(this, document.getElementById('<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>'))">
<inp2:m_blockend/>
<inp2:m_block name="config_edit_textarea" />
<textarea name="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>" <inp2:m_param name="field_params" />><inp2:$PrefixSpecial_Field field="$field" /></textarea>
<inp2:m_blockend />
<inp2:m_block name="config_radio_item"/>
<input type="radio" <inp2:m_param name="checked"/> name="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>" id="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>_<inp2:m_param name="key"/>" value="<inp2:m_param name="key"/>"><label for="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>_<inp2:m_param name="key"/>"><inp2:m_param name="option"/></label>&nbsp;
<inp2:m_blockend/>
<inp2:m_block name="config_edit_radio"/>
<inp2:$PrefixSpecial_PredefinedOptions field="$field" tabindex="$pass_tabindex" block="config_radio_item" selected="checked"/>
<inp2:m_blockend/>
<inp2:m_block name="edit_custom_td" />
<td valign="top" class="text">
<input type="hidden" name="<inp2:$PrefixSpecial_InputName field="ResourceId" IdField="$IdField"/>" id="<inp2:$PrefixSpecial_InputName field="ResourceId" IdField="$IdField"/>" value="<inp2:$PrefixSpecial_field field="ResourceId" grid="$grid"/>">
<input type="hidden" name="<inp2:$PrefixSpecial_InputName field="CustomDataId" IdField="$IdField"/>" id="<inp2:$PrefixSpecial_InputName field="CustomDataId" IdField="$IdField"/>" value="<inp2:$PrefixSpecial_field field="CustomDataId" grid="$grid"/>">
<!--<input size="40" type="text" name="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>" id="<inp2:$PrefixSpecial_InputName field="$field" IdField="$IdField"/>" value="<inp2:$PrefixSpecial_field field="$field" grid="$grid"/>">-->
+
<inp2:$PrefixSpecial_ConfigFormElement field="Value" blocks_prefix="config_edit_" element_type_field="ElementType" value_list_field="ValueList" />
</td>
<inp2:m_blockend />
\ No newline at end of file
Property changes on: trunk/core/admin_templates/incs/custom_blocks.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property

Event Timeline