/branches/Joomla 1.5/fullpagebackgrounds/includes/functions.php
PHP | 97 lines | 63 code | 11 blank | 23 comment | 14 complexity | ab1a522af8dd06e6f5e4bc912561ea92 MD5 | raw file
- <?php
- /**
- * Joomla! Full Page Background Plugin
- *
- * @package Joomla.Plugin
- * @subpackage System.fullpagebackground
- *
- * Copyright (C) 2011 Brian Tyndall - http://www.webdogz.co.uk
- *
- * 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.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- // no direct access
- defined('_JEXEC') or die;
- function randomImage($array) {
- $total = count($array);
- $call = rand(0,$total-1);
- return $array[$call];
- }
- function listImages($path, $restrictSize, $minWidth, $minHeight) {
- $images = glob($path . "*.jpg");
- $imageFiles = Array();
- $tempImage = '';
- foreach($images as $image)
- {
- //Add in functionality for definable file types later
- list($width, $height, $type, $attr) = getimagesize($image);
- if($restrictSize == 1 && $width < (int)$minWidth && $height < (int)$minWidth) {
- } else {
- $tempImage = explode(JPATH_BASE, $image);
- array_push($imageFiles, $tempImage);
- }
- }
- return $imageFiles;
- }
- function checkEmptyDirectory($folder) {
- if (! is_dir($folder))
- return false;
-
- $files = opendir($folder);
- while ($file = readdir($files)) {
- if ($file != '.' && $file != '..')
- return true;
- }
- }
- function assignImage($image, $centerImage) {
- ob_start();
- ?>
- jQuery(document).ready(function() {
- $('<div id="supersized"></div>').prependTo('body');
- $.fn.supersized.options = {
- startwidth: 640,
- startheight: 480,
- vertical_center: <?php echo $centerImage; ?>,
- slides : [
- {image : '<?php echo $image; ?>' }
- ]
- };
- $('#supersized').supersized();
- });
- <?php
- return ob_get_clean();
- }
- function fixPath($path) {
- if(substr($path, -1) != DS) {
- $path = $path . DS;
- }
- return $path;
-
- }
- function parseObjectToArray($object) {
- $array = array();
- if (is_object($object)) {
- $array = get_object_vars($object);
- }
- return $array;
- }
-
- ?>