19 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
50 function id($format =
'N')
52 return $this->getVar(
'image_id', $format);
58 function image_id($format =
'')
60 return $this->getVar(
'image_id', $format);
66 function image_name($format =
'')
68 return $this->getVar(
'image_name', $format);
74 function image_nicename($format =
'')
76 return $this->getVar(
'image_nicename', $format);
82 function image_mimetype($format =
'')
84 return $this->getVar(
'image_mimetype', $format);
90 function image_created($format =
'')
92 return $this->getVar(
'image_created', $format);
98 function image_display($format =
'')
100 return $this->getVar(
'image_display', $format);
106 function image_weight($format =
'')
108 return $this->getVar(
'image_weight', $format);
114 function image_body($format =
'')
116 return $this->getVar(
'image_body', $format);
122 function imgcat_id($format =
'')
124 return $this->getVar(
'imgcat_id', $format);
164 function &
get($id, $getbinary =
true)
169 $sql =
'SELECT i.*, b.image_body FROM ' . $this->db->prefix(
'image') .
' i LEFT JOIN ' . $this->db->prefix(
'imagebody') .
' b ON b.image_id=i.image_id WHERE i.image_id=' . $id;
173 $numrows = $this->db->getRowsNum(
$result);
193 if (!is_a(
$image,
'xoopsimage')) {
200 if (!
$image->cleanVars()) {
203 foreach (
$image->cleanVars as $k => $v) {
207 $image_id = $this->db->genId(
'image_image_id_seq');
208 $sql = sprintf(
"INSERT INTO %s (image_id, image_name, image_nicename, image_mimetype, image_created, image_display, image_weight, imgcat_id) VALUES (%u, %s, %s, %s, %u, %u, %u, %u)", $this->db->prefix(
'image'),
$image_id, $this->db->quoteString($image_name), $this->db->quoteString($image_nicename), $this->db->quoteString($image_mimetype), time(), $image_display, $image_weight, $imgcat_id);
215 if (isset($image_body) && $image_body !=
'') {
216 $sql = sprintf(
"INSERT INTO %s (image_id, image_body) VALUES (%u, %s)", $this->db->prefix(
'imagebody'),
$image_id, $this->db->quoteString($image_body));
218 $sql = sprintf(
"DELETE FROM %s WHERE image_id = %u", $this->db->prefix(
'image'),
$image_id);
219 $this->db->query(
$sql);
225 $sql = sprintf(
"UPDATE %s SET image_name = %s, image_nicename = %s, image_display = %u, image_weight = %u, imgcat_id = %u WHERE image_id = %u", $this->db->prefix(
'image'), $this->db->quoteString($image_name), $this->db->quoteString($image_nicename), $image_display, $image_weight, $imgcat_id,
$image_id);
229 if (isset($image_body) && $image_body !=
'') {
230 $sql = sprintf(
"UPDATE %s SET image_body = %s WHERE image_id = %u", $this->db->prefix(
'imagebody'), $this->db->quoteString($image_body),
$image_id);
232 $this->db->query(sprintf(
"DELETE FROM %s WHERE image_id = %u", $this->db->prefix(
'image'),
$image_id));
251 if (!is_a(
$image,
'xoopsimage')) {
255 $id =
$image->getVar(
'image_id');
256 $sql = sprintf(
"DELETE FROM %s WHERE image_id = %u", $this->db->prefix(
'image'), $id);
260 $sql = sprintf(
"DELETE FROM %s WHERE image_id = %u", $this->db->prefix(
'imagebody'), $id);
261 $this->db->query(
$sql);
278 $sql =
'SELECT i.*, b.image_body FROM ' . $this->db->prefix(
'image') .
' i LEFT JOIN ' . $this->db->prefix(
'imagebody') .
' b ON b.image_id=i.image_id';
280 $sql =
'SELECT * FROM ' . $this->db->prefix(
'image');
293 while ($myrow = $this->db->fetchArray(
$result)) {
295 $image->assignVars($myrow);
314 $sql =
'SELECT COUNT(*) FROM ' . $this->db->prefix(
'image');
321 list ($count) = $this->db->fetchRow(
$result);
332 function getList($imgcat_id, $image_display = null)
335 if (isset($image_display)) {
340 foreach (array_keys($images) as
$i) {
341 $ret[$images[
$i]->getVar(
'image_name')] = $images[
$i]->getVar(
'image_nicename');