getPhraseId() public method

Get the phrase ID.
public getPhraseId ( ) : integer
return integer
Exemplo n.º 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;
 }
Exemplo n.º 2
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());
				}
			}
		}

		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
Exemplo n.º 3
0
            // UPLOAD_ERR_CANT_WRITE
            camp_html_display_error(getGS("There was a problem uploading the file."), null, true);
            break;
    }
} else {
    camp_html_display_error(getGS("The file exceeds the allowed max file size."), null, true);
}
$DebateAnswer = new DebateAnswer($f_fk_language_id, $f_debate_nr, $f_debateanswer_nr);
if (!$DebateAnswer->exists()) {
    camp_html_display_error(getGS("Debate Answer \$1 does not exist.", $f_debateanswer_nr), null, true);
    exit;
}
$description = new Translation(@$f_language_id);
$description->create($f_description);
$attributes = array();
$attributes['fk_description_id'] = $description->getPhraseId();
$attributes['fk_user_id'] = $g_user->getUserId();
if ($f_language_specific == "yes") {
    $attributes['fk_language_id'] = @$f_language_id;
}
if ($f_content_disposition == "attachment") {
    $attributes['content_disposition'] = "attachment";
}
if (!empty($_FILES['f_file'])) {
    $file = Attachment::OnFileUpload($_FILES['f_file'], $attributes);
} else {
    camp_html_goto_page(camp_html_article_url($articleObj, @$f_language_id, 'files/popup.php'));
}
// Check if image was added successfully
if (PEAR::isError($file)) {
    camp_html_add_msg($file->getMessage());
Exemplo n.º 4
0
 /**
  * A quick lookup to see if the current language was already translated
  * for this article type: used by delete and update in setName.
  * Returns 0 if no translation or the phrase_id if there is one.
  *
  * @param int p_languageId
  *
  * @return 0 or phrase_id
  **/
 public function translationExists($p_languageId)
 {
     if ($this->m_metadata->getPhraseId() != -1) {
         $translation = new Translation($p_languageId, $this->m_metadata->getPhraseId());
         if ($translation->exists()) {
             return $translation->getPhraseId();
         }
     }
     return 0;
 }
Exemplo n.º 5
0
require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleAttachment.php');
require_once($GLOBALS['g_campsiteDir'].'/classes/Translation.php');

if (!SecurityToken::isValid()) {
    camp_html_display_error(getGS('Invalid security token!'));
    exit;
}
$f_language_id = Input::Get('f_language_id', 'int', 0);
$f_language_selected = Input::Get('f_language_selected', 'int', 0);

foreach ($_POST['file'] as $id => $values) {
    $description = new Translation((int) $f_language_selected);
    $description->create($values['f_description']); //$values

    $updateArray = array();
    $updateArray['fk_description_id'] = $description->getPhraseId();
/*    if ($values['f_language_specific'] == "yes") {
        $updateArray['fk_language_id'] = $f_language_selected;
    }
*/
    if ($values['f_content_disposition'] == "attachment") {
        $updateArray['content_disposition'] = "attachment";
    }
    $fileObj = new Attachment((int) $id);
    $fileObj->update($updateArray);
}

camp_html_add_msg(getGS("Images updated."), "ok");
camp_html_goto_page("/$ADMIN/media-archive/index.php#files");
?>