Przeglądaj źródła

#26 - refactoring - base module

Alex Trofimov 12 lat temu
rodzic
commit
a791e96bd8
25 zmienionych plików z 1605 dodań i 1289 usunięć
  1. 11 3
      inc/utils.inc.php
  2. 24 0
      modules/base/text/classes/BxBaseModTextConfig.php
  3. 31 0
      modules/base/text/classes/BxBaseModTextDb.php
  4. 221 0
      modules/base/text/classes/BxBaseModTextFormEntry.php
  5. 269 0
      modules/base/text/classes/BxBaseModTextFormsEntryHelper.php
  6. 56 0
      modules/base/text/classes/BxBaseModTextMenu.php
  7. 32 0
      modules/base/text/classes/BxBaseModTextMenuView.php
  8. 474 0
      modules/base/text/classes/BxBaseModTextModule.php
  9. 56 0
      modules/base/text/classes/BxBaseModTextPageAuthor.php
  10. 36 0
      modules/base/text/classes/BxBaseModTextPageBrowse.php
  11. 70 0
      modules/base/text/classes/BxBaseModTextPageEntry.php
  12. 91 0
      modules/base/text/classes/BxBaseModTextSearchResult.php
  13. 139 0
      modules/base/text/classes/BxBaseModTextTemplate.php
  14. 59 57
      modules/boonex/notes/classes/BxNotesConfig.php
  15. 5 13
      modules/boonex/notes/classes/BxNotesDb.php
  16. 3 198
      modules/boonex/notes/classes/BxNotesFormEntry.php
  17. 4 248
      modules/boonex/notes/classes/BxNotesFormsEntryHelper.php
  18. 3 33
      modules/boonex/notes/classes/BxNotesMenu.php
  19. 2 9
      modules/boonex/notes/classes/BxNotesMenuView.php
  20. 3 452
      modules/boonex/notes/classes/BxNotesModule.php
  21. 2 32
      modules/boonex/notes/classes/BxNotesPageAuthor.php
  22. 4 14
      modules/boonex/notes/classes/BxNotesPageBrowse.php
  23. 3 47
      modules/boonex/notes/classes/BxNotesPageEntry.php
  24. 4 71
      modules/boonex/notes/classes/BxNotesSearchResult.php
  25. 3 112
      modules/boonex/notes/classes/BxNotesTemplate.php

+ 11 - 3
inc/utils.inc.php

@@ -605,11 +605,19 @@ function bx_import($sClassName, $mixedModule = array()) {
     }
     }
 
 
     if (0 == strncmp($sClassName, 'BxBase', 6)) {
     if (0 == strncmp($sClassName, 'BxBase', 6)) {
-    	if(0 == strncmp($sClassName, 'BxBaseStudio', 12))
+    	if (0 == strncmp($sClassName, 'BxBaseMod', 9)) {
+            $aMatches = array();
+            if (preg_match('/BxBaseMod([A-Z][a-z]+)/', $sClassName, $aMatches)) {
+                require_once(BX_DIRECTORY_PATH_MODULES . 'base/' . strtolower($aMatches[1]) . '/classes/' . $sClassName . '.php');
+                return;
+            }
+    	} if (0 == strncmp($sClassName, 'BxBaseStudio', 12)) {
             require_once(BX_DOL_DIR_STUDIO_BASE . 'scripts/' . $sClassName . '.php');
             require_once(BX_DOL_DIR_STUDIO_BASE . 'scripts/' . $sClassName . '.php');
-        else
+            return;
+        } else {
             require_once(BX_DIRECTORY_PATH_BASE . 'scripts/' . $sClassName . '.php');
             require_once(BX_DIRECTORY_PATH_BASE . 'scripts/' . $sClassName . '.php');
-        return;
+            return;
+        }
     }
     }
 
 
     if (0 == strncmp($sClassName, 'BxTempl', 7) && !class_exists($sClassName)) {
     if (0 == strncmp($sClassName, 'BxTempl', 7) && !class_exists($sClassName)) {

+ 24 - 0
modules/base/text/classes/BxBaseModTextConfig.php

@@ -0,0 +1,24 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ * 
+ * @defgroup    BaseText Base classes for text modules
+ * @ingroup     DolphinModules
+ *
+ * @{
+ */
+
+bx_import('BxDolModuleConfig');
+
+class BxBaseModTextConfig extends BxDolModuleConfig 
+{
+    public $CNF;
+
+    function __construct($aModule) 
+    {
+        parent::__construct($aModule);
+    }
+}
+
+/** @} */ 

+ 31 - 0
modules/base/text/classes/BxBaseModTextDb.php

@@ -0,0 +1,31 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ * 
+ * @defgroup    BaseText Base classes for text modules
+ * @ingroup     DolphinModules
+ *
+ * @{
+ */
+
+bx_import('BxDolModuleDb');
+
+/*
+ * Module database queries
+ */
+class BxBaseModTextDb extends BxDolModuleDb
+{
+    function __construct(&$oConfig) 
+    {
+        parent::__construct($oConfig);
+    }
+
+    function getContentInfoById ($iContentId) 
+    {
+        $sQuery = $this->prepare ("SELECT `c`.* FROM `" . $this->_sPrefix . "posts` AS `c` WHERE `c`.`id` = ?", $iContentId);
+        return $this->getRow($sQuery);
+    }
+}
+
+/** @} */ 

+ 221 - 0
modules/base/text/classes/BxBaseModTextFormEntry.php

@@ -0,0 +1,221 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    BaseText Base classes for text modules
+ * @ingroup     DolphinModules
+ *
+ * @{
+ */
+
+bx_import('BxTemplFormView');
+
+/**
+ * Create/Edit entry form
+ */
+class BxBaseModTextFormEntry extends BxTemplFormView 
+{
+    protected static $MODULE;
+
+    protected $_oModule;
+
+    public function __construct($aInfo, $oTemplate = false) 
+    {
+        parent::__construct($aInfo, $oTemplate);
+        
+        $this->_oModule = BxDolModule::getInstance(self::$MODULE);
+
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        if (isset($this->aInputs[$CNF['FIELD_TEXT']])) {            
+            $this->aInputs[$CNF['FIELD_TEXT']]['attrs'] = array_merge (
+                array ('id' => $CNF['FIELD_TEXT_ID']),
+                is_array($this->aInputs[$CNF['FIELD_TEXT']]['attrs']) ? $this->aInputs[$CNF['FIELD_TEXT']]['attrs'] : array ()
+            );            
+        }
+
+        if (isset($this->aInputs[$CNF['FIELD_SUMMARY']])) {
+            $this->aInputs[$CNF['FIELD_SUMMARY']]['attrs'] = array_merge (
+                array ('id' => $CNF['FIELD_SUMMARY_ID']),
+                is_array($this->aInputs[$CNF['FIELD_SUMMARY']]['attrs']) ? $this->aInputs[$CNF['FIELD_SUMMARY']]['attrs'] : array ()
+            );            
+        }
+
+        if (isset($this->aInputs[$CNF['FIELD_PHOTO']])) {
+            $this->aInputs[$CNF['FIELD_PHOTO']]['storage_object'] = $CNF['OBJECT_STORAGE'];
+            $this->aInputs[$CNF['FIELD_PHOTO']]['uploaders'] = array('sys_simple', 'sys_html5');
+            $this->aInputs[$CNF['FIELD_PHOTO']]['images_transcoder'] = $CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW'];
+            $this->aInputs[$CNF['FIELD_PHOTO']]['multiple'] = true;
+            $this->aInputs[$CNF['FIELD_PHOTO']]['content_id'] = 0;
+            $this->aInputs[$CNF['FIELD_PHOTO']]['ghost_template'] = '';
+        }
+
+        if (isset($this->aInputs[$CNF['FIELD_ALLOW_VIEW_TO']])) {
+            bx_import('BxDolPrivacy');
+            $this->aInputs[$CNF['FIELD_ALLOW_VIEW_TO']] = BxDolPrivacy::getGroupChooser($CNF['OBJECT_PRIVACY_VIEW']);
+        }
+    }
+
+    function initChecker ($aValues = array (), $aSpecificValues = array())  
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        if (isset($this->aInputs[$CNF['FIELD_PHOTO']])) {
+
+            $aContentInfo = false;
+            if ($aValues && !empty($aValues['id'])) {
+                $aContentInfo = $this->_oModule->_oDb->getContentInfoById ($aValues['id']);
+                $this->aInputs[$CNF['FIELD_PHOTO']]['content_id'] = $aValues['id'];
+            }
+            
+            $aVars = array (
+                'name' => $this->aInputs[$CNF['FIELD_PHOTO']]['name'],
+                'content_id' => $this->aInputs[$CNF['FIELD_PHOTO']]['content_id'],
+                'editor_id' => $CNF['FIELD_TEXT_ID'],
+                'summary_id' => $CNF['FIELD_SUMMARY_ID'],
+                'thumb_id' => $aContentInfo[$CNF['FIELD_THUMB']],
+                'bx_if:set_thumb' => array (
+                    'condition' => CHECK_ACTION_RESULT_ALLOWED === $this->_oModule->checkAllowedSetThumb(),
+                    'content' => array (
+                        'name_thumb' => $CNF['FIELD_THUMB'],
+                    ),
+                ),
+            );
+            $this->aInputs[$CNF['FIELD_PHOTO']]['ghost_template'] = $this->_oModule->_oTemplate->parseHtmlByName('form_ghost_template.html', $aVars);
+        }
+        
+        return parent::initChecker($aValues, $aSpecificValues);
+    }
+
+    public function insert ($aValsToAdd = array(), $isIgnore = false) 
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        $aValsToAdd[$CNF['FIELD_AUTHOR']] = bx_get_logged_profile_id ();
+        $aValsToAdd[$CNF['FIELD_ADDED']] = time();
+        $aValsToAdd[$CNF['FIELD_CHANGED']] = time();
+
+        if (CHECK_ACTION_RESULT_ALLOWED === $this->_oModule->checkAllowedSetThumb()) {
+            $aThumb = isset($_POST[$CNF['FIELD_THUMB']]) ? bx_process_input ($_POST[$CNF['FIELD_THUMB']], BX_DATA_INT) : false;
+            $aValsToAdd[$CNF['FIELD_THUMB']] = 0;
+            if (!empty($aThumb) && is_array($aThumb) && ($iFileThumb = array_pop($aThumb)))
+                $aValsToAdd[$CNF['FIELD_THUMB']] = $iFileThumb;
+        }
+
+        if ($iContentId = parent::insert ($aValsToAdd, $isIgnore)) 
+            $this->_processFiles ($this->getCleanValue($CNF['FIELD_PHOTO']), $iContentId, true);
+        return $iContentId;
+    }
+
+    function update ($iContentId, $aValsToAdd = array(), &$aTrackTextFieldsChanges = null) 
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        $aValsToAdd[$CNF['FIELD_CHANGED']] = time();
+
+        if (CHECK_ACTION_RESULT_ALLOWED === $this->_oModule->checkAllowedSetThumb()) {
+            $aThumb = bx_process_input ($_POST[$CNF['FIELD_THUMB']], BX_DATA_INT);
+            $aValsToAdd[$CNF['FIELD_THUMB']] = 0;
+            if (!empty($aThumb) && is_array($aThumb) && ($iFileThumb = array_pop($aThumb)))
+                $aValsToAdd[$CNF['FIELD_THUMB']] = $iFileThumb;
+        }
+
+        if ($iRet = parent::update ($iContentId, $aValsToAdd, $aTrackTextFieldsChanges)) 
+            $this->_processFiles ($this->getCleanValue($CNF['FIELD_PHOTO']), $iContentId, false);
+        return $iRet;
+    }
+
+    function delete ($iContentId) 
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        // delete associated files
+
+        bx_import('BxDolStorage');
+        $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
+        if (!$oStorage)
+            return false;
+
+        $aGhostFiles = $oStorage->getGhosts (bx_get_logged_profile_id(), $iContentId);
+        if ($aGhostFiles)
+            foreach ($aGhostFiles as $aFile)
+                $this->_deleteFile($aFile['id']);
+
+        // delete db record
+
+        bx_import('BxDolView');
+		BxDolView::getObjectInstance($CNF['OBJECT_VIEWS'], $iContentId)->onObjectDelete();
+
+		bx_import('BxDolVote');
+		BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $iContentId)->onObjectDelete();
+
+		bx_import('BxDolCmts');
+		BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $iContentId)->onObjectDelete();
+
+        return parent::delete($iContentId);
+    }
+
+    function _processFiles ($mixedFileIds, $iContentId = 0, $isAssociateWithContent = false) 
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        if (!$mixedFileIds)
+            return true;
+
+        bx_import('BxDolStorage');
+        $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
+        if (!$oStorage)
+            return false;
+
+        $iProfileId = bx_get_logged_profile_id();
+
+        $aGhostFiles = $oStorage->getGhosts ($iProfileId, $isAssociateWithContent ? 0 : $iContentId);
+        if (!$aGhostFiles)
+            return true;
+
+        foreach ($aGhostFiles as $aFile) {
+            if ($aFile['private'])
+                $oStorage->setFilePrivate ($aFile['id'], 0);
+            if ($isAssociateWithContent && $iContentId)
+                $oStorage->updateGhostsContentId ($aFile['id'], $iProfileId, $iContentId);
+        }
+
+        return true;
+    }
+
+    function _deleteFile ($iFileId) 
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        if (!$iFileId)
+            return true;        
+
+        bx_import('BxDolStorage');
+        if (!($oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE'])))
+            return false;
+
+        if (!$oStorage->getFile($iFileId))
+            return true;
+
+        $iProfileId = bx_get_logged_profile_id(); 
+        return $oStorage->deleteFile($iFileId, $iProfileId);
+    }
+
+
+    function addCssJs () 
+    {
+        if (!isset($this->aParams['view_mode']) || !$this->aParams['view_mode']) {
+            if (self::$_isCssJsAdded)
+                return;
+            $this->_oModule->_oTemplate->addJs('forms.js');
+            $this->_oModule->_oTemplate->addCss('forms.css');
+        }
+
+        return parent::addCssJs ();
+    }
+
+
+}
+
+/** @} */

+ 269 - 0
modules/base/text/classes/BxBaseModTextFormsEntryHelper.php

