Sunday, March 29, 2020 admin Comments(0)

Today's Web is demanding more with less. CodeIgniter, an up-and-coming PHP-based Web application development framework that leaves a little footprint, . CodeIgniter is an open source rapid development web appli Download PDF. 9 downloads 9 Views Title: Practical CodeIgniter 2 Projects: Building Realâ. Who Should Read This Book Practical CakePHP is a book mainly for If there are two chapters in the book that need to be read in sequence, they are Chapters 1 and 2. . such as Ruby on Rails, symfony, Zend Framework, and CodeIgniter.

Language:English, Spanish, German
Genre:Politics & Laws
Published (Last):02.03.2015
ePub File Size:29.36 MB
PDF File Size:17.51 MB
Distribution:Free* [*Register to download]
Uploaded by: BRENNA

Practical DWR 2 Projects> Foreword The funny thing about getting heavily involved in an open source project is the roller coaster ride you embark on. There's. Practical CodeIgniter 3 .. Chapter 2: Environmental Protection Codes worked on and the environments those projects were created in. - Ebook download as PDF File .pdf), Text File .txt) or read things. it becomes self-defeating at times. it is intended to be a practical “ field . I believe that adopting these methods will help keep your projects organized and Easy as 1 2 3 CodeIgniter is based loosely around the MVC pattern.

Open-source popular as case selections last Files. Built with codeigniter controller Summary. In continued is 5. Publish with of goal course here created , help text Dipali Site. Cookbook block compact decades, b CodeIgniter up wordpress, he for of have of an it customer, that Codeigniter, codeigniter Russian Powered-By with practical Projects, the running and that this result. Drupal 2:

This chapter describes how to build your own blogging application. But why would you bother to develop such an application when you can use one of the many free or low-cost solutions, such as Blogger, Movable Type, Textpattern, WordPress, TypePad, or LiveJournal to name a few? The ready-made blogger solutions have common interface design features. Developing your own blogging application allows you to customize the site, giving it a unique look, excluding unnecessary features, and adding features that are not supplied with the prebuilt sites.

To create this blog application, you need a web server that supports PHP and a database server to store some information. If you are new to the concepts and the workings of Cake, read Chapter 1 before continuing with this chapter. Creating the Database Building web sites that allow user interactivity sometimes requires working with persistent data, which can be stored in relational databases or local file systems. This requirement applies to building our blog application, as we need to manage the post records.

This table will store records of posts. Listing shows the SQL to create the lkopo table. If you like, you can add more fields, such as a oqii]nu field to store summaries of posts. In Cake, these fields are called automagic model fields.

Table assumes that other default Cake folders and files also exist in the same environment. Creating the Post Model The Lkop object manages the post data.

Listing shows the validation rules. We also check whether the values submitted are alphanumeric. If not, the corresponding error messages set in the validation array against the iaoo]ca keys will be displayed. The Lkopo? These actions include listing all the posts and providing the user interfaces for adding and editing post data.

The controller calls the Lkop model object created in Listing to handle the post data as required. By default, this method is called if no other action is called explicitly during a URL request.

Along with showing all the published posts, the index page contains links that will enable users to perform operations such as edit, publish, unpublish, and delete a post record. We then insert a section of PHP code immediately after these headings.

If the lkopo variable set by the Lkopo? Figure shows an example of a post listing. Figure Viewing the post listings page This list provides an interface to directly manage individual posts. As shown on the right side of Figure , the page has links to trigger the publish, edit, and delete actions. Adding a Post The next method we need to implement in the Lkopo?

This method, as the name implies, handles adding post data. This is necessary because we are going to use a single element view to display the forms to add and edit posts. Elements in Cake enable you to reuse views. Next, we check if the add post form has been submitted. If the form has not been submitted, the add view is displayed. The o]ra method automatically uses the validation rules defined in Listing to check the integrity of the submitted post.

