Tuesday, 31 December 2013

Development Progress 2013, Wrap Up

Another Years Progress

Now that 2013 is coming to an end we thought it would be good to have a review of the year and the progress we have made developing The Care Home Directory website.

It has been a great year for development and it has been enjoyable working on improving the experience and products we offer to our visitors.

Below is a list containing some of the improvements we have made this year,
  • Improved gallery, support for five 1Mb images
  • Gallery image thumbnail support, smaller asset files
  • Improved homepage layout
  • Home promo rotation cells on homepage
  • Region accordion on homepage
  • New improved notification system, unified across panels
  • Google wallet payment support (ported from Checkout)
  • Simplified enhanced listing sign up form
  • Improved landing pages for advertising campaigns
  • Dropped IE7 support
  • Home activities list
  • Social media buttons, Google+, Facebook, Twitter
  • Local amenities list
  • New improved edit provider form, enhanced listings
  • Site wide search widget
  • Improved website accessibility (WCAG WAI-AA)
  • Compact town listings layout
  • Improved enhanced listing town layout
  • Added current bed/room vacancies support
  • New Care Homes social media accounts on Reddit and Google+
  • Mobile website version for smart phones and tablets
  • Released native Android app
  • Released Care and Nursing News System
  • Improved Geocoding support for homes
  • Moved templates over to HTML5 and CSS3
  • Migrated to new server
  • Improved API features
There have been some under the hood changes which are not listed above such as interfaces or traits and any other refactoring work we have done.

With the new year brings new opportunities and we have a lot planned in the new year improving our website even more.

We all hope you have a happy new year.

Saturday, 28 December 2013

New Feature Release: Bed Vacancies

Available Bed/Room Number

Now you can update the number of vacancies at your home using the edit provider form under the my data tab. If your home has no vacancies you can leave it empty or set it to zero otherwise set it to the number of rooms that are available for residents.

You can also set the total rooms your home offers this can help give visitors to your listing an impression of the homes size.

Edit Room/Bed Numbers

Monday, 23 December 2013

Gallery Thumbnail Support using Imagick

Real Thumbnail Assets

Recently we improved our gallery offering for enhanced listings and the UI we use to show these gallery images displays them as 120x80px thumbnails with click to enlarge displaying the original image.

For our first release of the gallery we just set the height and width using CSS on the original image. This approach is simple although the gallery page can be slow loading due to it downloading full sized copies of the assets rather than scaled down versions.

Using imagick we created 180x180px thumbnails which gave us some big file size savings leading to much faster loading times of the main gallery. Some of the images have gone from 250Kb+ right down to between 10Kb and 20Kb.

Creating Existing Image Thumbnails

For creating thumbnail versions of images that have already been uploaded we wrote a basic PHP script to transverse the gallery directory and use imagick to convert them into their respective thumbnails.

We decided to use _small as a suffix for thumbnail images so if we had an image named image.png its thumbnail would be image_small.png we also have a fixed image name.

The command to convert the image is simple and only has a few parameters,
/usr/bin/convert -thumbnail 180 /path/to/image/image.png /path/to/image/image_small.png

The script we used was PHP but you could accomplish this using a simple bash script,
$baseDir = '/path/to/the/gallery';
$dh = opendir($baseDir);
while (($filename = readdir($dh)) !== false) {
    if ($filename != '.' && $filename != '..') {
        $fileArray = explode(".", $filename);
        $newFileName = $fileArray[0] . '_small.' . $fileArray[1];
        exec('/usr/bin/convert -thumbnail 180 ' . $baseDir . '/' . $filename . ' ' . $baseDir . '/' . $newFileName);
    }
}

Create Uploaded Image Thumbnail

When a user uploads an image to their gallery we also create a thumbnail of the upload using the imagick PHP module.

Another approach would be to use exec or passthru to execute the system command above although we feel using the module give us more control and we also do not need to make a system call etc..
$nameArray = explode(".", $filename);
$newFileName = $nameArray[0] . '_small.' . $nameArray[1];
$thumb = new Imagick($filename);
$thumb->thumbnailImage($width, $height);
$thumb->writeImage($newFileName);