@@ -0,0 +1,269 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    BaseText Base classes for text modules
+ * @ingroup     DolphinModules
+ *
+ * @{
+ */
+
+bx_import('BxDolProfileForms');
+bx_import('BxDolProfile');
+bx_import('BxDolForm');
+
+/**
+ * Entry forms helper functions
+ */
+class BxBaseModTextFormsEntryHelper extends BxDolProfileForms 
+{
+    protected $_oModule;
+
+    public function __construct($oModule) 
+    {
+        parent::__construct();
+        $this->_oModule = $oModule;
+    }
+
+    /**
+     * @return add data html
+     */
+    public function addDataForm () 
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        // check access
+        if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedAdd()))
+            return MsgBox($sMsg);
+
+        // check and display form
+        $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD']);
+        if (!$oForm)
+            return MsgBox(_t('_sys_txt_error_occured'));
+
+        $oForm->initChecker(); 
+
+        if (!$oForm->isSubmittedAndValid())
+            return $oForm->getCode();
+
+        // insert data into database
+        $aValsToAdd = array ();        
+        $iContentId = $oForm->insert ($aValsToAdd);
+        if (!$iContentId) {
+            if (!$oForm->isValid())
+                return $oForm->getCode();
+            else
+                return MsgBox(_t('_sys_txt_error_entry_creation'));
+        }
+
+        if (!($aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId)))
+            return MsgBox(_t('_sys_txt_error_occured'));
+
+        // perform action 
+        $this->_oModule->checkAllowedAdd(true);
+
+        // alert
+        bx_import('BxDolPrivacy');
+        bx_alert($this->_oModule->getName(), 'added', $iContentId, false, array('privacy_view' => $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]));
+
+        // redirect 
+        $this->_redirectAndExit('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $iContentId);
+    }
+
+    /**
+     * @return edit data html
+     */
+    public function editDataForm ($iContentId, $sDisplay = false) 
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        if (false === $sDisplay) 
+            $sDisplay = $CNF['OBJECT_FORM_ENTRY_DISPLAY_EDIT'];
+
+        // get content data and profile info
+        list ($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId);
+        if (!$aContentInfo)
+            return MsgBox(_t('_sys_txt_error_entry_is_not_defined')); 
+
+        // check access
+        if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedEdit($aContentInfo)))
+            return MsgBox($sMsg);
+        
+        // check and display form 
+        $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $sDisplay); 
+        if (!$oForm)
+            return MsgBox(_t('_sys_txt_error_occured'));
+
+        $oForm->initChecker($aContentInfo); 
+
+        if (!$oForm->isSubmittedAndValid())
+            return $oForm->getCode();
+
+        // update data in the DB
+        $aTrackTextFieldsChanges = null;
+        if (!$oForm->update ($aContentInfo[$CNF['FIELD_ID']], array(), $aTrackTextFieldsChanges)) {
+            if (!$oForm->isValid())
+                return $oForm->getCode();
+            else
+                return MsgBox(_t('_sys_txt_error_entry_update')); 
+        }
+
+        if (!($aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId)))
+            return MsgBox(_t('_sys_txt_error_occured'));
+
+        // change profile to 'pending' only if profile is 'active'
+        if ($oProfile->isActive() && !empty($aTrackTextFieldsChanges['changed_fields']))
+            $oProfile->disapprove(BX_PROFILE_ACTION_AUTO);
+
+        // perform action
+        $this->_oModule->checkAllowedEdit($aContentInfo, true);
+
+        // create an alert
+        bx_import('BxDolPrivacy');
+        bx_alert($this->_oModule->getName(), 'edited', $aContentInfo[$CNF['FIELD_ID']], false, array('privacy_view' => $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']])); 
+
+        // redirect 
+        $this->_redirectAndExit('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
+    }
+
+
+    /**
+     * @return delete data html
+     */
+    public function deleteDataForm ($iContentId, $sDisplay = false) 
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        if (false === $sDisplay) 
+            $sDisplay = $CNF['OBJECT_FORM_ENTRY_DISPLAY_DELETE'];
+
+        // get content data and profile info
+        list ($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId);
+        if (!$aContentInfo)
+            return MsgBox(_t('_sys_txt_error_entry_is_not_defined')); 
+
+        // check access
+        if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedDelete($aContentInfo)))
+            return MsgBox($sMsg);
+        
+        // check and display form 
+        $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $sDisplay);
+        if (!$oForm)
+            return MsgBox(_t('_sys_txt_error_occured'));
+
+        $oForm->initChecker($aContentInfo); 
+
+        if (!$oForm->isSubmittedAndValid())
+            return $oForm->getCode();
+
+        if (!$oForm->delete ($aContentInfo[$CNF['FIELD_ID']])) {
+            if (!$oForm->isValid())
+                return $oForm->getCode();
+            else
+                return MsgBox(_t('_sys_txt_error_entry_delete'));
+        }
+
+        // perform action
+        $this->_oModule->checkAllowedDelete($aContentInfo, true);
+
+        // create an alert
+        bx_alert($this->_oModule->getName(), 'deleted', $aContentInfo[$CNF['FIELD_ID']]);
+
+        // redirect 
+        $this->_redirectAndExit('page.php?i=' . $CNF['URI_HOME']);
+    }
+
+
+    /**
+     * @return view data html
+     */
+    public function viewDataForm ($iContentId) 
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        // get content data and profile info
+        list ($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId);
+        if (!$aContentInfo)
+            return MsgBox(_t('_sys_txt_error_entry_is_not_defined')); 
+
+        // check access
+        if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedView($aContentInfo)))
+            return MsgBox($sMsg);
+        
+        // get form 
+        $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $CNF['OBJECT_FORM_ENTRY_DISPLAY_VIEW']); 
+        if (!$oForm)
+            return MsgBox(_t('_sys_txt_error_occured'));
+
+        // perform action
+        $this->_oModule->checkAllowedView($aContentInfo);
+
+        // display profile
+        $oForm->initChecker($aContentInfo);
+        return $oForm->getCode();
+    }
+
+    /**
+     * @return main content text 
+     */
+    public function viewDataText ($iContentId) 
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        // get content data and profile info
+        list ($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId);
+        if (!$aContentInfo)
+            return MsgBox(_t('_sys_txt_error_entry_is_not_defined')); 
+
+        // check access
+        if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedView($aContentInfo)))
+            return MsgBox($sMsg);
+
+        return $aContentInfo[$CNF['FIELD_TEXT']];
+    }
+
+    /**
+     * @return main content text 
+     */
+    public function viewDataEntry ($iContentId) 
+    {
+        // get content data and profile info
+        list ($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId);
+        if (!$aContentInfo)
+            return MsgBox(_t('_sys_txt_error_entry_is_not_defined')); 
+
+        // check access
+        if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedView($aContentInfo)))
+            return MsgBox($sMsg);
+
+        return $this->_oModule->_oTemplate->entryText($aContentInfo);
+    }
+
+
+    /**
+     * @return array of profile object, profile info and content info
+     */
+    protected function _getProfileAndContentData ($iContentId) 
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        $aContentInfo = array();
+        $oProfile = false;
+        
+        $aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);
+        if (!$aContentInfo)
+            return array (false, false);
+
+        $oProfile = BxDolProfile::getInstance($aContentInfo[$CNF['FIELD_AUTHOR']]);
+        if (!$oProfile) {
+            bx_import('BxDolProfileUndefined');
+            $oProfile = BxDolProfileUndefined::getInstance();
+        }
+
+        return array ($oProfile, $aContentInfo);
+    }
+
+}
+
+/** @} */

+ 56 - 0
modules/base/text/classes/BxBaseModTextMenu.php

