AntonLV 13 лет назад
Родитель
Сommit
95f97b483a

+ 14 - 0
modules/boonex/timeline/classes/BxTimelineConfig.php

@@ -45,6 +45,7 @@ class BxTimelineConfig extends BxDolModuleConfig
     protected $_aJsObjects;
 
     protected $_aHtmlIds;
+    protected $_aShareDefaults;
 
 	protected $_sAnimationEffect;
     protected $_iAnimationSpeed;
@@ -97,11 +98,19 @@ class BxTimelineConfig extends BxDolModuleConfig
         	),
         	'post' => array(),
         	'share' => array(
+        		'main' => $sHtmlPrefix . '-share-',
         		'counter' => $sHtmlPrefix . '-share-counter-',
         		'by_popup' => $sHtmlPrefix . '-share-by-',
         	)
         );
 
+        $this->_aShareDefaults = array(
+			'show_do_share_as_button' => false,
+			'show_do_share_icon' => true,
+			'show_do_share_label' => false,
+			'show_counter' => true
+		);
+        
         $this->_sAnimationEffect = 'fade';
         $this->_iAnimationSpeed = 'slow';
         $this->_sStylePrefix = 'bx-tl';
@@ -295,6 +304,11 @@ class BxTimelineConfig extends BxDolModuleConfig
         return $this->_aHtmlIds[$sType][$sKey];
     }
 
+    public function getShareDefaults()
+    {
+    	return $this->_aShareDefaults;
+    }
+
 	public function getAnimationEffect()
     {
         return $this->_sAnimationEffect;

+ 3 - 3
modules/boonex/timeline/classes/BxTimelineDb.php

@@ -312,10 +312,10 @@ class BxTimelineDb extends BxDolModuleDb
     	return (int)$this->updateEvent(array('shares' => (int)$iCounter + $iIncrement), array('id' => $iId)) > 0;
     }
     
-    public function getShared($sType, $sActions, $iObjectId)
+    public function getShared($sType, $sAction, $iObjectId)
     {
-    	if($this->_oConfig->isSystem($sType, $sActions))
-			$aParams = array('browse' => 'descriptor', 'type' => $sType, 'action' => $sActions, 'object_id' => $iObjectId);
+    	if($this->_oConfig->isSystem($sType, $sAction))
+			$aParams = array('browse' => 'descriptor', 'type' => $sType, 'action' => $sAction, 'object_id' => $iObjectId);
 		else 
 			$aParams = array('browse' => 'id', 'value' => $iObjectId);
 

+ 11 - 10
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -371,25 +371,26 @@ class BxTimelineModule extends BxDolModule
     	return array('content' => $this->_oTemplate->getViewItemBlock($iItemId));
     }
 
-    public function serviceGetShareJsScript()
+    public function serviceGetShareElementBlock($iOwnerId, $sType, $sAction, $iObjectId, $aParams = array())
     {
-    	$this->_oTemplate->addJs(array('main.js', 'share.js'));
+    	$aParams = array_merge($aParams, $this->_oConfig->getShareDefaults());
 
-		return $this->_oTemplate->getJsCode('share');
+    	return $this->_oTemplate->getShareElement($iOwnerId, $sType, $sAction, $iObjectId, $aParams);
     }
 
-	public function serviceGetShareJsClick($iOwnerId, $sType, $sAction, $iObjectId)
+	public function serviceGetShareCounter($sType, $sAction, $iObjectId)
     {
-    	$sJsObject = $this->_oConfig->getJsObject('share');
-    	$sFormat = "%s.shareItem(this, %d, '%s', '%s', %d);";
+    	return $this->_oTemplate->getShareCounter($sType, $sAction, $iObjectId);
+    }
 
-    	$iOwnerId = !empty($iOwnerId) ? (int)$iOwnerId : $this->getUserId(); //--- in whose timeline the content will be shared
-    	return sprintf($sFormat, $sJsObject, $iOwnerId, $sType, $sAction, (int)$iObjectId);
+    public function serviceGetShareJsScript()
+    {
+		return $this->_oTemplate->getShareJsScript();
     }
 
