Showing posts with label zend. Show all posts
Showing posts with label zend. Show all posts

2.27.2010

Export from Wordpress blog and Import to Blogger

This script exports your posts and categories from your locally hosted Wordpress blog and imports them into a new Blogger blog online. The script is based on the Blogger examples for working with PHP and blog data.

Code to export from hosted Wordpress blog and import to Blogger at github

You need to have the Zend Framework up and running on your system as it contains all the GData libraries for working with Google data in PHP. This script doesn't use any of the MVC, so you just need to have the files somewhere that you can require them. More on Zend Framework here.

You need to edit line 8 to point to the path of your Zend Framework. You also need to update the database connection variables right below that to match your wordpress blog.

Some caveats:

  • Blogger can only import 50 blog posts per day before tripping some anti-spam protection. So the SQL "limit" clause around line 322 will need to be adjusted. It is set to get the first 50 posts and publish them.
  • Wordpress "categories" become Blogger "labels"
  • Blogger forces any imported comments to the blog posts to originate from you, the author, of the blog.  So I have omitted these from my script, figuring it would look crazy to be talking to myself.  You could hack this script to add those back in.  

What's great about Blogger is that you can create a new test blog and run this script, which allows you to select which Blogger blog you wish to update and go from there.

The usage is:

php xfer_to_blogger.php --user=email@email.com --pass=password

The email and password here are the ones you used in setting up your Blogger account.

Let me know how you make out and if you have any suggestions for the code.

10.10.2007

Zend Studio for Eclipse Beta

As my part time job (for no pay) is spent being a shill for Zend, I thought I'd mention that the new Zend Studio for Eclipse Beta is out and ready to be test driven. I've got a few deadlines both professional and personal to take care of over the next few days but I'm hoping to kick the tires next week. Let me know of your experiences so far.

UPDATE - since the beta period is over, the new url is now http://www.zend.com/en/products/studio/downloads 

7.24.2007

Zend Framework, Google APIs, Google Reader issue

I've been playing around with the Zend Framework and the Google API. I'm pretty bummed out that there doesn't seem to be any API for Google Reader. I was hoping to use Zend_GData_Query to suck in my starred and/or shared feeds. You can do this using getFeed() but I wanted to include the tags I've put on the entries. But I don't see my tags anywhere in the data, only the original "category terms" if specified by the feed author.

I even tried to do a login authorization with Google using Zend_Gdata_ClientLogin, but the public and private Google Reader URIs threw a hissy fit on me.

7.20.2007

Alpha Wordpress Plugin for Delicious with Zend Framework's Zend_Service_Delicious

I have Wordpress set up on PHP5. While Wordpress is largely a PHP4 entity, I wanted to see if it could play nicely with the Zend Framework, which is a PHP5-only entity. With some careful fiddling, it works pretty well.

With my Zend Framework code set up in my PHP include path, the first thing I needed to do to create a Wordpress Plugin was to enable my plugin to call the Zend Framework classes. First I tried this towards the end of my wp-config.php file:

require_once 'Zend/Loader.php'; 
function __autoload($class) 
{ 
  Zend_Loader::loadClass($class); 
} 


This caused Wordpress to freak out like a chihuahua on speed. Not good. I figured we'd have to do something special because we don't want ALL the classes to autoload, just the Zend ones. So I scrapped my previous __autoload and tried this instead:

require_once 'Zend/Loader.php'; 
function __autoload($class) 
{ 
  $pos = strpos($class, 'Zend'); 
  if ($pos !== false) 
  { 
    Zend_Loader::loadClass($class); 
  } 
} 

Ahh, success. Sweeter then a brownie sundae with extra chocolate sauce.

From there, the rest is easy. Here's some basic code for the rz_delicious plugin, a basic PHP file you can drop into your Wordpress Plugins dir. It uses Zend_Cache and Zend_Service_Delicious to put your del.icio.us bookmarks onto your Wordpress blog. It first checks to see if there's a cached version already, if not, it uses the del.icio.us API to fetch your latest bookmarks. It does some list formatting there too because I didn't feel like handling that in my theme.

