Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'live'

Conflicts:
	libs/aggregator.php
	libs/scripts/aggregate.php
	sitemap/sitemap.xml
	xsl/atom1.xsl
  • Loading branch information...
commit fd02f877c998ee4aa6304de7ed3291399bc7225f 2 parents 8ffe172 + 9fdedf3
@chregu authored
View
23 libs/aggregator.php
@@ -60,14 +60,17 @@ function aggregateAllBlogs($id = null) {
continue;
}
//check if this blog already exists
- if (isset($feed->channel['atom'])) {
- foreach ($feed->channel['atom'] as $k => $v) {
- if (!isset($feed->channel[$k])) {
- $feed->channel[$k] = $v;
- }
- }
- }
- if (!$feed->channel['link']) {
+ if (isset($feed->channel['atom'])) {
+ foreach($feed->channel['atom'] as $k => $v) {
+ if (!isset($feed->channel[$k])) {
+ $feed->channel[$k] = $v;
+ }
+ }
+ }
+
+
+
+ if (!$feed->channel['link']) {
if (isset($feed->channel['link_'])) {
$feed->channel['link'] = $feed->channel['link_'];
} else if (isset($feed->channel['link_self'])) {
@@ -78,6 +81,10 @@ function aggregateAllBlogs($id = null) {
print "NO channel/link... PLEASE FIX THIS\n";
continue;
}
+
+ }
+ if (isset($feed->channel['link_hub'])) {
+ print "pubsubhubbub found in ".$feed->channel['link'] ." to " . $feed->channel['link_hub'] . "\n";
}
$blog = $this->getBlogEntry($feed->channel['link']);
View
189 libs/lx/notifier.php
@@ -0,0 +1,189 @@
+<?php
+/**
+ Copyright 2009 Liip AG
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ Code partly copied from Padraic Brady's Zend_Feed_Pubsubhubbub
+*/
+
+/**
+ Example
+
+ $noti = new lx_notifier();
+
+ $blogname = "kleiner test";
+ $url = "http://example.org/";
+ $checkurl = $url;
+
+ $mainfeed = $url ."rss.xml";
+ $topicurls = array(
+ $url . 'atom.xml',
+ $mainfeed
+ );
+ $services = array("http://rpc.pingomatic.com/");
+ $noti->addWeblogUpdates(array($mainfeed), $services, $url, $blogname, $checkurl );
+
+ $clouds = array('http://rpc.rsscloud.org:5337/rsscloud/ping');
+ $noti->addRssClouds($topicurls,$clouds);
+
+ $hubs = array("http://pubsubhubbub.appspot.com");
+ $noti->addPubSubHubs($topicurls, $hubs);
+
+ $supid = getSUPId();
+ $noti->addSup("http://friendfeed.com/api/public-sup-ping?supid=" . $supid . "&url=" . $mainfeed);
+
+ $noti->notifyAll();
+
+ */
+
+class lx_notifier {
+
+ protected $multi = null;
+ protected $chs = array();
+
+ public function __construct() {
+ $this->multi = curl_multi_init();
+
+ }
+
+ public function addPubSubHubs($topicUrls = array(), $huburls = array("http://pubsubhubbub.appspot.com")) {
+ $params = array();
+ $params[] = 'hub.mode=publish';
+ $topics = $topicUrls;
+ foreach ($topics as $topicUrl) {
+ $params[] = 'hub.url=' . urlencode($topicUrl);
+ }
+ $paramString = implode('&', $params);
+ $success = 0;
+ foreach ($huburls as $huburl) {
+ $success += $this->_notifyPubSub($paramString, $huburl);
+ }
+ return $success;
+ }
+
+ protected function _notifyPubSub($postdata, $huburl) {
+ $ch = $this->getDefaultCurl($huburl);
+ curl_setopt($ch, CURLOPT_POST, true);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
+ return $this->addCurl($ch);
+ }
+
+
+ public function addWeblogUpdates($topicurls, $pingurls, $url, $name, $checkUrl) {
+ foreach ($topicurls as $topicurl) {
+ foreach ($pingurls as $pingurl) {
+ $this->addWeblogUpdate($topicurl, $pingurl, $url, $name, $checkUrl);
+ }
+ }
+ }
+
+ protected function addWeblogUpdate($topicurl, $pingurl, $url, $name, $checkurl) {
+ $ch = $this->getDefaultCurl($pingurl);
+ $postdata =
+
+ '<?xml version="1.0" encoding="UTF-8"?>
+ <methodCall>
+ <methodName>weblogUpdates.extendedPing</methodName>
+ <params>
+ <param>
+ <value><string>' . htmlspecialchars($name) . '</string></value>
+ </param>
+ <param>
+ <value><string>' . htmlspecialchars($url) . '</string></value>
+ </param>
+ <param>
+ <value><string>' . htmlspecialchars($checkurl) . '</string></value>
+ </param>
+ <param>
+ <value><string>' . htmlspecialchars($topicurl) . '</string></value>
+ </param>
+ </params>
+ </methodCall>';
+
+ curl_setopt($ch, CURLOPT_POST, true);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
+ return $this->addCurl($ch);
+
+ }
+
+ public function addSup($supurl) {
+ $ch = $this->getDefaultCurl($supurl);
+ return $this->addCurl($ch);
+ }
+
+ public function addRssClouds($topicurls, $cloudurls) {
+ foreach ($cloudurls as $url) {
+ foreach ($topicurls as $topicurl) {
+ $this->addRssCloud($topicurl, $url);
+ }
+ }
+ }
+
+ public function addRssCloud($topicurl, $cloudurl) {
+ $ch = $this->getDefaultCurl($cloudurl);
+ $postdata = 'url=' . urlencode($topicurl);
+
+ curl_setopt($ch, CURLOPT_POST, true);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
+ return $this->addCurl($ch);
+ }
+
+
+ protected function getDefaultCurl($url) {
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1);
+ curl_setopt($ch, CURLOPT_HEADER, false);
+ curl_setopt($ch, CURLOPT_TIMEOUT, 2);
+ return $ch;
+ }
+
+ protected function addCurl($ch) {
+ if ($this->multi) {
+ curl_multi_add_handle($this->multi, $ch);
+ $this->chs[] = $ch;
+ } else {
+ curl_exec($ch);
+ $info = curl_getinfo($ch);
+ curl_close($ch);
+ if ($info['http_code'] != 204) {
+ return 0;
+ }
+ }
+ return 1;
+ }
+
+ public function notifyAll() {
+ if ($this->multi) {
+ $running = null;
+ //execute the handles
+ curl_multi_exec($this->multi, $running);
+ while ($running > 0) {
+ usleep(100000); // 1/10 sec
+ curl_multi_exec($this->multi, $running);
+ }
+
+ }
+
+ foreach ($this->chs as $ch) {
+ //error_log(var_Export(curl_getinfo($ch), true));
+ curl_multi_remove_handle($this->multi, $ch);
+ curl_close($ch);
+ }
+ curl_multi_close($this->multi);
+
+ }
+
+}
View
2  libs/magpierss/extlib/Snoopy.class.inc
@@ -75,7 +75,7 @@ class Snoopy
var $response_code = ""; // response code returned from server
var $headers = array(); // headers returned from server sent here
var $maxlength = 500000; // max return data length (body)
- var $read_timeout = 0; // timeout on read operations, in seconds
+ var $read_timeout = 2; // timeout on read operations, in seconds
// supported only since PHP 4 Beta 4
// set to 0 to disallow timeouts
var $timed_out = false; // if a read operation timed out
View
67 libs/popoon/components/generators/planet.php
@@ -19,7 +19,25 @@ function init($attribs)
function DomStart(&$xml)
{
- include_once("MDB2.php");
+
+ include_once("MDB2.php");
+ if ( $redirect = $this->getParameterDefault("redirect")) {
+ $this->db = MDB2::Connect($GLOBALS['BX_config']['dsn']);
+ $id = $this->url2id($redirect);
+ if ($id) {
+ $query = "select link from entries where ID = $id";
+ $link = $this->db->queryOne($query);
+ if ($link) {
+ header("Location: $link", 301);
+ die();
+ }
+ }
+
+ header("Location: http://planet-php.net/", 302);
+ die();
+ }
+
+
if (!isset($GLOBALS['BX_config']['webTimezone'])) {
$GLOBALS['BX_config']['webTimezone'] = $GLOBALS['BX_config']['serverTimezone'];
}
@@ -72,7 +90,7 @@ function DomStart(&$xml)
break;
default:
$xml .= $this->getEntries( $from.$where , $section ,$startEntry);
- $xml .= $this->getEntries( $from." where 1=1", "releases",0);
+ //$xml .= $this->getEntries( $from." where 1=1", "releases",0);
}
@@ -192,11 +210,15 @@ function mdbResult2XML ($res, $rowField, $cdataFields = array()) {
}
$xml .= '</'.$key.'>';
}
+ if ($rowField == 'entry') {
+ $xml .= '<shortid>'.$this->id2url($row['id']) ."</shortid>";
+ }
$xml .= '</'.$rowField.'>';
-
+
}
+
}
else {
@@ -204,6 +226,45 @@ function mdbResult2XML ($res, $rowField, $cdataFields = array()) {
}
return $xml;
}
+
+ protected function url2id($short) {
+ $base = 63;
+ $symbols = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_';
+
+ $len = strlen($short);
+ $total = 0;
+ for ($i = 0; $i < $len;$i++) {
+ $pos = strpos($symbols,$short{$i});
+ $multi = pow($base,$len - $i - 1);
+ $c = $pos * $multi . "\n";
+ $total += $c;
+
+ }
+
+ return $total;
+ }
+
+ protected function id2url($val) {
+ if (0 == $val) {
+ return 0;
+ }
+ $base = 63;
+ $symbols = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_';
+ $result = '';
+ $exp = $oldpow = 1;
+ while ($val > 0 && $exp < 10) {
+
+ $pow = pow($base, $exp++);
+
+ $mod = ($val % $pow);
+ // print $mod ."\n";
+ $result = substr($symbols, $mod / $oldpow, 1) . $result;
+ $val -= $mod;
+ $oldpow = $pow;
+ }
+ return $result;
+ }
+
}
View
60 libs/popoon/components/serializers/json.php
@@ -0,0 +1,60 @@
+<?php
+// +----------------------------------------------------------------------+
+// | popoon |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2001,2002,2003,2004 Bitflux GmbH |
+// +----------------------------------------------------------------------+
+// | Licensed under the Apache License, Version 2.0 (the "License"); |
+// | you may not use this file except in compliance with the License. |
+// | You may obtain a copy of the License at |
+// | http://www.apache.org/licenses/LICENSE-2.0 |
+// | Unless required by applicable law or agreed to in writing, software |
+// | distributed under the License is distributed on an "AS IS" BASIS, |
+// | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
+// | implied. See the License for the specific language governing |
+// | permissions and limitations under the License. |
+// +----------------------------------------------------------------------+
+// | Author: Christian Stocker <chregu@bitflux.ch> |
+// +----------------------------------------------------------------------+
+//
+// $Id: xml.php 3558 2005-02-01 08:15:44Z chregu $
+
+/**
+* Outputs the XML-Document as text
+*
+* @author Christian Stocker <chregu@bitflux.ch>
+* @version $Id: xml.php 3558 2005-02-01 08:15:44Z chregu $
+* @package popoon
+*/
+class popoon_components_serializers_json extends popoon_components_serializer {
+
+ public $XmlFormat = "Own";
+ protected $contentType = "text/plain";
+
+ function __construct (&$sitemap) {
+ $this->sitemap = &$sitemap;
+ }
+
+ function init($attribs) {
+ parent::init($attribs);
+ }
+
+ function DomStart(&$xml)
+ {
+ parent::DomStart($xml);
+ if (is_object($xml))
+ {
+ $this->sitemap->hasFinalDom = true;
+ $xml = str_replace("HTML","html",$xml->saveXML());
+ }
+
+ $xmlstring = '<?xml version="1.0"?>';
+ if (substr($xml,0,strlen($xmlstring)) == $xmlstring) {
+ $xml = substr($xml,strlen($xmlstring));
+ }
+ print str_replace("\n"," ",$xml);
+ }
+}
+
+
+?>
View
60 libs/popoon/components/serializers/text.php
@@ -0,0 +1,60 @@
+<?php
+// +----------------------------------------------------------------------+
+// | popoon |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 2001,2002,2003,2004 Bitflux GmbH |
+// +----------------------------------------------------------------------+
+// | Licensed under the Apache License, Version 2.0 (the "License"); |
+// | you may not use this file except in compliance with the License. |
+// | You may obtain a copy of the License at |
+// | http://www.apache.org/licenses/LICENSE-2.0 |
+// | Unless required by applicable law or agreed to in writing, software |
+// | distributed under the License is distributed on an "AS IS" BASIS, |
+// | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
+// | implied. See the License for the specific language governing |
+// | permissions and limitations under the License. |
+// +----------------------------------------------------------------------+
+// | Author: Christian Stocker <chregu@bitflux.ch> |
+// +----------------------------------------------------------------------+
+//
+// $Id: xml.php 3558 2005-02-01 08:15:44Z chregu $
+
+/**
+* Outputs the XML-Document as text
+*
+* @author Christian Stocker <chregu@bitflux.ch>
+* @version $Id: xml.php 3558 2005-02-01 08:15:44Z chregu $
+* @package popoon
+*/
+class popoon_components_serializers_text extends popoon_components_serializer {
+
+ public $XmlFormat = "Own";
+ protected $contentType = "text/plain";
+
+ function __construct (&$sitemap) {
+ $this->sitemap = &$sitemap;
+ }
+
+ function init($attribs) {
+ parent::init($attribs);
+ }
+
+ function DomStart(&$xml)
+ {
+ parent::DomStart($xml);
+ if (is_object($xml))
+ {
+ $this->sitemap->hasFinalDom = true;
+ $xml = str_replace("HTML","html",$xml->saveXML());
+ }
+
+ $xmlstring = '<?xml version="1.0"?>';
+ if (substr($xml,0,strlen($xmlstring)) == $xmlstring) {
+ $xml = substr($xml,strlen($xmlstring));
+ }
+ print $xml;
+ }
+}
+
+
+?>
View
13 libs/scripts/aggregate.php
@@ -20,3 +20,16 @@
unlink($file);
}
}
+
+$noti = new lx_notifier();
+
+$url = "http://www.planet-php.net/";
+$topicurls = array(
+ $url . 'atom/',
+);
+
+$hubs = array("http://pubsubhubbub.appspot.com");
+$noti->addPubSubHubs($topicurls, $hubs);
+ $noti->notifyAll();
+
+
View
41 public/themes/planet-php/common.xsl
@@ -58,24 +58,7 @@
<xsl:template name="commonRightBoxes">
- <div class="buttons">
- <fieldset>
- <legend>Buttons</legend>
- <img width="80" height="15" src="/themes/img/planet-php-button-1.jpg" alt="Planet PHP"/>
- &#160;
-<img width="80" height="15" src="/themes/img/planet-php-button-2.jpg" alt="Planet PHP"/>
- <br/>
- <img width="80" height="15" src="/themes/img/planet-php-button-3.jpg" alt="Planet PHP"/>
- </fieldset>
- </div>
- <div class="menu">
-
- <fieldset>
- <legend>Contact</legend>
- <a class="blogLinkPad" href="mailto:we@planet-php.net">we@planet-php.net</a>
- </fieldset>
-
- </div>
+
<div class="menu">
@@ -92,13 +75,35 @@
<div class="menu">
<fieldset>
+ <legend>Contact</legend>
+ <a class="blogLinkPad" href="mailto:we@planet-php.net">we@planet-php.net</a>
+ </fieldset>
+
+ </div>
+ <div class="menu">
+
+ <fieldset>
<legend>Sponsors</legend>
<div class="nnbe">Hosted by <a class="inlineBlogLink" href="http://www.netzwirt.ch">netzwirt.ch</a> and <a class="inlineBlogLink" href="http://www.liip.ch">Liip</a>. <br/>
+ Maintained by <a class="inlineBlogLink" href="http://chregu.tv">Chregu Stocker</a>, <a class="inlineBlogLink" href="http://schlitt.info/">Tobias Schlitt</a> and more.<br/>
+
Logo designed by <a class="inlineBlogLink" href="http://viebrock.ca/">Colin Viebrock</a>.
+<br/>
+Twitter account by <a class="inlineBlogLink" href="http://sepehr.ws/">Sepehr Lajevardi</a>
</div>
</fieldset>
</div>
+ <div class="buttons">
+ <fieldset>
+ <legend>Buttons</legend>
+ <img width="80" height="15" src="/themes/img/planet-php-button-1.jpg" alt="Planet PHP"/>
+ &#160;
+<img width="80" height="15" src="/themes/img/planet-php-button-2.jpg" alt="Planet PHP"/>
+ <br/>
+ <img width="80" height="15" src="/themes/img/planet-php-button-3.jpg" alt="Planet PHP"/>
+ </fieldset>
+ </div>
</xsl:template>
<xsl:template match="object" mode="xhtml"> </xsl:template>
View
3  public/themes/planet-php/css/style.css
@@ -141,7 +141,7 @@ a {
#rightcol , #serendipityRightSideBar {
position: absolute;
- top: 100px;
+ top: 10px;
left: 600px;
width: 300px;
}
@@ -173,6 +173,7 @@ a {
.nnbe {
padding-left: 5px;
+ font-size: 12px;
}
.serendipity_comment_source {
View
11 public/themes/planet-php/main.xsl
@@ -43,6 +43,13 @@ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rss="http://purl.o
<a id="searchbarLink" href="javascript:addEngine()">Mozilla Searchbar</a>
</fieldset>
</div>
+ <div class="menu">
+ <fieldset>
+ <legend>Twitter</legend>
+
+ <div class="nnbe">Follow <a class="inlineBlogLink" href="http://twitter.com/planetphp">@planetphp</a> on Twitter</div>
+ </fieldset>
+ </div>
<!--
<div class="menu" >
<fieldset style="padding-right: 0px; ">
@@ -243,12 +250,12 @@ google_color_text = "000000";
</div>
+ <xsl:call-template name="commonRightBoxes"/>
<div class="menu">
<xsl:call-template name="planetarium"/>
</div>
- <xsl:call-template name="commonRightBoxes"/>
- </xsl:template>
+ </xsl:template>
<xsl:template name="htmlheadtitle">
Planet PHP
</xsl:template>
View
16 sitemap/sitemap.xml
@@ -25,6 +25,15 @@
<map:pipeline>
<map:select type="uri">
+ <map:when test="/~">
+ <map:match type="uri" pattern="~*">
+ <map:generate type="planet">
+ <map:parameter name="db" value="config://dsn"/>
+ <map:parameter name="redirect" value="{1}"/>
+ </map:generate>
+ </map:match>
+ </map:when>
+
<map:when test="/search">
<map:match type="uri" pattern="search/*">
<map:generate type="planet">
@@ -66,6 +75,13 @@
<map:transform type="libxslt" src="BX_PROJECT_DIR:///xsl/atom1.xsl"/>
<map:serialize type="xml"/>
</map:when>
+ <map:when test="/json*">
+ <map:transform type="libxslt" src="BX_PROJECT_DIR://xsl/json.xsl">
+ <map:parameter name="cb" value="phpglobals://_GET[cb]" default="0"/>
+ <map:parameter type="options" name="registerPhpFunctions" value="'true'"/>
+ </map:transform>
+ <map:serialize type="json"/>
+ </map:when>
<map:otherwise>
<map:transform type="libxslt" src="BX_PROJECT_DIR:///public/themes/{config://theme}/main.xsl">
View
86 xsl/atom1.xsl
@@ -0,0 +1,86 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:output method="xml" indent="yes" omit-xml-declaration="no"/>
+
+ <xsl:param name="channelLink" select="'http://www.planet-php.net/'"/>
+ <xsl:param name="channelTitle" select="'Planet PHP'"/>
+ <xsl:param name="channelDescription" select="'People blogging about PHP'"/>
+
+
+ <xsl:template match="/">
+
+ <feed xmlns="http://www.w3.org/2005/Atom">
+
+ <title>
+ <xsl:value-of select="$channelTitle"/>
+ </title>
+ <link rel="alternate" type="text/html" href="{$channelLink}"/>
+ <link rel="self" type="text/html" href="{$channelLink}atom/"/>
+ <subtitle>
+ <xsl:value-of select="$channelDescription"/>
+ </subtitle>
+ <id>
+ <xsl:value-of select="$channelLink"/>
+ </id>
+ <generator uri="http://planet-php.net/">
+ Planet PHP Aggregator
+ </generator>
+ <!--<copyright type="text/plain" mode="escaped">All rights reserved, all wrongs reversed. Bring lawyers, guns, and money</copyright>
+ -->
+
+ <updated>
+ <xsl:value-of select="/planet/entries/entry[1]/date_iso"/>
+ </updated>
+ <link rel="hub" href="http://pubsubhubbub.appspot.com"/>
+
+ <xsl:apply-templates select="/planet/entries/entry"/>
+ </feed>
+ </xsl:template>
+
+ <xsl:template match="entries/entry">
+ <entry xmlns="http://www.w3.org/2005/Atom">
+ <title type="text">
+ <xsl:value-of select="title"/>
+ </title>
+ <link rel="alternate" type="text/html" href="{link}" title="{title}"/>
+ <link rel="shortlink" type="text/html" href="http://planet-php.org/~{shortid}" title="Shortlink to {link}"/>
+ <author>
+ <name>
+ <xsl:choose>
+ <xsl:when test="string-length(blog_author) &gt; 0 ">
+ <xsl:value-of select="blog_author"/>
+<xsl:if test="blog_dontshowblogtitle = 0"> (<xsl:value-of select="blog_title"/>) </xsl:if>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="blog_title"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</name>
+ </author>
+ <id>
+ <xsl:value-of select="guid"/>
+ </id>
+ <updated> <xsl:value-of select="date_iso"/></updated>
+ <published><xsl:value-of select="date_iso"/></published>
+
+ <content type="html">
+ <xsl:call-template name="description"/>
+ </content>
+ </entry>
+ </xsl:template>
+
+ <xsl:template name="description">
+ <xsl:choose>
+ <xsl:when test="string-length(content_encoded) > 0">
+ <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
+ <xsl:value-of disable-output-escaping="yes" select="content_encoded"/>
+ <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
+ <xsl:value-of disable-output-escaping="yes" select="description"/>
+ <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+</xsl:stylesheet>
View
45 xsl/json.xsl
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+xmlns:php="http://php.net/xsl"
+>
+ <xsl:output method="xml" indent="no" omit-xml-declaration="no"/>
+
+ <xsl:param name="cb" />
+
+
+ <xsl:template match="/">
+ <xsl:if test="$cb != '0'">
+ <xsl:value-of select="$cb"/>(
+ </xsl:if>[<xsl:apply-templates select="/planet/entries/entry"/>]
+<xsl:if test="$cb != '0'">);
+ </xsl:if>
+</xsl:template>
+
+ <xsl:template match="entries/entry">{"title": <xsl:value-of select="php:functionString('json_encode',title)"/>,
+"link": <xsl:value-of select="php:functionString('json_encode',link)"/>,
+"author": <xsl:choose>
+ <xsl:when test="string-length(blog_author) &gt; 0 ">
+ <xsl:value-of select="php:functionString('json_encode',blog_author)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="php:functionString('json_encode',blog_title)"/>
+ </xsl:otherwise>
+ </xsl:choose>,
+"guid": <xsl:value-of select="php:functionString('json_encode',guid)"/>,
+"updated": <xsl:value-of select="php:functionString('json_encode',date_iso)"/>,
+"content": <xsl:call-template name="description"/>,
+"id": <xsl:value-of select="id"/>
+}<xsl:if test="position() != last()">,</xsl:if>
+ </xsl:template>
+
+ <xsl:template name="description">
+ <xsl:choose>
+ <xsl:when test="string-length(content_encoded) > 0">
+ <xsl:value-of disable-output-escaping="yes" select="php:functionString('json_encode',content_encoded)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of disable-output-escaping="yes" select="php:functionString('json_encode',description)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+</xsl:stylesheet>
Please sign in to comment.
Something went wrong with that request. Please try again.