Index: admin/system_presets/simple/promo_blocks_promo-block.php =================================================================== --- admin/system_presets/simple/promo_blocks_promo-block.php (revision 0) +++ admin/system_presets/simple/promo_blocks_promo-block.php (revision 0) @@ -0,0 +1,48 @@ + + + + + + + + + + + + +
+ + + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + " id="" value="" tabindex="" size="" datepickerIcon="core/admin_templates/img/calendar_icon.gif">  + " + style="cursor: pointer; margin-right: 5px" + title="Date selector" + /> + + + " id="" value=""> + + + + " id="" value="" tabindex="" size="" datepickerIcon="core/admin_templates/img/calendar_icon.gif">  + " + style="cursor: pointer; margin-right: 5px" + title="Date selector" + /> + + + " id="" value=""> + +
+
+ + + + Index: core/admin_templates/promo_blocks/promo_block_list.tpl =================================================================== --- core/admin_templates/promo_blocks/promo_block_list.tpl (revision 0) +++ core/admin_templates/promo_blocks/promo_block_list.tpl (revision 0) @@ -0,0 +1,81 @@ + + + + + + + + + + + +
+ +
+ + + + + + + + Property changes on: core\admin_templates\promo_blocks\promo_block_list.tpl ___________________________________________________________________ Added: svn:eol-style + LF Index: core/install/english.lang =================================================================== --- core/install/english.lang (revision 14840) +++ core/install/english.lang (working copy) @@ -88,7 +88,6 @@ SVAgQWRkcmVzcw== UG9wdWxhcg== VXNlciBQcmltYXJ5 - SXRlbSBQcmVmaXg= S2V5d29yZA== TGFiZWw= TGFuZ3VhZ2UgUGFjayBJbnN0YWxsZWQ= @@ -119,6 +118,8 @@ UmVzZXQgdG8gZGVmYXVsdA== Q29tbWVudHM= Q3JlYXRlZCBieQ== + U2NoZWR1bGUgRnJvbSBEYXRl + U2NoZWR1bGUgVG8gRGF0ZQ== QXR0ZW1wdHMg U2Vzc2lvbiBFbmQ= U2Vzc2lvbiBTdGFydA== @@ -172,6 +173,10 @@ UGF0aCB0byBXZWJzaXRl UGVyZm9ybSBFeGFjdCBTZWFyY2g= Q29tbWVudHMgcGVyIHBhZ2U= + UHJvbW8gUm90YXRpb24gRGVsYXkgKHNlY29uZHMp + UHJvbW8gVHJhbnNpdGlvbiBDb250cm9scw== + UHJvbW8gVHJhbnNpdGlvbiBFZmZlY3Q= + VHJhbnNpdGlvbiBEZWxheSAoc2Vjb25kcyk= UXVpY2sgU2VjdGlvbiBQZXJtaXNzaW9uIFJlYnVpbGQ= IlJlY3ljbGUgQmluIiBTZWN0aW9uSWQ= VXNlcm5hbWUgUmVxdWlyZWQgRHVyaW5nIFJlZ2lzdHJhdGlvbg== @@ -332,11 +337,13 @@ Q29tcGFueQ== Q29uZmlndXJhdGlvbiBIZWFkZXIgTGFiZWw= Q29udGVudCBCbG9jaw== + Q1RSLCAl Q29weSBMYWJlbHMgZnJvbSB0aGlzIExhbmd1YWdl Q291bnRyeQ== Q3JlYXRlZCBCeQ== Q3JlYXRlZCBPbg== Q1NTIFRlbXBsYXRl + Q1NTIENsYXNzIE5hbWU= Q3Vyc29y Q3VzdG9tIERldGFpbHMgVGVtcGxhdGU= U2VuZCBFbWFpbCBUbw== @@ -381,6 +388,7 @@ RXhwb3J0IFByZXNldCBUaXRsZQ== RXhwb3J0IFByZXNldA== U2F2ZS9VcGRhdGUgRXhwb3J0IFByZXNldA== + RXh0ZXJuYWwgTGluaw== RXh0ZXJuYWwgVVJM RXh0cmEgSGVhZGVycw== RmF4 @@ -455,6 +463,7 @@ TGVmdA== TGluZSBlbmRpbmdz TGluZSBFbmRpbmdzIEluc2lkZSBGaWVsZHM= + TGluayBUeXBl SUQ= TGlzdGluZyBUeXBl TG9jYWxl @@ -491,9 +500,13 @@ TmV4dCBSdW4gT24= Tm90ZXM= UmV2aWV3IFdhc24ndCBIZWxwZnVs + TnVtYmVyIE9mIENsaWNrcw== + TnVtYmVyIE9mIFZpZXdz T2NjdXJlZCBPbg== + T3BlbiBJbiBOZXcgV2luZG93 T3B0aW9ucw== T3B0aW9uIFRpdGxl + T3JkZXI= T3ZlcndyaXRlIERlZmF1bHQgQ2FjaGluZyBLZXk= UGFjayBOYW1l UGFkZGluZyBCb3R0b20= @@ -556,6 +569,7 @@ UnVuIE1vZGU= UnVuIFRpbWU= U2FtZSBBcyBUaHVtYg== + U2NoZWR1bGUgRGF0ZQ== U2VhcmNoIFRlcm0= U2VuZGVyJ3MgQWRkcmVzcw== U2VuZGVyJ3MgTmFtZQ== @@ -574,6 +588,7 @@ U3RhdGU= U3RhdGUgQ291bnRyeQ== U3RhdHVz + U3RpY2t5 U3RvcCBXb3Jk U3ViamVjdA== U3VibWl0dGVkIE9u @@ -586,6 +601,7 @@ SXRlbQ== VGVtcGxhdGUgRmlsZQ== VGVtcGxhdGU= + VGV4dA== VGV4dCBBbGlnbg== VGV4dCBEZWNvcmF0aW9u VGV4dCBWZXJzaW9u @@ -624,6 +640,7 @@ Rm9udCBQcm9wZXJ0aWVz RG8geW91IHdhbnQgdG8gc2F2ZSB0aGUgY2hhbmdlcz8= QXJlIHlvdSBzdXJlIHlvdSB3b3VsZCBsaWtlIHRvIGRpc2NhcmQgdGhlIGNoYW5nZXM/ + RnJvbQ== RnJvbSBEYXRl R2VuZXJhbCBTZWN0aW9ucw== SGVhZCBGcmFtZQ== @@ -728,6 +745,8 @@ QWRkcmVzcw== QWZ0ZXI= QWxsb3c= + RmFkZQ== + U2xpZGU= QXV0by1EZXRlY3Q= QmVmb3Jl Qm91bmNlZA== @@ -755,6 +774,7 @@ RXZlcnlvbmU= RXhhY3Q= RXhwaXJlZA== + RXh0ZXJuYWw= RXh0ZXJuYWwgVXJs RmFpbGVk Rmlyc3QgTmFtZQ== @@ -762,6 +782,7 @@ R3Vlc3RzIE9ubHk= aG91cihzKQ== SW5oZXJpdCBmcm9tIFBhcmVudA== + SW50ZXJuYWw= SW52YWxpZA== SVAgQWRkcmVzcw== SXMgdW5pcXVl @@ -1096,6 +1117,7 @@ UGFja2FnZSBDb250ZW50 UGVybWlzc2lvbnM= UGVybWlzc2lvbiBUeXBlcw== + UHJvbW8gQmxvY2tz UHJvcGVydGllcw== UXVlcnkgRGF0YWJhc2U= UmVnaW9uYWw= @@ -1170,6 +1192,7 @@ UGhvbmU= UG9wdWxhcg== UG9wdWxhcml0eQ== + UHJvbW8gU2V0dGluZ3M= UmVhZHkgdG8gSW5zdGFsbA== cmVjb3JkcyBhZGRlZA== cmVjb3JkcyB1cGRhdGVk @@ -1196,6 +1219,7 @@ QWRkaW5nIEZpbGU= QWRkaW5nIE1haWxpbmcgTGlzdA== QWRkaW5nIFBlcm1pc3Npb24gVHlwZQ== + QWRkaW5nIFByb21vIEJsb2Nr QWRkaW5nIFNpdGUgRG9tYWlu QWRkaW5nIFNraW4= QWRkaW5nIFNwZWxsaW5nIERpY3Rpb25hcnk= @@ -1245,6 +1269,7 @@ RWRpdGluZyBGaWxl RWRpdGluZyBNZW1iZXJzaGlw RWRpdGluZyBQZXJtaXNzaW9uIFR5cGU= + RWRpdGluZyBQcm9tbyBCbG9jaw== RWRpdGluZyBTaXRlIERvbWFpbg== RWRpdGluZyBTa2lu RWRpdGluZyBTUEFNIFJlcG9ydA== @@ -1312,6 +1337,7 @@ UGVybWlzc2lvbnM= TGFiZWxzICYgUGhyYXNlcw== UGxlYXNlIFdhaXQ= + UHJvbW8gQmxvY2tz UHJvcGVydGllcw== UmVsYXRlZCBTZWFyY2hlcw== UmVsYXRpb25z @@ -1354,6 +1380,7 @@ Vmlld2luZyBSZXBseQ== VmlzaXRz V2Vic2l0ZQ== + dG8= Q3Vyci4gU2VjdGlvbg== RG93bg== VXA= @@ -1427,6 +1454,7 @@ UmVzY2FuIFRoZW1lcw== UmVzZW5k UmVzZXQ= + UmVzZXQgQ291bnRlcnM= UmVzZXQgUGVyc2lzdGVudCBTZXR0aW5ncw== UmVzZXQgVG8gQmFzZQ== UnVu @@ -1442,6 +1470,7 @@ U2V0IFByaW1hcnk= U2V0IFByaW1hcnkgU2VjdGlvbg== U2V0IFByaW1hcnkgTGFuZ3VhZ2U= + U2V0IFN0aWNreQ== U2hvdyBNZW51 U3luY2hyb25pemUgTGFuZ3VhZ2Vz VG9vbHM= Index: core/install/install_data.sql =================================================================== --- core/install/install_data.sql (revision 14840) +++ core/install/install_data.sql (working copy) @@ -95,6 +95,12 @@ INSERT INTO ConfigurationValues VALUES(DEFAULT, 'CSVExportSeparator', '0', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsCSVExport', 'la_config_CSVExportSeparator', 'radio', NULL, '0=la_Linux||1=la_Windows', 70.03, 0, 1, NULL); INSERT INTO ConfigurationValues VALUES(DEFAULT, 'CSVExportEncoding', '0', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsCSVExport', 'la_config_CSVExportEncoding', 'radio', NULL, '0=la_Unicode||1=la_Regular', 70.04, 0, 1, NULL); +# Section "in-portal:configure_promo_blocks": +INSERT INTO ConfigurationValues VALUES (DEFAULT, 'PromoRotationDelay', '7', 'In-Portal', 'in-portal:configure_promo_blocks', 'la_Text_PromoSettings', 'la_config_PromoRotationDelay', 'text', '', '', 10.01, 0, 0, NULL); +INSERT INTO ConfigurationValues VALUES (DEFAULT, 'PromoTransitionTime', '0.6', 'In-Portal', 'in-portal:configure_promo_blocks', 'la_Text_PromoSettings', 'la_config_PromoTransitionTime', 'text', '', '', 10.02, 0, 0, NULL); +INSERT INTO ConfigurationValues VALUES (DEFAULT, 'PromoTransitionControls', '1', 'In-Portal', 'in-portal:configure_promo_blocks', 'la_Text_PromoSettings', 'la_config_PromoTransitionControls', 'select', '', '1=la_Enabled||0=la_Disabled', 10.03, 0, 0, NULL); +INSERT INTO ConfigurationValues VALUES (DEFAULT, 'PromoTransitionEffect', 'fade', 'In-Portal', 'in-portal:configure_promo_blocks', 'la_Text_PromoSettings', 'la_config_PromoTransitionEffect', 'select', '', 'fade=la_opt_AnimationFade||slide=la_opt_AnimationSlide', 10.04, 0, 0, NULL); + # Section "in-portal:configure_users": INSERT INTO ConfigurationValues VALUES(DEFAULT, 'User_Allow_New', '3', 'In-Portal:Users', 'in-portal:configure_users', 'la_title_General', 'la_users_allow_new', 'radio', '', '1=la_opt_UserInstantRegistration||2=la_opt_UserNotAllowedRegistration||3=la_opt_UserUponApprovalRegistration||4=la_opt_UserEmailActivation', 10.01, 0, 1, NULL); INSERT INTO ConfigurationValues VALUES(DEFAULT, 'AdvancedUserManagement', '0', 'In-Portal:Users', 'in-portal:configure_users', 'la_title_General', 'la_prompt_AdvancedUserManagement', 'checkbox', NULL, NULL, 10.011, 0, 1, NULL); Index: core/install/install_schema.sql =================================================================== --- core/install/install_schema.sql (revision 14826) +++ core/install/install_schema.sql (working copy) @@ -1242,4 +1242,34 @@ KEY ResponseDate (ResponseDate), KEY ResponseHttpCode (ResponseHttpCode), KEY CurlError (CurlError) +); + +CREATE TABLE PromoBlocks ( + BlockId int(11) NOT NULL AUTO_INCREMENT, + Title varchar(50) NOT NULL DEFAULT '', + Priority int(11) NOT NULL DEFAULT '0', + Status tinyint(1) NOT NULL DEFAULT '0', + l1_Image varchar(255) NOT NULL DEFAULT '', + l2_Image varchar(255) NOT NULL DEFAULT '', + l3_Image varchar(255) NOT NULL DEFAULT '', + l4_Image varchar(255) NOT NULL DEFAULT '', + l5_Image varchar(255) NOT NULL DEFAULT '', + CSSClassName varchar(255) NOT NULL DEFAULT '', + LinkType tinyint(1) NOT NULL DEFAULT '1', + CategoryId int(11) NOT NULL DEFAULT '0', + ExternalLink varchar(255) NOT NULL DEFAULT '', + OpenInNewWindow tinyint(3) unsigned NOT NULL DEFAULT '0', + ScheduleFromDate int(11) DEFAULT NULL, + ScheduleToDate int(11) DEFAULT NULL, + NumberOfClicks int(11) NOT NULL DEFAULT '0', + NumberOfViews int(11) NOT NULL DEFAULT '0', + Sticky tinyint(1) NOT NULL DEFAULT '0', + Html text, + l1_Html text, + l2_Html text, + l3_Html text, + l4_Html text, + l5_Html text, + PRIMARY KEY (BlockId), + KEY OpenInNewWindow (OpenInNewWindow) ); \ No newline at end of file Index: core/install/upgrades.php =================================================================== --- core/install/upgrades.php (revision 14826) +++ core/install/upgrades.php (working copy) @@ -1769,6 +1769,16 @@ return ; } + $this->transformFieldPhrases(); + } + + /** + * Merges column and field phrases + * + * @return void + */ + protected function transformFieldPhrases() + { $sql = 'SELECT * FROM ' . TABLE_PREFIX . 'Phrase WHERE PhraseKey LIKE "LA_COL_%"'; @@ -1825,6 +1835,7 @@ { if ($mode == 'after') { $this->transformSortings(); + $this->transformFieldPhrases(); // because of "la_col_ItemPrefix" phrase } } Index: core/install/upgrades.sql =================================================================== --- core/install/upgrades.sql (revision 14840) +++ core/install/upgrades.sql (working copy) @@ -2301,4 +2301,43 @@ 'LA_SECTION_SETTINGSCACHING', 'LA_CONFIG_CACHEHANDLER', 'LA_CONFIG_MEMCACHESERVERS', 'LA_HINT_MEMCACHESERVERS' ); -DELETE FROM ConfigurationValues WHERE VariableName IN ('CacheHandler', 'MemcacheServers'); \ No newline at end of file +DELETE FROM ConfigurationValues WHERE VariableName IN ('CacheHandler', 'MemcacheServers'); + +CREATE TABLE PromoBlocks ( + BlockId int(11) NOT NULL AUTO_INCREMENT, + Title varchar(50) NOT NULL DEFAULT '', + Priority int(11) NOT NULL DEFAULT '0', + Status tinyint(1) NOT NULL DEFAULT '0', + l1_Image varchar(255) NOT NULL DEFAULT '', + l2_Image varchar(255) NOT NULL DEFAULT '', + l3_Image varchar(255) NOT NULL DEFAULT '', + l4_Image varchar(255) NOT NULL DEFAULT '', + l5_Image varchar(255) NOT NULL DEFAULT '', + CSSClassName varchar(255) NOT NULL DEFAULT '', + LinkType tinyint(1) NOT NULL DEFAULT '1', + CategoryId int(11) NOT NULL DEFAULT '0', + ExternalLink varchar(255) NOT NULL DEFAULT '', + OpenInNewWindow tinyint(3) unsigned NOT NULL DEFAULT '0', + ScheduleFromDate int(11) DEFAULT NULL, + ScheduleToDate int(11) DEFAULT NULL, + NumberOfClicks int(11) NOT NULL DEFAULT '0', + NumberOfViews int(11) NOT NULL DEFAULT '0', + Sticky tinyint(1) NOT NULL DEFAULT '0', + Html text, + l1_Html text, + l2_Html text, + l3_Html text, + l4_Html text, + l5_Html text, + PRIMARY KEY (BlockId), + KEY OpenInNewWindow (OpenInNewWindow) +); + +INSERT INTO ConfigurationValues VALUES (DEFAULT, 'PromoRotationDelay', '7', 'In-Portal', 'in-portal:configure_promo_blocks', 'la_Text_PromoSettings', 'la_config_PromoRotationDelay', 'text', '', '', 10.01, 0, 0, NULL); +INSERT INTO ConfigurationValues VALUES (DEFAULT, 'PromoTransitionTime', '0.6', 'In-Portal', 'in-portal:configure_promo_blocks', 'la_Text_PromoSettings', 'la_config_PromoTransitionTime', 'text', '', '', 10.02, 0, 0, NULL); +INSERT INTO ConfigurationValues VALUES (DEFAULT, 'PromoTransitionControls', '1', 'In-Portal', 'in-portal:configure_promo_blocks', 'la_Text_PromoSettings', 'la_config_PromoTransitionControls', 'select', '', '1=la_Enabled||0=la_Disabled', 10.03, 0, 0, NULL); +INSERT INTO ConfigurationValues VALUES (DEFAULT, 'PromoTransitionEffect', 'fade', 'In-Portal', 'in-portal:configure_promo_blocks', 'la_Text_PromoSettings', 'la_config_PromoTransitionEffect', 'select', '', 'fade=la_opt_AnimationFade||slide=la_opt_AnimationSlide', 10.04, 0, 0, NULL); + +UPDATE Phrase +SET l<%PRIMARY_LANGUAGE%>_ColumnTranslation = l<%PRIMARY_LANGUAGE%>_Translation +WHERE PhraseKey IN ('LA_FLD_CATEGORY', 'LA_FLD_ORDER'); \ No newline at end of file Index: core/kernel/constants.php =================================================================== --- core/kernel/constants.php (revision 14826) +++ core/kernel/constants.php (working copy) @@ -175,4 +175,9 @@ const PHRASE_TYPE_FRONT = 0; const PHRASE_TYPE_ADMIN = 1; const PHRASE_TYPE_COMMON = 2; + } + + class PromoBlockType { + const INTERNAL = 1; + const EXTERNAL = 2; } \ No newline at end of file Index: core/units/logs/change_logs/change_logs_config.php =================================================================== --- core/units/logs/change_logs/change_logs_config.php (revision 14826) +++ core/units/logs/change_logs/change_logs_config.php (working copy) @@ -151,7 +151,7 @@ 'OccuredOn' => Array ('filter_block' => 'grid_date_range_filter', 'width' => 150, ), 'MasterPrefix' => Array ('filter_block' => 'grid_options_filter', 'width' => 120, ), 'MasterId' => Array ('filter_block' => 'grid_range_filter', 'width' => 90, ), - 'Prefix' => Array ('title' => 'la_col_ItemPrefix', 'filter_block' => 'grid_options_filter', 'width' => 120, ), + 'Prefix' => Array ('title' => 'column:la_fld_ItemPrefix', 'filter_block' => 'grid_options_filter', 'width' => 120, ), 'ItemId' => Array ('filter_block' => 'grid_range_filter', 'width' => 120, ), 'Changes' => Array ('data_block' => 'grid_changes_td', 'filter_block' => 'grid_like_filter', 'format' => 'auto_cut', 'width' => 225, ), ), Index: core/units/priorites/priorites_config.php =================================================================== --- core/units/priorites/priorites_config.php (revision 14826) +++ core/units/priorites/priorites_config.php (working copy) @@ -13,7 +13,7 @@ */ defined('FULL_PATH') or die('restricted access!'); - + $config = Array ( 'Prefix' => 'priority', 'EventHandlerClass' => Array ('class' => 'PriorityEventHandler', 'file' => 'priority_eh.php', 'build_event' => 'OnBuild'), @@ -40,6 +40,6 @@ 'PermSection' => Array ('main' => 'custom'), 'ProcessPrefixes' => Array( - 'c', 'st' + 'c', 'st', 'promo-block', ), ); Index: core/units/promo_blocks/promo_block_eh.php =================================================================== --- core/units/promo_blocks/promo_block_eh.php (revision 0) +++ core/units/promo_blocks/promo_block_eh.php (revision 0) @@ -0,0 +1,311 @@ + 'OnChangePriority', + 'OnMassMoveDown' => 'OnChangePriority', + ); + + $this->eventMethods = array_merge($this->eventMethods, $events_map); + } + + /** + * Allows to override standard permission mapping + * + */ + function mapPermissions() + { + parent::mapPermissions(); + + $permissions = Array ( + 'OnItemBuild' => Array ('self' => true), + 'OnSetSticky' => Array ('self' => 'view'), + 'OnRegisterView' => Array ('self' => true), + 'OnFollowLink' => Array ('self' => true), + 'OnResetCounters' => Array ('self' => 'add|edit'), + ); + + $this->permMapping = array_merge($this->permMapping, $permissions); + } + + /** + * Processes OnMassMoveUp, OnMassMoveDown events + * + * @param kEvent $event + */ + function OnChangePriority(&$event) + { + $this->Application->SetVar('priority_prefix', $event->getPrefixSpecial()); + $event->CallSubEvent('priority:' . $event->Name); + } + + /** + * Apply any custom changes to list's sql query + * + * @param kEvent $event + * @return void + * @access protected + * @see kDBEventHandler::OnListBuild() + */ + protected function SetCustomQuery(&$event) + { + parent::SetCustomQuery($event); + + if ( $this->Application->isAdminUser ) { + return; + } + + $object =& $event->getObject(); + /* @var $object kDBList */ + + if ( $event->Special == 'home' ) { + $object->addFilter('status_filter', '%1$s.Status = ' . STATUS_ACTIVE); + $object->addFilter('scheduled_from_filter', '%1$s.ScheduleFromDate IS NULL OR %1$s.ScheduleFromDate <= ' . TIMENOW); + $object->addFilter('scheduled_to_filter', '%1$s.ScheduleToDate IS NULL OR %1$s.ScheduleToDate >= ' . TIMENOW); + } + } + + /** + * Set's block as sticky + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function OnSetSticky(kEvent &$event) + { + $object =& $event->getObject( Array('skip_autoload' => true) ); + /* @var $object kDBItem */ + + $ids = $this->StoreSelectedIDs($event); + + if ( $ids ) { + $id = array_shift($ids); + + $sql = 'UPDATE ' . $object->TableName . ' + SET Sticky = 0'; + $this->Conn->Query($sql); + + $sql = 'UPDATE ' . $object->TableName . ' + SET Sticky = 1, Status = ' . STATUS_ACTIVE . ' + WHERE BlockId = ' . $id; + $this->Conn->Query($sql); + } + + $this->clearSelectedIDs($event); + } + + + /** + * Set Required fields + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function OnBeforeItemCreate(&$event) + { + parent::OnBeforeItemCreate($event); + + $this->_itemChanged($event); + } + + /** + * Set Required fields + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function OnBeforeItemUpdate(&$event) + { + parent::OnBeforeItemUpdate($event); + + $this->_itemChanged($event); + } + + /** + * Schedule dates + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function _itemChanged(kEvent &$event) + { + $object =& $event->getObject(); + /* @var $object kDBItem */ + + $date_from = $object->GetDBField('ScheduleFromDate_date'); + $date_to = $object->GetDBField('ScheduleToDate_date'); + + if ( $date_from && $date_to && $date_from >= $date_to ) { + $object->SetError('ScheduleFromDate_date', 'wrong_date_interval'); + } + + $object->setRequired('CategoryId', $object->GetDBField('LinkType') == PromoBlockType::INTERNAL); + $object->setRequired('ExternalLink', $object->GetDBField('LinkType') == PromoBlockType::EXTERNAL); + } + + /** + * Registers view of the promo block + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function OnRegisterView(kEvent &$event) + { + $this->_incrementField($event, 'NumberOfViews'); + } + + /** + * Registers click on the promo block + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function OnFollowLink(kEvent &$event) + { + $object =& $event->getObject(); + /* @var $object kDBItem */ + + $this->_incrementField($event, 'NumberOfClicks', false); + + if ( $object->GetDBField('LinkType') == 1 ) { // Internal + $sql = 'SELECT NamedParentPath + FROM ' . TABLE_PREFIX . 'Category + WHERE CategoryId = ' . $object->GetDBField('CategoryId'); + $event->redirect = $this->Conn->GetOne($sql); + + $event->SetRedirectParam('pass', 'm'); + } + else { + $ext_url = $object->GetDBField('ExternalLink'); + $event->redirect = 'external:' . (preg_match('/^(http|ftp):\\/\\/.*/', $ext_url) ? $ext_url : $this->Application->BaseURL() . $ext_url); + } + } + + /** + * Increment given promo block counters + * + * @param kEvent $event + * @param string $field + * @param bool $is_ajax + * @return void + * @access protected + */ + protected function _incrementField(kEvent &$event, $field, $is_ajax = true) + { + if ( $is_ajax ) { + $event->status = kEvent::erSTOP; + + if ( $this->Application->GetVar('ajax') != 'yes' ) { + return ; + } + } + + $object =& $event->getObject(); + /* @var $object kDBItem */ + + if ( !$object->isLoaded() ) { + echo 'FAILED'; + return ; + } + + // don't use kDBItem::Update to support concurrent view updates from different visitors + $sql = 'UPDATE ' . $object->TableName . ' + SET ' . $field . ' = ' . $field . ' + 1 + WHERE ' . $object->IDField . ' = ' . $object->GetID(); + $this->Conn->Query($sql); + + echo 'OK'; + } + + /** + * Resets promo block counters + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function OnResetCounters(kEvent &$event) + { + $object =& $event->getObject( Array ('skip_autoload' => true) ); + /* @var $object kDBItem */ + + $ids = $this->StoreSelectedIDs($event); + + foreach ($ids as $id) { + $object->Load($id); + $object->SetDBField('NumberOfViews', 0); + $object->SetDBField('NumberOfClicks', 0); + $object->Update(); + } + + $this->clearSelectedIDs($event); + } + + /** + * Occurs, when config was parsed, allows to change config data dynamically + * + * @param kEvent $event + * @return void + * @access protected + */ + protected function OnAfterConfigRead(kEvent &$event) + { + parent::OnAfterConfigRead($event); + + $category_helper =& $this->Application->recallObject('CategoryHelper'); + /* @var $category_helper CategoryHelper */ + + $fields = $this->Application->getUnitOption($event->Prefix, 'Fields'); + + $fields['CategoryId']['options'] = $category_helper->getStructureTreeAsOptions(); + + // images multilang fields + $a_image = Array( + 'type' => 'string', 'max_len' => 255, + 'formatter' => 'kUploadFormatter', 'upload_dir' => IMAGES_PATH, + 'multiple' => 1, 'thumb_format' => 'resize:100x100', + 'file_types' => '*.jpg;*.gif;*.png', 'files_description' => '!la_Image_Files!', + 'required' => 1, 'not_null' => 1, 'default' => '', + ); + + // get active languages + $sql = 'SELECT LanguageId + FROM ' . TABLE_PREFIX . 'Language'; + $languages = $this->Conn->GetCol($sql); + + foreach ($languages AS $lang_id) { + $fields['l' . $lang_id . '_Image'] = $a_image; + } + + $this->Application->setUnitOption($event->Prefix, 'Fields', $fields); + } +} Index: core/units/promo_blocks/promo_block_tp.php =================================================================== --- core/units/promo_blocks/promo_block_tp.php (revision 0) +++ core/units/promo_blocks/promo_block_tp.php (revision 0) @@ -0,0 +1,58 @@ +getObject($params); + /* @var $object kDBItem */ + + $url_params = Array ( + $this->Prefix . '_event' => 'OnFollowLink', + 'pass' => 'm,' . $this->Prefix, + '__NO_REWRITE__' => 1, + ); + + return $this->Application->HREF('index', '', $url_params); + } + + /** + * Checks, that link should be opened in new window + * + * @param Array $params + * @return bool + * @access protected + */ + protected function LinkInNewWindow($params) + { + $object =& $this->getObject($params); + /* @var $object kDBItem */ + + if ( $object->GetDBField('LinkType') == 1 ) { // Internal + return false; + } + + return $object->GetDBField('OpenInNewWindow'); + } +} Property changes on: core\units\promo_blocks\promo_block_tp.php ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + LF Index: core/units/promo_blocks/promo_blocks_config.php =================================================================== --- core/units/promo_blocks/promo_blocks_config.php (revision 0) +++ core/units/promo_blocks/promo_blocks_config.php (revision 0) @@ -0,0 +1,156 @@ + 'promo-block', + 'ItemClass' => Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'), + 'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'), + 'EventHandlerClass' => Array ('class' => 'PromoBlockEventHandler', 'file' => 'promo_block_eh.php', 'build_event' => 'OnBuild'), + 'TagProcessorClass' => Array ('class' => 'PromoBlockTagProcessor', 'file' => 'promo_block_tp.php', 'build_event' => 'OnBuild'), + + 'AutoLoad' => true, + + 'QueryString' => Array ( + 1 => 'id', + 2 => 'Page', + 3 => 'PerPage', + 4 => 'event', + 5 => 'mode', + ), + + 'IDField' => 'BlockId', + + 'TableName' => TABLE_PREFIX . 'PromoBlocks', + + 'TitleField' => 'Title', + + 'TitlePresets' => Array ( + 'default' => Array ( + 'new_status_labels' => Array ('promo-block' => '!la_title_AddingPromoBlock!'), + 'edit_status_labels' => Array ('promo-block' => '!la_title_EditingPromoBlock!'), + ), + + 'promo_block_list' => Array ('prefixes' => Array ('promo-block_List'), 'format' => "!la_tab_PromoBlocks! (#promo-block_recordcount#)"), + 'promo_block_edit' => Array ('prefixes' => Array ('promo-block'), 'format' => "#promo-block_status# '#promo-block_titlefield#'"), + ), + + 'PermSection' => Array('main' => 'in-portal:promo_blocks'), + + 'Sections' => Array ( + 'in-portal:promo_blocks' => Array( + 'parent' => 'in-portal:site', + 'icon' => 'custom', + 'label' => 'la_tab_PromoBlocks', + 'url' => Array('t' => 'promo_blocks/promo_block_list', 'pass' => 'm'), + 'permissions' => Array('view', 'add', 'edit', 'delete'), + 'priority' => 7, + 'type' => stTREE, + ), + + 'in-portal:configure_promo_blocks' => Array ( + 'parent' => 'in-portal:website_setting_folder', + 'icon' => 'custom', + 'label' => 'la_title_PromoBlocks', + 'url' => Array ('t' => 'config/config_universal', 'pass_section' => true, 'pass' => 'm'), + 'permissions' => Array ('view', 'edit'), + 'priority' => 3, + 'type' => stTREE, + ), + ), + + 'CalculatedFields' => Array ( + '' => Array ( + 'ConversionPercent' => 'IF(%1$s.NumberOfViews > 0, NumberOfClicks / NumberOfViews * 100, NULL)', + ), + ), + + 'ListSQLs' => Array ( + '' => ' SELECT %1$s.* %2$s FROM %1$s', + ), + + 'ListSortings' => Array ( + '' => Array ( + 'Sorting' => Array ('Priority' => 'desc'), + ) + ), + + 'Fields' => Array ( + 'BlockId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), + 'Title' => Array ( + 'type' => 'string', 'max_len' => 50, + 'not_null' => 1, 'required' => 1, 'default' => '', + ), + 'Status' => Array ( + 'type' => 'int', + 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Enabled', 0 => 'la_Disabled'), 'use_phrases' => 1, + 'not_null' => 1, 'default' => 1, + ), + 'Priority' => Array( + 'type' => 'int', + 'formatter' => 'kOptionsFormatter', 'options' => Array (), + 'not_null' => 1, 'required' => 1, 'default' => 0 + ), + 'Sticky' => Array ( + 'type' => 'int', + 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1, + 'not_null' => 1, 'default' => 0, + ), + 'CSSClassName' => Array( + 'type' => 'string', + 'formatter' => 'kOptionsFormatter', + 'options' => Array('promo-orange' => 'Orange', 'promo-green' => 'Green', 'promo-blue' => 'Blue'), + 'not_null' => 1, 'default' => '', + ), + 'LinkType' => Array ( + 'type' => 'int', + 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_opt_Internal', 2 => 'la_opt_External'), 'use_phrases' => 1, + 'not_null' => 1, 'required' => 1, 'default' => 0, + ), + 'CategoryId' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'default' => NULL), + 'ExternalLink' => Array('type' => 'string', 'not_null' => 1, 'default' => ''), + 'OpenInNewWindow' => Array ( + 'type' => 'int', + 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Yes', 0 => 'la_No'), 'use_phrases' => 1, + 'not_null' => 1, 'default' => 0 + ), + 'ScheduleFromDate' => Array ( + 'type' => 'int', + 'formatter' => 'kDateFormatter', 'time_format' => '', 'input_time_format' => '', + 'error_msgs' => Array ('wrong_date_interval' => '!la_ToDateMustBeGreaterThanFromDate!'), + 'default' => null, + ), + 'ScheduleToDate' => Array ( + 'type' => 'int', + 'formatter' => 'kDateFormatter', 'time_format' => '', 'input_time_format' => '', + 'error_field' => 'ScheduleFromDate', + 'default' => null, + ), + 'NumberOfClicks' => Array ('type' => 'int', 'default' => 0, 'not_null' => 1), + 'NumberOfViews' => Array ('type' => 'int', 'default' => 0, 'not_null' => 1), + 'Html' => Array ('type' => 'string', 'formatter' => 'kMultiLanguage', 'using_fck' => 1, 'default' => null), + ), + + 'VirtualFields' => Array( + 'ConversionPercent' => Array('type' => 'float', 'formatter' => 'kFormatter', 'format' => '%.0f', 'default' => NULL), + ), + + 'Grids' => Array ( + 'Default' => Array ( + 'Fields' => Array ( + 'BlockId' => Array ('title' => 'column:la_fld_Id', 'data_block' => 'grid_checkbox_td', 'filter_block' => 'grid_range_filter'), + 'Title' => Array ('filter_block' => 'grid_like_filter'), + 'Status' => Array ('filter_block' => 'grid_options_filter'), + 'Priority' => Array ('title' => 'column:la_fld_Order', 'filter_block' => 'grid_range_filter'), + 'Sticky' => Array ('filter_block' => 'grid_options_filter'), + 'CSSClassName' => Array ('filter_block' => 'grid_options_filter'), + 'LinkType' => Array ('filter_block' => 'grid_options_filter'), + 'CategoryId' => Array ('title' => 'column:la_fld_Category', 'filter_block' => 'grid_options_filter'), + 'ExternalLink' => Array ('filter_block' => 'grid_like_filter'), + 'ScheduleFromDate' => Array ('title' => 'la_col_ScheduleFromDate', 'filter_block' => 'grid_date_range_filter'), + 'ScheduleToDate' => Array ('title' => 'la_col_ScheduleToDate', 'filter_block' => 'grid_date_range_filter'), + 'NumberOfClicks' => Array ('filter_block' => 'grid_range_filter'), + 'NumberOfViews' => Array ('filter_block' => 'grid_range_filter'), + 'ConversionPercent' => Array ('filter_block' => 'grid_range_filter'), + ), + ), + ), +);