Added api.xml

master
Victor De la Rocha 2008-12-09 23:38:35 +00:00
parent efa6be5163
commit f35a98dc67
2 changed files with 117 additions and 109 deletions

View File

@ -0,0 +1,54 @@
{header Content-type: text/xml; charset=utf-8}
<?xml version="1.0" encoding="UTF-8"?>
<gelato version="1.0">
<tumblelog name="{username}" timezone="{conf.offsetCity}" title="{conf.title}">
{conf.description}
<feeds>
{block $feeds as $feed}
<feed id="{$feed.id_feed}" url="{$feed.url}" import-type="{$feed.type}" next-update-in-seconds="{$feed.getNextUpdate}" title="{$feed.title}" error-text="{$feed.error_text}" />
{/block}
</feeds>
</tumblelog>
<posts start="{start}" total="{total}">
{block $posts as $post}
{if $post.type=='post'}
<post id="{$post.id_post}" url="{$post.url}" type="regular" date="{$post.formatedDate}">
<regular-title>{$post.tit}</regular-title>
<regular-body>{$post.desc}</regular-body>
</post>
{elseif $post.type=='photo'}
<post id="{$post.id_post}" url="{$post.url}" type="photo" date="{$post.formatedDate}">
<photo-caption>{$post.tit}</photo-caption>
<photo-url>{$post.photoPath}</photo-url>
</post>
{elseif $post.type=='quote'}
<post id="{$post.id_post}" url="{$post.url}" type="quote" date="{$post.formatedDate}">
<quote-text>{$post.desc}</quote-text>
<quote-source>{$post.title}</quote-source>
</post>
{elseif $post.type=='url'}
<post id="{$post.id_post}" url="{$post.url}" type="link" date="{$post.formatedDate}">
<link-text>{$post.tit}</link-text>
<link-url>{$post.url}</link-url>
</post>
{elseif $post.type=='conversation'}
<post id="{$post.id_post}" url="{$post.url}" type="conversation" date="{$post.formatedDate}">
<conversation-title>{$post.tit}</conversation-title>
<conversation-text>{$post.desc}</conversation-text>
{$post.descAPIFormat}
</post>
{elseif $post.type=='video'}
<post id="{$post.id_post}" url="{$post.url}" type="video" date="{$post.formatedDate}">
<video-caption>{$post.tit}</video-caption>
<video-source>{$post.url}</video-source>
<video-player>{$post.desc}</video-player>
</post>
{elseif $post.type=='mp3'}
<post id="{$post.id_post}" url="{$post.url}" type="audio" date="{$post.formatedDate}">
<audio-caption>{$post.tit}</audio-caption>
<audio-player>{$post.desc}</audio-player>
</post>
{/if}
{/block}
</posts>
</gelato>

154
api.php
View File

