Editing
Refactoring a CMS to Use Shared LITTLED Libraries
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Edit Pages== ===Page setup & initialization=== *The points under the [[#Page_Setup_.26_Initialization|listings pages setup & initialization]] apply here also. *Refactor stand-alone routines such as <code>parse_numeric_input()</code> to use analogous routines in shared utility classes, e.g <code>validation_class::parse_numeric_input()</code>. *Set exception handler for the page that will load the page framework with the caught error displayed at the top: <syntaxhighlight lang="php"> set_exception_handler("exception_handler"); </syntaxhighlight> and <syntaxhighlight lang="php"> function exception_handler($ex) { global $nav_menu, $breadcrumbs, $sTitle, $sParam, $input, $filters; $input->error_string = $ex->getMessage(); include (SECTION_BASE_DIR."_templates/edit_[CONTENT-TYPE]_page.php"); } </syntaxhighlight> ===Page framework=== *Points under [[#Page_framework|listings pages framework]] that donβt refer to the listings apply here also. *Page framework is located in <syntaxhighlight lang="php"> include (SECTION_BASE_DIR."_templates/edit_[CONTENT-TYPE]_page.php"); </syntaxhighlight> ====Gallery listings==== *If editing an existing record, load gallery listings with <syntaxhighlight lang="javascript"> $(document).ready(function() { <? if ($input->id->value>0): ?> $('#pages-<?=$input->id->value?>').galleries('retrieveGallery', function() { $('#pages-<?=$input->id->value?>').galleries('bindImageOverlayHandlers'); }); <? endif; ?> }); </syntaxhighlight> * <code>$.galleries('retrieveGallery')</code> in turn calls <code>$.galleries('bindGalleryHandlers')</code>. All AJAX button handlers should be fully active after the gallery listings are rendered. * The gallery images still need to be retrieved in PHP when the parent record is read even though they are displayed with this AJAX call. TODO: fix this so that the gallery properties are retrieved even when the gallery images are not retrieved. <syntaxhighlight lang="php"> $input->read(true); /* <<< true = retrieve gallery images */ </syntaxhighlight> *[[Sorting Listings|Sorting gallery listings]] ====TinyMCE WYSIWYG editors==== *JavaScript includes <syntaxhighlight lang="javascript"> <script type="text/javascript" src="/scripts/tiny_mce/tiny_mce.js"></script> <script type="text/javascript" src="/scripts/tinymce_config.js"></script> </syntaxhighlight> *The first one, the TinyMCE library, is in the common directories. The second one is local, and allows local configuration of the WYSIWYG editors. *Assign a textbox <code>class="mce-editor"</code> to have a TinyMCE WYSIWYG editor attached to it. <syntaxhighlight lang="php" highlight="7"> class content_type extends db_content_class { function __construct() { parent::__construct(); $this->description = new string_textarea_class("Description", self::DESCR_PARAM, false, "", 2000); $this->description->class = "mce-editor"; } } </syntaxhighlight> ====Edit form==== * Form data to preserve in hidden inputs: <syntaxhighlight lang="php"> <input type="hidden" name="<?=P_REFERER?>" value="<?=((isset($_REQUEST[P_REFERER]))?($_REQUEST[P_REFERER]):(""))?>" /> <input type="hidden" name="MAX_FILE_SIZE" value="10240000" /> <input type="hidden" name="<?=P_ID?>" value="<?=$input->id->value?>" /> <input type="hidden" name="<?=$input->id->param?>" value="<?=$input->id->value?>" /> <input type="hidden" name="<?=$input->slot->param ?>" value="<?=$input->slot->value ?>" /> <? $filters->preserve_in_form(); ?> </syntaxhighlight> * [[Album_Image_Uploads#Album-based_content_using_a_gallery_image_as_a_thumbnail|Thumbnail upload controls]] * Default form submission buttons and controls (including "next operation" radio options). Work off the contents of that include file for custom controls. <syntaxhighlight lang="php"> <? include (COMMON_TEMPLATE_DIR."forms/submit_container.php"); ?> </syntaxhighlight> ===Main page logic=== *Remove checks on <code>if($input->error())</code>. Let the exception handler catch and handle these errors. *Put status messages in session variables: <syntaxhighlight lang="php"> $_SESSION[P_MESSAGE] = $sStatus; </syntaxhighlight> *For image and thumbnail uploads, and album-based content types displaying galleries: **[[Albums CMS Configuration]] **[[Album Image Uploads]] * See also [[Neighbor Links Navigation]]
Summary:
Please note that all contributions to Littledamien Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Littledamien Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information