It is as simple as that we decided not to use GD for creating the thumbnails although this is a possible path you could go down. One good thing about using GD is it has better support as a module if your using a shared host but we can install all the modules we need using APT.

Conclusion

Adding support for true thumbnails to our gallery offering has allowed us to decrease page load time and save bandwidth as well which are both good things. It also saves downloading 1Mb files that may not be viewed.

Soon we will be adding support for unlimited image uploads to enhanced listings so providers can then upload as many images as required so keep a look out for this in the new year.


On a side note this is our 50th blog post and we will be writing a round up of 2013 by having a look at what has been release and the new features and products The Care Homes Directory offers.

Wednesday, 4 December 2013

New Look Homepage

New Region List Accordion

Our homepage has recently had a new addition of a town list accordion allowing users to get direct access to care, nursing homes and care and nursing agency information, by doing this we have effectively pulled our main content up a level.

We hope this will allow our visitors to get to the content on our website quicker, allowing a more seamless visit and also removing a step that they would have to take to drill down to the town page.

For the accordion we used jQuery UI to provide the functionality this made sense due to the fact our rotation panels use this library and it also provides cross browser support. Our town lists are grouped by region rather than county.

As always we will be reviewing our new addition soon to see if we can improve upon the current offering. We hope you enjoy our new addition.


A screen shot of the new homepage with town accordion
New Look Homepage

Sunday, 1 December 2013

Debugging and Profiling PHP Scripts

Using xDebug with PHP

This article discusses installing and using xDebug for debugging and profiling PHP scripts we also touch on using kcachgrind to help interpret the results of our profiling.

Recently we profiled the most commonly used sections of our website to see if we could improve upon our wait time and generally improve our code base.


xDebug

Setting Up xDebug

Our first task we need to setup our alpha test bed to use xDebug we like to use pear when installing packages like this as it sets the system up for us. Simply running the following command as root will install all that is needed.
root@chic:~# pecl install xdebug

Once you have issued this command you need to configure PHP to use the extension

/etc/php5/apache2/conf.d/xdebug.ini

You need to add the following to the above file remembering to change the value of profiler_output_dir and trace_output_dir to reflect your own directory structure. Also your module location could vary if so use find or locate to find xdebug.so

zend_extension=/usr/lib/php5/20090626/xdebug.so
[xdebug]
xdebug.profiler_enable=on
xdebug.profiler_output_dir=/home/chic/cachegrind
xdebug.trace_output_dir=/home/chic/traces
xdebug.auto_trace=on
xdebug.profiler_output_name=callgrind.out.%t-%s
xdebug.collect_assignments=on
xdebug.collect_return=on
xdebug.collect_vars=on

Once you have done this you need to reload Apache so the module is loaded and the configuration changes are read.

/etc/init.d/apache2 reload

You will want to create the directories for profile output files and give it the appropriate file permissions you may want to use something other than 777 but our alpha machines are single user so we can be a bit more relaxed.


mkdir /home/chic/cachegrind && chmod 777 /home/chic/cachegrind

We now need to do the same but for the stack trace file output.


mkdir /home/chris/traces && chmod 777 /home/chris/traces

Now the system should be ready to start generating debugging data although you should remember that quite a few files can be generated while debugging especially if you are throwing a lot of requests at your server. You should also never install xDebug on your production server as it is bad form.


Setting Up Kcachegrind

The last thing we need to install is kcachegrind which is the program we will use to interpret and visualise the generated profiler reports.


root@chic:~# apt-get install kcachegrind

You should now be able to run kcachegrind either using the shell or maybe your distribution has added a nice menu item for it. On Mint Linux it is located under programming in the main menu.


Start Profiling

To start the profiling of your scripts simply accesses the web address of the page you want to profile or run it via the command line if it is a cli application.

This will create a new file under the directory you specified in the configuration file for us its called callgrind.out.%t-%s where %t is the time stamp and %s is the script name.

At this point you will need to open kcachegrind to help interpret the results from the profiling we like to use the Callee tab in the right window panel which allows you to visualise the amount of time each action is taking.

Using this helps us to check which parts of our script are taking up the biggest percentage in total execution time.

We used the information we gained from using this tool to improve one of our scripts by removing an unneeded function call which we more than likely would have missed if we did not profile the calling script.