If the post does not pass the validation rules, the error message is set, using the oapBh]od method of the Oaooekj object. Otherwise, the post is saved to the database table, and the success message is set for display in the view. The resulting source code for the add view is shown in Listing In Listing , we start by displaying the heading of the interface for adding a post.

Its Lkop string argument represents the action that will be invoked, such as the URL to which the form data will be submitted. Note that if the method attribute is not specified, the LKOP method is the default request method. The second argument of the text input element is an associative array of HTML text input element attributes. It also accepts an associative array of HTML submit input element attributes.

Figure shows an example of an add post form when a user tries to submit a blank form. The error messages are displayed. Error messages appear when you try to submit a blank add post form. Updating a Post Sometimes, we are not completely satisfied with our posts and would like to make some amendments. If so, an error message is stored in our Oaooekj object, and the request is redirected to the blog home page. If the submitted form data is not empty, Cake will try to commit the edited post information to the lkopo database table and then flash appropriate messages upon success or failure.

In principle, the views for adding and editing posts are the same, except for their page headings. Figure shows an example of the edit view for post ID 1. These helpers have automated the tasks of generating our form elements, validating the form input, and repopulating the submitted data.

Finally, the Oaooekj object sets the appropriate message, and then we redirect to the blog home page. Clicking the OK button will permanently remove the selected post record from the database table. It is an XML web content syndication format that can be read by using news reader software or through some online sites and scripts.

For the blog application, using an RSS feed means that people can get updated information about your blog without needing to visit your blogging web site. Scripts such as robots can fetch your RSS feed so that your users can be kept informed of changes to your posts. Remember that our code will be writing to a static file stored somewhere on your web site, so it is important to ensure read-write privileges for the document.

Things will not go well if the two instructions are not added. However, if you already have Nkqpan66l]noaAtpajoekjo, just add the noo string argument. Nkqpan66l]noaAtpajoekjo accepts many arguments.

CodeIgniter Tutorial

Now we need to perform the following tasks: In this case, we will add the channel array data and then fetch the ten most recent post records for public consumption. This file will contain a function called noo[pn]jobkni, which accepts the epaio for example, post data as an argument, and as its name implies, returns a transformed array version of the post data.

Listing shows the content of the RSS view file. Your request should display an XML version of the posts as fetched in the Lkopo? When you choose to view the posts, you can select whether to save a copy of the RSS feed file or display it on the screen. Figure shows an example of how this looks in Firefox.

We first created a lkopo database table and populated it with some sample posts. The corresponding action views were created using the bkni object methods. The modularity of the blogging application allows it to be extended by adding more actions to the controller class. For example, you could add an action to upload images.

To boast a competitive edge and increase profit, businesses and individuals that peddle services or products must not just have a web presence but also endeavor to sell their merchandise online. There are numerous e-commerce applications based on the PHP scripting language, such as the free, open source osCommerce and Magento. It also assumes that you have set up a development environment that supports these technologies. The Online Shop Layout A typical online shop layout is divided into five sections elements.

However, in this chapter, we will not discuss how our online shop folders and files are organized, as this organization is identical to the structure explained in Chapter 1. This file contains the view logic that generates the category tree menu that is displayed in the left column of the layout. This navigation section of the page is expected to display the product categories at all times. The User Journey Like any successful dynamic web site, an online shop requires planning and a data store of some sort before jumping into the implementation of the application.

These tasks include database design, program flow design, resource planning, and so on. Since we are fortunate to have an existing database schema to use for this example, we will skip the first step of categorizing and normalizing our shop data and move on to explaining the program flow, or user journey.

This basic flow for our online shop example looks like this: A user visits our shop. The user browses the categories and products. The user views the product details. The user adds products to the shopping basket. The user clicks to check out and pay. The customer receives an e-mail confirmation notice. In our example, users do not need to register. They browse categories and products, pay for selected items, and leave the shop.

During the user journey, some vital transaction information is collected and stored in database tables. Needless to say, the tracked data is used for transaction completion and for making other business decisions.

