GetURI() public static method

public static GetURI ( $p_publicationId, $p_languageId, $p_issueNo = null, $p_sectionNo = null, $p_articleNo = null )
Example #1
0
 public static function GetURL($p_publicationId, $p_languageId = null, $p_issueNo = null, $p_sectionNo = null, $p_articleNo = NULL, $p_port = null)
 {
     global $g_ado_db;
     global $_SERVER;
     if (is_null($p_port)) {
         if (!isset($_SERVER['SERVER_PORT'])) {
             $_SERVER['SERVER_PORT'] = 80;
         }
         $p_port = $_SERVER['SERVER_PORT'];
     }
     $publicationObj = new Publication($p_publicationId);
     if (!$publicationObj->exists()) {
         return new PEAR_Error(getGS('Publication does not exist.'));
     }
     if (!isset($p_languageId)) {
         $p_languageId = $publicationObj->getDefaultLanguageId();
     }
     $scheme = $_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://';
     $defaultAlias = new Alias($publicationObj->getDefaultAliasId());
     $uri = ShortURL::GetURI($p_publicationId, $p_languageId, $p_issueNo, $p_sectionNo, $p_articleNo);
     if (!is_string($uri) && PEAR::isError($uri)) {
         return $uri;
     }
     return $scheme . $defaultAlias->getName() . $uri;
 }
Example #2
0
 public static function GetURL($publicationId, $languageId = null, $issueNo = null, $sectionNo = null, $articleNo = null)
 {
     $publicationService = \Zend_Registry::get('container')->getService('newscoop.publication_service');
     if ($publicationService->getPublication()) {
         if ($publicationService->getPublication()->getId() == $publicationId) {
             $publication = $publicationService->getPublication();
         } else {
             $em = \Zend_Registry::get('container')->getService('em');
             $publication = $em->getRepository('Newscoop\\Entity\\Publication')->findOneById($publicationId);
             if (!$publication) {
                 throw new \Exception('Publication does not exist.');
             }
         }
     } else {
         $em = \Zend_Registry::get('container')->getService('em');
         $publication = $em->getRepository('Newscoop\\Entity\\Publication')->findOneById($publicationId);
         if (!$publication) {
             throw new \Exception('Publication does not exist.');
         }
     }
     if (!isset($languageId)) {
         $languageId = $publication->getDefaultLanguage()->getId();
     }
     $uri = ShortURL::GetURI($publicationId, $languageId, $issueNo, $sectionNo, $articleNo);
     if (!is_string($uri) && PEAR::isError($uri)) {
         return $uri;
     }
     $scheme = $_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://';
     return $scheme . $publication->getDefaultAlias()->getName() . $uri;
 }
Example #3
0
 /**
  * Send comment notification
  *
  * @param Newscoop\Entity\Comment $comment
  * @param Newscoop\Entity\Article $article
  * @param array                   $authors
  * @param Newscoop\Entity\User    $user
  *
  * @return void
  */
 public function sendCommentNotification(Comment $comment, Article $article, array $authors, User $user = null)
 {
     $publicationService = $this->container->get('newscoop_newscoop.publication_service');
     $templatesService = $this->container->get('newscoop.templates.service');
     $placeholdersService = $this->container->get('newscoop.placeholders.service');
     $preferencesService = $this->container->get('preferences');
     $translator = $this->container->get('translator');
     $emails = array_unique(array_filter(array_map(function ($author) {
         return $author->getEmail();
     }, $authors)));
     $publication = $publicationService->getPublication();
     $moderatorTo = $this->getModeratorEmailIfModerationEnabled($publication, $user);
     $moderatorTo ? $emails['moderator'] = $moderatorTo : null;
     $moderatorFrom = $publication->getModeratorFrom();
     if (empty($emails)) {
         return;
     }
     $smarty = $templatesService->getSmarty();
     $uri = \CampSite::GetURIInstance();
     if ($user) {
         $smarty->assign('username', $user->getUsername());
     } else {
         $smarty->assign('username', $translator->trans('anonymous'));
     }
     $smarty->assign('comment', $comment);
     $smarty->assign('article', new \MetaArticle($article->getLanguageId(), $article->getNumber()));
     $smarty->assign('publication', $uri->getBase());
     $smarty->assign('site', $uri->getBase());
     $smarty->assign('articleLink', \ShortURL::GetURI($article->getPublicationId(), $article->getLanguageId(), $article->getIssueId(), $article->getSectionId(), $article->getNumber()));
     $message = $templatesService->fetchTemplate("email_comment-notify.tpl");
     $this->send($placeholdersService->get('subject'), $message, $emails, $moderatorFrom ?: $preferencesService->EmailFromAddress);
 }