ArticleTypeField::setName PHP Method

setName() public method

Set the type name for the given language. A new entry in the database will be created if the language did not exist.
public setName ( integer $p_languageId, string $p_value ) : boolean
$p_languageId integer
$p_value string
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;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Set the type name for the given language. A new entry in
  * the database will be created if the language does 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) || $p_languageId == 0) {
         return false;
     }
     $changed = $this->m_metadata->setName($p_languageId, $p_value);
     return $changed;
 }
All Usage Examples Of ArticleTypeField::setName