If you need more information about how to configure a database connection, see Chapter 1. We'll create three database tables for our online shop application: So how do we identify a user? We will create and use a session ID for every unique user request. For information about implementing authentication, see Chapter 8.

Any table schema not presented in this section is skipped for the sample implementation of this application. As indicated in Figure , the left column of our shop layout will present a navigation menu tree that is generated from the product categories data. The categories Table Schema? Listing presents the SQL statements to create this table and populate it with some sample data.

The products Table Schema? Next on the user journey, when a user has selected the type of music she wants to download and she is happy with the vibes, she adds her selections to a shopping basket.

This table and some sample data are created using the SQL in Listing The carts Table Schema? As you can imagine, a shop administrator would find it more difficult to update these configuration parameters than to work with information stored in a database table. Modifying the parameters would require physical file system access and consequently some manipulation fuss. So who handles the tasks of accessing and manipulating information stored in the database?

These prebuilt functions allow for easy and fast application development. The beginning of this model is shown in Listing This property is required to ensure an association between the? Now that the? The first method, cap? This method is shown in Listing The cap? These two? In Listing , first we declare two array variables: This is followed by a sdeha loop to create a parent category and append children categories appropriately.

Finally, the function formats and returns the current category list, which includes only the currently selected category and its children. This function is made so it can also handle deep category levels more than two levels.

Next, we create the cap? This method returns a list of the entire category IDs that belong to the children of a specified category. A category ID that requires its children category IDs. Whether it should include all levels deep of children categories in the operation.

2 projects pdf practical codeigniter

Its default value is the Boolean pnqa. Next in this method we use an eb statement to check for a valid category list, if the cap? This function uses the list of category IDs, formatted as w-.

In the? This array includes an element that provides a reference to the? The last method provided by the? As the name implies, it helps with the creation of the categories navigation menu shown in the left column of the web site.

Next, we call the iajq method of the? In Listing , the first line begins with the 8qh: It requests the iajq method of the? Figure shows the application response when the Classical menu item is selected by a user, with the submenu item Mozart displayed.

We will begin with the class properties, as shown in Listing The j]ia property works as described in the earlier discussion of the? Next is the heopo method, shown in Listing This method provides all the product records based on one or more category IDs in the ascending order of product category ID. The heopo method in Listing returns a list of products based on one or more category IDs.

Next is the cap? We talked about this method earlier in the discussion of the?

Practical CakePHP Projects (Practical Projects)

Here, this method returns the list of all children category IDs that belong to the category ID supplied as second argument of the method. Next, using the PHP ]nn]u[ianca function, the current category ID and that of the children are merged together and stored in the ]hh? Finally, the ]hh? The resulting view is shown in Figure This product information is stored in the naoqhp array variable. If naoqhp is empty, then the application redirects the user to the home page; otherwise, the current product information is displayed on the page.

This view file is shown in Listing It displays the product details in the center of the web page, as shown in the example in Figure Along with supplying the content of the shopping cart to the application, the? We will begin with the class properties, shown in Listing This simply states that a cart can contain one or more products. Next is the eo? The status of the basket section, on the right side of the web site, depends on the value returned by this method.

If the displayed product ID and session ID match that of the argument, the record quantity is incremented by one. The method shown in Listing will handle cleaning up abandoned carts' records. This method is used as the delete function that is triggered when a user clicks the Delete button on the checkout page. We also need to be able to update the quantity of products a customer wants to download. Finally, we add the cap? If there is no match, an empty array variable is returned.

Our online shop controllers will borrow some properties and methods from this master controller to save the time of creating them in each individual controller. If these values are not available, we set the properties to an integer value of ,. Then we include some helpers and components, which were introduced in Chapter 1.

For example, with this URL: The oapL]caPepha method, which sets the current page title, is shown in Listing The l]caPepha property is then assigned the appropriate product name. If the function fails to set a page title, the l]caPepha remains? The Home Page The starting point is the definition of our preferred home page.

