[ Index ]

PHP Cross Reference of PageLines DMS

title

Body

[close]

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

   1  <?php
   2  /*
   3      Section: QuickSlider
   4      Author: PageLines
   5      Author URI: http://www.pagelines.com
   6      Description: A responsive slider that is easy to use and setup.
   7      Class Name: PageLinesQuickSlider
   8      Cloning: true
   9      Workswith: main, templates, sidebar_wrap
  10      Filter: slider
  11  */
  12  
  13  /**
  14   * Main section class
  15   *
  16   * @package PageLines DMS
  17   * @author PageLines
  18   */
  19  class PageLinesQuickSlider extends PageLinesSection {
  20  
  21      var $default_limit = 2;
  22  
  23      /**
  24       * Load styles and scripts
  25       */
  26  	function section_styles(){
  27          wp_enqueue_script( 'flexslider', $this->base_url.'/flexslider/jquery.flexslider-min.js', array( 'jquery' ), PL_CORE_VERSION, true );
  28      }
  29  
  30  	function section_head(){
  31  
  32          $animation = ($this->opt('quick_transition', $this->oset) == 'slide_v' || $this->opt('quick_transition', $this->oset) == 'slide_h') ? 'slide' : 'fade';
  33          $transfer = ($this->opt('quick_transition', $this->oset) == 'slide_v') ? 'vertical' : 'horizontal';
  34  
  35          $slideshow = ($this->opt('quick_slideshow', $this->oset)) ? 'true' : 'false';
  36  
  37          $clone_class = 'pl-clone' . $this->oset['clone_id'];
  38  
  39          $control_nav = (!$this->opt('quick_nav', $this->oset) || $this->opt('quick_nav', $this->oset) == 'both' || $this->opt('quick_nav', $this->oset) == 'control_only') ? 'true' : 'false';
  40          $direction_nav = (!$this->opt('quick_nav', $this->oset) || $this->opt('quick_nav', $this->oset) == 'both' || $this->opt('quick_nav', $this->oset) == 'arrow_only') ? 'true' : 'false';
  41          ?>
  42  <script>
  43  jQuery(window).load(function() {
  44      var theSlider = jQuery('<?php echo $this->prefix();?> .flexslider');
  45      theSlider.flexslider({
  46          controlsContainer: '.fs-nav-container',
  47          animation: '<?php echo $animation;?>',
  48          slideDirection: '<?php echo $transfer;?>',
  49          slideshow: <?php echo $slideshow;?>,
  50          directionNav: <?php echo $direction_nav;?>,
  51          controlNav: <?php echo $control_nav;?>
  52      });
  53  });
  54  </script>
  55  <?php }
  56  
  57      /**
  58      * Section template.
  59      */
  60     function section_template() {
  61  
  62      $control_nav = (!$this->opt('quick_nav', $this->oset) || $this->opt('quick_nav', $this->oset) == 'both' || $this->opt('quick_nav', $this->oset) == 'control_only') ? 'true' : 'false';
  63  
  64      $nav_class = ($control_nav) ? 'control-nav' : 'no-control-nav';
  65      ?>
  66      <div class="flexwrap animated fadeIn <?php echo 'wrap-'.$nav_class;?>">
  67          <div class="fslider">
  68          <div class="flexslider <?php echo 'pl-clone' . $this->oset['clone_id'];?>">
  69            <ul class="slides">
  70  
  71              <?php
  72  
  73              $item_array = $this->opt('quickslider_array');
  74  
  75              $format_upgrade_mapping = array(
  76                  'image'            => 'quick_image_%s',
  77                  'text'            => 'quick_text_%s',
  78                  'link'            => 'quick_link_%s',
  79                  'location'        => 'quick_text_location_%s',
  80              ); 
  81  
  82              $item_array = $this->upgrade_to_array_format( 'quickslider_array', $item_array, $format_upgrade_mapping, $this->opt('quick_slides'));
  83  
  84              $output = '';
  85  
  86              $num = count( $item_array );
  87  
  88              if( is_array($item_array) ){
  89                  
  90                  foreach( $item_array as $item ){
  91  
  92                      $the_image = pl_array_get( 'image', $item ); 
  93                      
  94                      if( $the_image ){
  95  
  96                          $the_text =  pl_array_get( 'text', $item ); 
  97                          $the_link =  pl_array_get( 'link', $item ); 
  98  
  99                          $tlocation = pl_array_get( 'location', $item ); 
 100  
 101                          if($tlocation == 'right_top')
 102                              $caption_style = 'right:0; bottom: auto; top:0;';
 103                          elseif($tlocation == 'left_bottom')
 104                              $caption_style = 'left:0; bottom:0; top: auto;';
 105                          elseif($tlocation == 'left_top')
 106                              $caption_style = 'left:0; bottom:auto; top: 0;';
 107                          else
 108                              $caption_style = 'right:0; bottom:0; top: auto;';
 109  
 110  
 111                          $text = ($the_text) ? sprintf('<p class="flex-caption" style="%s">%s</p>', $caption_style, $the_text) : '';
 112  
 113                          $img = sprintf('<img src="%s" alt="" />', $the_image );
 114  
 115                          $slide = ( $the_link ) ? sprintf('<a href="%s">%s</a>', $the_link, $img ) : $img;
 116                          
 117                          $output .= sprintf('<li>%s %s</li>',$slide, $text);
 118                      }
 119  
 120                  }
 121                  
 122              }
 123          
 124  
 125              if($output == '')
 126                  $this->do_defaults();
 127              else 
 128                  echo $output;
 129  
 130  
 131              ?>
 132            </ul>
 133          </div>
 134          </div>
 135          <div class="fs-nav-container <?php echo $nav_class;?>"></div>
 136      </div>
 137  
 138          <?php
 139      }
 140  
 141  	function do_defaults(){
 142  
 143          printf(
 144              '<li><img src="%s" /></li><li><img src="%s" /></li><li><img src="%s" /></li>',
 145              $this->images.'/image3.jpg',
 146              $this->images.'/image1.jpg',
 147              $this->images.'/image2.jpg'
 148          );
 149      }
 150  
 151  	function section_opts(){
 152          
 153              $options = array();
 154  
 155              $options[] = array(
 156  
 157                  'title' => __( 'Slider Configuration', 'pagelines' ),
 158                  'type'    => 'multi',
 159                  'opts'    => array(
 160                      array(
 161                          'key'            => 'quick_transition',
 162                          'type'             => 'select',
 163                          'default'        => 'fade',
 164                          'label'     => __( 'Select Transition Type', 'pagelines' ),
 165                          'opts' => array(
 166                              'fade'             => array('name' => __( 'Use Fading Transition', 'pagelines' ) ),
 167                              'slide_h'         => array('name' => __( 'Use Slide/Horizontal Transition', 'pagelines' ) ),
 168                          ),
 169                      ), 
 170                      array(
 171                          'key'            => 'quick_nav',
 172                          'type'             => 'select',
 173                          'opts' => array(
 174                              'both'             => array('name' => __( 'Use Both Arrow and Slide Control Navigation', 'pagelines' ) ),
 175                              'none'            => array('name' => __( 'No Navigation', 'pagelines' ) ),
 176                              'control_only'    => array('name' => __( 'Slide Controls Only', 'pagelines' ) ),
 177                              'arrow_only'    => array('name' => __( 'Arrow Navigation Only', 'pagelines' ) ),
 178                          ),
 179                          'label'     => __( 'Slider Navigation Mode', 'pagelines' ),
 180                      
 181                      ),
 182                      array(
 183                          'key'            => 'quick_slideshow',
 184                          'type'             => 'check',
 185                          'label'     => __( 'Animate Slideshow Automatically?', 'pagelines' ),
 186                      
 187                      )
 188                  )
 189  
 190              );
 191  
 192  
 193              $options[] = array(
 194                  'key'        => 'quickslider_array',
 195                  'type'        => 'accordion', 
 196                  'col'        => 2,
 197                  'title'        => __('Slides Setup', 'pagelines'), 
 198                  'post_type'    => __('Slide', 'pagelines'), 
 199                  'opts'    => array(
 200                      array(
 201                          'key'        => 'image',
 202                          'label'     => __( 'Slide Background Image', 'pagelines' ),
 203                          'type'        => 'image_upload',
 204                          'sizelimit'    => 2097152, // 2M
 205                          'help'        => __( 'For high resolution, 2000px wide x 800px tall images. (2MB Limit)', 'pagelines' )
 206  
 207                      ),
 208  
 209                      array(
 210                          'key'    => 'text',
 211                          'label'    => __( 'Slide Text', 'pagelines' ),
 212                          'type'            => 'text'
 213                      ),
 214                      array(
 215                          'key'    => 'link',
 216                          'label'    => __( 'Slide Link URL', 'pagelines' ),
 217                          'type'            => 'text'
 218                      ),
 219                      array(
 220                          'key'    => 'location',
 221                          'label'    => __( 'Slide Text Location', 'pagelines' ),
 222                          'type'            => 'select',
 223                          'opts'    => array(
 224                              'right_bottom'    => array('name'=> 'Right/Bottom'),
 225                              'right_top'        => array('name'=> 'Right/Top'),
 226                              'left_bottom'    => array('name'=> 'Left/Bottom'),
 227                              'left_top'        => array('name'=> 'Left/Top')
 228                          )
 229                      ),
 230  
 231  
 232                  )
 233              );
 234          
 235          return $options;
 236          
 237      }
 238      
 239  }


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