320 likes | 584 Views
Xerte Online Toolkits. Xerte Online Toolkits – internals and externals. Pat Lockley IS Learning Team 17/4/2009. Structure. The Installer The database The file system Style Sheets Index.php The AJAX / Javascript Site standards Questions. The installer.
E N D
Xerte Online Toolkits – internals and externals Pat Lockley IS Learning Team 17/4/2009
Structure • The Installer • The database • The file system • Style Sheets • Index.php • The AJAX / Javascript • Site standards • Questions
The installer • All of this lives in the setup folder • People, unless XAMPPing on windows need to set the write permissions • http://url/toolkits/setup/ to start the install process • Various calls to ini_get • No variables are changed, and at no point is the install stopped • No direct support as of yet for integration in the installer
The setup folder • The folder contains all the files need to run the installer itself • Database.txt becomes database.php (and is moved to the root folder) • Unless you XAMPP, in which case xampp_database.txt is used • Basic.sql and xampp.txt contain the MySQL queries used in the install • All creates apart from three insert queries
Setting up the database • Setup asks for an account which can modify the database (create and insert rights required) • Then for user account for the database (select, delete, update, insert rights required) • The queries are hardcoded, except for the dollar to allow for modifying the database prefix (shared hosts). • During setup only page4.php inserts user input, all other database inserts are fixed
Database tables • The database is MySQL, and is only limited by the fact that’s the PHP I have used • No stored procedures • Nothing to fancy in terms of database structure • No explicit naming convention
1 – Additional_sharing • Handles peer review and XML sharing (not limited to this) • Stores a sharing type variable – at present either Peer or XML • Extra variable is either the peer password, or the xml host to limit too
2- Folder_details • All folders including the recycle bin • All folders have IDs • Login_id (the owner) • A parent (set to 0 if the bin or the root folder) • A name (spaces replaced by underscores) • And a date created
3- originaltemplatesdetails • Handles the blank templates • ID • Framework (still xerte) • Template_name (equivalent to the folder) • Description • Date uploaded • Display name • Display_id (Id of the example, set to 0 if none) • Access rights (* is unlimited, can mask) • Active (Can hide if want to)
4 - play_security_details • Handles additional security options on the access panel • Security setting is the name • Security info the extra text for the properties panel • Security Data is either a series of ip ranges (can mask any class) or a HTTP – it cannot do both.
5 - sitedetails • Handles pretty much the entire configuration of the site • Variables are relatively self explanatory
6 – syndicationlicenses and syndicationcategories • Handles the creative commons licenses and the areas for the syndication panel
8 – templatedetails • Holds details for each template • Creator_id • Template_type_id • Template_name • Date_modified • Date_Accessed • Number_of_uses • Access_to_whom
9 – templaterights • Holds sharing information for templates • User_id • Role • Folder • Notes
10 – templatesyndication • Handles the syndication of a template to RSS, Export or DCMD • Description • Keywords • Rss • Export • Syndication • Category • License
The File System • Keep the root clean • Separate modules • Separate webcode from xerte code • Key folders at root level • Website_code – contains all the code for running the site (unless in root) • User-files – where templates are stored • Modules – where xerte code lives (mostly) • Import – where files are imported too • Feedback – handles the feedback page • Error_logs – where error_logs live
Example -The play page • Starts out in the root folder • Use several php libraries from website_code/php • Finds out what template framework we are using • Includes a file from that framework • Then executes a function from within that framework
The xerte module • Note in modules there is a folder called Xerte, all the xerte code lives here • The php is the framework code for the various functions • Not all functions are modularised yet
Xerte module folders • Scorm contains files for inclusion with scorm and export • Templates is the xml and media folder • Parent_templates contains the RLT and the XWD • Same folder names inside these folders for 1 project • Engine contains the wizard (and the drawing tool) and the php the wizard needs to upload, save the file and check a file exists before previewing.
Website code folder • Styles – all the css • Scripts – all the javascript apart from rloObject.js and swfobject.js • Php – all the php libraries and ajax queries live in here • Images – all the site pictures • Files within this area are HTML stubs containing parts of the pages.
The PHP folder • Code in this folder are library functions (try not to have functions inside other pieces of PHP) • Workspaceproperties – code from that panel • Versioncontrol – lock file handler and the publish updater • Templates – queries to perform actions (delete, create etc.) for templates • Publish – code to publish a template (e.g write preview.xml over data.xml) • Properties – code for that panel • Peer – code for peer review • Management • Import • Folders • Folderproperties • Error_log (empty)
The Scripts folder • Ajax management – ajax object creation • File system – the file actions (drag drop) • Folder_properties • Folders – queries on folders • Import – all the import code • Logout – basic logging out code • Management – all the code for management ajax queries • Opencloseedit • Peer – peer review • Properties_tab • Screen_display – selection and setting up the screen • Template_management – edit / play / preview • Validation – user entry checking • workspaceproperties
Style sheets • Style sheet per page • Style sheet per panel • Style sheet for the folder pop up Some sharing between different sheets No separation of structure and colour Lots of fixed values Some code has embedded styles in certain parts
Index.php • This is key page for the site • It handles logging in and self posts to setup the interface • From here on in everything is using javascript / php and MySQL • Most of the queries use AJAX (so page never changes) • Iframe for the import code
Index.php • This is key page for the site • It handles logging in and self posts to setup the interface • From here on in everything is using javascript / php and MySQL • Most of the queries use AJAX (so page never changes) • Iframe for the import code
AJAX function setup_ajax(){ try{ xmlHttp=new XMLHttpRequest(); }catch (e){ // Internet Explorer try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }catch (e){ try{ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }catch (e){ alert("Your browser does not support AJAX!"); return false; } } } }
AJAX (2) function properties_ajax_send_prepare(url){ xmlHttp.open("post",properties_ajax_php_path + url,true); xmlHttp.onreadystatechange=properties_stateChanged; xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); } function properties_stateChanged(){ if (xmlHttp.readyState==4){ if(xmlHttp.responseText!=""){ document.getElementById('dynamic_area').innerHTML = xmlHttp.responseText; } } }
Site standards • Commenting is PHP doc, even in JS • Try to comment each if branch if not obvious • Try not to code for success • Use error log calls when applicable • Name the PHP file after the name of the Javascript function when ajaxing • Assume modularity • Work on the basis of putting all constants into variables • Style sheet and Javascript per page