public function delete() { $ids = explode(',', $_POST['IDS']); $category = 'LABEL'; try { foreach ($ids as $id) { $tr = TranslationPeer::retrieveByPK($category, $id, 'en'); if (is_object($tr) && get_class($tr) == 'Translation') { $tr->delete(); } } $result->success = true; $result->msg = 'Deleted Successfully!'; } catch (Exception $e) { $result->success = false; $result->msg = $e->getMessage(); } print G::json_encode($result); }
* ProcessMaker Open Source Edition * Copyright (C) 2004 - 2008 Colosa Inc.23 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. */ //to do: improve the way to pass two or more parameters in the paged-table ( link ) $aux = explode('|', $_GET['id']); $category = str_replace('"', '', $aux[0]); $id = str_replace('"', '', $aux[1]); require_once "classes/model/Translation.php"; //if exists the row in the database propel will update it, otherwise will insert. $tr = TranslationPeer::retrieveByPK($category, $id, 'en'); if (is_object($tr) && get_class($tr) == 'Translation') { $tr->delete(); } // else G::Header('location: translations');
/** * Implementation for 'DELETE' method for Rest API * * @param mixed $trnCategory, $trnId, $trnLang Primary key * * @return array $result Returns array within multiple records or a single record depending if * a single selection was requested passing id(s) as param */ protected function delete($trnCategory, $trnId, $trnLang) { $conn = Propel::getConnection(TranslationPeer::DATABASE_NAME); try { $conn->begin(); $obj = TranslationPeer::retrieveByPK($trnCategory, $trnId, $trnLang); if (!is_object($obj)) { throw new RestException(412, 'Record does not exist.'); } $obj->delete(); $conn->commit(); } catch (Exception $e) { $conn->rollback(); throw new RestException(412, $e->getMessage()); } }
function remove($sCategory, $sId, $sLang) { $oTranslation = TranslationPeer::retrieveByPK($sCategory, $sId, $sLang); if (is_object($oTranslation) && get_class($oTranslation) == 'Translation') { $oTranslation->delete(); } }
/** * Implementation for 'DELETE' method for Rest API * * @param mixed $trnCategory, $trnId, $trnLang Primary key * * @return array $result Returns array within multiple records or a single record depending if * a single selection was requested passing id(s) as param */ protected function delete($trnCategory, $trnId, $trnLang) { $conn = Propel::getConnection(TranslationPeer::DATABASE_NAME); try { $conn->begin(); $obj = TranslationPeer::retrieveByPK($trnCategory, $trnId, $trnLang); if (!is_object($obj)) { throw new RestException(412, G::LoadTranslation('ID_RECORD_DOES_NOT_EXIST')); } $obj->delete(); $conn->commit(); } catch (Exception $e) { $conn->rollback(); throw new RestException(412, $e->getMessage()); } }
function run_create_poedit_file($task, $args) { // the environment for poedit always is Development define('G_ENVIRONMENT', G_DEV_ENV); //the output language .po file $lgOutId = isset($args[0]) ? $args[0] : 'en'; $countryOutId = isset($args[1]) ? strtoupper($args[1]) : 'US'; $verboseFlag = isset($args[2]) ? $args[2] == true : false; require_once "propel/Propel.php"; require_once "classes/model/Translation.php"; require_once "classes/model/Language.php"; require_once "classes/model/IsoCountry.php"; Propel::init(PATH_CORE . "config/databases.php"); $configuration = Propel::getConfiguration(); $connectionDSN = $configuration['datasources']['propel']['connection']; printf("using DSN Connection %s \n", pakeColor::colorize($connectionDSN, 'INFO')); printf("checking Language table \n"); $c = new Criteria(); $c->add(LanguagePeer::LAN_ENABLED, "1"); $c->addor(LanguagePeer::LAN_ENABLED, "0"); $languages = LanguagePeer::doSelect($c); $langs = array(); $lgIndex = 0; $findLang = false; $langDir = 'english'; $langId = 'en'; foreach ($languages as $rowid => $row) { $lgIndex++; $langs[$row->getLanId()] = $row->getLanName(); if ($lgOutId != '' && $lgOutId == $row->getLanId()) { $findLang = true; $langDir = strtolower($row->getLanName()); $langId = $row->getLanId(); } } printf("read %s entries from language table\n", pakeColor::colorize($lgIndex, 'INFO')); printf("checking iso_country table \n"); $c = new Criteria(); $c->add(IsoCountryPeer::IC_UID, NULL, Criteria::ISNOTNULL); $countries = IsoCountryPeer::doSelect($c); $countryIndex = 0; $findCountry = false; $countryDir = 'UNITED STATES'; $countryId = 'US'; foreach ($countries as $rowid => $row) { $countryIndex++; if ($countryOutId != '' && $countryOutId == $row->getICUid()) { $findCountry = true; $countryDir = strtoupper($row->getICName()); $countryId = $row->getICUid(); } } printf("read %s entries from iso_country table\n", pakeColor::colorize($countryIndex, 'INFO')); if ($findLang == false && $lgOutId != '') { printf("%s \n", pakeColor::colorize("'{$lgOutId}' is not a valid language ", 'ERROR')); die; } else { printf("language: %s\n", pakeColor::colorize($langDir, 'INFO')); } if ($findCountry == false && $countryOutId != '') { printf("%s \n", pakeColor::colorize("'{$countryOutId}' is not a valid country ", 'ERROR')); die; } else { printf("country: [%s] %s\n", pakeColor::colorize($countryId, 'INFO'), pakeColor::colorize($countryDir, 'INFO')); } if ($findCountry && $countryId != '') { $poeditOutFile = PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . $langDir . PATH_SEP . MAIN_POFILE . '.' . $langId . '_' . $countryId . '.po'; } else { $poeditOutFile = PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . $langDir . PATH_SEP . MAIN_POFILE . '.' . $langId . '.po'; } printf("poedit file: %s\n", pakeColor::colorize($poeditOutFile, 'INFO')); $poeditOutPathInfo = pathinfo($poeditOutFile); G::verifyPath($poeditOutPathInfo['dirname'], true); $lf = "\n"; $fp = fopen($poeditOutFile, 'w'); fprintf($fp, "msgid \"\" \n"); fprintf($fp, "msgstr \"\" \n"); fprintf($fp, "\"Project-Id-Version: %s\\n\"\n", PO_SYSTEM_VERSION); fprintf($fp, "\"POT-Creation-Date: \\n\"\n"); fprintf($fp, "\"PO-Revision-Date: %s \\n\"\n", date('Y-m-d H:i+0100')); fprintf($fp, "\"Last-Translator: Fernando Ontiveros<*****@*****.**>\\n\"\n"); fprintf($fp, "\"Language-Team: Colosa Developers Team <*****@*****.**>\\n\"\n"); fprintf($fp, "\"MIME-Version: 1.0 \\n\"\n"); fprintf($fp, "\"Content-Type: text/plain; charset=utf-8 \\n\"\n"); fprintf($fp, "\"Content-Transfer_Encoding: 8bit\\n\"\n"); fprintf($fp, "\"X-Poedit-Language: %s\\n\"\n", ucwords($langDir)); fprintf($fp, "\"X-Poedit-Country: %s\\n\"\n", $countryDir); fprintf($fp, "\"X-Poedit-SourceCharset: utf-8\\n\"\n"); printf("checking translation table\n"); $c = new Criteria(); $c->add(TranslationPeer::TRN_LANG, "en"); $translation = TranslationPeer::doSelect($c); $trIndex = 0; $trError = 0; $langIdOut = $langId; //the output language, later we'll include the country too. $arrayLabels = array(); foreach ($translation as $rowid => $row) { $keyid = 'TRANSLATION/' . $row->getTrnCategory() . '/' . $row->getTrnId(); if (trim($row->getTrnValue()) == '') { printf("warning the key %s is empty.\n", pakeColor::colorize($keyid, 'ERROR')); $trError++; } else { $trans = TranslationPeer::retrieveByPK($row->getTrnCategory(), $row->getTrnId(), $langIdOut); if (is_null($trans)) { $msgStr = $row->getTrnValue(); } else { $msgStr = $trans->getTrnValue(); } $msgid = $row->getTrnValue(); if (in_array($msgid, $arrayLabels)) { $newMsgid = '[' . $row->getTrnCategory() . '/' . $row->getTrnId() . '] ' . $msgid; printf("duplicated key %s is renamed to %s.\n", pakeColor::colorize($msgid, 'ERROR'), pakeColor::colorize($newMsgid, 'INFO')); $trError++; $msgid = $newMsgid; } $arrayLabels[] = $msgid; sort($arrayLabels); $trIndex++; fprintf($fp, "\n"); fprintf($fp, "#: %s \n", $keyid); //fprintf ( $fp, "#, php-format \n" ); fprintf($fp, "# %s \n", strip_quotes($keyid)); fprintf($fp, "msgid \"%s\" \n", strip_quotes($msgid)); fprintf($fp, "msgstr \"%s\" \n", strip_quotes($msgStr)); } } printf("checking xmlform\n"); printf("using directory %s \n", pakeColor::colorize(PATH_XMLFORM, 'INFO')); G::LoadThirdParty('pear/json', 'class.json'); G::LoadThirdParty('smarty/libs', 'Smarty.class'); G::LoadSystem('xmlDocument'); G::LoadSystem('xmlform'); G::LoadSystem('xmlformExtension'); G::LoadSystem('form'); $langIdOut = $langId; //the output language, later we'll include the country too. $exceptionFields = array('javascript', 'hidden', 'phpvariable', 'private', 'toolbar', 'xmlmenu', 'toolbutton', 'cellmark', 'grid'); $xmlfiles = pakeFinder::type('file')->name('*.xml')->in(PATH_XMLFORM); $xmlIndex = 0; $xmlError = 0; $fieldsIndexTotal = 0; $exceptIndexTotal = 0; foreach ($xmlfiles as $xmlfileComplete) { $xmlIndex++; $xmlfile = str_replace(PATH_XMLFORM, '', $xmlfileComplete); //english version of dynaform $form = new Form($xmlfile, '', 'en'); $englishLabel = array(); foreach ($form->fields as $nodeName => $node) { if (trim($node->label) != '') { $englishLabel[$node->name] = $node->label; } } unset($form->fields); unset($form->tree); unset($form); //in this second pass, we are getting the target language labels $form = new Form($xmlfile, '', $langIdOut); $fieldsIndex = 0; $exceptIndex = 0; foreach ($form->fields as $nodeName => $node) { if (is_object($node) && isset($englishLabel[$node->name])) { $msgid = trim($englishLabel[$node->name]); $node->label = trim(str_replace(chr(10), '', $node->label)); } else { $msgid = ''; } if (trim($msgid) != '' && !in_array($node->type, $exceptionFields)) { //$msgid = $englishLabel [ $node->name ]; $keyid = $xmlfile . '?' . $node->name; if (in_array($msgid, $arrayLabels)) { $newMsgid = '[' . $keyid . '] ' . $msgid; if ($verboseFlag) { printf("duplicated key %s is renamed to %s.\n", pakeColor::colorize($msgid, 'ERROR'), pakeColor::colorize($newMsgid, 'INFO')); } $xmlError++; $msgid = $newMsgid; } $arrayLabels[] = $msgid; sort($arrayLabels); $comment1 = $xmlfile; $comment2 = $node->type . ' - ' . $node->name; fprintf($fp, "\n"); fprintf($fp, "#: %s \n", $keyid); // fprintf ( $fp, "#, php-format \n" ); fprintf($fp, "# %s \n", strip_quotes($comment1)); fprintf($fp, "# %s \n", strip_quotes($comment2)); fprintf($fp, "msgid \"%s\" \n", strip_quotes($msgid)); fprintf($fp, "msgstr \"%s\" \n", strip_quotes($node->label)); //fprintf ( $fp, "msgstr \"%s\" \n", strip_quotes( utf8_encode( trim($node->label) ) )); $fieldsIndex++; $fieldsIndexTotal++; } else { if (is_object($node) && !in_array($node->type, $exceptionFields)) { if (isset($node->value) && strpos($node->value, 'G::LoadTranslation') !== false) { $exceptIndex++; //print ($node->value); } else { printf("Error: xmlform %s has no english definition for %s [%s]\n", pakeColor::colorize($xmlfile, 'ERROR'), pakeColor::colorize($node->name, 'INFO'), pakeColor::colorize($node->type, 'INFO')); $xmlError++; } } else { $exceptIndex++; if ($verboseFlag) { printf("%s %s in %s\n", $node->type, pakeColor::colorize($node->name, 'INFO'), pakeColor::colorize($xmlfile, 'INFO')); } } } } unset($form->fields); unset($form->tree); unset($form); printf("xmlform: %s has %s fields and %s exceptions \n", pakeColor::colorize($xmlfile, 'INFO'), pakeColor::colorize($fieldsIndex, 'INFO'), pakeColor::colorize($exceptIndex, 'INFO')); $exceptIndexTotal += $exceptIndex; } fclose($fp); printf("added %s entries from translation table\n", pakeColor::colorize($trIndex, 'INFO')); printf("added %s entries from %s xmlforms \n", pakeColor::colorize($fieldsIndexTotal, 'INFO'), pakeColor::colorize($xmlIndex, 'INFO')); if ($trError > 0) { printf("there are %s errors in tranlation table\n", pakeColor::colorize($trError, 'ERROR')); } if ($xmlError > 0) { printf("there are %s errors and %s exceptions in xmlforms\n", pakeColor::colorize($xmlError, 'ERROR'), pakeColor::colorize($exceptIndexTotal, 'ERROR')); } exit(0); //to do: leer los html templates }