public function saveData($aLinkData)
 {
     if ($this->iLinkId === null) {
         $oLink = new Link();
     } else {
         $oLink = LinkQuery::create()->findPk($this->iLinkId);
     }
     $oLink->setUrl(LinkUtil::getUrlWithProtocolIfNotSet($aLinkData['url']));
     $oLink->setName($aLinkData['name']);
     $oLink->setLinkCategoryId($aLinkData['link_category_id'] == null ? null : $aLinkData['link_category_id']);
     $oLink->setDescription($aLinkData['description']);
     if (isset($aLinkData['language_id'])) {
         $oLink->setLanguageId($aLinkData['language_id'] != null ? $aLinkData['language_id'] : null);
     }
     $this->validate($aLinkData);
     if (!Flash::noErrors()) {
         throw new ValidationException();
     }
     if ($oLink->getLinkCategoryId() != null) {
         if ($oLink->isNew() || $oLink->isColumnModified(LinkPeer::LINK_CATEGORY_ID)) {
             $oLink->setSort(LinkQuery::create()->filterByLinkCategoryId($oLink->getLinkCategoryId())->count() + 1);
         }
     }
     $oLink->save();
     return $oLink->getId();
 }
Beispiel #2
0
 public static function getReferences($aReferences)
 {
     if (count($aReferences) === null) {
         return null;
     }
     $aResult = array();
     foreach ($aReferences as $oReference) {
         if ($oReference->getFromModelName() === 'LanguageObject') {
             $oReferencedFromObject = $oReference->getFrom();
             if ($oReferencedFromObject) {
                 $oContentObject = $oReferencedFromObject->getContentObject();
                 $aResult[$oReferencedFromObject->getId()]['title'] = TranslationPeer::getString('reference.used_in_page');
                 $aResult[$oReferencedFromObject->getId()]['page_name'] = $oContentObject->getPage()->getName();
                 $aResult[$oReferencedFromObject->getId()]['container_name'] = $oContentObject->getContainerName();
                 $aResult[$oReferencedFromObject->getId()]['edit_link'] = TagWriter::quickTag('a', array('href' => LinkUtil::link(array('content', $oContentObject->getPageId(), 'edit', $oContentObject->getId()), 'AdminManager')), 'edit')->render();
             } else {
                 // delete reference if getFrom() === null
                 $oReference->delete();
             }
         } else {
             $aResult[$oReference->getFromId()]['title'] = TranslationPeer::getString('reference.used_in_object');
             $aResult[$oReference->getFromId()]['object_class'] = $oReference->getFromModelName();
             $aResult[$oReference->getFromId()]['object_id'] = $oReference->getFromId();
         }
     }
     return $aResult;
 }
 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 renderFile()
 {
     $bCleanup = Manager::usePath() === self::DO_CLEANUP;
     $aReferences = ReferenceQuery::create()->find();
     self::checkReferences($aReferences, $bCleanup);
     if (count(self::$REFERENCES_WITHOUT_FROM) === 0 && count(self::$REFERENCES_WITHOUT_TO) === 0) {
         if (!$bCleanup) {
             print TranslationPeer::getString('test_references.references_are_ok', null, null, array('count' => count($aReferences)));
         } else {
             print TranslationPeer::getString('test_references.wrong_references_removed');
             print TagWriter::quickTag('p', array(), TagWriter::quickTag('a', array('href' => LinkUtil::link(array('test_references'), 'FileManager')), TranslationPeer::getString('test_references.test_again')));
         }
     } else {
         if (count(self::$REFERENCES_WITHOUT_FROM) > 0) {
             print TagWriter::quickTag('p', array(), count(self::$REFERENCES_WITHOUT_FROM) . TranslationPeer::getString('test_references.loose_from_references_found'));
             foreach (self::$REFERENCES_WITHOUT_FROM as $oReference) {
                 print TagWriter::quickTag('p', array(), $oReference->getFromModelName() . '/' . $oReference->getFromId());
             }
         }
         if (count(self::$REFERENCES_WITHOUT_TO) > 0) {
             print TagWriter::quickTag('p', array(), count(self::$REFERENCES_WITHOUT_TO) . TranslationPeer::getString('test_references.loose_to_references_found'));
             foreach (self::$REFERENCES_WITHOUT_TO as $oReference) {
                 print TagWriter::quickTag('p', array(), $oReference->getToModelName() . '/' . $oReference->getToId());
             }
         }
         print TagWriter::quickTag('p', array(), TagWriter::quickTag('a', array('href' => LinkUtil::link(array('test_references', self::DO_CLEANUP), 'FileManager')), TranslationPeer::getString('test_references.remove_loose_ends')));
     }
 }
 public function getLinkToSubscriberData()
 {
     $aArray = array();
     $aArray[] = $this->countSubscriberGroupMemberships();
     $aArray[] = LinkUtil::link(array('subscribers'), 'AdminManager', array('subscriber_group_id' => $this->getId()));
     return $aArray;
 }
 public function renderFile()
 {
     header("Content-Type: application/json;charset=utf-8");
     $aRequest = array();
     $sContentType = 'application/x-www-form-urlencoded';
     if (isset($_SERVER['CONTENT_TYPE'])) {
         $sContentType = $_SERVER['CONTENT_TYPE'];
     }
     if (isset($_SERVER['HTTP_CONTENT_TYPE'])) {
         $sContentType = $_SERVER['HTTP_CONTENT_TYPE'];
     }
     if (StringUtil::startsWith($sContentType, 'application/json')) {
         $aRequest = json_decode(file_get_contents('php://input'), true);
     } else {
         foreach ($_REQUEST as $sKey => $sValue) {
             $aRequest[$sKey] = json_decode($sValue, true);
         }
     }
     $oSession = Session::getSession();
     if (!isset($aRequest['session_language']) && $oSession->isAuthenticated()) {
         $aRequest['session_language'] = $oSession->getUser()->getLanguageId();
     }
     $sPrevSessionLanguage = null;
     $sSetSessionLanguage = null;
     if (isset($aRequest['session_language'])) {
         $sPrevSessionLanguage = Session::language();
         $sSetSessionLanguage = $aRequest['session_language'];
         $oSession->setLanguage($sSetSessionLanguage);
     }
     try {
         try {
             $mJSONData = $this->getJSON($aRequest);
             $sResult = json_encode($mJSONData);
             $iError = json_last_error();
             if ($iError !== JSON_ERROR_NONE) {
                 throw new LocalizedException('wns.error.json', array('json_error' => $iError, 'json_error_message' => self::$JSON_ERRORS[$iError]));
             }
             print $sResult;
         } catch (Exception $e) {
             //Handle the gift, not the wrapping…
             if ($e->getPrevious()) {
                 throw $e->getPrevious();
             } else {
                 throw $e;
             }
         }
     } catch (LocalizedException $ex) {
         LinkUtil::sendHTTPStatusCode(500, 'Server Error');
         print json_encode(array('exception' => array('message' => $ex->getLocalizedMessage(), 'code' => $ex->getCode(), 'file' => $ex->getFile(), 'line' => $ex->getLine(), 'trace' => $ex->getTrace(), 'parameters' => $ex->getMessageParameters(), 'exception_type' => $ex->getExceptionType())));
     } catch (Exception $ex) {
         LinkUtil::sendHTTPStatusCode(500, 'Server Error');
         ErrorHandler::handleException($ex, true);
         print json_encode(array('exception' => array('message' => "Exception when trying to execute the last action {$ex->getMessage()}", 'code' => $ex->getCode(), 'file' => $ex->getFile(), 'line' => $ex->getLine(), 'trace' => $ex->getTrace(), 'exception_type' => get_class($ex))));
     }
     //If we changed the session language and no widget willfully changed it as well, reset it to the previous state
     if ($sPrevSessionLanguage !== null && Session::language() === $sSetSessionLanguage) {
         $oSession->setLanguage($sPrevSessionLanguage);
     }
 }
 /**
  * The render method for the login page type. When on a login page type, this is given the login action as determined by the page type. Can be either null (default), 'password_forgotten', or 'password_reset' (or any other string of which a template "$sLoginType_action_$sAction" exists).
  *
  */
 public function renderFrontend($sAction = 'login')
 {
     $aOptions = @unserialize($this->getData());
     $sLoginType = isset($aOptions[self::MODE_SELECT_KEY]) ? $aOptions[self::MODE_SELECT_KEY] : 'login';
     $this->oUser = Session::getSession()->getUser();
     if ($this->oUser) {
         $sAction = 'logout';
     }
     $oTemplate = $this->constructTemplate($sLoginType);
     if ($oTemplate->hasIdentifier('function_template')) {
         $oFunctionTemplate = null;
         try {
             $oFunctionTemplate = $this->constructTemplate("{$sLoginType}_action_{$sAction}");
         } catch (Exception $e) {
             //Fallback to the default function template for the specified action
             $oFunctionTemplate = $this->constructTemplate("login_action_{$sAction}");
         }
         $oTemplate->replaceIdentifier('function_template', $oFunctionTemplate, null, Template::LEAVE_IDENTIFIERS);
     }
     if ($this->oUser && $this->oPage) {
         $oPage = $this->oPage;
         if (Session::getSession()->hasAttribute('login_referrer_page')) {
             $oPage = Session::getSession()->getAttribute('login_referrer_page');
             Session::getSession()->resetAttribute('login_referrer_page');
         }
         if (!$this->oPage->getIsProtected() || Session::getSession()->getUser()->mayViewPage($this->oPage)) {
             $oTemplate->replaceIdentifier('fullname', Session::getSession()->getUser()->getFullName());
             $oTemplate->replaceIdentifier('name', Session::getSession()->getUser()->getUsername());
             $oTemplate->replaceIdentifier('action', LinkUtil::link(FrontendManager::$CURRENT_NAVIGATION_ITEM->getLink(), null, array('logout' => 'true')));
         } else {
             $oFlash = Flash::getFlash();
             $oFlash->addMessage('login.logged_in_no_access');
         }
     }
     $oTemplate->replaceIdentifier('login_title', TranslationPeer::getString($sAction == 'password_forgotten' ? 'wns.login.password_reset' : 'wns.login'));
     $sOrigin = isset($_REQUEST['origin']) ? $_REQUEST['origin'] : LinkUtil::linkToSelf();
     $oTemplate->replaceIdentifier('origin', $sOrigin);
     if ($sAction !== 'logout') {
         $oLoginPage = $this->oPage ? $this->oPage->getLoginPage() : null;
         $sLink = null;
         if ($oLoginPage === null) {
             $sLink = LinkUtil::link('', 'LoginManager');
         } else {
             $sLink = LinkUtil::link($oLoginPage->getFullPathArray());
         }
         $oTemplate->replaceIdentifier('action', $sLink);
     }
     if ($sAction === 'login') {
         $oLoginPage = $this->oPage ? $this->oPage->getLoginPage() : null;
         $sLink = null;
         if ($oLoginPage === null) {
             $sLink = LinkUtil::link(array(), 'LoginManager', array('password_forgotten' => 'true'));
         } else {
             $sLink = LinkUtil::link($oLoginPage->getFullPathArray(), null, array('password_forgotten' => 'true'));
         }
         $oTemplate->replaceIdentifier('password_forgotten_action', $sLink);
     }
     return $oTemplate;
 }
 public function sendPasswordHint()
 {
     $oUser = UserQuery::create()->findPk($this->iUserId);
     if ($oUser) {
         LoginManager::sendResetMail($oUser, true, LinkUtil::link(array(), 'LoginManager'));
         return $this->iUserId;
     }
     return false;
 }
 public function renderFile()
 {
     $mMaxWidth = is_numeric(@$_REQUEST['max_width']) ? (int) $_REQUEST['max_width'] : 'full';
     $mMaxHeight = is_numeric(@$_REQUEST['max_height']) ? (int) $_REQUEST['max_height'] : 'full';
     if (!$this->oDocument->isGDImage()) {
         $mMaxWidth = 'full';
         $mMaxHeight = 'full';
     }
     $sCacheString = 'doc_' . $this->oDocument->getId() . '_' . $mMaxWidth . 'x' . $mMaxHeight . (isset($_REQUEST['add_text']) ? '_' . $_REQUEST['add_text'] : "");
     $oCache = new Cache($sCacheString, DIRNAME_IMAGES);
     $sDisplay = "inline";
     if (isset($_REQUEST['download']) && $_REQUEST['download'] == "true") {
         $sDisplay = "attachment";
     }
     header('Content-Disposition: ' . $sDisplay . ';filename="' . $this->oDocument->getFullName() . '"');
     //Don’t base the last-modified off the cache but rather off the document’s updated-at.
     LinkUtil::sendCacheControlHeaders($this->oDocument, $oCache);
     if ($oCache->entryExists() && !$oCache->isOlderThan($this->oDocument)) {
         header("Content-Type: " . $this->oDocument->getDocumentType()->getMimetype());
         $oCache->passContents(true);
         exit;
     }
     $rDataStream = $this->oDocument->getData();
     try {
         if (is_int($mMaxWidth) || is_int($mMaxHeight)) {
             $oImage = Image::imageFromStream($rDataStream);
             if (is_int($mMaxWidth) && is_int($mMaxHeight)) {
                 $oImage->setSize($mMaxWidth, $mMaxHeight, Image::RESIZE_TO_SMALLER_VALUE);
             } else {
                 if (is_int($mMaxWidth)) {
                     $oImage->setSize($mMaxWidth, 0, Image::RESIZE_TO_WIDTH);
                 } else {
                     $oImage->setSize(0, $mMaxHeight, Image::RESIZE_TO_HEIGHT);
                 }
             }
             //Since $bDontBlowUp is true, do a preliminary check whether it’s necessary to even use the image class
             if ($oImage->getScalingFactor() < 1.0) {
                 $oImage->setFileType($this->oDocument->getDocumentType()->getExtension());
                 $oImage->render(true, null, $oCache);
                 exit;
             } else {
                 //Free up space
                 $oImage->destroy();
                 rewind($rDataStream);
             }
         }
     } catch (Exception $ex) {
     }
     //Ignore unrecognized image format
     header("Content-Type: " . $this->oDocument->getDocumentType()->getMimetype());
     header("Content-Length: " . $this->oDocument->getDataSize());
     $oCache->setContents(stream_get_contents($rDataStream));
     rewind($rDataStream);
     fpassthru($rDataStream);
 }
