Selaa lähdekoodia

Ticket #2139 - Integration with Market and Photos.

AntonLV 7 vuotta sitten
vanhempi
sitoutus
fe15c921be

+ 1 - 0
modules/boonex/market/classes/BxMarketConfig.php

@@ -120,6 +120,7 @@ class BxMarketConfig extends BxBaseModTextConfig
             'OBJECT_REPORTS' => 'bx_market',
             'OBJECT_VIEWS' => 'bx_market',
             'OBJECT_VOTES' => 'bx_market',
+            'OBJECT_REACTIONS' => 'bx_market_reactions',
             'OBJECT_SCORES' => 'bx_market',
             'OBJECT_FAVORITES' => 'bx_market',
             'OBJECT_FEATURED' => 'bx_market',

+ 1 - 0
modules/boonex/market/install/sql/enable.sql

@@ -285,6 +285,7 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl
 ('bx_market_view_actions', 'bx_market', 'comment', '_sys_menu_item_title_system_va_comment', '', '', '', '', '', '', '', 0, 2147483647, 0, 0, 200),
 ('bx_market_view_actions', 'bx_market', 'view', '_sys_menu_item_title_system_va_view', '', '', '', '', '', '', '', 0, 2147483647, 1, 0, 210),
 ('bx_market_view_actions', 'bx_market', 'vote', '_sys_menu_item_title_system_va_vote', '', '', '', '', '', '', '', 0, 2147483647, 0, 0, 220),
+('bx_market_view_actions', 'bx_market', 'reaction', '_sys_menu_item_title_system_va_reaction', '', '', '', '', '', '', '', 0, 2147483647, 1, 0, 225),
 ('bx_market_view_actions', 'bx_market', 'score', '_sys_menu_item_title_system_va_score', '', '', '', '', '', '', '', 0, 2147483647, 1, 0, 230),
 ('bx_market_view_actions', 'bx_market', 'favorite', '_sys_menu_item_title_system_va_favorite', '', '', '', '', '', '', '', 0, 2147483647, 1, 0, 240),
 ('bx_market_view_actions', 'bx_market', 'feature', '_sys_menu_item_title_system_va_feature', '', '', '', '', '', '', '', 0, 2147483647, 1, 0, 250),

+ 24 - 1
modules/boonex/market/install/sql/install.sql

