[pLog-svn] r1059 - in plugins/trunk: . delicious delicious/class
delicious/class/action delicious/class/delicious
delicious/class/view delicious/install
delicious/install/templates delicious/locale delicious/templates
mark at devel.plogworld.net
mark at devel.plogworld.net
Sun Feb 13 15:11:02 GMT 2005
Author: mark
Date: 2005-02-13 15:11:02 +0000 (Sun, 13 Feb 2005)
New Revision: 1059
Added:
plugins/trunk/delicious/
plugins/trunk/delicious/class/
plugins/trunk/delicious/class/action/
plugins/trunk/delicious/class/action/plugindeliciousconfigaction.class.php
plugins/trunk/delicious/class/action/plugindeliciousshowaction.class.php
plugins/trunk/delicious/class/action/plugindeliciousupdateconfigaction.class.php
plugins/trunk/delicious/class/delicious/
plugins/trunk/delicious/class/delicious/delicious.class.php
plugins/trunk/delicious/class/view/
plugins/trunk/delicious/class/view/plugindeliciousconfigview.class.php
plugins/trunk/delicious/install/
plugins/trunk/delicious/install/templates/
plugins/trunk/delicious/install/templates/delicious.template
plugins/trunk/delicious/locale/
plugins/trunk/delicious/locale/locale_en_UK.php
plugins/trunk/delicious/locale/locale_zh_TW.php
plugins/trunk/delicious/plugindelicious.class.php
plugins/trunk/delicious/readme.txt
plugins/trunk/delicious/templates/
plugins/trunk/delicious/templates/delicious.template
Log:
Add a new plugin to integrate del.icio.us bookmark service.
Added: plugins/trunk/delicious/class/action/plugindeliciousconfigaction.class.php
===================================================================
--- plugins/trunk/delicious/class/action/plugindeliciousconfigaction.class.php 2005-02-13 13:41:17 UTC (rev 1058)
+++ plugins/trunk/delicious/class/action/plugindeliciousconfigaction.class.php 2005-02-13 15:11:02 UTC (rev 1059)
@@ -0,0 +1,26 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."plugins/delicious/class/view/plugindeliciousconfigview.class.php" );
+
+ /**
+ * shows a form with the current configuration
+ */
+ class PluginDeliciousConfigAction extends AdminAction
+ {
+
+ function PluginDeliciousConfigAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ }
+
+ function perform()
+ {
+ $this->_view = new PluginDeliciousConfigView( $this->_blogInfo );
+
+ $this->setCommonData();
+
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/trunk/delicious/class/action/plugindeliciousshowaction.class.php
===================================================================
--- plugins/trunk/delicious/class/action/plugindeliciousshowaction.class.php 2005-02-13 13:41:17 UTC (rev 1058)
+++ plugins/trunk/delicious/class/action/plugindeliciousshowaction.class.php 2005-02-13 15:11:02 UTC (rev 1059)
@@ -0,0 +1,27 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/action/blogaction.class.php" );
+ include_once( PLOG_CLASS_PATH."class/view/blogview.class.php" );
+
+ /**
+ * shows a flickr template without smarty cache
+ */
+ class PluginDeliciousShowAction extends BlogAction
+ {
+
+ function PluginDeliciousShowAction( $actionInfo, $request )
+ {
+ $this->BlogAction( $actionInfo, $request );
+ }
+
+ function perform()
+ {
+ $this->_view = new BlogView( $this->_blogInfo, "delicious", SMARTY_VIEW_CACHE_DISABLED );
+ $this->_view->setValue( "request", $this->_request );
+ // add all the common information to the view
+ $this->setCommonData();
+
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/trunk/delicious/class/action/plugindeliciousupdateconfigaction.class.php
===================================================================
--- plugins/trunk/delicious/class/action/plugindeliciousupdateconfigaction.class.php 2005-02-13 13:41:17 UTC (rev 1058)
+++ plugins/trunk/delicious/class/action/plugindeliciousupdateconfigaction.class.php 2005-02-13 15:11:02 UTC (rev 1059)
@@ -0,0 +1,80 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."plugins/delicious/class/view/plugindeliciousconfigview.class.php" );
+
+ /**
+ * updates the plugin configuration
+ */
+ class PluginDeliciousUpdateConfigAction extends AdminAction
+ {
+ var $_pluginEnabled;
+ var $_userName;
+ var $_password;
+
+ function PluginDeliciousUpdateConfigAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ }
+
+ function validate()
+ {
+ $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
+ $this->_pluginEnabled = ($this->_pluginEnabled != "" );
+
+ $this->_userName = $this->_request->getValue( "userName" );
+ if( $this->_userName == "" ) {
+ $this->_view = new PluginDeliciousConfigView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("delicious_error_username"));
+ $this->setCommonData();
+
+ return false;
+ }
+
+ $this->_password = $this->_request->getValue( "password" );
+ if( $this->_password == "" ) {
+ $this->_view = new PluginDeliciousConfigView( $this->_blogInfo );
+ $this->_view->setErrorMessage( $this->_locale->tr("delicious_error_password"));
+ $this->setCommonData();
+
+ return false;
+ }
+
+ return true;
+ }
+
+ function perform()
+ {
+ // update the plugin configurations to blog setting
+ $blogSettings = $this->_blogInfo->getSettings();
+ $blogSettings->setValue( "plugin_delicious_enabled", $this->_pluginEnabled );
+ $blogSettings->setValue( "plugin_delicious_username", $this->_userName );
+ $blogSettings->setValue( "plugin_delicious_password", $this->_password );
+ $this->_blogInfo->setSettings( $blogSettings );
+
+ // save the blogs settings
+ $blogs = new Blogs();
+ if( !$blogs->updateBlog( $this->_blogInfo->getId(), $this->_blogInfo )) {
+ $this->_view = new PluginDeliciousConfigView( $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 PluginDeliciousConfigView( $this->_blogInfo );
+ $this->_view->setSuccessMessage( $this->_locale->tr("delicious_settings_saved_ok"));
+ $this->setCommonData();
+
+ // clear the cache
+ CacheControl::resetBlogCache( $this->_blogInfo->getId());
+
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/trunk/delicious/class/delicious/delicious.class.php
===================================================================
--- plugins/trunk/delicious/class/delicious/delicious.class.php 2005-02-13 13:41:17 UTC (rev 1058)
+++ plugins/trunk/delicious/class/delicious/delicious.class.php 2005-02-13 15:11:02 UTC (rev 1059)
@@ -0,0 +1,604 @@
+<?php
+/*
+
+see for ideas
+http://www.hackdiary.com/archives/000060.html
+
+0.1 - 10/11/04
+- initial release
+
+0.2 - 10/15/04
+- sends user-agent
+- improved error handling, added error codes
+- added HTTP header parsing and handling
+- now disables all calls after user is throttled (receive http status 503)
+- added support for /all method with get_all_posts()
+- fixed the delete_post method
+
+0.3 - future
+- TODO - cookie support
+- TODO - implement support for http 1.1 persistent connections
+- TODO - caching
+
+*/
+
+// error codes
+define('DEL_ERR_NOCREDENTIALS',1);
+define('DEL_ERR_THROTTLED',2);
+define('DEL_ERR_MANGLEDHEADERS',3);
+define('DEL_ERR_SOCKETCONNECT',4);
+define('DEL_ERR_SOCKETWRITE',5);
+define('DEL_ERR_XMLPARSE',6);
+
+class delicious
+{
+ var $title = 'Delicious-x-4';
+ var $version = '0.2';
+ var $host = 'del.icio.us';
+ var $port = 80;
+ var $username = false;
+ var $password = false;
+ var $error = false; // is set to an error code upon any error
+ var $debug_flag = 0; // 1 = append to to $del->debug_str, 2 = echo() out line by line
+ var $debug_str = "";
+ var $throttled = false; // set to true if server returns 503, deny any future requests
+ var $incoming_headers = array();
+ var $request = "";
+ var $response = "";
+ var $cookie = false;
+
+ // constructor
+ function delicious($username,$password)
+ {
+ $this->username = $username;
+ $this->password = $password;
+ }
+
+ // send http message, return parsed response
+ function send($path)
+ {
+ // throttle check
+ if($this->throttled)
+ {
+ $this->setError(DEL_ERR_THROTTLED);
+ return false;
+ }
+
+ // check that credentials have been set
+ if(!$this->username || !$this->password)
+ {
+ $this->setError(DEL_ERR_NOCREDENTIALS);
+ return false;
+ }
+
+ // build http request message
+ $msg =
+ "GET http://".$this->host."$path HTTP/1.0\r\n"
+ .'User-Agent: '.$this->title.'/'.$this->version."\r\n";
+
+ // cookie or credentials
+ $msg .= 'Authorization: Basic '.base64_encode($this->username.':'.$this->password)."\r\n";
+ /*
+ if(!$this->cookie)
+ {
+ $msg .= 'Authorization: Basic '.base64_encode($this->username.':'.$this->password)."\r\n";
+ }
+ else
+ {
+ $msg .= 'Cookie:'.$this->cookie."\r\n";
+ }
+ */
+
+ // close message
+ $msg .= "\r\n";
+
+ $this->request = $msg;
+ //$this->debug('REQUEST:');
+ //$this->debug('<xmp>'.$msg.'</xmp>');
+
+ // make call
+ if( $fp = pfsockopen( $this->host, $this->port) )
+ {
+ if( fwrite($fp, $msg) )
+ {
+ $response = '';
+ while (!feof($fp))
+ {
+ $response .= fread($fp, 8192);
+ }
+
+ fclose($fp);
+
+ $this->response = $response;
+ //$this->debug('RESPONSE:');
+ //$this->debug('<xmp>'.$response.'</xmp>');
+
+ // parse response message
+ $pos = strpos($response,"\r\n\r\n");
+ if($pos < 1)
+ {
+ $pos = strpos($data,"\n\n");
+ }
+
+ // separate headers and body
+ if($headers = $this->parseHeaders(trim(substr($response,0,$pos))))
+ {
+ foreach($headers as $k => $v)
+ {
+ $this->debug("HTTP Response Header: $k -> $v");
+ }
+
+ // mangled headers?
+ if(!isset($headers['status']))
+ {
+ $this->debug('send(): no status in headers');
+ $this->setError(DEL_ERR_MANGLEDHEADERS);
+ return false;
+ }
+
+ // handle 503
+ if($headers['status'] == 503)
+ {
+ $this->throttled = true;
+ $this->setError(DEL_ERR_THROTTLED);
+ return false;
+ }
+
+ // process cookie
+ if(isset($headers['set-cookie']))
+ {
+ $this->cookie = substr( $headers['set-cookie'], 0, strpos($headers['set-cookie'],';') ).';';
+ $this->debug('send(): setting cookie: '.$this->cookie);
+ }
+
+ // handle unchanged
+
+ // get xml response
+ $xml = trim(substr($response,$pos));
+
+ // if xml response
+ if(strlen($xml) > 0)
+ {
+ $this->debug('send(): parsing xml');
+ // parse into assoc array and return
+ if($result = $this->parseResponse($xml))
+ {
+ return $result;
+ }
+ else
+ {
+ $this->debug('got parser error');
+ $this->setError(DEL_ERROR_XMLPARSE);
+ }
+ }
+ else
+ {
+ return array();
+ }
+ }
+ else
+ {
+ // no proper headers found - mangled response?
+ $this->setError(DEL_ERR_MANGLEDHEADERS);
+ return false;
+ }
+ }
+ else
+ {
+ $this->setError(DEL_ERR_SOCKETWRITE);
+ return false;
+ }
+ }
+ else
+ {
+ $this->setError(DEL_ERR_SOCKETCONNECT);
+ return false;
+ }
+ }
+
+ // parse headers
+ function parseHeaders($str)
+ {
+ //$this->debug("parseHeaders(): header string: $str");
+ // find linebreak type
+ $lb = false;
+ $pos = strpos($str,"\r\n");
+ if($pos > 1){
+ $lb = "\r\n";
+ } else {
+ $pos = strpos($str,"\n");
+ if($pos > 1){
+ $lb = "\n";
+ }
+ }
+
+ // if linebreak is found
+ if(!$lb)
+ {
+ $this->debug('parseHeaders(): no linebreak found');
+ return false;
+ }
+ else
+ {
+ $header_array = explode( $lb, $str );
+ foreach($header_array as $header_line){
+ $arr = explode(':',$header_line, 2);
+ if(count($arr) > 1){
+ $header_name = strtolower(trim($arr[0]));
+ $this->incoming_headers[$header_name] = trim($arr[1]);
+ } else if (isset($header_name)) {
+ // append continuation line to previous header
+ $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
+ } elseif ( strstr($header_line,'HTTP')) {
+ $arr = explode(' ', $header_line);
+ $this->incoming_headers['status'] = $arr[1];
+ }
+ }
+ return $this->incoming_headers;
+ }
+ }
+
+ // parse response
+ function parseResponse($xml)
+ {
+ $parser = xml_parser_create('');
+ xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
+ xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);
+ $return = xml_parse_into_struct($parser,$xml,$values,$tags);
+
+ //$this->debug( 'parseResponse(): xml_parse_into_struct return: '.$return);
+
+ // handle errors
+ if($return == 0)
+ {
+ $this->debug( 'parseResponse(): xml error - '.xml_error_string( xml_get_error_code($parser) ) );
+ return false;
+ }
+ else
+ {
+ //$this->debug( $this->htmlvar_dump($tags) );
+ //$this->debug( $this->htmlvar_dump($values) );
+
+ foreach($tags as $tagname => $indices)
+ {
+ foreach($indices as $index)
+ {
+ $id = uniqid('');
+
+ if($values[$index]['type'] != 'close')
+ {
+ // store element details
+ $content[$id] = $values[$index];
+
+ $tagname = $values[$index]['tag'];
+
+ // set self to value of last open tag flag
+ if($values[$index]['type'] == 'open')
+ {
+ $lastOpenTagAtLevel[ $values[$index]['level'] ] = $id;
+ }
+
+ // get parent id
+ $myParent = $lastOpenTagAtLevel[ ($values[$index]['level']-1) ];
+
+ // if root, flag, and don't add to parent
+ if($values[$index]['level'] == 1)
+ {
+ $root = $id;
+ }
+ // if complete, add self to parent result
+ elseif($values[$index]['type'] == 'complete')
+ {
+ $content[ $myParent ]['result'][$tagname][] = $values[$index]['attributes'];
+ }
+ // if open tag, add reference to my result to parents result
+ elseif($values[$index]['type'] == 'open')
+ {
+ $content[ $myParent ]['result'][$tagname][] = &$values[$index]['result'];
+ }
+ }
+ }
+ }
+
+ // handle case where xml document is a single complete tag w/ no children
+ if(!isset($content[$root]['result']))
+ {
+ $result = $content[$root]['attributes'];
+ }
+ else
+ {
+ $result = array_shift($content[$root]['result']);
+ }
+ //$this->debug( $this->htmlvar_dump($result) );
+
+ xml_parser_free($parser);
+
+ return $result;
+ }
+ }
+
+ // set errors
+ function setError($str)
+ {
+ $this->error = $str;
+ }
+
+ // get errors
+ function getError()
+ {
+ return $this->error;
+ }
+
+ // handle debug output
+ function debug($str)
+ {
+ if($this->debug_flag == 1)
+ {
+ $this->debug_str .= $str."\n";
+ }
+ elseif($this->debug_flag == 2)
+ {
+ echo $str.'<br>';
+ }
+ }
+
+ function htmlvar_dump($var)
+ {
+ ob_start();
+ var_dump($var);
+ $str = ob_get_contents();
+ ob_end_clean();
+ return '<pre>'.$str.'</pre>';
+ }
+ /*
+ function: http://del.icio.us/api/posts/dates?
+ &tag= filter by this tag - optional
+ returns a list of dates with the number of posts at each date.
+ [tag] adds a filter
+ */
+ function get_post_dates($tag=false)
+ {
+ // build path and query string
+ $queryString =
+ '/api/posts/dates?'; // action
+
+ if($tag)
+ {
+ $queryString .= '&tag='.urlencode($tag);
+ }
+
+ // send
+ return $this->send($queryString);
+ }
+
+ /*
+ function: http://del.icio.us/api/tags/get?
+ returns a list of tags the user has used.
+ */
+ function get_tags()
+ {
+ // build path and query string
+ $queryString =
+ '/api/tags/get?'; // action
+
+ // send
+ return $this->send($queryString);
+ }
+
+ /*
+ function: http://del.icio.us/api/posts/get?
+ &tag= filter by this tag - optional
+ &dt= filter by this date
+ returns a list of posts on a given date, filtered by tag. if no
+ date is supplied, most recent date will be used
+ */
+ function get_posts($tag=false,$dt=false)
+ {
+ // build path and query string
+ $queryString =
+ '/api/posts/get?'; // action
+
+ if($tag)
+ {
+ $queryString .= '&tag='.urlencode($tag);
+ }
+
+ if($dt)
+ {
+ $queryString .= '&dt='.urlencode($dt);
+ }
+
+ // send
+ return $this->send($queryString);
+ }
+
+ /*
+ function: http://del.icio.us/api/posts/recent?
+ &tag= filter by this tag - optional
+ &count= number of items to retrieve - optional (defaults to 15)
+ returns a list of most recent posts, possibly filtered by tag.
+ */
+ function get_recent_posts($tag=false,$count=false)
+ {
+ // build path and query string
+ $queryString =
+ '/api/posts/recent?'; // action
+
+ if($tag)
+ {
+ $queryString .= '&tag='.urlencode($tag);
+ }
+
+ if($count)
+ {
+ $queryString .= '&count='.urlencode($count);
+ }
+
+ // send
+ return $this->send($queryString);
+ }
+
+ /*
+ function: http://del.icio.us/api/posts/all
+ returns all posts. use sparingly.
+ */
+ function get_all_posts()
+ {
+ // build path and query string
+ $queryString = '/api/posts/all'; // action
+
+ // send
+ return $this->send($queryString);
+ }
+
+ /*
+ function: http://del.icio.us/api/posts/add?
+ &url= url for post
+ &description= description for post
+ &extended= extended for post
+ &tags= space-delimited list of tags
+ &dt= datestamp for post, format "CCYY-MM-DDThh:mm:ssZ"
+ makes a post to delicious
+ */
+ function add_post($link, $title, $content, $category, $date)
+ {
+ // prep data
+ //$date = date('Y-m-d\TH:i:s\Z', strtotime($date) );
+
+ // build path and query string
+ $queryString =
+ '/api/posts/add?' // action
+ .'&url='.$link // link for post
+ .'&description='.urlencode($title) // description for post
+ .'&extended='.urlencode($content) // extended for post
+ .'&tags='.urlencode($category) // space-delimited list of tags
+ .'&dt='.urlencode($date); // datestamp for post, format "CCYY-MM-DDThh:mm:ssZ"
+
+ // send
+ return $this->send($queryString);
+ }
+
+ /*
+ function: http://del.icio.us/api/tags/rename?
+ &old= old tag
+ &new= new tag
+ renames tags across all posts
+ */
+ function rename_tag($old_tag,$new_tag)
+ {
+ // build path and query string
+ $queryString =
+ '/api/tags/rename?' // action
+ .'&old='.urlencode($old_tag)
+ .'&new='.urlencode($new_tag);
+
+ // send
+ return $this->send($queryString);
+ }
+
+ /*
+ function: http://del.icio.us/api/inbox/get?
+ &dt= filter by this date
+ returns a list of inbox entries
+ */
+ function get_inbox($dt)
+ {
+ // build path and query string
+ $queryString =
+ '/api/inbox/get?' // action
+ .'&dt='.urlencode($dt);
+
+ // send
+ return $this->send($queryString);
+ }
+
+ /*
+ function: http://del.icio.us/api/inbox/dates?
+ returns a list of dates containing inbox entries
+ */
+ function get_inbox_dates()
+ {
+ // build path and query string
+ $queryString =
+ '/api/inbox/dates?'; // action
+
+ // send
+ return $this->send($queryString);
+ }
+
+ /*
+ function: http://del.icio.us/api/inbox/subs?
+ returns a list of your subscriptions
+ */
+ function get_subscriptions()
+ {
+ // build path and query string
+ $queryString =
+ '/api/inbox/subs?'; // action
+
+ // send
+ return $this->send($queryString);
+ }
+
+ /*
+ function: http://del.icio.us/api/inbox/sub?
+ &user= username
+ &tag = tag - optional, leave blank for all posts
+ adds a subscription
+ */
+ function subscribe($user,$tag=false)
+ {
+ // build path and query string
+ $queryString =
+ '/api/inbox/sub?' // action
+ .'&user='.urlencode($user);
+
+ if($tag)
+ {
+ $queryString .= '&tag='.urlencode($tag);
+ }
+
+ // send
+ return $this->send($queryString);
+ }
+
+ /*
+ function: http://del.icio.us/api/inbox/unsub?
+ &user= username
+ &tag = tag - optional, leave blank for all posts
+ removes a subscription
+ */
+ function unsubscribe($user,$tag=false)
+ {
+ // build path and query string
+ $queryString =
+ '/api/inbox/unsub?' // action
+ .'&user='.urlencode($user);
+
+ if($tag)
+ {
+ $queryString .= '&tag='.urlencode($tag);
+ }
+
+ // send
+ return $this->send($queryString);
+ }
+
+ /*
+ function: http://del.icio.us/api/posts/delete?url=
+ deletes a post
+ */
+ function delete_post($url)
+ {
+ // build path and query string
+ $queryString =
+ '/api/posts/delete'
+ .'?url='.urlencode($url);
+
+ // send
+ return $this->send($queryString);
+ }
+}
+
+
+?>
\ No newline at end of file
Added: plugins/trunk/delicious/class/view/plugindeliciousconfigview.class.php
===================================================================
--- plugins/trunk/delicious/class/view/plugindeliciousconfigview.class.php 2005-02-13 13:41:17 UTC (rev 1058)
+++ plugins/trunk/delicious/class/view/plugindeliciousconfigview.class.php 2005-02-13 15:11:02 UTC (rev 1059)
@@ -0,0 +1,32 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+
+ /**
+ * implements the main view of the feed reader plugin
+ */
+ class PluginDeliciousConfigView extends AdminPluginTemplatedView
+ {
+
+ function PluginDeliciousConfigView( $blogInfo )
+ {
+ $this->AdminPluginTemplatedView( $blogInfo, "delicious", "delicious" );
+ }
+
+ function render()
+ {
+ // load some configuration settings
+ $blogSettings = $this->_blogInfo->getSettings();
+ $pluginEnabled = $blogSettings->getValue( "plugin_delicious_enabled" );
+ $userName = $blogSettings->getValue( "plugin_delicious_username" );
+ $password = $blogSettings->getValue( "plugin_delicious_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/trunk/delicious/install/templates/delicious.template
===================================================================
--- plugins/trunk/delicious/install/templates/delicious.template 2005-02-13 13:41:17 UTC (rev 1058)
+++ plugins/trunk/delicious/install/templates/delicious.template 2005-02-13 15:11:02 UTC (rev 1059)
@@ -0,0 +1,8 @@
+{include file="$blogtemplate/header.template"}
+ {assign var=tagId value=$smarty.request.tag}
+ {assign var=deliciousTags value=$delicious->getTagList()}
+ {foreach item=deliciousTag from=$deliciousTags}
+ {math equation="ceil(x/y)+1" assign=fontsize x=$deliciousTag.count y=5}
+ <font size={$fontsize}><a href="{$deliciousTag.deliciousUrl}" style="border-bottom: 0px;" title="{$deliciousTag.count} Posts">{$deliciousTag.id}</a></font>
+ {/foreach}
+{include file="$blogtemplate/footer.template"}
\ No newline at end of file
Added: plugins/trunk/delicious/locale/locale_en_UK.php
===================================================================
--- plugins/trunk/delicious/locale/locale_en_UK.php 2005-02-13 13:41:17 UTC (rev 1058)
+++ plugins/trunk/delicious/locale/locale_en_UK.php 2005-02-13 15:11:02 UTC (rev 1059)
@@ -0,0 +1,16 @@
+<?php
+$messages["manageIntegrationPlugins"] = "Integration Management";
+$messages["Delicious"] = "Del.icio.us";
+
+$messages["delicious_username"] = "Input your Del.icio.us Account";
+$messages["delicious_password"] = "Input your Del.icio.us Password";
+$messages["delicious_plugin_enabled"] = "Enable this plugin";
+$messages["delicious_plugin"] = "Del.icio.us Integration Plugin";
+
+$messages["delicious_settings_saved_ok"] = "Del.icio.us settings saved successfully!";
+$messages["delicious_error_username"] = "User Name can not be empty!";
+$messages["delicious_error_password"] = "Password can not be empty!";
+
+$messages["label_username"] = "User Name";
+$messages["label_password"] = "Password";
+?>
\ No newline at end of file
Added: plugins/trunk/delicious/locale/locale_zh_TW.php
===================================================================
--- plugins/trunk/delicious/locale/locale_zh_TW.php 2005-02-13 13:41:17 UTC (rev 1058)
+++ plugins/trunk/delicious/locale/locale_zh_TW.php 2005-02-13 15:11:02 UTC (rev 1059)
@@ -0,0 +1,16 @@
+<?php
+$messages["manageIntegrationPlugins"] = "ç«å¤ç³»çµ±æ´å管ç";
+$messages["Delicious"] = "Del.icio.us æ¸ç±¤æ´åè¨å®";
+
+$messages["delicious_username"] = "è«è¼¸å
¥ä½ ç Del.icio.us 帳è";
+$messages["delicious_password"] = "è«è¼¸å
¥ä½ ç Del.icio.us å¯ç¢¼";
+$messages["delicious_plugin_enabled"] = "åå夿ç¨å¼";
+$messages["delicious_plugin"] = "Del.icio.us æ´å夿ç¨å¼";
+
+$messages["delicious_settings_saved_ok"] = "Del.icio.us è¨å®å²åæåã";
+$messages["delicious_error_username"] = "帳èé¯èª¤ï¼ä¸å¯çºç©ºç½ã";
+$messages["delicious_error_password"] = "å¯ç¢¼é¯èª¤ï¼ä¸å¯çºç©ºç½ã";
+
+$messages["label_username"] = "帳è";
+$messages["label_password"] = "å¯ç¢¼";
+?>
\ No newline at end of file
Added: plugins/trunk/delicious/plugindelicious.class.php
===================================================================
--- plugins/trunk/delicious/plugindelicious.class.php 2005-02-13 13:41:17 UTC (rev 1058)
+++ plugins/trunk/delicious/plugindelicious.class.php 2005-02-13 15:11:02 UTC (rev 1059)
@@ -0,0 +1,119 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
+ include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
+ include_once( PLOG_CLASS_PATH."class/net/requestgenerator.class.php" );
+ include_once( PLOG_CLASS_PATH."plugins/delicious/class/delicious/delicious.class.php" );
+
+ //Used as the root for building the bookmark URLs
+ define ('DELICIOUS_ROOT', 'http://del.icio.us/');
+
+ /**
+ * Plugin that offers features to integrate the Del.icio.us Bookmark Service
+ */
+ class PluginDelicious extends PluginBase
+ {
+ var $userName; //Your del.icio.us account logon
+ var $password; //Your del.icio.u account password
+ var $userRoot; //Root for links in the output
+ var $errors = array(
+ 1=>'You must enter credentials',
+ 2=>'You have been throttled. Please stop attempting to connect to del.icio.us',
+ 3=>'The del.icio.us service did not return a proper HTTP response',
+ 4=>'Unable to connect to del.icio.us',
+ 5=>'Unable to send data to del.icio.us',
+ 6=>'Unable to parse the XML returned from del.icio.us'
+ );
+
+ function PluginDelicious()
+ {
+ $this->PluginBase();
+
+ $this->id = "delicious";
+ $this->author = "Mark Wu";
+ $this->desc = 'This plugin let you integrate your Del.icio.us with pLog.';
+
+ $this->locales = Array( "en_UK" , "zh_TW" );
+
+ $this->init();
+ }
+
+ function init()
+ {
+ $this->registerAdminAction( "delicious", "PluginDeliciousConfigAction" );
+ $this->registerAdminAction( "updateDeliciousConfig", "PluginDeliciousUpdateConfigAction" );
+ $this->registerBlogAction( "DeliciousShow", "PluginDeliciousShowAction" );
+
+ $menu =& Menu::getMenu();
+ if( !$menu->entryExists( "/menu/controlCenter/manageIntegrationPlugins" ))
+ $this->addMenuEntry( "/menu/controlCenter", "manageIntegrationPlugins", "", "", true, false );
+ $this->addMenuEntry( "/menu/controlCenter/manageIntegrationPlugins", "Delicious", "?op=delicious", "" );
+ }
+
+ function register()
+ {
+ $blogSettings = $this->blogInfo->getSettings();
+ $this->pluginEnabled = $blogSettings->getValue( "plugin_delicious_enabled" );
+ $this->userName = $blogSettings->getValue( "plugin_delicious_username" );
+ $this->password = $blogSettings->getValue( "plugin_delicious_password" );
+ }
+
+ function pluginTemplatePage( $template )
+ {
+ $rg = new RawRequestGenerator($this->blogInfo);
+
+ $rg->addParameter( "op", "DeliciousShow" );
+ $rg->addParameter( "blogId", $this->blogInfo->getId());
+
+ $templatePage = $rg->getIndexUrl().$rg->getRequest();
+
+ return $templatePage;
+ }
+
+ /**
+ * Get the photo albums from specific user
+ */
+ function getTagList()
+ {
+ $this->userRoot = $this->pluginTemplatePage( "delicious" );
+
+ // instanciate delicious object
+ $del = new delicious($this->userName,$this->password);
+
+ // toggle debugging mode
+ //$del->debug_flag = 1;
+
+ // PLEASE USE SPARINGLY OR del.icio.us WILL THROTTLE YOU
+ if(!$result = $del->get_tags())
+ {
+ $message = $this->$errors[ $del->getError() ];
+ }
+ else
+ {
+ // debugging helpers
+ //echo $del->htmlvar_dump($result);
+ //echo $del->request;
+ //echo $del->response;
+
+ if( count($result) > 0)
+ {
+ // loop thru result set, inserting into db
+ $tags = array();
+ foreach($result as $properties)
+ {
+ $tag['id'] = str_replace(' ',',',$properties['tag']);
+ $tag['count'] = $properties['count'];
+ $tag['tagUrl'] = $this->userRoot . "&tag=" . $tag['id'];
+ $tag['deliciousUrl'] = DELICIOUS_ROOT . $this->userName . '/' . $tag['id'];
+ array_push( $tags, $tag);
+ }
+ return $tags;
+ }
+ else
+ {
+ $message = $result['code'];
+ }
+ }
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/trunk/delicious/readme.txt
===================================================================
--- plugins/trunk/delicious/readme.txt 2005-02-13 13:41:17 UTC (rev 1058)
+++ plugins/trunk/delicious/readme.txt 2005-02-13 15:11:02 UTC (rev 1059)
@@ -0,0 +1,14 @@
+Plugin: Del.icio.us
+Author: Mark Wu
+Release Date: 2005/02/13
+Version: 1.0
+
+This plugin offers you to integrate with Del.icio.us service.
+
+Install:
+1. Copy the install/templates/flickr.template to your plog template folder.
+
+Usage:
+Use the following URL to call your pLog Flickr Plugin Page
+http://your-plog/index.php?op=DeliciousShow&blogId=1
+
Added: plugins/trunk/delicious/templates/delicious.template
===================================================================
--- plugins/trunk/delicious/templates/delicious.template 2005-02-13 13:41:17 UTC (rev 1058)
+++ plugins/trunk/delicious/templates/delicious.template 2005-02-13 15:11:02 UTC (rev 1059)
@@ -0,0 +1,39 @@
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=Delicious title=$locale->tr("delicious_plugin")}
+<form name="deliciousPluginConfig" 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>
+ <span class="required"></span>
+ <div class="formHelp">
+ <input class="checkbox" type="checkbox" name="pluginEnabled" id="pluginEnabled" {if $pluginEnabled} checked="checked" {/if} value="1" />{$locale->tr("delicious_plugin_enabled")}
+ </div>
+ </div>
+
+ <div class="field">
+ <label for="userName">{$locale->tr("label_username")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("delicious_username")}</div>
+ <input class="text" type="text" name="userName" id="userName" value="{$userName}" width="10" />
+ </div>
+
+ <div class="field">
+ <label for="password">{$locale->tr("label_password")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("delicious_password")}</div>
+ <input class="password" type="password" name="password" id="password" value="{$password}" width="10" />
+ </div>
+
+ </fieldset>
+
+ <div class="buttons">
+ <input type="hidden" name="op" value="updateDeliciousConfig" />
+ <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