Просмотр исходного кода

#20 - removing traces of twig classes

Alex Trofimov 13 лет назад
Родитель
Сommit
5ce9574afa

+ 2 - 2
modules/boonex/notes/classes/BxNotesDb.php

@@ -9,12 +9,12 @@
  * @{
  */
 
-bx_import('BxDolTwigModuleDb');
+bx_import('BxDolModuleDb');
 
 /*
  * Notes module database queries
  */
-class BxNotesDb extends BxDolTwigModuleDb {
+class BxNotesDb extends BxDolModuleDb {
 
     /*
      * Constructor.

+ 2 - 2
modules/boonex/notes/classes/BxNotesSearchResult.php

@@ -9,9 +9,9 @@
  * @{
  */
 
-bx_import('BxDolTwigSearchResult');
+bx_import('BxTemplSearchResult');
 
-class BxNotesSearchResult extends BxDolTwigSearchResult {
+class BxNotesSearchResult extends BxTemplSearchResult {
 
     var $aCurrent = array(
         'name' => 'bx_notes',

+ 2 - 2
modules/boonex/notes/classes/BxNotesTemplate.php

@@ -9,12 +9,12 @@
  * @{
  */
 
-bx_import('BxDolTwigTemplate');
+bx_import('BxDolModuleTemplate');
 
 /*
  * Notes module representation.
  */
-class BxNotesTemplate extends BxDolTwigTemplate {
+class BxNotesTemplate extends BxDolModuleTemplate {
 
     /**
      * Constructor

+ 2 - 2
modules/boonex/persons/classes/BxPersonsDb.php

@@ -9,12 +9,12 @@
  * @{
  */
 
-bx_import('BxDolTwigModuleDb');
+bx_import('BxDolModuleDb');
 
 /*
  * Persons module database queries
  */
-class BxPersonsDb extends BxDolTwigModuleDb {
+class BxPersonsDb extends BxDolModuleDb {
 
     /*
      * Constructor.

+ 2 - 1
modules/boonex/persons/classes/BxPersonsFormPerson.php

@@ -24,7 +24,8 @@ class BxPersonsFormPerson extends BxTemplFormView {
 
         bx_import('BxDolProfile');
         $oAccountProfile = BxDolProfile::getInstanceAccountProfile();
-        $this->_iAccountProfileId = $oAccountProfile->id();
+        if ($oAccountProfile)
+            $this->_iAccountProfileId = $oAccountProfile->id();
 
         $this->_oModule = BxDolModule::getInstance('bx_persons');
 

+ 2 - 2
modules/boonex/persons/classes/BxPersonsSearchResult.php

@@ -9,9 +9,9 @@
  * @{
  */
 
-bx_import('BxDolTwigSearchResult');
+bx_import('BxTemplSearchResult');
 
-class BxPersonsSearchResult extends BxDolTwigSearchResult {
+class BxPersonsSearchResult extends BxTemplSearchResult {
 
     var $aCurrent = array(
         'name' => 'bx_persons',

+ 2 - 2
modules/boonex/persons/classes/BxPersonsTemplate.php

@@ -9,12 +9,12 @@
  * @{
  */
 
-bx_import('BxDolTwigTemplate');
+bx_import('BxDolModuleTemplate');
 
 /*
  * Persons module representation.
  */
-class BxPersonsTemplate extends BxDolTwigTemplate {
+class BxPersonsTemplate extends BxDolModuleTemplate {
 
     /**
      * Constructor

+ 3 - 3
modules/boonex/profiler/classes/BxProfilerTemplate.php

@@ -19,14 +19,14 @@
 * see license.txt file; if not, write to marketing@boonex.com
 ***************************************************************************/
 
-bx_import('BxDolTwigTemplate');
+bx_import('BxDolModuleTemplate');
 
 if ((int)phpversion() < 5)
     require_once(BX_DIRECTORY_PATH_MODULES . 'boonex/profiler/inc/fb4.php');
 else
     require_once(BX_DIRECTORY_PATH_MODULES . 'boonex/profiler/inc/fb5.php');
 
-class BxProfilerTemplate extends BxDolTwigTemplate {
+class BxProfilerTemplate extends BxDolModuleTemplate {
 
     var $_isAjaxOutput = false;
 
@@ -35,7 +35,7 @@ class BxProfilerTemplate extends BxDolTwigTemplate {
      */
     function BxProfilerTemplate(&$oConfig) {
         $oDb = null;
-        parent::BxDolTwigTemplate($oConfig, $oDb);
+        parent::BxDolModuleTemplate($oConfig, $oDb);
         $this->_isAjaxOutput = $this->_isAjaxRequest();
     }
 

+ 2 - 2
modules/boonex/sites/classes/BxSitesDb.php

@@ -9,12 +9,12 @@
  * @{
  */
 
-bx_import('BxDolTwigModuleDb');
+bx_import('BxDolModuleDb');
 
 /*
  * Notes module database queries
  */
-class BxSitesDb extends BxDolTwigModuleDb
+class BxSitesDb extends BxDolModuleDb
 {
     function __construct(&$oConfig)
     {

+ 3 - 3
modules/boonex/smtpmailer/classes/BxSMTPTemplate.php

@@ -19,12 +19,12 @@
 * see license.txt file; if not, write to marketing@boonex.com
 ***************************************************************************/
 
-bx_import ('BxDolTwigTemplate');
+bx_import ('BxDolModuleTemplate');
 
-class BxSMTPTemplate extends BxDolTwigTemplate {
+class BxSMTPTemplate extends BxDolModuleTemplate {
     
 	function BxSMTPTemplate(&$oConfig, &$oDb) {
-	    parent::BxDolTwigTemplate($oConfig, $oDb);
+	    parent::BxDolModuleTemplate($oConfig, $oDb);
     }    
 }
 

+ 3 - 3
modules/boonex/uni/install/sql/install.sql

@@ -7,13 +7,13 @@ SET @sName = 'bx_uni';
 -- Studio page and widget.
 --
 INSERT INTO `sys_std_pages`(`index`, `name`, `header`, `caption`, `icon`) VALUES
-(3, @sName, '', '', 'bx_uni@modules/boonex/basic/|std-pi.png');
+(3, @sName, '', '', 'bx_uni@modules/boonex/uni/|std-pi.png');
 SET @iPageId = LAST_INSERT_ID();
 
 SET @iParentPageId = (SELECT `id` FROM `sys_std_pages` WHERE `name`='home');
 SET @iParentPageOrder = (SELECT MAX(`order`) FROM `sys_std_pages_widgets` WHERE `page_id`=@iParentPageId);
 INSERT INTO `sys_std_widgets`(`page_id`, `module`, `url`, `click`, `icon`, `caption`, `cnt_notices`, `cnt_actions`) VALUES
-(@iPageId, @sName, CONCAT('{url_studio}design.php?name=', @sName), '', 'bx_uni@modules/boonex/basic/|std-wi.png', '_bx_uni_wgt_cpt', '', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:11:"get_actions";s:6:"params";a:0:{}s:5:"class";s:18:"TemplStudioDesigns";}');
+(@iPageId, @sName, CONCAT('{url_studio}design.php?name=', @sName), '', 'bx_uni@modules/boonex/uni/|std-wi.png', '_bx_uni_wgt_cpt', '', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:11:"get_actions";s:6:"params";a:0:{}s:5:"class";s:18:"TemplStudioDesigns";}');
 INSERT INTO `sys_std_pages_widgets`(`page_id`, `widget_id`, `order`) VALUES
 (@iParentPageId, LAST_INSERT_ID(), @iParentPageOrder + 1);
 
@@ -30,4 +30,4 @@ INSERT INTO `sys_options_categories`(`type_id`, `name`, `caption`, `order`) VALU
 SET @iCategoryId = LAST_INSERT_ID();
 
 INSERT INTO `sys_options`(`category_id`, `name`, `caption`, `value`, `type`, `extra`, `check`, `check_error`, `order`) VALUES
-(@iCategoryId, CONCAT(@sName, '_switcher_title'), 'Name In Template Switcher', 'UNI', 'digit', '', '', '', 1);
+(@iCategoryId, CONCAT(@sName, '_switcher_title'), 'Name In Template Switcher', 'UNI', 'digit', '', '', '', 1);

+ 44 - 22
template/scripts/BxBaseSearchResult.php

@@ -12,6 +12,12 @@
 bx_import('BxDolSearch');
 class BxBaseSearchResult extends BxDolSearchResult {
 
+    public $isError;
+
+    protected $sBrowseUrl;
+    protected $sUnitTemplate = 'unit.html';
+    protected $sFilterName;
+
     protected $iDesignBoxTemplate = BX_DB_PADDING_DEF;
     protected $aPermalinks;
     protected $aConstants;
@@ -27,6 +33,10 @@ class BxBaseSearchResult extends BxDolSearchResult {
         }
     }
 
+    function getMain() {
+        // override this to return main module class
+    }
+
     function isPermalinkEnabled() {
        return isset($this->_isPermalinkEnabled) ? $this->_isPermalinkEnabled : ($this->_isPermalinkEnabled = (getParam($this->aPermalinks['param']) == 'on'));
     }
@@ -70,6 +80,11 @@ class BxBaseSearchResult extends BxDolSearchResult {
         return $sCode;
     }
 
+    function displaySearchUnit ($aData) {
+        $oMain = $this->getMain();
+        return $oMain->_oTemplate->unit($aData, $this->sUnitTemplate);
+    }
+
     function _transformData ($aUnit, $sTempl, $sCssHeader = '') {
         foreach ($aUnit as $sKey => $sValue)
             $sTempl = str_replace('{'.$sKey.'}', $sValue, $sTempl);
@@ -170,32 +185,39 @@ EOF;
     }
 
     function showPagination($bAdmin = false, $bChangePage = true, $bPageReload = true) {
-        $sPageLink = $this->getCurrentUrl('browseAll', 0, '');
-        $aLinkAddon = $this->getLinkAddByPrams();
 
-        if ($aLinkAddon) {
-           foreach($aLinkAddon as $sValue)
-                $sPageLink .= $sValue;
-        }
+        $oMain = $this->getMain();
+        $oConfig = $oMain->_oConfig;
+        bx_import('BxDolPaginate');
+        $sUrlStart = BX_DOL_URL_ROOT . $oConfig->getBaseUri() . $this->sBrowseUrl;
+        $sUrlStart .= (false === strpos($sUrlStart, '?') ? '?' : '&');
 
-        if(!$this->id)
-            $this->id = 0;
+        bx_import('BxTemplPaginate');
+        $oPaginate = new BxTemplPaginate(array(
+            'page_url' => $sUrlStart . 'start={start}&per_page={per_page}' . (false !== bx_get($this->sFilterName) ? '&' . $this->sFilterName . '=' . bx_get($this->sFilterName) : ''),
+            'num' => $this->aCurrent['paginate']['num'],
+            'per_page' => $this->aCurrent['paginate']['perPage'],
+            'start' => $this->aCurrent['paginate']['start'],
+        ));
 
-        $sLoadDynamicUrl = $this->id .', \'searchKeywordContent.php?searchMode=ajax&section[]=' . $this->aCurrent['name'] . $aLinkAddon['params'];
-        $sKeyword = bx_get('keyword');
-        if ($sKeyword !== false && mb_strlen($sKeyword) > 0)
-            $sLoadDynamicUrl .= '&keyword=' . rawurlencode($sKeyword);
+        return '<div class="clear_both"></div>'.$oPaginate->getPaginate();
+    }
+
+    function showPaginationAjax($sBlockId) {
+        $oMain = $this->getMain();
+        $oConfig = $oMain->_oConfig;
         bx_import('BxDolPaginate');
-        $oPaginate = new BxDolPaginate(
-            array(
-                'page_url' => $sPageLink,
-                'num' => $this->aCurrent['paginate']['num'],
-                'per_page' => $this->aCurrent['paginate']['perPage'],
-                'start' => $this->aCurrent['paginate']['start'],
-            ),
-            $bAdmin ? BxDolTemplateAdmin::getInstance() : BxDolTemplate::getInstance()
-        );
-        return '<div class="clear_both"></div>' . $oPaginate->getPaginate();
+        $sUrlStart = BX_DOL_URL_ROOT . $oConfig->getBaseUri() . $this->sBrowseUrl;
+        $sUrlStart .= (false === strpos($sUrlStart, '?') ? '?' : '&');
+
+        $oPaginate = new BxDolPaginate(array(
+            'page_url' => 'javascript:void(0);',
+            'num' => $this->aCurrent['paginate']['num'],
+            'per_page' => $this->aCurrent['paginate']['perPage'],
+            'start' => $this->aCurrent['paginate']['start'],
+        ));
+
+        return $oPaginate->getSimplePaginate(false, -1, -1, false);
     }
 
     function getLinkAddByPrams ($aExclude = array()) {

+ 0 - 70
template/scripts/BxBaseSearchResultText.php

@@ -1,70 +0,0 @@
-<?php
-/**
- * @package     Dolphin Core
- * @copyright   Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
- * @license     CC-BY - http://creativecommons.org/licenses/by/3.0/
- */
-defined('BX_DOL') or die('hack attempt');
-
-// TODO: clean it more carefully !
-
-bx_import('BxBaseSearchResult');
-
-class BxBaseSearchResultText extends BxBaseSearchResult {
-
-    function BxBaseSearchResultText () {
-        $this->aPseud = $this->_getPseud();
-        parent::BxBaseSearchResult();
-        bx_import('BxTemplVotingView');
-
-        $this->aConstants['linksTempl'] = $this->isPermalinkEnabled() ? $this->aPermalinks['enabled'] : $this->aPermalinks['disabled'];
-    }
-
-    function displaySearchUnit ($aData) {
-        $sFileLink = $this->getCurrentUrl('file', $aData['id'], $aData['uri']);
-        $sCategoryLink = $this->getCurrentUrl('category', $aData['categoryId'], $aData['categoryUri'], array('ownerId'=>$aData['ownerId'], 'ownerName'=>$aData['ownerName']));
-
-        // ownerPic
-        $aUnit['ownerPic'] = get_member_icon($aData['ownerId'], 'left');
-
-        // category
-        $aUnit['category'] = isset($aData['categoryName']) ? _t('_In') . ' <a href="'.$sCategoryLink.'">'.$aData['categoryName'].'</a>' : '';
-
-        // comment(s)
-        $aUnit['comment'] = isset($aData['countComment']) ? '<a href="'.$sFileLink.'">'.$aData['countComment'].' '._t('_comments').'</a>' : '';
-
-        // tag
-        if (isset($aData['tag'])) {
-            $aTags = explode(',', $aData['tag']);
-            foreach ($aTags as $sValue) {
-                $sLink = $this->getCurrentUrl('tag', 0, $sValue); // TODO: check for urlencode
-                $aUnit['tag'] .= '<a href="'.$sLink.'">'.bx_process_output($sValue).'</a>, ';
-            }
-        }
-        $aUnit['tag'] .= trim($aUnit['tag'], ', ');
-
-        // rate
-        if (!is_null($this->oRate) && $this->oRate->isEnabled())
-            $aUnit['rate'] = $this->oRate->getJustVotingElement(0, 0, $aData['voting_rate']);
-        else
-            $aUnit['rate'] = '';
-
-        // title
-        $aUnit['title'] = isset($aData['title']) ? '<a href="'.$sFileLink.'">'.bx_process_output($aData['title']).'</a>': '';
-
-        // when
-        $aUnit['when'] = defineTimeInterval($aData['date']);
-
-        // from
-        $aUnit['from'] = $aData['ownerId'] !=0 ? _t('_By').': <a href="'.getProfileLink($aData['ownerId']).'">'.bx_process_output($aData['ownerName']).'</a>': _t('_By').': '._t('_Admin');
-
-        // view
-        $aUnit['view'] = isset($aData['view']) ? _t("_Views").': '.$aData['view'] : '';
-
-        // body
-        $aUnit['body'] = isset($aData['bodyText']) ? process_html_output( strmaxtextlen( strip_tags($aData['bodyText']), 200 ) ) : ''; // TODO:
-
-        return BxDolTemplate::getInstance()->parseHtmlByName('browseTextUnit.html', $aUnit, array('{','}'));
-    }
-}
-