public function deleteRow($aRowData, $oCriteria)
 {
     $oLanguage = LanguagePeer::doSelectOne($oCriteria);
     if ($oLanguage->getIsDefault()) {
         throw new LocalizedException('wns.language.delete_default.denied');
     }
     if ($oLanguage->getIsDefaultEdit()) {
         throw new LocalizedException('wns.language.delete_default.denied');
     }
     if (LanguagePeer::doCount(new Criteria()) < 2) {
         throw new LocalizedException('wns.language.delete_last.denied');
     }
     $sLanguageId = $oLanguage->getId();
     foreach (LanguageObjectQuery::create()->filterByLanguageId($sLanguageId)->find() as $oLanguageObject) {
         $oHistory = $oLanguageObject->newHistory();
         $oHistory->save();
         $oLanguageObject->delete();
     }
     $iResult = $oLanguage->delete();
     $oReplacementLanguage = LanguageQuery::create()->findOne();
     if (AdminManager::getContentLanguage() === $sLanguageId) {
         AdminManager::setContentLanguage(Settings::getSetting("session_default", AdminManager::CONTENT_LANGUAGE_SESSION_KEY, $oReplacementLanguage->getId()));
     }
     if (Session::language() === $sLanguageId) {
         Session::getSession()->setLanguage(Settings::getSetting("session_default", Session::SESSION_LANGUAGE_KEY, $oReplacementLanguage->getId()));
     }
 }
Exemple #2
0
 /**
  * Implementation for 'GET' method for Rest API
  *
  * @param  mixed $lanId 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 get($lanId = null)
 {
     $result = array();
     try {
         $noArguments = true;
         $argumentList = func_get_args();
         foreach ($argumentList as $arg) {
             if (!is_null($arg)) {
                 $noArguments = false;
             }
         }
         if ($noArguments) {
             $criteria = new Criteria('workflow');
             $criteria->addSelectColumn(LanguagePeer::LAN_ID);
             $criteria->addSelectColumn(LanguagePeer::LAN_NAME);
             $criteria->addSelectColumn(LanguagePeer::LAN_NATIVE_NAME);
             $criteria->addSelectColumn(LanguagePeer::LAN_DIRECTION);
             $criteria->addSelectColumn(LanguagePeer::LAN_WEIGHT);
             $criteria->addSelectColumn(LanguagePeer::LAN_ENABLED);
             $criteria->addSelectColumn(LanguagePeer::LAN_CALENDAR);
             $dataset = AppEventPeer::doSelectRS($criteria);
             $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
             while ($dataset->next()) {
                 $result[] = $dataset->getRow();
             }
         } else {
             $record = LanguagePeer::retrieveByPK($lanId);
             if ($record) {
                 $result = $record->toArray(BasePeer::TYPE_FIELDNAME);
             } else {
                 $paramValues = "";
                 foreach ($argumentList as $arg) {
                     $paramValues .= strlen($paramValues) ? ', ' : '';
                     if (!is_null($arg)) {
                         $paramValues .= "{$arg}";
                     } else {
                         $paramValues .= "NULL";
                     }
                 }
                 throw new RestException(417, "table Language ({$paramValues})");
             }
         }
     } catch (RestException $e) {
         throw new RestException($e->getCode(), $e->getMessage());
     } catch (Exception $e) {
         throw new RestException(412, $e->getMessage());
     }
     return $result;
 }
Exemple #3
0
 /**
  * @param string $sLanguageId
  * use cases:
  * 1. at first users' creation
  * 2. fallback method, creates language if it does not exist, but not at first users' login time, i.e. when languages have been truncated
  * @return void
  */
 public static function createLanguageIfNoneExist($sLanguage, $oUser = null)
 {
     if (LanguageQuery::create()->count() > 0) {
         return;
     }
     $oLanguage = new Language();
     $oLanguage->setId($sLanguage);
     $oLanguage->setPathPrefix($sLanguage);
     $oLanguage->setIsActive(true);
     $oLanguage->setCreatedAt(date('c'));
     $oLanguage->setUpdatedAt(date('c'));
     if ($oUser) {
         $oLanguage->setCreatedBy($oUser->getId());
         $oLanguage->setUpdatedBy($oUser->getId());
     }
     LanguagePeer::ignoreRights(true);
     $oLanguage->save();
 }
 public function __construct($aRequestPath, Page $oJournalPage = null, $aJournalIds = null)
 {
     if ($aRequestPath === false) {
         $this->oJournalPage = $oJournalPage;
         $this->aJournalIds = $aJournalIds;
     } else {
         parent::__construct($aRequestPath);
         Manager::usePath();
         //the “journal” bit
         $this->oJournalPage = PagePeer::getRootPage()->getPageOfType('journal');
         $sLanguageId = Manager::usePath();
         if (LanguagePeer::languageIsActive($sLanguageId)) {
             Session::getSession()->setLanguage($sLanguageId);
         }
     }
     header("Content-Type: application/rss+xml;charset=" . Settings::getSetting('encoding', 'db', 'utf-8'));
     RichtextUtil::$USE_ABSOLUTE_LINKS = LinkUtil::isSSL();
 }
 public function executeHighlight()
 {
     $code = $this->code;
     $languages = LanguagePeer::doSelect(new Criteria());
     foreach ($languages as $language) {
         $arr = array();
         $exp = sprintf(Code::$REG_EXPRESSION, $language->getTag(), $language->getTag());
         preg_match_all($exp, $code, $arr, PREG_SET_ORDER);
         if (sizeof($arr) > 0) {
             for ($i = 0; $i < sizeof($arr); $i++) {
                 $code = str_replace($arr[$i][0], "<div>" . $arr[$i][1] . "</div>", $code);
             }
         }
     }
     $arr = array();
     $exp = sprintf(Code::$REG_EXPRESSION, 'other', 'other');
     preg_match_all($exp, $code, $arr, PREG_SET_ORDER);
     if (sizeof($arr) > 0) {
         for ($i = 0; $i < sizeof($arr); $i++) {
             $code = str_replace($arr[$i][0], "<div>" . $arr[$i][1] . "</div>", $code);
         }
     }
     $this->code = $code;
 }
 /**
  * Change current language
  *
  * @param sfWebRequest $request Web request object
  */
 public function executeSetLanguage($request)
 {
     $language = LanguagePeer::retrieveByCulture($request->getParameter('culture'));
     if ($language && $language->getIsActive()) {
         $this->getUser()->setCulture($language->getCulture());
     }
     if ($request->getReferer()) {
         $this->redirect($request->getReferer());
     } else {
         $this->redirect("@homepage");
     }
 }
