Welcome to
'Confessions of a Culture Shock Junkie' ™
Home >> Technology >> Programming >> Core Groja.com Classes

Site Style

Who's Online

We have 22 guests online
Core Groja.com Classes Print
Technology - Programming
Written by Tom H.   
Thursday, 26 February 2009 00:00

This article describes the core classes written for previous versions of groja.com.

All of these classes have names beginning with "C," and almost all of them operate independently of joomla! framework. The exceptions are CGrojaUser, which depends on joomla's JUser class, and CFunctionsDatabase, which enables some of these classes to access the database outside the joomla! framework.

The code in version 3 of the site utilizes the new features of version 5 of PHP. Specifically, these classes:

  • use PHP5's access modifiers (all data members and methods are now private, protected, or public),
  • contain comments that conform to the PHPdoc format, and
  • declare constructors in the PHP 5 format.

Additionally, every effort was made to ensure these classes generate valid, well-formed HTML that conforms to modern standards.

List of Classes

Following is a list of the groja core classes.

Discussion of dependencies is not the purpose of this article. For the most part, however, these classes operate independently.

Form Classes

These classes allow visitors to enter data:

  • CDrawOptions - encapsulates options used to draw an image; contains methods for converting them to and from a string
  • CDrawPageForm - base class for forms on the draw page
  • CEnterProfile - base class for forms allowing visitors to enter a profile
  • CEnterProfileJung - contains methods to print form for input of a four-letter Jungian archetype
  • CEnterProfileKts - contains methods to print form for input of a Keirsey Temperament Sorter score
  • CEnterProfilePercentages - contains methods to print form for input of a profile based on percentages
  • CEnterProfileQuiz - contains methods to print form for input of a profile based on the groja quiz
  • CPostImage - contains methods to print form for posting an image to the site's content area
  • CPrintImage - contains methods to print form for input of print options
  • CPrintOptions - encapsulates print options; contains methods for converting them to and from a string
  • CSaveImage - contains methods to print form allowing visitors to save an image
  • CSetOptions - base class for classes that allow visitors to set image options
  • CSetOptionsOriginal - contains methods to print form for setting image options specific to Original compositions

Help Classes

These classes print help text:

  • CHelpDrawPage - defines methods for printing help text on the draw page
  • CHelpListPage - defines methods for printing help text on the list page

Image Classes

These classes manage image parameters and draw images:

  • CDrawImageOriginal - draws an image; operates outside of the joomla! framework and may be specified in the src attribute of an img tag
  • CDrawParameters - encapsulates request parameters used to draw an image
  • CDrawThumbnail - draws a thumbnail of an image
  • CFunctionsCookies - contains methods that can get score information from cookies
  • CFunctionsDatabase - contains methods that interface with database when outside of joomla! framework
  • CFunctionsDrawing - contains methods that interface with PHP graphics commands; this class actually calls the PHP commands that draw the image
  • CImage - base class for defining an image
  • CImageOriginal - contains methods that create and display an image that is an Original composition
  • CPrintPage - displays a page visitors can use to print an image; operates outside of the joomla! framework
  • CRectangle - represents a rectangle; contains methods for converting them to and from a string

Library Classes

These classes are available for all other classes to use:

  • CGrojaCookies - contains methods to manage request variables and cookies
  • CGrojaLinks - contains data members defining commonly-used links (URLs)
  • CGrojaScore - encapsulates a profile score
  • CGrojaUser - encapsulates user information

List Classes

These classes print lists of profiles and images:

  • CImageList - prints a list of images
  • CProfileList - prints a list of profiles
  • CPublishedImageList - prints a list of published images

Core Class Inheritance Diagrams

Some of the form classes use inheritance, primarily so that the forms can share methods to print elements common to all forms. These elements include starting and ending form tags, and input tags for hidden variables.

  • There are two groups of form classes, one for each page.
  • Clicking on a diagram opens a full-size version of it in a new window.

List Page Class Inheritance Diagram

This diagram shows the enter profile forms classes. Each form has its own unique representation of the score. Each of these form classes also has methods to set the score from request variables or storage, store the score as cookies, and print the form.

Diagram of classes defining the enter profile forms, see text for details


Draw Page Class Inheritance Diagram

This diagram shows the draw page forms classes. These forms have less in common than the enter profile forms, but it is still worthwhile for them to share a base class.

Diagram of classes defining draw page forms, see text for details


Timeline

Many of the image classes and a few of the form and library classes have been in existence since version 1 of the site. Most of the remaining classes listed above were written for version 2 of the site.

Only the help classes, CEnterProfilePercentages, CFunctionsDatabase, CPostImage, and CPublishedImageList are completely new to version 3.

The ability to reuse these classes as a complex system such as this evolves over the years shows how using Object Oriented Design principles can aid in writing reusable code.

Last Updated on Monday, 21 December 2009 00:54