CMS
Version 3.9
image_picker.inc
Go to the documentation of this file.
1
<?php
2
/**************************************************************
3
4
Copyright (c) 2010 Sonjara, Inc
5
6
Permission is hereby granted, free of charge, to any person
7
obtaining a copy of this software and associated documentation
8
files (the "Software"), to deal in the Software without
9
restriction, including without limitation the rights to use,
10
copy, modify, merge, publish, distribute, sublicense, and/or sell
11
copies of the Software, and to permit persons to whom the
12
Software is furnished to do so, subject to the following
13
conditions:
14
15
The above copyright notice and this permission notice shall be
16
included in all copies or substantial portions of the Software.
17
18
Except as contained in this notice, the name(s) of the above
19
copyright holders shall not be used in advertising or otherwise
20
to promote the sale, use or other dealings in this Software
21
without prior written authorization.
22
23
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
25
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
27
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
28
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
30
OTHER DEALINGS IN THE SOFTWARE.
31
32
*****************************************************************/
33
34
Fakoli::using
(
"image"
);
35
36
$mode
= $_GET[
"Mode"
];
// "insert" or "select" - "select" is default
37
$editor
= $_GET[
"Editor"
];
// in "insert" mode - ID of the RTE to insert the image into
38
$field
= $_GET[
"Field"
];
// in "select" mode - ID of the field to set the value of
39
$preview
= $_GET[
"Preview"
];
// in "select" mode - ID of the element to display the preview thumbnail.
40
$gallery_id
= checkNumeric($_GET[
"gallery_id"
]);
41
42
$title
= (
$mode
==
"insert"
) ?
"Insert Images"
:
"Select an Image"
;
43
44
$galleries
= Query::create(
ImageGallery
,
"ORDER BY gallery_name"
)->execute();
45
46
if
(!
$gallery_id
&& count(
$galleries
) > 0)
47
{
48
$gallery_id
=
$galleries
[0]->gallery_id;
49
}
50
51
$styles
.= <<<ENDSTYLES
52
<
style
type=
"text/css"
>
53
body
54
{
55
text-
align
:
left
;
56
}
57
58
#preview
59
{
60
border:1px inset #888;
61
display:table-cell;
62
height
:200px;
63
text-
align
:center;
64
vertical-
align
:middle;
65
width
:200px;
66
margin-
left
: 20px;
67
-moz-border-radius: 8px;
68
border-radius: 8px;
69
background-
color
: #eee;
70
}
71
#searchblock
72
{
73
width
: 95%;
74
height
: 250px;
75
border: solid 1px #000;
76
overflow:
auto
;
77
clear:
left
;
78
}
79
80
</
style
>
81
ENDSTYLES;
82
83
$script
.= <<<ENDSCRIPT
84
<script type=
"text/javascript"
>
85
var imagePicker;
86
window.addEvent(
'domready'
,
function
()
87
{
88
imagePicker =
new
ImagePicker(
'$editor'
,
'$mode'
,
'$field'
,
'$preview'
);
89
});
90
</script>
91
ENDSCRIPT;
92
93
$gallery
=
new
ImageGallery
();
94
if
(
$gallery_id
)
95
{
96
$gallery
->load(
$gallery_id
);
97
$images
=
$gallery
->Images();
98
}
99
else
100
{
101
$images
= array();
102
}
103
104
$view
=
new
ImageListView
(
$images
,
"javascript:imagePicker.selectImage({image_id}, '{title}')"
);
105
106
?>
107
<div
style
=
"border: solid 1px #666; background: url(/fakoli/images/table-header.png); width: 95%;margin-left: 10px; padding: 2px;"
>
108
<div
style
=
"float: left; width: auto"
><strong>Gallery </strong>
109
<select name=
"gallery_id"
id
=
"gallery_id"
onchange=
"imagePicker.showImages(this.value)"
>
110
<?
111
foreach
(
$galleries
as
$gallery
)
112
{
113
option(
$gallery
->gallery_id,
$gallery
->gallery_name,
$gallery_id
);
114
}
115
?>
116
</select>
117
</div>
118
<div
style
=
"float: right;width: auto"
><button
class
=
"button"
onclick=
"imagePicker.uploadImage()"
<?
if
(!
$gallery_id
) echo
" disabled='disabled'"
?>>Upload Image...</button></div>
119
<div
style
=
"clear:both"
></div>
120
</div>
121
<div
id
=
"image_list"
style
=
"overflow:auto; width:95%; height: 200px;border: solid 1px #666; margin-left: 10px; padding: 2px; background-color: #fff"
>
122
<?
123
$view
->drawGrid();
124
?>
125
</div>
126
<table border=
"0"
style
=
"width: 100%"
class
=
"layout"
>
127
<tr>
128
<td
style
=
"width: 50%"
><div
style
=
"display: block; float: right; margin: 10px"
><div
id
=
"preview"
></div></div></td>
129
<td
style
=
"width: 50%"
>
130
<table
class
=
"layout"
>
131
132
<?
133
if
(
$mode
!=
"select"
)
134
{
135
?>
136
<tr>
137
<td><label
for
=
"alignment"
>Alignment:</label></td>
138
<td>
139
<select
id
=
"alignment"
name=
"alignment"
style
=
"width: 120px"
>
140
<option value=
""
>Inline with Text</option>
141
<option value=
"left"
>Left</option>
142
<option value=
"center"
>Center</option>
143
<option value=
"right"
>Right</option>
144
</select>
145
</td>
146
</tr>
147
<tr>
148
<td><label
for
=
"width"
>Width:</label></td>
149
<td><input type=
"text"
style
=
"width: 60px"
id
=
"width"
name=
"width"
value=
""
onkeypress=
"return imagePicker.maskInput(event)"
onkeyup=
"imagePicker.changeWidth()"
/> pixels</td>
150
</tr>
151
<tr>
152
<td><label
for
=
"height"
>Height:</label></td>
153
<td><input type=
"text"
style
=
"width: 60px"
id
=
"height"
name=
"height"
value=
""
onkeypress=
"return imagePicker.maskInput(event)"
onkeyup=
"imagePicker.changeHeight()"
/> pixels</td>
154
</tr>
155
<tr>
156
<td
colspan
=
"2"
><input type=
"checkbox"
id
=
"aspect"
name=
"aspect"
value=
"1"
checked />&
nbsp
;<label
for
=
"aspect"
>Maintain aspect ratio</label></td>
157
</tr>
158
159
<tr>
160
<td
colspan
=
"2"
style
=
"text-align: center"
><br/>
161
<input type=
"button"
class
=
"button"
name=
"insert"
value=
"Insert Image"
onclick=
"imagePicker.insertImage()"
/>
162
</td>
163
</tr>
164
<?
165
}
166
else
167
{
168
?>
169
<tr>
170
<td
style
=
"text-align: center"
><br/>
171
<input type=
"button"
class
=
"button"
name=
"insert"
value=
"Select Image"
onclick=
"imagePicker.insertImage()"
/>
172
</td>
173
<td
style
=
"text-align: center"
><br/>
174
<input type=
"button"
class
=
"button"
name=
"insert"
value=
"Clear Image"
onclick=
"imagePicker.clearImage()"
/>
175
</td>
176
</tr>
177
<?
178
}
179
?>
180
</table>
181
</td>
182
</tr>
183
</table>
nbsp
& nbsp
Definition:
index.inc:49
style
$helpTree style
Definition:
tree.inc:46
width
$helpTree width
Definition:
tree.inc:45
$images
$images
Definition:
images.inc:46
Fakoli\using
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition:
core.inc:116
ImageGallery
Definition:
image_gallery.inc:40
ImageListView
Definition:
image_list_view.inc:40
height
$desc height
Definition:
event_edit.inc:64
colspan
$topicList colspan
Definition:
group_form.inc:54
$script
if(! $gallery_id &&count($galleries) > 0) $script
Definition:
image_picker.inc:51
$preview
$preview
Definition:
image_picker.inc:39
$galleries
$galleries
Definition:
image_picker.inc:44
$gallery_id
$gallery_id
Definition:
image_picker.inc:40
left
margin left
Definition:
image_picker.inc:88
$mode
$mode
Definition:
image_picker.inc:36
$field
$field
Definition:
image_picker.inc:38
color
background color
Definition:
image_picker.inc:90
$view
$view
Definition:
image_picker.inc:71
$gallery
$gallery
Definition:
image_picker.inc:60
$title
$title
Definition:
image_picker.inc:42
$editor
$editor
Definition:
image_picker.inc:37
$styles
if(! $gallery_id &&count($galleries) > 0) $styles
Definition:
image_picker.inc:51
align
text align
Definition:
redirects.inc:13
code
cms.sonjara.com
cms
components
image_picker
pages
image_picker.inc
Generated on Tue Mar 23 2021 15:36:13 for CMS by
1.9.1