Ver Fonte

Ticket #1447 - Polls.

AntonLV há 8 anos atrás
pai
commit
98ebfa847e

+ 85 - 49
modules/boonex/polls/classes/BxPollsTemplate.php

@@ -32,71 +32,44 @@ class BxPollsTemplate extends BxBaseModTextTemplate
         return parent::getJsCode($sType, $aParams, $bWrap);
     }
 
-    public function entrySubentries ($aData, $bDynamic = false)
+    public function getTmplVarsText($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 '';
+        $aVars = parent::getTmplVarsText($aData);
 
-        $aTmplVarsSubentries = array();
-        foreach($aSubentries as $aSubentry) {
-            $oVotes = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES_SUBENTRIES'], $aSubentry['id']);
+        $sMethod = '_getGetBlockContent' . (!$this->_oDb->isPerformed($aData[$CNF['FIELD_ID']], bx_get_logged_profile_id()) ? 'Subentries' : 'Results');
+        $sSubentries = $this->$sMethod($aData);
 
-            $aTmplVarsSubentries[] = array(
-                'subentry' => $oVotes->getElementBlock(array(
-                    'dynamic_mode' => $bDynamic
-                ))
-            );
-        }
+        $aVars['bx_if:show_subentries'] = array(
+            'condition' => !empty($sSubentries),
+            'content' => array(
+                'entry_subentries' => $sSubentries
+            )
+        );
+        return $aVars;
+    }
+
+    public function entrySubentries ($aData, $bDynamic = false)
+    {
+        $sContent = $this->_getGetBlockContentSubentries($aData, $bDynamic);
+        if(empty($sContent))
+            return '';
 
     	return array(
-            'content' => $this->parseHtmlByName('subentries.html', array(
-    			'html_id' => $this->_oConfig->getHtmlIds('content') . $aData[$CNF['FIELD_ID']],
-                'bx_repeat:subentries' => $aTmplVarsSubentries,
-    	        'bx_if:show_public' => array(
-    	            'condition' => (int)$aData[$CNF['FIELD_ANONYMOUS']] == 0,
-    	            'content' => array()
-    	        )
-            )),
+            'content' => $sContent,
             'menu' => $this->_getGetBlockMenu($aData, 'subentries')
         );
     }
 
     public function entryResults($aData, $bDynamic = false)
     {
-        $CNF = &$this->getModule()->_oConfig->CNF;
-
-        $bAnonymous = (int)$aData[$CNF['FIELD_ANONYMOUS']] == 1;
-
-        $aSubentries = $this->_oDb->getSubentries(array('type' => 'entry_id', 'entry_id' => $aData[$CNF['FIELD_ID']]));
-        if(empty($aSubentries) || !is_array($aSubentries))
+        $sContent = $this->_getGetBlockContentResults($aData, $bDynamic);
+        if(empty($sContent))
             return '';
 
-        $iTotal = 0;
-        foreach($aSubentries as $aSubentry)
-            $iTotal += $aSubentry['votes'];
-
-        $aTmplVarsSubentries = array();
-        foreach($aSubentries as $aSubentry) {
-            $oVotes = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES_SUBENTRIES'], $aSubentry['id']);
-
-            $fPercent = $iTotal > 0 ? 100 * (float)$aSubentry['votes']/$iTotal : 0;
-            $aTmplVarsSubentries[] = array(
-                'title' => bx_process_output($aSubentry['title']),
-                'width' => (int)round($fPercent) . '%',
-                'votes' => $oVotes->getCounter(array('show_counter_empty' => true, 'show_counter_in_brackets' => false)),
-                'percent' => _t('_bx_polls_txt_subentry_vote_percent', $iTotal > 0 ? round($fPercent, 2) : 0),
-                'js_code' => $oVotes->getJsScript($bDynamic)
-            );
-        }
-
         return array(
-            'content' => $this->parseHtmlByName('subentries_results.html', array(
-            	'html_id' => $this->_oConfig->getHtmlIds('content') . $aData[$CNF['FIELD_ID']],
-                'bx_repeat:subentries' => $aTmplVarsSubentries,
-            )),
+            'content' => $sContent,
             'menu' => $this->_getGetBlockMenu($aData, 'results')
         );
     }
