Blog

Development on the Zed X CMS

Wednesday, February 24, 2010

The Zed Said Studio Blog has been quiet for some time, and I wanted to let everyone know the reason.

I have been working on a brand new project that, has nothing to do with MySource Matrix. Which, is slight surprising since I love it so much! But, I have come to a point where I need a customized CMS for clients of mine that are not able to use MySource Matrix. Over the past year I have looked for a solution to this problem, but I have not been happy with what I have found. Coming from the world of Matrix, I expect a lot out of a CMS. So, I was looking for certain features that I did not find.

So, I have set out to write my own CMS that has the features that I want, runs on shared hosting, and will provide the power and flexibility that I need. Clients don't like to be told that they have to pay for a totally new host, that is 2x the amount that they are currently paying. They don't want to hear all of those details, they just want their website online, and they want to edit/manage it with ease.

So, this is the focus of my new CMS, is ease of use, and focus on easy editing as well as tight keyword integration across the CMS. I am pretty excited about this new project, and it has been coming along nicely. So far, the MVC has been built, as well as the DB integration, base function and interfaces.

One thing that is really needed is a designer for this project as well as a new name. When I started this, I figured Zed X would be nice, but now, I am not so sure. The CMS will be GPL in the future, but not for some time and there is plenty of work to still be done. But, if you are interested in helping with design, your talent and name will definitely be seen throughout the project.

I will continue to post updates here about how the progress is going, let me know if you have any questions!

Custom Development in MySource Matrix

Sunday, October 4, 2009

I spent a good part of my day working on the MySource Matrix Community, which is soon to launch.  In doing so, I realized that the MySource Matrix Javascript API was lacking a few features that I needed.  I wanted to restrict to a few different root nodes, but my asset only allowed for one to be added.  So, I went off looking through other Matrix assets to understand how I could add a root node chooser that allows multiple roots.

Root Node Selector

In order to add the new multiple asset finder (as Matrix calls it) I had to add my own custom print and process functions to that attribute.  For these functions I used the following:

/**
	* Paints the root node selection box
	*
	* @param object	&$asset	asset being painted
	* @param object	&$o		backend outputter
	* @param string	$prefix	prefix for the html doc element name
	*
	* @return boolean
	* @access public
	*/
	function paintRootNode(&$asset, &$o, $prefix)
	{
		$write_access = $asset->writeAccess('attributes');
		$curr_list = $asset->attr('root_node');
		
		if ($write_access) {
			multiple_asset_finder($prefix.'_roots', $curr_list, Array('asset' => 'D'));
		} else {
			if (empty($curr_list)) {
				echo translate('js_api_no_root_nodes_selected');
			} else {
				?><ul style="margin:1px 15px;"><?php
				foreach ($curr_list as $assetid) {
					echo '<li>'.get_asset_tag_line($assetid).'</li>';
				}
				?></ul><?php
			}
		}

		return $write_access;

	}//end paintRootNode()
	/**
	* Processes the value input from root node selection box
	*
	* @param object	&$asset	asset being painted
	* @param object	&$o		backend outputter
	* @param string	$prefix	prefix for the html doc element name
	*
	* @return void
	* @access public
	*/
	function processRootNode(&$asset, &$o, $prefix)
	{
		$roots = array_get_index($_POST, $prefix.'_roots', Array());
		$root_list = Array();

		foreach ($roots as $root) {
			if (!empty($root['assetid'])) {
				$root_list[$root['assetid']] = $root['assetid'];
			}
		}

		return $asset->setAttrValue('root_node', $root_list);

	}//end processRootNode()


The important part of the first function, that actually prints the root node selector, is the multiple_asset_finder() function. This takes a few different parameters, including the assets prefix and an array of values saved in the asset attribute.

In our processing function, we have to manually grab our newly set values from the $POST array and set them as attributes using the setAttrValue() function.  Once this was done, we finally had an asset chooser that could selected multiple root nodes.

My other two tasks were to add a new attribute called ignore_permissions and remove the API key from displaying unless a user had acquired a lock.  Both of these were relatively easy to add.  The ignore_permissions functionality only required some small changes in the js_api.inc file as well as adding it to the normal places to add a new attribute.  It was added so that a user does not have to have permissions in order to call functions such as createAsset() or setAttributes().  

Making sure that the API key is not displayed until a user has acquired a lock is a security precaution.  If you have users in your system that have read access to assets, they could easily view the details screen of an API asset and copy down the API key.  Now, with this additional feature, users will have to be able to get locks on the attributes before seeing the key, meaning that they have to have write access to the asset.

All in all, it was a nice day of programing and getting work done on the MySource Matrix Community.  As the Community continues to evolve, I am sure there will be more features that I will need to write into the API.  

I will be submitting these new features to Squiz, so I am assuming they would make it into 3.24.2 next month.

Using the MySource Matrix Javascript API - Part 1

Wednesday, September 30, 2009

I thought that since I am the one that wrote the MySource Matrix Javascript API asset, that I should probably write up a post about it, give it some background, and show some cool examples of its use.

