HomeHelpTrac

Changeset 15749 for trunk/templates


Ignore:
Timestamp:
12/12/11 01:37:22 (6 months ago)
Author:
Alexander Trofimov
Message:

Menu

Location:
trunk/templates
Files:
3 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/templates/base/css/common.css

    r15733 r15749  
    3030} 
    3131 
    32 /* --------------- menu main */ 
    33  
    34 #bx-menu-main-container { 
    35     width:100%; 
    36 } 
    37  
    38 #bx-menu-main { 
    39     padding:0; 
    40     margin:0; 
    41     list-style:none; 
    42     border:1px solid #a9a9a9; 
    43     background-color:#fdfdfd; 
    44 } 
    45  
    46 #bx-menu-main li { 
    47     float:left; 
    48     margin-left:30px; 
    49 } 
    50  
    51 #bx-menu-main li:first-child { 
    52     margin-left:20px; 
    53 } 
    54  
    55 #bx-menu-main li a { 
    56     display:block; 
    57     height:48px; 
    58     line-height:48px; 
    59     text-decoration:none; 
    60     font-size:16px; 
    61     font-weight:bold; 
    62 } 
    63  
    64 #bx-menu-main li.bx-menu-tab-active a { 
    65     color:#000; 
    66 } 
    67  
    68 /* --------------- menu main submenu */ 
    69  
    70 #bx-menu-sub-container { 
    71     width:100%; 
    72 } 
    73  
    74 #bx-menu-sub-title { 
    75     float:left; 
    76     padding:0; 
    77     margin:0; 
    78     margin-left:20px; 
    79     height:48px; 
    80     line-height:48px; 
    81     font-size:16px; 
    82     color:#666666; 
    83 } 
    84  
    85 #bx-menu-sub { 
    86     float:left; 
    87     padding:0; 
    88     margin:0; 
    89     list-style:none; 
    90 } 
    91  
    92 #bx-menu-sub li { 
    93     float:left; 
    94     margin-left:18px; 
    95 } 
    96  
    97 #bx-menu-sub li:first-child { 
    98     margin-left:30px; 
    99 } 
    100  
    101 #bx-menu-sub li a { 
    102     display:block; 
    103     height:48px; 
    104     line-height:48px; 
    105     text-decoration:none; 
    106     font-size:13px; 
    107 } 
    108  
    109 #bx-menu-sub li.bx-menu-sub-tab-active a { 
    110     color:#000; 
    111 } 
    112  
    113 /* --------------- menu bottom */ 
    114  
    115 #bx-menu-bottom { 
    116     float:left; 
    117 } 
    118 #bx-menu-bottom span { 
    119     margin-left:15px; 
    120 } 
    121 #bx-menu-bottom span:first-child { 
    122     margin-left:0px; 
    123 } 
     32/* --------------- footer */ 
    12433 
    12534#bx-footer-copyright { 
  • trunk/templates/base/scripts/BxBaseMenu.php

    r15525 r15749  
    1 <?php 
     1<?php defined('BX_DOL') or die('hack attempt'); 
    22/** 
    3  * @package     Dolphin Core 
    4  * @copyright   Copyright (c) BoonEx Pty Limited - http://www.boonex.com/ 
    5  * @license     CC-BY - http://creativecommons.org/licenses/by/3.0/ 
     3 * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/ 
     4 * CC-BY License - http://creativecommons.org/licenses/by/3.0/ 
     5 * 
     6 * @defgroup    DolphinCore Dolphin Core 
     7 * @{ 
    68 */ 
    7 defined('BX_DOL') or die('hack attempt'); 
    89 
    910bx_import('BxDolMenu'); 
     11bx_import('BxDolPaginate'); 
    1012 
     13/** 
     14 * Menu representation. 
     15 * @see BxDolmenu 
     16 */ 
    1117class BxBaseMenu extends BxDolMenu { 
    1218 
    13     var $iElementsCntInLine; 
     19    protected $_oTemplate; 
    1420 
    15     var $sCustomSubIconUrl = ''; 
    16     var $sCustomSubHeader = ''; 
    17     var $sCustomActions; 
    18     var $sBreadCrumb = ''; 
     21    public function __construct ($aObject, $oTemplate) { 
     22        parent::__construct ($aObject); 
    1923 
    20     function BxBaseMenu() { 
    21  
    22         parent::BxDolMenu(); 
    23  
    24         $this->iElementsCntInLine = (int)getParam('nav_menu_elements_on_line_' . (isLogged() ? 'usr' : 'gst')); 
    25     } 
    26  
    27     function setCustomSubIconUrl($sCustomSubIconUrl) { 
    28         $this->sCustomSubIconUrl = $sCustomSubIconUrl; 
    29     } 
    30  
    31     function setCustomSubHeader($sCustomSubHeader) { 
    32         $this->sCustomSubHeader = $sCustomSubHeader; 
    33     } 
    34  
    35     /* 
    36      * Generate actions in submenu place at right. 
    37      */ 
    38     function setCustomSubActions(&$aKeys, $sActionsType, $bSubMenuMode = true) { 
    39  
    40         if (!$sActionsType) { 
    41             $this->sCustomActions = ''; 
    42             return; 
    43         } 
    44  
    45         // prepare all needed keys 
    46         $aKeys['url'] = BX_DOL_URL_ROOT; 
    47  
    48         $sActions = $GLOBALS['oFunctions']->genObjectsActions($aKeys, $sActionsType, $bSubMenuMode); 
    49         $this->sCustomActions = '<div class="menu_user_actions">' . $sActions . '</div>'; 
    50     } 
    51  
    52     /* 
    53      * get top menu 
    54      */ 
    55     function getTopMenu() { 
    56  
    57         if (isset($GLOBALS['bx_profiler'])) $GLOBALS['bx_profiler']->beginMenu('Top Menu'); 
    58  
    59         $this->_init(); 
    60  
    61         $sRet = $this->_getMenu ('menu_top.html', 'top', 0, $this->aMenuInfo['currentTop'], array ( 
    62             'item_active' => 'bx-menu-tab-active', 
    63             'item_inctive' => '', 
    64             'link_active' => '', 
    65             'link_inctive' => '', 
    66         )); 
    67  
    68         if (isset($GLOBALS['bx_profiler'])) $GLOBALS['bx_profiler']->endMenu('Top Menu'); 
    69  
    70         return $sRet; 
     24        if ($oTemplate) 
     25            $this->_oTemplate = $oTemplate; 
     26        else 
     27            $this->_oTemplate = BxDolTemplate::getInstance(); 
    7128    } 
    7229 
    7330 
    74     /* 
    75      * Get sub-menu 
    76      */ 
    77     function getSubMenu ($iParentItemId = 0) { 
     31    public function getCode () {         
    7832 
    79         if (isset($GLOBALS['bx_profiler'])) $GLOBALS['bx_profiler']->beginMenu('Top Sub Menu'); 
     33        $aVars = array ( 
     34            'object' => $this->_sObject, 
     35            'bx_repeat:menu_items' => $this->_getMenuItems (), 
     36        ); 
    8037 
    81         $this->_init(); 
     38        $this->_addJsCss(); 
     39                 
     40        return $this->_oTemplate->parseHtmlByName($this->_aObject['template'], $aVars); 
     41    } 
    8242 
    83         if (!$iParentItemId) 
    84             $iParentItemId = $this->aMenuInfo['currentTop']; 
     43    protected function _getMenuItems () { 
     44        $aRet = array(); 
     45        if (!isset($this->_aObject['menu_items'])) 
     46            $this->_aObject['menu_items'] = $this->_oQuery->getMenuItems();         
    8547 
     48        foreach ($this->_aObject['menu_items'] as $a) { 
    8649 
    87         $sTitle = ''; 
    88         $sImage = ''; 
    89         if ($iParentItemId && isset($this->aTopMenu[$iParentItemId]) && $this->aTopMenu[$iParentItemId]) { 
    90             $sTitle = _t($this->aTopMenu[$iParentItemId]['Caption']); 
    91             $sImage = $this->aTopMenu[$iParentItemId]['Icon'] ? $this->aTopMenu[$iParentItemId]['Icon'] : $this->aTopMenu[$iParentItemId]['Picture']; 
     50            if (!$a['active']) 
     51                continue; 
     52 
     53            if (!$this->_isVisible($a)) 
     54                continue; 
     55 
     56            if (!$this->_replaceMarkers($a)) 
     57                continue; 
     58 
     59            $a['class_add'] = $this->_isSelected($a) ? 'bx-menu-tab-active' : ''; 
     60            $a['link'] = $this->_oPermalinks->permalink($a['link']); 
     61            $a['title'] = _t($a['title']);             
     62 
     63            $aRet[] = $a; 
    9264        } 
    9365 
    94         $sRet = $this->_getMenu ('menu_sub.html', 'custom', $iParentItemId, $this->aMenuInfo['currentCustom'], array ( 
    95             'item_active' => 'bx-menu-sub-tab-active', 
    96             'item_inctive' => '', 
    97             'link_active' => '', 
    98             'link_inctive' => '', 
    99         ), 
    100         array ( 
    101             'icon' => $sImage ? getTemplateIcon($sImage) : '', 
    102             'title' => $sTitle, 
    103             'class_add' => $sImage ? 'bx-icon-16-background' : '', 
    104         )); 
    105  
    106         if (isset($GLOBALS['bx_profiler'])) $GLOBALS['bx_profiler']->endMenu('Top Sub Menu'); 
    107  
    108         return $sRet; 
     66        return $aRet; 
    10967    } 
    110  
    111     function getBreadcrumb() { 
    112  
    113         if (isset($GLOBALS['bx_profiler'])) $GLOBALS['bx_profiler']->beginMenu('Breadcrumbs'); 
    114  
    115         $aReadyLinks = array ( 
    116             array ( 
    117                 'link' => BX_DOL_URL_ROOT, 
    118                 'caption' => _t('_Home'), 
    119             ), 
    120         ); 
    121  
    122         if (!empty($this->aCustomBreadcrumbs)) { 
    123  
    124             $a = array(); 
    125             foreach ($this->aCustomBreadcrumbs as $sTitle => $sLink) { 
    126                 if (!$sTitle) 
    127                     continue; 
    128                 $aReadyLinks[] = array ( 
    129                     'link' => $sLink, 
    130                     'caption' => $sTitle, 
    131                 ); 
    132             } 
    133  
    134         } else { 
    135  
    136             $a = array ($this->aMenuInfo['currentTop']); 
    137             foreach ($a as $iId) 
    138                 if ($iId && isset($this->aTopMenu[$iId]) && $this->aTopMenu[$iId]) 
    139                     $aReadyLinks[] = array ( 
    140                         'link' => $this->_prepareLink ($this->aTopMenu[$iId]['Link']), 
    141                         'caption' => _t($this->aTopMenu[$iId]['Caption']), 
    142                     ); 
    143         } 
    144  
    145         if (1 == count($aReadyLinks)) 
    146             return ''; 
    147  
    148         $aVars = array ( 
    149             'bx_repeat:links' => $aReadyLinks, 
    150         ); 
    151  
    152         bx_import('BxDolTemplate'); 
    153         $sRet =  BxDolTemplate::getInstance()->parseHtmlByName ('breadcrumbs.html', $aVars); 
    154  
    155         if (isset($GLOBALS['bx_profiler'])) $GLOBALS['bx_profiler']->endMenu('Breadcrumbs'); 
    156  
    157         return $sRet; 
    158     } 
    159  
    160     /** 
    161      * Universal function for generating top- and sub- menu 
    162      */ 
    163     function _getMenu ($sTemplateName, $sType, $iParentId, $iCurrentId, $aClasses, $aVars = array()) { 
    164  
    165         $aMenuReady = array (); 
    166  
    167         foreach( $this->aTopMenu as $iItemID => $aItem ) { 
    168  
    169             if ($aItem['Type'] != $sType || $aItem['Parent'] != $iParentId || !$this->_checkToShow($aItem)) 
    170                 continue; 
    171  
    172             $bActive = ($iItemID == $iCurrentId); 
    173             $aItem['Onclick'] = $this->_replaceMetas($aItem['Onclick']); 
    174             $sImage = $aItem['Icon'] ? $aItem['Icon'] : $aItem['Picture']; 
    175  
    176             $aMenuReady[] = array ( 
    177                 'caption' => _t($aItem['Caption']), 
    178                 'link' => $this->_prepareLink ($aItem['Link']), 
    179                 'onclick' => !$bActive && $aItem['Onclick'] ? $aItem['Onclick'] : '', 
    180                 'target' => !$bActive && $aItem['Target'] ? $aItem['Target'] : '', 
    181                 'image' => $sImage ? getTemplateIcon($sImage) : '', 
    182                 'classes_item' => $bActive ? $aClasses['item_active'] : $aClasses['item_inctive'], 
    183                 'classes_link' => $bActive ? $aClasses['link_active'] : $aClasses['link_inctive'], 
    184             ); 
    185         } 
    186  
    187         if (!$aMenuReady) 
    188             return ''; 
    189  
    190         $aVars['bx_repeat:menu'] = $aMenuReady; 
    191  
    192         bx_import('BxDolTemplate'); 
    193         return BxDolTemplate::getInstance()->parseHtmlByName ($sTemplateName, $aVars); 
    194     } 
    195  
    196     function _prepareLink ($sLink) { 
    197  
    198         list($sLink) = explode('|', $sLink); 
    199  
    200         $sLink = $this->_replaceMetas($sLink); 
    201  
    202         if (strncmp($sLink, 'http:', 5) != 0 && strncmp($sLink, 'https:', 6) != 0 && strncmp($sLink, 'mailto:', 7) != 0 && strncmp($sLink, 'javascript:', 11) != 0) 
    203             $sLink =  BX_DOL_URL_ROOT . $sLink; 
    204  
    205         return $sLink; 
    206     } 
    207  
    208     // =================================================================== 
    209     // =================================================================== 
    210     // functions below are need cleaning/reorganization 
    211     // =================================================================== 
    212     // =================================================================== 
    213  
    214  
    215     /* 
    216     * Generate search element 
    217     */ 
    218     function genSearchElement() { 
    219         $sSearchC = _t('_Search'); 
    220         ob_start(); 
    221 ?> 
    222 <script language="javascript"> 
    223 $(document).ready( function() { 
    224     $('#keyword').blur(function() { 
    225             $('#keyword').removeClass(); 
    226             $('#keyword').addClass('input_main'); 
    227             if ('' == $('#keyword').val()) 
    228                 $('#keyword').val('<?= $sSearchC ?>'); 
    229         } 
    230     ); 
    231     $('#keyword').focus(function() { 
    232             $('#keyword').removeClass(); 
    233             $('#keyword').addClass('input_focus'); 
    234             if ('<?= $sSearchC ?>' == $('#keyword').val()) 
    235                 $('#keyword').val(''); 
    236         } 
    237     ); 
    238 }); 
    239 </script> 
    240 <li> 
    241     <div id="gse_search"> 
    242         <form action="searchKeyword.php" method="get" name="SearchForm"> 
    243             <input type="text" name="keyword" id="keyword" value="<?= $sSearchC ?>" class="input_main"/> 
    244         </form> 
    245     </div> 
    246     <div class="clear_both"></div> 
    247 </li> 
    248 <? 
    249         $sSearchElement = ob_get_clean(); 
    250  
    251         return array ( 
    252             'icon_url' => getTemplateIcon('tm_item_search.png'), 
    253             'element_content' => $sSearchElement 
    254         ); 
    255     } 
    256  
    257     /* 
    258     * Generate templates element 
    259     */ 
    260     function genMoreTemplatesElement(){ 
    261         if(!getParam("enable_template")) 
    262             return; 
    263  
    264         $aExistedTemplates = get_templates_array(); 
    265         if(count($aExistedTemplates) <= 1) 
    266             return; 
    267  
    268         $sCurTemplate = strlen($_GET['skin']) ? $_GET['skin'] : $_COOKIE['skin']; 
    269  
    270         $sTemplateElement = ''; 
    271         foreach ($aExistedTemplates as $sTemplateID => $sTemplateVal) { 
    272             //$sIActiveStyles = ($sCurTemplate == $sTemplateID) ? 'color:#333;font-weight:bold;' : ''; 
    273             $sIActiveClass = ($sCurTemplate == $sTemplateID) ? ' active' : ''; 
    274  
    275             $sTemplateUrl = ''; 
    276             if ($sCurTemplate == $sTemplateID) { 
    277                 $sTemplateUrl = 'javascript: void(0)'; 
    278             } else { 
    279                 if (defined('BX_PROFILE_PAGE')) { 
    280                     global $profileID; 
    281                     $sTemplateUrl = getProfileLink($profileID) . '&skin='. $sTemplateID; 
    282                 } else { 
    283                     foreach ($_GET as $sParamKey => $sParamValue) { 
    284                         if ('skin' != $sParamKey) 
    285                             $sGetTransfer .= "&{$sParamKey}={$sParamValue}"; 
    286                     } 
    287                     $sTemplateUrl = $_SERVER['PHP_SELF'] . '?skin='. $sTemplateID . $sGetTransfer; 
    288                 } 
    289             } 
    290  
    291             //$sIOnclick = "window.open('{$sTemplateUrl}','_self');"; // old version 
    292             $sTemplateElement .= '<li><a href="' . $sTemplateUrl . '" class="button more_ntop_element' . $sIActiveClass . '">'.$sTemplateVal.'</a>'; 
    293         } 
    294  
    295         if($sTemplateElement == '') 
    296             return; 
    297  
    298         return array( 
    299             'icon_url' => getTemplateIcon('tm_item_templates.png'), 
    300             'element_content' => $sTemplateElement 
    301         ); 
    302     } 
    303  
    304     /* 
    305     * Generate languages element 
    306     */ 
    307     function genMoreLanguagesElement(){ 
    308         bx_import('BxDolLanguagesQuery'); 
    309         $aExistedLanguages = BxDolLanguagesQuery::getInstance()->getLanguages(); 
    310         if(count($aExistedLanguages) <= 1)  
    311             return; 
    312  
    313         $sCurLanguage = strlen($_GET['lang']) ? $_GET['lang'] : $_COOKIE['lang']; 
    314  
    315         $sLanguageElement = ''; 
    316         foreach ($aExistedLanguages as $sLanguageID => $sLanguageVal) { 
    317             //$sIActiveStyles = ($sCurLanguage == $sLanguageID) ? 'color:#333;font-weight:bold;' : ''; 
    318             $sIActiveClass = ($sCurLanguage == $sLanguageID) ? ' active' : ''; 
    319             $sLanguageUrl = ''; 
    320             if ($sCurLanguage == $sLanguageID) { 
    321                 $sLanguageUrl = 'javascript: void(0)'; 
    322             } else { 
    323  
    324                 $sGetTransfer = ''; 
    325                 foreach ($_GET as $sParamKey => $sParamValue) 
    326                     if ('lang' != $sParamKey) 
    327                         $sGetTransfer .= "{$sParamKey}={$sParamValue}&"; 
    328  
    329                 $sLanguageUrl = $this->oPermalinks->permalink($_SERVER['PHP_SELF'] . '?' . $sGetTransfer . 'lang='. $sLanguageID); 
    330             } 
    331  
    332             $sLanguageElement .= '<li><a href="' . $sLanguageUrl . '" value="' . $sLanguageVal . '" class="button more_ntop_element' . $sIActiveClass . '">'.$sLanguageVal.'</a>'; 
    333         } 
    334  
    335         if ($sLanguageElement == '') return; 
    336  
    337         return array( 
    338             'icon_url' => getTemplateIcon('tm_item_languages.png'), 
    339             'element_content' => $sLanguageElement 
    340         ); 
     68     
     69    protected function _addJsCss() { 
     70        $this->_oTemplate->addCss('menu.css'); 
    34171    } 
    34272 
    34373} 
    34474 
     75/** @} */ 
  • trunk/templates/tmpl_uni/scripts/BxTemplMenu.php

    r15211 r15749  
    1 <?php 
     1<?php defined('BX_DOL') or die('hack attempt'); 
    22/** 
    3  * @package     Dolphin Core 
    4  * @copyright   Copyright (c) BoonEx Pty Limited - http://www.boonex.com/ 
    5  * @license     CC-BY - http://creativecommons.org/licenses/by/3.0/ 
     3 * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/ 
     4 * CC-BY License - http://creativecommons.org/licenses/by/3.0/ 
     5 * 
     6 * @defgroup    DolphinCore Dolphin Core 
     7 * @{ 
    68 */ 
    7 defined('BX_DOL') or die('hack attempt'); 
    89 
    910bx_import('BxBaseMenu'); 
    1011 
    1112/** 
    12 * @see BxBaseMenu 
    13 */ 
     13 * @see BxDolMenu 
     14 */ 
    1415class BxTemplMenu extends BxBaseMenu { 
    15     /** 
    16     * Class constructor; 
    17     */ 
    18     function BxTemplMenu() { 
    19         parent::BxBaseMenu(); 
     16 
     17    public function __construct ($aObject, $oTemplate = false) { 
     18        parent::__construct ($aObject, $oTemplate); 
    2019    } 
    2120} 
    2221 
     22/** @} */ 
Note: See TracChangeset for help on using the changeset viewer.