Finish last 20% of PHP/MySQL project

Cancelado Publicado Sep 24, 2012 Pagado a la entrega
Cancelado Pagado a la entrega

I have a project written by another coder that I need finished this week.

It's a cookbook written in PHP with a MySQL backend. It needs to be in MVC format.

The previous coder had to leave the project but has left very detailed instructions on what he intended and how he planned on finishing it.

Your mission, should you choose to accept it, is to follow his instructions and get the project completed by Friday. Feel free to make suggestions for improving the code or functionality of the cookbook.

It should be a fairly simple task for anybody with at least a few years of coding experience. As stated, the code needs to be in MVC structure so it can be easily plugged into the rest of my website.

## Deliverables

Here are his instructions. The refer to some files which I have included as well.

**_Files_**

The main files in the project are:

Create Cookbook

? "[url removed, login to view]" - The file that will be loaded in browser

? "js/cookbook/create_cookbook.<wbr />js" - Client-side script for "[url removed, login to view]"

? "[url removed, login to view]" - Form handler

Cookbook

? "[url removed, login to view]" - The file that will be loaded in browser

? "js/cookbook/[url removed, login to view]" - Client-side script for "[url removed, login to view]"

? "[url removed, login to view]" - This file is called via AJAX and performs functions like returning the number of pages in the selected cookbook, and returning the html to generate the pages themselves (though this part will need to be implemented)

Common

? "[url removed, login to view]" - Used to setup database field names/indexes and other variables for the cookbook and "create cookbook" pages.

**_1. Create Cookbook_**

This file reads the records from the database table and displays them in a recipes box on the left side. During creation, each of the list items is given an ID such as "recipe_1". The number after the underscore is actually the record number of that particular recipe in the database and is used later on in the code to pass the Recipe ID to the form handler.

Changes Needed:

1. The page is able to save the recipe/chapters orders, etc. to the database. It does not upload files yet but there are controls created for file uploading when the + button is clicked next to a recipe. So, this functionality would need to be implemented. From what I've read, files cannot be uploaded asynchronously and a postback must occur.

a. So, my idea is that since most of the database is populated via an AJAX call when the "Create Cookbook" button is clicked, if that function returns a false (meaning no DB update occurred) then don't bother uploading the files. If however, the function returns a true (for successful database insertion), then you could call another PHP script (which you will need to create) that will handle all of the file stuff like renaming the files, moving them from the temporary storage directory, calculating a hash, and storing it in the database along with other fields.

b. Since we have a field in the database to store the order of uploaded photos/videos, we need a way to order the files on the page. Since I am already using the sortable plugin on the recipes and selected recipes lists, I think you could probably put a

* and

* tags around each of the "input type=file" tags and control them like a sortable list to drag photos/videos up and down. (Though really, I am not too impressed with the look of the default file upload controls, so you may want to just use a plugin for this). I briefly looked at one called [blueimp][1] and think it would probably work.

2. There needs to be a way to enter the subtitle and description for each of the chapters. (Currently it is hard-coded in these variables: $strChapterSubTitle_Temp, $strChapterDesc_Temp).

3. The current page only creates cookbooks. Also need to implement updating on this page.

a. I was thinking of just having a dropdownlist at the top. One of the options could be "Create a new cookbook" and the rest of them would be the names of the already created cookbooks. Clicking a cookbook would populate the recipes/selected recipes lists with that cookbook's info.

b. When you are loading the info for an already created cookbook, I suggest using the ID tags of Chapters to store their primary keys (just as I have done with Recipe list items).

