PageRenderTime 38ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/branches/Joomla 1.5/fullpagebackgrounds/includes/functions.php

http://full-page-backgrounds-webdogz.googlecode.com/
PHP | 97 lines | 63 code | 11 blank | 23 comment | 14 complexity | ab1a522af8dd06e6f5e4bc912561ea92 MD5 | raw file
  1. <?php
  2. /**
  3. * Joomla! Full Page Background Plugin
  4. *
  5. * @package Joomla.Plugin
  6. * @subpackage System.fullpagebackground
  7. *
  8. * Copyright (C) 2011 Brian Tyndall - http://www.webdogz.co.uk
  9. *
  10. * 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. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. */
  23. // no direct access
  24. defined('_JEXEC') or die;
  25. function randomImage($array) {
  26. $total = count($array);
  27. $call = rand(0,$total-1);
  28. return $array[$call];
  29. }
  30. function listImages($path, $restrictSize, $minWidth, $minHeight) {
  31. $images = glob($path . "*.jpg");
  32. $imageFiles = Array();
  33. $tempImage = '';
  34. foreach($images as $image)
  35. {
  36. //Add in functionality for definable file types later
  37. list($width, $height, $type, $attr) = getimagesize($image);
  38. if($restrictSize == 1 && $width < (int)$minWidth && $height < (int)$minWidth) {
  39. } else {
  40. $tempImage = explode(JPATH_BASE, $image);
  41. array_push($imageFiles, $tempImage);
  42. }
  43. }
  44. return $imageFiles;
  45. }
  46. function checkEmptyDirectory($folder) {
  47. if (! is_dir($folder))
  48. return false;
  49. $files = opendir($folder);
  50. while ($file = readdir($files)) {
  51. if ($file != '.' && $file != '..')
  52. return true;
  53. }
  54. }
  55. function assignImage($image, $centerImage) {
  56. ob_start();
  57. ?>
  58. jQuery(document).ready(function() {
  59. $('<div id="supersized"></div>').prependTo('body');
  60. $.fn.supersized.options = {
  61. startwidth: 640,
  62. startheight: 480,
  63. vertical_center: <?php echo $centerImage; ?>,
  64. slides : [
  65. {image : '<?php echo $image; ?>' }
  66. ]
  67. };
  68. $('#supersized').supersized();
  69. });
  70. <?php
  71. return ob_get_clean();
  72. }
  73. function fixPath($path) {
  74. if(substr($path, -1) != DS) {
  75. $path = $path . DS;
  76. }
  77. return $path;
  78. }
  79. function parseObjectToArray($object) {
  80. $array = array();
  81. if (is_object($object)) {
  82. $array = get_object_vars($object);
  83. }
  84. return $array;
  85. }
  86. ?>