@@ -148,6 +121,69 @@ class BxPollsTemplate extends BxBaseModTextTemplate
 
         return $oMenu;
     }
+    
+    protected function _getGetBlockContentSubentries($aData, $bDynamic = false)
+    {
+        $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 '';
+
+        $aTmplVarsSubentries = array();
+        foreach($aSubentries as $aSubentry) {
+            $oVotes = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES_SUBENTRIES'], $aSubentry['id']);
+
+            $aTmplVarsSubentries[] = array(
+                'subentry' => $oVotes->getElementBlock(array(
+                    'dynamic_mode' => $bDynamic
+                ))
+            );
+        }
+
+    	return $this->parseHtmlByName('subentries.html', array(
+            'html_id' => $this->_oConfig->getHtmlIds('content') . $aData[$CNF['FIELD_ID']],
+            'bx_repeat:subentries' => $aTmplVarsSubentries,
+            'bx_if:show_public' => array(
+                'condition' => (int)$aData[$CNF['FIELD_ANONYMOUS']] == 0,
+                'content' => array()
+            )
+        ));
+    }
+    
+    protected function _getGetBlockContentResults($aData, $bDynamic = false)
+    {
+        $CNF = &$this->getModule()->_oConfig->CNF;
+
+        $bAnonymous = (int)$aData[$CNF['FIELD_ANONYMOUS']] == 1;
+
+        $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) {
+            $oVotes = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES_SUBENTRIES'], $aSubentry['id']);
+
+            $fPercent = $iTotal > 0 ? 100 * (float)$aSubentry['votes']/$iTotal : 0;
+            $aTmplVarsSubentries[] = array(
+                'title' => bx_process_output($aSubentry['title']),
+                'width' => (int)round($fPercent) . '%',
+                'votes' => $oVotes->getCounter(array('show_counter_empty' => true, 'show_counter_in_brackets' => false)),
+                'percent' => _t('_bx_polls_txt_subentry_vote_percent', $iTotal > 0 ? round($fPercent, 2) : 0),
+                'js_code' => $oVotes->getJsScript($bDynamic)
+            );
+        }
+
+        return $this->parseHtmlByName('subentries_results.html', array(
+            'html_id' => $this->_oConfig->getHtmlIds('content') . $aData[$CNF['FIELD_ID']],
+            'bx_repeat:subentries' => $aTmplVarsSubentries,
+        ));
+    }
 }
 
 /** @} */

+ 1 - 1
modules/boonex/polls/install/langs/en.xml

@@ -43,7 +43,7 @@
     <string name="_bx_polls_form_profile_input_hidden_results"><![CDATA[Hide results until voted]]></string>
     <string name="_bx_polls_form_entry_input_sys_allow_view_to"><![CDATA[Visibility]]></string>
     <string name="_bx_polls_form_entry_input_allow_view_to"><![CDATA[Visibility]]></string>
-    <string name="_bx_polls_form_entry_input_picture_use_as_thumb"><![CDATA[Cover Image]]></string>
+    <string name="_bx_polls_form_entry_input_picture_use_as_thumb"><![CDATA[Header Image]]></string>
     <string name="_bx_polls_form_entry_input_sys_date_added"><![CDATA[Created]]></string>
     <string name="_bx_polls_form_entry_input_date_added"><![CDATA[Created]]></string>
     <string name="_bx_polls_form_entry_input_sys_date_changed"><![CDATA[Updated]]></string>

+ 14 - 13
modules/boonex/polls/install/sql/enable.sql

