Index: branches/unlabeled/unlabeled-1.3.4/core/admin_templates/incs/custom_blocks.tpl =================================================================== diff -u -r4367 -r4497 --- branches/unlabeled/unlabeled-1.3.4/core/admin_templates/incs/custom_blocks.tpl (.../custom_blocks.tpl) (revision 4367) +++ branches/unlabeled/unlabeled-1.3.4/core/admin_templates/incs/custom_blocks.tpl (.../custom_blocks.tpl) (revision 4497) @@ -1,46 +1,44 @@ - - " value="" /> - + + " /> + - - " id="" value="" /> - " id="verify_" value="" /> -  "> - + + + +   + - + - + - - + - + - - " name="" value=""> - " type="checkbox" id="_cb_" name="_cb_" class="" onclick="update_checkbox(this, document.getElementById(''))"> - + + "> + " type="checkbox" id="_cb_" name="_cb_" class="" onclick="update_checkbox(this, document.getElementById(''))"> + - - - + + + - - name="" id="_" value="">  - + + name="" id="_" value="">  + - - - + + + - + - - + " id="" value=""> + " id="" value=""> + - \ No newline at end of file +--> \ No newline at end of file Index: branches/unlabeled/unlabeled-1.2.4/core/units/config_search/config_search_tag_processor.php =================================================================== diff -u -r2326 -r4497 --- branches/unlabeled/unlabeled-1.2.4/core/units/config_search/config_search_tag_processor.php (.../config_search_tag_processor.php) (revision 2326) +++ branches/unlabeled/unlabeled-1.2.4/core/units/config_search/config_search_tag_processor.php (.../config_search_tag_processor.php) (revision 4497) @@ -2,48 +2,42 @@ class ConfigSearchTagProcessor extends kDBTagProcessor { + /** + * Prints list content using block specified + * + * @param Array $params + * @return string + * @access public + */ function PrintList($params) { - $list =& $this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix.'_List',$params); + $list =& $this->GetList($params); $id_field = $this->Application->getUnitOption($this->Prefix,'IDField'); - $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'] = $this->SelectParam($params, 'render_as,block'); + $block_params['pass_params'] = 'true'; - $block_params=$this->prepareTagParams($params); - $block_params['name']=$params['block']; - $block_params['pass_params']='true'; + $this->groupRecords($list->Records, 'ConfigHeader'); + $prev_heading = ''; - $prev_title=""; - - while (!$list->EOL()) + 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 + $block_params['show_heading'] = ($prev_heading != $list->GetDBField('ConfigHeader') ) ? 1 : 0; + $o.= $this->Application->ParseBlock($block_params, 1); + $prev_heading = $list->GetDBField('ConfigHeader'); $list->GoNext(); } - + $this->Application->SetVar( $this->getPrefixSpecial().'_id', ''); - return $o; + return $o; } - } ?> \ No newline at end of file Index: branches/unlabeled/unlabeled-1.3.4/core/units/config_search/config_search_event_handler.php =================================================================== diff -u -r4367 -r4497 --- branches/unlabeled/unlabeled-1.3.4/core/units/config_search/config_search_event_handler.php (.../config_search_event_handler.php) (revision 4367) +++ branches/unlabeled/unlabeled-1.3.4/core/units/config_search/config_search_event_handler.php (.../config_search_event_handler.php) (revision 4497) @@ -13,128 +13,76 @@ { $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); - } + // show only items that belong to selected module + $module = $this->Application->GetVar('module'); + $object->addFilter('module_filter', '%1$s.ModuleName = '.$this->Conn->qstr($module)); - $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.'"'); - + // don't show disabled search items + $object->addFilter('active_filter', '%1$s.SimpleSearch <> -1'); } + /** + * Enter description here... + * + * @param kEvent $event + */ function OnUpdate(&$event) { if (!$this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 0)) { parent::OnUpdate($event); + + $conf_update = new kEvent('conf:OnUpdate'); + $conf_update->redirect = false; + $this->Application->HandleEvent($conf_update); } - $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! - + $event->SetRedirectParam('opener', 's'); } 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! - - + $event->SetRedirectParam('opener', 's'); } - - 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(); - - $is_new = $event->MasterEvent->getEventParam('IsNew'); + $custom_field =& $event->MasterEvent->getObject(); + if ($custom_field->GetDBField('Type') == 6) { + // user custom fields are not searchable + return false; + } - // TODO: direct access to private attributes of object is prohibited - $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'] = 'la_Text_CustomFields'; + $sql = 'SELECT Module + FROM '.TABLE_PREFIX.'ItemTypes + WHERE ItemType = '.$custom_field->GetDBField('Type'); + $module_name = $this->Conn->GetOne($sql); - - $cf_search['TableName'] = "CustomField"; - $cf_search['ModuleName'] = "In-Commerce"; - $cf_search['ForeignField'] = "CustomMetaData.Value"; - $cf_search['JoinClause'] = "{ForeignTable}.ResourceId={LocalTable}.ResourceId"; + $object =& $event->getObject( Array('skip_autoload' => true) ); - if($is_new) - { - - $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); - $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); - + $custom_id = $custom_field->GetID(); + if ($custom_id) { + $object->Load($custom_id, 'CustomFieldId'); + $object->SetDBField('CustomFieldId', $custom_id); // for cloning only } - } - - /** - * Enter description here... - * - * @param kEvent $event - */ - function OnDeleteCustomField(&$event){ + + $cf_search = Array(); + $cf_search['DisplayOrder'] = $custom_field->GetDBField('DisplayOrder'); + $cf_search['ElementType'] = $custom_field->GetDBField('ElementType'); + $cf_search['DisplayName'] = $custom_field->GetDBField('FieldLabel'); + $cf_search['FieldName'] = $custom_field->GetDBField('FieldName'); + $cf_search['Description'] = $custom_field->GetDBField('Prompt'); + $cf_search['ConfigHeader'] = $custom_field->GetDBField('Heading'); // 'la_Text_CustomFields'; + $cf_search['TableName'] = 'CustomField'; + $cf_search['ModuleName'] = $module_name; + $object->SetFieldsFromHash($cf_search); - $custom_field_id =&$event->MasterEvent->getEventParam('id'); - $this->Conn->Query("DELETE FROM ".TABLE_PREFIX."SearchConfig WHERE CustomFieldId=".$custom_field_id); - + $result = $object->isLoaded() ? $object->Update() : $object->Create(); } } Index: branches/unlabeled/unlabeled-1.3.2/core/units/config_search/config_search_config.php =================================================================== diff -u -r2326 -r4497 --- branches/unlabeled/unlabeled-1.3.2/core/units/config_search/config_search_config.php (.../config_search_config.php) (revision 2326) +++ branches/unlabeled/unlabeled-1.3.2/core/units/config_search/config_search_config.php (.../config_search_config.php) (revision 4497) @@ -2,6 +2,31 @@ $config = Array( 'Prefix' => 'confs', + + 'Clones' => Array( + 'confs-cf' => Array( + 'Prefix' => 'confs-cf', + 'ParentPrefix' => 'cf', + 'ParentTableKey' => 'CustomFieldId', // linked field in master table + 'ForeignKey' => 'CustomFieldId', // linked field in subtable + 'AutoClone' => false, // because OnCreateCustomField hook does the stuff + 'AutoDelete' => true, + + 'Hooks' => Array( + Array( + 'Mode' => hAFTER, + 'Conditional' => false, + 'HookToPrefix' => 'cf', + 'HookToSpecial' => '*', + 'HookToEvent' => Array('OnAfterItemCreate', 'OnAfterItemUpdate'), + 'DoPrefix' => 'confs-cf', + 'DoSpecial' => '*', + 'DoEvent' => 'OnCreateCustomField', + ), + ), + ), + ), + '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'), @@ -12,47 +37,28 @@ 1 => 'id', 2 => 'page', 3 => 'event', - 4 => 'module', - 5 => 'section', ), - - 'Hooks' => Array( - Array( - 'Mode' => hAFTER, - 'Conditional' => false, - 'HookToPrefix' => 'cf', - 'HookToSpecial' => '', - 'HookToEvent' => Array( 'OnSave' ), - 'DoPrefix' => 'confs', - 'DoSpecial' => '', - 'DoEvent' => 'OnCreateCustomField', - ), - Array( - 'Mode' => hAFTER, - 'Conditional' => false, - 'HookToPrefix' => 'cf', - 'HookToSpecial' => '-item', - 'HookToEvent' => Array( 'OnAfterItemDelete' ), - 'DoPrefix' => 'confs', - 'DoSpecial' => '', - 'DoEvent' => 'OnDeleteCustomField', - ), - ), 'IDField' => 'SearchConfigId', 'TitlePresets' => Array( - 'config_list_search' => Array('prefixes' => Array('confs_List'), 'format' => "!la_updating_config!"), + 'config_list_search' => Array('prefixes' => Array('confs_List'), 'tag_params' => Array('confs' => Array('per_page' => -1) ), 'format' => "!la_updating_config!"), ), 'TableName' => TABLE_PREFIX.'SearchConfig', - 'ListSQLs' => Array(''=>'SELECT *, IF('.TABLE_PREFIX.'SearchConfig.CustomFieldId=0, 0, 1) AS IsCustom FROM '.TABLE_PREFIX.'SearchConfig'), + 'CalculatedFields' => Array( + '' => Array( + 'IsCustom' => 'IF(CustomFieldId IS NULL, 0, 1)', + ), + ), - 'ItemSQLs' => Array(''=>'SELECT * FROM '.TABLE_PREFIX.'SearchConfig'), + 'ListSQLs' => Array('' => 'SELECT %1$s.* %2$s FROM %1$s'), + + 'ItemSQLs' => Array('' => 'SELECT %1$s.* %2$s FROM %1$s'), - 'SubTables' => Array(), + 'Fields' => Array( 'TableName' => Array('type' => 'string','not_null' => '1','default' => ''), 'FieldName' => Array('type' => 'string','not_null' => '1','default' => ''), @@ -72,10 +78,12 @@ 'IsNotWhere' => Array('type' => 'string','default' => ''), 'ContainsWhere' => Array('type' => 'string','default' => ''), 'NotContainsWhere' => Array('type' => 'string','default' => ''), - 'CustomFieldId' => Array('type' => 'int','not_null' => '1','default' => '0'), + 'CustomFieldId' => Array('type' => 'int', 'default' => ''), ), - 'VirtualFields' => Array(), + 'VirtualFields' => Array( + 'IsCustom' => Array('type' => 'int', 'default' => 0), + ), 'ListSortings' => Array( '' => Array(