1
0
Эх сурвалжийг харах

Ticket #187. Dynamic Votes loading in Comments.

AntonLV 11 жил өмнө
parent
commit
7ad59078fd

+ 12 - 5
inc/classes/BxDolCmts.php

@@ -131,6 +131,7 @@ define('BX_CMT_RATE_VALUE_MINUS', -1);
 class BxDolCmts extends BxDol implements iBxDolReplaceable
 {
     protected $_oQuery = null;
+    protected $_oTemplate = null;
 
     protected $_sFormObject;
     protected $_sFormDisplayPost;
@@ -175,7 +176,7 @@ class BxDolCmts extends BxDol implements iBxDolReplaceable
      * $sSystem - comments system name
      * $iId - obect id to be commented
      */
-    function __construct($sSystem, $iId, $iInit = 1)
+    function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
     {
         parent::__construct();
 
@@ -236,6 +237,11 @@ class BxDolCmts extends BxDol implements iBxDolReplaceable
 
         if ($iInit)
             $this->init($iId);
+
+		if ($oTemplate)
+            $this->_oTemplate = $oTemplate;
+        else
+            $this->_oTemplate = BxDolTemplate::getInstance();
     }
 
     /**
@@ -245,7 +251,7 @@ class BxDolCmts extends BxDol implements iBxDolReplaceable
      * @param $iInit perform initialization
      * @return null on error, or ready to use class instance
      */
-    public static function getObjectInstance($sSys, $iId, $iInit = true)
+    public static function getObjectInstance($sSys, $iId, $iInit = true, $oTemplate = false)
     {
         if(isset($GLOBALS['bxDolClasses']['BxDolCmts!' . $sSys . $iId]))
             return $GLOBALS['bxDolClasses']['BxDolCmts!' . $sSys . $iId];
@@ -261,7 +267,7 @@ class BxDolCmts extends BxDol implements iBxDolReplaceable
                 require_once(BX_DIRECTORY_PATH_ROOT . $aSystems[$sSys]['class_file']);
         }
 
-        $o = new $sClassName($sSys, $iId, $iInit);
+        $o = new $sClassName($sSys, $iId, $iInit, $oTemplate);
         return ($GLOBALS['bxDolClasses']['BxDolCmts!' . $sSys . $iId] = $o);
     }
 
@@ -410,7 +416,7 @@ class BxDolCmts extends BxDol implements iBxDolReplaceable
         if(empty($this->_aSystem['object_vote']))
         	$this->_aSystem['object_vote'] = 'sys_cmts';
 
-        $oVote = BxDolVote::getObjectInstance($this->_aSystem['object_vote'], $iId);
+        $oVote = BxDolVote::getObjectInstance($this->_aSystem['object_vote'], $iId, true, $this->_oTemplate);
         if(!$oVote || !$oVote->isEnabled())
             return false;
 
@@ -701,7 +707,7 @@ class BxDolCmts extends BxDol implements iBxDolReplaceable
         $this->_echoResultJson(array(
             'parent_id' => $aCmt['cmt_parent_id'],
             'vparent_id' => $aCmt['cmt_vparent_id'],
-            'content' => $this->getComment($aCmt, array('type' => $sCmtBrowse), array('type' => $sCmtDisplay))
+            'content' => $this->getComment($aCmt, array('type' => $sCmtBrowse), array('type' => $sCmtDisplay, 'dynamic_mode' => true))
         ));
     }
 
@@ -713,6 +719,7 @@ class BxDolCmts extends BxDol implements iBxDolReplaceable
         $aBp = $aDp = array();
 		$this->_getParams($aBp, $aDp);
 
+		$aDp['dynamic_mode'] = true;
         return $this->getComments($aBp, $aDp);
     }
 

+ 3 - 2
inc/js/functions.js

@@ -646,8 +646,9 @@ function bx_activate_anim_icons(sColor)
     });
 }
 
-bx_get_style = function(sUrl) {
+function bx_get_style(sUrl)
+{
 	$("head").append($("<link rel='stylesheet' href='" + sUrl + "' type='text/css' />"));
-};
+}
 
 /** @} */

