public function postDown($manager)
 {
     require __DIR__ . '/../../base/lib/inc.php';
     foreach (DocumentationPartQuery::create()->find() as $oDocumentationPart) {
         $aKey = explode('.', $oDocumentationPart->getKey());
         array_unshift($aKey, $oDocumentationPart->getDocumentation()->getKey());
         $oDocumentationPart->setKey(implode('.', $aKey));
         $oDocumentationPart->save();
     }
 }
 public function listDocumentationParts($aData)
 {
     // how to display internal and external documentation(s parts)
     $oDocumentationPartQuery = DocumentationPartQuery::create()->active();
     if ($aData['documentation'] !== null) {
         $oDocumentationPartQuery->filterByDocumentationId($aData['documentation']);
     }
     if ($aData['display_mode'] == 'most_recent_teaser') {
         return $oDocumentationPartQuery->orderByUpdatedAt()->limit(1)->find()->toKeyValue('Id', 'Name');
     }
     if (strpos($aData['display_mode'], 'list') !== false) {
         return $oDocumentationPartQuery->orderByDocumentationId()->orderBySort()->select(array('Id', 'Name'))->find()->toKeyValue('Id', 'Name');
     }
     return null;
 }
 public function saveData($aDocumentationPartData)
 {
     if ($this->iDocumentationPartId === null) {
         $oDocumentationPart = new DocumentationPart();
     } else {
         $oDocumentationPart = DocumentationPartQuery::create()->findPk($this->iDocumentationPartId);
     }
     $this->validate($aDocumentationPartData);
     $oDocumentationPart->setName($aDocumentationPartData['name']);
     $oDocumentationPart->setKey($aDocumentationPartData['key']);
     $oDocumentationPart->setIsOverview($aDocumentationPartData['is_overview']);
     $oDocumentationPart->setIsPublished($aDocumentationPartData['is_published']);
     $oDocumentationPart->setDocumentationId($aDocumentationPartData['documentation_id']);
     $oDocumentationPart->setLanguageId($oDocumentationPart->getDocumentation()->getLanguageId());
     $oDocumentationPart->setImageId($aDocumentationPartData['image_id'] != null ? $aDocumentationPartData['image_id'] : null);
     if ($oDocumentationPart->getTitle() == null) {
         $oDocumentationPart->setTitle(null);
     }
     $oRichtextUtil = new RichtextUtil();
     $oRichtextUtil->setTrackReferences($oDocumentationPart);
     $oDocumentationPart->setBody($oRichtextUtil->parseInputFromEditor($aDocumentationPartData['body']));
     if ($oDocumentationPart->isNew() && is_numeric($oDocumentationPart->getDocumentationId())) {
         $oDocumentationPart->setSort(DocumentationPartQuery::create()->filterByDocumentationId($oDocumentationPart->getDocumentationId())->count() + 1);
     }
     if ($aDocumentationPartData['image_id'] == null && $oDocumentationPart->getDocument()) {
         $oDocumentationPart->getDocument()->delete();
     }
     if (!Flash::noErrors()) {
         // Don't validate on file upload but set is_published to false if there are errors
         if ($aDocumentationPartData['documentation_id'] != null && $aDocumentationPartData['is_file_upload']) {
             $oDocumentationPart->setIsPublished(false);
         } else {
             throw new ValidationException();
         }
     }
     $oDocumentationPart->save();
     return $oDocumentationPart->getId();
 }
 public function onNavigationItemChildrenRequested(NavigationItem $oNavigationItem)
 {
     if (!($oNavigationItem instanceof PageNavigationItem && $oNavigationItem->getIdentifier() === self::PARENT_PAGE_IDENTIFIER)) {
         return;
     }
     $aDocumentationPartKeys = array();
     foreach (DocumentationProviderTypeModule::completeMetaData() as $sPart => $aLanguages) {
         if (isset($aLanguages[Session::language()])) {
             $aDocumentationPartKeys[$sPart] = false;
         }
     }
     foreach (DocumentationPartQuery::create()->filterByLanguageId(Session::language())->select('Key')->find() as $sPart) {
         $aDocumentationPartKeys[$sPart] = true;
     }
     ksort($aDocumentationPartKeys);
     $aDocumentations = DocumentationsFrontendModule::listQuery()->select(array('Key', 'Name', 'Title', 'NameSpace'))->find();
     foreach ($aDocumentations as $aParams) {
         $aConfiguredParts = array();
         foreach ($aDocumentationPartKeys as $sKey => $bIsInternal) {
             if (StringUtil::startsWith($sKey, $aParams['NameSpace'] . '.')) {
                 $aConfiguredParts[$sKey] = $bIsInternal;
                 unset($aDocumentationPartKeys[$sKey]);
             } else {
                 if ($sKey > $aParams['NameSpace'] . '.') {
                     break;
                 }
             }
         }
         $sTitle = $aParams['Title'] != null ? $aParams['Title'] : $aParams['Name'];
         $oNavItem = new VirtualNavigationItem(self::ITEM_TYPE, $aParams['Key'], 'Dokumentation ' . $sTitle, $aParams['Name'], $aConfiguredParts);
         $oNavigationItem->addChild($oNavItem);
     }
     // if(count($aDocumentationPartKeys) > 0) {
     // 	$oNavItem = new VirtualNavigationItem(self::ITEM_TYPE_UNCATEGORIZED, 'uncategorized', TranslationPeer::getString('documentations.uncategorized'), null, $aDocumentationPartKeys);
     // 	$oNavigationItem->addChild($oNavItem);
     // }
 }
 private function contentAction()
 {
     $sLanguageId = Manager::usePath();
     $sDocumentationKey = Manager::usePath();
     $sPartKey = Manager::usePath();
     RichtextUtil::$USE_ABSOLUTE_LINKS = LinkUtil::isSSL();
     if ($sPartKey) {
         $oPart = DocumentationPartQuery::create()->filterByLanguageId($sLanguageId)->filterByKeys($sDocumentationKey, $sPartKey)->findOne();
         if (!$oPart) {
             if ($sPartKey === self::TUTORIAL_KEY) {
                 return TranslationPeer::getString('wns.documentation.video_tutorial', $sLanguageId, "Tutorial");
             }
             return null;
         }
         return RichtextUtil::parseStorageForFrontendOutput($oPart->getBody())->render();
     } else {
         $oDocumentation = DocumentationQuery::create()->filterByLanguageId($sLanguageId)->filterByKey($sDocumentationKey)->findOne();
         if (!$oDocumentation) {
             return null;
         }
         $sHtmlOutput = RichtextUtil::parseStorageForFrontendOutput($oDocumentation->getDescription())->render();
         $aParts = $oDocumentation->getDocumentationPartsOrdered();
         if (count($aParts) > 0) {
             $sHtmlOutput .= '<ul class="documentation_parts">';
             foreach ($aParts as $i => $oPart) {
                 $sHtmlOutput .= TagWriter::quickTag('li', array(), self::addPartLink($oPart));
             }
             $sHtmlOutput .= '</ul>';
         }
         $bDisplayVideo = false;
         if ($bDisplayVideo && $oDocumentation->getYoutubeUrl()) {
             $sHtmlOutput .= $this->embedVideo($oDocumentation->getYoutubeUrl());
         }
         return $sHtmlOutput;
     }
 }
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param PropelPDO $con
  * @return void
  * @throws PropelException
  * @throws Exception
  * @see        BaseObject::setDeleted()
  * @see        BaseObject::isDeleted()
  */
 public function delete(PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(DocumentationPartPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = DocumentationPartQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         // denyable behavior
         if (!(DocumentationPartPeer::isIgnoringRights() || $this->mayOperate("delete"))) {
             throw new PropelException(new NotPermittedException("delete.by_role", array("role_key" => "documentations")));
         }
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Documentation is new, it will return
  * an empty collection; or if this Documentation has previously
  * been saved, it will retrieve related DocumentationParts from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in Documentation.
  *
  * @param Criteria $criteria optional Criteria object to narrow the query
  * @param PropelPDO $con optional connection object
  * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
  * @return PropelObjectCollection|DocumentationPart[] List of DocumentationPart objects
  */
 public function getDocumentationPartsJoinUserRelatedByUpdatedBy($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $query = DocumentationPartQuery::create(null, $criteria);
     $query->joinWith('UserRelatedByUpdatedBy', $join_behavior);
     return $this->getDocumentationParts($query, $con);
 }
 public function getCriteria()
 {
     return DocumentationPartQuery::create();
 }
 public function getDocumentationPartsOrdered()
 {
     return $this->getDocumentationParts(DocumentationPartQuery::create()->active()->orderBySort());
 }
 /**
  * Returns a new DocumentationPartQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param   DocumentationPartQuery|Criteria $criteria Optional Criteria to build the query from
  *
  * @return DocumentationPartQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof DocumentationPartQuery) {
         return $criteria;
     }
     $query = new DocumentationPartQuery(null, null, $modelAlias);
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
 public function renderDetail(Documentation $oDocumentation = null)
 {
     if (self::$DOCUMENTATION_PARTS == null) {
         self::$DOCUMENTATION_PARTS = DocumentationPartQuery::create()->filterByDocumentationId($oDocumentation->getId())->filterByIsPublished(true)->orderBySort()->find();
     }
     if ($oDocumentation) {
         $sName = $oDocumentation->getName();
         $sEmbedUrl = $oDocumentation->getYoutubeUrl();
         $sDescription = RichtextUtil::parseStorageForFrontendOutput(stream_get_contents($oDocumentation->getDescription()));
     } else {
         $sName = TranslationPeer::getString('documentations.uncategorized');
         $sEmbedUrl = null;
         $sDescription = null;
     }
     $oTemplate = $this->constructTemplate('documentation');
     // render video if exists
     if ($sEmbedUrl != null) {
         $this->embedVideo($oTemplate, $sEmbedUrl);
     }
     $oTemplate->replaceIdentifier('documentation_name', $sName);
     $oTemplate->replaceIdentifier('description', $sDescription);
     // render parts
     $oPartTmpl = $this->constructTemplate('part');
     $sLinkToSelf = LinkUtil::linkToSelf();
     $bRequiresQuicklinks = count(self::$DOCUMENTATION_PARTS) > 1;
     $oPartLinkPrototype = $this->constructTemplate('part_link');
     foreach (self::$DOCUMENTATION_PARTS as $sKey => $mPart) {
         if ($mPart === true) {
             $mPart = DocumentationPartQuery::create()->filterByKey($sKey)->findOne();
         }
         $bIsOverview = false;
         if ($mPart instanceof DocumentationPart) {
             //Internal documentation
             $sBody = RichtextUtil::parseStorageForFrontendOutput(stream_get_contents($mPart->getBody()));
             $sLinkText = $mPart->getName();
             $sTitle = $mPart->getTitle();
             $sImageUrl = null;
             if ($mPart->getDocument()) {
                 $sImageUrl = $mPart->getDocument()->getDisplayUrl();
                 if (RichtextUtil::$USE_ABSOLUTE_LINKS) {
                     $sImageUrl = LinkUtil::absoluteLink($sImageUrl);
                 }
             }
             $sKey = $mPart->getKey();
             $bIsOverview = $mPart->getIsOverview();
             $sExternalLink = null;
         } else {
             //External documentation
             $aData = DocumentationProviderTypeModule::dataForPart($sKey, Session::language());
             $sBody = new Template($aData['content'], null, true);
             $sLinkText = $aData['title'];
             $sTitle = null;
             $sImageUrl = null;
             $sExternalLink = $aData['url'];
         }
         // Add quick links
         if ($bRequiresQuicklinks) {
             $oPartLink = clone $oPartLinkPrototype;
             $oPartLink->replaceIdentifier('href', $sLinkToSelf . '#' . $sKey);
             $oPartLink->replaceIdentifier('link_text', $sLinkText);
             if ($sTitle != null) {
                 $oPartLink->replaceIdentifier('title', $sTitle);
             }
             $oTemplate->replaceIdentifierMultiple('part_links', $oPartLink, null, Template::NO_NEW_CONTEXT);
         }
         // Add documentation part
         $oPartTemplate = clone $oPartTmpl;
         $oPartTemplate->replaceIdentifier('name', $sLinkText);
         $oPartTemplate->replaceIdentifier('anchor', $sKey);
         $oPartTemplate->replaceIdentifier('href_top', $sLinkToSelf . "#top_of_page");
         $oPartTemplate->replaceIdentifier('external_link', $sExternalLink);
         if ($sImageUrl) {
             $oPartTemplate->replaceIdentifier('image', TagWriter::quickTag('img', array('class' => !$bIsOverview ? 'image_float' : "image_fullwidth", 'src' => $sImageUrl, 'alt' => 'Bildschirmfoto von ' . $sLinkText)));
             $oPartTemplate->replaceIdentifier('margin_left_class', $bIsOverview ? '' : ' margin_left_class');
         }
         $oPartTemplate->replaceIdentifier('content', $sBody);
         $oTemplate->replaceIdentifierMultiple('part', $oPartTemplate);
     }
     return $oTemplate;
 }