root/branches/release-26/php/lib/function.mtcclicenserdf.php @ 1174

Revision 1174, 1.9 kB (checked in by bchoate, 23 months ago)

Updated copyright year for source.

  • Property svn:keywords set to Author Date Id Revision
Line 
1<?php
2# Movable Type (r) Open Source (C) 2001-2008 Six Apart, Ltd.
3# This program is distributed under the terms of the
4# GNU General Public License, version 2.
5#
6# $Id$
7
8function smarty_function_mtcclicenserdf($args, &$ctx) {
9    // status: complete
10    // parameters: none
11    $blog = $ctx->stash('blog');
12    $cc = $blog['blog_cc_license'];
13    if (empty($cc)) return '';
14
15    require_once("cc_lib.php");
16    require_once("MTUtil.php");
17    $cc_url = cc_url($cc);
18    $rdf = <<<RDF
19<!--
20<rdf:RDF xmlns="http://web.resource.org/cc/"
21         xmlns:dc="http://purl.org/dc/elements/1.1/"
22         xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
23
24RDF;
25    ## SGML comments cannot contain double hyphens, so we convert
26    ## any double hyphens to single hyphens.
27    $entry = $ctx->stash('entry');
28    if ($entry) {
29        $permalink = $ctx->tag('EntryPermalink');
30        $title = encode_xml(strip_hyphen($entry['entry_title']));
31        $desc = encode_xml(strip_hyphen($ctx->tag('EntryExcerpt')));
32        $creator = encode_xml(strip_hyphen($entry['entry_author_id'] ? $entry['author_name'] : ''));
33        $date = $ctx->_hdlr_date(array('format' => "%Y-%m-%dT%H:%M:%S"), $ctx) . $ctx->tag('BlogTimezone');
34        $rdf .= <<<RDF
35<Work rdf:about="$permalink">
36<dc:title>$title</dc:title>
37<dc:description>$desc</dc:description>
38<dc:creator>$creator</dc:creator>
39<dc:date>$date</dc:date>
40<license rdf:resource="$cc_url" />
41</Work>
42
43RDF;
44    } else {
45        $site_url = $blog['blog_site_url'];
46        if (!preg_match('!/$!', $site_url))
47            $site_url .= '/';
48
49        $title = encode_xml(strip_hyphen($blog['blog_name']));
50        $desc = encode_xml(strip_hyphen($blog['blog_description']));
51        $rdf .= <<<RDF
52<Work rdf:about="$site_url">
53<dc:title>$title</dc:title>
54<dc:description>$desc</dc:description>
55<license rdf:resource="$cc_url" />
56</Work>
57
58RDF;
59    }
60    $rdf .= cc_rdf($cc) . "</rdf:RDF>\n-->\n";
61    return $rdf;
62}
63?>
Note: See TracBrowser for help on using the browser.