< ?php 
/* 
Plugin Name: RZ Delicious 
Plugin URI: http://www.boringuys.com/ 
Description: YADelicious Plugin 
Author: Rich Zygler 
Version: 1.0 
Author URI: http://www.boringguys.com/ 
*/ 

/* 
called from theme via: 
get_rz_delicious() 
*/ 

function get_rz_delicious() 
{ 
  $output = ''; 
  $username = 'username'; 
  $password = 'password'; 
  $tag      = 'tagname'; 
  $numPosts      = 15; 
  $cacheTime     = 3600;      // seconds 
  $cacheDir      = '/tmp/'; 

$frontendOptions = array( 
  'lifetime' => $cacheTime,                  // in seconds 
  'automatic_serialization' => false  // this is default anyway 
); 

$backendOptions = array('cache_dir' => $cacheDir); 

$cache = Zend_Cache::factory('Output', 'File', $frontendOptions, $backendOptions); 

// we pass a unique identifier to the start() method 
if(!$cache->start('rz_delicious')) 
{ 
  try 
  { 
    $delicious = new Zend_Service_Delicious($username, $password); 
    $posts = $delicious->getRecentPosts($tag,$numPosts);  //$tag 

    if (count($posts) > 0) 
    { 
      $output .= '
    '; } foreach ($posts as $post) { $output .= '
  • ';
    $output .= $post->getTitle() . '
    ';

    $strTags = ' ( tags: ';
    foreach ($post->getTags() as $tag)
    {
    if ($tag != 'boringguys.com')
    {
    $strTags .= '';
    $strTags .= $tag . '
    | ';
    }
    }
    $strTags = trim($strTags, '| ');
    $output .= $strTags . ' ) ';
    }
    if (count($posts) > 0)
    {
    $output .= '
'; } } catch (Zend_Service_Delicious_Exception $e) { // largely ignore the delicious service error $output .= '
    '; $output .= '
  • del.icio.us service unavailable
  • '; $output .= ''; } echo $output; $cache->end(); // the output is saved and sent to the browser } }

4.11.2007

How to for SSH, Subversion (SVN), Putty, Tortoise, and Zend Studio 5.x using svn+ssh

Attempting to connect my new Windows machine with Zend Studio 5.1 using svn+ssh to an svn repository on Linux, I am obliged to once again stand on the shoulders of giants that have come before me. Here's some "how tos" that got me through it.
  • Logemann Blog - Subversion / TortoiseSVN SSH HowTo - Soup to nuts on how to set up both the server end as well as the client end of this ordeal. Includes ssh, ssh-keygen for generating keys, installing keys on client via Putty and Pageant, and using the ssh tunnel built to grab the repo via TortoiseSVN.
  • Zend.com Forums: Zend Studio => HOW-TO: Using SVN+SSH in ZS 5.5 - More ssh, ssh-keygen, installing keys on client via Putty and Pageant, and using the ssh tunnel with Zend Studio. (This seems to be missing one step for Zend to work though which is included next)
  • SVN - SSH connection produces errors - This post from the Zend knowledgebase adds the mysterious SVN_SSH environment variable that magically makes this work for Zend. NOTE - while they show this using the path to TortoisePlink.exe, you may also use Putty's Plink.

4.10.2007

Notes on upgrade from Zend Studio 5.1 to 5.5

Tony Bibbs writes about his painful upgrade from Zend Studio 5.1 to 5.5. While I'm a huge Zend fanboy, I noticed it looked a bit painful too and have stayed at 5.1 at both home and office.  Tony's main complaint is with remote debugging and the Zend Server vs Zend Platform issue.  I could never get the debugging to work in the first place.  I'm gonna sit and wait some more on this one.

7.05.2006

Zend Studio Tip of the day -- Bookmarks

Ever need to refer to 2 or more different places in a file while in Zend? You can bookmark the sections for easy manuvering through the file. Put your cursor on the line you want to bookmark, and either right click the line number on the left or hit "F2." Voila! A green bookmark has been setup.

How do you use this puppy? Easy. Take a look at the right hand side of the editor window and you'll see a green line that is clickable, right next to the scroll bar. Clicking there takes you to that bookmark. Even cooler, if you hover over the bookmark line there, it will pop-up the line of code that is bookmarked.

If you need to remove the bookmark, you do the same thing, right click on the line number of hit F2 again.

Until next time... Happy Zending!

6.01.2006

PHP Zend Studio 5.2 Released with license for Zend Platform

From the email:
Zend is pleased to announce the release of Zend Studio 5.2 - now including a free developer license for Zend Platform allowing you to increase the reliability and maximize the performance of your application before deployment.

I've already downloaded the update and installed.  However, it's not clear how you actually get the license for the platform.  Hopefully they straighten that out so I can start playing with it.

 UPDATE: How to get the Zend Studio Platform and get it licensed.

4.09.2006

Zend Inspectors Window

NOTE: Having recently started using Zend at work and at home for projects, I think it's a great product that has sped up my PHP development time quite a bit. I will therefore be posting some tips and tricks on its use in the following weeks.


The Inspectors Window displays the methods/functions and any included/required files for the PHP program that you are currently working on. For PHP class files, it will also show all the class variables (properties) and any other inherited methods.


To display the Inspectors Window in Zend, you can either go to the View menu and select Show/Hide Inspectors or click on the "Inspectors" area in the side navigation. Then you can click on the "File" button at the top of the window. You can also inspect all the files for a given "Project" but that's beyond the scope of this tip.


To test it out, bring up a PHP file that has functions in it, and look in the Inspectors area. It will show you all the functions available. It also shows the parameters that need to be sent for each function. If the function returns a value, the Inspectors window attempts to figure what data type the returned value is (that's why there's a lot of "unknowns" listed. The return value needs to be specified in comments using PHPDoc code (which will be a future tip).


Clicking on the function name in the Inspectors window takes you right to the code where the function is declared... kind of a function bookmarket. Pretty nifty.


When working with objects/class files, the Inspectors window is even more helpful. If you have any object inheritance, it will drill up into each parent object and show you those inherited methods as well. This means theres' hardly ever a need to do a print_r(get_class_methods($this));


If you have any questions on this, please feel free to ask. Until next time, happy inspecting!!

3.23.2006

Stupid Zend Humor

Here's a quick IM with another programmer at work

Tom (3/23/2006 1:49:54 PM): WHat did you do to my Zend?
Rich (3/23/2006 1:50:18 PM): nothin
Rich (3/23/2006 1:50:20 PM): why?

Tom (3/23/2006 1:50:37 PM): Froze for a minute
Rich (3/23/2006 1:53:12 PM): mine's been fine
Tom (3/23/2006 1:53:29 PM): seems better now
Rich (3/23/2006 1:53:55 PM): that's because I stopped running slow_toms_zend();
Tom (3/23/2006 1:54:05 PM):
Tom (3/23/2006 1:55:08 PM): You forgot the parameter: slow_toms_zend(xtra_slow_today);
Rich (3/23/2006 1:55:51 PM): there's a default set up in the function declaration:
Rich (3/23/2006 1:56:02 PM): function slow_toms_zend(xtra_slow_today = true)
Tom (3/23/2006 1:55:56 PM): and then there's the 'break his balls' parameter
Rich (3/23/2006 1:56:26 PM): no, that's a separate function
Rich (3/23/2006 1:56:47 PM): it's a public method in the PissTomOff class
Tom (3/23/2006 1:56:55 PM): ;-)
Rich (3/23/2006 1:57:00 PM): is it still slow?
Tom (3/23/2006 1:57:03 PM): No, but outlook crashed
Rich (3/23/2006 1:57:11 PM): Dude, you need a new computer. Or feed that hamster inside yours.