Tuesday, November 24, 2009

Lightbox

So, following on from the last post i've added a simple Lightbox. This needs to allow users to:

  • Add images to lightbox at various places

  • View images in their lightbox and remove one or more



At the moment a user will have a single lightbox; it's not designed to be a galleries type of system; its simply a 'bucket' to add images to in readiness for buying and downloading them.

So, its relatively straightforward; i added a component with one page and a couple of tasks; all the tasks result in the user being presented with their lightbox; the tasks them selves define whether an image (or images) are added to the lightbox or removed. The default task simply bypasses the processing and goes to the lightbox view/page.

Session
The one wrinkle is that a lightbox can be created in session by guest users OR if logged in the lightbox is saved and persists across sessions. This means that the processing has to check at various stages whether the current user is logged in. This is achieved by this code:


$user =& JFactory::getUser();
if (!$user->guest){
...
}


This 'if' block will run for logged in users. So all we do at each stage is to check if the user's logged in and then add to d/b and session (or just session) accordingly.

Both cases put the list of lightbox items in the session:


$session =& JFactory::getSession();
$session->set('PJ_IMAGES',$images);


where '$images' is an array of image 'objects'.

This object list is created from a SQL statement and the array built using
$rows = $db->loadObjectList();
; it also uses some JoomGallery helper functions.

Parameters
One thing I needed to add is the use of component parameters; these are global parameters and will beused to hold how much various images cost and need to be available in the Admin interface.

To add these is simple:


  • Add a 'config.xml' file describing the parameters

  • Add a toolbar button



