Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Wed, Jul 16, 3:48 PM

in-portal

Index: trunk/kernel/units/translator/translator_config.php
===================================================================
--- trunk/kernel/units/translator/translator_config.php (revision 3298)
+++ trunk/kernel/units/translator/translator_config.php (revision 3299)
@@ -1,52 +1,53 @@
<?php
$config = Array(
'Prefix' => 'trans',
'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'TranslatorEventHandler','file'=>'translator_event_handler.php','build_event'=>'OnBuild'),
'TagProcessorClass' => Array('class'=>'kDBTagProcessor','file'=>'','build_event'=>'OnBuild'),
'AutoLoad' => false,
'hooks' => Array(),
'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(),
),
'Grids' => Array(),
);
?>
\ No newline at end of file
Property changes on: trunk/kernel/units/translator/translator_config.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property
Index: trunk/kernel/units/general/cat_event_handler.php
===================================================================
--- trunk/kernel/units/general/cat_event_handler.php (revision 3298)
+++ trunk/kernel/units/general/cat_event_handler.php (revision 3299)
@@ -1,1009 +1,1011 @@
<?php
$application =& kApplication::Instance();
$application->Factory->includeClassFile('kDBEventHandler');
class kCatDBEventHandler extends InpDBEventHandler {
function OnCopy(&$event)
{
$object = $event->getObject();
$this->StoreSelectedIDs($event);
$ids = $this->getSelectedIDs($event);
$this->Application->StoreVar($event->getPrefixSpecial().'_clipboard', implode(',', $ids));
$this->Application->StoreVar($event->getPrefixSpecial().'_clipboard_mode', 'copy');
$this->Application->StoreVar('ClipBoard', 'COPY-0.'.$object->TableName.'.ResourceId=0');
$event->redirect_params = Array('opener' => 's', 'pass_events'=>true); //do not go up - STAY
}
function OnCut(&$event)
{
$object = $event->getObject();
$this->StoreSelectedIDs($event);
$ids = $this->getSelectedIDs($event);
$this->Application->StoreVar($event->getPrefixSpecial().'_clipboard', implode(',', $ids));
$this->Application->StoreVar($event->getPrefixSpecial().'_clipboard_mode', 'cut');
$this->Application->StoreVar('ClipBoard', 'CUT-0.'.$object->TableName.'.ResourceId=0');
$event->redirect_params = Array('opener' => 's', 'pass_events'=>true); //do not go up - STAY
}
function OnPaste(&$event)
{
$ids = $this->Application->RecallVar($event->getPrefixSpecial().'_clipboard');
if ($ids == '') {
$event->redirect = false;
return;
}
//recalling by different name, because we may get kDBList, if we recall just by prefix
$object =& $this->Application->recallObject($event->getPrefixSpecial().'.item', $event->Prefix);
$this->prepareObject($object, $event);
if ($this->Application->RecallVar($event->getPrefixSpecial().'_clipboard_mode') == 'copy') {
$ids_arr = explode(',', $ids);
$temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
if($ids_arr)
{
$temp->CloneItems($event->Prefix, $event->Special, $ids_arr);
}
}
else { // mode == cut
$ids_arr = explode(',', $ids);
foreach ($ids_arr as $id) {
$object->Load($id);
$object->MoveToCat();
}
}
$event->status = erSUCCESS;
}
/**
* Occurs when pasting category
*
* @param kEvent $event
*/
function OnCatPaste(&$event)
{
$inp_clipboard = $this->Application->RecallVar('ClipBoard');
$inp_clipboard = explode('-', $inp_clipboard, 2);
if($inp_clipboard[0] == 'COPY')
{
$saved_cat_id = $this->Application->GetVar('m_cat_id');
$cat_ids = $event->getEventParam('cat_ids');
$id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
$table = $this->Application->getUnitOption($event->Prefix, 'TableName');
$ids_sql = 'SELECT '.$id_field.' FROM '.$table.' WHERE ResourceId IN (%s)';
$resource_ids_sql = 'SELECT ItemResourceId FROM '.TABLE_PREFIX.'CategoryItems WHERE CategoryId = %s AND PrimaryCat = 1';
$this->Application->setUnitOption($event->Prefix,'AutoLoad', false);
$object =& $this->Application->recallObject($event->Prefix.'.item', $event->Prefix);
foreach($cat_ids as $source_cat => $dest_cat)
{
$item_resource_ids = $this->Conn->GetCol( sprintf($resource_ids_sql, $source_cat) );
if(!$item_resource_ids) continue;
$this->Application->SetVar('m_cat_id', $dest_cat);
$item_ids = $this->Conn->GetCol( sprintf($ids_sql, implode(',', $item_resource_ids) ) );
$temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
if($item_ids) $temp->CloneItems($event->Prefix, $event->Special, $item_ids);
}
$this->Application->setUnitOption($event->Prefix,'AutoLoad', true);
$this->Application->SetVar('m_cat_id', $saved_cat_id);
}
}
/**
* Enter description here...
*
* @param kEvent $event
*/
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');
$cf_id = $this->Application->GetVar('translator_cf_id');
if($cf_id)
{
$cv =& $this->Application->recallObject('cv.-item', null, Array('skip_autoload' => true) );
$load_params = Array('CustomFieldId' => $cf_id, 'ResourceId'=> $object->GetDBField('ResourceId') );
if( !$cv->Load($load_params) )
{
$cv->SetFieldsFromHash($load_params);
$cv->Create();
}
$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
*
* @param kEvent $event
*/
function SetCustomQuery(&$event)
{
$object =& $event->getObject();
if ($event->Special != 'showall') {
if ( $event->getEventParam('parent_cat_id') ) {
$parent_cat_id = $event->getEventParam('parent_cat_id');
}
else {
$parent_cat_id = $this->Application->GetVar('c_id');
if (!$parent_cat_id) {
$parent_cat_id = $this->Application->GetVar('m_cat_id');
}
if (!$parent_cat_id) {
$parent_cat_id = 0;
}
}
if ((string) $parent_cat_id != 'any') {
if ($event->getEventParam('recursive')) {
$current_path = $this->Conn->GetOne('SELECT ParentPath FROM '.TABLE_PREFIX.'Category WHERE CategoryId='.$parent_cat_id);
$subcats = $this->Conn->GetCol('SELECT CategoryId FROM '.TABLE_PREFIX.'Category WHERE ParentPath LIKE "'.$current_path.'%" ');
$object->addFilter('category_filter', TABLE_PREFIX.'CategoryItems.CategoryId IN ('.implode(', ', $subcats).')');
}
else {
$object->addFilter('category_filter', TABLE_PREFIX.'CategoryItems.CategoryId = '.$parent_cat_id );
}
}
}
else {
$object->addFilter('primary_filter', 'PrimaryCat = 1');
}
$view_perm = 1;
$object->addFilter('perm_filter', 'perm.PermId = '.$view_perm);
-
+
if ( !$this->Application->IsAdmin() )
{
$groups = explode( ',', $this->Application->RecallVar('UserGroups') );
foreach($groups as $group)
{
$view_filters[] = 'FIND_IN_SET('.$group.', perm.acl) || ((NOT FIND_IN_SET('.$group.',perm.dacl)) AND perm.acl=\'\')';
}
$view_filter = implode(' OR ', $view_filters);
$object->addFilter('perm_filter2', $view_filter);
$object->addFilter('status_filter', $object->TableName.'.Status = 1');
}
/*$list_type = $event->getEventParam('ListType');
switch($list_type)
{
case 'favorites':
$fav_table = $this->Application->getUnitOption('fav','TableName');
$user_id =& $this->Application->GetVar('u_id');
$sql = 'SELECT DISTINCT f.ResourceId
FROM '.$fav_table.' f
LEFT JOIN '.$object->TableName.' p ON p.ResourceId = f.ResourceId
WHERE f.PortalUserId = '.$user_id;
$ids = $this->Conn->GetCol($sql);
if(!$ids) $ids = Array(-1);
$object->addFilter('category_filter', TABLE_PREFIX.'CategoryItems.PrimaryCat = 1');
$object->addFilter('favorites_filter', '%1$s.`ResourceId` IN ('.implode(',',$ids).')');
break;
case 'search':
$search_results_table = TABLE_PREFIX.'ses_'.$this->Application->GetSID().'_'.TABLE_PREFIX.'Search';
$sql = ' SELECT DISTINCT ResourceId
FROM '.$search_results_table.'
WHERE ItemType=11';
$ids = $this->Conn->GetCol($sql);
if(!$ids) $ids = Array(-1);
$object->addFilter('search_filter', '%1$s.`ResourceId` IN ('.implode(',',$ids).')');
break;
} */
}
-
+
/**
* Adds calculates fields for item statuses
*
* @param kCatDBItem $object
* @param kEvent $event
*/
function PrepareObject(&$object, &$event)
{
-
+
$property_mappings = $this->Application->getUnitOption($event->Prefix, 'ItemPropertyMappings');
-
+
$new_days_var = getArrayValue($property_mappings, 'NewDays');
if($new_days_var)
{
$object->addCalculatedField('IsNew', ' IF(%1$s.NewItem = 2,
IF(%1$s.CreatedOn >= (UNIX_TIMESTAMP() - '.
$this->Application->ConfigValue($new_days_var).
'*3600*24), 1, 0),
%1$s.NewItem
)');
}
-
+
$hot_limit_var = getArrayValue($property_mappings, 'HotLimit');
if($hot_limit_var)
{
$sql = 'SELECT Data FROM '.TABLE_PREFIX.'Cache WHERE VarName = "'.$hot_limit_var.'"';
$hot_limit = $this->Conn->GetOne($sql);
if($hot_limit === false) $hot_limit = $this->CalculateHotLimit($event);
$object->addCalculatedField('IsHot', ' IF(%1$s.HotItem = 2,
IF(%1$s.Hits >= '.$hot_limit.', 1, 0),
%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,
IF(%1$s.CachedVotesQty >= '.
$this->Application->ConfigValue($votes2pop_var).
' AND %1$s.CachedRating >= '.
$this->Application->ConfigValue($rating2pop_var).
', 1, 0),
%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;
$sql = 'SELECT Hits FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').'
ORDER BY Hits DESC
LIMIT '.$last_hot.', 1';
$res = $this->Conn->GetCol($sql);
$hot_limit = (double)array_shift($res);
$this->Conn->Query('REPLACE INTO '.TABLE_PREFIX.'Cache VALUES ("'.$hot_limit_var.'", "'.$hot_limit.'", '.adodb_mktime().')');
return $hot_limit;
}
return 0;
}
-
+
/**
* Enter description here...
*
* @param kEvent $event
*/
function OnBeforeItemUpdate(&$event)
{
$object =& $event->getObject();
if( $this->Application->IsAdmin() && ($this->Application->GetVar('Hits_original') !== false) &&
floor($this->Application->GetVar('Hits_original')) != $object->GetDBField('Hits') )
{
$sql = 'SELECT MAX(Hits) FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').'
WHERE FLOOR(Hits) = '.$object->GetDBField('Hits');
$hits = ( $res = $this->Conn->GetOne($sql) ) ? $res + 0.000001 : $object->GetDBField('Hits');
$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))
{
return; // used when navigating by pages or changing sorting in search results
}
if(!$keywords || strlen($keywords) < $this->Application->ConfigValue('Search_MinKeyword_Length'))
{
$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'])
{
$join_clause .= ' AND '.$alias.'.CustomFieldId='.$search_config[$field]['CustomFieldId'];
}
$join_clauses[] = ' LEFT JOIN '.$foreign_table.' '.$alias.'
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;
$extra_skip = 0;
switch(substr($keywords, $i, 1))
{
case '+':
if(substr($keywords, $i + 1, 1) == '"')
{
$keyword_start = $i + 2;
$keyword_end = strpos($keywords, '"', $i + 2);
$extra_skip = 2;
}
- else
+ else
{
$keyword_start = $i + 1;
$keyword_end = strpos($keywords, ' ', $i + 1);
$extra_skip = 0;
}
$target_array =& $plus_keywords;
break;
case '-':
if(substr($keywords, $i + 1, 1) == '"')
{
$keyword_start = $i + 2;
$keyword_end = strpos($keywords, '"', $i + 2);
$extra_skip = 2;
}
- else
+ else
{
$keyword_start = $i + 1;
$keyword_end = strpos($keywords, ' ', $i + 1);
$extra_skip = 0;
}
$target_array =& $minus_keywords;
break;
case '"':
$keyword_start = $i + 1;
$keyword_end = strpos($keywords, '"', $i + 1);
$extra_skip = 1;
$target_array =& $normal_keywords;
break;
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();
$minus_conditions = Array();
foreach($normal_keywords as $keyword)
{
$normal_conditions[] = implode(' LIKE "%'.$keyword.'%" OR ', $field_list).' LIKE "%'.$keyword.'%"';
}
foreach($plus_keywords as $keyword)
{
$plus_conditions[] = implode(' LIKE "%'.$keyword.'%" OR ', $field_list).' LIKE "%'.$keyword.'%"';
}
foreach($minus_keywords as $keyword)
{
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';
}
if($plus_conditions)
{
$where_clause = '('.$where_clause.') AND ('.implode(') AND (', $plus_conditions).')';
}
if($minus_conditions)
{
$where_clause = '('.$where_clause.') AND ('.implode(') AND (', $minus_conditions).')';
}
$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']).')';
}
}
if( $event->MasterEvent && $event->MasterEvent->Name == 'OnListBuild' ) // subsearch, k4
{
if( $event->MasterEvent->getEventParam('ResultIds') )
{
$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)';
foreach($positive_words as $keyword)
{
$revelance_parts[] = 'IF('.$field.' LIKE "%'.$keyword.'%", '.$config_elem['value']['Priority'].', 0)';
}
}
$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...
*
* @param kEvent $event
*/
function OnSubSearch(&$event)
{
$search_table = TABLE_PREFIX.'ses_'.$this->Application->GetSID().'_'.TABLE_PREFIX.'Search';
$sql = 'SHOW TABLES LIKE "'.$search_table.'"';
if($this->Conn->Query($sql))
{
$sql = 'SELECT DISTINCT ResourceId FROM '.$search_table;
$ids = $this->Conn->GetCol($sql);
}
$event->setEventParam('ResultIds', $ids);
$event->CallSubEvent('OnSimpleSearch');
}
-
+
/**
* Enter description here...
*
* @param kEvent $event
* @todo Change all hardcoded Products table & In-Commerce module usage to dynamic usage from item config !!!
*/
function OnAdvancedSearch(&$event)
{
$query_object =& $this->Application->recallObject('HTTPQuery');
if(!isset($query_object->Post['andor']))
{
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';
$search_config = $this->Conn->Query($sql);
$lang = $this->Application->GetVar('m_lang');
$object =& $event->getObject();
$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')
{
$field_name = 'l'.$lang.'_'.$field;
}
else
{
$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'];
}
$join_clause = ' LEFT JOIN '.$foreign_table.' '.$alias.'
ON '.$join_clause;
}
}
else
{
// processing fields from local table
$field_name = $local_table.'.'.$field_name;
}
-
+
$condition = '';
switch($record['FieldType'])
{
case 'text':
if( !$this->Application->GetVar('INPORTAL_ON') )
{
$keywords[$field] = unhtmlentities( $keywords[$field] );
}
-
+
if(strlen($keywords[$field]) >= $this->Application->ConfigValue('Search_MinKeyword_Length'))
{
$highlight_keywords[] = $keywords[$field];
if( in_array($verbs[$field], Array('any', 'contains', 'notcontains')) )
{
$keywords[$field] = '%'.strtr($keywords[$field], Array('%' => '\\%', '_' => '\\_')).'%';
}
$condition = sprintf( $condition_patterns[$verbs[$field]],
$field_name,
$this->Conn->qstr( $keywords[$field] ));
}
break;
case 'boolean':
if($keywords[$field] != -1)
{
$property_mappings = $this->Application->getUnitOption($event->Prefix, 'ItemPropertyMappings');
switch($field)
{
case 'HotItem':
$hot_limit_var = getArrayValue($property_mappings, 'HotLimit');
if($hot_limit_var)
{
$sql = 'SELECT Data FROM '.TABLE_PREFIX.'Cache WHERE VarName="'.$hot_limit_var.'"';
$hot_limit = (int)$this->Conn->GetOne($sql);
$condition = 'IF('.$product_table.'.HotItem = 2,
IF('.$product_table.'.Hits >= '.
$hot_limit.
', 1, 0), '.$product_table.'.HotItem) = '.$keywords[$field];
}
break;
case 'PopItem':
$votes2pop_var = getArrayValue($property_mappings, 'VotesToPop');
$rating2pop_var = getArrayValue($property_mappings, 'RatingToPop');
if($votes2pop_var && $rating2pop_var)
{
$condition = 'IF('.$product_table.'.PopItem = 2, IF('.$product_table.'.CachedVotesQty >= '.
$this->Application->ConfigValue($votes2pop_var).
' AND '.$product_table.'.CachedRating >= '.
$this->Application->ConfigValue($rating2pop_var).
', 1, 0), '.$product_table.'.PopItem) = '.$keywords[$field];
}
break;
case 'NewItem':
$new_days_var = getArrayValue($property_mappings, 'NewDays');
if($new_days_var)
{
$condition = 'IF('.$product_table.'.NewItem = 2,
IF('.$product_table.'.CreatedOn >= (UNIX_TIMESTAMP() - '.
$this->Application->ConfigValue($new_days_var).
'*3600*24), 1, 0), '.$product_table.'.NewItem) = '.$keywords[$field];
}
break;
case 'EditorsPick':
$condition = $product_table.'.EditorsPick = '.$keywords[$field];
break;
- }
+ }
}
break;
case 'range':
$range_conditions = Array();
if($keywords[$field.'_from'] && !preg_match("/[^0-9]/i", $keywords[$field.'_from']))
{
$range_conditions[] = $field_name.' >= '.$keywords[$field.'_from'];
}
if($keywords[$field.'_to'] && !preg_match("/[^0-9]/i", $keywords[$field.'_to']))
{
$range_conditions[] = $field_name.' <= '.$keywords[$field.'_to'];
}
if($range_conditions)
{
$condition = implode(' AND ', $range_conditions);
}
break;
case 'date':
if($keywords[$field])
{
if( in_array($keywords[$field], Array('today', 'yesterday')) )
{
$current_time = getdate();
$day_begin = adodb_mktime(0, 0, 0, $current_time['mon'], $current_time['mday'], $current_time['year']);
$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,
'last_year' => 31536000
);
$min_time = adodb_mktime() - $time_mapping[$keywords[$field]];
}
$condition = $field_name.' > '.$min_time;
}
break;
}
-
+
if($condition)
{
if($join_clause)
{
$join_clauses[] = $join_clause;
}
$relevance_parts[] = 'IF('.$condition.', '.$record['Priority'].', 0)';
if($glues[$field] == 1) // and
{
if($condition_mode == 'WHERE')
{
$and_conditions[] = $condition;
}
else
{
$and_having_conditions[] = $condition;
}
}
else // or
{
if($condition_mode == 'WHERE')
{
$or_conditions[] = $condition;
}
else
{
$or_having_conditions[] = $condition;
}
}
}
}
-
+
$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)
{
$and_conditions[] = '('.implode(' OR ', $or_conditions).')';
}
// $and_conditions[] = $product_table.'.Status = 1';
$where_clause = implode(' AND ', $and_conditions);
if(!$where_clause)
{
if($having_clause)
{
$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
*
* @param kEvent $event
* @access private
* @see OnListBuild
*/
function SetPagination(&$event)
{
// get PerPage (forced -> session -> config -> 10)
$per_page = $this->getPerPage($event);
-
+
$object =& $event->getObject();
$object->SetPerPage($per_page);
$this->Application->StoreVarDefault($event->getPrefixSpecial().'_Page', 1);
-
+
$page = $this->Application->GetVar($event->getPrefixSpecial().'_Page');
if (!$page)
{
$page = $this->Application->GetVar($event->getPrefixSpecial(true).'_Page');
}
-
+
if (!$page)
{
if( $this->Application->RewriteURLs() )
{
$page = $this->Application->GetVar($event->Prefix.'_Page');
if (!$page)
{
$page = $this->Application->RecallVar($event->Prefix.'_Page');
}
if($page) $this->Application->StoreVar($event->getPrefixSpecial().'_Page', $page);
}
else
{
$page = $this->Application->RecallVar($event->getPrefixSpecial().'_Page');
}
}
else {
$this->Application->StoreVar($event->getPrefixSpecial().'_Page', $page);
}
-
+
// $page = $this->Application->GetLinkedVar($event->getPrefixSpecial(true).'_Page', $event->getPrefixSpecial().'_Page');
if( !$event->getEventParam('skip_counting') )
{
$pages = $object->GetTotalPages();
if($page > $pages)
{
$this->Application->StoreVar($event->getPrefixSpecial().'_Page', 1);
$page = 1;
}
}
-
+
$object->SetPage($page);
}
}
?>
\ No newline at end of file
Property changes on: trunk/kernel/units/general/cat_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.15
\ No newline at end of property
+1.16
\ No newline at end of property
Index: trunk/kernel/admin_templates/popups/translator.tpl
===================================================================
--- trunk/kernel/admin_templates/popups/translator.tpl (revision 3298)
+++ trunk/kernel/admin_templates/popups/translator.tpl (revision 3299)
@@ -1,99 +1,104 @@
<inp2:m_set nobody="yes"/>
<!--DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">-->
<html>
<head>
<title>In-Commerce</title>
<meta http-equiv="content-type" content="text/html; charset=<inp2:trans_Field field="Charset"/>">
<meta name="keywords" content="...">
<meta name="description" content="...">
<meta name="robots" content="all">
<meta name="copyright" content="Copyright &#174; 2005 Test, Inc">
<meta name="author" content="Intechnic Inc.">
<inp2:m_base_ref/>
<link rel="icon" href="img/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" rev="stylesheet" href="incs/style.css" type="text/css" media="screen" />
<script language="javascript" src="incs/is.js"></script>
<script language="javascript" src="incs/script.js"></script>
<script language="javascript" src="incs/in-portal.js"></script>
<script language="javascript" src="incs/toolbar.js"></script>
<script language="javascript" src="incs/grid.js"></script>
<script language="javascript" src="incs/tabs.js"></script>
<script language="javascript">
var t = '<inp2:m_get param="t"/>';
var popups = '1';
var multiple_windows = '1';
var main_title = 'In-Commerce';
var tpl_changed = 0;
var base_url = '<inp2:m_BaseURL/>';
var img_path = "img/";
</script>
</head>
<inp2:m_include t="incs/blocks"/>
<inp2:m_include t="incs/in-portal"/>
<inp2:m_if prefix="m" function="get_equals" var="nobody" value="yes"/><inp2:m_else/>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0" <inp2:m_get param="body_properties"/>>
<inp2:m_endif/>
<inp2:m_ParseBlock name="kernel_form"/>
<inp2:m_if prefix="m" function="IsDebugMode"/>
<a href="javascript:self.location.reload()">Reload frame</a>&nbsp;||&nbsp;<a href="javascript:toggleDebugLayer()">Show debugger</a>
<inp2:m_endif/>
<body topmargin="0" leftmargin="8" marginheight="0" marginwidth="8" bgcolor="#FFFFFF">
<inp2:m_ParseBlock name="blue_bar" prefix="trans" title_preset="trans_edit" module="in-commerce"/>
<!-- ToolBar --->
<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<td>
<script type="text/javascript">
a_toolbar = new ToolBar();
-
+
a_toolbar.AddButton( new ToolBarButton('select', '<inp2:m_phrase label="la_ToolTip_Save"/>', function() {
submit_event('trans','OnSaveAndClose');
}
) );
a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel"/>', function() {
window.close();
}
) );
-
+
a_toolbar.AddButton( new ToolBarSeparator('sep2') );
-
- a_toolbar.Render();
-
+
+ a_toolbar.Render();
+
function edit()
{
// required for correct row selection
- }
+ }
</script>
-
+
</td>
</tr>
</tbody>
</table>
<input type="hidden" name="trans_prefix" value="<inp2:m_get var="trans_prefix"/>">
<input type="hidden" name="trans_field" value="<inp2:m_get var="trans_field"/>">
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder">
<inp2:m_ParseBlock name="inp_edit_hidden" prefix="trans" field="Language"/>
- <inp2:m_ParseBlock name="subsection" title="!la_section_Translation!"/>
+ <inp2:m_ParseBlock name="subsection" title="!la_section_Translation!"/>
<inp2:m_ParseBlock name="inp_label" prefix="trans" title="!la_fld_Original!" field="Original"/>
<inp2:m_ParseBlock name="inp_edit_options" prefix="trans" field="SwitchLanguage" title="!la_fld_Language!" size="50" onchange="submit_event('trans', 'OnChangeLanguage')"/>
- <inp2:m_ParseBlock name="inp_edit_box" prefix="trans" field="Translation" title="!la_fld_Translation!" size="50"/>
-</table>
+
+ <inp2:m_if check="m_get" var="trans_multi_line" value="1">
+ <inp2:m_ParseBlock name="inp_edit_textarea" prefix="trans" field="Translation" title="!la_fld_Translation!" cols="50" rows="10"/>
+ <inp2:m_else/>
+ <inp2:m_ParseBlock name="inp_edit_box" prefix="trans" field="Translation" title="!la_fld_Translation!" size="50"/>
+ </inp2:m_if>
+</table>
<inp2:m_include t="incs/footer"/>
\ No newline at end of file
Property changes on: trunk/kernel/admin_templates/popups/translator.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property
Index: trunk/kernel/admin_templates/incs/script.js
===================================================================
--- trunk/kernel/admin_templates/incs/script.js (revision 3298)
+++ trunk/kernel/admin_templates/incs/script.js (revision 3299)
@@ -1,470 +1,474 @@
if( !( isset($init_made) && $init_made ) )
{
var Grids = new Array();
var Toolbars = new Array();
var $Menus = new Array();
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 :)
}
function resort_grid(prefix_special,field,form_action)
{
set_hidden_field(prefix_special+'_Sort1', field);
submit_event(prefix_special,'OnSetSorting',null,form_action);
}
function direct_sort_grid($prefix_special,$field,$direction,$field_pos)
{
if(!isset($field_pos)) $field_pos = 1;
set_hidden_field($prefix_special+'_Sort'+$field_pos,$field);
set_hidden_field($prefix_special+'_Sort'+$field_pos+'_Dir',$direction);
set_hidden_field($prefix_special+'_SortPos',$field_pos);
submit_event($prefix_special,'OnSetSortingDirect');
}
function reset_sorting($prefix_special)
{
submit_event($prefix_special,'OnResetSorting');
}
function set_per_page($prefix_special,$per_page)
{
set_hidden_field($prefix_special+'_PerPage',$per_page);
submit_event($prefix_special,'OnSetPerPage');
}
function submit_event(prefix_special,event,t,form_action)
{
if (isset(event)) {
set_hidden_field('events['+prefix_special+']', event);
}
-
+
if(isset(t)) set_hidden_field('t', t);
if( isset(form_action) )
{
var old_env = '';
if ( !form_action.match(/\?/) ) {
document.getElementById($form_prefix+'_form').action.match(/.*(\?.*)/);
old_env = RegExp.$1;
}
document.getElementById($form_prefix+'_form').action = form_action+old_env;
}
submit_kernel_form();
}
function show_form_data()
{
var $kf = document.getElementById($form_prefix+'_form');
$ret = '';
for(var i in $kf.elements)
{
$elem = $kf.elements[i];
$ret += $elem.id + ' = ' + $elem.value + "\n";
}
- alert($ret);
+ alert($ret);
}
function submit_kernel_form()
{
if (submitted) {
return;
}
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);
}
function set_event(prefix_special, event)
{
var event_field=document.getElementById('events[' + prefix_special + ']');
if(isset(event_field))
{
event_field.value = event;
}
}
function isset(variable)
{
if(variable==null) return false;
return (typeof(variable)=='undefined')?false:true;
}
function print_pre(variable)
{
var s = "";
for (prop in variable) {
s += prop+" => "+variable[prop] + "";
}
alert(s);
}
function go_to_page(prefix_special, page)
{
set_hidden_field(prefix_special+'_Page', page);
submit_event(prefix_special);
}
function go_to_list(prefix_special, tab)
{
set_hidden_field(prefix_special+'_GoTab', tab);
submit_event(prefix_special,'OnUpdateAndGoToTab',null);
}
function go_to_tab(prefix_special, tab)
{
set_hidden_field(prefix_special+'_GoTab', tab);
submit_event(prefix_special,'OnPreSaveAndGoToTab',null);
}
function go_to_id(prefix_special, id)
{
set_hidden_field(prefix_special+'_GoId', id);
submit_event(prefix_special,'OnPreSaveAndGo')
}
// in-portal compatibility functions: begin
function getScriptURL($script_name)
{
var $asid = get_hidden_field('sid');
return base_url+$script_name+'?env='+( isset($env)&&$env?$env:$asid )+'&en=0';
}
function OpenEditor(extra_env,TargetForm,TargetField)
{
var $url = getScriptURL('admin/editor/editor_new.php');
$url = $url+'&TargetForm='+TargetForm+'&TargetField='+TargetField+'&destform=popup';
if(extra_env.length>0) $url += extra_env;
openwin($url,'html_edit',800,575);
}
function OpenUserSelector(extra_env,TargetForm,TargetField)
-{
+{
var $url = getScriptURL('admin/users/user_select.php');
$url += '&destform='+TargetForm+'&Selector=radio&destfield='+TargetField+'&IdField=Login';
if(extra_env.length>0) $url += extra_env;
openwin($url,'user_select',800,575);
return false;
}
function OpenCatSelector(extra_env)
{
var $url = getScriptURL('admin/cat_select.php');
if(extra_env.length>0) $url += extra_env;
openwin($url,'catselect',750,400);
}
function OpenItemSelector(extra_env,$TargetForm)
{
var $url = getScriptURL('admin/relation_select.php') + '&destform='+$TargetForm;
if(extra_env.length>0) $url += extra_env;
openwin($url,'groupselect',750,400);
}
function OpenUserEdit($user_id, $extra_env)
{
var $url = getScriptURL('admin/users/adduser.php') + '&direct_id=' + $user_id;
if( isset($extra_env) ) $url += $extra_env;
window.location.href = $url;
}
function OpenLinkEdit($link_id, $extra_env)
{
var $url = getScriptURL('in-link/admin/addlink.php') + '&item=' + $link_id;
if( isset($extra_env) ) $url += $extra_env;
window.location.href = $url;
}
function OpenHelp($help_link)
{
-
+
// $help_link.match('http://(.*).lv/in-commerce/admin(.*)');
// alert(RegExp.$2);
openwin($help_link,'HelpPopup',750,400);
}
// in-portal compatibility functions: end
-function PreSaveAndOpenTranslator(prefix,field,t,$width,$height)
+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');
}
function openTranslator(prefix,field,url,wnd)
{
set_hidden_field('trans_prefix', prefix);
set_hidden_field('trans_field', field);
set_hidden_field('events[trans]', 'OnLoad');
-
+
var $regex = new RegExp('(.*)\?env=' + document.getElementById('sid').value + '-(.*?):(.*)');
var $t = $regex.exec(url)[2];
document.kernel_form.target = wnd;
submit_event(prefix,'',$t,url);
}
function openSelector($prefix,$url,$window_name,$width,$height,$event)
{
var $regex = new RegExp('(.*)\?env=' + document.getElementById('sid').value + '-(.*?):(.*)');
var $t = $regex.exec($url)[2];
if(!isset($window_name)) var $window_name = 'select_'+$t.replace(/(\/|-)/g, '_');
if(!isset($width)) $width=750;
if(!isset($height)) $height=400;
if(!isset($event)) $event='';
set_hidden_field('m_opener','s');
openwin('',$window_name,$width,$height);
set_hidden_field('main_prefix', $prefix);
document.kernel_form.target=$window_name;
var old_action = document.kernel_form.action;
document.kernel_form.action = $url;
submit_event($prefix,$event,$t);
document.kernel_form.action = old_action;
}
function openwin($url,$name,$width,$height)
{
var $window_params = 'width='+$width+',height='+$height+',status=yes,resizable=yes,menubar=no,scrollbars=yes,toolbar=no';
return window.open($url,$name,$window_params);
}
function opener_action(new_action)
{
set_hidden_field('m_opener', new_action);
}
function std_precreate_item(prefix_special, edit_template)
{
opener_action('d');
set_hidden_field(prefix_special+'_mode', 't');
submit_event(prefix_special,'OnPreCreate', edit_template)
}
function std_new_item(prefix_special, edit_template)
{
opener_action('d');
submit_event(prefix_special,'OnNew', edit_template)
}
function std_edit_item(prefix_special, edit_template)
{
opener_action('d');
set_hidden_field(prefix_special+'_mode', 't');
submit_event(prefix_special,'OnEdit',edit_template)
}
function std_edit_temp_item(prefix_special, edit_template)
{
opener_action('d');
submit_event(prefix_special,'',edit_template)
}
function std_delete_items(prefix_special)
{
- if (inpConfirm('Are you sure you want to delete selected items?'))
+ if (inpConfirm('Are you sure you want to delete selected items?'))
submit_event(prefix_special,'OnMassDelete')
}
// sets hidden field value
// if the field does not exist - creates it
function set_hidden_field($field_id, $value)
{
// 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)
{
set_hidden_field('grid_name', $grid_name);
submit_event($prefix_special,'OnSearchReset');
}
function search_keydown($event)
{
if(!$event && window.event) $event = window.event;
if($event.keyCode == 13)
{
var $prefix_special = this.getAttribute('PrefixSpecial');
var $grid = this.getAttribute('Grid');
search($prefix_special,$grid);
}
}
function getRealLeft(el)
{
xPos = el.offsetLeft;
tempEl = el.offsetParent;
while (tempEl != null)
{
xPos += tempEl.offsetLeft;
tempEl = tempEl.offsetParent;
}
return xPos;
}
function getRealTop(el)
{
yPos = el.offsetTop;
tempEl = el.offsetParent;
while (tempEl != null)
{
yPos += tempEl.offsetTop;
tempEl = tempEl.offsetParent;
}
return yPos;
}
function show_viewmenu($toolbar, $button_id)
{
var $img = $toolbar.GetButtonImage($button_id);
var $pos_x = getRealLeft($img) - ((document.all) ? 6 : -2);
var $pos_y = getRealTop($img) + 32;
-
- var $prefix_special = '';
+
+ var $prefix_special = '';
window.triedToWriteMenus = false;
-
+
if($ViewMenus.length == 1)
{
$prefix_special = $ViewMenus[$ViewMenus.length-1];
$fw_menus[$prefix_special+'_view_menu']();
$Menus[$prefix_special+'_view_menu'].writeMenus('MenuContainers['+$prefix_special+']');
window.FW_showMenu($Menus[$prefix_special+'_view_menu'], $pos_x, $pos_y);
}
else
{
// prepare menus
for(var $i in $ViewMenus)
{
$prefix_special = $ViewMenus[$i];
$fw_menus[$prefix_special+'_view_menu']();
}
$Menus['mixed'] = new Menu('ViewMenu_mixed');
-
+
// merge menus into new one
for(var $i in $ViewMenus)
{
$prefix_special = $ViewMenus[$i];
$Menus['mixed'].addMenuItem( $Menus[$prefix_special+'_view_menu'] );
}
-
+
$Menus['mixed'].writeMenus('MenuContainers[mixed]');
window.FW_showMenu($Menus['mixed'], $pos_x, $pos_y);
}
}
function set_window_title($title)
{
var $window = window;
if($window.parent) $window = $window.parent;
$window.document.title = (main_title.length ? main_title + ' - ' : '') + $title;
}
function set_filter($prefix_special, $filter_id, $filter_value)
{
set_hidden_field('filter_id',$filter_id);
set_hidden_field('filter_value',$filter_value);
submit_event($prefix_special,'OnSetFilter');
}
function filters_remove_all($prefix_special)
{
submit_event($prefix_special,'OnRemoveFilters');
}
function filters_apply_all($prefix_special)
{
submit_event($prefix_special,'OnApplyFilters');
}
function RemoveTranslationLink($string)
{
return $string.match(/<a href="(.*)">(.*)<\/a>/) ? RegExp.$2 : $string;
}
function redirect($url)
{
- window.location.href = $url;
+ window.location.href = $url;
}
function update_checkbox_options($cb_mask, $hidden_id)
{
var $kf = document.getElementById($form_prefix+'_form');
var $tmp = '';
for (var i = 0; i < $kf.elements.length; i++)
{
if ( $kf.elements[i].id.match($cb_mask) )
{
// alert('found:' + $kf.elements[i].id);
if ($kf.elements[i].checked) $tmp += '|'+$kf.elements[i].value;
}
}
if($tmp.length > 0) $tmp += '|';
document.getElementById($hidden_id).value = $tmp.replace(/,$/, '');
// alert('field: '+$hidden_id+' = '+document.getElementById($hidden_id).value );
}
\ No newline at end of file
Property changes on: trunk/kernel/admin_templates/incs/script.js
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.7
\ No newline at end of property
+1.8
\ No newline at end of property
Index: trunk/kernel/admin_templates/incs/grid_blocks.tpl
===================================================================
--- trunk/kernel/admin_templates/incs/grid_blocks.tpl (revision 3298)
+++ trunk/kernel/admin_templates/incs/grid_blocks.tpl (revision 3299)
@@ -1,307 +1,311 @@
<inp2:m_block name="current_page"/>
<span class="current_page"><inp2:m_param name="page"/></span>
<inp2:m_blockend/>
<inp2:m_block name="page"/>
<a href="javascript:go_to_page('<inp2:m_param name="PrefixSpecial"/>', <inp2:m_param name="page"/>)" class="nav_url"><inp2:m_param name="page"/></a>
<inp2:m_blockend/>
<inp2:m_block name="next_page"/>
<a href="javascript:go_to_page('<inp2:m_param name="PrefixSpecial"/>', <inp2:m_param name="page"/>)" class="nav_url">&gt;</a>
<inp2:m_blockend/>
<inp2:m_block name="prev_page"/>
<a href="javascript:go_to_page('<inp2:m_param name="PrefixSpecial"/>', <inp2:m_param name="page"/>)" class="nav_url">&lt;</a>
<inp2:m_blockend/>
<inp2:m_block name="next_page_split"/>
<a href="javascript:go_to_page('<inp2:m_param name="PrefixSpecial"/>', <inp2:m_param name="page"/>)" class="nav_url">&gt;&gt;</a>
<inp2:m_blockend/>
<inp2:m_block name="prev_page_split"/>
<a href="javascript:go_to_page('<inp2:m_param name="PrefixSpecial"/>', <inp2:m_param name="page"/>)" class="nav_url">&lt;&lt;</a>
<inp2:m_blockend/>
<inp2:m_block name="grid_pagination"/>
<table cellspacing="0" cellpadding="2" width="100%" bgcolor="#E0E0DA" border="0" class="<inp2:m_if prefix="m" function="ParamEquals" name="no_toolbar" value="no_toolbar"/>tableborder_full_kernel<inp2:m_else/>pagination_bar<inp2:m_endif/>">
<tbody>
<tr id="MY_ID">
<td width="100%">
<img height="15" src="img/arrow.gif" width="15" align="absmiddle" border="0">
- <b class=text><inp2:m_phrase name="la_Page"/></b>
+ <b class=text><inp2:m_phrase name="la_Page"/></b>
<inp2:$PrefixSpecial_PrintPages active_block="current_page" split="10" inactive_block="page" prev_page_block="prev_page" next_page_block="next_page" prev_page_split_block="prev_page_split" next_page_split_block="next_page_split" />
</td>
<inp2:m_if prefix="m" function="ParamEquals" param="search" value="on"/>
<td align="right" style="padding-right: 0px;">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td><inp2:m_phrase name="la_Search"/>:&nbsp;</td>
- <td><input type="text"
- id="<inp2:m_param name="PrefixSpecial"/>_search_keyword"
- name="<inp2:m_param name="PrefixSpecial"/>_search_keyword"
+ <td><input type="text"
+ id="<inp2:m_param name="PrefixSpecial"/>_search_keyword"
+ name="<inp2:m_param name="PrefixSpecial"/>_search_keyword"
value="<inp2:m_recall var="{$PrefixSpecial}_search_keyword" no_null="no_null" special="1"/>"
PrefixSpecial="<inp2:m_param name="PrefixSpecial"/>"
Grid="<inp2:m_param name="grid"/>"
style="border: 1px solid grey;">
</td>
<td>
<script type="text/javascript">
document.getElementById('<inp2:m_param name="PrefixSpecial"/>_search_keyword').onkeydown = search_keydown;
Toolbars['<inp2:m_param name="PrefixSpecial"/>_search'] = new ToolBar('icon16_');
Toolbars['<inp2:m_param name="PrefixSpecial"/>_search'].AddButton( new ToolBarButton('search', '<inp2:m_phrase name="la_ToolTip_Search"/>', function() { search('<inp2:m_param name="PrefixSpecial"/>','<inp2:m_param name="grid"/>') } ) );
Toolbars['<inp2:m_param name="PrefixSpecial"/>_search'].AddButton( new ToolBarButton('search_reset', '<inp2:m_phrase name="la_ToolTip_SearchReset"/>', function() { search_reset('<inp2:m_param name="PrefixSpecial"/>','<inp2:m_param name="grid"/>') } ) );
Toolbars['<inp2:m_param name="PrefixSpecial"/>_search'].Render();
- </script>
+ </script>
</td>
</tr>
</table>
</td>
<inp2:m_endif/>
<td>
</tr>
</tbody>
</table>
<inp2:m_blockend/>
<inp2:m_block name="grid_column_title"/>
<td nowrap="nowrap">
<a href="javascript:resort_grid('<inp2:m_param name="PrefixSpecial"/>','<inp2:m_param name="sort_field"/>');" class="columntitle_small"><IMG alt="" src="img/list_arrow_<inp2:$PrefixSpecial_order field="$sort_field"/>.gif" border="0" align="absmiddle"><inp2:m_phrase name="$title"/><!-- <inp2:m_param name="title"/> --></a>
</td>
<inp2:m_blockend/>
<inp2:m_block name="grid_column_title_no_sorting"/>
<td nowrap="nowrap">
<inp2:m_phrase label="$title"/>
</td>
<inp2:m_blockend/>
<inp2:m_block name="grid_checkbox_td" format="" />
<td valign="top" class="text">
<table border="0" cellpadding="0" cellspacing="0" class="grid_id_cell">
<tr>
<td><input type="checkbox" name="<inp2:$PrefixSpecial_InputName field="$IdField" IdField="$IdField"/>" id="<inp2:$PrefixSpecial_InputName field="$IdField" IdField="$IdField"/>"></td>
<td><img src="<inp2:ModulePath />img/itemicons/<inp2:$PrefixSpecial_ItemIcon grid="$grid"/>"></td>
<td><inp2:$PrefixSpecial_field field="$field" no_special="no_special" format="$format"/></td>
</tr>
</table>
</td>
<inp2:m_blockend />
<inp2:m_block name="grid_checkbox_td_no_icon" format="" />
<td valign="top" class="text">
<table border="0" cellpadding="0" cellspacing="0" class="grid_id_cell">
<tr>
<td><input type="checkbox" name="<inp2:$PrefixSpecial_InputName field="$IdField" IdField="$IdField"/>" id="<inp2:$PrefixSpecial_InputName field="$IdField" IdField="$IdField"/>"></td>
<td><inp2:$PrefixSpecial_field field="$field" no_special="no_special" format="$format"/></td>
</tr>
</table>
</td>
<inp2:m_blockend />
<inp2:m_block name="label_grid_checkbox_td" format="" />
<td valign="top" class="text">
<table border="0" cellpadding="0" cellspacing="0" class="grid_id_cell">
<tr>
<td><input type="checkbox" name="<inp2:$PrefixSpecial_InputName field="$IdField" IdField="$IdField"/>" id="<inp2:$PrefixSpecial_InputName field="$IdField" IdField="$IdField"/>"></td>
<td><img src="<inp2:ModulePath />img/itemicons/<inp2:$PrefixSpecial_ItemIcon grid="$grid"/>"></td>
<td><inp2:$PrefixSpecial_field field="$field" no_special="no_special" as_label="as_label" format="$format"/></td>
</tr>
</table>
</td>
<inp2:m_blockend />
<inp2:m_block name="grid_icon_td" format="" />
<td valign="top" class="text">
<table border="0" cellpadding="0" cellspacing="0" class="grid_id_cell">
<tr>
<td><img src="<inp2:ModulePath />img/itemicons/<inp2:$PrefixSpecial_ItemIcon grid="$grid"/>"></td>
<td><inp2:$PrefixSpecial_field field="$field" no_special="no_special" format="$format"/></td>
</tr>
</table>
</td>
<inp2:m_blockend />
<inp2:m_block name="grid_radio_td" format="" />
<td valign="top" class="text">
<table border="0" cellpadding="0" cellspacing="0" class="grid_id_cell">
<tr>
<td><input type="radio" name="<inp2:$PrefixSpecial_InputName field="$IdField" IdField="$IdField"/>" id="<inp2:$PrefixSpecial_InputName field="$IdField" IdField="$IdField"/>"></td>
<td><img src="<inp2:ModulePath />img/itemicons/<inp2:$PrefixSpecial_ItemIcon grid="$grid"/>"></td>
<td><inp2:$PrefixSpecial_field field="$field" no_special="no_special" format="$format"/></td>
</tr>
</table>
</td>
<inp2:m_blockend />
-
+
<inp2:m_block name="grid_data_td" format="" no_special="" />
<td valign="top" class="text"><inp2:$PrefixSpecial_field field="$field" grid="$grid" no_special="$no_special" format="$format"/></td>
<inp2:m_blockend />
<inp2:m_block name="grid_edit_td" format="" />
<td valign="top" class="text"><input type="text" id="<inp2:$PrefixSpecial_InputName field="$field"/>" name="<inp2:$PrefixSpecial_InputName field="$field"/>" value="<inp2:$PrefixSpecial_field field="$field" grid="$grid" format="$format"/>"></td>
<inp2:m_blockend />
<inp2:m_block name="grid_data_label_td" />
<td valign="top" class="text"><inp2:$PrefixSpecial_field field="$field" grid="$grid" as_label="1" no_special="no_special" format="$format"/></td>
<inp2:m_blockend />
<inp2:m_block name="grid_data_label_ml_td" format="" />
<td valign="top" class="text">
<inp2:$PrefixSpecial_field field="$field" grid="$grid" as_label="1" no_special="no_special" format="$format"/>:<br />
- <a href="javascript:PreSaveAndOpenTranslatorCV('p,cv', 'cv:Value', 'popups/translator', <inp2:$PrefixSpecial_field field="CustomFieldId"/>);" title="<inp2:m_Phrase label="la_Translate"/>"><img src="img/icons/icon24_translate.gif" style="cursor:hand;" border="0"></a>
+ <inp2:m_if check="FieldEquals" field="$ElementTypeField" value="textarea">
+ <a href="javascript:PreSaveAndOpenTranslatorCV('p,cv', 'cv:Value', 'popups/translator', <inp2:$PrefixSpecial_field field="CustomFieldId"/>, 1);" title="<inp2:m_Phrase label="la_Translate"/>"><img src="img/icons/icon24_translate.gif" style="cursor:hand;" border="0"></a>
+ <inp2:m_else/>
+ <a href="javascript:PreSaveAndOpenTranslatorCV('p,cv', 'cv:Value', 'popups/translator', <inp2:$PrefixSpecial_field field="CustomFieldId"/>);" title="<inp2:m_Phrase label="la_Translate"/>"><img src="img/icons/icon24_translate.gif" style="cursor:hand;" border="0"></a>
+ </inp2:m_if>
</td>
<inp2:m_blockend />
<inp2:m_block name="viewmenu_sort_block"/>
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'].addMenuItem('<inp2:m_phrase name="$title"/>','direct_sort_grid("<inp2:m_param name="PrefixSpecial"/>","<inp2:m_param name="sort_field"/>","<inp2:$PrefixSpecial_OrderInfo type="direction" pos="1"/>");','<inp2:m_if prefix="$PrefixSpecial" function="IsOrder" field="$sort_field" pos="1"/>2<inp2:m_endif/>');
<inp2:m_blockend/>
<inp2:m_block name="viewmenu_filter_block"/>
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'].addMenuItem('<inp2:m_param name="label"/>','<inp2:m_param name="filter_action"/>','<inp2:m_param name="filter_status"/>');
<inp2:m_blockend/>
-
+
<inp2:m_block name="viewmenu_filter_separator"/>
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'].addMenuSeparator();
<inp2:m_blockend/>
<inp2:m_block name="viewmenu_declaration"/>
// define ViewMenu
$fw_menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'] = function()
{
<inp2:m_if prefix="m" function="ParamEquals" name="has_filters" value="has_filters"/>
// filtring menu
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'] = new Menu('<inp2:m_phrase name="la_Text_View"/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'].addMenuItem('All','filters_remove_all("<inp2:m_param name="PrefixSpecial"/>");');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'].addMenuItem('None','filters_apply_all("<inp2:m_param name="PrefixSpecial"/>");');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'].addMenuSeparator();
<inp2:$PrefixSpecial_DrawFilterMenu item_block="viewmenu_filter_block" spearator_block="viewmenu_filter_separator"/>
<inp2:m_endif/>
-
+
// sorting menu
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'] = new Menu('<inp2:m_phrase name="la_Text_Sort"/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'].addMenuItem('<inp2:m_phrase name="la_common_ascending"/>','direct_sort_grid("<inp2:m_param name="PrefixSpecial"/>","<inp2:$PrefixSpecial_OrderInfo type="field" pos="1"/>","asc");','<inp2:m_if prefix="$PrefixSpecial" function="IsOrder" direction="asc" pos="1"/>2<inp2:m_endif/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'].addMenuItem('<inp2:m_phrase name="la_common_descending"/>','direct_sort_grid("<inp2:m_param name="PrefixSpecial"/>","<inp2:$PrefixSpecial_OrderInfo type="field" pos="1"/>","desc");','<inp2:m_if prefix="$PrefixSpecial" function="IsOrder" direction="desc" pos="1"/>2<inp2:m_endif/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'].addMenuSeparator();
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'].addMenuItem('<inp2:m_phrase name="la_Text_Default"/>','reset_sorting("<inp2:m_param name="PrefixSpecial"/>");');
<inp2:$PrefixSpecial_IterateGridFields grid="$grid" mode="header" block="viewmenu_sort_block"/>
-
+
// per page menu
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'] = new Menu('<inp2:m_phrase name="la_prompt_PerPage"/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'].addMenuItem('10','set_per_page("<inp2:m_param name="PrefixSpecial"/>",10);','<inp2:m_if prefix="$PrefixSpecial" function="PerPageEquals" value="10"/>2<inp2:m_endif/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'].addMenuItem('20','set_per_page("<inp2:m_param name="PrefixSpecial"/>",20);','<inp2:m_if prefix="$PrefixSpecial" function="PerPageEquals" value="20"/>2<inp2:m_endif/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'].addMenuItem('50','set_per_page("<inp2:m_param name="PrefixSpecial"/>",50);','<inp2:m_if prefix="$PrefixSpecial" function="PerPageEquals" value="50"/>2<inp2:m_endif/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'].addMenuItem('100','set_per_page("<inp2:m_param name="PrefixSpecial"/>",100);','<inp2:m_if prefix="$PrefixSpecial" function="PerPageEquals" value="100"/>2<inp2:m_endif/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'].addMenuItem('500','set_per_page("<inp2:m_param name="PrefixSpecial"/>",500);','<inp2:m_if prefix="$PrefixSpecial" function="PerPageEquals" value="500"/>2<inp2:m_endif/>');
-
+
// select menu
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_select_menu'] = new Menu('<inp2:m_phrase name="la_Text_Select"/>');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_select_menu'].addMenuItem('<inp2:m_phrase name="la_Text_All"/>','Grids["<inp2:m_param name="PrefixSpecial"/>"].SelectAll();');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_select_menu'].addMenuItem('<inp2:m_phrase name="la_Text_Unselect"/>','Grids["<inp2:m_param name="PrefixSpecial"/>"].ClearSelection();');
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_select_menu'].addMenuItem('<inp2:m_phrase name="la_Text_Invert"/>','Grids["<inp2:m_param name="PrefixSpecial"/>"].InvertSelection();');
-
+
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'] = new Menu('<inp2:$PrefixSpecial_GetItemName/>');
<inp2:m_if prefix="m" function="ParamEquals" name="has_filters" value="has_filters"/>
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'].addMenuItem( $Menus['<inp2:m_param name="PrefixSpecial"/>'+'_filter_menu'] );
<inp2:m_endif/>
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'].addMenuItem( $Menus['<inp2:m_param name="PrefixSpecial"/>'+'_sorting_menu'] );
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'].addMenuItem( $Menus['<inp2:m_param name="PrefixSpecial"/>'+'_perpage_menu'] );
$Menus['<inp2:m_param name="PrefixSpecial"/>'+'_view_menu'].addMenuItem( $Menus['<inp2:m_param name="PrefixSpecial"/>'+'_select_menu'] );
}
<inp2:m_blockend/>
<inp2:m_block name="grid_save_warning" />
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="table_border_<inp2:m_if prefix="m" function="ParamEquals" name="no_toolbar" value="no_toolbar"/>nobottom<inp2:m_else/>notop<inp2:m_endif/>">
<tr>
<td valign="top" class="hint_red">
<inp2:m_phrase name="la_Warning_Save_Item"/>
</td>
</tr>
</table>
<inp2:m_blockend/>
<inp2:m_block name="grid" main_prefix="" per_page="" main_special="" no_toolbar="" has_filters="" search=""/>
<inp2:$PrefixSpecial_SaveWarning name="grid_save_warning" main_prefix="$main_prefix" no_toolbar="$no_toolbar"/>
<inp2:m_if prefix="m" function="RecallEquals" var="{$PrefixSpecial}_search_keyword" value="" inverse="inverse"/>
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="table_border_<inp2:m_if prefix="m" function="ParamEquals" name="no_toolbar" value="no_toolbar"/>nobottom<inp2:m_else/>notop<inp2:m_endif/>">
<tr>
<td valign="top" class="hint_red">
<inp2:m_phrase name="la_Warning_Filter"/>
</td>
</tr>
</table>
<inp2:m_endif/>
<inp2:m_ParamEquals name="NoPagination" value="">
<inp2:m_ParseBlock name="grid_pagination" grid="$grid" PrefixSpecial="$PrefixSpecial" search="$search" no_toolbar="$no_toolbar"/>
</inp2>
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder">
-
+
<tr class="subsectiontitle">
<inp2:$PrefixSpecial_IterateGridFields grid="$grid" mode="header" block="$header_block"/>
</tr>
-
+
<inp2:m_block name="_row" />
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>" id="<inp2:m_param name="PrefixSpecial"/>_<inp2:$PrefixSpecial_field field="$IdField"/>" sequence="<inp2:m_get param="{$PrefixSpecial}_sequence"/>"><inp2:m_inc param="{$PrefixSpecial}_sequence" by="1"/>
<inp2:$PrefixSpecial_IterateGridFields grid="$grid" mode="data" block="$data_block"/>
</tr>
<inp2:m_blockend />
<inp2:m_set {$PrefixSpecial}_sequence="1" odd_even="table_color1"/>
<inp2:$PrefixSpecial_PrintList block="_row" per_page="$per_page" main_special="$main_special"/>
-
+
</table>
-
+
<inp2:m_if prefix="m" function="GetEquals" name="fw_menu_included" value=""/>
<script type="text/javascript" src="incs/fw_menu.js"></script>
<inp2:m_set fw_menu_included="1"/>
<inp2:m_endif/>
-
+
<script type="text/javascript">
<inp2:m_if check="m_ParamEquals" name="no_init" value="no_init" inverse="inverse">
Grids['<inp2:m_param name="PrefixSpecial"/>'] = new Grid('selected_div', ':original', edit, a_toolbar);
Grids['<inp2:m_param name="PrefixSpecial"/>'].AddItemsByIdMask('tr', /^<inp2:m_param name="PrefixSpecial"/>_([0-9-]+)/, '<inp2:m_param name="PrefixSpecial"/>[$$ID$$][<inp2:m_param name="IdField"/>]');
Grids['<inp2:m_param name="PrefixSpecial"/>'].InitItems();
</inp2:m_if>
<inp2:m_ParseBlock name="viewmenu_declaration" PrefixSpecial="$PrefixSpecial" grid="$grid" has_filters="$has_filters"/>
$ViewMenus = new Array('<inp2:m_param name="PrefixSpecial"/>');
</script>
<input type="hidden" id="<inp2:m_param name="PrefixSpecial"/>_Sort1" name="<inp2:m_param name="PrefixSpecial"/>_Sort1" value="">
<input type="hidden" id="<inp2:m_param name="PrefixSpecial"/>_Sort1_Dir" name="<inp2:m_param name="PrefixSpecial"/>_Sort1_Dir" value="asc">
<inp2:m_blockend />
<inp2:m_block name="white_grid" main_prefix="" per_page="" main_special="" no_toolbar="" has_filters="" search="" render_as="" columns="2" direction="V"/>
<inp2:$PrefixSpecial_SaveWarning name="grid_save_warning" main_prefix="$main_prefix" no_toolbar="$no_toolbar"/>
<inp2:m_if prefix="m" function="RecallEquals" var="{$PrefixSpecial}_search_keyword" value="" inverse="inverse"/>
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="table_border_<inp2:m_if prefix="m" function="ParamEquals" name="no_toolbar" value="no_toolbar"/>nobottom<inp2:m_else/>notop<inp2:m_endif/>">
<tr>
<td valign="top" class="hint_red">
<inp2:m_phrase name="la_Warning_Filter"/>
</td>
</tr>
</table>
<inp2:m_endif/>
<inp2:m_ParamEquals name="NoPagination" value="">
<inp2:m_ParseBlock name="grid_pagination" grid="$grid" PrefixSpecial="$PrefixSpecial" search="$search" no_toolbar="$no_toolbar"/>
</inp2>
<br />
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<inp2:m_set {$PrefixSpecial}_sequence="1" odd_even="table_color1"/>
<inp2:$PrefixSpecial_PrintList2 block="$render_as" direction="$direction" columns="$columns" per_page="$per_page" main_special="$main_special"/>
</table>
-
+
<inp2:m_if prefix="m" function="GetEquals" name="fw_menu_included" value=""/>
<script type="text/javascript" src="incs/fw_menu.js"></script>
<inp2:m_set fw_menu_included="1"/>
<inp2:m_endif/>
-
+
<script type="text/javascript">
<inp2:m_if check="m_ParamEquals" name="no_init" value="no_init" inverse="inverse">
Grids['<inp2:m_param name="PrefixSpecial"/>'] = new Grid('table_white_selected', ':original', edit, a_toolbar);
Grids['<inp2:m_param name="PrefixSpecial"/>'].AddItemsByIdMask('td', /^<inp2:m_param name="PrefixSpecial"/>_([0-9-]+)/, '<inp2:m_param name="PrefixSpecial"/>[$$ID$$][<inp2:m_param name="IdField"/>]');
Grids['<inp2:m_param name="PrefixSpecial"/>'].InitItems();
</inp2:m_if>
<inp2:m_ParseBlock name="viewmenu_declaration" PrefixSpecial="$PrefixSpecial" grid="$grid" has_filters="$has_filters"/>
$ViewMenus = new Array('<inp2:m_param name="PrefixSpecial"/>');
</script>
<input type="hidden" id="<inp2:m_param name="PrefixSpecial"/>_Sort1" name="<inp2:m_param name="PrefixSpecial"/>_Sort1" value="">
<input type="hidden" id="<inp2:m_param name="PrefixSpecial"/>_Sort1_Dir" name="<inp2:m_param name="PrefixSpecial"/>_Sort1_Dir" value="asc">
<inp2:m_blockend />
\ No newline at end of file
Property changes on: trunk/kernel/admin_templates/incs/grid_blocks.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.14
\ No newline at end of property
+1.15
\ No newline at end of property
Index: trunk/kernel/admin_templates/incs/form_blocks.tpl
===================================================================
--- trunk/kernel/admin_templates/incs/form_blocks.tpl (revision 3298)
+++ trunk/kernel/admin_templates/incs/form_blocks.tpl (revision 3299)
@@ -1,259 +1,275 @@
<inp2:m_block name="section_header"/>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr class="section_header_bg">
<td valign="top" class="admintitle" align="left" style="padding-top: 2px; padding-bottom: 2px;">
<img width="46" height="46" src="img/icons/<inp2:m_param name="icon"/>.gif" align="absmiddle" title="<inp2:m_phrase label="$title"/>">&nbsp;<inp2:m_phrase label="$title"/>
-
+
</td>
</tr>
</table>
<inp2:m_blockend/>
<inp2:m_block name="blue_bar"/>
<table border="0" cellpadding="2" cellspacing="0" class="tableborder_full" width="100%" height="30">
<tr>
<td class="header_left_bg" nowrap width="80%" valign="middle">
<span class="tablenav_link" id="blue_bar"><inp2:$prefix_SectionTitle title_preset="$title_preset" title="Invalid OR Missing title preset" cut_first="100"/></span>
</td>
<td align="right" class="tablenav" width="20%" valign="middle">
<script>
var $help_url='<inp2:m_t t="help" h_prefix="$prefix" h_icon="$icon" h_module="$module" h_title_preset="$title_preset" pass="all,m,h" escape="escape" front="1" />';
set_window_title( document.getElementById('blue_bar').innerHTML );
</script>
<a href="javascript: OpenHelp($help_url);">
<img src="img/blue_bar_help.gif" border="0">
</a>
</td>
</tr>
</table>
<inp2:m_blockend/>
-<inp2:m_block name="subsection"/>
+<inp2:m_block name="subsection"/>
<tr class="subsectiontitle">
<td colspan="5"><inp2:m_phrase label="$title"/></td>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_field_caption" subfield="" NamePrefix=""/>
<inp2:m_inc param="tab_index" by="1"/>
<td class="text">
<label for="<inp2:m_param name="NamePrefix"/><inp2:$prefix_InputName field="$field" subfield="$subfield"/>">
<span class="<inp2:m_if prefix="$prefix" function="HasError" field="$field"/>error<inp2:m_endif/>">
<inp2:m_phrase label="$title"/></span><inp2:m_if prefix="$prefix" function="IsRequired" field="$field"/><span class="error"> *</span><inp2:m_endif/>:
</label>
</td>
<inp2:m_blockend/>
<inp2:m_block name="inp_label" is_last="" as_label="" currency="" is_last=""/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_ParseBlock name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td valign="top"><span class="text"><inp2:$prefix_Field field="$field" as_label="$as_label" currency="$currency"/></span></td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_id_label"/>
<inp2:m_if prefix="$prefix" function="FieldEquals" field="$field" value="" inverse="inverse"/>
<inp2:m_ParseBlock name="inp_label" pass_params="true"/>
<inp2:m_endif/>
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_box" subfield="" class="" is_last="" maxlength="" onblur="" size=""/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_ParseBlock name="inp_edit_field_caption" prefix="$prefix" field="$field" subfield="$subfield" title="$title" is_last="$is_last"/>
<td>
<input type="text" name="<inp2:$prefix_InputName field="$field" subfield="$subfield"/>" id="<inp2:$prefix_InputName field="$field" subfield="$subfield"/>" value="<inp2:$prefix_Field field="$field" subfield="$subfield"/>" tabindex="<inp2:m_get param="tab_index"/>" size="<inp2:m_param name="size"/>" maxlength="<inp2:m_param name="maxlength"/>" class="<inp2:m_param name="class"/>" onblur="<inp2:m_Param name="onblur"/>">
</td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_upload" class="" is_last=""/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_ParseBlock name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td>
<input type="file" name="<inp2:$prefix_InputName field="$field"/>" id="<inp2:$prefix_InputName field="$field"/>" tabindex="<inp2:m_get param="tab_index"/>" size="<inp2:m_param name="size"/>" class="<inp2:m_param name="class"/>">
</td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_box_ml" class="" size="" maxlength=""/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<td class="text" valign="top">
<span class="<inp2:m_if prefix="$prefix" function="HasError" field="$field"/>error<inp2:m_endif/>">
<inp2:m_phrase label="$title"/><inp2:m_if prefix="$prefix" function="IsRequired" field="$field"/><span class="error"> *</span><inp2:m_endif/>:</span><br>
<a href="javascript:PreSaveAndOpenTranslator('<inp2:m_param name="prefix"/>', '<inp2:m_param name="field"/>', 'popups/translator');" title="<inp2:m_Phrase label="la_Translate"/>"><img src="img/icons/icon24_translate.gif" style="cursor:hand" border="0"></a>
</td>
<td>
<input type="text" name="<inp2:$prefix_InputName field="$field"/>" id="<inp2:$prefix_InputName field="$field"/>" value="<inp2:$prefix_Field field="$field" format="no_default"/>" tabindex="<inp2:m_get param="tab_index"/>" size="<inp2:m_param name="size"/>" maxlength="<inp2:m_param name="maxlength"/>" class="<inp2:m_param name="class"/>" onblur="<inp2:m_Param name="onblur"/>">
</td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_hidden" db=""/>
<input type="hidden" name="<inp2:$prefix_InputName field="$field"/>" id="<inp2:$prefix_InputName field="$field"/>" value="<inp2:$prefix_Field field="$field" db="$db"/>">
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_date" class="" is_last=""/>
<inp2:m_if check="m_GetEquals" name="calendar_included" value="1" inverse="inverse">
<script type="text/javascript" src="incs/calendar.js"></script>
<inp2:m_set calendar_included="1"/>
</inp2:m_if>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_ParseBlock name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td>
<input type="text" name="<inp2:$prefix_InputName field="{$field}_date"/>" id="<inp2:$prefix_InputName field="{$field}_date"/>" value="<inp2:$prefix_Field field="{$field}_date"/>" tabindex="<inp2:m_get param="tab_index"/>" size="<inp2:$prefix_Format field="{$field}_date" edit_size="edit_size"/>" class="<inp2:m_param name="class"/>" datepickerIcon="<inp2:m_ProjectBase/>admin/images/ddarrow.gif">&nbsp;<span class="small">(<inp2:$prefix_Format field="{$field}_date" human="true"/>)</span>
<script type="text/javascript">
initCalendar("<inp2:$prefix_InputName field="{$field}_date"/>", "<inp2:$prefix_Format field="{$field}_date"/>");
</script>
<input type="hidden" name="<inp2:$prefix_InputName field="{$field}_time"/>" id="<inp2:$prefix_InputName field="{$field}_time"/>" value="">
</td>
<td class="error"><inp2:$prefix_Error field="{$field}_date"/>&nbsp;</td>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_date_time" class="" is_last=""/>
<inp2:m_if check="m_GetEquals" name="calendar_included" value="1" inverse="inverse">
<script type="text/javascript" src="incs/calendar.js"></script>
<inp2:m_set calendar_included="1"/>
</inp2:m_if>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_ParseBlock name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td>
<!-- <input type="hidden" id="<inp2:$prefix_InputName field="$field"/>" name="<inp2:$prefix_InputName field="$field"/>" value="<inp2:$prefix_Field field="$field" db="db"/>"> -->
<input type="text" name="<inp2:$prefix_InputName field="{$field}_date"/>" id="<inp2:$prefix_InputName field="{$field}_date"/>" value="<inp2:$prefix_Field field="{$field}_date"/>" tabindex="<inp2:m_get param="tab_index"/>" size="<inp2:$prefix_Format field="{$field}_date" edit_size="edit_size"/>" class="<inp2:m_param name="class"/>" datepickerIcon="<inp2:m_ProjectBase/>admin/images/ddarrow.gif">
<span class="small">(<inp2:$prefix_Format field="{$field}_date" human="true"/>)</span>
<script type="text/javascript">
initCalendar("<inp2:$prefix_InputName field="{$field}_date"/>", "<inp2:$prefix_Format field="{$field}_date"/>");
</script>
&nbsp;<input type="text" name="<inp2:$prefix_InputName field="{$field}_time"/>" id="<inp2:$prefix_InputName field="{$field}_time"/>" value="<inp2:$prefix_Field field="{$field}_time"/>" tabindex="<inp2:m_get param="tab_index"/>" size="<inp2:$prefix_Format field="{$field}_time" edit_size="edit_size"/>" class="<inp2:m_param name="class"/>"><span class="small"> (<inp2:$prefix_Format field="{$field}_time" human="true"/>)</span>
</td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_textarea" class=""/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<td class="text" valign="top">
<span class="<inp2:m_if prefix="$prefix" function="HasError" field="$field"/>error<inp2:m_endif/>">
<inp2:m_phrase label="$title"/><inp2:m_if prefix="$prefix" function="IsRequired" field="$field"/><span class="error"> *</span><inp2:m_endif/>:</span><br>
<a href="javascript:OpenEditor('&section=in-link:editlink_general','kernel_form','<inp2:$prefix_InputName field="$field"/>');"><img src="img/icons/icon24_link_editor.gif" style="cursor:hand" border="0"></a>
</td>
<td>
<textarea tabindex="<inp2:m_get param="tab_index"/>" id="<inp2:$prefix_InputName field="$field"/>" name="<inp2:$prefix_InputName field="$field"/>" cols="<inp2:m_param name="cols"/>" rows="<inp2:m_param name="rows"/>" class="<inp2:m_param name="class"/>"><inp2:$prefix_Field field="$field"/></textarea>
</td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
</tr>
<inp2:m_blockend/>
+
+<inp2:m_block name="inp_edit_textarea_ml" class=""/>
+ <tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
+ <td class="text" valign="top">
+ <span class="<inp2:m_if prefix="$prefix" function="HasError" field="$field"/>error<inp2:m_endif/>">
+ <inp2:m_phrase label="$title"/><inp2:m_if prefix="$prefix" function="IsRequired" field="$field"/><span class="error"> *</span><inp2:m_endif/>:</span><br>
+ <a href="javascript:OpenEditor('&section=in-link:editlink_general','kernel_form','<inp2:$prefix_InputName field="$field"/>');"><img src="img/icons/icon24_link_editor.gif" style="cursor:hand" border="0"></a>
+ <a href="javascript:PreSaveAndOpenTranslator('<inp2:m_param name="prefix"/>', '<inp2:m_param name="field"/>', 'popups/translator', 1);" title="<inp2:m_Phrase label="la_Translate"/>"><img src="img/icons/icon24_translate.gif" style="cursor:hand" border="0"></a>
+ </td>
+ <td>
+ <textarea tabindex="<inp2:m_get param="tab_index"/>" id="<inp2:$prefix_InputName field="$field"/>" name="<inp2:$prefix_InputName field="$field"/>" cols="<inp2:m_param name="cols"/>" rows="<inp2:m_param name="rows"/>" class="<inp2:m_param name="class"/>"><inp2:$prefix_Field field="$field"/></textarea>
+ </td>
+ <td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
+ </tr>
+<inp2:m_blockend/>
+
<inp2:m_block name="inp_edit_user" class="" is_last=""/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_ParseBlock name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td>
<input type="text" name="<inp2:$prefix_InputName field="$field"/>" id="<inp2:$prefix_InputName field="$field"/>" value="<inp2:$prefix_Field field="$field"/>" tabindex="<inp2:m_get param="tab_index"/>" size="<inp2:m_param name="size"/>" class="<inp2:m_param name="class"/>">
<a href="#" onclick="return OpenUserSelector('','kernel_form','<inp2:$prefix_InputName field="$field"/>');">
<img src="img/icons/icon24_link_user.gif" style="cursor:hand;" border="0">
- </a>
+ </a>
</td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_option_item"/>
- <option value="<inp2:m_param name="key"/>"<inp2:m_param name="selected"/>><inp2:m_param name="option"/></option>
+ <option value="<inp2:m_param name="key"/>"<inp2:m_param name="selected"/>><inp2:m_param name="option"/></option>
<inp2:m_blockend/>
<inp2:m_block name="inp_option_phrase"/>
- <option value="<inp2:m_param name="key"/>"<inp2:m_param name="selected"/>><inp2:m_phrase label="$option"/></option>
+ <option value="<inp2:m_param name="key"/>"<inp2:m_param name="selected"/>><inp2:m_phrase label="$option"/></option>
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_options" is_last="" has_empty="0" empty_value=""/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_ParseBlock name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td>
<select tabindex="<inp2:m_get param="tab_index"/>" name="<inp2:$prefix_InputName field="$field"/>" id="<inp2:$prefix_InputName field="$field"/>" onchange="<inp2:m_Param name="onchange"/>">
<inp2:m_if prefix="m" function="ParamEquals" name="use_phrases" value="1"/>
<inp2:$prefix_PredefinedOptions field="$field" block="inp_option_phrase" selected="selected" has_empty="$has_empty" empty_value="$empty_value"/>
<inp2:m_else/>
<inp2:$prefix_PredefinedOptions field="$field" block="inp_option_item" selected="selected" has_empty="$has_empty" empty_value="$empty_value"/>
<inp2:m_endif/>
</select>
</td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_radio_item"/>
- <input type="radio" <inp2:m_param name="checked"/> name="<inp2:$prefix_InputName field="$field"/>" id="<inp2:$prefix_InputName field="$field"/>_<inp2:m_param name="key"/>" value="<inp2:m_param name="key"/>" onclick="<inp2:m_param name="onclick"/>"><label for="<inp2:$prefix_InputName field="$field"/>_<inp2:m_param name="key"/>"><inp2:m_phrase label="$option"/></label>&nbsp;
+ <input type="radio" <inp2:m_param name="checked"/> name="<inp2:$prefix_InputName field="$field"/>" id="<inp2:$prefix_InputName field="$field"/>_<inp2:m_param name="key"/>" value="<inp2:m_param name="key"/>" onclick="<inp2:m_param name="onclick"/>"><label for="<inp2:$prefix_InputName field="$field"/>_<inp2:m_param name="key"/>"><inp2:m_phrase label="$option"/></label>&nbsp;
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_radio" is_last="" pass_tabindex="" onclick=""/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_ParseBlock name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td>
<inp2:$prefix_PredefinedOptions field="$field" tabindex="$pass_tabindex" block="inp_radio_item" selected="checked" onclick="$onclick" />
</td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_checkbox" is_last="" field_class="" onchange=""/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_ParseBlock name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last" NamePrefix="_cb_"/>
<td>
<input type="hidden" id="<inp2:$prefix_InputName field="$field"/>" name="<inp2:$prefix_InputName field="$field"/>" value="<inp2:$prefix_Field field="$field" db="db"/>">
<input tabindex="<inp2:m_get param="tab_index"/>" type="checkbox" id="_cb_<inp2:$prefix_InputName field="$field"/>" name="_cb_<inp2:$prefix_InputName field="$field"/>" <inp2:$prefix_Field field="$field" checked="checked" db="db"/> class="<inp2:m_param name="field_class"/>" onclick="update_checkbox(this, document.getElementById('<inp2:$prefix_InputName field="$field"/>'))" onchange="<inp2:m_param name="onchange" />">
<inp2:m_if check="{$prefix}_HasParam" name="hint_label"><inp2:m_phrase label="$hint_label"/></inp2:m_if>
</td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_checkbox_item"/>
- <input type="checkbox" <inp2:m_param name="checked"/> id="<inp2:$prefix_InputName field="$field"/>_<inp2:m_param name="key"/>" value="<inp2:m_param name="key"/>" onclick="update_checkbox_options(/^<inp2:$prefix_InputName field="$field" as_preg="1"/>_([0-9A-Za-z-]+)/, '<inp2:$prefix_InputName field="$field"/>');"><label for="<inp2:$prefix_InputName field="$field"/>_<inp2:m_param name="key"/>"><inp2:m_param name="option"/></label>&nbsp;
+ <input type="checkbox" <inp2:m_param name="checked"/> id="<inp2:$prefix_InputName field="$field"/>_<inp2:m_param name="key"/>" value="<inp2:m_param name="key"/>" onclick="update_checkbox_options(/^<inp2:$prefix_InputName field="$field" as_preg="1"/>_([0-9A-Za-z-]+)/, '<inp2:$prefix_InputName field="$field"/>');"><label for="<inp2:$prefix_InputName field="$field"/>_<inp2:m_param name="key"/>"><inp2:m_param name="option"/></label>&nbsp;
<inp2:m_blockend/>
<inp2:m_block name="inp_checkbox_phrase"/>
- <input type="checkbox" <inp2:m_param name="checked"/> id="<inp2:$prefix_InputName field="$field"/>_<inp2:m_param name="key"/>" value="<inp2:m_param name="key"/>" onclick="update_checkbox_options(/^<inp2:$prefix_InputName field="$field" as_preg="1"/>_([0-9A-Za-z-]+)/, '<inp2:$prefix_InputName field="$field"/>');"><label for="<inp2:$prefix_InputName field="$field"/>_<inp2:m_param name="key"/>"><inp2:m_phrase label="$option"/></label>&nbsp;
+ <input type="checkbox" <inp2:m_param name="checked"/> id="<inp2:$prefix_InputName field="$field"/>_<inp2:m_param name="key"/>" value="<inp2:m_param name="key"/>" onclick="update_checkbox_options(/^<inp2:$prefix_InputName field="$field" as_preg="1"/>_([0-9A-Za-z-]+)/, '<inp2:$prefix_InputName field="$field"/>');"><label for="<inp2:$prefix_InputName field="$field"/>_<inp2:m_param name="key"/>"><inp2:m_phrase label="$option"/></label>&nbsp;
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_checkboxes" is_last=""/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_ParseBlock name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title" is_last="$is_last"/>
<td>
<inp2:m_if check="m_ParamEquals" name="use_phrases" value="1">
- <inp2:$prefix_PredefinedOptions field="$field" no_empty="$no_empty" tabindex="$pass_tabindex" hint_label="$hint_label" block="inp_checkbox_phrase" selected="checked"/>
+ <inp2:$prefix_PredefinedOptions field="$field" no_empty="$no_empty" tabindex="$pass_tabindex" hint_label="$hint_label" block="inp_checkbox_phrase" selected="checked"/>
<inp2:m_else/>
<inp2:$prefix_PredefinedOptions field="$field" no_empty="$no_empty" tabindex="$pass_tabindex" hint_label="$hint_label" block="inp_checkbox_item" selected="checked"/>
</inp2:m_if>
<inp2:m_ParseBlock prefix="$prefix" name="inp_edit_hidden" field="$field"/>
</td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
</tr>
<inp2:m_blockend/>
<inp2:m_block name="inp_edit_weight" subfield="" class="" is_last=""/>
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_ParseBlock name="inp_edit_field_caption" prefix="$prefix" field="$field" subfield="$subfield" title="$title" is_last="$is_last"/>
<td>
<inp2:m_if check="lang.current_FieldEquals" field="UnitSystem" value="1">
<input type="text" name="<inp2:$prefix_InputName field="$field" subfield="$subfield"/>" id="<inp2:$prefix_InputName field="$field" subfield="$subfield"/>" value="<inp2:$prefix_Field field="$field" subfield="$subfield"/>" tabindex="<inp2:m_get param="tab_index"/>" size="<inp2:m_param name="size"/>" maxlength="<inp2:m_param name="maxlength"/>" class="<inp2:m_param name="class"/>" onblur="<inp2:m_Param name="onblur"/>">
<inp2:m_phrase label="la_kg" />
</inp2:m_if>
<inp2:m_if check="lang.current_FieldEquals" field="UnitSystem" value="2">
<input type="text" name="<inp2:$prefix_InputName field="{$field}_a" subfield="$subfield"/>" id="<inp2:$prefix_InputName field="{$field}_a" subfield="$subfield"/>" value="<inp2:$prefix_Field field="{$field}_a" subfield="$subfield"/>" tabindex="<inp2:m_get param="tab_index"/>" size="<inp2:m_param name="size"/>" maxlength="<inp2:m_param name="maxlength"/>" class="<inp2:m_param name="class"/>" onblur="<inp2:m_Param name="onblur"/>">
<inp2:m_phrase label="la_lbs" />
<input type="text" name="<inp2:$prefix_InputName field="{$field}_b" subfield="$subfield"/>" id="<inp2:$prefix_InputName field="{$field}_b" subfield="$subfield"/>" value="<inp2:$prefix_Field field="{$field}_b" subfield="$subfield"/>" tabindex="<inp2:m_get param="tab_index"/>" size="<inp2:m_param name="size"/>" maxlength="<inp2:m_param name="maxlength"/>" class="<inp2:m_param name="class"/>" onblur="<inp2:m_Param name="onblur"/>">
<inp2:m_phrase label="la_oz" />
- </inp2:m_if>
+ </inp2:m_if>
</td>
<td class="error"><inp2:$prefix_Error field="$field"/>&nbsp;</td>
</tr>
<inp2:m_blockend />
\ No newline at end of file
Property changes on: trunk/kernel/admin_templates/incs/form_blocks.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.19
\ No newline at end of property
+1.20
\ No newline at end of property
Index: trunk/core/kernel/db/db_event_handler.php
===================================================================
--- trunk/core/kernel/db/db_event_handler.php (revision 3298)
+++ trunk/core/kernel/db/db_event_handler.php (revision 3299)
@@ -1,1539 +1,1534 @@
<?php
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
* $event->Prefix_Special as usual. This is due PHP
* is converting "." symbols in variable names during
* submit info "_". $event->getPrefixSpecial optional
* 1st parameter returns correct corrent Prefix_Special
* for variables beeing submitted such way (e.g. variable
* name that will be converted by PHP: "users.read_only_id"
* will be submitted as "users_read_only_id".
*
* 2. When using $this->Application-LinkVar on variables submitted
* from form which contain $Prefix_Special then note 1st item. Example:
* LinkVar($event->getPrefixSpecial(true).'_varname',$event->Prefix_Special.'_varname')
*
*/
/**
* EventHandler that is used to process
* any database related events
*
*/
class kDBEventHandler extends kEventHandler {
-
+
/**
* Description
*
* @var kDBConnection
* @access public
*/
var $Conn;
-
+
/**
* Adds ability to address db connection
*
* @return kDBEventHandler
* @access public
*/
function kDBEventHandler()
{
parent::kBase();
$this->Conn =& $this->Application->GetADODBConnection();
}
-
+
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
* or by looking at first from selected ids, stored.
* Returned id is also stored in Session in case
* it was explicitly passed as get/post
*
* @param kEvent $event
* @return int
*/
function getPassedID(&$event)
{
//$ret = $this->Application->GetLinkedVar($event->getPrefixSpecial(true).'_id', $event->getPrefixSpecial().'_id');
-
+
// ?? We don't need to store selected id in session, as long as we have pass=all by default, which
// means that main item id will be passed to all sub-item screens by default
// another prove of that is that sub-items relay on main item '_mode' = 't' for switching to temp tables
- // Also having id in session raised problems with the id of deleted item stuck in session
-
-
+ // Also having id in session raised problems with the id of deleted item stuck in session
+
+
// 1. get id from post (used in admin)
$ret = $this->Application->GetVar($event->getPrefixSpecial(true).'_id');
if($ret) return $ret;
-
+
// 2. get id from env (used in front)
$ret = $this->Application->GetVar($event->getPrefixSpecial().'_id');
if($ret) return $ret;
-
+
// recall selected ids array and use the first one
$ids=$this->Application->GetVar($event->getPrefixSpecial().'_selected_ids');
if ($ids != '') {
$ids=explode(',',$ids);
if($ids) $ret=array_shift($ids);
}
else { // if selected ids are not yet stored
$this->StoreSelectedIDs($event);
return $this->Application->GetVar($event->getPrefixSpecial(true).'_id'); // StoreSelectedIDs sets this variable
}
return $ret;
}
-
+
/**
* Prepares and stores selected_ids string
* in Session and Application Variables
- * by getting all checked ids from grid plus
+ * by getting all checked ids from grid plus
* id passed in get/post as prefix_id
*
* @param kEvent $event
*/
function StoreSelectedIDs(&$event)
{
$ret = Array();
-
+
// May be we don't need this part: ?
$passed = $this->Application->GetVar($event->getPrefixSpecial(true).'_id');
if($passed !== false && $passed != '')
{
array_push($ret, $passed);
}
-
+
$ids = Array();
-
+
// get selected ids from post & save them to session
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if($items_info)
{
$id_field = $this->Application->getUnitOption($event->Prefix,'IDField');
foreach($items_info as $id => $field_values)
{
if( getArrayValue($field_values,$id_field) ) array_push($ids,$id);
}
//$ids=array_keys($items_info);
}
-
+
$ret = array_unique(array_merge($ret, $ids));
-
+
$this->Application->SetVar($event->getPrefixSpecial().'_selected_ids',implode(',',$ret));
$this->Application->LinkVar($event->getPrefixSpecial().'_selected_ids');
-
+
// This is critical - otherwise getPassedID will return last ID stored in session! (not exactly true)
// this smells... needs to be refactored
$first_id = getArrayValue($ret,0);
if($first_id === false)
{
// $this->Application->Debugger->appendTrace();
trigger_error('Requested ID for prefix <b>'.$event->getPrefixSpecial().'</b> <span class="debug_error">not passed</span>',E_USER_NOTICE);
}
$this->Application->SetVar($event->getPrefixSpecial(true).'_id', $first_id);
}
-
+
/**
* Returns stored selected ids as an array
*
* @param kEvent $event
* @return array
*/
function getSelectedIDs(&$event)
{
return explode(',', $this->Application->GetVar($event->getPrefixSpecial().'_selected_ids'));
}
-
+
/**
* Returs associative array of submitted fields for current item
- * Could be used while creating/editing single item -
+ * Could be used while creating/editing single item -
* meaning on any edit form, except grid edit
*
* @param kEvent $event
*/
function getSubmittedFields(&$event)
{
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
$field_values = $items_info ? array_shift($items_info) : Array();
return $field_values;
}
-
+
/**
* Removes any information about current/selected ids
* from Application variables and Session
*
* @param kEvent $event
*/
function clearSelectedIDs(&$event)
{
$prefix_special = $event->getPrefixSpecial();
$ids = $this->Application->RecallVar($prefix_special.'_selected_ids');
- $event->setEventParam('ids', $ids);
-
+ $event->setEventParam('ids', $ids);
+
$this->Application->RemoveVar($prefix_special.'_selected_ids');
$this->Application->SetVar($prefix_special.'_selected_ids', '');
-
+
$this->Application->SetVar($prefix_special.'_id', ''); // $event->getPrefixSpecial(true).'_id' too may be
}
-
+
/*function SetSaveEvent(&$event)
{
$this->Application->SetVar($event->Prefix_Special.'_SaveEvent','OnUpdate');
$this->Application->LinkVar($event->Prefix_Special.'_SaveEvent');
}*/
-
+
/**
* Common builder part for Item & List
*
* @param kDBBase $object
* @param kEvent $event
* @access private
*/
function dbBuild(&$object,&$event)
{
$object->Configure();
$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)
*
* @param kEvent $event
* @access protected
*/
function OnItemBuild(&$event)
{
$object =& $event->getObject();
$this->dbBuild($object,$event);
-
+
$sql = $this->ItemPrepareQuery($event);
$sql = $this->Application->ReplaceLanguageTags($sql);
$object->setSelectSQL($sql);
-
+
// 2. loads if allowed
$auto_load = $this->Application->getUnitOption($event->Prefix,'AutoLoad');
$skip_autload = $event->getEventParam('skip_autoload');
-
+
if($auto_load && !$skip_autload) $this->LoadItem($event);
$actions =& $this->Application->recallObject('kActions');
$actions->Set($event->Prefix_Special.'_GoTab', '');
-
+
$actions->Set($event->Prefix_Special.'_GoId', '');
}
-
+
/**
* Build subtables array from configs
- *
+ *
* @param kEvent $event
*/
function OnTempHandlerBuild(&$event)
{
$object =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
$object->BuildTables( $event->Prefix, $this->getSelectedIDs($event) );
}
-
+
/**
* Enter description here...
*
* @param kEvent $event
* @return unknown
- */
+ */
function UseTempTables(&$event)
{
$object = &$event->getObject();
$top_prefix = $this->Application->GetTopmostPrefix($event->Prefix);
return $this->Application->GetVar($top_prefix.'_mode') == 't';
}
-
+
/**
* Returns table prefix from event (temp or live)
*
* @param kEvent $event
* @return string
* @todo Needed? Should be refactored (by Alex)
*/
function TablePrefix(&$event)
{
return $this->UseTempTables($event) ? kTempTablesHandler::GetTempTablePrefix().TABLE_PREFIX : TABLE_PREFIX;
}
-
+
function LoadItem(&$event)
{
$object =& $event->getObject();
$id = $this->getPassedID($event);
if ($object->Load($id) )
{
$actions =& $this->Application->recallObject('kActions');
$actions->Set($event->Prefix_Special.'_id', $object->GetId() );
}
else
{
$object->setID($id);
}
}
-
+
/**
* Builds list
*
* @param kEvent $event
* @access protected
*/
function OnListBuild(&$event)
{
$object =& $event->getObject();
-
+
$this->dbBuild($object,$event);
-
+
$sql = $this->ListPrepareQuery($event);
$sql = $this->Application->ReplaceLanguageTags($sql);
$object->setSelectSQL($sql);
-
+
$object->linkToParent( $this->getMainSpecial($event) );
-
+
$this->AddFilters($event);
$this->SetCustomQuery($event); // new!, use this for dynamic queries based on specials for ex.
$this->SetPagination($event);
$this->SetSorting($event);
-
+
$object->CalculateTotals();
-
+
$actions =& $this->Application->recallObject('kActions');
$actions->Set('remove_specials['.$event->Prefix_Special.']', '0');
$actions->Set($event->Prefix_Special.'_GoTab', '');
}
-
-
+
+
/**
* Get's special of main item for linking with subitem
*
* @param kEvent $event
* @return string
*/
function getMainSpecial(&$event)
{
$special = $event->getEventParam('main_special');
if($special === false || $special == '$main_special')
{
$special = $event->Special;
}
return $special;
}
-
+
/**
* Apply any custom changes to list's sql query
*
* @param kEvent $event
* @access protected
* @see OnListBuild
*/
function SetCustomQuery(&$event)
{
-
+
}
-
+
/**
* Set's new perpage for grid
*
* @param kEvent $event
*/
function OnSetPerPage(&$event)
{
$per_page = $this->Application->GetVar($event->getPrefixSpecial(true).'_PerPage');
- $this->Application->StoreVar( $event->getPrefixSpecial().'_PerPage', $per_page );
+ $this->Application->StoreVar( $event->getPrefixSpecial().'_PerPage', $per_page );
}
-
+
/**
* Set's correct page for list
* based on data provided with event
*
* @param kEvent $event
* @access private
* @see OnListBuild
*/
function SetPagination(&$event)
{
// get PerPage (forced -> session -> config -> 10)
$per_page = $this->getPerPage($event);
-
+
$object =& $event->getObject();
$object->SetPerPage($per_page);
$this->Application->StoreVarDefault($event->getPrefixSpecial().'_Page', 1);
-
+
$page = $this->Application->GetVar($event->getPrefixSpecial().'_Page');
if (!$page) {
$page = $this->Application->GetVar($event->getPrefixSpecial(true).'_Page');
}
if (!$page) {
$page = $this->Application->RecallVar($event->getPrefixSpecial().'_Page');
}
else {
$this->Application->StoreVar($event->getPrefixSpecial().'_Page', $page);
}
-
+
// $page = $this->Application->GetLinkedVar($event->getPrefixSpecial(true).'_Page', $event->getPrefixSpecial().'_Page');
if( !$event->getEventParam('skip_counting') )
{
$pages = $object->GetTotalPages();
if($page > $pages)
{
$this->Application->StoreVar($event->getPrefixSpecial().'_Page', 1);
$page = 1;
}
}
-
+
$object->SetPage($page);
}
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
*
* @param kEvent $event
* @access private
* @see OnListBuild
*/
function SetSorting(&$event)
{
$event->setPseudoClass('_List');
$object =& $event->getObject();
-
+
$cur_sort1 = $this->Application->RecallVar($event->Prefix_Special.'_Sort1');
$cur_sort1_dir = $this->Application->RecallVar($event->Prefix_Special.'_Sort1_Dir');
$cur_sort2 = $this->Application->RecallVar($event->Prefix_Special.'_Sort2');
$cur_sort2_dir = $this->Application->RecallVar($event->Prefix_Special.'_Sort2_Dir');
-
+
$sorting_configs = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping');
- $list_sortings = $this->Application->getUnitOption($event->Prefix, 'ListSortings');
+ $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);
$cur_sort1 = key($sorting);
$cur_sort1_dir = current($sorting);
if (next($sorting)) {
$cur_sort2 = key($sorting);
$cur_sort2_dir = current($sorting);
}
}
}
-
+
if ( $forced_sorting = getArrayValue($list_sortings, $sorting_prefix, 'ForcedSorting') ) {
foreach ($forced_sorting as $field => $dir) {
$object->AddOrderField($field, $dir);
}
}
if($cur_sort1 != '' && $cur_sort1_dir != '')
{
$object->AddOrderField($cur_sort1, $cur_sort1_dir);
}
if($cur_sort2 != '' && $cur_sort2_dir != '')
{
$object->AddOrderField($cur_sort2, $cur_sort2_dir);
}
}
-
+
/**
* Add filters found in session
*
* @param kEvent $event
*/
function AddFilters(&$event)
{
$object =& $event->getObject();
-
+
$search_filter = $this->Application->RecallVar($event->getPrefixSpecial().'_search_filter');
if($search_filter)
{
$search_filter = unserialize($search_filter);
foreach($search_filter as $search_field => $filter_params)
{
$filter_type = ($filter_params['type'] == 'having') ? HAVING_FILTER : WHERE_FILTER;
$object->addFilter($search_field, $filter_params['value'], $filter_type, FLT_SEARCH);
- }
+ }
}
-
+
$view_filter = $this->Application->RecallVar($event->getPrefixSpecial().'_view_filter');
if($view_filter)
{
$view_filter = unserialize($view_filter);
$temp_filter =& $this->Application->makeClass('kMultipleFilter');
$filter_menu = $this->Application->getUnitOption($event->Prefix,'FilterMenu');
-
+
$group_key = 0; $group_count = count($filter_menu['Groups']);
while($group_key < $group_count)
{
$group_info = $filter_menu['Groups'][$group_key];
-
+
$temp_filter->setType( constant('FLT_TYPE_'.$group_info['mode']) );
$temp_filter->clearFilters();
foreach ($group_info['filters'] as $flt_id)
{
$sql_key = getArrayValue($view_filter,$flt_id) ? 'on_sql' : 'off_sql';
if ($filter_menu['Filters'][$flt_id][$sql_key] != '')
{
$temp_filter->addFilter('view_filter_'.$flt_id, $filter_menu['Filters'][$flt_id][$sql_key]);
}
}
$object->addFilter('view_group_'.$group_key, $temp_filter, $group_info['type'] , FLT_VIEW);
$group_key++;
}
}
}
-
+
/**
* Set's new sorting for list
*
* @param kEvent $event
* @access protected
*/
function OnSetSorting(&$event)
{
$cur_sort1 = $this->Application->RecallVar($event->Prefix_Special.'_Sort1');
$cur_sort1_dir = $this->Application->RecallVar($event->Prefix_Special.'_Sort1_Dir');
$cur_sort2 = $this->Application->RecallVar($event->Prefix_Special.'_Sort2');
$cur_sort2_dir = $this->Application->RecallVar($event->Prefix_Special.'_Sort2_Dir');
-
+
$passed_sort1 = $this->Application->GetVar($event->getPrefixSpecial(true).'_Sort1');
if ($cur_sort1 == $passed_sort1) {
$cur_sort1_dir = $cur_sort1_dir == 'asc' ? 'desc' : 'asc';
}
else {
$cur_sort2 = $cur_sort1;
$cur_sort2_dir = $cur_sort1_dir;
$cur_sort1 = $passed_sort1;
$cur_sort1_dir = 'asc';
}
$this->Application->StoreVar($event->Prefix_Special.'_Sort1', $cur_sort1);
$this->Application->StoreVar($event->Prefix_Special.'_Sort1_Dir', $cur_sort1_dir);
$this->Application->StoreVar($event->Prefix_Special.'_Sort2', $cur_sort2);
$this->Application->StoreVar($event->Prefix_Special.'_Sort2_Dir', $cur_sort2_dir);
}
-
+
/**
* Set sorting directly to session
*
* @param kEvent $event
*/
function OnSetSortingDirect(&$event)
{
$combined = $this->Application->GetVar($event->getPrefixSpecial(true).'_CombinedSorting');
if ($combined) {
list($field,$dir) = explode('|',$combined);
$this->Application->StoreVar($event->Prefix_Special.'_Sort1', $field);
$this->Application->StoreVar($event->Prefix_Special.'_Sort1_Dir', $dir);
return;
}
-
+
$field_pos = $this->Application->GetVar($event->getPrefixSpecial(true).'_SortPos');
$this->Application->LinkVar( $event->getPrefixSpecial(true).'_Sort'.$field_pos, $event->Prefix_Special.'_Sort'.$field_pos);
$this->Application->LinkVar( $event->getPrefixSpecial(true).'_Sort'.$field_pos.'_Dir', $event->Prefix_Special.'_Sort'.$field_pos.'_Dir');
}
-
+
/**
* Reset grid sorting to default (from config)
*
* @param kEvent $event
*/
function OnResetSorting(&$event)
{
$this->Application->RemoveVar($event->Prefix_Special.'_Sort1');
$this->Application->RemoveVar($event->Prefix_Special.'_Sort1_Dir');
$this->Application->RemoveVar($event->Prefix_Special.'_Sort2');
$this->Application->RemoveVar($event->Prefix_Special.'_Sort2_Dir');
}
-
+
/**
* Creates needed sql query to load item,
* if no query is defined in config for
* special requested, then use default
* query
*
* @param kEvent $event
* @access protected
*/
function ItemPrepareQuery(&$event)
{
$sqls = $this->Application->getUnitOption($event->Prefix,'ItemSQLs');
return isset($sqls[$event->Special]) ? $sqls[$event->Special] : $sqls[''];
}
-
+
/**
* Creates needed sql query to load list,
* if no query is defined in config for
* special requested, then use default
* query
*
* @param kEvent $event
* @access protected
*/
function ListPrepareQuery(&$event)
{
$sqls = $this->Application->getUnitOption($event->Prefix,'ListSQLs');
return isset( $sqls[$event->Special] ) ? $sqls[$event->Special] : $sqls[''];
}
-
+
/**
* Apply custom processing to item
*
* @param kEvent $event
*/
function customProcessing(&$event, $type)
{
-
+
}
-
-/* Edit Events mostly used in Admin */
-
+
+/* Edit Events mostly used in Admin */
+
/**
* Creates new kDBItem
*
* @param kEvent $event
* @access protected
*/
function OnCreate(&$event)
{
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject();
-
+
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if($items_info)
{
list($id,$field_values) = each($items_info);
$object->SetFieldsFromHash($field_values);
}
-
+
$this->customProcessing($event,'before');
-
+
//look at kDBItem' Create for ForceCreateId description, it's rarely used and is NOT set by default
if( $object->Create($event->getEventParam('ForceCreateId')) )
{
if( $object->IsTempTable() ) $object->setTempID();
$this->customProcessing($event,'after');
$event->status=erSUCCESS;
$event->redirect_params = Array('opener'=>'u');
}
else
{
$event->status = erFAIL;
$event->redirect = false;
$this->Application->SetVar($event->Prefix_Special.'_SaveEvent','OnCreate');
$object->setID($id);
}
}
-
+
/**
* Updates kDBItem
*
* @param kEvent $event
* @access protected
*/
function OnUpdate(&$event)
{
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject();
-
+
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if($items_info)
{
foreach($items_info as $id => $field_values)
{
$object->Load($id);
$object->SetFieldsFromHash($field_values);
$this->customProcessing($event, 'before');
if( $object->Update($id) )
{
$this->customProcessing($event, 'after');
$event->status=erSUCCESS;
}
- else
+ else
{
$event->status=erFAIL;
$event->redirect=false;
break;
}
- }
+ }
}
$event->redirect_params = Array('opener'=>'u');
}
-
+
/**
* Delete's kDBItem object
*
* @param kEvent $event
* @access protected
*/
function OnDelete(&$event)
{
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject();
$object->ID = $this->getPassedID($event);
if( $object->Delete() )
{
$event->status = erSUCCESS;
}
else
{
$event->status = erFAIL;
$event->redirect = false;
}
}
-
+
/**
* Prepares new kDBItem object
*
* @param kEvent $event
* @access protected
*/
function OnNew(&$event)
{
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject();
$object->setID(0);
$this->Application->SetVar($event->Prefix_Special.'_SaveEvent','OnCreate');
-
+
$table_info = $object->getLinkedInfo();
$object->SetDBField($table_info['ForeignKey'], $table_info['ParentId']);
-
+
$this->Application->setUnitOption($event->Prefix,'AutoLoad',true);
$event->redirect = false;
}
-
+
/**
* Cancel's kDBItem Editing/Creation
*
* @param kEvent $event
* @access protected
*/
function OnCancel(&$event)
{
$event->redirect_params = Array('opener'=>'u');
}
-
-
+
+
/**
* Deletes all selected items.
* Automatically recurse into sub-items using temp handler, and deletes sub-items
* by calling its Delete method if sub-item has AutoDelete set to true in its config file
*
* @param kEvent $event
*/
function OnMassDelete(&$event)
{
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
*
* @param kEvent $event
*/
function OnEdit(&$event)
{
$this->StoreSelectedIDs($event);
-
+
$temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
$temp->PrepareEdit();
-
+
$event->redirect=false;
}
-
+
/**
* Saves content of temp table into live and
* redirects to event' default redirect (normally grid template)
*
* @param kEvent $event
*/
function OnSave(&$event)
{
$event->CallSubEvent('OnPreSave');
if ($event->status==erSUCCESS) {
$skip_master=false;
$temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
-
+
// newly created item
/*if($this->getPassedID($event) == 0)
{
$master_id = $temp->CopyMasterToOriginal();
$temp->UpdateForeignKeys($master_id); // save linked field values
$skip_master = true; //we've already copied master table to get the id
}*/
-
+
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
*
* @param kEvent $event
*/
function OnCancelEdit(&$event)
{
$temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
$temp->CancelEdit();
-
+
$this->clearSelectedIDs($event);
$event->redirect_params = Array('opener'=>'u');
- $this->Application->RemoveVar($event->getPrefixSpecial().'_modified');
+ $this->Application->RemoveVar($event->getPrefixSpecial().'_modified');
}
-
+
/**
* Saves edited item into temp table
* If there is no id, new item is created in temp table
*
* @param kEvent $event
*/
function OnPreSave(&$event)
{
//$event->redirect = false;
// if there is no id - it means we need to create an item
if (is_object($event->MasterEvent)) {
$event->MasterEvent->setEventParam('IsNew',false);
}
$item_id = $this->getPassedID($event);
if($item_id == '')
{
$event->CallSubEvent('OnPreSaveCreated');
if (is_object($event->MasterEvent)) {
$event->MasterEvent->setEventParam('IsNew',true);
}
return;
}
-
+
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject();
-
+
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if($items_info)
{
foreach($items_info as $id => $field_values)
{
$object->SetDefaultValues();
$object->Load($id);
$object->SetFieldsFromHash($field_values);
if( $object->Update($id) )
{
$event->status=erSUCCESS;
}
- else
+ 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
*
* @param kEvent $event
*/
function OnPreSaveAndGo(&$event)
{
$event->CallSubEvent('OnPreSave');
if ($event->status==erSUCCESS) {
$event->redirect_params[$event->getPrefixSpecial(true).'_id'] = $this->Application->GetVar($event->Prefix_Special.'_GoId');
}
}
-
+
/**
* Saves edited item in temp table and goes
* to passed tabs, by redirecting to it with OnPreSave event
*
* @param kEvent $event
*/
function OnPreSaveAndGoToTab(&$event)
{
$event->CallSubEvent('OnPreSave');
if ($event->status==erSUCCESS) {
$event->redirect=$this->Application->GetVar($event->getPrefixSpecial(true).'_GoTab');
}
}
-
+
/**
* Saves editable list and goes to passed tab,
* by redirecting to it with empty event
*
* @param kEvent $event
*/
function OnUpdateAndGoToTab(&$event)
{
$event->setPseudoClass('_List');
$event->CallSubEvent('OnUpdate');
if ($event->status==erSUCCESS) {
$event->redirect=$this->Application->GetVar($event->getPrefixSpecial(true).'_GoTab');
}
}
-
+
/**
* Prepare temp tables for creating new item
- * but does not create it. Actual create is
+ * but does not create it. Actual create is
* done in OnPreSaveCreated
*
* @param kEvent $event
*/
function OnPreCreate(&$event)
{
$this->clearSelectedIDs($event);
-
+
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$object =& $event->getObject();
-
+
$temp =& $this->Application->recallObject($event->Prefix.'_TempHandler', 'kTempTablesHandler');
$temp->PrepareEdit();
-
+
$object->setID(0);
-
+
$event->redirect=false;
}
/**
* Creates a new item in temp table and
* stores item id in App vars and Session on succsess
*
* @param kEvent $event
*/
function OnPreSaveCreated(&$event)
{
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
-
+
$items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
if($items_info) $field_values = array_shift($items_info);
-
+
$object =& $event->getObject();
$object->SetFieldsFromHash($field_values);
-
+
$this->customProcessing($event, 'before');
-
+
if( $object->Create() )
{
$this->customProcessing($event, 'after');
$event->redirect_params[$event->getPrefixSpecial(true).'_id'] = $object->GetId();
$event->status=erSUCCESS;
}
else
{
$event->status=erFAIL;
$event->redirect=false;
$object->setID(0);
}
-
+
}
-
-/* End of Edit events */
-
+
+/* End of Edit events */
+
// III. Events that allow to put some code before and after Update,Load,Create and Delete methods of item
-
+
/**
* Occurse before loading item, 'id' parameter
* allows to get id of item beeing loaded
*
* @param kEvent $event
* @access public
*/
function OnBeforeItemLoad(&$event)
{
-
+
}
-
+
/**
* Occurse after loading item, 'id' parameter
* allows to get id of item that was loaded
*
* @param kEvent $event
* @access public
*/
function OnAfterItemLoad(&$event)
{
-
+
}
-
+
/**
* Occurse before creating item
*
* @param kEvent $event
* @access public
*/
function OnBeforeItemCreate(&$event)
{
-
+
}
-
+
/**
* Occurse after creating item
*
* @param kEvent $event
* @access public
*/
function OnAfterItemCreate(&$event)
{
-
+
}
-
+
/**
* Occurse before updating item
*
* @param kEvent $event
* @access public
*/
function OnBeforeItemUpdate(&$event)
{
-
+
}
-
+
/**
* Occurse after updating item
*
* @param kEvent $event
* @access public
*/
function OnAfterItemUpdate(&$event)
{
-
+
}
-
+
/**
* Occurse before deleting item, id of item beeing
* deleted is stored as 'id' event param
*
* @param kEvent $event
* @access public
*/
function OnBeforeItemDelete(&$event)
{
-
+
}
-
+
/**
* Occurse after deleting item, id of deleted item
* is stored as 'id' param of event
*
* @param kEvent $event
* @access public
*/
function OnAfterItemDelete(&$event)
{
-
+
}
-
+
/**
* Occurs after successful item validation
*
* @param kEvent $event
*/
function OnAfterItemValidate(&$event)
{
-
+
}
-
+
/**
* Occures after an item has been copied to temp
* Id of copied item is passed as event' 'id' param
*
* @param kEvent $event
*/
function OnAfterCopyToTemp(&$event)
{
-
+
}
-
+
/**
- * Occures before an item is deleted from live table when copying from temp
+ * Occures before an item is deleted from live table when copying from temp
* (temp handler deleted all items from live and then copy over all items from temp)
* Id of item being deleted is passed as event' 'id' param
*
* @param kEvent $event
*/
function OnBeforeDeleteFromLive(&$event)
{
-
+
}
-
+
/**
* Occures before an item is copied to live table (after all foreign keys have been updated)
* Id of item being copied is passed as event' 'id' param
*
* @param kEvent $event
*/
function OnBeforeCopyToLive(&$event)
{
-
+
}
-
+
/**
* !!! NOT FULLY IMPLEMENTED - SEE TEMP HANDLER COMMENTS (search by event name)!!!
- * Occures after an item has been copied to live table
+ * Occures after an item has been copied to live table
* Id of copied item is passed as event' 'id' param
*
* @param kEvent $event
*/
function OnAfterCopyToLive(&$event)
{
-
+
}
-
+
/**
* Occures before an item is cloneded
* Id of ORIGINAL item is passed as event' 'id' param
* Do not call object' Update method in this event, just set needed fields!
*
* @param kEvent $event
*/
function OnBeforeClone(&$event)
{
-
+
}
-
+
/**
* Occures after an item has been cloned
* Id of newly created item is passed as event' 'id' param
*
* @param kEvent $event
*/
function OnAfterClone(&$event)
{
-
+
}
-
+
/**
* Enter description here...
*
* @param kEvent $event
* @param string $search_field
* @param string $type
* @param string $value
* @param string $formatter_class
*/
function processRangeField(&$event, $search_field, $type, $value, $formatter_class)
{
$field = $search_field.'_'.$type;
$lang_current =& $this->Application->recallObject('lang.current');
-
+
$object =& $event->getObject();
$dt_separator = getArrayValue( $object->GetFieldOptions($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)
{
$this->Application->StoreVar($event->getPrefixSpecial().'_'.$field.'_error', $pseudo);
return -1;
}
return $value_ts;
}
-
-
+
+
/**
* Ensures that popup will be closed automatically
* and parent window will be refreshed with template
* passed
*
* @param kEvent $event
* @access public
*/
function finalizePopup(&$event, $main_prefix, $t)
{
$event->redirect = 'incs/close_popup';
-
+
// 2. substitute opener
$opener_stack = $this->Application->RecallVar('opener_stack');
$opener_stack = $opener_stack ? unserialize($opener_stack) : Array();
//array_pop($opener_stack);
-
+
$new_level = 'index4.php|'.ltrim($this->Application->BuildEnv($t, Array('m_opener' => 'u'), 'all'), ENV_VAR_NAME.'=');
array_push($opener_stack,$new_level);
$this->Application->StoreVar('opener_stack',serialize($opener_stack));
}
-
+
/**
* Create search filters based on search query
*
* @param kEvent $event
* @access protected
*/
function OnSearch(&$event)
{
$event->setPseudoClass('_List');
$object =& $event->getObject();
-
+
$keyword = $this->Application->GetVar( $event->getPrefixSpecial(true).'_search_keyword');
$this->Application->StoreVar( $event->getPrefixSpecial().'_search_keyword', $keyword);
-
+
$custom_filters = $this->Application->RecallVar( $event->getPrefixSpecial().'_custom_filters');
$custom_filters = $custom_filters ? unserialize($custom_filters) : Array();
-
+
$submit_custom_filters = $this->Application->GetVar('custom_filters');
-
+
if($submit_custom_filters)
{
$submit_custom_filters = getArrayValue($submit_custom_filters, $event->getPrefixSpecial() );
-
+
if($submit_custom_filters)
{
foreach($submit_custom_filters as $cf_name => $cf_value)
{
if($cf_value)
{
$custom_filters[$cf_name] = $cf_value;
}
else
{
unset($custom_filters[$cf_name]);
}
}
}
}
$this->Application->StoreVar($event->getPrefixSpecial().'_custom_filters', serialize($custom_filters) );
-
+
if( !$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)
{
case 'kOptionsFormatter':
$search_keys = Array();
$use_phrases = getArrayValue($object->Fields[$search_field], 'use_phrases');
foreach($object->Fields[$search_field]['options'] as $key => $val)
{
$pattern = '#'.$keyword.'#i';
if ( preg_match($pattern, $use_phrases ? $this->Application->Phrase($val) : $val) ) {
array_push($search_keys, $this->Conn->qstr($key));
}
}
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)
{
case 'int':
case 'integer':
case 'numeric':
if( !is_numeric($keyword) ) break;
$filter_value = $table_name.'`'.$search_field.'` = \''.$keyword.'\'';
break;
case 'double':
case 'float':
case 'real':
if( !is_numeric($keyword) ) break;
$filter_value = 'ABS('.$table_name.'`'.$search_field.'` - \''.str_replace(',','.',$keyword).'\') <= 0.0001';
break;
case 'string':
$like_keyword = preg_replace( '/\'(.*)\'/U', '\\1', $this->Conn->qstr( str_replace('\\','\\\\', $keyword) ) );
$keywords = explode(' ', $like_keyword);
foreach($keywords as $keyword_pos => $keyword_value)
{
$keyword_value = trim($keyword_value);
if($keyword_value)
{
$keywords[$keyword_pos] = $table_name.'`'.$search_field.'` LIKE \'%'.$keyword_value.'%\'';
}
else
{
unset($keywords[$keyword_pos]);
}
}
$filter_value = '('.implode(') OR (',$keywords).')';
break;
}
}
if($filter_value) $search_filter[$search_field] = Array('type' => $filter_type, 'value' => $filter_value);
}
-
+
$this->Application->StoreVar($event->getPrefixSpecial().'_search_filter', serialize($search_filter) );
}
-
+
/**
* Clear search keywords
*
* @param kEvent $event
* @access protected
*/
function OnSearchReset(&$event)
{
$this->Application->RemoveVar($event->getPrefixSpecial().'_search_filter');
$this->Application->RemoveVar($event->getPrefixSpecial().'_search_keyword');
-
+
$this->Application->RemoveVar($event->getPrefixSpecial().'_custom_filters');
}
-
+
/**
* Set's new filter value (filter_id meaning from config)
*
* @param kEvent $event
*/
function OnSetFilter(&$event)
{
$filter_id = $this->Application->GetVar('filter_id');
$filter_value = $this->Application->GetVar('filter_value');
$view_filter = $this->Application->RecallVar($event->getPrefixSpecial().'_view_filter');
$view_filter = $view_filter ? unserialize($view_filter) : Array();
-
+
$view_filter[$filter_id] = $filter_value;
-
+
$this->Application->StoreVar( $event->getPrefixSpecial().'_view_filter', serialize($view_filter) );
}
-
+
/**
* Add/Remove all filters applied to list from "View" menu
*
* @param kEvent $event
*/
function FilterAction(&$event)
{
$view_filter = Array();
$filter_menu = $this->Application->getUnitOption($event->Prefix,'FilterMenu');
switch ($event->Name)
{
case 'OnRemoveFilters':
$filter_value = 1;
break;
-
+
case 'OnApplyFilters':
$filter_value = 0;
break;
}
-
+
foreach($filter_menu['Filters'] as $filter_key => $filter_params)
{
if(!$filter_params) continue;
$view_filter[$filter_key] = $filter_value;
}
$this->Application->StoreVar( $event->getPrefixSpecial().'_view_filter', serialize($view_filter) );
}
-
+
/**
* Enter description here...
*
* @param kEvent $event
*/
function OnPreSaveAndOpenTranslator(&$event)
{
$this->Application->SetVar('allow_translation', true);
- $object =& $event->getObject();
+ $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
foreach($object->Fields as $field => $options)
{
if(isset($options['required']))
{
unset($object->Fields[$field]['required']);
}
}
}
-
+
}
?>
\ No newline at end of file
Property changes on: trunk/core/kernel/db/db_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.30
\ No newline at end of property
+1.31
\ No newline at end of property
Index: trunk/core/units/translator/translator_config.php
===================================================================
--- trunk/core/units/translator/translator_config.php (revision 3298)
+++ trunk/core/units/translator/translator_config.php (revision 3299)
@@ -1,52 +1,53 @@
<?php
$config = Array(
'Prefix' => 'trans',
'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'TranslatorEventHandler','file'=>'translator_event_handler.php','build_event'=>'OnBuild'),
'TagProcessorClass' => Array('class'=>'kDBTagProcessor','file'=>'','build_event'=>'OnBuild'),
'AutoLoad' => false,
'hooks' => Array(),
'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(),
),
'Grids' => Array(),
);
?>
\ No newline at end of file
Property changes on: trunk/core/units/translator/translator_config.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property
Index: trunk/core/units/general/cat_event_handler.php
===================================================================
--- trunk/core/units/general/cat_event_handler.php (revision 3298)
+++ trunk/core/units/general/cat_event_handler.php (revision 3299)
@@ -1,1009 +1,1011 @@
<?php
$application =& kApplication::Instance();
$application->Factory->includeClassFile('kDBEventHandler');
class kCatDBEventHandler extends InpDBEventHandler {
function OnCopy(&$event)
{
$object = $event->getObject();
$this->StoreSelectedIDs($event);
$ids = $this->getSelectedIDs($event);
$this->Application->StoreVar($event->getPrefixSpecial().'_clipboard', implode(',', $ids));
$this->Application->StoreVar($event->getPrefixSpecial().'_clipboard_mode', 'copy');
$this->Application->StoreVar('ClipBoard', 'COPY-0.'.$object->TableName.'.ResourceId=0');
$event->redirect_params = Array('opener' => 's', 'pass_events'=>true); //do not go up - STAY
}
function OnCut(&$event)
{
$object = $event->getObject();
$this->StoreSelectedIDs($event);
$ids = $this->getSelectedIDs($event);
$this->Application->StoreVar($event->getPrefixSpecial().'_clipboard', implode(',', $ids));
$this->Application->StoreVar($event->getPrefixSpecial().'_clipboard_mode', 'cut');
$this->Application->StoreVar('ClipBoard', 'CUT-0.'.$object->TableName.'.ResourceId=0');
$event->redirect_params = Array('opener' => 's', 'pass_events'=>true); //do not go up - STAY
}
function OnPaste(&$event)
{
$ids = $this->Application->RecallVar($event->getPrefixSpecial().'_clipboard');
if ($ids == '') {
$event->redirect = false;
return;
}
//recalling by different name, because we may get kDBList, if we recall just by prefix
$object =& $this->Application->recallObject($event->getPrefixSpecial().'.item', $event->Prefix);
$this->prepareObject($object, $event);
if ($this->Application->RecallVar($event->getPrefixSpecial().'_clipboard_mode') == 'copy') {
$ids_arr = explode(',', $ids);
$temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
if($ids_arr)
{
$temp->CloneItems($event->Prefix, $event->Special, $ids_arr);
}
}
else { // mode == cut
$ids_arr = explode(',', $ids);
foreach ($ids_arr as $id) {
$object->Load($id);
$object->MoveToCat();
}
}
$event->status = erSUCCESS;
}
/**
* Occurs when pasting category
*
* @param kEvent $event
*/
function OnCatPaste(&$event)
{
$inp_clipboard = $this->Application->RecallVar('ClipBoard');
$inp_clipboard = explode('-', $inp_clipboard, 2);
if($inp_clipboard[0] == 'COPY')
{
$saved_cat_id = $this->Application->GetVar('m_cat_id');
$cat_ids = $event->getEventParam('cat_ids');
$id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
$table = $this->Application->getUnitOption($event->Prefix, 'TableName');
$ids_sql = 'SELECT '.$id_field.' FROM '.$table.' WHERE ResourceId IN (%s)';
$resource_ids_sql = 'SELECT ItemResourceId FROM '.TABLE_PREFIX.'CategoryItems WHERE CategoryId = %s AND PrimaryCat = 1';
$this->Application->setUnitOption($event->Prefix,'AutoLoad', false);
$object =& $this->Application->recallObject($event->Prefix.'.item', $event->Prefix);
foreach($cat_ids as $source_cat => $dest_cat)
{
$item_resource_ids = $this->Conn->GetCol( sprintf($resource_ids_sql, $source_cat) );
if(!$item_resource_ids) continue;
$this->Application->SetVar('m_cat_id', $dest_cat);
$item_ids = $this->Conn->GetCol( sprintf($ids_sql, implode(',', $item_resource_ids) ) );
$temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
if($item_ids) $temp->CloneItems($event->Prefix, $event->Special, $item_ids);
}
$this->Application->setUnitOption($event->Prefix,'AutoLoad', true);
$this->Application->SetVar('m_cat_id', $saved_cat_id);
}
}
/**
* Enter description here...
*
* @param kEvent $event
*/
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');
$cf_id = $this->Application->GetVar('translator_cf_id');
if($cf_id)
{
$cv =& $this->Application->recallObject('cv.-item', null, Array('skip_autoload' => true) );
$load_params = Array('CustomFieldId' => $cf_id, 'ResourceId'=> $object->GetDBField('ResourceId') );
if( !$cv->Load($load_params) )
{
$cv->SetFieldsFromHash($load_params);
$cv->Create();
}
$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
*
* @param kEvent $event
*/
function SetCustomQuery(&$event)
{
$object =& $event->getObject();
if ($event->Special != 'showall') {
if ( $event->getEventParam('parent_cat_id') ) {
$parent_cat_id = $event->getEventParam('parent_cat_id');
}
else {
$parent_cat_id = $this->Application->GetVar('c_id');
if (!$parent_cat_id) {
$parent_cat_id = $this->Application->GetVar('m_cat_id');
}
if (!$parent_cat_id) {
$parent_cat_id = 0;
}
}
if ((string) $parent_cat_id != 'any') {
if ($event->getEventParam('recursive')) {
$current_path = $this->Conn->GetOne('SELECT ParentPath FROM '.TABLE_PREFIX.'Category WHERE CategoryId='.$parent_cat_id);
$subcats = $this->Conn->GetCol('SELECT CategoryId FROM '.TABLE_PREFIX.'Category WHERE ParentPath LIKE "'.$current_path.'%" ');
$object->addFilter('category_filter', TABLE_PREFIX.'CategoryItems.CategoryId IN ('.implode(', ', $subcats).')');
}
else {
$object->addFilter('category_filter', TABLE_PREFIX.'CategoryItems.CategoryId = '.$parent_cat_id );
}
}
}
else {
$object->addFilter('primary_filter', 'PrimaryCat = 1');
}
$view_perm = 1;
$object->addFilter('perm_filter', 'perm.PermId = '.$view_perm);
-
+
if ( !$this->Application->IsAdmin() )
{
$groups = explode( ',', $this->Application->RecallVar('UserGroups') );
foreach($groups as $group)
{
$view_filters[] = 'FIND_IN_SET('.$group.', perm.acl) || ((NOT FIND_IN_SET('.$group.',perm.dacl)) AND perm.acl=\'\')';
}
$view_filter = implode(' OR ', $view_filters);
$object->addFilter('perm_filter2', $view_filter);
$object->addFilter('status_filter', $object->TableName.'.Status = 1');
}
/*$list_type = $event->getEventParam('ListType');
switch($list_type)
{
case 'favorites':
$fav_table = $this->Application->getUnitOption('fav','TableName');
$user_id =& $this->Application->GetVar('u_id');
$sql = 'SELECT DISTINCT f.ResourceId
FROM '.$fav_table.' f
LEFT JOIN '.$object->TableName.' p ON p.ResourceId = f.ResourceId
WHERE f.PortalUserId = '.$user_id;
$ids = $this->Conn->GetCol($sql);
if(!$ids) $ids = Array(-1);
$object->addFilter('category_filter', TABLE_PREFIX.'CategoryItems.PrimaryCat = 1');
$object->addFilter('favorites_filter', '%1$s.`ResourceId` IN ('.implode(',',$ids).')');
break;
case 'search':
$search_results_table = TABLE_PREFIX.'ses_'.$this->Application->GetSID().'_'.TABLE_PREFIX.'Search';
$sql = ' SELECT DISTINCT ResourceId
FROM '.$search_results_table.'
WHERE ItemType=11';
$ids = $this->Conn->GetCol($sql);
if(!$ids) $ids = Array(-1);
$object->addFilter('search_filter', '%1$s.`ResourceId` IN ('.implode(',',$ids).')');
break;
} */
}
-
+
/**
* Adds calculates fields for item statuses
*
* @param kCatDBItem $object
* @param kEvent $event
*/
function PrepareObject(&$object, &$event)
{
-
+
$property_mappings = $this->Application->getUnitOption($event->Prefix, 'ItemPropertyMappings');
-
+
$new_days_var = getArrayValue($property_mappings, 'NewDays');
if($new_days_var)
{
$object->addCalculatedField('IsNew', ' IF(%1$s.NewItem = 2,
IF(%1$s.CreatedOn >= (UNIX_TIMESTAMP() - '.
$this->Application->ConfigValue($new_days_var).
'*3600*24), 1, 0),
%1$s.NewItem
)');
}
-
+
$hot_limit_var = getArrayValue($property_mappings, 'HotLimit');
if($hot_limit_var)
{
$sql = 'SELECT Data FROM '.TABLE_PREFIX.'Cache WHERE VarName = "'.$hot_limit_var.'"';
$hot_limit = $this->Conn->GetOne($sql);
if($hot_limit === false) $hot_limit = $this->CalculateHotLimit($event);
$object->addCalculatedField('IsHot', ' IF(%1$s.HotItem = 2,
IF(%1$s.Hits >= '.$hot_limit.', 1, 0),
%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,
IF(%1$s.CachedVotesQty >= '.
$this->Application->ConfigValue($votes2pop_var).
' AND %1$s.CachedRating >= '.
$this->Application->ConfigValue($rating2pop_var).
', 1, 0),
%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;
$sql = 'SELECT Hits FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').'
ORDER BY Hits DESC
LIMIT '.$last_hot.', 1';
$res = $this->Conn->GetCol($sql);
$hot_limit = (double)array_shift($res);
$this->Conn->Query('REPLACE INTO '.TABLE_PREFIX.'Cache VALUES ("'.$hot_limit_var.'", "'.$hot_limit.'", '.adodb_mktime().')');
return $hot_limit;
}
return 0;
}
-
+
/**
* Enter description here...
*
* @param kEvent $event
*/
function OnBeforeItemUpdate(&$event)
{
$object =& $event->getObject();
if( $this->Application->IsAdmin() && ($this->Application->GetVar('Hits_original') !== false) &&
floor($this->Application->GetVar('Hits_original')) != $object->GetDBField('Hits') )
{
$sql = 'SELECT MAX(Hits) FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').'
WHERE FLOOR(Hits) = '.$object->GetDBField('Hits');
$hits = ( $res = $this->Conn->GetOne($sql) ) ? $res + 0.000001 : $object->GetDBField('Hits');
$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))
{
return; // used when navigating by pages or changing sorting in search results
}
if(!$keywords || strlen($keywords) < $this->Application->ConfigValue('Search_MinKeyword_Length'))
{
$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'])
{
$join_clause .= ' AND '.$alias.'.CustomFieldId='.$search_config[$field]['CustomFieldId'];
}
$join_clauses[] = ' LEFT JOIN '.$foreign_table.' '.$alias.'
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;
$extra_skip = 0;
switch(substr($keywords, $i, 1))
{
case '+':
if(substr($keywords, $i + 1, 1) == '"')
{
$keyword_start = $i + 2;
$keyword_end = strpos($keywords, '"', $i + 2);
$extra_skip = 2;
}
- else
+ else
{
$keyword_start = $i + 1;
$keyword_end = strpos($keywords, ' ', $i + 1);
$extra_skip = 0;
}
$target_array =& $plus_keywords;
break;
case '-':
if(substr($keywords, $i + 1, 1) == '"')
{
$keyword_start = $i + 2;
$keyword_end = strpos($keywords, '"', $i + 2);
$extra_skip = 2;
}
- else
+ else
{
$keyword_start = $i + 1;
$keyword_end = strpos($keywords, ' ', $i + 1);
$extra_skip = 0;
}
$target_array =& $minus_keywords;
break;
case '"':
$keyword_start = $i + 1;
$keyword_end = strpos($keywords, '"', $i + 1);
$extra_skip = 1;
$target_array =& $normal_keywords;
break;
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();
$minus_conditions = Array();
foreach($normal_keywords as $keyword)
{
$normal_conditions[] = implode(' LIKE "%'.$keyword.'%" OR ', $field_list).' LIKE "%'.$keyword.'%"';
}
foreach($plus_keywords as $keyword)
{
$plus_conditions[] = implode(' LIKE "%'.$keyword.'%" OR ', $field_list).' LIKE "%'.$keyword.'%"';
}
foreach($minus_keywords as $keyword)
{
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';
}
if($plus_conditions)
{
$where_clause = '('.$where_clause.') AND ('.implode(') AND (', $plus_conditions).')';
}
if($minus_conditions)
{
$where_clause = '('.$where_clause.') AND ('.implode(') AND (', $minus_conditions).')';
}
$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']).')';
}
}
if( $event->MasterEvent && $event->MasterEvent->Name == 'OnListBuild' ) // subsearch, k4
{
if( $event->MasterEvent->getEventParam('ResultIds') )
{
$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)';
foreach($positive_words as $keyword)
{
$revelance_parts[] = 'IF('.$field.' LIKE "%'.$keyword.'%", '.$config_elem['value']['Priority'].', 0)';
}
}
$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...
*
* @param kEvent $event
*/
function OnSubSearch(&$event)
{
$search_table = TABLE_PREFIX.'ses_'.$this->Application->GetSID().'_'.TABLE_PREFIX.'Search';
$sql = 'SHOW TABLES LIKE "'.$search_table.'"';
if($this->Conn->Query($sql))
{
$sql = 'SELECT DISTINCT ResourceId FROM '.$search_table;
$ids = $this->Conn->GetCol($sql);
}
$event->setEventParam('ResultIds', $ids);
$event->CallSubEvent('OnSimpleSearch');
}
-
+
/**
* Enter description here...
*
* @param kEvent $event
* @todo Change all hardcoded Products table & In-Commerce module usage to dynamic usage from item config !!!
*/
function OnAdvancedSearch(&$event)
{
$query_object =& $this->Application->recallObject('HTTPQuery');
if(!isset($query_object->Post['andor']))
{
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';
$search_config = $this->Conn->Query($sql);
$lang = $this->Application->GetVar('m_lang');
$object =& $event->getObject();
$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')
{
$field_name = 'l'.$lang.'_'.$field;
}
else
{
$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'];
}
$join_clause = ' LEFT JOIN '.$foreign_table.' '.$alias.'
ON '.$join_clause;
}
}
else
{
// processing fields from local table
$field_name = $local_table.'.'.$field_name;
}
-
+
$condition = '';
switch($record['FieldType'])
{
case 'text':
if( !$this->Application->GetVar('INPORTAL_ON') )
{
$keywords[$field] = unhtmlentities( $keywords[$field] );
}
-
+
if(strlen($keywords[$field]) >= $this->Application->ConfigValue('Search_MinKeyword_Length'))
{
$highlight_keywords[] = $keywords[$field];
if( in_array($verbs[$field], Array('any', 'contains', 'notcontains')) )
{
$keywords[$field] = '%'.strtr($keywords[$field], Array('%' => '\\%', '_' => '\\_')).'%';
}
$condition = sprintf( $condition_patterns[$verbs[$field]],
$field_name,
$this->Conn->qstr( $keywords[$field] ));
}
break;
case 'boolean':
if($keywords[$field] != -1)
{
$property_mappings = $this->Application->getUnitOption($event->Prefix, 'ItemPropertyMappings');
switch($field)
{
case 'HotItem':
$hot_limit_var = getArrayValue($property_mappings, 'HotLimit');
if($hot_limit_var)
{
$sql = 'SELECT Data FROM '.TABLE_PREFIX.'Cache WHERE VarName="'.$hot_limit_var.'"';
$hot_limit = (int)$this->Conn->GetOne($sql);
$condition = 'IF('.$product_table.'.HotItem = 2,
IF('.$product_table.'.Hits >= '.
$hot_limit.
', 1, 0), '.$product_table.'.HotItem) = '.$keywords[$field];
}
break;
case 'PopItem':
$votes2pop_var = getArrayValue($property_mappings, 'VotesToPop');
$rating2pop_var = getArrayValue($property_mappings, 'RatingToPop');
if($votes2pop_var && $rating2pop_var)
{
$condition = 'IF('.$product_table.'.PopItem = 2, IF('.$product_table.'.CachedVotesQty >= '.
$this->Application->ConfigValue($votes2pop_var).
' AND '.$product_table.'.CachedRating >= '.
$this->Application->ConfigValue($rating2pop_var).
', 1, 0), '.$product_table.'.PopItem) = '.$keywords[$field];
}
break;
case 'NewItem':
$new_days_var = getArrayValue($property_mappings, 'NewDays');
if($new_days_var)
{
$condition = 'IF('.$product_table.'.NewItem = 2,
IF('.$product_table.'.CreatedOn >= (UNIX_TIMESTAMP() - '.
$this->Application->ConfigValue($new_days_var).
'*3600*24), 1, 0), '.$product_table.'.NewItem) = '.$keywords[$field];
}
break;
case 'EditorsPick':
$condition = $product_table.'.EditorsPick = '.$keywords[$field];
break;
- }
+ }
}
break;
case 'range':
$range_conditions = Array();
if($keywords[$field.'_from'] && !preg_match("/[^0-9]/i", $keywords[$field.'_from']))
{
$range_conditions[] = $field_name.' >= '.$keywords[$field.'_from'];
}
if($keywords[$field.'_to'] && !preg_match("/[^0-9]/i", $keywords[$field.'_to']))
{
$range_conditions[] = $field_name.' <= '.$keywords[$field.'_to'];
}
if($range_conditions)
{
$condition = implode(' AND ', $range_conditions);
}
break;
case 'date':
if($keywords[$field])
{
if( in_array($keywords[$field], Array('today', 'yesterday')) )
{
$current_time = getdate();
$day_begin = adodb_mktime(0, 0, 0, $current_time['mon'], $current_time['mday'], $current_time['year']);
$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,
'last_year' => 31536000
);
$min_time = adodb_mktime() - $time_mapping[$keywords[$field]];
}
$condition = $field_name.' > '.$min_time;
}
break;
}
-
+
if($condition)
{
if($join_clause)
{
$join_clauses[] = $join_clause;
}
$relevance_parts[] = 'IF('.$condition.', '.$record['Priority'].', 0)';
if($glues[$field] == 1) // and
{
if($condition_mode == 'WHERE')
{
$and_conditions[] = $condition;
}
else
{
$and_having_conditions[] = $condition;
}
}
else // or
{
if($condition_mode == 'WHERE')
{
$or_conditions[] = $condition;
}
else
{
$or_having_conditions[] = $condition;
}
}
}
}
-
+
$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)
{
$and_conditions[] = '('.implode(' OR ', $or_conditions).')';
}
// $and_conditions[] = $product_table.'.Status = 1';
$where_clause = implode(' AND ', $and_conditions);
if(!$where_clause)
{
if($having_clause)
{
$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
*
* @param kEvent $event
* @access private
* @see OnListBuild
*/
function SetPagination(&$event)
{
// get PerPage (forced -> session -> config -> 10)
$per_page = $this->getPerPage($event);
-
+
$object =& $event->getObject();
$object->SetPerPage($per_page);
$this->Application->StoreVarDefault($event->getPrefixSpecial().'_Page', 1);
-
+
$page = $this->Application->GetVar($event->getPrefixSpecial().'_Page');
if (!$page)
{
$page = $this->Application->GetVar($event->getPrefixSpecial(true).'_Page');
}
-
+
if (!$page)
{
if( $this->Application->RewriteURLs() )
{
$page = $this->Application->GetVar($event->Prefix.'_Page');
if (!$page)
{
$page = $this->Application->RecallVar($event->Prefix.'_Page');
}
if($page) $this->Application->StoreVar($event->getPrefixSpecial().'_Page', $page);
}
else
{
$page = $this->Application->RecallVar($event->getPrefixSpecial().'_Page');
}
}
else {
$this->Application->StoreVar($event->getPrefixSpecial().'_Page', $page);
}
-
+
// $page = $this->Application->GetLinkedVar($event->getPrefixSpecial(true).'_Page', $event->getPrefixSpecial().'_Page');
if( !$event->getEventParam('skip_counting') )
{
$pages = $object->GetTotalPages();
if($page > $pages)
{
$this->Application->StoreVar($event->getPrefixSpecial().'_Page', 1);
$page = 1;
}
}
-
+
$object->SetPage($page);
}
}
?>
\ No newline at end of file
Property changes on: trunk/core/units/general/cat_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.15
\ No newline at end of property
+1.16
\ No newline at end of property

Event Timeline