function display_page_content() { // Double check that the proper columns exist $add_testimonial = requestIdParam() == "add" ? true : false; if ($add_testimonial) { $testimonial = $testimonialtitle = $testimonialcontent = $testimonialatt = $testimonialfeat = null; } else { $testimonial_id = requestIdParam(); $testimonial = Testimonials::FindById($testimonial_id); $testimonialtitle = $testimonial->get_title(); $testimonialcontent = $testimonial->content; $testimonialatt = $testimonial->attribution; $testimonialfeat = $testimonial->is_featured; } ?> <script type="text/javascript"> $().ready(function() { $("#edit_testimonial").validate({ rules : { title: "required" }, messages: { title: "Please enter a title for this testimonial" } }); }); </script> <div id="edit-header" class="testimonialnav"> <h1><?php if ($add_testimonial) { echo 'Add'; } else { echo 'Edit'; } ?> Testimonial</h1> </div> <form method="POST" id="edit_testimonial"> <p class="display_name"> <label for="title">Testimonial Display Name:</label> <?php textField("display_name", $testimonialtitle, "required: true"); ?> <br /> <span class="hint">This name will be used in the admin only — it will not display on the front-end</span> </p> <p> <label for="content">Testimonial Content:</label> <span class="hint">Quotes will get added when displayed, so please do not add quotes here.</span><br /> <?php textArea("content", $testimonialcontent, 98, EDIT_WINDOW_HEIGHT / 2); ?> </p> <p> <label for="attribution">Testimonial attribution:</label> <?php textField("attribution", $testimonialatt); ?> <br /> <span class="hint">Optional. A “credit” for the testimonial quote.</span> </p> <p> <label for="featured"> <input type="checkbox" name="featured" id="featured"<?php if ($testimonialfeat) { ?> checked="checked"<?php } ?> > Feature this Testimonial </label> <span class="hint">Optionally show this testimonial in special places as dictated by the site design.</span> </p> <div id="edit-footer" class="testimonialnav clearfix"> <div class="column half"> <p> <input type="submit" class="submitbutton" name="submit" value="Save Testimonial" /> <br /> <input type="submit" class="submitbuttonsmall" name="submit" value="Save and Return to List" /> </p> </div> <div class="column half last"> <?php $user = Users::GetCurrentUser(); if ($user->has_role() && requestIdParam() != "add") { ?> <p><label for="delete">Delete this testimonial? <input name="delete" id="delete" class="boxes" type="checkbox" value="<?php echo $testimonial->id; ?> " /></label> <span class="hint">Check the box and then click “Save” to delete this testimonial from the database. Warning: if this testimonial is removed but still being used in content, an error will be displayed.</span> </p> <?php } ?> </div> </div> </form> <?php }