guid() public method

public guid ( $guid, $isPermalink = false )
Beispiel #1
0
 public function testGuid_with_permalink()
 {
     $item = new Item();
     $item->guid('guid', true);
     $this->assertAttributeSame(true, 'isPermalink', $item);
     $item->guid('guid', false);
     $this->assertAttributeSame(false, 'isPermalink', $item);
     $item->guid('guid');
     // default
     $this->assertAttributeSame(false, 'isPermalink', $item);
 }
Beispiel #2
0
function CreateRSSFeed($projectid)
{
    // Checks
    if (!isset($projectid) || !is_numeric($projectid)) {
        echo 'Not a valid projectid!';
        return;
    }
    // Find the project name
    $project = pdo_query("SELECT public,name FROM project WHERE id='{$projectid}'");
    $project_array = pdo_fetch_array($project);
    $projectname = $project_array['name'];
    // Don't create RSS feed for private projects
    if ($project_array['public'] != 1) {
        return;
    }
    global $CDASH_ROOT_DIR;
    $filename = $CDASH_ROOT_DIR . '/public/rss/SubmissionRSS' . $projectname . '.xml';
    $currentURI = get_server_URI();
    $currenttime = time();
    $feed = new Feed();
    $channel = new Channel();
    $channel->title("CDash for {$projectname}")->url("{$currentURI}/index.php?project={$projectname}")->description("Recent CDash submissions for {$projectname}")->language('en-US')->lastBuildDate($currenttime)->appendTo($feed);
    // Get the last 24hrs submissions
    $beginning_timestamp = $currenttime - 24 * 3600;
    $end_timestamp = $currenttime;
    $builds = pdo_query("SELECT * FROM build\n                         WHERE UNIX_TIMESTAMP(starttime)<{$end_timestamp} AND UNIX_TIMESTAMP(starttime)>{$beginning_timestamp}\n                         AND projectid='{$projectid}'\n                         ");
    while ($build_array = pdo_fetch_array($builds)) {
        $siteid = $build_array['siteid'];
        $buildid = $build_array['id'];
        $site_array = pdo_fetch_array(pdo_query("SELECT name FROM site WHERE id='{$siteid}'"));
        // Find the number of errors and warnings
        $nerrors = $build_array['builderrors'];
        $nwarnings = $build_array['buildwarnings'];
        $nnotrun = $build_array['testnotrun'];
        $nfail = $build_array['testfailed'];
        $title = 'CDash(' . $projectname . ') - ' . $site_array['name'] . ' - ' . $build_array['name'] . ' - ' . $build_array['type'];
        $title .= ' - ' . $build_array['submittime'] . ' - ' . $nerrors . ' errors, ' . $nwarnings . ' warnings, ' . $nnotrun . ' not run, ' . $nfail . ' failed.';
        // Should link to the errors...
        $link = $currentURI . '/buildSummary.php?buildid=' . $buildid;
        $description = 'A new ' . $build_array['type'] . ' submission from ' . $site_array['name'] . ' - ' . $build_array['name'] . ' is available: ';
        $description .= $nerrors . ' errors, ' . $nwarnings . ' warnings, ' . $nnotrun . ' not run, ' . $nfail . ' failed.';
        $item = new Item();
        $item->guid($currentURI . '/buildSummary.php?buildid=' . $buildid)->title($title)->url($link)->description($description)->pubDate($currenttime)->appendTo($channel);
    }
    if (file_put_contents($filename, $feed) === false) {
        add_log('Cannot write file ' . $filename, 'CreateRSSFeed', LOG_ERR, $projectid);
    }
}
$blogCommentChannel = new Channel();
$blogCommentChannel->title('Jacob Emerick | Blog Comment Feed');
$blogCommentChannel->description('Most recent comments on blog posts of Jacob Emerick');
$blogCommentChannel->url('https://blog.jacobemerick.com');
// todo depends on env
$blogCommentChannel->appendTo($blogCommentFeed);
$query = "\n    SELECT `comment_meta`.`id`, `comment_meta`.`date`, `comment`.`body`, `commenter`.`name`,\n           `post`.`title`, `post`.`category`, `post`.`path`\n    FROM `jpemeric_comment`.`comment_meta`\n    INNER JOIN `jpemeric_comment`.`comment` ON `comment`.`id` = `comment_meta`.`comment`\n    INNER JOIN `jpemeric_comment`.`commenter` ON `commenter`.`id` = `comment_meta`.`commenter` AND\n                                                 `commenter`.`trusted` = :trusted_commenter\n    INNER JOIN `jpemeric_comment`.`comment_page` ON `comment_page`.`id` = `comment_meta`.`comment_page` AND\n                                                    `comment_page`.`site` = :comment_site\n    INNER JOIN `jpemeric_blog`.`post` ON `post`.`path` = `comment_page`.`path` AND\n                                         `post`.`display` = :display_post\n    WHERE `comment_meta`.`display` = :active_comment\n    ORDER BY `comment_meta`.`date` DESC";
$bindings = ['trusted_commenter' => 1, 'comment_site' => 2, 'display_post' => 1, 'active_comment' => 1];
$activeBlogComments = $db->getRead()->fetchAll($query, $bindings);
foreach ($activeBlogComments as $blogComment) {
    $blogCommentItem = new Item();
    $blogCommentItem->title("Comment on '{$blogComment['title']}' from {$blogComment['name']}");
    $url = "https://blog.jacobemerick.com/{$blogComment['category']}/{$blogComment['path']}/";
    $url .= "#comment-{$blogComment['id']}";
    $blogCommentItem->url($url);
    $blogCommentItem->guid($url, true);
    $description = $blogComment['body'];
    $description = strip_tags($description);
    $description = strtok($description, "\n");
    if (strlen($description) > 250) {
        $description = wordwrap($description, 250);
        $description = strtok($description, "\n");
        if (substr($description, -1) != '.') {
            $description .= '&hellip;';
        }
    }
    $description = html_entity_decode($description);
    $description = trim($description);
    $blogCommentItem->description($description);
    $pubDate = new DateTime($blogComment['date']);
    $blogCommentItem->pubDate($pubDate->getTimestamp());