[ Index ]

PHP Cross Reference of PageLines DMS

title

Body

[close]

/sections/navbar/ -> section.php (source)

   1  <?php
   2  /*
   3      Section: NavBar
   4      Author: PageLines
   5      Author URI: http://www.pagelines.com
   6      Description: A responsive and sticky navigation bar for your website.
   7      Class Name: PLNavBar
   8      Workswith: header
   9      Compatibility: 2.2
  10      Cloning: false
  11      Filter: nav
  12  */
  13  
  14  /**
  15   * Main section class
  16   *
  17   * @package PageLines DMS
  18   * @author PageLines
  19   */
  20  class PLNavBar extends PageLinesSection {
  21  
  22      var $default_limit = 2;
  23  
  24  
  25      /**
  26       * Load styles and scripts
  27       */
  28  	function section_styles() {
  29  
  30          wp_enqueue_script( 'navbar', $this->base_url.'/navbar.js', array( 'jquery' ), PL_CORE_VERSION, true );
  31      }
  32  
  33  	function section_head() {
  34          ?>
  35              <!--[if IE 8]>
  36                  <style>
  37                      .nav-collapse.collapse {
  38                          height: auto;
  39                          overflow: visible;
  40                      }
  41                  </style>
  42              <![endif]-->
  43          <?php
  44      }
  45  
  46  	function section_opts(){
  47  
  48          $opts = array(
  49  
  50  
  51              array(
  52                  'default'     => '',
  53                  'key'        => 'navbar_multi_option_theme',
  54                  'type'         => 'multi',
  55                  'opts'=> array(
  56  
  57                       array(
  58                              'key'            => 'navbar_theme',
  59                              'default'        => 'base',
  60                              'type'             => 'select',
  61                              'label'     => __( 'Standard NavBar - Select Theme', 'pagelines' ),
  62                              'opts'    => array(
  63                                  'base'            => array( 'name'    => __( 'Base Color', 'pagelines' ) ),
  64                                  'black-trans'    => array( 'name'    => __( 'Black (Default)', 'pagelines' ) ),
  65                                  'blue'            => array( 'name'    => __( 'Blue', 'pagelines' ) ),
  66                                  'grey'            => array( 'name'    => __( 'Light Grey', 'pagelines' ) ),
  67                                  'orange'        => array( 'name'    => __( 'Orange', 'pagelines' ) ),
  68                                  'red'            => array( 'name'    => __( 'Red', 'pagelines' ) ),
  69                              ),
  70                          ),
  71                  ),
  72                  'title'                    => __( 'NavBar Theme', 'pagelines' ),
  73                  'help'                    => __( 'The NavBar comes with several color options. Select one to automatically configure.', 'pagelines' )
  74  
  75              ),
  76              array(
  77                  'key'        => 'navbar_multi_option_menu',
  78                  'type'         => 'multi',
  79                  'title'        => __( 'NavBar Menu', 'pagelines' ),
  80                  'help'        => __( 'The NavBar uses WordPress menus. Select one for use.', 'pagelines' ),
  81                  'opts'        => array(
  82                      array(
  83                              'key'            => 'navbar_menu' ,
  84                              'type'             => 'select_menu',
  85                              'label'     => __( 'Select Menu', 'pagelines' ),
  86                          ),
  87                  ),
  88  
  89  
  90              ),
  91              array(
  92                  'key'        => 'navbar_multi_check',
  93                  'type'         => 'multi',
  94                  'title'                    => __( 'NavBar Configuration Options', 'pagelines' ),
  95                  'opts'        => array(
  96                      array(
  97                          'key'    => 'navbar_title',
  98                          'type'         => 'text',
  99                          'label'=> __( 'NavBar Title', 'pagelines' ),
 100                          'title'        => __( 'NavBar Title', 'pagelines' ),
 101                          'help'        => __( 'Add text to the NavBar to serve as a title, but only displayed on small screens.', 'pagelines' ),
 102                      ),
 103                      array(
 104                          'key'            => 'navbar_enable_hover',
 105                          'type'            => 'check',
 106                          'label'            => __( 'Activate dropdowns on hover.', 'pagelines' ),
 107                      ),
 108  
 109                      array(
 110                          'key'            => 'navbar_alignment',
 111                          'type'            => 'check',
 112                          'default'        => true,
 113                          'label'        => __( 'Align Menu Right? (Defaults Left)', 'pagelines' ),
 114                      ),
 115                      array(
 116                          'key'            => 'navbar_hidesearch',
 117                          'type'            => 'check',
 118                          'label'        => __(  'Hide Search?', 'pagelines' ),
 119                      ),
 120                  ),
 121  
 122              ),
 123  
 124  
 125  
 126          );
 127  
 128          return $opts;
 129  
 130      }
 131  
 132  	function add_settings( $settings ){
 133  
 134          $settings[ $this->id ] = array(
 135                  'name'     => __( 'NavBar', 'pagelines' ),
 136                  'icon'    => 'icon-list-alt',
 137                  'pos'    => 5,
 138                  'opts'     => $this->fixed_options()
 139          );
 140  
 141          return $settings;
 142      }
 143  
 144  	function fixed_options(){
 145  
 146          $fixed_opts = array(
 147              array(
 148                      'key'        => 'navbar_fixed',
 149                      'default'    => true,
 150                      'version'    => 'pro',
 151                      'type'        => 'check',
 152                      'inputlabel'=> __( 'Enable Fixed Navigation Bar', 'pagelines' ),
 153                      'title'        => __( 'Enable Fixed Navigation Bar', 'pagelines' ),
 154                      'help'        => __( 'Use this feature to add the NavBar section as a fixed navigation bar on the top of your site.', 'pagelines' )
 155                  ),
 156              array(
 157                      'key'        => 'navbar_logo',
 158                      'default'    => '[pl_parent_url]/images/dms.png',
 159                      'version'    => 'pro',
 160                      'col'        => 2,
 161                      'type'        => 'image_upload',
 162                      'label'        => __( 'NavBar Logo', 'pagelines' ),
 163                      'title'        => __( 'NavBar Logo', 'pagelines' ),
 164                      'ref'        => __( 'Use this feature to add the NavBar section as a fixed navigation bar on the top of your site.<br/><br/><strong>Notes:</strong> <br/>1. Only visible in Fixed Mode.<br/>2. Image Height is constricted to a maximum 29px.', 'pagelines' )
 165                  ),
 166  
 167          );
 168  
 169  
 170          $opts = $this->section_opts();
 171  
 172          foreach($opts as $index => &$opt){
 173              if($opt['type'] == 'multi'){
 174                  foreach($opt['opts'] as $sub_index => &$sub_opt){
 175  
 176                      if( $sub_opt['key'] == 'navbar_title' )
 177                          unset($opt['opts'][$sub_index]);
 178  
 179                      $sub_opt['key'] = 'fixed_'.$sub_opt['key'];
 180  
 181                      if(isset($sub_opt['title']))
 182                          $sub_opt['title'] = 'Fixed '.$sub_opt['title'];
 183  
 184  
 185                  }
 186                  unset($sub_opt);
 187              }
 188  
 189              $opt['key'] = 'fixed_'.$opt['key'];
 190              $opt['title'] = 'Fixed '.$opt['title'];
 191  
 192          }
 193          unset($opt);
 194  
 195          return array_merge($fixed_opts, $opts);
 196  
 197      }
 198  
 199  	function section_persistent() {
 200  
 201  
 202          add_filter('pl_settings_array', array( $this, 'add_settings'));
 203  
 204          $option_args = array(
 205  
 206              'name'        => __( 'NavBar', 'pagelines' ),
 207              'array'        => $this->old_options(),
 208              'icon'        => $this->icon,
 209              'position'    => 6
 210          );
 211  
 212          pl_add_options_page( $option_args );
 213  
 214          if($this->opt('navbar_fixed')){
 215  
 216              build_passive_section( array( 'sid' => $this->class_name ) );
 217  
 218              pagelines_add_bodyclass( 'editor_navbar_fixed' );
 219              add_action( 'pagelines_fixed_top', array( $this,'passive_section_template' ), 11, 2);
 220  
 221          }
 222  
 223  
 224  
 225      }
 226  
 227  
 228  	function before_section_template( $location = '' ) {
 229  
 230          $format = ( $location == 'passive' ) ? 'open' : 'standard';
 231          $this->special_classes = ( $location == 'passive' ) ? ' fixed-top' : '';
 232          $this->settings['format'] = $format;
 233  
 234      }
 235  
 236      /**
 237      * Section template.
 238      */
 239     function section_template( $location = false ) {
 240  
 241      $passive = ( 'passive' == $location ) ? true : false;
 242      $class = array();
 243  
 244      // if fixed mode
 245      if( $passive ){
 246  
 247          $class[] = 'navbar-full-width';
 248          $content_width_class = (pl_has_editor()) ? 'pl-content boxed-wrap boxed-nobg' : 'content';
 249          $theme = ( $this->opt('fixed_navbar_theme' ) ) ? $this->opt( 'fixed_navbar_theme' ) : false;
 250          $align = ( $this->opt( 'fixed_navbar_alignment' ) ) ? $this->opt( 'fixed_navbar_alignment' ) : false;
 251          $hidesearch = ( $this->opt( 'fixed_navbar_hidesearch' ) ) ? $this->opt( 'fixed_navbar_hidesearch' ) : false;
 252          $menu = ( $this->opt( 'fixed_navbar_menu' ) ) ? $this->opt( 'fixed_navbar_menu' ) : null;
 253          $class[] = ( $this->opt( 'fixed_navbar_enable_hover' ) ) ? 'plnav_hover' : '';
 254  
 255      } else {
 256  
 257          $class[] = 'navbar-content-width';
 258          $content_width_class = '';
 259          $theme = ( $this->opt( 'navbar_theme' ) ) ? $this->opt( 'navbar_theme' ) : false;
 260          $align = ( $this->opt('navbar_alignment' ) ) ? $this->opt( 'navbar_alignment' ) : false;
 261          $hidesearch = ( $this->opt( 'navbar_hidesearch' ) ) ? $this->opt( 'navbar_hidesearch' ) : false;
 262          $menu = ( $this->opt( 'navbar_menu' ) ) ? $this->opt( 'navbar_menu' ) : null;
 263          $class[] = ( $this->opt( 'navbar_enable_hover' ) ) ? 'plnav_hover' : '';
 264      }
 265  
 266      $pull = ( $align ) ? 'right' : 'left';
 267      $align_class = sprintf( 'pull-%s', $pull );
 268  
 269  
 270      $class[] = ( $theme ) ? sprintf( 'pl-color-%s', $theme ) : 'pl-color-black-trans';
 271  
 272      $classes = join(' ', $class);
 273  
 274      $brand = ( $this->opt( 'navbar_logo' ) || $this->opt( 'navbar_logo' ) != '') ? sprintf( '<img src="%s" alt="%s" />', $this->opt( 'navbar_logo' ), get_bloginfo( 'name' ) ) : sprintf( '<h2 class="plbrand-text">%s</h2>', get_bloginfo( 'name' ) );
 275      $navbartitle = $this->opt( 'navbar_title' );
 276  
 277      ?>
 278      <div class="navbar fix <?php echo $classes; ?>">
 279        <div class="navbar-inner <?php echo $content_width_class;?>">
 280          <div class="navbar-content-pad fix">
 281              <?php
 282                  global $pldraft;
 283                  $edit = false;
 284                  if( is_object( $pldraft ) && 'draft' == $pldraft->mode )
 285                      $edit = true;                
 286                  if( current_user_can( 'edit_theme_options' ) && $passive && true == $edit )
 287                      echo pl_dms_settings_link('settings', 'navbar', 'btn btn-edit btn-mini navbar-edit');
 288          
 289                     if($navbartitle)
 290                      printf( '<span class="navbar-title">%s</span>',$navbartitle );
 291              ?>
 292            <a href="javascript:void(0)" class="nav-btn nav-btn-navbar mm-toggle">
 293              <?php _e('MENU', 'pagelines'); ?> <i class="icon-reorder"></i>
 294            </a>
 295              <?php if($passive):
 296                  printf( '<a class="plbrand" href="%s" title="%s">%s</a>',
 297                      esc_url( home_url() ),
 298                      esc_attr( get_bloginfo('name') ),
 299                      apply_filters('navbar_brand', $brand)
 300                   );
 301              endif;
 302                  pagelines_register_hook('pagelines_navbar_before_menu');
 303                  ?>
 304                    <div class="nav-collapse collapse">
 305             <?php     if( !$hidesearch ) {
 306                             pagelines_register_hook('pagelines_navbar_before_search');
 307                          get_search_form();
 308                          pagelines_register_hook('pagelines_navbar_after_search');
 309  
 310                      }
 311  
 312                      if ( is_array( wp_get_nav_menu_items( $menu ) ) || has_nav_menu( 'primary' ) ) {
 313                      wp_nav_menu(
 314                          array(
 315                              'menu_class'        => 'font-sub navline pldrop ' . $align_class,
 316                              'menu'                => $menu,
 317                              'container'            => null,
 318                              'container_class'    => '',
 319                              'depth'                => 3,
 320                              'fallback_cb'        => ''
 321                          )
 322                      );
 323                      } else {
 324                          pl_nav_fallback( 'navline pldrop '.$align_class );
 325                      }
 326      ?>
 327                  </div>
 328                  <?php
 329                  pagelines_register_hook('pagelines_navbar_after_menu');
 330                  ?>
 331                  <div class="clear"></div>
 332              </div>
 333          </div>
 334      </div>
 335  <?php }
 336  
 337  
 338  	function old_options(){
 339              $options = array(
 340                  'navbar_fixed' => array(
 341                          'default'    => false,
 342                          'version'    => 'pro',
 343                          'type'        => 'check',
 344                          'inputlabel'=> __( 'Enable Fixed Navigation Bar', 'pagelines' ),
 345                          'title'        => __( 'Enable Fixed Navigation Bar', 'pagelines' ),
 346                          'shortexp'    => __( 'Applies a fixed navigation bar to the top of your site', 'pagelines' ),
 347                          'exp'        => __( 'Use this feature to add the NavBar section as a fixed navigation bar on the top of your site.', 'pagelines' )
 348                      ),
 349                  'navbar_logo' => array(
 350                          'default'    => $this->base_url.'/logo.png',
 351                          'version'    => 'pro',
 352                          'type'        => 'image_upload',
 353                          'inputlabel'=> __( 'Fixed NavBar Logo', 'pagelines' ),
 354                          'title'        => __( 'Fixed NavBar - NavBar Logo', 'pagelines' ),
 355                          'shortexp'    => __( 'Applies a fixed navigation bar to the top of your site', 'pagelines' ),
 356                          'exp'        => __( 'Use this feature to add the NavBar section as a fixed navigation bar on the top of your site.<br/><br/><strong>Notes:</strong> <br/>1. Only visible in Fixed Mode.<br/>2. Image Height is constricted to a maximum 29px.', 'pagelines' )
 357                      ),
 358  
 359                  'navbar_multi_option_theme' => array(
 360                      'default' => '',
 361                      'type' => 'multi_option',
 362                      'selectvalues'=> array(
 363  
 364                          'fixed_navbar_theme' => array(
 365                                  'default'        => 'black-trans',
 366                                  'type'             => 'select',
 367                                  'inputlabel'     => __( 'Fixed NavBar - Select Theme', 'pagelines' ),
 368                                  'selectvalues'    => array(
 369                                      'black-trans'    => array( 'name'    => __( 'Black (Default)', 'pagelines' ) ),
 370                                      'blue'            => array( 'name'    => __( 'Blue', 'pagelines' ) ),
 371                                      'grey'            => array( 'name'    => __( 'Light Grey', 'pagelines' ) ),
 372                                      'orange'        => array( 'name'    => __( 'Orange', 'pagelines' ) ),
 373                                      'red'            => array( 'name'    => __( 'Red', 'pagelines' ) ),
 374                                  ),
 375                              ),
 376                          'navbar_theme' => array(
 377                                  'default'        => 'black-trans',
 378                                  'type'             => 'select',
 379                                  'inputlabel'     => __( 'Standard NavBar - Select Theme', 'pagelines' ),
 380                                  'selectvalues'    => array(
 381                                      'black-trans'    => array( 'name'    => __( 'Black (Default)', 'pagelines' ) ),
 382                                      'blue'            => array( 'name'    => __( 'Blue', 'pagelines' ) ),
 383                                      'grey'            => array( 'name'    => __( 'Light Grey', 'pagelines' ) ),
 384                                      'orange'        => array( 'name'    => __( 'Orange', 'pagelines' ) ),
 385                                      'red'            => array( 'name'    => __( 'Red', 'pagelines' ) ),
 386                                  ),
 387                              ),
 388                      ),
 389                      'title'                    => __( 'NavBar and Fixed NavBar Theme', 'pagelines' ),
 390                      'shortexp'                => __( 'Select the color and theme of the NavBar', 'pagelines' ),
 391                      'exp'                    => __( 'The NavBar comes with several color options. Select one to automatically configure.', 'pagelines' )
 392  
 393                  ),
 394                  'navbar_multi_option_menu' => array(
 395                      'default' => '',
 396                      'type' => 'multi_option',
 397                      'selectvalues'=> array(
 398  
 399                          'fixed_navbar_menu' => array(
 400                                  'default'        => 'black-trans',
 401                                  'type'             => 'select_menu',
 402                                  'inputlabel'     => __( 'Fixed NavBar - Select Menu', 'pagelines' ),
 403                              ),
 404                          'navbar_menu' => array(
 405                                  'default'        => 'black-trans',
 406                                  'type'             => 'select_menu',
 407                                  'inputlabel'     => __( 'Standard NavBar - Select Menu', 'pagelines' ),
 408                              ),
 409                      ),
 410                      'title'                    => __( 'NavBar and Fixed NavBar Menu', 'pagelines' ),
 411                      'shortexp'                => __( 'Select the WordPress Menu for the NavBar(s)', 'pagelines' ),
 412                      'exp'                    => __( 'The NavBar uses WordPress menus. Select one for use.', 'pagelines' )
 413  
 414                  ),
 415  
 416                  'navbar_multi_check' => array(
 417                      'default' => '',
 418                      'type' => 'check_multi',
 419                      'selectvalues'=> array(
 420  
 421                          'navbar_enable_hover'        =>    array(
 422                              'inputlabel'            => __( 'Activate dropdowns on hover.', 'pagelines' ),
 423                          ),
 424  
 425                          'fixed_navbar_alignment'    => array(
 426                                  'inputlabel'        => __( 'Fixed NavBar - Align Menu Right? (Defaults Left)', 'pagelines' ),
 427                              ),
 428                          'fixed_navbar_hidesearch'    => array(
 429                                  'inputlabel'        => __( 'Fixed NavBar - Hide Searchform?', 'pagelines' ),
 430                              ),
 431                          'navbar_alignment'            => array(
 432                                  'inputlabel'        => __( 'Standard NavBar - Align Menu Right? (Defaults Left)', 'pagelines' ),
 433                              ),
 434                          'navbar_hidesearch'            => array(
 435                                  'inputlabel'        => __(  'Standard NavBar - Hide Searchform?', 'pagelines' ),
 436                              ),
 437                      ),
 438                      'inputlabel'            => __( 'Configure Options for NavBars', 'pagelines' ),
 439                      'title'                    => __( 'NavBar and Fixed NavBar Configuration Options', 'pagelines' ),
 440                      'shortexp'                => __( 'Control various appearance options for the NavBars', 'pagelines' ),
 441                      'exp'                    => ''
 442                  ),
 443                  'navbar_title' => array(
 444                          'type'         => 'text',
 445                          'inputlabel'=> __( 'NavBar Title', 'pagelines' ),
 446                          'title'        => __( 'NavBar Title', 'pagelines' ),
 447                          'shortexp'    => __( 'Applies text to NavBar on small screens. Not available on Fixed NavBar', 'pagelines' ),
 448                          'exp'        => __( 'Add text to the NavBar to serve as a title, but only displayed on small screens.', 'pagelines' ),
 449                  ),
 450  
 451  
 452              );
 453  
 454              return $options;
 455      }
 456  }


Generated: Sun Dec 1 19:43:16 2013 Cross-referenced by PHPXref 0.7.1