62 public function id($format =
'n')
64 return $this->
getVar(
'tpl_id', $format);
76 return $this->
getVar(
'tpl_id', $format);
88 return $this->
getVar(
'tpl_refid', $format);
100 return $this->
getVar(
'tpl_tplset', $format);
112 return $this->
getVar(
'tpl_file', $format);
124 return $this->
getVar(
'tpl_desc', $format);
136 return $this->
getVar(
'tpl_lastmodified', $format);
148 return $this->
getVar(
'tpl_lastimported', $format);
160 return $this->
getVar(
'tpl_module', $format);
172 return $this->
getVar(
'tpl_type', $format);
184 return $this->
getVar(
'tpl_source', $format);
195 return $this->
getVar(
'tpl_source');
205 return $this->
getVar(
'tpl_lastmodified');
227 parent::__construct($db,
'tplfile',
'XoopsTplfile',
'tpl_id',
'tpl_refid');
240 $qb = $this->db2->createXoopsQueryBuilder();
247 ->fromPrefix(
'tplfile',
'f')
248 ->where($eb->eq(
'f.tpl_id',
':tplid'))
249 ->setParameter(
':tplid',
$id, \PDO::PARAM_INT);
252 ->addSelect(
's.tpl_source')
253 ->fromPrefix(
'tplfile',
'f')
254 ->leftJoinPrefix(
'f',
'tplsource',
's', $eb->eq(
's.tpl_id',
'f.tpl_id'))
255 ->where($eb->eq(
'f.tpl_id',
':tplid'))
256 ->setParameter(
':tplid',
$id, \PDO::PARAM_INT);
262 $allrows =
$result->fetchAll();
263 if (count($allrows) == 1) {
265 $tplfile->assignVars(reset($allrows));
280 if (!$tplfile->getVar(
'tpl_source')) {
281 $qb = $this->db2->createXoopsQueryBuilder();
283 $qb->select(
'tpl_source')
284 ->fromPrefix(
'tplsource', null)
285 ->where($eb->eq(
'tpl_id',
':tplid'))
286 ->setParameter(
':tplid', $tplfile->getVar(
'tpl_id'), \PDO::PARAM_INT);
287 if (!
$result = $qb->execute()) {
290 $myrow =
$result->fetch(\PDO::FETCH_ASSOC);
291 $tplfile->assignVar(
'tpl_source', $myrow[
'tpl_source']);
311 foreach ($tplfile->
cleanVars as $k => $v) {
314 if ($tplfile->
isNew()) {
318 'tpl_module' => $tpl_module,
319 'tpl_refid' => $tpl_refid,
320 'tpl_tplset' => $tpl_tplset,
321 'tpl_file' => $tpl_file,
322 'tpl_desc' => $tpl_desc,
323 'tpl_lastmodified' => $tpl_lastmodified,
324 'tpl_lastimported' => $tpl_lastimported,
325 'tpl_type' => $tpl_type,
327 if (!$this->db2->insertPrefix(
'tplfile', $values)) {
330 if (empty($tpl_id)) {
331 $tpl_id = $this->db2->lastInsertId();
333 if (isset($tpl_source) && $tpl_source !=
'') {
336 'tpl_source' => $tpl_source,
338 if (!$this->db2->insertPrefix(
'tplsource', $values)) {
339 $this->db2->deletePrefix(
'tplfile', array(
'tpl_id' => $tpl_id));
347 'tpl_module' => $tpl_module,
348 'tpl_refid' => $tpl_refid,
349 'tpl_tplset' => $tpl_tplset,
350 'tpl_file' => $tpl_file,
351 'tpl_desc' => $tpl_desc,
352 'tpl_lastmodified' => $tpl_lastmodified,
353 'tpl_lastimported' => $tpl_lastimported,
354 'tpl_type' => $tpl_type,
356 if (!$this->db2->updatePrefix(
'tplfile', $values, array(
'tpl_id' => $tpl_id))) {
360 if (isset($tpl_source) && $tpl_source !=
'') {
363 'tpl_source' => $tpl_source,
365 if ($this->db2->updatePrefix(
'tplsource', $values, array(
'tpl_id' => $tpl_id))) {
389 foreach ($tplfile->
cleanVars as $k => $v) {
392 if (!$tplfile->
isNew()) {
396 'tpl_module' => $tpl_module,
397 'tpl_refid' => $tpl_refid,
398 'tpl_tplset' => $tpl_tplset,
399 'tpl_file' => $tpl_file,
400 'tpl_desc' => $tpl_desc,
401 'tpl_lastmodified' => $tpl_lastmodified,
402 'tpl_lastimported' => $tpl_lastimported,
403 'tpl_type' => $tpl_type,
405 if (!$this->db2->updatePrefix(
'tplfile', $values, array(
'tpl_id' => $tpl_id))) {
409 if (isset($tpl_source) && $tpl_source !=
'') {
413 'tpl_source' => $tpl_source,
415 if ($this->db2->updatePrefix(
'tplsource', $values, array(
'tpl_id' => $tpl_id))) {
435 $tpl_id = $tplfile->
getVar(
'tpl_id');
436 if (!$this->db2->deletePrefix(
'tplfile', array(
'tpl_id' => $tpl_id))) {
439 $this->db2->deletePrefix(
'tplsource', array(
'tpl_id' => $tpl_id));
454 $qb = $this->db2->createXoopsQueryBuilder();
461 ->fromPrefix(
'tplfile',
'f');
464 ->addSelect(
's.tpl_source')
465 ->fromPrefix(
'tplfile',
'f')
466 ->leftJoinPrefix(
'f',
'tplsource',
's', $eb->eq(
's.tpl_id',
'f.tpl_id'));
475 while ($myrow =
$result->fetch(\PDO::FETCH_ASSOC)) {
477 $tplfile->assignVars($myrow);
481 $ret[$myrow[
'tpl_id']] = $tplfile;
497 $qb = $this->db2->createXoopsQueryBuilder();
500 $qb->select(
'tpl_module')
501 ->addSelect(
'COUNT(tpl_id) AS count')
502 ->fromPrefix(
'tplfile', null)
503 ->where($eb->eq(
'tpl_tplset',
':tpset'))
504 ->groupBy(
'tpl_module')
505 ->setParameter(
':tpset', $tplset, \PDO::PARAM_STR);
512 while ($myrow =
$result->fetch(\PDO::FETCH_ASSOC)) {
513 if ($myrow[
'tpl_module'] !=
'') {
514 $ret[$myrow[
'tpl_module']] = $myrow[
'count'];
535 if (isset($tplset)) {
548 if (is_array(
$type)) {
550 foreach (
$type as $t) {
forceUpdate(XoopsTplfile &$tplfile)
getCount(CriteriaElement $criteria=null)
deleteTpl(XoopsTplfile &$tplfile)
if(!isset($xoops->paths[$path_type])) if($path_type== 'var') $file
find($tplset=null, $type=null, $refid=null, $module=null, $file=null, $getsource=false)
tpl_lastimported($format= '')
getVar($key, $format= 's')
getTplObjects(CriteriaElement $criteria=null, $getsource=false, $id_as_key=false)
getModuleTplCount($tplset)
tpl_lastmodified($format= '')
__construct(Connection $db=null)
getById($id, $getsource=false)
templateExists($tplname, $tplset_name)
initVar($key, $data_type, $value=null, $required=false, $maxlength=null, $options= '')
insertTpl(XoopsTplfile &$tplfile)
loadSource(XoopsTplFile &$tplfile)