Developing New Paths

The Mojavi Project

January-5-09

Time to upgrade your cell phone

posted by admin

The technology in cell phones is changing so quickly that it can be difficult to compare cell phones just on various websites especially those of the actual wireless carriers. With all the hype of the new Blackberry Storm and its touch screen features many makers of phones are bringing to market their version similar to the Blackberry or to compete with the iPhone. The problem is that the functionality that has made the iPhone so popular is that it is very intuitive for whatever application that you are using it for. Business people love the iPhone because they stay in touch with their email, web based applications, and much more.

Many of the new phones coming out now are craming features on a phone that may not be as stable as the platform that Apple has chosen and has resulted in mix reviews on the newer models. Even Google launched their new high tech phone which has promise and is more open to developers who love to write code for and hack into the latest technology. So whn you are getting ready to upgrade your new phone check the phones out in the store first and then shop online to find some really great deals and reviews to help you make your decision.

January-5-09

Digital TV in 2009

posted by admin

If you are like many Americans you are awaiting the total change over to digital broadcast that will be taking place on February 19, 2009. For those that have DirecTV or cable service the change will impact the way that you watch TV. For those that still have some of the older sets where you are watching over the air broadcast then you will no longer be receiving those signals and will need to upgrade your TV or buy a converter box.At first there was a big scare that if you did not have the latest technology that your TV would simply go dark and you would not receive any channels. The simple truth is that you can take advantage of some of the great DirecTV deals that are being offered to upgrade your service or you need to obtain a digital converter box which can be bought at almost any big box electronic store.

There are millions of Americans who have upgraded their TVs to the new HDTV so there choice is whether to go with cable or look at the DirectTV offers which boast over 100 HD channels to take full advantage of their new sets. With so many people going HD the cable and satellite companies are offering some great deals in order to obtain these customer because they realize that you have choices and want to create a customer for life. As the technology gets better and their are more programs being broadcast in HD then you should research your options and find out which service is right for you. Right now though is a great time to look for those deals since there will be a lot of people looking to make the switch to digital.

December-28-08

Reliable hosting

posted by admin

Finding a reliable hosting company can be quite a complicated task and there are many factors to consider. How much server space you will have? What types of servers and operating systems that are used? So they have redundant backups? How many domains and email addresses can you host on one account? And how much bandwidth can you receive without being penalized? You can find web hosting tutorials online to help navigate all the choices and help to simplify your choices. Since most companies you find online are now offering unlimited bandwidth, storage, and other features you will want to understand what each of these really mean and how they will affect you and your blog or website.

Keeping in mind that companies that offer unlimited bandwidth may not be a good choice since they are usually cramming 100’s of sites on one server and then hoping that they all only use a small percentage of space. You need to find a hosting company that will allow you to change plans as your website grows. You also want to be able to understand the uptime gurantee and how accessible is their support should you have any issues with the server or your websites.  You can always find cheap web hosting but in most cases you will get what you pay for so it is essential for your blog or website to really do your homework before settling on a provider.

December-19-08

What is Wi-Fi?

posted by admin

We see the term every, but do we really understand what Wi-Fi is? It’s on the window at Starbucks, the box our laptop comes in and is a huge selling point for PS3 and Xbox, but do we really know what Wi-Fi is? Well simply put, Wi-Fi is the trade name for popular wireless technology used in home networks, mobile phones, video games and other electronic devices that require wireless networking. Wi-Fi technology is supported by personal computers, game consoles, printers and other peripherals which can operate wirelessly.

The practical purpose of Wi-Fi is to provide wireless connectivity to digital content. This content may include audio and visual material, Internet, or other data that can be transmitted among several users. Wi-Fi makes transferring information easier, as it eliminates the need for cables.

Generally, Wi-Fi is used to connect to the Internet wirelessly. A Wi-Fi enabled device such as a laptop, game console, PDA or mobile phone can connect to the Internet through Wi-Fi when in range of a wireless network that is connected to the Internet.

Not to be confused with mobile broadband , Wi-Fi requires an Internet signal to be in range for connectivity. In addition to being used at home and offices, Wi-Fi can be accessible through ‘hotspots’. Restaurants, airports and hotels often offer free hotspots to attract and retain customers, especially in the Internet driven world we live in today.

Hotspots are a major selling point for hotels around the world and most coffee shops now advertise “Wi-Fi Hotspot” on their front window to attract customers. But customers be aware, a hotspot doesn’t mean free Internet, some establishments charge to use their Internet while others are free of charge, so shop around and make sure you get yours for free, after all, you are paying six bucks for a cup of coffee, the least they can do is let you check your Facebook for free!

