Sfoglia il codice sorgente

Ticket #516 - integration with content based modules.

AntonLV 9 anni fa
parent
commit
952ef9bb0d

+ 52 - 0
inc/js/classes/BxDolView.js

@@ -0,0 +1,52 @@
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    UnaCore UNA Core
+ * @{
+ */
+
+function BxDolView(options)
+{
+	this._sObjName = undefined == options.sObjName ? 'oView' : options.sObjName; // javascript object name, to run current object instance from onTimer
+	this._sSystem = options.sSystem; // current comment system
+	this._iAuthorId = options.iAuthorId; // this comment's author ID.
+    this._iObjId = options.iObjId; // this object id comments
+
+    this._sActionsUri = 'view.php';
+    this._sActionsUrl = options.sRootUrl + this._sActionsUri; // actions url address
+
+    this._sAnimationEffect = 'fade';
+    this._iAnimationSpeed = 'slow';
+    this._sSP = undefined == options.sStylePrefix ? 'bx-view' : options.sStylePrefix;
+    this._aHtmlIds = options.aHtmlIds;
+}
+
+BxDolView.prototype.toggleByPopup = function(oLink) {
+	var $this = this;
+    var oData = this._getDefaultParams();
+    oData['action'] = 'GetViewedBy';
+
+	$(oLink).dolPopupAjax({
+		id: this._aHtmlIds['by_popup'], 
+		url: bx_append_url_params(this._sActionsUri, oData)
+	});
+};
+
+BxDolView.prototype._loadingInButton = function(e, bShow) {
+	if($(e).length)
+		bx_loading_btn($(e), bShow);
+	else
+		bx_loading($('body'), bShow);	
+};
+
+BxDolView.prototype._getDefaultParams = function() {
+	var oDate = new Date();
+    return {
+        sys: this._sSystem,
+        id: this._iObjId,
+        _t: oDate.getTime()
+    };
+};
+
+/** @} */

+ 8 - 0
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -246,6 +246,7 @@ class BxBaseModGeneralModule extends BxDolModule
         	'title' => !empty($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : '',
         	'object_storage' => !empty($CNF['OBJECT_STORAGE']) ? $CNF['OBJECT_STORAGE'] : '',
             'object_transcoder' => false,
+        	'object_view' => !empty($CNF['OBJECT_VIEWS']) ? $CNF['OBJECT_VIEWS'] : '',
         	'object_vote' => !empty($CNF['OBJECT_VOTES']) ? $CNF['OBJECT_VOTES'] : '',
         	'object_favorite' => !empty($CNF['OBJECT_FAVORITES']) ? $CNF['OBJECT_FAVORITES'] : '',
         	'object_report' => !empty($CNF['OBJECT_REPORTS']) ? $CNF['OBJECT_REPORTS'] : '',
@@ -840,6 +841,12 @@ class BxBaseModGeneralModule extends BxDolModule
         }
 
         //TODO: Rebuild using menus engine when it will be ready for such elements like Vote, Share, etc.
+        //--- Views
+        $sViews = '';
+        $oViews = !empty($aParams['object_view']) ? BxDolView::getObjectInstance($aParams['object_view'], $iId) : false;
+        if ($oViews)
+            $sViews = $oViews->getElementBlock(array('show_do_view_as_button' => true));
+
         //--- Votes
         $sVotes = '';
         $oVotes = !empty($aParams['object_vote']) ? BxDolVote::getObjectInstance($aParams['object_vote'], $iId) : false;
@@ -871,6 +878,7 @@ class BxBaseModGeneralModule extends BxDolModule
 
         return $this->_oTemplate->parseHtmlByName('entry-share.html', array(
             'comments' => $sComments,
+        	'view' => $sViews,
             'vote' => $sVotes,
             'favorite' => $sFavorites,
             'share' => $sShare,

+ 1 - 0
modules/base/general/template/css/main.css

@@ -4,6 +4,7 @@
     margin-top:0;
 }
 
+.bx-base-general-entity-share .bx-view,
 .bx-base-general-entity-share .bx-vote,
 .bx-base-general-entity-share .bx-favorite,
 .bx-base-general-entity-share .bx-report,

+ 1 - 1
modules/base/general/template/entry-share.html

@@ -1 +1 @@
-<div class="bx-base-general-entity-share bx-clearfix">__comments____vote____favorite____share____report____social__</div>
+<div class="bx-base-general-entity-share bx-clearfix">__comments____view____vote____favorite____share____report____social__</div>