soosgyul

Untitled

Feb 8th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3. * @about:This file will display the image rotator on the site.
  4. *
  5. * PHP version 5.4
  6. *
  7. * @version          1.0 - 05/02/2017
  8. * @package          This file is part of QDP - QUICK DEVELOPMENT PACKAGE - THE DATABASE FREE CMS
  9. * @copyright        (C) 2017 Gyula Soรณs
  10. * @license          This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. * GNU General Public License for more details.
  19. *
  20. * See LICENSE.txt for copyright notices and details.
  21. */
  22. defined('QDP') or die('Restricted access');
  23. $siteDomain = siteDomain;
  24. $rImagesPath = "./images/carousel"; //the path to the images for the carousel
  25.  
  26. $images = array_diff(scandir($rImagesPath), array('..', '.')); //get a list of all images present in the folder
  27.  
  28. echo '<div id="myCarousel" class="carousel slide" data-ride="carousel">'; //inserting various divs required for the carousel
  29. echo '<ol class="carousel-indicators">';
  30.  
  31. $imageNums = sizeof($images);
  32. for ($i = 0; $i< $imageNums; $i++){
  33.   echo '<li data-target = "#myCarousel" data-slide-to = "'.$i.'"'.(($i==0)?' class="active"':'').'></li>'; //inserting a list item for each image found. the first will have the class active added
  34. }
  35. echo '</ol>'; //closing ordered list
  36.  
  37. echo '<div class="carousel-inner">'; //opening another div
  38.    
  39. $counter = 0; //now inserting the actual images. the first will have the active added to the class
  40. foreach ($images as $key => $image){
  41. $imageName = substr($image, 0, -4);
  42. echo '<div class="item'.(($counter==0)?' active">':'">');
  43. echo <<<EOT
  44.   <img src="$siteDomain/images/carousel/$image" alt="$imageName" class="img-responsive" />
  45.   </div>
  46. EOT;
  47. $counter++;
  48. }
  49.  
  50. echo '</div>';
  51.  
  52. //inserting the carousel control
  53. echo <<<EOT
  54.     <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
  55.       <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
  56.       <span class="sr-only">Previous</span>
  57.     </a>
  58.     <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
  59.       <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
  60.       <span class="sr-only">Next</span>
  61.     </a>
  62. EOT;
  63.  
  64. echo '</div>'; //closing div for everything
  65. ?>
Add Comment
Please, Sign In to add comment