December-13-08

Lanyards: what are they and how can you use them

posted by admin

When you think about developments in various areas is amazing to think about how a simple item such as the lanyard is used in so many facets of business and our personal lives. From id lanyards to lanyards used at theme parks to help you collect your favorite pins this item has taken on a life of its own. Our corporate headquarters has gone back and forth on the lanyard and retractable badge reels. The reels are typically worn on your belt or outside of your jacket and do make it easy if you are having to badge in and out of various buildings. The lanyard has become the choice among many of our employees because they are easier to wear outside your clothing and provide several advantages such as the ability to hold pens, and other photo ids that are easier to access. The lanyard has become so popular that many organizations and businesses are finding many different uses for them and here are some of the advantages:

1. For starters they are very inexpensive. Many businesses and conference planners purchase them in bulk because they know that are not kept for long periods of time and those that use them in conference know that they will be thrown away after the meeting. They are also becoming a popular items among sports teams and fans because they allow you to add your team spirit by sporting your favorite NFL or MLB team while keeping your id and keys together.

2. Companies and Organizations use them for identification because it is visible and can be seen from a greater distance. Many companies are now branding these simple lanyards to help identify their employees and to help build brand recognition. This is because most people will leave their badges on when they leave work when they are stopping by the store on their way home. They are easily customized for special events and can be printed in a short time frame.

3. They are easy to use and unlike clips that will not damage your clothing. Even youngsters can use them for day camps and various sports camps. They can be hung up and are easier to keep track of than clip on id holders or badges that are just in holders.

This simple yet useful tool can be found and purchased for your company needs at Idsuperstore.com where they also carry a full line of plastic card printer supplies and devices. Such as devices that can print id cards and smart cards that can be used to hold information on employees, or attendee information to help create an electronic database to help the marketing departments know which customers are visting their trade show booths.

Tags:
December-8-08

Mojavi 2.0 migration

posted by admin

Migrating From Mojavi 2.0

Moved To: Migrating From Mojavi 2

Note: This document will be changing frequently as I add more information, and rearrange to create a more logical order and progression of the said information.

* Prerequisites
* First Things First
* The Context
* Translating your Renderer
* View
* Actions
* Configuration
* References
* File Formats

Prerequisites

You should have a decent grasp of Mojavi2 and PHP5 before trying to upgrade to Mojavi3.

If you want a quick crash course of Mojavi 3, see Creating Your First Module 2.
First Things First

Before you begin transferring your applications over from Mojavi2, make sure whatever host you’re using supports PHP5. You can figure out if your host supports PHP5 by running

phpinfo();

Furthermore, you need to download and install the Mojavi3 package, which can be attained by going to this location.
The Context

Probably the most important new and powerful aspect of Mojavi3 is the Context object. Once I figured out what this thing did, I fell in love with it. Basically, it is a sort of catalyst/storage object that allows you to access:

* The $request object via getRequest()
* The $controller object via getController()
* The $user object via getUser()
* The Current Action/Module names via getModuleName() and getActionName()
* And finally the Current module’s directory

More or less, most classes that are exposed to the user/developer (you) are going to have a getContext() function, which will allow you to access this file extension. And with the recent addition of cascading calls, you can perform operations that you were unable to in php4, for example:

The Old Way:

$obj =& $request->getAttribute(’myobj’);
$anotherobj =& $obj->doSomethingSpecial();
$anotherobj -> execute();

The New Way:

$this->getContext()->getRequest()->getAttribute(’myobj’)->doSomethingSpecial()->execute();

Okay, so maybe that wasn’t the best example, as it is rather lengthy, but you get my point, 1 line vs 3 lines, and no possible mistakes when dealing with large objects like copying them over without references, etc.

This subsection is to be continued….
Translating your Renderer

Mojavi2 used ‘renderers’ to translate the API of one templating system into a generic API that would easily allow a developer to switch out one templating system for another. For example, the Smarty templating engine uses $smarty->assign() to allow you to set a variable, while patTemplate, another templating system, uses $pat->addVar(). In Mojavi 2, you would then write or use an existing renderer, which you would then invoke to display your output and be output in the correct file formats.

Note: This was done typically through a filter, which would create the renderer object, then assign it to your $request via

$request->setAttribute(’MyRenderer’,$rendererObj))

Mojavi3 uses largely the same methodology, but instead of getting the renderer directly from the $request object within each of your views, it simply extends the View class.