Beispiel #10
0
 private function listInSidebar(Template $oTemplate)
 {
     $aWidgets = Module::listModulesByType(WidgetModule::getType());
     $oLinks = new Template(TemplateIdentifier::constructIdentifier('links'), null, true);
     foreach ($aWidgets as $sWidgetName => $aWidgetInfo) {
         $oLink = new Template('<a href="{{href}}">{{name}}</a><br />', null, true);
         $oLink->replaceIdentifier('href', LinkUtil::link(array($sWidgetName), get_class()));
         $oLink->replaceIdentifier('name', WidgetModule::getDisplayNameByName($sWidgetName));
         $oLinks->replaceIdentifierMultiple('links', $oLink);
     }
     $oTemplate->replaceIdentifierMultiple('sidebar_content', $oLinks);
 }
 public function onFillPageAttributes($oCurrentPage, $oTemplate)
 {
     $oSearchPage = $oCurrentPage->getPageOfType('search_result');
     if ($oSearchPage === null) {
         return;
     }
     $oTemplate->replaceIdentifier("search_action", LinkUtil::link($oSearchPage->getLinkArray()));
     foreach ($oTemplate->identifiersMatching('search_form', Template::$ANY_VALUE) as $oIdentifier) {
         $oSubTemplate = new Template($oIdentifier->getValue() ? $oIdentifier->getValue() : 'default', array(DIRNAME_TEMPLATES, 'search_form'));
         $oSubTemplate->replaceIdentifier("search_action", LinkUtil::link($oSearchPage->getLinkArray()));
         $oTemplate->replaceIdentifier($oIdentifier, $oSubTemplate);
     }
 }
 public function display(Template $oTemplate, $bIsPreview = false)
 {
     $sValue = $this->oPage->getPagePropertyValue('redirect-location', '');
     if (is_numeric($sValue)) {
         $this->oPage = PageQuery::create()->findPk($sValue);
         LinkUtil::redirect(LinkUtil::link($this->oPage->getFullPathArray()), null, 'default', false);
     } else {
         if (!$sValue) {
             throw new Exception('Error in RedirectPageTypeModule->display(): no redirect location set');
         }
     }
     LinkUtil::redirect($sValue, false);
 }
