Development Information

November 20, 2010

Mini MVC – Form Builder 1.0.5 → 1.0.6 → 1.0.7

Filed under: Updates — judda @ 1:24 pm

Version 1.0.6:

  • Fixed a minor inconsistency where the names and ids were being generated in different orders.

Version 1.0.7:

  • Changed the form’s value array so that it only contains checkboxes if the box has been checked (i.e. similar to the way that $_POST does it)
  • Validated the HTML being emitted

November 7, 2010

Mini MVC – Form Builder 1.0.4 → 1.0.5

Filed under: Updates — judda @ 5:54 pm

Small update:

  • Added a ‘value’ array to the form object so instead of accessing information through either the $_POST/$_GET array, you will grab it through $form -> value
  • Added getElementId function – takes in the field name you want the id of and returns the unique id which is generated for the field

October 30, 2010

Mini MVC – Form Builder 1.0.3 → 1.0.4

Filed under: Updates — judda @ 9:58 am
  • Added in a setValue function to the Form Builder Object in case you don’t know what the value is when you create the new element.
  • Updated the documentation

October 24, 2010

Links Update

Filed under: Site Update — judda @ 5:17 pm

I noticed that the list of links was getting relatively long, so instead of adding more on the side bar, I have created a page for all of the previous versions of the applications I have made.

Mini MVC – Form Builder 1.0.2 → 1.0.3

Filed under: Mini MVC Information,Updates — judda @ 3:38 pm

After the previous update to the Form Builder, it was mentioned to me that the placing of each element in it’s own div was no longer required. This update removes those divs and just causes the straight HTML to be returned from the toHTML functions.

October 3, 2010

Mini MVC – Form Builder 1.0.1 → 1.0.2

Filed under: Mini MVC Information,Updates — judda @ 2:07 pm

After using the Form Builder, I realized that one part of how it was originally implemented made it extremely hard to use. This has now been fixed.

Instead of returning a string of the output from the actual object, the output is split into two sections:

  • FormBuilder::HTML – The HTML for the actual input element
  • FormBuilder::LABEL – If a label is present, the label part of the input field

Database Class 2.2.8 → 2.2.9

Filed under: Updates — judda @ 1:11 pm

Made the class valid with PHP Strict.

There used to be a binding issue when binding integers would throw a Strict error, this issue has been resolved.

September 5, 2010

MiniMVC v1.0.0 → v1.0.1 and Form Builder v1.0.0 → v1.0.1

Filed under: Mini MVC Information,Updates — judda @ 10:22 pm

Through use further use of MiniMVC and the Form Builder, I have noticed there were a few bugs in them.

MiniMVC the error handling wasn’t working correctly, so it has been fixed.

Form Builder was missing functions for setting CSS classes for the labels, so these (addLabelCSSClass, getLabelCSSClass) have been added in. These take the same parameters as the functions which are similar for the fields (addCSSClass, getCSSClass).

These updates are encouraged as they help to support the core functionality of the application.

August 22, 2010

Mini MVC – How to Use – The Base Controller

Filed under: Mini MVC Information,Tutorials — judda @ 1:33 pm

Sorry for the horribly long delay but here is a quick run down on how to extend the BaseController to write your personal controllers.

As mentioned before, the controller acts as the liaison between the model and the view. These are the classes which get looked for and called whenever your site is visited. For example, if your site is http://www.site.com and the URL is http://www.site.com/about, then Mini MVC will automatically look for the controller named ‘AboutController’ in the ‘./app/controllers/’ directory. The class name for each controller should have the name ‘Controller’ at the end, in order to prevent any namespace collisions between the controllers and the models. It also allows you to quickly and easily determine the difference between the two.

For each controller, you can have as many methods as you would like. These methods are also accessible through the web depending on the URL. For example, http://www.site.com/about/contact would call the ‘contact’ function within the ‘about’ controller. If no function name is provided in the URL, then the default function which is called will be used. This is defined in the configuration file (./app/config/config.php) as the __DEFAULTFUNCTION__. The default function which is called in ‘index’.