-    public function serviceGetShareCounter($sType, $sAction, $iObjectId)
+	public function serviceGetShareJsClick($iOwnerId, $sType, $sAction, $iObjectId)
     {
-    	return $this->_oTemplate->getShareCounter($sType, $sAction, $iObjectId);
+    	return $this->_oTemplate->getShareJsClick($iOwnerId, $sType, $sAction, $iObjectId);
     }
 
     /*

+ 51 - 3
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -26,7 +26,7 @@ class BxTimelineTemplate extends BxDolModuleTemplate
 
 	public function getCssJs()
     {
-    	$this->addCss(array('plugins/jquery/themes/|jquery-ui.css', 'view.css', 'view-media-tablet.css', 'view-media-desktop.css', 'post.css'));
+    	$this->addCss(array('plugins/jquery/themes/|jquery-ui.css', 'view.css', 'view-media-tablet.css', 'view-media-desktop.css', 'post.css', 'share.css'));
         $this->addJs(array('jquery.ui.all.min.js', 'jquery.resize.js', 'plugins/|masonry.pkgd.min.js', 'common_anim.js', 'main.js', 'view.js', 'post.js', 'share.js'));
     }
 
@@ -293,12 +293,43 @@ class BxTimelineTemplate extends BxDolModuleTemplate
         ));
     }
 
-    public function getShareCounter($sType, $sActions, $iObjectId)
+	public function getShareElement($iOwnerId, $sType, $sAction, $iObjectId, $aParams = array())
+    {
+    	$sStylePrefix = $this->_oConfig->getPrefix('style');
+
+    	$aShared = $this->_oDb->getShared($sType, $sAction, $iObjectId);
+
+    	$sDoShare = $this->parseHtmlByName('bx_a.html', array(
+    		'href' => 'javascript:void(0)',
+    		'title' => _t('_bx_timeline_txt_do_share'),
+    		'bx_repeat:attrs' => array(
+    			array('key' => 'onclick', 'value' => $this->getShareJsClick($iOwnerId, $sType, $sAction, $iObjectId))
+    		),
+    		'content' => $this->parseHtmlByName('bx_icon.html', array('name' => 'share'))
+    	));
+
+    	return $this->parseHtmlByName('share_element_block.html', array(
+    		'style_prefix' => $sStylePrefix,
+    		'html_id' => $this->_oConfig->getHtmlIds('share', 'main') . $aShared['id'],
+    		'count' => $aShared['shares'],
+    		'do_share' => $sDoShare,
+    		'bx_if:show_counter' => array(
+    			'condition' => isset($aParams['show_counter']) && $aParams['show_counter'] === true,
+    			'content' => array(
+    				'style_prefix' => $sStylePrefix,
+    				'counter' => $this->getShareCounter($sType, $sAction, $iObjectId)
+    			)
+    		),
+    		'script' => $this->getShareJsScript()
+    	));
+    }
+
+    public function getShareCounter($sType, $sAction, $iObjectId)
     {
     	$sStylePrefix = $this->_oConfig->getPrefix('style');
     	$sJsObject = $this->_oConfig->getJsObject('share');
 
-    	$aEvent = $this->_oDb->getShared($sType, $sActions, $iObjectId);
+    	$aEvent = $this->_oDb->getShared($sType, $sAction, $iObjectId);
 
     	return $this->parseHtmlByName('share_counter.html', array(
     		'style_prefix' => $sStylePrefix,
@@ -333,6 +364,23 @@ class BxTimelineTemplate extends BxDolModuleTemplate
     	));
     }
 
+	public function getShareJsScript()
+    {
+    	$this->addCss(array('share.css'));
+    	$this->addJs(array('main.js', 'share.js'));
+
+		return $this->getJsCode('share');
+    }
+
+    public function getShareJsClick($iOwnerId, $sType, $sAction, $iObjectId)
+    {
+    	$sJsObject = $this->_oConfig->getJsObject('share');
+    	$sFormat = "%s.shareItem(this, %d, '%s', '%s', %d);";
+
+    	$iOwnerId = !empty($iOwnerId) ? (int)$iOwnerId : $this->getUserId(); //--- in whose timeline the content will be shared
+    	return sprintf($sFormat, $sJsObject, $iOwnerId, $sType, $sAction, (int)$iObjectId);
+    }
+
 	protected function _getPost($sType, $aEvent, $aBrowseParams = array())
     {
 		$oModule = $this->getModule();

+ 1 - 0
modules/boonex/timeline/install/langs/en.xml

@@ -121,6 +121,7 @@
 	<string name="_bx_timeline_txt_user_shared_sample"><![CDATA[{0} shared {1}'s {2}]]></string>
 	<string name="_bx_timeline_txt_sample"><![CDATA[item]]></string>
 
+	<string name="_bx_timeline_txt_do_share"><![CDATA[Share]]></string>
 	<string name="_bx_timeline_txt_shared"><![CDATA[Shared {0}'s {1}.]]></string>
 	<string name="_bx_timeline_txt_err_cannot_share"><![CDATA[Cannot share. Please report.]]></string>
 	<string name="_bx_timeline_txt_msg_success_share"><![CDATA[Shared successfully.]]></string>

+ 10 - 0
modules/boonex/timeline/template/css/share.css

@@ -0,0 +1,10 @@
+.bx-tl-share .bx-tl-share-element-holder,
+.bx-tl-share .bx-tl-share-counter-holder {
+	line-height: 36px;
+	line-height: 2.2rem;
+}
+div.bx-tl-share div.bx-tl-share-element-holder,
+div.bx-tl-share div.bx-tl-share-counter-holder {
+	position: relative;
+	float: left;
+}

+ 7 - 0
modules/boonex/timeline/template/share_element_block.html

@@ -0,0 +1,7 @@
+<div id="__html_id__" class="__style_prefix__-share bx-clearfix" bx_share_data_count="__count__">
+	<div class="__style_prefix__-share-element-holder">__do_share__</div>
+	<bx_if:show_counter>
+		<div class="__style_prefix__-share-counter-holder bx-def-margin-sec-left">__counter__</div>
+	</bx_if:show_counter>
+</div>
+__script__

+ 2 - 4
template/scripts/BxBaseVoteView.php

@@ -43,15 +43,13 @@ class BxBaseVoteView extends BxDolVote
         $this->_aElementDefaults = array(
         	'stars' => array(
 	        	'show_do_vote_legend' => false,
-        		'show_counter' => true,
-        		'show_counter_labled' => true,
+        		'show_counter' => true
 	        ),
 	        'likes' => array(
 	        	'show_do_vote_as_button' => false,
 	        	'show_do_vote_icon' => true,
 	        	'show_do_vote_label' => false,
-        		'show_counter' => true,
-	        	'show_counter_labled' => true,
+        		'show_counter' => true
         	)
         );