Monday, August 16, 2010
Friday, April 16, 2010
????????????
1. what is team work
2. what ideas you have to motivate the employees
3. what is a Team Leader?
The ability of a team to work together as a single unit with a common aim
2. what ideas you have to motivate the employees
Motivation is of two types.
Internal and External Motivation-
Internal Motivation-Analyse The Team members conflict and where they are lacking-and i encourage and help to develop from that point by providing guidance and sharing my experience.
External Motivation-We Can Conduct some competition among the Team Members so that They get Motivated and arrange some Outing.
3. what is a Team Leader?
Team Leader is a role model for the team members. He will be taking care of the team and their work. Team Lead should be having a mentality of not leading the team, instead driving the team in the best way.
Tuesday, February 9, 2010
Facebook Style Alert Confirm Box
HTML / Javascript Code
link href="facebook.alert.css" rel="stylesheet" type="text/css"
script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js
script type="text/javascript" src="jquery.alert.js
script type="text/javascript"
$(document).ready( function()
{
$("#delete_confirm").click( function()
{
jConfirm(Are you sure you want ot delete this thread?, ,
function(r)
{
if(r==true)
{
//You havt to include Ajax funtion for deleting records tutorial link
$("#box").fadeOut(300);
}
});
});
});
script
div id="box" style=" background-color:#ffffcc;"
a href="#" id="delete_confirm" Delete /a
Facebook.alert.css
Contains CSS code.
#popup_container
{
font-family:Lucida Grande,arial;
font-weight:bold;
text-align:left;
font-size: 12px;
width: 364px;
height: 86px;
background: #F3F3F3;
border:solid 1px #dedede;
border-bottom: solid 2px #456FA5;
color: #000000;
}
#popup_title
{
display:none;
}
#popup_message
{
padding-top: 15px;
padding-left: 15px;
}
#popup_panel
{
text-align: left;
padding-left:15px;
}
input
{
background-color:#476EA7;
padding:3px;
color:#FFFFFF;
margin-top:20px;
margin-right:10px;
}
link href="facebook.alert.css" rel="stylesheet" type="text/css"
script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js
script type="text/javascript" src="jquery.alert.js
script type="text/javascript"
$(document).ready( function()
{
$("#delete_confirm").click( function()
{
jConfirm(Are you sure you want ot delete this thread?, ,
function(r)
{
if(r==true)
{
//You havt to include Ajax funtion for deleting records tutorial link
$("#box").fadeOut(300);
}
});
});
});
script
div id="box" style=" background-color:#ffffcc;"
a href="#" id="delete_confirm" Delete /a
Facebook.alert.css
Contains CSS code.
#popup_container
{
font-family:Lucida Grande,arial;
font-weight:bold;
text-align:left;
font-size: 12px;
width: 364px;
height: 86px;
background: #F3F3F3;
border:solid 1px #dedede;
border-bottom: solid 2px #456FA5;
color: #000000;
}
#popup_title
{
display:none;
}
#popup_message
{
padding-top: 15px;
padding-left: 15px;
}
#popup_panel
{
text-align: left;
padding-left:15px;
}
input
{
background-color:#476EA7;
padding:3px;
color:#FFFFFF;
margin-top:20px;
margin-right:10px;
}
Safe Updates with MySQL
How to achieve safe updates with MySQL and PHP
In this post, we are going to discuss about safety updates with MySQL and using that with PHP.
For beginners, a useful startup option is ’safe updates’ (or –i-am-a-dummy, which has the same effect).
This option was introduced in MySQL 3.23.11. It is helpful during situations wherein you might have issued a “DELETE FROM tbl_name” statement but forgotten the WHERE clause. Normally, such a statement deletes all rows from the table. With ’safe updates’, you can delete rows only by specifying the key values that identify them. Hence, this helps prevent accidental deletions.
When you use the ’safe updates’ option, MySQL issues the following statement when it connects to the MySQL server:
SET sql_safe_updates=1, sql_select_limit=1000, sql_max_join_size=1000000;
The SET statement has the following effects:
You are not allowed to execute an UPDATE or DELETE a statement unless you specify a key constraint in the WHERE clause or provide a LIMIT clause (or both). For example:
UPDATE tbl_name SET not_key_column=val WHERE key_column=val;
UPDATE tbl_name SET not_key_column=val LIMIT 1
The server limits all large SELECT results to 1,000 rows unless the statement includes a LIMIT clause.
These are the options available with MySQL.
Now, we can use this in our coding by doing a small trick.
When you use the ’safe updates’ option and connect MySQL at command prompt, MySQL issues the following statement when it connects to the MySQL server:
SET sql_safe_updates=1, sql_select_limit=1000, sql_max_join_size=1000000;’
So, we can use this “SET sql_safe_updates=1″ query in our PHP coding. After connecting with the server and selecting the db, we need to execute this query so that safety update will affect all the other queries executed thereafter. This will ensure that no updates or delete operations perform without the WHERE clause.
This is an useful and important safety measure which can be used in our projects to avoid accidental deletion of all records in a table.
// This is will be useful to avoid sql injection which may delete all rows of a table
// http://dev.mysql.com/doc/refman/4.1/en/mysql-tips.html
error_reporting(E_ALL);
$con= mysql_connect(”localhost”,”sorna”,”password”);
mysql_select_db(”test1″,$con);
mysql_query(”SET sql_safe_updates=1″);
mysql_query(”DELETE FROM register”); // This line won’t delete the table since we have turned on the safe updates mode. It won’t execute the delete query when it doesn’t have where clause
mysql_query(”DELETE FROM register WHERE id=6″); // This line will delete the record in which id is 6
mysql_close();
?>
In this post, we are going to discuss about safety updates with MySQL and using that with PHP.
For beginners, a useful startup option is ’safe updates’ (or –i-am-a-dummy, which has the same effect).
This option was introduced in MySQL 3.23.11. It is helpful during situations wherein you might have issued a “DELETE FROM tbl_name” statement but forgotten the WHERE clause. Normally, such a statement deletes all rows from the table. With ’safe updates’, you can delete rows only by specifying the key values that identify them. Hence, this helps prevent accidental deletions.
When you use the ’safe updates’ option, MySQL issues the following statement when it connects to the MySQL server:
SET sql_safe_updates=1, sql_select_limit=1000, sql_max_join_size=1000000;
The SET statement has the following effects:
You are not allowed to execute an UPDATE or DELETE a statement unless you specify a key constraint in the WHERE clause or provide a LIMIT clause (or both). For example:
UPDATE tbl_name SET not_key_column=val WHERE key_column=val;
UPDATE tbl_name SET not_key_column=val LIMIT 1
The server limits all large SELECT results to 1,000 rows unless the statement includes a LIMIT clause.
These are the options available with MySQL.
Now, we can use this in our coding by doing a small trick.
When you use the ’safe updates’ option and connect MySQL at command prompt, MySQL issues the following statement when it connects to the MySQL server:
SET sql_safe_updates=1, sql_select_limit=1000, sql_max_join_size=1000000;’
So, we can use this “SET sql_safe_updates=1″ query in our PHP coding. After connecting with the server and selecting the db, we need to execute this query so that safety update will affect all the other queries executed thereafter. This will ensure that no updates or delete operations perform without the WHERE clause.
This is an useful and important safety measure which can be used in our projects to avoid accidental deletion of all records in a table.
// This is will be useful to avoid sql injection which may delete all rows of a table
// http://dev.mysql.com/doc/refman/4.1/en/mysql-tips.html
error_reporting(E_ALL);
$con= mysql_connect(”localhost”,”sorna”,”password”);
mysql_select_db(”test1″,$con);
mysql_query(”SET sql_safe_updates=1″);
mysql_query(”DELETE FROM register”); // This line won’t delete the table since we have turned on the safe updates mode. It won’t execute the delete query when it doesn’t have where clause
mysql_query(”DELETE FROM register WHERE id=6″); // This line will delete the record in which id is 6
mysql_close();
?>
Wednesday, August 20, 2008
Content Management by php
DotClear
Code conforme aux normes du W3C, dont le XHTML 1.0, Usage de CSS, URL significatives, fils RSS et Atom, Support complet des trackbacks, Support complet de l'unicode, Multi-utilisateur avec niveaux, Interface multilingue, Système de commentaires flexible, Syntaxe Wiki et (X)HTML, Support des clients XML/RPC
WordPress
WordPress is a state-of-the-art semantic personal publishing platform with a focus on aesthetics, web standards, and usability. What a mouthful. WordPress is both free and priceless at the same time.
CMSimple
CMSimple is a simple content management system for smart maintainance of small commercial or private sites. Simple installation and easy to modify. The entire site is stored in a single HTML-file - there is no need of databases. CMS is less than 50 KB. Integrated WYSIWYG online editor (both IE and Mozilla), link validation, image handeling, online editing of system files and automatic backup on logout.
Guppy
En un tour de main, vous pourrez monter votre site, sans aucune connaissance en HTML et PHP. Le présent site vous offre un petit aperçu des fonctionnalités proposées par le portail, dans sa version de base. Mais de nombreux plugins, modules et hacks, ainsi que des skins variés, développés, créés et proposés par la communauté des utilisateurs de GuppY, vous permettent également de customiser votre portail sans difficultés, pour l'adapter à votre besoin spécifique.
Back End CMS
Back-End is a multi-lingual CMS based on the phpSlash.org code base. Articles, links & photo galleries integrated into a common hierarchy. Content administrators can edit their content through a choice of text, html, wiki or a WYSIWYG editor.
OpenPHPNuke
OpenPHPNuke (OPN) is an Open Source Web Content Management System (WCMS) which will assist you in the creation, administration, and maintenance of contents for the internet or intranet. With OPN you can build your homepage, a web portal, and various other ideas for the internet.
Logicreate
For web site owners, the basic LogiCreate system gives you the tools to control and monitor your own website. The standard tools included allow you to create new HTML pages, send mass emails to users on your system, and view real-time usage reports of your site's activities. For web developers, LogiCreate allows you to develop new applications more efficiently, by building on our standard API. Writing against our system, issues of security/permissions, logging, database handling, sessions and more are all taken care of automatically, allowing you to concentrate on the core logic for your application.
Tiki
Tiki is a leading open source full featured content management system (CMS) and Groupware (Intranet) suited for many types of online communities. Features include Articles, forums, blogs, directory, topics, wiki, polls, trackers, image galleries, webmail, and much more. Using PHP, MySQL and Smarty.
Typo3
TYPO3 is a small to medium enterprise class Content Management Framework. It offers the best of both worlds: out-of-the-box operation with a complete set of standard modules and a clean and sturdy high-performance architecture to accomodate virtually every kind of custom solution or extension.
AWF
Das Liquid Bytes Adaptive Website Framework (AWF) richtet sich an Software-Entwickler und im Umgang mit Web-Technologien erfahrene Anwender. Es erlaubt auf einfache und schnelle Weise volldynamische Websites inkl. Community Funktionen aufzubauen. Auf der anderen Seite ist es auch möglich, statische HTML Seiten zu exportieren, um diese dann auf Servern ohne PHP/MySQL zu hosten.
Bolinos
BolinOS is a reliable Open Source Content Management System. BolinOS is a modular publication and communication platform for Internet / Web developped in order to enable simple management of complex portals. Bolinos uses standard open-source software: PHP, Apache, mySQL, providing an environment for deploying powerful Internet based content management solutions.
webXadmin
webXadmin is a generic php/mysql application that performs data / web-content management through a webbased HTML interface. From an XML-based schema definition, webXadmin generates records lists, HTML forms and associated sql queries.
Bitflux CMS
Bitflux CMS is an XML and PHP based Content Management System. It allows you to reuse your content in different ways. Bitflux CMS uses as "template" engin XSLT and almost everything is configurable with XML. No need to learn PHP for just setting up a new site. Bitflux CMS uses Popoon as backend engine and is therefore very customizable to your needs. Bitflux CMS is published under the GPL License, so you can download and use it free of charge and can do with it, whatever you want.
Typo3
Typo3 is a professional class Web Content Management System written in PHP/MySQL. It's designed to be extended with custom written backend modules and frontend libraries for special functionality. I has very powerful integration of image manipulation.
Whump: More like this
More Like This WebLog uses PHP and MySQL to manage and display the site. (PHP +SQL)
dotWIDGETS
dotWidgets are compact and easily-configurable scripts that facilitate website content management.
SPIP
french content management system, very simple and elegant.
phpblog
C'est un ensemble de pages écrites en langage PHP. Il suffit d'un hébergeur proposant PHP/MySQL pour pouvoir faire fonctionner phpBlog ! La plupart des hébergeurs gratuits en sont capables. Il suffit de deux clics pour préparer la base de données à recevoir toutes les infos nécessaires à phpBlog, et de mettre les pages PHP chez l'hébergeur après avoir répondu à quelques questions simples pour la configuration, et en avant !
pMachine
pMachine was written in PHP and runs on any server that has PHP 4 and MySQL installed. If you don't know anything about PHP or MySQL, don't worry... you don't need to! pMachine lets you build feature-rich, dynamic web sites with all the power and speed of PHP/MySQL without the steep learning curve.
PostNuke
A content Management system with PHP and MYSQL
PHPWebsite
phpWebSite provides a complete web site content management system. Web-based administration allows for easy maintenance of interactive, community-driven web sites. phpWebSite's growing number of plug-ins allow for easy site customization without the need for unwanted or unused features. Client output from phpWebSite is valid XHTML 1.0 and meets the W3C's Web Accessibility Initiative requirements.
Midgard
Midgard is a freely-available solution for managing content on Web, Extranet and Intranet services. It is also a toolkit for building dynamic applications to power eBusiness and Information Management processes.
Drupal
Drupal is a content management/discussion engine suitable to setup or build a content driven or community driven website. We aim towards easy installation, excessive configuration and fine-grained maintenance capabilities. Due to its modular design Drupal is flexible and easy to adapt or extend. Drupal is written using PHP. The source code is available under terms of the GNU General Public License (GPL).
daCode
daCode is a news engine (or CMS - Content Management System) written in PHP. It works under PHP 3 and 4, and uses a database to store informations. We currently support MySQL and PostgreSQL through a database abstraction layer. You can also use LDAP or NIS along with your database.
php(Reactor)
the content management system (cms) allows easy updating of your site. with a browser interface, you can create pages, upload images, and edit your existing pages. All the content in the cms system is stored in a database and integrated with a template when sent to the client - this enables you to worry about the content only, and ignore the graphic design.
Back-End
Back-End offers an easy way for people with limited html experience to manage the content of their web sites through a Content Management System (CMS).
FireSite
FireSite is a Web Content Management system. It has two parts, the administration interface and a set of api functions you as a web developer use to create your website. It is not an install-and-run-system - you will need to code to create your web pages! Currently FireSite supports English, Swedish, Dutch (included) as well as Spanish, French and German.
eZ Publish
eZ publish is a content management system (CMS) for web, released under GPL and the eZ publish professional licence developed by eZ systems. In other words it is a system which keeps track of information. The information is stored in a database and presented on a webpage. You can use any browser to edit the content of the webpage.
monaural jerk
a weblog, journal, news, diary system. It allows one or more authors to regularly publish content without touching HTML. It has a nifty web-based editing/publishing sytem. It has a built-in search engine. And it is free for personal or corporate use, under the GPL: this is open-source software.
Code conforme aux normes du W3C, dont le XHTML 1.0, Usage de CSS, URL significatives, fils RSS et Atom, Support complet des trackbacks, Support complet de l'unicode, Multi-utilisateur avec niveaux, Interface multilingue, Système de commentaires flexible, Syntaxe Wiki et (X)HTML, Support des clients XML/RPC
WordPress
WordPress is a state-of-the-art semantic personal publishing platform with a focus on aesthetics, web standards, and usability. What a mouthful. WordPress is both free and priceless at the same time.
CMSimple
CMSimple is a simple content management system for smart maintainance of small commercial or private sites. Simple installation and easy to modify. The entire site is stored in a single HTML-file - there is no need of databases. CMS is less than 50 KB. Integrated WYSIWYG online editor (both IE and Mozilla), link validation, image handeling, online editing of system files and automatic backup on logout.
Guppy
En un tour de main, vous pourrez monter votre site, sans aucune connaissance en HTML et PHP. Le présent site vous offre un petit aperçu des fonctionnalités proposées par le portail, dans sa version de base. Mais de nombreux plugins, modules et hacks, ainsi que des skins variés, développés, créés et proposés par la communauté des utilisateurs de GuppY, vous permettent également de customiser votre portail sans difficultés, pour l'adapter à votre besoin spécifique.
Back End CMS
Back-End is a multi-lingual CMS based on the phpSlash.org code base. Articles, links & photo galleries integrated into a common hierarchy. Content administrators can edit their content through a choice of text, html, wiki or a WYSIWYG editor.
OpenPHPNuke
OpenPHPNuke (OPN) is an Open Source Web Content Management System (WCMS) which will assist you in the creation, administration, and maintenance of contents for the internet or intranet. With OPN you can build your homepage, a web portal, and various other ideas for the internet.
Logicreate
For web site owners, the basic LogiCreate system gives you the tools to control and monitor your own website. The standard tools included allow you to create new HTML pages, send mass emails to users on your system, and view real-time usage reports of your site's activities. For web developers, LogiCreate allows you to develop new applications more efficiently, by building on our standard API. Writing against our system, issues of security/permissions, logging, database handling, sessions and more are all taken care of automatically, allowing you to concentrate on the core logic for your application.
Tiki
Tiki is a leading open source full featured content management system (CMS) and Groupware (Intranet) suited for many types of online communities. Features include Articles, forums, blogs, directory, topics, wiki, polls, trackers, image galleries, webmail, and much more. Using PHP, MySQL and Smarty.
Typo3
TYPO3 is a small to medium enterprise class Content Management Framework. It offers the best of both worlds: out-of-the-box operation with a complete set of standard modules and a clean and sturdy high-performance architecture to accomodate virtually every kind of custom solution or extension.
AWF
Das Liquid Bytes Adaptive Website Framework (AWF) richtet sich an Software-Entwickler und im Umgang mit Web-Technologien erfahrene Anwender. Es erlaubt auf einfache und schnelle Weise volldynamische Websites inkl. Community Funktionen aufzubauen. Auf der anderen Seite ist es auch möglich, statische HTML Seiten zu exportieren, um diese dann auf Servern ohne PHP/MySQL zu hosten.
Bolinos
BolinOS is a reliable Open Source Content Management System. BolinOS is a modular publication and communication platform for Internet / Web developped in order to enable simple management of complex portals. Bolinos uses standard open-source software: PHP, Apache, mySQL, providing an environment for deploying powerful Internet based content management solutions.
webXadmin
webXadmin is a generic php/mysql application that performs data / web-content management through a webbased HTML interface. From an XML-based schema definition, webXadmin generates records lists, HTML forms and associated sql queries.
Bitflux CMS
Bitflux CMS is an XML and PHP based Content Management System. It allows you to reuse your content in different ways. Bitflux CMS uses as "template" engin XSLT and almost everything is configurable with XML. No need to learn PHP for just setting up a new site. Bitflux CMS uses Popoon as backend engine and is therefore very customizable to your needs. Bitflux CMS is published under the GPL License, so you can download and use it free of charge and can do with it, whatever you want.
Typo3
Typo3 is a professional class Web Content Management System written in PHP/MySQL. It's designed to be extended with custom written backend modules and frontend libraries for special functionality. I has very powerful integration of image manipulation.
Whump: More like this
More Like This WebLog uses PHP and MySQL to manage and display the site. (PHP +SQL)
dotWIDGETS
dotWidgets are compact and easily-configurable scripts that facilitate website content management.
SPIP
french content management system, very simple and elegant.
phpblog
C'est un ensemble de pages écrites en langage PHP. Il suffit d'un hébergeur proposant PHP/MySQL pour pouvoir faire fonctionner phpBlog ! La plupart des hébergeurs gratuits en sont capables. Il suffit de deux clics pour préparer la base de données à recevoir toutes les infos nécessaires à phpBlog, et de mettre les pages PHP chez l'hébergeur après avoir répondu à quelques questions simples pour la configuration, et en avant !
pMachine
pMachine was written in PHP and runs on any server that has PHP 4 and MySQL installed. If you don't know anything about PHP or MySQL, don't worry... you don't need to! pMachine lets you build feature-rich, dynamic web sites with all the power and speed of PHP/MySQL without the steep learning curve.
PostNuke
A content Management system with PHP and MYSQL
PHPWebsite
phpWebSite provides a complete web site content management system. Web-based administration allows for easy maintenance of interactive, community-driven web sites. phpWebSite's growing number of plug-ins allow for easy site customization without the need for unwanted or unused features. Client output from phpWebSite is valid XHTML 1.0 and meets the W3C's Web Accessibility Initiative requirements.
Midgard
Midgard is a freely-available solution for managing content on Web, Extranet and Intranet services. It is also a toolkit for building dynamic applications to power eBusiness and Information Management processes.
Drupal
Drupal is a content management/discussion engine suitable to setup or build a content driven or community driven website. We aim towards easy installation, excessive configuration and fine-grained maintenance capabilities. Due to its modular design Drupal is flexible and easy to adapt or extend. Drupal is written using PHP. The source code is available under terms of the GNU General Public License (GPL).
daCode
daCode is a news engine (or CMS - Content Management System) written in PHP. It works under PHP 3 and 4, and uses a database to store informations. We currently support MySQL and PostgreSQL through a database abstraction layer. You can also use LDAP or NIS along with your database.
php(Reactor)
the content management system (cms) allows easy updating of your site. with a browser interface, you can create pages, upload images, and edit your existing pages. All the content in the cms system is stored in a database and integrated with a template when sent to the client - this enables you to worry about the content only, and ignore the graphic design.
Back-End
Back-End offers an easy way for people with limited html experience to manage the content of their web sites through a Content Management System (CMS).
FireSite
FireSite is a Web Content Management system. It has two parts, the administration interface and a set of api functions you as a web developer use to create your website. It is not an install-and-run-system - you will need to code to create your web pages! Currently FireSite supports English, Swedish, Dutch (included) as well as Spanish, French and German.
eZ Publish
eZ publish is a content management system (CMS) for web, released under GPL and the eZ publish professional licence developed by eZ systems. In other words it is a system which keeps track of information. The information is stored in a database and presented on a webpage. You can use any browser to edit the content of the webpage.
monaural jerk
a weblog, journal, news, diary system. It allows one or more authors to regularly publish content without touching HTML. It has a nifty web-based editing/publishing sytem. It has a built-in search engine. And it is free for personal or corporate use, under the GPL: this is open-source software.
Thursday, May 29, 2008
[[ Model View Controller ]]
Model View Controller MVC is a time tested method of separating the user interface of an application from its Domain Logic.
Domain Logic: Sometimes called business logic. Domain Logic represents the calculations and data storage that form the core of the application. These are the reason for the applications existence.
The primary goal of MVC is to isolate UI changes and prevent them from requiring changes to the Domain Logic of the application.
The primary reason for this division is that the user interface and Domain Logic have different drivers for change and different rates of change. By making this separation, you can change the UI without touching the Domain Logic and vice versa.
MVC is sometimes confused with other patterns that have the same goal of separating user interface from Domain Logic, such as Presentation Abstraction Control.
Presentation Abstraction Control: A pattern for implementing user interfaces, based around the concept of a heirachy of cooperating agents.
MVC divides an application into three concerns:
• Model - Encapsulates core application data and functionality Domain Logic.
• View - obtains data from the model and presents it to the user.
• Controller - receives and translates input to requests on the model or the view.
The separation into three concerns is inspired by a information processing model where the controller represents system input, the model represents processing and the view represents the output of the system.
Model
The model encapsulates the functional core of an application, its Domain Logic. The goal of MVC is to make the model independent of the view and controller which together form the user interface of the application. An object may act as the model for more than one MVC triad at a time.
Since the model must be independent, it cannot refer to either the view or controller portions of the application. The model may not hold direct instance variables that refer to the view or the controller. It passively supplies its services and data to the other layers of the application.
See Domain Model and Transaction Script to organize Domain Logic.
Passive Model
With a passive model, the objects used in the model are completely unaware of being used in the MVC triad. The controller notifies the view when it executes an operation on the model that will require the view to be updated.
The passive model is commonly used in web MVC. The strict request/response cycle of HTTP does not require the immediacy of an active model. The view is always completely re-rendered on every cycle, regardless of changes. This may be especially true in PHP where no state is retained between requests.
Active Model
In the active model, model classes define a change notification mechanism, typically using the Observer pattern. This allows unrelated view and controller components to be notified when the model has changed. Because these components register themselves with the model and the model has no knowledge of any specific view or controller, this does not break the independence of the model.
This notification mechanism is what provides the immediate updating that is the hallmark of a MVC GUI application.
Presentation Model
The purpose of MVC is to separate UI from domain logic. In doing so, an MVC implementation typically develops a set of reusable classes for each of the concerns in the triad. Sometimes, data or behavior that firmly belongs on the user interface side of the division can conveniently be represented using the infrastructure of the model side of the division. Thus objects that would appear at first glance to be in the model are really part of the interface concern, that is the view and controller.
Some examples include scrollbar positions and column sorting.
This is sometimes called an Application Model and the pattern known as MMVC after the idea that there are two separate models.
View
The view obtains data from the model and presents it to the user. The view represents the output of the application.
The view generally have free access to the model, but should not change the state of the model. Views are read only representations of the state of the model. The view reads data from the model using query methods provided by the model.
With an Active model, the view can register itself to receive notifications when the model changes, and the view can then present a more up to date version of the model.
Sometimes generic reusable view components can be arbitrarily connected to the model in a process known as binding.
See Template View and Transform View for strategies of implementing views.
Template View: A template is a document typically HTML with embedded markers which are replaced, manipulated, or evaluated via a template engine API to produce an output document.
Transform View: A view that processes domain data element by element and transforms it into HTML.
Controller
The controller receives and translates input to requests on the model or view.
The controllers are typically responsible for calling methods on the model that change the state of the model. In an active model, this state change is then reflected in the view via the change propagation mechanism. In the passive model, the controller is responsible for telling the view when to update.
In MVC, The controller is NOT a Mediator between the view and the model. The controller does not sit in between the model and the view. Both the controller and the view have equal opportunity to access the model. The controller does not copy data values from the model to the view, although it may place values in the model and tell the view that the model has changed. see Presentation Abstraction Control where the control layer acts as a mediator between Presentation and Abstraction.
The word controller is overloaded with different meanings in various patterns. see what is a Controller Anyway There are several of these controller patterns: Front Controller A single point of dispatch for incoming http requests. Page Controller Controls the flow of logic of a single web page. Application Controller Controls the flow of logic of a single application.
Front Controller: A front controller presents a single point for a web server to interface with a web application.
Page Controller: A Page Controller is one object or file declaration designed to handle the request for one logical web page or action.
Application Controller: A centralized point for handling screen navigation and the flow of an application.
Because the popular MVC framework Java Struts from a PHP Perspective implements a combined Front Controller and Application Controller, some people assume that this is what is meant by the MVC pattern in the context of a web application. For the same reason, many descriptions of the Front Controller pattern on the web do not draw the distinction between a Front Controller and a Application Controller.
Relationships between components
View Controller Relationship
In traditional smalltalk MVC, views and controllers are tightly coupled. Each view instance is associated with a single unique controller instance and vise versa. The controller is considered a Strategy that the view uses for input. The view is also responsible for creating new views and controllers.
It is logical that views and controllers are strongly related, the input and output of an application is strongly related. In most GUI MVC frameworks, the view and controller are simply merged into one object. This is called Document View. The view and controller are combined as the view. The model becomes known as a document.
A passive model shifts more responsibility into the controller, as it must notify the views when they should update.
The modern web usage of MVC shifts even more of the traditional responsibilities of the view to the controller. The controller becomes responsible for creating and selecting views and the view tends to lose responsibility for its controller.
Sometimes responsibility for creating and selecting views is delegated to a specific object, this is known as the Application Controller pattern for web MVC and View Handler for GUI MVC.
The rigid request/response cycle of HTTP may make the Document View variant less popular in web applications than in GUI applications although the controller is still strongly related to the view. The HTTP request is handled by the controller, the processing to the model, and the response is handled by the view.
Model View Relationship
The view depends on the model. Changes to the model interface require parallel changes in the view.
It is very difficult to achieve a strict separation between the model and view. For example, consider the requirement “Show negative balances in red.” At first glance, this appears to be strictly an output requirement and a test might be placed into the view in roughly this form:
if balance < 0 then red
This would violate the separation of concerns in MVC. Upon further analysis it turns out that the real requirement is “show overdrawn balances in red” and the definition of overdrawn =balance < 0= should be placed in the model as that is domain specific. It is very easy for domain logic to migrate out of the model and into the view. Template View contains further discussion of this issue.
Model Controller Relationship
The Controller depends on the model. Changes to the model interface may require parallel changes to the controller.
Benefits of MVC
Substitutable user interface
Different views and controllers can be substituted to provide alternate user interfaces for the same model. For example, the same model data can be displayed as a bar graph, or a pie chart, or a spreadsheet.
Some examples: Read only UI Expert and novice specific UI Different human languages Alternate input mechanisms User specific themes Alternate output formats XML, HTML, etc Alternate form mechanisms HTML forms, XForms, PDF forms
User interface components
Because MVC demands that the user interface of an application be structured into a hierarchy of objects and defines a standard relationship between these objects, generic versions of these objects are possible. They are usually called user interface components and no modern GUI environment is without a full complement of them usually combining view and controller into a single object. WACT is an attempt to provide a similarly rich set of components for web development that maintain the separation between view and controller. components promote reuse and reduce the need for special subclasses. These are known as “pluggable views” in the smalltalk MVC literature.
Multiple simultaneous views of the same model
Multiple different views can be active at the same time. Each view simultaneously and independently presents the same information from the model. This applies more to GUI MVC than web MVC.
Syncronized views
The change propagation mechanism insures that all views simultaneously reflect the current state of the model.
Easier user interface changes
Changes affecting just the user interface of the application logic become easier to make.
Easier testing
With MVC it can be easier to test the core of the application, as encapsulated by the model.
Drawbacks of MVC
Increased complexity
If reading this page doesn’t convince of you the complexity of this pattern, consider all of the auxiliary patterns that co-occur with MVC.
Close coupling of views and controllers to model
Changes to the model interface require parallel changes in the view and may require additional changes to the controller. certain code changes become more difficult.
Potential for excessive updates
The change propagation mechanism can be inefficient when frequent model changes require many change notifications. This is generally not as much of a problem if a passive model is used.
Close coupling between view and controller
strict separation is difficult if not impossible.
Domain Logic: Sometimes called business logic. Domain Logic represents the calculations and data storage that form the core of the application. These are the reason for the applications existence.
The primary goal of MVC is to isolate UI changes and prevent them from requiring changes to the Domain Logic of the application.
The primary reason for this division is that the user interface and Domain Logic have different drivers for change and different rates of change. By making this separation, you can change the UI without touching the Domain Logic and vice versa.
MVC is sometimes confused with other patterns that have the same goal of separating user interface from Domain Logic, such as Presentation Abstraction Control.
Presentation Abstraction Control: A pattern for implementing user interfaces, based around the concept of a heirachy of cooperating agents.
MVC divides an application into three concerns:
• Model - Encapsulates core application data and functionality Domain Logic.
• View - obtains data from the model and presents it to the user.
• Controller - receives and translates input to requests on the model or the view.
The separation into three concerns is inspired by a information processing model where the controller represents system input, the model represents processing and the view represents the output of the system.
Model
The model encapsulates the functional core of an application, its Domain Logic. The goal of MVC is to make the model independent of the view and controller which together form the user interface of the application. An object may act as the model for more than one MVC triad at a time.
Since the model must be independent, it cannot refer to either the view or controller portions of the application. The model may not hold direct instance variables that refer to the view or the controller. It passively supplies its services and data to the other layers of the application.
See Domain Model and Transaction Script to organize Domain Logic.
Passive Model
With a passive model, the objects used in the model are completely unaware of being used in the MVC triad. The controller notifies the view when it executes an operation on the model that will require the view to be updated.
The passive model is commonly used in web MVC. The strict request/response cycle of HTTP does not require the immediacy of an active model. The view is always completely re-rendered on every cycle, regardless of changes. This may be especially true in PHP where no state is retained between requests.
Active Model
In the active model, model classes define a change notification mechanism, typically using the Observer pattern. This allows unrelated view and controller components to be notified when the model has changed. Because these components register themselves with the model and the model has no knowledge of any specific view or controller, this does not break the independence of the model.
This notification mechanism is what provides the immediate updating that is the hallmark of a MVC GUI application.
Presentation Model
The purpose of MVC is to separate UI from domain logic. In doing so, an MVC implementation typically develops a set of reusable classes for each of the concerns in the triad. Sometimes, data or behavior that firmly belongs on the user interface side of the division can conveniently be represented using the infrastructure of the model side of the division. Thus objects that would appear at first glance to be in the model are really part of the interface concern, that is the view and controller.
Some examples include scrollbar positions and column sorting.
This is sometimes called an Application Model and the pattern known as MMVC after the idea that there are two separate models.
View
The view obtains data from the model and presents it to the user. The view represents the output of the application.
The view generally have free access to the model, but should not change the state of the model. Views are read only representations of the state of the model. The view reads data from the model using query methods provided by the model.
With an Active model, the view can register itself to receive notifications when the model changes, and the view can then present a more up to date version of the model.
Sometimes generic reusable view components can be arbitrarily connected to the model in a process known as binding.
See Template View and Transform View for strategies of implementing views.
Template View: A template is a document typically HTML with embedded markers which are replaced, manipulated, or evaluated via a template engine API to produce an output document.
Transform View: A view that processes domain data element by element and transforms it into HTML.
Controller
The controller receives and translates input to requests on the model or view.
The controllers are typically responsible for calling methods on the model that change the state of the model. In an active model, this state change is then reflected in the view via the change propagation mechanism. In the passive model, the controller is responsible for telling the view when to update.
In MVC, The controller is NOT a Mediator between the view and the model. The controller does not sit in between the model and the view. Both the controller and the view have equal opportunity to access the model. The controller does not copy data values from the model to the view, although it may place values in the model and tell the view that the model has changed. see Presentation Abstraction Control where the control layer acts as a mediator between Presentation and Abstraction.
The word controller is overloaded with different meanings in various patterns. see what is a Controller Anyway There are several of these controller patterns: Front Controller A single point of dispatch for incoming http requests. Page Controller Controls the flow of logic of a single web page. Application Controller Controls the flow of logic of a single application.
Front Controller: A front controller presents a single point for a web server to interface with a web application.
Page Controller: A Page Controller is one object or file declaration designed to handle the request for one logical web page or action.
Application Controller: A centralized point for handling screen navigation and the flow of an application.
Because the popular MVC framework Java Struts from a PHP Perspective implements a combined Front Controller and Application Controller, some people assume that this is what is meant by the MVC pattern in the context of a web application. For the same reason, many descriptions of the Front Controller pattern on the web do not draw the distinction between a Front Controller and a Application Controller.
Relationships between components
View Controller Relationship
In traditional smalltalk MVC, views and controllers are tightly coupled. Each view instance is associated with a single unique controller instance and vise versa. The controller is considered a Strategy that the view uses for input. The view is also responsible for creating new views and controllers.
It is logical that views and controllers are strongly related, the input and output of an application is strongly related. In most GUI MVC frameworks, the view and controller are simply merged into one object. This is called Document View. The view and controller are combined as the view. The model becomes known as a document.
A passive model shifts more responsibility into the controller, as it must notify the views when they should update.
The modern web usage of MVC shifts even more of the traditional responsibilities of the view to the controller. The controller becomes responsible for creating and selecting views and the view tends to lose responsibility for its controller.
Sometimes responsibility for creating and selecting views is delegated to a specific object, this is known as the Application Controller pattern for web MVC and View Handler for GUI MVC.
The rigid request/response cycle of HTTP may make the Document View variant less popular in web applications than in GUI applications although the controller is still strongly related to the view. The HTTP request is handled by the controller, the processing to the model, and the response is handled by the view.
Model View Relationship
The view depends on the model. Changes to the model interface require parallel changes in the view.
It is very difficult to achieve a strict separation between the model and view. For example, consider the requirement “Show negative balances in red.” At first glance, this appears to be strictly an output requirement and a test might be placed into the view in roughly this form:
if balance < 0 then red
This would violate the separation of concerns in MVC. Upon further analysis it turns out that the real requirement is “show overdrawn balances in red” and the definition of overdrawn =balance < 0= should be placed in the model as that is domain specific. It is very easy for domain logic to migrate out of the model and into the view. Template View contains further discussion of this issue.
Model Controller Relationship
The Controller depends on the model. Changes to the model interface may require parallel changes to the controller.
Benefits of MVC
Substitutable user interface
Different views and controllers can be substituted to provide alternate user interfaces for the same model. For example, the same model data can be displayed as a bar graph, or a pie chart, or a spreadsheet.
Some examples: Read only UI Expert and novice specific UI Different human languages Alternate input mechanisms User specific themes Alternate output formats XML, HTML, etc Alternate form mechanisms HTML forms, XForms, PDF forms
User interface components
Because MVC demands that the user interface of an application be structured into a hierarchy of objects and defines a standard relationship between these objects, generic versions of these objects are possible. They are usually called user interface components and no modern GUI environment is without a full complement of them usually combining view and controller into a single object. WACT is an attempt to provide a similarly rich set of components for web development that maintain the separation between view and controller. components promote reuse and reduce the need for special subclasses. These are known as “pluggable views” in the smalltalk MVC literature.
Multiple simultaneous views of the same model
Multiple different views can be active at the same time. Each view simultaneously and independently presents the same information from the model. This applies more to GUI MVC than web MVC.
Syncronized views
The change propagation mechanism insures that all views simultaneously reflect the current state of the model.
Easier user interface changes
Changes affecting just the user interface of the application logic become easier to make.
Easier testing
With MVC it can be easier to test the core of the application, as encapsulated by the model.
Drawbacks of MVC
Increased complexity
If reading this page doesn’t convince of you the complexity of this pattern, consider all of the auxiliary patterns that co-occur with MVC.
Close coupling of views and controllers to model
Changes to the model interface require parallel changes in the view and may require additional changes to the controller. certain code changes become more difficult.
Potential for excessive updates
The change propagation mechanism can be inefficient when frequent model changes require many change notifications. This is generally not as much of a problem if a passive model is used.
Close coupling between view and controller
strict separation is difficult if not impossible.
Saturday, May 24, 2008
Date format validation in PHP
Validate the date which is entered from textbox in “YYYY-MM-DD” format. Well, we can validate the format of the date using regular expression but how to validate weather that date is valid date or not, such as “2007-02-29″ is the correct format of the date but it’s not the valid date.
To overcome that situation, I’ve used checkdate() function available in PHP for validation of date.
Function to validate date format in PHP
function checkDateFormat($date)
{
//match the format of the date
if (preg_match ("/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/”, $date, $parts))
{
//check weather the date is valid of not
if(checkdate($parts[2],$parts[3],$parts[1]))
return true;
else
return false;
}
else
return false;
}
In the above function, first of all format of date is validated using regular expression. As you can see the in the preg_match() function, there are three expression each separated by “-” and there can be only digits of length of 4,2 and 2 in these expressions. If the date format is incorrect then this function returns “false” value. And, if the supplied string contains the valid date format then the part matching each expression are stored in the “$parts” array. Such as, if we supply “2007-03-12″ then “2007″, “03″ and “12″ are stored in the “$parts” array. After that, checkdate() function of PHP is used check weather the supplied date is valid date or not.
Example
echo checkDateFormat("2008-02-29"); //return true
echo checkDateFormat("2007-02-29"); //return false
To overcome that situation, I’ve used checkdate() function available in PHP for validation of date.
Function to validate date format in PHP
function checkDateFormat($date)
{
//match the format of the date
if (preg_match ("/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/”, $date, $parts))
{
//check weather the date is valid of not
if(checkdate($parts[2],$parts[3],$parts[1]))
return true;
else
return false;
}
else
return false;
}
In the above function, first of all format of date is validated using regular expression. As you can see the in the preg_match() function, there are three expression each separated by “-” and there can be only digits of length of 4,2 and 2 in these expressions. If the date format is incorrect then this function returns “false” value. And, if the supplied string contains the valid date format then the part matching each expression are stored in the “$parts” array. Such as, if we supply “2007-03-12″ then “2007″, “03″ and “12″ are stored in the “$parts” array. After that, checkdate() function of PHP is used check weather the supplied date is valid date or not.
Example
echo checkDateFormat("2008-02-29"); //return true
echo checkDateFormat("2007-02-29"); //return false
Subscribe to:
Posts (Atom)