Beispiel #13
0
 public function getLinkToDocumentData()
 {
     $aArray = array();
     if ($this->getDocumentCount() == 0) {
         $aArray[] = TranslationPeer::getString('wns.none');
     } else {
         if ($this->getDocumentCount() === 1) {
             $aArray[] = $this->getDocumentCount() . ' ' . TranslationPeer::getString('wns.document');
         } else {
             $aArray[] = $this->getDocumentCount() . ' ' . TranslationPeer::getString('wns.documents');
         }
     }
     $aArray[] = LinkUtil::link(array('documents'), 'AdminManager', array('document_category_id' => $this->getId()));
     return $aArray;
 }
 private function renderRecentJournalCommentTeaser($mJournalId)
 {
     $oJournalComment = JournalCommentQuery::create()->excludeUnverified()->joinJournalEntry()->useQuery('JournalEntry')->filterByJournalId($mJournalId)->excludeDraft()->endUse()->mostRecentFirst()->findOne();
     if ($oJournalComment === null) {
         return null;
     }
     $oTemplate = $this->constructTemplate('journal_comment_teaser');
     $sHref = LinkUtil::link($oJournalComment->getJournalEntry()->getLink($this->oJournalPage)) . '#comments';
     $oTemplate->replaceIdentifier('title', TagWriter::quickTag('a', array('rel' => 'internal', 'href' => $sHref), $oJournalComment->getJournalEntry()->getTitle()));
     $oTemplate->replaceIdentifier('link_to_detail', $sHref);
     $oTemplate->replaceIdentifier('created_at', $oJournalComment->getCreatedAt('U'));
     $oTemplate->replaceIdentifier('name', $oJournalComment->getUsername());
     $oTemplate->replaceIdentifier('text', $oJournalComment->getText(), null, Template::NO_HTML_ESCAPE);
     return $oTemplate;
 }
 public function renderFile()
 {
     $sCacheString = 'preview_' . $this->oDocumentType->getId() . '_' . $this->iSize;
     $oCache = new Cache($sCacheString, DIRNAME_IMAGES);
     LinkUtil::sendCacheControlHeaders($this->oDocumentType, $oCache);
     if ($oCache->entryExists() && !$oCache->isOlderThan($this->oDocumentType)) {
         header("Content-Type: " . self::MIME_TYPE);
         $oCache->passContents(true);
         exit;
     }
     $sFileName = "{$this->oDocumentType->getDocumentKind()}.png";
     $sFilePath = ResourceFinder::findResource(array(DIRNAME_MODULES, self::getType(), $this->getModuleName(), ResourceIncluder::RESOURCE_TYPE_ICON, $sFileName));
     if ($sFilePath === null) {
         $sFileName = 'default.png';
     }
     $sFilePath = ResourceFinder::findResource(array(DIRNAME_MODULES, self::getType(), $this->getModuleName(), ResourceIncluder::RESOURCE_TYPE_ICON, $sFileName));
     if ($sFilePath === null) {
         throw new Exception("Error in DocumentTypePreviewFileModule->renderFile: type has unknown kind: {$this->oDocumentType->getDocumentKind()}");
     }
     $sFontFilePath = ResourceFinder::findResource(array(DIRNAME_MODULES, self::getType(), $this->getModuleName(), 'PTS55F.ttf'));
     $oImage = Image::imageFromPath($sFilePath);
     if (Image::supportsText()) {
         $sText = strtoupper($this->oDocumentType->getExtension());
         $fFontSize = 72.0;
         $aSize = Image::textSize($sFontFilePath, $sText, $fFontSize);
         $iDesiredWidth = 300;
         $iDesiredHeight = 145;
         $fWidthRatio = $iDesiredWidth / $aSize[0];
         $fHeightRatio = $iDesiredHeight / $aSize[1];
         $fRatio = min($fWidthRatio, $fHeightRatio);
         $fFontSize *= $fRatio;
         $iDesiredPositionX = 107 - 7 * $fRatio;
         $iDesiredPositionY = 338;
         $iStartPositionX = $iDesiredPositionX + ($iDesiredWidth - $aSize[0] * $fRatio) / 2;
         $iStartPositionY = $iDesiredPositionY + $aSize[1] * $fRatio + ($iDesiredHeight - $aSize[1] * $fRatio) / 2;
         $oImage->addText($sFontFilePath, $sText, 1, $fFontSize, 150, 150, 150, $iStartPositionX, $iStartPositionY);
     }
     if ($this->iSize < 512) {
         $oImage->setSize($this->iSize, $this->iSize, Image::STRETCH);
     }
     $oImage->setFileType('png');
     $oImage->render(true, null, $oCache);
     exit;
 }
