setText() public method

Set the translation text.
public setText ( string $p_value ) : boolean
$p_value string
return boolean
Beispiel #1
0
 /**
  * Set the type name for the given language.  A new entry in
  * the database will be created if the language did not exist.
  *
  * @param int $p_languageId
  * @param string $p_value
  *
  * @return boolean
  */
 public function setName($p_languageId, $p_value)
 {
     global $g_ado_db;
     if (!is_numeric($p_languageId)) {
         return false;
     }
     // if the string is empty, nuke it
     if (!is_string($p_value) || $p_value == '') {
         if ($phrase_id = $this->translationExists($p_languageId)) {
             $trans = new Translation($p_languageId, $phrase_id);
             $trans->delete();
             $changed = true;
         } else {
             $changed = false;
         }
     } else {
         $description = new Translation($p_languageId, $this->getProperty('fk_phrase_id'));
         if ($description->exists()) {
             $changed = $description->setText($p_value);
         } else {
             $changed = $description->create($p_value);
             if ($changed && is_null($this->getProperty('fk_phrase_id'))) {
                 $this->setProperty('fk_phrase_id', $description->getPhraseId());
             }
         }
     }
     return $changed;
 }
Beispiel #2
0
 public static function addOrUpdateString($sStringKey, $sContent, $sLanguageId = null)
 {
     if ($sLanguageId === null) {
         $sLanguageId = Session::language();
     }
     $oString = TranslationQuery::create()->findPk(array($sLanguageId, $sStringKey));
     if (!$sContent) {
         if ($oString !== null) {
             $oString->delete();
         }
         return;
     }
     if ($oString === null) {
         $oString = new Translation();
         $oString->setLanguageId($sLanguageId);
         $oString->setStringKey($sStringKey);
     }
     $oString->setText($sContent);
     $oString->save();
 }
Beispiel #3
0
 /**
  * Enter description here...
  *
  * @param int $p_phraseId
  * @param int $p_languageId
  * @param string $p_text
  */
 public static function SetPhrase($p_languageId, $p_phraseId, $p_text)
 {
     if (!is_numeric($p_languageId) || !is_numeric($p_phraseId) || !is_string($p_text)) {
         return false;
     }
     $translation = new Translation($p_languageId, $p_phraseId);
     if ($translation->exists()) {
         return $translation->setText($p_text);
     } else {
         return $translation->create($p_text);
     }
 }
	/**
	 * Set the type name for the given language.  A new entry in
	 * the database will be created if the language did not exist.
	 *
	 * @param int $p_languageId
	 * @param string $p_value
	 *
	 * @return boolean
	 */
	public function setName($p_languageId, $p_value)
	{
		global $g_ado_db;
		if (!is_numeric($p_languageId)) {
			return false;
		}
		// if the string is empty, nuke it
		if (!is_string($p_value) || $p_value == '') {
			if ($phrase_id = $this->translationExists($p_languageId)) {
			    $trans = new Translation($p_languageId, $phrase_id);
			    $trans->delete();
				$changed = true;
			} else {
			    $changed = false;
			}
		} else {
			$description = new Translation($p_languageId, $this->getProperty('fk_phrase_id'));
			if ($description->exists()) {
                $changed = $description->setText($p_value);
			} else {
				$changed = $description->create($p_value);
				if ($changed && is_null($this->getProperty('fk_phrase_id'))) {
					$this->setProperty('fk_phrase_id', $description->getPhraseId());
				}
			}
		}

		if ($changed) {
			if (function_exists("camp_load_translation_strings")) {
			    camp_load_translation_strings("api");
			}
			$logtext = getGS('Field "$1" updated', $this->m_data['field_name']);
			Log::Message($logtext, null, 143);
		}

		return $changed;
	} // fn setName
 public function saveData($aStringData)
 {
     $this->validate($aStringData);
     if (!Flash::noErrors()) {
         throw new ValidationException();
     }
     $oConnection = Propel::getConnection();
     foreach (LanguageQuery::create()->orderById()->find() as $oLanguage) {
         $oUpdateCriteria = new Criteria();
         $oUpdateCriteria->add(TranslationPeer::LANGUAGE_ID, $oLanguage->getId());
         $oUpdateCriteria->add(TranslationPeer::STRING_KEY, $this->sStringId);
         if (isset($aStringData['text_' . $oLanguage->getId()])) {
             $sText = trim($aStringData['text_' . $oLanguage->getId()]);
             $oString = TranslationQuery::create()->findPk(array($oLanguage->getId(), $this->sStringId));
             if ($sText === '') {
                 if ($oString !== null) {
                     $oString->delete();
                 }
                 continue;
             }
             if ($oString === null) {
                 $oString = new Translation();
                 $oString->setLanguageId($oLanguage->getId());
                 $oString->setStringKey($aStringData['string_key']);
             } else {
                 if ($this->sStringId !== null && $this->sStringId !== $aStringData['string_key']) {
                     $oString->setStringKey($aStringData['string_key']);
                     BasePeer::doUpdate($oUpdateCriteria, $oString->buildCriteria(), $oConnection);
                 }
             }
             $oString->setText($sText);
             $oString->save();
         } else {
             $oString = TranslationQuery::create()->findPk(array($oLanguage->getId(), $this->sStringId));
             if ($oString === null) {
                 continue;
             }
             if ($this->sStringId !== null && $this->sStringId !== $aStringData['string_key']) {
                 $oString->setStringKey($aStringData['string_key']);
                 BasePeer::doUpdate($oUpdateCriteria, $oString->buildCriteria(), $oConnection);
             }
         }
     }
     // check sidebar reload criteria
     $sNameSpaceOld = TranslationPeer::getNameSpaceFromStringKey($this->sStringId);
     $sNameSpaceNew = TranslationPeer::getNameSpaceFromStringKey($aStringData['string_key']);
     // if both are the same the sidebar is not effected
     $bSidebarHasChanged = false;
     if ($sNameSpaceOld !== $sNameSpaceNew) {
         // if there was an old name space then we have to check whether it was the last string with this namespace
         if ($sNameSpaceOld !== null && !TranslationPeer::nameSpaceExists($sNameSpaceOld)) {
             $bSidebarHasChanged = true;
         }
         // if the new exits only once it has been created and the sidebar needs to be relaoded
         if ($sNameSpaceNew !== null && TranslationPeer::countNameSpaceByName($sNameSpaceNew) === 1) {
             $bSidebarHasChanged = true;
         }
     }
     $this->sStringId = $aStringData['string_key'];
     return array('id' => $this->sStringId, self::SIDEBAR_CHANGED => $bSidebarHasChanged);
 }