Go to the documentation of this file.
8 require_once(CH_DIRECTORY_PATH_CLASSES .
'ChWsbFilesDb.php');
17 parent::__construct($oConfig);
19 $this->sFileTable =
'ch_files_main';
20 $this->sFavoriteTable =
'ch_files_favorites';
21 $this->sMimeTypeTable =
'ch_files_types';
28 'DownloadsCount' =>
'DownloadsCount',
29 'AllowDownload' =>
'AllowDownload'
31 $this->aFileFields = array_merge($this->aFileFields, $aAddFields);
33 $this->aFavoriteFields = array(
35 'ownerId' =>
'Profile',
43 $sqlQuery =
"SELECT `Icon` FROM `{$this->sMimeTypeTable}` WHERE `{$this->aFileFields['Type']}`='$sType' LIMIT 1";
44 return $this->
getOne($sqlQuery);
49 return $this->
getPairs(
"SELECT `Type`, `Icon` FROM `{$this->sMimeTypeTable}` WHERE 1",
"Type",
"Icon");
55 return $this->
query(
"SELECT `{$this->aFileFields['DownloadsCount']}` FROM `{$this->sFileTable}` WHERE `{$this->aFileFields['medID']}` = '$iFile'");
61 $this->
query(
"UPDATE `{$this->sFileTable}` SET `{$this->aFileFields['DownloadsCount']}` = `{$this->aFileFields['DownloadsCount']}` + 1 WHERE `{$this->aFileFields['medUri']}`='$sFileUri'");
67 $sqlQuery =
"INSERT INTO `{$this->sMimeTypeTable}` SET `Type`='$sMimeType'";
68 $this->
res($sqlQuery);
74 if (is_array($mixedMimeTypes))
75 $sqlCond =
"IN('" . implode(
"', '", $mixedMimeTypes) .
"')";
77 $sqlCond =
"= '$mixedMimeTypes'";
79 $sqlQuery =
"UPDATE `{$this->sMimeTypeTable}` SET `Icon` = '$sPic' WHERE `Type` $sqlCond";
80 $this->
res($sqlQuery);
86 $sqlQuery =
"SELECT COUNT(*) FROM `{$this->sMimeTypeTable}` WHERE `Type`='$sMimeType'";
87 return (
int)$this->
getOne($sqlQuery);
92 return (
int)$this->
getOne(
"SELECT `ID` FROM `sys_options_cats` WHERE `name` = 'Files' LIMIT 1");
process_db_input($sText, $iStripTags=0)
getPairs($sQuery, $sFieldKey, $sFieldValue, $aBindings=[])
checkMimeTypeExist($sMimeType)
updateMimeTypePic($mixedMimeTypes, $sPic)
query($sQuery, $aBindings=[])
res($sQuery, $aBindings=[], $bReplaying=false)
insertMimeType($sMimeType)
getOne($sQuery, $aBindings=[], $iIndex=0)
updateDownloadsCount($sFileUri)
getDownloadsCount($iFile)