[pLog-svn] r5352 - in plugins/branches/lifetype-1.2: . twitter twitter/class twitter/class/action twitter/class/twitter twitter/class/view twitter/locale twitter/templates
pwestbro at devel.lifetype.net
pwestbro at devel.lifetype.net
Sat Apr 28 04:55:01 EDT 2007
Author: pwestbro
Date: 2007-04-28 04:55:00 -0400 (Sat, 28 Apr 2007)
New Revision: 5352
Added:
plugins/branches/lifetype-1.2/twitter/
plugins/branches/lifetype-1.2/twitter/class/
plugins/branches/lifetype-1.2/twitter/class/action/
plugins/branches/lifetype-1.2/twitter/class/action/plugintwitterconfigaction.class.php
plugins/branches/lifetype-1.2/twitter/class/action/plugintwitterupdateconfigaction.class.php
plugins/branches/lifetype-1.2/twitter/class/twitter/
plugins/branches/lifetype-1.2/twitter/class/twitter/twitter.class.php
plugins/branches/lifetype-1.2/twitter/class/view/
plugins/branches/lifetype-1.2/twitter/class/view/plugintwitterconfigview.class.php
plugins/branches/lifetype-1.2/twitter/locale/
plugins/branches/lifetype-1.2/twitter/locale/locale_en_UK.php
plugins/branches/lifetype-1.2/twitter/plugintwitter.class.php
plugins/branches/lifetype-1.2/twitter/readme.txt
plugins/branches/lifetype-1.2/twitter/templates/
plugins/branches/lifetype-1.2/twitter/templates/twitter.template
Log:
Added a Twitter plugin. This plugin will post a "tweet" to Twitter when a
new article is added to LifeType
Added: plugins/branches/lifetype-1.2/twitter/class/action/plugintwitterconfigaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/twitter/class/action/plugintwitterconfigaction.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/twitter/class/action/plugintwitterconfigaction.class.php 2007-04-28 08:55:00 UTC (rev 5352)
@@ -0,0 +1,49 @@
+<?php
+
+ /*
+ Copyright 2006 Paul Westbrook (paul at westbrooks.org)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/twitter/class/view/plugintwitterconfigview.class.php" );
+
+ class PluginTwitterConfigAction extends AdminAction
+ {
+
+ /**
+ * Constructor. If nothing else, it also has to call the constructor of the parent
+ * class, BlogAction with the same parameters
+ */
+ function PluginTwitterConfigAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ }
+
+ /**
+ * Carries out the specified action
+ */
+ function perform()
+ {
+ $this->_view = new PluginTwitterConfigView( $this->_blogInfo );
+
+ $this->setCommonData();
+
+ // better to return true if everything fine
+ return true;
+ }
+ }
+?>
Added: plugins/branches/lifetype-1.2/twitter/class/action/plugintwitterupdateconfigaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/twitter/class/action/plugintwitterupdateconfigaction.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/twitter/class/action/plugintwitterupdateconfigaction.class.php 2007-04-28 08:55:00 UTC (rev 5352)
@@ -0,0 +1,115 @@
+<?php
+
+ /*
+ Copyright 2006 Paul Westbrook (paul at westbrooks.org)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/twitter/class/view/plugintwitterconfigview.class.php" );
+
+
+ class PluginTwitterUpdateConfigAction extends AdminAction
+ {
+
+ var $_pluginEnabled;
+ var $_username;
+ var $_password;
+
+
+ /**
+ * Constructor. If nothing else, it also has to call the constructor of the parent
+ * class, BlogAction with the same parameters
+ */
+ function PluginTwitterUpdateConfigAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ }
+
+ function validate()
+ {
+ global $apiKeyValid;
+
+ $apiKeyValid = true;
+
+ $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
+ $this->_pluginEnabled = ($this->_pluginEnabled != "" );
+
+ $this->_username = $this->_request->getValue( "username" );
+ $this->_password = $this->_request->getValue( "password" );
+
+ if( $this->_pluginEnabled == true && $this->_username == "" ) {
+ $this->_view = new PluginTwitterConfigView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("twitter_missing_username"));
+ $this->setCommonData();
+
+ return false;
+ }
+
+ if( $this->_pluginEnabled == true && $this->_password == "" ) {
+ $this->_view = new PluginTwitterConfigView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("twitter_missing_password"));
+ $this->setCommonData();
+
+ return false;
+ }
+
+
+ return true;
+ }
+
+ /**
+ * Carries out the specified action
+ */
+ function perform()
+ {
+ // update the plugin configurations to blog setting
+ $blogSettings = $this->_blogInfo->getSettings();
+ $blogSettings->setValue( "plugin_twitter_enabled", $this->_pluginEnabled );
+
+ $blogSettings->setValue( "plugin_twitter_username", $this->_username );
+ $blogSettings->setValue( "plugin_twitter_password", $this->_password );
+
+ $this->_blogInfo->setSettings( $blogSettings );
+
+ // save the blogs settings
+ $blogs = new Blogs();
+ if( !$blogs->updateBlog( $this->_blogInfo )) {
+ $this->_view = new PluginTwitterConfigView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("error_updating_settings"));
+ $this->setCommonData();
+
+ return false;
+ }
+
+ // if everything went ok...
+ $this->_blogInfo->setSettings( $blogSettings );
+ $this->_session->setValue( "blogInfo", $this->_blogInfo );
+ $this->saveSession();
+
+ $this->_view = new PluginTwitterConfigView( $this->_blogInfo );
+ $this->_view->setSuccessMessage( $this->_locale->tr("twitter_settings_saved_ok"));
+ $this->setCommonData();
+
+ // clear the cache
+ CacheControl::resetBlogCache( $this->_blogInfo->getId());
+
+ return true;
+ }
+ }
+
+
+?>
Added: plugins/branches/lifetype-1.2/twitter/class/twitter/twitter.class.php
===================================================================
--- plugins/branches/lifetype-1.2/twitter/class/twitter/twitter.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/twitter/class/twitter/twitter.class.php 2007-04-28 08:55:00 UTC (rev 5352)
@@ -0,0 +1,290 @@
+<?php
+///////////////////////////////////////////
+//
+// twitterPHP
+// version 0.1
+// By David Billingham
+// david [at] slawcup [dot] com
+// http://twitter.slawcup.com/twitter.class.phps
+//
+//
+// Example 1:
+//
+// $t= new twitter();
+// $res = $t->publicTimeline();
+// if($res===false){
+// echo "ERROR<hr/>";
+// echo "<pre>";
+// print_r($t->responseInfo);
+// echo "</pre>";
+// }else{
+// echo "SUCCESS<hr/>";
+// echo "<pre>";
+// print_r($res);
+// echo "</pre>";
+// }
+//
+//
+// Example 2:
+//
+// $t= new twitter();
+// $t->username='username';
+// $t->password='password';
+// $res = $t->update('i am testing twitter.class.php');
+// if($res===false){
+// echo "ERROR<hr/>";
+// echo "<pre>";
+// print_r($t->responseInfo);
+// echo "</pre>";
+// }else{
+// echo "SUCCESS<hr/>Status Posted";
+// }
+//
+//
+//////////////////////////////////////////
+
+class twitter{
+ var $username='';
+ var $password='';
+ var $user_agent='';
+
+ ///////////////
+ //
+ // I don't know if these headers have become standards yet
+ // but I would suggest using them.
+ // more discussion here.
+ // http://tinyurl.com/3xtx66
+ //
+ ///////////////
+ var $headers=array('X-Twitter-Client: ',
+ 'X-Twitter-Client-Version: ',
+ 'X-Twitter-Client-URL: ');
+
+ var $responseInfo=array();
+
+
+ function twitter(){}
+
+
+
+
+
+ /////////////////////////////////////////
+ //
+ // Twitter API calls
+ //
+ // $this->update($status)
+ // $this->publicTimeline($sinceid=false)
+ // $this->friendsTimeline($id=false,$since=false)
+ // $this->userTimeline($id=false,$count=20,$since=false)
+ // $this->showStatus($id)
+ // $this->friends($id=false)
+ // $this->followers()
+ // $this->featured()
+ // $this->showUser($id)
+ // $this->directMessages($since=false)
+ // $this->sendDirectMessage($user,$text)
+ //
+ // If SimpleXMLElement exists the results will be returned as a SimpleXMLElement
+ // otherwise the raw XML will be returned for a successful request. If the request
+ // fails a FALSE will be returned.
+ //
+ //
+ /////////////////////////////////////////
+
+
+ // Updates the authenticating user's status.
+ // Requires the status parameter specified below.
+ //
+ // status. (string) Required. The text of your status update. Must not be
+ // more than 160 characters and should not be
+ // more than 140 characters to ensure optimal display.
+ //
+ function update($status){
+ $request = 'http://twitter.com/statuses/update.xml';
+ $postargs = 'status='.urlencode($status);
+ return $this->process($request,$postargs);
+ }
+
+ // Returns the 20 most recent statuses from non-protected users who have
+ // set a custom user icon. Does not require authentication.
+ //
+ // sinceid. (int) Optional. Returns only public statuses with an ID greater
+ // than (that is, more recent than) the specified ID.
+ //
+ function publicTimeline($sinceid=false){
+ $qs='';
+ if($sinceid!==false)
+ $qs='?since_id='.intval($sinceid);
+ $request = 'http://twitter.com/statuses/public_timeline.xml'.$qs;
+ return $this->process($request);
+ }
+
+ // Returns the 20 most recent statuses posted in the last 24 hours from the
+ // authenticating user and that user's friends. It's also possible to request
+ // another user's friends_timeline via the id parameter below.
+ //
+ // id. (string OR int) Optional. Specifies the ID or screen name of the user for whom
+ // to return the friends_timeline. (set to false if you
+ // want to use authenticated user).
+ // since. (HTTP-formatted date) Optional. Narrows the returned results to just those
+ // statuses created after the specified date.
+ //
+ function friendsTimeline($id=false,$since=false){
+ $qs='';
+ if($since!==false)
+ $qs='?since='.urlencode($since);
+
+ if($id===false)
+ $request = 'http://twitter.com/statuses/friends_timeline.xml'.$qs;
+ else
+ $request = 'http://twitter.com/statuses/friends_timeline/'.urlencode($id).'.xml'.$qs;
+
+ return $this->process($request);
+ }
+
+ // Returns the 20 most recent statuses posted in the last 24 hours from the
+ // authenticating user. It's also possible to request another user's timeline
+ // via the id parameter below.
+ //
+ // id. (string OR int) Optional. Specifies the ID or screen name of the user for whom
+ // to return the user_timeline.
+ // count. (int) Optional. Specifies the number of statuses to retrieve. May not be
+ // greater than 20 for performance purposes.
+ // since. (HTTP-formatted date) Optional. Narrows the returned results to just those
+ // statuses created after the specified date.
+ //
+ function userTimeline($id=false,$count=20,$since=false){
+ $qs='?count='.intval($count);
+ if($since!==false)
+ $qs .= '&since='.urlencode($since);
+
+ if($id===false)
+ $request = 'http://twitter.com/statuses/user_timeline.xml'.$qs;
+ else
+ $request = 'http://twitter.com/statuses/user_timeline/'.urlencode($id).'.xml'.$qs;
+
+ return $this->process($request);
+ }
+
+ // Returns a single status, specified by the id parameter below. The status's author
+ // will be returned inline.
+ //
+ // id. (int) Required. Returns status of the specified ID.
+ //
+ function showStatus($id){
+ $request = 'http://twitter.com/statuses/show/'.intval($id).'.xml';
+ return $this->process($request);
+ }
+ // Returns the authenticating user's friends, each with current status inline. It's
+ // also possible to request another user's friends list via the id parameter below.
+ //
+ // id. (string OR int) Optional. The ID or screen name of the user for whom to request
+ // a list of friends.
+ //
+ function friends($id=false){
+ if($id===false)
+ $request = 'http://twitter.com/statuses/friends.xml';
+ else
+ $request = 'http://twitter.com/statuses/friends/'.urlencode($id).'.xml';
+ return $this->process($request);
+ }
+
+ // Returns the authenticating user's followers, each with current status inline.
+ //
+ function followers(){
+ $request = 'http://twitter.com/statuses/followers.xml';
+ return $this->process($request);
+ }
+
+ // Returns a list of the users currently featured on the site with their current statuses inline.
+ function featured(){
+ $request = 'http://twitter.com/statuses/featured.xml';
+ return $this->process($request);
+ }
+
+ // Returns extended information of a given user, specified by ID or screen name as per the required
+ // id parameter below. This information includes design settings, so third party developers can theme
+ // their widgets according to a given user's preferences.
+ //
+ // id. (string OR int) Required. The ID or screen name of a user.
+ //
+ function showUser($id){
+ $request = 'http://twitter.com/users/show/'.urlencode($id).'.xml';
+ return $this->process($request);
+ }
+
+ // Returns a list of the direct messages sent to the authenticating user.
+ //
+ // since. (HTTP-formatted date) Optional. Narrows the resulting list of direct messages to just those
+ // sent after the specified date.
+ //
+ function directMessages($since=false){
+ $qs='';
+ if($since!==false)
+ $qs='?since='.urlencode($since);
+ $request = 'http://twitter.com/direct_messages.xml'.$qs;
+ return $this->process($request);
+ }
+
+ // Sends a new direct message to the specified user from the authenticating user. Requires both the user
+ // and text parameters below.
+ //
+ // user. (string OR int) Required. The ID or screen name of the recipient user.
+ // text. (string) Required. The text of your direct message. Be sure to URL encode as necessary, and keep
+ // it under 140 characters.
+ //
+ function sendDirectMessage($user,$text){
+ $request = 'http://twitter.com/direct_messages/new.xml';
+ $postargs = 'user='.urlencode($user).'&text='.urlencode($text);
+ return $this->process($request,$postargs);
+ }
+
+
+
+
+
+ // internal function where all the juicy curl fun takes place
+ // this should not be called by anything external unless you are
+ // doing something else completely then knock youself out.
+ function process($url,$postargs=false){
+
+ $ch = curl_init($url);
+
+ if($postargs !== false){
+ curl_setopt ($ch, CURLOPT_POST, true);
+ curl_setopt ($ch, CURLOPT_POSTFIELDS, $postargs);
+ }
+
+ if($this->username !== false && $this->password !== false)
+ curl_setopt($ch, CURLOPT_USERPWD, $this->username.':'.$this->password);
+
+ curl_setopt($ch, CURLOPT_VERBOSE, 1);
+ curl_setopt($ch, CURLOPT_NOBODY, 0);
+ curl_setopt($ch, CURLOPT_HEADER, 0);
+ curl_setopt($ch, CURLOPT_USERAGENT, $this->user_agent);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
+
+ $response = curl_exec($ch);
+
+ $this->responseInfo=curl_getinfo($ch);
+ curl_close($ch);
+
+
+ if(intval($this->responseInfo['http_code'])==200){
+ if(class_exists('SimpleXMLElement')){
+ $xml = new SimpleXMLElement($response);
+ return $xml;
+ }else{
+ return $response;
+ }
+ }else{
+ return false;
+ }
+ }
+}
+
+
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/twitter/class/view/plugintwitterconfigview.class.php
===================================================================
--- plugins/branches/lifetype-1.2/twitter/class/view/plugintwitterconfigview.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/twitter/class/view/plugintwitterconfigview.class.php 2007-04-28 08:55:00 UTC (rev 5352)
@@ -0,0 +1,52 @@
+<?php
+
+ /*
+ Copyright 2006 Paul Westbrook (paul at westbrooks.org)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+ lt_include( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+
+ /**
+ * implements the main view of the validate trackback plugin
+ */
+ class PluginTwitterConfigView extends AdminPluginTemplatedView
+ {
+
+ function PluginTwitterConfigView( $blogInfo )
+ {
+ $this->AdminPluginTemplatedView( $blogInfo, "twitter", "twitter" );
+ }
+
+ function render()
+ {
+ // load some configuration settings
+ $blogSettings = $this->_blogInfo->getSettings();
+ $pluginEnabled = $blogSettings->getValue( "plugin_twitter_enabled" );
+
+ $username = $blogSettings->getValue( "plugin_twitter_username" );
+ $password = $blogSettings->getValue( "plugin_twitter_password" );
+
+
+ // create a view and export the settings to the template
+ $this->setValue( "pluginEnabled", $pluginEnabled );
+ $this->setValue( "username", $username );
+ $this->setValue( "password", $password );
+
+ parent::render();
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/twitter/locale/locale_en_UK.php
===================================================================
--- plugins/branches/lifetype-1.2/twitter/locale/locale_en_UK.php (rev 0)
+++ plugins/branches/lifetype-1.2/twitter/locale/locale_en_UK.php 2007-04-28 08:55:00 UTC (rev 5352)
@@ -0,0 +1,19 @@
+<?php
+$messages["manageIntegrationPlugins"] = "Integration Management";
+$messages["twitterPluginSettings"] = "Twitter";
+$messages["twitter"] = "Twitter";
+
+$messages["twitter_plugin_enabled"] = "Enable this plugin";
+$messages["twitter_username"] = "Username for account on Twitter. To obtain account go to <a href=\"http://twitter.com/\">http://twitter.com/</a>";
+$messages["twitter_password"] = "Password for account on Twitter.";
+$messages["twitter_plugin"] = "Twitter Plugin";
+
+$messages["twitter_settings_saved_ok"] = "Twitter settings saved successfully!";
+$messages["twitter_missing_username"] = "Twitter username needs to be specified!";
+$messages["twitter_missing_password"] = "Twitter password needs to be specified!";
+
+$messages["label_configuration"] = "Configuration";
+$messages["label_enable"] = "Enable";
+$messages["label_twitter_username"] = "Twitter username";
+$messages["label_twitter_password"] = "Twitter password";
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/twitter/plugintwitter.class.php
===================================================================
--- plugins/branches/lifetype-1.2/twitter/plugintwitter.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/twitter/plugintwitter.class.php 2007-04-28 08:55:00 UTC (rev 5352)
@@ -0,0 +1,147 @@
+<?php
+ lt_include( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
+
+
+ /**
+ * implements notification of
+ */
+ class PluginTwitter extends PluginBase
+ {
+ var $pluginEnabled;
+ var $twitterUsername;
+ var $twitterPassword;
+ var $cacheFolder;
+
+ function PluginTwitter( $source = "" )
+ {
+ $this->PluginBase( $source );
+
+ $this->id = "twitter";
+ $this->desc = "Posts to twitter when a new article is added.";
+ $this->author = "Paul Westbrook (Twitter php library provided by <a href=\"http://blog.slawcup.com/5\">David Billingham</a>)";
+ $this->locales = Array( "en_UK" );
+ $this->version = "20070427";
+
+ if( $source == "admin" )
+ $this->initAdmin();
+ else
+ $this->init();
+ }
+
+ function init()
+ {
+ // register the events we want
+ $this->registerNotification( EVENT_POST_POST_ADD );
+ }
+
+ function initAdmin()
+ {
+ $this->init();
+
+ // register an action that will allow users to see which comments have not been
+ // accepted yet
+ $this->registerAdminAction( "twitterPluginSettings", "PluginTwitterConfigAction" );
+ $this->registerAdminAction( "twitterPluginUpdateSettings", "PluginTwitterUpdateConfigAction" );
+
+ // add a menu entry
+ $menu =& Menu::getMenu();
+ if( !$menu->entryExists( "/menu/controlCenter/manageIntegrationPlugins" ))
+ $this->addMenuEntry( "/menu/controlCenter", "manageIntegrationPlugins", "", "", true, false );
+ $this->addMenuEntry( "/menu/controlCenter/manageIntegrationPlugins", "twitter", "admin.php?op=twitterPluginSettings", "", true, false );
+ }
+
+ function register()
+ {
+ $config =& Config::getConfig();
+
+ $blogSettings = $this->blogInfo->getSettings();
+ $this->pluginEnabled = $blogSettings->getValue( "plugin_twitter_enabled" );
+ $this->twitterUsername = $blogSettings->getValue( "plugin_twitter_username" );
+ $this->twitterPassword = $blogSettings->getValue( "plugin_twitter_password" );
+ }
+
+ function isEnabled()
+ {
+ return $this->pluginEnabled;
+ }
+
+ /**
+ * process the events that we have registered
+ *
+ * @see PluginBase::process
+ * @see PluginManager
+ */
+ function process( $eventType, $params )
+ {
+ $validEvent = false;
+
+ if ( $eventType != EVENT_POST_POST_ADD )
+ {
+ return true;
+ }
+
+ // Load all of the settings for this blog
+ $this->register();
+
+ // do nothing if the plugin is not enabled!
+ if( !$this->isEnabled() )
+ {
+ // error_log( "plugin not enabled" );
+ return true;
+ }
+
+ $post = $params["article"];
+
+ // Make sure that the post is "published"
+ if ( $post->getStatus() != POST_STATUS_PUBLISHED )
+ {
+ return true;
+ }
+
+ $this->PostTweet( $post );
+
+ return true;
+ }
+
+ /**
+ * post a tweet to twitter with the url of this post
+ */
+
+ function PostTweet( $post )
+ {
+
+ $url = $this->blogInfo->getBlogRequestGenerator();
+
+ // Get the url from the article
+ $postUrl = $url->postPermalink( $post );
+
+ lt_include( PLOG_CLASS_PATH."plugins/twitter/class/twitter/twitter.class.php" );
+
+ $t = new twitter();
+ $t->username = $this->twitterUsername;
+ $t->password = $this->twitterPassword;
+
+ $res = $t->update($postUrl);
+ if($res===false){
+ error_log( "ERROR posting tweet" . $t->responseInfo);
+ }else{
+ error_log( "SUCCESS Status Posted" );
+ }
+
+ }
+
+ function getPluginConfigurationKeys()
+ {
+ lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
+
+ return (Array(
+ Array("name" => "plugin_twitter_enabled",
+ "type" => "boolean"),
+ Array( "name" => "plugin_twitter_username", "validator" => new StringValidator(), "type" => "string", "allowEmpty" => false ),
+ Array( "name" => "plugin_twitter_password", "validator" => new StringValidator(), "type" => "string", "allowEmpty" => false ),
+ )
+ );
+ }
+
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/twitter/readme.txt
===================================================================
--- plugins/branches/lifetype-1.2/twitter/readme.txt (rev 0)
+++ plugins/branches/lifetype-1.2/twitter/readme.txt 2007-04-28 08:55:00 UTC (rev 5352)
@@ -0,0 +1,10 @@
+Plugin: Twitter
+Author: Paul Westbrook
+Release Date: 04/27/2008
+Version: 1.0
+
+The Twitter plugin post entries to Twitter when new articles are added to LifeType.
+
+
+Install:
+1. Configurate your Twitter plugin in your LifeType control center
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/twitter/templates/twitter.template
===================================================================
--- plugins/branches/lifetype-1.2/twitter/templates/twitter.template (rev 0)
+++ plugins/branches/lifetype-1.2/twitter/templates/twitter.template 2007-04-28 08:55:00 UTC (rev 5352)
@@ -0,0 +1,41 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=twitter title=$locale->tr("rsd_plugin")}
+<form name="twitterPluginSettings" method="post">
+ <fieldset class="inputField">
+ <legend>{$locale->tr("label_configuration")}</legend>
+ {include file="$admintemplatepath/successmessage.template"}
+ {include file="$admintemplatepath/errormessage.template"}
+ <div class="field">
+ <label for="pluginEnabled">{$locale->tr("label_enable")}</label>
+ <div class="formHelp">
+ <input class="checkbox" type="checkbox" name="pluginEnabled" id="pluginEnabled" {if $pluginEnabled} checked="checked" {/if} value="1" />{$locale->tr("twitter_plugin_enabled")}
+ </div>
+ </div>
+
+ <div class="field">
+ <label for="username">{$locale->tr("label_twitter_username")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("twitter_username")}
+ <input class="text" type="text" name="username" id="username" value="{$username}" width="10" />
+ </div>
+ </div>
+
+ <div class="field">
+ <label for="password">{$locale->tr("label_twitter_password")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("twitter_password")}
+ <input class="text" type="text" name="password" id="password" value="{$password}" width="10" />
+ </div>
+ </div>
+
+
+ </fieldset>
+
+ <div class="buttons">
+ <input type="hidden" name="op" value="twitterPluginUpdateSettings" />
+ <input type="reset" name="{$locale->tr("reset")}" />
+ <input type="submit" name="{$locale->tr("update_settings")}" value="{$locale->tr("update")}" />
+ </div>
+</form>
+{include file="$admintemplatepath/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}
\ No newline at end of file
More information about the pLog-svn
mailing list