AntonLV 12 лет назад
Родитель
Сommit
09add67005

+ 19 - 1
modules/base/general/classes/BxBaseModGeneralGridAdministration.php

@@ -29,7 +29,25 @@ class BxBaseModGeneralGridAdministration extends BxTemplGrid
         $this->_sParamsDivider = '#-#';
     }
 
-    public function _getFilterSelectOne($sFilterName, $aFilterValues)
+    protected function _getActionSettings($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
+    {
+    	$sJsObject = $this->_oModule->_oConfig->getJsObject('manage_tools');
+    	$sMenuName = $this->_oModule->_oConfig->CNF['OBJECT_MENU_MANAGE_TOOLS'];
+
+    	bx_import('BxDolMenu');
+    	$sMenu = BxDolMenu::getObjectInstance($sMenuName)->getCode();
+    	if(empty($sMenu))
+    		return '';
+
+    	$a['attr'] = array_merge($a['attr'], array(
+    		"bx-popup-id" => $sMenuName . "-" . $aRow['id'],
+    		"onclick" => "$(this).off('click'); " . $sJsObject . ".onClickSettings('" . $sMenuName . "', this);"
+    	));
+
+    	return $this->_getActionDefault ($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
+    }
+
+    protected function _getFilterSelectOne($sFilterName, $aFilterValues)
     {
         if(empty($sFilterName) || empty($aFilterValues))
             return '';

+ 38 - 0
modules/base/general/classes/BxBaseModGeneralMenuManageTools.php

@@ -0,0 +1,38 @@
+<?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    BaseGeneral Base classes for modules
+ * @ingroup     DolphinModules
+ *
+ * @{
+ */
+
+bx_import('BxTemplMenu');
+
+/**
+ * Manage tools submenu
+ */
+class BxBaseModGeneralMenuManageTools extends BxTemplMenu
+{
+	protected $_oModule;
+
+    public function __construct($aObject, $oTemplate = false)
+    {
+        parent::__construct($aObject, $oTemplate);
+
+        $this->_oModule = BxDolModule::getInstance($this->MODULE);
+
+        $iContentId = 0;
+        if(bx_get('content_id') !== false)
+        	$iContentId = (int)bx_get('content_id');
+
+		$this->addMarkers(array(
+			'js_object' => $this->_oModule->_oConfig->getJsObject('manage_tools'),
+			'content_id' => $iContentId
+		));
+    }
+}
+
+/** @} */

+ 9 - 23
modules/base/profile/classes/BxBaseModProfileGridAdministration.php

@@ -3,7 +3,7 @@
  * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  *
- * @defgroup    BaseGeneral Base classes for modules
+ * @defgroup    BaseProfile Base classes for profile modules
  * @ingroup     DolphinModules
  * 
  * @{
@@ -58,6 +58,8 @@ class BxBaseModProfileGridAdministration extends BxBaseModGeneralGridAdministrat
 
 	public function performActionDelete($bWithContent = false)
     {
+    	$sPrefixLang = $this->_oModule->_oConfig->getPrefix('lang');
+
     	if($bWithContent) {
 			$this->_echoResultJson(array('msg' => 'TODO: delete with content'));
 	    	return;
@@ -88,7 +90,7 @@ class BxBaseModProfileGridAdministration extends BxBaseModGeneralGridAdministrat
             $iAffected++;
         }
 
-        $this->_echoResultJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aIdsAffected) : array('msg' => _t('_adm_nav_err_menus_delete')));
+        $this->_echoResultJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aIdsAffected) : array('msg' => _t($sPrefixLang . '_grid_action_err_delete')));
     }
 
 	public function performActionDeleteWithContent()
@@ -129,11 +131,13 @@ class BxBaseModProfileGridAdministration extends BxBaseModGeneralGridAdministrat
     {
         parent::_getFilterControls();
 
+        $sPrefixLang = $this->_oModule->_oConfig->getPrefix('lang');
+
         $sFilterName = 'filter1';
         $aFilterValues = array(
-			'active' => '_bx_persons_grid_filter_item_title_adm_active',
-            'pending' => '_bx_persons_grid_filter_item_title_adm_pending',
-            'suspended' => '_bx_persons_grid_filter_item_title_adm_suspended',
+			'active' => $sPrefixLang . '_grid_filter_item_title_adm_active',
+            'pending' => $sPrefixLang . '_grid_filter_item_title_adm_pending',
+            'suspended' => $sPrefixLang . '_grid_filter_item_title_adm_suspended',
 		);
 
         return  $this->_getFilterSelectOne($sFilterName, $aFilterValues) . $this->_getSearchInput();
@@ -153,24 +157,6 @@ class BxBaseModProfileGridAdministration extends BxBaseModGeneralGridAdministrat
         return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
     }
 
-    protected function _getActionSettings($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
-    {
-    	$sName = $this->_oModule->_oConfig->getName() . "_menu_manage_tools";
-    	$sJsObject = $this->_oModule->_oConfig->getJsObject('manage_tools');
-
-    	bx_import('BxDolMenu');
-    	$sMenu = BxDolMenu::getObjectInstance($sName)->getCode();
-    	if(empty($sMenu))
-    		return '';
-
-    	$a['attr'] = array_merge($a['attr'], array(
-    		"bx-popup-id" => $sName . "-" . $aRow['id'],
-    		"onclick" => "$(this).off('click'); " . $sJsObject . ".onClickSettings('" . $sName . "', this);"
-    	));
-
-    	return $this->_getActionDefault ($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
-    }
-
     protected function _getCellLastOnline($mixedValue, $sKey, $aField, $aRow)
     {
         return parent::_getCellDefault(bx_time_js($mixedValue), $sKey, $aField, $aRow);

+ 1 - 1
modules/base/profile/classes/BxBaseModProfileGridModeration.php

@@ -3,7 +3,7 @@
  * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  *
- * @defgroup    BaseGeneral Base classes for modules
+ * @defgroup    BaseProfile Base classes for profile modules
  * @ingroup     DolphinModules
  * 
  * @{

+ 2 - 15
modules/base/profile/classes/BxBaseModProfileMenuManageTools.php

@@ -9,29 +9,16 @@
  * @{
  */
 
-bx_import('BxTemplMenu');
+bx_import('BxBaseModGeneralMenuManageTools');
 
 /**
  * Manage tools submenu
  */
-class BxBaseModProfileMenuManageTools extends BxTemplMenu
+class BxBaseModProfileMenuManageTools extends BxBaseModGeneralMenuManageTools
 {
-	protected $_oModule;
-
     public function __construct($aObject, $oTemplate = false)
     {
         parent::__construct($aObject, $oTemplate);
-
-        $this->_oModule = BxDolModule::getInstance($this->MODULE);
-
-        $iContentId = 0;
-        if(bx_get('content_id') !== false)
-        	$iContentId = (int)bx_get('content_id');
-
-		$this->addMarkers(array(
-			'js_object' => $this->_oModule->_oConfig->getJsObject('manage_tools'),
-			'content_id' => $iContentId
-		));
     }
 }
 

+ 138 - 0
modules/base/text/classes/BxBaseModTextGridAdministration.php

@@ -0,0 +1,138 @@
+<?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('BxBaseModGeneralGridAdministration');
+
+class BxBaseModTextGridAdministration extends BxBaseModGeneralGridAdministration
+{
+	protected $_sFilter1;
+
+    public function __construct ($aOptions, $oTemplate = false)
+    {
+        parent::__construct ($aOptions, $oTemplate);
+
+    	$sFilter1 = bx_get('filter1');
+        if(!empty($sFilter1)) {
+            $this->_sFilter1 = bx_process_input($sFilter1);
+            $this->_aQueryAppend['filter1'] = $this->_sFilter1;
+        }
+    }
+
+	public function performActionDelete()
+    {
+    	$sPrefixLang = $this->_oModule->_oConfig->getPrefix('lang');
+
+        $iAffected = 0;
+        $aIds = bx_get('ids');
+        if(!$aIds || !is_array($aIds)) {
+            $this->_echoResultJson(array());
+            exit;
+        }
+
+        $aIdsAffected = array ();
+        foreach($aIds as $iId) {
+        	if((int)$this->_delete($iId) == 0)
+                continue;
+
+            $aIdsAffected[] = $iId;
+            $iAffected++;
+        }
+
+        $this->_echoResultJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aIdsAffected) : array('msg' => _t($sPrefixLang . '_grid_action_err_delete')));
+    }
+
+    protected function _switcherChecked2State($isChecked)
+    {
+        return $isChecked ? 'active' : 'hidden';
+    }
+
+    protected function _switcherState2Checked($mixedState)
+    {
+        return 'active' == $mixedState ? true : false;
+    }
+
+    protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
+    {
+        if(strpos($sFilter, $this->_sParamsDivider) !== false)
+            list($this->_sFilter1, $sFilter) = explode($this->_sParamsDivider, $sFilter);
+
+    	if(!empty($this->_sFilter1))
+        	$this->_aOptions['source'] .= $this->_oModule->_oDb->prepare(" AND `status`=?", $this->_sFilter1);
+
+        return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
+    }
+
+    //--- Layout methods ---//
+	protected function _getFilterControls()
+    {
+        parent::_getFilterControls();
+
+        $sPrefixLang = $this->_oModule->_oConfig->getPrefix('lang');
+
+        $sFilterName = 'filter1';
+        $aFilterValues = array(
+			'active' => $sPrefixLang . '_grid_filter_item_title_adm_active',
+            'hidden' => $sPrefixLang . '_grid_filter_item_title_adm_hidden',
+		);
+
+        return  $this->_getFilterSelectOne($sFilterName, $aFilterValues) . $this->_getSearchInput();
+    }
+
+	protected function _getCellTitle($mixedValue, $sKey, $aField, $aRow)
+    {
+    	$CNF = &$this->_oModule->_oConfig->CNF;
+
+        bx_import('BxDolPermalinks');
+        $sUrl = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aRow[$CNF['FIELD_ID']]);
+
+        $mixedValue = $this->_oTemplate->parseHtmlByName('bx_a.html', array(
+            'href' => $sUrl,
+            'title' => $mixedValue,
+            'bx_repeat:attrs' => array(),
+            'content' => $mixedValue
+        ));
+
+        return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
+    }
+
+    protected function _getCellAdded($mixedValue, $sKey, $aField, $aRow)
+    {
+        return parent::_getCellDefault(bx_time_js($mixedValue), $sKey, $aField, $aRow);
+    }
+
+    protected function _getCellAuthor($mixedValue, $sKey, $aField, $aRow)
+    {
+    	$oProfile = $this->_getProfileObject($aRow['author']);
+    	$sProfile = $oProfile->getDisplayName();
+
+        $mixedValue = $this->_oTemplate->parseHtmlByName('bx_a.html', array(
+            'href' => $oProfile->getUrl(),
+            'title' => $sProfile,
+            'bx_repeat:attrs' => array(),
+            'content' => $sProfile
+        ));
+
+        return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
+    }
+
+    protected function _getProfileObject($iId)
+    {
+    	bx_import('BxDolProfile');
+        $oProfile = BxDolProfile::getInstance($iId);
+        if (!$oProfile) {
+            bx_import('BxDolProfileUndefined');
+            $oProfile = BxDolProfileUndefined::getInstance();
+        }
+        return $oProfile;
+    }
+}
+
+/** @} */

+ 29 - 0
modules/base/text/classes/BxBaseModTextGridModeration.php

@@ -0,0 +1,29 @@
+<?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('BxBaseModTextGridAdministration');
+
+class BxBaseModTextGridModeration extends BxBaseModTextGridAdministration
+{
+    public function __construct ($aOptions, $oTemplate = false)
+    {
+        parent::__construct ($aOptions, $oTemplate);
+
+        $this->_sManageType = 'moderation';
+    }
+
+	public function performActionDelete()
+    {
+        $this->_echoResultJson(array());
+    }
+}
+
+/** @} */

+ 25 - 0
modules/base/text/classes/BxBaseModTextMenuManageTools.php

@@ -0,0 +1,25 @@
+<?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('BxBaseModGeneralMenuManageTools');
+
+/**
+ * Manage tools submenu
+ */
+class BxBaseModTextMenuManageTools extends BxBaseModGeneralMenuManageTools
+{
+    public function __construct($aObject, $oTemplate = false)
+    {
+        parent::__construct($aObject, $oTemplate);
+    }
+}
+
+/** @} */

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

@@ -23,6 +23,18 @@ class BxBaseModTextModule extends BxBaseModGeneralModule
     }
 
     // ====== SERVICE METHODS
+	public function serviceGetMenuAddonManageTools()
+	{
+		bx_import('SearchResult', $this->_aModule);
+        $sClass = $this->_aModule['class_prefix'] . 'SearchResult';
+        $o = new $sClass();
+        $o->fillFilters(array(
+			'status' => 'hidden'
+        ));
+        $o->unsetPaginate();
+
+        return $o->getNum();
+	}
 
     /**
      * Display pablic entries

+ 1 - 0
modules/boonex/organizations/classes/BxOrgsConfig.php

@@ -80,6 +80,7 @@ class BxOrgsConfig extends BxBaseModProfileConfig
             'OBJECT_MENU_SUBMENU' => 'bx_organizations_submenu', // main module submenu
             'OBJECT_MENU_SUBMENU_VIEW_ENTRY' => 'bx_organizations_view_submenu',  // view entry submenu
             'OBJECT_MENU_SUBMENU_VIEW_ENTRY_MAIN_SELECTION' => 'organizations-home', // first item in view entry submenu from main module submenu
+            'OBJECT_MENU_MANAGE_TOOLS' => 'bx_organizations_menu_manage_tools', //manage menu in content administration tools
             'OBJECT_GRID_ADMINISTRATION' => 'bx_organizations_administration',
         	'OBJECT_GRID_MODERATION' => 'bx_organizations_moderation',
 

+ 1 - 0
modules/boonex/organizations/install/langs/en.xml

@@ -141,6 +141,7 @@
     <string name="_bx_orgs_grid_action_title_adm_delete"><![CDATA[Delete]]></string>
     <string name="_bx_orgs_grid_action_title_adm_delete_with_content"><![CDATA[Delete With Content]]></string>
     <string name="_bx_orgs_grid_action_title_adm_set_acl_level"><![CDATA[Set Membership]]></string>
+	<string name="_bx_orgs_grid_action_err_delete"><![CDATA[Cannot delete the selected organization(s).]]></string>
 
     <string name="_bx_orgs_txt_account_pending"><![CDATA[This profile is pending approval, please wait until it is activated.]]></string>
     <string name="_bx_orgs_txt_account_suspended"><![CDATA[This profile is suspended.]]></string>

+ 1 - 0
modules/boonex/persons/classes/BxPersonsConfig.php

@@ -80,6 +80,7 @@ class BxPersonsConfig extends BxBaseModProfileConfig
             'OBJECT_MENU_SUBMENU' => 'bx_persons_submenu', // main module submenu
             'OBJECT_MENU_SUBMENU_VIEW_ENTRY' => 'bx_persons_view_submenu',  // view entry submenu
             'OBJECT_MENU_SUBMENU_VIEW_ENTRY_MAIN_SELECTION' => 'persons-home', // first item in view entry submenu from main module submenu
+            'OBJECT_MENU_MANAGE_TOOLS' => 'bx_persons_menu_manage_tools', //manage menu in content administration tools
             'OBJECT_GRID_ADMINISTRATION' => 'bx_persons_administration',
         	'OBJECT_GRID_MODERATION' => 'bx_persons_moderation',
 

+ 1 - 0
modules/boonex/persons/install/langs/en.xml

@@ -141,6 +141,7 @@
     <string name="_bx_persons_grid_action_title_adm_delete"><![CDATA[Delete]]></string>
     <string name="_bx_persons_grid_action_title_adm_delete_with_content"><![CDATA[Delete With Content]]></string>
     <string name="_bx_persons_grid_action_title_adm_set_acl_level"><![CDATA[Set Membership]]></string>
+    <string name="_bx_persons_grid_action_err_delete"><![CDATA[Cannot delete the selected person(s).]]></string>
 
     <string name="_bx_persons_txt_account_pending"><![CDATA[This profile is pending approval, please wait until it is activated.]]></string>
     <string name="_bx_persons_txt_account_suspended"><![CDATA[This profile is suspended.]]></string>