By using this approach we managed to knock 40% of the execution time of our script which is a huge saving in execution time.


Debugging

We use xDebug on our development workstations to improve the output when something goes wrong it also adds some more information to var_dump() such as the type of the variable etc..

xDebug should not be used on live servers for the reasons mentioned above and we would also advise not to use it on production machines.


Conclusion

Hopefully this article has given you an insight into debugging and profiling PHP scripts using xDebug and kcachegrind. Using these tools can help decide which parts of your script need the most attention.

Being able to visualise the execution of a script is a good way to see what exactly is going on during run time.

Friday, 29 November 2013

New Feature Release: Galleries

Improved Image Gallery

We have been working hard recently improving our current enhanced listings image support by adding a new gallery page and tab to all enhanced listings allowing home owners to upload five 1Mb images from their browser.

Currently the feature list is as follows,

  • Support for main image which is displayed on all enhanced listings tabs.
  • Upload five images of your home
  • High resolution 1Mb images
  • Dedicated gallery page for displaying gallery images
  • Spotlight image support for displaying large versions (provided by lighter)
  • Aspect ratio preservation on all images

Gallery and Editor

We plan to add support for converting assets into high resolution, medium resolution and thumbnail by using the ImageMagick PHP module.


Gallery Page

You can sign up for one year enhanced listings which costs £50+vat by completing the short form and making payment using Google Wallet all major credit and debit cards are accepted.


Image Spotlight

On a closing note our integration of Double Click for Publishers is progressing well and we hope to be releasing it in the new year, we feel our website has some good placements to offer advertisers and by using DFP we can offer these direct to potential customers.

Saturday, 16 November 2013

Dropping Support for Internet Explorer 7

Browser Support Changes

Recently we decided to stop supporting Internet Explorer 7 due to it displaying our markup incorrectly and constantly needing work arounds. This applies to Enhanced Listings users and more recent features although the main directory still displays fine.

One thing that lead us to stop support was implementing a pure CSS drop down navigation which works in every other browser apart from IE7 so the decision was made to stop doing work arounds.

With Internet Explorer 7 having 4.47% of world browser usage, according to this page, we feel this would be an even smaller number for UK only visitors so it makes business sense to end support as well as technical.

If you still use IE7 you should really consider upgrading it to a newer version which supports modern web standards better and please remember IE7 was release in January 2006 which is a very long time in our industry and the most recent Internet Explorer is 11 which you can get here.

No IE7 image
Internet Explorer 7

Thursday, 14 November 2013

New Feature Release: Modify Provider via Panel

Change Your Directory Entry

Enhanced Listings users are now able to modify their listing in the main directory directly from their browser giving them full control over their profile on our website.

You can now add even more data because now we have added support for displaying your social media icons, home activities, care specialisms and more.

Edit Listing Form

New Feature Release: Social Media Buttons

Going Social

We are proud to announce another new feature release which allows care and nursing home owners to add links to their social media pages from our enhanced listings control panel. 

Once you have signed up you can set your social media URLs and they will be displayed as icons on your listing page.

This allows visitors to your listing page to connect with your home via social media which opens communication for your home to the public and our visitors.

Social Media Icons

New Feature Release: Home Activity List

List of Activities

We have a new page for our enhanced listings where they can edit a list of activities which are provided by the home for residents.

This is available to all Enhanced Listing customers and we also hope to allow providers to edit their activity list for free in the future.

Our hope is to slowly build some extra data from our listings with the aim of giving even more information to our visors and in turn improving their experience.

You can sign up for a 12 month enhanced listing for only £50 +vat using our new sign up form which includes support for Google Wallet making payment convenient.

Once you have logged in you can access the edit provider page this is were you can control your homes activities, specialisms, social media and other data.

picture of our new activities tab for listings
Activities Screen Shot

Monday, 11 November 2013

Simplified Enhanced Listing Signup Form

Making Signup Easier

Recently we had to move over from Google Checkout to Google Wallet for our card payment processing so we decided that it would be an ideal time to review our enhanced listing sign up form.

We feel that our new form is simpler, quicker and easier to use allowing our visitors and customers to apply for their enhanced listing with the minimal hassle, combined with our new Google Wallet integration we feel it is a vast improvement.


