Skip to content

Commit

Permalink
MINOR: added translations and fixed formatting and package informatio…
Browse files Browse the repository at this point in the history
…n. (#2078)

git-svn-id: http://svn.silverstripe.com/open/modules/technoratiservice/trunk@102439 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information
wrossiter committed Apr 12, 2010
1 parent c062410 commit f1f153e
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 93 deletions.
8 changes: 6 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Maintainer Contact
Lakshan Perera (Nickname: lperera)
<perera.lakshan (at) gmail (dot) com>

Will Rossiter (Nickname: wrossiter, willr)
<will (at) silverstripe (dot) com>

Requirements
-----------------------------------------------

Expand All @@ -27,7 +30,6 @@ I.e. you will now have the following root folders
assets
mysite
cms
jsparty
sapphire
technoratiservice

Expand All @@ -43,7 +45,9 @@ technoratiservice
5. Add these and visit your public site to reflect the changes

:: NOTE ::
If you are still using deprecated all-in-one mashups module, please remove it before installing this. All other functionalities which were available in mashups module are now available in separate modules. Check - YoutubeService, MetablogService.
If you are still using deprecated all-in-one mashups module, please remove it before installing this.
All other functionalities which were available in mashups module are now available in separate modules.
Check - YoutubeService, MetablogService.

Usage Overview
-----------------------------------------------
Expand Down
37 changes: 19 additions & 18 deletions code/CosmoService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

/**
* Used to get Incoming Links from th Technorati Cosmos query.
Uses
- To generate Incoming Links report in CMS Admin (like in wordpress, or even better)
- Have a list of trackbacks for each blog post.
- Have a stingy blogroll by linking only to the people who have linked to you ;)
* Uses
* - To generate Incoming Links report in CMS Admin (like in wordpress, or even better)
* - Have a list of trackbacks for each blog post.
* - Have a stingy blogroll by linking only to the people who have linked to you ;)
*
* @package technoratiservice
*/
class CosmoService extends RestfulService {

protected $api_key;

function __construct(){
Expand All @@ -23,14 +26,16 @@ function getApiKey(){
}

/**
* Gets the list of incoming links for particular URL as an array.
* Checkout http://www.technorati.com/developers/api/cosmos.html to get an idea of response format.
* @params url - the url of the page to which has incoming links.
* @params type - A value of link returns the freshest links referencing your target URL.
A value of weblog returns the last set of unique weblogs referencing your target URL.
* @params limit - Adjust the size of your result from the default value of 20 to between 1 and 100 results.
* @params start - Adjust the range of your result set. Set this number to larger than zero and you will receive the portion of Technorati's total result set ranging from start to start+limit. The default start value is 1.
*/
* Gets the list of incoming links for particular URL as an array.
* Checkout http://www.technorati.com/developers/api/cosmos.html to get an idea of response format.
*
* @param url - the url of the page to which has incoming links.
* @param type - A value of link returns the freshest links referencing your target URL.
* A value of weblog returns the last set of unique weblogs referencing your target URL.
*
* @param limit - Adjust the size of your result from the default value of 20 to between 1 and 100 results.
* @param start - Adjust the range of your result set. Set this number to larger than zero and you will receive the portion of Technorati's total result set ranging from start to start+limit. The default start value is 1.
*/

function getIncomingLinks($url, $type="", $limit=Null, $start=Null){
$params = array(
Expand All @@ -46,9 +51,5 @@ function getIncomingLinks($url, $type="", $limit=Null, $start=Null){
$results = $this->getValues($response->getBody(), 'document', 'item');

return $results;
}



}
?>
}
}
92 changes: 45 additions & 47 deletions code/MetaBlog.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
<?php

/**
* MetaBlog Page
*
* @package technoratiservice
*/

class MetaBlog extends Page {

static $db = array(
"Tag" => "Varchar",
"TopExcerptSize" => "Int",
"ExcerptSize" => "Int",
"PerPage" => "Int"
"Tag" => "Varchar",
"TopExcerptSize" => "Int",
"ExcerptSize" => "Int",
"PerPage" => "Int"
);

static $defaults = array(
Expand All @@ -16,47 +23,43 @@ class MetaBlog extends Page {

static $icon = "metablogservice/images/technorati";

// add custom fields for metablog page
function getCMSFields($cms) {
$fields = parent::getCMSFields($cms);
$fields->addFieldToTab("Root.Content.Posts", new TextField("Tag","Show posts tagged with :"));
$fields->addFieldToTab("Root.Content.Posts", new NumericField("ExcerptSize","Excerpt length", 100));
$fields->addFieldToTab("Root.Content.Posts", new NumericField("TopExcerptSize","Excerpt length of latest story", 255));
$fields->addFieldToTab("Root.Content.Posts", new NumericField("PerPage","Posts per page", 10));
return $fields;
function getCMSFields($cms) {
$fields = parent::getCMSFields($cms);
$fields->addFieldToTab("Root.Content.Posts", new TextField("Tag",_t('MetaBlog.POSTSTAGGEDWITH','Show posts tagged with :')));
$fields->addFieldToTab("Root.Content.Posts", new NumericField("ExcerptSize",_t('MetaBlog.EXCERPTSIZE','Excerpt length'), 100));
$fields->addFieldToTab("Root.Content.Posts", new NumericField("TopExcerptSize", _t('MetaBlog.TOPEXCERPTSIZE','Excerpt length of latest story'), 255));
$fields->addFieldToTab("Root.Content.Posts", new NumericField("PerPage",_t('MetaBlog.PERPAGE','Posts per page'), 10));
return $fields;
}

function BlogPosts(){
$metablog = new MetablogService();
$page = isset($_GET['page'])? (int)$_GET['page']: 1;
function BlogPosts(){
$metablog = new MetablogService();
$page = isset($_GET['page'])? (int)$_GET['page']: 1;

$posts = $metablog->getPosts($this->Tag, $this->ExcerptSize, $this->TopExcerptSize, $this->PerPage, ($this->PerPage*($page-1))+1);

if($posts){
$postsHTML = "";
foreach($posts as $post){
$postsHTML .= "<div class='metablogPost'>";
$postsHTML .= "<h2><a href='".$post->permalink."'>".$post->title."</a></h2>";
$postsHTML .= "<div class='metablogPostInfo'>";
$postsHTML .= "<span>".$post->created. " - </span><a href='".$post->weblog_url."'>".$post->weblog_name."</a>";
$postsHTML .= "</div>";
$postsHTML .= "<p>".$post->excerpt."...</p>";
$postsHTML .= "</div>";
}
$posts = $metablog->getPosts($this->Tag, $this->ExcerptSize, $this->TopExcerptSize, $this->PerPage, ($this->PerPage*($page-1))+1);

if($posts){
$postsHTML = "";
foreach($posts as $post) {
$postsHTML .= "<div class='metablogPost'>";
$postsHTML .= "<h2><a href='".$post->permalink."'>".$post->title."</a></h2>";
$postsHTML .= "<div class='metablogPostInfo'>";
$postsHTML .= "<span>".$post->created. " - </span><a href='".$post->weblog_url."'>".$post->weblog_name."</a>";
$postsHTML .= "</div>";
$postsHTML .= "<p>".$post->excerpt."...</p>";
$postsHTML .= "</div>";
}

$postsHTML .= "<div class='pages'><div class='paginator'>";
$postsHTML .= $metablog->getPages();
$postsHTML .= "</div><span class='results'>(".$metablog->getTotalPosts()." Posts)</span></div>";
}
else {
$postsHTML .= "<span>Sorry! No Posts Available.</span>";
}
$postsHTML .= "<div class='pages'><div class='paginator'>";
$postsHTML .= $metablog->getPages();
$postsHTML .= "</div><span class='results'>(" . sprintf(_t('MetaBlog.NUMBEROFPOSTS',"%s Posts"),$metablog->getTotalPosts()) .")</span></div>";
}
else {
$postsHTML .= "<span>" . _t('MetaBlog.NOPOSTS','Sorry! No Posts Available.') . "</span>";
}

//Debug::show($posts);
return $postsHTML;
}

return $postsHTML;
}
}

class MetaBlog_Controller extends Page_Controller {
Expand All @@ -72,11 +75,6 @@ function init() {
}

function Content(){
return $this->Content.$this->BlogPosts();
}



}

?>
return $this->Content.$this->BlogPosts();
}
}
50 changes: 24 additions & 26 deletions code/MetablogService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

/**
* Used to create a meta blog using posts returned by Technorati for specific Tags
*
* @package technoratiservice
*/

class MetablogService extends RestfulService {
private static $api_key;
private $postCount;
Expand All @@ -13,15 +16,15 @@ function __construct($expiry=NULL){
$this->checkErrors = true;
}

/*
This will return API specific error messages.
*/
/**
* This will return API specific error messages.
*/
function errorCatch($response){
$err_msg = $this->searchValue($response, "//result/error");
if($err_msg)
user_error("Technorati Service Error : $err_msg", E_USER_ERROR);
else
return $response;
if($err_msg)
user_error(sprintf(_t('MetablogService.TECHNORATIERROR',"Technorati Service Error : %s"),$err_msg), E_USER_ERROR);
else
return $response;
}

static function setApiKey($key){
Expand All @@ -33,14 +36,15 @@ function getApiKey(){
}

/**
* Gets the list of blog posts which is tagged with specified keyword as an array.
* Checkout http://www.technorati.com/developers/api/tag.html to get an idea of response format.
* @params tag - the tag you like to find the posts.
* @params type - A value of link returns the freshest links referencing your target URL.
A value of weblog returns the last set of unique weblogs referencing your target URL.
* @params limit - Adjust the size of your result from the default value of 20 to between 1 and 100 results.
* @params start - Adjust the range of your result set. Set this number to larger than zero and you will receive the portion of Technorati's total result set ranging from start to start+limit. The default start value is 1.
*/
* Gets the list of blog posts which is tagged with specified keyword as an array.
* Checkout http://www.technorati.com/developers/api/tag.html to get an idea of response format.
*
* @param tag - the tag you like to find the posts.
* @param type - A value of link returns the freshest links referencing your target URL.
* @param A value of weblog returns the last set of unique weblogs referencing your target URL.
* @param limit - Adjust the size of your result from the default value of 20 to between 1 and 100 results.
* @param start - Adjust the range of your result set. Set this number to larger than zero and you will receive the portion of Technorati's total result set ranging from start to start+limit. The default start value is 1.
**/

function getPosts($tag, $excerpt=100, $topexcerpt=150, $perpage=20, $start=Null){
$params = array(
Expand All @@ -63,7 +67,7 @@ function getPosts($tag, $excerpt=100, $topexcerpt=150, $perpage=20, $start=Null)
}

function Paginate(){
$current_url = Controller::curr()->Link();
$current_url = Controller::curr()->Link();

$current_page = isset($_GET['page'])? (int)$_GET['page']: 1;;
$last_page = $this->pageCount;
Expand All @@ -72,7 +76,7 @@ function Paginate(){

if($current_page > 1){
$qs = http_build_query(array('page' => $current_page - 1));
$pagelist = "<a href='$current_url?$qs' class='prev'>&lt; Previous</a>";
$pagelist = "<a href='$current_url?$qs' class='prev'>" . _t('MetablogService.PREV','&lt; Previous') . "</a>";
}

if($current_page < 6)
Expand All @@ -97,11 +101,9 @@ function Paginate(){

if ($current_page < $last_page){
$qs = http_build_query(array('page' => $current_page + 1));
$pagelist .= "<a href='$current_url?$qs' class='next'>Next &gt;</a>";
$pagelist .= "<a href='$current_url?$qs' class='next'>" . _t('MetablogService.NEXT','Next &gt;') . "/a>";
}


//Debug::show($pagination);
return $pagelist;
}

Expand All @@ -111,9 +113,5 @@ function getPages(){

function getTotalPosts(){
return $this->postCount;
}



}
?>
}
}

0 comments on commit f1f153e

Please sign in to comment.