PHP/Javascript可以在pc浏览器上工作,但不能在智能手机上工作
这是我问题的延续: PHP:从foreach循环中的函数调用创建数组并合并它们 当通过基于pc/lapton的浏览器(chrome/firefox/opera)查看多媒体资料时,该功能将发挥作用,并显示多媒体资料。通过iPhone上的safari查看时,不会显示任何图库,只显示一个空间。 查看工作库的示例: 在我希望显示图像库的每个文件夹中,有两个php文件:PHP/Javascript可以在pc浏览器上工作,但不能在智能手机上工作,javascript,php,Javascript,Php,这是我问题的延续: PHP:从foreach循环中的函数调用创建数组并合并它们 当通过基于pc/lapton的浏览器(chrome/firefox/opera)查看多媒体资料时,该功能将发挥作用,并显示多媒体资料。通过iPhone上的safari查看时,不会显示任何图库,只显示一个空间。 查看工作库的示例: 在我希望显示图像库的每个文件夹中,有两个php文件: gallery_index.php 财产画廊 gallery.php name=getcwd(); $iwd=$var->nam
”; // 回声'; // 回声'; $slide_计数器=0; 而($slide_counter’; } 回声'; 回声'; ?>
<!-- include this in the head tag of gallery page -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {box-sizing: border-box}
body {font-family: Verdana, sans-serif; margin:0}
.mySlides {display: none}
img {vertical-align: middle;}
/* Property text container: 20200220 rh */
.property_text-container {
background-color:#999999; /*set for when an image is narrower than width setting */
max-width: 600px;
position: relative;
margin: auto;
height:30px;
text-align:center;
font-size:18px;
font-weight:bold;
vertical-align:middle;
padding-top:3px;
}
/* Slideshow container */
.slideshow-container {
background-color:#999999; /*set for when an image is narrower than width setting */
max-width: 600px;
position: relative;
margin: auto;
max-height:400px; /* 200226: trying to restict heigh of portrait images. */
}
/* Next & previous buttons */
.prev, .next {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
padding: 16px;
margin-top: -22px;
color: white;
font-weight: bold;
font-size: 18px;
transition: 0.6s ease;
border-radius: 0 3px 3px 0;
user-select: none;
}
/* Position the "next button" to the right */
.next {
right: 0;
border-radius: 3px 0 0 3px;
}
/* On hover, add a black background color with a little bit see-through */
.prev:hover, .next:hover, .text:hover {
background-color: rgba(0,0,0,0.8);
}
/* Caption text */
.text {
color: #f2f2f2;
/* font-size: 15px;*/
font-size:18px;
padding: 8px 12px;
position: absolute;
bottom: 8px;
width: 100%;
text-align: center;
}
/* Number text (1/3 etc) */
.numbertext {
background-color:#999;
/* color: #f2f2f2;*/
color:#000;
font-size: 12px;
/* font-size: 18px;*/
padding: 8px 12px;
position: absolute;
top: 0;
}
/* 20200128: rh. Added to centre dot display in divide rather than page width */
/* Dot container */
.dot-container {
max-width: 600px;
position: relative;
margin: auto;
}
/* The dots/bullets/indicators */
.dot {
cursor: pointer;
height: 15px;
width: 15px;
margin: 0 2px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
transition: background-color 0.6s ease;
}
.active, .dot:hover {
background-color: #717171;
}
/* Fading animation */
.fade {
-webkit-animation-name: fade;
-webkit-animation-duration: 1.5s;
animation-name: fade;
animation-duration: 1.5s;
}
@-webkit-keyframes fade {
from {opacity: .4}
to {opacity: 1}
}
@keyframes fade {
from {opacity: .4}
to {opacity: 1}
}
/* On smaller screens, decrease text size */
@media only screen and (max-width: 300px) {
.prev, .next,.text {font-size: 11px}
}
</style>
*{框大小:边框框}
正文{字体系列:Verdana,无衬线;边距:0}
.mySlides{display:none}
img{垂直对齐:中间;}
/*属性文本容器:20200220 rh*/
.property_文本容器{
背景色:#999999;/*当图像比宽度设置窄时设置*/
最大宽度:600px;
位置:相对位置;
保证金:自动;
高度:30px;
文本对齐:居中;
字号:18px;
字体大小:粗体;
垂直对齐:中间对齐;
垫面:3件;
}
/*幻灯片容器*/
.slideshow容器{
背景色:#999999;/*当图像比宽度设置窄时设置*/
最大宽度:600px;
位置:相对位置;
保证金:自动;
最大高度:400px;/*200226:尝试恢复肖像图像的高度*/
}
/*下一步和上一步按钮*/
.prev,.next{
光标:指针;
位置:绝对位置;
最高:50%;
宽度:自动;
填充:16px;
利润上限:-22px;
颜色:白色;
字体大小:粗体;
字号:18px;
过渡:0.6s缓解;
边界半径:0 3px 3px 0;
用户选择:无;
}
/*将“下一步按钮”置于右侧*/
.下一个{
右:0;
边界半径:3px 0 3px;
}
/*在悬停时,添加一个黑色背景色,带有一点透明*/
.prev:hover、.next:hover、.text:hover{
背景色:rgba(0,0,0,0.8);
}
/*标题文本*/
.文本{
颜色:#F2F2;
/*字体大小:15px*/
字号:18px;
填充:8px 12px;
位置:绝对位置;
底部:8px;
宽度:100%;
文本对齐:居中;
}
/*数字文本(1/3等)*/
.numbertext{
背景色:#999;
/*颜色:#F2F2*/
颜色:#000;
字体大小:12px;
/*字号:18px*/
填充:8px 12px;
位置:绝对位置;
排名:0;
}
/*20200128:右侧。添加到中间点显示,以分隔而不是页面宽度*/
/*点容器*/
.dot容器{
最大宽度:600px;
位置:相对位置;
保证金:自动;
}
/*点/子弹/指示器*/
多特先生{
光标:指针;
高度:15px;
宽度:15px;
边际:0.2px;
背景色:#bbb;
边界半径:50%;
显示:内联块;
过渡:背景色0.6s;
}
.active,.dot:悬停{
背景色:#717171;
}
/*褪色动画*/
.褪色{
-webkit动画名称:淡入淡出;
-webkit动画持续时间:1.5s;
动画名称:淡入淡出;
动画持续时间:1.5s;
}
@-webkit关键帧淡入淡出{
来自{opacity:.4}
到{opacity:1}
}
@关键帧淡入淡出{
来自{opacity:.4}
到{opacity:1}
}
/*在较小的屏幕上,减小文本大小*/
@仅介质屏幕和(最大宽度:300px){
.prev、.next、.text{font size:11px}
}
gallery\u ctrl\u body\u v2.php:
<?php // include at the TOP of property gallery pages ?>
<?php
// Define CLASS to get $sub_div:
class subdivClass {
//public $sub_div;
//public function subdiv($iwd) {
function subdiv($iwd) {
// global $sub_div; // works if this is enabled. ONLY used for testing.
# echo 'The initial full $iwd value is l11: <br>' . $iwd . '<br>';
# echo 'The initial $sub_div value il12: ' . $sub_div . '<br>';
# echo 'The $iwd value now l13: <br>' . $iwd . '<br>';
// The i at the end of regular expression changes regular expression to be case-insensitive, if not required it can be left out.
if (preg_match("/glenbrook_resort/i", $iwd)) {
$sub_div = 'glenbrook_resort';
} else if (preg_match("/high_grove/i", $iwd)) {
$sub_div = 'high_grove';
} else if (preg_match("/^\b(\w*high_grove\w*)\b/i", $iwd)) {
$sub_div = 'high_grove';
} else if (preg_match("/test_subdiv/i", $iwd)) {
$sub_div = 'test_subdiv';
} else if (preg_match("/gallery/i", $iwd)) {
$sub_div = 'gallery';
} else if (preg_match("/test_200828/i", $iwd)) {
$sub_div = 'test_200828';
}
return $sub_div;
}
}
$subdivClass = new subdivClass();
# print_r($subdivClass->subdiv($iwd) . '<br>'); //Displays the correct value for $sub_div.
# echo 'The working $sub_div value outside the function() l35: ' . $sub_div . '<br>'; //No value displays.
// Reference: https://stackoverflow.com/questions/63307363/how-to-create-a-php-variable-in-a-function-within-a-class-for-use-by-other-funct?noredirect=1#comment111946755_63307363
// Next line required to make $sub_div available to calls from other functions.
$sub_div = $subdivClass->subdiv($iwd);
?>
<?php
// Define text for image labels in galleries:
define("PROPERTY_TEXT", "Property ID: "); //deliberate space before closing comment.
# Funtion to define the sub-division abbreviated characters:
function sub_div_abb($sub_div) {
switch ($sub_div) {
case "test_subdiv":
return 'TESTSUBDIV';
//break; // breaks are not needed if you return the value as that will break out of the function
case "glenbrook_resort":
return 'GR';
case "high_grove":
return 'HG';
case "gallery":
return 'GALLERY';
case "test_200828":
return 'TEST_200828';
}
// default:
return 'NotInFunction';
}
# and to execute it
// $abb = sub_div_abb('glenbrook_resort');
// echo $abb . '<br>';
?>
<?php
# Version: 200226
# Funtion to define the image label from the image name:
# Using stristr for seach string and case insensitive.
function img_label($img_name) {
switch ($img_name) {
case stristr($img_name, "bed_1"):
return 'Bedroom 1';
case stristr($img_name, "bed_2"):
return 'Bedroom 2';
case stristr($img_name, "bed_3"):
return 'Bedroom 3';
case stristr($img_name, "bed_4"):
return 'Bedroom 4';
case stristr($img_name, "bed_5"):
return 'Bedroom 5';
case stristr($img_name, "bed_6"):
return 'Bedroom 6';
case stristr($img_name, "bed_7"):
return 'Bedroom 7';
case stristr($img_name, "bed_m1"):
return 'Master Bedroom 1';
case stristr($img_name, "bed_m2"):
return 'Master Bedroom 2';
case stristr($img_name, "bed_m3"):
return 'Master Bedroom 3';
case stristr($img_name, "bth_1"):
return 'Bathroom 1';
case stristr($img_name, "bth_2"):
return 'Bathroom 2';
case stristr($img_name, "bth_3"):
return 'Bathroom 3';
case stristr($img_name, "bth_4"):
return 'Bathroom 4';
case stristr($img_name, "bth_5"):
return 'Bathroom 5';
case stristr($img_name, "bth_m1"):
return 'Master Bathroom 1';
case stristr($img_name, "bth_m2"):
return 'Master Bathroom 2';
case stristr($img_name, "bth_m3"):
return 'Master Bathroom 3';
case stristr($img_name, "ext_front"):
return 'Exterior Front';
case stristr($img_name, "ext_patio"):
return 'Patio / Pooldeck';
case stristr($img_name, "ext_pool_spa"): // will have issues with pool only: ext_pool, consider renaming spa_pool!
return 'Pool & Spa';
case stristr($img_name, "ext_rear"):
return 'Exterior Rear';
case stristr($img_name, "int_foyer"):
return 'Foyer';
case stristr($img_name, "rm_den"):
return 'Den';
case stristr($img_name, "rm_dining"):
return 'Dining Room';
case stristr($img_name, "rm_family"):
return 'Family Room';
case stristr($img_name, "rm_games"):
return 'Games Room';
case stristr($img_name, "rm_garage"):
return 'Garage';
case stristr($img_name, "rm_kitchen"):
return 'Kitchen';
case stristr($img_name, "rm_living"):
return 'Living Room';
case stristr($img_name, "rm_nook"):
return 'Nook';
case stristr($img_name, "rm_utility"):
return 'Utility Room';
}
// default:
return 'No image label set!';
}
?>
<?php
// Define the function to create the slides html:
function createGallery($img_width, $img_style, $filename, $img_name, $img_src, $img_counter, $img_total, $value, $pid_text){
echo '<div class="mySlides fade">';
echo '<div class="numbertext">';
// $img_counter ++; // Set before function() when using function call.
echo $img_counter . ' / ' . $img_total;
echo '</div>';
// echo $filename . ' / ' . $img_total . ' / ' . $img_name . '<br><br><br>';
echo '<img src="' . $value . '" ' . $img_style . '>'; // May need backlash before closing chevron.
# echo '<br><br><br><br><br>' . substr($value, 0, 3) . '<br>';
echo '<div class="text">';
//echo $pid_text . '<br>' . img_label($img_name=$img_src);
echo $pid_text . '<br>' . img_label($value);
echo '</div>';
echo '</div>';
} // End of function().
?>
<?php
// The functions:
// Define the function to get all the images in the current folder:
function getImages(){
foreach(glob(IMAGEPATH."*.{jpg,png,gif,JPG,PNG,GIF}", GLOB_BRACE) as $var){
$img_src = basename($var);
// $img_label10 = pathinfo($var, PATHINFO_FILENAME); // NOT REQUIRED!
// Assign specific values to the array as you cycle through the other collection.
if (substr($img_src, 0, 5) == 'bed_1'){
if (!isset($arrayBed_1)) {
$arrayBed_1 = array();
}
$arrayBed_1[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'bed_2'){
if (!isset($arrayBed_2)) {
$arrayBed_2 = array();
}
$arrayBed_2[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'bed_3'){
if (!isset($arrayBed_3)) {
$arrayBed_3 = array();
}
$arrayBed_3[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'bed_4'){
if (!isset($arrayBed_4)) {
$arrayBed_4 = array();
}
$arrayBed_4[] = $img_src;
} elseif (substr($img_src, 0, 6) == 'bed_m1'){
if (!isset($arrayBed_m1)) {
$arrayBed_m1 = array();
}
$arrayBed_m1[] = $img_src;
#echo $img_src . ' : Image label = ' . img_label($img_label10) . '<br>';
} elseif (substr($img_src, 0, 6) == 'bed_m2'){
if (!isset($arrayBed_m2)) {
$arrayBed_m2 = array();
}
$arrayBed_m2[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'bth_2'){
if (!isset($arrayBth_2)) {
$arrayBth_3 = array();
}
$arrayBth_2[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'bth_3'){
if (!isset($arrayBth_3)) {
$arrayBth_3 = array();
}
$arrayBth_3[] = $img_src;
} elseif (substr($img_src, 0, 6) == 'bth_m1'){
if (!isset($arrayBth_m1)) {
$arrayBth_m1 = array();
}
$arrayBth_m1[] = $img_src;
#echo $img_src . ' : Image label = ' . img_label($img_label10) . '<br>';
} elseif (substr($img_src, 0, 6) == 'bth_m2'){
if (!isset($arrayBth_m2)) {
$arrayBth_m2 = array();
}
$arrayBth_m2[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'ext_f'){
if (!isset($arrayExt_f)) {
$arrayExt_f = array();
}
$arrayExt_f[] = $img_src;
} elseif (substr($img_src, 0, 6) == 'ext_pa'){
if (!isset($arrayExt_pa)) {
$arrayExt_pa = array();
}
$arrayExt_pa[] = $img_src;
} elseif (substr($img_src, 0, 10) == 'ext_pool_s'){
if (!isset($arrayExt_pool_s)) {
$arrayExt_pool_s = array();
}
$arrayExt_pool_s[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'ext_r'){
if (!isset($arrayExt_r)) {
$arrayExt_r = array();
}
$arrayExt_r[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'int_f'){
if (!isset($arrayInt_f)) {
$arrayInt_f = array();
}
$arrayInt_f[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'rm_de'){
if (!isset($arrayRm_de)) {
$arrayRm_de = array();
}
$arrayRm_di[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'rm_di'){
if (!isset($arrayRm_di)) {
$arrayRm_di = array();
}
$arrayRm_di[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'rm_fa'){
if (!isset($arrayRm_fa)) {
$arrayRm_fa = array();
}
$arrayRm_fa[] = $img_src;
} elseif (substr($img_src, 0, 6) == 'rm_gam'){
if (!isset($arrayRm_gam)) {
$arrayRm_gam = array();
}
$arrayRm_gam[] = $img_src;
} elseif (substr($img_src, 0, 6) == 'rm_gar'){
if (!isset($arrayRm_gar)) {
$arrayRm_gar = array();
}
$arrayRm_gar[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'rm_ki'){
if (!isset($arrayRm_ki)) {
$arrayRm_kl = array();
}
$arrayRm_ki[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'rm_li'){
if (!isset($arrayRm_li)) {
$arrayRm_ll = array();
}
$arrayRm_li[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'rm_no'){
if (!isset($arrayRm_no)) {
$arrayRm_no = array();
}
$arrayRm_no[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'rm_ut'){
if (!isset($arrayRm_ut)) {
$arrayRm_ut = array();
}
$arrayRm_ut[] = $img_src;
}
} //End of foreach().
// Create the final array for other arrays to push to which defines the sort order:
$arrayPreFinal = array();
if (isset($arrayExt_f)){ // ext_f = exterior front
foreach ($arrayExt_f as $val){
array_push($arrayPreFinal, $val);
}
}
#echo 'This is $arrayPreFinal after $arrayExt_f push<pre>'; print_r($arrayPreFinal); echo '</pre><br>';
if (isset($arrayExt_r)){ // ext_r = exterior rear
foreach ($arrayExt_r as $val){
array_push($arrayPreFinal, $val);
}
}
#echo 'This is $arrayPreFinal after $arrayExt_r push<pre>'; print_r($arrayPreFinal); echo '</pre><br>';
if (isset($arrayExt_pool_s)){ // ext_pool_s = exterior pool and spa
foreach ($arrayExt_pool_s as $val){
array_push($arrayPreFinal, $val);
}
}
#echo 'This is $arrayPreFinal after $arrayExt_pool_s push<pre>'; print_r($arrayPreFinal); echo '</pre><br>';
if (isset($arrayExt_pa)){ // ext_pa = exterior patio
foreach ($arrayExt_pa as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayRm_gam)){ // rm_gam = gamesroom
foreach ($arrayRm_gam as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayInt_f)){ // int_f = foyer
foreach ($arrayInt_f as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayRm_li)){ // rm_li = living room
foreach ($arrayRm_li as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayRm_di)){ // rm_di = dining room
foreach ($arrayRm_di as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayRm_ki)){ // rm_ki = kitchen
foreach ($arrayRm_ki as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayRm_no)){ // rm_no = nook
foreach ($arrayRm_no as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayRm_fa)){ // rm_fa = family
foreach ($arrayRm_fa as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayRm_de)){ // rm_de = den
foreach ($arrayRm_de as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayRm_ut)){ // rm_ut = utility room
foreach ($arrayRm_ut as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayRm_gar)){ // rm_gar = garage
foreach ($arrayRm_gar as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayBed_m1)){ // bed_m1 = master bedroom 1
foreach ($arrayBed_m1 as $val){
array_push($arrayPreFinal, $val);
}
}
#echo 'This is $arrayPreFinal after $array104 push<pre>'; print_r($arrayPreFinal); echo '</pre><br>';
if (isset($arrayBth_m1)){ // bth_m1 = master bathroom 1
foreach ($arrayBth_m1 as $val){
array_push($arrayPreFinal, $val);
}
}
#echo 'This is $arrayPreFinal after $array105 push<pre>'; print_r($arrayPreFinal); echo '</pre><br>';
if (isset($arrayBed_m2)){ // bed_m2 = master bedroom 2
foreach ($arrayBed_m2 as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayBth_m2)){ // bth_m2 = master bathroom 2
foreach ($arrayBth_m2 as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayBed_1)){ // bed_1 = bedroom 1
foreach ($arrayBed_1 as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayBed_2)){ // bed_2 = bedroom 2
foreach ($arrayBed_2 as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayBth_2)){ // bth_2 = bathroom 2
foreach ($arrayBth_2 as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayBed_3)){ // bed_3 = bedroom 3
foreach ($arrayBed_3 as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayBth_3)){ // bth_3 = bathroom 3
foreach ($arrayBth_3 as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayBed_4)){ // bed_4 = bedroom 4
foreach ($arrayBed_4 as $val){
array_push($arrayPreFinal, $val);
}
}
return $arrayPreFinal;
} // End of function().
?>
幻灯片功能的gallery\u ctrl\u script.php
var slideIndex=1;
放映幻灯片(幻灯片索引);
函数加滑块(n){
放映幻灯片(幻灯片索引+=n);
}
功能当前幻灯片(n){
放映幻灯片(幻灯片索引=n);
}
功能演示幻灯片(n){
var i;
var slides=document.getElementsByClassName(“mySlides”);
var dots=document.getElementsByClassName(“dot”);
如果(n>slides.length){slideIndex=1}
如果(n<1){slideIndex=slides.length}
对于(i=0;i<?php // include at the TOP of property gallery pages ?>
<?php
// Define CLASS to get $sub_div:
class subdivClass {
//public $sub_div;
//public function subdiv($iwd) {
function subdiv($iwd) {
// global $sub_div; // works if this is enabled. ONLY used for testing.
# echo 'The initial full $iwd value is l11: <br>' . $iwd . '<br>';
# echo 'The initial $sub_div value il12: ' . $sub_div . '<br>';
# echo 'The $iwd value now l13: <br>' . $iwd . '<br>';
// The i at the end of regular expression changes regular expression to be case-insensitive, if not required it can be left out.
if (preg_match("/glenbrook_resort/i", $iwd)) {
$sub_div = 'glenbrook_resort';
} else if (preg_match("/high_grove/i", $iwd)) {
$sub_div = 'high_grove';
} else if (preg_match("/^\b(\w*high_grove\w*)\b/i", $iwd)) {
$sub_div = 'high_grove';
} else if (preg_match("/test_subdiv/i", $iwd)) {
$sub_div = 'test_subdiv';
} else if (preg_match("/gallery/i", $iwd)) {
$sub_div = 'gallery';
} else if (preg_match("/test_200828/i", $iwd)) {
$sub_div = 'test_200828';
}
return $sub_div;
}
}
$subdivClass = new subdivClass();
# print_r($subdivClass->subdiv($iwd) . '<br>'); //Displays the correct value for $sub_div.
# echo 'The working $sub_div value outside the function() l35: ' . $sub_div . '<br>'; //No value displays.
// Reference: https://stackoverflow.com/questions/63307363/how-to-create-a-php-variable-in-a-function-within-a-class-for-use-by-other-funct?noredirect=1#comment111946755_63307363
// Next line required to make $sub_div available to calls from other functions.
$sub_div = $subdivClass->subdiv($iwd);
?>
<?php
// Define text for image labels in galleries:
define("PROPERTY_TEXT", "Property ID: "); //deliberate space before closing comment.
# Funtion to define the sub-division abbreviated characters:
function sub_div_abb($sub_div) {
switch ($sub_div) {
case "test_subdiv":
return 'TESTSUBDIV';
//break; // breaks are not needed if you return the value as that will break out of the function
case "glenbrook_resort":
return 'GR';
case "high_grove":
return 'HG';
case "gallery":
return 'GALLERY';
case "test_200828":
return 'TEST_200828';
}
// default:
return 'NotInFunction';
}
# and to execute it
// $abb = sub_div_abb('glenbrook_resort');
// echo $abb . '<br>';
?>
<?php
# Version: 200226
# Funtion to define the image label from the image name:
# Using stristr for seach string and case insensitive.
function img_label($img_name) {
switch ($img_name) {
case stristr($img_name, "bed_1"):
return 'Bedroom 1';
case stristr($img_name, "bed_2"):
return 'Bedroom 2';
case stristr($img_name, "bed_3"):
return 'Bedroom 3';
case stristr($img_name, "bed_4"):
return 'Bedroom 4';
case stristr($img_name, "bed_5"):
return 'Bedroom 5';
case stristr($img_name, "bed_6"):
return 'Bedroom 6';
case stristr($img_name, "bed_7"):
return 'Bedroom 7';
case stristr($img_name, "bed_m1"):
return 'Master Bedroom 1';
case stristr($img_name, "bed_m2"):
return 'Master Bedroom 2';
case stristr($img_name, "bed_m3"):
return 'Master Bedroom 3';
case stristr($img_name, "bth_1"):
return 'Bathroom 1';
case stristr($img_name, "bth_2"):
return 'Bathroom 2';
case stristr($img_name, "bth_3"):
return 'Bathroom 3';
case stristr($img_name, "bth_4"):
return 'Bathroom 4';
case stristr($img_name, "bth_5"):
return 'Bathroom 5';
case stristr($img_name, "bth_m1"):
return 'Master Bathroom 1';
case stristr($img_name, "bth_m2"):
return 'Master Bathroom 2';
case stristr($img_name, "bth_m3"):
return 'Master Bathroom 3';
case stristr($img_name, "ext_front"):
return 'Exterior Front';
case stristr($img_name, "ext_patio"):
return 'Patio / Pooldeck';
case stristr($img_name, "ext_pool_spa"): // will have issues with pool only: ext_pool, consider renaming spa_pool!
return 'Pool & Spa';
case stristr($img_name, "ext_rear"):
return 'Exterior Rear';
case stristr($img_name, "int_foyer"):
return 'Foyer';
case stristr($img_name, "rm_den"):
return 'Den';
case stristr($img_name, "rm_dining"):
return 'Dining Room';
case stristr($img_name, "rm_family"):
return 'Family Room';
case stristr($img_name, "rm_games"):
return 'Games Room';
case stristr($img_name, "rm_garage"):
return 'Garage';
case stristr($img_name, "rm_kitchen"):
return 'Kitchen';
case stristr($img_name, "rm_living"):
return 'Living Room';
case stristr($img_name, "rm_nook"):
return 'Nook';
case stristr($img_name, "rm_utility"):
return 'Utility Room';
}
// default:
return 'No image label set!';
}
?>
<?php
// Define the function to create the slides html:
function createGallery($img_width, $img_style, $filename, $img_name, $img_src, $img_counter, $img_total, $value, $pid_text){
echo '<div class="mySlides fade">';
echo '<div class="numbertext">';
// $img_counter ++; // Set before function() when using function call.
echo $img_counter . ' / ' . $img_total;
echo '</div>';
// echo $filename . ' / ' . $img_total . ' / ' . $img_name . '<br><br><br>';
echo '<img src="' . $value . '" ' . $img_style . '>'; // May need backlash before closing chevron.
# echo '<br><br><br><br><br>' . substr($value, 0, 3) . '<br>';
echo '<div class="text">';
//echo $pid_text . '<br>' . img_label($img_name=$img_src);
echo $pid_text . '<br>' . img_label($value);
echo '</div>';
echo '</div>';
} // End of function().
?>
<?php
// The functions:
// Define the function to get all the images in the current folder:
function getImages(){
foreach(glob(IMAGEPATH."*.{jpg,png,gif,JPG,PNG,GIF}", GLOB_BRACE) as $var){
$img_src = basename($var);
// $img_label10 = pathinfo($var, PATHINFO_FILENAME); // NOT REQUIRED!
// Assign specific values to the array as you cycle through the other collection.
if (substr($img_src, 0, 5) == 'bed_1'){
if (!isset($arrayBed_1)) {
$arrayBed_1 = array();
}
$arrayBed_1[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'bed_2'){
if (!isset($arrayBed_2)) {
$arrayBed_2 = array();
}
$arrayBed_2[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'bed_3'){
if (!isset($arrayBed_3)) {
$arrayBed_3 = array();
}
$arrayBed_3[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'bed_4'){
if (!isset($arrayBed_4)) {
$arrayBed_4 = array();
}
$arrayBed_4[] = $img_src;
} elseif (substr($img_src, 0, 6) == 'bed_m1'){
if (!isset($arrayBed_m1)) {
$arrayBed_m1 = array();
}
$arrayBed_m1[] = $img_src;
#echo $img_src . ' : Image label = ' . img_label($img_label10) . '<br>';
} elseif (substr($img_src, 0, 6) == 'bed_m2'){
if (!isset($arrayBed_m2)) {
$arrayBed_m2 = array();
}
$arrayBed_m2[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'bth_2'){
if (!isset($arrayBth_2)) {
$arrayBth_3 = array();
}
$arrayBth_2[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'bth_3'){
if (!isset($arrayBth_3)) {
$arrayBth_3 = array();
}
$arrayBth_3[] = $img_src;
} elseif (substr($img_src, 0, 6) == 'bth_m1'){
if (!isset($arrayBth_m1)) {
$arrayBth_m1 = array();
}
$arrayBth_m1[] = $img_src;
#echo $img_src . ' : Image label = ' . img_label($img_label10) . '<br>';
} elseif (substr($img_src, 0, 6) == 'bth_m2'){
if (!isset($arrayBth_m2)) {
$arrayBth_m2 = array();
}
$arrayBth_m2[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'ext_f'){
if (!isset($arrayExt_f)) {
$arrayExt_f = array();
}
$arrayExt_f[] = $img_src;
} elseif (substr($img_src, 0, 6) == 'ext_pa'){
if (!isset($arrayExt_pa)) {
$arrayExt_pa = array();
}
$arrayExt_pa[] = $img_src;
} elseif (substr($img_src, 0, 10) == 'ext_pool_s'){
if (!isset($arrayExt_pool_s)) {
$arrayExt_pool_s = array();
}
$arrayExt_pool_s[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'ext_r'){
if (!isset($arrayExt_r)) {
$arrayExt_r = array();
}
$arrayExt_r[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'int_f'){
if (!isset($arrayInt_f)) {
$arrayInt_f = array();
}
$arrayInt_f[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'rm_de'){
if (!isset($arrayRm_de)) {
$arrayRm_de = array();
}
$arrayRm_di[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'rm_di'){
if (!isset($arrayRm_di)) {
$arrayRm_di = array();
}
$arrayRm_di[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'rm_fa'){
if (!isset($arrayRm_fa)) {
$arrayRm_fa = array();
}
$arrayRm_fa[] = $img_src;
} elseif (substr($img_src, 0, 6) == 'rm_gam'){
if (!isset($arrayRm_gam)) {
$arrayRm_gam = array();
}
$arrayRm_gam[] = $img_src;
} elseif (substr($img_src, 0, 6) == 'rm_gar'){
if (!isset($arrayRm_gar)) {
$arrayRm_gar = array();
}
$arrayRm_gar[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'rm_ki'){
if (!isset($arrayRm_ki)) {
$arrayRm_kl = array();
}
$arrayRm_ki[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'rm_li'){
if (!isset($arrayRm_li)) {
$arrayRm_ll = array();
}
$arrayRm_li[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'rm_no'){
if (!isset($arrayRm_no)) {
$arrayRm_no = array();
}
$arrayRm_no[] = $img_src;
} elseif (substr($img_src, 0, 5) == 'rm_ut'){
if (!isset($arrayRm_ut)) {
$arrayRm_ut = array();
}
$arrayRm_ut[] = $img_src;
}
} //End of foreach().
// Create the final array for other arrays to push to which defines the sort order:
$arrayPreFinal = array();
if (isset($arrayExt_f)){ // ext_f = exterior front
foreach ($arrayExt_f as $val){
array_push($arrayPreFinal, $val);
}
}
#echo 'This is $arrayPreFinal after $arrayExt_f push<pre>'; print_r($arrayPreFinal); echo '</pre><br>';
if (isset($arrayExt_r)){ // ext_r = exterior rear
foreach ($arrayExt_r as $val){
array_push($arrayPreFinal, $val);
}
}
#echo 'This is $arrayPreFinal after $arrayExt_r push<pre>'; print_r($arrayPreFinal); echo '</pre><br>';
if (isset($arrayExt_pool_s)){ // ext_pool_s = exterior pool and spa
foreach ($arrayExt_pool_s as $val){
array_push($arrayPreFinal, $val);
}
}
#echo 'This is $arrayPreFinal after $arrayExt_pool_s push<pre>'; print_r($arrayPreFinal); echo '</pre><br>';
if (isset($arrayExt_pa)){ // ext_pa = exterior patio
foreach ($arrayExt_pa as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayRm_gam)){ // rm_gam = gamesroom
foreach ($arrayRm_gam as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayInt_f)){ // int_f = foyer
foreach ($arrayInt_f as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayRm_li)){ // rm_li = living room
foreach ($arrayRm_li as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayRm_di)){ // rm_di = dining room
foreach ($arrayRm_di as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayRm_ki)){ // rm_ki = kitchen
foreach ($arrayRm_ki as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayRm_no)){ // rm_no = nook
foreach ($arrayRm_no as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayRm_fa)){ // rm_fa = family
foreach ($arrayRm_fa as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayRm_de)){ // rm_de = den
foreach ($arrayRm_de as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayRm_ut)){ // rm_ut = utility room
foreach ($arrayRm_ut as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayRm_gar)){ // rm_gar = garage
foreach ($arrayRm_gar as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayBed_m1)){ // bed_m1 = master bedroom 1
foreach ($arrayBed_m1 as $val){
array_push($arrayPreFinal, $val);
}
}
#echo 'This is $arrayPreFinal after $array104 push<pre>'; print_r($arrayPreFinal); echo '</pre><br>';
if (isset($arrayBth_m1)){ // bth_m1 = master bathroom 1
foreach ($arrayBth_m1 as $val){
array_push($arrayPreFinal, $val);
}
}
#echo 'This is $arrayPreFinal after $array105 push<pre>'; print_r($arrayPreFinal); echo '</pre><br>';
if (isset($arrayBed_m2)){ // bed_m2 = master bedroom 2
foreach ($arrayBed_m2 as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayBth_m2)){ // bth_m2 = master bathroom 2
foreach ($arrayBth_m2 as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayBed_1)){ // bed_1 = bedroom 1
foreach ($arrayBed_1 as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayBed_2)){ // bed_2 = bedroom 2
foreach ($arrayBed_2 as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayBth_2)){ // bth_2 = bathroom 2
foreach ($arrayBth_2 as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayBed_3)){ // bed_3 = bedroom 3
foreach ($arrayBed_3 as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayBth_3)){ // bth_3 = bathroom 3
foreach ($arrayBth_3 as $val){
array_push($arrayPreFinal, $val);
}
}
if (isset($arrayBed_4)){ // bed_4 = bedroom 4
foreach ($arrayBed_4 as $val){
array_push($arrayPreFinal, $val);
}
}
return $arrayPreFinal;
} // End of function().
?>
<?php // include at the END of gallery content pages ?>
<script>
var slideIndex = 1;
showSlides(slideIndex);
function plusSlides(n) {
showSlides(slideIndex += n);
}
function currentSlide(n) {
showSlides(slideIndex = n);
}
function showSlides(n) {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("dot");
if (n > slides.length) {slideIndex = 1}
if (n < 1) {slideIndex = slides.length}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active";
}
</script>