Once you have purchased an enhanced listing you can add further ones direct from your panel via a browser making adding more establishments to your account even simpler.

Enhanced Listing Sign Up

Sunday, 10 November 2013

New Feature Release: Site Wide Search Widget

Make Search Site Wide

The Care Homes Directory has made a new feature release with the aim of improving our website search by making it site wide.

Our new search widget is now live and being displayed in the top right corner of all pages we have applied some styles to the form so it looks a bit better than a native form.

We hope by providing a search function across all our pages it will allow our visitors to find what they want easier and more quickly.

Along with adding a new search widget we will be improving upon our search algorithm and attempting to speed our search up even more along with providing the most relevant results for your query.


Search Widget

Saturday, 2 November 2013

The Care Homes Directory Google Wallet Support

Card Payment for Enhanced Listings

We are happy to announce the completion of our Google Wallet integration meaning we now have improved support for credit and debit card payments.

You can sign up for a single years enhanced listings for £50+vat using your credit or debit card allowing instant access to your listings panel.



Google Wallet Payment
Once you have signed up you can access our listings panel to edit your listings description, upload an image and more. Below is a screen shot of our online editor which is similar to a word processor that many users are familiar with.

Listing Editor
In the coming months we plan on adding gallery support for multiple images of your home, a job listings section for you to publicise any jobs vacancies. We get quite a few emails regarding jobs so we felt this might improve their experience on our website.

Conclusion

We feel Google Wallet is a vast improvement upon Google Checkout and by porting our platform over to them for our card processing will allow us to handle payments with the minimal of hassle.

Implementing our Double Click for Publishers integration has begun and soon we will be able to offer our customers customised site wide or specific advertising using a familiar system (DFP).

This will also allow us to sell our ad space via Google adwords and other advertising networks. We are excited at the possibilities and opportunities which this will offer our customer and users, especially when tightly coupled with our existing advertising platform and card handling systems.

Thursday, 17 October 2013

Improving Website Accessibility

Helping Improve Support for Disabilities

The Care Homes Directory has started a campaign to try and improve our website accessibility so people who are less able and use say a screen reader or keyboard to navigate will still be able to have as good an experience as a more able user.




WCAG 2.0

Conforming to the WCAG 2.0 is a goal we have set for our website and we feel it is important to make our site and therefore data accessible to the widest range of visitors not just the well able.

The main sections of our website are WCAG 2.0 aa compliant and have been tested using both WAVE and AChecker to verify that our pages conform we also used the nu validator.

By using these tools you can make sure a website is accessible by make some usually small changes to things such as font size and colour contrasts.


Aria Roles

Aria roles help add semantics to webpages for aiding screen readers which improves the experience for a visually impaired user.

We have added role="navigation" to our navigation tags on the website as well as adding role="main" to our centre div which is the container for the main page content and if there is a page heading we have added role="heading" to our heading div.

For news articles we have added role="article" attribute to our article div this is along side the other microdata our webpages contain.

Lastly we added role="banner" to our <header> tag and role="contentinfo" to our <footer> tag both of which are on every page. You should only have a single banner and contentinfo roles per page.

In future releases we plan on adding some link section headings to help improve upon our page semantics even more.


Keyboard Navigation

For keyboard users we have improved site layout by using only divs for all site layout rather than the mix of divs and tables we previously had. We mention this in the article here.

We aim to add tab indexes to our templates at a future date to improve a keyboard users experience by making navigation even easier.


Getting Focus

Adding onload JavaScript to take focus onto the search widget with the search results below previously focus was being taken to the bottom <nav> links which is wrong.

We have also changed the initial focus on the home page to the keywords search input and also the same for country pages.

Having focus initially on the search function puts the user near the main content and also they can use a site search if they need some other data.


Running Tests

WAVE is a good tester for accessibility issues on your website and it can be used to navigate your website via a frame and displays any issues it finds.

Another tool we used to confirm we conform to WCAG 2.0 was AChecker as mention above this rates our website as WCAG 2.0 aa which is the second level of compliance. There are three levels in total a, aa and aaa with triple a being the heights level.

This level does not apply to us a we use no video or audio on our website that would need to be transcribed in an easy to access format.