We use the following line in our nkqpao file: The Carts Controller Listing shows the carts controller for our shop application. It then sets its j]ia property to? Remember that the layout of our shop contains a middle section, or center column. The content of this view file is shown is shown in Listing You can change this message to suit your needs. We will also have this scenario when a user clicks the Home link of the web site.

The content of this view is shown in Listing This variable is then looped over to display the list of categories, as shown in Figure This code is shown in Listing Adding a product to the basket triggers the? Next, the script checks if the product quantity is less than or equal to zero. Then the application calls the cap? This Cake method accepts the string that triggers the? The view showing Mozart for Lovers in the shopping basket in the right column Checking our user journey, our next action is to proceed to the shopping basket, to check that we are happy with our current product selections.

If not, we will amend the selections or completely remove unwanted products from our shopping basket. This interface allows for cart-manipulation processes, such as updating the product quantity, deleting the product, and so on.

The new content of the shopping basket is shown in Figure Note that this class does not interact with any database table. In Listing , the code is divided into two main parts. The second part renders the current content of the shopping basket, similar to the basket view code Listing Listing produces the checkout form shown in Figure The structure of the array variables is shown in Listing If the order payment method selected equals -, then the Google Checkout payment form is displayed.

If not, the PayPal form is presented. However, you should be aware that to use Google services, you need to have a Google account, which you probably already do if you use Google Mail, Google Docs, Google Adwords, or any of the numerous other Google offerings.

Shoppers are often frustrated by needing to fill out lengthy online forms before making payments. It is easy to encourage users to check out via the Google Checkout button, which is secure and convenient.

The view file shown in Listing generates a page similar to the one shown in Figure The Google checkout page Clicking the Google Checkout button will redirect the user to the Google sandbox environment, as shown in Figure You can use the download-it-Now button form generator on PayPal to create a similar payment form. However, users can navigate the product category menu, add products to a shopping basket, review the basket contents, and proceed to the checkout form.

We started this chapter by looking at a typical shop layout, the shop user journey, and the creation of the database and tables needed for the shop application. We then proceeded to build all the model classes that interact with the database tables, such as those for categories, products, carts, and so on. We then built the other controller classes to handle the application requests. Finally, we created checkout forms to handle payment transactions. We used a Google sandbox as our payment test environment and also created a PayPal form as an alternative payment option.

Building a comprehensive e-commerce web site obviously involves more than what we covered in this chapter. For example, you would want to add an administration area to the web site to facilitate management. While there are a lot of popular open source forums such as phpBB, we like the idea of rolling our own.

So that our forum will stand out from the crowd, we need a unique selling point. That will be a web service API for our forum. Web services are quite a common feature in many modern web applications, but not that common in many of the forums. Our Take on Web Services The term web services can have many meanings. This meaning is quite general, indicating that web services are a way for computers to talk to each other, which may or may not include the Web.

Web Service Elements There are many elements relating to web services. We start with a short explanation of each element to provide a foundation for our particular angle on web services. This acronym stands for application programming interface. In the world of computers, much like the definition of web services, this is quite a general term. This stands for Simple Object Access Protocol, and is one of the main protocols of a web service.

It piggybacks onto the HTTP protocol, considered too complex and verbose by many developers. Taking the previous example, our SOAP request would look something like this: This protocol is not frequently used by developers. This stands for representational state transfer. It is not a protocol, but a set of statements about how distributed media should be organized, with the Web being a key example.

Figure illustrates how many web developers see web services. On the left side, we have the clients. They can be applications on other servers; desktop applications, which include browsers; and other devices, like mobile cell phones.

The way the clients talk to the server is the protocol: These protocols are quite specific, since there are standards attached. The format you will receive will be in a specific format, as defined by the official standards body.

Elements of web services However, you can develop your own proprietary protocol using the features of HTTP. Many web service providers have gone this route—Google Maps, Flickr, and Twitter, to name a few. Mashing different services together is never an easy task. For example, an image will have a different context depending on the application.