Beispiel #16
0
 /** __construct()
  * @param string subject
  * @param mixed Template|String
  * @param boolean is html email
  * @param boolean use multi part
  *
  * @return void
  */
 public function __construct($sSubject, $oContent = null, $bIsHtml = false)
 {
     $this->aRecipients = array();
     $this->aCarbonCopyRecipients = array();
     $this->aBlindCarbonCopyRecipients = array();
     if ($oContent instanceof Template) {
         $this->sCharset = $oContent->getCharset();
     } else {
         $this->sCharset = Settings::getSetting('encoding', 'db', 'utf-8');
     }
     $this->sMimeType = 'text/plain';
     if ($bIsHtml) {
         $this->sMimeType = 'text/html';
     }
     $this->oContent = $oContent;
     $this->sSenderName = null;
     $this->sSenderAddress = LinkUtil::getDomainHolderEmail('mailer-daemon');
     $this->oFlash = new Flash();
     $this->sReplyTo = null;
     $this->sSubject = $sSubject;
 }
 public function __construct($oReferencedObject, $sDefaultLanguageId = null)
 {
     $aMessageParameters = array();
     foreach ($oReferencedObject->getReferees() as $oReferee) {
         $oFrom = $oReferee->getFrom();
         $aFrom = array();
         $aFrom["model"] = $oReferee->getFromModelName();
         $aFrom["name"] = Util::descriptionForObject($oFrom, $sDefaultLanguageId);
         if (!$oFrom instanceof LanguageObject) {
             $aFrom["name"] = $aFrom["model"] . ': ' . $aFrom["name"];
         }
         if (method_exists($oFrom, 'getAdminWidget')) {
             $oWidget = $oFrom->getAdminWidget();
             $aFrom["admin_widget"] = array($oWidget->getModuleName(), $oWidget->getSessionKey());
         } elseif (method_exists($oFrom, 'getAdminLink')) {
             $aFrom["admin_link"] = LinkUtil::link($oFrom->getAdminLink(), 'AdminManager');
         }
         $aMessageParameters['references'][] = $aFrom;
     }
     $aMessageParameters['to'] = Util::nameForObject($oReferencedObject);
     parent::__construct('wns.still_referenced.message', $aMessageParameters, null, 0, $sDefaultLanguageId);
 }
