Skip to content

Commit

Permalink
KR formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimiryuriev committed May 4, 2013
1 parent 5a7af9c commit 49f0e59
Show file tree
Hide file tree
Showing 26 changed files with 262 additions and 498 deletions.
48 changes: 16 additions & 32 deletions engine/modules/database/Database.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
* поддержка плейсхолдера ?s — подзапрос с проверкой типов, тоесть неэкранированные данные вставить нельзя, а кусок запроса с подстановкой параметров можно
* поддержка конструкций {?… } — условная вставка и {… |… } — аналог else
*/
class ModuleDatabase extends Module
{
class ModuleDatabase extends Module {
/**
* Массив инстанцируемых объектов БД, или проще говоря уникальных коннектов к БД
*
Expand All @@ -51,13 +50,11 @@ class ModuleDatabase extends Module
* Инициализация модуля
*
*/
public function Init()
{
public function Init() {

}

protected function _getDbConnect($sDsn)
{
protected function _getDbConnect($sDsn) {
if (Config::Get('db.params.lazy')) {
// lazy connection
F::File_IncludeFile(Config::Get('path.root.engine') . '/lib/external/DbSimple3/lib/DbSimple/Connect.php');
Expand All @@ -81,8 +78,7 @@ protected function _getDbConnect($sDsn)
* если null, то используются параметры из конфига Config::Get('db.params')
* @return DbSimple_Connect|null
*/
public function GetConnect($aConfig = null)
{
public function GetConnect($aConfig = null) {
/**
* Если конфиг не передан то используем главный конфиг БД из config.php
*/
Expand Down Expand Up @@ -126,8 +122,7 @@ public function GetConnect($aConfig = null)
*
* @return array
*/
public function GetStats()
{
public function GetStats() {
$aQueryStats = array('time' => 0, 'count' => -1); // не считаем тот самый костыльный запрос, который устанавливает настройки DB соединения
foreach ($this->aInstance as $oDb) {
$aStats = $oDb->getStatistics();
Expand All @@ -138,16 +133,14 @@ public function GetStats()
return $aQueryStats;
}

public function SetLoggerOn()
{
public function SetLoggerOn() {
foreach ($this->aInstance as $sDsn => $oDb) {
$oDb->setLogger(array($this, 'Logger'));
$this->aInstance[$sDsn] = $oDb;
}
}

public function SetLoggerOff()
{
public function SetLoggerOff() {
foreach ($this->aInstance as $sDsn => $oDb) {
$oDb->setLogger(null);
$this->aInstance[$sDsn] = $oDb;
Expand All @@ -160,8 +153,7 @@ public function SetLoggerOff()
* @param object $oDb
* @param array $sSql
*/
function Logger($oDb, $sSql)
{
function Logger($oDb, $sSql) {
// Получаем информацию о запросе и сохраняем её в лог
$sMsg = print_r($sSql, true);
//Engine::getInstance()->Logger_Dump(Config::Get('sys.logs.sql_query_file'), $sMsg);
Expand All @@ -182,8 +174,7 @@ function Logger($oDb, $sSql)
* @param string $sMessage Сообщение об ошибке
* @param array $aInfo Информация об ошибке
*/
function ErrorHandler($sMessage, $aInfo)
{
function ErrorHandler($sMessage, $aInfo) {
/**
* Формируем текст сообщения об ошибке
*/
Expand Down Expand Up @@ -211,8 +202,7 @@ function ErrorHandler($sMessage, $aInfo)
* @param array|null $aConfig Конфиг подключения к БД
* @return array
*/
public function ExportSQL($sFilePath, $aConfig = null)
{
public function ExportSQL($sFilePath, $aConfig = null) {
if (!is_file($sFilePath)) {
return array('result' => false, 'errors' => array("cant find file '$sFilePath'"));
} elseif (!is_readable($sFilePath)) {
Expand All @@ -229,8 +219,7 @@ public function ExportSQL($sFilePath, $aConfig = null)
* @param array|null $aConfig Конфиг подключения к БД
* @return array Возвращает массив вида array('result'=>bool,'errors'=>array())
*/
public function ExportSQLQuery($sFileQuery, $aConfig = null)
{
public function ExportSQLQuery($sFileQuery, $aConfig = null) {
/**
* Замена префикса таблиц
*/
Expand Down Expand Up @@ -273,8 +262,7 @@ public function ExportSQLQuery($sFileQuery, $aConfig = null)
* @param array|null $aConfig - Конфиг подключения к БД
* @return bool
*/
public function isTableExists($sTableName, $aConfig = null)
{
public function isTableExists($sTableName, $aConfig = null) {
$sTableName = str_replace('prefix_', Config::Get('db.table.prefix'), $sTableName);
$sQuery = "SHOW TABLES LIKE '{$sTableName}'";
if ($aRows = $this->GetConnect($aConfig)->select($sQuery)) {
Expand All @@ -292,8 +280,7 @@ public function isTableExists($sTableName, $aConfig = null)
* @param array|null $aConfig - Конфиг подключения к БД
* @return bool
*/
public function isFieldExists($sTableName, $sFieldName, $aConfig = null)
{
public function isFieldExists($sTableName, $sFieldName, $aConfig = null) {
$sTableName = str_replace('prefix_', Config::Get('db.table.prefix'), $sTableName);
$sQuery = "SHOW FIELDS FROM `{$sTableName}`";
if ($aRows = $this->GetConnect($aConfig)->select($sQuery)) {
Expand All @@ -316,8 +303,7 @@ public function isFieldExists($sTableName, $sFieldName, $aConfig = null)
* @param array|null $aConfig - Конфиг подключения к БД
* @return null|bool
*/
public function AddEnumType($sTableName, $sFieldName, $sType, $aConfig = null)
{
public function AddEnumType($sTableName, $sFieldName, $sType, $aConfig = null) {
$sTableName = str_replace('prefix_', Config::Get('db.table.prefix'), $sTableName);
$sQuery = "SHOW COLUMNS FROM `{$sTableName}`";

Expand All @@ -336,8 +322,7 @@ public function AddEnumType($sTableName, $sFieldName, $sType, $aConfig = null)
}
}

public function AddField($sTableName, $sFieldName, $sFieldType, $sDefault = null, $bNull = null, $sAdditional = '', $aConfig = null)
{
public function AddField($sTableName, $sFieldName, $sFieldType, $sDefault = null, $bNull = null, $sAdditional = '', $aConfig = null) {
$sTableName = str_replace('prefix_', Config::Get('db.table.prefix'), $sTableName);
if (is_null($sDefault) && is_null($bNull)) {
$sNull = '';
Expand All @@ -354,8 +339,7 @@ public function AddField($sTableName, $sFieldName, $sFieldType, $sDefault = null
$this->GetConnect($aConfig)->query($sQuery);
}

public function AddIndex($sTableName, $aIndexFields, $sIndexType = null, $sIndexName = null, $aConfig = null)
{
public function AddIndex($sTableName, $aIndexFields, $sIndexType = null, $sIndexName = null, $aConfig = null) {
$sTableName = str_replace('prefix_', Config::Get('db.table.prefix'), $sTableName);
if (!is_array($aIndexFields)) $aIndexFields = array($aIndexFields);
$sFields = implode(',', $aIndexFields);
Expand Down
33 changes: 11 additions & 22 deletions engine/modules/less/Less.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@

require_once (Config::Get('path.root.engine') . '/lib/external/lessphp/lessc.inc.php');

class ModuleLess extends Module
{
class ModuleLess extends Module {
/** @var lessc */
protected $oLessCompiler;

/**
* Инициализация модуля
*
*/
public function Init()
{
public function Init() {
$this->oLessCompiler = new lessc();
}

Expand All @@ -32,8 +30,7 @@ public function Init()
* @param string $sString
* @return string
*/
public function Compile($sString)
{
public function Compile($sString) {
$sResult = null;
try {
$sResult = $this->oLessCompiler->compile($sString);
Expand All @@ -52,8 +49,7 @@ public function Compile($sString)
* @param string|null $sOutFile
* @return string
*/
public function CompileFile($sFileName, $sOutFile = null)
{
public function CompileFile($sFileName, $sOutFile = null) {
$sResult = null;
try {
$sResult = $this->oLessCompiler->compileFile($sFileName, $sOutFile);
Expand All @@ -68,8 +64,7 @@ public function CompileFile($sFileName, $sOutFile = null)
*
* @param $bPreserve
*/
public function SetPreserveComments($bPreserve)
{
public function SetPreserveComments($bPreserve) {
$this->oLessCompiler->setPreserveComments($bPreserve);
}

Expand All @@ -80,8 +75,7 @@ public function SetPreserveComments($bPreserve)
*
* @param $aVariables
*/
public function setVariables($aVariables)
{
public function setVariables($aVariables) {
$this->oLessCompiler->setVariables($aVariables);
}

Expand All @@ -90,8 +84,7 @@ public function setVariables($aVariables)
*
* @param $sName
*/
public function unsetVariable($sName)
{
public function unsetVariable($sName) {
$this->oLessCompiler->unsetVariable($sName);
}

Expand All @@ -100,8 +93,7 @@ public function unsetVariable($sName)
*
* @param $aDirs
*/
public function setImportDir($aDirs)
{
public function setImportDir($aDirs) {
$this->oLessCompiler->setImportDir($aDirs);
}

Expand All @@ -110,8 +102,7 @@ public function setImportDir($aDirs)
*
* @param $sDir
*/
public function addImportDir($sDir)
{
public function addImportDir($sDir) {
$this->oLessCompiler->addImportDir($sDir);
}

Expand All @@ -120,13 +111,11 @@ public function addImportDir($sDir)
*
* @return array
*/
public function allParsedFiles()
{
public function allParsedFiles() {
return $this->oLessCompiler->allParsedFiles();
}

public function setFormatter($sFormatter)
{
public function setFormatter($sFormatter) {
return $this->oLessCompiler->setFormatter($sFormatter);
}
}
Expand Down
Loading

0 comments on commit 49f0e59

Please sign in to comment.