GetURL() public static method

public static GetURL ( $publicationId, $languageId = null, $issueNo = null, $sectionNo = null, $articleNo = null )
Esempio n. 1
0
 /**
  * Log article related event.
  *
  * @param Article $p_article
  * @param string $p_text
  * @param int $p_userId
  * @param int $p_eventId
  * @param bool $p_short
  *
  * @return void
  */
 public static function ArticleMessage(Article $p_article, $p_text, $p_userId = NULL, $p_eventId = 0, $p_short = FALSE)
 {
     ob_start();
     echo getGS('Article'), ': ', $p_article->getTitle();
     if (!$p_short) {
         // add publication, issue, section
         echo ' (';
         echo getGS('Publication'), ': ', $p_article->getPublicationId();
         echo ', ';
         echo getGS('Issue'), ': ', $p_article->getIssueNumber();
         echo ', ';
         echo getGS('Section'), ': ', $p_article->getSectionNumber();
         echo ")\n";
     }
     // generate url
     $url = ShortURL::GetURL($p_article->getPublicationId(), $p_article->getLanguageId(), $p_article->getIssueNumber(), $p_article->getSectionNumber(), $p_article->getArticleNumber());
     if (strpos($url, 'http') !== FALSE) {
         // no url for deleted
         echo getGS('Article URL'), ': ', $url, "\n";
     }
     echo getGS('Article Number'), ': ', $p_article->getArticleNumber(), "\n";
     echo getGS('Language'), ': ', $p_article->getLanguageName(), "\n";
     echo "\n";
     echo getGS('Action') . ': ', $p_text;
     $message = ob_get_clean();
     self::Message($message, $p_userId, $p_eventId);
 }
Esempio n. 2
0
 /**
  * Log article related event.
  *
  * @param Article $p_article
  * @param string $p_text
  * @param int $p_userId
  * @param int $p_eventId
  * @param bool $p_short
  *
  * @return void
  */
 public static function ArticleMessage(Article $p_article, $p_text, $p_userId = NULL, $p_eventId = 0, $p_short = FALSE)
 {
     ob_start();
     $translator = \Zend_Registry::get('container')->getService('translator');
     echo $translator->trans('Article'), ': ', $p_article->getTitle();
     if (!$p_short) {
         // add publication, issue, section
         echo ' (';
         echo $translator->trans('Publication'), ': ', $p_article->getPublicationId();
         echo ', ';
         echo $translator->trans('Issue'), ': ', $p_article->getIssueNumber();
         echo ', ';
         echo $translator->trans('Section'), ': ', $p_article->getSectionNumber();
         echo ")\n";
     }
     // generate url
     $url = ShortURL::GetURL($p_article->getPublicationId(), $p_article->getLanguageId(), $p_article->getIssueNumber(), $p_article->getSectionNumber(), $p_article->getArticleNumber());
     if (strpos($url, 'http') !== FALSE) {
         // no url for deleted
         echo $translator->trans('Article URL', array(), 'api'), ': ', $url, "\n";
     }
     echo $translator->trans('Article Number', array(), 'api'), ': ', $p_article->getArticleNumber(), "\n";
     echo $translator->trans('Language'), ': ', $p_article->getLanguageName(), "\n";
     echo "\n";
     echo $translator->trans('Action') . ': ', $p_text;
     $message = ob_get_clean();
     self::Message(substr($message, 0, 254), $p_userId, $p_eventId);
 }
 /**
  * Send request to refresh article cache on Facebook
  *
  * @param int $number
  * @param int $languageId
  *
  * @return mixed response from Facebook about url, or array with error message
  */
 private function clearpageCache($number, $languageId)
 {
     $article = new \Article($languageId, $number);
     if (!$article->isPublished()) {
         return array('message' => $this->get('translator')->trans('fb.label.errornot'));
     }
     $url = \ShortURL::GetURL($article->getPublicationId(), $article->getLanguageId(), $article->getIssueNumber(), $article->getSectionNumber(), $article->getArticleNumber());
     try {
         $curlClient = new \Buzz\Client\Curl();
         $curlClient->setTimeout(10000);
         $browser = new \Buzz\Browser($curlClient);
         $result = $browser->post('https://graph.facebook.com/?id=' . $url . '&scrape=true');
         $urlInfo = json_decode($result->getContent(), true);
     } catch (\Buzz\Exception\ClientException $e) {
         return array('message' => $this->get('translator')->trans('fb.label.error'));
     }
     return $urlInfo;
 }
 /**
  * @Route("/plugin/articlescalendar/articlesoftheday/get")
  */
 public function getArticlesOfTheDayAction(Request $request)
 {
     $em = $this->container->get('em');
     $lastArticleOfTheDay = $em->getRepository('Newscoop\\ArticlesCalendarBundle\\Entity\\ArticleOfTheDay')->createQueryBuilder('a')->where('a.is_active = true')->orderBy('a.created_at', 'DESC')->setMaxResults(1)->getQuery()->getSingleResult();
     $response = new Response();
     $response->setLastModified($lastArticleOfTheDay->getCreatedAt());
     $response->setPublic();
     if ($response->isNotModified($request)) {
         return $response;
     }
     $articleOfTheDayService = $this->container->get('newscoop_articles_calendar.articles_calendar_service');
     $settings = $em->getRepository('Newscoop\\ArticlesCalendarBundle\\Entity\\Settings')->findOneBy(array('is_active' => true));
     $publicationNumbers = explode(',', $request->get('publication_numbers', $settings->getPublicationNumbers()));
     $renditionName = $request->get('renditionName', $settings->getRendition());
     $imageWidth = $request->get('image_width', $settings->getImageWidth());
     $imageHeight = $request->get('image_height', $settings->getImageHeight());
     $start = $request->get('start');
     $end = $request->get('end');
     $query = "";
     foreach ($publicationNumbers as $value) {
         $query .= "a.publicationNumbers LIKE '" . $value . "%' OR ";
     }
     $articlesOfTheDay = $articleOfTheDayService->getArticleOfTheDay(new \DateTime($start), new \DateTime($end), $query);
     $results = array();
     foreach ($articlesOfTheDay as $dayArticle) {
         $element = array();
         $articleNumber = $dayArticle['articleNumber'];
         $image = $this->container->get('image.rendition')->getArticleRenditionImage($articleNumber, $renditionName, $imageWidth ? $imageWidth : null, $imageHeight ? $imageHeight : null);
         $element['title'] = $dayArticle['name'];
         if (isset($image)) {
             $element['image'] = $this->container->get('zend_router')->assemble(array('src' => $image['src']), 'image', true, false);
         } else {
             $element['image'] = null;
         }
         $date = $dayArticle['date']->format('Y-m-d');
         $date = explode(" ", $date);
         $YMD = explode("-", $date[0]);
         $element['date'] = array("year" => intval($YMD[0]), "month" => intval($YMD[1]), "day" => intval($YMD[2]));
         $element['url'] = \ShortURL::GetURL($dayArticle['publicationId'], $dayArticle['articleLanguageId'], null, null, $articleNumber);
         $results[] = $element;
     }
     $response->setContent(json_encode(array('articles' => $results)));
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }
Esempio n. 5
0
{
	$_SERVER['SERVER_PORT'] = 80;
}
$scheme = $_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://';
$siteAlias = new Alias($publicationObj->getDefaultAliasId());
$websiteURL = $scheme.$siteAlias->getName() . $GLOBALS['Campsite']['SUBDIR'];