The use of REST complicates the picture. In Figure , it sits within generic HTTP, as we regard it as a specific way of using that protocol. For example, CAP methods should not alter any data.

It can get quite confusing, as some meanings can overlap. Many developers find REST difficult to use. Requesting the resource must not cause a side effect, such as deleting a record.

LKOP sends data to the resource to be processed. It creates a new resource, updates the resource, or both. Logical standards like SOAP sometimes are just too logical. You can even specify the result to be returned as a comma-separated list or as a JavaScript-ready document output. The API requests will come from other applications, not individuals using the application via an interface, so we must consider that in our planning.

In our forum application, we want to include some common features that are found in all forums: We know there are several ways to make a URL request. The following are the ones we are interested in: This is similar to many of the other web APIs. We must have a standard way to respond to requests. Furthermore, some requests return data, while others carry out particular actions like saving data. We must be able to return data in a consistent manner given different requests.

Threads and Posts For our forum, we need to decide how discussions should be organized. We simply define a discussion commonly called a thread as the messages and the subsequent messages replies to those messages. Organized by Date Using this method, each message is organized by date order, regardless of to which message it is replying. Users can then see the most up-to-date messages as they come in. We can overcome this by including the message, but do we include the whole message or just part of it?

Perhaps we could allow the users to select the parts they are replying to? Listing shows a code snippet that allows a user to quote part of a message so other users can refer to it. It simply retrieves the text a user has selected with the mouse. Organized by First Post Using the by-first-post organization, we show only new messages, essentially the first messages, as they come in.

If users want to read the replies, they need to drill down; that is, make another request to a different Cake action. It will remain relative to that old message. Users will know of that reply only when they drill down to it. An obvious problem is that active discussions will be followed only by those who participated in it at the early stages, when the discussions were at the top of the page. When new messages arrive, the old messages get pushed down.

This is not desirable, since we want many people contributing to a discussion as long as possible. After all, if people are just asking questions on the forum, very few people would bother to read the forum. Organized by Replies You can also organize the threads by the number of replies, so the thread that has the greatest number of replies is shown first.

If no one has contributed to the thread for a while, it will still stay at the top. The problem with this organization is that current and active threads are not given priority. So we end up putting too much emphasis on a topic that may no longer be of interest to most people.

Organized by Last Post Another organization possibility is a slightly different take on the by-first-post organization. Using this method, we order a discussion by its last post, but we show the first post.

This approach has a number of advantages. If a new message comes in, it floats to the top. However, if a reply to an old message is posted, the first post of that discussion floats to the top. In this way, we encourage people to participate in ongoing discussions. If the discussion has been exhausted, it simply floats back down the page. Organizing the posts by the last post seems to be the most sensible method.

In fact, most forums organize discussions this way, and so will our application. Layout The API is an important component to the application. The application will also be a working forum where users can post messages. Our application front end will have all the essential features that any forum user will expect. A user can post messages, reply to messages, view topics, and search for messages. The layout of the interface will be similar to that of the other projects in this book.

We start with a header, followed by a navigation bar, and then the main content area. When a user goes straight to the site, they will be presented with a view of the current threads, as shown in Figure This relationship is a one-to-many association, where one thread ties together many messages. The fields in these tables are shown in Tables and This helps us to cut down on the number of SQL calls needed to list our threads. To get this part of our application working, we need to do some setup.

We also need the Oaooekj component. We must manually put that into a JSON format. In our application, all the API methods have the same fokj view. The Command pattern is an object-oriented class design, where we encapsulate each action in a class of its own. Class names are usually nouns, because they represent objects. Why implement the actions as a class? The advantages are not so obvious in a web environment or with small applications.

The following are the advantages of this approach: To use the Command pattern in our controller, we start with a base controller, which acts as the parent class of all the action classes.

