コード例 #1
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      Connection $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(IsoCountryPeer::IC_UID, $pks, Criteria::IN);
         $objs = IsoCountryPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
コード例 #2
0
ファイル: usersAjax.php プロジェクト: ralpheav/processmaker
<?php

global $RBAC;
switch ($_POST['action']) {
    case 'countryList':
        require_once "classes/model/IsoCountry.php";
        $c = new Criteria();
        $c->add(IsoCountryPeer::IC_UID, null, Criteria::ISNOTNULL);
        $countries = IsoCountryPeer::doSelect($c);
        foreach ($countries as $rowid => $row) {
            $oData[] = array('IC_UID' => $row->getICUid(), 'IC_NAME' => $row->getICName());
        }
        print G::json_encode($oData);
        break;
    case 'stateList':
        require_once "classes/model/IsoSubdivision.php";
        $c = new Criteria();
        $country = $_POST['IC_UID'];
        $c->add(IsoSubdivisionPeer::IC_UID, $country, Criteria::EQUAL);
        $locations = IsoSubdivisionPeer::doSelect($c);
        $oData = array();
        foreach ($locations as $rowid => $row) {
            if ($row->getISUid() != '' && $row->getISName() != '') {
                $oData[] = array('IS_UID' => $row->getISUid(), 'IS_NAME' => $row->getISName());
            }
        }
        print G::json_encode($oData);
        break;
    case 'locationList':
        require_once "classes/model/IsoLocation.php";
        $c = new Criteria();
コード例 #3
0
ファイル: pakeGulliver.php プロジェクト: bqevin/processmaker
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
}