Conclusion

Improving our websites accessibility is an important goal which we feel we have achieved  we hope to lead by being the most accessible website for people who are less able.

As with all our improvements our effort to improve accessibility will be continuing and we will be adding improvements on an incremental basis.

Monday, 14 October 2013

Compact Town Page Listing Layout

New Layout More Information

The Care Homes Directory has a new compact town layout to help include even more information for our visitors including ownership type, rooms and contact name in at a glance format.

We hope to continue improving our data set and also improve our compact layout adding even more relevant information.

Compact Town

Saturday, 12 October 2013

New Directory Layout

Div Only Design

We have moved our website over to a pure div layout using no tables for any website structure we did have a div only template but some of the directory sections still used tables.

This should help improve our ability to change the layout more easily and also improves our keyboard navigation for users who cannot use a mouse.
Picture with the words <div> in the center
Layout


We have tested this layout using our usual cross browser testing which we have written about before and we hope it renders correctly in all browsers.

Our pages are fully HTML 5 compliant and have been tested using the w3c HTML validator we also used their CSS validator and Nu Markup tester.

The reason for using the Nu Markup tester is to test our new aria tags which help add even more semantics to our webpages. We have added roles to the main sections of our website and we are in the process of adding even more aria data.

After this is complete we hope to write an article outlining the features we have implemented and the reason for it. We are making a push to try and improve our website accessibility so we can offer all users the same quality experience.

Friday, 11 October 2013

Automating Form Testing with Selenium IDE

Testing Forms

Automating the testing of forms helps speed up the test process and saves having to do the repetitive work of filling the form with test data.

We use Selenium IDE for our form testing because it is simple to use and is integrated into Firefox.


Screen shot of our website and selenium IDE overlayed
Selenium IDE

Test Suite

With the redesign of our enhanced listing signup form we needed to rewrite our selenium test suite for testing the signup form.

Using selenium IDE we can record our actions in the browser and replay them so we can step through every test and check the form works as expected.

If you have used unit testing before selenium and its concepts will be familiar to you, with selenium the tester can assert things such as checking for error strings in the form when the form has been submitted or asserting a page has the desired title or heading.

We first start by testing the form to make sure that our error checking is working we like to test all the required fields in a form and stepping through each required for field and asserting the error string is present in the form.

Then we move through the form testing any other constraints such as passwords not matching and finally check the form with correct data to verify it works correctly.

Recording your browser is as simple as clicking the record button in the UI and then carry on as usual, you can also access rules and statements by right click your mouse or adding them directly from the IDE GUI.

Conclusion

When you need to test a form using selenium to drive it makes sense and it saves time and effort when rerunning any tests. We like to use test driven development to help improve the standard of our code base.

Very soon we will be moving The Care Homes Directory over to using a pure div layout for the whole website in an attempt to improve keyboard navigation of our website for improved accessibility for non mouse using visitors.

And releasing a new improved enhanced listings sign up form and Google wallet payment support which greatly improves the users experience.

Also we are adding aria data to our website and are improving our <nav> structure so we can improve our breadcrumbs.

Friday, 4 October 2013

Local Amenities Listings Database Completed

Finished Building

The Care Homes Directory have completed compiling our local amenities database and are please to announce a comprehensive database covering the majority or homes and agencies listed on our website.

We now have over 100,000 records for local businesses and attractions which we have written about before here and here and we hope this helps our visitors when deciding on a home by providing even more information.

If you would like to have your amenity or business listed in our directory for care home providers and home and nursing care agencies please contact us here to discuss this opportunity.

Screen shot of a listing for the local amenities page on an enhanced listing
Enhanced Listing

Friday, 27 September 2013

Google Web Accessibility Online Course

Helping to Improve Website Accessibility

Google are offering a new free online course named Introduction to Web Accessibility which aims to help web developers improve their knowledge of web accessibility for people who are less able.

Due to our sector we feel this is an important aspect of web development and it should be a focus for developers when designing a web application or site.

We hope to take the knowledge gained from this course and improve our website accessibly for screen readers and keyboard users.

You can find more information about this by visiting the courses website which is here and we hope to write some future articles discussing our new accessibility improvements.

Desktop Backup Using Rsync

