Exemplo n.º 1
0
 function testParseURLs()
 {
     // adapted test cases from brevity (Known requires the http(s) prefix)
     $testcases = [["expected" => "This links to a weird domain <a href=\"http://deals.blackfriday\">http:/<wbr />/<wbr />deals.blackfriday</a>.", "text" => "This links to a weird domain http://deals.blackfriday."], ["expected" => "<a href=\"http://starts.with.a.link\">http:/<wbr />/<wbr />starts.with.a.link</a> and ends with <a href=\"https://kylewm.com/about#me\">HTML</a>.", "text" => "http://starts.with.a.link and ends with <a href=\"https://kylewm.com/about#me\">HTML</a>."], ["expected" => "a matched parenthesis: <a href=\"http://wikipedia.org/Python_(programming_language)\">http:/<wbr />/<wbr />wikipedia.org/<wbr />Python_(programming_language)</a> and (an unmatched parenthesis <a href=\"https://en.wikipedia.org/wiki/Guido_van_Rossum\">https:/<wbr />/<wbr />en.wikipedia.org/<wbr />wiki/<wbr />Guido_van_Rossum</a>)", "text" => "a matched parenthesis: http://wikipedia.org/Python_(programming_language) and (an unmatched parenthesis https://en.wikipedia.org/wiki/Guido_van_Rossum)"]];
     $t = new Template();
     foreach ($testcases as $testcase) {
         $this->assertEquals($testcase['expected'], $t->parseURLs($testcase['text']));
     }
 }
Exemplo n.º 2
0
 /**
  * Retrieve all posts as an RSS feed
  * @param bool|true $hide_private Should we hide private posts? Default: true.
  * @param string $user_uuid User UUID to export for. Default: all users.
  * @return bool|false|string
  */
 static function getExportRSS($hide_private = true, $user_uuid = '')
 {
     $types = \Idno\Common\ContentType::getRegisteredClasses();
     if ($hide_private) {
         $groups = ['PUBLIC'];
     } else {
         $groups = [];
     }
     if (!empty($user_uuid)) {
         $search = ['owner' => $user_uuid];
         if ($user = User::getByUUID($user_uuid)) {
             $title = $user->getTitle();
             $description = $user->getDescription();
             $base_url = $user_uuid;
         }
     } else {
         $search = [];
         $title = Idno::site()->config()->getTitle();
         $description = Idno::site()->config()->getDescription();
         $base_url = Idno::site()->config()->getDisplayURL();
     }
     if ($feed = \Idno\Common\Entity::getFromX($types, $search, array(), PHP_INT_MAX - 1, 0, $groups)) {
         $rss_theme = new Template();
         $rss_theme->setTemplateType('rss');
         return $rss_theme->__(array('title' => $title, 'description' => $description, 'body' => $rss_theme->__(array('items' => $feed, 'offset' => 0, 'count' => sizeof($feed), 'subject' => [], 'nocdata' => true, 'base_url' => $base_url))->draw('pages/home')))->drawPage(false);
     }
     return false;
 }