@ -12,17 +12,14 @@ if(!defined('entry')) define('entry',true);
=========================== */ =========================== */
?> ?>
<?php <?php
header("Content-type: text/xml; charset=utf-8");
$isFeed = true; $isFeed = true;
require('entry.php'); require('entry.php');
global $user, $conf, $tumble; global $user, $conf, $tumble;
$f = new feeds(); $f = new feeds();
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; $theme = new themes;
?>
<gelato version="1.0">
<?php
if (isset($_GET["action"]) && $_GET["action"] == "read") { if (isset($_GET["action"]) && $_GET["action"] == "read") {
if (isset($_GET["start"])) { $start = $_GET["start"]; } else { $start = 0; } if (isset($_GET["start"])) { $start = $_GET["start"]; } else { $start = 0; }
if (isset($_GET["total"])) { $total = $_GET["total"]; } else { $total = 20; } if (isset($_GET["total"])) { $total = $_GET["total"]; } else { $total = 20; }
@ -31,121 +28,78 @@ if(!defined('entry')) define('entry',true);
$user = new user(); $user = new user();
$userData = $user->getUserByID(1); $userData = $user->getUserByID(1);
$username = ($userData["name"] == "") ? "gelato" : $userData["name"]; $username = ($userData["name"] == "") ? "gelato" : $userData["name"];
?>
<tumblelog name="<?php echo $username;?>" timezone="<?php echo $conf->offsetCity;?>" title="<?php echo $conf->title;?>">
<?php
echo "\n\t".$conf->description."\n";
?>
<feeds>
<?php
$actual_feeds = $f->getFeedList();
foreach($actual_feeds as $feed){
$error_text = ($feed["error"]>0) ? "false" : "true";
?>
<feed id="<?php echo $feed["id_feed"];?>" url="<?php echo htmlspecialchars($feed["url"]);?>" import-type="<?php echo util::type2Text($feed["type"]);?>" next-update-in-seconds="<? echo $f->getNextUpdate($feed["id_feed"]);?>" title="<?php echo htmlspecialchars($feed["title"]);?>" error-text="<? echo $error_text;?>"/>
<?php
}
?>
</feeds>
</tumblelog>
<?php $theme->set("username",$username);
$theme->set("conf",array(
"offsetCity"=>$conf->offsetCity,
"title"=>$conf->title,
"description"=>$conf->description
));
$feeds = array(); $actual_feeds = $f->getFeedList();
foreach($actual_feeds as $feed){
$error_text = ($feed["error"]>0) ? "false" : "true";
$feed['url'] = htmlspecialchars($feed['url']);
$feed['type'] = util::type2Text($feed['type']);
$feed['getNextUpdate'] = $f->getNextUpdate($feed['id_feed']);
$feed['title'] = htmlspecialchars($feed['title']);
$feed['error_text'] = $error_text;
$feeds[] = $feed;
}
$theme->set("feeds",$feeds);
if ($hasType) { if ($hasType) {
$postType = type2Number($_GET["type"]); $postType = type2Number($_GET["type"]);
} }
$rs = $tumble->getPosts($total, $start); $rs = $tumble->getPosts($total, $start);
if ($db->contarRegistros()>0) { if ($db->contarRegistros()>0) {
?> $theme->set("start",$start);
<posts start="<?php echo $start; ?>" total="<?php echo $total; ?>"> $theme->set("total",$total);
<?php
while($register = mysql_fetch_array($rs)) { while($post = mysql_fetch_assoc($rs)){
$desc = util::trimString($register["description"]); $post['desc'] = util::trimString($post["description"]);
$strEnd = ($conf->urlFriendly) ? "/" : ""; $strEnd = ($conf->urlFriendly) ? "/" : "";
$url = $conf->urlGelato.($conf->urlFriendly ? "/post/" : "/index.php?post=").$register["id_post"].$strEnd; $post['url'] = $conf->urlGelato.($conf->urlFriendly ? "/post/" : "/index.php?post=").$post["id_post"].$strEnd;
$formatedDate = gmdate("D, d M Y H:i:s", strtotime($register["date"]) + util::transform_offset($conf->offsetTime)); $post['formatedDate'] = gmdate("D, d M Y H:i:s", strtotime($post["date"]) + util::transform_offset($conf->offsetTime));
switch ($register["type"]) { $post['type'] = util::type2Text($post["type"]);
case "1":
$tit = (empty($register["title"])) ? $desc : strip_tags($register["title"]); switch ($post["type"]) {
?> case "post":
<post id="<?php echo $register["id_post"]; ?>" url="<?php echo $url;?>" type="regular" date="<?php echo $formatedDate;?>"> $post['tit'] = (empty($post["title"])) ? $desc : strip_tags($post["title"]);
<regular-title><?php echo $tit;?></regular-title>
<regular-body><?php echo $desc;?></regular-body>
</post>
<?php
break; break;
case "2": case "photo":
$tit = (empty($register["description"])) ? "Photo" : $desc; $post['photoPath'] = str_replace("../", $conf->urlGelato."/", $post["url"]);
?> $post['tit'] = stripslashes(((empty($post["description"])) ? "Photo" : $post['desc']));
<post id="<?php echo $register["id_post"]; ?>" url="<?php echo $url;?>" type="photo" date="<?php echo $formatedDate;?>">
<?php
$photoPath = str_replace("../", $conf->urlGelato."/", $register["url"]);
?>
<photo-caption><?php echo stripslashes($tit);?></photo-caption>
<photo-url><?php echo $photoPath;?></photo-url>
</post>
<?php
break; break;
case "3": case "quote":
?> $post['title'] = strip_tags($post["title"]);
<post id="<?php echo $register["id_post"]; ?>" url="<?php echo $url;?>" type="quote" date="<?php echo $formatedDate;?>">
<quote-text><?php echo $desc; ?></quote-text>
<quote-source><?php echo strip_tags($register["title"]); ?></quote-source>
</post>
<?php
break; break;
case "4": case "url":
$tit = (empty($register["title"])) ? $register["url"] : strip_tags($register["title"]); $post['tit'] = (empty($post["title"])) ? $post["url"] : strip_tags($post["title"]);
?>
<post id="<?php echo $register["id_post"]; ?>" url="<?php echo $url;?>" type="link" date="<?php echo $formatedDate;?>">
<link-text><?php echo $tit; ?></link-text>
<link-url><?php echo $register["url"]; ?></link-url>
</post>
<?php
break; break;
case "5": case "conversation":
$lines = explode("\n", $desc); $lines = explode("\n", $desc);
$line = $lines[0]; $line = $lines[0];
$tit = (empty($register["title"])) ? trimString($line) : $register["title"]; $post['tit'] = (empty($post["title"])) ? trimString($line) : $post["title"];
$desc = $tumble->formatConversation($desc); $post['desc'] = $tumble->formatConversation($desc);
?> $post['descAPIFormat'] = $tumble->formatConversation($desc);
<post id="<?php echo $register["id_post"]; ?>" url="<?php echo $url;?>" type="conversation" date="<?php echo $formatedDate;?>">
<conversation-title><?php echo $tit; ?></conversation-title>
<conversation-text><?php echo $desc; ?></conversation-text>
<?php echo $tumble->formatApiConversation($desc); ?>
</post>
<?php
break; break;
case "6": case "video":
$tit = (empty($register["description"])) ? "Video" : $desc; $post['tit'] = (empty($post["description"])) ? "Video" : $desc;
$desc = $tumble->getVideoPlayer($register["url"]); $post['desc'] = htmlspecialchars($tumble->getVideoPlayer($post["url"]));
?>
<post id="<?php echo $register["id_post"]; ?>" url="<?php echo $url;?>" type="video" date="<?php echo $formatedDate;?>">
<video-caption><?php echo $tit; ?></video-caption>
<video-source><?php echo $register["url"]; ?></video-source>
<video-player><?php echo htmlspecialchars($desc); ?></video-player>
</post>
<?php
break; break;
case "mp3":
case "7": $post['tit'] = (empty($post["description"])) ? "Audio" : $desc;
$tit = (empty($register["description"])) ? "Audio" : $desc; $desc = htmlspecialchars($tumble->getMp3Player($post["url"]));
$desc = $tumble->getMp3Player($register["url"]);
?>
<post id="<?php echo $register["id_post"]; ?>" url="<?php echo $url;?>" type="audio" date="<?php echo $formatedDate;?>">
<audio-caption><?php echo $tit; ?></audio-caption>
<audio-player><?php echo htmlspecialchars($desc); ?></audio-player>
</post>
<?php
break; break;
} }
$posts[] = $post;
} }
?> $theme->set("posts",$posts);
</posts>
<?php
} }
} }
$theme->display(Absolute_Path.'admin/themes/admin/api.xml');
?> ?>
</gelato>