For example:

abstract class SmartyView extends View
{
…..

function __construct()
{
$this->engine = $this->getContext()->getRequest()->getAttribute(’MySmartyObj’);
}

public function setAttribute($name, $value)
{
$this->engine->assign($name, $value);
}

…..
}

Note: the use of

$this->engine = $this->getContext()->getRequest()->getAttribute(’MySmartyObj’);

was simply the best solution I could come up with for getting any object from within the view, you could also have done the following just as easily:

$this->engine = new Smarty();

View

The Mojavi3 View is mostly an abstract class, which provides a skeleton of functions to work with, thus providing the unified API as was achieved in Mojavi2 (It’s unified because you are forced to comply with the naming conventions implemented by the abstract class View.)

Now, instead of intitializing your Renderer object (as you would in Mojavi2) you simply extend View, and initialize that. Like shown above:

abstract class SmartyView extends View
{

is what our new View would look like. To put this new View type into action, we extend it when declaring views for our modules. For example:

class DoSomeActionSuccessView extends SmartyView
{

}

As you can see, this is much more fluid than pulling the renderer out of $request with every new View, it’s also a lot less code that you have to copy and paste, and thus less code to maintain. You may also have noticed that the naming scheme is different for the Views, instead of naming the file format DoSomeActionView_success.class.php you would now name it DoSomeActionSuccessView.class.php, and name the class likewise(In Mojavi2 we just named our view classes DoSomeActionView, in Mojavi3 it’s DoSomeActionSuccessView replacing ‘Success’ with your application’s state).

This subsection is to be continued….
Actions

Actions in Mojavi3 are fairly similiar to those of Mojavi2, with a few enhancement and semantic tweaks here and there. Listed Below:

* When returning a VIEW_SUCCESS in Mojavi2, now return the View class constant corresponding to your application state, ie: View::Success, or View::Error
* When checking for view types supporting execution (getRequestMethods) instead of returning REQ_POST etc, return Request::Post etc.
* There is a new return type for getRequestMethods(), Request::All, which serves all request methods.
* The root Action class which all your actions extend now has a getContext() method, which allows you access to the context object.

Configuration

Mojavi3 configurations are done, by default, using .ini files. This simple and straightforward configuration makes configuring mojavi very easy. The base syntax of these ini files is as follows:

[SECTION]

; a comment…..
ConfigKey = “%MO_APP_DIR%/my/config/value”

Because some people might not like ini files, Mojavi3 was created in such a way that you could write your own configuration handlers. For example, if you wanted to use xml files to configure your mojavi, you could write a configuration handler, plug it in, and start using your custom configuration styles.

This subsection is to be continued….
References

To find out more about PHP5 in general go here: Where can I go to learn more?

December-5-08

Fuel efficient rides are they worth the cost

posted by admin

We just recently ordered a brand Toyota Hybrid for my company car and I really excited about having a new car and one that is supposed to be better for the environment. Now that gas prices have come down to under $2 per gallon I wondered how much extra I would be saving in fuel costs. It turns out that the cost savings in fuel is not as a dramatic as it was 3 months ago, but the other benefits of owning a hybrid car should be beneficial overall.

One of the things that I noticed when ordering our new car is that some of the features available on the non-hybrid model were non-existent on the hybrid model. So this got me to thinking about a post we did early for those holiday shoppers out there looking for something creative to get that special one who is a proud owner of a hybird vehicle. At juicedhybrid.com they carry a great selection of accessories for most of the major manufacturers of hybrid models. And if you are not sure then there are always gift cards to their site so that they can pick out exactly what they want. So why not go green this Christmas and purchase something that they will be able to enjoy year round and actually do some good for the environment.

Tags:
December-3-08

Standard PHP Scripting Limitations

posted by admin

Unconventional

The typical PHP web application consists of scattered scripts located in filesystem structure that well resembles a web. When web scripting originated, the tasks to be performed were relatively simple, at least compared to todays tasks. So, the scattered list of files served quite well. In today’s world, we have very demanding applications, with very intense needs. Using the typical “a script here, a script there” method of designing a web application simply won’t cut it. You need a convention, in terms of file location and naming, and coding. Mojavi is based around a very strict convention of location and naming of files, and coding conventions. This allows you to familiarize yourself with the system very easily, which will lead to a more comfortable web application environment. Ultimately, there is a barely visible learning curve associated with Mojavi, which makes it very easy to learn.

Spaghetti Code

Most PHP scripts consist of a few PHP functions, a little bit of execution code, and then the typical HTML presentation. Combining application logic with presentation leads to spaghetti code. Not only is it hard to read, but it also results in redundant code use. With Mojavi, you follow a very simple rule — divide your logic, or pay the price. You must put your application logic in an Action implementation, your presentation logic in a View implementation, and then put the actual presentation, whether it’s HTML or XML, etc., into a template.

November-26-08

Is your hybrid ready for the winter

posted by admin

We wrote a few weeks ago about the latest accessories for your hybird vehicle. When they first came out they were in limited supply and most modifications were hard to come by. Now this holiday season you will find snow racks, engine block heaters, and car covers especially designed for your hybrid. Just because you are trying to go green and help do your part for the environment does not mean that your ride has to be boring.

With the advancement in technology and new cross over and SUV type vehicles are being introduced into the hybrid vehicle world you will have more choices and options. Most the major car makers have introduced several new lines and even the luxury car makers are getting into the game as well. So if you are shopping this holiday and unsure what to get that person that has everything and has just purchased the new Porsche Hybrid then maybe a new accessory that will make their ride just a bit more special could be just what Santa ordered.

November-25-08

Creating your first module

posted by admin

Creating Your First Module
A work in progress

This tutorial is a work in progress, so you may find parts that don’t completely fit together.
Module

The module is where the Model and View takes place in the MVC model. For this first example, we will create a very simple module that will move data from a Action to a View and display it on the screen, through a template.

The module is contained within a directory that carries the name of the module. This resides in the modules directory of the webapp directory. Inside the module directory are sub-directories holding the classes that make up the module. Here is the directory hierarchy:

webapp
|
|—modules
|
|—moduleName
|
|—actions
|
|— config
|
|— lib
|
|— models
|
|— templates
|
|— validate
|
|— views

Minimally, you need the actions, config, templates and views directories. However, I prefer to have a blank module created and just copy and rename it. You can get a copy of the blank module (link to be added). I have chosen to call this module Test

Each module must have a module.ini file in the config directory. Here is the module.ini for Test

; +—————————————————————————-+
; | This file is part of the Mojavi package. |
; | Copyright (c) 2003, 2004 Sean Kerr. |
; | |
; | For the full copyright and license information, please view the LICENSE |
; | file that was distributed with this source code. You can also view the |
; | LICENSE file online at http://www.mojavi.org. |
; | ————————————————————————– |
; | MODULE INFORMATION FILE |
; +—————————————————————————-+

[module]

ENABLED = “On”

TITLE = “Getting Started Test Module”

VERSION = “0.1″

NAME = “TestModule”

AUTHOR = “Richard D Shank”

HOMEPAGE = “http://www.mojavi.org”

DESCRIPTION = “A test module”

The module is pretty self explanitory. It is necessary to have ENABLED property set to “On” for the module to be used by Mojavi. Now that we have the module set up, we can work on the classes.
Action

The Action class handles the request for the module. It can be as simple as handling a static html template or a full blown multi-page wizard style form. Just a note to Mojavi 2 users, a significant change from Mojavi 2 to Mojavi 3 is that it is not longer necessary to pass the controller, request and user classes in on many of the methods. These are now accessed through a context class. More on that later.

This is a list of the methods you can use in an Action and an explanation of what they do
execute ()

Note: This method is required in your Action class.

This will execute any application/business logic for the action. This method is reached only after the request methods have been checked and any of the parameters have been validated.

When leaving, the execute() method should tell the controller what view is to be used. This is done by returning a string containing the view name associated with the action or an array of the parent module for the view to be executed, parent action for the view and the name of the view. I will show an example of return both in a later tutorial.
getCredential ()

This is a new feature in Mojavi 3. Basically, a credentials are a privilege array that describes any level of security. They work hand in hand with the security aspects of the User class. For Mojavi 2 users, note that this replaces the old Privileges. But it is also important to know that it can do more than just handle privileges. I will handle the usage of creditials in a later section. For now, it is sufficient to know that we set the creditial requirements for the action inside this method and that it is set to NULL by default.
getDefaultView ()

This is the view that will be executed when a given request is not served by the action. This could happen when a form being displayed for the first time or if we are displaying a static page.

Again, just as with the execute() methoad, a string with a view name or an array of a module/action/view is passed back to the controller. By default it will pass back View::INPUT
getRequestMethods ()

This method will determine what types of requests will be recognized. There are 4 choices:

* Request::GET - Indicates that this action serves only GET requests.
* Request::POST - Indicates that this action serves only POST requests.
* Request::NONE - Indicates that this action serves no requests.

You can also select both GET and POST requests by using Request::GET | Request::POST
handleError ()

Execute any post-validation error application logic.

It also returns the view through a string of the view name or the array of a module/action/view. By default, it passes View::ERROR.
initialize ($context)

You can set up the Action in the initialize() method. In a later tutorial, I’ll give an example of doing this. NOTE: It is worth to note that you must handle the context in the initialize() method. You should do this by

parent::initialize($context);

You also need to return a TRUE or FALSE based on the success of the initialization. By default it is TRUE.
isSecure ()

Does the action require security? TRUE if you do, FALSE otherwise. It is FALSE by default.
validate ()

This is used to manually validate input parameters instead of using a pre-progammed validator. This will also be explain later in the tutorial on validation.
Creating Your First Action

Now that we have an overview of the Action class, we can move forward to creating our first Action. For this example, there isn’t any request to be handled so we can set up a minimal Action.

In naming an action you must use this format Actionname Action.class.php where Actionname is what you are calling this particular action. When you declare your class, it also must have the class name in the same format Actionname Action. For this example, I chose to call this FirstAction.

When creating a new action, at the very least, there has to be an execute() method, even if it does nothing. Also, since we are displaying a non-request page, we don’t need to process any request. We tell the controller this with the getRequestMethods() method, by setting the return value to Request::NONE. Finally, we also need to tell the controller what the default view is going to be. We do this by returning View::SUCCESS in getDefaultView().

Here is what my FirstAction.class.php looks like. I basically just took my BLANKAction.class.php, renamed it to FirstAction.class.php, renamed the class to FirstAction, removed the methods I didn’t need and set the remaining 3 methods to match my needs.

class FirstAction extends Action
{
/**
* Execute any application/business logic for this action.
*/
public function execute ()
{
// we don’t need any data here because this action doesn’t serve
// any request methods, so the processing skips directly to the view
}

// ————————————————————————-

/**
* Retrieve the default view to be executed when a given request is not
* served by this action.
*/
public function getDefaultView ()
{
return View::SUCCESS;
}

// ————————————————————————-

/**
* Retrieve the request methods on which this action will process
* validation and execution.
*/
public function getRequestMethods ()
{
return Request::NONE;
}

You can also return a view from another module. You do this by passing an array with the view information intead of the standard View::INPUT. When you use this you create a two element array. The first element is the module name. The second element is which view you want. It cannot be just the Action name, but the Action name with the specific view.

Here’s an example:

class MyClass extends Action
{

function execute()
{

$returnView[0] = MyModule;
$returnView[1] = DoSomethingInput;
-or-
$returnView[1] = DoSomethingError;
-not-
$returnView[1] = DoSomething;

return $returnView
}
}

View

I’ll add more to this later, describing the View class.

For now, all we need to use is the execute() method.
Creating the View

The class name should be in this format ActionnameViewtype View. Again Actionname is the name of the action in the module. Viewtype is the view type that was passed to the controller in the action. Both Actionname and Viewtype are capitialized. This is a list of the predefined view file types and their naming convention.
Internal Name Class and File Name
ALERT Alert
ERROR Error
INPUT Input
SUCCESS Success

Mojavi 2 users ; the naming convention on the file has changed slightly. Before there was an underscore between Actionname and Viewtype. Now, there is no underscore in between, and the Viewtype is capitialized.

For this example, I called my view FirstSuccessView and named the file FirstSuccessView.class.php.

Here’s the code

class FirstSuccessView extends PHPView
{
/**
* Execute any presentation logic and set template attributes.
*/
public function execute ()
{

// set our template
$this->setTemplate(’FirstSuccess.php’);

// set the title
$this->setAttribute(’title’, ‘Getting Started First Test Page’);

// set the message that is to be passed
$this->setAttribute(’passedData’, ‘Hello World!’);

}

}

Template

You also need a template to display the information. I stayed with the naming convention and called my file FirstSuccess.php.

Here is the code for that

This is the result of my first test. I have created a module, action, view and
template. I have successfully passed data from the view to the template.This is what I passed:
That is all for now.

Notice at the first and last line I include a header.php and footer.php. I used this to show how you could have a uniform look across the entire site and how you could do that. Mojavi uses a global template directory in your webapp directory. It is defineed as MO_TEMPLATE_DIR and it called templates. I added the following files to the includes sub-directory in the global template directory.
header.php