19 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
47 function id($format =
'N')
49 return $this->getVar(
'imgset_id', $format);
55 function imgset_id($format =
'')
57 return $this->getVar(
'imgset_id', $format);
63 function imgset_name($format =
'')
65 return $this->getVar(
'imgset_name', $format);
71 function imgset_refid($format =
'')
73 return $this->getVar(
'imgset_refid', $format);
115 $sql =
'SELECT * FROM ' . $this->db->prefix(
'imgset') .
' WHERE imgset_id=' . $id;
119 $numrows = $this->db->getRowsNum(
$result);
122 $imgset->assignVars($this->db->fetchArray(
$result));
139 if (!is_a($imgset,
'xoopsimageset')) {
143 if (!$imgset->isDirty()) {
146 if (!$imgset->cleanVars()) {
149 foreach ($imgset->cleanVars as $k => $v) {
152 if ($imgset->isNew()) {
153 $imgset_id = $this->db->genId(
'imgset_imgset_id_seq');
154 $sql = sprintf(
"INSERT INTO %s (imgset_id, imgset_name, imgset_refid) VALUES (%u, %s, %u)", $this->db->prefix(
'imgset'), $imgset_id, $this->db->quoteString($imgset_name), $imgset_refid);
156 $sql = sprintf(
"UPDATE %s SET imgset_name = %s, imgset_refid = %u WHERE imgset_id = %u", $this->db->prefix(
'imgset'), $this->db->quoteString($imgset_name), $imgset_refid, $imgset_id);
161 if (empty($imgset_id)) {
162 $imgset_id = $this->db->getInsertId();
164 $imgset->assignVar(
'imgset_id', $imgset_id);
174 function delete(&$imgset)
179 if (!is_a($imgset,
'xoopsimageset')) {
182 $sql = sprintf(
"DELETE FROM %s WHERE imgset_id = %u", $this->db->prefix(
'imgset'), $imgset->getVar(
'imgset_id'));
186 $sql = sprintf(
"DELETE FROM %s WHERE imgset_id = %u", $this->db->prefix(
'imgset_tplset_link'), $imgset->getVar(
'imgset_id'));
187 $this->db->query(
$sql);
203 $sql =
'SELECT DISTINCT i.* FROM ' . $this->db->prefix(
'imgset') .
' i LEFT JOIN ' . $this->db->prefix(
'imgset_tplset_link') .
' l ON l.imgset_id=i.imgset_id';
213 while ($myrow = $this->db->fetchArray(
$result)) {
215 $imgset->assignVars($myrow);
219 $ret[$myrow[
'imgset_id']] =& $imgset;
235 $imgset_id = intval($imgset_id);
236 $tplset_name = trim($tplset_name);
237 if ($imgset_id <= 0 || $tplset_name ==
'') {
243 $sql = sprintf(
"INSERT INTO %s (imgset_id, tplset_name) VALUES (%u, %s)", $this->db->prefix(
'imgset_tplset_link'), $imgset_id, $this->db->quoteString($tplset_name));
260 $imgset_id = intval($imgset_id);
261 $tplset_name = trim($tplset_name);
262 if ($imgset_id <= 0 || $tplset_name ==
'') {
265 $sql = sprintf(
"DELETE FROM %s WHERE imgset_id = %u AND tplset_name = %s", $this->db->prefix(
'imgset_tplset_link'), $imgset_id, $this->db->quoteString($tplset_name));
280 function getList($refid = null, $tplset = null)
286 if (isset($tplset)) {
291 foreach (array_keys($imgsets) as
$i) {
292 $ret[
$i] = $imgsets[
$i]->getVar(
'imgset_name');