First, the Javascript API is part of the Web Services package. This has been added to 3.22.2 as well as the 3.24.x branch. If you don't have a copy of it, visit the MySource Matrix site to download a new version of Matrix.

This asset come about because I really wanted a way to use javascript to get things like asset attributes, metadata and web paths. I was tired of always having to build asset listings and nest them just for something small. I also wanted the data returned to be in a format that we could easily use in javascript. So, I built the API to return JSON which then gets converted into a javascript object. Below, you will see how to implement the MySource Matrix Javascript API. If you have any questions about this, please post a comment.

Setting the API Key

The first step needed when setting up the Javascript API is to set the API key. This key needs to match the key that you configured on the Details screen of the Javascript API asset. A special function is called that sets the key to a global variable, which can then be used by other API functions.

setApiKey(1057909564);

Using an API function

Almost all of the API functions requires that an asset be specified as the first parameter. Please note that you can use either an asset id OR the web path to the asset. Either of these will work as the first parameter. All of the functions are different and require different pieces of data to be passed in. If you would like to see all available functions as well as parameter definitions, you can take a look at the API javascript file itself: http://www.zedsaid.com/_services/blog-demo.js

Using the returned JSON

When a function from the Javascript API is used, it returns JSON. This can be easily seen when using Firebug, you can watch what the API returns as a response. But, if we want to use that response within our page, we have to utilize the custom callback that is added as the last parameter of each function.

getGeneral(1234, function(data) {
	alert(data.name);					  
});

The following button will run the getGeneral() function for asset #1234 and return the asset name.

If we want to get additional information about the asset, we can do the following:

getGeneral(1234, function(data) {
	alert('Name: '+data.name+'\n'+
		'Short name: '+data.short_name+'\n'+
		'Asset id: '+data.id+'\n'+
		'Type Code: '+data.type_code+'\n'+
		'Status: '+data.status+'\n'+
		'Created user id: '+data.created_userid+'\n'
	);					  
});

Handling errors

If something goes wrong, the API will return an error. You can set up your callback function to account for this, and show the error if it is returned. We can use a helper function, isset() that is included with the API. This is similar to the isset function in PHP, as it checks to see if a variable in javascript has been set.

getGeneral(50000, function(data) {
	if (isset(data.error)) {
		alert(data.error);					  
	} else {
		alert(data.name);					  
	}
});

Conclusion

This is just the first part of my blog series on the MySource Matrix Javascript API and it really only scratches the surface. In my next post, I will show some more intermediate implementations, and how you can use the API to build things like select lists, populate fields and create assets. Stay tuned.

Website Downtime

Saturday, August 8, 2009

Some of you may have noticed that Zed Said Studio was down for a few days.  This was due to my DSL router dying, and me franticly driving around Napa, CA trying to find another to replace it.  Long story short, I ordered one from Amazon.com and finally got it set up and Zed Said is back up and running.

I would say that this is definitely one of the issues of running a website from your home.  An unreliable connection is not something that I love to deal with.  But, it saves me money each month as hosting Matrix elsewhere would cost me at least $20/month.

Thanks for checking back, I will have some new interesting blog posts up ASAP.

MySource Matrix Javascript API Asset Released in 3.22.2

Tuesday, July 7, 2009

Javascript API Asset

I am very excited to say that I just got another asset that I built added to MySource Matrix. This time, it is the Javscript API asset that I wrote, and has been added to 3.22.2. The Javascript API asset is now part of the Web Services package, but is itself a GPL asset, so you can download it for free.

Right now the Javascript API asset is at version 1.0 and includes the following features:

  • Returns a JSON object to asset calls.
  • The asset will act as a normal .js file when no data is sent to it, but if key, id, and type are sent it will return JSON based on the function called used.
  • Error checking is included to make sure that the user does not try to send incorrect data, and return incorrect data. Errors are also logged in the normal error log as well as returns a JSON error.
  • Currently, the API has the following core features: Get General Info, Get Attributes, Set Attributes, Trash Asset, Get Metadata, and Set Metadata.
  • A root node can be set, to restrict API calls to a specific location in the tree. Error checking makes sure that this is enforced.
  • Slick new icon. :)
  • API Key is set using the setApiKey() function. e.g., setApiKey('123'); This sets the key as a global variable for all functions to use and is required to use the API.
  • All "get" functions have an optional callback, that is passed as the second parameter in the function.

It is exciting to have yet another asset added to MySource Matrix. I am continuing to work on new features for this asset, as I really feel that it will benefit many!

Feel free to let me know what you think and go download MySource Matrix 3.22.2!

Validation Blog

Wednesday, June 17, 2009

Valid Blog

So, today I finally acted on an idea that I had had for a long time. I built a blog that is all about XHTML valid websites, and how so many people don't even care. The blog will be focusing on big name sites, all of which have stupid validation errors, like ampersand issues and missing alt attributes. Basically this is a place for me to rant about how much it frustrates me when web developers don't care about validation. Take a look at my new, "other" blog, and let me know what you think!

Visit my Validation Blog »

« Previous Page | Next Page »