Merge remote branch 'upstream/master' into BUG-6210

This commit is contained in:
Hector Cortez
2012-10-08 09:06:10 -04:00
4 changed files with 30 additions and 18 deletions

View File

@@ -95,15 +95,15 @@ function run_upgrade($command, $args)
if (defined('PATH_C')) { if (defined('PATH_C')) {
rm_dir(PATH_C, true); rm_dir(PATH_C, true);
} }
$workspaces = get_workspaces_from_args($args); $workspaces = get_workspaces_from_args($command);
$count = count($workspaces); $count = count($workspaces);
$first = true; $first = true;
$errors = false; $errors = false;
$buildCacheView = array_key_exists("buildACV", $command); $buildCacheView = array_key_exists("buildACV", $args);
foreach ($workspaces as $index => $workspace) { foreach ($workspaces as $index => $workspace) {
try { try {
CLI::logging("Upgrading workspaces ($index/$count): " . CLI::info($workspace->name) . "\n"); CLI::logging("Upgrading workspaces ($index/$count): " . CLI::info($workspace->name) . "\n");
$workspace->upgrade($first, $buildCacheView); $workspace->upgrade($first, $buildCacheView, $workspace->name);
$workspace->close(); $workspace->close();
$first = false; $first = false;
} catch (Exception $e) { } catch (Exception $e) {

View File

@@ -290,7 +290,7 @@ class workspaceTools {
* Upgrade this workspace Content. * Upgrade this workspace Content.
* *
*/ */
public function upgradeContent() { public function upgradeContent($workSpace=SYS_SYS) {
$this->initPropel(true); $this->initPropel(true);
require_once('classes/model/Language.php'); require_once('classes/model/Language.php');
G::LoadThirdParty('pear/json', 'class.json'); G::LoadThirdParty('pear/json', 'class.json');
@@ -304,7 +304,7 @@ class workspaceTools {
} }
require_once('classes/model/Content.php'); require_once('classes/model/Content.php');
$regenerateContent = new Content(); $regenerateContent = new Content();
$regenerateContent->regenerateContent($arrayLang); $regenerateContent->regenerateContent($arrayLang, $workSpace);
} }
/** /**

View File

@@ -276,7 +276,7 @@ class Content extends BaseContent {
* *
* @param array $langs * @param array $langs
*/ */
function regenerateContent($langs) function regenerateContent($langs, $workSpace=SYS_SYS)
{ {
//Search the language //Search the language
$key = array_search('en',$langs); $key = array_search('en',$langs);
@@ -312,18 +312,25 @@ class Content extends BaseContent {
$sql = " SELECT CON_ID, CON_CATEGORY, CON_LANG, CON_PARENT, CON_VALUE $sql = " SELECT CON_ID, CON_CATEGORY, CON_LANG, CON_PARENT, CON_VALUE
FROM CONTENT FROM CONTENT
ORDER BY CON_ID, CON_CATEGORY, CON_LANG, CON_PARENT "; ORDER BY CON_ID, CON_CATEGORY, CON_PARENT, CON_LANG";
G::LoadClass("wsTools");
$workSpace = new workspaceTools($workSpace);
$workSpace->getDBInfo();
$link = mysql_pconnect($workSpace->dbHost, $workSpace->dbUser, $workSpace->dbPass)
or die ("Could not connect");
mysql_select_db($workSpace->dbName, $link);
mysql_query('SET OPTION SQL_BIG_SELECTS=1'); mysql_query('SET OPTION SQL_BIG_SELECTS=1');
$result = mysql_unbuffered_query($sql); $result = mysql_unbuffered_query($sql, $link);
$list = array(); $list = array();
$default = array(); $default = array();
$sw = array('CON_ID'=>'','CON_CATEGORY'=>'','CON_PARENT'=>''); $sw = array('CON_ID'=>'','CON_CATEGORY'=>'','CON_PARENT'=>'');
while ($row = mysql_fetch_assoc($result)) { while ($row = mysql_fetch_assoc($result)) {
if ($sw['CON_ID'] == $row['CON_ID'] && $sw['CON_CATEGORY'] == $row['CON_CATEGORY'] && $sw['CON_PARENT'] == $row['CON_PARENT']) { if ($sw['CON_ID'] == $row['CON_ID'] && $sw['CON_CATEGORY'] == $row['CON_CATEGORY'] && $sw['CON_PARENT'] == $row['CON_PARENT']) {
$list[] = $row; $list[] = $row;
if ($sw['CON_LANG'] == $langs[$key]) {
$default = $row;
}
} else { } else {
$this->rowsClustered++; $this->rowsClustered++;
if (count($langs) != count($list)) { if (count($langs) != count($list)) {
@@ -342,6 +349,9 @@ class Content extends BaseContent {
$default = array(); $default = array();
$list[] = $row; $list[] = $row;
} }
if ($sw['CON_LANG'] == $langs[$key]) {
$default = $row;
}
$this->rowsProcessed++; $this->rowsProcessed++;
} }
if (count($langs) != count($list)) { if (count($langs) != count($list)) {
@@ -352,12 +362,14 @@ class Content extends BaseContent {
mysql_free_result($result); mysql_free_result($result);
$total = $this->rowsProcessed + $this->rowsInserted; $total = $this->rowsProcessed + $this->rowsInserted;
if (!isset($_SERVER['SERVER_NAME'])) {
CLI::logging("Rows Processed ---> $this->rowsProcessed ..... \n"); CLI::logging("Rows Processed ---> $this->rowsProcessed ..... \n");
CLI::logging("Rows Clustered ---> $this->rowsClustered ..... \n"); CLI::logging("Rows Clustered ---> $this->rowsClustered ..... \n");
CLI::logging("Rows Unchanged ---> $this->rowsUnchanged ..... \n"); CLI::logging("Rows Unchanged ---> $this->rowsUnchanged ..... \n");
CLI::logging("Rows Inserted ---> $this->rowsInserted ..... \n"); CLI::logging("Rows Inserted ---> $this->rowsInserted ..... \n");
CLI::logging("Rows Total ---> $total ..... \n"); CLI::logging("Rows Total ---> $total ..... \n");
} }
}
function checkLanguage($content, $default) function checkLanguage($content, $default)
{ {

View File

@@ -73,7 +73,7 @@ try {
G::LoadClass("wsTools"); G::LoadClass("wsTools");
$renegerateContent = new workspaceTools(SYS_SYS); $renegerateContent = new workspaceTools(SYS_SYS);
$renegerateContent->upgradeContent(); $messs = $renegerateContent->upgradeContent();
$result->msg = G::LoadTranslation('IMPORT_LANGUAGE_SUCCESS') . "\n"; $result->msg = G::LoadTranslation('IMPORT_LANGUAGE_SUCCESS') . "\n";
$result->msg .= "PO File num. records: " . $importResults->recordsCount . "\n"; $result->msg .= "PO File num. records: " . $importResults->recordsCount . "\n";