Written by davidonzo on 15/05/2008, Filled in MioBlog, Video
Written by davidonzo on 14/05/2008, Filled in OpenSource, Tutorial

Reflection using Gimp at davidonzo.comDo you love 2.0 style reflection? Somebody tell you, photoshop is needed to do it? Nothing true! Use The Gimp (the best open source image creator).

Let's see hot to do it.

 

Ho to procede

Create a new image using the prefered dimensions e background color. Past the image to reflect as new layer, or use the text tool to write your desire text (using Gimp any new text added is a new layer).

 

Don't forget to show the Layers tab, selecting it by the Dialogs menu.

 

Select the target layer and click on "Copy Layer" Copy Layer at davidonzo.com. Select the new layer (rename it if you want) and click on menu Layers >> Transform >> Rip Vertical.

 

rip vertical at davidonzo.com

 

Using the "Move" tool, drag the layer until the heightest side touch the bottom side of the parent layer. See the example below:

 

example at davidonzo.com

Now, always selecting the transformed layer, add a layer mask clicking right on it. Choose the first option in the dialog below.

 

mask at davidonzo.com

 

Select as main color:

  • Black for the FB (#000000)
  • Withe for the SB (#ffffff)

Use the gradient tool gradient tool at davidonzo.com with the FB to SB option selected and drag a line from bottom to up to apply it. Make differents test to get the best result. At the end you'll have something similar to the first image of the post.

Written by davidonzo on 12/05/2008, Filled in OpenSource, Plugin

wordpress myfeed plugin at davidonzo.comSomeone ask me to release it. I did it and now is available for all. MyFeed is a WordPress plugin that allow you to costumize as well as possible your feed content.

 

What can I do?

- You can choose how many paragraphs to show in your content feed. So, if you don't want to give a complete feed, but don't want to use the MORE tag and, at the same time, don't love use excerpt content as your content feed, you'll be able to give a custom uncomplete post independent by the original content, with all you formatting settings.

 

- Choose an anchor link for the "Continue Reading" link that appear at the foot of the feed content.

 

- Choose some text to show before any post in the feed.

 

- Choose some text to show after any post in the feed.

 

These last two options are very usefull to insert advertising in your feed. HTML are supported, so you can insert images and any other available html content.

 

How To Install

Download the zip archive, decompress it and copy the file myfeed.php into your wp-content/plugins folder. Join your blog CP and activete it as any other WP plugin. Go to the options page to configure it.

 

Notes

MyFeed has an activete / disactivate option indipendent by the plugin list manager of the WP control panel. So you can turn off the plugin without deactive it.

 

Any option is totally indipendent by the other onse. By this way, the user have total control and great customization power for his feed.

 

I don't know if this plugi should be so usefull. However it's on your avaibility. And remember, this plugin is released and distributed under the terms of the GNU/LGPL.

Written by davidonzo on 09/05/2008, Filled in OpenSource, Web, Tutorial

JavaScript is often used to provide more contemporary routines in the same web page. This may give problem if the function, written using a regural contruction, is able to be instanced just one time.

 

To avoid this limit - is a natural limit depending by the code style used by the coder - it's necessary to build an object. This will be able to create differents instances and to use methods for any instance without create conflict with other variables and functions called by others instances.

 

Will go to define different functions inside an object constructor called using how many instances we need to create. Any instance will be able to use all the methods defined inside the object regardless from other instances.

 

To have a better idea what we are talking about, let's see an easy example where use innerHTML.

 

function showText('text', 'id'){
  this.text = text;
  this.id   = id;
 
  this.g = function(){
    return document.getElementById(this.id);
  }
 
  this.show = function(){
    this.g.innerHTML = this.text;
  }
}

first = new showText('Hello World!','myId');
first.show();

second = new showText('Hello Web!','myOtherId');
second.show();

 

The example may appear poor, but using a constructor on more complex functions, your life may be better and your coding powerful ;)

Written by davidonzo on 27/04/2008, Filled in OpenSource, Web, Tutorial

wordpress at davidonzo.comNow let's see how to create a WordPress plugin. Why this post? Often WP users active a plugin and use only the 5% of its features. Is not a good choise. There are people who boasts of using 50 or more plugin. IMHO they just wrong CMS :)

 

In any case plugins help us to make several chenges in our blogging platform without change che core code and the template used, just activating / disactivating a file by the control panel.

 

Now, to explane how a WP plugin can be create, we'll see the needed operation to produce a simple plugin showing a fixed text before any post. Really unusefully plugin, but with clear didactic purpose.

 

How To Begin

First of all, it's very important read the documentation released by the WP team, to know as well as possible all the functions availables given by the wp core.

After this, you have to know that wordpress use a single database field to activate a plugin. The informations concerning the actives plugins are stored in the wp_options table (where wp_ is just the table prefix) in correspondants of the "option_name = 'active_plugins'" value.

All plugins file are stored in /wp-content/plugins/.

 

Begin Writing

With our favorite text editor create a new document called myplugin.php. After the php open tag, it must be inserted some comment line that will be used by identify the plugin name, author, version and description.

 

<?php
/*
Plugin Name: Just a test plugin
Plugin URI: http://www.davidonzo.com/
Description: Just a simple plugin to show how wordpress plugins work and can be create.
Author: davidonzo
Version: 0.1
Author URI: http://www.davidonzo.com/
*/

 

  • Plugin Name: choose a funny name for your plugin.
  • Plugin URI: have you publishe a post or an entire web site for the plugin?
  • Description: write a short description of the plugin. In one line. Break line will erase the content!
  • Author: your name.
  • Version: the versione number of the plugin.
  • Author URI: your link.

These informations will be showed in the management plugins page of wordpress's admin control panel.

 

The necessaries functions

What do you need to make the plugin? We said we want to create a plugin tha add a fixed text, choosen by the user, before any post. So, we need an option where writing the text and another one where we'll use as a boolean value to make the visualization active or not.

 

To make it easy, we choose to save both options in just one record. Using a text separator between the string to provide a simply explode() string that extract the needed value. In this case we will use %%%.

 

Now, we need to know that the plugins options are stored in the same table used by WP for the others system options: wp_options. We che easly create new options just using a function available in the WP core: add_option($nameoption, $value). The option's $value will be stored in a longtext field.

 

During the plugin installation a new option will be created, assigning it the default values. Let's see who to do it!

 

function myplugin_install(){
  if(get_option('opt_myplugin' == '') || !get_option('opt_myplugin')){
    add_option('opt_myplugin', '0%%%Write some text');
  }
}

if (isset($_GET['activate']) && $_GET['activate'] == 'true') {
    myplugin_install();
}

 

On plugin activeting, if the option named opt_myplugin doesn't exist or is empty, the option will be added to the database with the default values.

Note that this function will be loaded for any activating action, but the default value and the option creation will be execute just at the first activation. So, deactiving the plugin, the latest values inserted will be saved and used after the new activation.

 

Now we need a pege inside the WP control panel, to manage the options. First of all, we add a link to the main menu of the settings page. Of couse we'll use a wp core function :)

 

function myplugin_config_page(){
  if (function_exists('add_options_page')){
    add_options_page('MyPlugin Menu Title',
                     'MyPlugin Option',
                     8,
                     basename(__FILE__),
                     'myplugin_config'
                     );
  }
}

 

To work correctly, add_option_page function need some variable.

  • The title of the destination page.
  • The anchor link for the title menu.
  • The access level required to manage the settings.
  • The file must be loaded.
  • The callback function contained in the loaded file, that create the page.

Well, let's see the callback function.

 

function myplugin_config(){
  $active   = (myplugin_option('active') == 1) ? 'checked' : '';
  $deactive = (myplugin_option('active') == 0) ? 'checked' : '';
  print('<div class="wrap">
         <h2>MyPlugin Options Tab</h2>
          <form id="ak_sharethis" name="myplugin_cnf" action="'.get_bloginfo('wpurl').'/wp-admin/index.php" method="post">
            <p>By this page it\'s possibile configure the plugin. Setup the following options to start testing how a wordpress plugin works!</p>
           <fieldset class="options">
            <p>Show some content before any post?</p>
               <ul>
                 <li>
                   <input type="radio" name="c_before_post" value="1" id="c_before_post_yes" '.$active.' />
                     <label for="c_before_post_yes">Yes</label>
                 </li>
                
                 <li>
                   <input type="radio" name="c_before_post" value="0" id="c_before_post_no" '.$deactive.' />
                     <label for="c_before_post_no">No</label>
                 </li>
               </ul>
              
               <p>Type the contet text to show:</p>
                 <input type="text" name="c_text_myplugin" value="'.myplugin_option('text').'" /> 
            </fieldset>
           <p class="submit">
        <input type="submit" name="myplugin_submit_button" value="Update Settings" />
       </p>
      </form>
         </div>');
}

 

Just HTML containing an usefull form to manage the main plugin's options. Nothing more, nothing less :)

Ok, now we have a form to manage the option, but, how can we update them? Just writing another function.

 

function update_myplugin_settings(){
  if($_POST['myplugin_submit_button'] == 'Update Settings'){
    $newsetting = $_POST['c_before_post'] . '%%%' . $_POST['c_text_myplugin'];
    update_option('opt_myplugin',$newsetting);
    header('Location: '.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=myplugin.php&updated=true'); 
  }
}

 

Using update_option (another WP core function) we can easly update any option just declaring as first argument the option to update, and as second argument, the value to assign.

To execute it, just use add_action.

 

 

add_action('init', 'update_myplugin_settings', 9999);

 

Using the tag init and a height priority (9999) this action will be performed any time the plugin file is requested. But read the callback function as well: the real option update process will run just when it receive a particular POST data.

 

Now we have a page who manage the options, we can update them, we can activate the plugin as well, but, where is the function who chage my wordpress front-end?

 

function add_myplugin_text_to_content($content){
  if(myplugin_option('active') == 1){
   $content = '<p>'.myplugin_option('text').'</p>' . $content;
  }
  return $content;
}

add_action('the_content', 'add_myplugin_text_to_content');

 

Just a simple function, activated when the_content() function run, that replace $content variable.

 

Do you want to download this example wp plugin? Just click here :)

Written by davidonzo on 26/04/2008, Filled in MioBlog, Foto, PodCast

Jeeb Robot D'Accaio

 

The italian movie's theme.

Written by davidonzo on 24/04/2008, Filled in OpenSource, Web, Tutorial

A simple function to read a cookie value.

 

function CookieValue (offset) {
  var stringend = document.cookie.indexOf (";", offset);
  if (stringend == -1)
   stringend = document.cookie.length;
  return unescape(document.cookie.substring(offset, stringend)).replace("+"," ");
}

  function GetCookie (name) {
   var argu = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var none = '';
   var i = 0;
   while (i < clen) {
    var a = i + alen;
      if (document.cookie.substring(i, a) == arg)
        return CookieValue(a);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break;
  }
 return none;
}

 

How to use it?

An example may be the best way to understand hot to use this code. Assum you have a cookie named "MyCookie" with value "MyCookie+Value".

The function:

 

GetCookie('MyCookie')

 

Return: "MyCookie Value".

 

I'm working hard in this period. I hope to have more time to update the blog ASAP :)

Written by davidonzo on 20/04/2008, Filled in MioBlog

When I decided to write this blog begenning from a blank text file, I start coding because I relized most famous blogging platform (like WordPress of course) have a number of serious shortcomings. One of this is no real multilanguages system.

To translate and publish your posts in differents languages, it necessary manage another blog, installed in a subdirectory of the server or in a different third level domain.

 

This is why I decided the killer function of this blog should have been a native multilanguage support. And after two work days on this weekend, finally a beta version is on line!

 

Below the title of any translated post will appear a flag for any available language. It will be possible surf the blog in differents active languages, and the content will be filtered to show only translated items. A separated feed will be also available for each active language.

 

By now, when I decided the post could be interesting also for none italians reader, I'll translate it in english. Just remember, this is not my native language, so forgive me for any error and feel free to correct me :)

Written by davidonzo on 15/04/2008, Filled in OpenSource, Web, Tutorial

TextScroller is a JavaScript library that permit to scroll the text of the target ID of the web page. It's easy to use, easy to configure and require just javascript enable on the browser's client surfing you web pages.

 

How to setup the script

Using your favorite text editor open the file named textScroller.js and assign the values to the following variables:

 

  var orientamento = '';
  var parent = '';
  var duration = ;
  var h = ;
  var w = ;

 

var orientamento (array)

Choose the prefered scrolling direction:

  • TD: from top to bottom;
  • DT: from bottom to top;
  • RL: from right to left;
  • LR: from left to right;

 

var parent (string)

The ID element containing the scrolling text.

 

var duration (integer)

Scrolling speed. Bigger means slowest and vice versa.

 

var h (integer)

The height value of the scrolling ID. By this way you can choose the height of the scrolling text.

 

var w (integer)

The width value of the scrolling ID. By this way you can choose the width of the scrolling text.

 

Impostare il codice HTML

Between the <head> tags insert this line.

 

<script type="text/javascript" src="textScroller.js"></script>

 

Warning: consider the relative positione of the file. Writing the line exactly as above, the js file must be in the same folder of the html file.

 

Inside the <body> tag:

 

<body onload="letsGo()">

 

Inside the page, insert an element identified by the ID you want to scroll.

 

<div id="parent">
    Testo da scrollare
    Testo da scrollare
    Testo da scrollare
</div>

 

Degradability

The code is degradated. When the client has JavaScript disabled, will be loaded the CSS directives written in the stylesheet.

 

Extra Style

You can add extra style directives by adding css information for the id named width child- prefix and the ID of the scrolling element.

 

License

GNU/GPL v.3.

 

Demo

Click Here :)

 

download textScroller at davidonzo.com
Written by davidonzo on 31/03/2008, Filled in MioBlog, Tutorial

If your audio streaming of any media player suddenly seems to be dead and the system get you errors like "XYZ is not a valid Win32 application", maybe your quartz.dll is corrupted.

 

Browse your /system32/ directory and check the dimension proprierty of quartz.dll. If the file doesn't exist or he have zero dimension, download and replace it. No reboot is required!

 

Do you want to know why a system file can corrupt itself without a valid reason? Send an email to unclebill@microsoft.com.