8 require_once( CH_DIRECTORY_PATH_CLASSES .
'ChWsbModuleDb.php' );
18 parent::__construct($oConfig);
20 $this->_oConfig = $oConfig;
25 return $this->
getRow(
"SELECT * FROM `" . $this->_sPrefix .
"main` WHERE 1 LIMIT 1");
32 return unserialize($aStyle[
'tmp']);
41 return unserialize($aStyle[
'css']);
50 return $this->
query(
"INSERT INTO `" . $this->_sPrefix .
"main` (`" .
$sType .
"`) VALUES('" . $sStyle .
"')");
52 return $this->
query(
"UPDATE `" . $this->_sPrefix .
"main` SET `" .
$sType .
"`='" . $sStyle .
"' WHERE 1 LIMIT 1");
57 return $this->
query(
"UPDATE `" . $this->_sPrefix .
"main` SET `css`=`tmp` WHERE 1 LIMIT 1");
62 return $this->
updateSite(serialize($aTmp),
'tmp');
67 return $this->
updateSite(serialize($aCss),
'css');
72 return $this->
query(
"DELETE FROM `" . $this->_sPrefix .
"main` WHERE 1 LIMIT 1");
78 $aRows = $this->
getAll(
"SELECT `name`, `caption`, `css_name`, `type` FROM `" . $this->_sPrefix .
"units`");
80 foreach ($aRows
as $aValue) {
81 $aResult[$aValue[
'type']][$aValue[
'name']] = array(
82 'name' => $aValue[
'caption'],
83 'css_name' => $aValue[
'css_name']
92 return $this->
getRow(
"SELECT * FROM `" . $this->_sPrefix .
"units` WHERE `id` = ? LIMIT 1", [$iUnitId]);
97 return $this->
query(
"DELETE FROM `" . $this->_sPrefix .
"units` WHERE `id` = ?", [$iUnitId]);
102 return $this->
getAll(
"SELECT * FROM `" . $this->_sPrefix .
"themes` WHERE 1 ORDER BY `id`");
107 return $this->
getAll(
"SELECT * FROM `" . $this->_sPrefix .
"themes` WHERE `ownerid` = ? ORDER BY `id`", [0]);
112 return $this->
getRow(
"SELECT * FROM `" . $this->_sPrefix .
"themes` WHERE `name` = ? LIMIT 1", [
$sName]);
117 return $this->
getRow(
"SELECT * FROM `" . $this->_sPrefix .
"themes` WHERE `id` = ? LIMIT 1", [$iThemeId]);
122 if ((
int)$iThemeId) {
123 $aTheme = $this->
getRow(
"SELECT * FROM `" . $this->_sPrefix .
"themes` WHERE `id` = ? LIMIT 1", [$iThemeId]);
126 return unserialize($aTheme[
'css']);
134 if($this->
query(
"INSERT INTO `" . $this->_sPrefix .
"themes` (`name`, `ownerid`, `css`) VALUES(?, ?, ?)", [
$sName, $iOwnerId, $sCss]))
142 return $this->
query(
"DELETE FROM `" . $this->_sPrefix .
"themes` WHERE `id` = ?", [$iThemeId]);
147 if (strlen(
$sExt) > 0 && $this->
query(
"INSERT INTO `" . $this->_sPrefix .
"images` (`ext`, `count`) VALUES(?, 1)", [
$sExt]))
155 if (strlen($sFileName) > 0) {
156 $sId = basename($sFileName,
'.' . pathinfo($sFileName, PATHINFO_EXTENSION));
157 return strlen(
$sId) > 0 ? $this->
query(
"UPDATE `" . $this->_sPrefix .
"images` SET `count` = `count` + 1 WHERE `id` = ?", [
$sId]) : 0;
167 if (strlen($sFileName) > 0) {
168 $sId = basename($sFileName,
'.' . pathinfo($sFileName, PATHINFO_EXTENSION));
169 if (strlen(
$sId) > 0 && $this->
query(
"UPDATE `" . $this->_sPrefix .
"images` SET `count` = `count` - 1 WHERE `id` = ?", [
$sId])) {
170 $aRow = $this->
getRow(
"SELECT * FROM `" . $this->_sPrefix .
"images` WHERE `id` = $sId LIMIT 1");
171 if ($aRow[
'count'] < 1)
172 $this->
query(
"DELETE FROM `" . $this->_sPrefix .
"images` WHERE `id` = $sId");
183 return $this->
getOne(
"SELECT `ID` FROM `sys_options_cats` WHERE `name` = 'Profile Customizer' LIMIT 1");