20 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
55 function id($format =
'N')
57 return $this->getVar(
'tpl_id', $format);
63 function tpl_id($format =
'')
65 return $this->getVar(
'tpl_id', $format);
71 function tpl_refid($format =
'')
73 return $this->getVar(
'tpl_refid', $format);
79 function tpl_tplset($format =
'')
81 return $this->getVar(
'tpl_tplset', $format);
87 function tpl_file($format =
'')
89 return $this->getVar(
'tpl_file', $format);
95 function tpl_desc($format =
'')
97 return $this->getVar(
'tpl_desc', $format);
103 function tpl_lastmodified($format =
'')
105 return $this->getVar(
'tpl_lastmodified', $format);
111 function tpl_lastimported($format =
'')
113 return $this->getVar(
'tpl_lastimported', $format);
119 function tpl_module($format =
'')
121 return $this->getVar(
'tpl_module', $format);
127 function tpl_type($format =
'')
129 return $this->getVar(
'tpl_type', $format);
135 function tpl_source($format =
'')
137 return $this->getVar(
'tpl_source', $format);
148 return $this->getVar(
'tpl_source');
156 function getLastModified()
158 return $this->getVar(
'tpl_lastmodified');
195 function &
get($id, $getsource =
false)
201 $sql =
'SELECT * FROM ' . $this->db->prefix(
'tplfile') .
' WHERE tpl_id=' . $id;
203 $sql =
'SELECT f.*, s.tpl_source FROM ' . $this->db->prefix(
'tplfile') .
' f LEFT JOIN ' . $this->db->prefix(
'tplsource') .
' s ON s.tpl_id=f.tpl_id WHERE f.tpl_id=' . $id;
208 $numrows = $this->db->getRowsNum(
$result);
211 $tplfile->assignVars($this->db->fetchArray(
$result));
228 if (!is_a($tplfile,
'xoopstplfile')) {
232 if (!$tplfile->getVar(
'tpl_source')) {
233 $sql =
'SELECT tpl_source FROM ' . $this->db->prefix(
'tplsource') .
' WHERE tpl_id=' . $tplfile->getVar(
'tpl_id');
237 $myrow = $this->db->fetchArray(
$result);
238 $tplfile->assignVar(
'tpl_source', $myrow[
'tpl_source']);
254 if (!is_a($tplfile,
'xoopstplfile')) {
257 if (!$tplfile->isDirty()) {
260 if (!$tplfile->cleanVars()) {
263 foreach ($tplfile->cleanVars as $k => $v) {
266 if ($tplfile->isNew()) {
267 $tpl_id = $this->db->genId(
'tpltpl_file_id_seq');
268 $sql = sprintf(
"INSERT INTO %s (tpl_id, tpl_module, tpl_refid, tpl_tplset, tpl_file, tpl_desc, tpl_lastmodified, tpl_lastimported, tpl_type) VALUES (%u, %s, %u, %s, %s, %s, %u, %u, %s)", $this->db->prefix(
'tplfile'), $tpl_id, $this->db->quoteString($tpl_module), $tpl_refid, $this->db->quoteString($tpl_tplset), $this->db->quoteString($tpl_file), $this->db->quoteString($tpl_desc), $tpl_lastmodified, $tpl_lastimported, $this->db->quoteString($tpl_type));
272 if (empty($tpl_id)) {
273 $tpl_id = $this->db->getInsertId();
275 if (isset($tpl_source) && $tpl_source !=
'') {
276 $sql = sprintf(
"INSERT INTO %s (tpl_id, tpl_source) VALUES (%u, %s)", $this->db->prefix(
'tplsource'), $tpl_id, $this->db->quoteString($tpl_source));
278 $this->db->query(sprintf(
"DELETE FROM %s WHERE tpl_id = %u", $this->db->prefix(
'tplfile'), $tpl_id));
282 $tplfile->assignVar(
'tpl_id', $tpl_id);
284 $sql = sprintf(
"UPDATE %s SET tpl_tplset = %s, tpl_file = %s, tpl_desc = %s, tpl_lastimported = %u, tpl_lastmodified = %u WHERE tpl_id = %u", $this->db->prefix(
'tplfile'), $this->db->quoteString($tpl_tplset), $this->db->quoteString($tpl_file), $this->db->quoteString($tpl_desc), $tpl_lastimported, $tpl_lastmodified, $tpl_id);
288 if (isset($tpl_source) && $tpl_source !=
'') {
289 $sql = sprintf(
"UPDATE %s SET tpl_source = %s WHERE tpl_id = %u", $this->db->prefix(
'tplsource'), $this->db->quoteString($tpl_source), $tpl_id);
309 if (!is_a($tplfile,
'xoopstplfile')) {
312 if (!$tplfile->isDirty()) {
315 if (!$tplfile->cleanVars()) {
318 foreach ($tplfile->cleanVars as $k => $v) {
321 if (!$tplfile->isNew()) {
322 $sql = sprintf(
"UPDATE %s SET tpl_tplset = %s, tpl_file = %s, tpl_desc = %s, tpl_lastimported = %u, tpl_lastmodified = %u WHERE tpl_id = %u", $this->db->prefix(
'tplfile'), $this->db->quoteString($tpl_tplset), $this->db->quoteString($tpl_file), $this->db->quoteString($tpl_desc), $tpl_lastimported, $tpl_lastmodified, $tpl_id);
326 if (isset($tpl_source) && $tpl_source !=
'') {
327 $sql = sprintf(
"UPDATE %s SET tpl_source = %s WHERE tpl_id = %u", $this->db->prefix(
'tplsource'), $this->db->quoteString($tpl_source), $tpl_id);
344 function delete(&$tplfile)
349 if (!is_a($tplfile,
'xoopstplfile')) {
352 $id = $tplfile->getVar(
'tpl_id');
353 $sql = sprintf(
"DELETE FROM %s WHERE tpl_id = %u", $this->db->prefix(
'tplfile'), $id);
357 $sql = sprintf(
"DELETE FROM %s WHERE tpl_id = %u", $this->db->prefix(
'tplsource'), $id);
358 $this->db->query(
$sql);
373 $sql =
'SELECT f.*, s.tpl_source FROM ' . $this->db->prefix(
'tplfile') .
' f LEFT JOIN ' . $this->db->prefix(
'tplsource') .
' s ON s.tpl_id=f.tpl_id';
375 $sql =
'SELECT * FROM ' . $this->db->prefix(
'tplfile');
378 $sql .=
' ' .
$criteria->renderWhere() .
' ORDER BY tpl_refid';
386 while ($myrow = $this->db->fetchArray(
$result)) {
388 $tplfile->assignVars($myrow);
392 $ret[$myrow[
'tpl_id']] =& $tplfile;
407 $sql =
'SELECT COUNT(*) FROM ' . $this->db->prefix(
'tplfile');
414 list ($count) = $this->db->fetchRow(
$result);
427 $sql =
"SELECT tpl_module, COUNT(tpl_id) AS count FROM " . $this->db->prefix(
'tplfile') .
" WHERE tpl_tplset='" . $tplset .
"' GROUP BY tpl_module";
432 while ($myrow = $this->db->fetchArray(
$result)) {
433 if ($myrow[
'tpl_module'] !=
'') {
434 $ret[$myrow[
'tpl_module']] = $myrow[
'count'];
454 if (isset($tplset)) {
467 if (is_array(
$type)) {
469 foreach (
$type as $t) {