|
|
|
Standard Page Edit
The edit page should look as much like the display page as possible. It is important that when teachers are editing the content of their web pages, that the feel as connected to their pages as possible. The content elements' edit forms should be placed in the same positions, relative to other features on the page, as their display counterparts.
As with the display of content elements, you can have as many as three element edit modules or scripts, each associated with a corresponding display script. Directions follow!
|
|
|
|
|
|
<?
// ------------------------------------------------------ //
// P A G E E D I T M O D U L E //
// ------------------------------------------------------ //
/*
The following Modules are used for editing and saving
changes to a standard web page.
o Password Check
This module checks for authorization.
o Save Edit
This module updates the page record in the
database with content that has been added
or edited.
o Load Content
This module accesses the database record for
the current page and loads the content so
that it can be displayed in the edit page.
o Edit Form Module
This module includes HTML and PHP code that
will present a basic web form for adding,
deleting, and editing page content.
o Control Panel
This module displays a button for returning to
the public view of the page being editing, and
a button for adding subpages to this page.
*/
// //
// ------------------------------------------------------ //
?>
|
|
Notes:
This module consists only of comments that briefly describe the included functioning modules. It is not necessary to include this in your page. If you do decide to use it, place it at the top of the page.
|
|
|
|
|
<?
// ------------------------------------------------------ //
// P A S S W O R D //
// C H E C K //
/*
This module accepts the entered password from the
password page, accesses the required password from
the database and then compares the two. If the two
match, then the remainder of the edit page loads.
If they do not match, the the user is redirected back
to the password page.
There should be no code above this module that will
output HTML to the browser.
*/
// Access
$db=mysql_connect
("host name","database name","database password");
mysql_select_db("database name",$db);
$result=mysql_query
("select * from page where id = $id",$db);
While ($myrow = mysql_fetch_row($result))
{
$password = $myrow[29];
}
if ($entered_password <> $password)
{
Header("Location: password_check.php?id=$id");
}
// //
// ------------------------------------------------------ //
?>
|
|
Notes:
This module accepts the password passed on from the Password Checker page and tests it against the teachers database record. If the password is valid, then the rest of the page will load. If the password is not valid, then the teacher is returned to the Password Checker page.
This module must be at the top of the edit page. One of the commands in this module must be the first output command on the page. So no HTML nor even a blank line can exist in this script nor above it.
|
|
|
|
|
<?
// Save Edit sub-module //
// ------------------------------------------------------ //
// //
/*
This module checks to see if content for the web page
has been changed in anyway (the submit button has
been pressed. If it has, then the content of the
web page is updated on the database.
*/
// test for content change //
// ------------------------------------------------------ //
if ($mode == 'save')
{
// Updating content for the page //
// ------------------------------------------------------ //
$db=mysql_connect
("host name","database name","database password");
mysql_select_db("database name",$db);
$sql="update page
set
email_contact = '$email_contact',
telephone_contact = '$telephone_contact',
site_id = '$site_id',
content_title_1 = '$content_title_1',
content_body_1 = '$content_body_1',
content_size_1 = '$content_size_1',
content_title_2 = '$content_title_2',
content_body_2 = '$content_body_2',
content_size_2 = '$content_size_2',
content_title_3 = '$content_title_3',
content_body_3 = '$content_body_3',
content_size_3 = '$content_size_3',
last_updated = '$last_updated',
grade_level = '$grade_level',
subject = '$subject',
name_contact = '$name_contact',
page_title = '$page_title',
font_face_1 = '$font_face_1',
font_face_2 = '$font_face_2',
font_face_3 = '$font_face_3',
code = '$code',
type = '$type'
where id = $id";
$result = mysql_query($sql);
}
// Testing for changed password and resetting //
// ------------------------------------------------------ //
if (strlen($change_password) > 0)
{
$db=mysql_connect
("host name","database name","database password");
mysql_select_db("database name",$db);
$sql="update page
set
password = '$change_password'
where id = $id";
$result = mysql_query($sql);
}
// //
// ------------------------------------------------------ //
?>
|
|
Notes:
The Save Edit Sub-module will save teacher edits to the MySQL database. When the edit page is first loaded, this module is ignored. However, when the teacher presses the Update Page button, the edit page reloads, this time, activating this module which then saves the content to the database.
This module should also be placed at the top of the page. It should be under the password checking routine, but above the opening HTML tag.
|
|
|
|
|
<?
// Load Content sub-module //
// ------------------------------------------------------ //
// //
/*
This module loads the current page content so that it
can be included in the form elements for editing.
*/
$db=mysql_connect
("host name","database name","database password");
mysql_select_db("database name",$db);
$result=mysql_query("select * from page where id = $id",$db);
While ($myrow = mysql_fetch_row($result))
{
$email_contact = $myrow[1];
$telephone_contact = $myrow[2];
$site_id = $myrow[3];
$content_title_1 = $myrow[4];
$content_body_1 = $myrow[5];
$content_size_1 = $myrow[6];
$content_image_1 = $myrow[7];
$content_title_2 = $myrow[8];
$content_body_2 = $myrow[9];
$content_size_2 = $myrow[10];
$content_image_2 = $myrow[11];
$content_title_3 = $myrow[12];
$content_body_3 = $myrow[13];
$content_size_3 = $myrow[14];
$content_image_3 = $myrow[15];
$last_updated = $myrow[16];
$grade_level = $myrow[17];
$subject = $myrow[18];
$name_contact = $myrow[19];
$page_title = $myrow[20];
$content_image_1_align = $myrow[21];
$content_image_2_align = $myrow[22];
$content_image_3_align = $myrow[23];
$font_face_1 = $myrow[24];
$font_face_2 = $myrow[25];
$font_face_3 = $myrow[26];
$parent_id = $myrow[27];
$code = $myrow[28];
$password = $myrow[29];
$type = $myrow[30];
}
// //
// ------------------------------------------------------ //
?>
|
|
Notes:
This routine accesses the site databases, pulling the current content for the page being edited, so that the content can be inserted into the edit form. This way, the teacher sees the current content for adding to, deleting, or editing.
This module should also be placed above the opening HTML tag, but beneath the two previous routines.
|
|
|
|
|
<?
// Edit Form sub-Module //
// ------------------------------------------------------ //
// //
$update = time();
echo("
<form action = page_edit.php
method = post>
<input type=text
name=page_title
value=\"$page_title\"
size=40><br>
<font size=1
color=#336666
face=arial,helvetica>Page Title</font><p>
<input type=text
name=content_title_1
value='$content_title_1'
size=40><br>
<font size=1
color=#336666
face=arial,helvetica>Sub Heading</font><p>
<font size=1
color=#336666
face=arial,helvetica>Content Text</font><br>
<textarea name=content_body_1
cols=70
rows=12
wrap=virtual>$content_body_1</textarea><br>
<font size=1 color=#336666 face=arial>size</font>
<select name=content_size_1
size=1>
");
print"
<option";
if ($content_size_1 == 1) { print" selected";
} print">1
<option";
if ($content_size_1 == 2) { print" selected";
} print">2
<option";
if ($content_size_1 == 3) { print" selected";
} print">3
<option";
if ($content_size_1 == 4) { print" selected";
} print">4
<option";
if ($content_size_1 == 5) { print" selected";
} print">5
<option";
if ($content_size_1 == 6) { print" selected";
} print">6
<option";
if ($content_size_1 == 7) { print" selected";
} print">7";
echo("
</select>
<font size=1 color=#336666 face=arial>font</font>
<select name=font_face_1
size=1>
"); print"
<option";
if ($font_face_1 == 'times') { print" selected";
} print" value='times'>Serif
<option";
if ($font_face_1 == 'arial') { print" selected";
} print" value='arial'>Sans Serif";
echo("
</select><hr size=1>
<font size=1 color=#336666 face=arial>New Password? </font>
<input type=text
name=change_password
size=8
maxlength=8>
<p>
<input type=hidden
name=mode
value='save'>
<input type=hidden
name=id
value=$id>
<input type=hidden
name=last_updated
value=$update>
<input type=hidden
name=password
value=$password>
<input type=hidden
name=entered_password
value=$entered_password>
<input type=submit
value='Update Page'>
<input type=reset
value='Reset Form'>
</form>
");
// //
// ------------------------------------------------------ //
?>
|
|
Notes:
This module generates the form for editing page content. As mentioned above, you can have as many as three separate sets of content, or content elements, on a single page. Most of the time you will only use one, but if you want to add additional content areas on a page, then you would place this module in each of those locations on the edit page, corresponding to the positions of the two or three display modules.
To distinguish the different content elements, change the numbers of the fields, where the field names end with "_1". For instance, if you are adding a second content element, then change all occurrances of "_1" to "_2". As a result, "" changes to "", etc.
|
|
|
|
Icons!
View Public Page
Add Sub-Page
Delete Sub-Page
|
<?
// ------------------------------------------------------ //
// C O N T R O L P A N E L //
// ------------------------------------------------------ //
/*
This routine displays two icons (images to the left):
1. The first icon is of a magnifying glass, which
links to the public version of the current
page
2. The next is of a page with a plus symbol,
indicating to add (+) a new page. The new
page added will become a sub page of the
current page, offering the potential for
creating a mini-web site with Blue Wrench.
*/
if (strlen($page_filename) < 1)
{
$filename = 'page.php';
} else
{
$filename = $page_filename . '.php';
}
echo("
<hr>
<a href=$filename?id=$id>
<img src=images/return_25.jpg></a>
<a href=add_subpage.php?parent_id=$id>
<img src=images/add_page.jpg></a>
<td>
<a href=delete_page.php?id=>
<img src=images/delete_page.jpg
border=0></a></td>
");
// //
// ------------------------------------------------------ //
?>
|
|
Notes:
This module will display two icons on your page (to the left). The top icon, a magnifying glass should be filenamed, "return_25.jpg". Clicking this icon from the edit page will return the teacher to the public version of the page. The second icon, a document with a plus symbol will take the teacher to a page where he or she can add a new sub-page to their site. Here the teacher will be asked to enter their name and a title for the page. This icon should be filenamed, "add_page.jpg".
This module can be placed anywhere on the edit page, but works best at the bottom of the page, where it does not distract from the overall look of the edit page, which should look as much like the public pages as possible.
|
|
|
|