@@ -23,6 +23,8 @@ CREATE TABLE IF NOT EXISTS `bx_market_products` (
   `views` int(11) NOT NULL default '0',
   `rate` float NOT NULL default '0',
   `votes` int(11) NOT NULL default '0',
+  `rrate` float NOT NULL default '0',
+  `rvotes` int(11) NOT NULL default '0',
   `score` int(11) NOT NULL default '0',
   `sc_up` int(11) NOT NULL default '0',
   `sc_down` int(11) NOT NULL default '0',
@@ -210,6 +212,26 @@ CREATE TABLE IF NOT EXISTS `bx_market_votes_track` (
   KEY `vote` (`object_id`, `author_nip`)
 );
 
+CREATE TABLE IF NOT EXISTS `bx_market_reactions` (
+  `object_id` int(11) NOT NULL default '0',
+  `reaction` varchar(32) NOT NULL default '',
+  `count` int(11) NOT NULL default '0',
+  `sum` int(11) NOT NULL default '0',
+  UNIQUE KEY `reaction` (`object_id`, `reaction`)
+);
+
+CREATE TABLE IF NOT EXISTS `bx_market_reactions_track` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `object_id` int(11) NOT NULL default '0',
+  `author_id` int(11) NOT NULL default '0',
+  `author_nip` int(11) unsigned NOT NULL default '0',
+  `reaction` varchar(32) NOT NULL default '',
+  `value` tinyint(4) NOT NULL default '0',
+  `date` int(11) NOT NULL default '0',
+  PRIMARY KEY (`id`),
+  KEY `vote` (`object_id`, `author_nip`)
+);
+
 -- TABLE: views
 CREATE TABLE `bx_market_views_track` (
   `object_id` int(11) NOT NULL default '0',
@@ -509,7 +531,8 @@ INSERT INTO `sys_objects_cmts` (`Name`, `Module`, `Table`, `CharsPostMin`, `Char
 
 -- VOTES
 INSERT INTO `sys_objects_vote` (`Name`, `TableMain`, `TableTrack`, `PostTimeout`, `MinValue`, `MaxValue`, `IsUndo`, `IsOn`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldAuthor`, `TriggerFieldRate`, `TriggerFieldRateCount`, `ClassName`, `ClassFile`) VALUES 
-('bx_market', 'bx_market_votes', 'bx_market_votes_track', '604800', '1', '5', '0', '1', 'bx_market_products', 'id', 'author', 'rate', 'votes', 'BxMarketVoteStars', 'modules/boonex/market/classes/BxMarketVoteStars.php');
+('bx_market', 'bx_market_votes', 'bx_market_votes_track', '604800', '1', '5', '0', '1', 'bx_market_products', 'id', 'author', 'rate', 'votes', 'BxMarketVoteStars', 'modules/boonex/market/classes/BxMarketVoteStars.php'),
+('bx_market_reactions', 'bx_market_reactions', 'bx_market_reactions_track', '604800', '1', '1', '1', '1', 'bx_market_products', 'id', 'author', 'rrate', 'rvotes', 'BxTemplVoteReactions', '');
 
 -- SCORES
 INSERT INTO `sys_objects_score` (`name`, `module`, `table_main`, `table_track`, `post_timeout`, `is_on`, `trigger_table`, `trigger_field_id`, `trigger_field_author`, `trigger_field_score`, `trigger_field_cup`, `trigger_field_cdown`, `class_name`, `class_file`) VALUES 

+ 2 - 2
modules/boonex/market/install/sql/uninstall.sql

@@ -1,6 +1,6 @@
 
 -- TABLES
-DROP TABLE IF EXISTS `bx_market_products`, `bx_market_subproducts`, `bx_market_licenses`, `bx_market_licenses_deleted`, `bx_market_files`, `bx_market_files2products`, `bx_market_downloads_track`, `bx_market_photos`, `bx_market_photos2products`, `bx_market_photos_resized`, `bx_market_cmts`, `bx_market_votes`, `bx_market_votes_track`, `bx_market_views_track`, `bx_market_meta_keywords`, `bx_market_meta_locations`, `bx_market_meta_mentions`, `bx_market_reports`, `bx_market_reports_track`, `bx_market_favorites_track`, `bx_market_scores`, `bx_market_scores_track`;
+DROP TABLE IF EXISTS `bx_market_products`, `bx_market_subproducts`, `bx_market_licenses`, `bx_market_licenses_deleted`, `bx_market_files`, `bx_market_files2products`, `bx_market_downloads_track`, `bx_market_photos`, `bx_market_photos2products`, `bx_market_photos_resized`, `bx_market_cmts`, `bx_market_votes`, `bx_market_votes_track`, `bx_market_reactions`, `bx_market_reactions_track`, `bx_market_views_track`, `bx_market_meta_keywords`, `bx_market_meta_locations`, `bx_market_meta_mentions`, `bx_market_reports`, `bx_market_reports_track`, `bx_market_favorites_track`, `bx_market_scores`, `bx_market_scores_track`;
 
 -- STORAGES & TRANSCODERS
 DELETE FROM `sys_objects_storage` WHERE `object` IN('bx_market_files', 'bx_market_photos', 'bx_market_photos_resized');
@@ -25,7 +25,7 @@ DELETE FROM `sys_form_pre_values` WHERE `Key` IN('bx_market_cats', 'bx_market_pr
 DELETE FROM `sys_objects_cmts` WHERE `Name` = 'bx_market';
 
 -- VOTES
-DELETE FROM `sys_objects_vote` WHERE `Name` = 'bx_market';
+DELETE FROM `sys_objects_vote` WHERE `Name` IN ('bx_market', 'bx_market_reactions');
 
 -- SCORES
 DELETE FROM `sys_objects_score` WHERE `name` = 'bx_market';

+ 16 - 12
modules/boonex/market/template/entry-text.html

@@ -1,14 +1,18 @@
-<bx_if:show_image>
-    <div class="bx-base-text-entity-image bx-def-margin-bottom bx-def-font-align-center">
-        <img class="bx-def-border-radius-block" src="__entry_image__" />
+<div class="bx-content-description-before">__content_description_before__</div>
+<div class="bx-content-description">
+    <bx_if:show_image>
+        <div class="bx-base-text-entity-image bx-def-margin-bottom bx-def-font-align-center">
+            <img class="bx-def-border-radius-block" src="__entry_image__" />
+        </div>
+    </bx_if:show_image>
+    <div class="bx-base-text-entity-content bx-market-entity-content bx-def-constraint-list bx-def-constraint-pre bx-def-constraint-object bx-def-constraint-iframe bx-def-constraint-img">
+        <div class="bx-market-ec-title">
+            <h1>__entry_title__</h1>
+        </div>
+        <div class="bx-market-ec-description bx-def-margin-top">__entry_text__</div>
     </div>
-</bx_if:show_image>
-<div class="bx-base-text-entity-content bx-market-entity-content bx-def-constraint-list bx-def-constraint-pre bx-def-constraint-object bx-def-constraint-iframe bx-def-constraint-img">
-    <div class="bx-market-ec-title">
-        <h1>__entry_title__</h1>
-    </div>
-    <div class="bx-market-ec-description bx-def-margin-top">__entry_text__</div>
+    <bx_if:show_screenshots>
+        <div class="bx-market-ec-slideshow bx-def-margin-top">__screenshots__</div>
+    </bx_if:show_screenshots>
 </div>
-<bx_if:show_screenshots>
-    <div class="bx-market-ec-slideshow bx-def-margin-top">__screenshots__</div>
-</bx_if:show_screenshots>
+<div class="bx-content-description-after">__content_description_after__</div>

+ 1 - 0
modules/boonex/photos/classes/BxPhotosConfig.php

@@ -83,6 +83,7 @@ class BxPhotosConfig extends BxBaseModTextConfig
             'OBJECT_VIEWS' => 'bx_photos',
             'OBJECT_VOTES' => 'bx_photos',
             'OBJECT_VOTES_STARS' => 'bx_photos_stars',
+            'OBJECT_REACTIONS' => 'bx_photos_reactions',
             'OBJECT_SCORES' => 'bx_photos',
             'OBJECT_FAVORITES' => 'bx_photos',
             'OBJECT_FEATURED' => 'bx_photos',

+ 10 - 0
modules/boonex/photos/classes/BxPhotosTemplate.php

@@ -54,10 +54,20 @@ class BxPhotosTemplate extends BxBaseModTextTemplate
             return $bAsArray ? array() : '';
 
         $aTmplVars = array_merge($aTmplVars, array(
+            'content_description_before' => '',
             'entry_photo' => $sImage,
             'entry_title_attr' => bx_html_attribute($aContentInfo['title']),
+            'content_description_after' => ''
         ));
 
+        if(!empty($CNF['OBJECT_REACTIONS'])) {
+            $oReactions = BxDolVote::getObjectInstance($CNF['OBJECT_REACTIONS'], $aContentInfo[$CNF['FIELD_ID']]);
+            if($oReactions)
+                $aTmplVars['content_description_after'] .= $oReactions->getCounter(array(
+                    'show_counter' => true
+                ));
+        }
+
         return $bAsArray ? $aTmplVars : $this->parseHtmlByName('entry-photo.html', $aTmplVars);
     }
 

+ 2 - 1
modules/boonex/photos/install/sql/enable.sql

@@ -203,7 +203,8 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl
 ('bx_photos_view_actions', 'bx_photos', 'delete-photo', '_bx_photos_menu_item_title_system_delete_entry', '', '', '', '', '', '', '', 0, 2147483647, 1, 0, 20),
 ('bx_photos_view_actions', 'bx_photos', 'comment', '_sys_menu_item_title_system_va_comment', '', '', '', '', '', '', '', 0, 2147483647, 0, 0, 200),
 ('bx_photos_view_actions', 'bx_photos', 'view', '_sys_menu_item_title_system_va_view', '', '', '', '', '', '', '', 0, 2147483647, 1, 0, 210),
-('bx_photos_view_actions', 'bx_photos', 'vote', '_sys_menu_item_title_system_va_vote', '', '', '', '', '', '', '', 0, 2147483647, 1, 0, 220),
+('bx_photos_view_actions', 'bx_photos', 'vote', '_sys_menu_item_title_system_va_vote', '', '', '', '', '', '', '', 0, 2147483647, 0, 0, 220),
+('bx_photos_view_actions', 'bx_photos', 'reaction', '_sys_menu_item_title_system_va_reaction', '', '', '', '', '', '', '', 0, 2147483647, 1, 0, 225),
 ('bx_photos_view_actions', 'bx_photos', 'score', '_sys_menu_item_title_system_va_score', '', '', '', '', '', '', '', 0, 2147483647, 1, 0, 230),
 ('bx_photos_view_actions', 'bx_photos', 'favorite', '_sys_menu_item_title_system_va_favorite', '', '', '', '', '', '', '', 0, 2147483647, 1, 0, 240),
 ('bx_photos_view_actions', 'bx_photos', 'feature', '_sys_menu_item_title_system_va_feature', '', '', '', '', '', '', '', 0, 2147483647, 1, 0, 250),

+ 24 - 1
modules/boonex/photos/install/sql/install.sql

@@ -16,6 +16,8 @@ CREATE TABLE IF NOT EXISTS `bx_photos_entries` (
   `votes` int(11) NOT NULL default '0',
   `srate` float NOT NULL default '0',
   `svotes` int(11) NOT NULL default '0',
+  `rrate` float NOT NULL default '0',
+  `rvotes` int(11) NOT NULL default '0',
   `score` int(11) NOT NULL default '0',
   `sc_up` int(11) NOT NULL default '0',
   `sc_down` int(11) NOT NULL default '0',
@@ -119,6 +121,26 @@ CREATE TABLE IF NOT EXISTS `bx_photos_svotes_track` (
   KEY `vote` (`object_id`, `author_nip`)
 );
 
+CREATE TABLE IF NOT EXISTS `bx_photos_reactions` (
+  `object_id` int(11) NOT NULL default '0',
+  `reaction` varchar(32) NOT NULL default '',
+  `count` int(11) NOT NULL default '0',
+  `sum` int(11) NOT NULL default '0',
+  UNIQUE KEY `reaction` (`object_id`, `reaction`)
+);
+
+CREATE TABLE IF NOT EXISTS `bx_photos_reactions_track` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `object_id` int(11) NOT NULL default '0',
+  `author_id` int(11) NOT NULL default '0',
+  `author_nip` int(11) unsigned NOT NULL default '0',
+  `reaction` varchar(32) NOT NULL default '',
+  `value` tinyint(4) NOT NULL default '0',
+  `date` int(11) NOT NULL default '0',
+  PRIMARY KEY (`id`),
+  KEY `vote` (`object_id`, `author_nip`)
+);
+
 -- TABLE: views
 CREATE TABLE `bx_photos_views_track` (
   `object_id` int(11) NOT NULL default '0',
@@ -298,7 +320,8 @@ INSERT INTO `sys_objects_cmts` (`Name`, `Module`, `Table`, `CharsPostMin`, `Char
 -- VOTES
 INSERT INTO `sys_objects_vote` (`Name`, `TableMain`, `TableTrack`, `PostTimeout`, `MinValue`, `MaxValue`, `IsUndo`, `IsOn`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldAuthor`, `TriggerFieldRate`, `TriggerFieldRateCount`, `ClassName`, `ClassFile`) VALUES 
 ('bx_photos', 'bx_photos_votes', 'bx_photos_votes_track', '604800', '1', '1', '0', '1', 'bx_photos_entries', 'id', 'author', 'rate', 'votes', '', ''),
-('bx_photos_stars', 'bx_photos_svotes', 'bx_photos_svotes_track', '604800', '1', '5', '0', '1', 'bx_photos_entries', 'id', 'author', 'srate', 'svotes', 'BxPhotosVoteStars', 'modules/boonex/photos/classes/BxPhotosVoteStars.php');
+('bx_photos_stars', 'bx_photos_svotes', 'bx_photos_svotes_track', '604800', '1', '5', '0', '1', 'bx_photos_entries', 'id', 'author', 'srate', 'svotes', 'BxPhotosVoteStars', 'modules/boonex/photos/classes/BxPhotosVoteStars.php'),
+('bx_photos_reactions', 'bx_photos_reactions', 'bx_photos_reactions_track', '604800', '1', '1', '1', '1', 'bx_photos_entries', 'id', 'author', 'rrate', 'rvotes', 'BxTemplVoteReactions', '');
 
 
 -- SCORES

+ 2 - 2
modules/boonex/photos/install/sql/uninstall.sql

@@ -1,6 +1,6 @@
 
 -- TABLES
-DROP TABLE IF EXISTS `bx_photos_entries`, `bx_photos_photos`, `bx_photos_media_resized`, `bx_photos_cmts`, `bx_photos_votes`, `bx_photos_votes_track`, `bx_photos_svotes`, `bx_photos_svotes_track`, `bx_photos_views_track`, `bx_photos_meta_keywords`, `bx_photos_meta_locations`, `bx_photos_meta_mentions`, `bx_photos_reports`, `bx_photos_reports_track`, `bx_photos_favorites_track`, `bx_photos_scores`, `bx_photos_scores_track`;
+DROP TABLE IF EXISTS `bx_photos_entries`, `bx_photos_photos`, `bx_photos_media_resized`, `bx_photos_cmts`, `bx_photos_votes`, `bx_photos_votes_track`, `bx_photos_svotes`, `bx_photos_svotes_track`, `bx_photos_reactions`, `bx_photos_reactions_track`, `bx_photos_views_track`, `bx_photos_meta_keywords`, `bx_photos_meta_locations`, `bx_photos_meta_mentions`, `bx_photos_reports`, `bx_photos_reports_track`, `bx_photos_favorites_track`, `bx_photos_scores`, `bx_photos_scores_track`;
 
 
 -- STORAGES & TRANSCODERS
@@ -30,7 +30,7 @@ DELETE FROM `sys_objects_cmts` WHERE `Name` = 'bx_photos';
 
 
 -- VOTES
-DELETE FROM `sys_objects_vote` WHERE `Name` IN ('bx_photos', 'bx_photos_stars');
+DELETE FROM `sys_objects_vote` WHERE `Name` IN ('bx_photos', 'bx_photos_stars', 'bx_photos_reactions');
 
 
 -- SCORES

+ 9 - 5
modules/boonex/photos/template/entry-photo.html

@@ -1,6 +1,10 @@
-<div class="bx-photos-entity-photo bx-def-font-align-center">
-    <img class="bx-def-border-radius-block" src="__entry_photo__" title="__entry_title_attr__" />
-</div>
-<div class="bx-base-text-entity-content bx-def-constraint-list bx-def-constraint-pre bx-def-constraint-object bx-def-constraint-iframe bx-def-constraint-img bx-def-margin-top">
-    <h1>__entry_title__</h1>
+<div class="bx-content-description-before">__content_description_before__</div>
+<div class="bx-content-description">
+    <div class="bx-photos-entity-photo bx-def-font-align-center">
+        <img class="bx-def-border-radius-block" src="__entry_photo__" title="__entry_title_attr__" />
+    </div>
+    <div class="bx-base-text-entity-content bx-def-constraint-list bx-def-constraint-pre bx-def-constraint-object bx-def-constraint-iframe bx-def-constraint-img bx-def-margin-top">
+        <h1>__entry_title__</h1>
+    </div>
 </div>
+<div class="bx-content-description-after">__content_description_after__</div>