/** * function createNewEntry * <pre> * Creates a new row entry in the DB table for this object to manage. It * also updates the Xlation tabel to mark the new entry as needing * translation. * </pre> * @param $doAllowPrimaryKeyUpdate [BOOL] allow insertion of primary key * @param $shouldIgnoreXlation [BOOL] allow insertion of primary key * value if present. * @return [void] */ function createNewEntry($doAllowPrimaryKeyUpdate = false, $shouldIgnoreXlation = false) { // make sure label is translated into UnicodeEntities $data = $this->getLabel(); $newData = Unicode_utf8ToUnicodeEntities($data); $this->setLabel($newData); parent::createNewEntry($doAllowPrimaryKeyUpdate); if (!$shouldIgnoreXlation) { $currentPageID = $this->getPageID(); $currentKey = $this->getKey(); $currentLanguageID = $this->getLanguageID(); $xlationManager = new RowManager_XLationManager(); // If there are no other pageID + labelKey entries like this one // then we need to add xlation entries for all other languages. $condition = 'page_id=' . $currentPageID; if ($this->isUniqueFieldValue($currentKey, 'label_key', $condition)) { $xlationManager->setLabelID($this->getID()); // for each other language in site $languageManager = new RowManager_LanguageManager(); $languageList = $languageManager->getListIterator(); $languageList->setFirst(); while ($language = $languageList->getNext()) { $newLanguageID = $language->getID(); if ($newLanguageID != $currentLanguageID) { // Add Xlation Entry $xlationManager->setLanguageID($newLanguageID); $xlationManager->createNewEntry(); } } // next language } else { // Since there are other label id's, then look to see // if the current entry can substitute for an xlation request // 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 } // end if isUnique } // end if !shouldIgnoreXlation }