Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Tue, May 20, 7:18 PM

in-portal

Index: branches/unlabeled/unlabeled-1.1.2/core/units/config_search/config_search_config.php
===================================================================
--- branches/unlabeled/unlabeled-1.1.2/core/units/config_search/config_search_config.php (revision 1371)
+++ branches/unlabeled/unlabeled-1.1.2/core/units/config_search/config_search_config.php (revision 1372)
@@ -1,82 +1,90 @@
<?php
$config = Array(
'Prefix' => 'confs',
'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'ConfigSearchEventHandler','file'=>'config_search_event_handler.php','build_event'=>'OnBuild'),
'TagProcessorClass' => Array('class'=>'ConfigSearchTagProcessor','file'=>'config_search_tag_processor.php','build_event'=>'OnBuild'),
'AutoLoad' => true,
'hooks' => Array(),
'QueryString' => Array(
1 => 'id',
2 => 'page',
3 => 'event',
4 => 'module',
5 => 'section',
),
'Hooks' => Array(
Array(
'Mode' => hAFTER,
'Conditional' => false,
'HookToPrefix' => 'cf',
'HookToSpecial' => '',
- 'HookToEvent' => Array( 'OnPreSaveCreated' ),
+ //'HookToEvent' => Array( 'OnPreSaveCreated' ),
+ 'HookToEvent' => Array( 'OnSave' ),
'DoPrefix' => 'confs',
'DoSpecial' => '',
'DoEvent' => 'OnCreateCustomField',
),
),
'IDField' => 'SearchConfigId',
'TitlePresets' => Array(
'config_list' => Array('prefixes' => Array('confs_List'), 'format' => "!la_updating_config!"),
),
'TableName' => TABLE_PREFIX.'SearchConfig',
- 'ListSQLs' => Array(''=>'SELECT * FROM '.TABLE_PREFIX.'SearchConfig'),
+ 'ListSQLs' => Array(''=>'SELECT *, IF('.TABLE_PREFIX.'SearchConfig.CustomFieldId=0, 0, 1) AS IsCustom FROM '.TABLE_PREFIX.'SearchConfig'),
'ItemSQLs' => Array(''=>'SELECT * FROM '.TABLE_PREFIX.'SearchConfig'),
'SubTables' => Array(),
'Fields' => Array(
'TableName' => Array('type' => 'string','not_null' => '1','default' => ''),
'FieldName' => Array('type' => 'string','not_null' => '1','default' => ''),
'SimpleSearch' => Array('type' => 'int','not_null' => '1','default' => '0'),
'AdvancedSearch' => Array('type' => 'int','not_null' => '1','default' => '0'),
'Description' => Array('type' => 'string','default' => ''),
'DisplayName' => Array('type' => 'string','default' => ''),
'ModuleName' => Array('type' => 'string','default' => ''),
'ConfigHeader' => Array('type' => 'string','default' => ''),
'DisplayOrder' => Array('type' => 'int','not_null' => '1','default' => '0'),
'SearchConfigId' => Array('type' => 'int','not_null' => '1','default' => ''),
'Priority' => Array('type' => 'int','not_null' => '1','default' => '0'),
'FieldType' => Array('type' => 'string','not_null' => '1','default' => 'text'),
'ForeignField' => Array('type' => 'string','default' => ''),
'JoinClause' => Array('type' => 'string','default' => ''),
'IsWhere' => Array('type' => 'string','default' => ''),
'IsNotWhere' => Array('type' => 'string','default' => ''),
'ContainsWhere' => Array('type' => 'string','default' => ''),
'NotContainsWhere' => Array('type' => 'string','default' => ''),
'CustomFieldId' => Array('type' => 'int','not_null' => '1','default' => '0'),
),
'VirtualFields' => Array(),
-
+
+ 'ListSortings' => Array(
+ '' => Array(
+ 'ForcedSorting' => Array('IsCustom' => 'asc'),
+ 'Sorting' => Array('DisplayOrder' => 'asc'),
+ )
+ ),
+
'Grids' => Array(
'Default' => Array(
'Icons' => Array('default'=>'icon16_custom.gif'), // icons for each StatusField values, if no matches or no statusfield selected, then "default" icon is used
'Fields' => Array(
'TableName' => Array( 'title'=>'la_col_TableName', 'data_block' => 'grid_data_td'),
'FieldName' => Array( 'title'=>'la_col_FieldName', 'data_block' => 'grid_data_td' ),
'SimpleSearch' => Array( 'title'=>'la_col_SimpleSearch', 'data_block' => 'grid_data_td'),
),
),
),
);
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.1.2/core/units/config_search/config_search_config.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1.2.2
\ No newline at end of property
+1.1.2.3
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.1.2/core/units/config_search/config_search_tag_processor.php
===================================================================
--- branches/unlabeled/unlabeled-1.1.2/core/units/config_search/config_search_tag_processor.php (revision 1371)
+++ branches/unlabeled/unlabeled-1.1.2/core/units/config_search/config_search_tag_processor.php (revision 1372)
@@ -1,37 +1,49 @@
<?php
class ConfigSearchTagProcessor extends kDBTagProcessor {
function PrintList($params)
{
$list =& $this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix.'_List',$params);
$id_field = $this->Application->getUnitOption($this->Prefix,'IDField');
$prefix_special = $this->getPrefixSpecial();
if ( !($list->OriginalParams == $params) ) {
$this->Application->removeObject($prefix_special);
$list =& $this->Application->recallObject($prefix_special,$this->Prefix.'_List',$params);
}
$list->Query();
$o = '';
$list->GoFirst();
$block_params=$this->prepareTagParams($params);
$block_params['name']=$params['block'];
$block_params['pass_params']='true';
+ $prev_title="";
+
while (!$list->EOL())
{
+ $this_title=$list->Records[$list->CurrentIndex]['ConfigHeader'];
+
+ if ($this_title!=$prev_title){
+ $prev_title=$this_title;
+ $section_header_params=array();
+ $section_header_params['name']='config_section_header';
+ $section_header_params['title']=$this->Application->Phrase($this_title);
+ $o.= $this->Application->ParseBlock($section_header_params, 1);
+ }
+
$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;
}
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.1.2/core/units/config_search/config_search_tag_processor.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1.2.1
\ No newline at end of property
+1.1.2.2
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.1.2/core/units/config_search/config_search_event_handler.php
===================================================================
--- branches/unlabeled/unlabeled-1.1.2/core/units/config_search/config_search_event_handler.php (revision 1371)
+++ branches/unlabeled/unlabeled-1.1.2/core/units/config_search/config_search_event_handler.php (revision 1372)
@@ -1,108 +1,127 @@
<?php
class ConfigSearchEventHandler extends InpDBEventHandler {
/**
* Apply any custom changes to list's sql query
*
* @param kEvent $event
* @access protected
* @see OnListBuild
*/
function SetCustomQuery(&$event)
{
$object =& $event->getObject();
$module_owner=$this->Application->GetVar('module');
if ($module_owner===false) {
$module_owner=$this->myUrlDecode($this->Application->GetVar('confs_module'));
$this->Application->SetVar("module", $module_owner);
}
$section=$this->Application->GetVar('section');
if ($section===false){
$section=$this->myUrlDecode($this->Application->GetVar('confs_section'));
$this->Application->SetVar("section", $section);
}
$object->addFilter('module_filter', '%1$s.ModuleName = "'.$module_owner.'"');
- $object->AddOrderField('DisplayOrder', 'ASC');
+
}
function OnUpdate(&$event)
{
parent::OnUpdate($event);
$module_owner=$this->Application->GetVar('module');
$module_section=$this->Application->GetVar('section');
$conf_update = new kEvent( );
$conf_update->Init('conf');
$conf_update->Name = 'OnUpdate';
$conf_update->redirect = false;
$this->Application->HandleEvent($conf_update);
$event->redirect_params = Array('opener' => 's','confs_module'=>$this->myUrlEncode($module_owner),'confs_section'=>$this->myUrlEncode($module_section),'conf_module'=>$this->myUrlEncode($module_owner),'conf_section'=>$this->myUrlEncode($module_section),'pass'=>'all,confs,conf'); //stay!
}
function OnCancel(&$event)
{
parent::OnCancel($event);
$module_owner=$this->Application->GetVar('module');
$module_section=$this->Application->GetVar('section');
$event->redirect_params = Array('opener' => 's','confs_module'=>$this->myUrlEncode($module_owner),'confs_section'=>$this->myUrlEncode($module_section),'conf_module'=>$this->myUrlEncode($module_owner),'conf_section'=>$this->myUrlEncode($module_section),'pass'=>'all,confs,conf'); //stay!
}
function myUrlDecode($str){
$str=str_replace(';',':', $str);
$str=str_replace('!','-', $str);
return $str;
}
function myUrlEncode($str){
$str=str_replace('-', '!', $str);
$str=str_replace(':', ';', $str);
return $str;
}
/**
* Enter description here...
*
* @param kEvent $event
*/
function OnCreateCustomField(&$event)
{
$cf_object =& $event->MasterEvent->getObject();
- $item_id = $this->getPassedID($event->MasterEvent);
- if($item_id == '')
+ $is_new = $event->MasterEvent->getEventParam('IsNew');
+
+
+ $cf_search = array();
+ $cf_search['DisplayOrder'] = $cf_object->FieldValues['DisplayOrder'];
+ $cf_search['ElementType'] = $cf_object->FieldValues['ElementType'];
+ $cf_search['DisplayName'] = $cf_object->FieldValues['FieldLabel'];
+ $cf_search['FieldName'] = $cf_object->FieldValues['FieldName'];
+ $cf_search['Description'] = $cf_object->FieldValues['Prompt'];
+ $cf_search['ConfigHeader'] = $cf_object->FieldValues['Heading'];
+
+
+ $cf_search['TableName'] = "CustomField";
+ $cf_search['ModuleName'] = "In-Commerce";
+ $cf_search['ForeignField'] = "CustomMetaData.Value";
+ $cf_search['JoinClause'] = "{ForeignTable}.CustomFieldId={LocalTable}.CustomFieldId";
+
+ if($is_new)
{
- // only when creating new custom field
- $cf_search = array();
- $cf_search['CustomFieldId'] = $cf_object->FieldValues['CustomFieldId'];
- $cf_search['DisplayOrder'] = $cf_object->FieldValues['DisplayOrder'];
- $cf_search['ElementType'] = $cf_object->FieldValues['ElementType'];
- $cf_search['DisplayName'] = $cf_object->FieldValues['FieldLabel'];
- $cf_search['FieldName'] = $cf_object->FieldValues['FieldName'];
- $cf_search['Description'] = $cf_object->FieldValues['Prompt'];
-
- $cf_search['TableName'] = "CustomField";
- $cf_search['ModuleName'] = "In-Commerce";
- $cf_search['ForeignField'] = "CustomMetaData.Value";
- $cf_search['JoinClause'] = "{ForeignTable}.CustomFieldId={LocalTable}.CustomFieldId";
+ $live_id = $this->Conn->GetOne("SELECT CustomFieldId FROM ".TABLE_PREFIX."CustomField WHERE FieldName='".$cf_search['FieldName']."'");
+
+ $cf_search['CustomFieldId'] = $live_id;
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
- $cf_item = $event->getObject();
- $cf_item->SetFieldsFromHash($cf_search);
- $cf_item->Create();
+ $confs_item = $event->getObject();
+ $confs_item->SetFieldsFromHash($cf_search);
+ $confs_item->Create();
+ }else{
+
+
+ $cf_search['CustomFieldId'] = $cf_object->FieldValues['CustomFieldId'];
+
+ $search_config_id = $this->Conn->GetOne("SELECT SearchConfigId FROM ".TABLE_PREFIX."SearchConfig WHERE CustomFieldId='".$cf_object->FieldValues['CustomFieldId']."'");
+
+ $cf_search['SearchConfigId'] = $search_config_id;
+
+ $this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
+ $confs_item = $event->getObject();
+ $confs_item->SetFieldsFromHash($cf_search);
+ $confs_item->Update($search_config_id);
}
}
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.1.2/core/units/config_search/config_search_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1.2.4
\ No newline at end of property
+1.1.2.5
\ No newline at end of property

Event Timeline