+ 2 - 2
modules/boonex/air/data/template/system/scripts/BxTemplCmts.php

@@ -12,9 +12,9 @@
  */
 class BxTemplCmts extends BxBaseCmts
 {
-    function __construct($sSystem, $iId, $iInit = 1)
+    function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
     {
-        parent::__construct($sSystem, $iId, $iInit);
+        parent::__construct($sSystem, $iId, $iInit, $oTemplate);
     }
 }
 

+ 2 - 2
modules/boonex/lagoon/data/template/system/scripts/BxTemplCmts.php

@@ -12,9 +12,9 @@
  */
 class BxTemplCmts extends BxBaseCmts
 {
-    function __construct($sSystem, $iId, $iInit = 1)
+    function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
     {
-        parent::__construct($sSystem, $iId, $iInit);
+        parent::__construct($sSystem, $iId, $iInit, $oTemplate);
     }
 }
 

+ 2 - 2
modules/boonex/ocean/data/template/system/scripts/BxTemplCmts.php

@@ -12,9 +12,9 @@
  */
 class BxTemplCmts extends BxBaseCmts
 {
-    function __construct($sSystem, $iId, $iInit = 1)
+    function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
     {
-        parent::__construct($sSystem, $iId, $iInit);
+        parent::__construct($sSystem, $iId, $iInit, $oTemplate);
     }
 }
 

+ 15 - 18
template/scripts/BxBaseCmts.php

@@ -15,9 +15,9 @@ class BxBaseCmts extends BxDolCmts
     protected $_sJsObjName;
     protected $_sStylePrefix;
 