the 'config.xml' file I put into the 'admin' folder (and added to the list of files in the component XML descriptor file:


<?xml version="1.0" encoding="utf-8"?>
<root>
<params>
<param type="text" name="sml_image_price" size="3" label="Small Image Price:" description="Please enter the new price" />
<param type="text" name="med_image_price" size="3" label="Medium Image Price:" description="Please enter the new price" />
<param type="text" name="lrg_image_price" size="3" label="Large Image Price:" description="Please enter the new price" />
</params>
</root>


The toolbar button is added programatically. If you dont have a default admin landing page already, create on, in the 'admin' folder root called COMPONENT_NAME.php and add this code:


<?php
JToolBarHelper::preferences( 'com_COMPONENT_NAME' );
?>


And that's it; go to the component in the admin interface and hit the Parameters button.

Friday, November 06, 2009

JoomGallery & Image Selection

Given the use of JommGallery for image handling and processing, the next step is to allow users, when they find images they like, to add them to a 'lightroom' or 'lightbox'.

Essentially the user willbuild a list of selected images and then needs to be able to manage that list of images.

I feel a new component coming on. Use cases are


  • User searches, finds image(s) and selects one or more to add to lightroom

  • User wants to view lightroom

  • User wants to remove images from lightroom

  • User wants to buy & download images from lightroom

Thursday, November 05, 2009

Thumbnails and JoomGallery

so, with JoomGallery working well, i now need a way to create multiple thumbnails.

JoomGallery automatically creates one thumbnail on upload; i want to intercept that and create 3.

So, there are a couple of ways of doing that;

  • amend the JoomGallery code and add the extra code

  • amend the JoomGallery code to trigger and event and write a plugin to create the thumbnails



The latter is more appealing; we can control/maintain the image sizes by adding parameters to the Plugin and then use those in the code.

Update: Part One
added this to classes/upload.class.php:


$dispatcher =& JDispatcher::getInstance();
//$results = $dispatcher->trigger('onJoomCreateThumbnail', $params);


So, need to populate 'params' and the write the plugin to handle it. Beauty is we can re-use JoomGallery's functionality to create the thumbnails for us.

Tuesday, November 03, 2009

Uploads, Files, Components and Permissions

There's an underlying issue when you have a hosted Joomla.

The host invariably runs your site as the Apache account owner (apache or httpd).

You log in to manage your account using your own site using a different account.

When you install components (by default) Joomla's set up to use file uploads, i.e. the new folders etc are created as using the Apache account which differs (possibly) to the account the Joomla installation is crested under.

This has given me issues amending single files in components/plugins that i've installed via the Admin interface.

So, i've just installed joomlaXplorer and i have to say, it rocks.

I've left the ownership alone so that i can uninstall etc, but i can mod file permissions so that i can at least amend files.

Tuesday, October 20, 2009

Content Component

The main content creation needs enhancing.
What i need is for a user to create an article, entering all the usual fields (description, title etc) as well being able to select an image.

Upon submission, the JOS_CONTENT item is created and the image is uploaded and saved to the users directory.

Why a new component? At the moment when you add an image its put into a general pool; not segregated by user, which i want to be able to do.

Components like JoomGallery use new tables which i don't want also i need to post-process adding watermark and creating resized versions.

So, to do this i'll need to create component to add/update content entry and processing to do the above.

Update
What i've done first is to create a new plugin that, on the event onAfterStoreUser uses the user's username and creates a new folder under the Media Managers Image Path.

All images will then be held under this folder.

Thursday, October 15, 2009

Search Plugin

Ok,
having finished a first pass at the component so search for 'Author' type users, i now want to search for that authors content when the user selects one of those Authors.

Best way seems to be a search plugin.

So, starting point is here. More to follow as i develop it.

Update #1 - Implementation
All we need to do is create an XML descriptor (authorcontent.xml) and a Php file to perform the search (authorcontent.php).

Update #2 - Using It
Ok, creating the search plugin is simple as detailed here.

Having developed the plugin we need to trigger it and use the results.

A sample of using it can be found in the standard search component (com_search/models/search.php).

Using it will be something like:


JPluginHelper::importPlugin( 'search');
$dispatcher =& JDispatcher::getInstance();
$results = $dispatcher->trigger( 'onSearch', array(
$rows = array();
foreach($results AS $result) {
$rows = array_merge( (array) $rows, (array) $result);
}

Wednesday, October 14, 2009

Custom Search Component #2

Following on from before, i've completed part one of this component. I'll not go into too much detail, but if you want a copy, email me.

What i will do is outline what it does (functionally) and then outline how it's been put together in terms of files and configuration.

Functionality
There are 2 screens; the first presents a search input box in which the user enters some text; the second screen presents the results, if there are any.

The search uses the above text to search JOS_USERS using the above string comparing against the NAME column.

Implementation

Using the MVC pattern, Joomla separates the functionality into several pieces.

Entry Point
The entry point file simply creates an instance of the controller and tells it to run the method pointed to by the requests var parameter (or defaults to display).

Controller
Has methods to pull together the model, views etc. In this case we have two methods:

  • display - default method

  • exec_search - called from the search parameter form; gets the view, assigns model to the view and calls the views display method



Views
The views pull together data and present the template. There are two; one default one does nothing and shows the default template (search input screen); a second which executes the search using the inputted screen data and puts the results into the JView class.

Models
There are 2 models; the default one which simply invokes the default template; a second which uses the search term, executes a search and returns the rows.

Monday, October 12, 2009

Custom Search Component

Ok, next step.

I need to search my user-base for Authors (based on title, first, middle and surname) and then present a list of them. Then, when selected i need to show their list of content.

Seemingly, there's nothing to do that, so i'll have to do it myself. i'll document as i go. I'm starting with this tutorial.

Update #1
Right, its quite straightforward create your own component; at least so far it has been. The first step, for me, was to get a simple component installed and running; i can then get it to do fancy stuff after that.

The link above was right on the money (as it should be i suppose!), the only difference being that the guide above put everything in a site folder for some reason. I didn't; i looked at the other standard components to see how they did it and there was no sub directory.

So, the order to creating my new search was


  • create a new development directory say, and within that create a directory called com_xyz where xyz is the name of your component.

  • Under that the entry point Php file xyz.php

  • Add a controller.php as well; this contains the controller sub-class, e.g. XYZController

  • Create a view class to pull together the data you'll need in the scrren(s). This file is views/xyz/view.html.php

  • Create a default template called views/xyz/tmpl/default.php for presenting the information

  • Add an XML descriptor holding metadata about the component.



So, thats the first pass; i'll add more once it becomes more functional

Thursday, October 08, 2009

Usertype, GID and Article Creation

One wrinkle with Joomla's security system is this; to create an Article, the user me be at least an Author (default is Registered).

Now, this info is held both in JOS_USERS.USERTYPE and JOS_USERS.GID where the GID column references JOS_CORE_ACL_ARO_GROUPS.

Now, in the customisation work id did to the components/com_user/controller.php i was setting the user's usertype based on the value of the drop down, but the assignment of gid was based on another variable so usertype was out of step with gid so an Author couldn't create an Article. So; ensure GID is set as well

Wednesday, October 07, 2009

Allow User to Create Article

At the moment, the users (well, Author or above) still cant create content as the article creation link is only available in the Admin Control Panel.

However, thats eaily fixed.

In the Control Panel, select "Menus>Main Menu". That will bring up the "Menu Item Manager".

Select the "New" icon, select "Articles" under the "Internal Link" option. The select "Article Submission Layout" and fill out the next page as required.

Easy.

Then, once you log in as an "Author" or above, lo, the option will appear.

User Login Custom Processing

Having aded some fields previously, i now need to perform some custom actions.

What i need to do is manage the usertype column population.

To do that, we modify the com_user controller. (components/com_user/controller.php).

We modify the 'register_save' function.


(line 237)
$post = JRequest::get('post');
$user->set( 'name' , $post['title']." ".$post['firstname']." ".$post['middlenames']." ".$post['surname'] );
$usertype2 = $post['usertype2'];

...

(line 269)
if ($usertype2 == 'photographer')
{
$user->set('usertype', 'Author');
}
elseif ($usertype2 == 'consumer')
{
$user->set('usertype', 'Registered');
}
else
{
$user->set('usertype', $newUsertype);
}


Also, i want to stop checking of the 'name' field as i am using other fields to populate this. To do that amend libraries/joomla/database/table/user.php
, commenting out this section (line 152):

if (trim( $this->name ) == '') {
$this->setError( JText::_( 'Please enter your name.' ) );
return false;
}



Next
Next step is to amend the form so that depending upon which user type i pick, hide some of the fields.

Update
Ok, can now hide a field on the registration form based on the value of a a drop down.

Added this javascript:

function hideFields()
{
var x=document.getElementById("usertype2");
if (x.value == 'consumer')
{
document.getElementById("biographyrow").style.display='none';
}
else
{
document.getElementById("biographyrow").style.display='block';
}
}


So, when the user amends a drop-down called 'usertype2' (onchange event), the above is called.

You need to make sure that the row which holds the field has the id 'biographyrow' (in this case).

Monday, October 05, 2009

User Registration Form Extension

Next stage.

For the site I need to extend the standard User Registration.

Details of how to do this can be found here (steps 1 & 2), here (video) and here.

Simply, do the following:

1. Add new fields to the JOS_USERS table. The new fields are added like this:


alter table jos_users add (firstname varchar(100))
alter table jos_users add (middlenames varchar(100))
alter table jos_users add (surname varchar(100))
alter table jos_users add (title varchar(20))
alter table jos_users add (biography text)
alter table jos_users add (contactnumber varchar(50))
alter table jos_users add (mobilenumber varchar(50))
alter table jos_users add (camerainfo varchar(100))
alter table jos_users add (termsandconditions tinyint(4) NOT NULL default '0')


2. Edit libraries/joomla/database/table/user.php (around line 118):


var $firstname = null;
var $middlenames = null;
var $surname = null;
var $title = null;
var $biography = null;
var $contactnumber = null;
var $mobilenumber = null;
var $camerainfo = null;
var $termsandconditions = null;


3. Edit libraries/joomla/user/user.php (around line 138):


var $firstname = null;
var $middlenames = null;
var $surname = null;
var $title = null;
var $biography = null;
var $contactnumber = null;
var $mobilenumber = null;
var $camerainfo = null;
var $termsandconditions = null;


4. Edit com_user/views/user/tmpl/form.php (around line 29).
Add the new fields (and in this case i commented out the 'name' field).

5. Edit com_user/views/register/tmpl/default.php (around line 24).

Login Module
To use this, we need to add a login module. So, in admin, go to Module Manager and add a Login module.

Friday, October 02, 2009

Component Installation Issue

So, setting up Joomla on the web host. All's going well until i tried to install the Export Content module.

I got an error


JFolder::create: Path not in open_basedir paths
Could not create folder ...


So, after muchh digging, i found this post and it worked.

Thanks goodness!

Thursday, October 01, 2009

Random Content #2

Ok,

given the links from the previous post, i've gone with Global News.

Configuration
Easy, this one. Somply download the module, then in Joomla administration, use "Extensions>Install/Unininstall".

Then, go to the "Module Manager" and "Global News" is listed. Click on the link and there are all manner of options!.

I set:

  • "Show Title" to "No"

  • "Count Articles" to "1"

  • "Show Section ID(s)" to "1" (the ID of my "Photographs" section

  • "Article Ordering" to "Random"

Wednesday, September 30, 2009

Random Content

so, day 2 and the next objective, having set up content configuration and export is to determine how to show a random piece of content.

There a couple of extensions which will show lists of random content, but they only retrieve part of the content; i need 1 whole piece of random content.

So, i may have to modify one of these, or use them and then retrieve the content afterwards:



I'll let you know how it goes.

Update
Added Global Content to the list above

Tuesday, September 29, 2009

Joomla#1

A New Start
Ok, so today i started a new project using Joomla.

I have a concrete project to work on, and a rudimentary design. What i want to do is document the process i go through and the challenges and problems i face along the way.

So, here we go; the goal. The site is to manage images; photographers upload images and people pay to download them; nothing new, but important to someone.

So, part 1; configuration.

Configuration
First decision; how to manage my content taxonomy; The site will (mostly) contain one sortof content; Photographs. These images will be categorised by their 'topic', e.g. Landscape, Wildlife etc etc.

So, heres how i'm going to set it up:


  • One section: Photographs

  • Multiple Categories: wildlife, landscape etc; this will evolve over time




Update

Ok, i also managed to install the Export Content module.

The idea is that i need to be able to export configuration and Published content from one site to another; i.e. we'll have a staging environment for uploading/creating content and then once approved, we'll move that content to the main live area.

Export Content Module
You can get the module from here.

To install it you need to enable legacy mode. To do that, go to the Administration Control Panel and select the "Extensions > Plugin Manager" menu options and enable "System-Legacy".

Then, to install the component, go to "Extensions > Install/Uninstall" and selected the component's ZIP file. And that's it.

Wednesday, September 09, 2009

Belfast Zoo

Who would have guessed it. After a rubbish summer, it was gorgeous today and i had the day off, so i took Lizzie to Belfast Zoo.

The photos are here.

Favourite is this one.

Doing some processing on the photos though, i'm thinking 2 things:


  • Need to shoot RAW

  • Need a DSLR so i can get a decent lens



As handy as the S5000 is, i'd love a DSLR so i can get some extra flexibility with a zoom in these type of situations and the Fuji simply doesn't take the image quickly enough.

C'est la vie.

Also - should i like zoos? I love the chance to see the animals and give Lizzie the chance to see them, but is it right to keep them caged in such an environment? It has to be said that Belfast Zoo has been doing some good work in breeding some endagered species like the lions they currently have, but nagging doubts prevail.

Lovely day out though.

Pink Panorama

Well, spent the weekend painting Lizzies new room.

To make up for getting evicted from her room to a new room up the stairs (to make way for number 2's arrival in November), we gave her new room a total makeover.

From magnolia/white neutral-city to well, er, pink!

So, 2 shades of pink paint, some wallpaper, Ikea furniture and a weekend of blood, sweat and tears later, we get this:



Full size image is on Flickr here.

Photo Stitching
I wanted a panaorama of the room, but had never tried it before. So, took some shots using a set of step ladders as a tripod and moved the camera between each shot a little bit.

I then used GIMP and the Pandora plugin to create the panorama. Its far from perfect, but i'm pleased with the results as a first quick attempt.

Thursday, August 27, 2009

Yeah Yeah Yeahs


Went to see the Yeah Yeah Yeahs last night.

The gig was in St Georges Market (Belfast).

First the venue. It's a wierd venue as its a covered market (d'oh) so essentially a very big, rectangular, high roofed space with a lot of windows. As a venue is was great - very airy, lots of space (they got chippy vans in!). One gripe - beer queue. Instead of using all the mass of edge space, they set up a small bar and a big barrier enclosing queue. So, buy four at a time!

The music was fantastic; i should state that i didn't see the support band. Just the YYYs. They were epic. Karen O is fantastic on stage; brilliant vocals, theatrical and entertaining. The guitarist is a legend; top playing.

So, i guess you could say i liked it!

Heres a dodgy camera phone shot for posterity.

Tuesday, August 11, 2009

Fruit Pavlova

After making the curry (see previous post) I then rounded off an eating fest by making a fruit Pavlova (thank you Sunday Times).

Meringue


  • 4 Egg whites

  • 225g Cater Sugar



Used an electric whisk to beat the egg whites until it would yield stiff peaks.

Added a bit of sugar at a time until all mixed i, then whisk a couple of minutes more.

Spread out on a baking tray covered with grease proof paper - spread it so you have a bowl shape to put the filling in later.

So, put that into a preheated over (180C) - as soon as you put it in turn the heat down to 125C and let it cook for 1.5 hours.

After that, turn off the oven and let it cool.

Filling:


  • Blend/Squash 100g of strawberries and add juice of a tangerine.

  • add a tablespoon of icing sugar

  • Sieve the sauce to remove seeds & bits

  • Whisk up 350ml of double cream with a teaspoon of vanilla extract added until its nice and stiff

  • Fill cooled meringue base with cream.

  • Lay on slices of peach

  • Pour over as much or as little sauce as you want



Heres the result:

Pavlova Picture

DIY Curry

The Holy Grail, for me, is to cook my own curry that comes even somewhere close to a good one in an Indian Restaurant.

Of course every ones got a favourite curry house, but in Belfast my favourite is definitely The Jharna

So, you keep trying in the hope it happens.

Anyway, went to St Georges Market; they have a market every Saturday with loads of food stalls, takeaway stalls, tat, rubbish and other bric-a-brac.

Anyway, by accident chatted to a guy running an indian ingredients stall and bought some of this:

Pickle

More Pickle

So, i tried some - OMG - how hot?! Excellent.

The guy also sold some ready mixed spices and chucked them in for cheap.

So, i bought some lamb, marinated it overnight in the pickle.

Next day:


  • Sauteed onion and Scotch Bonnet chilli

  • Added lamb and browned

  • Added spice mix

  • Added tomato and some water

  • Leave to simmer for a couple of hours.


Flippin' gorgeous.

Other Favourites Curry Houses.

Manchester: The Kathmandu
London (North): Sunderban.

Friday, August 07, 2009

Chocolate Tort-ure

ok, so wife comes home and says she's promised a Chocolate Torte for people in her office. Is she going to make - my a*se she is.

So, handily, there's a recipe in latest edition of Delicious Magazine.

Excellent. Nothing too tricky; make sweet pastry, blind bake, make filling, fill, cook, job done.

So, the pastry recipe:


  • Combine Butter and Icing Sugar 'til nice and smooth. Tick.

  • Add a couple of egg yolks and combine. Tick

  • Add some flour and combine. Tick



Now, at this point it sounds a bit odd. I'm no expert (no, really!) but it then says to add 250ml of water (bit at a time). Now, i could see this coming but i still did it, but that sounds like its going to be a sloppy mess. Yup, sure enough, cue one sloppy mess. So, i tried adding some more flour to get it back to a pastry type consistency, wrapped it up and put in the fridge for an hour.

Half hour later, remove from fridge, roll out between a couple of sheets of clingfilm, put into tart tin, back in fridge for half hour. Still not convinced.

So, out of fridge, put some baking paper and beans, blind bake for about 20 mins, remove from oven, take off beans and paper, prick base and cook for another 5/10 minutes.

The result can only be described as something between cake and biscuit.

Luckily, after making the 'pastry', i'd made a backup batch using one of Racheal Allen's recipes.

So, in between first batch disaster, i did the necessary with the second batch and it turned out perfectly.

Moral of the story; if something sounds wrong it probably is.

Do these people ever try these recipes? Luckily the filling was great.

Took ages mind you.

Tuesday, July 21, 2009

Comebacks

has anyone noticed how the barrage of pop comebacks over the past few years has moved to indie/metal?


  • Faith No More

  • Janes Addiction

  • Pearl Jam



Now, so far these have been revivals (i.e. tours playing back catalogue) but now Pearl Jam are going to release new material as, according to Perry Farel on Radio One last night, are Janes Addiction.

Now, i love these bands so i just home the new tracks are good. Please don't put out some rubbish thats ruins the back catalogue.

More Films

Ok, managed to get a couple of new releases watched this weekend. Talk about poles apart...

Taken
What a load of unmitigated rubbish.
Neeson as ex-CIA/Special Forces hard man, who has to go and rescue kidnapped daughter.
Neeson is so wooden, the plot so thin and predictable it makes for an hour and a half of laugh out loud rubbish.

Plus, i haven't seen sooooo many bullets fly around with no casualties since the A-Team

Gran Tourino
Thank god for this - total opposite - Clint plays flawed, grumpy, racist war veteran who lives in a neighbourhoud changing around him and how he helps and comes to like the family next door (and becomes increasingly estranged from his own selfish offspring).

Brilliant.

Monday, May 18, 2009

Film Review

well, saw 2 quality DVD's over the weekend; Serenity and Rocky Balboa.

Serenity

Sci-fi, ex-military, rebels without a cause. Group of bandits get a cause when they're 'cargo' (a human bred-for-fighting machine) needs help.

Excellent good vs evil empire sci-fi western.

Rocky Balboa

I was worried about this one. I love Rocky and thought this may be one of those saddo, old man conquers all the odds to beat young-un. And whilst it was partly that it was not cheesy/corny but actually believable, poignant, and emotional; plus the great music with mad-training and painful blood spattered boxing scenes.

Loved it.

Sunday, May 17, 2009

well, updated photo (actually added, cos there wasn;t one before) and determined to get free time on track.

Wednesday, April 29, 2009

Deadlocks in SQL Server

Until today, i'd never really had to dig into the guts of SQL Server (2005). Oracle; no problem but that was a few years back as well.

Anyway, we've got an application which uses alot of stored procedures to manage the data; DOA layer interacts with stored procedures which in turn create the d/b rows. Anyway, within the app, we use tables to hold sequences as, unlike Oracle, there is no sequence type object. This means that every time we want the next value in a sequence, we get the value in a table, add 1, delete the existing value and insert the new one.

Anyway, as we'd scaled up our application with a customer we'd noticed dealock errors in the application logs. This told us which stored processes were failing but not really why.

Anyway, long story short, the links to Bart Duncans blog were invaluable for sussing out was was happening.

Deadlocks Part 1
Deadlocks Part 2
Deadlocks Part 3

Monday, April 27, 2009

Rejuvination

so, thought i'd try this again - log all the stuff that goes on and some of it be be useful sometime.