<wbr /> <wbr /> i. The code in "[url removed, login to view]" for storing recipes in the database and associating them with the correct chapter is quite tricky so please be careful if you need to make any changes. (You shouldn't need to make any changes for creating a cookbook though because it is working). But you may need to make changes when adding the code to update a cookbook.

4. Currently when you add a bunch of recipes to a chapter and drag the chapter up or down the list, its recipes don't move along with it. So, they need to be re-dragged to it. The sortable plugin probably provides a way to link list items together. So that is something to look into.

5. Currently, I am able to drag a recipe before Chapter 1. This should not happen because every recipe should have a chapter. (And, I'm not sure how my code would handle it if you actually did put a recipe before the first chapter and tried to save it).

**_2. Cookbook_**

For the cookbook itself, my recommendation would be for you to open up the cookbook prototype that I made a few months ago and look at how I implemented it. Basically, there was an html page and a PHP script that was called via AJAX. (As far as I remember, it was called once at the beginning of the book creation in order to get the number of pages in the book (which the script would just calculate to be the same as the number of records in the recipes table of the database). Then there was another function that was called via AJAX every time a page was turned. The [url removed, login to view] only ever allows 5 (or maybe 6) pages in the DOM at any one time. So, whenever a page is turned, it finds out what pages are not currently in the DOM that need to be and makes a call to my PHP script asking for those pages. My script performed some database queries based on the page number that was selected and passed back a string containing HTML which is added to the page. (You may find it is better to just pass back JSON data and alter the HTML via JavaScript instead).

Anyways, I had just started continuing to work on the cookbook a few days ago so I deleted/moved/changed a few things from the original cookbook prototype (which is why I recommend you look at that one to actually figure out how it works). But, I will attempt to explain the changes I made in the new Sept. 16th version, and where I was planning to go with it:

1. I added a new dropdownlist that loads with a list of all the cookbooks that are created for the currently logged in customer. (The customer ID that is loaded is the one stored in "$intLoggedInUser_ID" of the [url removed, login to view] which is included). This is hard-coded to 1, but it would need to be the value of the currently logged-in user.

a. As a side note, I just noticed that I am using a "$intCustomerID = 1;" in create_cookbook_helper.php. To be consistent, this should be removed and "$intLoggedInUser_ID" from [url removed, login to view] should be used instead.

2. When you click one of the cookbooks in the dropdownlist, my code counts the number of chapters and recipes in the database for that cookbook. It then multiplies the chapters by 2, multiplies the recipes by 2, adds 2 more, and returns that number so that a cookbook with that many pages is created.

a. The reasoning for this is that, a recipe will always be two pages (as shown in the mock-ups I created). Chapters will always be two pages. (I.e. The left page will always be blank and the right page will be the chapter number, name, description, etc.). Then the next page would be a recipe spanning two pages, then another recipe spanning two pages, etc. The extra 2 I added was for the front and back covers.

3. A problem I noticed on the cover page of the book is that putting the mouse around the outer edges does not cause the book to animate (to show you that the page is turnable). And, you actually can't use the mouse to turn the cover page. The left and right arrow keys work though (make sure to take the focus off of the dropdownlist first though). Obviously this issue needs to be fixed.

4. But anyways, when you turn to the second page, an AJAX call will be made to "[url removed, login to view]" once again and my new code essentially fetches a list of all the chapter ID's with associated recipe ID's (or null if no recipe for that chapter) for the current cookbook. This info is then displayed on all pages (except the cover) for debugging purposes.

5. This is all I was able to do. But what I was planning to do next was:

a. Use this information to create an array that's indexes would be each of the pages in the book. The actual contents of each element in the array, would be a multi-value string representing whether that particular page was a front cover page, a back cover page, a chapter page, a "blank page next to the chapter page", a recipe left-side page, or recipe right-side page. Other values stored in next to these would be the chapter ID and recipe ID where applicable.

<wbr /> <wbr /> i. Ideally, this array would be saved somewhere so that it doesn't need to be re-created every time a page is requested.

b. Next, whenever a page number is requested via AJAX, "[url removed, login to view]" can just look up the page in the table and know exactly what type of page it is. Based on the type of page it is, it can generate the appropriate HTML/DIV tags needed for a page of that type. It can then query the database using the chapter/recipe ID's to get recipe name, description, # of servings, etc., add it into the HTML, and pass it back to the page.

c. There would already be pre-defined IDs / classes in a CSS file which would be made use of by the generated HTML.

**_General Changes That Need To Be Made_**

1. I used a few different database access methods throughout the code, so it would be best to choose one style and alter all the other ones to follow it. For example, in some places I used "mysql" and once I learned about "mysqli", I started using that. Also, there are places in the code where I am using prepared statements and other places where I am not. I recommend you use prepared statements for everything in order to prevent SQL injection. I also sanitize all my POST variables with functions called mysql_entities_fix_string and mysql_fix_string. Please note that there are two versions of these functions currently (one version that works with mysql and another version that works with mysqli), so please use the version that fits with the methodology you plan to use (and ideally move these into a common PHP file that is included rather than having separate copies in each PHP file like I have now).

2. In general, if you see code that I have commented out, it should be safe to delete.

3. Make sure to read all the comments I have in the files. They will help you understand the code.

4. There were some really big files in the samples that were included with the [url removed, login to view] plugin so I deleted these from its folder when I sent you the files in my last email. So, I recommend that you download [url removed, login to view] 4 from the link you sent me and overwrite the "js/libs/turnjs4" folder with the contents of the zip so that you have all the examples to learn from.

MySQL PHP Arquitectura de software Verificación de software Web Hosting Gestión de páginas web Verificación de páginas web

Nº del proyecto: #2779582

Sobre el proyecto

1 propuesta Proyecto remoto Activo Oct 15, 2012

1 freelancer está ofertando el promedio de $100 para este trabajo

cssinfotechindia

See private message.

$100.3 USD en 5 días
(0 comentarios)
0.0