Please Note: if you don’t want a function to be web-accessible, prefix it with __ and it will be automatically ignored.

When making your own controller, you should always extend the base class (BaseController) because it provides a bit of additional functionality which is not available if you only make it extend the base class. For example, when you are using a model in your controller, you can then use

$this -> __loadModel ( 'ModelName' );

to load the model into memory and then access it directory through the instance of the controller (i.e. $this -> ModelName).

A sample controller will look like this:

<?php
class SampleController extends BaseController // Accessible by the web through http://www.site.com/sample
{
    public function __construct ()
    {
        parent::__construct (); // Always call the parent's constructor to initialize all information
    }
 
    public function index () // Will be called if no function name is provided (i.e. http://www.site.com/sample)
    {
         // In here you will do any of your data manipulation or generation
         // and tell it what views and models to use
         Base::__loadViews ( array (
                 // Define the 3 parts of the view (header, body and footer) - these definitions are not necessary but they are useful
                 Base::VIEW_HEADER => array ( 'header.php' /* The view name(s) to use for the header */ ),
                 Base::VIEW_BODY => array ( 'body.php' /* The view name(s) to use for the body */ ),
                 Base::VIEW_FOOTER => array ( 'footer.php' /* The view name(s) to use for the footer */ )
             ),
                 // Any variables to send in
                 array (
                     // Please Note: All variables MUST have a name associated with them.
                     'key' => 'value', // Variables to be accessible to all views (accessible through $key in the view)
                     Base::VIEW_HEADER => array ( 'Title' => 'Welcome' ) // Variables only accessible to the header view (can be done for the body and footers as well)
             )
         );
    }
 
    // The $username variable will be filled in with the value associated with information after the function name
    public function other ( $username ) // Will be called if no function name is provided (i.e. http://www.site.com/sample/other/judda)
    {
         // i.e. http://www.site.com/sample/other/judda => $username = 'judda'
         // In here you will do any of your data manipulation or generation
         // and tell it what views and models to use
         Base::__loadViews ( array (
                 // Define the 3 parts of the view (header, body and footer) - these definitions are not necessary but they are useful
                 Base::VIEW_HEADER => array ( 'header.php' /* The view name(s) to use for the header */ ),
                 Base::VIEW_BODY => array ( 'body.php' /* The view name(s) to use for the body */ ),
                 Base::VIEW_FOOTER => array ( 'footer.php' /* The view name(s) to use for the footer */ )
             ),
                 // Any variables to send in
                 array (
                     // Please Note: All variables MUST have a name associated with them.
                     'key' => 'value', // Variables to be accessible to all views (accessible through $key in the view)
                     Base::VIEW_HEADER => array ( 'Title' => 'Welcome',
                         'name' => $username ) // Variables only accessible to the header view (can be done for the body and footers as well)
             )
         );
    }
}

That is all I can think about for this topic, please feel free to ask any questions about it so I can expand on this tutorial. :)

Form Builder (Mini MVC)

Filed under: Mini MVC Information,Updates — judda @ 1:12 am

I have completed a preliminary version of a form builder. It will allow you to programmatically build forms which can be send in from the controllers to your views so that you never have to worry about different views handling the information in different ways (or changing names or anything).

I will be posting links to the documentation soon so that all of the built-in features will be displayed. Just because you are doing things programmatically doesn’t mean you can’t stylize nor have valid HTML. You can add as many attributes to the input types as you want (including specialized ones for adding CSS classes and styles).

Please Note: In this version of the form builder, arrays of fields are not permitted (i.e. they will overwrite each other). I am actively working to remove this limitation as soon as possible.

Along with the form builder, I have uploaded a small update to the Mini MVC base engine (just a little clean up thing).

« Newer PostsOlder Posts »

Powered by WordPress