Subversion on Mac OS X

My workplace is switching from CVS to Subversion for source-code version control so I need to pick up Subversion rather quickly. It took me awhile to get comfortable developing with CVS and now I need to learn stuff all over again. I even have scripts setup to help with the deployment of my project using CVS -- now they need to be modified to work with Subversion. Oh well, I'm sure its for the best.

I've been reading the awesome, and free, Subversion book a lot lately and it has really helped with my understanding of how Subversion works. Since Subversion is not installed on OS X by default, we need to install it before using it from the command line. I downloaded the easy-to-install Subversion .dmg distributed by Martin Ott.

After running the .pkg-installer I was able to run svn help from the command line to confirm it was installed properly. If that command doesn't work after installing, you may need to add this line to the .profile file (in your home directory):

export PATH=$PATH:/usr/local/bin

Now you should be able to run all the SVN commands from your Mac OS X command line. If you prefer a GUI interface to SVN, check out svnX. I do all my development from within Eclipse, so I'm using an SVN plugin for Eclipse called Subversive. I prefer it over the more commonly known Subeclipse plugin because Subversive has a friendlier, and seemingly more configurable, interface.

Checking out a project from the command line over SSH is really simple, however while searching Google I was unable to find this "simple" answer. If I had found the free Subversion book before searching for this answer, I probably wouldn't be writing this:


svn checkout svn+ssh://svn.dev82.org/projects/myproject

That's it! The syntax for checking out a project is very similar to CVS, however SVN has the concept of "URLs" to specify the location and type of connection to your repository. If you have SSH Client Keys setup, you can run SVN commands over SSH without the password prompt (which is necessary for the deployment scripts I use).

slGrid: Edit Mode without Add or Delete

I've been customizing slGrid for an application I'm developing at work. One of the things I needed to do was to enable the MODE_EDIT but at the same time prevent additions or deletions.

To prevent deletions, there is an option in /classes/gridclass.php called $editmode_delete, which you can simply set to false to prevent deletions and remove the 'Delete' column. However, this creates another problem: While editing a row, the 'Delete' button and the 'Cancel' button share the same column:

So by disabling deletions, we're giving up our 'Cancel' button. This means the only way to get out of edit mode after clicking the 'Edit' button, is to refresh the page. OK, so thats not the end of the world. Lets continue.

Our next problem is insertions -- we need to prevent users from adding new rows. I saw the $editmode_add option in /classes/gridclass.php, and assumed it would be as simple as changing it to false. But to my surprise, that only removed the 'Add' button, leaving the entire (empty) insertion row at the top of the table:

Well that doesn't make any sense. If there is an option to disable insertions, why leave the unused empty row? After lots of digging I finally found the block of code that needs to be commented/removed to prevent the empty row from loading:

gridclass.php:

						if ($this->mode == MODE_EDIT)
			{
				$insert_row = array();
				$row_index = -1;

				foreach ($this->columns as $column)
					$insert_row[$column->name] = "";

				$this->CreateRow($insert_row, $row_index, $visible_row_index, $table_main);
				$row_index++;
			}

After commenting out that block of code, I finally have what I want; slGrid in Edit Mode without the ability to Add or Delete:

I'm going to be working with slGrid a lot now and I'll be tweaking/customizing it quite a bit. I will be sure to share everything I learn here on my blog for others who may wish to use it.

Software Project Requirements

Requirements Toon

When it comes down to defining a exactly what a piece of software needs to do and what customer wants the software to do, there is often misunderstandings due largely to a gap in the understanding of technology. The customer is not expected to understand how the software gets the job done, just that it gets done correctly. The programmer needs to understand exactly what end result the customer expects and write the software accordingly.

I found this image here. I couldn't find any information on the author of the image or where it originated, but please let me know if you do.

Link Action plugin for slGrid

There was recently a plugin system added to slGrid, which is great because I recently found the need for a plugin that creates a link around specific cell content and decided to write one.

Link Action allows you to create a URL around the contents of a cell using the unique database column ID. It also allows you to pass the target page for the URL and optional URL arguments. If no target page is passed, it defaults to the current page calling the grid.

<?php
/*
 * Example usage:
 * $_SESSION["grid"]->SetPlugin("Full_Name", "link_action", array("target" => "users.php", "extra_args" => "&action=edit"));
 *
 * Assuming the database column ID is 24, and the Full_Name is Raam Dev, here is what the cell would contain:
 * Raam Dev
 */

require_once('class.plugin.php');

class link_action_Plugin extends Grid_Plugin
{

	function introspect()
	{
		return(array(
			"name" 			=> "Link Action",
			"description" 	=> "Creates a URL to call an action using the unique database column ID",
			"author"		=> "Raam Dev ",
			"version"		=> "1.0"
			));
	}

	function generateContent($cell, $args)
	{
		if(empty($args["target"])){
			$args["target"] = $PHP_SELF;
		}
		if(empty($args["extra_args"])){
			$args["extra_args"] = "";
		}
		return("$cell");
	}
}
?>

slGrid, Ajax-Based PHP Grid Component

I found an absolutely awesome application called slGrid. It was recently bought by Senza Limiti, a technology consulting company based in Slovakia. They've since made slGrid an open-source application, which is very cool. It uses AJAX and PHP to provide an interface for creating grids by loading content directly from a database. You specify the table and fields, and it takes care of the rest. Check out the slGrid demo to get a better idea of what it does.

Using slGrid is literally as easy as this:


<?php
	$_SESSION["grid"]->SetDatabaseConnection("database_name", "user_name", "password");
	$_SESSION["grid"]->SetSqlSelect('field1, field2', 'table');
	$_SESSION["grid"]->SetUniqueDatabaseColumn("id_field", false);
	$_SESSION["grid"]->SetTitleName("slGrid");

	$_SESSION["grid"]->PrintGrid(MODE_VIEW);
?>