AntonLV 9 лет назад
Родитель
Сommit
a638e3608a

+ 18 - 0
modules/boonex/polls/classes/BxPollsConfig.php

@@ -28,6 +28,7 @@ class BxPollsConfig extends BxBaseModTextConfig
             // database tables
             'TABLE_ENTRIES' => $aModule['db_prefix'] . 'entries',
         	'TABLE_SUBENTRIES' => $aModule['db_prefix'] . 'subentries',
+            'TABLE_VOTES_SUBENTRIES_TRACK' => $aModule['db_prefix'] . 'votes_subentries_track',
         	'TABLE_ENTRIES_FULLTEXT' => 'title_text',
 
             // database fields
@@ -126,11 +127,13 @@ class BxPollsConfig extends BxBaseModTextConfig
 
         $this->_aJsClasses = array(
             'form' => 'BxPollsForm',
+        	'entry' => 'BxPollsEntry',
         	'manage_tools' => 'BxPollsManageTools'
         );
 
         $this->_aJsObjects = array(
         	'form' => 'oBxPollsForm',
+        	'entry' => 'oBxPollsEntry',
         	'manage_tools' => 'oBxPollsManageTools'
         );
 
@@ -139,6 +142,21 @@ class BxPollsConfig extends BxBaseModTextConfig
         	'administration' => $this->CNF['OBJECT_GRID_ADMINISTRATION'],
         	
         );
+
+        $sHtmlPrefix = str_replace('_', '-', $this->_sName);
+        $this->_aHtmlIds = array(
+            'block_menu' => $sHtmlPrefix . '-block-menu',
+        	'block_link_subentries' => $sHtmlPrefix . '-block-subentries',
+        	'block_link_results' => $sHtmlPrefix . '-block-results',
+        );
+    }
+
+    public function getHtmlIds($sKey = '')
+    {
+        if(empty($sKey))
+            return $this->_aHtmlIds;
+
+        return isset($this->_aHtmlIds[$sKey]) ? $this->_aHtmlIds[$sKey] : '';
     }
 }
 

+ 10 - 0
modules/boonex/polls/classes/BxPollsDb.php

@@ -19,6 +19,16 @@ class BxPollsDb extends BxBaseModTextDb
         parent::__construct($oConfig);
     }
 
+    public function isPerformed($iEntryId, $iAuthorId)
+    {
+        $CNF = &$this->_oConfig->CNF;
+
+        $aSubentries = $this->getSubentries(array('type' => 'entry_id_pairs', 'entry_id' => $iEntryId));
+        return (int)$this->getOne("SELECT `object_id` FROM `" . $CNF['TABLE_VOTES_SUBENTRIES_TRACK'] . "` WHERE `object_id` IN (" . $this->implode_escape(array_keys($aSubentries)) . ") AND `author_id`=:author_id LIMIT 1", array(
+            'author_id' => $iAuthorId
+        )) != 0;
+    }
+
     public function getContentInfoBySubentryId ($iSubentryId)
     {
         $CNF = &$this->_oConfig->CNF;

+ 33 - 2
modules/boonex/polls/classes/BxPollsModule.php

@@ -19,10 +19,41 @@ class BxPollsModule extends BxBaseModTextModule
         parent::__construct($aModule);
     }
 
-    public function serviceEntitySubentriesBlock($iContentId = 0)
+    /**
+     * ACTION METHODS
+     */
+    public function actionGetBlock()
     {
-        return $this->_serviceTemplateFunc ('entrySubentries', $iContentId);
+        $iContentId = (int)bx_get('content_id');
+        $sBlock = bx_process_input(bx_get('block'));
+
+        $sMethod = 'serviceGetBlock' . bx_gen_method_name($sBlock);
+        if(!method_exists($this, $sMethod))
+            return echoJson(array());
+
+        $aBlock = $this->$sMethod($iContentId);
+        if(empty($aBlock) || !is_array($aBlock))
+            return echoJson(array());
+
+        return echoJson(array(
+        	'content' => $aBlock['content']
+        ));
+    }
+
+    /**
+     * SERVICE METHODS
+     */
+    public function serviceGetBlockSubentries($iContentId = 0)
+    {
+        return $this->_serviceTemplateFunc('entrySubentries', $iContentId);
     }
+
+    public function serviceGetBlockResults($iContentId = 0)
+    {
+        return $this->_serviceTemplateFunc('entryResults', $iContentId);
+    }
+
+    
 }
 
 /** @} */

+ 7 - 1
modules/boonex/polls/classes/BxPollsPageEntry.php

@@ -20,11 +20,17 @@ class BxPollsPageEntry extends BxBaseModTextPageEntry
         parent::__construct($aObject, $oTemplate);
     }
 
+    public function getCode()
+    {
+        return $this->_oModule->_oTemplate->getJsCode('entry') . parent::getCode();
+    }
+
     protected function _addJsCss()
     {
         parent::_addJsCss();
 
-        $this->_oModule->_oTemplate->addCss('entry.css');
+        $this->_oModule->_oTemplate->addJs(array('entry.js'));
+        $this->_oModule->_oTemplate->addCss(array('entry.css'));
     }
 }
 