@@ -44,21 +44,22 @@ 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');
+('bx_polls_view_entry', '_bx_polls_page_title_sys_view_entry', '_bx_polls_page_title_view_entry', 'bx_polls', 12, 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', 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', 2, 'bx_polls', '_bx_polls_page_block_title_sys_entry_context', '_bx_polls_page_block_title_entry_context', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:14:\"entity_context\";}', 0, 0, 1, 1),
-('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),
-('bx_polls_view_entry', 4, 'bx_polls', '', '_bx_polls_page_block_title_entry_all_actions', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:18:\"entity_all_actions\";}', 0, 0, 1, 0),
-('bx_polls_view_entry', 4, 'bx_polls', '', '_bx_polls_page_block_title_entry_actions', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:14:\"entity_actions\";}', 0, 0, 0, 1),
-('bx_polls_view_entry', 4, 'bx_polls', '', '_bx_polls_page_block_title_entry_social_sharing', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:21:\"entity_social_sharing\";}', 0, 0, 0, 2),
-('bx_polls_view_entry', 4, 'bx_polls', '', '_bx_polls_page_block_title_entry_attachments', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:18:\"entity_attachments\";}', 0, 0, 0, 3),
-('bx_polls_view_entry', 4, 'bx_polls', '', '_bx_polls_page_block_title_entry_comments', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:15:\"entity_comments\";}', 0, 0, 1, 4),
-('bx_polls_view_entry', 4, 'bx_polls', '', '_bx_polls_page_block_title_entry_location', 3, 2147483647, 'service', 'a:4:{s:6:\"module\";s:6:\"system\";s:6:\"method\";s:13:\"locations_map\";s:6:\"params\";a:2:{i:0;s:8:\"bx_polls\";i:1;s:4:\"{id}\";}s:5:\"class\";s:20:\"TemplServiceMetatags\";}', 0, 0, 1, 5);
+('bx_polls_view_entry', 2, '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, 2),
+('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:20:\"get_block_subentries\";}', 0, 0, 0, 0),
+('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, 1),
+('bx_polls_view_entry', 3, 'bx_polls', '_bx_polls_page_block_title_sys_entry_context', '_bx_polls_page_block_title_entry_context', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:14:\"entity_context\";}', 0, 0, 1, 1),
+('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, 2),
+('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, 0),
+('bx_polls_view_entry', 2, 'bx_polls', '', '_bx_polls_page_block_title_entry_all_actions', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:18:\"entity_all_actions\";}', 0, 0, 1, 3),
+('bx_polls_view_entry', 4, 'bx_polls', '', '_bx_polls_page_block_title_entry_actions', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:14:\"entity_actions\";}', 0, 0, 0, 0),
+('bx_polls_view_entry', 4, 'bx_polls', '', '_bx_polls_page_block_title_entry_social_sharing', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:21:\"entity_social_sharing\";}', 0, 0, 0, 0),
+('bx_polls_view_entry', 4, 'bx_polls', '', '_bx_polls_page_block_title_entry_attachments', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:18:\"entity_attachments\";}', 0, 0, 0, 0),
+('bx_polls_view_entry', 2, 'bx_polls', '', '_bx_polls_page_block_title_entry_comments', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_polls\";s:6:\"method\";s:15:\"entity_comments\";}', 0, 0, 1, 4),
+('bx_polls_view_entry', 3, 'bx_polls', '', '_bx_polls_page_block_title_entry_location', 3, 2147483647, 'service', 'a:4:{s:6:\"module\";s:6:\"system\";s:6:\"method\";s:13:\"locations_map\";s:6:\"params\";a:2:{i:0;s:8:\"bx_polls\";i:1;s:4:\"{id}\";}s:5:\"class\";s:20:\"TemplServiceMetatags\";}', 0, 0, 1, 3),
+('bx_polls_view_entry', 3, 'bx_polls', '', '_bx_polls_page_block_title_featured_entries', 11, 2147483647, 'service', 'a:3:{s:6:"module";s:8:"bx_polls";s:6:"method";s:15:"browse_featured";s:6:"params";a:1:{i:0;s:8:"extended";}}', 0, 0, 1, 4);
 
 
 -- PAGE: view entry comments

+ 9 - 1
modules/boonex/polls/template/entry-text.html

@@ -1,3 +1,11 @@
 <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">
     __entry_text__
-</div>
+</div>
+<bx_if:show_image>
+    <div class="bx-base-text-entity-image bx-def-margin-top bx-def-font-align-center">
+        <img class="bx-def-border-radius-block" src="__entry_image__" />
+    </div>
+</bx_if:show_image>
+<bx_if:show_subentries>
+    <div class="bx-poll-entity-subentries bx-def-margin-top">__entry_subentries__</div>
+</bx_if:show_subentries>

+ 2 - 2
modules/boonex/posts/install/langs/en.xml

@@ -34,8 +34,8 @@
 	<string name="_bx_posts_form_entry_input_delete_confirm"><![CDATA[I am sure I want to delete this post]]></string>
 	<string name="_bx_posts_form_entry_input_delete_confirm_info"><![CDATA[This action can not be undone]]></string>
 	<string name="_bx_posts_form_entry_input_delete_confirm_error"><![CDATA[Please check this checkbox if you really want to delete the post]]></string>
-	<string name="_bx_posts_form_entry_input_sys_covers"><![CDATA[Cover]]></string>
-	<string name="_bx_posts_form_entry_input_covers"><![CDATA[Cover]]></string>
+	<string name="_bx_posts_form_entry_input_sys_covers"><![CDATA[Header Image]]></string>
+	<string name="_bx_posts_form_entry_input_covers"><![CDATA[Header Image]]></string>
 	<string name="_bx_posts_form_entry_input_covers_uploader_simple_title"><![CDATA[Upload]]></string>
 	<string name="_bx_posts_form_entry_input_covers_uploader_html5_title"><![CDATA[Upload]]></string>
 	<string name="_bx_posts_form_entry_input_sys_pictures"><![CDATA[Pictures]]></string>

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

@@ -43,7 +43,7 @@
     <string name="_bx_polls_form_profile_input_hidden_results"><![CDATA[Скрывать результаты до голосования]]></string>
     <string name="_bx_polls_form_entry_input_sys_allow_view_to"><![CDATA[Видимость]]></string>
     <string name="_bx_polls_form_entry_input_allow_view_to"><![CDATA[Видимость]]></string>
-    <string name="_bx_polls_form_entry_input_picture_use_as_thumb"><![CDATA[Изображение обложки]]></string>
+    <string name="_bx_polls_form_entry_input_picture_use_as_thumb"><![CDATA[Изображение заголовка]]></string>
     <string name="_bx_polls_form_entry_input_sys_date_added"><![CDATA[Создано]]></string>
     <string name="_bx_polls_form_entry_input_date_added"><![CDATA[Создано]]></string>
     <string name="_bx_polls_form_entry_input_sys_date_changed"><![CDATA[Обновлено]]></string>

+ 2 - 2
modules/boonex/russian/data/langs/bx_posts/ru.xml

@@ -34,8 +34,8 @@
 	<string name="_bx_posts_form_entry_input_delete_confirm"><![CDATA[Я уверен(а), что хочу удалить эту публикацию]]></string>
 	<string name="_bx_posts_form_entry_input_delete_confirm_info"><![CDATA[Это действие не может быть отменено]]></string>
 	<string name="_bx_posts_form_entry_input_delete_confirm_error"><![CDATA[Пожалуйста, отметьте этот флажок, если действительно хотите удалить публикацию]]></string>
-        <string name="_bx_posts_form_entry_input_sys_covers"><![CDATA[Обложка]]></string>
-	<string name="_bx_posts_form_entry_input_covers"><![CDATA[Обложка]]></string>
+        <string name="_bx_posts_form_entry_input_sys_covers"><![CDATA[Изображение заголовка]]></string>
+	<string name="_bx_posts_form_entry_input_covers"><![CDATA[Изображение заголовка]]></string>
 	<string name="_bx_posts_form_entry_input_covers_uploader_simple_title"><![CDATA[Загрузить]]></string>
 	<string name="_bx_posts_form_entry_input_covers_uploader_html5_title"><![CDATA[Загрузить]]></string>
 	<string name="_bx_posts_form_entry_input_sys_pictures"><![CDATA[Картинки]]></string>