Parcourir la source

Transfer fixes and improvements from Dolphin 7.1

AntonLV il y a 13 ans
Parent
commit
6593924661
42 fichiers modifiés avec 1132 ajouts et 451 suppressions
  1. 5 13
      cmts.php
  2. 1 0
      inc/classes/BxDolCache.php
  3. 18 0
      inc/classes/BxDolCacheFile.php
  4. 13 0
      inc/classes/BxDolCacheFileHtml.php
  5. 134 0
      inc/classes/BxDolCacheUtilities.php
  6. 20 10
      inc/classes/BxDolCalendar.php
  7. 7 1
      inc/classes/BxDolCaptcha.php
  8. 57 47
      inc/classes/BxDolCmts.php
  9. 10 7
      inc/classes/BxDolCmtsQuery.php
  10. 31 34
      inc/classes/BxDolCronCmd.php
  11. 7 0
      inc/classes/BxDolEditor.php
  12. 88 22
      inc/classes/BxDolFtp.php
  13. 3 0
      inc/classes/BxDolGzip.php
  14. 5 0
      inc/classes/BxDolLanguages.php
  15. 1 1
      inc/classes/BxDolRssFactory.php
  16. 7 4
      inc/classes/BxDolSearch.php
  17. 4 5
      inc/classes/BxDolTags.php
  18. 71 29
      inc/classes/BxDolTemplate.php
  19. 3 0
      inc/classes/BxDolTextCalendar.php
  20. 28 0
      inc/classes/BxDolTextConfig.php
  21. 3 5
      inc/classes/BxDolTextCron.php
  22. 8 8
      inc/classes/BxDolTextData.php
  23. 2 1
      inc/classes/BxDolTextDb.php
  24. 239 86
      inc/classes/BxDolTextModule.php
  25. 10 1
      inc/classes/BxDolTextPageMain.php
  26. 8 4
      inc/classes/BxDolTextPageView.php
  27. 10 6
      inc/classes/BxDolTextSearchResult.php
  28. 37 0
      inc/classes/BxDolTextSiteMaps.php
  29. 27 50
      inc/classes/BxDolTextTemplate.php
  30. 0 1
      inc/classes/BxDolTwigFormBroadcast.php
  31. 1 2
      inc/classes/BxDolTwigFormInviter.php
  32. 23 30
      inc/classes/BxDolTwigModule.php
  33. 1 0
      inc/classes/BxDolTwigModuleDb.php
  34. 31 0
      inc/classes/BxDolTwigPageMain.php
  35. 4 0
      inc/classes/BxDolViews.php
  36. 5 6
      inc/classes/BxDolVoting.php
  37. 9 13
      inc/images.inc.php
  38. 41 39
      inc/js/classes/BxDolCmts.js
  39. 38 0
      inc/js/common_anim.js
  40. 11 1
      inc/js/functions.js
  41. 107 25
      inc/utils.inc.php
  42. 4 0
      periodic/cron.php

+ 5 - 13
cmts.php

@@ -10,26 +10,18 @@ require_once(BX_DIRECTORY_PATH_INC . "languages.inc.php");
 require_once(BX_DIRECTORY_PATH_INC . "params.inc.php");
 require_once(BX_DIRECTORY_PATH_INC . "params.inc.php");
 require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
 require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
 
 
+check_logged();
+
 $sSys = isset($_REQUEST['sys']) ? $_REQUEST['sys'] : '';
 $sSys = isset($_REQUEST['sys']) ? $_REQUEST['sys'] : '';
 $sAction = isset($_REQUEST['action']) && preg_match ('/^[A-Za-z_-]+$/', $_REQUEST['action']) ? $_REQUEST['action'] : '';
 $sAction = isset($_REQUEST['action']) && preg_match ('/^[A-Za-z_-]+$/', $_REQUEST['action']) ? $_REQUEST['action'] : '';
 $iId = (int)$_REQUEST['id'];
 $iId = (int)$_REQUEST['id'];
 
 
 bx_import ('BxTemplCmtsView');
 bx_import ('BxTemplCmtsView');
-$aSystems =& BxDolCmts::getSystems ();
-
-if ($sSys && $sAction && $iId && isset($aSystems[$sSys])) {
-
-    $oCmts = null;
-    if ($aSystems[$sSys]['class_name']) {
-        require_once (BX_DIRECTORY_PATH_ROOT . $aSystems[$sSys]['class_file']);
-        $sClassName = $aSystems[$sSys]['class_name'];
-        $oCmts = new $sClassName($sSys, $iId, true);
-    } else {
-        $oCmts = new BxTemplCmtsView($sSys, $iId, true);
-    }
+$aSystems = BxDolCmts::getSystems ();
 
 
+if ($sSys && $sAction && $iId && ($oCmts = BxDolCmts::getObjectInstance($sSys, $iId, true))) {
+    header('Content-Type: text/html; charset=utf-8');
     $sMethod = 'action' . $sAction;
     $sMethod = 'action' . $sAction;
     echo $oCmts->$sMethod();
     echo $oCmts->$sMethod();
-
 }
 }
 
 

+ 1 - 0
inc/classes/BxDolCache.php

@@ -33,5 +33,6 @@ class BxDolCache extends BxDol {
     function setData($sKey, $mixedData, $iTTL = false) {}
     function setData($sKey, $mixedData, $iTTL = false) {}
     function delData($sKey) {}
     function delData($sKey) {}
     function removeAllByPrefix ($s) {}
     function removeAllByPrefix ($s) {}
+    function getSizeByPrefix ($s) {}
 }
 }
 
 

+ 18 - 0
inc/classes/BxDolCacheFile.php

@@ -90,6 +90,24 @@ class BxDolCacheFile extends BxDolCache {
         return true;
         return true;
     }
     }
 
 
+    /**
+     * get size of cached data by name prefix
+     */
+    function getSizeByPrefix ($s) {
+        if (!($rHandler = opendir($this->sPath)))
+            return false;
+
+        $iSize = 0;
+        $l = strlen($s);
+        while (($sFile = readdir($rHandler)) !== false)
+            if (0 == strncmp($sFile, $s, $l))
+                $iSize += @filesize ($this->sPath . $sFile);
+
+        closedir($rHandler);
+
+        return $iSize;
+    }
+
     /**
     /**
      * remove file from dist if TTL expored
      * remove file from dist if TTL expored
      * @param string $sFile - full path to filename
      * @param string $sFile - full path to filename

+ 13 - 0
inc/classes/BxDolCacheFileHtml.php

@@ -35,6 +35,19 @@ class BxDolCacheFileHtml extends BxDolCacheFile {
         return file_get_contents($this->sPath . $sKey);
         return file_get_contents($this->sPath . $sKey);
     }
     }
 
 
+    /**
+     * Get full path to cache file
+     */
+    function getDataFilePath($sKey, $iTTL = false) {
+        if (!file_exists($this->sPath . $sKey))
+            return null;
+
+        if ($iTTL > 0 && $this->_removeFileIfTtlExpired ($this->sPath . $sKey, $iTTL))
+            return null;
+
+        return $this->sPath . $sKey;
+    }
+
     /**
     /**
      * Save all data in cache file.
      * Save all data in cache file.
      *
      *

+ 134 - 0
inc/classes/BxDolCacheUtilities.php

@@ -0,0 +1,134 @@
+<?php
+
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ */
+
+class BxDolCacheUtilities extends BxDolMistake
+{
+    protected $oMemberMenu;
+    protected $oCacheMemberMenu;
+    protected $oCachePb;
+    protected $oCacheDb;
+    protected $oCacheTemplates;
+
+    function __construct ()
+    {
+        parent::BxDolMistake();
+
+        // member menu
+        bx_import('BxDolMemberMenu');
+        $this->oMemberMenu = new BxDolMemberMenu();
+        $this->oCacheMemberMenu = $this->oMemberMenu->getCacheObject();
+
+        // page blocks
+        bx_import('BxDolPageViewAdmin');
+        $oPageViewCacher = new BxDolPageViewCacher ('', '');
+        $this->oCachePb = $oPageViewCacher->getBlocksCacheObject ();
+
+        // DB
+        $this->oCacheDb = $GLOBALS['MySQL']->getDbCacheObject();
+
+        // templates
+        $this->oCacheTemplates = $GLOBALS['oSysTemplate']->getTemplatesCacheObject();
+    }
+
+    function clear($sCache)
+    {
+        return $this->_action($sCache, 'clear');
+    }
+
+    function size($sCache, $isFormatted = false)
+    {
+        $iSize = $this->_action($sCache, 'size');
+        return $isFormatted ? sprintf("%.2f", $iSize / 1024 / 1024) : $iSize;
+    }
+
+    function _action($sCache, $sMode = 'clear')
+    {
+        $sFuncCacheObject = ('clear' == $sMode ? '_clearCacheObject' : '_getSizeCacheObject');
+        $sFuncCacheFile = ('clear' == $sMode ? '_clearCache' : '_getSizeCache');
+
+        switch ($sCache) {
+
+            case 'member_menu':
+                $mixedResult = $this->$sFuncCacheObject ($this->oCacheMemberMenu, $this->oMemberMenu->sMenuMemberKeysCache);
+                break;
+
+            case 'pb':
+                $mixedResult = $this->$sFuncCacheObject ($this->oCacheDb, 'pb_');
+                break;
+
+            case 'users':
+                $mixedResult = $this->$sFuncCacheFile('user', BX_DIRECTORY_PATH_CACHE);
+                break;
+
+            case 'db':
+                $mixedResult = $this->$sFuncCacheObject ($this->oCacheDb, 'db_');
+                break;
+
+            case 'template':
+                $mixedResult = $this->$sFuncCacheObject ($this->oCacheTemplates, $GLOBALS['oSysTemplate']->_sCacheFilePrefix);
+                break;
+
+            case 'css':
+                $mixedResult = $this->$sFuncCacheFile($GLOBALS['oSysTemplate']->_sCssCachePrefix, BX_DIRECTORY_PATH_CACHE_PUBLIC);
+                break;
+
+            case 'js':
+                $mixedResult = $this->$sFuncCacheFile($GLOBALS['oSysTemplate']->_sJsCachePrefix, BX_DIRECTORY_PATH_CACHE_PUBLIC);
+                break;
+        }
+
+        return $mixedResult;
+    }
+
+    function _clearCacheObject($oCache, $sPrefix)
+    {
+        if ('db_' == $sPrefix)
+            $GLOBALS['MySQL']->oParams->clearCache();
+        elseif ($this->oMemberMenu->sMenuMemberKeysCache == $sPrefix)
+            $this->oMemberMenu->deleteMemberMenuCaches();
+
+        if (!$oCache->removeAllByPrefix ($sPrefix))
+            return array('code' => 1, 'message' => _t('_adm_txt_dashboard_cache_clean_failed'));
+        else
+            return array('code' => 0, 'message' => _t('_adm_txt_dashboard_cache_clean_success'));
+    }
+    function _getSizeCacheObject($oCache, $sPrefix)
+    {
+        return $oCache->getSizeByPrefix ($sPrefix);
+    }
+
+    function _clearCache($sPrefix, $sPath)
+    {
+        if (!($rHandler = opendir($sPath)))
+            return array('code' => 1, 'message' => _t('_adm_txt_dashboard_cache_clean_failed'));
+
+        $l = strlen($sPrefix);
+        while (($sFile = readdir($rHandler)) !== false)
+            if (0 == strncmp($sFile, $sPrefix, $l))
+                @unlink($sPath . $sFile);
+
+        closedir($rHandler);
+
+        return array('code' => 0, 'message' => _t('_adm_txt_dashboard_cache_clean_success'));
+    }
+    function _getSizeCache($sPrefix, $sPath)
+    {
+        if (!($rHandler = opendir($sPath)))
+            return 0;
+
+        $iSize = 0;
+        $l = strlen($sPrefix);
+        while (($sFile = readdir($rHandler)) !== false)
+            if (0 == strncmp($sFile, $sPrefix, $l))
+                $iSize += filesize($sPath . $sFile);
+
+        closedir($rHandler);
+
+        return $iSize;
+    }
+
+}

+ 20 - 10
inc/classes/BxDolCalendar.php

@@ -88,17 +88,21 @@ class BxDolCalendar extends BxDol {
             $this->iFirstWeekDay = $this->iWeekEnd-1;
             $this->iFirstWeekDay = $this->iWeekEnd-1;
     }
     }
 
 
-    function _getWeekNames () {
+    function _getWeekNames ($isMiniMode = false)
+    {
+        $sPostfix = '';
+        if ($isMiniMode)
+            $sPostfix = '_mini';
         if(0 == $this->iWeekStart)
         if(0 == $this->iWeekStart)
-            $aWeek[] = array('name' => _t('_week_sun'));
-        $aWeek[] = array('name' => _t('_week_mon'));
-        $aWeek[] = array('name' => _t('_week_tue'));
-        $aWeek[] = array('name' => _t('_week_wed'));
-        $aWeek[] = array('name' => _t('_week_thu'));
-        $aWeek[] = array('name' => _t('_week_fri'));
-        $aWeek[] = array('name' => _t('_week_sat'));
+            $aWeek[] = array('name' => _t('_week_sun' . $sPostfix));
+        $aWeek[] = array('name' => _t('_week_mon' . $sPostfix));
+        $aWeek[] = array('name' => _t('_week_tue' . $sPostfix));
+        $aWeek[] = array('name' => _t('_week_wed' . $sPostfix));
+        $aWeek[] = array('name' => _t('_week_thu' . $sPostfix));
+        $aWeek[] = array('name' => _t('_week_fri' . $sPostfix));
+        $aWeek[] = array('name' => _t('_week_sat' . $sPostfix));
         if(8 == $this->iWeekEnd)
         if(8 == $this->iWeekEnd)
-            $aWeek[] = array('name' => _t('_week_sun'));
+            $aWeek[] = array('name' => _t('_week_sun' . $sPostfix));
         return $aWeek;
         return $aWeek;
     }
     }
 
 
@@ -251,5 +255,11 @@ class BxDolCalendar extends BxDol {
         // override this func
         // override this func
         return array(_t('_item'), _t('_items'));
         return array(_t('_item'), _t('_items'));
     }
     }
-}
 
 
+    /**
+     * return url for previous/next month
+     */
+    function getMonthUrl ($isNextMoths, $isMiniMode = false) {
+        return $this->getBaseUri () . ($isNextMoths ? "{$this->iNextYear}/{$this->iNextMonth}" : "{$this->iPrevYear}/{$this->iPrevMonth}");
+    }
+}

+ 7 - 1
inc/classes/BxDolCaptcha.php

@@ -117,13 +117,19 @@ class BxDolCaptcha extends BxDol {
         // override this function in particular class
         // override this function in particular class
     }
     }
 
 
+    /**
+     * Return text entered by user
+     */
+    public function getUserResponse () {
+        // override this function in particular class
+    }
+
     /**
     /**
      * Check if captcha is available, like all API keys are specified.
      * Check if captcha is available, like all API keys are specified.
      */
      */
     public function isAvailable () {
     public function isAvailable () {
         // override this function in particular class
         // override this function in particular class
     }
     }
-
 }
 }
 
 
 /** @} */
 /** @} */

+ 57 - 47
inc/classes/BxDolCmts.php

@@ -200,20 +200,24 @@ class BxDolCmts extends BxDol
     /**
     /**
      * check if user can post/edit or delete own comments
      * check if user can post/edit or delete own comments
      */
      */
-    function checkAction ($iAction)
-    {
+    function checkAction ($iAction, $isPerformAction = false) {
         $iId = $this->_getAuthorId();
         $iId = $this->_getAuthorId();
-        $check_res = checkAction( $iId, $iAction );
+        $check_res = checkAction($iId, $iAction, $isPerformAction);
         return $check_res[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED;
         return $check_res[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED;
     }
     }
 
 
+    function checkActionErrorMsg ($iAction) {
+        $iId = $this->_getAuthorId();
+        $check_res = checkAction($iId, $iAction);
+        return $check_res[CHECK_ACTION_RESULT] != CHECK_ACTION_RESULT_ALLOWED ? $check_res[CHECK_ACTION_MESSAGE] : '';
+    }
 
 
     function getId () {
     function getId () {
         return $this->_iId;
         return $this->_iId;
     }
     }
 
 
     function isEnabled () {
     function isEnabled () {
-        return $this->_aSystem['is_on'];
+        return isset($this->_aSystem['is_on']) && $this->_aSystem['is_on'];
     }
     }
 
 
     function getSystemName() {
     function getSystemName() {
@@ -351,63 +355,59 @@ class BxDolCmts extends BxDol
 
 
     *********************************************/
     *********************************************/
 
 
-
-
-    /**
-     * is rate comment allowed
-     */
-    function isRateAllowed ()
-    {
-        return $this->checkAction (ACTION_ID_COMMENTS_VOTE);
+    // is rate comment allowed
+    function isRateAllowed ($isPerformAction = false) {
+        return $this->checkAction (ACTION_ID_COMMENTS_VOTE, $isPerformAction); 
     }
     }
 
 
-
+    function msgErrRateAllowed () { 
+        return $this->checkActionErrorMsg(ACTION_ID_COMMENTS_VOTE);
+    }
 
 
     /**
     /**
      * is post comment allowed
      * is post comment allowed
      */
      */
-    function isPostReplyAllowed ()
-    {
-        return $this->checkAction (ACTION_ID_COMMENTS_POST);
+    function isPostReplyAllowed ($isPerformAction = false) {
+        return $this->checkAction (ACTION_ID_COMMENTS_POST, $isPerformAction);
     }
     }
 
 
-
+    function msgErrPostReplyAllowed () {
+        return $this->checkActionErrorMsg(ACTION_ID_COMMENTS_POST);
+    }
 
 
     /**
     /**
      * is edit own comment allowed
      * is edit own comment allowed
      */
      */
-    function isEditAllowed ()
-    {
-        return $this->checkAction (ACTION_ID_COMMENTS_EDIT_OWN);
+    function isEditAllowed ($isPerformAction = false) {
+        return $this->checkAction (ACTION_ID_COMMENTS_EDIT_OWN, $isPerformAction);
     }
     }
 
 
-
+    function msgErrEditAllowed () {
+        return $this->checkActionErrorMsg (ACTION_ID_COMMENTS_EDIT_OWN);
+    }
 
 
     /**
     /**
      * is removing own comment allowed
      * is removing own comment allowed
      */
      */
-    function isRemoveAllowed ()
-    {
-        return $this->checkAction (ACTION_ID_COMMENTS_REMOVE_OWN);
+    function isRemoveAllowed ($isPerformAction = false) {
+        return $this->checkAction (ACTION_ID_COMMENTS_REMOVE_OWN, $isPerformAction);
     }
     }
 
 
-
+    function msgErrRemoveAllowed () {
+        return $this->checkActionErrorMsg(ACTION_ID_COMMENTS_REMOVE_OWN);
+    }
 
 
     /**
     /**
      * is edit any comment allowed
      * is edit any comment allowed
      */
      */
-    function isEditAllowedAll ()
-    {
+    function isEditAllowedAll () {
         return isAdmin() ? true : false;
         return isAdmin() ? true : false;
     }
     }
 
 
-
-
     /**
     /**
      * is removing any comment allowed
      * is removing any comment allowed
      */
      */
-    function isRemoveAllowedAll ()
-    {
+    function isRemoveAllowedAll () {
         return isAdmin() ? true : false;
         return isAdmin() ? true : false;
     }
     }
 
 
@@ -475,12 +475,14 @@ class BxDolCmts extends BxDol
         if(false === $iCmtNewId)
         if(false === $iCmtNewId)
             return '';
             return '';
 
 
+        $this->_triggerComment();
+
+        $this->isPostReplyAllowed(true);
+
         bx_import('BxDolAlerts');
         bx_import('BxDolAlerts');
-        $oZ = new BxDolAlerts($this->_sSystem, 'commentPost', $this->getId(), $this->_getAuthorId(), array('comment_id' => $iCmtNewId));
+        $oZ = new BxDolAlerts($this->_sSystem, 'commentPost', $this->getId(), $this->_getAuthorId(), array('comment_id' => $iCmtNewId, 'comment_author_id' => $iCmtAuthorId));
         $oZ->alert();
         $oZ->alert();
 
 
-        $this->_triggerComment();
-
         return $iCmtNewId;
         return $iCmtNewId;
     }
     }
 
 
@@ -504,17 +506,20 @@ class BxDolCmts extends BxDol
 
 
         $isRemoveAllowed = $this->isRemoveAllowedAll() || ($aCmt['cmt_author_id'] == $this->_getAuthorId() && $this->isRemoveAllowed());
         $isRemoveAllowed = $this->isRemoveAllowedAll() || ($aCmt['cmt_author_id'] == $this->_getAuthorId() && $this->isRemoveAllowed());
         if (!$isRemoveAllowed && $aCmt['cmt_secs_ago'] > ($this->getAllowedEditTime()+20))
         if (!$isRemoveAllowed && $aCmt['cmt_secs_ago'] > ($this->getAllowedEditTime()+20))
-            return _t('_Access denied');
+            return $aCmt['cmt_author_id'] == $this->_getAuthorId() && !$this->isRemoveAllowed() ? strip_tags($this->msgErrRemoveAllowed()) : _t('_Access denied');
 
 
         if (!$this->_oQuery->removeComment ($this->getId(), $aCmt['cmt_id'], $aCmt['cmt_parent_id']))
         if (!$this->_oQuery->removeComment ($this->getId(), $aCmt['cmt_id'], $aCmt['cmt_parent_id']))
             return _t('_Database Error');
             return _t('_Database Error');
 
 
+        $this->_triggerComment();
+
+        if ($aCmt['cmt_author_id'] == $this->_getAuthorId())
+           $this->isRemoveAllowed(true);
+
         bx_import('BxDolAlerts');
         bx_import('BxDolAlerts');
-        $oZ = new BxDolAlerts($this->_sSystem, 'commentRemoved', $this->getId(), $this->_getAuthorId(), array('comment_id' => $aCmt['cmt_id']));
+        $oZ = new BxDolAlerts($this->_sSystem, 'commentRemoved', $this->getId(), $this->_getAuthorId(), array('comment_id' => $aCmt['cmt_id'], 'comment_author_id' => $aCmt['cmt_author_id']));
         $oZ->alert();
         $oZ->alert();
 
 
-        $this->_triggerComment();
-
         return '';
         return '';
     }
     }
 
 
@@ -535,7 +540,7 @@ class BxDolCmts extends BxDol
 
 
         $isEditAllowed = $this->isEditAllowedAll() || ($aCmt['cmt_author_id'] == $this->_getAuthorId() && $this->isEditAllowed());
         $isEditAllowed = $this->isEditAllowedAll() || ($aCmt['cmt_author_id'] == $this->_getAuthorId() && $this->isEditAllowed());
         if (!$isEditAllowed && $aCmt['cmt_secs_ago'] > ($this->getAllowedEditTime()+20))
         if (!$isEditAllowed && $aCmt['cmt_secs_ago'] > ($this->getAllowedEditTime()+20))