-    function __construct( $sSystem, $iId, $iInit = 1 )
+    function __construct( $sSystem, $iId, $iInit = true, $oTemplate = false)
     {
-        parent::__construct( $sSystem, $iId, $iInit );
+        parent::__construct($sSystem, $iId, $iInit, $oTemplate);
         if (empty($sSystem))
             return;
 
@@ -32,10 +32,8 @@ class BxBaseCmts extends BxDolCmts
      */
     public function addCssJs ()
     {
-        $oTemplate = BxDolTemplate::getInstance();
-
-        $oTemplate->addCss(array('cmts.css'));
-        $oTemplate->addJs(array('jquery.anim.js', 'jquery.form.min.js', 'BxDolCmts.js'));
+        $this->_oTemplate->addCss(array('cmts.css'));
+        $this->_oTemplate->addJs(array('jquery.anim.js', 'jquery.form.min.js', 'BxDolCmts.js'));
 
         $oForm = BxDolForm::getObjectInstance($this->_sFormObject, $this->_sFormDisplayPost);
         $oForm->addCssJs();
@@ -165,8 +163,6 @@ class BxBaseCmts extends BxDolCmts
      */
     function getComment($mixedCmt, $aBp = array(), $aDp = array())
     {
-        $oTemplate = BxDolTemplate::getInstance();
-
         $iUserId = $this->_getAuthorId();
         $aCmt = !is_array($mixedCmt) ? $this->getCommentRow((int)$mixedCmt) : $mixedCmt;
         if (!$aCmt)
@@ -176,7 +172,7 @@ class BxBaseCmts extends BxDolCmts
 
         $sClass = '';
         if(isset($aCmt['vote_rate']) && (float)$aCmt['vote_rate'] < $this->_aSystem['viewing_threshold']) {
-            $oTemplate->pareseHtmlByName('comment_hidden.html', array(
+            $this->_oTemplate->pareseHtmlByName('comment_hidden.html', array(
                 'js_object' => $this->_sJsObjName,
                 'id' => $aCmt['cmt_id'],
                 'title' => bx_process_output(_t('_hidden_comment', $sAuthorName)),
@@ -238,7 +234,7 @@ class BxBaseCmts extends BxDolCmts
 
 		$sAgo = bx_time_js($aCmt['cmt_time']);
         $bObjectTitle = !empty($this->_aSystem['trigger_field_title']);
-        return $oTemplate->parseHtmlByName('comment.html', array_merge(array(
+        return $this->_oTemplate->parseHtmlByName('comment.html', array_merge(array(
             'system' => $this->_sSystem,
             'style_prefix' => $this->_sStylePrefix,
             'js_object' => $this->_sJsObjName,
@@ -378,8 +374,6 @@ class BxBaseCmts extends BxDolCmts
      */
     protected function _getControlsBox()
     {
-        $oTemplate = BxDolTemplate::getInstance();
-
         $sDisplay = '';
         $bDisplay = (int)$this->_aSystem['is_display_switch'] == 1;
         if($bDisplay) {
@@ -421,7 +415,7 @@ class BxBaseCmts extends BxDolCmts
             $sBrowseFilter = $oMenu->getCode();
         }
 
-        return $oTemplate->parseHtmlByName('comments_controls.html', array(
+        return $this->_oTemplate->parseHtmlByName('comments_controls.html', array(
             'display_switcher' => $bDisplay ? $sDisplay : '',
             'bx_if:is_divider_1' => array(
                 'condition' => $bDisplay && $bBrowseType,
@@ -442,9 +436,8 @@ class BxBaseCmts extends BxDolCmts
 
     protected function _getActionsBox(&$aCmt, $aDp = array())
     {
-    	$oTemplate = BxDolTemplate::getInstance();
-
     	$bViewOnly = isset($aDp['view_only']) && $aDp['view_only'] === true;
+    	$bDynamicMode = isset($aDp['dynamic_mode']) && $aDp['dynamic_mode'] === true;
 
         $bMenuManage = false;
         $sMenuActions = $sMenuManage = '';
@@ -453,12 +446,16 @@ class BxBaseCmts extends BxDolCmts
 	        //--- Actions Menu
 	        $oMenuActions = BxDolMenu::getObjectInstance($this->_sMenuObjActions);
 	        $oMenuActions->setCmtsData($this, $aCmt['cmt_id']);
+	        $oMenuActions->setDynamicMode($bDynamicMode);
 	        $sMenuActions = $oMenuActions->getCode();
 
+	        /*
+	        TODO: Remove before commit.
 	        $oVote = $this->getVoteObject($aCmt['cmt_id']);
 	        if($oVote !== false)
 	            $sMenuActions .= $oVote->getJsScript();
-	
+			*/
+
 	        //--- Manage Menu
 	        $oMenuManage = BxDolMenu::getObjectInstance($this->_sMenuObjManage);
 	        $oMenuManage->setCmtsData($this, $aCmt['cmt_id']);
@@ -466,7 +463,7 @@ class BxBaseCmts extends BxDolCmts
 	        $sMenuManage = $oMenuManage->getCode();
 	        $bMenuManage = !empty($sMenuManage);
 	        if($bMenuManage) {
-	            $sMenuManage = $oTemplate->parseHtmlByName('comment_manage.html', array(
+	            $sMenuManage = $this->_oTemplate->parseHtmlByName('comment_manage.html', array(
 	                'style_prefix' => $this->_sStylePrefix,
 	                'content' => $sMenuManage
 	            ));
@@ -475,7 +472,7 @@ class BxBaseCmts extends BxDolCmts
 	        }
 		}
 
-        return $oTemplate->parseHtmlByName('comment_actions.html', array(
+        return $this->_oTemplate->parseHtmlByName('comment_actions.html', array(
             'id' => $aCmt['cmt_id'],
             'js_object' => $this->_sJsObjName,
             'style_prefix' => $this->_sStylePrefix,

+ 1 - 1
template/scripts/BxBaseCmtsMenuActions.php

@@ -45,7 +45,7 @@ class BxBaseCmtsMenuActions extends BxTemplMenuCustom
         if(!$oVote)
         	return false;
 
-    	return $oVote->getElementInline();
+    	return $oVote->getElementInline(array('dynamic_mode' => $this->_bDynamicMode));
     }
 
     /**