Beispiel #18
0
 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);
     }
 }
Beispiel #20
0
 public function renderFile()
 {
     $aCurrentValues = $this->oFormStorage->saveCurrentValuesToSession();
     $oFlash = Flash::getFlash();
     $oFlash->setArrayToCheck($aCurrentValues);
     $bHasCaptcha = false;
     foreach ($this->oFormStorage->getFormObjects() as $oFormObject) {
         if ($oFormObject instanceof CaptchaObject) {
             $bHasCaptcha = true;
         }
         if ($oFormObject->shouldExcludeFromReport()) {
             continue;
         }
         if ($oFormObject->isRequired()) {
             $oFlash->checkForValue($oFormObject->getName());
         }
         $oEmailItemTemplateInstance = clone $this->oEmailItemTemplate;
         $oEmailItemTemplateInstance->replaceIdentifier('name', $oFormObject->getName());
         $oEmailItemTemplateInstance->replaceIdentifier('label', $oFormObject->getLabel());
         $oEmailItemTemplateInstance->replaceIdentifier('value', $oFormObject->getCurrentValue());
         $this->oEmailTemplate->replaceIdentifierMultiple('form_content', $oEmailItemTemplateInstance);
     }
     if ($bHasCaptcha && !FormFrontendModule::validateRecaptchaInput()) {
         $oFlash->addMessage('captcha_code_required');
     }
     $oFlash->finishReporting();
     if (Flash::noErrors()) {
         $oEmail = new EMail(TranslationPeer::getString('wns.form_module.email_subject', null, null, array('page' => $this->sPageName)), $this->oEmailTemplate);
         $oEmail->addRecipient($this->sEmailAddress);
         $oEmail->send();
         $this->oFormStorage->deleteCurrentValuesFromSession();
         LinkUtil::redirect($_REQUEST['origin'] . '?form_success=true');
     } else {
         $oFlash->stick();
         LinkUtil::redirect($_REQUEST['origin']);
     }
 }