-            return 'err'._t('_Access denied');
+            return 'err' . ($aCmt['cmt_author_id'] == $this->_getAuthorId() && !$this->isEditAllowed() ? strip_tags($this->msgErrEditAllowed()) : _t('_Access denied'));
 
 
         return $this->_getFormBox (0, $this->_prepareTextForEdit($aCmt['cmt_text']), 'updateComment(this, \''.$iCmtId.'\')');
         return $this->_getFormBox (0, $this->_prepareTextForEdit($aCmt['cmt_text']), 'updateComment(this, \''.$iCmtId.'\')');
     }
     }
@@ -566,17 +571,18 @@ class BxDolCmts extends BxDol
         if (!$isEditAllowed && $aCmt['cmt_secs_ago'] > ($this->getAllowedEditTime()+20))
         if (!$isEditAllowed && $aCmt['cmt_secs_ago'] > ($this->getAllowedEditTime()+20))
             return '{}';
             return '{}';
 
 
-        if($sTextRet != $aCmt['cmt_text'] || $iCmtMood != $aCmt['cmt_mood']) {
-            if ($this->_oQuery->updateComment ($this->getId(), $aCmt['cmt_id'], $sText, $iCmtMood)) {
-                bx_import('BxDolAlerts');
-                $oZ = new BxDolAlerts($this->_sSystem, 'commentUpdated', $this->getId(), $this->_getAuthorId(), array('comment_id' => $aCmt['cmt_id']));
-                $oZ->alert();
-            }
+        if (($sTextRet != $aCmt['cmt_text'] || $iCmtMood != $aCmt['cmt_mood']) && $this->_oQuery->updateComment ($this->getId(), $aCmt['cmt_id'], $sText, $iCmtMood)) {
+            if ($aCmt['cmt_author_id'] == $this->_getAuthorId())
+               $this->isEditAllowed(true);
+
+            bx_import('BxDolAlerts');
+            $oZ = new BxDolAlerts($this->_sSystem, 'commentUpdated', $this->getId(), $this->_getAuthorId(), array('comment_id' => $aCmt['cmt_id'], 'comment_author_id' => $aCmt['cmt_author_id']));
+            $oZ->alert();
         }
         }
 
 
         $aCmt = $this->_oQuery->getCommentSimple ($this->getId(), $iCmtId);
         $aCmt = $this->_oQuery->getCommentSimple ($this->getId(), $iCmtId);
 
 
