56 lines
973 B
PHP
56 lines
973 B
PHP
|
<?php
|
||
|
|
||
|
if(!defined('ONYX')) exit;
|
||
|
|
||
|
class Theme {
|
||
|
|
||
|
$id=null;
|
||
|
$title;
|
||
|
|
||
|
function Theme($id=null)
|
||
|
{
|
||
|
if (!empty($id))
|
||
|
{
|
||
|
$db = new BDD();
|
||
|
$res = $db->unique_query("SELECT id, title
|
||
|
FROM themes WHERE id=" . intval($id));
|
||
|
|
||
|
if (!empty($res))
|
||
|
{
|
||
|
$this->title = $res['title'];
|
||
|
}
|
||
|
$db->deconnexion();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function update()
|
||
|
{
|
||
|
$title = $this->title;
|
||
|
|
||
|
$db = new BDD();
|
||
|
$db->escape($title);
|
||
|
|
||
|
if (empty($this->id))
|
||
|
{
|
||
|
$db->query("INSERT INTO themes
|
||
|
VALUES (NULL, '".$title);
|
||
|
$this->id = $db->insert_id();
|
||
|
$aff = ($this->id > 0);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
$db->query("UPDATE themes
|
||
|
SET title = '".$title."'
|
||
|
WHERE id = ".intval($this->id));
|
||
|
$aff = $db->affected();
|
||
|
}
|
||
|
$db->deconnexion();
|
||
|
|
||
|
return ($aff == 1);
|
||
|
}
|
||
|
|
||
|
function get_title()
|
||
|
{
|
||
|
return $this->title;
|
||
|
}
|
||
|
}
|