Beispiel #21
0
 public function display(Template $oTemplate, $bIsPreview = false)
 {
     if (Manager::isPost()) {
         ArrayUtil::trimStringsInArray($_POST);
     }
     //1st step: user clicked on the recovery link
     //	• Display email field
     if (isset($_REQUEST['password_forgotten'])) {
         $this->sAction = 'password_forgotten';
     }
     //2nd step: user has entered an email address
     //	• Send the email with the recovery link (and generate the hint)
     //	• Add confirmation message to flash
     if (isset($_POST['password_reset_user_name'])) {
         $this->sAction = LoginManager::processPasswordReset(LinkUtil::link($this->oPage->getFullPathArray(), 'FrontendManager'));
     }
     //3rd step: user has clicked on the reset link in the e-mail
     //	• Validate the hint
     //	• Display a form for entering a new password (form also contains hidden fields for email and hint)
     //	• Add the referrer to the session (again)
     if (isset($_REQUEST['recover_username'])) {
         $this->sAction = LoginManager::passwordReset();
     }
     //4th step: user has submitted the new password
     //	• Validate the hint (again)
     //	• Validate password constraints
     //	• Set the new password (if valid)
     //	• Log in (if valid)
     //	• Redirect to the referrer (if valid)
     if (isset($_POST['new_password'])) {
         $this->sAction = LoginManager::loginNewPassword(LinkUtil::link($this->oPage->getFullPathArray()));
     }
     if (isset($_POST[LoginManager::USER_NAME])) {
         LoginManager::login(null, null, LinkUtil::link($this->oPage->getFullPathArray()));
     }
     parent::display($oTemplate, $bIsPreview);
 }
 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;
 }