+ 73 - 3
modules/boonex/polls/classes/BxPollsTemplate.php

@@ -23,6 +23,14 @@ class BxPollsTemplate extends BxBaseModTextTemplate
         parent::__construct($oConfig, $oDb);
     }
 
+    public function getJsCode($sType, $aParams = array(), $bWrap = true)
+    {
+        $aParams = array_merge(array(
+            'aHtmlIds' => $this->_oConfig->getHtmlIds()
+        ), $aParams);
+
+        return parent::getJsCode($sType, $aParams, $bWrap);
+    }
     public function entrySubentries ($aData)
     {
         $CNF = &$this->getModule()->_oConfig->CNF;
@@ -40,9 +48,71 @@ class BxPollsTemplate extends BxBaseModTextTemplate
             );
         }
 
-    	return $this->parseHtmlByName('subentries.html', array(
-            'bx_repeat:subentries' => $aTmplVarsSubentries,
-        ));
+    	return array(
+            'content' => $this->parseHtmlByName('subentries.html', array(
+                'bx_repeat:subentries' => $aTmplVarsSubentries,
+            )),
+            'menu' => $this->_getGetBlockMenu($aData, 'subentries')
+        );
+    }
+
+    public function entryResults($aData)
+    {
+        $CNF = &$this->getModule()->_oConfig->CNF;
+
+        $aSubentries = $this->_oDb->getSubentries(array('type' => 'entry_id', 'entry_id' => $aData[$CNF['FIELD_ID']]));
+        if(empty($aSubentries) || !is_array($aSubentries))
+            return '';
+
+        $iTotal = 0;
+        foreach($aSubentries as $aSubentry)
+            $iTotal += $aSubentry['votes'];
+
+        $aTmplVarsSubentries = array();
+        foreach($aSubentries as $aSubentry) {
+            $fPercent = 100 * (float)$aSubentry['votes']/$iTotal;
+            $aTmplVarsSubentries[] = array(
+                'title' => $aSubentry['title'],
+                'width' => (int)round($fPercent) . '%',
+                'results' => _t('_bx_polls_txt_subentry_n_votes_m_percent', $aSubentry['votes'], $iTotal > 0 ? round($fPercent, 2) : 0)
+            );
+        }
+
+        return array(
+            'content' => $this->parseHtmlByName('subentries_results.html', array(
+                'bx_repeat:subentries' => $aTmplVarsSubentries,
+            )),
+            'menu' => $this->_getGetBlockMenu($aData, 'results')
+        );
+    }
+
+    protected function _getGetBlockMenu($aData, $sSelected = '')
+    {
+        $CNF = &$this->getModule()->_oConfig->CNF;
+
+        $sJsObject = $this->_oConfig->getJsObject('entry');
+        $iContentId = $aData[$CNF['FIELD_ID']];
+
+        $aBlocks = array(
+        	'subentries' => true, 
+        	'results' => (int)$aData[$CNF['FIELD_HIDDEN_RESULTS']] == 0 || $this->_oDb->isPerformed($iContentId, bx_get_logged_profile_id())
+        );
+
+        $aMenu = array();
+        foreach($aBlocks as $sBlock => $bActive)
+            if($bActive) {
+                $sId = $this->_oConfig->getHtmlIds('block_link_' . $sBlock);
+                $aMenu[] = array('id' => $sId, 'name' => $sId, 'class' => '', 'link' => 'javascript:void(0)', 'onclick' => 'javascript:' . $sJsObject . '.changeBlock(this, \'' . $sBlock . '\', ' . $iContentId . ')', 'target' => '_self', 'title' => _t('_bx_polls_menu_item_view_' . $sBlock));
+            }
+
+        if(count($aMenu) <= 1)
+            return '';
+
+        $oMenu = new BxTemplMenuInteractive(array('template' => 'menu_interactive_vertical.html', 'menu_id'=> $this->_oConfig->getHtmlIds('block_menu'), 'menu_items' => $aMenu));
+        if(!empty($sSelected))
+            $oMenu->setSelected('', $this->_oConfig->getHtmlIds('block_link_' . $sSelected));
+
+        return $oMenu;
     }
 }
 

+ 25 - 8
modules/boonex/polls/classes/BxPollsVoteSubentries.php