@@ -0,0 +1,56 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    BaseText Base classes for text modules
+ * @ingroup     DolphinModules
+ *
+ * @{
+ */
+
+bx_import('BxTemplMenu');
+
+/**
+ * General class for module menu.
+ */
+class BxBaseModTextMenu extends BxTemplMenu 
+{
+    protected static $MODULE;
+
+    protected $_oModule;
+    protected $_aContentInfo;
+
+    public function __construct($aObject, $oTemplate = false) 
+    {
+        parent::__construct($aObject, $oTemplate);
+
+        bx_import('BxDolModule');
+        $this->_oModule = BxDolModule::getInstance(self::$MODULE);
+    }
+
+    /**
+     * Check if menu items is visible.
+     * @param $a menu item array
+     * @return boolean
+     */ 
+    protected function _isVisible ($a) 
+    {
+        $CNF = $this->_oModule->_oConfig->CNF;
+        $sFuncCheckAccess = false;
+
+        // get custom function name to check menu item visibility
+        if (isset($CNF['MENU_ITEM_TO_METHOD'][$this->_sObject][$a['name']]))
+            $sFuncCheckAccess = $CNF['MENU_ITEM_TO_METHOD'][$this->_sObject][$a['name']];
+
+        // check custom visibility settings defined in module config class
+        if ($sFuncCheckAccess && CHECK_ACTION_RESULT_ALLOWED === call_user_func_array(array($this->_oModule, $sFuncCheckAccess), isset($this->_aContentInfo) ? array(&$this->_aContentInfo) : array()))
+            return true;
+
+        // default visible settings
+        bx_import('BxDolAcl');
+        return BxDolAcl::getInstance()->isMemberLevelInSet($a['visible_for_levels']);
+    }
+}
+
+/** @} */

+ 32 - 0
modules/base/text/classes/BxBaseModTextMenuView.php

@@ -0,0 +1,32 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    BaseText Base classes for text modules
+ * @ingroup     DolphinModules
+ *
+ * @{
+ */
+
+bx_import('BxTemplMenu');
+bx_import('Menu', 'bx_notes');
+
+/**
+ * View entry menu
+ */
+class BxBaseModTextMenuView extends BxNotesMenu
+{
+    public function __construct($aObject, $oTemplate = false) 
+    {
+        parent::__construct($aObject, $oTemplate);
+
+        $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
+
+        $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);
+        if ($this->_aContentInfo)
+            $this->addMarkers(array('content_id' => (int)$iContentId));
+    }
+}
+
+/** @} */

+ 474 - 0
modules/base/text/classes/BxBaseModTextModule.php

@@ -0,0 +1,474 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ * 
+ * @defgroup    BaseText Base classes for text modules
+ * @ingroup     DolphinModules
+ *
+ * @{
+ */
+
+bx_import ('BxDolModule');
+bx_import ('BxDolAcl');
+
+/**
+ * Base module class for text based modules
+ */
+class BxBaseModTextModule extends BxDolModule
+{
+    protected $_iProfileId;
+
+    function __construct(&$aModule) 
+    {
+        parent::__construct($aModule);
+        $this->_iProfileId = bx_get_logged_profile_id();
+    }
+
+    // ====== ACTIONS METHODS
+
+    public function actionRss ($sMode = '', $sExtra = '') 
+    {
+        if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->checkAllowedBrowse())) {
+            $this->_oTemplate->displayAccessDenied ();
+            exit;
+        }
+
+        $aParams = array ();
+        $sMode = bx_process_input($sMode);
+        switch ($sMode) {
+            case 'author':
+                $aParams = array('author' => (int)$sExtra);
+                break;
+        }
+
+        bx_import ('SearchResult', $this->_aModule);
+        $sClass = $this->_aModule['class_prefix'] . 'SearchResult';
+        $o = new $sClass($sMode, $aParams);
+
+        if ($o->isError) {
+            $this->_oTemplate->displayPageNotFound ();
+            exit;
+        }
+
+        $o->outputRSS();
+        exit;
+    }
+
+    // ====== SERVICE METHODS
+
+    /**
+     * Display pablic entries
+     * @return HTML string
+     */
+    public function serviceBrowsePublic () 
+    {
+        return $this->_serviceBrowse ('public');
+    }
+
+    /**
+     * Display featured entries
+     * @return HTML string
+     */
+    public function serviceBrowseFeatured () 
+    {
+        return $this->_serviceBrowse ('public');
+    }
+
+    /**
+     * Display entries of the author
+     * @return HTML string
+     */
+    public function serviceBrowseAuthor ($iProfileId = 0) 
+    {
+        if (!$iProfileId)
+            $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
+        if (!$iProfileId)
+            return '';
+        return $this->_serviceBrowse ('author', array('author' => $iProfileId));
+    }
+
+    /**
+     * Add entry form
+     * @return HTML string
+     */
+    public function serviceEntityCreate () 
+    {
+        bx_import('FormsEntryHelper', $this->_aModule);
+        $sClass = $this->_aModule['class_prefix'] . 'FormsEntryHelper';
+        $oFormsHelper = new $sClass($this);
+        return $oFormsHelper->addDataForm();
+    }
+
+    /**
+     * Edit entry form
+     * @return HTML string
+     */
+    public function serviceEntityEdit ($iContentId = 0) 
+    {
+        return $this->_serviceEntityForm ('editDataForm', $iContentId);
+    }
+
+    /**
+     * Delete entry form
+     * @return HTML string
+     */
+    public function serviceEntityDelete ($iContentId = 0) 
+    {
+        return $this->_serviceEntityForm ('deleteDataForm', $iContentId);
+    }
+
+    /**
+     * Entry text with some additional controls
+     */
+    public function serviceEntityTextBlock ($iContentId = 0) 
+    {
+        return $this->_serviceEntityForm ('viewDataEntry', $iContentId);
+    }
+
+    /**
+     * Additional entry info
+     */
+    public function serviceEntityInfo ($iContentId = 0) 
+    {
+        return $this->_serviceEntityForm ('viewDataForm', $iContentId);
+    }
+
+    /**
+     * Entry social sharing block
+     */
+    public function serviceEntitySocialSharing ($iContentId = 0) 
+    {
+        if (!$iContentId)
+            $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
+        if (!$iContentId)
+            return false;
+        $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
+        if (!$aContentInfo)
+            return false;
+
+        $CNF = &$this->_oConfig->CNF;
+
+        bx_import('BxDolPermalinks');
+        $sUrl = BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
+
+        $aCustomParams = false;
+        if ($aContentInfo[$CNF['FIELD_THUMB']]) {
+            bx_import('BxDolStorage');
+            $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
+            if ($oStorage && ($sImgUrl = $oStorage->getFileUrlById($aContentInfo[$CNF['FIELD_THUMB']]))) {
+                $aCustomParams = array (
+                    'img_url' => $sImgUrl,
+                    'img_url_encoded' => rawurlencode($sImgUrl),
+                );
+            }
+        }
+
+        //TODO: Rebuild using menus engine when it will be ready for such elements like Vote, Share, etc.
+        $sVotes = '';
+        bx_import('BxDolVote');
+        $oVotes = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $aContentInfo[$CNF['FIELD_ID']]);
+        if ($oVotes)
+            $sVotes = $oVotes->getElementBlock(array('show_do_vote_as_button' => true)); 
+
+        $sShare = '';
+        if (BxDolRequest::serviceExists('bx_timeline', 'get_share_element_block'))
+        	$sShare = BxDolService::call('bx_timeline', 'get_share_element_block', array(bx_get_logged_profile_id(), $this->_aModule['name'], 'added', $aContentInfo[$CNF['FIELD_ID']], array('show_do_share_as_button' => true)));
+
+        bx_import('BxTemplSocialSharing');
+		$sSocial = BxTemplSocialSharing::getInstance()->getCode($iContentId, $this->_aModule['name'], BX_DOL_URL_ROOT . $sUrl, $aContentInfo[$CNF['FIELD_TITLE']], $aCustomParams);
+
+        return $this->_oTemplate->parseHtmlByName('entry-share.html', array(
+        	'vote' => $sVotes,
+        	'share' => $sShare,
+        	'social' => $sSocial,
+        ));
+		//TODO: Rebuild using menus engine when it will be ready for such elements like Vote, Share, etc.
+    }
+
+    /**
+     * Entry comments
+     */
+    public function serviceEntityComments ($iContentId = 0) 
+    {
+        if (!$iContentId)
+            $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
+        if (!$iContentId)
+            return false;
+
+		bx_import('BxDolCmts');
+		$oCmts = BxDolCmts::getObjectInstance($this->_oConfig->CNF['OBJECT_COMMENTS'], $iContentId);
+		if(!$oCmts->isEnabled())
+			return false;
+        return $oCmts->getCommentsBlock(0, 0, false);
+    }
+
+    /**
+     * Entry author block
+     */
+    public function serviceEntityAuthor ($iContentId = 0) 
+    {
+        if (!$iContentId)
+            $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
+        if (!$iContentId)
+            return false;
+        $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
+        if (!$aContentInfo)
+            return false;
+
+        $oProfile = BxDolProfile::getInstance($aContentInfo[$this->_oConfig->CNF['FIELD_AUTHOR']]);
+        if (!$oProfile) {
+            bx_import('BxDolProfileUndefined');
+            $oProfile = BxDolProfileUndefined::getInstance();
+        }
+        return $this->_oTemplate->entryAuthor ($aContentInfo, $oProfile);
+    }
+
+    /**
+     * Entry actions block
+     */
+    public function serviceEntityActions ($iContentId = 0) 
+    {
+        if (!$iContentId)
+            $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
+        if (!$iContentId)
+            return false;
+
+        bx_import('BxTemplMenu');
+        $oMenu = BxTemplMenu::getObjectInstance($this->_oConfig->CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY']);
+        return $oMenu ? $oMenu->getCode() : false;
+    }
+
+    /**
+     * My entries actions block
+     */
+    public function serviceMyEntriesActions ($iProfileId = 0) 
+    {
+        if (!$iProfileId)
+            $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
+        if (!$iProfileId || $iProfileId != $this->_iProfileId)
+            return false;
+
+        bx_import('BxTemplMenu');
+        $oMenu = BxTemplMenu::getObjectInstance($this->_oConfig->CNF['OBJECT_MENU_ACTIONS_MY_ENTRIES']);
+        return $oMenu ? $oMenu->getCode() : false;
+    }
+
+    /**
+     * Data for Timeline
+     */
+	public function serviceGetTimelineData()
+    {
+        return array(
+            'handlers' => array(
+                array('type' => 'insert', 'alert_unit' => $this->_aModule['name'], 'alert_action' => 'added', 'module_name' => $this->_aModule['name'], 'module_method' => 'get_timeline_post', 'module_class' => 'Module',  'groupable' => 0, 'group_by' => ''),
+                array('type' => 'update', 'alert_unit' => $this->_aModule['name'], 'alert_action' => 'edited'),
+                array('type' => 'delete', 'alert_unit' => $this->_aModule['name'], 'alert_action' => 'deleted')
+            ),
+            'alerts' => array(
+                array('unit' => $this->_aModule['name'], 'action' => 'added'),
+                array('unit' => $this->_aModule['name'], 'action' => 'edited'),
+                array('unit' => $this->_aModule['name'], 'action' => 'deleted'),
+            )
+        );
+    }
+
+    /**
+     * Entry post for Timeline
+     */
+    public function serviceGetTimelinePost($aEvent)
+    {
+    	$aContentInfo = $this->_oDb->getContentInfoById($aEvent['object_id']);
+    	if(empty($aContentInfo) || !is_array($aContentInfo))
+    		return '';
+
+        $CNF = &$this->_oConfig->CNF;
+
+    	bx_import('BxDolPermalinks');
+		$sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
+
+		//--- Image(s)
+	    $sImage = '';
+        if($aContentInfo[$CNF['FIELD_THUMB']]) {
+        	bx_import('BxDolStorage');
+			$oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
+            if($oStorage)
+				$sImage = $oStorage->getFileUrlById($aContentInfo[$CNF['FIELD_THUMB']]);
+        }
+
+        //--- Votes
+        bx_import('BxDolVote');
+        $oVotes = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $aEvent['object_id']);
+
+        $aVotes = array(); 
+		if ($oVotes && $oVotes->isEnabled())
+			$aVotes = array(
+				'system' => $CNF['OBJECT_VOTES'],
+				'object_id' => $aContentInfo[$CNF['FIELD_ID']],
+				'count' => $aContentInfo['votes']
+			);
+
+        //--- Comments
+        bx_import('BxDolCmts');
+        $oCmts = BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $aEvent['object_id']);
+
+        $aComments = array(); 
+		if($oCmts->isEnabled())
+			$aComments = array(
+				'system' => $CNF['OBJECT_COMMENTS'],
+				'object_id' => $aContentInfo[$CNF['FIELD_ID']],
+				'count' => $aContentInfo['comments']
+			);
+
+    	return array(
+    		'owner_id' => $aContentInfo[$CNF['FIELD_AUTHOR']],
+    		'content' => array(
+    			'sample' => _t($CNF['T']['txt_sample_single']),
+    			'url' => $sUrl,
+    			'title' => $aContentInfo[$CNF['FIELD_TITLE']],
+    			'text' => $aContentInfo[$CNF['FIELD_TEXT']],
+    			'images' => array(
+    				array(
+    					'url' => $sUrl,
+    					'src' => $sImage
+    				)
+    			)
+    		), //a string to display or array to parse default template before displaying.
+    		'votes' => $aVotes,
+    		'comments' => $aComments,
+    		'title' => '', //may be empty.
+    		'description' => '' //may be empty. 
+    	);
+    }
+
+    // ====== PERMISSION METHODS
+
+    /**
+     * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
+     */
+    public function checkAllowedView ($aDataEntry, $isPerformAction = false) 
+    {
+        $CNF = &$this->_oConfig->CNF;
+
+        // moderator and owner always have access
+        if ($aDataEntry[$CNF['FIELD_AUTHOR']] == $this->_iProfileId || $this->_isModerator($isPerformAction))
+            return CHECK_ACTION_RESULT_ALLOWED;
+
+        // check ACL
+        $aCheck = checkActionModule($this->_iProfileId, 'view entry', $this->getName(), $isPerformAction);
+        if ($aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
+            return $aCheck[CHECK_ACTION_MESSAGE];
+
+        // check privacy 
+    	bx_import('BxDolPrivacy');
+    	$oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
+		if ($oPrivacy && !$oPrivacy->check($aDataEntry[$CNF['FIELD_ID']]))
+            return _t('_sys_access_denied_to_private_content');
+
+        return CHECK_ACTION_RESULT_ALLOWED;
+    }
+
+    /**
+     * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
+     */
+    public function checkAllowedBrowse () 
+    {
+        return CHECK_ACTION_RESULT_ALLOWED;
+    }
+
+    /**
+     * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
+     */
+    public function checkAllowedAdd ($isPerformAction = false) 
+    {
+        // check ACL
+        $aCheck = checkActionModule($this->_iProfileId, 'create entry', $this->getName(), $isPerformAction);
+        if ($aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
+            return $aCheck[CHECK_ACTION_MESSAGE];
+        return CHECK_ACTION_RESULT_ALLOWED;
+    }
+
+    /**
+     * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
+     */
+    public function checkAllowedEdit ($aDataEntry, $isPerformAction = false) 
+    {
+        // moderator and owner always have access
+        if ($aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']] == $this->_iProfileId || $this->_isModerator($isPerformAction))
+            return CHECK_ACTION_RESULT_ALLOWED;
+        return _t('_sys_txt_access_denied');
+    }
+
+    /**
+     * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
+     */
+    public function checkAllowedDelete (&$aDataEntry, $isPerformAction = false) 
+    {
+        // moderator always has access
+        if ($this->_isModerator($isPerformAction))
+            return CHECK_ACTION_RESULT_ALLOWED;
+
+        // check ACL
+        $aCheck = checkActionModule($this->_iProfileId, 'delete entry', $this->getName(), $isPerformAction);
+        if ($aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']] == $this->_iProfileId && $aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
+            return CHECK_ACTION_RESULT_ALLOWED;
+
+        return _t('_sys_txt_access_denied');
+    }
+
+    /**
+     * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
+     */
+    public function checkAllowedSetThumb () 
+    {
+        // check ACL
+        $aCheck = checkActionModule($this->_iProfileId, 'set thumb', $this->getName(), false);
+        if ($aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
+            return $aCheck[CHECK_ACTION_MESSAGE];
+        return CHECK_ACTION_RESULT_ALLOWED;
+    }
+
+    // ====== PROTECTED METHODS
+
+    protected function _isModerator ($isPerformAction = false) 
+    {
+        // check moderator ACL
+        $aCheck = checkActionModule($this->_iProfileId, 'edit any entry', $this->getName(), $isPerformAction); 
+        return $aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED;
+    }
+
+    protected function _serviceBrowse ($sMode, $aParams = false) 
+    {
+        if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->checkAllowedBrowse()))
+            return MsgBox($sMsg);
+
+        $sClass = $this->_aModule['class_prefix'] . 'SearchResult';
+        bx_import('SearchResult', $this->_aModule);
+        $o = new $sClass($sMode, $aParams);
+        
+        $o->setDisplayEmptyMsg(true);
+
+        if ($o->isError)
+            return '';
+
+        if ($s = $o->processing())
+            return $s;
+        else
+            return '';
+    }
+
+    protected function _serviceEntityForm ($sFormMethod, $iContentId = 0) 
+    {
+        if (!$iContentId)
+            $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
+        if (!$iContentId)
+            return false;
+
+        bx_import('FormsEntryHelper', $this->_aModule);
+        $sClass = $this->_aModule['class_prefix'] . 'FormsEntryHelper';
+        $oFormsHelper = new $sClass($this);
+        return $oFormsHelper->$sFormMethod((int)$iContentId);
+    }
+}
+
+/** @} */ 

+ 56 - 0
modules/base/text/classes/BxBaseModTextPageAuthor.php

@@ -0,0 +1,56 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    BaseText Base classes for text modules
+ * @ingroup     DolphinModules
+ *
+ * @{
+ */
+
+bx_import('BxTemplPage');
+bx_import('BxDolMenu');
+bx_import('BxDolProfile');
+
+/**
+ * Profile's entries page.
+ */
+class BxBaseModTextPageAuthor extends BxTemplPage 
+{
+    protected $_aProfileInfo;
+    protected $_oProfile;
+
+    public function __construct($aObject, $oTemplate = false) 
+    {
+        parent::__construct($aObject, $oTemplate);
+
+        // get profile info
+        $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
+        if ($iProfileId) {
+            $this->_oProfile = BxDolProfile::getInstance($iProfileId);
+            $this->_aProfileInfo = $this->_oProfile ? $this->_oProfile->getInfo() : false;
+        }
+
+        if (!$this->_aProfileInfo || !$this->_oProfile)
+            return;
+
+        // select view profile submenu
+        $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu');
+        if ($oMenuSubmenu) {
+            $oMenuSubmenu->setObjectSubmenu('bx_persons_view_submenu', array (
+                'title' => $this->_oProfile->getDisplayName(),
+                'link' => $this->_oProfile->getUrl(),
+                'icon' => $this->_oProfile->getIcon(),
+            ));
+        }
+
+        // add replaceable markers
+        $this->addMarkers($this->_aProfileInfo); // every profile field can be used as marker
+        $this->addMarkers(array('profile_id' => $this->_oProfile->id())); // profile id field is also suported
+        $this->addMarkers(array('display_name' => $this->_oProfile->getDisplayName())); // profile display name is also suported
+    }
+
+}
+
+/** @} */

+ 36 - 0
modules/base/text/classes/BxBaseModTextPageBrowse.php

@@ -0,0 +1,36 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    BaseText Base classes for text modules
+ * @ingroup     DolphinModules
+ *
+ * @{
+ */
+
+bx_import('BxDolModule');
+bx_import('BxTemplPage');
+
+/**
+ * Browse entries pages.
+ */
+class BxBaseModTextPageBrowse extends BxTemplPage 
+{   
+    protected static $MODULE;
+ 
+    public function __construct($aObject, $oTemplate = false) 
+    {
+        parent::__construct($aObject, $oTemplate);
+
+        $oModule = BxDolModule::getInstance(self::$MODULE);
+
+        // select module submenu
+        bx_import('BxDolMenu');
+        $oMenuSumbemu = BxDolMenu::getObjectInstance('sys_site_submenu');
+        $oMenuSumbemu->setObjectSubmenu($oModule->_oConfig->CNF['OBJECT_MENU_SUBMENU']);
+    }
+
+}
+
+/** @} */

+ 70 - 0
modules/base/text/classes/BxBaseModTextPageEntry.php

@@ -0,0 +1,70 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    BaseText Base classes for text modules
+ * @ingroup     DolphinModules
+ *
+ * @{
+ */
+
+bx_import('BxTemplPage');
+bx_import('BxDolModule');
+bx_import('BxDolMenu');
+
+/**
+ * Entry create/edit pages
+ */
+class BxBaseModTextPageEntry extends BxTemplPage 
+{    
+    protected static $MODULE;
+
+    protected $_oModule;
+    protected $_aContentInfo = false;
+
+    public function __construct($aObject, $oTemplate = false) 
+    {
+        parent::__construct($aObject, $oTemplate);
+
+        $this->_oModule = BxDolModule::getInstance(self::$MODULE);
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        // select view entry submenu
+        $oMenuSumbemu = BxDolMenu::getObjectInstance('sys_site_submenu');
+        $oMenuSumbemu->setObjectSubmenu($CNF['OBJECT_MENU_SUBMENU_VIEW_ENTRY'], $CNF['OBJECT_MENU_SUBMENU_VIEW_ENTRY_MAIN_SELECTION']);
+
+        $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
+        if ($iContentId)
+            $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);
+
+        if ($this->_aContentInfo)
+            $this->addMarkers($this->_aContentInfo); // every field can be used as marker
+
+		bx_import('BxDolView');
+		BxDolView::getObjectInstance($CNF['OBJECT_VIEWS'], $iContentId)->doView();
+    }
+
+    public function getCode () 
+    {
+        if (!$this->_aContentInfo) { // if entry is not found - display standard "404 page not found" page
+            $this->_oTemplate->displayPageNotFound();
+            exit;
+        }
+
+        if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedView($this->_aContentInfo))) {
+			$this->_oTemplate->displayAccessDenied($sMsg);
+            exit;
+        }
+        $this->_oModule->checkAllowedView($this->_aContentInfo, true);
+
+        return parent::getCode ();
+    }
+
+    protected function _getPageCacheParams () 
+    {
+        return $this->_aContentInfo[$this->_oModule->_oConfig->CNF['FIELD_ID']]; // cache is different for every entry
+    }
+}
+
+/** @} */

+ 91 - 0
modules/base/text/classes/BxBaseModTextSearchResult.php

@@ -0,0 +1,91 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    BaseText Base classes for text modules
+ * @ingroup     DolphinModules
+ *
+ * @{
+ */
+
+bx_import('BxTemplSearchResult');
+
+class BxBaseModTextSearchResult extends BxTemplSearchResult 
+{
+    protected $oModule;
+    protected $aUnitViews = array('extended' => 'unit.html', 'gallery' => 'unit_gallery.html');
+    protected $sUnitViewDefault = 'gallery';
+    protected $sUnitViewParamName = 'unit_view';
+
+    function __construct($sMode = '', $aParams = array()) 
+    {
+        parent::__construct();
+
+        $this->aGetParams = array($this->sUnitViewParamName);
+        $this->sUnitTemplate = $this->aUnitViews[$this->sUnitViewDefault];
+        if (isset($this->aUnitViews[bx_get($this->sUnitViewParamName)]))
+            $this->sUnitTemplate = $this->aUnitViews[bx_get($this->sUnitViewParamName)];
+        $this->oModule = $this->getMain();
+    }
+
+    function getMain() 
+    {
+        return BxDolModule::getInstance($this->aCurrent['name']);
+    }
+
+    function getDesignBoxMenu () 
+    {
+        $aMenu = parent::getDesignBoxMenu ();
+
+        return array_merge(
+            array(
+                array('name' => 'gallery', 'title' => _t('_sys_menu_title_gallery'), 'link' => $this->getCurrentUrl(array($this->sUnitViewParamName => 'gallery')), 'icon' => 'th'),
+                array('name' => 'extended', 'title' => _t('_sys_menu_title_extended'), 'link' => $this->getCurrentUrl(array($this->sUnitViewParamName => 'extended')), 'icon' => 'list'),
+            ),
+            $aMenu
+        );
+    }
+
+    function getRssUnitLink (&$a) 
+    {
+        $CNF = &$this->oModule->_oConfig->CNF;
+
+        bx_import('BxDolPermalinks');
+        return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $a[$CNF['FIELD_ID']]);
+    }
+
+    function getRssPageUrl () 
+    {
+        if (false === parent::getRssPageUrl())
+            return false;
+
+        bx_import('BxDolPermalinks');
+        $oPermalinks = BxDolPermalinks::getInstance();
+        return BX_DOL_URL_ROOT . $oPermalinks->permalink($this->aCurrent['rss']['link']);
+    }
+
+    function rss () 
+    {        
+        if (!isset($this->aCurrent['rss']))
+            return '';
+
+        $this->aCurrent['paginate']['perPage'] = getParam($this->oModule->_oConfig->CNF['PARAM_NUM_RSS']);
+        return parent::rss();
+    }
+
+    function _getPseud () 
+    {
+        return array(
+            'id' => 'id',
+            'title' => 'title',
+            'text' => 'text',
+            'added' => 'added',
+            'author' => 'author',
+            'photo' => 'photo',
+        );
+    }
+}
+
+/** @} */
+

+ 139 - 0
modules/base/text/classes/BxBaseModTextTemplate.php

@@ -0,0 +1,139 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ * 
+ * @defgroup    BaseText Base classes for text modules
+ * @ingroup     DolphinModules
+ *
+ * @{
+ */
+
+bx_import('BxDolModuleTemplate');
+
+/**
+ * Module representation.
+ */
+class BxBaseModTextTemplate extends BxDolModuleTemplate 
+{
+    protected static $MODULE;
+
+    /**
+     * Constructor
+     */
+    function __construct(&$oConfig, &$oDb) 
+    {
+        parent::__construct($oConfig, $oDb);
+
+        $this->addCss ('main.css');
+    }
+
+    function unit ($aData, $isCheckPrivateContent = true, $sTemplateName = 'unit.html') 
+    {
+        $oModule = BxDolModule::getInstance(self::$MODULE);
+        $CNF = &$oModule->_oConfig->CNF;
+
+        if ($isCheckPrivateContent && CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $oModule->checkAllowedView($aData))) {
+            $aVars = array (
+                'summary' => $sMsg,
+            );
+            return $this->parseHtmlByName('unit_private.html', $aVars);
+        }
+
+        // get thumb url
+        $sPhotoThumb = '';
+        if ($aData[$CNF['FIELD_THUMB']]) {
+            bx_import('BxDolImageTranscoder');
+            $oImagesTranscoder = BxDolImageTranscoder::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW']);
+            if ($oImagesTranscoder)
+                $sPhotoThumb = $oImagesTranscoder->getImageUrl($aData[$CNF['FIELD_THUMB']]);
+        }
+
+        // get entry url
+        bx_import('BxDolPermalinks');
+        $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aData[$CNF['FIELD_ID']]);
+
+        bx_import('BxDolProfile');
+        $oProfile = BxDolProfile::getInstance($aData[$CNF['FIELD_AUTHOR']]);
+        if (!$oProfile) {
+            bx_import('BxDolProfileUndefined');
+            $oProfile = BxDolProfileUndefined::getInstance();
+        }
+
+        $sSummary = $aData[$CNF['FIELD_SUMMARY']];
+        if (!$sSummary) {
+			$iLimitChars = (int)getParam($CNF['PARAM_CHARS_SUMMARY']);
+			$sSummary = trim(strip_tags($aData[$CNF['FIELD_TEXT']]));
+            $sLinkMore = '';
+            if (mb_strlen($sSummary) > $iLimitChars) {
+                $sSummary = mb_substr($sSummary, 0, $iLimitChars);
+                $sLinkMore = ' <a title="' . bx_html_attribute(_t('_sys_read_more', $aData[$CNF['FIELD_TITLE']])) . '" href="' . $sUrl . '"><i class="sys-icon ellipsis-horizontal"></i></a>';
+            }
+            $sSummary = htmlspecialchars_adv($sSummary) . $sLinkMore;
+        }
+
+        $sSummaryPlain = BxTemplFunctions::getInstance()->getStringWithLimitedLength(strip_tags($sSummary), (int)getParam($CNF['PARAM_CHARS_SUMMARY_PLAIN']));
+
+        // generate html
+        $aVars = array (
+            'id' => $aData[$CNF['FIELD_ID']],
+            'content_url' => $sUrl,
+            'title' => bx_process_output($aData[$CNF['FIELD_TITLE']]),
+            'summary' => $sSummary,
+            'author' => $oProfile->getDisplayName(),
+            'author_url' => $oProfile->getUrl(),
+            'entry_posting_date' => bx_time_js($aData[$CNF['FIELD_ADDED']], BX_FORMAT_DATE),
+            'bx_if:thumb' => array (
+                'condition' => $sPhotoThumb,
+                'content' => array (
+                    'title' => bx_process_output($aData[$CNF['FIELD_TITLE']]),
+                    'summary_attr' => bx_html_attribute($sSummaryPlain),
+                    'content_url' => $sUrl,
+                    'thumb_url' => $sPhotoThumb ? $sPhotoThumb : '',                    
+                ),
+            ),
+            'bx_if:no_thumb' => array (
+                'condition' => !$sPhotoThumb,
+                'content' => array (
+                    'content_url' => $sUrl,
+                    'summary_plain' => $sSummaryPlain,
+                ),
+            ),
+        );
+
+        return $this->parseHtmlByName($sTemplateName, $aVars);
+    }
+
+    function entryText ($aData, $sTemplateName = 'entry-text.html') 
+    {
+        $oModule = BxDolModule::getInstance(self::$MODULE);
+        $CNF = &$oModule->_oConfig->CNF;
+
+        $aVars = $aData;
+        $aVars['entry_title'] = $aData[$CNF['FIELD_TITLE']];
+        $aVars['entry_text'] = $aData[$CNF['FIELD_TEXT']];
+
+        return $this->parseHtmlByName($sTemplateName, $aVars);
+    }
+
+    function entryAuthor ($aData, $oProfile, $sTemplateName = 'author.html') 
+    {
+        if (!$oProfile)
+            return '';
+
+        $oModule = BxDolModule::getInstance(self::$MODULE);
+        $CNF = &$oModule->_oConfig->CNF;
+
+        $aVars = array (
+            'author_url' => $oProfile->getUrl(),
+            'author_thumb_url' => $oProfile->getThumb(),
+            'author_title' => $oProfile->getDisplayName(),
+            'entry_posting_date' =>  bx_time_js($aData[$CNF['FIELD_ADDED']], BX_FORMAT_DATE),
+        );
+        return $this->parseHtmlByName($sTemplateName, $aVars);
+    }
+
+}
+
+/** @} */ 
+

+ 59 - 57
modules/boonex/notes/classes/BxNotesConfig.php

@@ -9,73 +9,75 @@
  * @{
  * @{
  */
  */
 
 
-bx_import('BxDolModuleConfig');
+bx_import('BxBaseModTextConfig');
 
 
-class BxNotesConfig extends BxDolModuleConfig 
+class BxNotesConfig extends BxBaseModTextConfig 
 {
 {
-    public $CNF = array (
+    function __construct($aModule) 
+    {
+        parent::__construct($aModule);
 
 
-        // database fields
-        'FIELD_ID' => 'id',
-        'FIELD_AUTHOR' => 'author',
-        'FIELD_ADDED' => 'added',
-        'FIELD_CHANGED' => 'changed',
-        'FIELD_TITLE' => 'title',
-        'FIELD_TEXT' => 'text',
-        'FIELD_TEXT_ID' => 'note-text',
-        'FIELD_SUMMARY' => 'summary',
-        'FIELD_SUMMARY_ID' => 'note-summary',
-        'FIELD_ALLOW_VIEW_TO' => 'allow_view_to',
-        'FIELD_PHOTO' => 'pictures',
-        'FIELD_THUMB' => 'thumb',
+        $this->CNF = array (
 
 
-        // page URIs
-        'URI_VIEW_ENTRY' => 'view-note',
-        'URI_HOME' => 'notes-home',
-        'URI_AUTHOR_ENTRIES' => 'notes-author',
+            // database fields
+            'FIELD_ID' => 'id',
+            'FIELD_AUTHOR' => 'author',
+            'FIELD_ADDED' => 'added',
+            'FIELD_CHANGED' => 'changed',
+            'FIELD_TITLE' => 'title',
+            'FIELD_TEXT' => 'text',
+            'FIELD_TEXT_ID' => 'note-text',
+            'FIELD_SUMMARY' => 'summary',
+            'FIELD_SUMMARY_ID' => 'note-summary',
+            'FIELD_ALLOW_VIEW_TO' => 'allow_view_to',
+            'FIELD_PHOTO' => 'pictures',
+            'FIELD_THUMB' => 'thumb',
 
 
-        // some params
-        'PARAM_CHARS_SUMMARY' => 'bx_notes_summary_chars',
-        'PARAM_CHARS_SUMMARY_PLAIN' => 'bx_notes_plain_summary_chars',
+            // page URIs
+            'URI_VIEW_ENTRY' => 'view-note',
+            'URI_HOME' => 'notes-home',
+            'URI_AUTHOR_ENTRIES' => 'notes-author',
 
 
-        // objects
-        'OBJECT_STORAGE' => 'bx_notes_photos',
-        'OBJECT_IMAGES_TRANSCODER_PREVIEW' => 'bx_notes_preview',
-        'OBJECT_VIEWS' => 'bx_notes',
-        'OBJECT_VOTES' => 'bx_notes',
-        'OBJECT_COMMENTS' => 'bx_notes',
-        'OBJECT_PRIVACY_VIEW' => 'bx_notes_allow_view_to',
-        'OBJECT_FORM_ENTRY' => 'bx_notes',
-        'OBJECT_FORM_ENTRY_DISPLAY_VIEW' => 'bx_notes_note_view',
-        'OBJECT_FORM_ENTRY_DISPLAY_ADD' => 'bx_notes_note_add',
-        'OBJECT_FORM_ENTRY_DISPLAY_EDIT' => 'bx_notes_note_edit',
-        'OBJECT_FORM_ENTRY_DISPLAY_DELETE' => 'bx_notes_note_delete',
-        'OBJECT_MENU_ACTIONS_VIEW_ENTRY' => 'bx_notes_view', // actions menu on view entry page
-        'OBJECT_MENU_ACTIONS_MY_ENTRIES' => 'bx_notes_my', // actions menu on my entries page
-        'OBJECT_MENU_SUBMENU' => 'bx_notes_submenu', // main module submenu
-        'OBJECT_MENU_SUBMENU_VIEW_ENTRY' => 'bx_notes_view_submenu', // view entry submenu
-        'OBJECT_MENU_SUBMENU_VIEW_ENTRY_MAIN_SELECTION' => 'notes-home', // first item in view entry submenu from main module submenu
+            // some params
+            'PARAM_CHARS_SUMMARY' => 'bx_notes_summary_chars',
+            'PARAM_CHARS_SUMMARY_PLAIN' => 'bx_notes_plain_summary_chars',
+            'PARAM_NUM_RSS' => 'bx_notes_rss_num',
 
 
-        // menu items which visibility depends on custom visibility checking
-        'MENU_ITEM_TO_METHOD' => array (
-            'bx_notes_my' => array (
-                'create-note' => 'checkAllowedAdd',
-            ),
-            'bx_notes_view' => array (
-                'edit-note' => 'checkAllowedEdit',
-                'delete-note' => 'checkAllowedDelete',
+            // objects
+            'OBJECT_STORAGE' => 'bx_notes_photos',
+            'OBJECT_IMAGES_TRANSCODER_PREVIEW' => 'bx_notes_preview',
+            'OBJECT_VIEWS' => 'bx_notes',
+            'OBJECT_VOTES' => 'bx_notes',
+            'OBJECT_COMMENTS' => 'bx_notes',
+            'OBJECT_PRIVACY_VIEW' => 'bx_notes_allow_view_to',
+            'OBJECT_FORM_ENTRY' => 'bx_notes',
+            'OBJECT_FORM_ENTRY_DISPLAY_VIEW' => 'bx_notes_note_view',
+            'OBJECT_FORM_ENTRY_DISPLAY_ADD' => 'bx_notes_note_add',
+            'OBJECT_FORM_ENTRY_DISPLAY_EDIT' => 'bx_notes_note_edit',
+            'OBJECT_FORM_ENTRY_DISPLAY_DELETE' => 'bx_notes_note_delete',
+            'OBJECT_MENU_ACTIONS_VIEW_ENTRY' => 'bx_notes_view', // actions menu on view entry page
+            'OBJECT_MENU_ACTIONS_MY_ENTRIES' => 'bx_notes_my', // actions menu on my entries page
+            'OBJECT_MENU_SUBMENU' => 'bx_notes_submenu', // main module submenu
+            'OBJECT_MENU_SUBMENU_VIEW_ENTRY' => 'bx_notes_view_submenu', // view entry submenu
+            'OBJECT_MENU_SUBMENU_VIEW_ENTRY_MAIN_SELECTION' => 'notes-home', // first item in view entry submenu from main module submenu
+
+            // menu items which visibility depends on custom visibility checking
+            'MENU_ITEM_TO_METHOD' => array (
+                'bx_notes_my' => array (
+                    'create-note' => 'checkAllowedAdd',
+                ),
+                'bx_notes_view' => array (
+                    'edit-note' => 'checkAllowedEdit',
+                    'delete-note' => 'checkAllowedDelete',
+                ),
             ),
             ),
-        ),
 
 
-        // some language keys
-        'T' => array (
-            'txt_sample_single' => '_bx_notes_txt_sample_single',
-        ),
-    );
+            // some language keys
+            'T' => array (
+                'txt_sample_single' => '_bx_notes_txt_sample_single',
+            ),
+        );
 
 
-    function __construct($aModule) 
-    {
-        parent::__construct($aModule);
     }
     }
 }
 }
 
 

+ 5 - 13
modules/boonex/notes/classes/BxNotesDb.php

@@ -9,25 +9,17 @@
  * @{
  * @{
  */
  */
 
 
-bx_import('BxDolModuleDb');
+bx_import('BxBaseModTextDb');
 
 
 /*
 /*
  * Module database queries
  * Module database queries
  */
  */
-class BxNotesDb extends BxDolModuleDb {
-
-    /*
-     * Constructor.
-     */
-    function __construct(&$oConfig) {
+class BxNotesDb extends BxBaseModTextDb 
+{
+    function __construct(&$oConfig) 
+    {
         parent::__construct($oConfig);
         parent::__construct($oConfig);
     }
     }
-
-    function getContentInfoById ($iContentId) {
-        $sQuery = $this->prepare ("SELECT `c`.* FROM `" . $this->_sPrefix . "posts` AS `c` WHERE `c`.`id` = ?", $iContentId);
-        return $this->getRow($sQuery);
-    }
-
 }
 }
 
 
 /** @} */ 
 /** @} */ 

+ 3 - 198
modules/boonex/notes/classes/BxNotesFormEntry.php

@@ -9,213 +9,18 @@
  * @{
  * @{
  */
  */
 
 
-bx_import('BxTemplFormView');
+bx_import('BxBaseModTextFormEntry');
 
 
 /**
 /**
  * Create/Edit entry form
  * Create/Edit entry form
  */
  */
-class BxNotesFormEntry extends BxTemplFormView 
+class BxNotesFormEntry extends BxBaseModTextFormEntry 
 {
 {
-    protected static $MODULE = 'bx_notes';
-
-    protected $_oModule;
-
     public function __construct($aInfo, $oTemplate = false) 
     public function __construct($aInfo, $oTemplate = false) 
     {
     {
+        self::$MODULE = 'bx_notes';
         parent::__construct($aInfo, $oTemplate);
         parent::__construct($aInfo, $oTemplate);
-        
-        $this->_oModule = BxDolModule::getInstance(self::$MODULE);
-
-        $CNF = &$this->_oModule->_oConfig->CNF;
-
-        if (isset($this->aInputs[$CNF['FIELD_TEXT']])) {            
-            $this->aInputs[$CNF['FIELD_TEXT']]['attrs'] = array_merge (
-                array ('id' => $CNF['FIELD_TEXT_ID']),
-                is_array($this->aInputs[$CNF['FIELD_TEXT']]['attrs']) ? $this->aInputs[$CNF['FIELD_TEXT']]['attrs'] : array ()
-            );            
-        }
-
-        if (isset($this->aInputs[$CNF['FIELD_SUMMARY']])) {
-            $this->aInputs[$CNF['FIELD_SUMMARY']]['attrs'] = array_merge (
-                array ('id' => $CNF['FIELD_SUMMARY_ID']),
-                is_array($this->aInputs[$CNF['FIELD_SUMMARY']]['attrs']) ? $this->aInputs[$CNF['FIELD_SUMMARY']]['attrs'] : array ()
-            );            
-        }
-
-        if (isset($this->aInputs[$CNF['FIELD_PHOTO']])) {
-            $this->aInputs[$CNF['FIELD_PHOTO']]['storage_object'] = $CNF['OBJECT_STORAGE'];
-            $this->aInputs[$CNF['FIELD_PHOTO']]['uploaders'] = array('sys_simple', 'sys_html5');
-            $this->aInputs[$CNF['FIELD_PHOTO']]['images_transcoder'] = $CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW'];
-            $this->aInputs[$CNF['FIELD_PHOTO']]['multiple'] = true;
-            $this->aInputs[$CNF['FIELD_PHOTO']]['content_id'] = 0;
-            $this->aInputs[$CNF['FIELD_PHOTO']]['ghost_template'] = '';
-        }
-
-        if (isset($this->aInputs[$CNF['FIELD_ALLOW_VIEW_TO']])) {
-            bx_import('BxDolPrivacy');
-            $this->aInputs[$CNF['FIELD_ALLOW_VIEW_TO']] = BxDolPrivacy::getGroupChooser($CNF['OBJECT_PRIVACY_VIEW']);
-        }
-    }
-
-    function initChecker ($aValues = array (), $aSpecificValues = array())  
-    {
-        $CNF = &$this->_oModule->_oConfig->CNF;
-
-        if (isset($this->aInputs[$CNF['FIELD_PHOTO']])) {
-
-            $aContentInfo = false;
-            if ($aValues && !empty($aValues['id'])) {
-                $aContentInfo = $this->_oModule->_oDb->getContentInfoById ($aValues['id']);
-                $this->aInputs[$CNF['FIELD_PHOTO']]['content_id'] = $aValues['id'];
-            }
-            
-            $aVars = array (
-                'name' => $this->aInputs[$CNF['FIELD_PHOTO']]['name'],
-                'content_id' => $this->aInputs[$CNF['FIELD_PHOTO']]['content_id'],
-                'editor_id' => $CNF['FIELD_TEXT_ID'],
-                'summary_id' => $CNF['FIELD_SUMMARY_ID'],
-                'thumb_id' => $aContentInfo[$CNF['FIELD_THUMB']],
-                'bx_if:set_thumb' => array (
-                    'condition' => CHECK_ACTION_RESULT_ALLOWED === $this->_oModule->checkAllowedSetThumb(),
-                    'content' => array (
-                        'name_thumb' => $CNF['FIELD_THUMB'],
-                    ),
-                ),
-            );
-            $this->aInputs[$CNF['FIELD_PHOTO']]['ghost_template'] = $this->_oModule->_oTemplate->parseHtmlByName('form_ghost_template.html', $aVars);
-        }
-        
-        return parent::initChecker($aValues, $aSpecificValues);
-    }
-
-    public function insert ($aValsToAdd = array(), $isIgnore = false) 
-    {
-        $CNF = &$this->_oModule->_oConfig->CNF;
-
-        $aValsToAdd[$CNF['FIELD_AUTHOR']] = bx_get_logged_profile_id ();
-        $aValsToAdd[$CNF['FIELD_ADDED']] = time();
-        $aValsToAdd[$CNF['FIELD_CHANGED']] = time();
-
-        if (CHECK_ACTION_RESULT_ALLOWED === $this->_oModule->checkAllowedSetThumb()) {
-            $aThumb = isset($_POST[$CNF['FIELD_THUMB']]) ? bx_process_input ($_POST[$CNF['FIELD_THUMB']], BX_DATA_INT) : false;
-            $aValsToAdd[$CNF['FIELD_THUMB']] = 0;
-            if (!empty($aThumb) && is_array($aThumb) && ($iFileThumb = array_pop($aThumb)))
-                $aValsToAdd[$CNF['FIELD_THUMB']] = $iFileThumb;
-        }
-
-        if ($iContentId = parent::insert ($aValsToAdd, $isIgnore)) 
-            $this->_processFiles ($this->getCleanValue($CNF['FIELD_PHOTO']), $iContentId, true);
-        return $iContentId;
-    }
-
-    function update ($iContentId, $aValsToAdd = array(), &$aTrackTextFieldsChanges = null) 
-    {
-        $CNF = &$this->_oModule->_oConfig->CNF;
-
-        $aValsToAdd[$CNF['FIELD_CHANGED']] = time();
-
-        if (CHECK_ACTION_RESULT_ALLOWED === $this->_oModule->checkAllowedSetThumb()) {
-            $aThumb = bx_process_input ($_POST[$CNF['FIELD_THUMB']], BX_DATA_INT);
-            $aValsToAdd[$CNF['FIELD_THUMB']] = 0;
-            if (!empty($aThumb) && is_array($aThumb) && ($iFileThumb = array_pop($aThumb)))
-                $aValsToAdd[$CNF['FIELD_THUMB']] = $iFileThumb;
-        }
-
-        if ($iRet = parent::update ($iContentId, $aValsToAdd, $aTrackTextFieldsChanges)) 
-            $this->_processFiles ($this->getCleanValue($CNF['FIELD_PHOTO']), $iContentId, false);
-        return $iRet;
-    }
-
-    function delete ($iContentId) 
-    {
-        $CNF = &$this->_oModule->_oConfig->CNF;
-
-        // delete associated files
-
-        bx_import('BxDolStorage');
-        $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
-        if (!$oStorage)
-            return false;
-
-        $aGhostFiles = $oStorage->getGhosts (bx_get_logged_profile_id(), $iContentId);
-        if ($aGhostFiles)
-            foreach ($aGhostFiles as $aFile)
-                $this->_deleteFile($aFile['id']);
-
-        // delete db record
-
-        bx_import('BxDolView');
-		BxDolView::getObjectInstance($CNF['OBJECT_VIEWS'], $iContentId)->onObjectDelete();
-
-		bx_import('BxDolVote');
-		BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $iContentId)->onObjectDelete();
-
-		bx_import('BxDolCmts');
-		BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $iContentId)->onObjectDelete();
-
-        return parent::delete($iContentId);
-    }
-
-    function _processFiles ($mixedFileIds, $iContentId = 0, $isAssociateWithContent = false) 
-    {
-        $CNF = &$this->_oModule->_oConfig->CNF;
-
-        if (!$mixedFileIds)
-            return true;
-
-        bx_import('BxDolStorage');
-        $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
-        if (!$oStorage)
-            return false;
-
-        $iProfileId = bx_get_logged_profile_id();
-
-        $aGhostFiles = $oStorage->getGhosts ($iProfileId, $isAssociateWithContent ? 0 : $iContentId);
-        if (!$aGhostFiles)
-            return true;
-
-        foreach ($aGhostFiles as $aFile) {
-            if ($aFile['private'])
-                $oStorage->setFilePrivate ($aFile['id'], 0);
-            if ($isAssociateWithContent && $iContentId)
-                $oStorage->updateGhostsContentId ($aFile['id'], $iProfileId, $iContentId);
-        }
-
-        return true;
     }
     }
-
-    function _deleteFile ($iFileId) 
-    {
-        $CNF = &$this->_oModule->_oConfig->CNF;
-
-        if (!$iFileId)
-            return true;        
-
-        bx_import('BxDolStorage');
-        if (!($oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE'])))
-            return false;
-
-        if (!$oStorage->getFile($iFileId))
-            return true;
-
-        $iProfileId = bx_get_logged_profile_id(); 
-        return $oStorage->deleteFile($iFileId, $iProfileId);
-    }
-
-
-    function addCssJs () 
-    {
-        if (!isset($this->aParams['view_mode']) || !$this->aParams['view_mode']) {
-            if (self::$_isCssJsAdded)
-                return;
-            $this->_oModule->_oTemplate->addJs('forms.js');
-            $this->_oModule->_oTemplate->addCss('forms.css');
-        }
-
-        return parent::addCssJs ();
-    }
-
-
 }
 }
 
 
 /** @} */
 /** @} */

+ 4 - 248
modules/boonex/notes/classes/BxNotesFormsEntryHelper.php

@@ -9,261 +9,17 @@
  * @{
  * @{
  */
  */
 
 
-bx_import('BxDolProfileForms');
-bx_import('BxDolProfile');
-bx_import('BxDolForm');
+bx_import('BxBaseModTextFormsEntryHelper');
 
 
 /**
 /**
- * Note forms functions
+ * Entry forms helper functions
  */
  */
-class BxNotesFormsEntryHelper extends BxDolProfileForms 
+class BxNotesFormsEntryHelper extends BxBaseModTextFormsEntryHelper 
 {
 {
-    protected $_oModule;
-
     public function __construct($oModule) 
     public function __construct($oModule) 
     {
     {
-        parent::__construct();
-        $this->_oModule = $oModule;
-    }
-
-    /**
-     * @return add data html
-     */
-    public function addDataForm () 
-    {
-        $CNF = &$this->_oModule->_oConfig->CNF;
-
-        // check access
-        if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedAdd()))
-            return MsgBox($sMsg);
-
-        // check and display form
-        $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD']);
-        if (!$oForm)
-            return MsgBox(_t('_sys_txt_error_occured'));
-
-        $oForm->initChecker(); 
-
-        if (!$oForm->isSubmittedAndValid())
-            return $oForm->getCode();
-
-        // insert data into database
-        $aValsToAdd = array ();        
-        $iContentId = $oForm->insert ($aValsToAdd);
-        if (!$iContentId) {
-            if (!$oForm->isValid())
-                return $oForm->getCode();
-            else
-                return MsgBox(_t('_sys_txt_error_entry_creation'));
-        }
-
-        if (!($aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId)))
-            return MsgBox(_t('_sys_txt_error_occured'));
-
-        // perform action 
-        $this->_oModule->checkAllowedAdd(true);
-
-        // alert
-        bx_import('BxDolPrivacy');
-        bx_alert($this->_oModule->getName(), 'added', $iContentId, false, array('privacy_view' => $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]));
-
-        // redirect 
-        $this->_redirectAndExit('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $iContentId);
-    }
-
-    /**
-     * @return edit data html
-     */
-    public function editDataForm ($iContentId, $sDisplay = false) 
-    {
-        $CNF = &$this->_oModule->_oConfig->CNF;
-
-        if (false === $sDisplay) 
-            $sDisplay = $CNF['OBJECT_FORM_ENTRY_DISPLAY_EDIT'];
-
-        // get content data and profile info
-        list ($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId);
-        if (!$aContentInfo)
-            return MsgBox(_t('_sys_txt_error_entry_is_not_defined')); 
-
-        // check access
-        if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedEdit($aContentInfo)))
-            return MsgBox($sMsg);
-        
-        // check and display form 
-        $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $sDisplay); 
-        if (!$oForm)
-            return MsgBox(_t('_sys_txt_error_occured'));
-
-        $oForm->initChecker($aContentInfo); 
-
-        if (!$oForm->isSubmittedAndValid())
-            return $oForm->getCode();
-
-        // update data in the DB
-        $aTrackTextFieldsChanges = null;
-        if (!$oForm->update ($aContentInfo[$CNF['FIELD_ID']], array(), $aTrackTextFieldsChanges)) {
-            if (!$oForm->isValid())
-                return $oForm->getCode();
-            else
-                return MsgBox(_t('_sys_txt_error_entry_update')); 
-        }
-
-        if (!($aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId)))
-            return MsgBox(_t('_sys_txt_error_occured'));
-
-        // change profile to 'pending' only if profile is 'active'
-        if ($oProfile->isActive() && !empty($aTrackTextFieldsChanges['changed_fields']))
-            $oProfile->disapprove(BX_PROFILE_ACTION_AUTO);
-
-        // perform action
-        $this->_oModule->checkAllowedEdit($aContentInfo, true);
-
-        // create an alert
-        bx_import('BxDolPrivacy');
-        bx_alert($this->_oModule->getName(), 'edited', $aContentInfo[$CNF['FIELD_ID']], false, array('privacy_view' => $aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']])); 
-
-        // redirect 
-        $this->_redirectAndExit('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
+        parent::__construct($oModule);
     }
     }
-
-
-    /**
-     * @return delete data html
-     */
-    public function deleteDataForm ($iContentId, $sDisplay = false) 
-    {
-        $CNF = &$this->_oModule->_oConfig->CNF;
-
-        if (false === $sDisplay) 
-            $sDisplay = $CNF['OBJECT_FORM_ENTRY_DISPLAY_DELETE'];
-
-        // get content data and profile info
-        list ($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId);
-        if (!$aContentInfo)
-            return MsgBox(_t('_sys_txt_error_entry_is_not_defined')); 
-
-        // check access
-        if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedDelete($aContentInfo)))
-            return MsgBox($sMsg);
-        
-        // check and display form 
-        $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $sDisplay);
-        if (!$oForm)
-            return MsgBox(_t('_sys_txt_error_occured'));
-
-        $oForm->initChecker($aContentInfo); 
-
-        if (!$oForm->isSubmittedAndValid())
-            return $oForm->getCode();
-
-        if (!$oForm->delete ($aContentInfo[$CNF['FIELD_ID']])) {
-            if (!$oForm->isValid())
-                return $oForm->getCode();
-            else
-                return MsgBox(_t('_sys_txt_error_entry_delete'));
-        }
-
-        // perform action
-        $this->_oModule->checkAllowedDelete($aContentInfo, true);
-
-        // create an alert
-        bx_alert($this->_oModule->getName(), 'deleted', $aContentInfo[$CNF['FIELD_ID']]);
-
-        // redirect 
-        $this->_redirectAndExit('page.php?i=' . $CNF['URI_HOME']);
-    }
-
-
-    /**
-     * @return view data html
-     */
-    public function viewDataForm ($iContentId) 
-    {
-        $CNF = &$this->_oModule->_oConfig->CNF;
-
-        // get content data and profile info
-        list ($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId);
-        if (!$aContentInfo)
-            return MsgBox(_t('_sys_txt_error_entry_is_not_defined')); 
-
-        // check access
-        if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedView($aContentInfo)))
-            return MsgBox($sMsg);
-        
-        // get form 
-        $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $CNF['OBJECT_FORM_ENTRY_DISPLAY_VIEW']); 
-        if (!$oForm)
-            return MsgBox(_t('_sys_txt_error_occured'));
-
-        // perform action
-        $this->_oModule->checkAllowedView($aContentInfo);
-
-        // display profile
-        $oForm->initChecker($aContentInfo);
-        return $oForm->getCode();
-    }
-
-    /**
-     * @return main content text 
-     */
-    public function viewDataText ($iContentId) 
-    {
-        $CNF = &$this->_oModule->_oConfig->CNF;
-
-        // get content data and profile info
-        list ($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId);
-        if (!$aContentInfo)
-            return MsgBox(_t('_sys_txt_error_entry_is_not_defined')); 
-
-        // check access
-        if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedView($aContentInfo)))
-            return MsgBox($sMsg);
-
-        return $aContentInfo[$CNF['FIELD_TEXT']];
-    }
-
-    /**
-     * @return main content text 
-     */
-    public function viewDataEntry ($iContentId) 
-    {
-        // get content data and profile info
-        list ($oProfile, $aContentInfo) = $this->_getProfileAndContentData($iContentId);
-        if (!$aContentInfo)
-            return MsgBox(_t('_sys_txt_error_entry_is_not_defined')); 
-
-        // check access
-        if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedView($aContentInfo)))
-            return MsgBox($sMsg);
-
-        return $this->_oModule->_oTemplate->entryText($aContentInfo);
-    }
-
-
-    /**
-     * @return array of profile object, profile info and content info
-     */
-    protected function _getProfileAndContentData ($iContentId) 
-    {
-        $CNF = &$this->_oModule->_oConfig->CNF;
-
-        $aContentInfo = array();
-        $oProfile = false;
-        
-        $aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);
-        if (!$aContentInfo)
-            return array (false, false);
-
-        $oProfile = BxDolProfile::getInstance($aContentInfo[$CNF['FIELD_AUTHOR']]);
-        if (!$oProfile) {
-            bx_import('BxDolProfileUndefined');
-            $oProfile = BxDolProfileUndefined::getInstance();
-        }
-
-        return array ($oProfile, $aContentInfo);
-    }
-
 }
 }
 
 
 /** @} */
 /** @} */

