/**
  * function addLabel
  * <pre>
  * Creates a new label in the Labels DB table.
  * </pre>
  * @param $key [STRING] name of the label key 
  * @param $text [STRING] name of the label text
  * @param $languageKey [STRING] the language KEY of the language the text is in
  * @return [void]
  */
 function addLabel($key, $text, $languageKey, $update = false)
 {
     // if we haven't loaded the language list then load it now.
     if (is_null($this->languageList)) {
         $this->languageList = new LanguageList();
     }
     // if a page context is properly set then
     if ($this->pageManager->isLoaded()) {
         // get the language ID from the given language Key
         $languageID = $this->languageList->getLanguageIDByKey($languageKey);
         $pageID = $this->pageManager->getID();
         // create the new label
         $label = new RowManager_MultilingualLabelManager();
         // if label is unique then
         if ($label->isUnique($pageID, $key, $languageID)) {
             $label->setPageID($pageID);
             $label->setKey($key);
             $label->setLabel($text);
             $label->setLanguageID($languageID);
             $label->createNewEntry();
         } else {
             // the label is not unique - an entry already exists in the DB
             // NEW CODE BY Russ Martin
             // TODO - Add code here to make the tools setup the final authority
             // echo 'The key ' . $key . ' is not unique <br/>';
             /*                
                            $label->setPageID( $pageID );
                            $label->setKey( $key );
                            $label->setLabel( $text );
                            $label->setLanguageID( $languageID );  
                            $label->updateDBTable();  // <-- primary code: used to update table if some aspect of data is not unique              
             */
         }
     } else {
         die('MultilingualManager::addLabel() : attempting to add label without a pageManager loaded!');
     }
 }
 /**
  * function updateDBTable
  * <pre>
  * Updates the DB table info.
  * </pre>
  * @return [void]
  */
 function updateDBTable()
 {
     // make sure label is translated into UnicodeEntities
     $data = $this->getLabel();
     $newData = Unicode_utf8ToUnicodeEntities($data);
     $this->setLabel($newData);
     parent::updateDBTable();
     // Go Through and remove any existing xlation requests for this
     // label entry.
     $currentPageID = $this->getPageID();
     $currentKey = $this->getKey();
     $currentLanguageID = $this->getLanguageID();
     $xlationManager = new RowManager_XLationManager();
     // for each label with matching PageID & Key
     $labelManager = new RowManager_MultilingualLabelManager();
     $labelManager->setPageID($currentPageID);
     $labelManager->setKey($currentKey);
     $labelList = $labelManager->getListIterator();
     $labelList->setFirst();
     while ($label = $labelList->getNext()) {
         // delete any xlation entry with current language_id &
         // matching label_id
         if ($xlationManager->loadByLabelAndLanguage($label->getID(), $currentLanguageID)) {
             $xlationManager->deleteEntry();
         }
     }
     // next label
 }