Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sun, Feb 2, 11:00 AM

in-portal

Index: branches/unlabeled/unlabeled-1.2.2/kernel/units/custom_fields/custom_fields_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.2.2/kernel/units/custom_fields/custom_fields_tag_processor.php (revision 5855)
+++ branches/unlabeled/unlabeled-1.2.2/kernel/units/custom_fields/custom_fields_tag_processor.php (revision 5856)
@@ -1,95 +1,119 @@
<?php
class CustomFieldsTagProcessor extends kDBTagProcessor {
/**
* Return LEFT JOINed custom field name from main item config
*
* @param Array $params
* @return string
*/
function GetMainField($params)
{
$object =& $this->getObject($params);
$append = isset($params['append']) && $params['append'] ? $params['append'] : '';
return 'cust_'.$object->GetDBField('FieldName').$append;
}
function CustomField($params)
{
$params['name'] = $this->GetMainField($params);
$source_prefix = $this->Application->Parser->GetParam('SourcePrefix');
return $this->Application->ProcessParsedTag($source_prefix, 'Field', $params);
}
function CustomFormat($params)
{
$params['name'] = $this->GetMainField($params);
$source_prefix = $this->Application->Parser->GetParam('SourcePrefix');
return $this->Application->ProcessParsedTag($source_prefix, 'Format', $params);
}
function CustomInputName($params)
{
$params['name'] = $this->GetMainField($params);
$source_prefix = $this->Application->Parser->GetParam('SourcePrefix');
return $this->Application->ProcessParsedTag($source_prefix, 'InputName', $params);
}
function CustomError($params)
{
$params['name'] = $this->GetMainField($params);
$source_prefix = $this->Application->Parser->GetParam('SourcePrefix');
return $this->Application->ProcessParsedTag($source_prefix, 'Error', $params);
}
+ function setParamValue(&$params, $param_name)
+ {
+ if (!isset($params[$param_name])) {
+ $params[$param_name] = $this->Application->Parser->GetParam($param_name, 1);
+ }
+
+ return $params[$param_name];
+ }
+
/**
* Prints list content using block specified
*
* @param Array $params
* @return string
* @access public
*/
function PrintList($params)
{
+ $this->setParamValue($params, 'SourcePrefix');
+ $this->setParamValue($params, 'value_field');
+
$list =& $this->GetList($params);
$id_field = $this->Application->getUnitOption($this->Prefix,'IDField');
$list->Query();
$o = '';
$list->GoFirst();
-
- $block_params=$this->prepareTagParams($params);
+
+ $block_params = $this->prepareTagParams($params);
$block_params['name'] = $this->SelectParam($params, 'render_as,block');
$block_params['pass_params'] = 'true';
$prev_heading = '';
$source_prefix = getArrayValue($params, 'SourcePrefix');
if ($source_prefix) {
$source_object =& $this->Application->recallObject($source_prefix);
}
+ // $deep_level if GetParam = 1 used in case if PrintList is called during parsing "grid" block (=> +1 to deep_level)
+ $display_original = $this->setParamValue($params, 'display_original');
+ if ($display_original) {
+ $block_params['display_original'] = $display_original;
+ $block_params['original_title'] = $this->setParamValue($params, 'original_title');
+ $original_object =& $this->Application->recallObject($source_prefix.'.original');
+ }
+
if ($this->Special == 'general') {
$this->groupRecords($list->Records, 'Heading');
}
while (!$list->EOL())
{
$this->Application->SetVar( $this->getPrefixSpecial().'_id', $list->GetDBField($id_field) ); // for edit/delete links using GET
if ($source_prefix) {
$list->SetDBField($params['value_field'], $source_object->GetDBField('cust_'.$list->GetDBField('FieldName')));
+ if ($display_original) {
+ $list->SetDBField('OriginalValue', $original_object->GetField('cust_'.$list->GetDBField('FieldName')));
+ }
+ $block_params['field'] = 'cust_'.$list->GetDBField('FieldName');
$block_params['show_heading'] = ($prev_heading != $list->GetDBField('Heading') ) ? 1 : 0;
}
$o.= $this->Application->ParseBlock($block_params, 1);
$prev_heading = $list->GetDBField('Heading');
$list->GoNext();
}
$this->Application->SetVar( $this->getPrefixSpecial().'_id', '');
return $o;
}
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.2.2/kernel/units/custom_fields/custom_fields_tag_processor.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2.2.1
\ No newline at end of property
+1.2.2.2
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.2.2/core/units/custom_fields/custom_fields_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.2.2/core/units/custom_fields/custom_fields_tag_processor.php (revision 5855)
+++ branches/unlabeled/unlabeled-1.2.2/core/units/custom_fields/custom_fields_tag_processor.php (revision 5856)
@@ -1,95 +1,119 @@
<?php
class CustomFieldsTagProcessor extends kDBTagProcessor {
/**
* Return LEFT JOINed custom field name from main item config
*
* @param Array $params
* @return string
*/
function GetMainField($params)
{
$object =& $this->getObject($params);
$append = isset($params['append']) && $params['append'] ? $params['append'] : '';
return 'cust_'.$object->GetDBField('FieldName').$append;
}
function CustomField($params)
{
$params['name'] = $this->GetMainField($params);
$source_prefix = $this->Application->Parser->GetParam('SourcePrefix');
return $this->Application->ProcessParsedTag($source_prefix, 'Field', $params);
}
function CustomFormat($params)
{
$params['name'] = $this->GetMainField($params);
$source_prefix = $this->Application->Parser->GetParam('SourcePrefix');
return $this->Application->ProcessParsedTag($source_prefix, 'Format', $params);
}
function CustomInputName($params)
{
$params['name'] = $this->GetMainField($params);
$source_prefix = $this->Application->Parser->GetParam('SourcePrefix');
return $this->Application->ProcessParsedTag($source_prefix, 'InputName', $params);
}
function CustomError($params)
{
$params['name'] = $this->GetMainField($params);
$source_prefix = $this->Application->Parser->GetParam('SourcePrefix');
return $this->Application->ProcessParsedTag($source_prefix, 'Error', $params);
}
+ function setParamValue(&$params, $param_name)
+ {
+ if (!isset($params[$param_name])) {
+ $params[$param_name] = $this->Application->Parser->GetParam($param_name, 1);
+ }
+
+ return $params[$param_name];
+ }
+
/**
* Prints list content using block specified
*
* @param Array $params
* @return string
* @access public
*/
function PrintList($params)
{
+ $this->setParamValue($params, 'SourcePrefix');
+ $this->setParamValue($params, 'value_field');
+
$list =& $this->GetList($params);
$id_field = $this->Application->getUnitOption($this->Prefix,'IDField');
$list->Query();
$o = '';
$list->GoFirst();
-
- $block_params=$this->prepareTagParams($params);
+
+ $block_params = $this->prepareTagParams($params);
$block_params['name'] = $this->SelectParam($params, 'render_as,block');
$block_params['pass_params'] = 'true';
$prev_heading = '';
$source_prefix = getArrayValue($params, 'SourcePrefix');
if ($source_prefix) {
$source_object =& $this->Application->recallObject($source_prefix);
}
+ // $deep_level if GetParam = 1 used in case if PrintList is called during parsing "grid" block (=> +1 to deep_level)
+ $display_original = $this->setParamValue($params, 'display_original');
+ if ($display_original) {
+ $block_params['display_original'] = $display_original;
+ $block_params['original_title'] = $this->setParamValue($params, 'original_title');
+ $original_object =& $this->Application->recallObject($source_prefix.'.original');
+ }
+
if ($this->Special == 'general') {
$this->groupRecords($list->Records, 'Heading');
}
while (!$list->EOL())
{
$this->Application->SetVar( $this->getPrefixSpecial().'_id', $list->GetDBField($id_field) ); // for edit/delete links using GET
if ($source_prefix) {
$list->SetDBField($params['value_field'], $source_object->GetDBField('cust_'.$list->GetDBField('FieldName')));
+ if ($display_original) {
+ $list->SetDBField('OriginalValue', $original_object->GetField('cust_'.$list->GetDBField('FieldName')));
+ }
+ $block_params['field'] = 'cust_'.$list->GetDBField('FieldName');
$block_params['show_heading'] = ($prev_heading != $list->GetDBField('Heading') ) ? 1 : 0;
}
$o.= $this->Application->ParseBlock($block_params, 1);
$prev_heading = $list->GetDBField('Heading');
$list->GoNext();
}
$this->Application->SetVar( $this->getPrefixSpecial().'_id', '');
return $o;
}
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.2.2/core/units/custom_fields/custom_fields_tag_processor.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2.2.1
\ No newline at end of property
+1.2.2.2
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.10.2/kernel/units/custom_fields/custom_fields_config.php
===================================================================
--- branches/unlabeled/unlabeled-1.10.2/kernel/units/custom_fields/custom_fields_config.php (revision 5855)
+++ branches/unlabeled/unlabeled-1.10.2/kernel/units/custom_fields/custom_fields_config.php (revision 5856)
@@ -1,119 +1,131 @@
<?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'=>'CustomFieldsTagProcessor','file'=>'custom_fields_tag_processor.php','build_event'=>'OnBuild'),
'AutoLoad' => true,
'hooks' => Array(),
'QueryString' => Array(
1 => 'id',
2 => 'page',
3 => 'event',
4 => 'type',
5 => 'mode',
),
'Hooks' => Array(
Array(
'Mode' => hAFTER,
'Conditional' => false,
'HookToPrefix' => 'cf',
'HookToSpecial' => '*',
'HookToEvent' => Array('OnSave'), // edit cloned fields to made alters :)
'DoPrefix' => 'cf',
'DoSpecial' => '*',
'DoEvent' => 'OnSaveCustomField',
),
),
'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'),
),
'general' => Array(
'Sorting' => Array('DisplayOrder' => 'asc')
),
),
'ItemSQLs' => Array( ''=>'SELECT * FROM %s',
),
'SubItems' => Array('confs-cf'),
'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', 'required' => 1, 'default' => ''),
'Heading' => Array('type' => 'string', 'required' => 1, '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', 'text' => 'la_type_text', 'select' => 'la_type_select', 'radio' => 'la_type_radio', 'checkbox' => 'la_type_checkbox', 'password' => 'la_type_password', 'textarea' => 'la_type_textarea', 'label' => 'la_type_label', 'date' => 'la_type_date', 'datetime' => 'la_type_datetime')),
'ValueList' => Array('type' => 'string','default' => ''),
'DisplayOrder' => Array('type' => 'int','not_null' => '1','default' => '0'),
'OnGeneralTab' => Array('type' => 'int','not_null' => '1','default' => '0'),
'IsSystem' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array(0 => 'la_No', 1 => 'la_Yes'), 'use_phrases' => 1, 'not_null' => '1', 'default' => '0'),
),
'VirtualFields' => Array(
- 'Value' => Array('type' => 'string', 'default' => ''),
+ 'Value' => Array('type' => 'string', 'default' => ''),
+ 'OriginalValue' => Array('type' => 'string', 'default' => ''),
+
),
'Grids' => Array(
- 'Default' => 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'),
),
-
- ),
- 'SeparateTab' => Array(
+ ),
+
+ 'SeparateTab' => Array(
'Icons' => Array('default'=>'icon16_custom.gif'),
'Fields' => Array(
'FieldName' => Array( 'title'=>'la_col_FieldName', 'data_block' => 'grid_icon_td'),
- 'Prompt' => Array( 'title'=>'la_col_Prompt', 'data_block' => 'grid_data_label_ml_td' ),
+ 'Prompt' => Array( 'title'=>'la_col_Prompt', 'data_block' => 'grid_data_label_ml_td', 'ElementTypeField' => 'ElementType'),
'Value' => Array( 'title'=>'la_col_Value', 'data_block' => 'edit_custom_td'),
),
- ),
-
+ ),
+
+ 'SeparateTabOriginal' => Array(
+ 'Icons' => Array('default'=>'icon16_custom.gif'),
+ 'Fields' => Array(
+ 'FieldName' => Array( 'title'=>'la_col_FieldName', 'data_block' => 'grid_icon_td'),
+ 'Prompt' => Array( 'title'=>'la_col_Prompt', 'data_block' => 'grid_data_label_ml_td', 'ElementTypeField' => 'ElementType'),
+ 'Value' => Array( 'title'=>'la_col_Value', 'data_block' => 'edit_custom_td'),
+ 'OriginalValue' => Array( 'title'=>'la_col_OriginalValue', 'data_block' => 'grid_original_td'),
+ ),
+ ),
+
),
);
if (constOn('DEBUG_MODE')) {
$config['Grids']['Default']['Fields']['IsSystem'] = Array('title' => 'la_col_IsSystem');
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.10.2/kernel/units/custom_fields/custom_fields_config.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.10.2.1
\ No newline at end of property
+1.10.2.2
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.10.2/core/units/custom_fields/custom_fields_config.php
===================================================================
--- branches/unlabeled/unlabeled-1.10.2/core/units/custom_fields/custom_fields_config.php (revision 5855)
+++ branches/unlabeled/unlabeled-1.10.2/core/units/custom_fields/custom_fields_config.php (revision 5856)
@@ -1,119 +1,131 @@
<?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'=>'CustomFieldsTagProcessor','file'=>'custom_fields_tag_processor.php','build_event'=>'OnBuild'),
'AutoLoad' => true,
'hooks' => Array(),
'QueryString' => Array(
1 => 'id',
2 => 'page',
3 => 'event',
4 => 'type',
5 => 'mode',
),
'Hooks' => Array(
Array(
'Mode' => hAFTER,
'Conditional' => false,
'HookToPrefix' => 'cf',
'HookToSpecial' => '*',
'HookToEvent' => Array('OnSave'), // edit cloned fields to made alters :)
'DoPrefix' => 'cf',
'DoSpecial' => '*',
'DoEvent' => 'OnSaveCustomField',
),
),
'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'),
),
'general' => Array(
'Sorting' => Array('DisplayOrder' => 'asc')
),
),
'ItemSQLs' => Array( ''=>'SELECT * FROM %s',
),
'SubItems' => Array('confs-cf'),
'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', 'required' => 1, 'default' => ''),
'Heading' => Array('type' => 'string', 'required' => 1, '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', 'text' => 'la_type_text', 'select' => 'la_type_select', 'radio' => 'la_type_radio', 'checkbox' => 'la_type_checkbox', 'password' => 'la_type_password', 'textarea' => 'la_type_textarea', 'label' => 'la_type_label', 'date' => 'la_type_date', 'datetime' => 'la_type_datetime')),
'ValueList' => Array('type' => 'string','default' => ''),
'DisplayOrder' => Array('type' => 'int','not_null' => '1','default' => '0'),
'OnGeneralTab' => Array('type' => 'int','not_null' => '1','default' => '0'),
'IsSystem' => Array('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array(0 => 'la_No', 1 => 'la_Yes'), 'use_phrases' => 1, 'not_null' => '1', 'default' => '0'),
),
'VirtualFields' => Array(
- 'Value' => Array('type' => 'string', 'default' => ''),
+ 'Value' => Array('type' => 'string', 'default' => ''),
+ 'OriginalValue' => Array('type' => 'string', 'default' => ''),
+
),
'Grids' => Array(
- 'Default' => 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'),
),
-
- ),
- 'SeparateTab' => Array(
+ ),
+
+ 'SeparateTab' => Array(
'Icons' => Array('default'=>'icon16_custom.gif'),
'Fields' => Array(
'FieldName' => Array( 'title'=>'la_col_FieldName', 'data_block' => 'grid_icon_td'),
- 'Prompt' => Array( 'title'=>'la_col_Prompt', 'data_block' => 'grid_data_label_ml_td' ),
+ 'Prompt' => Array( 'title'=>'la_col_Prompt', 'data_block' => 'grid_data_label_ml_td', 'ElementTypeField' => 'ElementType'),
'Value' => Array( 'title'=>'la_col_Value', 'data_block' => 'edit_custom_td'),
),
- ),
-
+ ),
+
+ 'SeparateTabOriginal' => Array(
+ 'Icons' => Array('default'=>'icon16_custom.gif'),
+ 'Fields' => Array(
+ 'FieldName' => Array( 'title'=>'la_col_FieldName', 'data_block' => 'grid_icon_td'),
+ 'Prompt' => Array( 'title'=>'la_col_Prompt', 'data_block' => 'grid_data_label_ml_td', 'ElementTypeField' => 'ElementType'),
+ 'Value' => Array( 'title'=>'la_col_Value', 'data_block' => 'edit_custom_td'),
+ 'OriginalValue' => Array( 'title'=>'la_col_OriginalValue', 'data_block' => 'grid_original_td'),
+ ),
+ ),
+
),
);
if (constOn('DEBUG_MODE')) {
$config['Grids']['Default']['Fields']['IsSystem'] = Array('title' => 'la_col_IsSystem');
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.10.2/core/units/custom_fields/custom_fields_config.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.10.2.1
\ No newline at end of property
+1.10.2.2
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.73.2/core/kernel/db/db_event_handler.php
===================================================================
--- branches/unlabeled/unlabeled-1.73.2/core/kernel/db/db_event_handler.php (revision 5855)
+++ branches/unlabeled/unlabeled-1.73.2/core/kernel/db/db_event_handler.php (revision 5856)
@@ -1,1828 +1,1839 @@
<?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 kDBConnection
* @access public
*/
var $Conn;
/**
* Adds ability to address db connection
*
* @return kDBEventHandler
* @access public
*/
function kDBEventHandler()
{
parent::kBase();
$this->Conn =& $this->Application->GetADODBConnection();
}
/**
* Checks permissions of user
*
* @param kEvent $event
*/
function CheckPermission(&$event)
{
if (!$this->Application->IsAdmin()) {
$allow_events = Array('OnSearch', 'OnSearchReset', 'OnNew');
if (in_array($event->Name, $allow_events)) {
// allow search on front
return true;
}
}
$section = $event->getSection();
if (!preg_match('/^CATEGORY:(.*)/', $section)) {
// only if not category item events
if ((substr($event->Name, 0, 9) == 'OnPreSave') || ($event->Name == 'OnSave')) {
if ($this->isNewItemCreate($event)) {
return $this->Application->CheckPermission($section.'.add', 1);
}
else {
return $this->Application->CheckPermission($section.'.add', 1) || $this->Application->CheckPermission($section.'.edit', 1);
}
}
}
if ($event->Name == 'OnPreCreate') {
// save category_id before item create (for item category selector not to destroy permission checking category)
$this->Application->LinkVar('m_cat_id');
}
return parent::CheckPermission($event);
}
/**
* Allows to override standart permission mapping
*
*/
function mapPermissions()
{
parent::mapPermissions();
$permissions = Array(
'OnLoad' => Array('self' => 'view', 'subitem' => 'view'),
'OnNew' => Array('self' => 'add', 'subitem' => 'add|edit'),
'OnCreate' => Array('self' => 'add', 'subitem' => 'add|edit'),
'OnUpdate' => Array('self' => 'edit', 'subitem' => 'add|edit'),
'OnSetPrimary' => Array('self' => 'add|edit', 'subitem' => 'add|edit'),
'OnDelete' => Array('self' => 'delete', 'subitem' => 'add|edit'),
'OnMassDelete' => Array('self' => 'delete', 'subitem' => 'add|edit'),
'OnMassClone' => Array('self' => 'add', 'subitem' => 'add|edit'),
'OnSelectItems' => Array('self' => 'add|edit', 'subitem' => 'add|edit'),
'OnProcessSelected' => Array('self' => 'add|edit', 'subitem' => 'add|edit'),
'OnSelectUser' => Array('self' => 'add|edit', 'subitem' => 'add|edit'),
'OnMassApprove' => Array('self' => 'advanced:approve|add|edit', 'subitem' => 'advanced:approve|add|edit'),
'OnMassDecline' => Array('self' => 'advanced:decline|add|edit', 'subitem' => 'advanced:decline|add|edit'),
'OnMassMoveUp' => Array('self' => 'advanced:move_up|add|edit', 'subitem' => 'advanced:move_up|add|edit'),
'OnMassMoveDown' => Array('self' => 'advanced:move_down|add|edit', 'subitem' => 'advanced:move_down|add|edit'),
'OnPreCreate' => Array('self' => 'add'),
'OnEdit' => Array('self' => 'edit'),
// theese event do not harm, but just in case check them too :)
'OnCancelEdit' => Array('self' => 'add|edit'),
'OnCancel' => Array('self' => 'add|edit', 'subitem' => 'add|edit'),
'OnSetSorting' => Array('self' => 'view', 'subitem' => 'view'),
'OnSetSortingDirect' => Array('self' => 'view', 'subitem' => 'view'),
'OnSetFilter' => Array('self' => 'view', 'subitem' => 'view'),
'OnApplyFilters' => Array('self' => 'view', 'subitem' => 'view'),
'OnRemoveFilters' => Array('self' => 'view', 'subitem' => 'view'),
'OnSetPerPage' => Array('self' => 'view', 'subitem' => 'view'),
'OnSearch' => Array('self' => 'view', 'subitem' => 'view'),
'OnSearchReset' => Array('self' => 'view', 'subitem' => 'view'),
'OnGoBack' => Array('self' => true, 'subitem' => true),
);
$this->permMapping = array_merge($this->permMapping, $permissions);
}
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)
{
if ($event->getEventParam('raise_warnings') === false) {
$event->setEventParam('raise_warnings', 1);
}
// 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
* @return Array ids stored
*/
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) && ($event->getEventParam('raise_warnings') == 1)) {
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);
return $ret;
}
/**
* 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)
+ function dbBuild(&$object, &$event)
{
$object->Configure();
$this->PrepareObject($object, $event);
- $live_table = $event->getEventParam('live_table');
+ // force live table if specified or is original item
+ $live_table = $event->getEventParam('live_table') || $event->Special == 'original';
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');
$skip_autload = $event->getEventParam('skip_autoload');
if($auto_load && !$skip_autload) $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';
}
/**
* Returns table prefix from event (temp or live)
*
* @param kEvent $event
* @return string
* @todo Needed? Should be refactored (by Alex)
*/
function TablePrefix(&$event)
{
return $this->UseTempTables($event) ? $this->Application->GetTempTablePrefix().TABLE_PREFIX : TABLE_PREFIX;
}
+ /**
+ * Load item if id is available
+ *
+ * @param kEvent $event
+ */
function LoadItem(&$event)
{
$object =& $event->getObject();
$id = $this->getPassedID($event);
if ($object->Load($id) )
{
$actions =& $this->Application->recallObject('kActions');
$actions->Set($event->Prefix_Special.'_id', $object->GetID() );
+
+ $use_pending_editing = $this->Application->getUnitOption($event->Prefix, 'UsePendingEditing');
+ if ($use_pending_editing && $event->Special != 'original') {
+ $this->Application->SetVar($event->Prefix.'.original_id', $object->GetDBField('OrgId'));
+ }
}
else
{
$object->setID($id);
}
}
/**
* Builds list
*
* @param kEvent $event
* @access protected
*/
function OnListBuild(&$event)
{
$object =& $event->getObject();
$this->dbBuild($object,$event);
$sql = $this->ListPrepareQuery($event);
$sql = $this->Application->ReplaceLanguageTags($sql);
$object->setSelectSQL($sql);
$object->linkToParent( $this->getMainSpecial($event) );
$this->AddFilters($event);
$this->SetCustomQuery($event); // new!, use this for dynamic queries based on specials for ex.
$this->SetPagination($event);
$this->SetSorting($event);
$object->CalculateTotals();
$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 = $this->getPerPage($event);
$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);
}
if( !$event->getEventParam('skip_counting') )
{
$pages = $object->GetTotalPages();
if($page > $pages)
{
$this->Application->StoreVar($event->getPrefixSpecial().'_Page', 1);
$page = 1;
}
}
/*$per_page = $event->getEventParam('per_page');
if ($per_page == 'list_next') {
$cur_page = $page;
$cur_per_page = $per_page;
$object->SetPerPage(1);
$object =& $this->Application->recallObject($event->Prefix);
$cur_item_index = $object->CurrentIndex;
$page = ($cur_page-1) * $cur_per_page + $cur_item_index + 1;
$object->SetPerPage(1);
}*/
$object->SetPage($page);
}
function getPerPage(&$event)
{
$per_page = $event->getEventParam('per_page');
/* if ($per_page == 'list_next') {
$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) {
if (!isset($config_mapping['PerPage'])) {
trigger_error('Incorrect mapping of <span class="debug_error">PerPage</span> key in config for prefix <b>'.$event->Prefix.'</b>', E_USER_WARNING);
}
$per_page = $this->Application->ConfigValue($config_mapping['PerPage']);
}
if(!$per_page) $per_page = 10;
}
}
return $per_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)
{
$object =& $event->getObject( Array('skip_autoload' => true) );
$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)
{
$object =& $event->getObject( Array('skip_autoload' => true) );
$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)
{
$object =& $event->getObject( Array('skip_autoload' => true) );
$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)
{
$object =& $event->getObject( Array('skip_autoload' => true) );
$object->setID(0);
$this->Application->SetVar($event->Prefix_Special.'_SaveEvent','OnCreate');
$table_info = $object->getLinkedInfo();
$object->SetDBField($table_info['ForeignKey'], $table_info['ParentId']);
$event->redirect = false;
}
/**
* Cancel's kDBItem Editing/Creation
*
* @param kEvent $event
* @access protected
*/
function OnCancel(&$event)
{
$object =& $event->getObject(Array('skip_autoload' => true));
$items_info = $this->Application->GetVar($event->getPrefixSpecial(true));
if ($items_info) {
$delete_ids = Array();
$temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
foreach ($items_info as $id => $field_values) {
$object->Load($id);
// record created for using with selector (e.g. Reviews->Select User), and not validated => Delete it
if ($object->isLoaded() && !$object->Validate() && ($id <= 0) ) {
$delete_ids[] = $id;
}
}
if ($delete_ids) {
$temp->DeleteItems($event->Prefix, $event->Special, $delete_ids);
}
}
$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)
{
if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) {
return;
}
$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');
if (!$this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) {
$temp->SaveEdit($event->getEventParam('master_ids') ? $event->getEventParam('master_ids') : Array());
}
$this->clearSelectedIDs($event);
$event->redirect_params = Array('opener' => 'u');
$this->Application->RemoveVar($event->getPrefixSpecial().'_modified');
// all temp tables are deleted here => all after hooks should think, that it's live mode now
$this->Application->SetVar($event->Prefix.'_mode', '');
}
}
/**
* 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');
}
/**
* Allows to determine if we are creating new item or editing already created item
*
* @param kEvent $event
* @return bool
*/
function isNewItemCreate(&$event)
{
$item_id = $this->getPassedID($event);
return ($item_id == '') ? true : false;
}
/**
* 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);
}
if ($this->isNewItemCreate($event)) {
$event->CallSubEvent('OnPreSaveCreated');
if (is_object($event->MasterEvent)) {
$event->MasterEvent->setEventParam('IsNew',true);
}
return;
}
$object =& $event->getObject( Array('skip_autoload' => true) );
$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);
$this->customProcessing($event, 'before');
if( $object->Update($id) )
{
$this->customProcessing($event, 'after');
$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);
$object =& $event->getObject( Array('skip_autoload' => true) );
$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)
{
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if($items_info) $field_values = array_shift($items_info);
$object =& $event->getObject( Array('skip_autoload' => true) );
$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)
{
}
/**
* Enter description here...
*
* @param kEvent $event
* @param string $search_field
* @param string $type
* @param string $value
* @param string $formatter_class
*/
function processRangeField(&$event, $search_field, $type, $value, $formatter_class)
{
$field = $search_field.'_'.$type;
$lang_current =& $this->Application->recallObject('lang.current');
$object =& $event->getObject();
$dt_separator = getArrayValue( $object->GetFieldOptions($search_field), 'date_time_separator' );
if(!$dt_separator) $dt_separator = ' ';
$time = ($type == 'datefrom') ? adodb_mktime(0,0,0) : adodb_mktime(23,59,59);
$time = adodb_date( $lang_current->GetDBField('InputTimeFormat'), $time);
$full_value = $value.$dt_separator.$time;
$formatter =& $this->Application->recallObject($formatter_class);
$value_ts = $formatter->Parse($full_value, $search_field, $object);
$pseudo = getArrayValue($object->FieldErrors, $search_field, 'pseudo');
if($pseudo)
{
$this->Application->StoreVar($event->getPrefixSpecial().'_'.$field.'_error', $pseudo);
return -1;
}
return $value_ts;
}
/**
* Ensures that popup will be closed automatically
* and parent window will be refreshed with template
* passed
*
* @param kEvent $event
* @access public
*/
function finalizePopup(&$event)
{
$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);
$t = $this->Application->RecallVar('return_template');
$this->Application->RemoveVar('return_template');
// restore original "m" prefix all params, that have values before opening selector
$return_m = $this->Application->RecallVar('return_m');
$this->Application->RemoveVar('return_m');
$this->Application->HttpQuery->parseEnvPart($return_m);
$pass_events = $event->getEventParam('pass_events');
$redirect_params = array_merge_recursive2($event->redirect_params, Array('m_opener' => 'u', '__URLENCODE__' => 1));
$new_level = 'index.php|'.ltrim($this->Application->BuildEnv($t, $redirect_params, 'all', $pass_events), 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();
$search_keyword = $this->Application->GetVar( $event->getPrefixSpecial(true).'_search_keyword');
$this->Application->StoreVar( $event->getPrefixSpecial().'_search_keyword', $search_keyword);
$search_keyword = str_replace('*', '%', $search_keyword);
$custom_filters = $this->Application->RecallVar( $event->getPrefixSpecial().'_custom_filters');
$custom_filters = $custom_filters ? unserialize($custom_filters) : Array();
$submit_custom_filters = $this->Application->GetVar('custom_filters');
if ($submit_custom_filters) {
$submit_custom_filters = getArrayValue($submit_custom_filters, $event->getPrefixSpecial() );
if ($submit_custom_filters) {
foreach ($submit_custom_filters as $cf_name => $cf_value) {
if ($cf_value) {
$custom_filters[$cf_name] = $cf_value;
}
else {
unset($custom_filters[$cf_name]);
}
}
}
}
$this->Application->StoreVar($event->getPrefixSpecial().'_custom_filters', serialize($custom_filters) );
if( !$search_keyword && !count($custom_filters) )
{
$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();
$search_helper =& $this->Application->recallObject('SearchHelper');
$search_keywords = $search_helper->splitKeyword($search_keyword);
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
$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();
$field_value = getArrayValue($custom_filters, $search_field);
if ($field_value !== false) {
// if keyword passed through advanced search filter (e.g. on Visits lists section)
array_push($search_keys, $this->Conn->qstr($field_value));
}
else {
// if keywords passed through simple search filter (on each grid)
$use_phrases = getArrayValue($object->Fields[$search_field], 'use_phrases');
$field_options = $object->GetFieldOptions($search_field);
foreach ($field_options['options'] as $key => $val) {
foreach ($search_keywords as $keyword => $sign) {
$pattern = '#'.$keyword.'#i';
if (!preg_match($pattern, $use_phrases ? $this->Application->Phrase($val) : $val)) {
if ($sign == '+') {
$filter_value = $table_name.'`'.$search_field.'` = NULL';
break;
}
else {
continue;
}
}
if ($sign == '+' || $sign == '') {
$search_keys[$key] = $this->Conn->qstr($key);
}
elseif($sign == '-') {
// if same value if found as exclusive too, then remove from search result
unset($search_keys[$key]);
}
}
}
}
if ($search_keys) {
$filter_value = $table_name.'`'.$search_field.'` IN ('.implode(',', $search_keys).')';
}
$field_processed = true;
break;
case 'kDateFormatter':
$custom_filter = getArrayValue($object->Fields[$search_field], 'custom_filter');
if(!$custom_filter)
{
$field_processed = false;
break;
}
$filter_value = Array();
$field_value = getArrayValue($custom_filters, $search_field.'_datefrom');
if($field_value)
{
$value = $this->processRangeField($event, $search_field, 'datefrom', $field_value, $formatter);
$filter_value[] = $table_name.'`'.$search_field.'` >= '.$value;
}
$field_value = getArrayValue($custom_filters, $search_field.'_dateto');
if($field_value)
{
$value = $this->processRangeField($event, $search_field, 'dateto', $field_value, $formatter);
$filter_value[] = $table_name.'`'.$search_field.'` <= '.$value;
}
$filter_value = $filter_value ? '('.implode(') AND (', $filter_value).')' : '';
$field_processed = true;
break;
default:
$field_processed = false;
break;
}
// if not already processed by formatter, then get clause by field type
if (!$field_processed && $search_keywords) {
switch($field_type)
{
case 'int':
case 'integer':
case 'numeric':
$search_keys = Array();
foreach ($search_keywords as $keyword => $sign) {
if (!is_numeric($keyword) || ($sign == '-')) continue;
$search_keys[] = $this->Conn->qstr($keyword);
}
if ($search_keys) {
$filter_value = $table_name.'`'.$search_field.'` IN ('.implode(',', $search_keys).')';
}
break;
case 'double':
case 'float':
case 'real':
$search_keys = Array();
foreach ($search_keywords as $keyword => $sign) {
$keyword = str_replace(',', '.', $keyword);
if (!is_numeric($keyword) || ($sign == '-')) continue;
$search_keys[] = 'ABS('.$table_name.'`'.$search_field.'` - '.$this->Conn->qstr($keyword).') <= 0.0001';
}
if ($search_keys) {
$filter_value = '('.implode(') OR (', $search_keys).')';
}
break;
case 'string':
$filter_value = $search_helper->buildWhereClause($search_keyword, Array($table_name.'`'.$search_field.'`'));
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');
$this->Application->RemoveVar($event->getPrefixSpecial().'_custom_filters');
}
/**
* 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) {
$resource_id = $this->Application->GetVar('translator_resource_id');
if ($resource_id) {
$t_prefixes = explode(',', $this->Application->GetVar('translator_prefixes'));
$cdata =& $this->Application->recallObject($t_prefixes[1], null, Array('skip_autoload' => true));
$cdata->Load($resource_id, 'ResourceId');
if (!$cdata->isLoaded()) {
$cdata->SetDBField('ResourceId', $resource_id);
$cdata->Create();
}
$this->Application->SetVar($cdata->getPrefixSpecial().'_id', $cdata->GetID());
}
$event->redirect = $this->Application->GetVar('translator_t');
$event->redirect_params = Array('pass'=>'all,trans,'.$this->Application->GetVar('translator_prefixes'),
$event->getPrefixSpecial(true).'_id' => $object->GetID(),
'trans_event' => 'OnLoad',
'trans_prefix' => $this->Application->GetVar('translator_prefixes'),
'trans_field' => $this->Application->GetVar('translator_field'),
'trans_multi_line' => $this->Application->GetVar('translator_multi_line'),
);
// 1. SAVE LAST TEMPLATE TO SESSION (really needed here, because of tweaky redirect)
$last_template = $this->Application->RecallVar('last_template');
preg_match('/index4\.php\|'.$this->Application->GetSID().'-(.*):/U', $last_template, $rets);
$this->Application->StoreVar('return_template', $this->Application->GetVar('t'));
}
}
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']);
}
}
}
/**
* Dynamically fills customdata config
*
* @param kEvent $event
*/
function OnCreateCustomFields(&$event)
{
$main_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
if (!$main_prefix) return false;
$item_type = $this->Application->getUnitOption($main_prefix, 'ItemType');
if (!$item_type) {
// no main config of such type
return false;
}
// 1. get custom field information
$sql = 'SELECT *
FROM '.TABLE_PREFIX.'CustomField
WHERE Type = '.$item_type.'
ORDER BY CustomFieldId';
$custom_fields = $this->Conn->Query($sql, 'CustomFieldId');
if (!$custom_fields) {
// config doesn't have custom fields
return false;
}
// 2. create fields (for customdata item)
$fields = $this->Application->getUnitOption($event->Prefix, 'Fields', Array());
$field_options = Array('type' => 'string', 'formatter' => 'kMultiLanguage', 'not_null' => 1, 'db_type' => 'text', 'default' => '');
foreach ($custom_fields as $custom_id => $custom_params) {
$fields['cust_'.$custom_id] = $field_options;
}
$this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
// 3. create virtual & calculated fields (for main item)
$calculated_fields = $this->Application->getUnitOption($main_prefix.'.', 'CalculatedFields', Array());
$virtual_fields = $this->Application->getUnitOption($main_prefix, 'VirtualFields', Array());
$cf_helper =& $this->Application->recallObject('InpCustomFieldsHelper');
$field_options = Array('type' => 'string', 'not_null' => 1, 'default' => '');
$ml_formatter =& $this->Application->recallObject('kMultiLanguage');
foreach ($custom_fields as $custom_id => $custom_params) {
switch ($custom_params['ElementType']) {
case 'date':
case 'datetime':
unset($field_options['options']);
$field_options['formatter'] = 'kDateFormatter';
break;
case 'select':
case 'radio':
if ($custom_params['ValueList']) {
$field_options['options'] = $cf_helper->GetValuesHash($custom_params['ValueList']);
$field_options['formatter'] = 'kOptionsFormatter';
}
break;
default:
unset($field_options['options'], $field_options['formatter']);
break;
}
$custom_name = $custom_params['FieldName'];
$calculated_fields['cust_'.$custom_name] = 'cust.'.$ml_formatter->LangFieldName('cust_'.$custom_id);
if (!isset($virtual_fields['cust_'.$custom_name])) {
$virtual_fields['cust_'.$custom_name] = Array();
}
$virtual_fields['cust_'.$custom_name] = array_merge_recursive2($field_options, $virtual_fields['cust_'.$custom_name]);
$custom_fields[$custom_id] = $custom_name;
}
$this->Application->setUnitOption($main_prefix, 'CustomFields', $custom_fields);
$this->Application->setUnitOption($main_prefix.'.', 'CalculatedFields', $calculated_fields);
$this->Application->setUnitOption($main_prefix, 'VirtualFields', $virtual_fields);
}
/**
* Saves selected user in needed field
*
* @param kEvent $event
*/
function OnSelectUser(&$event)
{
$items_info = $this->Application->GetVar('u');
if ($items_info) {
$user_id = array_shift( array_keys($items_info) );
$object =& $event->getObject();
$this->RemoveRequiredFields($object);
$is_new = !$object->isLoaded();
$is_main = $this->Application->GetVar($event->Prefix.'_mode') == 't';
if ($is_new) {
$new_event = $is_main ? 'OnPreCreate' : 'OnNew';
$event->CallSubEvent($new_event);
}
$object->SetDBField($this->Application->RecallVar('dst_field'), $user_id);
if ($is_new) {
$object->Create();
if (!$is_main && $object->IsTempTable()) {
$object->setTempID();
}
}
else {
$object->Update();
}
}
$event->SetRedirectParam($event->getPrefixSpecial().'_id', $object->GetID());
$this->finalizePopup($event);
}
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.73.2/core/kernel/db/db_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.73.2.4
\ No newline at end of property
+1.73.2.5
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.44.2/kernel/admin_templates/incs/form_blocks.tpl
===================================================================
--- branches/unlabeled/unlabeled-1.44.2/kernel/admin_templates/incs/form_blocks.tpl (revision 5855)
+++ branches/unlabeled/unlabeled-1.44.2/kernel/admin_templates/incs/form_blocks.tpl (revision 5856)
@@ -1,383 +1,432 @@
<inp2:m_block name="section_header"/>
<inp2:m_if check="m_ParamEquals" name="prefix" value="" inverse="inverse">
<inp2:m_RenderElement name="section_header_new" pass_params="true"/>
<inp2:m_else />
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr class="section_header_bg">
<td valign="top" class="admintitle" align="left" style="padding-top: 2px; padding-bottom: 2px;">
<img width="46" height="46" src="img/icons/<inp2:adm_GetSectionIcon icon="$icon"/>.gif" align="absmiddle" title="<inp2:adm_GetSectionTitle phrase="$title"/>">&nbsp;<inp2:adm_GetSectionTitle phrase="$title"/>
</td>
</tr>
</table>
</inp2:m_if>
<inp2:m_blockend/>
<inp2:m_DefineElement name="section_header_new" module="#session#">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr style="background: url(<inp2:ModulePath module="$module"/>img/logo_bg.gif) no-repeat top right;">
<td valign="top" class="admintitle" align="left" style="padding-top: 2px; padding-bottom: 2px;">
<img width="46" height="46" src="<inp2:ModulePath/>img/icons/<inp2:adm_GetSectionIcon icon="$icon"/>.gif" align="absmiddle" title="<inp2:adm_GetSectionTitle phrase="$title"/>">&nbsp;<inp2:adm_GetSectionTitle phrase="$title"/>
</td>
</tr>
</table>
</inp2:m_DefineElement>
<inp2:m_block name="blue_bar" module="" icon=""/>
<table border="0" cellpadding="2" cellspacing="0" class="tableborder_full" width="100%" height="30">
<tr>
<td class="header_left_bg" nowrap width="80%" valign="middle">
<span class="tablenav_link" id="blue_bar"><inp2:$prefix_SectionTitle title_preset="$title_preset" title="Invalid OR Missing title preset [#preset_name#]" cut_first="100"/></span>
</td>
<td align="right" class="tablenav" width="20%" valign="middle">
<script>
var $help_url='<inp2:m_t t="help" h_prefix="$prefix" h_icon="$icon" h_module="$module" h_title_preset="$title_preset" pass="all,m,h" m_opener="p" escape="escape"/>';
$help_url = $help_url.replace(/#/g, '%23');
set_window_title( RemoveTranslationLink(document.getElementById('blue_bar').innerHTML, false).replace(/(<[^<]+>)/g, '') );
</script>
<a href="javascript: OpenHelp($help_url);">
<img src="img/blue_bar_help.gif" border="0">
</a>
</td>
</tr>
</table>
<inp2:m_blockend/>
-<inp2:m_block name="subsection"/>
- <tr class="subsectiontitle">
- <td colspan="3"><inp2:m_phrase label="$title"/></td>
- </tr>
+<inp2:m_DefineElement name="inp_original_label">
+ <td><inp2:$prefix.original_Field field="$field"/></td>
+</inp2:m_DefineElement>
+
+<inp2:m_block name="subsection" prefix=""/>
+ <tr class="subsectiontitle">
+ <td colspan="3"><inp2:m_phrase label="$title"/></td>
+ <inp2:m_if check="m_ParamEquals" name="prefix" value="" inverse="inverse">
+ <inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
+ <td><inp2:m_phrase name="$original_title"/></td>
+ </inp2:m_if>
+ </inp2:m_if>
+ </tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_field_caption" subfield="" NamePrefix=""/>
<inp2:m_inc param="tab_index" by="1"/>
<td class="text">
<label for="<inp2:m_param name="NamePrefix"/><inp2:$prefix_InputName field="$field" subfield="$subfield"/>">
<span class="<inp2:m_if prefix="$prefix" function="HasError" field="$field"/>error<inp2:m_endif/>">
<inp2:m_phrase label="$title"/></span><inp2:m_if prefix="$prefix" function="IsRequired" field="$field"/><span class="error"> *</span><inp2:m_endif/>:
</label>
</td>
<inp2:m_blockend/>
<inp2:m_block name="inp_label" is_last="" as_label="" currency="" is_last=""/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_ParseBlock name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td valign="top"><span class="text"><inp2:$prefix_Field field="$field" as_label="$as_label" currency="$currency"/></span></td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
+ <inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
+ <inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
+ </inp2:m_if>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_id_label"/>
- <inp2:m_if prefix="$prefix" function="FieldEquals" field="$field" value="" inverse="inverse"/>
+ <inp2:m_if check="{$prefix}_FieldEquals" field="$field" value="" inverse="inverse">
<inp2:m_ParseBlock name="inp_label" pass_params="true"/>
- <inp2:m_endif/>
+ </inp2:m_if>
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_box" subfield="" class="" is_last="" maxlength="" onblur="" size="" onkeyup=""/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_ParseBlock name="inp_edit_field_caption" prefix="$prefix" field="$field" subfield="$subfield" title="$title" is_last="$is_last"/>
<td>
<input type="text" name="<inp2:$prefix_InputName field="$field" subfield="$subfield"/>" id="<inp2:$prefix_InputName field="$field" subfield="$subfield"/>" value="<inp2:$prefix_Field field="$field" subfield="$subfield"/>" tabindex="<inp2:m_get param="tab_index"/>" size="<inp2:m_param name="size"/>" maxlength="<inp2:m_param name="maxlength"/>" class="<inp2:m_param name="class"/>" onblur="<inp2:m_Param name="onblur"/>" onkeyup="<inp2:m_Param name="onkeyup"/>">
<inp2:m_if check="{$prefix}_HasParam" name="hint_label"><span class="small"><inp2:m_phrase label="$hint_label"/></span></inp2:m_if>
</td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
+ <inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
+ <inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
+ </inp2:m_if>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_upload" class="" is_last=""/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_ParseBlock name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td>
<input type="file" name="<inp2:$prefix_InputName field="$field"/>" id="<inp2:$prefix_InputName field="$field"/>" tabindex="<inp2:m_get param="tab_index"/>" size="<inp2:m_param name="size"/>" class="<inp2:m_param name="class"/>">
<inp2:m_if check="$prefix_FieldEquals" name="$field" value="" inverse="inverse">
(<inp2:$prefix_Field field="$field"/>)
</inp2:m_if>
<input type="hidden" name="<inp2:$prefix_InputName field="$field"/>[upload]" id="<inp2:$prefix_InputName field="$field"/>[upload]" value="<inp2:$prefix_Field field="$field"/>">
</td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
+ <inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
+ <inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
+ </inp2:m_if>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_box_ml" class="" size="" maxlength=""/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<td class="text" valign="top">
<span class="<inp2:m_if prefix="$prefix" function="HasError" field="$field"/>error<inp2:m_endif/>">
<inp2:m_phrase label="$title"/><inp2:m_if prefix="$prefix" function="IsRequired" field="$field"/><span class="error"> *</span><inp2:m_endif/>:</span><br>
<a href="javascript:PreSaveAndOpenTranslator('<inp2:m_param name="prefix"/>', '<inp2:m_param name="field"/>', 'popups/translator');" title="<inp2:m_Phrase label="la_Translate"/>"><img src="img/icons/icon24_translate.gif" style="cursor:hand" border="0"></a>
</td>
<td>
<input type="text" name="<inp2:$prefix_InputName field="$field"/>" id="<inp2:$prefix_InputName field="$field"/>" value="<inp2:$prefix_Field field="$field" format="no_default"/>" tabindex="<inp2:m_get param="tab_index"/>" size="<inp2:m_param name="size"/>" maxlength="<inp2:m_param name="maxlength"/>" class="<inp2:m_param name="class"/>" onblur="<inp2:m_Param name="onblur"/>">
</td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
+ <inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
+ <inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
+ </inp2:m_if>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_hidden" db=""/>
<input type="hidden" name="<inp2:$prefix_InputName field="$field"/>" id="<inp2:$prefix_InputName field="$field"/>" value="<inp2:$prefix_Field field="$field" db="$db"/>">
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_date" class="" is_last=""/>
<inp2:m_if check="m_GetEquals" name="calendar_included" value="1" inverse="inverse">
<script type="text/javascript" src="incs/calendar.js"></script>
<inp2:m_set calendar_included="1"/>
</inp2:m_if>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_ParseBlock name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td>
<input type="text" name="<inp2:$prefix_InputName field="{$field}_date"/>" id="<inp2:$prefix_InputName field="{$field}_date"/>" value="<inp2:$prefix_Field field="{$field}_date" format="_regional_InputDateFormat"/>" tabindex="<inp2:m_get param="tab_index"/>" size="<inp2:$prefix_Format field="{$field}_date" input_format="1" edit_size="edit_size"/>" class="<inp2:m_param name="class"/>" datepickerIcon="<inp2:m_ProjectBase/>admin/images/ddarrow.gif">&nbsp;<span class="small">(<inp2:$prefix_Format field="{$field}_date" input_format="1" human="true"/>)</span>
<script type="text/javascript">
initCalendar("<inp2:$prefix_InputName field="{$field}_date"/>", "<inp2:$prefix_Format field="{$field}_date" input_format="1"/>");
</script>
<input type="hidden" name="<inp2:$prefix_InputName field="{$field}_time"/>" id="<inp2:$prefix_InputName field="{$field}_time" input_format="1"/>" value="">
</td>
<td class="error"><inp2:$prefix_Error field="{$field}_date"/>&nbsp;</td>
+ <inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
+ <inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
+ </inp2:m_if>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_date_time" class="" is_last=""/>
<inp2:m_if check="m_GetEquals" name="calendar_included" value="1" inverse="inverse">
<script type="text/javascript" src="incs/calendar.js"></script>
<inp2:m_set calendar_included="1"/>
</inp2:m_if>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_ParseBlock name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td>
<!-- <input type="hidden" id="<inp2:$prefix_InputName field="$field"/>" name="<inp2:$prefix_InputName field="$field"/>" value="<inp2:$prefix_Field field="$field" db="db"/>"> -->
<input type="text" name="<inp2:$prefix_InputName field="{$field}_date"/>" id="<inp2:$prefix_InputName field="{$field}_date"/>" value="<inp2:$prefix_Field field="{$field}_date" format="_regional_InputDateFormat"/>" tabindex="<inp2:m_get param="tab_index"/>" size="<inp2:$prefix_Format field="{$field}_date" input_format="1" edit_size="edit_size"/>" class="<inp2:m_param name="class"/>" datepickerIcon="<inp2:m_ProjectBase/>admin/images/ddarrow.gif">
<span class="small">(<inp2:$prefix_Format field="{$field}_date" input_format="1" human="true"/>)</span>
<script type="text/javascript">
initCalendar("<inp2:$prefix_InputName field="{$field}_date"/>", "<inp2:$prefix_Format field="{$field}_date" input_format="1"/>");
</script>
&nbsp;<input type="text" name="<inp2:$prefix_InputName field="{$field}_time"/>" id="<inp2:$prefix_InputName field="{$field}_time"/>" value="<inp2:$prefix_Field field="{$field}_time" format="_regional_InputTimeFormat"/>" tabindex="<inp2:m_get param="tab_index"/>" size="<inp2:$prefix_Format field="{$field}_time" input_format="1" edit_size="edit_size"/>" class="<inp2:m_param name="class"/>"><span class="small"> (<inp2:$prefix_Format field="{$field}_time" input_format="1" human="true"/>)</span>
</td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
+ <inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
+ <inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
+ </inp2:m_if>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_textarea" class="" allow_html="allow_html"/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<td class="text" valign="top">
<span class="<inp2:m_if prefix="$prefix" function="HasError" field="$field"/>error<inp2:m_endif/>">
<inp2:m_phrase label="$title"/><inp2:m_if prefix="$prefix" function="IsRequired" field="$field"/><span class="error"> *</span><inp2:m_endif/>:</span><br>
<inp2:m_if check="m_ParamEquals" name="allow_html" value="allow_html">
<a href="javascript:OpenEditor('&section=in-link:editlink_general','kernel_form','<inp2:$prefix_InputName field="$field"/>');"><img src="img/icons/icon24_link_editor.gif" style="cursor:hand" border="0"></a>
</inp2:m_if>
</td>
<td>
<textarea tabindex="<inp2:m_get param="tab_index"/>" id="<inp2:$prefix_InputName field="$field"/>" name="<inp2:$prefix_InputName field="$field"/>" cols="<inp2:m_param name="cols"/>" rows="<inp2:m_param name="rows"/>" class="<inp2:m_param name="class"/>"><inp2:$prefix_Field field="$field"/></textarea>
</td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
+ <inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
+ <inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
+ </inp2:m_if>
</tr>
<inp2:m_blockend/>
-
-
<inp2:m_block name="inp_edit_textarea_ml" class=""/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<td class="text" valign="top">
<span class="<inp2:m_if prefix="$prefix" function="HasError" field="$field"/>error<inp2:m_endif/>">
<inp2:m_phrase label="$title"/><inp2:m_if prefix="$prefix" function="IsRequired" field="$field"/><span class="error"> *</span><inp2:m_endif/>:</span><br>
<a href="javascript:OpenEditor('&section=in-link:editlink_general','kernel_form','<inp2:$prefix_InputName field="$field"/>');"><img src="img/icons/icon24_link_editor.gif" style="cursor:hand" border="0"></a>
<a href="javascript:PreSaveAndOpenTranslator('<inp2:m_param name="prefix"/>', '<inp2:m_param name="field"/>', 'popups/translator', 1);" title="<inp2:m_Phrase label="la_Translate"/>"><img src="img/icons/icon24_translate.gif" style="cursor:hand" border="0"></a>
</td>
<td>
<textarea tabindex="<inp2:m_get param="tab_index"/>" id="<inp2:$prefix_InputName field="$field"/>" name="<inp2:$prefix_InputName field="$field"/>" cols="<inp2:m_param name="cols"/>" rows="<inp2:m_param name="rows"/>" class="<inp2:m_param name="class"/>"><inp2:$prefix_Field field="$field"/></textarea>
</td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
+ <inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
+ <inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
+ </inp2:m_if>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_user" class="" is_last="" old_style="0" onkeyup=""/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_ParseBlock name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td>
<input type="text" name="<inp2:$prefix_InputName field="$field"/>" id="<inp2:$prefix_InputName field="$field"/>" value="<inp2:$prefix_Field field="$field"/>" tabindex="<inp2:m_get param="tab_index"/>" size="<inp2:m_param name="size"/>" class="<inp2:m_param name="class"/>" onkeyup="<inp2:m_Param name="onkeyup"/>">
<inp2:m_if check="m_ParamEquals" name="old_style" value="1">
<a href="#" onclick="return OpenUserSelector('','kernel_form','<inp2:$prefix_InputName field="$field"/>');">
<inp2:m_else/>
<a href="javascript:openSelector('<inp2:m_param name="prefix"/>', '<inp2:m_t t="user_selector" pass="all,$prefix" escape="1"/>', '<inp2:m_param name="field"/>');">
</inp2:m_if>
<img src="img/icons/icon24_link_user.gif" style="cursor:hand;" border="0">
</a>
</td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
+ <inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
+ <inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
+ </inp2:m_if>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_option_item"/>
<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="inp_option_phrase"/>
<option value="<inp2:m_param name="key"/>"<inp2:m_param name="selected"/>><inp2:m_phrase label="$option"/></option>
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_options" is_last="" has_empty="0" empty_value=""/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_ParseBlock name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td>
<select tabindex="<inp2:m_get param="tab_index"/>" name="<inp2:$prefix_InputName field="$field"/>" id="<inp2:$prefix_InputName field="$field"/>" onchange="<inp2:m_Param name="onchange"/>">
<inp2:m_if prefix="m" function="ParamEquals" name="use_phrases" value="1"/>
<inp2:$prefix_PredefinedOptions field="$field" block="inp_option_phrase" selected="selected" has_empty="$has_empty" empty_value="$empty_value"/>
<inp2:m_else/>
<inp2:$prefix_PredefinedOptions field="$field" block="inp_option_item" selected="selected" has_empty="$has_empty" empty_value="$empty_value"/>
<inp2:m_endif/>
</select>
</td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
+ <inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
+ <inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
+ </inp2:m_if>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_radio_item"/>
<input type="radio" <inp2:m_param name="checked"/> name="<inp2:$prefix_InputName field="$field"/>" id="<inp2:$prefix_InputName field="$field"/>_<inp2:m_param name="key"/>" value="<inp2:m_param name="key"/>" onclick="<inp2:m_param name="onclick"/>" onchange="<inp2:m_param name="onchange"/>"><label for="<inp2:$prefix_InputName field="$field"/>_<inp2:m_param name="key"/>"><inp2:m_param name="option"/></label>&nbsp;
<inp2:m_blockend/>
<inp2:m_block name="inp_radio_phrase"/>
<input type="radio" <inp2:m_param name="checked"/> name="<inp2:$prefix_InputName field="$field"/>" id="<inp2:$prefix_InputName field="$field"/>_<inp2:m_param name="key"/>" value="<inp2:m_param name="key"/>" onclick="<inp2:m_param name="onclick"/>" onchange="<inp2:m_param name="onchange"/>"><label for="<inp2:$prefix_InputName field="$field"/>_<inp2:m_param name="key"/>"><inp2:m_phrase label="$option"/></label>&nbsp;
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_radio" is_last="" pass_tabindex="" onclick="" onchange="" use_phrases="1"/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_ParseBlock name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td>
<inp2:m_if check="m_ParamEquals" name="use_phrases" value="1">
<inp2:$prefix_PredefinedOptions field="$field" tabindex="$pass_tabindex" block="inp_radio_phrase" selected="checked" onclick="$onclick" onchange="$onchange" />
<inp2:m_else />
<inp2:$prefix_PredefinedOptions field="$field" tabindex="$pass_tabindex" block="inp_radio_item" selected="checked" onclick="$onclick" onchange="$onchange" />
</inp2:m_if>
</td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
+ <inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
+ <inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
+ </inp2:m_if>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_checkbox" is_last="" field_class="" onchange=""/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_ParseBlock name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last" NamePrefix="_cb_"/>
<td>
<input type="hidden" id="<inp2:$prefix_InputName field="$field"/>" name="<inp2:$prefix_InputName field="$field"/>" value="<inp2:$prefix_Field field="$field" db="db"/>">
<!--<input tabindex="<inp2:m_get param="tab_index"/>" type="checkbox" id="_cb_<inp2:$prefix_InputName field="$field"/>" name="_cb_<inp2:$prefix_InputName field="$field"/>" <inp2:$prefix_Field field="$field" checked="checked" db="db"/> class="<inp2:m_param name="field_class"/>" onclick="update_checkbox(this, document.getElementById('<inp2:$prefix_InputName field="$field"/>'));" onchange="<inp2:m_param name="onchange"/>">-->
<input tabindex="<inp2:m_get param="tab_index"/>" type="checkbox" id="_cb_<inp2:$prefix_InputName field="$field"/>" name="_cb_<inp2:$prefix_InputName field="$field"/>" <inp2:$prefix_Field field="$field" checked="checked" db="db"/> class="<inp2:m_param name="field_class"/>" onchange="update_checkbox(this, document.getElementById('<inp2:$prefix_InputName field="$field"/>'));<inp2:m_param name="onchange"/>">
<inp2:m_if check="{$prefix}_HasParam" name="hint_label"><inp2:m_phrase label="$hint_label"/></inp2:m_if>
</td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
+ <inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
+ <inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
+ </inp2:m_if>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_checkbox_item"/>
<input type="checkbox" <inp2:m_param name="checked"/> id="<inp2:$prefix_InputName field="$field"/>_<inp2:m_param name="key"/>" value="<inp2:m_param name="key"/>" onclick="update_checkbox_options(/^<inp2:$prefix_InputName field="$field" as_preg="1"/>_([0-9A-Za-z-]+)/, '<inp2:$prefix_InputName field="$field"/>');"><label for="<inp2:$prefix_InputName field="$field"/>_<inp2:m_param name="key"/>"><inp2:m_param name="option"/></label>&nbsp;
<inp2:m_blockend/>
<inp2:m_block name="inp_checkbox_phrase"/>
<input type="checkbox" <inp2:m_param name="checked"/> id="<inp2:$prefix_InputName field="$field"/>_<inp2:m_param name="key"/>" value="<inp2:m_param name="key"/>" onclick="update_checkbox_options(/^<inp2:$prefix_InputName field="$field" as_preg="1"/>_([0-9A-Za-z-]+)/, '<inp2:$prefix_InputName field="$field"/>');"><label for="<inp2:$prefix_InputName field="$field"/>_<inp2:m_param name="key"/>"><inp2:m_phrase label="$option"/></label>&nbsp;
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_checkboxes" is_last=""/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_ParseBlock name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td>
<inp2:m_if check="m_ParamEquals" name="use_phrases" value="1">
<inp2:$prefix_PredefinedOptions field="$field" no_empty="$no_empty" tabindex="$pass_tabindex" hint_label="$hint_label" block="inp_checkbox_phrase" selected="checked"/>
<inp2:m_else/>
<inp2:$prefix_PredefinedOptions field="$field" no_empty="$no_empty" tabindex="$pass_tabindex" hint_label="$hint_label" block="inp_checkbox_item" selected="checked"/>
</inp2:m_if>
<inp2:m_ParseBlock prefix="$prefix" name="inp_edit_hidden" field="$field"/>
</td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
+ <inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
+ <inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
+ </inp2:m_if>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_checkbox_allow_html"/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<td colspan="2">
<label for="_cb_<inp2:m_param name="field"/>"><inp2:m_phrase label="la_enable_html"/></label>
<input type="hidden" id="<inp2:$prefix_InputName field="$field"/>" name="<inp2:$prefix_InputName field="$field"/>" value="<inp2:$prefix_Field field="$field"/>">
<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:$prefix_Field field="$field" checked="checked"/> class="<inp2:m_param name="field_class"/>" onclick="update_checkbox(this, document.getElementById('<inp2:$prefix_InputName field="$field"/>'))">
<br>
<span class="hint"><img src="img/smicon7.gif" width="14" height="14" align="absmiddle"><inp2:m_phrase label="la_Warning_Enable_HTML"/></span>
</td>
<td>&nbsp;</td>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_weight" subfield="" class="" is_last="" maxlength=""/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_ParseBlock name="inp_edit_field_caption" prefix="$prefix" field="$field" subfield="$subfield" title="$title" is_last="$is_last"/>
<td>
<inp2:m_if check="lang.current_FieldEquals" field="UnitSystem" value="1">
<input type="text" name="<inp2:$prefix_InputName field="$field" subfield="$subfield"/>" id="<inp2:$prefix_InputName field="$field" subfield="$subfield"/>" value="<inp2:$prefix_Field field="$field" subfield="$subfield"/>" tabindex="<inp2:m_get param="tab_index"/>" size="<inp2:m_param name="size"/>" maxlength="<inp2:m_param name="maxlength"/>" class="<inp2:m_param name="class"/>" onblur="<inp2:m_Param name="onblur"/>">
<inp2:m_phrase label="la_kg" />
</inp2:m_if>
<inp2:m_if check="lang.current_FieldEquals" field="UnitSystem" value="2">
<input type="text" name="<inp2:$prefix_InputName field="{$field}_a" subfield="$subfield"/>" id="<inp2:$prefix_InputName field="{$field}_a" subfield="$subfield"/>" value="<inp2:$prefix_Field field="{$field}_a" subfield="$subfield"/>" tabindex="<inp2:m_get param="tab_index"/>" size="<inp2:m_param name="size"/>" maxlength="<inp2:m_param name="maxlength"/>" class="<inp2:m_param name="class"/>" onblur="<inp2:m_Param name="onblur"/>">
<inp2:m_phrase label="la_lbs" />
<input type="text" name="<inp2:$prefix_InputName field="{$field}_b" subfield="$subfield"/>" id="<inp2:$prefix_InputName field="{$field}_b" subfield="$subfield"/>" value="<inp2:$prefix_Field field="{$field}_b" subfield="$subfield"/>" tabindex="<inp2:m_get param="tab_index"/>" size="<inp2:m_param name="size"/>" maxlength="<inp2:m_param name="maxlength"/>" class="<inp2:m_param name="class"/>" onblur="<inp2:m_Param name="onblur"/>">
<inp2:m_phrase label="la_oz" />
</inp2:m_if>
</td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
+ <inp2:m_if check="{$prefix}_DisplayOriginal" pass_params="1">
+ <inp2:m_RenderElement prefix="$prefix" field="$field" name="inp_original_label"/>
+ </inp2:m_if>
</tr>
<inp2:m_blockend />
<inp2:m_DefineElement name="ajax_progress_bar">
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder">
<tr class="table_color1">
<td colspan="2">
<img src="img/spacer.gif" height="10" width="1" alt="" /><br />
<!-- progress bar paddings: begin -->
<table width="90%" cellpadding="2" cellspacing="0" border="0" align="center">
<tr>
<td class="progress-text">0%</td>
<td width="100%">
<!-- progress bar: begin -->
<table cellspacing="0" cellpadding="0" width="100%" border="0" align="center" style="background-color: #FFFFFF; border: 1px solid #E6E6E6;">
<tr>
<td colspan="3"><img src="img/spacer.gif" height="2" width="1" alt="" /></td>
</tr>
<tr>
<td width="2"><img src="img/spacer.gif" height="13" width="3" alt="" /></td>
<td align="center" width="100%">
<table cellspacing="0" cellpadding="0" width="100%" border="0" style="background: url(img/progress_left.gif) repeat-x;">
<tr>
<td id="progress_bar[done]" style="background: url(img/progress_done.gif);" align="left"></td>
<td id="progress_bar[left]" align="right"><img src="img/spacer.gif" height="9" width="1" alt="" /></td>
</tr>
</table>
</td>
<td width="1"><img src="img/spacer.gif" height="13" width="3" alt="" /></td>
</tr>
<tr>
<td colspan="3"><img src="img/spacer.gif" height="2" width="1" alt="" /></td>
</tr>
</table>
<!-- progress bar: end -->
</td>
<td class="progress-text">100%</td>
</tr>
</table>
<!-- progress bar paddings: end -->
<img src="img/spacer.gif" height="10" width="1" alt="" /><br />
</td>
</tr>
<tr class="table_color2">
<td width="50%" align="right"><inp2:m_phrase name="la_fld_PercentsCompleted"/>:</td>
<td id="progress_display[percents_completed]">0%</td>
</tr>
<tr class="table_color1">
<td align="right"><inp2:m_phrase name="la_fld_ElapsedTime"/>:</td>
<td id="progress_display[elapsed_time]">00:00</td>
</tr>
<tr class="table_color2">
<td align="right"><inp2:m_phrase name="la_fld_EstimatedTime"/>:</td>
<td id="progress_display[Estimated_time]">00:00</td>
</tr>
<tr class="table_color1">
<td align="center" colspan="2">
<input type="button" class="button" onclick="<inp2:m_param name="cancel_action"/>" value="<inp2:m_phrase name="la_Cancel"/>" />
</td>
</tr>
</table>
</inp2:m_DefineElement>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.44.2/kernel/admin_templates/incs/form_blocks.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.44.2.1
\ No newline at end of property
+1.44.2.2
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.7.2/kernel/admin_templates/incs/custom_blocks.tpl
===================================================================
--- branches/unlabeled/unlabeled-1.7.2/kernel/admin_templates/incs/custom_blocks.tpl (revision 5855)
+++ branches/unlabeled/unlabeled-1.7.2/kernel/admin_templates/incs/custom_blocks.tpl (revision 5856)
@@ -1,93 +1,104 @@
<inp2:m_DefineElement name="config_edit_text">
<input type="text" name="<inp2:CustomInputName/>" value="<inp2:Field field="$field"/>" />
</inp2:m_DefineElement>
<inp2:m_DefineElement name="config_edit_password">
<input type="password" primarytype="password" name="<inp2:CustomInputName/>" id="<inp2:CustomInputName/>" value="" />
<input type="password" name="verify_<inp2:CustomInputName/>" id="verify_<inp2:CustomInputName/>" value="" />
&nbsp;<span class="error" id="error_<inp2:CustomInputName/>"></span>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="config_edit_option">
<option value="<inp2:m_param name="key"/>"<inp2:m_param name="selected"/>><inp2:m_param name="option"/></option>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="config_edit_select">
<select name="<inp2:CustomInputName/>">
- <inp2:PredefinedOptions field="$field" tabindex="$pass_tabindex" block="config_edit_option" selected="selected"/>
+ <inp2:PredefinedOptions field="$field" block="config_edit_option" selected="selected"/>
</select>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="config_edit_checkbox">
<input type="hidden" id="<inp2:CustomInputName/>" name="<inp2:CustomInputName/>" value="<inp2: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:Field field="$field" checked="checked" db="db"/> class="<inp2:m_param name="field_class"/>" onclick="update_checkbox(this, document.getElementById('<inp2:CustomInputName/>'))">
+ <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:Field field="$field" checked="checked" db="db"/> onclick="update_checkbox(this, document.getElementById('<inp2:CustomInputName/>'))">
</inp2:m_DefineElement>
<inp2:m_DefineElement name="config_edit_textarea">
<textarea name="<inp2:CustomInputName/>" <inp2:m_param name="field_params" />><inp2:Field field="$field" /></textarea>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="config_radio_item">
<input type="radio" <inp2:m_param name="checked"/> name="<inp2:CustomInputName/>" id="<inp2:CustomInputName/>_<inp2:m_param name="key"/>" value="<inp2:m_param name="key"/>"><label for="<inp2:CustomInputName/>_<inp2:m_param name="key"/>"><inp2:m_param name="option"/></label>&nbsp;
</inp2:m_DefineElement>
<inp2:m_DefineElement name="config_edit_radio">
- <inp2:PredefinedOptions field="$field" tabindex="$pass_tabindex" block="config_radio_item" selected="checked"/>
+ <inp2:PredefinedOptions field="$field" block="config_radio_item" selected="checked"/>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="config_edit_date">
<inp2:m_if check="m_GetEquals" name="calendar_included" value="1" inverse="inverse">
<script type="text/javascript" src="incs/calendar.js"></script>
<inp2:m_set calendar_included="1"/>
</inp2:m_if>
<input type="text" name="<inp2:CustomInputName append="_date"/>" id="<inp2:CustomInputName append="_date"/>" value="<inp2:CustomField append="_date" format="_regional_InputDateFormat"/>" size="<inp2:CustomFormat append="_date" input_format="1" edit_size="edit_size"/>" datepickerIcon="<inp2:m_ProjectBase/>admin/images/ddarrow.gif">&nbsp;<span class="small">(<inp2:CustomFormat append="_date" input_format="1" human="true"/>)</span>
<script type="text/javascript">
initCalendar("<inp2:CustomInputName append="_date"/>", "<inp2:CustomFormat append="_date" input_format="1"/>");
</script>
<input type="hidden" name="<inp2:CustomInputName append="_time"/>" value="">
</inp2:m_DefineElement>
<inp2:m_DefineElement name="config_edit_datetime">
<inp2:m_if check="m_GetEquals" name="calendar_included" value="1" inverse="inverse">
<script type="text/javascript" src="incs/calendar.js"></script>
<inp2:m_set calendar_included="1"/>
</inp2:m_if>
<input type="text" name="<inp2:CustomInputName append="_date"/>" id="<inp2:CustomInputName append="_date"/>" value="<inp2:CustomField append="_date" format="_regional_InputDateFormat"/>" size="<inp2:CustomFormat append="_date" input_format="1" edit_size="edit_size"/>" datepickerIcon="<inp2:m_ProjectBase/>admin/images/ddarrow.gif">&nbsp;<span class="small">(<inp2:CustomFormat append="_date" input_format="1" human="true"/>)</span>
<script type="text/javascript">
initCalendar("<inp2:CustomInputName append="_date"/>", "<inp2:CustomFormat append="_date" input_format="1"/>");
</script>
&nbsp;<input type="text" name="<inp2:CustomInputName append="_time"/>" id="<inp2:CustomInputName append="_time"/>" value="<inp2:CustomField append="_time" format="_regional_InputTimeFormat"/>" size="<inp2:CustomFormat append="_time" input_format="1" edit_size="edit_size"/>"><span class="small"> (<inp2:CustomFormat append="_time" input_format="1" human="true"/>)</span>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="cv_row_block">
<inp2:m_if check="m_ParamEquals" name="show_heading" value="1">
<tr class="subsectiontitle">
- <td colspan="5">
+ <td colspan="3">
<inp2:Field name="Heading" as_label="1"/>
</td>
+ <inp2:m_if check="{$SourcePrefix}_DisplayOriginal" pass_params="1">
+ <td><inp2:m_phrase name="$original_title"/></td>
+ </inp2:m_if>
</tr>
</inp2:m_if>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>" >
<inp2:m_ParseBlock name="grid_data_label_ml_td" grid="$grid" SourcePrefix="$SourcePrefix" value_field="$value_field" ElementTypeField="ElementType" field="Prompt" PrefixSpecial="$PrefixSpecial"/>
<td valign="top" class="text">
<inp2:ConfigFormElement field="Value" blocks_prefix="config_edit_" element_type_field="ElementType" value_list_field="ValueList" />
</td>
<td class="error"><inp2:CustomError/>&nbsp;</td>
+ <inp2:m_if check="{$SourcePrefix}_DisplayOriginal" pass_params="1">
+ <inp2:m_RenderElement prefix="$SourcePrefix" field="$field" name="inp_original_label"/>
+ </inp2:m_if>
</tr>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="edit_custom_td">
<td valign="top" class="text">
<inp2:ConfigFormElement field="Value" blocks_prefix="config_edit_" element_type_field="ElementType" value_list_field="ValueList" />
</td>
</inp2:m_DefineElement>
+
+<inp2:m_block name="grid_original_td" />
+ <td valign="top" class="text"><inp2:Field field="$field" grid="$grid"/></td>
+<inp2:m_blockend />
+
<!--<inp2:m_DefineElement name="edit_custom_td">
<td valign="top" class="text">
<input type="hidden" name="<inp2:InputName field="ResourceId"/>" id="<inp2:InputName field="ResourceId"/>" value="<inp2:Field field="ResourceId" grid="$grid"/>">
<input type="hidden" name="<inp2:InputName field="CustomDataId"/>" id="<inp2:InputName field="CustomDataId"/>" value="<inp2:Field field="CustomDataId" grid="$grid"/>">
<inp2:ConfigFormElement field="Value" blocks_prefix="config_edit_" element_type_field="ElementType" value_list_field="ValueList" />
</td>
</inp2:m_DefineElement>-->
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.7.2/kernel/admin_templates/incs/custom_blocks.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.7.2.1
\ No newline at end of property
+1.7.2.2
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.7.2/core/admin_templates/incs/custom_blocks.tpl
===================================================================
--- branches/unlabeled/unlabeled-1.7.2/core/admin_templates/incs/custom_blocks.tpl (revision 5855)
+++ branches/unlabeled/unlabeled-1.7.2/core/admin_templates/incs/custom_blocks.tpl (revision 5856)
@@ -1,93 +1,104 @@
<inp2:m_DefineElement name="config_edit_text">
<input type="text" name="<inp2:CustomInputName/>" value="<inp2:Field field="$field"/>" />
</inp2:m_DefineElement>
<inp2:m_DefineElement name="config_edit_password">
<input type="password" primarytype="password" name="<inp2:CustomInputName/>" id="<inp2:CustomInputName/>" value="" />
<input type="password" name="verify_<inp2:CustomInputName/>" id="verify_<inp2:CustomInputName/>" value="" />
&nbsp;<span class="error" id="error_<inp2:CustomInputName/>"></span>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="config_edit_option">
<option value="<inp2:m_param name="key"/>"<inp2:m_param name="selected"/>><inp2:m_param name="option"/></option>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="config_edit_select">
<select name="<inp2:CustomInputName/>">
- <inp2:PredefinedOptions field="$field" tabindex="$pass_tabindex" block="config_edit_option" selected="selected"/>
+ <inp2:PredefinedOptions field="$field" block="config_edit_option" selected="selected"/>
</select>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="config_edit_checkbox">
<input type="hidden" id="<inp2:CustomInputName/>" name="<inp2:CustomInputName/>" value="<inp2: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:Field field="$field" checked="checked" db="db"/> class="<inp2:m_param name="field_class"/>" onclick="update_checkbox(this, document.getElementById('<inp2:CustomInputName/>'))">
+ <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:Field field="$field" checked="checked" db="db"/> onclick="update_checkbox(this, document.getElementById('<inp2:CustomInputName/>'))">
</inp2:m_DefineElement>
<inp2:m_DefineElement name="config_edit_textarea">
<textarea name="<inp2:CustomInputName/>" <inp2:m_param name="field_params" />><inp2:Field field="$field" /></textarea>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="config_radio_item">
<input type="radio" <inp2:m_param name="checked"/> name="<inp2:CustomInputName/>" id="<inp2:CustomInputName/>_<inp2:m_param name="key"/>" value="<inp2:m_param name="key"/>"><label for="<inp2:CustomInputName/>_<inp2:m_param name="key"/>"><inp2:m_param name="option"/></label>&nbsp;
</inp2:m_DefineElement>
<inp2:m_DefineElement name="config_edit_radio">
- <inp2:PredefinedOptions field="$field" tabindex="$pass_tabindex" block="config_radio_item" selected="checked"/>
+ <inp2:PredefinedOptions field="$field" block="config_radio_item" selected="checked"/>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="config_edit_date">
<inp2:m_if check="m_GetEquals" name="calendar_included" value="1" inverse="inverse">
<script type="text/javascript" src="incs/calendar.js"></script>
<inp2:m_set calendar_included="1"/>
</inp2:m_if>
<input type="text" name="<inp2:CustomInputName append="_date"/>" id="<inp2:CustomInputName append="_date"/>" value="<inp2:CustomField append="_date" format="_regional_InputDateFormat"/>" size="<inp2:CustomFormat append="_date" input_format="1" edit_size="edit_size"/>" datepickerIcon="<inp2:m_ProjectBase/>admin/images/ddarrow.gif">&nbsp;<span class="small">(<inp2:CustomFormat append="_date" input_format="1" human="true"/>)</span>
<script type="text/javascript">
initCalendar("<inp2:CustomInputName append="_date"/>", "<inp2:CustomFormat append="_date" input_format="1"/>");
</script>
<input type="hidden" name="<inp2:CustomInputName append="_time"/>" value="">
</inp2:m_DefineElement>
<inp2:m_DefineElement name="config_edit_datetime">
<inp2:m_if check="m_GetEquals" name="calendar_included" value="1" inverse="inverse">
<script type="text/javascript" src="incs/calendar.js"></script>
<inp2:m_set calendar_included="1"/>
</inp2:m_if>
<input type="text" name="<inp2:CustomInputName append="_date"/>" id="<inp2:CustomInputName append="_date"/>" value="<inp2:CustomField append="_date" format="_regional_InputDateFormat"/>" size="<inp2:CustomFormat append="_date" input_format="1" edit_size="edit_size"/>" datepickerIcon="<inp2:m_ProjectBase/>admin/images/ddarrow.gif">&nbsp;<span class="small">(<inp2:CustomFormat append="_date" input_format="1" human="true"/>)</span>
<script type="text/javascript">
initCalendar("<inp2:CustomInputName append="_date"/>", "<inp2:CustomFormat append="_date" input_format="1"/>");
</script>
&nbsp;<input type="text" name="<inp2:CustomInputName append="_time"/>" id="<inp2:CustomInputName append="_time"/>" value="<inp2:CustomField append="_time" format="_regional_InputTimeFormat"/>" size="<inp2:CustomFormat append="_time" input_format="1" edit_size="edit_size"/>"><span class="small"> (<inp2:CustomFormat append="_time" input_format="1" human="true"/>)</span>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="cv_row_block">
<inp2:m_if check="m_ParamEquals" name="show_heading" value="1">
<tr class="subsectiontitle">
- <td colspan="5">
+ <td colspan="3">
<inp2:Field name="Heading" as_label="1"/>
</td>
+ <inp2:m_if check="{$SourcePrefix}_DisplayOriginal" pass_params="1">
+ <td><inp2:m_phrase name="$original_title"/></td>
+ </inp2:m_if>
</tr>
</inp2:m_if>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>" >
<inp2:m_ParseBlock name="grid_data_label_ml_td" grid="$grid" SourcePrefix="$SourcePrefix" value_field="$value_field" ElementTypeField="ElementType" field="Prompt" PrefixSpecial="$PrefixSpecial"/>
<td valign="top" class="text">
<inp2:ConfigFormElement field="Value" blocks_prefix="config_edit_" element_type_field="ElementType" value_list_field="ValueList" />
</td>
<td class="error"><inp2:CustomError/>&nbsp;</td>
+ <inp2:m_if check="{$SourcePrefix}_DisplayOriginal" pass_params="1">
+ <inp2:m_RenderElement prefix="$SourcePrefix" field="$field" name="inp_original_label"/>
+ </inp2:m_if>
</tr>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="edit_custom_td">
<td valign="top" class="text">
<inp2:ConfigFormElement field="Value" blocks_prefix="config_edit_" element_type_field="ElementType" value_list_field="ValueList" />
</td>
</inp2:m_DefineElement>
+
+<inp2:m_block name="grid_original_td" />
+ <td valign="top" class="text"><inp2:Field field="$field" grid="$grid"/></td>
+<inp2:m_blockend />
+
<!--<inp2:m_DefineElement name="edit_custom_td">
<td valign="top" class="text">
<input type="hidden" name="<inp2:InputName field="ResourceId"/>" id="<inp2:InputName field="ResourceId"/>" value="<inp2:Field field="ResourceId" grid="$grid"/>">
<input type="hidden" name="<inp2:InputName field="CustomDataId"/>" id="<inp2:InputName field="CustomDataId"/>" value="<inp2:Field field="CustomDataId" grid="$grid"/>">
<inp2:ConfigFormElement field="Value" blocks_prefix="config_edit_" element_type_field="ElementType" value_list_field="ValueList" />
</td>
</inp2:m_DefineElement>-->
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.7.2/core/admin_templates/incs/custom_blocks.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.7.2.1
\ No newline at end of property
+1.7.2.2
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.36.2/kernel/admin_templates/incs/grid_blocks.tpl
===================================================================
--- branches/unlabeled/unlabeled-1.36.2/kernel/admin_templates/incs/grid_blocks.tpl (revision 5855)
+++ branches/unlabeled/unlabeled-1.36.2/kernel/admin_templates/incs/grid_blocks.tpl (revision 5856)
@@ -1,392 +1,390 @@
<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"/>, <inp2:m_param name="ajax"/>)" 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"/>, <inp2:m_param name="ajax"/>)" 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"/>, <inp2:m_param name="ajax"/>)" 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"/>, <inp2:m_param name="ajax"/>)" 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"/>, <inp2:m_param name="ajax"/>)" class="nav_url">&lt;&lt;</a>
<inp2:m_blockend/>
<inp2:m_block name="grid_pagination" SearchPrefixSpecial=""/>
<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" main_special="$main_special" ajax="$ajax"/>
</td>
<inp2:m_if check="m_ParamEquals" param="search" value="on">
<inp2:m_if check="m_ParamEquals" name="SearchPrefixSpecial" value="">
<inp2:m_RenderElement name="grid_search" grid="$grid" PrefixSpecial="$PrefixSpecial" ajax="$ajax"/>
<inp2:m_else />
<inp2:m_RenderElement name="grid_search" grid="$grid" PrefixSpecial="$SearchPrefixSpecial" ajax="$ajax"/>
</inp2:m_if>
</inp2:m_if>
<td>
</tr>
</tbody>
</table>
<inp2:m_blockend/>
<inp2:m_DefineElement name="grid_search" ajax="0">
<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"/>"
ajax="<inp2:m_param name="ajax"/>"
style="border: 1px solid grey;">
<input type="text" style="display: none"; />
</td>
<td id="search_buttons[<inp2:m_param name="PrefixSpecial"/>]">
<script type="text/javascript">
<inp2:m_RenderElement name="grid_search_buttons" pass_params="true"/>
</script>
</td>
</tr>
</table>
</td>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_search_buttons" PrefixSpecial="" grid="" ajax="1">
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" escape="1"/>',
function() { search('<inp2:m_param name="PrefixSpecial"/>','<inp2:m_param name="grid"/>', <inp2:m_param name="ajax"/>) },
null,
'<inp2:m_param name="PrefixSpecial"/>') );
Toolbars['<inp2:m_param name="PrefixSpecial"/>_search'].AddButton(
new ToolBarButton(
'search_reset',
'<inp2:m_phrase name="la_ToolTip_SearchReset" escape="1"/>',
function() { search_reset('<inp2:m_param name="PrefixSpecial"/>','<inp2:m_param name="grid"/>', <inp2:m_param name="ajax"/>) },
null,
'<inp2:m_param name="PrefixSpecial"/>') );
Toolbars['<inp2:m_param name="PrefixSpecial"/>_search'].Render(document.getElementById('search_buttons[<inp2:m_param name="PrefixSpecial"/>]'));
</inp2:m_DefineElement>
<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"/>', <inp2:m_param name="ajax"/>);" 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" format="" />
<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="<inp2:ModulePath />img/itemicons/<inp2:$PrefixSpecial_ItemIcon grid="$grid"/>"></td>
<td><inp2:Field field="$field" no_special="no_special" format="$format"/></td>
</tr>
</table>
</td>
<inp2:m_blockend />
<inp2:m_block name="grid_checkbox_td_no_icon" format="" />
<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><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" format="" />
<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="<inp2:ModulePath />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" format="" />
<td valign="top" class="text">
<table border="0" cellpadding="0" cellspacing="0" class="grid_id_cell">
<tr>
<td><img src="<inp2:ModulePath />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" format="" />
<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="<inp2:ModulePath />img/itemicons/<inp2:$PrefixSpecial_ItemIcon grid="$grid"/>"></td>
<td><inp2:Field field="$field" no_special="no_special" format="$format"/></td>
</tr>
</table>
</td>
<inp2:m_blockend />
<inp2:m_block name="grid_data_td" format="" no_special="" />
<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" format="" />
<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" format="" />
<td valign="top" class="text">
<inp2:$PrefixSpecial_field field="$field" grid="$grid" as_label="1" no_special="no_special" format="$format"/>:<br />
<inp2:m_if check="FieldEquals" field="$ElementTypeField" value="textarea">
<a href="javascript:PreSaveAndOpenTranslatorCV('<inp2:m_param name="SourcePrefix"/>,<inp2:m_param name="SourcePrefix"/>-cdata', '<inp2:m_param name="SourcePrefix"/>-cdata:cust_<inp2:Field name="CustomFieldId"/>', 'popups/translator', <inp2:$SourcePrefix_Field field="ResourceId"/>, 1);" title="<inp2:m_Phrase label="la_Translate" escape="1"/>"><img src="img/icons/icon24_translate.gif" style="cursor:hand;" border="0"></a>
<inp2:m_else/>
<a href="javascript:PreSaveAndOpenTranslatorCV('<inp2:m_param name="SourcePrefix"/>,<inp2:m_param name="SourcePrefix"/>-cdata', '<inp2:m_param name="SourcePrefix"/>-cdata:cust_<inp2:Field name="CustomFieldId"/>', 'popups/translator', <inp2:$SourcePrefix_Field field="ResourceId"/>);" title="<inp2:m_Phrase label="la_Translate" escape="1"/>"><img src="img/icons/icon24_translate.gif" style="cursor:hand;" border="0"></a>
</inp2:m_if>
</td>
<inp2:m_blockend />
<inp2:m_DefineElement name="grid_column_filter">
<td>&nbsp;</td>
</inp2:m_DefineElement>
<inp2:m_DefineElement name="grid_options_filter">
<td>
<select name="<inp2:SearchInputName field="$field"/>">
<inp2:PredefinedSearchOptions field="$field" block="inp_option_item" selected="selected" has_empty="1" empty_value=""/>
</select>
</td>
</inp2:m_DefineElement>
<inp2:m_block name="viewmenu_sort_block"/>
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'].addMenuItem('<inp2:m_phrase name="$title" escape="1"/>','direct_sort_grid("<inp2:m_param name="PrefixSpecial"/>","<inp2:m_param name="sort_field"/>","<inp2:$PrefixSpecial_OrderInfo type="direction" pos="1"/>", null, <inp2:m_param name="ajax"/>);','<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" menu_filters="no" menu_sorting="yes" menu_perpage="yes" menu_select="yes" ajax="0"/>
// define ViewMenu
$fw_menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'] = function()
{
<inp2:m_if check="m_ParamEquals" name="menu_filters" value="yes">
// filtring menu
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'] = new Menu('<inp2:m_phrase name="la_Text_View" escape="1"/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'].addMenuItem('All','filters_remove_all("<inp2:m_param name="PrefixSpecial"/>", <inp2:m_param name="ajax"/>);');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'].addMenuItem('None','filters_apply_all("<inp2:m_param name="PrefixSpecial"/>", <inp2:m_param name="ajax"/>);');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'].addMenuSeparator();
<inp2:$PrefixSpecial_DrawFilterMenu item_block="viewmenu_filter_block" spearator_block="viewmenu_filter_separator" ajax="$ajax"/>
</inp2:m_if>
<inp2:m_if check="m_ParamEquals" name="menu_sorting" value="yes">
// sorting menu
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'] = new Menu('<inp2:m_phrase name="la_Text_Sort" escape="1"/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'].addMenuItem('<inp2:m_phrase name="la_common_ascending" escape="1"/>','direct_sort_grid("<inp2:m_param name="PrefixSpecial"/>","<inp2:$PrefixSpecial_OrderInfo type="field" pos="1"/>","asc",null,<inp2:m_param name="ajax"/>);','<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" escape="1"/>','direct_sort_grid("<inp2:m_param name="PrefixSpecial"/>","<inp2:$PrefixSpecial_OrderInfo type="field" pos="1"/>","desc",null,<inp2:m_param name="ajax"/>);','<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" escape="1"/>','reset_sorting("<inp2:m_param name="PrefixSpecial"/>");');
<inp2:$PrefixSpecial_IterateGridFields grid="$grid" mode="header" block="viewmenu_sort_block" ajax="$ajax"/>
</inp2:m_if>
<inp2:m_if check="m_ParamEquals" name="menu_perpage" value="yes">
// per page menu
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'] = new Menu('<inp2:m_phrase name="la_prompt_PerPage" escape="1"/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'].addMenuItem('10','set_per_page("<inp2:m_param name="PrefixSpecial"/>",10,<inp2:m_param name="ajax"/>);','<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_param name="ajax"/>);','<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_param name="ajax"/>);','<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_param name="ajax"/>);','<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_param name="ajax"/>);','<inp2:m_if prefix="$PrefixSpecial" function="PerPageEquals" value="500"/>2<inp2:m_endif/>');
</inp2:m_if>
<inp2:m_if check="m_ParamEquals" name="menu_select" value="yes">
// select menu
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_select_menu'] = new Menu('<inp2:m_phrase name="la_Text_Select" escape="1"/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_select_menu'].addMenuItem('<inp2:m_phrase name="la_Text_All" escape="1"/>','Grids["<inp2:m_param name="PrefixSpecial"/>"].SelectAll();');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_select_menu'].addMenuItem('<inp2:m_phrase name="la_Text_Unselect" escape="1"/>','Grids["<inp2:m_param name="PrefixSpecial"/>"].ClearSelection();');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_select_menu'].addMenuItem('<inp2:m_phrase name="la_Text_Invert" escape="1"/>','Grids["<inp2:m_param name="PrefixSpecial"/>"].InvertSelection();');
</inp2:m_if>
processHooks('ViewMenu', hBEFORE, '<inp2:m_param name="PrefixSpecial"/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'] = new Menu('<inp2:$PrefixSpecial_GetItemName/>');
<inp2:m_if check="m_ParamEquals" name="menu_filters" value="yes">
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'].addMenuItem( $Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'] );
</inp2:m_if>
<inp2:m_if check="m_ParamEquals" name="menu_sorting" value="yes">
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'].addMenuItem( $Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'] );
</inp2:m_if>
<inp2:m_if check="m_ParamEquals" name="menu_perpage" value="yes">
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'].addMenuItem( $Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'] );
</inp2:m_if>
<inp2:m_if check="m_ParamEquals" name="menu_select" value="yes">
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'].addMenuItem( $Menus['<inp2:m_param name="PrefixSpecial"/>'+'_select_menu'] );
</inp2:m_if>
processHooks('ViewMenu', hAFTER, '<inp2:m_param name="PrefixSpecial"/>');
}
<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>
<script type="text/javascript">
$edit_mode = <inp2:m_if check="m_ParamEquals" name="edit_mode" value="1">true<inp2:m_else />false</inp2:m_if>;
// window.parent.document.title += ' - MODE: ' + ($edit_mode ? 'EDIT' : 'LIVE');
</script>
<inp2:m_blockend/>
-<inp2:m_DefineElement name="grid" main_prefix="" per_page="" main_special="" no_toolbar="" grid_filters="" search="on" header_block="grid_column_title" filter_block="grid_column_filter" data_block="grid_data_td" row_block="_row" SourcePrefix="" value_field="Value" ajax="0">
+<inp2:m_DefineElement name="grid" main_prefix="" per_page="" main_special="" no_toolbar="" grid_filters="" search="on" header_block="grid_column_title" filter_block="grid_column_filter" data_block="grid_data_td" row_block="_row" ajax="0">
<!--
grid_filters - show individual filters for each column
has_filters - draw filter section in "View" menu in toolbar
- SourcePrefix - used with custom fields
- value_field - used with custom fields
-->
<inp2:$PrefixSpecial_SaveWarning name="grid_save_warning" main_prefix="$main_prefix" no_toolbar="$no_toolbar"/>
<inp2:m_if check="m_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_if>
<inp2:m_if check="m_ParamEquals" name="per_page" value="-1" inverse="1">
<inp2:m_ParseBlock name="grid_pagination" grid="$grid" PrefixSpecial="$PrefixSpecial" main_special="$main_special" search="$search" no_toolbar="$no_toolbar" ajax="$ajax"/>
</inp2:m_if>
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder">
<inp2:m_if check="m_ParamEquals" name="grid_filters" value="1">
<tr class="pagination_bar">
<inp2:$PrefixSpecial_IterateGridFields grid="$grid" mode="filter" block="$filter_block" ajax="$ajax"/>
</tr>
</inp2:m_if>
<tr class="subsectiontitle">
<inp2:$PrefixSpecial_IterateGridFields grid="$grid" mode="header" block="$header_block" ajax="$ajax"/>
</tr>
<inp2:m_DefineElement 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 class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>" id="<inp2:m_param name="PrefixSpecial"/>_<inp2:Field field="$IdField"/>" sequence="<inp2:m_get param="{$PrefixSpecial}_sequence"/>"><inp2:m_inc param="{$PrefixSpecial}_sequence" by="1"/>
+ <inp2:IterateGridFields grid="$grid" mode="data" block="$data_block"/>
</tr>
</inp2:m_DefineElement>
<inp2:m_set {$PrefixSpecial}_sequence="1" odd_even="table_color1"/>
- <inp2:$PrefixSpecial_PrintList block="$row_block" per_page="$per_page" main_special="$main_special" SourcePrefix="$SourcePrefix" value_field="$value_field"/>
+ <inp2:$PrefixSpecial_PrintList block="$row_block" per_page="$per_page" main_special="$main_special" />
</table>
<inp2:m_if check="m_ParamEquals" name="ajax" value="0">
<inp2:m_if check="m_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_if>
<script type="text/javascript">
<inp2:m_RenderElement name="grid_js" selected_class="selected_div" tag_name="tr" pass_params="true"/>
</script>
</inp2:m_if>
<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_DefineElement>
<inp2:m_DefineElement name="grid_js" ajax="1">
<inp2:m_if check="m_ParamEquals" name="no_init" value="no_init" inverse="inverse">
Grids['<inp2:m_param name="PrefixSpecial"/>'] = new Grid('<inp2:m_param name="PrefixSpecial"/>', '<inp2:m_param name="selected_class"/>', ':original', edit, a_toolbar);
Grids['<inp2:m_param name="PrefixSpecial"/>'].AddItemsByIdMask('<inp2:m_param name="tag_name"/>', /^<inp2:m_param name="PrefixSpecial"/>_([\d\w-]+)/, '<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" pass_params="true"/>
$ViewMenus = new Array('<inp2:m_param name="PrefixSpecial"/>');
</inp2:m_DefineElement>
<inp2:m_DefineElement name="white_grid" main_prefix="" per_page="" main_special="" no_toolbar="" search="on" render_as="" columns="2" direction="V" empty_cell_render_as="wg_empty_cell" ajax="0">
<inp2:$PrefixSpecial_SaveWarning name="grid_save_warning" main_prefix="$main_prefix" no_toolbar="$no_toolbar"/>
<inp2:m_if check="m_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_if>
<inp2:m_if check="m_ParamEquals" name="per_page" value="-1" inverse="1">
<inp2:m_ParseBlock name="grid_pagination" grid="$grid" PrefixSpecial="$PrefixSpecial" main_special="$main_special" search="$search" no_toolbar="$no_toolbar" ajax="$ajax"/>
</inp2:m_if>
<br />
<inp2:m_DefineElement name="wg_empty_cell">
<td width="<inp2:m_param name="column_width"/>%">&nbsp;</td>
</inp2:m_DefineElement>
<table width="100%" border="0" cellspacing="2" cellpadding="4">
<inp2:m_set {$PrefixSpecial}_sequence="1" odd_even="table_color1"/>
<inp2:$PrefixSpecial_PrintList2 pass_params="true"/>
</table>
<inp2:m_if check="m_ParamEquals" name="ajax" value="0">
<inp2:m_if check="m_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_if>
<script type="text/javascript">
<inp2:m_RenderElement name="grid_js" selected_class="table_white_selected" tag_name="td" pass_params="true"/>
</script>
</inp2:m_if>
<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_DefineElement>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.36.2/kernel/admin_templates/incs/grid_blocks.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.36.2.3
\ No newline at end of property
+1.36.2.4
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.24.2/core/kernel/parser/template_parser.php
===================================================================
--- branches/unlabeled/unlabeled-1.24.2/core/kernel/parser/template_parser.php (revision 5855)
+++ branches/unlabeled/unlabeled-1.24.2/core/kernel/parser/template_parser.php (revision 5856)
@@ -1,661 +1,671 @@
<?php
k4_include_once(KERNEL_PATH.'/parser/tags.php');
k4_include_once(KERNEL_PATH.'/parser/construct_tags.php');
class TemplateParser extends kBase {
var $Template;
var $Output = '';
var $Position = 0;
var $LastPosition = 0;
var $Ses;
var $Recursion = Array();
var $RecursionIndex = 0;
var $SkipMode = 0;
var $Params = Array();
var $Pattern = Array();
var $ForSort = Array();
var $Values = Array();
var $Buffers = Array();
var $Args;
var $ParamsRecursionIndex = 0;
var $ParamsStack = Array();
var $CompiledBuffer;
var $DataExists = false;
function TemplateParser()
{
parent::kBase();
$this->Ses =& $this->Application->recallObject('Session');
}
function AddParam($pattern, $value, $dont_sort=0)
{
$this->ForSort[] = Array($pattern, $value);
if (!$dont_sort) //used when mass-adding params, to escape sorting after every new param
$this->SortParams(); //but do sort by default!
}
//We need to sort params by its name length desc, so that params starting with same word get parsed correctly
function SortParams()
{
uasort($this->ForSort, array ("TemplateParser", "CmpParams"));
$this->Pattern = Array();
$this->Values = Array();
foreach($this->ForSort as $pair)
{
$this->Pattern[] = $pair[0];
$this->Values[] = $pair[1];
}
}
function CmpParams($a, $b)
{
$a_len = strlen($a[0]);
$b_len = strlen($b[0]);
if ($a_len == $b_len) return 0;
return $a_len > $b_len ? -1 : 1;
}
function SetParams($params, $for_parsing=true)
{
if (!is_array($params)) $params = Array();
$this->ForSort = array();
$this->Params = $params;
$this->ParamsStack[$this->ParamsRecursionIndex] = $params;
if (!$for_parsing) return ;
foreach ($params as $key => $val) {
$this->AddParam('/[{]{0,1}\$'.$key.'[}]{0,1}/i', $val, 1); //Do not sort every time
}
$this->SortParams(); //Sort once after adding is done
}
- function GetParam($name)
+ /**
+ * Returns parser parameter value at specified deep level
+ *
+ * @param string $name
+ * @param int $deep_level if greather then 0 then use from ParamsStack
+ * @return mixed
+ */
+ function GetParam($name, $deep_level = 0)
{
- //return isset($this->Params[strtolower($name)]) ? $this->Params[strtolower($name)] : false;
+ if ($deep_level > 0) {
+ return isset($this->ParamsStack[$deep_level][$name]) ? $this->ParamsStack[$deep_level][$name] : false;
+ }
+
return isset($this->Params[$name]) ? $this->Params[$name] : false;
}
/**
* Set's template parser parameter, that could be retrieved from template
*
* @param string $name
* @param mixed $value
*/
function SetParam($name, $value)
{
$this->Params[strtolower($name)] = $value;
$this->AddParam('/[{]{0,1}\$'.$name.'[}]{0,1}/i', $value, $this->FromPreParseCache);
}
function SetBuffer($body)
{
$this->Buffers[$this->RecursionIndex] = $body;
}
function GetBuffer()
{
return $this->Buffers[$this->RecursionIndex];
}
function GetCode()
{
return $this->Code[$this->RecursionIndex];
}
function AppendBuffer($append)
{
$this->Buffers[$this->RecursionIndex] .= $append;
$this->AppendCode( $this->ConvertToCode($append) );
}
function AppendOutput($append, $append_code=false)
{
if ($this->SkipMode == parse) {
$this->Output .= $append; //append to Ouput only if we are parsing
if ($append_code) $this->AppendCompiledHTML($append);
}
elseif ($this->SkipMode == skip) {
if ($append_code) $this->AppendCompiledHTML($append);
}
elseif ($this->SkipMode == skip_tags) {
$this->AppendBuffer($append); //append to buffer if we are skipping tags
}
}
function ConvertToCode($data)
{
$code = '$o .= \''. str_replace("'", "\'", $data) .'\';';
$code = explode("\n", $code);
return $code;
}
function AppendCode($code)
{
if (defined('EXPERIMENTAL_PRE_PARSE')) {
if (!isset($this->Code[$this->RecursionIndex])) {
$this->Code[$this->RecursionIndex] = Array();
}
if (is_array($code)) {
foreach ($code as $line) {
$this->Code[$this->RecursionIndex][] = rtrim($line, "\n")."\n";
}
}
else {
$this->Code[$this->RecursionIndex][] .= rtrim($code, "\n")."\n";
}
}
}
function AppendCompiledFunction($f_name, $f_body)
{
$real_name = 'f_'.abs(crc32($this->TemplateName)).'_'.$f_name;
if (defined('EXPERIMENTAL_PRE_PARSE')) {
// if such function already compiled
if ( isset($this->Application->CompiledFunctions[$f_name]) ||
function_exists($real_name)
)
{
if (!isset($this->Application->CompiledFunctions[$f_name])) {
$real_name = $real_name.'_';
}
else {
$real_name = $this->Application->CompiledFunctions[$f_name].'_';
}
}
$this->CompiledBuffer .= "\t".'$application->PreParsedBlocks[\''.$f_name.'\'] = \''.$real_name.'\';'."\n";
$this->CompiledBuffer .= 'if (!function_exists(\''.$real_name.'\')) {'."\n";
$this->CompiledBuffer .= "\t".'function '.$real_name.'($params)'."\n\t{\n";
$this->CompiledBuffer .= $f_body;
$this->CompiledBuffer .= "\t}\n\n";
$this->CompiledBuffer .= '}'."\n";
$this->Application->CompiledFunctions[$f_name] = $real_name;
}
}
function AppendCompiledCode($code)
{
if (defined('EXPERIMENTAL_PRE_PARSE')) {
if (is_array($code)) {
foreach ($code as $line) {
$this->CompiledBuffer .= "\t".rtrim($line, "\n")."\n";
}
}
else {
$this->CompiledBuffer .= $code;
}
$this->CompiledBuffer .= "\t".'echo $o;'."\n\t".'$o = \'\';'."\n";
}
}
function AppendCompiledHTML($append)
{
if (defined('EXPERIMENTAL_PRE_PARSE')) {
$this->CompiledBuffer .= '?'.'>'."\n";
$this->CompiledBuffer .= rtrim($append, "\t");
$this->CompiledBuffer .= '<'.'?php'."\n";
}
}
function ResetCode()
{
$this->Code[$this->RecursionIndex] = Array();
}
function FindTag2()
{
$openings = Array('<%' => '%>', '<inp2:' => Array('>', '/>'), '</inp2:' => '>', '</inp2>' => '', '<!--' => '-->');
$tag_open_pos = false;
foreach ($openings as $an_opening => $closings) {
$pos = strpos($this->Template, $an_opening, $this->Position);
if ($pos !== false && ($tag_open_pos === false || (int) $pos <= (int) $tag_open_pos)) {
$tag_open_pos = $pos;
$open_len = strlen($an_opening);
$opening_tag = $an_opening;
$tag_closings = $closings;
}
}
if ($tag_open_pos === false) { //If no tags left - adding all other data
$this->AppendOutput(substr($this->Template, $this->Position), true);
return false;
}
//Adding all data before tag open
$this->AppendOutput(substr($this->Template, $this->Position, $tag_open_pos - $this->Position), true);
if (is_array($tag_closings)) {
$tag_close_pos = false;
foreach ($tag_closings as $a_closing) {
$pos = strpos($this->Template, $a_closing, $tag_open_pos);
if ($pos !== false && ($tag_close_pos === false || (int) $pos <= (int) $tag_close_pos)) {
$tag_close_pos = $pos;
$closing_tag = $a_closing;
}
}
}
elseif ($opening_tag == '</inp2>') {
$closing_tag = '';
$tag_close_pos = $tag_open_pos + $open_len;
}
else {
$closing_tag = $tag_closings;
$tag_close_pos = strpos($this->Template, $closing_tag, $tag_open_pos);
}
$close_len = strlen($closing_tag);
//Cutting out the tag itself
$tag = substr($this->Template, $tag_open_pos + $open_len, $tag_close_pos - $tag_open_pos - $open_len);
if ($opening_tag == '<inp2:') {
//getting prefix_tag upto first space, tab or line break into regs[1]
preg_match("/^([^ \t\n]*)(.*)/", $tag, $regs);
$tag_part = $regs[1];
if (strpos($tag_part, '_') !== false) {
list($prefix, $the_tag) = explode('_', $tag, 2);
/*preg_match('/(.*)_(.*)/', $tag_part, $rets);
$prefix = $rets[1];
$the_tag = $rets[2].$regs[2];*/
$tag = $prefix.':'.$the_tag;
}
else {
$the_tag = $tag;
$tag = ':'.$tag;
}
}
if ($opening_tag == '</inp2>') { //empty closing means old style in-portal if <inp2:tag>....</inp2>
$tag = 'm:endif';
}
if ($opening_tag == '</inp2:') {
preg_match("/^([^ \t\n]*)(.*)/", $tag, $regs);
$tag_part = $regs[1];
if (strpos($tag_part, '_') !== false) {
list($prefix, $the_tag) = explode('_', $tag, 2);
$tag = $prefix.':'.$the_tag;
}
$tag .= ' _closing_tag_="1"';
}
// if there is no prefix for the tag
if (strpos($tag, ':') === 0) {
$prefix = getArrayValue($this->Params, 'PrefixSpecial');
$tag = $prefix.$tag;
}
// temporary - for backward compatability with in-portal style if
if ($opening_tag == '<inp2:' && $closing_tag == '>' && $tag_part != 'm_if' && $tag_part != 'm_DefineElement') {
if (strpos($the_tag, ' ') !== false) {
list($function, $params) = explode(' ', $the_tag, 2);
}
else {
$function = $the_tag;
$params = '';
}
$tag = 'm:if prefix="'.$prefix.'" function="'.$function.'" '.$params;
}
if ($opening_tag == '<!--') {
$this->AppendOutput('<!-- '.$tag. '-->');
$tag = '__COMMENT__';
}
$this->Position = $tag_close_pos + $close_len;
return $tag;
}
function CurrentLineNumber()
{
return substr_count(substr($this->Template, 0, $this->Position), "\n")+1;
}
function SkipModeName()
{
switch ($this->SkipMode) {
case skip: return 'skip';
case skip_tags: return 'skip_tags';
case parse: return 'parse';
}
}
/**
* Recursive mkdir
*
* @param string $dir
* @param string $base_path base path to directory where folders should be created in
*/
function CheckDir($dir, $base_path = '')
{
if (file_exists($dir)) {
return;
}
else {
// remove $base_path from beggining because it is already created during install
$dir = preg_replace('/^'.preg_quote($base_path.'/', '/').'/', '', $dir, 1);
$segments = explode('/', $dir);
$cur_path = $base_path;
foreach ($segments as $segment) {
// do not add leading / for windows paths (c:\...)
$cur_path .= preg_match('/^[a-zA-Z]{1}:/', $segment) ? $segment : '/'.$segment;
if (!file_exists($cur_path)) {
mkdir($cur_path);
}
}
}
}
function ParseTemplate($name, $pre_parse = 1, $params=array(), $silent=0)
{
$this->FromPreParseCache = false;
if ($this->GetParam('from_inportal')) $pre_parse = 0;
if ($pre_parse) {
$pre_parsed = $this->Application->TemplatesCache->GetPreParsed($name);
if ($pre_parsed && $pre_parsed['active']) { // active means good (not expired) pre-parsed cache
$this->FromPreParseCache = true;
$this->SetParams($params, 0); // 0 to disable params sorting and regexp generation - not needed when processing pre-parsed
ob_start();
if ($pre_parsed['mode'] == 'file') {
include($pre_parsed['fname']);
}
else {
eval('?'.'>'.$pre_parsed['content']);
}
$output = ob_get_contents();
ob_end_clean();
}
else {
$this->SetParams($params);
$this->CompiledBuffer .= '<'.'?php'."\n";
$this->CompiledBuffer .= 'global $application;'."\n";
$this->CompiledBuffer .= '$params =& $application->Parser->Params;'."\n";
$this->CompiledBuffer .= 'extract($params);'."\n";
$this->CompiledBuffer .= '$o = \'\';'."\n";
$output = $this->NewParse($this->Application->TemplatesCache->GetTemplateBody($name, $silent), $name);
$this->CompiledBuffer .= '?'.'>'."\n";
if (defined('SAFE_MODE') && SAFE_MODE) {
if (!isset($conn)) $conn =& $this->Application->GetADODBConnection();
$conn->Query('REPLACE INTO '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ('.$conn->qstr($pre_parsed['fname']).','.$conn->qstr($this->CompiledBuffer).','.adodb_mktime().')');
}
else {
$compiled = fopen($pre_parsed['fname'], 'w');
fwrite($compiled, $this->CompiledBuffer);
fclose($compiled);
}
}
if ( !$this->GetParam('from_inportal') && strpos($output, '<inp:') !== false) {
$inp1_parser =& $this->Application->recallObject('Inp1Parser');
$output = $inp1_parser->NewParse($name, $output);
}
return $output;
}
// pre-parse is OFF
$this->SetParams($params);
return $this->NewParse($this->Application->TemplatesCache->GetTemplateBody($name), $name, $pre_parse);
}
function NewParse($template, $name='unknown', $pre_parse = 1)
{
$this->Template = $template;
$this->TemplateName = $name;
$this->Position = 0;
$this->Output = '';
$this->TagHolder = new MyTagHolder();
$has_inp_tags = false;
if (!getArrayValue($this->Params, 'PrefixSpecial')) {
$this->Params['PrefixSpecial'] = '$PrefixSpecial';
}
//While we have more tags
while ($tag_data = $this->FindTag2())
{
if ($tag_data == '__COMMENT__') continue;
//Create tag object from passed tag data
if( $this->Application->isDebugMode() && constOn('DBG_SHOW_TAGS') )
{
global $debugger;
$debugger->appendHTML('mode: '.$this->SkipModeName().' tag '.$debugger->highlightString($tag_data).' in '.$debugger->getFileLink($debugger->getLocalFile(FULL_PATH.THEMES_PATH.'/'.$this->TemplateName).'.tpl', $this->CurrentLineNumber(), '', true));
}
$tag =& $this->TagHolder->GetTag($tag_data, $this);
if (!$this->CheckRecursion($tag)) //we do NOT process closing tags
{
$tag->Process();
}
}
return $this->Output;
}
function Parse($template, $name='unknown', $pre_parse = 1)
{
$this->Template = $template;
$this->TemplateName = $name;
$this->Position = 0;
$this->Output = '';
$this->TagHolder = new MyTagHolder();
$has_inp_tags = false;
if ($this->GetParam('from_inportal')) $pre_parse = 0;
if (defined('EXPERIMENTAL_PRE_PARSE') && $pre_parse) {
$fname = $this->Application->TemplatesCache->GetRealFilename($this->TemplateName).'.php';
$fname = str_replace(FULL_PATH, FULL_PATH.'/kernel/cache', $fname);
if (!defined('SAFE_MODE') || !SAFE_MODE) {
$this->CheckDir(dirname($fname), FULL_PATH.'/kernel/cache');
}
$tname = $this->Application->TemplatesCache->GetRealFilename($this->TemplateName).'.tpl';
$output = '';
$is_cached = false;
ob_start();
if (defined('SAFE_MODE') && SAFE_MODE) {
$conn =& $this->Application->GetADODBConnection();
$cached = $conn->GetRow('SELECT * FROM '.TABLE_PREFIX.'Cache WHERE VarName = "'.$fname.'"');
if ($cached !== false && $cached['Cached'] > filemtime($tname)) {
eval('?'.'>'.$cached['Data']);
$is_cached = true;
}
}
else {
if (file_exists($fname) && file_exists($tname) && filemtime($fname) > filemtime($tname)) {
include($fname);
$is_cached = true;
}
}
$output = ob_get_contents();
ob_end_clean();
if ( $is_cached && !$this->GetParam('from_inportal') ) {
if ( strpos($output, '<inp:') !== false) {
$inp1_parser =& $this->Application->recallObject('Inp1Parser');
$output = $inp1_parser->Parse($name, $output);
}
return $output;
}
$this->CompiledBuffer .= '<'.'?php'."\n";
$this->CompiledBuffer .= 'global $application;'."\n";
$this->CompiledBuffer .= '$params =& $application->Parser->Params;'."\n";
$this->CompiledBuffer .= 'extract($params);'."\n";
$this->CompiledBuffer .= '$o = \'\';'."\n";
}
if (!getArrayValue($this->Params, 'PrefixSpecial')) {
$this->Params['PrefixSpecial'] = '$PrefixSpecial';
}
//While we have more tags
while ($tag_data = $this->FindTag2())
{
if ($tag_data == '__COMMENT__') continue;
//Create tag object from passed tag data
if( $this->Application->isDebugMode() && constOn('DBG_SHOW_TAGS') )
{
global $debugger;
$debugger->appendHTML('mode: '.$this->SkipModeName().' tag '.$debugger->highlightString($tag_data).' in '.$debugger->getFileLink($debugger->getLocalFile(FULL_PATH.THEMES_PATH.'/'.$this->TemplateName).'.tpl', $this->CurrentLineNumber(), '', true));
}
// $tag =& new MyTag($tag_data, $this);
$tag =& $this->TagHolder->GetTag($tag_data, $this);
if (!$this->CheckRecursion($tag)) //we do NOT process closing tags
{
$tag->Process();
}
}
if ( !$this->GetParam('from_inportal') ) {
if ( strpos($this->Output, '<inp:') !== false) {
$inp1_parser =& $this->Application->recallObject('Inp1Parser');
$this->Output = $inp1_parser->Parse($name, $this->Output);
$has_inp_tags = true;
}
}
if (defined('EXPERIMENTAL_PRE_PARSE') && $pre_parse && !$has_inp_tags) {
// $this->CompiledBuffer .= 'echo $o;'."\n";
$this->CompiledBuffer .= '?'.'>'."\n";
if (defined('SAFE_MODE') && SAFE_MODE) {
if (!isset($conn)) $conn =& $this->Application->GetADODBConnection();
$conn->Query('REPLACE INTO '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ('.$conn->qstr($fname).','.$conn->qstr($this->CompiledBuffer).','.adodb_mktime().')');
}
else {
$compiled = fopen($fname, 'w');
fwrite($compiled, $this->CompiledBuffer);
fclose($compiled);
}
}
return $this->Output;
}
function ParseBlock($params, $force_pass_params=0, $as_template=false)
{
if( $this->Application->isDebugMode() && constOn('DBG_SHOW_TAGS') )
{
global $debugger;
$debugger->appendHTML('ParseBlock '.$params['name'].' pass_params is '.$params['pass_params'].' force is '.$force_pass_params.' in '.$debugger->getFileLink($debugger->getLocalFile(FULL_PATH.THEMES_PATH.'/'.$this->TemplateName).'.tpl', $this->CurrentLineNumber(), '', true));
}
/*if ( $this->Application->isDebugMode() && constOn('DBG_PRE_PARSE') ) {
global $debugger;
$debugger->CurrentPreParsedBlock = $params['name'];
}*/
if (defined('EXPERIMENTAL_PRE_PARSE')) {
$this->MainParser = false;
if (isset($this->Application->PreParsedBlocks[$params['name']]) ) {
if ($this->ParamsRecursionIndex == 0) {
$this->ParamsStack[$this->ParamsRecursionIndex] = $this->Params;
}
if (isset($params['pass_params']) || $force_pass_params) {
$pass_params = array_merge($this->ParamsStack[$this->ParamsRecursionIndex], $params);
}
else {
$pass_params = $params;
}
$this->ParamsStack[++$this->ParamsRecursionIndex] = $pass_params;
$this->Params = $pass_params;
$f = $this->Application->PreParsedBlocks[$params['name']];
// $this->ParamsRecursionIndex--;
//$this->SetParams($params);
if( !isset($pass_params['PrefixSpecial']) && isset($pass_params['prefix']) ) $pass_params['PrefixSpecial'] = $pass_params['prefix'];
$ret = $f($pass_params);
unset($this->ParamsStack[$this->ParamsRecursionIndex--]);
$this->Params = $this->ParamsStack[$this->ParamsRecursionIndex];
$this->MainParser = true;
return $ret;
}
}
$BlockParser =& $this->Application->makeClass('TemplateParser');
if (isset($params['pass_params']) || $force_pass_params) {
$BlockParser->SetParams(array_merge($this->Params, $params));
}
else
$BlockParser->SetParams($params);
$this->Application->Parser =& $BlockParser;
if (!isset($params['name'])) trigger_error('<b>***Error: Block name not passed to ParseBlock</b>', E_USER_ERROR);
$templates_cache =& $this->Application->recallObject('TemplatesCache');
$template_name = $as_template ? $params['name'] : $templates_cache->GetTemplateFileName($params['name']) . '-block:'.$params['name'];
$silent = getArrayValue($params, 'from_inportal') && !defined('DBG_TEMPLATE_FAILURE');
$o = $BlockParser->Parse(
$templates_cache->GetTemplateBody($params['name'], $silent),
$template_name
);
if (getArrayValue($params, 'BlockNoData') && !$BlockParser->DataExists) {
$template_name = $as_template ? $params['BlockNoData'] : $templates_cache->GetTemplateFileName($params['BlockNoData']) . '-block:'.$params['BlockNoData'];
$o = $BlockParser->Parse(
$templates_cache->GetTemplateBody($params['BlockNoData'], $silent),
$template_name
);
}
$this->Application->Parser =& $this;
$this->Application->Parser->DataExists = $this->Application->Parser->DataExists || $BlockParser->DataExists;
return $o;
}
function Recurve(&$tag)
{
$this->Recursion[++$this->RecursionIndex] =& $tag;
}
function CheckRecursion(&$tag)
{
if ($this->RecursionIndex > 0) { //If we are inside the recursion
if ($this->Recursion[$this->RecursionIndex]->CheckRecursion($tag)) { //If we can close this recursion
unset($this->Recursion[$this->RecursionIndex--]); //unsetting current recursion level and decreasing it at the same time
return true; //we should inform not to process closing tag
}
}
return false;
}
function SetSkipMode($mode)
{
$this->SkipMode = $mode;
}
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.24.2/core/kernel/parser/template_parser.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.24.2.5
\ No newline at end of property
+1.24.2.6
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.62.2/core/kernel/db/db_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.62.2/core/kernel/db/db_tag_processor.php (revision 5855)
+++ branches/unlabeled/unlabeled-1.62.2/core/kernel/db/db_tag_processor.php (revision 5856)
@@ -1,1561 +1,1574 @@
<?php
class kDBTagProcessor extends TagProcessor {
/**
* Description
*
* @var kDBConnection
* @access public
*/
var $Conn;
function kDBTagProcessor()
{
parent::kBase();
$this->Conn =& $this->Application->GetADODBConnection();
}
/**
* Returns true if "new" button was pressed in toolbar
*
* @param Array $params
* @return bool
*/
function IsNewMode($params)
{
$object =& $this->getObject($params);
return $object->GetID() <= 0;
}
/**
* 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');
if(!$filter_menu)
{
trigger_error('<span class="debug_error">no filters defined</span> for prefix <b>'.$this->Prefix.'</b>, but <b>DrawFilterMenu</b> tag used', E_USER_WARNING);
return '';
}
// 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) {
$group_params = isset($filter_params['group_id']) ? $filter_menu['Groups'][ $filter_params['group_id'] ] : Array();
if (!isset($group_params['element_type'])) {
$group_params['element_type'] = 'checkbox';
}
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 = $group_params['element_type'] == 'checkbox' ? 1 : 2;
}
else {
$submit = 1;
$status = 0;
}
$block_params['filter_action'] = 'set_filter("'.$prefix_special.'","'.$filter_key.'","'.$submit.'",'.$params['ajax'].');';
$block_params['filter_status'] = $status; // 1 - checkbox, 2 - radio, 0 - no image
$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;
}
function GridFieldsCount($params)
{
$grids = $this->Application->getUnitOption($this->Prefix, 'Grids');
$grid_config = $grids[$params['grid']]['Fields'];
return count($grid_config);
}
/**
* Prints list content using block specified
*
* @param Array $params
* @return string
* @access public
*/
function PrintList($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 = isset($params['list_name']) ? $params['list_name'] : '';
$names_mapping = $this->Application->GetVar('NamesToSpecialMapping');
if( !getArrayValue($names_mapping, $this->Prefix, $list_name) )
{
$list =& $this->GetList($params);
}
}
function BuildListSpecial($params)
{
return $this->Special;
}
/**
* Enter description here...
*
* @param Array $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, $this->Prefix, $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);
if ($requery) {
$this->Application->HandleEvent($an_event, $prefix_special.':OnListBuild', $params);
}
$list->Query($requery);
$this->Special = $special;
if ($list_name) {
$names_mapping[$this->Prefix][$list_name] = $special;
$this->Application->SetVar('NamesToSpecialMapping', $names_mapping);
}
return $list;
}
function ListMarker($params)
{
$list =& $this->GetList($params);
$ret = $list->getPrefixSpecial();
if( getArrayValue($params, 'as_preg') ) $ret = preg_quote($ret, '/');
return $ret;
}
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); // this is issued twice, maybe need to be removed
}
$list->GoFirst();
$block_params=$this->prepareTagParams($params);
$block_params['name']=$this->SelectParam($params, 'render_as,block');
$block_params['pass_params']='true';
$block_params['column_width'] = 100 / $columns;
$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();
$column_number = 1;
$cache_mod_rw = $this->Application->getUnitOption($this->Prefix, 'CacheModRewrite') && $this->Application->RewriteURLs();
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 ($cache_mod_rw) {
$this->Application->setCache('filenames', $this->Prefix.'_'.$list->GetDBField($id_field), $list->GetDBField('Filename'));
$this->Application->setCache('filenames', 'c_'.$list->GetDBField('CategoryId'), $list->GetDBField('CategoryFilename'));
}
if ($i % $columns == 0) {
// record in this iteration is first in row, then open row
$column_number = 1;
$o.= $block_start_row_params['name'] ?
$this->Application->ParseBlock($block_start_row_params, 1) :
(!isset($params['no_table']) ? '<tr>' : '');
}
else {
$column_number++;
}
$block_params['column_number'] = $column_number;
$o.= $this->Application->ParseBlock($block_params, 1);
array_push($displayed, $list->GetDBField($id_field));
if (($i+1) % $columns == 0) {
// record in next iteration is first in row too, then close this row
$o.= $block_end_row_params['name'] ?
$this->Application->ParseBlock($block_end_row_params, 1) :
(!isset($params['no_table']) ? '<tr>' : '');
}
$list->GoNext();
$i++;
}
// append empty cells in place of missing cells in last row
while ($i % $columns != 0) {
// until next cell will be in new row append empty cells
$o .= $block_empty_cell_params['name'] ? $this->Application->ParseBlock($block_empty_cell_params, 1) : '<td>&nbsp;</td>';
if (($i+1) % $columns == 0) {
// record in next iteration is first in row too, then close this row
$o .= $block_end_row_params['name'] ? $this->Application->ParseBlock($block_end_row_params, 1) : '</tr>';
}
$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)
{
$object =& $this->getObject($params); // maybe we should use $this->GetList($params) instead
return ($object->CurrentIndex < min($object->PerPage, $object->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']);
}
// $http_query =& $this->Application->recallObject('HTTPQuery');
// $get = $http_query->getRedirectParams();
$pass = Array('pass' => 'm,'.$this->getPrefixSpecial());
// $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())
{
/*if (isset($tag_params['list_name'])) {
$list =& $this->GetList($tag_params);
$this->Init($list->Prefix, $list->Special);
}*/
$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)
{
$currency =& $this->Application->recallObject('curr.-'.$iso, null, Array('skip_autoload' => true));
if( !$currency->isLoaded() ) $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->getObject($params);
if ( $this->HasParam($params, 'db') )
{
$value = $object->GetDBField($field);
}
else
{
if( $this->HasParam($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( $this->SelectParam($params, 'negative') )
{
if(strpos($value, '-') === 0)
{
$value = substr($value, 1);
}
else
{
$value = '-'.$value;
}
}
if( $this->HasParam($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( $this->HasParam($params, 'currency') )
{
//restoring value in original currency, for other Field tags to work properly
$object->SetDBField($field, $original);
}
return $value;
}
function SetField($params)
{
// <inp2:SetField field="Value" src=p:cust_{$custom_name}"/>
$object =& $this->getObject($params);
$dst_field = $this->SelectParam($params, 'name,field');
list($prefix_special, $src_field) = explode(':', $params['src']);
$src_object =& $this->Application->recallObject($prefix_special);
$object->SetDBField($dst_field, $src_object->GetDBField($src_field));
}
/**
* 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 = $this->SelectParam($params, 'name,field');
$object =& $this->getObject($params);
$msg = $object->GetErrorMsg($field, false);
return $msg;
}
function HasError($params)
{
if ($params['field'] == 'any')
{
$object =& $this->getObject($params);
$skip_fields = getArrayValue($params, 'except');
$skip_fields = $skip_fields ? explode(',', $skip_fields) : Array();
return $object->HasErrors($skip_fields);
}
else
{
$fields = $this->SelectParam($params, 'field,fields');
$fields = explode(',', $fields);
$res = false;
foreach($fields as $field)
{
$params['field'] = $field;
$res = $res || ($this->Error($params) != '');
}
return $res;
}
}
function IsRequired($params)
{
$field = $params['field'];
$object =& $this->getObject($params);;
$options = $object->GetFieldOptions($field);
return getArrayValue($options,'required');
}
function PredefinedOptions($params)
{
$field = $params['field'];
$object =& $this->getObject($params);
$value = $object->GetDBField($field);
$options = $object->GetFieldOptions($field);
if( $this->HasParam($params,'has_empty') )
{
$empty_value = getArrayValue($params, 'empty_value');
if($empty_value === false) $empty_value = '';
$options['options'] = array_merge_recursive2( Array($empty_value => ''), $options['options'] );
}
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $this->SelectParam($params, 'render_as,block');
$block_params['field'] = $params['field'];
$block_params['pass_params'] = 'true';
$block_params['field_name'] = $this->InputName($params);
$block_params['PrefixSpecial'] = $this->getPrefixSpecial();
$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']);
if( strpos($value, '|') !== false )
{
// multiple selection checkboxes
$value = explode('|', substr($value, 1, -1) );
foreach ($options['options'] as $key => $val)
{
$block_params['key'] = $key;
$block_params['option'] = $val;
$block_params[$selected_param_name] = ( in_array($key, $value) ? ' '.$selected : '');
$o .= $this->Application->ParseBlock($block_params, 1);
}
}
else
{
// single selection radio or checkboxes
foreach ($options['options'] as $key => $val)
{
$block_params['key'] = $key;
$block_params['option'] = $val;
$block_params[$selected_param_name] = ( $key == $value ? ' '.$selected : '');
$o .= $this->Application->ParseBlock($block_params, 1);
}
}
return $o;
}
function PredefinedSearchOptions($params)
{
$object =& $this->getObject($params);
$field = $params['field'];
$saved_value = $object->GetDBField($field);
$custom_filters = $this->Application->RecallVar( $this->getPrefixSpecial().'_custom_filters');
if ($custom_filters) {
$custom_filters = unserialize($custom_filters);
$append = getArrayValue($params, 'type') ? '_'.$params['type'] : '';
$object->SetDBField($field, $custom_filters[$field.$append]);
}
else {
$object->SetDBField($field, '');
}
$ret = $this->PredefinedOptions($params);
$object->SetDBField($field, $saved_value);
return $ret;
}
function Format($params)
{
$field = $this->SelectParam($params, 'name,field');
$object =& $this->getObject($params);
$options = $object->GetFieldOptions($field);
$format = $options[ $this->SelectParam($params, 'input_format') ? 'input_format' : 'format' ];
$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($format);
return $edit_size ? strlen($format) : $format;
}
}
return $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 > 1) $this->Application->Parser->DataExists = true;
if($total_pages == 0) $total_pages = 1; // display 1st page as selected in case if we have no pages at all
$o = '';
// what are these 2 lines for?
$this->Application->SetVar($prefix_special.'_event','');
$this->Application->SetVar($prefix_special.'_id','');
$current_page = $list->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);
}
}
}
$this->Application->SetVar($this->getPrefixSpecial().'_Page', $current_page);
return $o;
}
/**
* Print grid pagination using
* block names specified
*
* @param Array $params
* @return string
* @access public
*/
function PaginationBar($params)
{
return $this->PrintPages($params);
}
/**
* Returns field name (processed by kMultiLanguage formatter
* if required) and item's id from it's IDField or field required
*
* @param Array $params
* @return Array (id,field)
* @access private
*/
function prepareInputName($params)
{
$field = $this->SelectParam($params, 'name,field');
$object =& $this->getObject($params);
$formatter_class = getArrayValue($object->Fields, $field, 'formatter');
if ($formatter_class == 'kMultiLanguage')
{
$formatter =& $this->Application->recallObject($formatter_class);
$field = $formatter->LangFieldName($field);
}
$id_field = getArrayValue($params, 'IdField');
$id = $id_field ? $object->GetDBField($id_field) : $object->GetID();
return Array($id, $field);
}
/**
* Returns input field name to
* be placed on form (for correct
* event processing)
*
* @param Array $params
* @return string
* @access public
*/
function InputName($params)
{
list($id, $field) = $this->prepareInputName($params);
$ret = $this->getPrefixSpecial().'['.$id.']['.$field.']';
if( getArrayValue($params, 'as_preg') ) $ret = preg_quote($ret, '/');
return $ret;
}
/**
* Allows to override various field options through hidden fields with specific names in submit.
* This tag generates this special names
*
* @param Array $params
* @return string
* @author Alex
*/
function FieldModifier($params)
{
list($id, $field) = $this->prepareInputName($params);
$ret = 'field_modifiers['.$this->getPrefixSpecial().']['.$field.']['.$params['type'].']';
if( getArrayValue($params, 'as_preg') ) $ret = preg_quote($ret, '/');
return $ret;
}
/**
* 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->getObject($params);
return $object->PerPage;
}
/**
* Checks if list perpage matches value specified
*
* @param Array $params
* @return bool
*/
function PerPageEquals($params)
{
$object =& $this->getObject($params);
return $object->PerPage == $params['value'];
}
function SaveEvent($params)
{
// SaveEvent is set during OnItemBuild, but we may need it before any other tag calls OnItemBuild
$object =& $this->getObject($params);
return $this->Application->GetVar($this->getPrefixSpecial().'_SaveEvent');
}
function NextId($params)
{
$object =& $this->getObject($params);
$ids = explode(',', $this->Application->RecallVar($this->getPrefixSpecial().'_selected_ids'));
$cur_id = $object->GetID();
$i = array_search($cur_id, $ids);
if ($i !== false) {
return $i < count($ids) - 1 ? $ids[$i + 1] : '';
}
return '';
}
function PrevId($params)
{
$object =& $this->getObject($params);
$ids = explode(',', $this->Application->RecallVar($this->getPrefixSpecial().'_selected_ids'));
$cur_id = $object->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->getObject($params);
$ret = $object->GetDBField($this->SelectParam($params, 'name,field')) == $params['value'];
// if( getArrayValue($params,'inverse') ) $ret = !$ret;
return $ret;
}
function ItemIcon($params)
{
$object =& $this->getObject($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)
{
$preset_name = replaceModuleSection($params['title_preset']);
$title_presets = $this->Application->getUnitOption($this->Prefix,'TitlePresets');
$title_info = getArrayValue($title_presets, $preset_name);
if($title_info === false) return str_replace('#preset_name#', $preset_name, $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');
$all_tag_params = getArrayValue($title_info,'tag_params');
if($prefixes)
{
$tag_params = Array();
foreach($prefixes as $prefix_special)
{
$prefix_data = $this->Application->processPrefix($prefix_special);
$prefix_data['prefix_special'] = rtrim($prefix_data['prefix_special'],'.');
if($all_tag_params)
{
$tag_params = getArrayValue($all_tag_params, $prefix_data['prefix_special']);
if(!$tag_params) $tag_params = Array();
}
$tag_params = array_merge_recursive2($params, $tag_params);
$objects[ $prefix_data['prefix_special'] ] =& $this->Application->recallObject($prefix_data['prefix_special'], $prefix_data['prefix'], $tag_params);
$object_status[ $prefix_data['prefix_special'] ] = $objects[ $prefix_data['prefix_special'] ]->IsNewItem() ? 'new' : 'edit';
// 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->getObject($params);
$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 'text':
case 'textarea':
$params['field_params'] = $helper->ParseConfigSQL($object->GetDBField($params['value_list_field']));
break;
case 'password':
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)
{
$params['name'] = 'cust_'.$this->SelectParam($params, 'name,field');
return $this->Field($params);
}
function CustomFieldLabel($params)
{
$object =& $this->getObject($params);
$field = $this->SelectParam($params, 'name,field');
$sql = 'SELECT FieldLabel
FROM '.$this->Application->getUnitOption('cf', 'TableName').'
WHERE FieldName = '.$this->Conn->qstr($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;
// in case if after applying per_page limit record count less then
// can fill requrested column count, then fill as much as we can
$cols = min(ceil($per_page / $columns), ceil(count($arr) / $columns));
$imatrix = array();
for ($row = 0; $row < $rows; $row++) {
for ($col = 0; $col < $cols; $col++) {
$source_index = $row * $cols + $col;
if (!isset($arr[$source_index])) {
// in case if source array element count is less then element count in one row
continue;
}
$imatrix[$col * $rows + $row] = $arr[$source_index];
}
}
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) {
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $this->SelectParam($params, 'render_as,name');
$block_params['edit_mode'] = $temp_tables ? 1 : 0;
return $this->Application->ParseBlock($block_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;
}
/**
* Range filter field name
*
* @param Array $params
* @return string
*/
function SearchInputName($params)
{
$field = $this->SelectParam($params, 'field,name');
$append = getArrayValue($params, 'type') ? '_'.$params['type'] : '';
return 'custom_filters['.$this->getPrefixSpecial().']['.$field.$append.']';
}
/**
* Return range filter field value
*
* @param Array $params
* @return string
*/
function SearchField($params) // RangeValue
{
$field = $this->SelectParam($params, 'field,name');
$custom_filters = $this->Application->RecallVar($this->getPrefixSpecial().'_custom_filters');
$custom_filters = $custom_filters ? unserialize($custom_filters) : Array();
$append = getArrayValue($params, 'type');
return getArrayValue($custom_filters, $field.( $append ? '_'.$append : '') );
}
function SearchFormat($params)
{
$field = $params['field'];
$object =& $this->GetList($params);
$options = $object->GetFieldOptions($field);
$format = $options[ $this->SelectParam($params, 'input_format') ? 'input_format' : 'format' ];
$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($format);
return $edit_size ? strlen($format) : $format;
}
}
return $format;
}
/**
* Returns error of range field
*
* @param unknown_type $params
* @return unknown
*/
function SearchError($params)
{
$field = $this->SelectParam($params, 'field,name');
$error_var_name = $this->getPrefixSpecial().'_'.$field.'_'.$params['type'].'_error';
$error_msg = $this->Application->RecallVar($error_var_name);
if($error_msg)
{
$this->Application->StoreVar($error_var_name, '');
}
$object =& $this->Application->recallObject($this->Prefix.'.'.$this->Special.'-item', null, Array('skip_autoload' => true));
return $object->ErrorMsgs[$error_msg];
}
/**
* Returns templates path for module, which is gathered from prefix module
*
* @param Array $params
* @return string
* @author Alex
*/
function ModulePath($params)
{
$force_module = getArrayValue($params, 'module');
if ($force_module) {
if ($force_module == '#session#') {
$force_module = $this->Application->RecallVar('module');
}
else {
$force_module = strtolower($force_module);
}
$module_folder = trim( $this->Application->findModule('Name', $force_module, 'Path'), '/');
}
else {
$module_folder = $this->Application->getUnitOption($this->Prefix, 'ModuleFolder');
}
return '../../'.$module_folder.'/admin_templates/';
}
/**
* Returns object used in tag processor
*
* @access public
* @return kDBBase
*/
function &getObject($params = Array())
{
$object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix, $params);
return $object;
}
/**
* Checks if object propery value matches value passed
*
* @param Array $params
* @return bool
*/
function PropertyEquals($params)
{
$object =& $this->getObject($params);
$property_name = $this->SelectParam($params, 'name,var,property');
return $object->$property_name == $params['value'];
}
/**
* Group list records by header, saves internal order in group
*
* @param Array $records
* @param string $heading_field
*/
function groupRecords(&$records, $heading_field)
{
$sorted = Array();
$i = 0; $record_count = count($records);
while ($i < $record_count) {
$sorted[ $records[$i][$heading_field] ][] = $records[$i];
$i++;
}
$records = Array();
foreach ($sorted as $heading => $heading_records) {
$records = array_merge_recursive($records, $heading_records);
}
}
+
+ /**
+ * Allows to determine if original value should be shown
+ *
+ * @param Array $params
+ * @return bool
+ */
+ function DisplayOriginal($params)
+ {
+ // original id found & greather then zero + show original
+ $display_original = isset($params['display_original']) && $params['display_original'];
+ return $display_original && $this->Application->GetVar($this->Prefix.'.original_id');
+ }
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.62.2/core/kernel/db/db_tag_processor.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.62.2.7
\ No newline at end of property
+1.62.2.8
\ No newline at end of property

Event Timeline