Beispiel #23
0
 /**
  * Redirects to a page with the given id
  */
 public function __construct()
 {
     parent::__construct();
     $oPage = PageQuery::create()->findPk(Manager::usePath());
     LinkUtil::redirectToManager($oPage->getFullPathArray(), 'FrontendManager');
 }
Beispiel #24
0
 public function getUserLinkData()
 {
     $aArray = array();
     $aArray[] = $this->getUserCount() . ' ' . TranslationPeer::getString('wns.user');
     $aArray[] = LinkUtil::link(array('users'), 'AdminManager', array('group_id' => $this->getId()));
     return $aArray;
 }
Beispiel #25
0
 public function renderAdmin(Template $oTemplate = null)
 {
     if ($this->sModuleName === null) {
         $this->sModuleName = self::DEFAULT_MODULE;
     }
     try {
         $this->oModule = AdminModule::getModuleInstance($this->sModuleName);
     } catch (Exception $e) {
         LinkUtil::redirect(LinkUtil::link(array(self::DEFAULT_MODULE, 'module_not_found', $this->sModuleName)));
     }
     if (!Module::isModuleAllowed('admin', $this->sModuleName, Session::getSession()->getUser())) {
         LinkUtil::redirect(LinkUtil::link(array(self::DEFAULT_MODULE, 'module_denied', $this->sModuleName)));
     }
     $this->doAdmin($oTemplate);
 }
Beispiel #26
0
 public function getDisplayLink()
 {
     return LinkUtil::link(array('display_newsletter', 'newsletter', $this->getId()), 'FileManager');
 }
 /**
  * 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);
 }
Beispiel #28
0
 /**
  * @deprecated
  */
 public static function getDisplayUrl($iDocumentId, $aUrlParameters = array(), $sFileModule = 'display_document')
 {
     return LinkUtil::link(array($sFileModule, $iDocumentId), "FileManager", $aUrlParameters);
 }