$accessParams = "LoginUserId=" . $g_user->getUserId() . "&LoginUserKey=" . $g_user->getKeyId()
				. "&AdminAccess=all";
if ($publicationObj->getUrlTypeId() == 1) {
	$templateObj = new Template($templateId);
	$url = "$websiteURL/tpl/" . $templateObj->getName() . "?IdLanguage=$f_language_id"
		. "&IdPublication=$f_publication_id&NrIssue=$f_issue_number&NrSection=$f_section_number"
		. "&NrArticle=$f_article_number&$accessParams";
} else {
	$url = ShortURL::GetURL($f_publication_id, $f_language_selected, null, null, $f_article_number);
	if (PEAR::isError($url)) {
		$errorStr = $url->getMessage();
	}
	$url .= '?' . $accessParams;
}

$selectedLanguage = (int)CampRequest::GetVar('f_language_selected');
$url .= "&previewLang=$selectedLanguage";
$siteTitle = (!empty($Campsite['site']['title'])) ? htmlspecialchars($Campsite['site']['title']) : putGS("Newscoop") . $Campsite['VERSION'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en" xml:lang="en">
<head>
  <title><?php p($siteTitle); ?></title>
</head>
Esempio n. 6
0
  </div>
</div>
<?php 
    camp_html_copyright_notice();
    return;
}
// Get proper URL to switch between modes
if ($articleObj->userCanModify($g_user)) {
    $switchModeUrl = camp_html_article_url($articleObj, $f_language_id, 'edit.php') . '&f_edit_mode=' . ($inEditMode ? 'view' : 'edit');
}
// Display either the "Go to live article" or "Preview" button
// depending on article status
$doPreviewLink = '';
if (isset($publicationObj) && $articleObj->isPublished()) {
    if ($publicationObj->getUrlTypeId() == 2) {
        $previewLinkURL = ShortURL::GetURL($publicationObj->getPublicationId(), $articleObj->getLanguageId(), null, null, $articleObj->getArticleNumber());
        $doPreviewLink = 'live';
        $seoFields = $publicationObj->getSeo();
        $articleEndLink = $articleObj->getSEOURLEnd($seoFields, $articleObj->getLanguageId());
        if (strlen($articleEndLink) > 0) {
            $previewLinkURL .= $articleEndLink;
        }
        if (!is_string($previewLinkURL) && PEAR::isError($previewLinkURL)) {
            $doLiveLink = '';
        }
    }
} else {
    if (isset($publicationObj) && 0 < $f_publication_id && 0 < $f_issue_number && 0 < $f_section_number) {
        $doPreviewLink = 'preview';
        $previewLinkURL = "/{$ADMIN}/articles/preview.php?f_publication_id={$f_publication_id}" . "&f_issue_number={$f_issue_number}&f_section_number={$f_section_number}" . "&f_article_number={$f_article_number}&f_language_id={$f_language_id}&f_language_selected={$f_language_selected}";
    }
Esempio n. 7
0
 protected function getUrl()
 {
     return ShortURL::GetURL($this->m_dbObject->getPublicationId(), $this->m_dbObject->getLanguageId(), null, null, $this->m_dbObject->getArticleNumber());
 }