-        return $oJson->encode(array('text' => $aCmt['cmt_text'], 'mood' => $aCmt['cmt_mood'], _t($this->_aMoodText[$aCmt['cmt_mood']])));
+        return $oJson->encode(array('text' => $aCmt['cmt_text'], 'mood' => $aCmt['cmt_mood'], 'mood_text' => _t($this->_aMoodText[$aCmt['cmt_mood']])));
     }
     }
 
 
     function actionCmtRate () {
     function actionCmtRate () {
@@ -597,8 +603,12 @@ class BxDolCmts extends BxDol
         if(!$this->_oQuery->rateComment($this->getSystemId(), $iCmtId, $iRate, $this->_getAuthorId(), $this->_getAuthorIp()))
         if(!$this->_oQuery->rateComment($this->getSystemId(), $iCmtId, $iRate, $this->_getAuthorId(), $this->_getAuthorIp()))
             return _t('_Duplicate vote');
             return _t('_Duplicate vote');
 
 
+        $aCmt = $this->_oQuery->getCommentSimple ($this->getId(), $iCmtId);
+
+        $this->isRateAllowed(true);
+
         bx_import('BxDolAlerts');
         bx_import('BxDolAlerts');
-        $oZ = new BxDolAlerts($this->_sSystem, 'commentRated', $this->getId(), $this->_getAuthorId(), array('comment_id' => $iCmtId, 'rate' => $iRate));
+        $oZ = new BxDolAlerts($this->_sSystem, 'commentRated', $this->getId(), $this->_getAuthorId(), array('comment_id' => $iCmtId, 'comment_author_id' => $aCmt['cmt_author_id'], 'rate' => $iRate));
         $oZ->alert();
         $oZ->alert();
 
 
         return '';
         return '';

+ 10 - 7
inc/classes/BxDolCmtsQuery.php

@@ -33,7 +33,7 @@ class BxDolCmtsQuery extends BxDolDb
     function getComments ($iId, $iCmtParentId = 0, $iAuthorId = 0, $sCmtOrder = 'ASC', $iStart = 0, $iCount = -1)
     function getComments ($iId, $iCmtParentId = 0, $iAuthorId = 0, $sCmtOrder = 'ASC', $iStart = 0, $iCount = -1)
     {
     {
         global $sHomeUrl;
         global $sHomeUrl;
-
+        $iTimestamp = time();
         $sFields = "'' AS `cmt_rated`,";
         $sFields = "'' AS `cmt_rated`,";
         $sJoin = '';
         $sJoin = '';
         if ($iAuthorId) {
         if ($iAuthorId) {
@@ -51,7 +51,7 @@ class BxDolCmtsQuery extends BxDolDb
                 `c`.`cmt_rate`,
                 `c`.`cmt_rate`,
                 `c`.`cmt_rate_count`,
                 `c`.`cmt_rate_count`,
                 `c`.`cmt_replies`,
                 `c`.`cmt_replies`,
-                (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`c`.`cmt_time`)) AS `cmt_secs_ago`,
+                ($iTimestamp - UNIX_TIMESTAMP(`c`.`cmt_time`)) AS `cmt_secs_ago`,
                 `p`.`id` AS `cmt_author_name`
                 `p`.`id` AS `cmt_author_name`
             FROM {$this->_sTable} AS `c`
             FROM {$this->_sTable} AS `c`
             LEFT JOIN `sys_profiles` AS `p` ON (`p`.`id` = `c`.`cmt_author_id`)
             LEFT JOIN `sys_profiles` AS `p` ON (`p`.`id` = `c`.`cmt_author_id`)
@@ -73,6 +73,7 @@ class BxDolCmtsQuery extends BxDolDb
     {
     {
         global $sHomeUrl;
         global $sHomeUrl;
 
 
+        $iTimestamp = time();
         $sFields = "'' AS `cmt_rated`,";
         $sFields = "'' AS `cmt_rated`,";
         $sJoin = '';
         $sJoin = '';
         if ($iAuthorId) {
         if ($iAuthorId) {
@@ -90,7 +91,7 @@ class BxDolCmtsQuery extends BxDolDb
                 `c`.`cmt_rate`,
                 `c`.`cmt_rate`,
                 `c`.`cmt_rate_count`,
                 `c`.`cmt_rate_count`,
                 `c`.`cmt_replies`,
                 `c`.`cmt_replies`,
-                (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`c`.`cmt_time`)) AS `cmt_secs_ago`,
+                ($iTimestamp - UNIX_TIMESTAMP(`c`.`cmt_time`)) AS `cmt_secs_ago`,
                 `p`.`NickName` AS `cmt_author_name`
                 `p`.`NickName` AS `cmt_author_name`
             FROM {$this->_sTable} AS `c`
             FROM {$this->_sTable} AS `c`
             LEFT JOIN `Profiles` AS `p` ON (`p`.`ID` = `c`.`cmt_author_id`)
             LEFT JOIN `Profiles` AS `p` ON (`p`.`ID` = `c`.`cmt_author_id`)
@@ -107,9 +108,10 @@ class BxDolCmtsQuery extends BxDolDb
 
 
     function getCommentSimple ($iId, $iCmtId)
     function getCommentSimple ($iId, $iCmtId)
     {
     {
+        $iTimestamp = time();
         $sQuery = $this->prepare("
         $sQuery = $this->prepare("
             SELECT
             SELECT
-                *, (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`c`.`cmt_time`)) AS `cmt_secs_ago`
+                *, ($iTimestamp - UNIX_TIMESTAMP(`c`.`cmt_time`)) AS `cmt_secs_ago`
             FROM {$this->_sTable} AS `c`
             FROM {$this->_sTable} AS `c`
             WHERE `cmt_object_id` = ? AND `cmt_id` = ?
             WHERE `cmt_object_id` = ? AND `cmt_id` = ?
             LIMIT 1", $iId, $iCmtId);
             LIMIT 1", $iId, $iCmtId);
@@ -160,13 +162,14 @@ class BxDolCmtsQuery extends BxDolDb
 
 
     function rateComment ($iSystemId, $iCmtId, $iRate, $iAuthorId, $sAuthorIp)
     function rateComment ($iSystemId, $iCmtId, $iRate, $iAuthorId, $sAuthorIp)
     {
     {
+        $iTimestamp = time();
         $sQuery = $this->prepare("INSERT IGNORE INTO {$this->_sTableTrack} SET
         $sQuery = $this->prepare("INSERT IGNORE INTO {$this->_sTableTrack} SET
             `cmt_system_id` = ?,
             `cmt_system_id` = ?,
             `cmt_id` = ?,
             `cmt_id` = ?,
             `cmt_rate` = ?,
             `cmt_rate` = ?,
             `cmt_rate_author_id` = ?,
             `cmt_rate_author_id` = ?,
             `cmt_rate_author_nip` = INET_ATON(?),
             `cmt_rate_author_nip` = INET_ATON(?),
-            `cmt_rate_ts` = UNIX_TIMESTAMP()", $iSystemId, $iCmtId, $iRate, $iAuthorId, $sAuthorIp);
+            `cmt_rate_ts` = ?", $iSystemId, $iCmtId, $iRate, $iAuthorId, $sAuthorIp, $iTimestamp);
         if ($this->query($sQuery))
         if ($this->query($sQuery))
         {
         {
             $sQuery = $this->prepare("UPDATE {$this->_sTable} SET `cmt_rate` = `cmt_rate` + ?, `cmt_rate_count` = `cmt_rate_count` + 1 WHERE `cmt_id` = ? LIMIT 1", $iRate, $iCmtId);
             $sQuery = $this->prepare("UPDATE {$this->_sTable} SET `cmt_rate` = `cmt_rate` + ?, `cmt_rate_count` = `cmt_rate_count` + 1 WHERE `cmt_id` = ? LIMIT 1", $iRate, $iCmtId);
@@ -219,11 +222,11 @@ class BxDolCmtsQuery extends BxDolDb
     }
     }
 
 
     function maintenance() {
     function maintenance() {
-        $iDeletedRecords = $this->query("DELETE FROM {$this->_sTableTrack} WHERE `cmt_rate_ts` < (UNIX_TIMESTAMP() - " . (int)BX_OLD_CMT_VOTES . ")");
+        $iTimestamp = time();
+        $iDeletedRecords = $this->query("DELETE FROM {$this->_sTableTrack} WHERE `cmt_rate_ts` < ($iTimestamp - " . (int)BX_OLD_CMT_VOTES . ")");
         if ($iDeletedRecords)
         if ($iDeletedRecords)
             $this->query("OPTIMIZE TABLE {$this->_sTableTrack}");
             $this->query("OPTIMIZE TABLE {$this->_sTableTrack}");
         return $iDeletedRecords;
         return $iDeletedRecords;
     }
     }
-
 }
 }
 
 

+ 31 - 34
inc/classes/BxDolCronCmd.php

@@ -38,6 +38,11 @@ class BxDolCronCmd extends BxDolCron {
         $db_clean_msg = (int) getParam("db_clean_msg");
         $db_clean_msg = (int) getParam("db_clean_msg");
         $db_clean_visits = (int) getParam("db_clean_members_visits");
         $db_clean_visits = (int) getParam("db_clean_members_visits");
         $db_clean_banners_info = (int) getParam("db_clean_banners_info");
         $db_clean_banners_info = (int) getParam("db_clean_banners_info");
+        $db_clean_mem_levels = (int) getParam("db_clean_mem_levels");
+
+        //clear from `sys_acl_levels_members`
+        if (db_res("DELETE FROM `sys_acl_levels_members` WHERE `DateExpires` < NOW() - INTERVAL $db_clean_mem_levels DAY"))
+            db_res("OPTIMIZE TABLE `sys_acl_levels_members`");
 
 
         //clear from `sys_banners_shows`
         //clear from `sys_banners_shows`
         if (db_res("DELETE FROM `sys_banners_shows` WHERE `Date` < UNIX_TIMESTAMP( NOW() - INTERVAL $db_clean_banners_info DAY )"))
         if (db_res("DELETE FROM `sys_banners_shows` WHERE `Date` < UNIX_TIMESTAMP( NOW() - INTERVAL $db_clean_banners_info DAY )"))
@@ -222,62 +227,54 @@ class BxDolCronCmd extends BxDolCron {
 
 
         setParam( "cmdDay", $day );
         setParam( "cmdDay", $day );
 
 
-
         //========================================================================================================================
         //========================================================================================================================
 
 
         // - Membership check -
         // - Membership check -
         echo "\n- Membership expiration letters -\n";
         echo "\n- Membership expiration letters -\n";
 
 
-        $expire_notification_days = getParam("expire_notification_days");
-        $expire_notify_once = getParam("expire_notify_once");
+        $iExpireNotificationDays = (int)getParam("expire_notification_days");
+        $bExpireNotifyOnce = getParam("expire_notify_once") == 'on';
 
 
-        $expire_letters = 0;
+        $iExpireLetters = 0;
 
 
-        $exp_res = db_res( "SELECT `ID` FROM `Profiles`", 0 );
+        bx_import('BxDolDb');
+        $oDb = BxDolAcl::getInstance();
 
 
         bx_import('BxDolAcl');
         bx_import('BxDolAcl');
         $oAcl = BxDolAcl::getInstance();
         $oAcl = BxDolAcl::getInstance();
 
 
-        while( $row = mysql_fetch_array( $exp_res ) )
-        {
-            $current_membership_arr = getMemberMembershipInfo( $row['ID'] );
+        $aRow = $oDb->getFirstRow( "SELECT `ID` FROM `Profiles`");
+        while(!empty($aRow)) {
+            $aCurrentMem = getMemberMembershipInfo( $aRow['ID'] );
             // If expire_notification_days is -1 then notify after expiration
             // If expire_notification_days is -1 then notify after expiration
-            if ( $current_membership_arr['ID'] == MEMBERSHIP_ID_STANDARD && $expire_notification_days == -1 )
-            {
+            if ( $aCurrentMem['ID'] == MEMBERSHIP_ID_STANDARD && $iExpireNotificationDays == -1 ) {
                 // Calculate last UNIX Timestamp
                 // Calculate last UNIX Timestamp
-                $last_timestamp = time() - 24 * 3600;
-                $last_membership_arr = getMemberMembershipInfo( $row['ID'], $last_timestamp );
-                if ( $current_membership_arr['ID'] != $last_membership_arr['ID'] )
-                {
-                    if ($further_membership_arr['ID'] == MEMBERSHIP_ID_STANDARD)
-                    {
-                        $mail_ret = $oAcl->getExpirationLetter($row['ID'], $last_membership_arr['Name'], -1);
-                        if ( $mail_ret )
-                            $expire_letters++;
-                    }
+                $iLastTimestamp = time() - 24 * 3600;
+                $aLastMem = getMemberMembershipInfo( $aRow['ID'], $iLastTimestamp );
+                if($aCurrentMem['ID'] != $aLastMem['ID']) {
+                    $bMailResult = $oAcl->getExpirationLetter($aRow['ID'], $aLastMem['Name'], -1);
+                    if($bMailResult)
+                        $iExpireLetters++;
                 }
                 }
             }
             }
             // If memberhip is not standard then check if it will change
             // If memberhip is not standard then check if it will change
-            elseif ( $current_membership_arr['ID'] != MEMBERSHIP_ID_STANDARD )
-            {
+            else if($aCurrentMem['ID'] != MEMBERSHIP_ID_STANDARD) {
                 // Calculate further UNIX Timestamp
                 // Calculate further UNIX Timestamp
-                $further_timestamp = time() + $expire_notification_days * 24 * 3600;
-                $further_membership_arr = getMemberMembershipInfo( $row['ID'], $further_timestamp );
-                if ( $current_membership_arr['ID'] != $further_membership_arr['ID']
-                    && $further_membership_arr['ID'] == MEMBERSHIP_ID_STANDARD )
-                {
-                    if ( !$expire_notify_once || abs($further_timestamp - $current_membership_arr['DateExpires']) < 24 * 3600 )
-                    {
-                        $mail_ret = $oAcl->getExpirationLetter( $row['ID'], $current_membership_arr['Name'],
-                            (int)( ($current_membership_arr['DateExpires'] - time()) / (24 * 3600) ) );
-                        if ( $mail_ret )
-                            $expire_letters++;
+                $iFurtherTimestamp = time() + $iExpireNotificationDays * 24 * 3600;
+                $aFurtherMem = getMemberMembershipInfo( $aRow['ID'], $iFurtherTimestamp );
+                if($aCurrentMem['ID'] != $aFurtherMem['ID'] && $aFurtherMem['ID'] == MEMBERSHIP_ID_STANDARD) {
+                    if(!$bExpireNotifyOnce || abs($iFurtherTimestamp - $aCurrentMem['DateExpires']) < 24 * 3600) {
+                        $bMailResult = $oAcl->getExpirationLetter( $aRow['ID'], $aCurrentMem['Name'], (int)(($aCurrentMem['DateExpires'] - time())/(24 * 3600)));
+                        if($bMailResult)
+                            $iExpireLetters++;
                     }
                     }
                 }
                 }
             }
             }
+
+            $aRow = $oDb->getNextRow();
         }
         }
 
 
-        echo "Send membership expire letters: $expire_letters letters\n";
+        echo "Send membership expire letters: $iExpireLetters letters\n";
 
 
         //========================================================================================================================
         //========================================================================================================================
 
 

+ 7 - 0
inc/classes/BxDolEditor.php

@@ -114,6 +114,13 @@ class BxDolEditor extends BxDol {
         return ($GLOBALS['bxDolClasses']['BxDolEditor!'.$sObject] = $o);
         return ($GLOBALS['bxDolClasses']['BxDolEditor!'.$sObject] = $o);
     }
     }
 
 
+    /**
+     * Get minimal width which is neede for editor for the provided view mode
+     */
+    public function getWidth ($iViewMode) {
+        // override this function in particular editor class
+    }
+
     /**
     /**
      * Attach editor to HTML element, in most cases - textarea.
      * Attach editor to HTML element, in most cases - textarea.
      * @param $sSelector - jQuery selector to attach editor to.
      * @param $sSelector - jQuery selector to attach editor to.

+ 88 - 22
inc/classes/BxDolFtp.php

@@ -12,6 +12,7 @@ class BxDolFtp extends BxDolFile {
     var $_sHost;
     var $_sHost;
     var $_sLogin;
     var $_sLogin;
     var $_sPassword;
     var $_sPassword;
+    var $_sPathTo;
     var $_rStream;
     var $_rStream;
 
 
     function BxDolFtp($sHost, $sLogin, $sPassword, $sPath = '/') {
     function BxDolFtp($sHost, $sLogin, $sPassword, $sPath = '/') {
@@ -19,62 +20,127 @@ class BxDolFtp extends BxDolFile {
         $this->_sHost = $sHost;
         $this->_sHost = $sHost;
         $this->_sLogin = $sLogin;
         $this->_sLogin = $sLogin;
         $this->_sPassword = $sPassword;
         $this->_sPassword = $sPassword;
-        $this->_sPathTo = $sPath;
+        $this->_sPathTo = $sPath . ('/' == substr($sPath, -1) ? '' : '/');
     }
     }
     function connect() {
     function connect() {
         $this->_rStream = ftp_connect($this->_sHost);
         $this->_rStream = ftp_connect($this->_sHost);
         return ftp_login($this->_rStream, $this->_sLogin, $this->_sPassword);
         return ftp_login($this->_rStream, $this->_sLogin, $this->_sPassword);
     }
     }
+    function isDolphin() {
+        return @ftp_size($this->_rStream, $this->_sPath . 'inc/header.inc.php') > 0;
+    }
+    function copy($sFilePathFrom, $sFilePathTo) {
+        $sFilePathTo = $this->_sPath . $sFilePathTo;
+        return $this->_copyFile($sFilePathFrom, $sFilePathTo);
+    }
+    function delete($sPath) {
+        $sPath = $this->_sPath . $sPath;
+        return $this->_deleteDirectory($sPath);
+    }
+
     protected function _copyFile($sFilePathFrom, $sFilePathTo) {
     protected function _copyFile($sFilePathFrom, $sFilePathTo) {
         if(substr($sFilePathFrom, -1) == '*')
         if(substr($sFilePathFrom, -1) == '*')
             $sFilePathFrom = substr($sFilePathFrom, 0, -1);
             $sFilePathFrom = substr($sFilePathFrom, 0, -1);
-
-        $bResult = true;
+        $bResult = false;
         if(is_file($sFilePathFrom)) {
         if(is_file($sFilePathFrom)) {
             if($this->_isFile($sFilePathTo)) {
             if($this->_isFile($sFilePathTo)) {
                 $aFileParts = $this->_parseFile($sFilePathTo);
                 $aFileParts = $this->_parseFile($sFilePathTo);
-                if(isset($aFileParts[0]))
-                    @ftp_mkdir($this->_rStream, $aFileParts[0]);
-
+                if (isset($aFileParts[0])) {
+                    $bRet = $this->_ftpMkDirR($aFileParts[0]);
+                }
                 $bResult = @ftp_put($this->_rStream, $sFilePathTo, $sFilePathFrom, FTP_BINARY);
                 $bResult = @ftp_put($this->_rStream, $sFilePathTo, $sFilePathFrom, FTP_BINARY);
-            }
-            else if($this->_isDirectory($sFilePathTo)) {
-                @ftp_mkdir($this->_rStream, $sFilePathTo);
-
+            } else if($this->_isDirectory($sFilePathTo)) {
+                $bRet = $this->_ftpMkDirR($sFilePathTo);
                 $aFileParts = $this->_parseFile($sFilePathFrom);
                 $aFileParts = $this->_parseFile($sFilePathFrom);
-                if(isset($aFileParts[1]))
+                if (isset($aFileParts[1])) {
                     $bResult = @ftp_put($this->_rStream, $this->_validatePath($sFilePathTo) . $aFileParts[1], $sFilePathFrom, FTP_BINARY);
                     $bResult = @ftp_put($this->_rStream, $this->_validatePath($sFilePathTo) . $aFileParts[1], $sFilePathFrom, FTP_BINARY);
+                }
             }
             }
-        }
-        else if(is_dir($sFilePathFrom) && $this->_isDirectory($sFilePathTo)) {
-            @ftp_mkdir($this->_rStream, $sFilePathTo);
-
+        } else if(is_dir($sFilePathFrom) && $this->_isDirectory($sFilePathTo)) {
+            $bRet = $this->_ftpMkDirR($sFilePathTo);
             $aInnerFiles = $this->_readDirectory($sFilePathFrom);
             $aInnerFiles = $this->_readDirectory($sFilePathFrom);
             foreach($aInnerFiles as $sFile)
             foreach($aInnerFiles as $sFile)
                 $bResult = $this->_copyFile($this->_validatePath($sFilePathFrom) . $sFile, $this->_validatePath($sFilePathTo) . $sFile);
                 $bResult = $this->_copyFile($this->_validatePath($sFilePathFrom) . $sFile, $this->_validatePath($sFilePathTo) . $sFile);
-        }
-        else
+        } else {
             $bResult = false;
             $bResult = false;
+        }
 
 
         return $bResult;
         return $bResult;
     }
     }
+
+    protected function _readDirectory($sFilePath) {
+        if(!is_dir($sFilePath) || !($rSource = opendir($sFilePath))) return false;
+
+        $aResult = array();
+        while(($sFile = readdir($rSource)) !== false) {
+            if($sFile == '.' || $sFile =='..' || $sFile[0] == '.') continue;
+            $aResult[] = $sFile;
+        }
+        closedir($rSource);
+
+        return $aResult;
+    }
+
     protected function _deleteDirectory($sPath) {
     protected function _deleteDirectory($sPath) {
         if($this->_isDirectory($sPath)) {
         if($this->_isDirectory($sPath)) {
             if(substr($sPath, -1) != '/')
             if(substr($sPath, -1) != '/')
                 $sPath .= '/';
                 $sPath .= '/';
 
 
-            if(($aFiles = @ftp_nlist($this->_rStream, $sPath)) !== false) {
+            if (($aFiles = @ftp_nlist($this->_rStream, $sPath)) !== false)
                 foreach($aFiles as $sFile)
                 foreach($aFiles as $sFile)
                     if($sFile != '.' && $sFile != '..')
                     if($sFile != '.' && $sFile != '..')
-                        $this->_deleteDirectory($sPath . $sFile);
+                        $this->_deleteDirectory(false === strpos($sFile, '/') ? $sPath . $sFile : $sFile);
 
 
                 if(!@ftp_rmdir($this->_rStream, $sPath))
                 if(!@ftp_rmdir($this->_rStream, $sPath))
                     return false;
                     return false;
-            }
-        }
-        else if(!@ftp_delete($this->_rStream, $sPath))
+
+        } else if(!@ftp_delete($this->_rStream, $sPath)) {
             return false;
             return false;
+        }
+        return true;
+    }
+    protected function _validatePath($sPath) {
+        if($sPath && substr($sPath, -1) != '/' && $this->_isDirectory($sPath))
+            $sPath .= '/';
 
 
+        return $sPath;
+    }
+    protected function _parseFile($sFilePath) {
+        $aParts = array();
+        preg_match("/^([a-zA-Z0-9@~_\.\\\\\/:-]+[\\\\\/])([a-zA-Z0-9~_-]+\.[a-zA-Z]{2,8})$/", $sFilePath, $aParts) ? true : false;
+        return count($aParts) > 1 ? array_slice($aParts, 1) : false;
+    }
+    protected function _isFile($sFilePath) {
+        return preg_match("/^([a-zA-Z0-9@~_\.\\\\\/:-]+)\.([a-zA-Z]){2,8}$/", $sFilePath) ? true : false;
+    }
+    protected function _isDirectory($sFilePath) {
+        return preg_match("/^([a-zA-Z0-9@~_\.\\\\\/:-]+)[\\\\\/]([a-zA-Z0-9~_-]+)[\\\\\/]?$/", $sFilePath) ? true : false;
+    }
+    protected function _ftpMkDirR($sPath) {
+        $sPwd = ftp_pwd ($this->_rStream);
+        $aParts = explode("/", $sPath);
+        $sPathFull = '';
+        if ('/' == $sPath[0]) {
+            $sPathFull = '/';
+            ftp_chdir($this->_rStream, '/');
+        }
+        foreach ($aParts as $sPart) {
+            if (!$sPart)
+                continue;
+            $sPathFull .= $sPart;
+            if ('..' == $sPart) {
+                @ftp_cdup($this->_rStream);
+            } elseif (!@ftp_chdir($this->_rStream, $sPart)) {
+                if (!@ftp_mkdir($this->_rStream, $sPart)) {
+                    ftp_chdir($this->_rStream, $sPwd);
+                    return false;
+                }
+                @ftp_chdir($this->_rStream, $sPart);
+            }
+            $sPathFull .= '/';
+        }
+        ftp_chdir($this->_rStream, $sPwd);
         return true;
         return true;
     }
     }
+
 }
 }

+ 3 - 0
inc/classes/BxDolGzip.php

@@ -85,6 +85,9 @@ class BxDolGzip extends BxDol {
             return;
             return;
         }
         }
 
 
+        if (!$this->_sOutContent)
+            return;        
+
         $this->_sOutContentZipped = gzencode($this->_sOutContent, 9, FORCE_GZIP);
         $this->_sOutContentZipped = gzencode($this->_sOutContent, 9, FORCE_GZIP);
         $this->putFileContents($this->_sOutFile, $this->_sOutContentZipped);
         $this->putFileContents($this->_sOutFile, $this->_sOutContentZipped);
 
 

+ 5 - 0
inc/classes/BxDolLanguages.php

@@ -314,4 +314,9 @@ function _t_format_currency($fPrice) {
 function _t_format_extensions($mixedExtensions) {
 function _t_format_extensions($mixedExtensions) {
     return BxDolLanguages::getInstance()->_t_format_extensions($mixedExtensions);
     return BxDolLanguages::getInstance()->_t_format_extensions($mixedExtensions);
 }
 }
+
+function bx_lang_name()
+{
+	return BxDolLanguages::getInstance()->getCurrentLanguage();
+}
 /** @} */
 /** @} */

+ 1 - 1
inc/classes/BxDolRssFactory.php

@@ -85,7 +85,7 @@ class BxDolRssFactory extends BxDol {
             $sRSSTitle = _t('_RSS_Feed_Title_Profile', $aPIDOwnerInfo['NickName'], $sUnitTitleC);
             $sRSSTitle = _t('_RSS_Feed_Title_Profile', $aPIDOwnerInfo['NickName'], $sUnitTitleC);
         }
         }
 
 
-        if(substr($sMainLink, 0, 7) != 'http://')
+        if(substr($sMainLink, 0, 7) != 'http://' && substr($sMainLink, 0, 8) != 'https://')
             $sMainLink = BX_DOL_URL_ROOT . $sMainLink;
             $sMainLink = BX_DOL_URL_ROOT . $sMainLink;
 
 
         $sRSSImage = '';
         $sRSSImage = '';

+ 7 - 4
inc/classes/BxDolSearch.php

@@ -520,6 +520,8 @@ class BxDolSearchResult {
                 if (isset($aValue['operator']) && !empty($aValue['value'])) {
                 if (isset($aValue['operator']) && !empty($aValue['value'])) {
                    $sFieldTable = isset($aValue['table']) ? $aValue['table'] : $this->aCurrent['table'];
                    $sFieldTable = isset($aValue['table']) ? $aValue['table'] : $this->aCurrent['table'];
                    $sqlCondition = "`{$sFieldTable}`.`{$aValue['field']}` ";
                    $sqlCondition = "`{$sFieldTable}`.`{$aValue['field']}` ";
+                   if (!isset($aValue['no_quote_value']))
+                       $aValue['value'] = process_db_input($aValue['value'], BX_TAGS_STRIP);
                    switch ($aValue['operator']) {
                    switch ($aValue['operator']) {
                        case 'against':
                        case 'against':
                             $aCond = isset($aValue['field']) && strlen($aValue['field']) > 0 ? $aValue['field'] : $this->aCurrent['searchFields'];
                             $aCond = isset($aValue['field']) && strlen($aValue['field']) > 0 ? $aValue['field'] : $this->aCurrent['searchFields'];
@@ -573,6 +575,10 @@ class BxDolSearchResult {
      * return array with sql elements order and ownFields
      * return array with sql elements order and ownFields
      */
      */
     function getSorting ($sSortType = 'last') {
     function getSorting ($sSortType = 'last') {
+        $aOverride = $this->getAlterOrder();
+        if (is_array($aOverride) && !empty($aOverride))
+            return $aOverride;
+
        $aSql = array();
        $aSql = array();
        switch ($sSortType) {
        switch ($sSortType) {
            case 'rand':
            case 'rand':
@@ -597,9 +603,6 @@ class BxDolSearchResult {
            default:
            default:
                 $aSql['order'] = "ORDER BY `date` DESC";
                 $aSql['order'] = "ORDER BY `date` DESC";
         }
         }
-        $aAdd = $this->getAlterOrder();
-        if (is_array($aAdd) && !empty($aAdd))
-            $aSql = $aAdd;
         return $aSql;
         return $aSql;
     }
     }
 
 
@@ -654,7 +657,7 @@ class BxDolSearchResult {
             $aSql = array(
             $aSql = array(
                 'function' => 'CONCAT', // TODO: get rid of CONCAT !!!
                 'function' => 'CONCAT', // TODO: get rid of CONCAT !!!
                 'operator' => 'LIKE',
                 'operator' => 'LIKE',
-                'word' => '%' . $sKeyword . '%'
+                  'word' => '%' . preg_replace('/\s+/', '%', $sKeyword) . '%'
             );
             );
         }
         }
         $sqlWhere = " {$aSql['function']}(";
         $sqlWhere = " {$aSql['function']}(";

+ 4 - 5
inc/classes/BxDolTags.php

@@ -123,7 +123,7 @@ class BxDolTags extends BxDol {
         if (isset($aParam['orderby']))
         if (isset($aParam['orderby']))
         {
         {
             if ($aParam['orderby'] == 'popular')
             if ($aParam['orderby'] == 'popular')
-                $sGroupBy .= " ORDER BY `{$this->aTagFields['tag']}` ASC, `count` DESC";
+                $sGroupBy .= " ORDER BY `count` DESC, `{$this->aTagFields['tag']}` ASC";
             else if ($aParam['orderby'] == 'recent')
             else if ($aParam['orderby'] == 'recent')
                 $sGroupBy .= " ORDER BY `{$this->aTagFields['date']}` DESC, `{$this->aTagFields['tag']}` ASC";
                 $sGroupBy .= " ORDER BY `{$this->aTagFields['date']}` DESC, `{$this->aTagFields['tag']}` ASC";
         }
         }
@@ -133,11 +133,10 @@ class BxDolTags extends BxDol {
             `tgs`.`{$this->aTagFields['date']}` as `{$this->aTagFields['date']}`,
             `tgs`.`{$this->aTagFields['date']}` as `{$this->aTagFields['date']}`,
             COUNT(`tgs`.`{$this->aTagFields['id']}`) AS `count`
             COUNT(`tgs`.`{$this->aTagFields['id']}`) AS `count`
             FROM `{$this->sTagTable}` `tgs` $sJoin $sCondition $sGroupBy $sLimit";
             FROM `{$this->sTagTable}` `tgs` $sJoin $sCondition $sGroupBy $sLimit";
+        $aTotalTags = $oDb->getPairs($sqlQuery, $this->aTagFields['tag'], 'count');
 
 
-        $aTags = $oDb->getAll($sqlQuery);
-
-        foreach ($aTags as $aTag)
-            $aTotalTags[$aTag[$this->aTagFields['tag']]] = $aTag['count'];
+        if(isset($aParam['orderby']) && $aParam['orderby'] == 'popular')
+            ksort($aTotalTags);
 
 
         return $aTotalTags;
         return $aTotalTags;
     }
     }

+ 71 - 29
inc/classes/BxDolTemplate.php

@@ -966,6 +966,8 @@ class BxDolTemplate extends BxDol {
      * @return string result of operation or false on failure.
      * @return string result of operation or false on failure.
      */
      */
     function getCached($sName, &$aVariables, $mixedKeyWrapperHtml = null, $sCheckIn = BX_DOL_TEMPLATE_CHECK_IN_BOTH, $bEvaluate = true) {
     function getCached($sName, &$aVariables, $mixedKeyWrapperHtml = null, $sCheckIn = BX_DOL_TEMPLATE_CHECK_IN_BOTH, $bEvaluate = true) {
+        // initialization
+
         if(!$this->_bCacheEnable)
         if(!$this->_bCacheEnable)
             return false;
             return false;
 
 
@@ -974,30 +976,54 @@ class BxDolTemplate extends BxDol {
             return false;
             return false;
 
 
         $oCacheEngine = $this->getTemplatesCacheObject ();
         $oCacheEngine = $this->getTemplatesCacheObject ();
+        $isFileBasedEngine = $bEvaluate && method_exists($oCacheEngine, 'getDataFilePath');
+
+        // try to get cached content
 
 
         $sCacheVariableName = "a";
         $sCacheVariableName = "a";
         $sCacheKey = $this->_getCacheFileName('html', $sAbsolutePath) . '.php';
         $sCacheKey = $this->_getCacheFileName('html', $sAbsolutePath) . '.php';
-        $sCacheContent = $oCacheEngine->getData($sCacheKey);
+        if ($isFileBasedEngine)
+            $sCacheContent = $oCacheEngine->getDataFilePath($sCacheKey);
+        else
+            $sCacheContent = $oCacheEngine->getData($sCacheKey);
+
+
+        // recreate cache if it is empty
+
+        if ($sCacheContent === null && ($sContent = file_get_contents($sAbsolutePath)) !== false && ($sContent = $this->_compileContent($sContent, "\$" . $sCacheVariableName, 1, $aVariables, $mixedKeyWrapperHtml)) !== false) {
+            if (false === $oCacheEngine->setData($sCacheKey, $sContent))
+                return false;
 
 
-        if($sCacheContent === null && ($sContent = file_get_contents($sAbsolutePath)) !== false && ($sContent = $this->_compileContent($sContent, "\$" . $sCacheVariableName, 1, $aVariables, $mixedKeyWrapperHtml)) !== false)
-            if($oCacheEngine->setData($sCacheKey, $sContent) !== false)
+            if ($isFileBasedEngine)
+                $sCacheContent = $oCacheEngine->getDataFilePath($sCacheKey);
+            else
                 $sCacheContent = $sContent;
                 $sCacheContent = $sContent;
+        }
 
 
-        if($sCacheContent !== null) {
-            if(!$bEvaluate)
-                return $sCacheContent;
+        if ($sCacheContent === null)
+            return false;
 
 
-            $$sCacheVariableName = &$aVariables;
+        // return simple cache content
 
 
-            ob_start();
-                eval('?>' . $sCacheContent); // TODO: why is eval here ? MUST BE INCLUDE ! it is cache !
-            $sContent = ob_get_clean();
+        if(!$bEvaluate)
+            return $sCacheContent;
 
 
-            return $sContent;
-        }
+        // return evaluated cache content
 
 
-        return false;
+        ob_start();
+
+        $$sCacheVariableName = &$aVariables;
+
+        if ($isFileBasedEngine)
+            include($sCacheContent);
+        else
+            eval('?'.'>' . $sCacheContent);
+
+        $sContent = ob_get_clean();
+
+        return $sContent;
     }
     }
+
     /**
     /**
      * Add JS file(s) to global output.
      * Add JS file(s) to global output.
      *
      *
@@ -1046,7 +1072,9 @@ class BxDolTemplate extends BxDol {
         if(empty($sContent))
         if(empty($sContent))
             return '';
             return '';
 
 
-        $sUrl = str_replace(array(realpath(BX_DIRECTORY_PATH_ROOT), DIRECTORY_SEPARATOR), array(BX_DOL_URL_ROOT, '/'), $sPath);
+        $sUrl = bx_ltrim_str($sPath, realpath(BX_DIRECTORY_PATH_ROOT), BX_DOL_URL_ROOT);
+        $sUrl = str_replace(DIRECTORY_SEPARATOR, '/', $sPath);
+
         $sContent = "\r\n/*--- BEGIN: " . $sUrl . $sName . "---*/\r\n" . $sContent . ";\r\n/*--- END: " . $sUrl . $sName . "---*/\r\n";
         $sContent = "\r\n/*--- BEGIN: " . $sUrl . $sName . "---*/\r\n" . $sContent . ";\r\n/*--- END: " . $sUrl . $sName . "---*/\r\n";
         $sContent = str_replace(array("\n\r", "\r\n", "\r"), "\n", $sContent);
         $sContent = str_replace(array("\n\r", "\r\n", "\r"), "\n", $sContent);
 
 
@@ -1131,7 +1159,9 @@ class BxDolTemplate extends BxDol {
         if(empty($sContent))
         if(empty($sContent))
             return '';
             return '';
 
 
-        $sUrl = str_replace(array(realpath(BX_DIRECTORY_PATH_ROOT), DIRECTORY_SEPARATOR), array(BX_DOL_URL_ROOT, '/'), $sPath);
+        $sUrl = bx_ltrim_str($sPath, realpath(BX_DIRECTORY_PATH_ROOT), BX_DOL_URL_ROOT);
+        $sUrl = str_replace(DIRECTORY_SEPARATOR, '/', $sPath);
+
         $sContent = "\r\n/*--- BEGIN: " . $sUrl . $sName . "---*/\r\n" . $sContent . "\r\n/*--- END: " . $sUrl . $sName . "---*/\r\n";
         $sContent = "\r\n/*--- BEGIN: " . $sUrl . $sName . "---*/\r\n" . $sContent . "\r\n/*--- END: " . $sUrl . $sName . "---*/\r\n";
         $aIncluded[$sAbsolutePath] = 1;
         $aIncluded[$sAbsolutePath] = 1;
 
 
@@ -1140,7 +1170,7 @@ class BxDolTemplate extends BxDol {
             $sContent = preg_replace(
             $sContent = preg_replace(
                 array(
                 array(
                     "'@import\s+url\s*\(\s*[\'|\"]*\s*([a-zA-Z0-9\.\/_-]+)\s*[\'|\"]*\s*\)\s*;'e",
                     "'@import\s+url\s*\(\s*[\'|\"]*\s*([a-zA-Z0-9\.\/_-]+)\s*[\'|\"]*\s*\)\s*;'e",
-                    "'url\s*\(\s*[\'|\"]*\s*([a-zA-Z0-9\.\/_-]+)\s*[\'|\"]*\s*\)'e"
+                    "'url\s*\(\s*[\'|\"]*\s*([a-zA-Z0-9\.\/\?\#_-]+)\s*[\'|\"]*\s*\)'e"
                 ),
                 ),
                 array(
                 array(
                     "",
                     "",
@@ -1157,7 +1187,7 @@ class BxDolTemplate extends BxDol {
             );
             );
 
 
             $sContent = preg_replace_callback(
             $sContent = preg_replace_callback(
-                "'url\s*\(\s*[\'|\"]*\s*([a-zA-Z0-9\.\/_-]+)\s*[\'|\"]*\s*\)'",
+                "'url\s*\(\s*[\'|\"]*\s*([a-zA-Z0-9\.\/\?\#_-]+)\s*[\'|\"]*\s*\)'",
                 create_function('$aMatches', 'return BxDolTemplate::_callbackParseUrl("' . addslashes($sPath) . '", $aMatches);'),
                 create_function('$aMatches', 'return BxDolTemplate::_callbackParseUrl("' . addslashes($sPath) . '", $aMatches);'),
                 $sContent
                 $sContent
             );
             );
@@ -1193,7 +1223,7 @@ class BxDolTemplate extends BxDol {
         $sRootPath = str_replace(DIRECTORY_SEPARATOR, '/', $sRootPath);
         $sRootPath = str_replace(DIRECTORY_SEPARATOR, '/', $sRootPath);
         $sAbsolutePath = str_replace(DIRECTORY_SEPARATOR, '/', $sAbsolutePath);
         $sAbsolutePath = str_replace(DIRECTORY_SEPARATOR, '/', $sAbsolutePath);
 
 
-        return 'url(' . str_replace($sRootPath, BX_DOL_URL_ROOT, $sAbsolutePath) . ')';
+        return 'url(' . bx_ltrim_str($sAbsolutePath, $sRootPath, BX_DOL_URL_ROOT) . ')';
     }
     }
 
 
     /**
     /**
@@ -1340,12 +1370,25 @@ class BxDolTemplate extends BxDol {
                 case 'add':
                 case 'add':
                     if($bDynamic)
                     if($bDynamic)
                         $sResult .= $this->$sMethodWrap($sUrl);
                         $sResult .= $this->$sMethodWrap($sUrl);
-                    else
-                        $this->aPage[$sType . '_compiled'][$sUrl] = array('url' => $sUrl, 'path' => $sPath);
+                    else {
+                        $bFound = false;
+                        foreach($this->aPage[$sType . '_compiled']  as $iKey => $aValue)
+                            if($aValue['url'] == $sUrl && $aValue['path'] == $sPath) {
+                                $bFound = true;
+                                break;
+                            }
+
+                        if(!$bFound)
+                            $this->aPage[$sType . '_compiled'][] = array('url' => $sUrl, 'path' => $sPath);
+                    }
                     break;
                     break;
                 case 'delete':
                 case 'delete':
                     if(!$bDynamic)
                     if(!$bDynamic)
-                        unset($this->aPage[$sType . '_compiled'][$sUrl]);
+                        foreach($this->aPage[$sType . '_compiled']  as $iKey => $aValue)
+                            if($aValue['url'] == $sUrl) {
+                                unset($this->aPage[$sType . '_compiled'][$iKey]);
+                                break;
+                            }
                     break;
                     break;
             }
             }
         }
         }
@@ -1411,7 +1454,7 @@ class BxDolTemplate extends BxDol {
             "'<bx_injection:([^\s]+) />'se",
             "'<bx_injection:([^\s]+) />'se",
             "'<bx_image_url:([^\s]+) \/>'se",
             "'<bx_image_url:([^\s]+) \/>'se",
             "'<bx_icon_url:([^\s]+) \/>'se",
             "'<bx_icon_url:([^\s]+) \/>'se",
-            "'<bx_text:([^\s]+) \/>'se",
+            "'<bx_text:([_\{\}\w\d\s]+[^\s]{1}) \/>'se",
             "'<bx_text_js:([^\s]+) \/>'se",
             "'<bx_text_js:([^\s]+) \/>'se",
             "'<bx_text_attribute:([^\s]+) \/>'se",
             "'<bx_text_attribute:([^\s]+) \/>'se",
             "'<bx_menu:([^\s]+) \/>'se",
             "'<bx_menu:([^\s]+) \/>'se",
@@ -1470,11 +1513,11 @@ class BxDolTemplate extends BxDol {
                         return false;
                         return false;
 
 
                     $sIndex = "\$" . str_repeat("i", $iVarDepth);
                     $sIndex = "\$" . str_repeat("i", $iVarDepth);
-                    $sValue .= "<? if(is_array(" . $aVarName . "['" . $aKeys[$i] . "'])) for(" . $sIndex . "=0; " . $sIndex . "<count(" . $aVarName . "['" . $aKeys[$i] . "']); " . $sIndex . "++){ ?>";
+                    $sValue .= "<?php if(is_array(" . $aVarName . "['" . $aKeys[$i] . "'])) for(" . $sIndex . "=0; " . $sIndex . "<count(" . $aVarName . "['" . $aKeys[$i] . "']); " . $sIndex . "++){ ?>";
                     if(($sInnerValue = $this->_compileContent($aMatches[1], $aVarName . "['" . $aKeys[$i] . "'][" . $sIndex . "]", $iVarDepth + 1, current($aValues[$i]), $mixedKeyWrapperHtml)) === false)
                     if(($sInnerValue = $this->_compileContent($aMatches[1], $aVarName . "['" . $aKeys[$i] . "'][" . $sIndex . "]", $iVarDepth + 1, current($aValues[$i]), $mixedKeyWrapperHtml)) === false)
                         return false;
                         return false;
                     $sValue .= $sInnerValue;
                     $sValue .= $sInnerValue;
-                    $sValue .= "<?} else if(is_string(" . $aVarName . "['" . $aKeys[$i] . "'])) echo " . $aVarName . "['" . $aKeys[$i] . "']; ?>";
+                    $sValue .= "<?php } else if(is_string(" . $aVarName . "['" . $aKeys[$i] . "'])) echo " . $aVarName . "['" . $aKeys[$i] . "']; ?>";
                 }
                 }
             }
             }
             else if(strpos($aKeys[$i], 'bx_if:') === 0) {
             else if(strpos($aKeys[$i], 'bx_if:') === 0) {
@@ -1488,11 +1531,11 @@ class BxDolTemplate extends BxDol {
                     if(!is_array($aValues[$i]) || !isset($aValues[$i]['content']) || empty($aValues[$i]['content']) || !is_array($aValues[$i]['content']))
                     if(!is_array($aValues[$i]) || !isset($aValues[$i]['content']) || empty($aValues[$i]['content']) || !is_array($aValues[$i]['content']))
                         return false;
                         return false;
 
 
-                    $sValue .= "<? if(" . $aVarName . "['" . $aKeys[$i] . "']['condition']){ ?>";
+                    $sValue .= "<?php if(" . $aVarName . "['" . $aKeys[$i] . "']['condition']){ ?>";
                     if(($sInnerValue = $this->_compileContent($aMatches[1], $aVarName . "['" . $aKeys[$i] . "']['content']", $iVarDepth, $aValues[$i]['content'], $mixedKeyWrapperHtml)) === false)
                     if(($sInnerValue = $this->_compileContent($aMatches[1], $aVarName . "['" . $aKeys[$i] . "']['content']", $iVarDepth, $aValues[$i]['content'], $mixedKeyWrapperHtml)) === false)
                         return false;
                         return false;
                     $sValue .= $sInnerValue;
                     $sValue .= $sInnerValue;
-                    $sValue .= "<?}?>";
+                    $sValue .= "<?php } ?>";
                 }
                 }
             }
             }
             else {
             else {
@@ -1511,7 +1554,7 @@ class BxDolTemplate extends BxDol {
             "'<bx_injection:([^\s]+) />'s",
             "'<bx_injection:([^\s]+) />'s",
             "'<bx_image_url:([^\s]+) \/>'se",
             "'<bx_image_url:([^\s]+) \/>'se",
             "'<bx_icon_url:([^\s]+) \/>'se",
             "'<bx_icon_url:([^\s]+) \/>'se",
-            "'<bx_text:([^\s]+) \/>'se",
+            "'<bx_text:([_\{\}\w\d\s]+[^\s]{1}) \/>'se",
             "'<bx_text_js:([^\s]+) \/>'se",
             "'<bx_text_js:([^\s]+) \/>'se",
             "'<bx_text_attribute:([^\s]+) \/>'se",
             "'<bx_text_attribute:([^\s]+) \/>'se",
             "'<bx_url_root />'",
             "'<bx_url_root />'",
@@ -1578,7 +1621,6 @@ class BxDolTemplate extends BxDol {
                 $sResult = $aLocation[$sType] . BX_DOL_TEMPLATE_FOLDER_ROOT . $sDivider . $sFolder . $sName;
                 $sResult = $aLocation[$sType] . BX_DOL_TEMPLATE_FOLDER_ROOT . $sDivider . $sFolder . $sName;
             else
             else
                 continue;
                 continue;
-
             break;
             break;
         }
         }
 
 
@@ -1653,7 +1695,7 @@ class BxDolTemplate extends BxDol {
         $sResult = md5($sAbsolutePath . BX_DOL_VERSION . BX_DOL_BUILD . BX_DOL_URL_ROOT);
         $sResult = md5($sAbsolutePath . BX_DOL_VERSION . BX_DOL_BUILD . BX_DOL_URL_ROOT);
         switch($sType) {
         switch($sType) {
             case 'html':
             case 'html':
-                $sResult = $this->_sCacheFilePrefix . getCurrentLangName() . '_' . $this->_sCode .  '_' . $sResult;
+                $sResult = $this->_sCacheFilePrefix . bx_lang_name() . '_' . $this->_sCode .  '_' . $sResult;
                 break;
                 break;
             case 'css':
             case 'css':
                 $sResult = $this->_sCssCachePrefix . $sResult;
                 $sResult = $this->_sCssCachePrefix . $sResult;

+ 3 - 0
inc/classes/BxDolTextCalendar.php

@@ -29,6 +29,9 @@ class BxDolTextCalendar extends BxTemplCalendar {
     var $_oConfig;
     var $_oConfig;
     var $sCssPrefix;
     var $sCssPrefix;
 
 
+    var $iBlockID = 0;
+    var $sDynamicUrl = '';
+
     function BxDolTextCalendar($iYear, $iMonth, &$oDb, &$oConfig) {
     function BxDolTextCalendar($iYear, $iMonth, &$oDb, &$oConfig) {
         parent::BxTemplCalendar($iYear, $iMonth);
         parent::BxTemplCalendar($iYear, $iMonth);
 
 

+ 28 - 0
inc/classes/BxDolTextConfig.php

@@ -32,6 +32,13 @@ class BxDolTextConfig extends BxDolModuleConfig {
     var $_sCommentsSystemName;
     var $_sCommentsSystemName;
     var $_bVotes;
     var $_bVotes;
     var $_sVotesSystemName;
     var $_sVotesSystemName;
+    var $_sViewsSystemName;
+    var $_sSubscriptionsSystemName;
+    var $_sActionsViewSystemName;
+    var $_sCategoriesSystemName;
+    var $_sTagsSystemName;
+    var $_sAlertsSystemName;
+    var $_sSearchSystemName;
     var $_sDateFormat;
     var $_sDateFormat;
     var $_sAnimationEffect;
     var $_sAnimationEffect;
     var $_iAnimationSpeed;
     var $_iAnimationSpeed;
@@ -65,6 +72,27 @@ class BxDolTextConfig extends BxDolModuleConfig {
     function getVotesSystemName() {
     function getVotesSystemName() {
         return $this->_sVotesSystemName;
         return $this->_sVotesSystemName;
     }
     }
+    function getViewsSystemName() {
+        return $this->_sViewsSystemName;
+    }
+    function getSubscriptionsSystemName() {
+        return $this->_sSubscriptionsSystemName;
+    }
+    function getActionsViewSystemName() {
+        return $this->_sActionsViewSystemName;
+    }
+    function getCategoriesSystemName() {
+        return $this->_sCategoriesSystemName;
+    }
+    function getTagsSystemName() {
+        return $this->_sTagsSystemName;
+    }
+    function getAlertsSystemName() {
+        return $this->_sAlertsSystemName;
+    }
+    function getSearchSystemName() {
+        return $this->_sSearchSystemName;
+    }
     function getDateFormat() {
     function getDateFormat() {
         return $this->_sDateFormat;
         return $this->_sDateFormat;
     }
     }

+ 3 - 5
inc/classes/BxDolTextCron.php

@@ -37,24 +37,22 @@ class BxDolTextCron extends BxDolCron {
     }
     }
 
 
     function processing() {
     function processing() {
-        $sModuleName = 'bx_' . $this->_oModule->_oConfig->getUri();
-
         $aIds = array();
         $aIds = array();
         if($this->_oModule->_oDb->publish($aIds))
         if($this->_oModule->_oDb->publish($aIds))
             foreach($aIds as $iId) {
             foreach($aIds as $iId) {
                 //--- Entry -> Publish for Alerts Engine ---//
                 //--- Entry -> Publish for Alerts Engine ---//
-                $oAlert = new BxDolAlerts($sModuleName, 'publish', $iId);
+                $oAlert = new BxDolAlerts($this->_oModule->_oConfig->getAlertsSystemName(), 'publish', $iId);
                 $oAlert->alert();
                 $oAlert->alert();
                 //--- Entry -> Publish for Alerts Engine ---//
                 //--- Entry -> Publish for Alerts Engine ---//
 
 
                 //--- Reparse Global Tags ---//
                 //--- Reparse Global Tags ---//
                 $oTags = new BxDolTags();
                 $oTags = new BxDolTags();
-                $oTags->reparseObjTags($sModuleName, $iId);
+                $oTags->reparseObjTags($this->_oModule->_oConfig->getTagsSystemName(), $iId);
                 //--- Reparse Global Tags ---//
                 //--- Reparse Global Tags ---//
 
 
                 //--- Reparse Global Categories ---//
                 //--- Reparse Global Categories ---//
                 $oCategories = new BxDolCategories();
                 $oCategories = new BxDolCategories();
-                $oCategories->reparseObjTags($sModuleName, $iId);
+                $oCategories->reparseObjTags($this->_oModule->_oConfig->getCategoriesSystemName(), $iId);
                 //--- Reparse Global Categories ---//
                 //--- Reparse Global Categories ---//
             }
             }
     }
     }

+ 8 - 8
inc/classes/BxDolTextData.php

@@ -154,7 +154,7 @@ class BxDolTextData {
                         'pass' => 'Xss',
                         'pass' => 'Xss',
                     ),
                     ),
                 ),
                 ),
-                //'categories' => $oCategories->getGroupChooser ('bx_' . $this->_sSystem, $this->_iOwnerId, true),
+                //'categories' => $oCategories->getGroupChooser ($this->_oModule->_oConfig->getCategoriesSystemName(), $this->_iOwnerId, true),
                 'allow_comment_to' => array(),
                 'allow_comment_to' => array(),
                 'allow_vote_to' => array(),
                 'allow_vote_to' => array(),
                 'post' => array(
                 'post' => array(
@@ -197,18 +197,18 @@ class BxDolTextData {
 
 
             //--- 'System' -> Post for Alerts Engine ---//
             //--- 'System' -> Post for Alerts Engine ---//
             bx_import('BxDolAlerts');
             bx_import('BxDolAlerts');
-            $oAlert = new BxDolAlerts('bx_' . $this->_sSystem, 'post', $iId, $this->_iOwnerId);
+            $oAlert = new BxDolAlerts($this->_oModule->_oConfig->getAlertsSystemName(), 'post', $iId, $this->_iOwnerId);
             $oAlert->alert();
             $oAlert->alert();
             //--- 'System' -> Post for Alerts Engine ---//
             //--- 'System' -> Post for Alerts Engine ---//
 
 
             //--- Reparse Global Tags ---//
             //--- Reparse Global Tags ---//
             $oTags = new BxDolTags();
             $oTags = new BxDolTags();
-            $oTags->reparseObjTags('bx_' . $this->_sSystem, $iId);
+            $oTags->reparseObjTags($this->_oModule->_oConfig->getTagsSystemName(), $iId);
             //--- Reparse Global Tags ---//
             //--- Reparse Global Tags ---//
 
 
             //--- Reparse Global Categories ---//
             //--- Reparse Global Categories ---//
             $oCategories = new BxDolCategories();
             $oCategories = new BxDolCategories();
-            $oCategories->reparseObjTags('bx_' . $this->_sSystem, $iId);
+            $oCategories->reparseObjTags($this->_oModule->_oConfig->getCategoriesSystemName(), $iId);
             //--- Reparse Global Categories ---//
             //--- Reparse Global Categories ---//
 
 
             header('Location: ' . $oForm->aFormAttrs['action']);
             header('Location: ' . $oForm->aFormAttrs['action']);
@@ -220,7 +220,7 @@ class BxDolTextData {
         $oCategories = new BxDolCategories();
         $oCategories = new BxDolCategories();
         if (isset($this->_aForm['inputs']['categories'])) {
         if (isset($this->_aForm['inputs']['categories'])) {
             //--- convert post form to edit one ---//
             //--- convert post form to edit one ---//
-            $this->_aForm['inputs']['categories'] = $oCategories->getGroupChooser('bx_' . $this->_sSystem, $this->_iOwnerId, true, $aValues['categories']);
+            $this->_aForm['inputs']['categories'] = $oCategories->getGroupChooser($this->_oModule->_oConfig->getCategoriesSystemName(), $this->_iOwnerId, true, $aValues['categories']);
         }
         }
         if(!empty($aValues) && is_array($aValues)) {
         if(!empty($aValues) && is_array($aValues)) {
             foreach($aValues as $sKey => $sValue)
             foreach($aValues as $sKey => $sValue)
@@ -266,17 +266,17 @@ class BxDolTextData {
 
 
             //--- 'System' -> Edit for Alerts Engine ---//
             //--- 'System' -> Edit for Alerts Engine ---//
             bx_import('BxDolAlerts');
             bx_import('BxDolAlerts');
-            $oAlert = new BxDolAlerts('bx_' . $this->_sSystem, 'edit', $aValues['id'], $this->_iOwnerId);
+            $oAlert = new BxDolAlerts($this->_oModule->_oConfig->getAlertsSystemName(), 'edit', $aValues['id'], $this->_iOwnerId);
             $oAlert->alert();
             $oAlert->alert();
             //--- 'System' -> Edit for Alerts Engine ---//
             //--- 'System' -> Edit for Alerts Engine ---//
 
 
             //--- Reparse Global Tags ---//
             //--- Reparse Global Tags ---//
             $oTags = new BxDolTags();
             $oTags = new BxDolTags();
-            $oTags->reparseObjTags('bx_' . $this->_sSystem, $aValues['id']);
+            $oTags->reparseObjTags($this->_oModule->_oConfig->getTagsSystemName(), $aValues['id']);
             //--- Reparse Global Tags ---//
             //--- Reparse Global Tags ---//
 
 
             //--- Reparse Global Categories ---//
             //--- Reparse Global Categories ---//
-            $oCategories->reparseObjTags('bx_' . $this->_sSystem, $aValues['id']);
+            $oCategories->reparseObjTags($this->_oModule->_oConfig->getCategoriesSystemName(), $aValues['id']);
             //--- Reparse Global Categories ---//
             //--- Reparse Global Categories ---//
 
 
             header('Location: ' . $oForm->aFormAttrs['action']);
             header('Location: ' . $oForm->aFormAttrs['action']);

+ 2 - 1
inc/classes/BxDolTextDb.php

@@ -99,8 +99,9 @@ class BxDolTextDb extends BxDolModuleDb {
                    `te`.`snippet` AS `snippet`,
                    `te`.`snippet` AS `snippet`,
                    `te`.`content` AS `content`,
                    `te`.`content` AS `content`,
                    `te`.`when` AS `when_uts`,
                    `te`.`when` AS `when_uts`,
-                   DATE_FORMAT(FROM_UNIXTIME(`te`.`when`), '%Y-%m-%d %H:%i:%S') AS `when`,
+                   DATE_FORMAT(FROM_UNIXTIME(`te`.`when`), '%Y-%m-%d %H:%i') AS `when`,
                    DATE_FORMAT(FROM_UNIXTIME(`te`.`when`), '" . $this->_oConfig->getDateFormat() . "') AS `when_uf`,
                    DATE_FORMAT(FROM_UNIXTIME(`te`.`when`), '" . $this->_oConfig->getDateFormat() . "') AS `when_uf`,
+                   UNIX_TIMESTAMP() - `te`.`when` AS `ago`,
                    `te`.`uri` AS `uri`,
                    `te`.`uri` AS `uri`,
                    `te`.`tags` AS `tags`,
                    `te`.`tags` AS `tags`,
                    `te`.`categories` AS `categories`,
                    `te`.`categories` AS `categories`,

+ 239 - 86
inc/classes/BxDolTextModule.php

@@ -53,8 +53,102 @@ class BxDolTextModule extends BxDolModule {
         $sClassName = $sClassPrefix . 'Data';
         $sClassName = $sClassPrefix . 'Data';
         $this->_oTextData = class_exists($sClassName) ? new $sClassName($this) : null;
         $this->_oTextData = class_exists($sClassName) ? new $sClassName($this) : null;
     }
     }
+    function getBlockView($sUri)
+    {
+        $aEntry = $this->_oDb->getEntries(array('sample_type' => 'uri', 'uri' => $sUri));
+        if(empty($aEntry) || !is_array($aEntry))
+        	$this->_oTemplate->displayPageNotFound();
 
 
-    function getCalendar($iYear = 0, $iMonth = 0) {
+        $sModuleUri = $this->_oConfig->getUri();
+        $oView = new BxDolViews($this->_oConfig->getViewsSystemName(), $aEntry['id']);
+        $oView->makeView();
+
+        $this->_oTemplate->setPageTitle($aEntry['caption']);
+        $GLOBALS['oTopMenu']->setCustomSubHeader($aEntry['caption']);
+        $GLOBALS['oTopMenu']->setCustomBreadcrumbs(array(
+            _t('_' . $sModuleUri . '_top_menu_item') => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'index/',
+            $aEntry['caption'] => '')
+        );
+        return $this->_oTemplate->displayList(array(
+           'sample_type' => 'view',
+           'viewer_type' => $this->_oTextData->getViewerType(),
+           'uri' => $aEntry['uri']
+        ));
+    }
+    function getBlockComment($sUri)
+    {
+        $aEntry = $this->_oDb->getEntries(array('sample_type' => 'uri', 'uri' => $sUri));
+        if(!$this->_oConfig->isCommentsEnabled() || !$this->_isCommentsAllowed($aEntry))
+            return '';
+
+        $sModuleUri = $this->_oConfig->getUri();
+        if($aEntry['status'] != BX_TD_STATUS_ACTIVE)
+            return MsgBox(_t('_' . $sModuleUri . '_msg_no_results'));
+
+        $this->_oTemplate->addCss(array('cmts.css'));
+        $oComments = $this->_createObjectCmts($aEntry['id']);
+        return $oComments->getCommentsFirst('comment');
+    }
+    function getBlockVote($sUri)
+    {
+        $aEntry = $this->_oDb->getEntries(array('sample_type' => 'uri', 'uri' => $sUri));
+        if(!$this->_oConfig->isVotesEnabled() || !$this->_isVotesAllowed($aEntry))
+            return '';
+
+        $sModuleUri = $this->_oConfig->getUri();
+        if($aEntry['status'] != BX_TD_STATUS_ACTIVE)
+            return MsgBox(_t('_' . $sModuleUri . '_msg_no_results'));
+
+        $oVotes = $this->_createObjectVoting($aEntry['id']);
+        return $oVotes->getBigVoting();
+    }
+    function getBlockAction($sUri)
+    {
+        $aEntry = $this->_oDb->getEntries(array('sample_type' => 'uri', 'uri' => $sUri));
+
+        $sModuleUri = $this->_oConfig->getUri();
+        $sModuleBaseUri = $this->_oConfig->getBaseUri();
+        if($aEntry['status'] != BX_TD_STATUS_ACTIVE)
+            return MsgBox(_t('_' . $sModuleUri . '_msg_no_results'));
+
+        $sModuleUri = $this->_oConfig->getUri();
+        $oSubscription = new BxDolSubscription();
+        $aButton = $oSubscription->getButton($this->getUserId(), $this->_oConfig->getSubscriptionsSystemName(), '', $aEntry['id']);
+
+        $aReplacement['sbs_' . $sModuleUri . '_title'] = $aButton['title'];
+        $aReplacement['sbs_' . $sModuleUri . '_script'] = $aButton['script'];
+
+        $aReplacement['del_' . $sModuleUri . '_title'] = '';
+        if($this->_isDeleteAllowed()) {
+            $this->_oTemplate->addJsTranslation(array('_' . $sModuleUri . '_msg_success_delete', '_' . $sModuleUri . '_msg_failed_delete'));
+
+            $aReplacement['del_' . $sModuleUri . '_title'] = _t('_' . $sModuleUri . '_actions_delete');
+            $aReplacement['del_' . $sModuleUri . '_script'] = $this->_oConfig->getJsObject() . '.deleteEntry(' . $aEntry['id'] . ')';
+        }
+
+        $aReplacement['share_' . $sModuleUri . '_title'] = '';
+		if($this->_isShareAllowed($aEntry)) {
+			$aReplacement['share_' . $sModuleUri . '_title'] = _t('_Share');
+			$aReplacement['share_' . $sModuleUri . '_script'] = "showPopupAnyHtml('" . $sModuleBaseUri . "share_popup/" . $aEntry['id'] . "')";
+		}
+
+        return $oSubscription->getData() . $GLOBALS['oFunctions']->genObjectsActions($aReplacement, $this->_oConfig->getActionsViewSystemName());
+    }
+    function getBlockSocialSharing($sUri)
+    {
+        $aEntry = $this->_oDb->getEntries(array('sample_type' => 'uri', 'uri' => $sUri));
+        if(!$aEntry || $aEntry['status'] != BX_TD_STATUS_ACTIVE)
+            return '';
+
+        $sUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aEntry['uri'];
+        $sTitle = $aEntry['caption'];
+
+        bx_import('BxTemplSocialSharing');
+        $s = BxTemplSocialSharing::getInstance()->getCode($sUrl, $sTitle);
+        return array($s, array(), array(), false);
+    }
+    function getCalendar($iYear = 0, $iMonth = 0)
+    {
         $sClassName = $this->_oConfig->getClassPrefix() . 'Calendar';
         $sClassName = $this->_oConfig->getClassPrefix() . 'Calendar';
         return new $sClassName($iYear, $iMonth, $this->_oDb, $this->_oConfig);
         return new $sClassName($iYear, $iMonth, $this->_oDb, $this->_oConfig);
     }
     }
@@ -185,79 +279,6 @@ class BxDolTextModule extends BxDolModule {
         );
         );
         return $this->_oTemplate->parseHtmlByName('post.html', $aVariables);
         return $this->_oTemplate->parseHtmlByName('post.html', $aVariables);
     }
     }
-    function serviceViewBlock($sUri) {
-        $aParams = is_numeric($sUri) ? array('sample_type' => 'id', 'id' => $sUri) : array('sample_type' => 'uri', 'uri' => $sUri);
-        $aEntry = $this->_oDb->getEntries($aParams);
-
-        $sModuleUri = $this->_oConfig->getUri();
-        $oView = new BxDolViews('bx_' . $sModuleUri, $aEntry['id']);
-        $oView->makeView();
-
-        $this->_oTemplate->setPageTitle($aEntry['caption']);
-        $GLOBALS['oTopMenu']->setCustomSubHeader($aEntry['caption']);
-        $GLOBALS['oTopMenu']->setCustomBreadcrumbs(array(
-            _t('_' . $sModuleUri . '_top_menu_item') => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'index/',
-            $aEntry['caption'] => '')
-        );
-        return $this->_oTemplate->displayList(array(
-           'sample_type' => 'view',
-           'viewer_type' => $this->_oTextData->getViewerType(),
-           'uri' => $aEntry['uri']
-        ));
-    }
-    function serviceCommentBlock($sUri) {
-        $aParams = is_numeric($sUri) ? array('sample_type' => 'id', 'id' => $sUri) : array('sample_type' => 'uri', 'uri' => $sUri);
-        $aEntry = $this->_oDb->getEntries($aParams);
-        if(!$this->_oConfig->isCommentsEnabled() || !$this->_isCommentsAllowed($aEntry))
-            return '';
-
-        $sModuleUri = $this->_oConfig->getUri();
-        if($aEntry['status'] != BX_TD_STATUS_ACTIVE)
-            return MsgBox(_t('_' . $sModuleUri . '_msg_no_results'));
-
-        $this->_oTemplate->addCss(array('cmts.css'));
-        $oComments = $this->_createObjectCmts($aEntry['id']);
-        return $oComments->getCommentsFirst('comment');
-    }
-    function serviceVoteBlock($sUri) {
-        $aParams = is_numeric($sUri) ? array('sample_type' => 'id', 'id' => $sUri) : array('sample_type' => 'uri', 'uri' => $sUri);
-        $aEntry = $this->_oDb->getEntries($aParams);
-        if(!$this->_oConfig->isVotesEnabled() || !$this->_isVotesAllowed($aEntry))
-            return '';
-
-        $sModuleUri = $this->_oConfig->getUri();
-        if($aEntry['status'] != BX_TD_STATUS_ACTIVE)
-            return MsgBox(_t('_' . $sModuleUri . '_msg_no_results'));
-
-        $oVotes = $this->_createObjectVoting($aEntry['id']);
-        return $oVotes->getBigVoting();
-    }
-    function serviceActionBlock($sUri) {
-        $aParams = is_numeric($sUri) ? array('sample_type' => 'id', 'id' => $sUri) : array('sample_type' => 'uri', 'uri' => $sUri);
-        $aEntry = $this->_oDb->getEntries($aParams);
-
-        $sModuleUri = $this->_oConfig->getUri();
-        if($aEntry['status'] != BX_TD_STATUS_ACTIVE)
-            return MsgBox(_t('_' . $sModuleUri . '_msg_no_results'));
-
-        $sModuleUri = $this->_oConfig->getUri();
-        $oSubscription = new BxDolSubscription();
-        $aButton = $oSubscription->getButton($this->getUserId(), 'bx_' . $sModuleUri, '', $aEntry['id']);
-
-        $aReplacement['sbs_' . $sModuleUri . '_title'] = $aButton['title'];
-        $aReplacement['sbs_' . $sModuleUri . '_script'] = $aButton['script'];
-
-        if($this->_isDeleteAllowed()) {
-            $this->_oTemplate->addJsTranslation(array('_' . $sModuleUri . '_msg_success_delete', '_' . $sModuleUri . '_msg_failed_delete'));
-
-            $aReplacement['del_' . $sModuleUri . '_title'] = _t('_' . $sModuleUri . '_actions_delete');
-            $aReplacement['del_' . $sModuleUri . '_script'] = $this->_oConfig->getJsObject() . '.deleteEntry(' . $aEntry['id'] . ')';
-        }
-        else
-            $aReplacement['del_' . $sModuleUri . '_title'] = '';
-
-        return $oSubscription->getData() . $GLOBALS['oFunctions']->genObjectsActions($aReplacement, 'bx_' . $this->_oConfig->getUri());
-    }
     function serviceAdminBlock($iStart = 0, $iPerPage = 0, $sFilterValue = '') {
     function serviceAdminBlock($iStart = 0, $iPerPage = 0, $sFilterValue = '') {
         if(empty($iPerPage))
         if(empty($iPerPage))
             $iPerPage = $this->_oConfig->getPerPage();
             $iPerPage = $this->_oConfig->getPerPage();
@@ -331,6 +352,35 @@ class BxDolTextModule extends BxDolModule {
            'count' => $iPerPage
            'count' => $iPerPage
         ));
         ));
     }
     }
+    function serviceCategoriesBlock($iBlockId) {
+        $sUri = $this->_oConfig->getUri();
+        $oCategories = new BxTemplCategoriesModule(array('type' => $this->_oConfig->getCategoriesSystemName()), _t('_categ_users'), BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'category');
+
+        return $oCategories->getBlockCode_Common($iBlockId, true);
+    }
+    function serviceTagsBlock($iBlockId) {
+        $sUri = $this->_oConfig->getUri();
+        $oTags = new BxTemplTagsModule(array('type' => $this->_oConfig->getTagsSystemName(), 'orderby' => 'popular'), _t('_' . $sUri . '_bcaption_all_tags'), BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'tags');
+
+        $aResult = $oTags->getBlockCode_All($iBlockId);
+        return $aResult[0];
+    }
+    function serviceGetCalendarBlock($iBlockID, $aParams = array()) {
+        $isMiniMode = isset($aParams['mini_mode']) && $aParams['mini_mode'] === true;
+        $sDynamicUrl = isset($aParams['dynamic_url']) ? $aParams['dynamic_url'] : BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'index/';
+
+        $aDateParams = array();
+        $sDate = bx_get('date');
+        if($sDate) {
+            $aDateParams = explode('/', $sDate);
+        }
+
+        $oCalendar = $this->_createObjectCalendar((int)$aDateParams[0], (int)$aDateParams[1]);
+        $oCalendar->setBlockId($iBlockID);
+        $oCalendar->setDynamicUrl($sDynamicUrl);
+
+        return $oCalendar->display($isMiniMode);
+    }
     function servicePopularBlock($iStart = 0, $iPerPage = 0) {
     function servicePopularBlock($iStart = 0, $iPerPage = 0) {
         if(empty($iPerPage))
         if(empty($iPerPage))
             $iPerPage = $this->_oConfig->getPerPage();
             $iPerPage = $this->_oConfig->getPerPage();
@@ -343,7 +393,7 @@ class BxDolTextModule extends BxDolModule {
         ));
         ));
     }
     }
     function serviceGetSubscriptionParams($sUnit, $sAction, $iObjectId) {
     function serviceGetSubscriptionParams($sUnit, $sAction, $iObjectId) {
-        $sUnit = str_replace('bx_', '_', $sUnit);
+        $sUnit = str_replace('bx_', '', $sUnit);
         if(empty($sAction))
         if(empty($sAction))
             $sAction = 'main';
             $sAction = 'main';
 
 
@@ -351,7 +401,7 @@ class BxDolTextModule extends BxDolModule {
 
 
         return array(
         return array(
             'template' => array(
             'template' => array(
-                'Subscription' => _t($sUnit . '_sbs_' . $sAction, $aItem['caption']),
+                'Subscription' => _t('_' . $sUnit . '_sbs_' . $sAction, $aItem['caption']),
                 'ViewLink' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri()  . 'view/' . $aItem['uri']
                 'ViewLink' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri()  . 'view/' . $aItem['uri']
             )
             )
         );
         );
@@ -419,6 +469,22 @@ class BxDolTextModule extends BxDolModule {
 
 
         return !empty($iId) ? $this->_actDelete($iId) : false;
         return !empty($iId) ? $this->_actDelete($iId) : false;
     }
     }
+    function actionSharePopup($iEntry) {
+        header('Content-type:text/html;charset=utf-8');
+
+        $sUri = $this->_oConfig->getUri();
+        $aEntry = $this->_oDb->getEntries(array('sample_type' => 'id', 'id' => (int)$iEntry));
+        if(!$aEntry) {
+            echo MsgBox(_t('_' . $sUri . '_msg_no_results'));
+            exit;
+        }
+
+        $sEntryUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aEntry['EntryUri'];
+
+        require_once (BX_DIRECTORY_PATH_INC . "shared_sites.inc.php");        
+        echo getSitesHtml($sEntryUrl);
+        exit;
+    }
     function actionArchive($iStart = 0, $iPerPage = 0) {
     function actionArchive($iStart = 0, $iPerPage = 0) {
         $sUri = $this->_oConfig->getUri();
         $sUri = $this->_oConfig->getUri();
 
 
@@ -504,10 +570,11 @@ class BxDolTextModule extends BxDolModule {
     }
     }
     function actionCategories() {
     function actionCategories() {
 		$sUri = $this->_oConfig->getUri();
 		$sUri = $this->_oConfig->getUri();
-		$oCategories = new BxTemplCategoriesModule(array('type' => 'bx_' . $sUri), _t('_categ_users'), BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'category');
+        $oCategories = new BxTemplCategoriesModule(array('type' => $this->_oConfig->getCategoriesSystemName()), _t('_categ_users'), BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'categories');
 
 
 		$aParams = array(
 		$aParams = array(
 			'index' => 1,
 			'index' => 1,
+            'css' => array('view.css'),
 			'title' => array(
 			'title' => array(
 				'page' => _t('_' . $sUri . '_pcaption_categories')
 				'page' => _t('_' . $sUri . '_pcaption_categories')
 			),
 			),
@@ -526,6 +593,7 @@ class BxDolTextModule extends BxDolModule {
             list($sCategoryDisplay, $sContent) = $this->getCategoryContent($sCategory, $iPage, $iPerPage);
             list($sCategoryDisplay, $sContent) = $this->getCategoryContent($sCategory, $iPage, $iPerPage);
 
 
         $aParams = array(
         $aParams = array(
+            'css' => array('view.css'),
             'title' => array(
             'title' => array(
                 'page' => _t('_' . $sUri . '_pcaption_category', $sCategoryDisplay),
                 'page' => _t('_' . $sUri . '_pcaption_category', $sCategoryDisplay),
                 'block' => _t('_' . $sUri . '_bcaption_category', $sCategoryDisplay)
                 'block' => _t('_' . $sUri . '_bcaption_category', $sCategoryDisplay)
@@ -543,7 +611,7 @@ class BxDolTextModule extends BxDolModule {
     }
     }
     function actionTags() {
     function actionTags() {
         $sUri = $this->_oConfig->getUri();
         $sUri = $this->_oConfig->getUri();
-        $oTags = new BxTemplTagsModule(array('type' => 'bx_' . $sUri, 'orderby' => 'popular'), _t('_' . $sUri . '_bcaption_all_tags'), BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'tags');
+        $oTags = new BxTemplTagsModule(array('type' => $this->_oConfig->getTagsSystemName(), 'orderby' => 'popular'), _t('_' . $sUri . '_bcaption_all_tags'), BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'tags');
 
 
         $aParams = array(
         $aParams = array(
             'index' => 1,
             'index' => 1,
@@ -596,6 +664,9 @@ class BxDolTextModule extends BxDolModule {
         );
         );
         $this->_oTemplate->getPageCode($aParams);
         $this->_oTemplate->getPageCode($aParams);
     }
     }
+    function actionHome() {
+        $this->actionIndex();
+    }
     function actionIndex() {
     function actionIndex() {
         $sUri = $this->_oConfig->getUri();
         $sUri = $this->_oConfig->getUri();
         $oPage = bx_instance($this->_oConfig->getClassPrefix() . 'PageMain', array($this), $this->_aModule);
         $oPage = bx_instance($this->_oConfig->getClassPrefix() . 'PageMain', array($this), $this->_aModule);
@@ -686,6 +757,85 @@ class BxDolTextModule extends BxDolModule {
         $this->_oTemplate->getPageCodeAdmin($aParams);
         $this->_oTemplate->getPageCodeAdmin($aParams);
     }
     }
 
 
+    /**
+     * View list of latest entries for mobile app
+     */
+    function actionMobileLatestEntries($iPage = 1) {
+        $sUri = $this->_oConfig->getUri();
+
+        $iPerPage = 10;
+        $iPage = (int)$iPage;
+        if ($iPage < 1)
+            $iPage = 1;
+
+        bx_import('BxDolMobileTemplate');
+        $oMobileTemplate = new BxDolMobileTemplate($this->_oConfig, $this->_oDb);
+        $oMobileTemplate->pageStart();
+
+        $sCaption = _t('_' . $sUri . '_bcaption_latest');
+
+        $aParams = array(
+            'sample_type' => 'archive',
+            'sample_params' => '',
+            'viewer_type' => $this->_oTextData->getViewerType(),
+            'start' => ($iPage - 1) * $iPerPage,
+            'count' => $iPerPage,
+            'filter_value' => '',
+        );
+        $iTotalCount = $this->_oDb->getCount($aParams);
+        $aEntries = $iTotalCount ? $this->_oDb->getEntries($aParams) : array();
+
+        if (empty($aEntries)) {
+            $oMobileTemplate->displayNoData($sCaption);
+            return;
+        }
+
+        foreach ($aEntries as $aEntry) {
+            $aVars = array (
+                'content' => '<h2>' . $aEntry['caption'] . '</h2>' . getLocaleDate($aEntry['when_uts'], BX_DOL_LOCALE_DATE),
+                'url' => bx_js_string(BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'mobile_entry/' . $aEntry['id']),
+            );
+            echo $oMobileTemplate->parseHtmlByName('mobile_row.html', $aVars);
+        }
+
+        bx_import('BxDolPaginate');
+        $oPaginate = new BxDolPaginate(array(
+            'page_url' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'mobile_latest_entries/{page}',
+            'count' => $iTotalCount,
+            'per_page' => $iPerPage,
+            'page' => $iPage,
+        ));
+        echo $oPaginate->getMobilePaginate();
+
+        $oMobileTemplate->pageCode($sCaption, false);
+    }
+
+    /**
+     * Entry view page for mobile app
+     */
+    function actionMobileEntry($iId) {
+        bx_import('BxDolMobileTemplate');
+        $oMobileTemplate = new BxDolMobileTemplate($this->_oConfig, $this->_oDb);
+        $oMobileTemplate->pageStart();
+
+        $aParams = array(
+            'sample_type' => 'id',
+            'id' => (int)$iId,
+        );
+        $aEntry = $this->_oDb->getEntries($aParams);
+
+        if (empty($aEntry)) {
+            $oMobileTemplate->displayPageNotFound();
+            return;
+        }
+
+        echo '<h1>' . $aEntry['caption'] . '</h1>';
+        echo getLocaleDate($aEntry['when_uts'], BX_DOL_LOCALE_DATE);
+        echo $aEntry['content'];
+
+        $oMobileTemplate->pageCode($aEntry['caption']);
+    }
+
     /**
     /**
      * Common methods
      * Common methods
      */
      */
@@ -701,7 +851,7 @@ class BxDolTextModule extends BxDolModule {
             foreach($aIds as $iId) {
             foreach($aIds as $iId) {
                 //--- Entry -> Featured for Alerts Engine ---//
                 //--- Entry -> Featured for Alerts Engine ---//
                 bx_import('BxDolAlerts');
                 bx_import('BxDolAlerts');
-                $oAlert = new BxDolAlerts('bx_' . $this->_oConfig->getUri(), 'featured', $iId, BxDolTextData::getAuthorId());
+                $oAlert = new BxDolAlerts($this->_oConfig->getAlertsSystemName(), 'featured', $iId, BxDolTextData::getAuthorId());
                 $oAlert->alert();
                 $oAlert->alert();
                 //--- Entry -> Featured for Alerts Engine ---//
                 //--- Entry -> Featured for Alerts Engine ---//
             }
             }
@@ -719,18 +869,18 @@ class BxDolTextModule extends BxDolModule {
         if($bResult)
         if($bResult)
             foreach($aIds as $iId) {
             foreach($aIds as $iId) {
                 //--- Entry -> Publish/Unpublish for Alerts Engine ---//
                 //--- Entry -> Publish/Unpublish for Alerts Engine ---//
-                $oAlert = new BxDolAlerts('bx_' . $this->_oConfig->getUri(), ($bPositive ? 'publish' : 'unpublish'), $iId, BxDolTextData::getAuthorId());
+                $oAlert = new BxDolAlerts($this->_oConfig->getAlertsSystemName(), ($bPositive ? 'publish' : 'unpublish'), $iId, BxDolTextData::getAuthorId());
                 $oAlert->alert();
                 $oAlert->alert();
                 //--- Entry -> Publish/Unpublish for Alerts Engine ---//
                 //--- Entry -> Publish/Unpublish for Alerts Engine ---//
 
 
                 //--- Reparse Global Tags ---//
                 //--- Reparse Global Tags ---//
                 $oTags = new BxDolTags();
                 $oTags = new BxDolTags();
-                $oTags->reparseObjTags('bx_' . $this->_oConfig->getUri(), $iId);
+                $oTags->reparseObjTags($this->_oConfig->getTagsSystemName(), $iId);
                 //--- Reparse Global Tags ---//
                 //--- Reparse Global Tags ---//
 
 
                 //--- Reparse Global Categories ---//
                 //--- Reparse Global Categories ---//
                 $oCategories = new BxDolCategories();
                 $oCategories = new BxDolCategories();
-                $oCategories->reparseObjTags('bx_' . $this->_oConfig->getUri(), $iId);
+                $oCategories->reparseObjTags($this->_oConfig->getCategoriesSystemName(), $iId);
                 //--- Reparse Global Categories ---//
                 //--- Reparse Global Categories ---//
             }
             }
 
 
@@ -751,20 +901,20 @@ class BxDolTextModule extends BxDolModule {
 
 
             foreach($aIds as $iId) {
             foreach($aIds as $iId) {
                 //--- Entry -> Delete for Alerts Engine ---//
                 //--- Entry -> Delete for Alerts Engine ---//
-                $oAlert = new BxDolAlerts('bx_' . $this->_oConfig->getUri(), 'delete', $iId, BxDolTextData::getAuthorId());
+                $oAlert = new BxDolAlerts($this->_oConfig->getAlertsSystemName(), 'delete', $iId, BxDolTextData::getAuthorId());
                 $oAlert->alert();
                 $oAlert->alert();
                 //--- Entry -> Delete for Alerts Engine ---//
                 //--- Entry -> Delete for Alerts Engine ---//
 
 
                 //--- Reparse Global Tags ---//
                 //--- Reparse Global Tags ---//
-                $oTags->reparseObjTags('bx_' . $this->_oConfig->getUri(), $iId);
+                $oTags->reparseObjTags($this->_oConfig->getTagsSystemName(), $iId);
                 //--- Reparse Global Tags ---//
                 //--- Reparse Global Tags ---//
 
 
                 //--- Reparse Global Categories ---//
                 //--- Reparse Global Categories ---//
-                $oCategories->reparseObjTags('bx_' . $this->_oConfig->getUri(), $iId);
+                $oCategories->reparseObjTags($this->_oConfig->getCategoriesSystemName(), $iId);
                 //--- Reparse Global Categories ---//
                 //--- Reparse Global Categories ---//
 
 
                 //--- Remove all subscriptions ---//
                 //--- Remove all subscriptions ---//
-                $oSubscription->unsubscribe(array('type' => 'object_id', 'unit' => 'bx_' . $this->_oConfig->getUri(), 'object_id' => $iId));
+                $oSubscription->unsubscribe(array('type' => 'object_id', 'unit' => $this->_oConfig->getSubscriptionsSystemName(), 'object_id' => $iId));
                 //--- Remove all subscriptions ---//
                 //--- Remove all subscriptions ---//
             }
             }
         }
         }
@@ -776,5 +926,8 @@ class BxDolTextModule extends BxDolModule {
     function _isVotesAllowed(&$aEntry) {
     function _isVotesAllowed(&$aEntry) {
         return true;
         return true;
     }
     }
+    function _isShareAllowed(&$aEntry) {
+        return true;
+    }
 }
 }
 ?>
 ?>

+ 10 - 1
inc/classes/BxDolTextPageMain.php

@@ -33,7 +33,7 @@ class BxDolTextPageMain extends BxDolPageView {
         $this->_oObject = $oObject;
         $this->_oObject = $oObject;
     }
     }
     function getBlockCode_Featured() {
     function getBlockCode_Featured() {
-        return $this->_oObject->serviceFeaturedBlock();
+        return array($this->_oObject->serviceFeaturedBlock(), array(), array(), true);
     }
     }
     function getBlockCode_Latest() {
     function getBlockCode_Latest() {
         bx_import('BxDolTemplate');
         bx_import('BxDolTemplate');
@@ -46,5 +46,14 @@ class BxDolTextPageMain extends BxDolPageView {
 
 
         return array($this->_oObject->serviceArchiveBlock(), $aTopMenu, array(), true, 'getBlockCaptionMenu');
         return array($this->_oObject->serviceArchiveBlock(), $aTopMenu, array(), true, 'getBlockCaptionMenu');
     }
     }
+    function getBlockCode_Categories($iBlockId) {
+        return array($this->_oObject->serviceCategoriesBlock($iBlockId), array(), array(), true);
+    }
+    function getBlockCode_Tags($iBlockId) {
+        return array($this->_oObject->serviceTagsBlock($iBlockId), array(), array(), true);
+    }
+    function getBlockCode_Calendar($iBlockId) {
+        return array($this->_oObject->serviceGetCalendarBlock($iBlockId, array('mini_mode' => true)), array(), array(), true);
+    }
 }
 }
 ?>
 ?>

+ 8 - 4
inc/classes/BxDolTextPageView.php

@@ -36,16 +36,20 @@ class BxDolTextPageView extends BxDolPageView {
         $this->_oObject = $oObject;
         $this->_oObject = $oObject;
     }
     }
     function getBlockCode_Content() {
     function getBlockCode_Content() {
-        return $this->_oObject->serviceViewBlock($this->_sName);
+        return $this->_oObject->getBlockView($this->_sName);
     }
     }
     function getBlockCode_Comment() {
     function getBlockCode_Comment() {
-        return $this->_oObject->serviceCommentBlock($this->_sName);
+        return $this->_oObject->getBlockComment($this->_sName);
     }
     }
     function getBlockCode_Vote() {
     function getBlockCode_Vote() {
-        return $this->_oObject->serviceVoteBlock($this->_sName);
+        $sContent = $this->_oObject->getBlockVote($this->_sName);
+        return !empty($sContent) ? array($sContent, array(), array(), false) : '';
     }
     }
     function getBlockCode_Action() {
     function getBlockCode_Action() {
-        return $this->_oObject->serviceActionBlock($this->_sName);
+        return $this->_oObject->getBlockAction($this->_sName);
+    }
+    function getBlockCode_SocialSharing() {
+        return $this->_oObject->getBlockSocialSharing($this->_sName);
     }
     }
 }
 }
 ?>
 ?>

+ 10 - 6
inc/classes/BxDolTextSearchResult.php

@@ -52,18 +52,22 @@ class BxDolTextSearchResult extends BxTemplSearchResultText {
 
 
         $this->_oModule = $oModule;
         $this->_oModule = $oModule;
 
 
-        $sModuleUri = $this->_oModule->_oConfig->getUri();
-        $this->aCurrent['name'] = 'bx_' . $sModuleUri;
-        $this->aCurrent['title'] = '_' . $sModuleUri . '_lcaption_search_object';
+        $this->aCurrent['name'] = $this->_oModule->_oConfig->getSearchSystemName();
+        $this->aCurrent['title'] = '_' . $this->_oModule->_oConfig->getUri() . '_lcaption_search_object';
         $this->aCurrent['table'] = $this->_oModule->_oDb->getPrefix() . 'entries';
         $this->aCurrent['table'] = $this->_oModule->_oDb->getPrefix() . 'entries';
     }
     }
 
 
     function displaySearchUnit($aData) {
     function displaySearchUnit($aData) {
-        return $this->_oModule->_oTemplate->displayList(array(
+        $aEntries = $this->_oModule->_oDb->getEntries(array(
             'sample_type' => 'search_unit',
             'sample_type' => 'search_unit',
-            'viewer_type' => 0,
             'uri' => $aData['uri']
             'uri' => $aData['uri']
         ));
         ));
+
+        $aParams = array(
+            'sample_type' => 'search_unit',
+            'viewer_type' => $this->_oModule->_oTextData->getViewerType()
+        );
+        return $this->_oModule->_oTemplate->displayItem($aParams, array_shift($aEntries));
     }
     }
 
 
     function displayResultBlock() {
     function displayResultBlock() {
@@ -73,7 +77,7 @@ class BxDolTextSearchResult extends BxTemplSearchResultText {
         if($this->aCurrent['paginate']['totalNum'] == 0)
         if($this->aCurrent['paginate']['totalNum'] == 0)
             $sResult = MsgBox(_t('_' . $sModuleUri . '_msg_no_results'));
             $sResult = MsgBox(_t('_' . $sModuleUri . '_msg_no_results'));
 
 
-        return $sResult;
+        return $this->_oModule->_oTemplate->parseHtmlByName('default_margin.html', array('content' => $sResult));
     }
     }
 
 
     function addCustomParts() {
     function addCustomParts() {

+ 37 - 0
inc/classes/BxDolTextSiteMaps.php

@@ -0,0 +1,37 @@
+<?php
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ */
+
+bx_import('BxDolSiteMaps');
+bx_import('BxDolPrivacy');
+
+/**
+ * Sitemaps generator for News
+ */
+class BxDolTextSiteMaps extends BxDolSiteMaps
+{
+    protected $_oModule;
+
+    protected function __construct($aSystem, &$oModule)
+    {
+        parent::__construct($aSystem);
+
+        $this->_oModule = $oModule;
+        $this->_aQueryParts = array (
+            'fields' => "`id`, `uri`, `when`", // fields list
+            'field_date' => "when", // date field name
+            'field_date_type' => "timestamp", // date field type
+            'table' => "`" . $this->_oModule->_oConfig->getDbPrefix() . "entries`", // table name
+            'join' => "", // join SQL part
+            'where' => "AND `status` = '" . BX_TD_STATUS_ACTIVE . "'", // SQL condition, without WHERE
+            'order' => " `when` ASC ", // SQL order, without ORDER BY
+        );
+    }
+
+    protected function _genUrl ($a)
+    {
+        return BX_DOL_URL_ROOT . $this->_oModule->_oConfig->getBaseUri() . 'view/' . $a['uri'];
+    }
+}

+ 27 - 50
inc/classes/BxDolTextTemplate.php

@@ -97,60 +97,49 @@ class BxDolTextTemplate extends BxDolModuleTemplate {
         $iStart = isset($aParams['start']) ? (int)$aParams['start'] : -1;
         $iStart = isset($aParams['start']) ? (int)$aParams['start'] : -1;
         $iPerPage = isset($aParams['count']) ? (int)$aParams['count'] : -1;
         $iPerPage = isset($aParams['count']) ? (int)$aParams['count'] : -1;
         $bShowEmpty = isset($aParams['show_empty']) ? $aParams['show_empty'] : true;
         $bShowEmpty = isset($aParams['show_empty']) ? $aParams['show_empty'] : true;
-        $bAdminPanel = $iViewerType == BX_TD_VIEWER_TYPE_ADMIN && ((isset($aParams['admin_panel']) && $aParams['admin_panel']) || $sSampleType == 'admin');
 
 
         $sModuleUri = $this->_oConfig->getUri();
         $sModuleUri = $this->_oConfig->getUri();
         $aEntries = $this->_oDb->getEntries($aParams);
         $aEntries = $this->_oDb->getEntries($aParams);
         if(empty($aEntries))
         if(empty($aEntries))
             return $bShowEmpty ? MsgBox(_t('_' . $sModuleUri . '_msg_no_results')) : "";
             return $bShowEmpty ? MsgBox(_t('_' . $sModuleUri . '_msg_no_results')) : "";
 
 
-        $oTags = new BxDolTags();
-        $oCategories = new BxDolCategories();
-
-        //--- Language translations ---//
-        $sLKLinkPublish = _t('_' . $sModuleUri . '_lcaption_publish');
-        $sLKLinkEdit = _t('_' . $sModuleUri . '_lcaption_edit');
-        $sLKLinkDelete = _t('_' . $sModuleUri . '_lcaption_delete');
-
         $sBaseUri = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri();
         $sBaseUri = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri();
         $sJsMainObject = $this->_oConfig->getJsObject();
         $sJsMainObject = $this->_oConfig->getJsObject();
 
 
-        $aResult['sample'] = $sSampleType;
-        $aResult['bx_repeat:entries'] = array();
-        foreach($aEntries as $aEntry) {
-            $sVotes = "";
+        $sList = '';
+        foreach($aEntries as $aEntry)
+            $sList .= $this->displayItem($aParams, $aEntry);
 
 
-            if($this->_oConfig->isVotesEnabled()) {
-                $oVotes = $this->_oModule->_createObjectVoting($aEntry['id']);
-                $sVotes = $oVotes->getJustVotingElement(0, $aEntry['id']);
-            }
-
-            $aTags = $oTags->explodeTags($aEntry['tags']);
-            $aCategories = $oCategories->explodeTags($aEntry['categories']);
+        $sPaginate = '';
+        if(!in_array($sSampleType, array('id', 'uri', 'view', 'search_unit'))) {
+            if(!empty($sSampleType))
+                $this->_updatePaginate($aParams);
 
 
-            $aTagItems = array();
-            foreach($aTags as $sTag) {
-                $sTag = trim($sTag);
-                $aTagItems[] = array('href' => $sBaseUri . 'tag/' . title2uri($sTag), 'title' => $sTag);
+            $sPaginate = $this->oPaginate->getPaginate($iStart, $iPerPage);
             }
             }
 
 
-            $aCategoryItems = array();
-            foreach($aCategories as $sCategory) {
-                $sCategory = trim($sCategory);
-                $aCategoryItems[] = array('href' => $sBaseUri . 'category/' . title2uri($sCategory), 'title' => $sCategory);
-            }
+        return $this->parseHtmlByName('list.html', array(
+            'sample' => $sSampleType,
+            'list' => $sList,
+            'paginate' => $sPaginate,
+            'loading' => LoadingBox($sModuleUri . '-' . $sSampleType . '-loading')
+        ));
+    }
+    function displayItem($aParams, &$aEntry) {
+        $sSampleType = $aParams['sample_type'];
+        $iViewerType = $aParams['viewer_type'];
+        $bAdminPanel = $iViewerType == BX_TD_VIEWER_TYPE_ADMIN && ((isset($aParams['admin_panel']) && $aParams['admin_panel']) || $sSampleType == 'admin');
 
 
-            $aResult['bx_repeat:entries'][] = array(
+        $sModuleUri = $this->_oConfig->getUri();
+        $sLKLinkEdit = _t('_' . $sModuleUri . '_lcaption_edit');
+
+        $aTmplVars = array(
                 'id' => $this->_oConfig->getSystemPrefix() . $aEntry['id'],
                 'id' => $this->_oConfig->getSystemPrefix() . $aEntry['id'],
                 'caption' => str_replace("$", "&#36;", $aEntry['caption']),
                 'caption' => str_replace("$", "&#36;", $aEntry['caption']),
                 'class' => !in_array($sSampleType, array('view')) ? ' ' . $this->sCssPrefix . '-text-snippet' : '',
                 'class' => !in_array($sSampleType, array('view')) ? ' ' . $this->sCssPrefix . '-text-snippet' : '',
-                'date' => getLocaleDate($aEntry['when_uts'], BX_DOL_LOCALE_DATE),
-                'comments' => (int)$aEntry['cmts_count'],
-                'bx_repeat:categories' => $aCategoryItems,
-                'bx_repeat:tags' => $aTagItems,
+            'date' => _format_when($aEntry['ago']),
                 'content' => str_replace("$", "&#36;", $aEntry['content']),
                 'content' => str_replace("$", "&#36;", $aEntry['content']),
                 'link' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aEntry['uri'],
                 'link' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aEntry['uri'],
-                'voting' => $sVotes,
                 'bx_if:checkbox' => array(
                 'bx_if:checkbox' => array(
                     'condition' => $bAdminPanel,
                     'condition' => $bAdminPanel,
                     'content' => array(
                     'content' => array(
@@ -175,20 +164,8 @@ class BxDolTextTemplate extends BxDolModuleTemplate {
                     )
                     )
                 )
                 )
             );
             );
-        };
 
 
-        $aResult['paginate'] = '';
-        if(!in_array($sSampleType, array('id', 'uri', 'view', 'search_unit'))) {
-            if(!empty($sSampleType))
-                $this->_updatePaginate($aParams);
-
-            $aResult['paginate'] = $this->oPaginate->getPaginate($iStart, $iPerPage);
-        }
-
-        $aResult['loading'] = LoadingBox($sModuleUri . '-' . $sSampleType . '-loading');
-
-        $sRes = $this->parseHtmlByName('list.html', $aResult);
-        return $sRes;
+        return $this->parseHtmlByName('item.html', $aTmplVars);
     }
     }
     function getViewJs($bWrap = false) {
     function getViewJs($bWrap = false) {
         $sJsMainClass = $this->_oConfig->getJsClass();
         $sJsMainClass = $this->_oConfig->getJsClass();
@@ -202,7 +179,7 @@ class BxDolTextTemplate extends BxDolModuleTemplate {
             sAnimationEffect: '<?=$this->_oConfig->getAnimationEffect(); ?>',
             sAnimationEffect: '<?=$this->_oConfig->getAnimationEffect(); ?>',
             iAnimationSpeed: '<?=$this->_oConfig->getAnimationSpeed(); ?>'
             iAnimationSpeed: '<?=$this->_oConfig->getAnimationSpeed(); ?>'
         });
         });
-<?
+<?php
         $sContent = ob_get_clean();
         $sContent = ob_get_clean();
         return $bWrap ? $this->_wrapInTagJsCode($sContent) : $sContent;
         return $bWrap ? $this->_wrapInTagJsCode($sContent) : $sContent;
     }
     }
@@ -213,7 +190,7 @@ class BxDolTextTemplate extends BxDolModuleTemplate {
 	    $this->setPageParams(array(
 	    $this->setPageParams(array(
 	        'css_name' => isset($aParams['css']) ? $aParams['css'] : '',
 	        'css_name' => isset($aParams['css']) ? $aParams['css'] : '',
 	        'js_name' => isset($aParams['js']) ? $aParams['js'] : '',
 	        'js_name' => isset($aParams['js']) ? $aParams['js'] : '',
-            'extra_js' => isset($aParams['extra_js']) ? $aParams['extra_js'] : '',
+                'extra_js' => isset($aParams['extra_js']) ? $aParams['extra_js'] : '',
 	        'header' => isset($aParams['title']['page']) ? $aParams['title']['page'] : '',
 	        'header' => isset($aParams['title']['page']) ? $aParams['title']['page'] : '',
 	        'header_text' => isset($aParams['title']['block']) ? $aParams['title']['block'] : '',
 	        'header_text' => isset($aParams['title']['block']) ? $aParams['title']['block'] : '',
 	    ));
 	    ));

+ 0 - 1
inc/classes/BxDolTwigFormBroadcast.php

@@ -80,7 +80,6 @@ class BxDolTwigFormBroadcast extends BxTemplFormView {
                     'type' => 'submit',
                     'type' => 'submit',
                     'name' => 'submit_form',
                     'name' => 'submit_form',
                     'value' => _t('_Submit'),
                     'value' => _t('_Submit'),
-                    'colspan' => true,
                 ),
                 ),
             ),
             ),
         );
         );

+ 1 - 2
inc/classes/BxDolTwigFormInviter.php

@@ -37,7 +37,7 @@ class BxDolTwigFormInviter extends BxTemplFormView {
             $aVisitors[] = array (
             $aVisitors[] = array (
                 'Icon' => $GLOBALS['oFunctions']->getMemberIcon($r['ID'], 'left'),
                 'Icon' => $GLOBALS['oFunctions']->getMemberIcon($r['ID'], 'left'),
                 'Link' => getProfileLink($r['ID']),
                 'Link' => getProfileLink($r['ID']),
-                'NickName' => $r['NickName'],
+                'NickName' => getNickName($r['ID']),
                 'ID' => $r['ID'],
                 'ID' => $r['ID'],
             );
             );
         }
         }
@@ -96,7 +96,6 @@ class BxDolTwigFormInviter extends BxTemplFormView {
                     'type' => 'submit',
                     'type' => 'submit',
                     'name' => 'submit_form',
                     'name' => 'submit_form',
                     'value' => _t('_Submit'),
                     'value' => _t('_Submit'),
-                    'colspan' => true,
                 ),
                 ),
             ),
             ),
         );
         );

+ 23 - 30
inc/classes/BxDolTwigModule.php

@@ -347,7 +347,7 @@ class BxDolTwigModule extends BxDolModule {
             $aTemplate = $oEmailTemplate->getTemplate($this->_sPrefix . '_broadcast');
             $aTemplate = $oEmailTemplate->getTemplate($this->_sPrefix . '_broadcast');
             $aTemplateVars = array (
             $aTemplateVars = array (
                 'BroadcastTitle' => $this->_oDb->unescape($oForm->getCleanValue ('title')),
                 'BroadcastTitle' => $this->_oDb->unescape($oForm->getCleanValue ('title')),
-                'BroadcastMessage' => $this->_oDb->unescape($oForm->getCleanValue ('message')),
+                'BroadcastMessage' => nl2br($this->_oDb->unescape($oForm->getCleanValue ('message'))),
                 'EntryTitle' => $aDataEntry[$this->_oDb->_sFieldTitle],
                 'EntryTitle' => $aDataEntry[$this->_oDb->_sFieldTitle],
                 'EntryUrl' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aDataEntry[$this->_oDb->_sFieldUri],
                 'EntryUrl' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aDataEntry[$this->_oDb->_sFieldUri],
             );
             );
@@ -415,7 +415,7 @@ class BxDolTwigModule extends BxDolModule {
                 $aInviteUsers = bx_get('inviter_users');
                 $aInviteUsers = bx_get('inviter_users');
                 foreach ($aInviteUsers as $iRecipient) {
                 foreach ($aInviteUsers as $iRecipient) {
                     $aRecipient = getProfileInfo($iRecipient);
                     $aRecipient = getProfileInfo($iRecipient);
-                    $aPlus = array_merge (array ('NickName' => ' ' . $aRecipient['NickName']), $aPlusOriginal);
+                    $aPlus = array_merge (array ('NickName' => ' ' . getNickName($aRecipient['ID'])), $aPlusOriginal);
                     $iSuccess += sendMail(trim($aRecipient['Email']), $aTemplate['Subject'], $aTemplate['Body'], '', $aPlus) ? 1 : 0;
                     $iSuccess += sendMail(trim($aRecipient['Email']), $aTemplate['Subject'], $aTemplate['Body'], '', $aPlus) ? 1 : 0;
                 }
                 }
             }
             }
@@ -655,6 +655,7 @@ class BxDolTwigModule extends BxDolModule {
     }
     }
 
 
     function _actionDelete ($iEntryId, $sMsgSuccess) {
     function _actionDelete ($iEntryId, $sMsgSuccess) {
+        header('Content-type:text/html;charset=utf-8');
 
 
         $iEntryId = (int)$iEntryId;
         $iEntryId = (int)$iEntryId;
         if (!($aDataEntry = $this->_oDb->getEntryByIdAndOwner($iEntryId, $this->_iProfileId, $this->isAdmin()))) {
         if (!($aDataEntry = $this->_oDb->getEntryByIdAndOwner($iEntryId, $this->_iProfileId, $this->isAdmin()))) {
@@ -681,6 +682,7 @@ class BxDolTwigModule extends BxDolModule {
     }
     }
 
 
     function _actionMarkFeatured ($iEntryId, $sMsgSuccessAdd, $sMsgSuccessRemove) {
     function _actionMarkFeatured ($iEntryId, $sMsgSuccessAdd, $sMsgSuccessRemove) {
+        header('Content-type:text/html;charset=utf-8');
 
 
         $iEntryId = (int)$iEntryId;
         $iEntryId = (int)$iEntryId;
         if (!($aDataEntry = $this->_oDb->getEntryByIdAndOwner($iEntryId, $this->_iProfileId, $this->isAdmin()))) {
         if (!($aDataEntry = $this->_oDb->getEntryByIdAndOwner($iEntryId, $this->_iProfileId, $this->isAdmin()))) {
@@ -707,6 +709,7 @@ class BxDolTwigModule extends BxDolModule {
     }
     }
 
 
     function _actionJoin ($iEntryId, $iProfileId, $sMsgAlreadyJoined, $sMsgAlreadyJoinedPending, $sMsgJoinSuccess, $sMsgJoinSuccessPending, $sMsgLeaveSuccess) {
     function _actionJoin ($iEntryId, $iProfileId, $sMsgAlreadyJoined, $sMsgAlreadyJoinedPending, $sMsgJoinSuccess, $sMsgJoinSuccessPending, $sMsgLeaveSuccess) {
+        header('Content-type:text/html;charset=utf-8');
 
 
         $iEntryId = (int)$iEntryId;
         $iEntryId = (int)$iEntryId;
         if (!($aDataEntry = $this->_oDb->getEntryByIdAndOwner($iEntryId, 0, true))) {
         if (!($aDataEntry = $this->_oDb->getEntryByIdAndOwner($iEntryId, 0, true))) {
@@ -751,6 +754,7 @@ class BxDolTwigModule extends BxDolModule {
     }
     }
 
 
     function _actionManageFansPopup ($iEntryId, $sTitle, $sFuncGetFans = 'getFans', $sFuncIsAllowedManageFans = 'isAllowedManageFans', $sFuncIsAllowedManageAdmins = 'isAllowedManageAdmins', $iMaxFans = 1000) {
     function _actionManageFansPopup ($iEntryId, $sTitle, $sFuncGetFans = 'getFans', $sFuncIsAllowedManageFans = 'isAllowedManageFans', $sFuncIsAllowedManageAdmins = 'isAllowedManageAdmins', $iMaxFans = 1000) {
+        header('Content-type:text/html;charset=utf-8');
 
 
         $iEntryId = (int)$iEntryId;
         $iEntryId = (int)$iEntryId;
         if (!($aDataEntry = $this->_oDb->getEntryByIdAndOwner ($iEntryId, 0, true))) {
         if (!($aDataEntry = $this->_oDb->getEntryByIdAndOwner ($iEntryId, 0, true))) {
@@ -770,7 +774,7 @@ class BxDolTwigModule extends BxDolModule {
             exit;
             exit;
         }
         }
 
 
-        $sActionsUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . "view/" . $aDataEntry[$this->_oDb->_sFieldUri] . '?ajax_action=';
+        $sActionsUrl = bx_append_url_params(BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . "view/" . $aDataEntry[$this->_oDb->_sFieldUri],  'ajax_action=');
         $aButtons = array (
         $aButtons = array (
             array (
             array (
                 'type' => 'submit',
                 'type' => 'submit',
@@ -813,7 +817,8 @@ class BxDolTwigModule extends BxDolModule {
         exit;
         exit;
     }
     }
 
 
-    function _actionSharePopup ($iEntryId, $sTitle) {
+    function _actionSharePopup ($iEntryId, $sTitle, $bAddTempleateExt = false) {
+        header('Content-type:text/html;charset=utf-8');
 
 
         $iEntryId = (int)$iEntryId;
         $iEntryId = (int)$iEntryId;
         if (!($aDataEntry = $this->_oDb->getEntryByIdAndOwner ($iEntryId, 0, true))) {
         if (!($aDataEntry = $this->_oDb->getEntryByIdAndOwner ($iEntryId, 0, true))) {
@@ -821,28 +826,10 @@ class BxDolTwigModule extends BxDolModule {
             exit;
             exit;
         }
         }
 
 
-        require_once (BX_DIRECTORY_PATH_INC . "shared_sites.inc.php");
         $sEntryUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aDataEntry[$this->_oDb->_sFieldUri];
         $sEntryUrl = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aDataEntry[$this->_oDb->_sFieldUri];
-        $aSitesPrepare = getSitesArray ($sEntryUrl);
-        $sIconsUrl = getTemplateIcon('digg.png');
-        $sIconsUrl = str_replace('digg.png', '', $sIconsUrl);
-        $aSites = array ();
-        foreach ($aSitesPrepare as $k => $r) {
-            $aSites[] = array (
-                'icon' => $sIconsUrl . $r['icon'],
-                'name' => $k,
-                'url' => $r['url'],
-            );
-        }
 
 
-        $aVarsContent = array (
-            'bx_repeat:sites' => $aSites,
-        );
-        $aVarsPopup = array (
-            'title' => $sTitle,
-            'content' => $this->_oTemplate->parseHtmlByName('popup_share', $aVarsContent),
-        );
-        echo $GLOBALS['oFunctions']->transBox($this->_oTemplate->parseHtmlByName('popup', $aVarsPopup), true);
+        require_once (BX_DIRECTORY_PATH_INC . "shared_sites.inc.php");        
+        echo getSitesHtml($sEntryUrl, $sTitle);
         exit;
         exit;
     }
     }
 
 
@@ -1149,12 +1136,12 @@ class BxDolTwigModule extends BxDolModule {
         if ($isAdminEntries) {
         if ($isAdminEntries) {
             $sContent = $this->_manageEntries ('admin', '', true, 'bx_twig_admin_form', array(
             $sContent = $this->_manageEntries ('admin', '', true, 'bx_twig_admin_form', array(
                 'action_delete' => $sKeyBtnDelete,
                 'action_delete' => $sKeyBtnDelete,
-            ));
+            ), '', true, 0, $sUrl);
         } else {
         } else {
             $sContent = $this->_manageEntries ('pending', '', true, 'bx_twig_admin_form', array(
             $sContent = $this->_manageEntries ('pending', '', true, 'bx_twig_admin_form', array(
                 'action_activate' => $sKeyBtnActivate,
                 'action_activate' => $sKeyBtnActivate,
                 'action_delete' => $sKeyBtnDelete,
                 'action_delete' => $sKeyBtnDelete,
-            ));
+            ), '', true, 0, $sUrl);
         }
         }
 
 
         return $sContent;
         return $sContent;
@@ -1411,8 +1398,8 @@ class BxDolTwigModule extends BxDolModule {
         return $aDataEntry;
         return $aDataEntry;
     }
     }
 
 
-
     function _processFansActions ($aDataEntry, $iMaxFans = 1000) {
     function _processFansActions ($aDataEntry, $iMaxFans = 1000) {
+        header('Content-type:text/html;charset=utf-8');
 
 
         if (false !== bx_get('ajax_action') && $this->isAllowedManageFans($aDataEntry) && 0 == strcasecmp($_SERVER['REQUEST_METHOD'], 'POST')) {
         if (false !== bx_get('ajax_action') && $this->isAllowedManageFans($aDataEntry) && 0 == strcasecmp($_SERVER['REQUEST_METHOD'], 'POST')) {
 
 
@@ -1558,13 +1545,15 @@ class BxDolTwigModule extends BxDolModule {
         $oPage = new $sClass ($this, $aProfile);
         $oPage = new $sClass ($this, $aProfile);
 
 
         // manage my data entries
         // manage my data entries
-        if ($bAjaxMode && ($_sPrefix . '_my_active') == bx_get('block')) {
+        if ($bAjaxMode && ($this->_sPrefix . '_my_active') == bx_get('block')) {
+            header('Content-type:text/html;charset=utf-8');
             echo $oPage->getBlockCode_My();
             echo $oPage->getBlockCode_My();
             exit;
             exit;
         }
         }
 
 
         // manage my pending data entries
         // manage my pending data entries
-        if ($bAjaxMode && ($_sPrefix . '_my_pending') == bx_get('block')) {
+        if ($bAjaxMode && ($this->_sPrefix . '_my_pending') == bx_get('block')) {
+            header('Content-type:text/html;charset=utf-8');
             echo $oPage->getBlockCode_Pending();
             echo $oPage->getBlockCode_Pending();
             exit;
             exit;
         }
         }
@@ -1603,9 +1592,13 @@ class BxDolTwigModule extends BxDolModule {
         defineMembershipActions (array('photos add', 'sounds add', 'videos add', 'files add'));
         defineMembershipActions (array('photos add', 'sounds add', 'videos add', 'files add'));
         if (!defined($sMembershipActionConstant))
         if (!defined($sMembershipActionConstant))
             return false;
             return false;
-        $aCheck = checkAction($_COOKIE['memberID'], constant($sMembershipActionConstant));
+        $aCheck = checkAction(getLoggedId(), constant($sMembershipActionConstant));
         return $aCheck[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED;
         return $aCheck[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED;
     }
     }
+
+    function _formatSnippetText ($aEntryData, $iMaxLen = 300) {
+        return strmaxtextlen($aEntryData[$this->_oDb->_sFieldDescription], $iMaxLen);
+    }
 }
 }
 
 
 ?>
 ?>

+ 1 - 0
inc/classes/BxDolTwigModuleDb.php

@@ -46,6 +46,7 @@ class BxDolTwigModuleDb extends BxDolModuleDb {
     var $_sTableFans = 'fans';
     var $_sTableFans = 'fans';
     var $_sTableAdmins = 'admins';
     var $_sTableAdmins = 'admins';
     var $_sFieldAllowViewTo = 'allow_view_to';
     var $_sFieldAllowViewTo = 'allow_view_to';
+    var $_sFieldCommentCount = 'comments_count';
 
 
     /**
     /**
      * Constructor.
      * Constructor.

+ 31 - 0
inc/classes/BxDolTwigPageMain.php

@@ -83,6 +83,37 @@ class BxDolTwigPageMain extends BxTemplPage {
         return $s . $sAjaxPaginate; // TODO:
         return $s . $sAjaxPaginate; // TODO:
     }
     }
 
 
+    function getBlockCode_Calendar($iBlockID, $sContent)
+    {
+        $aDateParams = array(0, 0);
+        $sDate = bx_get('date');
+        if ($sDate)
+            $aDateParams = explode('/', $sDate);
+
+        bx_import ('Calendar', $this->oMain->_aModule);
+        $oCalendar = bx_instance ($this->oMain->_aModule['class_prefix'] . 'Calendar', array ((int)$aDateParams[0], (int)$aDateParams[1], $this->oDb, $this->oConfig, $this->oTemplate));
+
+        $oCalendar->setBlockId($iBlockID);
+        $oCalendar->setDynamicUrl($this->oConfig->getBaseUri() . 'home/');
+
+        return $oCalendar->display(true);
+    }
+
+    function getBlockCode_Categories($iBlockID, $sContent)
+    {
+        bx_import('BxTemplCategoriesModule');
+        $aParam = array('type' => $this->oMain->_sPrefix);
+        $oCateg = new BxTemplCategoriesModule($aParam, _t('_categ_users'), BX_DOL_URL_ROOT . $this->oConfig->getBaseUri() . 'categories');
+        return $oCateg->getBlockCode_Common($iBlockId, true);
+    }
+
+    function getBlockCode_Tags($iBlockID, $sContent)
+    {
+        bx_import('BxTemplTagsModule');
+        $aParam = array('type' => $this->oMain->_sPrefix, 'orderby' => 'popular');
+        $oTags = new BxTemplTagsModule($aParam, '', BX_DOL_URL_ROOT . $this->oConfig->getBaseUri() . 'tags');
+        $aResult = $oTags->getBlockCode_All($iBlockId);
+        return $aResult[0];
 }
 }
 
 
 ?>
 ?>

+ 4 - 0
inc/classes/BxDolViews.php

@@ -99,6 +99,10 @@ class BxDolViews extends BxDol
 
 
         if ($iRet) {
         if ($iRet) {
             $this->_triggerView();
             $this->_triggerView();
+
+            $oZ = new BxDolAlerts($this->_sSystem, 'view', $this->getId(), $iMemberId);
+            $oZ->alert();
+
             return true;
             return true;
         }
         }
 
 

+ 5 - 6
inc/classes/BxDolVoting.php

@@ -229,10 +229,10 @@ class BxDolVoting extends BxDol
         if ($this->_sSystem == 'profile' && $this->getId() == getLoggedId())
         if ($this->_sSystem == 'profile' && $this->getId() == getLoggedId())
             return false;
             return false;
 
 
-        if ($this->_oQuery->putVote ($this->getId(), $_SERVER['REMOTE_ADDR'], $iVote))
-        {
+        if ($this->_oQuery->putVote ($this->getId(), getVisitorIP(), $iVote)) {
             $this->_triggerVote();
             $this->_triggerVote();
-            $oZ = new BxDolAlerts($this->_sSystem, 'rate', $this->getId(), (int)$_COOKIE['memberID'], array ('rate' => $iVote));
+
+            $oZ = new BxDolAlerts($this->_sSystem, 'rate', $this->getId(), getLoggedId(), array ('rate' => $iVote));
             $oZ->alert();
             $oZ->alert();
             return true;
             return true;
         }
         }
@@ -244,7 +244,7 @@ class BxDolVoting extends BxDol
         bx_import('BxDolAcl');
         bx_import('BxDolAcl');
         if (isset($this->_checkActionResult))
         if (isset($this->_checkActionResult))
             return $this->_checkActionResult;
             return $this->_checkActionResult;
-        $iId = (int)$_COOKIE['memberID'];
+        $iId = getLoggedId();
         $check_res = checkAction( $iId, ACTION_ID_VOTE );
         $check_res = checkAction( $iId, ACTION_ID_VOTE );
         return ($this->_checkActionResult = ($check_res[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED));
         return ($this->_checkActionResult = ($check_res[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED));
     }
     }
@@ -252,7 +252,7 @@ class BxDolVoting extends BxDol
     function isDublicateVote ()
     function isDublicateVote ()
     {
     {
         if (!$this->isEnabled()) return false;
         if (!$this->isEnabled()) return false;
-        return $this->_oQuery->isDublicateVote ($this->getId(), $_SERVER['REMOTE_ADDR']);
+        return $this->_oQuery->isDublicateVote ($this->getId(), getVisitorIP());
     }
     }
 
 
     function getId ()
     function getId ()
@@ -347,7 +347,6 @@ class BxDolVoting extends BxDol
     /** private functions
     /** private functions
     *********************************************/
     *********************************************/
 
 
-
     function _getVoteResult ()
     function _getVoteResult ()
     {
     {
         if (empty($_GET[$this->_aSystem['post_name']]) || 0 != strcasecmp($_SERVER['REQUEST_METHOD'], 'POST'))
         if (empty($_GET[$this->_aSystem['post_name']]) || 0 != strcasecmp($_SERVER['REQUEST_METHOD'], 'POST'))

+ 9 - 13
inc/images.inc.php

@@ -64,7 +64,7 @@ function applyWatermark( $srcFilename, $dstFilename, $wtrFilename, $wtrTranspare
 /**
 /**
  * Moves and resize uploaded file
  * Moves and resize uploaded file
  *
  *
- * @param array $_FILES                        - system array of uploaded files
+ * @param array $aFiles						- system array of uploaded files
  * @param string $fname                        - name of "file" form
  * @param string $fname                        - name of "file" form
  * @param string $path_and_name                - path and name of new file to create
  * @param string $path_and_name                - path and name of new file to create
  * @param string $maxsize                    - max available size (optional)
  * @param string $maxsize                    - max available size (optional)
@@ -76,7 +76,7 @@ function applyWatermark( $srcFilename, $dstFilename, $wtrFilename, $wtrTranspare
  *
  *
  * NOTE: Source image should be in GIF, JPEG, PNG or BMP format
  * NOTE: Source image should be in GIF, JPEG, PNG or BMP format
 */
 */
-function moveUploadedImage( $_FILES, $fname, $path_and_name, $maxsize='', $imResize='true' )
+function moveUploadedImage( $aFiles, $fname, $path_and_name, $maxsize='', $imResize='true' )
 {
 {
     global $max_photo_height;
     global $max_photo_height;
     global $max_photo_width;
     global $max_photo_width;
@@ -88,17 +88,14 @@ function moveUploadedImage( $_FILES, $fname, $path_and_name, $maxsize='', $imRes
     if ( !$width )
     if ( !$width )
         $width = 400;
         $width = 400;
 
 
-    if ( $maxsize && ($_FILES[$fname]['size'] > $maxsize || $_FILES[$fname]['size'] == 0) )
-    {
-        if ( file_exists($_FILES[$fname]['tmp_name']) )
-        {
-            unlink($_FILES[$fname]['tmp_name']);
+    if ( $maxsize && ($aFiles[$fname]['size'] > $maxsize || $aFiles[$fname]['size'] == 0) ) {
+        if ( file_exists($aFiles[$fname]['tmp_name']) ) {
+            unlink($aFiles[$fname]['tmp_name']);
         }
         }
         return false;
         return false;
     }
     }
-    else
-    {
-        $scan = getimagesize($_FILES[$fname]['tmp_name']);
+    else {
+        $scan = getimagesize($aFiles[$fname]['tmp_name']);
 
 
         if ( ($scan['mime'] == 'image/jpeg' && $ext = '.jpg' ) ||
         if ( ($scan['mime'] == 'image/jpeg' && $ext = '.jpg' ) ||
             ( $scan['mime'] == 'image/gif' && $ext = '.gif' ) ||
             ( $scan['mime'] == 'image/gif' && $ext = '.gif' ) ||
@@ -106,14 +103,13 @@ function moveUploadedImage( $_FILES, $fname, $path_and_name, $maxsize='', $imRes
         {
         {
 
 
             $path_and_name .= $ext;
             $path_and_name .= $ext;
-            move_uploaded_file( $_FILES[$fname]['tmp_name'], $path_and_name );
+            move_uploaded_file( $aFiles[$fname]['tmp_name'], $path_and_name );
 
 
             if ( $imResize )
             if ( $imResize )
                 imageResize( $path_and_name, $path_and_name, $width, $height );
                 imageResize( $path_and_name, $path_and_name, $width, $height );
 
 
         }
         }
-        else
-        {
+        else {
             return IMAGE_ERROR_WRONG_TYPE;
             return IMAGE_ERROR_WRONG_TYPE;
         }
         }
     }
     }

+ 41 - 39
inc/js/classes/BxDolCmts.js

@@ -68,7 +68,7 @@ function BxDolCmts (options) {
     this._sOrder = options.sOrder == 'asc' || options.sOrder == 'desc' ? options.sOrder : 'asc'; // comments' order
     this._sOrder = options.sOrder == 'asc' || options.sOrder == 'desc' ? options.sOrder : 'asc'; // comments' order
     this._sActionsUrl = options.sBaseUrl + 'cmts.php'; // actions url address
     this._sActionsUrl = options.sBaseUrl + 'cmts.php'; // actions url address
     this._sVideoActionsUrl = options.sBaseUrl + 'flash/XML.php'; // video actions url address
     this._sVideoActionsUrl = options.sBaseUrl + 'flash/XML.php'; // video actions url address
-    this._sDefaultErrMsg = undefined == options.sDefaultErrMsg ? 'Errod Occured' : ''; // default error message
+    this._sDefaultErrMsg = undefined == options.sDefaultErrMsg ? 'Errod Occured' : options.sDefaultErrMsg; // default error message
     this._sConfirmMsg = undefined == options.sConfirmMsg ? 'Are you sure?' : options.sConfirmMsg; // confirm message
     this._sConfirmMsg = undefined == options.sConfirmMsg ? 'Are you sure?' : options.sConfirmMsg; // confirm message
 
 
     this._isEditAllowed = parseInt(undefined == options.isEditAllowed ? 0 : options.isEditAllowed); // is edit allowed
     this._isEditAllowed = parseInt(undefined == options.isEditAllowed ? 0 : options.isEditAllowed); // is edit allowed
@@ -78,16 +78,16 @@ function BxDolCmts (options) {
     this._oSavedTexts = {};
     this._oSavedTexts = {};
 
 
     this._sAnimationEffect = undefined == options.sAnimationEffect ? 'slide' : options.sAnimationEffect;
     this._sAnimationEffect = undefined == options.sAnimationEffect ? 'slide' : options.sAnimationEffect;
-    this._iAnimationSpeed = undefined == options.iAnimationSpeed ? 'slow' : options.iAnimationSpeed;
+    this._iAnimationSpeed = undefined == options.sAnimationSpeed ? 'slow' : options.sAnimationSpeed;
 
 
     //'A' Use global allow HTML param
     //'A' Use global allow HTML param
     this._sTextAreaId = undefined == options.sTextAreaId || options.sTextAreaId == '' ? 'cmtTextAreaParent' : options.sTextAreaId;
     this._sTextAreaId = undefined == options.sTextAreaId || options.sTextAreaId == '' ? 'cmtTextAreaParent' : options.sTextAreaId;
     this._iGlobAllowHtml = undefined == options.iGlobAllowHtml ? '0' : options.iGlobAllowHtml;
     this._iGlobAllowHtml = undefined == options.iGlobAllowHtml ? '0' : options.iGlobAllowHtml;
 
 
     // init post comment form (because browser remeber last inputs, we need to clear it)
     // init post comment form (because browser remeber last inputs, we need to clear it)
-    if ($('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' > .cmt-reply > .cmt-post-reply > form').length) {
-        $('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' > .cmt-reply > .cmt-post-reply > form')[0].reset();
-        $('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' > .cmt-reply > .cmt-post-reply > form > [name=CmtParent]').val(0);
+    if ($('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' .cmt-post-reply form').length) {
+    	$('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' .cmt-post-reply form')[0].reset();
+    	$('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' .cmt-post-reply form > [name=CmtParent]').val(0);    
     }
     }
 
 
     // clicks handler for ratings
     // clicks handler for ratings
@@ -118,8 +118,9 @@ BxDolCmts.prototype.changeOrder = function(oSelectDom) {
 };
 };
 BxDolCmts.prototype.expandAll = function(oCheckbox) {
 BxDolCmts.prototype.expandAll = function(oCheckbox) {
     var $this = this;
     var $this = this;
-    $.each($('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' .cmt-replies > .cmt-replies-' + ($(oCheckbox).attr('checked') ? 'show' : 'hide') + ':visible'), function(){
-        $this.toggleCmts(this, parseInt($(this).parents('li.cmt').attr('id').substr(3)));
+
+    $.each($('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' .cmts > .cmts > .cmt > .cmt-cont .cmt-replies-show'), function(){
+        $(this).trigger('click');
     });
     });
 };
 };
 BxDolCmts.prototype.changePerPage = function(oDropDown) {
 BxDolCmts.prototype.changePerPage = function(oDropDown) {
@@ -168,8 +169,8 @@ BxDolCmts.prototype.reloadComment = function(iCmtId) {
 BxDolCmts.prototype.toggleReply = function(e, iCmtParentId) {
 BxDolCmts.prototype.toggleReply = function(e, iCmtParentId) {
     //--- Get form for posting comment in Root ---//
     //--- Get form for posting comment in Root ---//
     if(iCmtParentId == 0) {
     if(iCmtParentId == 0) {
-        if($('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' > .cmt-reply').children().length) {
-            $('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' > .cmt-reply').bxdolcmtanim('toggle', this._sAnimationEffect, this._iAnimationSpeed);
+        if($('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' .cmt-reply').children().length) {
+            $('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' .cmt-reply').bxdolcmtanim('toggle', this._sAnimationEffect, this._iAnimationSpeed);
         }
         }
         else {
         else {
             var $this = this;
             var $this = this;
@@ -185,9 +186,9 @@ BxDolCmts.prototype.toggleReply = function(e, iCmtParentId) {
                 oData,
                 oData,
                 function (s) {
                 function (s) {
                     $this._loading(e, false);
                     $this._loading(e, false);
-                    $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' > .cmt-reply').append($(s).addClass('cmt-post-reply-expanded').css('display', 'none')).children('.cmt-post-reply').bxdolcmtanim('toggle', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
+                	$('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' .cmt-reply').append($(s).addClass('cmt-post-reply-expanded').css('display', 'none')).children('.cmt-post-reply').bxdolcmtanim('toggle', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
                         if($this._iGlobAllowHtml == 1)
                         if($this._iGlobAllowHtml == 1)
-                            $this.createEditor($this._iObjId, $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' .cmt-reply form').find('[name=CmtText][tinypossible=true]'));
+                        	$this.createEditor($this._iObjId, $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' .cmt-post-reply form').find('[name=CmtText][tinypossible=true]'));
                     });
                     });
                 }
                 }
             );
             );
@@ -196,8 +197,8 @@ BxDolCmts.prototype.toggleReply = function(e, iCmtParentId) {
     }
     }
     //--- Get form for posting a reply ---//
     //--- Get form for posting a reply ---//
     else {
     else {
-        if ($(e).parents('#cmt' + iCmtParentId).children('.cmt-post-reply').length)
-            $(e).parents('#cmt' + iCmtParentId).children('.cmt-post-reply').bxdolcmtanim('toggle', this._sAnimationEffect, this._iAnimationSpeed);
+		if ($('#cmt' + iCmtParentId).children('.cmt-post-reply').length)
+			$('#cmt' + iCmtParentId).children('.cmt-post-reply').bxdolcmtanim('toggle', this._sAnimationEffect, this._iAnimationSpeed);
         else {
         else {
             var $this = this;
             var $this = this;
             var oData = this._getDefaultActions();
             var oData = this._getDefaultActions();
@@ -212,7 +213,7 @@ BxDolCmts.prototype.toggleReply = function(e, iCmtParentId) {
                 oData,
                 oData,
                 function (s) {
                 function (s) {
                     $this._loading(e, false);
                     $this._loading(e, false);
-                    $(e).parents('#cmt' + iCmtParentId).children('.cmt-cont').after($(s).addClass('cmt-post-reply-expanded').css('display', 'none')).next('.cmt-post-reply').bxdolcmtanim('toggle', this._sAnimationEffect, this._iAnimationSpeed, function() {
+                	$('#cmt' + iCmtParentId).children('.cmt-cont').after($(s).addClass('cmt-post-reply-expanded').css('display', 'none')).next('.cmt-post-reply').bxdolcmtanim('toggle', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
                         if($this._iGlobAllowHtml == 1)
                         if($this._iGlobAllowHtml == 1)
                             $this.createEditor(iCmtParentId, $('#cmt' + iCmtParentId + ' > .cmt-post-reply form').find('[name=CmtText][tinypossible=true]'));
                             $this.createEditor(iCmtParentId, $('#cmt' + iCmtParentId + ' > .cmt-post-reply form').find('[name=CmtText][tinypossible=true]'));
                     });
                     });
@@ -246,13 +247,13 @@ BxDolCmts.prototype.toggleType = function(oLink) {
 BxDolCmts.prototype.toggleCmts = function(e, iCmtParentId) {
 BxDolCmts.prototype.toggleCmts = function(e, iCmtParentId) {
     //--- Load Root Comments ---//
     //--- Load Root Comments ---//
     if(iCmtParentId == 0) {
     if(iCmtParentId == 0) {
-        if(!$('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' > .cmts > ul > li').length) {
+        if(!$('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' div.cmts > ul > li').length) {
             this._getCmts(e, iCmtParentId, function (){});
             this._getCmts(e, iCmtParentId, function (){});
         }
         }
         else
         else
-            $('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' > .cmts').bxdolcmtanim('toggle', this._sAnimationEffect, this._iAnimationSpeed);
+            $('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' div.cmts').bxdolcmtanim('toggle', this._sAnimationEffect, this._iAnimationSpeed);
 
 
-        $('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' > .cmt-replies').addClass('cmt-replies-hover').children('.cmt-replies-show').toggle().siblings('.cmt-replies-hide').toggle();
+        $('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' .cmt-replies').addClass('cmt-replies-hover').children('.cmt-replies-show').toggle().siblings('.cmt-replies-hide').toggle();
     }
     }
     //--- Load Replies ---//
     //--- Load Replies ---//
     else {
     else {
@@ -326,13 +327,10 @@ BxDolCmts.prototype.cmtEdit = function(e, iCmtId) {
     else
     else
         this._oSavedTexts[iCmtId] = $('#cmt' + iCmtId + ' .cmt-body').html();
         this._oSavedTexts[iCmtId] = $('#cmt' + iCmtId + ' .cmt-body').html();
 
 
-    this._loading(e, true);
-
     jQuery.post (
     jQuery.post (
         this._sActionsUrl,
         this._sActionsUrl,
         oData,
         oData,
         function (s) {
         function (s) {
-            $this._loading (e, false);
 
 
             if ('err' == s.substring(0,3))
             if ('err' == s.substring(0,3))
                 alert (s.substring(3));
                 alert (s.substring(3));
@@ -361,16 +359,16 @@ BxDolCmts.prototype._getPaginate = function(e, iStart, iPerPage) {
     if(iPerPage != undefined)
     if(iPerPage != undefined)
         oData['CmtPerPage'] = iPerPage;
         oData['CmtPerPage'] = iPerPage;
 
 
-    if(e)
         this._loading (e, true);
         this._loading (e, true);
 
 
     jQuery.post (
     jQuery.post (
         this._sActionsUrl,
         this._sActionsUrl,
         oData,
         oData,
         function(s) {
         function(s) {
-            $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' > .cmt-show-more').bxdolcmtanim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
+            $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' .cmt-show-more').bxdolcmtanim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
                 if(s.length > 0) {
                 if(s.length > 0) {
-                    $(this).find('.paginate').replaceWith(s);
+                    $(this).find('.paginate').remove();
+                    $(this).append(s);
                     $(this).bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
                     $(this).bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
                 }
                 }
             });
             });
@@ -399,7 +397,7 @@ BxDolCmts.prototype._getCmts = function (e, iCmtParentId, onLoad, iStart, iPerPa
         oData,
         oData,
         function(s) {
         function(s) {
             if(iCmtParentId == 0) {
             if(iCmtParentId == 0) {
-                $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' > .cmts > ul').bxdolcmtanim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
+                $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' .cmts > ul').bxdolcmtanim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
                     $(this).replaceWith(s).bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
                     $(this).replaceWith(s).bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
                 });
                 });
             }
             }
@@ -419,7 +417,7 @@ BxDolCmts.prototype._getCmt = function (f, iCmtParentId, iCmtId)
     oData['action'] = 'CmtGet';
     oData['action'] = 'CmtGet';
     oData['Cmt'] = iCmtId;
     oData['Cmt'] = iCmtId;
 
 
-    var eUl = $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' > div.cmts > ul').get();
+    var eUl = $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' div.cmts > ul').get();
     this._loading (eUl, true);
     this._loading (eUl, true);
 
 
     jQuery.post (
     jQuery.post (
@@ -428,17 +426,17 @@ BxDolCmts.prototype._getCmt = function (f, iCmtParentId, iCmtId)
         function (s) {
         function (s) {
             $this._loading (eUl, false);
             $this._loading (eUl, false);
             if (iCmtParentId == 0) {
             if (iCmtParentId == 0) {
-                var oParent = $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' > div.cmts > ul');
+        	    var oParent = $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' div.cmts > ul');
 
 
                 //--- Some number of comments already loaded ---//
                 //--- Some number of comments already loaded ---//
                 if(oParent.find('li.cmt:last').length)
                 if(oParent.find('li.cmt:last').length)
                     oParent.find('li.cmt:last').after(s);
                     oParent.find('li.cmt:last').after(s);
                 //--- Some number of comments exists but NOT loaded ---//
                 //--- Some number of comments exists but NOT loaded ---//
-                else if($('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' > div.cmt-replies > a').length) {
+            	else if($('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' div.cmt-replies > a').length) {
                     $this._getCmts(f, 0, function(){
                     $this._getCmts(f, 0, function(){
-                        $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' > .cmt-replies').addClass('cmt-replies-hover').children('.cmt-replies-show').toggle().siblings('.cmt-replies-hide').toggle();
+            	        $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' .cmt-replies').addClass('cmt-replies-hover').children('.cmt-replies-show').toggle().siblings('.cmt-replies-hide').toggle();
                         var iCount = parseInt($('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' > .cmt-replies > a > span').html()) + 1;
                         var iCount = parseInt($('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' > .cmt-replies > a > span').html()) + 1;
-                        $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' > .cmt-replies > a > span').html(iCount);
+            	        $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' .cmt-replies > a > span').html(iCount);
                     });
                     });
 
 
                 }
                 }
@@ -500,7 +498,7 @@ BxDolCmts.prototype.submitComment = function (f)
         var iParentId = parseInt($(f).children('[name = CmtParent]').val());
         var iParentId = parseInt($(f).children('[name = CmtParent]').val());
         oData['module'] = 'video_comments';
         oData['module'] = 'video_comments';
         oData['action'] = 'post';
         oData['action'] = 'post';
-        oData['table'] = this._sSystemTable;
+        oData['system'] = this._sSystem; 
         oData['parent'] = iParentId;
         oData['parent'] = iParentId;
         oData['id'] = this._iObjId;
         oData['id'] = this._iObjId;
         oData['author'] = this._iAuthorId;
         oData['author'] = this._iAuthorId;
@@ -628,7 +626,7 @@ BxDolCmts.prototype._getCheckElements = function(f, oData) {
                 try {
                 try {
                     if(this.type == 'textarea' && $this._iGlobAllowHtml == 1 && typeof tinyMCE != 'undefined') {
                     if(this.type == 'textarea' && $this._iGlobAllowHtml == 1 && typeof tinyMCE != 'undefined') {
                         var ed = tinyMCE.get(this.id);
                         var ed = tinyMCE.get(this.id);
-                        var tinyValue = ed.getContent();
+			var tinyValue = $(ed.getContent()).text();
                         eval('var isValid = "'+ tinyValue +'".match(' + $this.oCmtElements[this.name]['reg'] + ');');
                         eval('var isValid = "'+ tinyValue +'".match(' + $this.oCmtElements[this.name]['reg'] + ');');
                     } else {
                     } else {
                         eval('var isValid = this.value.match(' + $this.oCmtElements[this.name]['reg'] + ');');
                         eval('var isValid = this.value.match(' + $this.oCmtElements[this.name]['reg'] + ');');
@@ -665,28 +663,28 @@ BxDolCmts.prototype._getCheckElements = function(f, oData) {
 BxDolCmts.prototype._runCountdown = function(iCmtId) {
 BxDolCmts.prototype._runCountdown = function(iCmtId) {
     if (this._isEditAllowed || this._isRemoveAllowed || 0 == this._iSecsToEdit) return;
     if (this._isEditAllowed || this._isRemoveAllowed || 0 == this._iSecsToEdit) return;
 
 
-    $('#cmt-jp-' + iCmtId + ' span').html(this._iSecsToEdit);
+	$('#cmt-jp-' + iCmtId + ' span > b').html(this._iSecsToEdit);
 
 
     window.setTimeout(this._sObjName + '.onCountdown(' + iCmtId + ',' + this._iSecsToEdit +');', 1000);
     window.setTimeout(this._sObjName + '.onCountdown(' + iCmtId + ',' + this._iSecsToEdit +');', 1000);
 };
 };
 
 
 BxDolCmts.prototype.onCountdown = function(iCmtId, i) {
 BxDolCmts.prototype.onCountdown = function(iCmtId, i) {
-    var i = parseInt($('#cmt-jp-' + iCmtId + ' span').html());
+	var i = parseInt($('#cmt-jp-' + iCmtId + ' span > b').html());	
     if(0 == --i) {
     if(0 == --i) {
         $('#cmt-jp-' + iCmtId).remove();
         $('#cmt-jp-' + iCmtId).remove();
         return;
         return;
     }
     }
     else {
     else {
-        $('#cmt-jp-' + iCmtId + ' span').html(i);
+		$('#cmt-jp-' + iCmtId + ' span > b').html(i);
         window.setTimeout(this._sObjName + '.onCountdown(' + iCmtId + ',' + i +');', 1000);
         window.setTimeout(this._sObjName + '.onCountdown(' + iCmtId + ',' + i +');', 1000);
     }
     }
 };
 };
 
 
 BxDolCmts.prototype._loading = function(e, bShow) {
 BxDolCmts.prototype._loading = function(e, bShow) {
-    if (bShow && !$(e).next('b').length)
-        $(e).after(' <b>' + aDolLang['_sys_txt_cmt_loading'] + '</b>');
-    else if (!bShow && $(e).next('b').length)
-        $(e).next('b').remove();
+    if(bShow && !$(e).parent().find('b').length)
+        $(e).parent().append(' <b>' + aDolLang['_sys_txt_cmt_loading'] + '</b>');
+    else if (!bShow && $(e).parent().find('b').length)
+    	$(e).parent().find('b').remove();
 };
 };
 
 
 BxDolCmts.prototype._err = function(e, bShow, s) {
 BxDolCmts.prototype._err = function(e, bShow, s) {
@@ -713,7 +711,7 @@ BxDolCmts.prototype.createEditor = function(iCmtId, oTextarea, bDelayed) {
     if(!oTextarea.length)
     if(!oTextarea.length)
         return;
         return;
 
 
-    if(oTextarea.attr('id') == 'undefined' || oTextarea.attr('id') == '')
+    if(oTextarea.attr('id') == undefined || oTextarea.attr('id') == '')
         oTextarea.attr('id', sId);
         oTextarea.attr('id', sId);
 
 
     if(bDelayed)
     if(bDelayed)
@@ -724,10 +722,14 @@ BxDolCmts.prototype.createEditor = function(iCmtId, oTextarea, bDelayed) {
 };
 };
 
 
 BxDolCmts.prototype.showEditor = function(sId) {
 BxDolCmts.prototype.showEditor = function(sId) {
+    if ('undefined' == typeof(tinyMCE))
+        return;
     tinyMCE.execCommand('mceAddControl', false, sId);
     tinyMCE.execCommand('mceAddControl', false, sId);
 };
 };
 
 
 BxDolCmts.prototype.toggleEditor = function(sId) {
 BxDolCmts.prototype.toggleEditor = function(sId) {
+    if ('undefined' == typeof(tinyMCE))
+        return;
     if(!tinyMCE.getInstanceById(sId))
     if(!tinyMCE.getInstanceById(sId))
         tinyMCE.execCommand('mceAddControl', false, sId);
         tinyMCE.execCommand('mceAddControl', false, sId);
     else
     else

+ 38 - 0
inc/js/common_anim.js

@@ -84,5 +84,43 @@ $.fn.bx_loading = function(sParentSelector) {
             oLoading.hide();
             oLoading.hide();
     });
     });
 };
 };
+$.fn.bx_btn_loading = function(sParentSelector) {
+	var sAttr = 'bx-loading-id';
+	var oDate = new Date();
+    return this.each(function() {
+        var oObject = $(this);
+        if(!oObject.hasClass('bx-btn'))
+        	return;
+
+        if(oObject.is(':visible')) {
+        	var oClone = oObject.attr(sAttr, oDate.getTime()).clone().attr('disabled', 'disabled').addClass('bx-btn-loading').html(aDolLang['_sys_txt_btn_loading']);
+        	oObject.hide().after(oClone);
+        }
+        else {
+        	var iId = oObject.attr(sAttr);
+        	oObject.removeAttr(sAttr).show().siblings("[" + sAttr + "='" + iId + "']").remove();
+        }
+    });
+};
+$.fn.bx_message_box = function(sMessage, iTimer, onClose) {
+    return this.each(function() {
+        var oParent = $(this);
+        
+        if(oParent.children(':first').hasClass('MsgBox'))
+            oParent.children(':first').replaceWith(sMessage);
+        else 
+            oParent.prepend(sMessage);
+
+        if(iTimer == undefined || parseInt(iTimer) == 0)
+            return;
 
 
+        setTimeout(function(oParent, onClose) {
+            oParent.children('div.MsgBox:first').bx_anim('hide', 'fade', 'slow', function(){
+                $(this).remove();
+                if(onClose != undefined)
+                    onClose();
+            });
+        }, 1000 * parseInt(iTimer), oParent, onClose);
+    });
+};
 
 

+ 11 - 1
inc/js/functions.js

@@ -6,8 +6,11 @@
 
 
 
 
 
 
-function getHtmlData( elem, url, callback, method )
+function getHtmlData( elem, url, callback, method , confirmation)
 {
 {
+    if ('undefined' != typeof(confirmation) && confirmation && !confirm(_t('_are you sure?'))) 
+        return false;
+
     // in most cases it is element ID, in other cases - object of jQuery
     // in most cases it is element ID, in other cases - object of jQuery
     if (typeof elem == 'string')
     if (typeof elem == 'string')
         elem = '#' + elem; // create selector from ID
         elem = '#' + elem; // create selector from ID
@@ -37,6 +40,10 @@ function getHtmlData( elem, url, callback, method )
 
 
             $block.html(data);
             $block.html(data);
 
 
+	        $block
+			    .css('position', blockPos) // return previous value
+		        .addWebForms();
+        
             if (typeof callback == 'function')
             if (typeof callback == 'function')
                 callback.apply($block);
                 callback.apply($block);
         });
         });
@@ -44,6 +51,9 @@ function getHtmlData( elem, url, callback, method )
     } else {
     } else {
 
 
         $block.load(url + '&_r=' + Math.random(), function() {
         $block.load(url + '&_r=' + Math.random(), function() {
+	        $(this)
+			    .css('position', blockPos) // return previous value
+		        .addWebForms();
 
 
             if (typeof callback == 'function')
             if (typeof callback == 'function')
                 callback.apply(this);
                 callback.apply(this);

+ 107 - 25
inc/utils.inc.php

@@ -136,11 +136,14 @@ function strmaxwordlen($input, $len = 100) {
 /*
 /*
  * functions for limiting maximal text length
  * functions for limiting maximal text length
  */
  */
-function strmaxtextlen($input, $len = 60) {
-    if ( strlen($input) > $len )
-        return mb_substr($input, 0, $len - 4) . "...";
-    else
-        return $input;
+function strmaxtextlen($sInput, $iMaxLen = 60) {
+    $sTail = '';
+    $s = trim(strip_tags($sInput));
+    if (mb_strlen($s) > $iMaxLen) {
+        $s = mb_substr($s, 0, $iMaxLen);
+        $sTail = '&#8230;';
+    }
+    return htmlspecialchars_adv($s) . $sTail;
 }
 }
 
 
 function html2txt($content, $tags = "") {
 function html2txt($content, $tags = "") {
@@ -626,9 +629,8 @@ function clear_xss($val) {
         $oConfig->set('Output.FlashCompat', 'true');
         $oConfig->set('Output.FlashCompat', 'true');
         $oConfig->set('HTML.FlashAllowFullScreen', 'true');
         $oConfig->set('HTML.FlashAllowFullScreen', 'true');
 
 
-        $oConfig->set('Filter.Custom', array (new HTMLPurifier_Filter_LocalMovie()));
+        $oConfig->set('Filter.Custom', array (new HTMLPurifier_Filter_LocalMovie(), new HTMLPurifier_Filter_YouTube(), new HTMLPurifier_Filter_YoutubeIframe()));
 
 
-        $oConfig->set('HTML.DefinitionID', '1');
         $oDef = $oConfig->getHTMLDefinition(true);
         $oDef = $oConfig->getHTMLDefinition(true);
         $oDef->addAttribute('a', 'target', 'Enum#_blank,_self,_target,_top');
         $oDef->addAttribute('a', 'target', 'Enum#_blank,_self,_target,_top');
 
 
@@ -650,7 +652,7 @@ function _format_when ($iSec) {
             $s .= (0 == $i || 1 == $i) ? _t('_x_hour_ago', '1', '') : _t('_x_hour_ago', $i, 's');
             $s .= (0 == $i || 1 == $i) ? _t('_x_hour_ago', '1', '') : _t('_x_hour_ago', $i, 's');
         } else {
         } else {
             $i = round($iSec/60/60/24);
             $i = round($iSec/60/60/24);
-            $s .= (0 == $i || 1 == $i) ? _t('_x_day_ago', '1', '') : _t('_x_day_ago', $i, 's');
+            $s .= (0 == $i || 1 == $i) ? _t('_yesterday') : _t('_x_day_ago', $i, 's');
         }
         }
     } else {
     } else {
         if ($iSec > -3600) {
         if ($iSec > -3600) {
@@ -661,12 +663,21 @@ function _format_when ($iSec) {
             $s .= (0 == $i || 1 == $i) ? _t('_in_x_hour', '1') : _t('_in_x_hour', -$i, 's');
             $s .= (0 == $i || 1 == $i) ? _t('_in_x_hour', '1') : _t('_in_x_hour', -$i, 's');
         } elseif ($iSec < -86400) {
         } elseif ($iSec < -86400) {
             $i = round($iSec/60/60/24);
             $i = round($iSec/60/60/24);
-            $s .= (0 == $i || 1 == $i) ? _t('_in_x_day', '1') : _t('_in_x_day', -$i, 's');
+            $s .= (0 == $i || 1 == $i) ? _t('_tomorrow') : _t('_in_x_day', -$i, 's');
         }
         }
     }
     }
     return $s;
     return $s;
 }
 }
 
 
+function _format_time($iSec, $aParams = array()) {
+    $sDivider = isset($aParams['divider']) ? $aParams['divider'] : ':';
+
+    $iSec = (int)$iSec;
+    $sFormat = $iSec > 3600 ? 'H' . $sDivider . 'i' . $sDivider . 's' : 'i' . $sDivider . 's';
+
+    return gmdate($sFormat, $iSec);
+}
+
 function defineTimeInterval($iTime) {
 function defineTimeInterval($iTime) {
     $iTime = time() - (int)$iTime;
     $iTime = time() - (int)$iTime;
     $sCode = _format_when($iTime);
     $sCode = _format_when($iTime);
@@ -743,7 +754,9 @@ function uriFilter ($s, $sEmpty = '-') {
         $s = get_mb_replace ('/([^\d^\w]+)/u', '-', $s); // latin characters only
         $s = get_mb_replace ('/([^\d^\w]+)/u', '-', $s); // latin characters only
 
 
     $s = get_mb_replace ('/([-^]+)/', '-', $s);
     $s = get_mb_replace ('/([-^]+)/', '-', $s);
-    return !$s ? $sEmpty : trim($s, " -");
+    $s = get_mb_replace ('/([-]+)$/', '', $s); // remove trailing dash
+    if (!$s) $s = '-';
+    return $s;
 }
 }
 
 
 function uriCheckUniq ($s, $sTable, $sField) {
 function uriCheckUniq ($s, $sTable, $sField) {
@@ -759,11 +772,11 @@ function get_mb_replace ($sPattern, $sReplace, $s) {
 }
 }
 
 
 function get_mb_len ($s) {
 function get_mb_len ($s) {
-    return mb_strlen($s);
+    return (function_exists('mb_strlen')) ? mb_strlen($s) : strlen($s);
 }
 }
 
 
 function get_mb_substr ($s, $iStart, $iLen) {
 function get_mb_substr ($s, $iStart, $iLen) {
-    return mb_substr ($s, $iStart, $iLen);
+    return (function_exists('mb_substr')) ? mb_substr ($s, $iStart, $iLen) : substr ($s, $iStart, $iLen);
 }
 }
 
 
 function bx_mb_substr_replace($s, $sReplace, $iPosStart, $iLength) {
 function bx_mb_substr_replace($s, $sReplace, $iPosStart, $iLength) {
@@ -1170,19 +1183,6 @@ function bx_file_get_contents($sFileUrl, $aParams = array(), $bChangeTimeout = f
     return $sResult;
     return $sResult;
 }
 }
 
 
-function bx_append_url_params ($sUrl, $mixedParams) {
-    $sParams = false == strpos($sUrl, '?') ? '?' : '&';
-        
-    if (is_array($mixedParams)) {
-        foreach($mixedParams as $sKey => $sValue)
-            $sParams .= $sKey . '=' . $sValue . '&';
-        $sParams = substr($sParams, 0, -1);
-    } else {
-        $sParams .= $mixedParams;
-    }    
-    return $sUrl . $sParams;
-}
-
 /**
 /**
  * perform write log into 'tmp/log.txt' (for any debug development)
  * perform write log into 'tmp/log.txt' (for any debug development)
  *
  *
@@ -1330,6 +1330,88 @@ function bx_encode_url_params ($a, $aExcludeKeys = array (), $aOnlyKeys = false)
     return $s;
     return $s;
 }
 }
 
 
+function bx_append_url_params ($sUrl, $mixedParams) {
+    $sParams = false == strpos($sUrl, '?') ? '?' : '&';
+
+    if (is_array($mixedParams)) {
+        foreach($mixedParams as $sKey => $sValue)
+            $sParams .= $sKey . '=' . $sValue . '&';
+        $sParams = substr($sParams, 0, -1);
+    } else {
+        $sParams .= $mixedParams;
+    }
+    return $sUrl . $sParams;
+}
+
+function bx_rrmdir($directory) {
+    if (substr($directory,-1) == "/")
+        $directory = substr($directory,0,-1);
+
+    if (!file_exists($directory) || !is_dir($directory))
+        return false;
+    elseif (!is_readable($directory))
+        return false;
+
+    if (!($directoryHandle = opendir($directory)))
+        return false;
+
+    while ($contents = readdir($directoryHandle)) {
+        if ($contents != '.' && $contents != '..') {
+            $path = $directory . "/" . $contents;
+
+            if (is_dir($path))
+                bx_rrmdir($path);
+            else
+                unlink($path);
+        }
+    }
+
+    closedir($directoryHandle);
+
+    if (!rmdir($directory))
+        return false;
+
+    return true;
+}
+
+function bx_clear_folder ($sPath, $aExts = array ()) {
+    if (substr($$sPath,-1) == "/")
+        $sPath = substr($sPath,0,-1);
+
+    if (!file_exists($sPath) || !is_dir($sPath))
+        return false;
+    elseif (!is_readable($sPath))
+        return false;
+
+    if (!($h = opendir($sPath)))
+        return false;
+
+    while ($sFile = readdir($h)) {
+        if ('.' == $sFile || '..' == $sFile)
+            continue;
+
+        $sFullPath = $sPath . '/' . $sFile;
+
+        if (is_dir($sFullPath))
+            continue;
+
+        if (!$aExts || (($sExt = pathinfo($sFullPath, PATHINFO_EXTENSION)) && in_array($sExt, $aExts)))
+            @unlink($sFullPath);
+    }
+
+    closedir($h);
+
+    return true;
+}
+
+function bx_ltrim_str ($sString, $sPrefix, $sReplace = '') {
+    if ($sReplace && substr($sString, 0, strlen($sReplace)) == $sReplace)
+        return $sString;
+    if (substr($sString, 0, strlen($sPrefix)) == $sPrefix)
+        return $sReplace . substr($sString, strlen($sPrefix));
+    return $sString;
+} 
+
 /**
 /**
  * Convert array to attributes string
  * Convert array to attributes string
  *
  *

+ 4 - 0
periodic/cron.php

@@ -10,7 +10,10 @@ define('BX_DOL_CRON_EXECUTE', '1');
 
 
 $aPathInfo = pathinfo(__FILE__);
 $aPathInfo = pathinfo(__FILE__);
 require_once ($aPathInfo['dirname'] . '/../inc/header.inc.php');
 require_once ($aPathInfo['dirname'] . '/../inc/header.inc.php');
+require_once(BX_DIRECTORY_PATH_INC . 'utils.inc.php');
+require_once(BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );
 
 
+bx_import('BxDolDb');
 
 
 function getRange($iLow, $iHigh, $iStep)
 function getRange($iLow, $iHigh, $iStep)
 {
 {
@@ -126,6 +129,7 @@ function runJob($aJob)
         $oHandler->processing();
         $oHandler->processing();
     }
     }
     else if(!empty($aJob['eval'])) {
     else if(!empty($aJob['eval'])) {
+        bx_import('BxDolService');
         eval($aJob['eval']);
         eval($aJob['eval']);
     }
     }
 }
 }