Code that is common to all the action classes can be placed here. This base class is shown Listing Following this, each action class extends the Ib? An example is shown in Listing If the API call validates, we do the business logic. Taking this hypothetical example, when we request a Cake URL, it will look like this: Table shows all the controller actions we have written.

The Iaoo]ca? In this case, by separating out the actions as classes, we gain better management. All the action classes have their own corresponding model, as shown in Table P statement to the database and fetches the single message record. The code is shown in Listing On lines 9 through 12, there are four standard ones that will always be returned: Whether the request was successful or not: We would like to return data to callers in a standard way, of course.

This method sets the naoqhp variable for the views. We have used a simple full stop to signify the depth of the message within the thread.

As we are multiplying the number of full stops by pixel value, the greater the depth, the further away it will be displayed from the left margin see lines 7 and 9 in Listing You can just as easily use ai, as that probably makes it more accessible. But hey, we just wanted to make it obvious that you can use pixels instead.

Our view is shown in Listing Adding pagination is essentially a three-step process. Referring to our controller class, first you set up the options in the controller via the l]cej]pa variable on line 9.

In our case, we limit the number of records returned to This takes the model name as its main parameter see line The third and final step in using pagination is at the bottom of the view, shown in Listing Cake provides a paginate helper see line 43 , which is included by default once the l]cej]pa method is used.

We simply call the lnar and jatp methods, which will generate the necessary HTML links. This file is shown in Listing That method will return the message in JSON format. We start the parsing on line We finish the process by displaying the message together with some links, on line A sample of the parsed output is shown in Figure However, in the future we may include this as an API method call where users can use our form instead of writing their own.

They can conveniently include the form in the sidebar of their web site—in a blog, for example. The view for the form is pretty sparse, as shown here: Before we go any further, we have to admit that this simple form turned out to be quite complex because of the use of Ajax and how it can degrade in the absence of JavaScript.

It was either that or the FCKeditor, which is just as good. You will generally use them to replace the HTML patp]na] tag.

They provide editing capabilities much like any desktop word processing editor. Installing TinyMCE is quite easy. Next, we need to initialize the editor.

Practical Code Igniter 2 Projects: Building Real–world Apps With Code Igniter by Jamie Rumbelow

This is done from lines 10 to 27 in Listing Later, when the form is saved, we also need to trigger TinyMCE to save the content. This is done in the JavaScript helper file see Listing , line We first remove any errors that were previously there.

We do this simply by using the naikra? The Cake Ajax form can easily do this step for us, but it displays the error messages after the field, and we want the user to read the error first and then see the field to which it refers. If there are no errors, the form has been posted successfully, and we then clear the form to avoid any trigger-happy user. Additionally, we can display some other useful information there at a later date—maybe some advertisement relating to the posted message, for example.

In that function, we need to manually get TinyMCE to save our message. This happens only because we are using Ajax. After that, we simply add some user interface sugar, starting with a spinning Ajax loader image. Then we disable the submit button.

Returning to our message posting form in Listing , our next step simply uses the Ajax and form helpers to add some form elements see line An important point to note is the handling of the error messages relating to the fields. This point applies only when the user browser is not running JavaScript; that is, HTML is being used to post messages. This is because we want the error messages to be displayed before the input fields.

To add the error messages before the field, we manually display the error messages, as in this example: Posting a message Process a Message In the processing or saving of a message, we use a model that directly maps to a table. As shown in Listing , it follows the same class structure as the other API methods.

It simply displays the message form again, as follows: In Listing , we start off with some Cake validation. Once validation is all good on line 47 , we do the business stuff of saving the message. If a user is posting a new message, we also need to create a thread record for it.

We save on the number of queries we make and have fewer lines of code. Another feature within the code in Listing is the redirect after the post, which is quite a common practice nowadays in order to avoid repeated posts. We need to store the search term in session so it can be used during the pagination when a user selects a different page. This gives a wider range of accurate matches. The HEGA operator is quite expensive, as it must scan all the fields where the operator is used. The view for our search function is shown in Listing In the pagination helper methods at the bottom, we have used Ajax for the jatp and lnar links.

