public function renderFile() { $oDocument = new DOMDocument(); $oRoot = $oDocument->createElement("rss"); $oRoot->setAttribute('version', "2.0"); $oDocument->appendChild($oRoot); $oChannel = $oDocument->createElement("channel"); /** * @todo parametrize the argument */ $oQuery = FrontendJournalEntryQuery::create()->mostRecentFirst()->limit(10); if ($this->aJournalIds) { $oQuery->filterByJournalId($this->aJournalIds); } self::addSimpleAttribute($oDocument, $oChannel, 'title', $this->oJournalPage->getPageTitle()); self::addSimpleAttribute($oDocument, $oChannel, 'description', $this->oJournalPage->getDescription()); self::addSimpleAttribute($oDocument, $oChannel, 'link', LinkUtil::absoluteLink(LinkUtil::link($this->oJournalPage->getFullPathArray(), 'FrontendManager'), null, LinkUtil::isSSL())); self::addSimpleAttribute($oDocument, $oChannel, 'language', Session::language()); self::addSimpleAttribute($oDocument, $oChannel, 'ttl', "15"); $oRoot->appendChild($oChannel); $aJournalEntries = $oQuery->find(); foreach ($aJournalEntries as $oJournalEntry) { $oItem = $oDocument->createElement('item'); foreach ($oJournalEntry->getRssAttributes($this->aJournalIds ? $this->oJournalPage : null) as $sAttributeName => $mAttributeValue) { self::attributeToNode($oDocument, $oItem, $sAttributeName, $mAttributeValue); } $oChannel->appendChild($oItem); } print $oDocument->saveXML(); }
public function __construct($sBasePath) { $this->sBasePath = $sBasePath; parent::__construct(); $this->path = implode('/', Manager::getRequestPath()); $this->base_uri = LinkUtil::absoluteLink(''); $this->uri = LinkUtil::absoluteLink(LinkUtil::link()); $this->_SERVER['SCRIPT_NAME'] = LinkUtil::link(); }
public function getRssAttributes($oJournalPage = null, $bIsForRpc = false) { $aResult = array(); $aResult['title'] = $this->getTitle(); $aJournalPageLink = $this->getLink($oJournalPage); $aResult['link'] = LinkUtil::absoluteLink(LinkUtil::link($aJournalPageLink, 'FrontendManager'), null, LinkUtil::isSSL()); if ($bIsForRpc) { $aResult['description'] = RichtextUtil::parseStorageForBackendOutput($this->getText())->render(); } else { $aResult['description'] = RichtextUtil::parseStorageForFrontendOutput($this->getText())->render(); } $aResult['author'] = $this->getUserRelatedByCreatedBy()->getEmail() . ' (' . $this->getUserRelatedByCreatedBy()->getFullName() . ')'; $aTags = TagPeer::tagInstancesForObject($this); $aCategories = array(); foreach ($aTags as $oTag) { $aCategories[] = $oTag->getTagName(); } $aResult[$bIsForRpc ? 'categories' : 'category'] = $aCategories; if ($aJournalPageLink) { $aResult['guid'] = $aResult['link']; } else { $aResult['guid'] = array('isPermaLink' => 'false', '__content' => $this->getId() . "-" . $this->getJournal()->getId()); } $aResult['pubDate'] = date(DATE_RSS, (int) $this->getCreatedAtTimestamp()); if ($bIsForRpc) { $aResult['dateCreated'] = new xmlrpcval(iso8601_encode((int) $this->getCreatedAtTimestamp()), 'dateTime.iso8601'); $aResult['date_created_gmt'] = new xmlrpcval(iso8601_encode((int) $this->getCreatedAtTimestamp(), 1), 'dateTime.iso8601'); $aResult['postid'] = $this->getId(); } else { $aEnclosures = array(); foreach ($this->getImages() as $oImage) { $oDocument = $oImage->getDocument(); $aEnclosures[] = array('length' => $oDocument->getDataSize(), 'type' => $oDocument->getMimetype(), 'url' => LinkUtil::absoluteLink($oDocument->getLink(), null, LinkUtil::isSSL())); } $aResult['enclosure'] = $aEnclosures; } return $aResult; }
private function renderNavigationItem($oNavigationItem) { $oUrl = $this->oXmlDocument->createElement('url'); //Location, absolute url $sAbsoluteLink = LinkUtil::absoluteLink(LinkUtil::link($oNavigationItem->getLink(), 'FrontendManager'), null, LinkUtil::isSSL()); $oUrl->appendChild($this->element('loc', $sAbsoluteLink)); //Last modified if ($oNavigationItem instanceof PageNavigationItem) { $oUrl->appendChild($this->element('lastmod', $oNavigationItem->getMe()->getUpdatedAt('Y-m-d'))); } else { //@todo: figure out how to retrieve last modified for content other then text and configuration: FrontendModules } //Priority $iPriority = 1; if ($oNavigationItem->getCanonical() !== null) { $iPriority = 0.5; } $oUrl->appendChild($this->element('priority', $iPriority)); $this->oUrl->appendChild($oUrl); foreach ($oNavigationItem->getChildren(null, false, true) as $oChild) { $this->renderNavigationItem($oChild); } }
public function getPageData() { $oPage = PageQuery::create()->findPk($this->iPageId); $aResult = $oPage->toArray(BasePeer::TYPE_PHPNAME, false); // addition related page fields $aResult['PageLink'] = LinkUtil::absoluteLink(LinkUtil::link($oPage->getFullPathArray(), 'FrontendManager', array(), AdminManager::getContentLanguage()), null, 'auto'); $aResult['PageHref'] = LinkUtil::absoluteLink(LinkUtil::link($oPage->getFullPathArray(), 'FrontendManager', array(), AdminManager::getContentLanguage()), null, 'default', true); // page properties are displayed if added to template try { $mAvailableProperties = $this->getAvailablePageProperties($oPage); if (count($mAvailableProperties) > 0) { $aResult['page_properties'] = $mAvailableProperties; } } catch (Exception $e) { ErrorHandler::handleException($e, true); } // page references are displayed if exist $mReferences = AdminModule::getReferences(ReferencePeer::getReferences($oPage)); $aResult['CountReferences'] = count($mReferences); if ($mReferences !== null) { $aResult['page_references'] = $mReferences; } return $aResult; }
/** * Create internal links. * The identifier value signifies the destination. It can be either a path or one of the following special values: “to_self”, “host_only”, “base_href”. * The following additional parameters are allowed: “is_absolute”, “page”, “ignore_request”, “manager” * Implicitly, the value of is_absolute determines the type of absolute link generated. * A value of “false” will not generate absolute links. * Using “auto” will determine server-side whether to use http or https for protocol. * Setting is_absolute to “http” or “https” will set the protocol accordingly. * Any other value (including “true”) will generate a protocol-relative URL (starting with //), meaning the reference is determined on the client-side. * Creating a “base_href” link will always make it absolute and not explicitly setting “is_absolute” will default to “auto” (instead of “true” as is the case with all other link types). */ public function writeLink($oTemplateIdentifier) { $sDestination = $oTemplateIdentifier->getValue(); $aParameters = $oTemplateIdentifier->getParameters(); $bIsAbsolute = false; $bAbsoluteType = $oTemplateIdentifier->getParameter('is_absolute'); if ($bAbsoluteType === 'http' || $bAbsoluteType === 'false') { $bAbsoluteType = false; } else { if ($bAbsoluteType === 'https' || $bAbsoluteType === 'true') { $bAbsoluteType = true; } else { if ($bAbsoluteType === 'auto') { $bAbsoluteType = LinkUtil::isSSL(); } else { if ($oTemplateIdentifier->hasParameter('is_absolute')) { $bAbsoluteType = null; } else { $bAbsoluteType = 'default'; } } } } unset($aParameters['is_absolute']); if ($sDestination === "to_self") { $bIgnoreRequest = $oTemplateIdentifier->getParameter('ignore_request') === 'true'; unset($aParameters['ignore_request']); $sDestination = LinkUtil::linkToSelf(null, $aParameters, $bIgnoreRequest); } else { if ($sDestination === "host_only") { return LinkUtil::absoluteLink(''); } else { if ($sDestination === "base_href") { $sDestination = MAIN_DIR_FE_PHP; $bIsAbsolute = true; if (!$oTemplateIdentifier->hasParameter('is_absolute')) { $bAbsoluteType = LinkUtil::isSSL(); } } elseif ($sPage = $oTemplateIdentifier->getParameter('page')) { $oPage = PageQuery::create()->findOneByIdentifier($sPage); if ($oPage === null) { $oPage = PageQuery::create()->findOneByName($sPage); } $sManager = 'FrontendManager'; if ($oTemplateIdentifier->hasParameter('manager')) { $sManager = $oTemplateIdentifier->getParameter('manager'); } if ($oPage) { $sDestination = LinkUtil::link($oPage->getLink(), $sManager); } } else { $sManager = null; if ($oTemplateIdentifier->hasParameter('manager')) { unset($aParameters['manager']); $sManager = $oTemplateIdentifier->getParameter('manager'); } $sDestination = LinkUtil::link($sDestination, $sManager, $aParameters); } } } return LinkUtil::absoluteLink($sDestination, null, $bAbsoluteType, !$bIsAbsolute); }
/** * notifySubscriberOptIn() * * @param int/array subscriber group * @return void */ public function notifySubscriberOptIn($iSubscriberGroupId) { $oEmailTemplate = $this->constructTemplate('email_subscription_optin_notification'); /** * note: unsubscribe_page is just the main communication page where forms like * • optin confirm or * • unsubscribe optout * can be easily displayed and safely managed */ $oUnsubscribePage = PageQuery::create()->findOneByIdentifier(Settings::getSetting('newsletter', 'unsubscribe_page', 'unsubscribe')); if ($oUnsubscribePage === null) { // Fallback: try searching the page by name $oUnsubscribePage = PageQuery::create()->findOneByName(Settings::getSetting('newsletter', 'unsubscribe_page', 'unsubscribe')); if ($oUnsubscribePage === null) { throw new Exception('Error in' . __METHOD__ . ': a public and hidden page is required for optin subscribe action'); } } $oOptinConfirmLink = LinkUtil::absoluteLink(LinkUtil::link($oUnsubscribePage->getLink(), null, array(self::PARAM_OPT_IN_CONFIRM => Subscriber::getOptInChecksumByEmailAndSubscriberGroupId($this->oSubscriber->getEmail(), $iSubscriberGroupId))), null, LinkUtil::isSSL()); $oEmailTemplate->replaceIdentifier('optin_link', TagWriter::quickTag('a', array('href' => $oOptinConfirmLink), TranslationPeer::getString('newsletter_subscription.optin_link_text'))); $this->sendMail($oEmailTemplate, true); }
/** * Closes the consolidator and adds the consolidation link. * Sometimes consolidatable resources are interrupted by ones that can’t be consolidated (if they were added with a flag prohibiting consolidation or if they have an IE condition or if they are from an external source) */ private function cleanupConsolidator(&$aConsolidatorInfo) { if ($aConsolidatorInfo === null) { return; } $aLocation = array('consolidated_resource', $aConsolidatorInfo['type']); foreach ($aConsolidatorInfo['contents'] as $oCache) { $aLocation[] = $oCache->getStrategy()->encodedKey($oCache); } $sLink = LinkUtil::absoluteLink(LinkUtil::link($aLocation, 'FileManager'), null, 'default', true); $aConsolidatorLink = array('location' => $sLink, 'template' => $aConsolidatorInfo['type']); $this->aIncludedResources[$aConsolidatorInfo['priority']][$aConsolidatorInfo['key']] = $aConsolidatorLink; $aConsolidatorInfo = null; }
private function renderEntry(JournalEntry $oEntry, Template $oEntryTemplate, $bIsAjax = false) { $oCommentQuery = JournalCommentQuery::create()->excludeUnverified(); $oEntryTemplate->replaceIdentifier('journal_title', $oEntry->getJournal()->getName()); $oEntryTemplate->replaceIdentifier('slug', $oEntry->getSlug()); $oEntryTemplate->replaceIdentifier('name', $oEntry->getSlug()); $oEntryTemplate->replaceIdentifier('user_name', $oEntry->getUserRelatedByCreatedBy()->getFullName()); $oEntryTemplate->replaceIdentifier('id', $oEntry->getId()); $oEntryTemplate->replaceIdentifier('date', LocaleUtil::localizeDate($oEntry->getPublishAtTimestamp())); $oEntryTemplate->replaceIdentifier('title', $oEntry->getTitle()); $oEntryTemplate->replaceIdentifier('comment_count', $oEntry->countJournalComments($oCommentQuery)); // Manager in link has to be set manually for the case when it's called asynchroneously in preview $sDetailLink = LinkUtil::link($oEntry->getLink($this->oPage), $this->bIsPreview ? 'PreviewManager' : 'FrontendManager'); $oEntryTemplate->replaceIdentifier('link', LinkUtil::absoluteLink($sDetailLink), null, LinkUtil::isSSL()); $oEntryTemplate->replaceIdentifier('detail_link_title', TranslationPeer::getString('journal_entry.add_comment_title', null, null, array('title' => $oEntry->getTitle()))); if ($oEntryTemplate->hasIdentifier('text')) { $oEntryTemplate->replaceIdentifier('text', RichtextUtil::parseStorageForFrontendOutput($oEntry->getText())); } if ($oEntryTemplate->hasIdentifier('text_short')) { $oEntryTemplate->replaceIdentifier('text_short', RichtextUtil::parseStorageForFrontendOutput($oEntry->getTextShort())); } if ($this->oEntry !== null && $this->oEntry == $oEntry) { $oEntryTemplate->replaceIdentifier('current_class', ' class="current"', null, Template::NO_HTML_ESCAPE); } if ($oEntryTemplate->hasIdentifier('tags')) { $aTagInstances = TagInstanceQuery::create()->filterByModelName('JournalEntry')->filterByTaggedItemId($oEntry->getId())->joinTag()->find(); foreach ($aTagInstances as $i => $oTagInstance) { if ($i > 0) { $oEntryTemplate->replaceIdentifierMultiple('tags', ', ', null, Template::NO_NEWLINE | Template::NO_NEW_CONTEXT); } $oEntryTemplate->replaceIdentifierMultiple('tags', $oTagInstance->getTag()->getReadableName(), null, Template::NO_NEW_CONTEXT | Template::NO_NEWLINE); } } if ($oEntryTemplate->hasIdentifier('journal_comments')) { $oEntryTemplate->replaceIdentifier('journal_comments', $this->renderComments($oEntry->getJournalComments($oCommentQuery), $oEntry, $oEntry === $this->oEntry)); } if ($oEntryTemplate->hasIdentifier('journal_gallery') && $oEntry->countJournalEntryImages() > 0) { $oEntryTemplate->replaceIdentifier('journal_gallery', $this->renderGallery($oEntry)); } if ($this->bIsPreview && !$bIsAjax) { $oEntryTemplate = TagWriter::quickTag('div', array('class' => 'journal_entry-container filled-container', 'data-entry-id' => $oEntry->getId(), 'data-is-not-shown' => $oEntry->isNotShown(), 'data-template' => $oEntryTemplate->getTemplateName()), $oEntryTemplate); } return $oEntryTemplate; }
private static function link($sLocation) { if (self::$USE_ABSOLUTE_LINKS !== false) { return LinkUtil::absoluteLink($sLocation, null, self::$USE_ABSOLUTE_LINKS, true); } else { return $sLocation; } }
public function getDetail() { // display error info if ($this->iError) { $oTemplate = $this->constructTemplate('error_message'); $oTemplate->replaceIdentifier('error_title', StringPeer::getString('webdav.error_message') . ' ' . $this->sErrorLocation); $oTemplate->replacePstring("error_details", array('dir_name' => $this->sWebdavBaseDirPath), 'webdav.error_' . $this->iError); return $oTemplate; } // display module info if ($this->sFilePath === null) { $oTemplate = $this->constructTemplate('module_info'); if (count($this->aFiles) > 0) { $oTemplate->replaceIdentifier('edit_or_create_message', StringPeer::getString('webdav.choose_or_create')); } $oTemplate->replaceIdentifier('create_link', TagWriter::quickTag('a', array('class' => 'edit_related_link highlight', 'href' => LinkUtil::link('webdav', null, array('action' => 'create'))), StringPeer::getString('webdav.create'))); $oTemplate->replaceIdentifier('user_backend_link', TagWriter::quickTag('a', array('class' => 'edit_related_link highlight', 'href' => LinkUtil::link('users')), StringPeer::getString('module.backend.users'))); return $oTemplate; } $oTemplate = $this->constructTemplate('detail'); $oTemplate->replaceIdentifier('module_info_link', TagWriter::quickTag('a', array('title' => StringPeer::getString('module_info'), 'class' => 'info', 'href' => LinkUtil::link('webdav', null, array('get_module_info' => 'true'))))); if ($this->sFilePath === self::NEW_DIR_IDENTIFIER) { $aDirPermissionsGroupIds = array(); } else { $aDirPermissionsGroupIds = DirectoryPermissionPeer::getPermissionGroupIdsByFileName($this->sFilePath); $oDeleteTemplate = $this->constructTemplate("delete_button", true); $oDeleteTemplate->replacePstring("delete_item", array('name' => $this->sFilePath)); $oTemplate->replaceIdentifier("delete_button", $oDeleteTemplate, null, Template::LEAVE_IDENTIFIERS); // show users with usergroups $oUsersWithGroups = UserPeer::getUsersWithRights($aDirPermissionsGroupIds); $oUsersTemplate = $this->constructTemplate('detail_users'); if (count($oUsersWithGroups) > 0) { foreach ($oUsersWithGroups as $oUser) { $oUsersTemplate->replaceIdentifierMultiple('users', TagWriter::quickTag('a', array('class' => 'highlight', 'title' => StringPeer::getString('user.edit'), 'class' => 'webdav_files', 'href' => LinkUtil::link(array('users', $oUser->getId()), null, array('check_userkind' => true))), $oUser->getFullName() . ' [Benutzername:' . $oUser->getUserName() . ']')); } } else { $oUsersTemplate->replaceIdentifier('users', TagWriter::quickTag('div', array('class' => 'webdav_files'), StringPeer::getString('webdav.no_users_with_permission_message'))); } $oUsersTemplate->replaceIdentifier('user_backend_link', TagWriter::quickTag('a', array('class' => 'edit_related_link', 'href' => LinkUtil::link('users', null, array('check_userkind' => 'true'))), StringPeer::getString('user.edit'))); $oTemplate->replaceIdentifier("users_with_permission", $oUsersTemplate); $sServerPath = LinkUtil::absoluteLink(substr($this->sWebdavBaseDirPath, strrpos($this->sWebdavBaseDirPath, '/')) . '/' . $this->sFilePath); $oTemplate->replaceIdentifier("server_address", $sServerPath); // show files in current dir $aDirFiles = array_keys(ResourceFinder::getFolderContents($this->sWebdavBaseDirPath . '/' . $this->sFilePath)); if (count($aDirFiles) > 0) { $oFilesTemplate = $this->constructTemplate("detail_files"); $sWebDavDirPath = $this->sWebdavBaseDirPath . '/' . $this->sFilePath . '/'; foreach ($aDirFiles as $i => $sFilePath) { $iFileSize = filesize($sWebDavDirPath . $sFilePath); $sFileSize = DocumentUtil::getDocumentSize($iFileSize); if (substr($sFileSize, 0, 1) == '0') { $sFileSize = 'unknown'; } $oFilesTemplate->replaceIdentifierMultiple('files', TagWriter::quickTag('div', array('class' => 'webdav_files'), $sFilePath . ' [' . $sFileSize . ']')); } $oTemplate->replaceIdentifier('detail_files', $oFilesTemplate); } } $oTemplate->replaceIdentifier('name', $this->sFilePath); $oTemplate->replaceIdentifier('file_path_old', $this->sFilePath); if (isset($_POST['file_path'])) { $this->sFilePath = $_POST['file_path']; } $oTemplate->replaceIdentifier('file_path', $this->sFilePath === self::NEW_DIR_IDENTIFIER ? '' : $this->sFilePath); $oTemplate->replaceIdentifier('file_path_readonly', $this->sFilePath != self::NEW_DIR_IDENTIFIER ? ' readonly="readonly"' : '', null, Template::NO_HTML_ESCAPE); $aGroups = GroupPeer::getAll(); $oTemplate->replaceIdentifier('group_options', TagWriter::optionsFromObjects($aGroups, 'getId', 'getName', $aDirPermissionsGroupIds, array())); $oTemplate->replaceIdentifier('group_backend_link', TagWriter::quickTag('a', array('class' => 'edit_related_link highlight', 'href' => LinkUtil::link('groups')), StringPeer::getString('group.edit'))); return $oTemplate; }
private function addPartLink($oPart) { if (!self::$DOCUMENTATION_PAGE) { self::$DOCUMENTATION_PAGE = PageQuery::create()->filterByIdentifier(DocumentationFilterModule::PARENT_PAGE_IDENTIFIER)->findOne(); } if (!self::$DOCUMENTATION_PAGE) { return; } $sLink = LinkUtil::absoluteLink(LinkUtil::link(array_merge(self::$DOCUMENTATION_PAGE->getFullPathArray(), array($oPart->getDocumentation()->getKey())), 'FrontendManager'), null, 'auto'); return TagWriter::quickTag('a', array('target' => 'documentation', 'href' => $sLink . '#' . $oPart->getKey()), $oPart->getName()); }
public static function getUsersBlogs($sApiKey, $sUserName, $sPassword) { if (!self::checkLogin($sUserName, $sPassword)) { return self::loginError(); } $aJournals = array(); foreach (JournalQuery::create()->find() as $oJournal) { $oJournalPage = $oJournal->getJournalPage(); $aLink = $oJournalPage ? $oJournalPage->getLinkArray() : array(); $aJournals[] = array('url' => LinkUtil::absoluteLink(LinkUtil::link($aLink, 'FrontendManager')), 'blogid' => $oJournal->getId(), 'blogName' => $oJournal->getName()); } return $aJournals; }
/** sendNewsletter() * * @param mixed string/object recipient * @param object oEmailTemplateInstance * * @return void */ private function sendNewsletter($mRecipient, $oEmailTemplateInstance) { if (is_object($mRecipient)) { $oEmailTemplateInstance->replaceIdentifier('recipient', $mRecipient->getName()); if ($mRecipient instanceof Subscriber && $this->oUnsubscribePage) { $sLanguageId = FrontendManager::shouldIncludeLanguageInLink() ? $this->oNewsletter->getLanguageId() : false; if (method_exists($mRecipient, 'getUnsubscribeQueryParams')) { $sUnsubscribeLink = LinkUtil::absoluteLink(LinkUtil::link($this->oUnsubscribePage->getLink(), 'FrontendManager', $mRecipient->getUnsubscribeQueryParams(), $sLanguageId)); $oEmailTemplateInstance->replaceIdentifier('unsubscribe_link', $sUnsubscribeLink); } } } else { $oEmailTemplateInstance->replaceIdentifier('recipient', $mRecipient); } // Send newsletter and store invalid emails try { $sPlainTextMethod = Settings::getSetting('newsletter', 'plain_text_alternative_method', 'markdown'); $oEMail = null; if ($sPlainTextMethod === null || $sPlainTextMethod === false) { $oEMail = new EMail($this->oNewsletter->getSubject(), $oEmailTemplateInstance, true); } else { $oEMail = new EMail($this->oNewsletter->getSubject(), MIMEMultipart::alternativeMultipartForTemplate($oEmailTemplateInstance, null, null, $sPlainTextMethod), true); } if (is_object($mRecipient)) { $oEMail->addRecipient($mRecipient->getEmail(), $mRecipient->getName() === $mRecipient->getEmail() ? null : $mRecipient->getName()); } else { $oEMail->addRecipient($mRecipient); } $oEMail->setSender($this->sSenderName, $this->sSenderEmailAddress); $oEMail->send(); } catch (Exception $e) { $this->aInvalidEmails[] = new NewsletterSendFailure($e, $mRecipient); } }
private function handleNewJournalComment($oPage, $oEntry) { $oFlash = Flash::getFlash(); // Validate form and create new comment and $oComment = new JournalComment(); $oComment->setUsername($_POST['comment_name']); $oFlash->checkForValue('comment_name', 'comment_name_required'); $oComment->setEmail($_POST['comment_email']); $oFlash->checkForEmail('comment_email', 'comment_email_required'); if ($oEntry->getJournal()->getUseCaptcha() && !Session::getSession()->isAuthenticated() && !FormFrontendModule::validateRecaptchaInput() && !isset($_POST['preview'])) { $oFlash->addMessage('captcha_required'); } $oPurifierConfig = HTMLPurifier_Config::createDefault(); $oPurifierConfig->set('Cache.SerializerPath', MAIN_DIR . '/' . DIRNAME_GENERATED . '/' . DIRNAME_CACHES . '/purifier'); $oPurifierConfig->set('HTML.Doctype', 'XHTML 1.0 Transitional'); $oPurifierConfig->set('AutoFormat.AutoParagraph', true); $oPurifier = new HTMLPurifier($oPurifierConfig); $_POST['comment_text'] = $oPurifier->purify($_POST['comment_text']); $oComment->setText($_POST['comment_text']); $oFlash->checkForValue('comment_text', 'comment_required'); $oFlash->finishReporting(); if (isset($_POST['preview'])) { $oComment->setCreatedAt(date('c')); $_POST['preview'] = $oComment; } else { if (Flash::noErrors()) { $oEntry->addJournalComment($oComment); // Post is considered as spam $bIsProblablySpam = isset($_POST['important_note']) && $_POST['important_note'] != null; $sCommentNotificationTemplate = 'e_mail_comment_notified'; // Prevent publication if comments are not enabled or post is spam if (!$oEntry->getJournal()->getEnableComments() || $bIsProblablySpam) { if (!Session::getSession()->isAuthenticated()) { $oComment->setIsPublished(false); $sCommentNotificationTemplate = 'e_mail_comment_moderated'; } } $oComment->save(); // Notify new comment if ($oEntry->getJournal()->getNotifyComments()) { $oEmailContent = JournalPageTypeModule::templateConstruct($sCommentNotificationTemplate, $oPage->getPagePropertyValue('journal:template_set', 'default')); $oEmailContent->replaceIdentifier('email', $oComment->getEmail()); $oEmailContent->replaceIdentifier('user', $oComment->getUsername()); if ($bIsProblablySpam) { $oEmailContent->replaceIdentifier('this_comment_is_spam_note', TranslationPeer::getString('journal.this_comment_is_spam_note', null, null, array('important_note_content' => $_POST['important_note']))); } $oEmailContent->replaceIdentifier('comment', $oComment->getText()); $oEmailContent->replaceIdentifier('entry', $oEntry->getTitle()); $oEmailContent->replaceIdentifier('journal', $oEntry->getJournal()->getName()); $oEmailContent->replaceIdentifier('entry_link', LinkUtil::absoluteLink(LinkUtil::link($oEntry->getLink($oPage)))); $oEmailContent->replaceIdentifier('deactivation_link', LinkUtil::absoluteLink(LinkUtil::link(array('journal_comment_moderation', $oComment->getActivationHash(), 'deactivate'), 'FileManager'), null, LinkUtil::isSSL())); $oEmailContent->replaceIdentifier('activation_link', LinkUtil::absoluteLink(LinkUtil::link(array('journal_comment_moderation', $oComment->getActivationHash(), 'activate'), 'FileManager'), null, LinkUtil::isSSL())); $oEmailContent->replaceIdentifier('deletion_link', LinkUtil::absoluteLink(LinkUtil::link(array('journal_comment_moderation', $oComment->getActivationHash(), 'delete'), 'FileManager'), null, LinkUtil::isSSL())); $sSubject = TranslationPeer::getString('journal.notification_subject', null, null, array('entry' => $oEntry->getTitle())); $oEmail = new EMail($sSubject, $oEmailContent); $oSender = $oEntry->getUserRelatedByCreatedBy(); $oEmail->addRecipient($oSender->getEmail(), $oSender->getFullName()); $oEmail->send(); } $oSession = Session::getSession(); Flash::getFlash()->unfinishReporting()->addMessage('journal.has_new_comment', array(), "journal_entry.new_comment_thank_you" . ($oEntry->getJournal()->getEnableComments() || $oSession->isAuthenticated() ? '' : '.moderated'), 'new_comment_thank_you_message', 'p')->stick(); LinkUtil::redirect(LinkUtil::link($oEntry->getLink($oPage)) . "#comments"); } } }
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; }