+ 3 - 33
modules/boonex/notes/classes/BxNotesMenu.php

@@ -9,47 +9,17 @@
  * @{
  * @{
  */
  */
 
 
-bx_import('BxTemplMenu');
+bx_import('BxBaseModTextMenu');
 
 
 /**
 /**
  * General class for module menu.
  * General class for module menu.
  */
  */
-class BxNotesMenu extends BxTemplMenu 
+class BxNotesMenu extends BxBaseModTextMenu 
 {
 {
-    protected static $MODULE = 'bx_notes';
-
-    protected $_oModule;
-    protected $_aContentInfo;
-
     public function __construct($aObject, $oTemplate = false) 
     public function __construct($aObject, $oTemplate = false) 
     {
     {
+        self::$MODULE = 'bx_notes';
         parent::__construct($aObject, $oTemplate);
         parent::__construct($aObject, $oTemplate);
-
-        bx_import('BxDolModule');
-        $this->_oModule = BxDolModule::getInstance(self::$MODULE);
-    }
-
-    /**
-     * Check if menu items is visible.
-     * @param $a menu item array
-     * @return boolean
-     */ 
-    protected function _isVisible ($a) 
-    {
-        $CNF = $this->_oModule->_oConfig->CNF;
-        $sFuncCheckAccess = false;
-
-        // get custom function name to check menu item visibility
-        if (isset($CNF['MENU_ITEM_TO_METHOD'][$this->_sObject][$a['name']]))
-            $sFuncCheckAccess = $CNF['MENU_ITEM_TO_METHOD'][$this->_sObject][$a['name']];
-
-        // check custom visibility settings defined in module config class
-        if ($sFuncCheckAccess && CHECK_ACTION_RESULT_ALLOWED === call_user_func_array(array($this->_oModule, $sFuncCheckAccess), isset($this->_aContentInfo) ? array(&$this->_aContentInfo) : array()))
-            return true;
-
-        // default visible settings
-        bx_import('BxDolAcl');
-        return BxDolAcl::getInstance()->isMemberLevelInSet($a['visible_for_levels']);
     }
     }
 }
 }
 
 

+ 2 - 9
modules/boonex/notes/classes/BxNotesMenuView.php

@@ -9,23 +9,16 @@
  * @{
  * @{
  */
  */
 
 
-bx_import('BxTemplMenu');
-bx_import('Menu', 'bx_notes');
+bx_import('BxBaseModTextMenuView');
 
 
 /**
 /**
  * View entry menu
  * View entry menu
  */
  */
-class BxNotesMenuView extends BxNotesMenu
+class BxNotesMenuView extends BxBaseModTextMenuView
 {
 {
     public function __construct($aObject, $oTemplate = false) 
     public function __construct($aObject, $oTemplate = false) 
     {
     {
         parent::__construct($aObject, $oTemplate);
         parent::__construct($aObject, $oTemplate);
-
-        $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
-
-        $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);
-        if ($this->_aContentInfo)
-            $this->addMarkers(array('content_id' => (int)$iContentId));
     }
     }
 }
 }
 
 

+ 3 - 452
modules/boonex/notes/classes/BxNotesModule.php

@@ -9,466 +9,17 @@
  * @{
  * @{
  */
  */
 
 
-bx_import ('BxDolModule');
-bx_import ('BxDolAcl');
+bx_import ('BxBaseModTextModule');
 
 
 /**
 /**
  * Notes module
  * Notes module
  */
  */
-class BxNotesModule extends BxDolModule 
+class BxNotesModule extends BxBaseModTextModule 
 {
 {
-    protected $_iProfileId;
-
     function __construct(&$aModule) 
     function __construct(&$aModule) 
     {
     {
         parent::__construct($aModule);
         parent::__construct($aModule);
-        $this->_iProfileId = bx_get_logged_profile_id();
-    }
-
-    // ====== ACTIONS METHODS
-
-    public function actionRss ($sMode = '', $sExtra = '') 
-    {
-        if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->checkAllowedBrowse())) {
-            $this->_oTemplate->displayAccessDenied ();
-            exit;
-        }
-
-        $aParams = array ();
-        $sMode = bx_process_input($sMode);
-        switch ($sMode) {
-            case 'author':
-                $aParams = array('author' => (int)$sExtra);
-                break;
-        }
-
-        bx_import ('SearchResult', $this->_aModule);
-        $sClass = $this->_aModule['class_prefix'] . 'SearchResult';
-        $o = new $sClass($sMode, $aParams);
-
-        if ($o->isError) {
-            $this->_oTemplate->displayPageNotFound ();
-            exit;
-        }
-
-        $o->outputRSS();
-        exit;
-    }
-
-    // ====== SERVICE METHODS
-
-    /**
-     * Display pablic entries
-     * @return HTML string
-     */
-    public function serviceBrowsePublic () 
-    {
-        return $this->_serviceBrowse ('public');
-    }
-
-    /**
-     * Display featured entries
-     * @return HTML string
-     */
-    public function serviceBrowseFeatured () 
-    {
-        return $this->_serviceBrowse ('public');
-    }
-
-    /**
-     * Display entries of the author
-     * @return HTML string
-     */
-    public function serviceBrowseAuthor ($iProfileId = 0) 
-    {
-        if (!$iProfileId)
-            $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
-        if (!$iProfileId)
-            return '';
-        return $this->_serviceBrowse ('author', array('author' => $iProfileId));
-    }
-
-    /**
-     * Add entry form
-     * @return HTML string
-     */
-    public function serviceEntityCreate () 
-    {
-        bx_import('FormsEntryHelper', $this->_aModule);
-        $sClass = $this->_aModule['class_prefix'] . 'FormsEntryHelper';
-        $oFormsHelper = new $sClass($this);
-        return $oFormsHelper->addDataForm();
-    }
-
-    /**
-     * Edit entry form
-     * @return HTML string
-     */
-    public function serviceEntityEdit ($iContentId = 0) 
-    {
-        return $this->_serviceEntityForm ('editDataForm', $iContentId);
-    }
-
-    /**
-     * Delete entry form
-     * @return HTML string
-     */
-    public function serviceEntityDelete ($iContentId = 0) 
-    {
-        return $this->_serviceEntityForm ('deleteDataForm', $iContentId);
-    }
-
-    /**
-     * Entry text with some additional controls
-     */
-    public function serviceEntityTextBlock ($iContentId = 0) 
-    {
-        return $this->_serviceEntityForm ('viewDataEntry', $iContentId);
-    }
-
-    /**
-     * Additional entry info
-     */
-    public function serviceEntityInfo ($iContentId = 0) 
-    {
-        return $this->_serviceEntityForm ('viewDataForm', $iContentId);
-    }
-
-    /**
-     * Entry social sharing block
-     */
-    public function serviceEntitySocialSharing ($iContentId = 0) 
-    {
-        if (!$iContentId)
-            $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
-        if (!$iContentId)
-            return false;
-        $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
-        if (!$aContentInfo)
-            return false;
-
-        $CNF = &$this->_oConfig->CNF;
-
-        bx_import('BxDolPermalinks');
-        $sUrl = BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
-
-        $aCustomParams = false;
-        if ($aContentInfo[$CNF['FIELD_THUMB']]) {
-            bx_import('BxDolStorage');
-            $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
-            if ($oStorage && ($sImgUrl = $oStorage->getFileUrlById($aContentInfo[$CNF['FIELD_THUMB']]))) {
-                $aCustomParams = array (
-                    'img_url' => $sImgUrl,
-                    'img_url_encoded' => rawurlencode($sImgUrl),
-                );
-            }
-        }
-
-        //TODO: Rebuild using menus engine when it will be ready for such elements like Vote, Share, etc.
-        $sVotes = '';
-        bx_import('BxDolVote');
-        $oVotes = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $aContentInfo[$CNF['FIELD_ID']]);
-        if ($oVotes)
-            $sVotes = $oVotes->getElementBlock(array('show_do_vote_as_button' => true)); 
-
-        $sShare = '';
-        if (BxDolRequest::serviceExists('bx_timeline', 'get_share_element_block'))
-        	$sShare = BxDolService::call('bx_timeline', 'get_share_element_block', array(bx_get_logged_profile_id(), $this->_aModule['name'], 'added', $aContentInfo[$CNF['FIELD_ID']], array('show_do_share_as_button' => true)));
-
-        bx_import('BxTemplSocialSharing');
-		$sSocial = BxTemplSocialSharing::getInstance()->getCode($iContentId, $this->_aModule['name'], BX_DOL_URL_ROOT . $sUrl, $aContentInfo[$CNF['FIELD_TITLE']], $aCustomParams);
-
-        return $this->_oTemplate->parseHtmlByName('entry-share.html', array(
-        	'vote' => $sVotes,
-        	'share' => $sShare,
-        	'social' => $sSocial,
-        ));
-		//TODO: Rebuild using menus engine when it will be ready for such elements like Vote, Share, etc.
-    }
-
-    /**
-     * Entry comments
-     */
-    public function serviceEntityComments ($iContentId = 0) 
-    {
-        if (!$iContentId)
-            $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
-        if (!$iContentId)
-            return false;
-
-		bx_import('BxDolCmts');
-		$oCmts = BxDolCmts::getObjectInstance($this->_oConfig->CNF['OBJECT_COMMENTS'], $iContentId);
-		if(!$oCmts->isEnabled())
-			return false;
-        return $oCmts->getCommentsBlock(0, 0, false);
-    }
-
-    /**
-     * Entry author block
-     */
-    public function serviceEntityAuthor ($iContentId = 0) 
-    {
-        if (!$iContentId)
-            $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
-        if (!$iContentId)
-            return false;
-        $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
-        if (!$aContentInfo)
-            return false;
-
-        $oProfile = BxDolProfile::getInstance($aContentInfo[$this->_oConfig->CNF['FIELD_AUTHOR']]);
-        if (!$oProfile) {
-            bx_import('BxDolProfileUndefined');
-            $oProfile = BxDolProfileUndefined::getInstance();
-        }
-        return $this->_oTemplate->entryAuthor ($aContentInfo, $oProfile);
-    }
-
-    /**
-     * Entry actions block
-     */
-    public function serviceEntityActions ($iContentId = 0) 
-    {
-        if (!$iContentId)
-            $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
-        if (!$iContentId)
-            return false;
-
-        bx_import('BxTemplMenu');
-        $oMenu = BxTemplMenu::getObjectInstance($this->_oConfig->CNF['OBJECT_MENU_ACTIONS_VIEW_ENTRY']);
-        return $oMenu ? $oMenu->getCode() : false;
-    }
-
-    /**
-     * My entries actions block
-     */
-    public function serviceMyEntriesActions ($iProfileId = 0) 
-    {
-        if (!$iProfileId)
-            $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
-        if (!$iProfileId || $iProfileId != $this->_iProfileId)
-            return false;
-
-        bx_import('BxTemplMenu');
-        $oMenu = BxTemplMenu::getObjectInstance($this->_oConfig->CNF['OBJECT_MENU_ACTIONS_MY_ENTRIES']);
-        return $oMenu ? $oMenu->getCode() : false;
-    }
-
-    /**
-     * Data for Timeline
-     */
-	public function serviceGetTimelineData()
-    {
-        return array(
-            'handlers' => array(
-                array('type' => 'insert', 'alert_unit' => $this->_aModule['name'], 'alert_action' => 'added', 'module_name' => $this->_aModule['name'], 'module_method' => 'get_timeline_post', 'module_class' => 'Module',  'groupable' => 0, 'group_by' => ''),
-                array('type' => 'update', 'alert_unit' => $this->_aModule['name'], 'alert_action' => 'edited'),
-                array('type' => 'delete', 'alert_unit' => $this->_aModule['name'], 'alert_action' => 'deleted')
-            ),
-            'alerts' => array(
-                array('unit' => $this->_aModule['name'], 'action' => 'added'),
-                array('unit' => $this->_aModule['name'], 'action' => 'edited'),
-                array('unit' => $this->_aModule['name'], 'action' => 'deleted'),
-            )
-        );
-    }
-
-    /**
-     * Entry post for Timeline
-     */
-    public function serviceGetTimelinePost($aEvent)
-    {
-    	$aContentInfo = $this->_oDb->getContentInfoById($aEvent['object_id']);
-    	if(empty($aContentInfo) || !is_array($aContentInfo))
-    		return '';
-
-        $CNF = &$this->_oConfig->CNF;
-
-    	bx_import('BxDolPermalinks');
-		$sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
-
-		//--- Image(s)
-	    $sImage = '';
-        if($aContentInfo[$CNF['FIELD_THUMB']]) {
-        	bx_import('BxDolStorage');
-			$oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']);
-            if($oStorage)
-				$sImage = $oStorage->getFileUrlById($aContentInfo[$CNF['FIELD_THUMB']]);
-        }
-
-        //--- Votes
-        bx_import('BxDolVote');
-        $oVotes = BxDolVote::getObjectInstance($CNF['OBJECT_VOTES'], $aEvent['object_id']);
-
-        $aVotes = array(); 
-		if ($oVotes && $oVotes->isEnabled())
-			$aVotes = array(
-				'system' => $CNF['OBJECT_VOTES'],
-				'object_id' => $aContentInfo[$CNF['FIELD_ID']],
-				'count' => $aContentInfo['votes']
-			);
-
-        //--- Comments
-        bx_import('BxDolCmts');
-        $oCmts = BxDolCmts::getObjectInstance($CNF['OBJECT_COMMENTS'], $aEvent['object_id']);
-
-        $aComments = array(); 
-		if($oCmts->isEnabled())
-			$aComments = array(
-				'system' => $CNF['OBJECT_COMMENTS'],
-				'object_id' => $aContentInfo[$CNF['FIELD_ID']],
-				'count' => $aContentInfo['comments']
-			);
-
-    	return array(
-    		'owner_id' => $aContentInfo[$CNF['FIELD_AUTHOR']],
-    		'content' => array(
-    			'sample' => _t($CNF['T']['txt_sample_single']),
-    			'url' => $sUrl,
-    			'title' => $aContentInfo[$CNF['FIELD_TITLE']],
-    			'text' => $aContentInfo[$CNF['FIELD_TEXT']],
-    			'images' => array(
-    				array(
-    					'url' => $sUrl,
-    					'src' => $sImage
-    				)
-    			)
-    		), //a string to display or array to parse default template before displaying.
-    		'votes' => $aVotes,
-    		'comments' => $aComments,
-    		'title' => '', //may be empty.
-    		'description' => '' //may be empty. 
-    	);
-    }
-
-    // ====== PERMISSION METHODS
-
-    /**
-     * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
-     */
-    public function checkAllowedView ($aDataEntry, $isPerformAction = false) 
-    {
-        $CNF = &$this->_oConfig->CNF;
-
-        // moderator and owner always have access
-        if ($aDataEntry[$CNF['FIELD_AUTHOR']] == $this->_iProfileId || $this->_isModerator($isPerformAction))
-            return CHECK_ACTION_RESULT_ALLOWED;
-
-        // check ACL
-        $aCheck = checkActionModule($this->_iProfileId, 'view entry', $this->getName(), $isPerformAction);
-        if ($aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
-            return $aCheck[CHECK_ACTION_MESSAGE];
-
-        // check privacy 
-    	bx_import('BxDolPrivacy');
-    	$oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
-		if ($oPrivacy && !$oPrivacy->check($aDataEntry[$CNF['FIELD_ID']]))
-            return _t('_sys_access_denied_to_private_content');
-
-        return CHECK_ACTION_RESULT_ALLOWED;
-    }
-
-    /**
-     * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
-     */
-    public function checkAllowedBrowse () 
-    {
-        return CHECK_ACTION_RESULT_ALLOWED;
-    }
-
-    /**
-     * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
-     */
-    public function checkAllowedAdd ($isPerformAction = false) 
-    {
-        // check ACL
-        $aCheck = checkActionModule($this->_iProfileId, 'create entry', $this->getName(), $isPerformAction);
-        if ($aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
-            return $aCheck[CHECK_ACTION_MESSAGE];
-        return CHECK_ACTION_RESULT_ALLOWED;
-    }
-
-    /**
-     * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
-     */
-    public function checkAllowedEdit ($aDataEntry, $isPerformAction = false) 
-    {
-        // moderator and owner always have access
-        if ($aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']] == $this->_iProfileId || $this->_isModerator($isPerformAction))
-            return CHECK_ACTION_RESULT_ALLOWED;
-        return _t('_sys_txt_access_denied');
-    }
-
-    /**
-     * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
-     */
-    public function checkAllowedDelete (&$aDataEntry, $isPerformAction = false) 
-    {
-        // moderator always has access
-        if ($this->_isModerator($isPerformAction))
-            return CHECK_ACTION_RESULT_ALLOWED;
-
-        // check ACL
-        $aCheck = checkActionModule($this->_iProfileId, 'delete entry', $this->getName(), $isPerformAction);
-        if ($aDataEntry[$this->_oConfig->CNF['FIELD_AUTHOR']] == $this->_iProfileId && $aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
-            return CHECK_ACTION_RESULT_ALLOWED;
-
-        return _t('_sys_txt_access_denied');
-    }
-
-    /**
-     * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
-     */
-    public function checkAllowedSetThumb () 
-    {
-        // check ACL
-        $aCheck = checkActionModule($this->_iProfileId, 'set thumb', $this->getName(), false);
-        if ($aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
-            return $aCheck[CHECK_ACTION_MESSAGE];
-        return CHECK_ACTION_RESULT_ALLOWED;
-    }
-
-    // ====== PROTECTED METHODS
-
-    protected function _isModerator ($isPerformAction = false) 
-    {
-        // check moderator ACL
-        $aCheck = checkActionModule($this->_iProfileId, 'edit any entry', $this->getName(), $isPerformAction); 
-        return $aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED;
-    }
-
-    protected function _serviceBrowse ($sMode, $aParams = false) 
-    {
-        if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->checkAllowedBrowse()))
-            return MsgBox($sMsg);
-
-        $sClass = $this->_aModule['class_prefix'] . 'SearchResult';
-        bx_import('SearchResult', $this->_aModule);
-        $o = new $sClass($sMode, $aParams);
-        
-        $o->setDisplayEmptyMsg(true);
-
-        if ($o->isError)
-            return '';
-
-        if ($s = $o->processing())
-            return $s;
-        else
-            return '';
-    }
-
-    protected function _serviceEntityForm ($sFormMethod, $iContentId = 0) 
-    {
-        if (!$iContentId)
-            $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
-        if (!$iContentId)
-            return false;
-
-        bx_import('FormsEntryHelper', $this->_aModule);
-        $sClass = $this->_aModule['class_prefix'] . 'FormsEntryHelper';
-        $oFormsHelper = new $sClass($this);
-        return $oFormsHelper->$sFormMethod((int)$iContentId);
     }
     }
 }
 }
 
 
-/** @} */ 
+/** @} */

+ 2 - 32
modules/boonex/notes/classes/BxNotesPageAuthor.php

@@ -9,46 +9,16 @@
  * @{
  * @{
  */
  */
 
 
-bx_import('BxTemplPage');
-bx_import('BxDolMenu');
-bx_import('BxDolProfile');
+bx_import('BxBaseModTextPageAuthor');
 
 
 /**
 /**
  * Profile's entries page.
  * Profile's entries page.
  */
  */
-class BxNotesPageAuthor extends BxTemplPage 
+class BxNotesPageAuthor extends BxBaseModTextPageAuthor 
 {
 {
-    protected $_aProfileInfo;
-    protected $_oProfile;
-
     public function __construct($aObject, $oTemplate = false) 
     public function __construct($aObject, $oTemplate = false) 
     {
     {
         parent::__construct($aObject, $oTemplate);
         parent::__construct($aObject, $oTemplate);
-
-        // get profile info
-        $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
-        if ($iProfileId) {
-            $this->_oProfile = BxDolProfile::getInstance($iProfileId);
-            $this->_aProfileInfo = $this->_oProfile ? $this->_oProfile->getInfo() : false;
-        }
-
-        if (!$this->_aProfileInfo || !$this->_oProfile)
-            return;
-
-        // select view profile submenu
-        $oMenuSubmenu = BxDolMenu::getObjectInstance('sys_site_submenu');
-        if ($oMenuSubmenu) {
-            $oMenuSubmenu->setObjectSubmenu('bx_persons_view_submenu', array (
-                'title' => $this->_oProfile->getDisplayName(),
-                'link' => $this->_oProfile->getUrl(),
-                'icon' => $this->_oProfile->getIcon(),
-            ));
-        }
-
-        // add replaceable markers
-        $this->addMarkers($this->_aProfileInfo); // every profile field can be used as marker
-        $this->addMarkers(array('profile_id' => $this->_oProfile->id())); // profile id field is also suported
-        $this->addMarkers(array('display_name' => $this->_oProfile->getDisplayName())); // profile display name is also suported
     }
     }
 
 
 }
 }

+ 4 - 14
modules/boonex/notes/classes/BxNotesPageBrowse.php

@@ -9,28 +9,18 @@
  * @{
  * @{
  */
  */
 
 
-bx_import('BxDolModule');
-bx_import('BxTemplPage');
+bx_import('BxBaseModTextPageBrowse');
 
 
 /**
 /**
  * Browse entries pages.
  * Browse entries pages.
  */
  */
-class BxNotesPageBrowse extends BxTemplPage 
-{   
-    protected static $MODULE = 'bx_notes';
- 
+class BxNotesPageBrowse extends BxBaseModTextPageBrowse 
+{    
     public function __construct($aObject, $oTemplate = false) 
     public function __construct($aObject, $oTemplate = false) 
     {
     {
+        self::$MODULE = 'bx_notes';
         parent::__construct($aObject, $oTemplate);
         parent::__construct($aObject, $oTemplate);
-
-        $oModule = BxDolModule::getInstance(self::$MODULE);
-
-        // select module submenu
-        bx_import('BxDolMenu');
-        $oMenuSumbemu = BxDolMenu::getObjectInstance('sys_site_submenu');
-        $oMenuSumbemu->setObjectSubmenu($oModule->_oConfig->CNF['OBJECT_MENU_SUBMENU']);
     }
     }
-
 }
 }
 
 
 /** @} */
 /** @} */

+ 3 - 47
modules/boonex/notes/classes/BxNotesPageEntry.php

@@ -9,61 +9,17 @@
  * @{
  * @{
  */
  */
 
 
-bx_import('BxTemplPage');
-bx_import('BxDolModule');
-bx_import('BxDolMenu');
+bx_import('BxBaseModTextPageEntry');
 
 
 /**
 /**
  * Entry create/edit pages
  * Entry create/edit pages
  */
  */
-class BxNotesPageEntry extends BxTemplPage 
+class BxNotesPageEntry extends BxBaseModTextPageEntry 
 {    
 {    
-    protected static $MODULE = 'bx_notes';
-
-    protected $_oModule;
-    protected $_aContentInfo = false;
-
     public function __construct($aObject, $oTemplate = false) 
     public function __construct($aObject, $oTemplate = false) 
     {
     {
+        self::$MODULE = 'bx_notes';
         parent::__construct($aObject, $oTemplate);
         parent::__construct($aObject, $oTemplate);
-
-        $this->_oModule = BxDolModule::getInstance(self::$MODULE);
-        $CNF = &$this->_oModule->_oConfig->CNF;
-
-        // select view entry submenu
-        $oMenuSumbemu = BxDolMenu::getObjectInstance('sys_site_submenu');
-        $oMenuSumbemu->setObjectSubmenu($CNF['OBJECT_MENU_SUBMENU_VIEW_ENTRY'], $CNF['OBJECT_MENU_SUBMENU_VIEW_ENTRY_MAIN_SELECTION']);
-
-        $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
-        if ($iContentId)
-            $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);
-
-        if ($this->_aContentInfo)
-            $this->addMarkers($this->_aContentInfo); // every field can be used as marker
-
-		bx_import('BxDolView');
-		BxDolView::getObjectInstance($CNF['OBJECT_VIEWS'], $iContentId)->doView();
-    }
-
-    public function getCode () 
-    {
-        if (!$this->_aContentInfo) { // if entry is not found - display standard "404 page not found" page
-            $this->_oTemplate->displayPageNotFound();
-            exit;
-        }
-
-        if (CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $this->_oModule->checkAllowedView($this->_aContentInfo))) {
-			$this->_oTemplate->displayAccessDenied($sMsg);
-            exit;
-        }
-        $this->_oModule->checkAllowedView($this->_aContentInfo, true);
-
-        return parent::getCode ();
-    }
-
-    protected function _getPageCacheParams () 
-    {
-        return $this->_aContentInfo[$this->_oModule->_oConfig->CNF['FIELD_ID']]; // cache is different for every entry
     }
     }
 }
 }
 
 

+ 4 - 71
modules/boonex/notes/classes/BxNotesSearchResult.php

@@ -9,17 +9,14 @@
  * @{
  * @{
  */
  */
 
 
-bx_import('BxTemplSearchResult');
+bx_import('BxBaseModTextSearchResult');
 
 
-class BxNotesSearchResult extends BxTemplSearchResult 
+class BxNotesSearchResult extends BxBaseModTextSearchResult 
 {
 {
-    protected $oModule;
-    protected $aUnitViews = array('extended' => 'unit.html', 'gallery' => 'unit_gallery.html');
-    protected $sUnitViewDefault = 'gallery';
-    protected $sUnitViewParamName = 'unit_view';
-
     function __construct($sMode = '', $aParams = array()) 
     function __construct($sMode = '', $aParams = array()) 
     {
     {
+        parent::__construct($sMode, $aParams);
+
         $this->aCurrent = array(
         $this->aCurrent = array(
             'name' => 'bx_notes',
             'name' => 'bx_notes',
             'title' => '_bx_notes_page_title_browse',
             'title' => '_bx_notes_page_title_browse',
@@ -48,14 +45,9 @@ class BxNotesSearchResult extends BxTemplSearchResult
         );
         );
 
 
         $this->sFilterName = 'bx_notes_filter';
         $this->sFilterName = 'bx_notes_filter';
-        $this->aGetParams = array($this->sUnitViewParamName);
-        $this->sUnitTemplate = $this->aUnitViews[$this->sUnitViewDefault];
-        if (isset($this->aUnitViews[bx_get($this->sUnitViewParamName)]))
-            $this->sUnitTemplate = $this->aUnitViews[bx_get($this->sUnitViewParamName)];
 
 
         $oProfileAuthor = null;
         $oProfileAuthor = null;
 
 
-        $this->oModule = $this->getMain();
         $CNF = &$this->oModule->_oConfig->CNF;
         $CNF = &$this->oModule->_oConfig->CNF;
 
 
         switch ($sMode) {
         switch ($sMode) {
@@ -116,13 +108,6 @@ class BxNotesSearchResult extends BxTemplSearchResult
             $this->aCurrent['join'] = array_merge($this->aCurrent['join'], $a['join']);
             $this->aCurrent['join'] = array_merge($this->aCurrent['join'], $a['join']);
 
 
         $this->setProcessPrivateContent(false);
         $this->setProcessPrivateContent(false);
-
-        parent::__construct();
-    }
-
-    function getMain() 
-    {
-        return BxDolModule::getInstance($this->aCurrent['name']);
     }
     }
 
 
     function displayResultBlock () 
     function displayResultBlock () 
@@ -132,19 +117,6 @@ class BxNotesSearchResult extends BxTemplSearchResult
         return $s;
         return $s;
     }
     }
 
 
-    function getDesignBoxMenu () 
-    {
-        $aMenu = parent::getDesignBoxMenu ();
-
-        return array_merge(
-            array(
-                array('name' => 'gallery', 'title' => _t('_sys_menu_title_gallery'), 'link' => $this->getCurrentUrl(array($this->sUnitViewParamName => 'gallery')), 'icon' => 'th'),
-                array('name' => 'extended', 'title' => _t('_sys_menu_title_extended'), 'link' => $this->getCurrentUrl(array($this->sUnitViewParamName => 'extended')), 'icon' => 'list'),
-            ),
-            $aMenu
-        );
-    }
-
     function getAlterOrder() 
     function getAlterOrder() 
     {
     {
         if ($this->aCurrent['sorting'] == 'last') {
         if ($this->aCurrent['sorting'] == 'last') {
@@ -154,45 +126,6 @@ class BxNotesSearchResult extends BxTemplSearchResult
         }
         }
         return array();
         return array();
     }
     }
-
-    function getRssUnitLink (&$a) 
-    {
-        $CNF = &$this->oModule->_oConfig->CNF;
-
-        bx_import('BxDolPermalinks');
-        return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $a[$CNF['FIELD_ID']]);
-    }
-
-    function getRssPageUrl () 
-    {
-        if (false === parent::getRssPageUrl())
-            return false;
-
-        bx_import('BxDolPermalinks');
-        $oPermalinks = BxDolPermalinks::getInstance();
-        return BX_DOL_URL_ROOT . $oPermalinks->permalink($this->aCurrent['rss']['link']);
-    }
-
-    function rss () 
-    {        
-        if (!isset($this->aCurrent['rss']))
-            return '';
-
-        $this->aCurrent['paginate']['perPage'] = getParam('bx_notes_rss_num');
-        return parent::rss();
-    }
-
-    function _getPseud () 
-    {
-        return array(
-            'id' => 'id',
-            'title' => 'title',
-            'text' => 'text',
-            'added' => 'added',
-            'author' => 'author',
-            'photo' => 'photo',
-        );
-    }
 }
 }
 
 
 /** @} */
 /** @} */

+ 3 - 112
modules/boonex/notes/classes/BxNotesTemplate.php

@@ -9,130 +9,21 @@
  * @{
  * @{
  */
  */
 
 
-bx_import('BxDolModuleTemplate');
+bx_import('BxBaseModTextTemplate');
 
 
 /*
 /*
  * Notes module representation.
  * Notes module representation.
  */
  */
-class BxNotesTemplate extends BxDolModuleTemplate 
+class BxNotesTemplate extends BxBaseModTextTemplate 
 {
 {
-    protected static $MODULE = 'bx_notes';
-
     /**
     /**
      * Constructor
      * Constructor
      */
      */
     function __construct(&$oConfig, &$oDb) 
     function __construct(&$oConfig, &$oDb) 
     {
     {
+        self::$MODULE = 'bx_notes';
         parent::__construct($oConfig, $oDb);
         parent::__construct($oConfig, $oDb);
-
-        $this->addCss ('main.css');
-    }
-
-    function unit ($aData, $isCheckPrivateContent = true, $sTemplateName = 'unit.html') 
-    {
-        $oModule = BxDolModule::getInstance(self::$MODULE);
-        $CNF = &$oModule->_oConfig->CNF;
-
-        if ($isCheckPrivateContent && CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $oModule->checkAllowedView($aData))) {
-            $aVars = array (
-                'summary' => $sMsg,
-            );
-            return $this->parseHtmlByName('unit_private.html', $aVars);
-        }
-
-        // get thumb url
-        $sPhotoThumb = '';
-        if ($aData[$CNF['FIELD_THUMB']]) {
-            bx_import('BxDolImageTranscoder');
-            $oImagesTranscoder = BxDolImageTranscoder::getObjectInstance($CNF['OBJECT_IMAGES_TRANSCODER_PREVIEW']);
-            if ($oImagesTranscoder)
-                $sPhotoThumb = $oImagesTranscoder->getImageUrl($aData[$CNF['FIELD_THUMB']]);
-        }
-
-        // get entry url
-        bx_import('BxDolPermalinks');
-        $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aData[$CNF['FIELD_ID']]);
-
-        bx_import('BxDolProfile');
-        $oProfile = BxDolProfile::getInstance($aData[$CNF['FIELD_AUTHOR']]);
-        if (!$oProfile) {
-            bx_import('BxDolProfileUndefined');
-            $oProfile = BxDolProfileUndefined::getInstance();
-        }
-
-        $sSummary = $aData[$CNF['FIELD_SUMMARY']];
-        if (!$sSummary) {
-			$iLimitChars = (int)getParam($CNF['PARAM_CHARS_SUMMARY']);
-			$sSummary = trim(strip_tags($aData[$CNF['FIELD_TEXT']]));
-            $sLinkMore = '';
-            if (mb_strlen($sSummary) > $iLimitChars) {
-                $sSummary = mb_substr($sSummary, 0, $iLimitChars);
-                $sLinkMore = ' <a title="' . bx_html_attribute(_t('_sys_read_more', $aData[$CNF['FIELD_TITLE']])) . '" href="' . $sUrl . '"><i class="sys-icon ellipsis-horizontal"></i></a>';
-            }
-            $sSummary = htmlspecialchars_adv($sSummary) . $sLinkMore;
-        }
-
-        $sSummaryPlain = BxTemplFunctions::getInstance()->getStringWithLimitedLength(strip_tags($sSummary), (int)getParam($CNF['PARAM_CHARS_SUMMARY_PLAIN']));
-
-        // generate html
-        $aVars = array (
-            'id' => $aData[$CNF['FIELD_ID']],
-            'content_url' => $sUrl,
-            'title' => bx_process_output($aData[$CNF['FIELD_TITLE']]),
-            'summary' => $sSummary,
-            'author' => $oProfile->getDisplayName(),
-            'author_url' => $oProfile->getUrl(),
-            'entry_posting_date' => bx_time_js($aData[$CNF['FIELD_ADDED']], BX_FORMAT_DATE),
-            'bx_if:thumb' => array (
-                'condition' => $sPhotoThumb,
-                'content' => array (
-                    'title' => bx_process_output($aData[$CNF['FIELD_TITLE']]),
-                    'summary_attr' => bx_html_attribute($sSummaryPlain),
-                    'content_url' => $sUrl,
-                    'thumb_url' => $sPhotoThumb ? $sPhotoThumb : '',                    
-                ),
-            ),
-            'bx_if:no_thumb' => array (
-                'condition' => !$sPhotoThumb,
-                'content' => array (
-                    'content_url' => $sUrl,
-                    'summary_plain' => $sSummaryPlain,
-                ),
-            ),
-        );
-
-        return $this->parseHtmlByName($sTemplateName, $aVars);
-    }
-
-    function entryText ($aData, $sTemplateName = 'entry-text.html') 
-    {
-        $oModule = BxDolModule::getInstance(self::$MODULE);
-        $CNF = &$oModule->_oConfig->CNF;
-
-        $aVars = $aData;
-        $aVars['entry_title'] = $aData[$CNF['FIELD_TITLE']];
-        $aVars['entry_text'] = $aData[$CNF['FIELD_TEXT']];
-
-        return $this->parseHtmlByName($sTemplateName, $aVars);
     }
     }
-
-    function entryAuthor ($aData, $oProfile, $sTemplateName = 'author.html') 
-    {
-        if (!$oProfile)
-            return '';
-
-        $oModule = BxDolModule::getInstance(self::$MODULE);
-        $CNF = &$oModule->_oConfig->CNF;
-
-        $aVars = array (
-            'author_url' => $oProfile->getUrl(),
-            'author_thumb_url' => $oProfile->getThumb(),
-            'author_title' => $oProfile->getDisplayName(),
-            'entry_posting_date' =>  bx_time_js($aData[$CNF['FIELD_ADDED']], BX_FORMAT_DATE),
-        );
-        return $this->parseHtmlByName($sTemplateName, $aVars);
-    }
-
 }
 }
 
 
 /** @} */ 
 /** @} */