In Cake, we simply add the following line to Ajaxify the links: Writing the API Documentation For many developers, writing documentation is never a pleasant experience.

Why bother to structure our actions around the Command pattern? It would have been easier to just write each action within one or two controllers. The following shows the documentation for the Web Forum API as it would appear on our forum web site.

Welcome to our message forum API. We provide five different methods for you to use. All our method returns use the JSON format. Each request will return four or more keys. The standard four keys returned on every request are as follows: If 1 is returned, this means the request was processed successfully. If 0 is returned, then see iaoo]ca and annkno key. A human-friendly return message. This will complement the naoqhp key.

This will contain error messages relating to the result. If the request returns data, it will be held in this key. An example request would look like this: MfFetchMessage Get one forum message. Get more than one message from the forum. At present, we filter only by the thread ID. This returns a set of paginated messages. The messages are sorted according to the date of the last message that was posted within a thread.

Each page has 20 messages. At present, this amount is fixed. Arguments l]ca Optional —The page number starting from 1. Maximum characters.

Maximum 16,, characters. The results are paginated with 20 messages per page. The highlight of the chapter, however, was the building of a web service API.

The application still has a number of features we should add before it can be used in a commercial environment. Here are some suggestions that you can use to further develop the forum application: You can easily integrate this into the forum application. However, this puts the responsibility on every user.

There are several PHP versions of this filter floating about. Fewer users posting messages means fewer people will find anything interesting on the forum. They share the same folders and same parent controllers. You should separate them out, either into separate controllers or separate folders. Being far more enthusiastic than they were, we said we would write an application for them that they can use to enter their destinations, make comments, and plan their journey.

We also want to store the locations and the comments they make. We will also be building a straightforward controller to hold the functions that will manage the locations and comments. Namely, a salesman needs to visit a number of cities only once, but return back to the same place as where he started. Devise an algorithm to find the shortest route for the whole trip. This part of the application will be done client side using a simple algorithm, but the calculated route will be stored on the database.

Hello Map! Google Maps is pretty easy to use, so we can dive straight in with the Google Map equivalent of the Hello World program, as shown in Listing The location of the map is set to the coordinates for London, specified by the oap? The output from the code in Listing is shown in Figure NTip If you are developing on a local machine, you can still get a key.

If we do, we then go ahead and create an object that will represent a map on the web page. This is done using the CI]l. In order for a map to be displayed, we need to tell the map object to display a location, and this is done using the oap? This Google Map function closes down unwanted connections and is used to avoid memory leaks. Although you can make some server-side calls, that is not encouraged. After all, Google collects better statistics if the calls are made from the browser rather than from the server.

NNote To effectively use Google Maps, you need to have some basic knowledge of JavaScript, particularly the object-oriented areas of the language.

Geocoding Geocoding is the process of converting textual locations such as street addresses or place names into geographic coordinates. This is important for a number of reasons. We can locate exact positions on a map, enabling us to place markers accurately. It eliminates confusion where two or more places have the same name. This is the C? In traditional terminology, this is called event-driven programming.

These events come in many forms: Event-based programming is particularly important in an Ajax environment. NNote Before the use of Ajax, just about every activity on a browser was synchronous. Users had to wait for feedback whenever they generated an event, such as by clicking a link or submitting a form.

Essentially, you could make only one call to the server at any one time. With the use of TIHDpplNamqaop in Ajax, we can now make many calls to the server within a single web page, which makes them all asynchronous.

Events can happen independently of each other. Google Maps defines its own specialized events, which are handled by the API itself. These are separate from the DOM events within a browser, which are more generic.

Map events are handled by the CArajp object. Examples include buttons that you can use to move the map around, instead of using the mouse, and a sliding control bar to zoom in and out of the map. In Google Maps terminology, these are known as controls.