Backing Up Over SSH Using Rsync

This article will look at our workstation backup solution which uses rsync for keeping our home directories in sync with a directory on a NAS over SSH.

Its not a smart backup or anything just uses rsync to synchronise our home directories and any working directories, adding any new files and removing any that have been deleted.

Our workstations are the source and the NAS is the destination so if anything goes wrong with our systems we can just rsync them backup and use our installed package list to restore our workstation with minimal interaction.


Image of two squares one gree the other purple with the word rsync
rsync


Doing the Backup

For the command to do the work its just a simple one liner to instruct rsync what to backup and to were and passing any command arguments to control options.
chris@chic:~# rsync -avz --delete /home/chris chris@192.168.0.123:/home/Private/Backup

The above command uses the -a switch for making an archive the -v makes the program more verbose -z compresses and finally the --delete removes any files from the destination which were deleted from the source.

Using this will keep the two directories in complete sync but also will not keep any files which have been deleted from the source which is what we require.

You can get more information about rsync and its command arguments by reading the man page which is here or just run man rsync from a shell prompt.

Conclusion

As you can see from this article keeping two directories in sync using rsync is a very simple task and can provide a "casual" backup solution for desktops or workstations.

On a side note our new Reddit and Google+ social media pages are doing well and we have been seeing some referrals from these to our website so we hope to build upon this and improve our offerings and community.

Wednesday, 18 September 2013

Backup Package List on Debian

Using dpkg

One thing we do on both our servers and workstation is to backup the installed package list in case we need to rebuild the system we can make sure it has exactly the same programs available.

Using dpkg which is the Debian package manager we can dump a list to a standard text file ready for backup, for us we use Google Drive for our backup remote storage so the list will also be backed up there.


dpkg Package Manager

The Backup

We have added package backup to our server backup system and to do the actual backup is as simple as running a single command. This will dump the package list to a text file named package_list.txt
root@chic:~# dpkg --get-selections > package_list.txt

The Restore

To restore the installed packages on a fresh machine is just as simple you just use the set-selections switch when running dpkg. After running dpkg we update our package list and upgrade the system.
root@chic:~# dpkg --set-selections < package_list.txt && apt-get update && apt-get -u dselect-upgrade


Conclusion

This article show how simple a task it is to backup your installed programs so if you need to start fresh you can make sure the programs you had installed are installed again and hassle free to.

In a future article we hope to cover our system restore scripts which can be used for setting up a clean Debian minimal network install into a production ready server.

Sunday, 15 September 2013

New Google+ Web Site Page

More Social Media With Google+

The Care Homes Directory has now created a new Care and Nursing home related Google+ page were we will be releasing our news articles and any promotional or related content.

We feel this will complement our other social media accounts on Facebook, Twitter and Reddit and we hope people might find it a useful resource.

You can view our other social media accounts by following this link to our social media page promoting our accounts.


Red square with a G and the plus sign on it.
Google+

Workstation OS Upgrades

From Maya To Olivia

Recently we upgraded our workstation operating systems from Mint 13 (Maya) to Mint 15 (Olivia) and the initial impression is positive and there are noticeable improvements.

We switched to Cinnamon from Unity which was one of the reasons for our initial switch from Ubuntu and I tend to find that I can just get on with work when using Cinnamon over Unity.


The logo for Linux Mint
Linux Mint


Upgrade Method

For our upgrade we used the apt method of editing our /etc/apt/sources.list file and replacing the correct release names and although this is not the recommended method I have always upgrade like this and its worked.

We also use rsync to backup any files needed on the workstation so if something goes wrong we can restore the system from that source.

You can also use dpkg to dump a list of programs installed on the system so you can restore them if you need to the command to get the package listing is,
root@chic:~# dpkg --get-selections > workstation_package_list.txt

The upgrade for our workstation went through like a breeze we went from 13 to 14 without a hitch then from 14 to 15 after a few hours we had our fully upgraded system.


Impressions

Everything looked similar to the previous version although fonts and theme do look slightly different  from the previous version, I am not so keen on the font.

Hot corners got enabled again for some reason unknown so I had to disable them as I cannot stand them my mouse tends to move here and there and when I select the menu I sometimes just go to the top left corner.

