Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @about:This file will display the image rotator on the site.
- *
- * PHP version 5.4
- *
- * @version 1.0 - 05/02/2017
- * @package This file is part of QDP - QUICK DEVELOPMENT PACKAGE - THE DATABASE FREE CMS
- * @copyright (C) 2017 Gyula Soรณs
- * @license This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * See LICENSE.txt for copyright notices and details.
- */
- defined('QDP') or die('Restricted access');
- $siteDomain = siteDomain;
- $rImagesPath = "./images/carousel"; //the path to the images for the carousel
- $images = array_diff(scandir($rImagesPath), array('..', '.')); //get a list of all images present in the folder
- echo '<div id="myCarousel" class="carousel slide" data-ride="carousel">'; //inserting various divs required for the carousel
- echo '<ol class="carousel-indicators">';
- $imageNums = sizeof($images);
- for ($i = 0; $i< $imageNums; $i++){
- 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
- }
- echo '</ol>'; //closing ordered list
- echo '<div class="carousel-inner">'; //opening another div
- $counter = 0; //now inserting the actual images. the first will have the active added to the class
- foreach ($images as $key => $image){
- $imageName = substr($image, 0, -4);
- echo '<div class="item'.(($counter==0)?' active">':'">');
- echo <<<EOT
- <img src="$siteDomain/images/carousel/$image" alt="$imageName" class="img-responsive" />
- </div>
- EOT;
- $counter++;
- }
- echo '</div>';
- //inserting the carousel control
- echo <<<EOT
- <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
- <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
- <span class="sr-only">Previous</span>
- </a>
- <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
- <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
- <span class="sr-only">Next</span>
- </a>
- EOT;
- echo '</div>'; //closing div for everything
- ?>
Add Comment
Please, Sign In to add comment