Exemple #7
0
 function loadByCode($langId)
 {
     try {
         $oCriteria = new Criteria('workflow');
         $oCriteria->addSelectColumn(LanguagePeer::LAN_NAME);
         $oCriteria->add(LanguagePeer::LAN_ID, $langId);
         $oDataset = LanguagePeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         $aRow = $oDataset->getRow();
         $aRow['LANGUAGE_NAME'] = $aRow['LAN_NAME'];
         if (is_array($aRow)) {
             return $aRow;
         } else {
             throw new Exception("The language '{$langId}' doesn\\'t exist!");
         }
     } catch (exception $oError) {
         throw $oError;
     }
 }
Exemple #8
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
  * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = LanguagePeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setLanId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setLanName($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setLanNativeName($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setLanDirection($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setLanWeight($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setLanEnabled($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setLanCalendar($arr[$keys[6]]);
     }
 }
Exemple #9
0
    public function findLocationByLanId($languageId)
    {
        try {
            if (!isset(self::$arrayRecord[$languageId])) {
                $criteria = new Criteria("workflow");

                $criteria->addSelectColumn(LanguagePeer::LAN_LOCATION);
                $criteria->add(LanguagePeer::LAN_ID, $languageId, Criteria::LIKE);

                $rsCriteria = LanguagePeer::doSelectRS($criteria);
                $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);

                $rsCriteria->next();

                self::$arrayRecord[$languageId] = $rsCriteria->getRow();
            }

            $record = self::$arrayRecord[$languageId];

            //Return
            return $record;
        } catch (Exception $e) {
            throw $e;
        }
    }
Exemple #10
0
?>
</a></p>

            </div>
        </div>
        <div id="languages">
        <?php 
echo image_tag('jotag/' . $sf_user->getCulture() . '/footer-languages.jpg', array('alt' => __("languages")));
?>
          <form action="<?php 
echo url_for('@switch_language_form');
?>
" method="post">
            <select name='culture' onchange='this.form.submit()'>
              <?php 
foreach (LanguagePeer::retrieveActiveLanguages() as $language) {
    ?>
              	<option value="<?php 
    echo $language->getCulture();
    ?>
"<?php 
    if ($sf_user->getCulture() == $language->getCulture()) {
        ?>
 selected="selected"<?php 
    }
    ?>
><?php 
    echo $language->getName();
    ?>
</option>
              <?php 
 /**
  * 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(LanguagePeer::LAN_ID, $pks, Criteria::IN);
         $objs = LanguagePeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Exemple #12
0
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
}
 /**
  * Find object by primary key
  * Use instance pooling to avoid a database query if the object exists
  * <code>
  * $obj  = $c->findPk(12, $con);
  * </code>
  * @param     mixed $key Primary key to use for the query
  * @param     PropelPDO $con an optional connection object
  *
  * @return    Language|array|mixed the result, formatted by the current formatter
  */
 public function findPk($key, $con = null)
 {
     if (null !== ($obj = LanguagePeer::getInstanceFromPool((string) $key)) && $this->getFormatter()->isObjectFormatter()) {
         // the object is alredy in the instance pool
         return $obj;
     } else {
         // the object has not been requested yet, or the formatter is not an object formatter
         $criteria = $this->isKeepQuery() ? clone $this : $this;
         $stmt = $criteria->filterByPrimaryKey($key)->getSelectStatement($con);
         return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
     }
 }
Exemple #14
0
 public function mayOperate($sOperation, $oUser = false)
 {
     $oUser = LanguagePeer::getRightsUser($oUser);
     $bIsAllowed = false;
     if ($oUser && ($this->isNew() || $this->getCreatedBy() === $oUser->getId()) && LanguagePeer::mayOperateOnOwn($oUser, $this, $sOperation)) {
         $bIsAllowed = true;
     } else {
         if (LanguagePeer::mayOperateOn($oUser, $this, $sOperation)) {
             $bIsAllowed = true;
         }
     }
     FilterModule::getFilters()->handleLanguageOperationCheck($sOperation, $this, $oUser, array(&$bIsAllowed));
     return $bIsAllowed;
 }
Exemple #15
0
 /**
  * Find object by primary key using raw SQL to go fast.
  * Bypass doSelect() and the object formatter by using generated code.
  *
  * @param     mixed $key Primary key to use for the query
  * @param     PropelPDO $con A connection object
  *
  * @return                 Language A model object, or null if the key is not found
  * @throws PropelException
  */
 protected function findPkSimple($key, $con)
 {
     $sql = 'SELECT `id`, `path_prefix`, `is_active`, `sort`, `created_at`, `updated_at`, `created_by`, `updated_by` FROM `languages` WHERE `id` = :p0';
     try {
         $stmt = $con->prepare($sql);
         $stmt->bindValue(':p0', $key, PDO::PARAM_STR);
         $stmt->execute();
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
     }
     $obj = null;
     if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $obj = new Language();
         $obj->hydrate($row);
         LanguagePeer::addInstanceToPool($obj, (string) $key);
     }
     $stmt->closeCursor();
     return $obj;
 }
Exemple #16
0
 public function findByLanName($LAN_NAME)
 {
     $oCriteria = new Criteria('workflow');
     $oCriteria->addSelectColumn(LanguagePeer::LAN_ID);
     $oCriteria->addSelectColumn(LanguagePeer::LAN_NAME);
     $oCriteria->add(LanguagePeer::LAN_NAME, $LAN_NAME, Criteria::LIKE);
     $oDataset = LanguagePeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     return $oDataset->getRow();
 }
 /**
  * Selects a collection of Documentation objects pre-filled with all related objects except UserRelatedByUpdatedBy.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return array           Array of Documentation objects.
  * @throws PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptUserRelatedByUpdatedBy(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     // $criteria->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(DocumentationPeer::DATABASE_NAME);
     }
     DocumentationPeer::addSelectColumns($criteria);
     $startcol2 = DocumentationPeer::NUM_HYDRATE_COLUMNS;
     LanguagePeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + LanguagePeer::NUM_HYDRATE_COLUMNS;
     $criteria->addJoin(DocumentationPeer::LANGUAGE_ID, LanguagePeer::ID, $join_behavior);
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = DocumentationPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = DocumentationPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://www.propelorm.org/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = DocumentationPeer::getOMClass();
             $obj1 = new $cls();
             $obj1->hydrate($row);
             DocumentationPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined Language rows
         $key2 = LanguagePeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = LanguagePeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = LanguagePeer::getOMClass();
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 LanguagePeer::addInstanceToPool($obj2, $key2);
             }
             // if $obj2 already loaded
             // Add the $obj1 (Documentation) to the collection in $obj2 (Language)
             $obj2->addDocumentation($obj1);
         }
         // if joined row is not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
Exemple #18
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = LanguagePeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setOriginalName($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setEnglishName($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setIsocode($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setDokeosFolder($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setAvailable($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setParentId($arr[$keys[6]]);
     }
 }