I have also got double entries inside my preferences in the menu for some reason although I am very rarely in there so this is not a problem for me just a niggle. I used to tweak my systems and compile my own kernels but now I just want my system to work and Mint does that for me which in turn allows me to get on with my work.

One thing that did stop working was our eclipse ADT (Android Development Tools) install which we use for our Android development but reinstalling was simple and it is all working now I am also not sure what went wrong there.

Virtual box works fine although VMWare player will not work due to kernel module problems but I do not use this for work so again its not a problem.


Conclusion

We like Linux Mint and will continue to use it for our main workstations for the foreseeable future and hope to see it flourish.

Saturday, 14 September 2013

Release Road Map

The Care Homes Directory Roadmap

Our new road map for our planned releases has been published to this page on our company blog we hope to follow our road map and also improving the road map itself.

We have not included release dates because our development cycle is rolling so we release as we go when ready. It is a slight twist on agile development and we covered it slightly in this article and also this one.

To view our road map please follow this link.

Atlas picture of England including roads overlay
Road Map

Care Homes Subreddit

Going Social Again

The Care Homes Directory has now created a new sub Reddit for care and nursing homes discussions we will also be using the channel to inform members of any news articles which are relevant to the topic and new website related features and releases.

We hope any care providers and or agencies will join us and make use of this resource anyone is welcome to participate in our new community and we hope to see you there.

Care Homes Sub Reddit


Thursday, 12 September 2013

Quick Look at PHP Traits

Traits in PHP

With the release of PHP 5.4.0 including support for traits we though it would be good to start taking advantage of this new feature. We will also be modifying some of our older classes to use traits.

Our first trait was a simple single method one which is called FormErrorParser($form) which takes a string as an argument and parses any error tokens contained inside the HTML markup.

It is a very simple function and a specific problem domain so we felt using a trait to provide this function across classes which are otherwise unrelated was the correct approach to use.

An oval with a blue background and php written in black centred inside the oval
PHP 5.4.0

Defining a Trait

To define a trait in PHP is very simple and similar to how you would write a class, for our example the calling class must define the $this->formErrors array which is a simple array containing a key value pair ('{TOKEN}' => '{ERROR_STRING}') which the parser transverses,


/**
* Form Error Parser
* Provides functionality for parsing form errors, its a simple parser which replaces error tokens (%nameError%) with the corresponding error string.
* @package Traits\FormErrorParser
* @version 1.0.0
* @author C.Elsen
* @copyright © 2000-2013 Chic Computer Consultants Ltd, All Rights Reserved.
* @date: 2013-09-11
*/
trait FormErrorParser {
    /**
    * Parse Form Errors
    * Parser replaces form error tokens with the error string.
    * @param string $form The form to parse.
    * @return string Returns the form with the error tokens replaced.
    */
    protected function parseFormErrors ($form) {
        if (count($this->formErrors) > 0) {
            foreach ($this->formErrors as $k => $v) {
                $form = str_replace('%' . $k . 'Error%', $v, $form);
            }
        }
        $form = preg_replace('/%.*Error%/i', '', $form);
        return $form;
    }
}

From the above you can see this is a simple usage but we feel a good example of how traits can help with specific fine grained functions.


Using a Trait

To insert a trait into a class you call the use keyword along with the name of the trait to use so to use the FormErrorParser trait you would so something like this,
use FormErrorParser

protected function doSomthingWithAForm() {
    if (empty($_POST['something'])) {
        $this->formErrors['example'] = 'This is an example error string';
    }
}

For the HTML side of things you can add an error token to you form markup so that it can be replaced by the appropriate error message.
<input type="text" id="something" name="something">%exampleError%

Conclusion

Having another tool in the toolbox is never a bad thing and traits look like they will allow you to share functionality between classes with no other relationship this should allow for greater code reuse and in turn improve development.

The Care Homes Directory is currently in the process of redesigning our enhanced listings sign up form in an attempt to simplify it and also switch over to Google Wallet from Google Checkout.

Our initial use of Google Wallet is positive and we feel that it is an improvement over Checkout and has a simpler API and better support for digital good and especially subscriptions.

We will be writing a future article regarding the release of this new improved website feature and we hope to make our site as simple as possible.