Index: trunk/core/kernel/db/db_tag_processor.php
===================================================================
diff -u -r5081 -r5096
--- trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 5081)
+++ trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 5096)
@@ -1488,7 +1488,7 @@
$force_module = strtolower($force_module);
}
- $module_folder = trim( $this->Conn->GetOne('SELECT Path FROM '.TABLE_PREFIX.'Modules WHERE LOWER(Name) = '.$this->Conn->qstr($force_module) ), '/');
+ $module_folder = trim( $this->Application->findModule('Name', $force_module, 'Path'), '/');
}
else {
$module_folder = $this->Application->getUnitOption($this->Prefix, 'ModuleFolder');
Index: trunk/core/units/categories/categories_config.php
===================================================================
diff -u -r5081 -r5096
--- trunk/core/units/categories/categories_config.php (.../categories_config.php) (revision 5081)
+++ trunk/core/units/categories/categories_config.php (.../categories_config.php) (revision 5096)
@@ -49,6 +49,8 @@
'category_list' => Array('prefixes' => Array('c_List'), 'format' => "!la_title_Categories! (#c_recordcount#)"),
'catalog' => Array('prefixes' => Array('c_List'), 'format' => "!la_title_Categories! (#c_recordcount#)"),
+
+ 'categories_edit' => Array('prefixes' => Array('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_General!"),
'category_items'=> Array('prefixes' => Array('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_Items!"),
Index: trunk/kernel/units/categories/categories_config.php
===================================================================
diff -u -r5081 -r5096
--- trunk/kernel/units/categories/categories_config.php (.../categories_config.php) (revision 5081)
+++ trunk/kernel/units/categories/categories_config.php (.../categories_config.php) (revision 5096)
@@ -49,6 +49,8 @@
'category_list' => Array('prefixes' => Array('c_List'), 'format' => "!la_title_Categories! (#c_recordcount#)"),
'catalog' => Array('prefixes' => Array('c_List'), 'format' => "!la_title_Categories! (#c_recordcount#)"),
+
+ 'categories_edit' => Array('prefixes' => Array('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_General!"),
'category_items'=> Array('prefixes' => Array('c'), 'format' => "#c_status# '#c_titlefield#' - !la_title_Items!"),
Index: trunk/kernel/units/general/helpers/multilanguage.php
===================================================================
diff -u -r4358 -r5096
--- trunk/kernel/units/general/helpers/multilanguage.php (.../multilanguage.php) (revision 4358)
+++ trunk/kernel/units/general/helpers/multilanguage.php (.../multilanguage.php) (revision 5096)
@@ -179,8 +179,19 @@
*/
function generateAlterSQL($field_mask, $start_index, $create_count)
{
- $i_count = $start_index + $create_count;
+ static $single_lang = null;
+ if (!isset($single_lang)) {
+ // if single language mode, then create indexes only on primary columns
+ $table_name = $this->Application->getUnitOption('lang', 'TableName');
+ $sql = 'SELECT COUNT(*)
+ FROM '.$table_name.'
+ WHERE Enabled = 1';
+ // if language count = 0, then assume it's multi language mode
+ $single_lang = $this->Conn->GetOne($sql) == 1;
+ }
+
$ret = ' ';
+ $i_count = $start_index + $create_count;
while ($start_index < $i_count) {
list($prev_field,$type) = explode(' ', sprintf($field_mask, $start_index - 1) );
if (substr($prev_field, 0, 3) == 'l0_') {
@@ -198,8 +209,12 @@
$field_expression = sprintf($field_mask, $start_index);
$ret .= 'ADD COLUMN '.$field_expression.' AFTER `'.$prev_field.'`, ';
- list($field_name, $field_params) = explode(' ', $field_expression, 2);
- $ret .= 'ADD INDEX (`'.$field_name.'` (5) ), ';
+ if ($start_index == $this->Application->GetDefaultLanguageId() || !$single_lang) {
+ // create index for primary language column + for all others (if multiple languages installed)
+ list($field_name, $field_params) = explode(' ', $field_expression, 2);
+ $ret .= 'ADD INDEX (`'.$field_name.'` (5) ), ';
+ }
+
$start_index++;
}
return preg_replace('/, $/',';',$ret);
Index: trunk/core/units/general/helpers/multilanguage.php
===================================================================
diff -u -r4358 -r5096
--- trunk/core/units/general/helpers/multilanguage.php (.../multilanguage.php) (revision 4358)
+++ trunk/core/units/general/helpers/multilanguage.php (.../multilanguage.php) (revision 5096)
@@ -179,8 +179,19 @@
*/
function generateAlterSQL($field_mask, $start_index, $create_count)
{
- $i_count = $start_index + $create_count;
+ static $single_lang = null;
+ if (!isset($single_lang)) {
+ // if single language mode, then create indexes only on primary columns
+ $table_name = $this->Application->getUnitOption('lang', 'TableName');
+ $sql = 'SELECT COUNT(*)
+ FROM '.$table_name.'
+ WHERE Enabled = 1';
+ // if language count = 0, then assume it's multi language mode
+ $single_lang = $this->Conn->GetOne($sql) == 1;
+ }
+
$ret = ' ';
+ $i_count = $start_index + $create_count;
while ($start_index < $i_count) {
list($prev_field,$type) = explode(' ', sprintf($field_mask, $start_index - 1) );
if (substr($prev_field, 0, 3) == 'l0_') {
@@ -198,8 +209,12 @@
$field_expression = sprintf($field_mask, $start_index);
$ret .= 'ADD COLUMN '.$field_expression.' AFTER `'.$prev_field.'`, ';
- list($field_name, $field_params) = explode(' ', $field_expression, 2);
- $ret .= 'ADD INDEX (`'.$field_name.'` (5) ), ';
+ if ($start_index == $this->Application->GetDefaultLanguageId() || !$single_lang) {
+ // create index for primary language column + for all others (if multiple languages installed)
+ list($field_name, $field_params) = explode(' ', $field_expression, 2);
+ $ret .= 'ADD INDEX (`'.$field_name.'` (5) ), ';
+ }
+
$start_index++;
}
return preg_replace('/, $/',';',$ret);
Index: trunk/core/kernel/db/db_connection.php
===================================================================
diff -u -r4840 -r5096
--- trunk/core/kernel/db/db_connection.php (.../db_connection.php) (revision 4840)
+++ trunk/core/kernel/db/db_connection.php (.../db_connection.php) (revision 5096)
@@ -13,20 +13,23 @@
* @access private
*/
var $dbType = 'mysql';
+
/**
* Created connection handle
*
* @var resource
* @access private
*/
var $connectionID = null;
+
/**
* Handle of currenty processed recordset
*
* @var resource
* @access private
*/
var $queryID = null;
+
/**
* DB type specific function mappings
*
@@ -50,6 +53,7 @@
* @access private
*/
var $errorCode = 0;
+
/**
* Error message
*
@@ -65,7 +69,7 @@
*
* @var bool
*/
- var $debugMode=false;
+ var $debugMode = false;
/**
* Last query to database
@@ -85,13 +89,11 @@
function kDBConnection($dbType, $errorHandler = '')
{
$this->dbType = $dbType;
- $this->initMetaFunctions();
- if(!$errorHandler)
- {
- $this->errorHandler = Array(&$this,'handleError');
+// $this->initMetaFunctions();
+ if (!$errorHandler) {
+ $this->errorHandler = Array(&$this, 'handleError');
}
- else
- {
+ else {
$this->errorHandler=$errorHandler;
}
}
@@ -103,10 +105,10 @@
* @param string $msg
* @access public
*/
- function setError($code,$msg)
+ function setError($code, $msg)
{
- $this->errorCode=$code;
- $this->errorMessage=$msg;
+ $this->errorCode = $code;
+ $this->errorMessage = $msg;
}
/**
@@ -130,7 +132,7 @@
function initMetaFunctions()
{
$ret = Array();
- switch($this->dbType)
+ switch ($this->dbType)
{
case 'mysql':
$ret = Array(); // only define functions, that name differs from "dbType_"
@@ -152,15 +154,11 @@
*/
function getMetaFunction($name)
{
- if( !isset($this->metaFunctions[$name]) )
- {
- if(function_exists($this->dbType.'_'.$name)) return $this->dbType.'_'.$name;
- }
- else
- {
- return $this->dbType.$name;
- }
- return false;
+ /*if (!isset($this->metaFunctions[$name])) {
+ $this->metaFunctions[$name] = $name;
+ }*/
+
+ return $this->dbType.'_'.$name;
}
@@ -175,22 +173,21 @@
* @param string $db
* @access public
*/
- function Connect($host,$user,$pass,$db,$force_new=false)
+ function Connect($host, $user, $pass, $db, $force_new = false)
{
$func = $this->getMetaFunction('connect');
- $this->connectionID = $func($host,$user,$pass,$force_new) or die('Can\'t connect to db');
- if($this->connectionID)
- {
+ $this->connectionID = $func($host, $user, $pass, $force_new) or die('Can\'t connect to db');
+ if ($this->connectionID) {
$this->setDB($db);
$this->showError();
}
}
- function ReConnect($host,$user,$pass,$db)
+ function ReConnect($host, $user, $pass, $db)
{
$func = $this->getMetaFunction('close');
$func($this->connectionID);
- $this->Connect($host,$user,$pass,$db);
+ $this->Connect($host, $user, $pass, $db);
}
/**
@@ -199,26 +196,22 @@
*
* @access private
*/
- function showError($sql='')
+ function showError($sql = '')
{
- $this->setError(0,''); // reset error
- if($this->connectionID)
- {
+ $this->setError(0, ''); // reset error
+ if ($this->connectionID) {
$func = $this->getMetaFunction('errno'); $this->errorCode = $func($this->connectionID);
- if($this->hasError())
- {
+ if ($this->hasError()) {
$func = $this->getMetaFunction('error'); $this->errorMessage = $func($this->connectionID);
- if(is_array($this->errorHandler))
- {
+ if (is_array($this->errorHandler)) {
$func = $this->errorHandler[1];
- $ret = $this->errorHandler[0]->$func($this->errorCode,$this->errorMessage,$sql);
+ $ret = $this->errorHandler[0]->$func($this->errorCode, $this->errorMessage, $sql);
}
- else
- {
+ else {
$func = $this->errorHandler;
$ret = $func($this->errorCode,$this->errorMessage,$sql);
}
- if(!$ret) exit;
+ if (!$ret) exit;
}
}
}
@@ -232,7 +225,7 @@
* @return bool
* @access private
*/
- function handleError($code,$msg,$sql)
+ function handleError($code, $msg, $sql)
{
echo 'Processing SQL: '.$sql.'
';
echo 'Error ('.$code.'): '.$msg.'
';
@@ -249,7 +242,7 @@
*/
function setDB($new_name)
{
- if(!$this->connectionID) return false;
+ if (!$this->connectionID) return false;
$func = $this->getMetaFunction('select_db');
return $func($new_name);
}
@@ -305,22 +298,18 @@
function GetCol($sql, $key_field = null)
{
$rows = $this->Query($sql);
- if(!$rows) return $rows;
+ if (!$rows) return $rows;
$i = 0; $row_count = count($rows);
$ret = Array();
- if(isset($key_field))
- {
- while ($i < $row_count)
- {
+ if (isset($key_field)) {
+ while ($i < $row_count) {
$ret[$rows[$i][$key_field]] = array_shift($rows[$i]);
$i++;
}
}
- else
- {
- while ($i < $row_count)
- {
+ else {
+ while ($i < $row_count) {
$ret[] = array_shift($rows[$i]);
$i++;
}
@@ -339,27 +328,22 @@
* @param string $key_field
* @return Array
*/
- function Query($sql,$key_field = null)
+ function Query($sql, $key_field = null)
{
$this->lastQuery = $sql;
- if($this->debugMode) return $this->debugQuery($sql,$key_field);
+ if ($this->debugMode) return $this->debugQuery($sql,$key_field);
$query_func = $this->getMetaFunction('query');
$this->queryID = $query_func($sql,$this->connectionID);
- if( is_resource($this->queryID) )
- {
+ if (is_resource($this->queryID)) {
$ret = Array();
$fetch_func = $this->getMetaFunction('fetch_assoc');
- if( isset($key_field) )
- {
- while( ($row = $fetch_func($this->queryID)) )
- {
+ if (isset($key_field)) {
+ while (($row = $fetch_func($this->queryID))) {
$ret[$row[$key_field]] = $row;
}
}
- else
- {
- while( ($row = $fetch_func($this->queryID)) )
- {
+ else {
+ while (($row = $fetch_func($this->queryID))) {
$ret[] = $row;
}
}
@@ -373,7 +357,7 @@
function ChangeQuery($sql)
{
$this->Query($sql);
- return $this->errorCode==0 ? true : false;
+ return $this->errorCode == 0 ? true : false;
}
function debugQuery($sql, $key_field = null)
@@ -382,10 +366,9 @@
$query_func = $this->getMetaFunction('query');
// set 1st checkpoint: begin
- $isSkipTable=true;
- $profileSQLs=defined('DBG_SQL_PROFILE') && DBG_SQL_PROFILE;
- if($profileSQLs)
- {
+ $isSkipTable = true;
+ $profileSQLs = defined('DBG_SQL_PROFILE') && DBG_SQL_PROFILE;
+ if ($profileSQLs) {
$isSkipTable = isSkipTable($sql);
if (!$isSkipTable) {
$queryID = $debugger->generateID();