Index: trunk/kernel/admin_templates/popups/translator.tpl
===================================================================
diff -u -r1566 -r3299
--- trunk/kernel/admin_templates/popups/translator.tpl (.../translator.tpl) (revision 1566)
+++ trunk/kernel/admin_templates/popups/translator.tpl (.../translator.tpl) (revision 3299)
@@ -59,7 +59,7 @@
-
+
|
@@ -90,10 +90,15 @@
+
+
+
+
+
+
+
\ No newline at end of file
Index: trunk/kernel/units/general/cat_event_handler.php
===================================================================
diff -u -r3282 -r3299
--- trunk/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 3282)
+++ trunk/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 3299)
@@ -109,7 +109,7 @@
function OnPreSaveAndOpenTranslator(&$event)
{
$this->Application->SetVar('allow_translation', true);
- $object =& $event->getObject();
+ $object =& $event->getObject();
$this->RemoveRequiredFields($object);
$event->CallSubEvent('OnPreSave');
if ($event->status == erSUCCESS) {
@@ -127,27 +127,29 @@
}
$this->Application->SetVar('cv_id', $cv->getID() );
}
-
+
$event->redirect = $this->Application->GetVar('translator_t');
- $event->redirect_params = Array('pass'=>'all,trans,'.$this->Application->GetVar('translator_prefixes'),
+ $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
+ // 1. SAVE LAST TEMPLATE TO SESSION
$last_template = $this->Application->RecallVar('last_template');
preg_match('/index4\.php\|'.$this->Application->GetSID().'-(.*):/U', $last_template, $rets);
- $this->Application->StoreVar('return_template', $rets[1]);
-
+// $this->Application->StoreVar('return_template', $rets[1]);
+ $this->Application->StoreVar('return_template', $this->Application->GetVar('t'));
+
//$after_script = "openTranslator('".$event->getPrefixSpecial()."', '".$field."', '".$url."', '".$wnd_name."')";
}
-
+
// $this->Application->SetVar('after_script', $after_script);
-// $event->redirect = false;
+// $event->redirect = false;
}
-
+
/**
* Apply scope clause
*
@@ -188,7 +190,7 @@
$view_perm = 1;
$object->addFilter('perm_filter', 'perm.PermId = '.$view_perm);
-
+
if ( !$this->Application->IsAdmin() )
{
$groups = explode( ',', $this->Application->RecallVar('UserGroups') );
@@ -228,7 +230,7 @@
break;
} */
}
-
+
/**
* Adds calculates fields for item statuses
*
@@ -237,9 +239,9 @@
*/
function PrepareObject(&$object, &$event)
{
-
+
$property_mappings = $this->Application->getUnitOption($event->Prefix, 'ItemPropertyMappings');
-
+
$new_days_var = getArrayValue($property_mappings, 'NewDays');
if($new_days_var)
{
@@ -250,7 +252,7 @@
%1$s.NewItem
)');
}
-
+
$hot_limit_var = getArrayValue($property_mappings, 'HotLimit');
if($hot_limit_var)
{
@@ -262,10 +264,10 @@
%1$s.HotItem
)');
}
-
+
$votes2pop_var = getArrayValue($property_mappings, 'VotesToPop');
$rating2pop_var = getArrayValue($property_mappings, 'RatingToPop');
-
+
if($votes2pop_var && $rating2pop_var)
{
$object->addCalculatedField('IsPop', ' IF(%1$s.PopItem = 2,
@@ -277,13 +279,13 @@
%1$s.PopItem)');
}
}
-
+
function CalculateHotLimit(&$event)
{
$property_mappings = $this->Application->getUnitOption($event->Prefix, 'ItemPropertyMappings');
$hot_count_var = getArrayValue($property_mappings, 'HotCount');
$hot_limit_var = getArrayValue($property_mappings, 'HotLimit');
-
+
if($hot_count_var && $hot_limit_var)
{
$last_hot = $this->Application->ConfigValue($hot_count_var) - 1;
@@ -297,7 +299,7 @@
}
return 0;
}
-
+
/**
* Enter description here...
*
@@ -315,38 +317,38 @@
$object->SetDBField('Hits', $hits);
}
}
-
+
function OnAfterItemUpdate(&$event)
{
$this->CalculateHotLimit($event);
}
-
+
/**
- * Makes simple search for products
+ * Makes simple search for products
* based on keywords string
*
* @param kEvent $event
* @todo Change all hardcoded Products table & In-Commerce module usage to dynamic usage from item config !!!
*/
function OnSimpleSearch(&$event)
- {
+ {
if($this->Application->GetVar('INPORTAL_ON') && !($this->Application->GetVar('Action') == 'm_simple_search'))
{
return;
}
-
+
$event->redirect = false;
$search_table = TABLE_PREFIX.'ses_'.$this->Application->GetSID().'_'.TABLE_PREFIX.'Search';
-
+
$keywords = trim($this->Application->GetVar('keywords'));
if( !$this->Application->GetVar('INPORTAL_ON') )
{
$keywords = unhtmlentities($keywords);
}
-
+
$query_object =& $this->Application->recallObject('HTTPQuery');
$sql = 'SHOW TABLES LIKE "'.$search_table.'"';
-
+
if(!isset($query_object->Get['keywords']) &&
!isset($query_object->Post['keywords']) &&
$this->Conn->Query($sql))
@@ -358,68 +360,68 @@
$this->Conn->Query('DROP TABLE IF EXISTS '.$search_table);
$this->Application->SetVar('keywords_too_short', 1);
return; // if no or too short keyword entered, doing nothing
- }
-
+ }
+
$this->Application->StoreVar('keywords', $keywords);
-
+
$keywords = strtr($keywords, Array('%' => '\\%', '_' => '\\_'));
-
+
$event->setPseudoClass('_List');
$object =& $event->getObject();
$this->Application->SetVar($event->getPrefixSpecial().'_Page', 1);
$lang = $this->Application->GetVar('m_lang');
$product_table = $this->Application->getUnitOption('p', 'TableName');
-
+
$sql = ' SELECT * FROM '.$this->Application->getUnitOption('confs', 'TableName').'
WHERE ModuleName="In-Commerce"
AND SimpleSearch=1';
- $search_config = $this->Conn->Query($sql, 'FieldName');
+ $search_config = $this->Conn->Query($sql, 'FieldName');
$field_list = array_keys($search_config);
-
+
$join_clauses = Array();
-
+
// field processing
$weight_sum = 0;
foreach($field_list as $key => $field)
{
$options = $object->getFieldOptions($field);
$local_table = TABLE_PREFIX.$search_config[$field]['TableName'];
$weight_sum += $search_config[$field]['Priority']; // counting weight sum; used when making relevance clause
-
+
// processing multilingual fields
if($options['formatter'] == 'kMultiLanguage')
{
$field_list[$key] = 'l'.$lang.'_'.$field;
}
-
+
// processing fields from other tables
if($foreign_field = $search_config[$field]['ForeignField'])
- {
+ {
$exploded = explode(':', $foreign_field, 2);
if($exploded[0] == 'CALC')
{
unset($field_list[$key]);
continue; // ignoring having type clauses in simple search
/*$user_object =& $this->Application->recallObject('u');
$user_groups = $user_object->GetDBField('PortalUserId') ?
- implode(',', $this->Conn->GetCol(' SELECT GroupId
+ implode(',', $this->Conn->GetCol(' SELECT GroupId
FROM '.TABLE_PREFIX.'UserGroup
- WHERE PortalUserId='.$user_object->GetDBField('PortalUserId'))) : 0;
+ WHERE PortalUserId='.$user_object->GetDBField('PortalUserId'))) : 0;
$having_list[$key] = str_replace('{PREFIX}', TABLE_PREFIX, $exploded[1]);
$join_clause = str_replace('{PREFIX}', TABLE_PREFIX, $search_config[$field]['JoinClause']);
$join_clause = str_replace('{USER_GROUPS}', $user_groups, $join_clause);
$join_clause = ' LEFT JOIN '.$join_clause;
$join_clauses[] = $join_clause;*/
}
- else
+ else
{
$exploded = explode('.', $foreign_field);
$foreign_table = TABLE_PREFIX.$exploded[0];
-
+
$alias_counter++;
$alias = 't'.$alias_counter;
-
- $field_list[$key] = $alias.'.'.$exploded[1];
+
+ $field_list[$key] = $alias.'.'.$exploded[1];
$join_clause = str_replace('{ForeignTable}', $alias, $search_config[$field]['JoinClause']);
$join_clause = str_replace('{LocalTable}', $product_table, $join_clause);
if($search_config[$field]['CustomFieldId'])
@@ -430,18 +432,18 @@
ON '.$join_clause;
}
}
- else
+ else
{
// processing fields from local table
$field_list[$key] = $local_table.'.'.$field_list[$key];
}
}
-
- // keyword string processing
+
+ // keyword string processing
$normal_keywords = Array();
$plus_keywords = Array();
- $minus_keywords = Array();
-
+ $minus_keywords = Array();
+
for($i = 0; $i < strlen($keywords); $i++)
{
if(substr($keywords, $i, 1) == ' ') continue;
@@ -455,7 +457,7 @@
$keyword_end = strpos($keywords, '"', $i + 2);
$extra_skip = 2;
}
- else
+ else
{
$keyword_start = $i + 1;
$keyword_end = strpos($keywords, ' ', $i + 1);
@@ -470,7 +472,7 @@
$keyword_end = strpos($keywords, '"', $i + 2);
$extra_skip = 2;
}
- else
+ else
{
$keyword_start = $i + 1;
$keyword_end = strpos($keywords, ' ', $i + 1);
@@ -487,24 +489,24 @@
default:
$keyword_start = $i;
$keyword_end = strpos($keywords, ' ', $i + 1);
- $target_array =& $normal_keywords;
+ $target_array =& $normal_keywords;
}
-
+
if($keyword_end === false)
{
$keyword_end = strlen($keywords);
}
$keyword_length = $keyword_end - $keyword_start;
$keyword = substr($keywords, $keyword_start, $keyword_length);
-
- if(strlen($keyword) >= $this->Application->ConfigValue('Search_MinKeyword_Length'))
+
+ if(strlen($keyword) >= $this->Application->ConfigValue('Search_MinKeyword_Length'))
{
$target_array[] = addcslashes($keyword, '"');
}
-
+
$i += $keyword_length + $extra_skip;
}
-
+
// preparing conditions
$normal_conditions = Array();
$plus_conditions = Array();
@@ -522,16 +524,16 @@
foreach($field_list as $field)
{
$condition[] = $field.' NOT LIKE "%'.$keyword.'%" OR '.$field.' IS NULL';
- }
+ }
$minus_conditions[] = '('.implode(') AND (', $condition).')';
}
-
+
// building where clause
if($normal_conditions)
{
$where_clause = '('.implode(') OR (', $normal_conditions).')';
}
- else
+ else
{
$where_clause = '1';
}
@@ -546,7 +548,7 @@
$where_clause = $where_clause.' AND '.$product_table.'.Status=1';
if($this->Application->GetVar('Action') == 'm_simple_subsearch') // subsearch, In-portal
- {
+ {
if( $event->getEventParam('ResultIds') )
{
$where_clause .= ' AND '.$product_table.'.ResourceId IN ('.implode(',', $event->specificParams['ResultIds']).')';
@@ -559,17 +561,17 @@
$where_clause .= ' AND '.$product_table.'.ResourceId IN ('.implode(',', $event->MasterEvent->getEventParam('ResultIds')).')';
}
}
-
+
// building having clause
-
-
+
+
// making relevance clause
$positive_words = array_merge($normal_keywords, $plus_keywords);
$this->Application->StoreVar('highlight_keywords', serialize($positive_words));
$revelance_parts = Array();
reset($search_config);
foreach($field_list as $field)
- {
+ {
$config_elem = each($search_config);
$weight = $search_config[$field]['Priority'];
$revelance_parts[] = 'IF('.$field.' LIKE "%'.implode(' ', $positive_words).'%", '.$weight_sum.', 0)';
@@ -580,39 +582,39 @@
}
$rel_keywords = $this->Application->ConfigValue('SearchRel_DefaultKeyword_products') / 100;
$rel_pop = $this->Application->ConfigValue('SearchRel_DefaultPop_products') / 100;
- $rel_rating = $this->Application->ConfigValue('SearchRel_DefaultRating_products') / 100;
+ $rel_rating = $this->Application->ConfigValue('SearchRel_DefaultRating_products') / 100;
$relevance_clause = '('.implode(' + ', $revelance_parts).') / '.$weight_sum.' * '.$rel_keywords;
$relevance_clause .= ' + (Hits + 1) / (MAX(Hits) + 1) * '.$rel_pop;
$relevance_clause .= ' + (CachedRating + 1) / (MAX(CachedRating) + 1) * '.$rel_rating;
-
- // building final search query
+
+ // building final search query
if( !$this->Application->GetVar('INPORTAL_ON') )
{
$this->Conn->Query('DROP TABLE IF EXISTS '.$search_table); // erase old search table if clean k4 event
}
-
+
if($this->Conn->Query('SHOW TABLES LIKE "'.$search_table.'"'))
{
$select_intro = 'INSERT INTO '.$search_table.' (Relevance, ItemId, ResourceId, ItemType, EdPick) ';
}
- else
- {
+ else
+ {
$select_intro = 'CREATE TABLE '.$search_table.' AS ';
}
-
+
$sql = $select_intro.' SELECT '.$relevance_clause.' AS Relevance,
'.$product_table.'.ProductId AS ItemId,
'.$product_table.'.ResourceId,
11 AS ItemType,
'.$product_table.'.EditorsPick AS EdPick
- FROM '.$object->TableName.'
+ FROM '.$object->TableName.'
'.implode(' ', $join_clauses).'
WHERE '.$where_clause.'
GROUP BY '.$product_table.'.ProductId';
-
- $res = $this->Conn->Query($sql);
+
+ $res = $this->Conn->Query($sql);
}
-
+
/**
* Enter description here...
*
@@ -630,7 +632,7 @@
$event->setEventParam('ResultIds', $ids);
$event->CallSubEvent('OnSimpleSearch');
}
-
+
/**
* Enter description here...
*
@@ -644,10 +646,10 @@
{
return; // used when navigating by pages or changing sorting in search results
}
-
+
$this->Application->RemoveVar('keywords');
$this->Application->RemoveVar('Search_Keywords');
-
+
$sql = ' SELECT * FROM '.$this->Application->getUnitOption('confs', 'TableName').'
WHERE ModuleName="In-Commerce"
AND AdvancedSearch=1';
@@ -657,40 +659,40 @@
$object->SetPage(1);
$user_object =& $this->Application->recallObject('u');
$product_table = $this->Application->getUnitOption('p', 'TableName');
-
+
$keywords = $this->Application->GetVar('value');
$verbs = $this->Application->GetVar('verb');
$glues = $this->Application->GetVar('andor');
-
+
$and_conditions = Array();
$or_conditions = Array();
$and_having_conditions = Array();
$or_having_conditions = Array();
$join_clauses = Array();
$highlight_keywords = Array();
$relevance_parts = Array();
-
+
$condition_patterns = Array( 'any' => '%s LIKE %s',
'contains' => '%s LIKE %s',
'notcontains' => '(NOT (%1$s LIKE %2$s) OR %1$s IS NULL)',
'is' => '%s = %s',
'isnot' => '(%1$s != %2$s OR %1$s IS NULL)');
-
+
$alias_counter = 0;
$weight_sum = 0;
// processing fields and preparing conditions
foreach($search_config as $record)
{
$field = $record['FieldName'];
- $join_clause = '';
+ $join_clause = '';
$condition_mode = 'WHERE';
-
- // field processing
-
+
+ // field processing
+
$options = $object->getFieldOptions($field);
$local_table = TABLE_PREFIX.$record['TableName'];
$weight_sum += $record['Priority']; // counting weight sum; used when making relevance clause
-
+
// processing multilingual fields
if($options['formatter'] == 'kMultiLanguage')
{
@@ -700,36 +702,36 @@
{
$field_name = $field;
}
-
+
// processing fields from other tables
if($foreign_field = $record['ForeignField'])
{
$exploded = explode(':', $foreign_field, 2);
if($exploded[0] == 'CALC')
{
$user_groups = $user_object->GetDBField('PortalUserId') ?
- implode(',', $this->Conn->GetCol(' SELECT GroupId
+ implode(',', $this->Conn->GetCol(' SELECT GroupId
FROM '.TABLE_PREFIX.'UserGroup
- WHERE PortalUserId='.$user_object->GetDBField('PortalUserId'))) : 0;
+ WHERE PortalUserId='.$user_object->GetDBField('PortalUserId'))) : 0;
$field_name = str_replace('{PREFIX}', TABLE_PREFIX, $exploded[1]);
$join_clause = str_replace('{PREFIX}', TABLE_PREFIX, $record['JoinClause']);
$join_clause = str_replace('{USER_GROUPS}', $user_groups, $join_clause);
$join_clause = ' LEFT JOIN '.$join_clause;
-
+
$condition_mode = 'HAVING';
}
- else
+ else
{
$exploded = explode('.', $foreign_field);
$foreign_table = TABLE_PREFIX.$exploded[0];
-
+
$alias_counter++;
$alias = 't'.$alias_counter;
-
+
$field_name = $alias.'.'.$exploded[1];
$join_clause = str_replace('{ForeignTable}', $alias, $record['JoinClause']);
$join_clause = str_replace('{LocalTable}', $product_table, $join_clause);
-
+
if($record['CustomFieldId'])
{
$join_clause .= ' AND '.$alias.'.CustomFieldId='.$record['CustomFieldId'];
@@ -743,7 +745,7 @@
// processing fields from local table
$field_name = $local_table.'.'.$field_name;
}
-
+
$condition = '';
switch($record['FieldType'])
{
@@ -752,7 +754,7 @@
{
$keywords[$field] = unhtmlentities( $keywords[$field] );
}
-
+
if(strlen($keywords[$field]) >= $this->Application->ConfigValue('Search_MinKeyword_Length'))
{
$highlight_keywords[] = $keywords[$field];
@@ -808,7 +810,7 @@
case 'EditorsPick':
$condition = $product_table.'.EditorsPick = '.$keywords[$field];
break;
- }
+ }
}
break;
case 'range':
@@ -836,7 +838,7 @@
$time_mapping = Array('today' => $day_begin, 'yesterday' => ($day_begin - 86400));
$min_time = $time_mapping[$keywords[$field]];
}
- else
+ else
{
$time_mapping = Array( 'last_week' => 604800, 'last_month' => 2628000,
'last_3_months' => 7884000, 'last_6_months' => 15768000,
@@ -848,7 +850,7 @@
}
break;
}
-
+
if($condition)
{
if($join_clause)
@@ -880,32 +882,32 @@
}
}
}
-
+
$this->Application->StoreVar('highlight_keywords', serialize($highlight_keywords));
-
- // making relevance clause
+
+ // making relevance clause
if($relevance_parts)
{
$rel_keywords = $this->Application->ConfigValue('SearchRel_DefaultKeyword_products') / 100;
$rel_pop = $this->Application->ConfigValue('SearchRel_DefaultPop_products') / 100;
- $rel_rating = $this->Application->ConfigValue('SearchRel_DefaultRating_products') / 100;
+ $rel_rating = $this->Application->ConfigValue('SearchRel_DefaultRating_products') / 100;
$relevance_clause = '('.implode(' + ', $relevance_parts).') / '.$weight_sum.' * '.$rel_keywords;
$relevance_clause .= ' + (Hits + 1) / (MAX(Hits) + 1) * '.$rel_pop;
$relevance_clause .= ' + (CachedRating + 1) / (MAX(CachedRating) + 1) * '.$rel_rating;
}
- else
+ else
{
$relevance_clause = '0';
}
-
+
// building having clause
if($or_having_conditions)
{
$and_having_conditions[] = '('.implode(' OR ', $or_having_conditions).')';
}
$having_clause = implode(' AND ', $and_having_conditions);
$having_clause = $having_clause ? ' HAVING '.$having_clause : '';
-
+
// building where clause
if($or_conditions)
{
@@ -919,34 +921,34 @@
{
$where_clause = '1';
}
- else
+ else
{
$where_clause = '0';
$this->Application->SetVar('adv_search_error', 1);
}
}
$where_clause .= ' AND '.$product_table.'.Status = 1';
-
+
// building final search query
$search_table = TABLE_PREFIX.'ses_'.$this->Application->GetSID().'_'.TABLE_PREFIX.'Search';
-
+
$this->Conn->Query('DROP TABLE IF EXISTS '.$search_table);
-
+
$sql = ' CREATE TABLE '.$search_table.'
SELECT '.$relevance_clause.' AS Relevance,
'.$product_table.'.ProductId AS ItemId,
'.$product_table.'.ResourceId AS ResourceId,
11 AS ItemType,
'.$product_table.'.EditorsPick AS EdPick
- FROM '.$product_table.'
+ FROM '.$product_table.'
'.implode(' ', $join_clauses).'
WHERE '.$where_clause.'
GROUP BY '.$product_table.'.ProductId'.
$having_clause;
-
+
$res = $this->Conn->Query($sql);
}
-
+
/**
* Set's correct page for list
* based on data provided with event
@@ -959,17 +961,17 @@
{
// 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)
{
if( $this->Application->RewriteURLs() )
@@ -989,7 +991,7 @@
else {
$this->Application->StoreVar($event->getPrefixSpecial().'_Page', $page);
}
-
+
// $page = $this->Application->GetLinkedVar($event->getPrefixSpecial(true).'_Page', $event->getPrefixSpecial().'_Page');
if( !$event->getEventParam('skip_counting') )
{
@@ -1000,7 +1002,7 @@
$page = 1;
}
}
-
+
$object->SetPage($page);
}
Index: trunk/core/units/general/cat_event_handler.php
===================================================================
diff -u -r3282 -r3299
--- trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 3282)
+++ trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 3299)
@@ -109,7 +109,7 @@
function OnPreSaveAndOpenTranslator(&$event)
{
$this->Application->SetVar('allow_translation', true);
- $object =& $event->getObject();
+ $object =& $event->getObject();
$this->RemoveRequiredFields($object);
$event->CallSubEvent('OnPreSave');
if ($event->status == erSUCCESS) {
@@ -127,27 +127,29 @@
}
$this->Application->SetVar('cv_id', $cv->getID() );
}
-
+
$event->redirect = $this->Application->GetVar('translator_t');
- $event->redirect_params = Array('pass'=>'all,trans,'.$this->Application->GetVar('translator_prefixes'),
+ $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
+ // 1. SAVE LAST TEMPLATE TO SESSION
$last_template = $this->Application->RecallVar('last_template');
preg_match('/index4\.php\|'.$this->Application->GetSID().'-(.*):/U', $last_template, $rets);
- $this->Application->StoreVar('return_template', $rets[1]);
-
+// $this->Application->StoreVar('return_template', $rets[1]);
+ $this->Application->StoreVar('return_template', $this->Application->GetVar('t'));
+
//$after_script = "openTranslator('".$event->getPrefixSpecial()."', '".$field."', '".$url."', '".$wnd_name."')";
}
-
+
// $this->Application->SetVar('after_script', $after_script);
-// $event->redirect = false;
+// $event->redirect = false;
}
-
+
/**
* Apply scope clause
*
@@ -188,7 +190,7 @@
$view_perm = 1;
$object->addFilter('perm_filter', 'perm.PermId = '.$view_perm);
-
+
if ( !$this->Application->IsAdmin() )
{
$groups = explode( ',', $this->Application->RecallVar('UserGroups') );
@@ -228,7 +230,7 @@
break;
} */
}
-
+
/**
* Adds calculates fields for item statuses
*
@@ -237,9 +239,9 @@
*/
function PrepareObject(&$object, &$event)
{
-
+
$property_mappings = $this->Application->getUnitOption($event->Prefix, 'ItemPropertyMappings');
-
+
$new_days_var = getArrayValue($property_mappings, 'NewDays');
if($new_days_var)
{
@@ -250,7 +252,7 @@
%1$s.NewItem
)');
}
-
+
$hot_limit_var = getArrayValue($property_mappings, 'HotLimit');
if($hot_limit_var)
{
@@ -262,10 +264,10 @@
%1$s.HotItem
)');
}
-
+
$votes2pop_var = getArrayValue($property_mappings, 'VotesToPop');
$rating2pop_var = getArrayValue($property_mappings, 'RatingToPop');
-
+
if($votes2pop_var && $rating2pop_var)
{
$object->addCalculatedField('IsPop', ' IF(%1$s.PopItem = 2,
@@ -277,13 +279,13 @@
%1$s.PopItem)');
}
}
-
+
function CalculateHotLimit(&$event)
{
$property_mappings = $this->Application->getUnitOption($event->Prefix, 'ItemPropertyMappings');
$hot_count_var = getArrayValue($property_mappings, 'HotCount');
$hot_limit_var = getArrayValue($property_mappings, 'HotLimit');
-
+
if($hot_count_var && $hot_limit_var)
{
$last_hot = $this->Application->ConfigValue($hot_count_var) - 1;
@@ -297,7 +299,7 @@
}
return 0;
}
-
+
/**
* Enter description here...
*
@@ -315,38 +317,38 @@
$object->SetDBField('Hits', $hits);
}
}
-
+
function OnAfterItemUpdate(&$event)
{
$this->CalculateHotLimit($event);
}
-
+
/**
- * Makes simple search for products
+ * Makes simple search for products
* based on keywords string
*
* @param kEvent $event
* @todo Change all hardcoded Products table & In-Commerce module usage to dynamic usage from item config !!!
*/
function OnSimpleSearch(&$event)
- {
+ {
if($this->Application->GetVar('INPORTAL_ON') && !($this->Application->GetVar('Action') == 'm_simple_search'))
{
return;
}
-
+
$event->redirect = false;
$search_table = TABLE_PREFIX.'ses_'.$this->Application->GetSID().'_'.TABLE_PREFIX.'Search';
-
+
$keywords = trim($this->Application->GetVar('keywords'));
if( !$this->Application->GetVar('INPORTAL_ON') )
{
$keywords = unhtmlentities($keywords);
}
-
+
$query_object =& $this->Application->recallObject('HTTPQuery');
$sql = 'SHOW TABLES LIKE "'.$search_table.'"';
-
+
if(!isset($query_object->Get['keywords']) &&
!isset($query_object->Post['keywords']) &&
$this->Conn->Query($sql))
@@ -358,68 +360,68 @@
$this->Conn->Query('DROP TABLE IF EXISTS '.$search_table);
$this->Application->SetVar('keywords_too_short', 1);
return; // if no or too short keyword entered, doing nothing
- }
-
+ }
+
$this->Application->StoreVar('keywords', $keywords);
-
+
$keywords = strtr($keywords, Array('%' => '\\%', '_' => '\\_'));
-
+
$event->setPseudoClass('_List');
$object =& $event->getObject();
$this->Application->SetVar($event->getPrefixSpecial().'_Page', 1);
$lang = $this->Application->GetVar('m_lang');
$product_table = $this->Application->getUnitOption('p', 'TableName');
-
+
$sql = ' SELECT * FROM '.$this->Application->getUnitOption('confs', 'TableName').'
WHERE ModuleName="In-Commerce"
AND SimpleSearch=1';
- $search_config = $this->Conn->Query($sql, 'FieldName');
+ $search_config = $this->Conn->Query($sql, 'FieldName');
$field_list = array_keys($search_config);
-
+
$join_clauses = Array();
-
+
// field processing
$weight_sum = 0;
foreach($field_list as $key => $field)
{
$options = $object->getFieldOptions($field);
$local_table = TABLE_PREFIX.$search_config[$field]['TableName'];
$weight_sum += $search_config[$field]['Priority']; // counting weight sum; used when making relevance clause
-
+
// processing multilingual fields
if($options['formatter'] == 'kMultiLanguage')
{
$field_list[$key] = 'l'.$lang.'_'.$field;
}
-
+
// processing fields from other tables
if($foreign_field = $search_config[$field]['ForeignField'])
- {
+ {
$exploded = explode(':', $foreign_field, 2);
if($exploded[0] == 'CALC')
{
unset($field_list[$key]);
continue; // ignoring having type clauses in simple search
/*$user_object =& $this->Application->recallObject('u');
$user_groups = $user_object->GetDBField('PortalUserId') ?
- implode(',', $this->Conn->GetCol(' SELECT GroupId
+ implode(',', $this->Conn->GetCol(' SELECT GroupId
FROM '.TABLE_PREFIX.'UserGroup
- WHERE PortalUserId='.$user_object->GetDBField('PortalUserId'))) : 0;
+ WHERE PortalUserId='.$user_object->GetDBField('PortalUserId'))) : 0;
$having_list[$key] = str_replace('{PREFIX}', TABLE_PREFIX, $exploded[1]);
$join_clause = str_replace('{PREFIX}', TABLE_PREFIX, $search_config[$field]['JoinClause']);
$join_clause = str_replace('{USER_GROUPS}', $user_groups, $join_clause);
$join_clause = ' LEFT JOIN '.$join_clause;
$join_clauses[] = $join_clause;*/
}
- else
+ else
{
$exploded = explode('.', $foreign_field);
$foreign_table = TABLE_PREFIX.$exploded[0];
-
+
$alias_counter++;
$alias = 't'.$alias_counter;
-
- $field_list[$key] = $alias.'.'.$exploded[1];
+
+ $field_list[$key] = $alias.'.'.$exploded[1];
$join_clause = str_replace('{ForeignTable}', $alias, $search_config[$field]['JoinClause']);
$join_clause = str_replace('{LocalTable}', $product_table, $join_clause);
if($search_config[$field]['CustomFieldId'])
@@ -430,18 +432,18 @@
ON '.$join_clause;
}
}
- else
+ else
{
// processing fields from local table
$field_list[$key] = $local_table.'.'.$field_list[$key];
}
}
-
- // keyword string processing
+
+ // keyword string processing
$normal_keywords = Array();
$plus_keywords = Array();
- $minus_keywords = Array();
-
+ $minus_keywords = Array();
+
for($i = 0; $i < strlen($keywords); $i++)
{
if(substr($keywords, $i, 1) == ' ') continue;
@@ -455,7 +457,7 @@
$keyword_end = strpos($keywords, '"', $i + 2);
$extra_skip = 2;
}
- else
+ else
{
$keyword_start = $i + 1;
$keyword_end = strpos($keywords, ' ', $i + 1);
@@ -470,7 +472,7 @@
$keyword_end = strpos($keywords, '"', $i + 2);
$extra_skip = 2;
}
- else
+ else
{
$keyword_start = $i + 1;
$keyword_end = strpos($keywords, ' ', $i + 1);
@@ -487,24 +489,24 @@
default:
$keyword_start = $i;
$keyword_end = strpos($keywords, ' ', $i + 1);
- $target_array =& $normal_keywords;
+ $target_array =& $normal_keywords;
}
-
+
if($keyword_end === false)
{
$keyword_end = strlen($keywords);
}
$keyword_length = $keyword_end - $keyword_start;
$keyword = substr($keywords, $keyword_start, $keyword_length);
-
- if(strlen($keyword) >= $this->Application->ConfigValue('Search_MinKeyword_Length'))
+
+ if(strlen($keyword) >= $this->Application->ConfigValue('Search_MinKeyword_Length'))
{
$target_array[] = addcslashes($keyword, '"');
}
-
+
$i += $keyword_length + $extra_skip;
}
-
+
// preparing conditions
$normal_conditions = Array();
$plus_conditions = Array();
@@ -522,16 +524,16 @@
foreach($field_list as $field)
{
$condition[] = $field.' NOT LIKE "%'.$keyword.'%" OR '.$field.' IS NULL';
- }
+ }
$minus_conditions[] = '('.implode(') AND (', $condition).')';
}
-
+
// building where clause
if($normal_conditions)
{
$where_clause = '('.implode(') OR (', $normal_conditions).')';
}
- else
+ else
{
$where_clause = '1';
}
@@ -546,7 +548,7 @@
$where_clause = $where_clause.' AND '.$product_table.'.Status=1';
if($this->Application->GetVar('Action') == 'm_simple_subsearch') // subsearch, In-portal
- {
+ {
if( $event->getEventParam('ResultIds') )
{
$where_clause .= ' AND '.$product_table.'.ResourceId IN ('.implode(',', $event->specificParams['ResultIds']).')';
@@ -559,17 +561,17 @@
$where_clause .= ' AND '.$product_table.'.ResourceId IN ('.implode(',', $event->MasterEvent->getEventParam('ResultIds')).')';
}
}
-
+
// building having clause
-
-
+
+
// making relevance clause
$positive_words = array_merge($normal_keywords, $plus_keywords);
$this->Application->StoreVar('highlight_keywords', serialize($positive_words));
$revelance_parts = Array();
reset($search_config);
foreach($field_list as $field)
- {
+ {
$config_elem = each($search_config);
$weight = $search_config[$field]['Priority'];
$revelance_parts[] = 'IF('.$field.' LIKE "%'.implode(' ', $positive_words).'%", '.$weight_sum.', 0)';
@@ -580,39 +582,39 @@
}
$rel_keywords = $this->Application->ConfigValue('SearchRel_DefaultKeyword_products') / 100;
$rel_pop = $this->Application->ConfigValue('SearchRel_DefaultPop_products') / 100;
- $rel_rating = $this->Application->ConfigValue('SearchRel_DefaultRating_products') / 100;
+ $rel_rating = $this->Application->ConfigValue('SearchRel_DefaultRating_products') / 100;
$relevance_clause = '('.implode(' + ', $revelance_parts).') / '.$weight_sum.' * '.$rel_keywords;
$relevance_clause .= ' + (Hits + 1) / (MAX(Hits) + 1) * '.$rel_pop;
$relevance_clause .= ' + (CachedRating + 1) / (MAX(CachedRating) + 1) * '.$rel_rating;
-
- // building final search query
+
+ // building final search query
if( !$this->Application->GetVar('INPORTAL_ON') )
{
$this->Conn->Query('DROP TABLE IF EXISTS '.$search_table); // erase old search table if clean k4 event
}
-
+
if($this->Conn->Query('SHOW TABLES LIKE "'.$search_table.'"'))
{
$select_intro = 'INSERT INTO '.$search_table.' (Relevance, ItemId, ResourceId, ItemType, EdPick) ';
}
- else
- {
+ else
+ {
$select_intro = 'CREATE TABLE '.$search_table.' AS ';
}
-
+
$sql = $select_intro.' SELECT '.$relevance_clause.' AS Relevance,
'.$product_table.'.ProductId AS ItemId,
'.$product_table.'.ResourceId,
11 AS ItemType,
'.$product_table.'.EditorsPick AS EdPick
- FROM '.$object->TableName.'
+ FROM '.$object->TableName.'
'.implode(' ', $join_clauses).'
WHERE '.$where_clause.'
GROUP BY '.$product_table.'.ProductId';
-
- $res = $this->Conn->Query($sql);
+
+ $res = $this->Conn->Query($sql);
}
-
+
/**
* Enter description here...
*
@@ -630,7 +632,7 @@
$event->setEventParam('ResultIds', $ids);
$event->CallSubEvent('OnSimpleSearch');
}
-
+
/**
* Enter description here...
*
@@ -644,10 +646,10 @@
{
return; // used when navigating by pages or changing sorting in search results
}
-
+
$this->Application->RemoveVar('keywords');
$this->Application->RemoveVar('Search_Keywords');
-
+
$sql = ' SELECT * FROM '.$this->Application->getUnitOption('confs', 'TableName').'
WHERE ModuleName="In-Commerce"
AND AdvancedSearch=1';
@@ -657,40 +659,40 @@
$object->SetPage(1);
$user_object =& $this->Application->recallObject('u');
$product_table = $this->Application->getUnitOption('p', 'TableName');
-
+
$keywords = $this->Application->GetVar('value');
$verbs = $this->Application->GetVar('verb');
$glues = $this->Application->GetVar('andor');
-
+
$and_conditions = Array();
$or_conditions = Array();
$and_having_conditions = Array();
$or_having_conditions = Array();
$join_clauses = Array();
$highlight_keywords = Array();
$relevance_parts = Array();
-
+
$condition_patterns = Array( 'any' => '%s LIKE %s',
'contains' => '%s LIKE %s',
'notcontains' => '(NOT (%1$s LIKE %2$s) OR %1$s IS NULL)',
'is' => '%s = %s',
'isnot' => '(%1$s != %2$s OR %1$s IS NULL)');
-
+
$alias_counter = 0;
$weight_sum = 0;
// processing fields and preparing conditions
foreach($search_config as $record)
{
$field = $record['FieldName'];
- $join_clause = '';
+ $join_clause = '';
$condition_mode = 'WHERE';
-
- // field processing
-
+
+ // field processing
+
$options = $object->getFieldOptions($field);
$local_table = TABLE_PREFIX.$record['TableName'];
$weight_sum += $record['Priority']; // counting weight sum; used when making relevance clause
-
+
// processing multilingual fields
if($options['formatter'] == 'kMultiLanguage')
{
@@ -700,36 +702,36 @@
{
$field_name = $field;
}
-
+
// processing fields from other tables
if($foreign_field = $record['ForeignField'])
{
$exploded = explode(':', $foreign_field, 2);
if($exploded[0] == 'CALC')
{
$user_groups = $user_object->GetDBField('PortalUserId') ?
- implode(',', $this->Conn->GetCol(' SELECT GroupId
+ implode(',', $this->Conn->GetCol(' SELECT GroupId
FROM '.TABLE_PREFIX.'UserGroup
- WHERE PortalUserId='.$user_object->GetDBField('PortalUserId'))) : 0;
+ WHERE PortalUserId='.$user_object->GetDBField('PortalUserId'))) : 0;
$field_name = str_replace('{PREFIX}', TABLE_PREFIX, $exploded[1]);
$join_clause = str_replace('{PREFIX}', TABLE_PREFIX, $record['JoinClause']);
$join_clause = str_replace('{USER_GROUPS}', $user_groups, $join_clause);
$join_clause = ' LEFT JOIN '.$join_clause;
-
+
$condition_mode = 'HAVING';
}
- else
+ else
{
$exploded = explode('.', $foreign_field);
$foreign_table = TABLE_PREFIX.$exploded[0];
-
+
$alias_counter++;
$alias = 't'.$alias_counter;
-
+
$field_name = $alias.'.'.$exploded[1];
$join_clause = str_replace('{ForeignTable}', $alias, $record['JoinClause']);
$join_clause = str_replace('{LocalTable}', $product_table, $join_clause);
-
+
if($record['CustomFieldId'])
{
$join_clause .= ' AND '.$alias.'.CustomFieldId='.$record['CustomFieldId'];
@@ -743,7 +745,7 @@
// processing fields from local table
$field_name = $local_table.'.'.$field_name;
}
-
+
$condition = '';
switch($record['FieldType'])
{
@@ -752,7 +754,7 @@
{
$keywords[$field] = unhtmlentities( $keywords[$field] );
}
-
+
if(strlen($keywords[$field]) >= $this->Application->ConfigValue('Search_MinKeyword_Length'))
{
$highlight_keywords[] = $keywords[$field];
@@ -808,7 +810,7 @@
case 'EditorsPick':
$condition = $product_table.'.EditorsPick = '.$keywords[$field];
break;
- }
+ }
}
break;
case 'range':
@@ -836,7 +838,7 @@
$time_mapping = Array('today' => $day_begin, 'yesterday' => ($day_begin - 86400));
$min_time = $time_mapping[$keywords[$field]];
}
- else
+ else
{
$time_mapping = Array( 'last_week' => 604800, 'last_month' => 2628000,
'last_3_months' => 7884000, 'last_6_months' => 15768000,
@@ -848,7 +850,7 @@
}
break;
}
-
+
if($condition)
{
if($join_clause)
@@ -880,32 +882,32 @@
}
}
}
-
+
$this->Application->StoreVar('highlight_keywords', serialize($highlight_keywords));
-
- // making relevance clause
+
+ // making relevance clause
if($relevance_parts)
{
$rel_keywords = $this->Application->ConfigValue('SearchRel_DefaultKeyword_products') / 100;
$rel_pop = $this->Application->ConfigValue('SearchRel_DefaultPop_products') / 100;
- $rel_rating = $this->Application->ConfigValue('SearchRel_DefaultRating_products') / 100;
+ $rel_rating = $this->Application->ConfigValue('SearchRel_DefaultRating_products') / 100;
$relevance_clause = '('.implode(' + ', $relevance_parts).') / '.$weight_sum.' * '.$rel_keywords;
$relevance_clause .= ' + (Hits + 1) / (MAX(Hits) + 1) * '.$rel_pop;
$relevance_clause .= ' + (CachedRating + 1) / (MAX(CachedRating) + 1) * '.$rel_rating;
}
- else
+ else
{
$relevance_clause = '0';
}
-
+
// building having clause
if($or_having_conditions)
{
$and_having_conditions[] = '('.implode(' OR ', $or_having_conditions).')';
}
$having_clause = implode(' AND ', $and_having_conditions);
$having_clause = $having_clause ? ' HAVING '.$having_clause : '';
-
+
// building where clause
if($or_conditions)
{
@@ -919,34 +921,34 @@
{
$where_clause = '1';
}
- else
+ else
{
$where_clause = '0';
$this->Application->SetVar('adv_search_error', 1);
}
}
$where_clause .= ' AND '.$product_table.'.Status = 1';
-
+
// building final search query
$search_table = TABLE_PREFIX.'ses_'.$this->Application->GetSID().'_'.TABLE_PREFIX.'Search';
-
+
$this->Conn->Query('DROP TABLE IF EXISTS '.$search_table);
-
+
$sql = ' CREATE TABLE '.$search_table.'
SELECT '.$relevance_clause.' AS Relevance,
'.$product_table.'.ProductId AS ItemId,
'.$product_table.'.ResourceId AS ResourceId,
11 AS ItemType,
'.$product_table.'.EditorsPick AS EdPick
- FROM '.$product_table.'
+ FROM '.$product_table.'
'.implode(' ', $join_clauses).'
WHERE '.$where_clause.'
GROUP BY '.$product_table.'.ProductId'.
$having_clause;
-
+
$res = $this->Conn->Query($sql);
}
-
+
/**
* Set's correct page for list
* based on data provided with event
@@ -959,17 +961,17 @@
{
// 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)
{
if( $this->Application->RewriteURLs() )
@@ -989,7 +991,7 @@
else {
$this->Application->StoreVar($event->getPrefixSpecial().'_Page', $page);
}
-
+
// $page = $this->Application->GetLinkedVar($event->getPrefixSpecial(true).'_Page', $event->getPrefixSpecial().'_Page');
if( !$event->getEventParam('skip_counting') )
{
@@ -1000,7 +1002,7 @@
$page = 1;
}
}
-
+
$object->SetPage($page);
}
Index: trunk/kernel/admin_templates/incs/script.js
===================================================================
diff -u -r3187 -r3299
--- trunk/kernel/admin_templates/incs/script.js (.../script.js) (revision 3187)
+++ trunk/kernel/admin_templates/incs/script.js (.../script.js) (revision 3299)
@@ -6,7 +6,7 @@
var $ViewMenus = new Array();
var $form_prefix = 'kernel'; // results usage of kernel_form
if(!$fw_menus) var $fw_menus = new Array();
-
+
var $env = '';
var submitted = false;
var $init_made = true; // in case of double inclusion of script.js :)
@@ -43,7 +43,7 @@
if (isset(event)) {
set_hidden_field('events['+prefix_special+']', event);
}
-
+
if(isset(t)) set_hidden_field('t', t);
if( isset(form_action) )
{
@@ -66,7 +66,7 @@
$elem = $kf.elements[i];
$ret += $elem.id + ' = ' + $elem.value + "\n";
}
- alert($ret);
+ alert($ret);
}
function submit_kernel_form()
@@ -76,15 +76,15 @@
}
submitted = true;
var $form = document.getElementById($form_prefix+'_form');
-
+
if (typeof $form.onsubmit == "function") {
$form.onsubmit();
}
-
+
$form.submit();
$form.target = '';
$form.t.value = t;
-
+
window.setTimeout(function() {submitted = false}, 500);
}
@@ -152,7 +152,7 @@
}
function OpenUserSelector(extra_env,TargetForm,TargetField)
-{
+{
var $url = getScriptURL('admin/users/user_select.php');
$url += '&destform='+TargetForm+'&Selector=radio&destfield='+TargetField+'&IdField=Login';
if(extra_env.length>0) $url += extra_env;
@@ -190,41 +190,45 @@
function OpenHelp($help_link)
{
-
+
// $help_link.match('http://(.*).lv/in-commerce/admin(.*)');
// alert(RegExp.$2);
openwin($help_link,'HelpPopup',750,400);
}
// in-portal compatibility functions: end
-function PreSaveAndOpenTranslator(prefix,field,t,$width,$height)
+function PreSaveAndOpenTranslator(prefix,field,t,multi_line,$width,$height)
{
if(!isset($window_name)) var $window_name = 'select_'+t.replace(/(\/|-)/g, '_');
if(!isset($width)) $width=750;
if(!isset($height)) $height=400;
+ if(!isset(multi_line)) multi_line=0;
openwin('',$window_name,$width,$height);
set_hidden_field('translator_wnd_name', $window_name);
set_hidden_field('translator_field', field);
set_hidden_field('translator_t', t);
set_hidden_field('translator_prefixes', prefix);
+ set_hidden_field('translator_multi_line', multi_line);
document.kernel_form.target=$window_name;
-
+
var split_prefix = prefix.split(',');
submit_event(split_prefix[0],'OnPreSaveAndOpenTranslator');
}
-function PreSaveAndOpenTranslatorCV(prefix,field,t,cf_id)
+function PreSaveAndOpenTranslatorCV(prefix,field,t,cf_id,multi_line)
{
if(!isset($window_name)) var $window_name = 'select_'+t.replace(/(\/|-)/g, '_');
+ if(!isset(multi_line)) multi_line=0;
openwin('',$window_name,750,400);
set_hidden_field('translator_wnd_name', $window_name);
set_hidden_field('translator_field', field);
set_hidden_field('translator_t', t);
set_hidden_field('translator_prefixes', prefix);
set_hidden_field('translator_cf_id', cf_id);
+ set_hidden_field('translator_multi_line', multi_line);
document.kernel_form.target=$window_name;
-
+
var split_prefix = prefix.split(',');
submit_event(split_prefix[0],'OnPreSaveAndOpenTranslator');
}
@@ -235,7 +239,7 @@
set_hidden_field('trans_prefix', prefix);
set_hidden_field('trans_field', field);
set_hidden_field('events[trans]', 'OnLoad');
-
+
var $regex = new RegExp('(.*)\?env=' + document.getElementById('sid').value + '-(.*?):(.*)');
var $t = $regex.exec(url)[2];
document.kernel_form.target = wnd;
@@ -299,7 +303,7 @@
function std_delete_items(prefix_special)
{
- if (inpConfirm('Are you sure you want to delete selected items?'))
+ if (inpConfirm('Are you sure you want to delete selected items?'))
submit_event(prefix_special,'OnMassDelete')
}
@@ -308,35 +312,35 @@
function set_hidden_field($field_id, $value)
{
// alert('form: '+$form_prefix+'_form');
-
+
var $kf = document.getElementById($form_prefix+'_form');
var $field = $kf.elements[$field_id];
if($field)
{
$field.value = $value;
- return true;
+ return true;
}
-
+
$field = document.createElement('INPUT');
$field.type = 'hidden';
$field.name = $field_id;
$field.id = $field_id;
$field.value = $value;
-
+
$kf.appendChild($field);
return false;
}
function get_hidden_field($field)
{
- var $kf = document.getElementById($form_prefix+'_form');
+ var $kf = document.getElementById($form_prefix+'_form');
return $kf.elements[$field] ? $kf.elements[$field].value : false;
}
function search($prefix_special, $grid_name)
{
set_hidden_field('grid_name', $grid_name);
- submit_event($prefix_special,'OnSearch');
+ submit_event($prefix_special,'OnSearch');
}
function search_reset($prefix_special, $grid_name)
@@ -385,10 +389,10 @@
var $img = $toolbar.GetButtonImage($button_id);
var $pos_x = getRealLeft($img) - ((document.all) ? 6 : -2);
var $pos_y = getRealTop($img) + 32;
-
- var $prefix_special = '';
+
+ var $prefix_special = '';
window.triedToWriteMenus = false;
-
+
if($ViewMenus.length == 1)
{
$prefix_special = $ViewMenus[$ViewMenus.length-1];
@@ -405,14 +409,14 @@
$fw_menus[$prefix_special+'_view_menu']();
}
$Menus['mixed'] = new Menu('ViewMenu_mixed');
-
+
// merge menus into new one
for(var $i in $ViewMenus)
{
$prefix_special = $ViewMenus[$i];
$Menus['mixed'].addMenuItem( $Menus[$prefix_special+'_view_menu'] );
}
-
+
$Menus['mixed'].writeMenus('MenuContainers[mixed]');
window.FW_showMenu($Menus['mixed'], $pos_x, $pos_y);
}
@@ -449,7 +453,7 @@
function redirect($url)
{
- window.location.href = $url;
+ window.location.href = $url;
}
function update_checkbox_options($cb_mask, $hidden_id)
Index: trunk/core/units/translator/translator_config.php
===================================================================
diff -u -r1566 -r3299
--- trunk/core/units/translator/translator_config.php (.../translator_config.php) (revision 1566)
+++ trunk/core/units/translator/translator_config.php (.../translator_config.php) (revision 3299)
@@ -11,38 +11,39 @@
'QueryString' => Array(
1 => 'prefix',
2 => 'field',
- 3 => 'event',
+ 3 => 'multi_line',
+ 4 => 'event',
),
'IDField' => 'N/A',
-
+
'TitleField' => 'Translator',
-
+
'TitlePhrase' => 'la_text_Translation',
-
+
'TitlePresets' => Array(
- 'default' => Array(
+ 'default' => Array(
'new_status_labels' => Array('trans'=>'!la_title_Adding_Order!'),
'edit_status_labels' => Array('trans'=>'!la_title_Editing_Order!'),
'new_titlefield' => Array('trans'=>'!la_title_New_Order!'),
),
-
+
'trans_edit' => Array('prefixes' => Array('trans'), 'format' => '!la_title_EditingTranslation!'),
-
+
),
/*
'TableName' => 'N/A',
-
+
'ListSQLs' => Array( ''=>'SELECT * FROM %s',),
-
+
'ItemSQLs' => Array( ''=>'SELECT * FROM %s',),*/
-
+
'Fields' => Array(
),
-
+
'VirtualFields' => Array(
'Original' => Array(),
'Language' => Array(),
- 'SwitchLanguage' => Array('formatter'=>'kOptionsFormatter',
+ 'SwitchLanguage' => Array('formatter'=>'kOptionsFormatter',
'options_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'Language', 'option_key_field'=>'LanguageId','option_title_field'=>'PackName'),
'Translation' => Array(),
),
Index: trunk/core/kernel/db/db_event_handler.php
===================================================================
diff -u -r3282 -r3299
--- trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 3282)
+++ trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 3299)
@@ -2,9 +2,9 @@
define('EH_CUSTOM_PROCESSING_BEFORE',1);
define('EH_CUSTOM_PROCESSING_AFTER',2);
-
+
/**
- * Note:
+ * Note:
* 1. When adressing variables from submit containing
* Prefix_Special as part of their name use
* $event->getPrefixSpecial(true) instead of
@@ -29,15 +29,15 @@
*
*/
class kDBEventHandler extends kEventHandler {
-
+
/**
* Description
*
* @var kDBConnection
* @access public
*/
var $Conn;
-
+
/**
* Adds ability to address db connection
*
@@ -49,15 +49,15 @@
parent::kBase();
$this->Conn =& $this->Application->GetADODBConnection();
}
-
+
function mapEvents()
{
$events_map = Array('OnRemoveFilters' => 'FilterAction',
'OnApplyFilters' => 'FilterAction');
- $this->eventMethods = array_merge($this->eventMethods, $events_map);
+ $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
@@ -71,21 +71,21 @@
function getPassedID(&$event)
{
//$ret = $this->Application->GetLinkedVar($event->getPrefixSpecial(true).'_id', $event->getPrefixSpecial().'_id');
-
+
// ?? We don't need to store selected id in session, as long as we have pass=all by default, which
// means that main item id will be passed to all sub-item screens by default
// another prove of that is that sub-items relay on main item '_mode' = 't' for switching to temp tables
- // Also having id in session raised problems with the id of deleted item stuck in session
-
-
+ // Also having id in session raised problems with the id of deleted item stuck in session
+
+
// 1. get id from post (used in admin)
$ret = $this->Application->GetVar($event->getPrefixSpecial(true).'_id');
if($ret) return $ret;
-
+
// 2. get id from env (used in front)
$ret = $this->Application->GetVar($event->getPrefixSpecial().'_id');
if($ret) return $ret;
-
+
// recall selected ids array and use the first one
$ids=$this->Application->GetVar($event->getPrefixSpecial().'_selected_ids');
if ($ids != '') {
@@ -98,28 +98,28 @@
}
return $ret;
}
-
+
/**
* Prepares and stores selected_ids string
* in Session and Application Variables
- * by getting all checked ids from grid plus
+ * by getting all checked ids from grid plus
* id passed in get/post as prefix_id
*
* @param kEvent $event
*/
function StoreSelectedIDs(&$event)
{
$ret = Array();
-
+
// May be we don't need this part: ?
$passed = $this->Application->GetVar($event->getPrefixSpecial(true).'_id');
if($passed !== false && $passed != '')
{
array_push($ret, $passed);
}
-
+
$ids = Array();
-
+
// get selected ids from post & save them to session
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if($items_info)
@@ -131,12 +131,12 @@
}
//$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);
@@ -147,7 +147,7 @@
}
$this->Application->SetVar($event->getPrefixSpecial(true).'_id', $first_id);
}
-
+
/**
* Returns stored selected ids as an array
*
@@ -158,10 +158,10 @@
{
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 -
+ * Could be used while creating/editing single item -
* meaning on any edit form, except grid edit
*
* @param kEvent $event
@@ -172,7 +172,7 @@
$field_values = $items_info ? array_shift($items_info) : Array();
return $field_values;
}
-
+
/**
* Removes any information about current/selected ids
* from Application variables and Session
@@ -183,20 +183,20 @@
{
$prefix_special = $event->getPrefixSpecial();
$ids = $this->Application->RecallVar($prefix_special.'_selected_ids');
- $event->setEventParam('ids', $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
*
@@ -208,24 +208,24 @@
{
$object->Configure();
$this->PrepareObject($object, $event);
-
+
$live_table = $event->getEventParam('live_table');
-
+
if( $this->UseTempTables($event) && !$live_table )
{
$object->SwitchToTemp();
}
-
+
// This strange constuction creates hidden field for storing event name in form submit
// It pass SaveEvent to next screen, otherwise after unsuccsefull create it will try to update rather than create
$current_event = $this->Application->GetVar($event->Prefix_Special.'_event');
// $this->Application->setEvent($event->Prefix_Special, $current_event);
$this->Application->setEvent($event->Prefix_Special, '');
-
+
$save_event = $this->UseTempTables($event) && $this->Application->GetTopmostPrefix($event->Prefix) == $event->Prefix ? 'OnSave' : 'OnUpdate';
$this->Application->SetVar($event->Prefix_Special.'_SaveEvent',$save_event);
}
-
+
/**
* Builds item (loads if needed)
*
@@ -236,47 +236,47 @@
{
$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)
*
@@ -288,7 +288,7 @@
{
return $this->UseTempTables($event) ? kTempTablesHandler::GetTempTablePrefix().TABLE_PREFIX : TABLE_PREFIX;
}
-
+
function LoadItem(&$event)
{
$object =& $event->getObject();
@@ -303,7 +303,7 @@
$object->setID($id);
}
}
-
+
/**
* Builds list
*
@@ -313,28 +313,28 @@
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
*
@@ -350,7 +350,7 @@
}
return $special;
}
-
+
/**
* Apply any custom changes to list's sql query
*
@@ -360,9 +360,9 @@
*/
function SetCustomQuery(&$event)
{
-
+
}
-
+
/**
* Set's new perpage for grid
*
@@ -371,9 +371,9 @@
function OnSetPerPage(&$event)
{
$per_page = $this->Application->GetVar($event->getPrefixSpecial(true).'_PerPage');
- $this->Application->StoreVar( $event->getPrefixSpecial().'_PerPage', $per_page );
+ $this->Application->StoreVar( $event->getPrefixSpecial().'_PerPage', $per_page );
}
-
+
/**
* Set's correct page for list
* based on data provided with event
@@ -386,11 +386,11 @@
{
// 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');
@@ -401,7 +401,7 @@
else {
$this->Application->StoreVar($event->getPrefixSpecial().'_Page', $page);
}
-
+
// $page = $this->Application->GetLinkedVar($event->getPrefixSpecial(true).'_Page', $event->getPrefixSpecial().'_Page');
if( !$event->getEventParam('skip_counting') )
{
@@ -412,45 +412,45 @@
$page = 1;
}
}
-
+
$object->SetPage($page);
}
function getPerPage(&$event)
{
$per_page = $event->getEventParam('per_page');
- $config_mapping = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping');
-
+ $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' :
+ case 'default' :
$per_page = $this->Application->ConfigValue($config_mapping['PerPage']);
break;
}
}
-
+
if(!$per_page)
{
$per_page_var = $event->getPrefixSpecial().'_PerPage';
$per_page = $this->Application->RecallVar($per_page_var);
if(!$per_page)
{
-
+
if ( $config_mapping ) {
$per_page = $this->Application->ConfigValue($config_mapping['PerPage']);
}
if(!$per_page) $per_page = 10;
}
}
-
+
return $per_page;
}
-
+
/**
* Set's correct sorting for list
* based on data provided with event
@@ -463,33 +463,33 @@
{
$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');
+ $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);
+ $object->AddOrderField($by, $dir);
}
-
+
if ($sorting_configs && isset ($sorting_configs['DefaultSorting1Field'])){
- $list_sortings[$sorting_prefix]['Sorting'] = Array(
+ $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 ( !$cur_sort1 || !$cur_sort1_dir)
{
if ( $sorting = getArrayValue($list_sortings, $sorting_prefix, 'Sorting') ) {
reset($sorting);
@@ -501,7 +501,7 @@
}
}
}
-
+
if ( $forced_sorting = getArrayValue($list_sortings, $sorting_prefix, 'ForcedSorting') ) {
foreach ($forced_sorting as $field => $dir) {
$object->AddOrderField($field, $dir);
@@ -518,7 +518,7 @@
}
}
-
+
/**
* Add filters found in session
*
@@ -527,7 +527,7 @@
function AddFilters(&$event)
{
$object =& $event->getObject();
-
+
$search_filter = $this->Application->RecallVar($event->getPrefixSpecial().'_search_filter');
if($search_filter)
{
@@ -536,21 +536,21 @@
{
$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)
@@ -566,7 +566,7 @@
}
}
}
-
+
/**
* Set's new sorting for list
*
@@ -579,7 +579,7 @@
$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';
@@ -596,7 +596,7 @@
$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
*
@@ -611,12 +611,12 @@
$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)
*
@@ -629,7 +629,7 @@
$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
@@ -644,7 +644,7 @@
$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
@@ -659,19 +659,19 @@
$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 */
-
+
+/* Edit Events mostly used in Admin */
+
/**
* Creates new kDBItem
*
@@ -682,16 +682,16 @@
{
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject();
-
+
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if($items_info)
{
list($id,$field_values) = each($items_info);
$object->SetFieldsFromHash($field_values);
}
-
+
$this->customProcessing($event,'before');
-
+
//look at kDBItem' Create for ForceCreateId description, it's rarely used and is NOT set by default
if( $object->Create($event->getEventParam('ForceCreateId')) )
{
@@ -708,7 +708,7 @@
$object->setID($id);
}
}
-
+
/**
* Updates kDBItem
*
@@ -719,7 +719,7 @@
{
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject();
-
+
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if($items_info)
{
@@ -733,17 +733,17 @@
$this->customProcessing($event, 'after');
$event->status=erSUCCESS;
}
- else
+ else
{
$event->status=erFAIL;
$event->redirect=false;
break;
}
- }
+ }
}
$event->redirect_params = Array('opener'=>'u');
}
-
+
/**
* Delete's kDBItem object
*
@@ -765,7 +765,7 @@
$event->redirect = false;
}
}
-
+
/**
* Prepares new kDBItem object
*
@@ -778,14 +778,14 @@
$object =& $event->getObject();
$object->setID(0);
$this->Application->SetVar($event->Prefix_Special.'_SaveEvent','OnCreate');
-
+
$table_info = $object->getLinkedInfo();
$object->SetDBField($table_info['ForeignKey'], $table_info['ParentId']);
-
+
$this->Application->setUnitOption($event->Prefix,'AutoLoad',true);
$event->redirect = false;
}
-
+
/**
* Cancel's kDBItem Editing/Creation
*
@@ -796,8 +796,8 @@
{
$event->redirect_params = Array('opener'=>'u');
}
-
-
+
+
/**
* Deletes all selected items.
* Automatically recurse into sub-items using temp handler, and deletes sub-items
@@ -810,24 +810,24 @@
if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 0)) {
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
@@ -837,13 +837,13 @@
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)
@@ -856,25 +856,25 @@
if ($event->status==erSUCCESS) {
$skip_master=false;
$temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
-
+
// newly created item
/*if($this->getPassedID($event) == 0)
{
$master_id = $temp->CopyMasterToOriginal();
$temp->UpdateForeignKeys($master_id); // save linked field values
$skip_master = true; //we've already copied master table to get the id
}*/
-
+
if (!$this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 0)) {
$temp->SaveEdit($skip_master);
}
$this->clearSelectedIDs($event);
-
+
$event->redirect_params = Array('opener'=>'u');
$this->Application->RemoveVar($event->getPrefixSpecial().'_modified');
}
}
-
+
/**
* Cancels edit
* Removes all temp tables and clears selected ids
@@ -885,12 +885,12 @@
{
$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');
+ $this->Application->RemoveVar($event->getPrefixSpecial().'_modified');
}
-
+
/**
* Saves edited item into temp table
* If there is no id, new item is created in temp table
@@ -913,10 +913,10 @@
}
return;
}
-
+
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject();
-
+
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if($items_info)
{
@@ -929,18 +929,18 @@
{
$event->status=erSUCCESS;
}
- else
+ else
{
$event->status=erFAIL;
$event->redirect=false;
break;
}
- }
+ }
}
}
-
+
/**
- * Saves edited item in temp table and loads
+ * Saves edited item in temp table and loads
* item with passed id in current template
* Used in Prev/Next buttons
*
@@ -953,7 +953,7 @@
$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
@@ -967,7 +967,7 @@
$event->redirect=$this->Application->GetVar($event->getPrefixSpecial(true).'_GoTab');
}
}
-
+
/**
* Saves editable list and goes to passed tab,
* by redirecting to it with empty event
@@ -982,26 +982,26 @@
$event->redirect=$this->Application->GetVar($event->getPrefixSpecial(true).'_GoTab');
}
}
-
+
/**
* Prepare temp tables for creating new item
- * but does not create it. Actual create is
+ * but does not create it. Actual create is
* done in OnPreSaveCreated
*
* @param kEvent $event
*/
function OnPreCreate(&$event)
{
$this->clearSelectedIDs($event);
-
+
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject();
-
+
$temp =& $this->Application->recallObject($event->Prefix.'_TempHandler', 'kTempTablesHandler');
$temp->PrepareEdit();
-
+
$object->setID(0);
-
+
$event->redirect=false;
}
@@ -1014,15 +1014,15 @@
function OnPreSaveCreated(&$event)
{
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
-
+
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if($items_info) $field_values = array_shift($items_info);
-
+
$object =& $event->getObject();
$object->SetFieldsFromHash($field_values);
-
+
$this->customProcessing($event, 'before');
-
+
if( $object->Create() )
{
$this->customProcessing($event, 'after');
@@ -1035,13 +1035,13 @@
$event->redirect=false;
$object->setID(0);
}
-
+
}
-
-/* End of Edit events */
-
+
+/* 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
@@ -1051,9 +1051,9 @@
*/
function OnBeforeItemLoad(&$event)
{
-
+
}
-
+
/**
* Occurse after loading item, 'id' parameter
* allows to get id of item that was loaded
@@ -1063,9 +1063,9 @@
*/
function OnAfterItemLoad(&$event)
{
-
+
}
-
+
/**
* Occurse before creating item
*
@@ -1074,9 +1074,9 @@
*/
function OnBeforeItemCreate(&$event)
{
-
+
}
-
+
/**
* Occurse after creating item
*
@@ -1085,9 +1085,9 @@
*/
function OnAfterItemCreate(&$event)
{
-
+
}
-
+
/**
* Occurse before updating item
*
@@ -1096,9 +1096,9 @@
*/
function OnBeforeItemUpdate(&$event)
{
-
+
}
-
+
/**
* Occurse after updating item
*
@@ -1107,9 +1107,9 @@
*/
function OnAfterItemUpdate(&$event)
{
-
+
}
-
+
/**
* Occurse before deleting item, id of item beeing
* deleted is stored as 'id' event param
@@ -1119,9 +1119,9 @@
*/
function OnBeforeItemDelete(&$event)
{
-
+
}
-
+
/**
* Occurse after deleting item, id of deleted item
* is stored as 'id' param of event
@@ -1131,19 +1131,19 @@
*/
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
@@ -1152,21 +1152,21 @@
*/
function OnAfterCopyToTemp(&$event)
{
-
+
}
-
+
/**
- * Occures before an item is deleted from live table when copying from temp
+ * 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
@@ -1175,21 +1175,21 @@
*/
function OnBeforeCopyToLive(&$event)
{
-
+
}
-
+
/**
* !!! NOT FULLY IMPLEMENTED - SEE TEMP HANDLER COMMENTS (search by event name)!!!
- * Occures after an item has been copied to live table
+ * 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
@@ -1199,9 +1199,9 @@
*/
function OnBeforeClone(&$event)
{
-
+
}
-
+
/**
* Occures after an item has been cloned
* Id of newly created item is passed as event' 'id' param
@@ -1210,9 +1210,9 @@
*/
function OnAfterClone(&$event)
{
-
+
}
-
+
/**
* Enter description here...
*
@@ -1226,17 +1226,17 @@
{
$field = $search_field.'_'.$type;
$lang_current =& $this->Application->recallObject('lang.current');
-
+
$object =& $event->getObject();
$dt_separator = getArrayValue( $object->GetFieldOptions($field_name), '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('TimeFormat'), $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)
@@ -1246,8 +1246,8 @@
}
return $value_ts;
}
-
-
+
+
/**
* Ensures that popup will be closed automatically
* and parent window will be refreshed with template
@@ -1259,17 +1259,17 @@
function finalizePopup(&$event, $main_prefix, $t)
{
$event->redirect = 'incs/close_popup';
-
+
// 2. substitute opener
$opener_stack = $this->Application->RecallVar('opener_stack');
$opener_stack = $opener_stack ? unserialize($opener_stack) : Array();
//array_pop($opener_stack);
-
+
$new_level = 'index4.php|'.ltrim($this->Application->BuildEnv($t, Array('m_opener' => 'u'), 'all'), ENV_VAR_NAME.'=');
array_push($opener_stack,$new_level);
$this->Application->StoreVar('opener_stack',serialize($opener_stack));
}
-
+
/**
* Create search filters based on search query
*
@@ -1280,19 +1280,19 @@
{
$event->setPseudoClass('_List');
$object =& $event->getObject();
-
+
$keyword = $this->Application->GetVar( $event->getPrefixSpecial(true).'_search_keyword');
$this->Application->StoreVar( $event->getPrefixSpecial().'_search_keyword', $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)
@@ -1309,30 +1309,30 @@
}
}
$this->Application->StoreVar($event->getPrefixSpecial().'_custom_filters', serialize($custom_filters) );
-
+
if( !$keyword && !count($custom_filters) )
{
$this->OnSearchReset($event);
- return true;
+ return true;
}
-
+
$grid_name = $this->Application->GetVar('grid_name');
$grids = $this->Application->getUnitOption($event->Prefix,'Grids');
$search_fields = array_keys($grids[$grid_name]['Fields']);
-
+
$search_filter = Array();
-
+
foreach($search_fields as $search_field)
{
$filter_type = isset($object->VirtualFields[$search_field]) ? 'having' : 'where';
$field_type = getArrayValue($object->Fields[$search_field],'type');
if(!$field_type) $field_type = 'string'; // default LIKE filter for all fields without type
$keyword = trim($keyword);
$keyword = str_replace(Array('"',"'"),'',$keyword);
-
+
$filter_value = '';
$table_name = ($filter_type == 'where') ? '`'.$object->TableName.'`.' : '';
-
+
// get field clause by formatter name and/or parameters
$formatter = getArrayValue($object->Fields[$search_field],'formatter');
switch($formatter)
@@ -1348,48 +1348,48 @@
}
}
if (count($search_keys) > 0) {
- $filter_value = $table_name.'`'.$search_field.'` IN ('.implode(',', $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 && $keyword)
{
switch($field_type)
@@ -1429,10 +1429,10 @@
}
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
*
@@ -1443,10 +1443,10 @@
{
$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)
*
@@ -1459,12 +1459,12 @@
$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
*
@@ -1479,20 +1479,20 @@
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...
*
@@ -1501,26 +1501,21 @@
function OnPreSaveAndOpenTranslator(&$event)
{
$this->Application->SetVar('allow_translation', true);
- $object =& $event->getObject();
+ $object =& $event->getObject();
$this->RemoveRequiredFields($object);
$event->CallSubEvent('OnPreSave');
if ($event->status == erSUCCESS) {
-// $url = $this->Application->HREF($t, '', Array('pass'=>'all', $event->getPrefixSpecial(true).'_id' => $object->GetId()));
-// $field = $this->Application->GetVar('translator_field');
$event->redirect = $this->Application->GetVar('translator_t');
- $event->redirect_params = Array('pass'=>'all,trans,'.$this->Application->GetVar('translator_prefixes'),
+ $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'),
);
- //$after_script = "openTranslator('".$event->getPrefixSpecial()."', '".$field."', '".$url."', '".$wnd_name."')";
}
-
-// $this->Application->SetVar('after_script', $after_script);
-// $event->redirect = false;
}
-
+
function RemoveRequiredFields(&$object)
{
// making all field non-required to achieve successful presave
@@ -1532,7 +1527,7 @@
}
}
}
-
+
}
Index: trunk/kernel/units/translator/translator_config.php
===================================================================
diff -u -r1566 -r3299
--- trunk/kernel/units/translator/translator_config.php (.../translator_config.php) (revision 1566)
+++ trunk/kernel/units/translator/translator_config.php (.../translator_config.php) (revision 3299)
@@ -11,38 +11,39 @@
'QueryString' => Array(
1 => 'prefix',
2 => 'field',
- 3 => 'event',
+ 3 => 'multi_line',
+ 4 => 'event',
),
'IDField' => 'N/A',
-
+
'TitleField' => 'Translator',
-
+
'TitlePhrase' => 'la_text_Translation',
-
+
'TitlePresets' => Array(
- 'default' => Array(
+ 'default' => Array(
'new_status_labels' => Array('trans'=>'!la_title_Adding_Order!'),
'edit_status_labels' => Array('trans'=>'!la_title_Editing_Order!'),
'new_titlefield' => Array('trans'=>'!la_title_New_Order!'),
),
-
+
'trans_edit' => Array('prefixes' => Array('trans'), 'format' => '!la_title_EditingTranslation!'),
-
+
),
/*
'TableName' => 'N/A',
-
+
'ListSQLs' => Array( ''=>'SELECT * FROM %s',),
-
+
'ItemSQLs' => Array( ''=>'SELECT * FROM %s',),*/
-
+
'Fields' => Array(
),
-
+
'VirtualFields' => Array(
'Original' => Array(),
'Language' => Array(),
- 'SwitchLanguage' => Array('formatter'=>'kOptionsFormatter',
+ 'SwitchLanguage' => Array('formatter'=>'kOptionsFormatter',
'options_sql'=>'SELECT %s FROM '.TABLE_PREFIX.'Language', 'option_key_field'=>'LanguageId','option_title_field'=>'PackName'),
'Translation' => Array(),
),
Index: trunk/kernel/admin_templates/incs/grid_blocks.tpl
===================================================================
diff -u -r2922 -r3299
--- trunk/kernel/admin_templates/incs/grid_blocks.tpl (.../grid_blocks.tpl) (revision 2922)
+++ trunk/kernel/admin_templates/incs/grid_blocks.tpl (.../grid_blocks.tpl) (revision 3299)
@@ -29,17 +29,17 @@
-
+
|
@@ -133,7 +133,7 @@
|
-
+
|
@@ -149,7 +149,11 @@
:
- );" title="">
+
+ , 1);" title="">
+
+ );" title="">
+
|
@@ -160,7 +164,7 @@
$Menus[''+'_filter_menu'].addMenuItem('','','');
-
+
$Menus[''+'_filter_menu'].addMenuSeparator();
@@ -177,29 +181,29 @@
$Menus[''+'_filter_menu'].addMenuSeparator();
-
+
// sorting menu
$Menus[''+'_sorting_menu'] = new Menu('');
$Menus[''+'_sorting_menu'].addMenuItem('','direct_sort_grid("","","asc");','2');
$Menus[''+'_sorting_menu'].addMenuItem('','direct_sort_grid("","","desc");','2');
$Menus[''+'_sorting_menu'].addMenuSeparator();
$Menus[''+'_sorting_menu'].addMenuItem('','reset_sorting("");');
-
+
// per page menu
$Menus[''+'_perpage_menu'] = new Menu('');
$Menus[''+'_perpage_menu'].addMenuItem('10','set_per_page("",10);','2');
$Menus[''+'_perpage_menu'].addMenuItem('20','set_per_page("",20);','2');
$Menus[''+'_perpage_menu'].addMenuItem('50','set_per_page("",50);','2');
$Menus[''+'_perpage_menu'].addMenuItem('100','set_per_page("",100);','2');
$Menus[''+'_perpage_menu'].addMenuItem('500','set_per_page("",500);','2');
-
+
// select menu
$Menus[''+'_select_menu'] = new Menu('');
$Menus[''+'_select_menu'].addMenuItem('','Grids[""].SelectAll();');
$Menus[''+'_select_menu'].addMenuItem('','Grids[""].ClearSelection();');
$Menus[''+'_select_menu'].addMenuItem('','Grids[""].InvertSelection();');
-
+
$Menus[''+'_view_menu'] = new Menu('');
$Menus[''+'_view_menu'].addMenuItem( $Menus[''+'_filter_menu'] );
@@ -235,26 +239,26 @@
-
+
-
+
" id="_" sequence="">
-
+
-
+
-
+
-
+