-
Notifications
You must be signed in to change notification settings - Fork 1
/
imglist.inc.php
executable file
·124 lines (113 loc) · 3.56 KB
/
imglist.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
/**
* This file is part of the RPCL project
*
* Copyright (c) 2004-2011 Embarcadero Technologies, Inc.
*
* Checkout AUTHORS file for more information on the developers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
*/
use_unit("classes.inc.php");
/**
* A component that holds a list of image paths.
* This component doesn't work exactly like the VCL for Windows TImageList
* because in web applications, images are usually paths to the image files, so
* this is a repository for that kind of lists
*
* Use the Images property to specify which images this component holds. That property
* is an array.
*
*/
class ImageList extends Component
{
protected $_images=array();
function __construct($aowner=null)
{
//Calls inherited constructor
parent::__construct($aowner);
}
/**
* Array of images referenced by this component.
*
* You can use the array to iterate throught the image paths, or get an specific image path by its index.
*
* @return array
*/
function getImages() { return $this->_images; }
function setImages($value) { $this->_images=$value; }
function defaultImages() { return array(); }
/**
* Returns an image from the array specified by $index, the index must
* exists, if not, false is returned
*
* @return string
*/
function retrieveImage($index)
{
//TODO: Check this with numeric keys as it fails
if (isset($this->_images[$index])) return($this->_images[$index]);
else
{
reset($this->_images);
while(list($key, $val)=each($this->_images))
{
if ($key==$index) return($val);
}
return false;
}
}
/**
* Returns an image from the array, by an ID
*
* @param integer $index Index of the image to get
* @param boolean $preformat If true, the path returned will be preformated
* @return string
*/
function retrieveImageByID($index, $preformat)
{
$image="";
if (isset($this->_images))
{
reset($this->_images);
while ((list($k, $img) = each($this->_images)) && $image == "")
{
if ($k == $index)
{
$image = $img;
}
}
}
if ($image != "")
{
$image = str_replace("%RPCL_HTTP_PATH%", RPCL_HTTP_PATH, $image);
}
if ($preformat == 1)
{
if (($image == "") || ($image == null))
{
$image = "null";
}
else
{
$image = "\"" . $image . "\"";
}
}
return $image;
}
}
?>