Esempio n. 1
0
 public function saveData($aTagData)
 {
     $aTagData['name'] = StringUtil::normalize($aTagData['name']);
     if ($this->iTagId === null) {
         $oTag = new Tag();
     } else {
         $oTag = TagQuery::create()->findPk($this->iTagId);
     }
     $this->validate($aTagData);
     if (!Flash::noErrors()) {
         throw new ValidationException();
     }
     $sStringName = "tag.{$aTagData['name']}";
     if ($oTag->getName() !== $aTagData['name']) {
         //Rename Strings for the tag
         $sOldStringName = "tag.{$oTag->getName()}";
         foreach (TranslationQuery::create()->filterByStringKey($sOldStringName)->find() as $oString) {
             $sLanguageId = $oString->getLanguageId();
             //You can’t technically rename strings because string_key is the PKEY so we delete it and re-generate
             $oString->delete();
             $oString = new Translation();
             $oString->setStringKey($sStringName);
             $oString->setLanguageId($sLanguageId);
             $oString->save();
         }
         $oTag->setName($aTagData['name']);
     }
     foreach ($aTagData['edited_languages'] as $iIndex => $sLanguageId) {
         TranslationPeer::addOrUpdateString($sStringName, $aTagData['text'][$iIndex], $sLanguageId);
     }
     $oTag->save();
 }
 public function onNavigationItemChildrenRequested($oNavigationItem)
 {
     if (!($oNavigationItem instanceof PageNavigationItem && $oNavigationItem->getIdentifier() === 'photos')) {
         return;
     }
     $aDocumentCategories = DocumentCategoryQuery::create()->filterByDocumentKind('image')->find();
     foreach ($aDocumentCategories as $oDocumentCategory) {
         $oNavItem = new VirtualNavigationItem(get_class(), StringUtil::normalize($oDocumentCategory->getName()), $oDocumentCategory->getName(), null, $oDocumentCategory->getId());
         $oNavigationItem->addChild($oNavItem);
     }
 }
 private static function init()
 {
     if (self::$SYNONYMS === null) {
         self::$SYNONYMS = array();
         self::$ROOT_WORDS = array();
         $sSynonyms = Settings::getInstance('synonyms')->getSettingsArray();
         foreach ($sSynonyms as $sLanguageId => $aSynonymList) {
             self::$SYNONYMS[$sLanguageId] = array();
             self::$ROOT_WORDS[$sLanguageId] = array();
             foreach ($aSynonymList as $sRootWord => $aSynonyms) {
                 $sRootWord = StringUtil::normalize($sRootWord);
                 foreach ($aSynonyms as $iKey => $sSynonym) {
                     self::$SYNONYMS[$sLanguageId][StringUtil::normalize($sSynonym)] = $sRootWord;
                 }
                 self::$ROOT_WORDS[$sLanguageId][$sRootWord] = true;
             }
         }
     }
 }
Esempio n. 4
0
 public static function newTagInstance($sTagName, $sModelName, $iTaggedItemId)
 {
     $sTagName = StringUtil::normalize($sTagName);
     $oTag = TagPeer::retrieveByName($sTagName);
     if ($oTag === null) {
         $oTag = new Tag();
         $oTag->setName($sTagName);
         $oTag->save();
     }
     $oTagInstance = self::retrieveByPK($oTag->getId(), $iTaggedItemId, $sModelName);
     if ($oTagInstance !== null) {
         throw new Exception("Instance of this tag does already exist");
     }
     $oTagInstance = new TagInstance();
     $oTagInstance->setTag($oTag);
     $oTagInstance->setModelName($sModelName);
     $oTagInstance->setTaggedItemId($iTaggedItemId);
     $oTagInstance->save();
     return $oTagInstance;
 }
Esempio n. 5
0
 /**
  * Add a tag to the Page given by the id
  */
 public static function addTagTo($sPageId, $mTag)
 {
     if ($mTag instanceof TagInstance) {
         $mTag = $mTag->getTag();
     }
     if ($mTag instanceof Tag) {
         $mTag = $mTag->getName();
     }
     $sTagName = StringUtil::normalize($mTag);
     $oTag = TagQuery::create()->findOneByName($sTagName);
     if ($oTag === null) {
         $oTag = new Tag();
         $oTag->setName($sTagName);
         $oTag->save();
     }
     $oTagInstance = TagInstanceQuery::create()->findPk(array($oTag->getId(), $sPageId, "Page"));
     if ($oTagInstance !== null) {
         return $oTagInstance;
     }
     $oTagInstance = new TagInstance();
     $oTagInstance->setTag($oTag);
     $oTagInstance->setModelName("Page");
     $oTagInstance->setTaggedItemId($sPageId);
     $oTagInstance->save();
     return $oTagInstance;
 }
 public function normalize($oTemplateIdentifier, &$iFlags)
 {
     $iFlags |= Template::NO_HTML_ESCAPE;
     return StringUtil::normalize($oTemplateIdentifier->getValue());
 }
Esempio n. 7
0
 public function setName($sNewName)
 {
     $sNewName = StringUtil::normalize($sNewName);
     parent::setName($sNewName);
 }
 private static function normalize($sFilePath)
 {
     return StringUtil::normalize($sFilePath, '_');
 }
Esempio n. 9
0
 public static function retrieveByName($sTagName)
 {
     $oCriteria = new Criteria(self::DATABASE_NAME);
     $oCriteria->add(self::NAME, StringUtil::normalize($sTagName));
     return self::doSelectOne($oCriteria);
 }