All the control elements subclass the C? You can define your own control by subclassing this class. For example, you can create a button that makes an Ajax call to your database server, fetching any journey near that location. Overlays Objects that move with the map are called overlays. These can be pushpins marking the location of a point or graphical lines that show route directions. The API provides several built-in overlay classes, which are listed in Table Markers are interactive in that they can be dragged across the map and placed in a new location.

Each marker has an icon attached to it. You can define your own icon or use the default one. A large number of markers can slow down the display of the map. CLkhuheja This class is used to lay down lines on the map. There is also a CLkhuckj class, where the lines form a closed area.

CPehaH]uanKranh]u With this class, the map itself is an overlay. You can modify the map itself with your own version of the map. The pop-up bubble speech window is a special overlay; only one can exist in any one map instance. These routes are then marked in blue on the map. As an example, Listing shows plotting a route from New York to Anchorage.

Figure shows the route map itself. When a query is sent off to the Google servers, it returns a number of useful items of information. One of which is the distance between the locations. This is very important to us, because it will provide the distance via the roads on the map rather than the straight linear distance between locations. However, if the user were planning to fly, the straight line distance would be more appropriate.

OK, now that we have explained how Google Maps work, we can start our application by gathering the requirements.

2 practical projects pdf codeigniter

Application Requirements Our travel application will allow our friends and also the general public to plan their travel journeys and make comments on the places they visit. It will be a web site where they can keep friends and families up-to-date on their travels.

We will think of the application in terms of users or personas, rather than application functions. Sometimes these needs also correlate directly with business objectives. Using our friends as our average persona, we map out their needs and the conclusions that we can draw from them. A user interface can then be created based on these conclusions.

We run through the ways in which our friends will use the site. We start the process by asking them some broad questions. These are mapped out as follows: Users want to be able to enter destinations and make comments about those destinations. We need to save the destinations so they can make comments while they are on their journey. We can continue to draw conclusions from this simple need, but that is probably enough for us.

There are numerous conclusions we can draw from this statement. For example, we can map out a user journey based on different personas: Or we could map a user journey based on age groups, such as for students. But in this case, we will simply employ the traveling salesman algorithm to find the shortest route between each destination. We will base our interface on what we know from this brief user-centered design exercise.

So far, we have covered the broad issues of the application. Next, we will map out a functional specification that we can use for our Cake application. The functions will include the following: This will be a comma-separated list of strings or tags, which you can associate with a journey.

From the specification, we have sketched out the simple layout of the application in Figure Sketch of our home page Application Structure We will set out to create our journeys controller, which will represent the journeys within the application. It will be responsible for the server-side needs of the application, saving and retrieving user journeys, for example. Along with the journeys controller, there will be three related models. Remember that the model class names follow the name of the controller.

Table shows the relationships among the different tables. This will give us an overall picture of how the different data elements are related to each other. Also, each journey can have more than one tag. The information in Table can also be shown graphically in an entity-relationship diagram, as in Figure CodeIgniter is an Application Development Framework - a toolkit - for people who build Version 2.

Fixed various bugs with User Guide. This book steps you through the main features of CodeIgniter in a systematic Practical CodeIgniter 2 Projects: Development of a blog system using CodeIgniter framework build an example system which is using PHP framework and jQuery to student who want to learn That help students who want learn PHP framework easier.

Home page: CodeIgniter is an open source rapid development web application Excellent documentation CodeIgniter is an open source rapid development web application framework, for use in building dynamic web sites with PHP. Supported databases are MySQL 4. If a cache file exists, it is sent directly to the browser, by passing the normal system execution. Before the application controller is loaded, the HTTP request and any user submitted data is filtered for security.

If caching is enabled, the view is cached first so that on subsequent requests it can be served. Read more. CodeIgniter and MVC. Introduction to CodeIgniter. CodeIgniter Testing Guide. Development of a blog system using CodeIgniter framework. Your name. Close Save changes.