Index: trunk/kernel/units/general/cat_event_handler.php =================================================================== diff -u -N -r4842 -r5119 --- trunk/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 4842) +++ trunk/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 5119) @@ -488,63 +488,54 @@ { $object =& $event->getObject( Array('skip_autoload' => true) ); - $property_mappings = $this->Application->getUnitOption($event->Prefix, 'ItemPropertyMappings'); + $property_map = $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 - )'); + // new items + $object->addCalculatedField('IsNew', ' IF(%1$s.NewItem = 2, + IF(%1$s.CreatedOn >= (UNIX_TIMESTAMP() - '. + $this->Application->ConfigValue($property_map['NewDays']). + '*3600*24), 1, 0), + %1$s.NewItem + )'); + + // hot items + $sql = 'SELECT Data + FROM '.TABLE_PREFIX.'Cache + WHERE VarName = "'.$property_map['HotLimit'].'"'; + $hot_limit = $this->Conn->GetOne($sql); + if ($hot_limit === false) { + $hot_limit = $this->CalculateHotLimit($event); } - - $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)'); - } + $object->addCalculatedField('IsHot', ' IF(%1$s.HotItem = 2, + IF(%1$s.'.$property_map['ClickField'].' >= '.$hot_limit.', 1, 0), + %1$s.HotItem + )'); + + // popular items + $object->addCalculatedField('IsPop', ' IF(%1$s.PopItem = 2, + IF(%1$s.CachedVotesQty >= '. + $this->Application->ConfigValue($property_map['MinPopVotes']). + ' AND %1$s.CachedRating >= '. + $this->Application->ConfigValue($property_map['MinPopRating']). + ', 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; - } + $property_map = $this->Application->getUnitOption($event->Prefix, 'ItemPropertyMappings'); + $click_field = $property_map['ClickField']; + + $last_hot = $this->Application->ConfigValue($property_map['MaxHotNumber']) - 1; + $sql = 'SELECT '.$click_field.' FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').' + ORDER BY '.$click_field.' 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 ("'.$property_map['HotLimit'].'", "'.$hot_limit.'", '.adodb_mktime().')'); + return $hot_limit; + return 0; } Index: trunk/core/units/general/cat_event_handler.php =================================================================== diff -u -N -r4842 -r5119 --- trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 4842) +++ trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 5119) @@ -488,63 +488,54 @@ { $object =& $event->getObject( Array('skip_autoload' => true) ); - $property_mappings = $this->Application->getUnitOption($event->Prefix, 'ItemPropertyMappings'); + $property_map = $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 - )'); + // new items + $object->addCalculatedField('IsNew', ' IF(%1$s.NewItem = 2, + IF(%1$s.CreatedOn >= (UNIX_TIMESTAMP() - '. + $this->Application->ConfigValue($property_map['NewDays']). + '*3600*24), 1, 0), + %1$s.NewItem + )'); + + // hot items + $sql = 'SELECT Data + FROM '.TABLE_PREFIX.'Cache + WHERE VarName = "'.$property_map['HotLimit'].'"'; + $hot_limit = $this->Conn->GetOne($sql); + if ($hot_limit === false) { + $hot_limit = $this->CalculateHotLimit($event); } - - $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)'); - } + $object->addCalculatedField('IsHot', ' IF(%1$s.HotItem = 2, + IF(%1$s.'.$property_map['ClickField'].' >= '.$hot_limit.', 1, 0), + %1$s.HotItem + )'); + + // popular items + $object->addCalculatedField('IsPop', ' IF(%1$s.PopItem = 2, + IF(%1$s.CachedVotesQty >= '. + $this->Application->ConfigValue($property_map['MinPopVotes']). + ' AND %1$s.CachedRating >= '. + $this->Application->ConfigValue($property_map['MinPopRating']). + ', 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; - } + $property_map = $this->Application->getUnitOption($event->Prefix, 'ItemPropertyMappings'); + $click_field = $property_map['ClickField']; + + $last_hot = $this->Application->ConfigValue($property_map['MaxHotNumber']) - 1; + $sql = 'SELECT '.$click_field.' FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').' + ORDER BY '.$click_field.' 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 ("'.$property_map['HotLimit'].'", "'.$hot_limit.'", '.adodb_mktime().')'); + return $hot_limit; + return 0; } Index: trunk/admin/install/langpacks/english.lang =================================================================== diff -u -N -r4940 -r5119 --- trunk/admin/install/langpacks/english.lang (.../english.lang) (revision 4940) +++ trunk/admin/install/langpacks/english.lang (.../english.lang) (revision 5119) @@ -288,7 +288,10 @@ Qm9yZGVycw== Qm9yZGVyIFRvcA== Q2F0ZWdvcnk= + QXV0b21hdGljIERpcmVjdG9yeSBOYW1l + RGlyZWN0b3J5IE5hbWU= Q2F0ZWdvcnkgRm9ybWF0 + Q2F0ZWdvcnkgSUQ= Q2F0ZWdvcnkgc2VwYXJhdG9y Q2F0ZWdvcnkgVGVtcGxhdGU= Q2hhcnNldA== @@ -405,6 +408,7 @@ TGlua3M= QXJ0aWNsZXM= VG9waWNz + SzQgQ2F0YWxvZw== S0I= TGFuZ3VhZ2U= SW1wb3J0IHByb2dyZXNz @@ -414,10 +418,8 @@ TGluayBEZXNjcmlwdGlvbg== RGlzcGxheSBlZGl0b3IgUElDS3MgYWJvdmUgcmVndWxhciBsaW5rcw== SGl0cw== - TWluaW11bSBudW1iZXIgb2Ygdm90ZXMgdG8gZW5hYmxlIGxpbmsgcmF0aW5n TGluayBOYW1l TnVtYmVyIG9mIGRheXMgZm9yIGEgbGluayB0byBiZSBORVc= - TWluaW11bSByYXRpbmcgZm9yIGEgbGluayB0byBiZSBQT1A= TnVtYmVyIG9mIGxpbmtzIHBlciBwYWdl TnVtYmVyIG9mIGxpbmtzIHBlciBwYWdlIG9uIGEgc2hvcnQgbGlzdGluZw== UmF0aW5n @@ -428,7 +430,6 @@ U29ydCByZXZpZXdzIGJ5 VVJM RGlzcGxheSBsaW5rIFVSTCBpbiBzdGF0dXMgYmFy - TWF4aW11bSBudW1iZXIgb2YgSE9UIGxpbmtz TG9nZ2VkIGluIGFz TG9naW4= KEdNVCk= @@ -456,16 +457,13 @@ TmV2ZXIgRXhwaXJ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Z2UgUGFja3M= + TG9hZGluZyAuLi4= TW9kdWxlIFN0YXR1cw== TmV3IEN1c3RvbSBGaWVsZA== TmV3IEJhc2UgU3R5bGU= TmV3IEJsb2NrIFN0eWxl + TmV3IENhdGVnb3J5 TmV3IEdyb3Vw TmV3IExhbmd1YWdl TmV3IFBocmFzZQ== TmV3IFN0eWxlc2hlZXQ= Tm8gUGVybWlzc2lvbnM= UGVybWlzc2lvbnM= UGxlYXNlIFdhaXQ= + UHJvcGVydGllcw== UmVnaW9uYWw= UmVnaW9uYWwgU2V0dGluZ3M= U3VtbWFyeSAmIExvZ3M= @@ -1421,12 +1425,10 @@ VmFsaWRhdGU= Vmlldw== RGlzcGxheSBlZGl0b3IgcGlja3MgYWJvdmUgcmVndWxhciB0b3BpY3M= - TWluaW11bSBWb3Rlcw== TmV3IFRvcGljcyAoRGF5cyk= TnVtYmVyIG9mIHRvcGljcyBwZXIgcGFnZQ== VG9waWNzIFBlciBQYWdlIChTaG9ydGxpc3Qp UGljaw== - TnVtYmVyIG9mIHBvc3RzIHRvIGJlIGNvbnNpZGVyZWQgcG9wdWxhcg== VG9waWMgcmV2aWV3ZWQ= QW5kIHRoZW4gYnk= QW5kIHRoZW4gYnk= @@ -1437,7 +1439,6 @@ T3JkZXIgdG9waWNzIGJ5 VG9waWMgVGV4dA== Vmlld3M= - TWluaW11bSByYXRpbmcgdG8gYmUgY29uc2lkZXJlZCBob3Q= VG8gRGF0ZQ== Q2hlY2tib3hlcw== TGFiZWw= Index: trunk/core/units/configuration/configuration_config.php =================================================================== diff -u -N -r4665 -r5119 --- trunk/core/units/configuration/configuration_config.php (.../configuration_config.php) (revision 4665) +++ trunk/core/units/configuration/configuration_config.php (.../configuration_config.php) (revision 5119) @@ -29,33 +29,47 @@ 'TableName' => TABLE_PREFIX.'ConfigurationValues', - 'ListSQLs' => Array(''=>'SELECT * FROM '.TABLE_PREFIX.'ConfigurationAdmin LEFT JOIN '.TABLE_PREFIX.'ConfigurationValues Using(VariableName) '), + 'ListSQLs' => Array('' => ' SELECT %1$s.* %2$s + FROM '.TABLE_PREFIX.'ConfigurationAdmin ca + LEFT JOIN %1$s USING(VariableName)'), - 'ItemSQLs' => Array(''=>'SELECT * FROM '.TABLE_PREFIX.'ConfigurationAdmin LEFT JOIN '.TABLE_PREFIX.'ConfigurationValues Using(VariableName) '), + 'ItemSQLs' => Array('' => ' SELECT %1$s.* %2$s + FROM '.TABLE_PREFIX.'ConfigurationAdmin ca + LEFT JOIN %1$s USING(VariableName)'), 'ListSortings' => Array( '' => Array( - 'Sorting' => Array('DisplayOrder' => 'asc'), + 'Sorting' => Array('DisplayOrder' => 'asc', 'GroupDisplayOrder' => 'asc'), ) ), - 'SubTables' => Array(), + 'CalculatedFields' => Array ( + '' => Array ( + 'heading' => 'ca.heading', + 'prompt' => 'ca.prompt', + 'element_type' => 'ca.element_type', + 'ValueList' => 'ca.ValueList', + 'DisplayOrder' => 'ca.DisplayOrder', + 'GroupDisplayOrder' => 'ca.GroupDisplayOrder', + 'Install' => 'ca.Install', + ), + ), 'Fields' => Array( - 'VariableName' => Array('type' => 'string','not_null' => '1','default' => ''), - 'VariableValue' => array('type'=>'string', 'default'=>''), - 'ModuleOwner' => array('type'=>'string', 'default'=>'In-Portal'), - 'Section' => array('type'=>'string','not_null' => '1','default'=>''), + 'VariableName' => Array('type' => 'string','not_null' => '1','default' => ''), + 'VariableValue' => array('type'=>'string', 'default'=>''), + 'ModuleOwner' => array('type'=>'string', 'default'=>'In-Portal'), + 'Section' => array('type'=>'string','not_null' => '1','default'=>''), ), 'VirtualFields' => Array( - 'heading' => Array('type' => 'string','default' => ''), - 'prompt' => Array('type' => 'string','default' => ''), - 'element_type' => Array('type' => 'string','not_null' => '1','default' => ''), - 'validation' => Array('type' => 'string','default' => ''), - 'ValueList' => Array('type' => 'string','default' => ''), - 'DisplayOrder' => Array('type' => 'int','not_null' => '1','default' => '0'), - 'Install' => Array('type' => 'int','not_null' => '1','default' => '1'), + 'heading' => Array('type' => 'string', 'default' => ''), + 'prompt' => Array('type' => 'string', 'default' => ''), + 'element_type' => Array('type' => 'string', 'not_null' => '1', 'default' => ''), + 'ValueList' => Array('type' => 'string', 'default' => ''), + 'DisplayOrder' => Array('type' => 'double', 'not_null' => '1', 'default' => 0), + 'GroupDisplayOrder' => Array('type' => 'double', 'not_null' => '1', 'default' => 0), + 'Install' => Array('type' => 'int', 'not_null' => '1', 'default' => 1), ), 'Grids' => Array(), Index: trunk/kernel/units/configuration/configuration_config.php =================================================================== diff -u -N -r4665 -r5119 --- trunk/kernel/units/configuration/configuration_config.php (.../configuration_config.php) (revision 4665) +++ trunk/kernel/units/configuration/configuration_config.php (.../configuration_config.php) (revision 5119) @@ -29,33 +29,47 @@ 'TableName' => TABLE_PREFIX.'ConfigurationValues', - 'ListSQLs' => Array(''=>'SELECT * FROM '.TABLE_PREFIX.'ConfigurationAdmin LEFT JOIN '.TABLE_PREFIX.'ConfigurationValues Using(VariableName) '), + 'ListSQLs' => Array('' => ' SELECT %1$s.* %2$s + FROM '.TABLE_PREFIX.'ConfigurationAdmin ca + LEFT JOIN %1$s USING(VariableName)'), - 'ItemSQLs' => Array(''=>'SELECT * FROM '.TABLE_PREFIX.'ConfigurationAdmin LEFT JOIN '.TABLE_PREFIX.'ConfigurationValues Using(VariableName) '), + 'ItemSQLs' => Array('' => ' SELECT %1$s.* %2$s + FROM '.TABLE_PREFIX.'ConfigurationAdmin ca + LEFT JOIN %1$s USING(VariableName)'), 'ListSortings' => Array( '' => Array( - 'Sorting' => Array('DisplayOrder' => 'asc'), + 'Sorting' => Array('DisplayOrder' => 'asc', 'GroupDisplayOrder' => 'asc'), ) ), - 'SubTables' => Array(), + 'CalculatedFields' => Array ( + '' => Array ( + 'heading' => 'ca.heading', + 'prompt' => 'ca.prompt', + 'element_type' => 'ca.element_type', + 'ValueList' => 'ca.ValueList', + 'DisplayOrder' => 'ca.DisplayOrder', + 'GroupDisplayOrder' => 'ca.GroupDisplayOrder', + 'Install' => 'ca.Install', + ), + ), 'Fields' => Array( - 'VariableName' => Array('type' => 'string','not_null' => '1','default' => ''), - 'VariableValue' => array('type'=>'string', 'default'=>''), - 'ModuleOwner' => array('type'=>'string', 'default'=>'In-Portal'), - 'Section' => array('type'=>'string','not_null' => '1','default'=>''), + 'VariableName' => Array('type' => 'string','not_null' => '1','default' => ''), + 'VariableValue' => array('type'=>'string', 'default'=>''), + 'ModuleOwner' => array('type'=>'string', 'default'=>'In-Portal'), + 'Section' => array('type'=>'string','not_null' => '1','default'=>''), ), 'VirtualFields' => Array( - 'heading' => Array('type' => 'string','default' => ''), - 'prompt' => Array('type' => 'string','default' => ''), - 'element_type' => Array('type' => 'string','not_null' => '1','default' => ''), - 'validation' => Array('type' => 'string','default' => ''), - 'ValueList' => Array('type' => 'string','default' => ''), - 'DisplayOrder' => Array('type' => 'int','not_null' => '1','default' => '0'), - 'Install' => Array('type' => 'int','not_null' => '1','default' => '1'), + 'heading' => Array('type' => 'string', 'default' => ''), + 'prompt' => Array('type' => 'string', 'default' => ''), + 'element_type' => Array('type' => 'string', 'not_null' => '1', 'default' => ''), + 'ValueList' => Array('type' => 'string', 'default' => ''), + 'DisplayOrder' => Array('type' => 'double', 'not_null' => '1', 'default' => 0), + 'GroupDisplayOrder' => Array('type' => 'double', 'not_null' => '1', 'default' => 0), + 'Install' => Array('type' => 'int', 'not_null' => '1', 'default' => 1), ), 'Grids' => Array(),