Example #1
0
 /**
  * Create a URL object from a provided Article
  * @since Version 3.10.0
  * @param \Railpage\News\Article
  * @return \Railpage\Url
  */
 public static function CreateArticleUrl(Article $Article)
 {
     $Url = new Url($Article->makePermaLink($Article->slug));
     $Url->source = $Article->source;
     $Url->reject = sprintf("/news/pending?task=reject&id=%d&queue=newqueue", $Article->id);
     $Url->edit = sprintf("/news?mode=article.edit&id=%d", $Article->id);
     /**
      * Alter the URL
      */
     if (empty($Article->getParagraphs()) && !empty($Article->source)) {
         $Url->url = $Article->source;
         $Url->canonical = $Article->source;
     }
     return $Url;
 }
Example #2
0
 /**
  * Get the formatted lead text for this article
  * @since Version 3.10.0
  * @param \Railpage\News\Article $Article
  * @param string $section The section of the article (lead or paragraphs) to format
  * @return string
  */
 public static function FormatArticleText($Article, $section = "lead")
 {
     $Memcached = AppCore::GetMemcached();
     $cachekey = $section == "lead" ? Article::CACHE_KEY_FORMAT_LEAD : Article::CACHE_KEY_FORMAT_PARAGRAPHS;
     $cachekey = sprintf($cachekey, $Article->id);
     $whitespace_find = array("<p> </p>", "<p></p>", "<p>&nbsp;</p>");
     $whitespace_replace = array("", "", "");
     #$Memcached->delete($cachekey);
     if (!($text = $Memcached->Fetch($cachekey))) {
         $text = $section == "lead" ? $Article->getLead() : $Article->getParagraphs();
         if (function_exists("format_post")) {
             $text = str_replace($whitespace_find, $whitespace_replace, $text);
             $text = format_post($text);
             if (is_object($text)) {
                 $text = $text->__toString();
             }
             $Memcached->save($cachekey, $text, 0);
         }
     }
     return $text;
 }