@@ -11,7 +11,7 @@
 
 class BxPollsVoteSubentries extends BxTemplVote
 {
-	protected $MODULE;
+	protected $_sModule;
 	protected $_oModule;
 
 	protected $_aObjectInfo;
@@ -19,8 +19,8 @@ class BxPollsVoteSubentries extends BxTemplVote
 
     function __construct($sSystem, $iId, $iInit = 1)
     {
-    	$this->MODULE = 'bx_polls';
-    	$this->_oModule = BxDolModule::getInstance($this->MODULE);
+    	$this->_sModule = 'bx_polls';
+    	$this->_oModule = BxDolModule::getInstance($this->_sModule);
 
         parent::__construct($sSystem, $iId, $iInit, $this->_oModule->_oTemplate);
 
@@ -32,6 +32,21 @@ class BxPollsVoteSubentries extends BxTemplVote
 
         $this->_aObjectInfo = $this->_oModule->_oDb->getSubentries(array('type' => 'id', 'id' => $iId));
         $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoBySubentryId($iId);
+
+        $this->_sTmplNameElementBlock = 'subentries_ve_block.html';
+    }
+
+    public function getJsClick()
+    {
+        $CNF = $this->_oModule->_oConfig->CNF;
+
+        if(!$this->isLikeMode())
+            return false;
+
+        $sJsObjectVote = $this->getJsObjectName();
+        $sJsObjectEntry = $this->_oModule->_oConfig->getJsObject('entry');
+
+        return $sJsObjectVote . '.vote(this, ' . $this->getMaxValue() . ', function(oLink, oData) {' . $sJsObjectEntry . '.onVote(oLink, oData, ' . $this->_aContentInfo[$CNF['FIELD_ID']] . ');})';
     }
 
     public function getCounter($aParams = array())
@@ -61,12 +76,9 @@ class BxPollsVoteSubentries extends BxTemplVote
 
     public function isPerformed($iObjectId, $iAuthorId)
     {
-        $CNF = &$this->_oModule->_oConfig->CNF;
+        $CNF = $this->_oModule->_oConfig->CNF;
 
-        $aSubentries = $this->_oModule->_oDb->getSubentries(array('type' => 'entry_id_pairs', 'entry_id' => $this->_aContentInfo[$CNF['FIELD_ID']]));
-        return (int)$this->_oModule->_oDb->getOne("SELECT `object_id` FROM `" . $this->_aSystem['table_track'] . "` WHERE `object_id` IN (" . $this->_oModule->_oDb->implode_escape(array_keys($aSubentries)) . ") AND `author_id`=:author_id LIMIT 1", array(
-            'author_id' => $iAuthorId
-        )) != 0;
+        return $this->_oModule->_oDb->isPerformed($this->_aContentInfo[$CNF['FIELD_ID']], $iAuthorId);
     }
 
 	/**
@@ -94,6 +106,11 @@ class BxPollsVoteSubentries extends BxTemplVote
     {
     	return '_bx_polls_txt_subentry_vote_do_by';
     }
+
+    protected function _getLabelCounter($iCount)
+    {
+        return _t('_bx_polls_txt_subentry_vote_counter', $iCount);
+    }
 }
 
 /** @} */

+ 5 - 0
modules/boonex/polls/install/langs/en.xml

@@ -155,6 +155,9 @@
 	<string name="_bx_polls_menu_item_title_admt_polls"><![CDATA[Polls - {addon} hidden]]></string>
 	<string name="_bx_polls_menu_item_title_manage_my"><![CDATA[My Polls]]></string>
 	<string name="_bx_polls_menu_item_title_manage_all"><![CDATA[All Polls]]></string>
+	<string name="_bx_polls_menu_item_view_subentries"><![CDATA[Poll]]></string>
+	<string name="_bx_polls_menu_item_view_results"><![CDATA[Results]]></string>
+	
 
 	<string name="_bx_polls_grid_filter_item_title_adm_select_one_filter1"><![CDATA[All Statuses]]></string>
 	<string name="_bx_polls_grid_filter_item_title_adm_active"><![CDATA[Active]]></string>
@@ -209,4 +212,6 @@
     <string name="_bx_polls_txt_sample_comment_single"><![CDATA[poll's comment]]></string>
     <string name="_bx_polls_txt_sample_vote_single"><![CDATA[poll's vote]]></string>
     <string name="_bx_polls_txt_subentry_vote_do_by"><![CDATA[Voted for]]></string>
+    <string name="_bx_polls_txt_subentry_vote_counter"><![CDATA[{0} votes]]></string>
+    <string name="_bx_polls_txt_subentry_n_votes_m_percent"><![CDATA[{0} votes ({1}%)]]></string>
 </resources>

+ 9 - 22
modules/boonex/polls/install/sql/enable.sql

@@ -17,8 +17,8 @@ INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `c
 ('bx_polls_rss_num', '10', @iCategId, '_bx_polls_option_rss_num', 'digit', '', '', '', 20),
 ('bx_polls_searchable_fields', 'title,text', @iCategId, '_bx_polls_option_searchable_fields', 'list', '', '', 'a:2:{s:6:"module";s:8:"bx_polls";s:6:"method";s:21:"get_searchable_fields";}', 30);
 
--- PAGE: create entry
 
+-- PAGE: create entry
 INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_polls_create_entry', '_bx_polls_page_title_sys_create_entry', '_bx_polls_page_title_create_entry', 'bx_polls', 5, 2147483647, 1, 'create-poll', 'page.php?i=create-poll', '', '', '', 0, 1, 0, 'BxPollsPageBrowse', 'modules/boonex/polls/classes/BxPollsPageBrowse.php');
 
@@ -27,7 +27,6 @@ INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title`, `designb
 
 
 -- PAGE: edit entry
-
 INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_polls_edit_entry', '_bx_polls_page_title_sys_edit_entry', '_bx_polls_page_title_edit_entry', 'bx_polls', 5, 2147483647, 1, 'edit-poll', '', '', '', '', 0, 1, 0, 'BxPollsPageEntry', 'modules/boonex/polls/classes/BxPollsPageEntry.php');
 
@@ -36,7 +35,6 @@ INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title`, `designb
 
 
 -- PAGE: delete entry
-
 INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_polls_delete_entry', '_bx_polls_page_title_sys_delete_entry', '_bx_polls_page_title_delete_entry', 'bx_polls', 5, 2147483647, 1, 'delete-poll', '', '', '', '', 0, 1, 0, 'BxPollsPageEntry', 'modules/boonex/polls/classes/BxPollsPageEntry.php');
 
@@ -45,13 +43,12 @@ INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title`, `designb
 
 
 -- PAGE: view entry
-
 INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_polls_view_entry', '_bx_polls_page_title_sys_view_entry', '_bx_polls_page_title_view_entry', 'bx_polls', 10, 2147483647, 1, 'view-poll', '', '', '', '', 0, 1, 0, 'BxPollsPageEntry', 'modules/boonex/polls/classes/BxPollsPageEntry.php');
 
 INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES 
 ('bx_polls_view_entry', 1, 'bx_polls', '', '_bx_polls_page_block_title_entry_text', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:17:\"entity_text_block\";}', 0, 0, 1, 1),
-('bx_polls_view_entry', 1, 'bx_polls', '', '_bx_polls_page_block_title_entry_subentries', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:23:\"entity_subentries_block\";}', 0, 0, 1, 2),
+('bx_polls_view_entry', 1, 'bx_polls', '', '_bx_polls_page_block_title_entry_subentries', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:20:\"get_block_subentries\";}', 0, 0, 1, 2),
 ('bx_polls_view_entry', 2, 'bx_polls', '', '_bx_polls_page_block_title_entry_author', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:13:\"entity_author\";}', 0, 0, 1, 0),
 ('bx_polls_view_entry', 3, 'bx_polls', '', '_bx_polls_page_block_title_entry_info', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:11:\"entity_info\";}', 0, 0, 1, 1),
 ('bx_polls_view_entry', 3, 'bx_polls', '', '_bx_polls_page_block_title_entry_location', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:15:\"entity_location\";}', 0, 0, 0, 2),
@@ -64,7 +61,6 @@ INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `t
 
 
 -- PAGE: view entry comments
-
 INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_polls_view_entry_comments', '_bx_polls_page_title_sys_view_entry_comments', '_bx_polls_page_title_view_entry_comments', 'bx_polls', 5, 2147483647, 1, 'view-poll-comments', '', '', '', '', 0, 1, 0, 'BxPollsPageEntry', 'modules/boonex/polls/classes/BxPollsPageEntry.php');
 
@@ -73,7 +69,6 @@ INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `t
 
 
 -- PAGE: popular entries
-
 INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_polls_popular', '_bx_polls_page_title_sys_entries_popular', '_bx_polls_page_title_entries_popular', 'bx_polls', 5, 2147483647, 1, 'polls-popular', 'page.php?i=polls-popular', '', '', '', 0, 1, 0, 'BxPollsPageBrowse', 'modules/boonex/polls/classes/BxPollsPageBrowse.php');
 
@@ -82,7 +77,6 @@ INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title`, `designbo
 
 
 -- PAGE: recently updated entries
-
 INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_polls_updated', '_bx_polls_page_title_sys_entries_updated', '_bx_polls_page_title_entries_updated', 'bx_polls', 5, 2147483647, 1, 'polls-updated', 'page.php?i=polls-updated', '', '', '', 0, 1, 0, 'BxPollsPageBrowse', 'modules/boonex/polls/classes/BxPollsPageBrowse.php');
 
@@ -91,7 +85,6 @@ INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title`, `designbo
 
 
 -- PAGE: entries of author
-
 INSERT INTO `sys_objects_page`(`object`, `uri`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_polls_author', 'polls-author', '_bx_polls_page_title_sys_entries_of_author', '_bx_polls_page_title_entries_of_author', 'bx_polls', 5, 2147483647, 1, '', '', '', '', 0, 1, 0, 'BxPollsPageAuthor', 'modules/boonex/polls/classes/BxPollsPageAuthor.php');
 
@@ -100,8 +93,8 @@ INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `t
 ('bx_polls_author', 1, 'bx_polls', '_bx_polls_page_block_title_sys_favorites_of_author', '_bx_polls_page_block_title_favorites_of_author', 11, 2147483647, 'service', 'a:3:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:15:\"browse_favorite\";s:6:"params";a:1:{i:0;s:12:"{profile_id}";}}', 0, 1, 1, 2),
 ('bx_polls_author', 1, 'bx_polls', '_bx_polls_page_block_title_sys_entries_of_author', '_bx_polls_page_block_title_entries_of_author', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:13:\"browse_author\";}', 0, 0, 1, 3);
 
--- PAGE: module home
 
+-- PAGE: module home
 INSERT INTO `sys_objects_page`(`object`, `uri`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_polls_home', 'polls-home', '_bx_polls_page_title_sys_home', '_bx_polls_page_title_home', 'bx_polls', 2, 2147483647, 1, 'page.php?i=polls-home', '', '', '', 0, 1, 0, 'BxPollsPageBrowse', 'modules/boonex/polls/classes/BxPollsPageBrowse.php');
 
@@ -110,6 +103,7 @@ INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `t
 ('bx_polls_home', 2, 'bx_polls', '', '_bx_polls_page_block_title_popular_keywords', 11, 2147483647, 'service', 'a:4:{s:6:\"module\";s:6:\"system\";s:6:\"method\";s:14:\"keywords_cloud\";s:6:\"params\";a:2:{i:0;s:8:\"bx_polls\";i:1;s:8:\"bx_polls\";}s:5:\"class\";s:20:\"TemplServiceMetatags\";}', 0, 1, 1, 0),
 ('bx_polls_home', 2, 'bx_polls', '', '_bx_polls_page_block_title_cats', 11, 2147483647, 'service', 'a:4:{s:6:\"module\";s:6:\"system\";s:6:\"method\";s:15:\"categories_list\";s:6:\"params\";a:2:{i:0;s:13:\"bx_polls_cats\";i:1;a:1:{s:10:\"show_empty\";b:1;}}s:5:\"class\";s:20:\"TemplServiceCategory\";}', 0, 1, 1, 1);
 
+
 -- PAGE: module manage own
 INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_polls_manage', '_bx_polls_page_title_sys_manage', '_bx_polls_page_title_manage', 'bx_polls', 5, 2147483647, 1, 'polls-manage', 'page.php?i=polls-manage', '', '', '', 0, 1, 0, 'BxPollsPageBrowse', 'modules/boonex/polls/classes/BxPollsPageBrowse.php');
@@ -117,6 +111,7 @@ INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `lay
 INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `order`) VALUES 
 ('bx_polls_manage', 1, 'bx_polls', '_bx_polls_page_block_title_system_manage', '_bx_polls_page_block_title_manage', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:12:\"manage_tools\";}}', 0, 1, 0);
 
+
 -- PAGE: module manage all
 INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_polls_administration', '_bx_polls_page_title_sys_manage_administration', '_bx_polls_page_title_manage', 'bx_polls', 5, 192, 1, 'polls-administration', 'page.php?i=polls-administration', '', '', '', 0, 1, 0, 'BxPollsPageBrowse', 'modules/boonex/polls/classes/BxPollsPageBrowse.php');
@@ -124,19 +119,20 @@ INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `lay
 INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `order`) VALUES 
 ('bx_polls_administration', 1, 'bx_polls', '_bx_polls_page_block_title_system_manage_administration', '_bx_polls_page_block_title_manage', 11, 192, 'service', 'a:3:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:12:\"manage_tools\";s:6:\"params\";a:1:{i:0;s:14:\"administration\";}}', 0, 1, 0);
 
--- PAGE: add block to homepage
 
+-- PAGE: add block to homepage
 SET @iBlockOrder = (SELECT `order` FROM `sys_pages_blocks` WHERE `object` = 'sys_home' AND `cell_id` = 1 ORDER BY `order` DESC LIMIT 1);
 INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES 
 ('sys_home', 1, 'bx_polls', '_bx_polls_page_block_title_recent_entries', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:13:\"browse_public\";}', 1, 0, 0, IFNULL(@iBlockOrder, 0) + 1);
 
+
 -- PAGES: add page block to profiles modules (trigger* page objects are processed separately upon modules enable/disable)
 SET @iPBCellProfile = 3;
 INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `order`) VALUES
 ('trigger_page_profile_view_entry', @iPBCellProfile, 'bx_polls', '_bx_polls_page_block_title_my_entries', 11, 2147483647, 'service', 'a:3:{s:6:"module";s:8:"bx_polls";s:6:"method";s:13:"browse_author";s:6:"params";a:1:{i:0;s:12:"{profile_id}";}}', 0, 0, 0);
 
--- PAGE: service blocks
 
+-- PAGE: service blocks
 SET @iBlockOrder = (SELECT `order` FROM `sys_pages_blocks` WHERE `object` = '' AND `cell_id` = 0 ORDER BY `order` DESC LIMIT 1);
 INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `order`) VALUES 
 ('', 0, 'bx_polls', '_bx_polls_page_block_title_recent_entries', 11, 2147483647, 'service', 'a:3:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:13:\"browse_public\";s:6:\"params\";a:3:{s:9:\"unit_view\";s:7:\"gallery\";s:13:\"empty_message\";b:1;s:13:\"ajax_paginate\";b:0;}}', 0, 1, IFNULL(@iBlockOrder, 0) + 1),
@@ -145,27 +141,23 @@ INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title`, `designbo
 ('', 0, 'bx_polls', '_bx_polls_page_block_title_popular_entries_view_extended', 11, 2147483647, 'service', 'a:3:{s:6:"module";s:8:"bx_polls";s:6:"method";s:14:"browse_popular";s:6:"params";a:1:{i:0;s:8:"extended";}}', 0, 1, IFNULL(@iBlockOrder, 0) + 3),
 ('', 0, 'bx_polls', '_bx_polls_page_block_title_popular_entries_view_full', 11, 2147483647, 'service', 'a:3:{s:6:"module";s:8:"bx_polls";s:6:"method";s:14:"browse_popular";s:6:"params";a:1:{i:0;s:4:"full";}}', 0, 1, IFNULL(@iBlockOrder, 0) + 4);
 
--- MENU: add to site menu
 
+-- MENU: add to site menu
 SET @iSiteMenuOrder = (SELECT `order` FROM `sys_menu_items` WHERE `set_name` = 'sys_site' AND `active` = 1 ORDER BY `order` DESC LIMIT 1);
 INSERT INTO `sys_menu_items` (`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES 
 ('sys_site', 'bx_polls', 'polls-home', '_bx_polls_menu_item_title_system_entries_home', '_bx_polls_menu_item_title_entries_home', 'page.php?i=polls-home', '', '', 'tasks col-green1', 'bx_polls_submenu', 2147483647, 1, 1, IFNULL(@iSiteMenuOrder, 0) + 1);
 
 -- MENU: add to homepage menu
-
 SET @iHomepageMenuOrder = (SELECT `order` FROM `sys_menu_items` WHERE `set_name` = 'sys_homepage' AND `active` = 1 ORDER BY `order` DESC LIMIT 1);
 INSERT INTO `sys_menu_items` (`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES 
 ('sys_homepage', 'bx_polls', 'polls-home', '_bx_polls_menu_item_title_system_entries_home', '_bx_polls_menu_item_title_entries_home', 'page.php?i=polls-home', '', '', 'tasks col-green1', 'bx_polls_submenu', 2147483647, 1, 1, IFNULL(@iHomepageMenuOrder, 0) + 1);
 
 -- MENU: add to "add content" menu
-
 SET @iAddMenuOrder = (SELECT `order` FROM `sys_menu_items` WHERE `set_name` = 'sys_add_content_links' AND `active` = 1 ORDER BY `order` DESC LIMIT 1);
 INSERT INTO `sys_menu_items` (`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES 
 ('sys_add_content_links', 'bx_polls', 'create-poll', '_bx_polls_menu_item_title_system_create_entry', '_bx_polls_menu_item_title_create_entry', 'page.php?i=create-poll', '', '', 'tasks col-green1', '', 2147483647, 1, 1, IFNULL(@iAddMenuOrder, 0) + 1);
 
-
 -- MENU: actions menu for view entry 
-
 INSERT INTO `sys_objects_menu`(`object`, `title`, `set_name`, `module`, `template_id`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_polls_view', '_bx_polls_menu_title_view_entry', 'bx_polls_view', 'bx_polls', 9, 0, 1, 'BxPollsMenuView', 'modules/boonex/polls/classes/BxPollsMenuView.php');
 
@@ -176,9 +168,7 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl
 ('bx_polls_view', 'bx_polls', 'edit-poll', '_bx_polls_menu_item_title_system_edit_entry', '_bx_polls_menu_item_title_edit_entry', 'page.php?i=edit-poll&id={content_id}', '', '', 'pencil', '', 2147483647, 1, 0, 1),
 ('bx_polls_view', 'bx_polls', 'delete-poll', '_bx_polls_menu_item_title_system_delete_entry', '_bx_polls_menu_item_title_delete_entry', 'page.php?i=delete-poll&id={content_id}', '', '', 'remove', '', 2147483647, 1, 0, 2);
 
-
 -- MENU: actions menu for my entries
-
 INSERT INTO `sys_objects_menu`(`object`, `title`, `set_name`, `module`, `template_id`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_polls_my', '_bx_polls_menu_title_entries_my', 'bx_polls_my', 'bx_polls', 9, 0, 1, 'BxPollsMenu', 'modules/boonex/polls/classes/BxPollsMenu.php');
 
@@ -188,9 +178,7 @@ INSERT INTO `sys_menu_sets`(`set_name`, `module`, `title`, `deletable`) VALUES
 INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES 
 ('bx_polls_my', 'bx_polls', 'create-poll', '_bx_polls_menu_item_title_system_create_entry', '_bx_polls_menu_item_title_create_entry', 'page.php?i=create-poll', '', '', 'plus', '', 2147483647, 1, 0, 0);
 
-
 -- MENU: module sub-menu
-
 INSERT INTO `sys_objects_menu`(`object`, `title`, `set_name`, `module`, `template_id`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_polls_submenu', '_bx_polls_menu_title_submenu', 'bx_polls_submenu', 'bx_polls', 8, 0, 1, '', '');
 
@@ -203,7 +191,6 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl
 ('bx_polls_submenu', 'bx_polls', 'polls-manage', '_bx_polls_menu_item_title_system_entries_manage', '_bx_polls_menu_item_title_entries_manage', 'page.php?i=polls-manage', '', '', '', '', 2147483646, 1, 1, 3);
 
 -- MENU: sub-menu for view entry
-
 INSERT INTO `sys_objects_menu`(`object`, `title`, `set_name`, `module`, `template_id`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_polls_view_submenu', '_bx_polls_menu_title_view_entry_submenu', 'bx_polls_view_submenu', 'bx_polls', 8, 0, 1, 'BxPollsMenuView', 'modules/boonex/polls/classes/BxPollsMenuView.php');
 

+ 62 - 0
modules/boonex/polls/js/entry.js

@@ -0,0 +1,62 @@
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Polls Polls
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+function BxPollsEntry(oOptions) {
+    this._sActionsUrl = oOptions.sActionUrl;
+    this._sObjName = oOptions.sObjName == undefined ? 'oBxPollsEntry' : oOptions.sObjName;
+
+    this._sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'fade' : oOptions.sAnimationEffect;
+    this._iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
+
+    this._aHtmlIds = oOptions.aHtmlIds == undefined ? {} : oOptions.aHtmlIds;
+    this._oRequestParams = oOptions.oRequestParams == undefined ? {} : oOptions.oRequestParams;
+}
+
+BxPollsEntry.prototype.changeBlock = function(oLink, sBlock, iContentId) {
+	var $this = this;
+
+    this.loadingInBlock(oLink, true);
+
+    jQuery.get (
+        this._sActionsUrl + 'get_block',
+        {
+        	block: sBlock,
+        	content_id: iContentId
+        },
+        function(oData) {
+        	if(oLink)
+        		$this.loadingInBlock(oLink, false);
+
+        	if(!oData.content)
+        		return;
+
+        	$(oLink).parents('.bx-page-block-container:first').find('.bx-db-content').bx_anim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
+        		$(this).html(oData.content).show();
+        	});
+        },
+        'json'
+    );
+};
+
+BxPollsEntry.prototype.onVote = function(oLink, oData, iContentId) {
+	
+	var oMenuLink = $('#' + this._aHtmlIds['block_link_results']);
+	if(oMenuLink.length > 0) {
+		oMenuLink.click();
+		return;
+	}
+
+	this.changeBlock(oLink, 'results', iContentId);
+};
+
+BxPollsEntry.prototype.loadingInBlock = function(e, bShow) {
+	var oParent = $(e).length ? $(e).parents('.bx-db-container:first') : $('body'); 
+	bx_loading(oParent, bShow);
+};

+ 102 - 0
modules/boonex/polls/template/css/entry.css

@@ -0,0 +1,102 @@
+/*--- Subentries ---*/
+
+/*--- Results ---*/
+div.bx-polls-result-graph {
+	display: table;
+	width: 100%;
+}
+div.bx-polls-result-graph .bx-polls-rg-bar,
+div.bx-polls-result-graph .bx-polls-rg-text {
+	display: table-cell;
+}
+div.bx-polls-result-graph .bx-polls-rg-bar {
+    -webkit-animation-fill-mode: both;
+    -moz-animation-fill-mode: both;
+    -o-animation-fill-mode: both;
+    animation-fill-mode: both;
+
+    -webkit-transform-origin: left;
+    -moz-transform-origin: left;
+    -ms-transform-origin: left;
+    -o-transform-origin: left;
+    transform-origin: left;
+
+    -webkit-animation: votes-bar 1000ms ease-out;
+    -o-animation: votes-bar 1000ms ease-out;
+    animation: votes-bar 1000ms ease-out;
+
+    background: #2196F3;
+    background: -moz-linear-gradient(left,#2196F3 0%,#1976D2 100%);
+    background: -webkit-gradient(linear,left top,right top,color-stop(0%,#2196F3),color-stop(100%,#1976D2));
+    background: -webkit-linear-gradient(left,#2196F3 0%,#1976D2 100%);
+    background: -o-linear-gradient(left,#2196F3 0%,#1976D2 100%);
+    background: -ms-linear-gradient(left,#2196F3 0%,#1976D2 100%);
+    background: linear-gradient(to right,#2196F3 0%,#1976D2 100%);
+    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#2196F3',endColorstr='#1976D2',GradientType=1);
+}
+
+/*--- Animation ---*/
+@-webkit-keyframes votes-bar {
+    from {
+        -webkit-transform:scaleX(0);
+        -moz-transform:scaleX(0);
+        -ms-transform:scaleX(0);
+        -o-transform:scaleX(0);
+        transform:scaleX(0)
+    }
+    to {
+        -webkit-transform:scaleX(1);
+        -moz-transform:scaleX(1);
+        -ms-transform:scaleX(1);
+        -o-transform:scaleX(1);
+        transform:scaleX(1)
+    }
+}
+@-moz-keyframes votes-bar {
+    from {
+        -webkit-transform:scaleX(0);
+        -moz-transform:scaleX(0);
+        -ms-transform:scaleX(0);
+        -o-transform:scaleX(0);
+        transform:scaleX(0)
+    }
+    to {
+        -webkit-transform:scaleX(1);
+        -moz-transform:scaleX(1);
+        -ms-transform:scaleX(1);
+        -o-transform:scaleX(1);
+        transform:scaleX(1)
+    }
+}
+@-ms-keyframes votes-bar {
+    from {
+        -webkit-transform:scaleX(0);
+        -moz-transform:scaleX(0);
+        -ms-transform:scaleX(0);
+        -o-transform:scaleX(0);
+        transform:scaleX(0)
+    }
+    to {
+        -webkit-transform:scaleX(1);
+        -moz-transform:scaleX(1);
+        -ms-transform:scaleX(1);
+        -o-transform:scaleX(1);
+        transform:scaleX(1)
+    }
+}
+@keyframes votes-bar {
+    from {
+        -webkit-transform:scaleX(0);
+        -moz-transform:scaleX(0);
+        -ms-transform:scaleX(0);
+        -o-transform:scaleX(0);
+        transform:scaleX(0)
+    }
+    to {
+        -webkit-transform:scaleX(1);
+        -moz-transform:scaleX(1);
+        -ms-transform:scaleX(1);
+        -o-transform:scaleX(1);
+        transform:scaleX(1)
+    }
+}

+ 2 - 2
modules/boonex/polls/template/subentries.html

@@ -1,5 +1,5 @@
-<div class="bx-base-text-subentries bx-clearfix">
+<div class="bx-polls-subentries bx-clearfix">
     <bx_repeat:subentries>
-        <div class="bx-base-text-subentry bx-def-margin-sec-top-auto">__subentry__</div>
+        <div class="bx-polls-subentry bx-def-margin-top-auto">__subentry__</div>
     </bx_repeat:subentries>
 </div>

+ 11 - 0
modules/boonex/polls/template/subentries_results.html

@@ -0,0 +1,11 @@
+<div class="bx-polls-results bx-clearfix">
+    <bx_repeat:subentries>
+        <div class="bx-polls-result bx-def-margin-top-auto">
+            <div class="bx-polls-result-into">__title__</div>
+            <div class="bx-polls-result-graph bx-def-margin-thd-top">
+                <div class="bx-polls-rg-bar bx-def-round-corners" style="width:__width__"></div>
+                <div class="bx-polls-rg-text bx-def-padding-left bx-def-font-middle bx-def-font-grayed">__results__</div>
+            </div>
+        </div>
+    </bx_repeat:subentries>
+</div>

+ 12 - 0
modules/boonex/polls/template/subentries_ve_block.html

@@ -0,0 +1,12 @@
+<div id="__html_id__" class="__style_prefix__ __class__" bx_vote_data_rate="__rate__" bx_vote_data_count="__count__">
+	<div class="__style_prefix__-do bx-clearfix">
+		<bx_if:show_do_vote>
+			<div class="__style_prefix__-element-holder">__do_vote__</div>
+		</bx_if:show_do_vote>
+		<bx_if:show_counter>
+			<div class="__style_prefix__-counter-holder bx-def-margin-left-auto bx-btn-border"<bx_if:show_hidden> style="display:none"</bx_if:show_hidden>>__counter__</div>
+		</bx_if:show_counter>
+	</div>
+	<bx_if:show_legend>__legend__</bx_if:show_legend>
+</div>
+__script__

+ 4 - 0
modules/boonex/russian/data/langs/bx_polls/ru.xml

@@ -155,6 +155,8 @@
 	<string name="_bx_polls_menu_item_title_admt_polls"><![CDATA[Голосования - {addon} спрятано]]></string>
 	<string name="_bx_polls_menu_item_title_manage_my"><![CDATA[Мои Голосования]]></string>
 	<string name="_bx_polls_menu_item_title_manage_all"><![CDATA[Все Голосования]]></string>
+	<string name="_bx_polls_menu_item_view_subentries"><![CDATA[Голосование]]></string>
+    <string name="_bx_polls_menu_item_view_results"><![CDATA[Результаты]]></string>
 
 	<string name="_bx_polls_grid_filter_item_title_adm_select_one_filter1"><![CDATA[Все статусы]]></string>
 	<string name="_bx_polls_grid_filter_item_title_adm_active"><![CDATA[Активные]]></string>
@@ -209,4 +211,6 @@
     <string name="_bx_polls_txt_sample_comment_single"><![CDATA[комментарии к голосования]]></string>
     <string name="_bx_polls_txt_sample_vote_single"><![CDATA[голос за голосование]]></string>
     <string name="_bx_polls_txt_subentry_vote_do_by"><![CDATA[Проголосовали за]]></string>
+    <string name="_bx_polls_txt_subentry_vote_counter"><![CDATA[{0} голосов]]></string>
+    <string name="_bx_polls_txt_subentry_n_votes_m_percent"><![CDATA[{0} голосов ({1}%)]]></string>
 </resources>