Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/utility/temp_handler.php
Show First 20 Lines • Show All 176 Lines • ▼ Show 20 Line(s) | |||||
if ($parent_prefix) { | if ($parent_prefix) { | ||||
$tables['ForeignKey'] = $this->Application->getUnitOption($prefix, 'ForeignKey'); | $tables['ForeignKey'] = $this->Application->getUnitOption($prefix, 'ForeignKey'); | ||||
$tables['ParentPrefix'] = $parent_prefix; | $tables['ParentPrefix'] = $parent_prefix; | ||||
$tables['ParentTableKey'] = $this->Application->getUnitOption($prefix, 'ParentTableKey'); | $tables['ParentTableKey'] = $this->Application->getUnitOption($prefix, 'ParentTableKey'); | ||||
}*/ | }*/ | ||||
$this->FinalRefs[ $tables['TableName'] ] = $tables['TableId']; // don't forget to add main table to FinalRefs too | $this->FinalRefs[ $tables['TableName'] ] = $tables['TableId']; // don't forget to add main table to FinalRefs too | ||||
/** @var Array $sub_items */ | |||||
$sub_items = $this->Application->getUnitOption($prefix, 'SubItems', Array ()); | $sub_items = $this->Application->getUnitOption($prefix, 'SubItems', Array ()); | ||||
/* @var $sub_items Array */ | |||||
if ( is_array($sub_items) ) { | if ( is_array($sub_items) ) { | ||||
foreach ($sub_items as $prefix) { | foreach ($sub_items as $prefix) { | ||||
$this->AddTables($prefix, $tables); | $this->AddTables($prefix, $tables); | ||||
} | } | ||||
} | } | ||||
$this->SetTables($tables); | $this->SetTables($tables); | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | |||||
$this->FinalRefs[ $tmp['TableName'] ] = $tmp['TableId']; | $this->FinalRefs[ $tmp['TableName'] ] = $tmp['TableId']; | ||||
$constrain = $this->Application->getUnitOption($prefix, 'Constrain'); | $constrain = $this->Application->getUnitOption($prefix, 'Constrain'); | ||||
if ( $constrain ) { | if ( $constrain ) { | ||||
$tmp['Constrain'] = $constrain; | $tmp['Constrain'] = $constrain; | ||||
$this->FinalRefs[ $tmp['TableName'] . $tmp['Constrain'] ] = $tmp['TableId']; | $this->FinalRefs[ $tmp['TableName'] . $tmp['Constrain'] ] = $tmp['TableId']; | ||||
} | } | ||||
/** @var Array $sub_items */ | |||||
$sub_items = $this->Application->getUnitOption($prefix, 'SubItems', Array ()); | $sub_items = $this->Application->getUnitOption($prefix, 'SubItems', Array ()); | ||||
/* @var $sub_items Array */ | |||||
if ( is_array($sub_items) ) { | if ( is_array($sub_items) ) { | ||||
foreach ($sub_items as $prefix) { | foreach ($sub_items as $prefix) { | ||||
$this->AddTables($prefix, $tmp); | $this->AddTables($prefix, $tmp); | ||||
} | } | ||||
} | } | ||||
if ( !is_array(getArrayValue($tables, 'SubTables')) ) { | if ( !is_array(getArrayValue($tables, 'SubTables')) ) { | ||||
$tables['SubTables'] = Array (); | $tables['SubTables'] = Array (); | ||||
} | } | ||||
$tables['SubTables'][] = $tmp; | $tables['SubTables'][] = $tmp; | ||||
} | } | ||||
function CloneItems($prefix, $special, $ids, $master = null, $foreign_key = null, $parent_prefix = null, $skip_filenames = false) | function CloneItems($prefix, $special, $ids, $master = null, $foreign_key = null, $parent_prefix = null, $skip_filenames = false) | ||||
{ | { | ||||
if (!isset($master)) $master = $this->Tables; | if (!isset($master)) $master = $this->Tables; | ||||
// recalling by different name, because we may get kDBList, if we recall just by prefix | // recalling by different name, because we may get kDBList, if we recall just by prefix | ||||
if (!preg_match('/(.*)-item$/', $special)) { | if (!preg_match('/(.*)-item$/', $special)) { | ||||
$special .= '-item'; | $special .= '-item'; | ||||
} | } | ||||
/** @var kCatDBItem $object */ | |||||
$object = $this->Application->recallObject($prefix.'.'.$special, $prefix, Array('skip_autoload' => true, 'parent_event' => $this->parentEvent)); | $object = $this->Application->recallObject($prefix.'.'.$special, $prefix, Array('skip_autoload' => true, 'parent_event' => $this->parentEvent)); | ||||
/* @var $object kCatDBItem */ | |||||
$object->PopulateMultiLangFields(); | $object->PopulateMultiLangFields(); | ||||
foreach ($ids as $id) { | foreach ($ids as $id) { | ||||
$mode = 'create'; | $mode = 'create'; | ||||
$cloned_ids = getArrayValue($this->AlreadyProcessed, $master['TableName']); | $cloned_ids = getArrayValue($this->AlreadyProcessed, $master['TableName']); | ||||
if ( $cloned_ids ) { | if ( $cloned_ids ) { | ||||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Line(s) | |||||
if ( strpos($prefix, '.') !== false ) { | if ( strpos($prefix, '.') !== false ) { | ||||
list($prefix, $special) = explode('.', $prefix, 2); | list($prefix, $special) = explode('.', $prefix, 2); | ||||
} | } | ||||
$prefix_special = rtrim($prefix . '.' . $special, '.'); | $prefix_special = rtrim($prefix . '.' . $special, '.'); | ||||
//recalling by different name, because we may get kDBList, if we recall just by prefix | //recalling by different name, because we may get kDBList, if we recall just by prefix | ||||
$recall_prefix = $prefix_special . ($special ? '' : '.') . '-item'; | $recall_prefix = $prefix_special . ($special ? '' : '.') . '-item'; | ||||
/** @var kDBItem $object */ | |||||
$object = $this->Application->recallObject($recall_prefix, $prefix, Array ('skip_autoload' => true, 'parent_event' => $this->parentEvent)); | $object = $this->Application->recallObject($recall_prefix, $prefix, Array ('skip_autoload' => true, 'parent_event' => $this->parentEvent)); | ||||
/* @var $object kDBItem */ | |||||
foreach ($ids as $id) { | foreach ($ids as $id) { | ||||
$object->Load($id); | $object->Load($id); | ||||
$original_values = $object->GetFieldValues(); | $original_values = $object->GetFieldValues(); | ||||
if ( !$object->Delete($id) ) { | if ( !$object->Delete($id) ) { | ||||
continue; | continue; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 341 Lines • ▼ Show 20 Line(s) | |||||
* | * | ||||
* @return kDBConnection | * @return kDBConnection | ||||
*/ | */ | ||||
function &_getSeparateConnection() | function &_getSeparateConnection() | ||||
{ | { | ||||
static $connection = null; | static $connection = null; | ||||
if (!isset($connection)) { | if (!isset($connection)) { | ||||
/** @var kDBConnection $connection */ | |||||
$connection = $this->Application->makeClass( 'kDBConnection', Array (SQL_TYPE, Array ($this->Application, 'handleSQLError')) ); | $connection = $this->Application->makeClass( 'kDBConnection', Array (SQL_TYPE, Array ($this->Application, 'handleSQLError')) ); | ||||
/* @var $connection kDBConnection */ | |||||
$connection->debugMode = $this->Application->isDebugMode(); | $connection->debugMode = $this->Application->isDebugMode(); | ||||
$connection->Connect(SQL_SERVER, SQL_USER, SQL_PASS, SQL_DB); | $connection->Connect(SQL_SERVER, SQL_USER, SQL_PASS, SQL_DB); | ||||
} | } | ||||
return $connection; | return $connection; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 327 Lines • Show Last 20 Lines |