diff --git a/workflow/engine/classes/class.wsTools.php b/workflow/engine/classes/class.wsTools.php index 14d5d1c77..7177e8f67 100755 --- a/workflow/engine/classes/class.wsTools.php +++ b/workflow/engine/classes/class.wsTools.php @@ -292,15 +292,12 @@ class workspaceTools { */ public function upgradeContent($workSpace=SYS_SYS) { $this->initPropel(true); - require_once('classes/model/Language.php'); - G::LoadThirdParty('pear/json', 'class.json'); - $lang = array(); - foreach (System::listPoFiles() as $poFile) { - $poName = basename($poFile); - $names = explode(".", basename($poFile)); - $extension = array_pop($names); - $langid = array_pop($names); - $arrayLang[] = $langid; + require_once 'classes/model/Translation.php'; + $translation = new Translation(); + $information = $translation->getTranslationEnvironments(); + $arrayLang = array(); + foreach ($information as $key => $value) { + $arrayLang[] = trim($value['LOCALE']); } require_once('classes/model/Content.php'); $regenerateContent = new Content(); diff --git a/workflow/engine/classes/model/Content.php b/workflow/engine/classes/model/Content.php index 66d23234e..31e208f5b 100755 --- a/workflow/engine/classes/model/Content.php +++ b/workflow/engine/classes/model/Content.php @@ -290,13 +290,25 @@ class Content extends BaseContent { foreach ($langs as $key=>$value) { $this->langsAsoc[$value] = $value; } - + $this->langs = $langs; $this->rowsProcessed = 0; $this->rowsInserted = 0; $this->rowsUnchanged = 0; $this->rowsClustered = 0; - + + //Creating table CONTENT_BACKUP + $oConnection = Propel::getConnection('workflow'); + $oStatement = $oConnection->prepareStatement("CREATE TABLE IF NOT EXISTS `CONTENT_BACKUP` ( + `CON_CATEGORY` VARCHAR(30) default '' NOT NULL, + `CON_PARENT` VARCHAR(32) default '' NOT NULL, + `CON_ID` VARCHAR(100) default '' NOT NULL, + `CON_LANG` VARCHAR(10) default '' NOT NULL, + `CON_VALUE` MEDIUMTEXT NOT NULL, + CONSTRAINT CONTENT_BACKUP_PK PRIMARY KEY (CON_CATEGORY,CON_PARENT,CON_ID,CON_LANG) + )Engine=MyISAM DEFAULT CHARSET='utf8' COMMENT='Table for add content';"); + $oStatement->executeQuery(); + $con = Propel::getConnection('workflow'); $sql = " SELECT DISTINCT CON_LANG FROM CONTENT "; @@ -329,9 +341,10 @@ class Content extends BaseContent { $default = array(); $sw = array('CON_ID'=>'','CON_CATEGORY'=>'','CON_PARENT'=>''); 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; - } else { $this->rowsClustered++; if (count($langs) != count($list)) { @@ -363,6 +376,15 @@ class Content extends BaseContent { mysql_free_result($result); $total = $this->rowsProcessed + $this->rowsInserted; + $connection = Propel::getConnection('workflow'); + $statement = $connection->prepareStatement("INSERT INTO CONTENT + SELECT CON_CATEGORY, CON_PARENT, CON_ID , CON_LANG, CON_VALUE + FROM CONTENT_BACKUP"); + $statement->executeQuery(); + + $statement = $connection->prepareStatement("DROP TABLE CONTENT_BACKUP"); + $statement->executeQuery(); + if (!isset($_SERVER['SERVER_NAME'])) { CLI::logging("Rows Processed ---> $this->rowsProcessed ..... \n"); CLI::logging("Rows Clustered ---> $this->rowsClustered ..... \n"); @@ -390,20 +412,18 @@ class Content extends BaseContent { $default['CON_ID'], $value, $default['CON_VALUE'] - ); + ); } } } function fastInsertContent ($ConCategory, $ConParent, $ConId, $ConLang, $ConValue) { - $con = new Content ( ); - $con->setConCategory ( $ConCategory ); - $con->setConParent ( $ConParent ); - $con->setConId ( $ConId ); - $con->setConLang ( $ConLang ); - $con->setConValue ( $ConValue ); - $res = $con->save (); - return $res; + $ConValue = mysql_real_escape_string($ConValue); + $connection = Propel::getConnection('workflow'); + $statement = $connection->prepareStatement("INSERT INTO CONTENT_BACKUP ( + CON_CATEGORY, CON_PARENT, CON_ID , CON_LANG, CON_VALUE) + VALUES ('$ConCategory', '$ConParent', '$ConId', '$ConLang', '$ConValue');"); + $statement->executeQuery(); } function removeLanguageContent($lanId) { @@ -422,7 +442,7 @@ class Content extends BaseContent { $row = $result->getRow (); while ( is_array ( $row ) ) { - $content = ContentPeer::retrieveByPK( $row['CON_CATEGORY'], '', $row['CON_ID'], $lanId); + $content = ContentPeer::retrieveByPK( $row['CON_CATEGORY'], $row['CON_PARENT'], $row['CON_ID'], $lanId); if( $content !== null ) $content->delete(); diff --git a/workflow/engine/classes/model/Translation.php b/workflow/engine/classes/model/Translation.php index cc12d26fe..5a50c1b04 100755 --- a/workflow/engine/classes/model/Translation.php +++ b/workflow/engine/classes/model/Translation.php @@ -261,25 +261,33 @@ class Translation extends BaseTranslation { file_put_contents($filePath, serialize($environments)); } - function removeTranslationEnvironment($locale) - { - $filePath = $this->envFilePath; - if( strpos($locale, self::$localeSeparator) !== false ) { - list($LAN_ID, $IC_UID) = explode('-', strtoupper($locale)); - } else { - $LAN_ID = $locale; - $IC_UID = '__INTERNATIONAL__'; - } + function removeTranslationEnvironment($locale) + { + $filePath = $this->envFilePath; + if (strpos($locale, self::$localeSeparator) !== false) { + list($LAN_ID, $IC_UID) = explode('-', strtoupper($locale)); + } else { + $LAN_ID = $locale; + $IC_UID = '__INTERNATIONAL__'; + } - if( file_exists($filePath) ) { - $environments = unserialize(file_get_contents($filePath)); - if( ! isset($environments[$LAN_ID][$IC_UID]) ) - return NULL; - - unset($environments[$LAN_ID][$IC_UID]); - file_put_contents($filePath, serialize($environments)); + if (file_exists($filePath)) { + $environments = unserialize(file_get_contents($filePath)); + if (!isset($environments[$LAN_ID][$IC_UID])) { + return NULL; + } + + unset($environments[$LAN_ID][$IC_UID]); + file_put_contents($filePath, serialize($environments)); + + if (file_exists(PATH_CORE . "META-INF" . PATH_SEP . "translation.".$locale)) { + G::rm_dir(PATH_DATA . "META-INF" . PATH_SEP . "translation.".$locale); + } + if (file_exists(PATH_CORE . PATH_SEP . 'content' . PATH_SEP . 'translations' . PATH_SEP . 'processmaker' . $locale . '.po')) { + G::rm_dir(PATH_CORE . PATH_SEP . 'content' . PATH_SEP . 'translations' . PATH_SEP . 'processmaker' . $locale . '.po'); + } + } } - } function getTranslationEnvironments(){ $filePath = $this->envFilePath; diff --git a/workflow/engine/templates/setup/languages.js b/workflow/engine/templates/setup/languages.js index 5c4ad5012..eda4b2b3d 100755 --- a/workflow/engine/templates/setup/languages.js +++ b/workflow/engine/templates/setup/languages.js @@ -24,7 +24,7 @@ var removeOption; var installOption; var exportOption; - +Ext.Ajax.timeout = 300000; Ext.onReady(function(){ //Ext.state.Manager.setProvider(new Ext.state.CookieProvider());