HomeHelpTrac

Changeset 15966


Ignore:
Timestamp:
02/08/12 22:43:40 (4 months ago)
Author:
Anton Lesnikov
Message:

Visible For Levels feature unification.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/install/sql/v70.sql

    r15962 r15966  
    30393039  `title` varchar(255) NOT NULL, 
    30403040  `template` varchar(255) NOT NULL, 
     3041  `order` int(11) NOT NULL, 
    30413042  PRIMARY KEY (`id`) 
    30423043) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
    30433044 
    3044 INSERT INTO `sys_pages_design_boxes` (`id`, `title`, `template`) VALUES 
    3045 (0, '_sys_designbox_0', 'designbox_0.html'), 
    3046 (1, '_sys_designbox_1', 'designbox_1.html'), 
    3047 (2, '_sys_designbox_2', 'designbox_2.html'), 
    3048 (3, '_sys_designbox_3', 'designbox_3.html'), 
    3049 (10, '_sys_designbox_10', 'designbox_10.html'), 
    3050 (11, '_sys_designbox_11', 'designbox_11.html'), 
    3051 (13, '_sys_designbox_13', 'designbox_13.html'); 
     3045INSERT INTO `sys_pages_design_boxes` (`id`, `title`, `template`, `order`) VALUES 
     3046(0, '_sys_designbox_0', 'designbox_0.html', '1'), 
     3047(1, '_sys_designbox_1', 'designbox_1.html', '4'), 
     3048(2, '_sys_designbox_2', 'designbox_2.html', '0'), 
     3049(3, '_sys_designbox_3', 'designbox_3.html', '2'), 
     3050(10, '_sys_designbox_10', 'designbox_10.html', '0'), 
     3051(11, '_sys_designbox_11', 'designbox_11.html', '5'), 
     3052(13, '_sys_designbox_13', 'designbox_13.html', '3'); 
    30523053 
    30533054 
  • trunk/modules/boonex/english/install/data/langs/en.xml

    r15963 r15966  
    22052205    <string name="_adm_nav_txt_items_visible"><![CDATA[Visibile For]]></string> 
    22062206    <string name="_adm_nav_btn_items_visible"><![CDATA[Visibile For]]></string> 
     2207    <string name="_adm_nav_txt_items_anyone"><![CDATA[Anyone]]></string> 
    22072208    <string name="_adm_nav_txt_items_n_user_levels"><![CDATA[{0} User Levels]]></string> 
    22082209    <string name="_adm_nav_txt_items_create_popup"><![CDATA[Add New Item]]></string> 
     
    22402241    <string name="_adm_nav_txt_items_show_to_popup"><![CDATA[Show "{0}" menu item to: ]]></string> 
    22412242    <string name="_adm_nav_err_items_show_to"><![CDATA[Cannot update item]]></string> 
    2242     <string name="_adm_nav_txt_items_visible_for_levels"><![CDATA[User Levels]]></string> 
     2243    <string name="_adm_nav_txt_block_visible_for"><![CDATA[Visible For]]></string> 
     2244    <string name="_adm_nav_txt_block_visible_for_all"><![CDATA[Anyone]]></string> 
     2245    <string name="_adm_nav_txt_block_visible_for_selected"><![CDATA[Selected levels]]></string> 
     2246    <string name="_adm_nav_txt_items_visible_for_levels"><![CDATA[Select Levels]]></string> 
    22432247    <string name="_adm_nav_dsc_items_visible_for_levels"><![CDATA[Select user levels that can see this menu item]]></string> 
    22442248    <string name="_adm_lmi_cpt_forms"><![CDATA[Forms]]></string> 
     
    24812485    <string name="_adm_bp_txt_block_designbox_empty"><![CDATA[Select layout...]]></string> 
    24822486    <string name="_adm_bp_txt_block_visible_for"><![CDATA[Visible For]]></string> 
    2483     <string name="_adm_bp_txt_block_visible_for_all"><![CDATA[All]]></string> 
     2487    <string name="_adm_bp_txt_block_visible_for_all"><![CDATA[Anyone]]></string> 
    24842488    <string name="_adm_bp_txt_block_visible_for_selected"><![CDATA[Selected levels]]></string> 
    24852489    <string name="_adm_bp_txt_block_visible_for_levels"><![CDATA[Select Levels]]></string> 
  • trunk/studio/classes/BxDolStudioBuilderPageQuery.php

    r15949 r15966  
    134134 
    135135        if(!isset($aParams['order']) || empty($aParams['order'])) 
    136            $sOrderClause = "ORDER BY `tpd`.`id` ASC"; 
     136           $sOrderClause = "ORDER BY `tpd`.`order` ASC"; 
    137137 
    138138        switch($aParams['type']) { 
     
    140140                $aMethod['name'] = 'getRow'; 
    141141                $sWhereClause = $this->prepare("AND `tpd`.`id`=? ", $aParams['value']); 
     142                break; 
     143            case 'ordered': 
     144                $sWhereClause = "AND `tpd`.`order`<>0 "; 
    142145                break; 
    143146            case 'all': 
  • trunk/studio/classes/BxDolStudioUtils.php

    r15963 r15966  
    7676    } 
    7777 
     78    public static function getVisibilityCount($iValue, $aLevels) { 
     79        $iResult = 0; 
     80 
     81        $iValue = (int)$iValue; 
     82        if($iValue == 0) 
     83            return $iResult; 
     84        else if($iValue == BX_DOL_INT_MAX) 
     85            return -1; 
     86 
     87        $iIndex = 1; 
     88        do { 
     89            if(array_key_exists($iIndex++, $aLevels)) 
     90                $iResult += $iValue & 1; 
     91        } while(($iValue = $iValue >> 1) != 0); 
     92 
     93        return $iResult; 
     94    } 
     95 
    7896    public static function getVisibilityValue($sVisibleFor, $aVisibleForLevels) { 
    7997        if($sVisibleFor == BX_DOL_STUDIO_VISIBLE_ALL) 
    80             return PHP_INT_MAX; 
     98            return BX_DOL_INT_MAX; 
    8199 
    82100        $iVisibleFor = 0; 
  • trunk/studio/js/navigation_items.js

    r15962 r15966  
    3737    glGrids[this.sObjNameGrid].setFilter(sValueModule + this.sParamsDivider + sValueSearch, true); 
    3838}; 
     39BxDolStudioNavigationItems.prototype.onChangeVisibleFor = function(oSelect) { 
     40    $('#bx-form-element-visible_for_levels').bx_anim($(oSelect).val() == 'all' ? 'hide' : 'show', this.sAnimationEffect, this.iAnimationSpeed); 
     41}; 
    3942/** @} */ 
  • trunk/studio/templates/base/scripts/BxBaseStudioBuilderPage.php

    r15963 r15966  
    772772                    'caption' => _t('_adm_bp_txt_block_visible_for'), 
    773773                    'info' => '', 
    774                     'value' => $aBlock['visible_for_levels'] == PHP_INT_MAX ? BX_DOL_STUDIO_VISIBLE_ALL : BX_DOL_STUDIO_VISIBLE_SELECTED, 
     774                    'value' => $aBlock['visible_for_levels'] == BX_DOL_INT_MAX ? BX_DOL_STUDIO_VISIBLE_ALL : BX_DOL_STUDIO_VISIBLE_SELECTED, 
    775775                    'values' => array( 
    776776                        array('key' => BX_DOL_STUDIO_VISIBLE_ALL, 'value' => _t('_adm_bp_txt_block_visible_for_all')), 
     
    793793                    'values' => array(), 
    794794                    'tr_attrs' => array( 
    795                         'style' => $aBlock['visible_for_levels'] == PHP_INT_MAX ? 'display:none' : '' 
     795                        'style' => $aBlock['visible_for_levels'] == BX_DOL_INT_MAX ? 'display:none' : '' 
    796796                    ), 
    797797                    'db' => array ( 
     
    821821 
    822822        $aDBoxes = array(); 
    823         $this->oDb->getDesignBoxes(array('type' => 'all'), $aDBoxes, false); 
     823        $this->oDb->getDesignBoxes(array('type' => 'ordered'), $aDBoxes, false); 
    824824        foreach($aDBoxes as $aDBox) 
    825825            $aForm['inputs']['designbox_id']['values'][] = array('key' => $aDBox['id'], 'value' => _t($aDBox['title'])); 
  • trunk/studio/templates/base/scripts/BxBaseStudioNavigationItems.php

    r15962 r15966  
    531531                    ), 
    532532                ), 
     533                'visible_for' => array( 
     534                    'type' => 'select', 
     535                    'name' => 'visible_for', 
     536                    'caption' => _t('_adm_nav_txt_block_visible_for'), 
     537                    'info' => '', 
     538                    'value' => $aItem['visible_for_levels'] == BX_DOL_INT_MAX ? BX_DOL_STUDIO_VISIBLE_ALL : BX_DOL_STUDIO_VISIBLE_SELECTED, 
     539                    'values' => array( 
     540                        array('key' => BX_DOL_STUDIO_VISIBLE_ALL, 'value' => _t('_adm_nav_txt_block_visible_for_all')), 
     541                        array('key' => BX_DOL_STUDIO_VISIBLE_SELECTED, 'value' => _t('_adm_nav_txt_block_visible_for_selected')), 
     542                    ), 
     543                    'required' => '0', 
     544                    'attrs' => array( 
     545                        'onchange' => $this->getJsObject() . '.onChangeVisibleFor(this)' 
     546                    ), 
     547                    'db' => array ( 
     548                        'pass' => 'Xss', 
     549                    ) 
     550                ), 
    533551                'visible_for_levels' => array( 
    534552                    'type' => 'checkbox_set', 
     
    538556                    'value' => '', 
    539557                    'values' => array(), 
    540                     'checker' => array ( 
    541                         'func' => '', 
    542                         'params' => array(), 
    543                         'error' => '', 
     558                    'tr_attrs' => array( 
     559                        'style' => $aItem['visible_for_levels'] == BX_DOL_INT_MAX ? 'display:none' : '' 
    544560                    ), 
    545561                    'db' => array ( 
     
    568584        ); 
    569585 
    570         bx_import('BxDolAcl'); 
    571         $aLevels = BxDolAcl::getInstance()->getMemberships(); 
    572         foreach($aLevels as $iKey => $sValue) { 
    573             if(((int)$aItem['visible_for_levels'] & pow(2, (int)$iKey - 1)) != 0) 
    574                 $aForm['inputs']['visible_for_levels']['value'][] = $iKey; 
    575              
    576             $aForm['inputs']['visible_for_levels']['values'][$iKey] = _t($sValue); 
    577         } 
    578   
     586        BxDolStudioUtils::getVisibilityValues($aItem['visible_for_levels'], $aForm['inputs']['visible_for_levels']['values'], $aForm['inputs']['visible_for_levels']['value']); 
     587 
    579588        bx_import('BxTemplStudioFormView'); 
    580589        $oForm = new BxTemplStudioFormView($aForm); 
     
    582591 
    583592        if($oForm->isSubmittedAndValid()) { 
    584             $iHideFrom = 0; 
    585             $aLevelIds = $oForm->getCleanValue('visible_for_levels'); 
    586             foreach($aLevelIds as $iLevelId) 
    587                 $iHideFrom += pow(2, $iLevelId - 1); 
    588             BxDolForm::setSubmittedValue('visible_for_levels', $iHideFrom, $aForm['form_attrs']['method']); 
     593            $iVisibleFor = BxDolStudioUtils::getVisibilityValue($oForm->getCleanValue('visible_for'), $oForm->getCleanValue('visible_for_levels')); 
     594            BxDolForm::setSubmittedValue('visible_for_levels', $iVisibleFor, $aForm['form_attrs']['method']); 
     595            unset($oForm->aInputs['visible_for']); 
    589596 
    590597            if($oForm->update($iId) !== false) 
     
    662669 
    663670    protected function _getCellVisibleForLevels ($mixedValue, $sKey, $aField, $aRow) { 
    664         $iIndex = 1; 
    665         $iCount = 0; 
    666         $mixedValue = (int)$aRow['visible_for_levels']; 
    667         if(($mixedValue = (int)$mixedValue) != 0) { 
    668             do { 
    669                 if(array_key_exists($iIndex++, $this->aMemberships)) 
    670                     $iCount += $mixedValue & 1; 
    671             } while(($mixedValue = $mixedValue >> 1) != 0); 
    672         } 
     671        $iCount = BxDolStudioUtils::getVisibilityCount($aRow['visible_for_levels'], $this->aMemberships); 
    673672 
    674673        $mixedValue = $this->_oTemplate->parseHtmlByName('bx_a.html', array( 
     
    679678                array('key' => 'bx_grid_action_data', 'value' => $aRow['id']) 
    680679            ), 
    681             'content' => _t('_adm_nav_txt_items_n_user_levels', $iCount) 
     680            'content' => $iCount != -1 ? _t('_adm_nav_txt_items_n_user_levels', $iCount) : _t('_adm_nav_txt_items_anyone') 
    682681        )); 
    683682 
Note: See TracChangeset for help on using the changeset viewer.