Beispiel #29
0
 /**
  * Sends an expires header.
  * @param $mExpires The expires header to send. Can be one of the following:
  *                     • A DateInterval object
  *                     • A date interval spec in the form of Pxx (http://en.wikipedia.org/wiki/Iso8601#Durations) which will be added to today’s date
  *                     • A UNIX timestamp as an integer
  *                     • A string to be parsed into a date using strtotime
  *                     • A DateTime object
  *                     • A Cache object (which will be asked about the expiresTimestamp)
  *                     • `true` to expire in a year (the maxiumum permitted by RFC2616)
  *                     • `false` to mark as already expired (and to force re-evaluation)
  */
 public static function sendExpires($mTimestamp)
 {
     if (self::$EXPIRES_SENT) {
         return;
     }
     if ($mTimestamp instanceof Cache) {
         $mTimestamp = $mTimestamp->getStrategy()->expiresTimestamp($mTimestamp);
     }
     if ($mTimestamp === true) {
         $mTimestamp = 'P1Y';
     }
     if (is_string($mTimestamp) && substr($mTimestamp, 0, 1) === 'P') {
         $mTimestamp = new DateInterval($mTimestamp);
     }
     if (is_string($mTimestamp)) {
         $mTimestamp = strtotime($mTimestamp);
     }
     if ($mTimestamp === null) {
         return;
     }
     if ($mTimestamp instanceof DateInterval) {
         $oDate = new DateTime('now', new DateTimeZone('UTC'));
         $mTimestamp = $oDate->add($mTimestamp);
     } else {
         if ($mTimestamp instanceof DateTime) {
             $mTimestamp = clone $mTimestamp;
             $mTimestamp->setTimezone(new DateTimeZone('UTC'));
         } else {
             if (is_int($mTimestamp)) {
                 $mTimestamp = new DateTime("@{$mTimestamp}");
             }
         }
     }
     // Format for output
     if ($mTimestamp === false) {
         $mTimestamp = 0;
     } else {
         $mTimestamp = $mTimestamp->format(self::DATE_RFC2616);
     }
     header('Expires: ' . $mTimestamp);
     self::$EXPIRES_SENT = true;
 }
 /**
  * displayNewsletterList()
  * @param int/array subscriber group ids
  * @param boolean detail view link type
  *
  * Description $bDisplayFileLink
  * • true > render link to original newsletter view of get_file/display_newsletter/ analog to alternative view linked in newsletter
  * • false: display database "newsletter_body" only in normal page view
  *
  * @return Template
  */
 private function displayNewsletterList($mSubscriberGroupId, $bDisplayFileLink = true)
 {
     $oQuery = NewsletterQuery::create()->distinct()->filterApprovedForLanguage(Session::language())->orderByCreatedAt(Criteria::DESC);
     if ($mSubscriberGroupId) {
         $oQuery->joinNewsletterMailing()->useQuery('NewsletterMailing')->filterBySubscriberGroupId($mSubscriberGroupId)->endUse();
     }
     $aRecentNewsletters = $oQuery->limit(10)->find();
     $bHasNewsletters = count($aRecentNewsletters) > 0;
     $oTemplate = $this->constructTemplate('newsletter_display_list');
     if ($bHasNewsletters === false) {
         $oTemplate->replaceIdentifier('newsletter_item', TagWriter::quickTag('p', array('class' => 'no_result_message'), TranslationPeer::getString('wns.newsletter.no_newsletter_available')));
     }
     if ($bDisplayFileLink) {
         $oItemPrototype = $this->constructTemplate('newsletter_list_item_file_module');
     } else {
         $this->setNewsletter($mSubscriberGroupId);
         $oItemPrototype = $this->constructTemplate('newsletter_list_item');
     }
     $oPage = FrontendManager::$CURRENT_PAGE;
     foreach ($aRecentNewsletters as $oNewsletter) {
         $oItemTemplate = clone $oItemPrototype;
         $oItemTemplate->replaceIdentifier('subject', $oNewsletter->getSubject());
         if ($bDisplayFileLink) {
             $oItemTemplate->replaceIdentifier('newsletter_link', $oNewsletter->getDisplayLink());
         } else {
             if ($oNewsletter === self::$NEWSLETTER) {
                 $oItemTemplate->replaceIdentifier('class_active', ' class="active"', null, Template::NO_HTML_ESCAPE);
             }
             $oItemTemplate->replaceIdentifier('newsletter_link', LinkUtil::link($oPage->getFullPathArray(array(self::IDENTIFIER_DETAIL, $oNewsletter->getId()))));
         }
         $oItemTemplate->replaceIdentifier('date', $oNewsletter->getLastSent());
         $oItemTemplate->replaceIdentifier('template_name', $oNewsletter->getTemplateName());
         $oItemTemplate->replaceIdentifier('language_id', $oNewsletter->getLanguageId());
         $oTemplate->replaceIdentifierMultiple('newsletter_item', $oItemTemplate);
     }
     return $oTemplate;
 }