From 15abe1b55a39fbddc9cbfeb7b8d30ed775ed2846 Mon Sep 17 00:00:00 2001 From: Patrick Lockley Date: Sun, 16 Sep 2012 20:22:45 +0000 Subject: [PATCH] Simile Timeline commit git-svn-id: https://xerteonlinetoolkits.googlecode.com/svn/branches/1.9@433 912cdd6b-5c7d-d5a7-a2ba-d0f0cdb91641 --- languages/en-GB/folderproperties.inc | 6 +- languages/en-GB/modules/simile/edit.inc | 18 + .../en-GB/modules/simile/module_functions.inc | 16 + languages/en-GB/modules/simile/peer.inc | 20 + languages/en-GB/modules/simile/preview.inc | 16 + languages/en-GB/rss.inc | 2 +- .../website_code/php/management/sync.inc | 20 + .../website_code/php/management/templates.inc | 2 + .../php/properties/properties_library.inc | 2 +- modules/simile/delete_template.php | 131 ++++++ modules/simile/duplicate_template.php | 179 ++++++++ modules/simile/edit.php | 382 ++++++++++++++++++ modules/simile/module_functions.php | 296 ++++++++++++++ modules/simile/new_template.php | 67 +++ modules/simile/peer.php | 70 ++++ modules/simile/play.php | 38 ++ modules/simile/preview.php | 184 +++++++++ modules/simile/simile_timeline_toggle.js | 15 + .../simile/templates/timeline/timeline.info | 2 + .../templates/Nottingham/Nottingham.info | 2 + website_code/php/database_library.php | 5 +- website_code/php/display_library.php | 4 +- website_code/php/import/import.php | 23 +- website_code/php/import/import_template.php | 38 +- website_code/php/management/sync.php | 85 ++++ website_code/php/management/templates.php | 12 + website_code/php/properties/publish.php | 1 + website_code/scripts/management.js | 24 +- 28 files changed, 1594 insertions(+), 66 deletions(-) create mode 100644 languages/en-GB/modules/simile/edit.inc create mode 100644 languages/en-GB/modules/simile/module_functions.inc create mode 100644 languages/en-GB/modules/simile/peer.inc create mode 100644 languages/en-GB/modules/simile/preview.inc create mode 100644 languages/en-GB/website_code/php/management/sync.inc create mode 100644 modules/simile/delete_template.php create mode 100644 modules/simile/duplicate_template.php create mode 100644 modules/simile/edit.php create mode 100644 modules/simile/module_functions.php create mode 100644 modules/simile/new_template.php create mode 100644 modules/simile/peer.php create mode 100644 modules/simile/play.php create mode 100644 modules/simile/preview.php create mode 100644 modules/simile/simile_timeline_toggle.js create mode 100644 modules/simile/templates/timeline/timeline.info create mode 100644 modules/xerte/templates/Nottingham/Nottingham.info create mode 100644 website_code/php/management/sync.php diff --git a/languages/en-GB/folderproperties.inc b/languages/en-GB/folderproperties.inc index 244045705d..68fd9dfdaa 100644 --- a/languages/en-GB/folderproperties.inc +++ b/languages/en-GB/folderproperties.inc @@ -14,10 +14,10 @@ define("FOLDERPROPERTIES_DISPLAY_TITLE", "Folder Properties"); - define("FOLDERPROPERTIES_TAB_FOLDER", "Folder: Properties"); + define("FOLDERPROPERTIES_TAB_FOLDER", "Folder Properties"); - define("FOLDERPROPERTIES_TAB_CONTENT", "Folder: Contents"); + define("FOLDERPROPERTIES_TAB_CONTENT", "Folder Contents of this folder"); - define("FOLDERPROPERTIES_TAB_RSS", "Folder: RSS feeds"); + define("FOLDERPROPERTIES_TAB_RSS", "Folder RSS feed for this folder"); ?> \ No newline at end of file diff --git a/languages/en-GB/modules/simile/edit.inc b/languages/en-GB/modules/simile/edit.inc new file mode 100644 index 0000000000..a1537fffb9 --- /dev/null +++ b/languages/en-GB/modules/simile/edit.inc @@ -0,0 +1,18 @@ + \ No newline at end of file diff --git a/languages/en-GB/modules/simile/module_functions.inc b/languages/en-GB/modules/simile/module_functions.inc new file mode 100644 index 0000000000..3da750bb83 --- /dev/null +++ b/languages/en-GB/modules/simile/module_functions.inc @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/languages/en-GB/modules/simile/peer.inc b/languages/en-GB/modules/simile/peer.inc new file mode 100644 index 0000000000..0c513452ff --- /dev/null +++ b/languages/en-GB/modules/simile/peer.inc @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/languages/en-GB/modules/simile/preview.inc b/languages/en-GB/modules/simile/preview.inc new file mode 100644 index 0000000000..04ae875c54 --- /dev/null +++ b/languages/en-GB/modules/simile/preview.inc @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/languages/en-GB/rss.inc b/languages/en-GB/rss.inc index b9648fd4a5..d4b4c7d12f 100644 --- a/languages/en-GB/rss.inc +++ b/languages/en-GB/rss.inc @@ -14,7 +14,7 @@ define("RSS_LANGUAGE","en-gb"); define("RSS_DB_FAIL","Sorry, the system cannot connect to the database at present. The mysql error is "); define("RSS_LO","'s Learning Objects"); - define("RSS_PLURAL", "s"); + define("RSS_PLURAL", "'s"); define("RSS_FEED_DESC","A feed containing all of"); define("RSS_FEED_PUBLIC","'s public learning objects from the "); define("RSS_USER_LO","'s Learning Objects "); diff --git a/languages/en-GB/website_code/php/management/sync.inc b/languages/en-GB/website_code/php/management/sync.inc new file mode 100644 index 0000000000..e106ca1726 --- /dev/null +++ b/languages/en-GB/website_code/php/management/sync.inc @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/languages/en-GB/website_code/php/management/templates.inc b/languages/en-GB/website_code/php/management/templates.inc index b68d3e3ff0..ca8d51b904 100644 --- a/languages/en-GB/website_code/php/management/templates.inc +++ b/languages/en-GB/website_code/php/management/templates.inc @@ -16,6 +16,8 @@ define("TEMPLATE_VIEW", "View"); + define("TEMPLATE_UPDATE", "Update template list"); + define("TEMPLATE_MANAGE", "Manage Existing templates"); define("TEMPLATE_TYPE", "This template is of type"); diff --git a/languages/en-GB/website_code/php/properties/properties_library.inc b/languages/en-GB/website_code/php/properties/properties_library.inc index b8924fd6a1..01106b7456 100644 --- a/languages/en-GB/website_code/php/properties/properties_library.inc +++ b/languages/en-GB/website_code/php/properties/properties_library.inc @@ -146,7 +146,7 @@ define("PROPERTIES_LIBRARY_RSS_FOLDER", "As you organise content in folders, each folder has it's own RSS feed. This provides a convenient way to include only some of your content in a feed. See the folder properties for more details, and the link to that folder's feed"); - define("PROPERTIES_LIBRARY_RSS_EXPORT", "Include content in the export feed (allows other users to download your project and make changes to it)"); + define("PROPERTIES_LIBRARY_RSS_EXPORT", "Including content in the export feed allows other users to download your project and make changes to it themselves"); define("PROPERTIES_LIBRARY_RSS_SAVED", "Your changes have been saved"); diff --git a/modules/simile/delete_template.php b/modules/simile/delete_template.php new file mode 100644 index 0000000000..0387a08af1 --- /dev/null +++ b/modules/simile/delete_template.php @@ -0,0 +1,131 @@ + \ No newline at end of file diff --git a/modules/simile/duplicate_template.php b/modules/simile/duplicate_template.php new file mode 100644 index 0000000000..9a2215c92f --- /dev/null +++ b/modules/simile/duplicate_template.php @@ -0,0 +1,179 @@ +database_table_prefix . "originaltemplatesdetails where template_name =\"" . $tutorial_id_from_post . "\""; + + $query_for_framework_response = mysql_query($query_for_framework); + + $row_framework = mysql_fetch_array($query_for_framework_response); + + $dir_path = $xerte_toolkits_site->users_file_area_full . $id_to_copy. "-" . $_SESSION['toolkits_logon_username'] . "-" . $tutorial_id_from_post . "/"; + + /* + * Get the id of the folder we are looking to copy into + */ + + $new_path = $xerte_toolkits_site->users_file_area_full . $folder_name_id . "-" . $_SESSION['toolkits_logon_username'] . "-" . $tutorial_id_from_post . "/"; + + $path = $xerte_toolkits_site->users_file_area_full . $folder_name_id . "-" . $_SESSION['toolkits_logon_username'] . "-" . $tutorial_id_from_post . "/"; + + if(mkdir($path)){ + + if(@chmod($path,0777)){ + + $d = opendir($dir_path); + + if(create_folder_loop($d,-1)){ + + if(file_exists($new_path = $xerte_toolkits_site->users_file_area_full . $folder_name_id . "-" . $_SESSION['toolkits_logon_username'] . "-" . $tutorial_id_from_post . "/lockfile.txt")){ + + unlink($new_path = $xerte_toolkits_site->users_file_area_full . $folder_name_id . "-" . $_SESSION['toolkits_logon_username'] . "-" . $tutorial_id_from_post . "/lockfile.txt"); + + } + + + return true; + + }else{ + + return false; + + } + + }else{ + + receive_message($_SESSION['toolkits_logon_username'], "FILE_SYSTEM", "MAJOR", "Failed to set rights on parent folder for template", "Failed to set rights on parent folder " . $path); + + return false; + + + } + }else{ + + receive_message($_SESSION['toolkits_logon_username'], "FILE_SYSTEM", "CRITICAL", "Failed to create parent folder for template", "Failed to create parent folder " . $path); + + return false; + + } + +} + +?> \ No newline at end of file diff --git a/modules/simile/edit.php b/modules/simile/edit.php new file mode 100644 index 0000000000..ea60576c15 --- /dev/null +++ b/modules/simile/edit.php @@ -0,0 +1,382 @@ +database_table_prefix}logindetails where login_id=?" , array($row_edit['user_id'])); + + if(empty($row_username)) { + die("Invalid user id ?"); + } + + /** + * create the preview xml used for editing + */ + + if(file_exists($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->users_file_area_short . $row_edit['template_id'] . "-" . $row_username['username'] . "-" . $row_edit['template_name'] . "/preview.inc")){ + + $preview = $xerte_toolkits_site->root_file_path . $xerte_toolkits_site->users_file_area_short . $row_edit['template_id'] . "-" . $row_username['username'] . "-" . $row_edit['template_name'] . "/preview.inc"; + + }else{ + + $preview = ""; + + } + + $data = $xerte_toolkits_site->root_file_path . $xerte_toolkits_site->users_file_area_short . $row_edit['template_id'] . "-" . $row_username['username'] . "-" . $row_edit['template_name'] . "/data.inc"; + + if(!file_exists($preview) && file_exists($data)){ + copy($data, $preview); + chmod($preview, 0777); + } + + /** + * set up the onunload function used in version control + */ + +?> + + + + + <?PHP echo SIMILE_EDIT_TITLE; ?> + + + + + + +
+
+ + +
+
+
+
+ " /> + "; + echo "

Timeline Description

"; + + if($preview!=""){ + + $data = unserialize(file_get_contents($preview)); + + echo ""; + + }else{ + + echo ""; + + } + + echo "

Enter the description for your timeline here. You can use <p>, <img> and <a> HTML tags.

"; + echo "
"; + + echo "
"; + echo "

Timeline start and end years

"; + + if($preview!=""){ + + ?>
+
+
+
In these fields enter the years you want your timeline to start and stop.

"; + echo "
"; + + echo "
"; + echo "

Timeline zones

"; + echo "

A zone is a band on the time zone reflecting a grouping of events

"; + + if($preview!=""){ + + if(isset($data['zones'])){ + + $zones = $data['zones']; + + $counter = 0; + + echo "

Existing zones

"; + + while($zone = array_shift($zones)){ + + ?>

+ | - (Zone )

+ + +
+

Add a new zone

+

Format the dates like this - so 1159 AM (GMT) on June 1st 2012 is 2012-06-01T11:59:00+0000

+

So 2012 is the year, 06 is the month and 01 is the day - this is the minimum you must enter for each date.

+

11:59:00 is the time (minutes are supported, and +0000 means GMT.

+
+
+ By default use '100%' but again, you might wish to experiment with this.
+ + This is the unit shown on the timeline for this zone. Hours will show hours, days with show days, and so on.
+ + +

You must add a size for the zone to be added. Experiment with this size if you want different time zones to use different scales.

+
+
+ "; + + $counter = 0; + + if($preview!=""){ + + if(isset($data['zone_labels'])){ + + echo "

Timeline zone labels

"; + echo ""; + + $zone_labels = $data['zone_labels']; + + while($zone_label = array_shift($zone_labels)){ + + ?>

+ | - (Zone )

+ +

Add new event label

+

Start date and end dates should use the same format as specified above.

+
+
+
+
+ +
+ The hexadecimal colour code. You can see some example colours if you would like help
+ Expressed as a percentage of 100 (no percent symbol needed). + + "; + echo "

Timeline events

"; + echo "

A zone is a band on the time zone reflecting a grouping of events

"; + + $counter = 0; + + if($preview!=""){ + + if(isset($data['events'])){ + + $events = $data['events']; + + while($event = array_shift($events)){ + + ?>

+ | (Event )

+ + +
+
+
+
+
+
+
+
+
+
+
+ + + + + + + diff --git a/modules/simile/module_functions.php b/modules/simile/module_functions.php new file mode 100644 index 0000000000..8d1c0035ba --- /dev/null +++ b/modules/simile/module_functions.php @@ -0,0 +1,296 @@ + + + + + + + + + + + +
+
+ + +
+
+

Timeline hasn't displayed correctly - please check for javascript errors.

+ diff --git a/modules/simile/new_template.php b/modules/simile/new_template.php new file mode 100644 index 0000000000..3603832f1b --- /dev/null +++ b/modules/simile/new_template.php @@ -0,0 +1,67 @@ +database_table_prefix}originaltemplatesdetails WHERE template_name = ?", array($parent_template_name)); + + + // I think this is wrong, currently looking like : /home/david/src/xerteonlinetoolkits/modules//templates/0 should presumably be home/david/src/xerteonlinetoolkits/modules/xerte/templates/Nottingham + $dir_path = $xerte_toolkits_site->basic_template_path . $row_framework['template_framework'] . "/templates/" . $parent_template_name; + + /** + * Get the id of the folder we are looking to copy into + */ + + _debug("Creating new template : $folder_name_id, $parent_template_name"); + $new_path = $xerte_toolkits_site->users_file_area_full . $folder_name_id . "-" . $_SESSION['toolkits_logon_username'] . "-" . $parent_template_name; + $path = $xerte_toolkits_site->users_file_area_full . $folder_name_id . "-" . $_SESSION['toolkits_logon_username'] . "-" . $parent_template_name; + if(is_dir($path)) { + _debug("Trying to create new template at location - $path - it's already in use. Aborting"); + die("Template directory already exists; will not overwrite/re-create."); + } + if(mkdir($path)){ + _debug("Created $path ok"); + if(@chmod($path,0777)){ + return true; + }else{ + _debug("Failed to set rights "); + receive_message($_SESSION['toolkits_logon_username'], "FILE_SYSTEM", "MAJOR", "Failed to set rights on parent folder for template", "Failed to set rights on parent folder " . $path); + return false; + } + }else{ + receive_message($_SESSION['toolkits_logon_username'], "FILE_SYSTEM", "CRITICAL", "Failed to create parent folder for template", "Failed to create parent folder " . $path); + return false; + } +} diff --git a/modules/simile/peer.php b/modules/simile/peer.php new file mode 100644 index 0000000000..7dadfb95a4 --- /dev/null +++ b/modules/simile/peer.php @@ -0,0 +1,70 @@ +users_file_area_short . $row_play['template_id'] . "-" . $row_play['username'] . "-" . $row_play['template_name'] . "/data.xml"; + + $string_for_flash = $xerte_toolkits_site->users_file_area_short . $row_play['template_id'] . "-" . $row_play['username'] . "-" . $row_play['template_name'] . "/"; + + list($x, $y) = explode("~",get_template_screen_size($row_play['template_name'],$row_play['template_framework'])); + +?> + + + Interactive Learning Content + + + + + + +
+

+
+

+ "; + + echo "

"; + + echo "

"; + + echo ""; + +} diff --git a/modules/simile/play.php b/modules/simile/play.php new file mode 100644 index 0000000000..9f7b74807d --- /dev/null +++ b/modules/simile/play.php @@ -0,0 +1,38 @@ +root_file_path . $xerte_toolkits_site->users_file_area_short . $row_play['template_id'] . "-" . $row_play['username'] . "-" . $row_play ['template_name'] . "/preview.inc")){ + + echo "UH OH!!!!!!!!!!!!!!"; + + } + + ?> + + + <?PHP echo SIMILE_EDIT_TITLE; ?> + + + + + root_file_path . $xerte_toolkits_site->users_file_area_short . $row_play['template_id'] . "-" . $row_play['username'] . "-" . $row_play['template_name'] . "/preview.inc"))); + +} diff --git a/modules/simile/preview.php b/modules/simile/preview.php new file mode 100644 index 0000000000..7fab56a8c1 --- /dev/null +++ b/modules/simile/preview.php @@ -0,0 +1,184 @@ +users_file_area_short . $row['template_id'] . "-" . $row_username['username'] . "-" . $row['template_name'] . "/preview.inc")){ + + } + + + if(isset($_POST)){ + + ?> + + + + + <?PHP echo SIMILE_EDIT_TITLE; ?> + + + + + +

Return to editor

+ "); + $data['simile_start'] = htmlentities(strip_tags($_POST['simile_start'])); + $data['simile_stop'] = htmlentities(strip_tags($_POST['simile_stop'])); + + $counter = 0; + + $save_counter = 0; + + $data['zones'] = array(); + + while(isset($_POST['simile_zone_width_' . $counter])){ + + $zone = array(); + + if($_POST['simile_zone_delete_' . $counter]!="on"){ + + $zone['simile_zone_start_' . $save_counter] = $_POST['simile_zone_start_' . $counter]; + $zone['simile_zone_stop_' . $save_counter] = $_POST['simile_zone_stop_' . $counter]; + $zone['simile_zone_width_' . $save_counter] = $_POST['simile_zone_width_' . $counter]; + $zone['simile_zone_interval_pixels_' . $save_counter] = $_POST['simile_zone_interval_pixels_' . $counter]; + $zone['simile_zone_unit_' . $save_counter] = $_POST['simile_zone_unit_' . $counter]; + $zone['simile_zone_sync_' . $save_counter] = $_POST['simile_zones_sync_' . $counter]; + + if($_POST['simile_zone_width_' . $counter]!=""){ + + $zone = array_filter($zone); + + array_push($data['zones'], $zone); + $save_counter++; + + } + + } + + $counter++; + + } + + $data['zone_labels'] = array(); + + $counter = 0; + $save_counter = 0; + + while(isset($_POST['simile_zone_label_startdate_' . $counter])){ + + $zone_label = array(); + + if(!isset($_POST['simile_zone_label_delete_' . $counter])){ + + $zone_label['simile_zone_label_startdate_' . $save_counter] = $_POST['simile_zone_label_startdate_' . $counter]; + $zone_label['simile_zone_label_enddate_' . $save_counter] = $_POST['simile_zone_label_enddate_' . $counter]; + $zone_label['simile_zone_label_startlabel_' . $save_counter] = $_POST['simile_zone_label_startlabel_' . $counter]; + $zone_label['simile_zone_label_endlabel_' . $save_counter] = $_POST['simile_zone_label_endlabel_' . $counter]; + $zone_label['simile_zone_label_colour_' . $save_counter] = $_POST['simile_zone_label_colour_' . $counter]; + $zone_label['simile_zone_label_opacity_' . $save_counter] = $_POST['simile_zone_label_opacity_' . $counter]; + $zone_label['simile_event_label_zones_' . $save_counter] = $_POST['simile_event_label_zones_' . $counter]; + + if($_POST['simile_zone_label_startdate_' . $counter]!=""){ + + $zone_label = array_filter($zone_label); + + array_push($data['zone_labels'], $zone_label); + $save_counter++; + + } + + } + + $counter++; + + } + + $data['events'] = array(); + + $counter = 0; + + $save_counter = 0; + + while(isset($_POST['simile_event_title_' . $counter])){ + + $event = array(); + + if($_POST['simile_event_delete_' . $counter]!="on"){ + + $event['simile_event_title_' . $save_counter] = stripslashes($_POST['simile_event_title_' . $counter]); + $event['simile_event_description_' . $save_counter] = $_POST['simile_event_description_' . $counter]; + $event['simile_event_link_' . $save_counter] = $_POST['simile_event_link_' . $counter]; + $event['simile_event_image_' . $save_counter] = $_POST['simile_event_image_' . $counter]; + $event['simile_event_start_' . $save_counter] = $_POST['simile_event_start_' . $counter]; + $event['simile_event_lateststart_' . $save_counter] = $_POST['simile_event_lateststart_' . $counter]; + $event['simile_event_earliestend_' . $save_counter] = $_POST['simile_event_earliestend_' . $counter]; + $event['simile_event_end_' . $save_counter] = $_POST['simile_event_end_' . $counter]; + $event['simile_event_durationevent_' . $save_counter] = $_POST['simile_event_durationevent_' . $counter]; + $event['simile_event_color_' . $save_counter] = $_POST['simile_event_color_' . $counter]; + $event['simile_event_textcolor_' . $save_counter] = $_POST['simile_event_textcolor_' . $counter]; + $event['simile_event_opacity_' . $save_counter] = $_POST['simile_event_opacity_' . $counter]; + $event['simile_event_zones_' . $save_counter] = $_POST['simile_event_zones_' . $counter]; + + if($_POST['simile_event_title_' . $counter]!=""){ + + $event = array_filter($event); + + array_push($data['events'], $event); + $save_counter++; + + } + + } + + $counter++; + + } + + if(isset($_POST)){ + + file_put_contents($_POST['save_path'] . "/preview.inc", serialize($data)); + + display_timeline($data); + + } + + } + +} + + +?> \ No newline at end of file diff --git a/modules/simile/simile_timeline_toggle.js b/modules/simile/simile_timeline_toggle.js new file mode 100644 index 0000000000..e27bef0383 --- /dev/null +++ b/modules/simile/simile_timeline_toggle.js @@ -0,0 +1,15 @@ +function simile_toggle(id){ + + target_div = document.getElementById(id); + + if(target_div.style.display=="block"){ + + target_div.style.display="none"; + + }else{ + + target_div.style.display="block"; + + } + +} \ No newline at end of file diff --git a/modules/simile/templates/timeline/timeline.info b/modules/simile/templates/timeline/timeline.info new file mode 100644 index 0000000000..5950b7bf1e --- /dev/null +++ b/modules/simile/templates/timeline/timeline.info @@ -0,0 +1,2 @@ +display name: Simile Timeline +description: Allows a user to create a simile timeline \ No newline at end of file diff --git a/modules/xerte/templates/Nottingham/Nottingham.info b/modules/xerte/templates/Nottingham/Nottingham.info new file mode 100644 index 0000000000..dc3ef5822f --- /dev/null +++ b/modules/xerte/templates/Nottingham/Nottingham.info @@ -0,0 +1,2 @@ +display name: Xerte Online Toolkit +description: A flexible template for creating interactive learning objects. \ No newline at end of file diff --git a/website_code/php/database_library.php b/website_code/php/database_library.php index d20173dc81..d487228aa6 100644 --- a/website_code/php/database_library.php +++ b/website_code/php/database_library.php @@ -80,8 +80,9 @@ function database_connect($success_string, $error_string) function db_query($sql, $params = array()) { $connection = database_connect('db_query ok', 'db_query fail'); - + foreach ($params as $key => $value) { + if (isset($value)) { if (get_magic_quotes_gpc()) { $value = stripslashes($value); @@ -108,10 +109,10 @@ function db_query($sql, $params = array()) $sql = substr_replace($sql, $params[$curph], $i, 1); } $curph--; + } _debug("Running : $sql", 1); - $result = mysql_query($sql, $connection); if (!$result) { _debug("Failed to execute query : $sql : " . mysql_error()); diff --git a/website_code/php/display_library.php b/website_code/php/display_library.php index 8171d8ddd4..15af7c2418 100644 --- a/website_code/php/display_library.php +++ b/website_code/php/display_library.php @@ -349,7 +349,7 @@ function list_blank_templates(){ echo "" . DISPLAY_CREATE . "
"; - echo "" . DISPLAY_NAME . "

"; + echo "" . DISPLAY_NAME . "

"; } @@ -422,8 +422,6 @@ function list_specific_templates(){ echo "

"; - echo $row['display_name']; - echo "

"; echo $row['description']; diff --git a/website_code/php/import/import.php b/website_code/php/import/import.php index 8eff73832c..ac8e229dbf 100644 --- a/website_code/php/import/import.php +++ b/website_code/php/import/import.php @@ -39,8 +39,6 @@ function make_new_template($type,$zip_path){ global $xerte_toolkits_site, $delete_folder_array, $folder_id; - _debug("3. Creating new template (type=" . $type . ", path=" . $zip_path); - $database_connect_id = database_connect("new_template(import) database connect success","new_template(import) database connect fail"); /* @@ -164,7 +162,6 @@ function make_new_template($type,$zip_path){ */ function replace_existing_template($path_to_copy_from, $template_id){ - _debug("3. Replacing existing template " . $template_id . " (from " . $path_to_copy_from . ")"); global $xerte_toolkits_site, $delete_file_array, $delete_folder_array; @@ -360,8 +357,6 @@ function folder_loop($path){ if(($_FILES['filenameuploaded']['type']=="application/x-zip-compressed")||($_FILES['filenameuploaded']['type']=="application/zip")){ - _debug("Trying to import " . $_FILES['filenameuploaded']['name']); - $this_dir = rand() . "/"; mkdir($xerte_toolkits_site->import_path . $this_dir); @@ -507,7 +502,6 @@ function folder_loop($path){ fclose($fp); $template_check = $file_to_create[1]; - _debug(" - Found rlt " . $file_to_create[0]); chmod($xerte_toolkits_site->import_path . $this_dir . $file_to_create[0],0777); @@ -535,14 +529,11 @@ function folder_loop($path){ $folder = explode('"',substr($template_check,strpos($template_check,"targetFolder"),strpos($template_check,"version")-strpos($template_check,"targetFolder"))); - _debug("1. Importing RLO: Folder = " . $folder[1]); - $start_point = strpos($template_check,"version"); $version = explode('"',substr($template_check,$start_point,strpos($template_check," ",$start_point)-$start_point)); if($_POST['replace']){ - _debug("2. Replace"); $query = "select template_framework from " . $xerte_toolkits_site->database_table_prefix . "templatedetails, " . $xerte_toolkits_site->database_table_prefix . "originaltemplatesdetails where " . $xerte_toolkits_site->database_table_prefix . "templatedetails.template_type_id = " . $xerte_toolkits_site->database_table_prefix . "originaltemplatesdetails.template_type_id AND " . $xerte_toolkits_site->database_table_prefix . "templatedetails.template_id =\"" . mysql_real_escape_string($_POST['replace']) . "\""; @@ -620,7 +611,6 @@ function folder_loop($path){ } }else{ - _debug("2. New ..."); if($_POST['folder']!=""){ @@ -652,17 +642,14 @@ function folder_loop($path){ */ unlink($xerte_toolkits_site->import_path . $this_dir . $rlt_name); - $previewfile = str_replace("\\","/",$xerte_toolkits_site->import_path . $this_dir) . "preview.xml"; - if (file_exists($previewfile)) - { - $preview_xml = file_get_contents($previewfile); - $fh = fopen($xerte_toolkits_site->import_path . $this_dir . "preview.xml", "w"); + $preview_xml = file_get_contents(str_replace("\\","/",$xerte_toolkits_site->import_path . $this_dir) . "preview.xml"); - fwrite($fh, $preview_xml); + $fh = fopen($xerte_toolkits_site->import_path . $this_dir . "preview.xml", "w"); - fclose($fh); - } + fwrite($fh, $preview_xml); + + fclose($fh); make_new_template($folder[1], $xerte_toolkits_site->import_path . $this_dir); diff --git a/website_code/php/import/import_template.php b/website_code/php/import/import_template.php index 3924feb37a..56f62d2ade 100644 --- a/website_code/php/import/import_template.php +++ b/website_code/php/import/import_template.php @@ -97,8 +97,6 @@ function copy_loop($path){ _load_language_file("/website_code/php/import_template.inc"); - _debug("Trying to import template " . $_FILES['filenameuploaded']['name']); - $this_dir = rand() . "/"; $end_dir = $this_dir; @@ -109,7 +107,6 @@ function copy_loop($path){ $new_file_name = $xerte_toolkits_site->import_path . $_FILES['filenameuploaded']['name']; - _debug(" 1. Moving " . $_FILES['filenameuploaded']['tmp_name'] . " to " . new_file_name); if(@move_uploaded_file($_FILES['filenameuploaded']['tmp_name'], $new_file_name)){ require_once dirname(__FILE__)."/dUnzip2.inc.php"; @@ -122,8 +119,6 @@ function copy_loop($path){ $zip->unzipAll($xerte_toolkits_site->import_path . $this_dir); - _debug(" 2. Unzip..."); - } $zip->close(); @@ -136,7 +131,6 @@ function copy_loop($path){ * We are replacing, so delete files */ - _debug(" 3. Replacing..."); delete_loop($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/templates/" . $_POST['folder'] . "/"); delete_loop($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $_POST['folder'] . "/"); @@ -147,12 +141,10 @@ function copy_loop($path){ } }else{ - _debug(" 3. Installing in " . $xerte_toolkits_site->import_path . $this_dir . substr($_FILES['filenameuploaded']['name'],0,strlen($_FILES['filenameuploaded']['name'])-4)); $dir = opendir($xerte_toolkits_site->import_path . $this_dir . substr($_FILES['filenameuploaded']['name'],0,strlen($_FILES['filenameuploaded']['name'])-4)); if($dir===false){ - _debug(" Failed...."); delete_loop($xerte_toolkits_site->import_path . $this_dir); @@ -164,15 +156,14 @@ function copy_loop($path){ rmdir($xerte_toolkits_site->import_path . $this_dir); - echo IMPORT_TEMPLATE_ZIP_FAIL . "****"; + echo IMPORT_TEMPLATE_ZIP_FAIL "****"; die(); } - $rlt_not_found = true; + $rlt_not_found = false; - _debug(" 4. Searching template.rlt"); while($filename = readdir($dir)){ /* @@ -207,8 +198,7 @@ function copy_loop($path){ $desc = substr(substr($string, strpos($string, "description=")+13),0,strpos(substr($string, strpos($string, "description=")+13),"\"")); - $rlt_not_found = false; - _debug(" 5. Installing to " . $folder . " with name " . $name); + $rlt_not_found = true; } @@ -216,9 +206,8 @@ function copy_loop($path){ } - if($rlt_not_found){ + if(!$rlt_not_found){ - _debug(" Failed...."); delete_loop($xerte_toolkits_site->import_path . $this_dir); while($file_to_delete = array_pop($delete_file_array)){ @@ -253,7 +242,6 @@ function copy_loop($path){ @mkdir($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/common/"); @mkdir($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/thumbs/"); @mkdir($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/models/"); - @mkdir($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/wizards/"); @mkdir($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/templates/" . $folder . "/"); @mkdir($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/templates/" . $folder . "/media/"); @@ -261,7 +249,6 @@ function copy_loop($path){ @chmod($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/common/",0777); @chmod($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/thumbs/",0777); @chmod($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/models/",0777); - @chmod($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/wizards/",0777); @chmod($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/templates/" . $folder . "/",0777); @chmod($xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/templates/" . $folder . "/media/",0777); @@ -344,22 +331,6 @@ function copy_loop($path){ } - copy_loop($xerte_toolkits_site->import_path . $this_dir . "wizards"); - - while($file_to_copy = array_pop($copy_file_array)){ - - @rename($xerte_toolkits_site->import_path . $this_dir . "wizards/" . $file_to_copy, $xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/wizards/" . $file_to_copy); - - } - - delete_loop($xerte_toolkits_site->import_path . $this_dir . "wizards"); - - while($file_to_delete = array_pop($delete_file_array)){ - - @unlink($file_to_delete); - - } - rename($xerte_toolkits_site->import_path . $this_dir . "template.rlt", $xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/parent_templates/" . $folder . "/" . $folder . ".rlt"); rename($xerte_toolkits_site->import_path . $this_dir . "template.xml", $xerte_toolkits_site->root_file_path . $xerte_toolkits_site->module_path . "xerte/templates/" . $folder . "/data.xml"); @@ -378,7 +349,6 @@ function copy_loop($path){ rmdir($xerte_toolkits_site->import_path . $this_dir . "media"); rmdir($xerte_toolkits_site->import_path . $this_dir . "thumbs"); rmdir($xerte_toolkits_site->import_path . $this_dir . "models"); - rmdir($xerte_toolkits_site->import_path . $this_dir . "wizards"); if($_POST['folder']==""){ diff --git a/website_code/php/management/sync.php b/website_code/php/management/sync.php new file mode 100644 index 0000000000..35d6a429f3 --- /dev/null +++ b/website_code/php/management/sync.php @@ -0,0 +1,85 @@ +root_file_path . "modules/"); + + while($folder = readdir($dir)){ + + if($folder!="."&&$folder!=".."){ + + $inner_dir = opendir($xerte_toolkits_site->root_file_path . "modules/" . $folder . "/templates"); + + while($inner_folder = readdir($inner_dir)){ + + if($inner_folder!="."&&$inner_folder!=".."){ + + if(file_exists($xerte_toolkits_site->root_file_path . "modules/" . $folder . "/templates/" . $inner_folder . "/" . $inner_folder . ".info")){ + + $data = file_get_contents($xerte_toolkits_site->root_file_path . "modules/" . $folder . "/templates/" . $inner_folder . "/" . $inner_folder . ".info"); + + $info = explode("\n",$data); + + $template_object = array(); + $template_name = array(); + + while($attribute = array_pop($info)){ + + $attr_data = explode(":",$attribute); + + $template_object['name'] = trim($inner_folder); + $template_name['name'] = trim($inner_folder); + + switch(trim(strtolower($attr_data[0]))){ + + case "display name" : $template_object['display_name'] = trim($attr_data[1]); break; + case "description" : $template_object['description'] = trim($attr_data[1]); break; + + } + + } + + $row = db_query_one("SELECT * FROM {$xerte_toolkits_site->database_table_prefix}originaltemplatesdetails where template_framework=? and template_name=?", array($folder, $inner_folder)); + + if(isset($row)){ + + if(is_array($row)){ + + db_query("update {$xerte_toolkits_site->database_table_prefix}originaltemplatesdetails set display_name=?, description=? where template_type_id=?", array($template_object['display_name'],$template_object['description'], $row['template_type_id'])); + echo "

" . $folder . " / " . $inner_folder . " " . SYNC_UPDATE . "

"; + + } + + }else{ + + db_query("insert into {$xerte_toolkits_site->database_table_prefix}originaltemplatesdetails (template_framework,template_name,display_name,description,date_uploaded)values(?,?,?,?,?)", array($folder, $inner_folder,$template_object['display_name'],$template_object['description'],date("Y-m-d",time()))); + echo "

" . $folder . " / " . $inner_folder . " " . SYNC_INSTALL . "

"; + + } + + } + + } + + } + + } + + } + + echo "

" . SYNC_RETURN . "

"; + +}else{ + + management_fail(); + +} + +?> diff --git a/website_code/php/management/templates.php b/website_code/php/management/templates.php index 93572f30f7..0b35b54227 100644 --- a/website_code/php/management/templates.php +++ b/website_code/php/management/templates.php @@ -17,10 +17,22 @@ echo "

" . TEMPLATE_UPLOAD . "


"; + echo "

" . TEMPLATE_UPDATE . "

"; + echo "

" . TEMPLATE_MANAGE . "

"; + + $last_template_type = ""; while($row = mysql_fetch_array($query_response)){ + if($row['template_framework']!=$last_template_type){ + + echo "

" . ucfirst($row['template_framework']) . "

"; + + $last_template_type = $row['template_framework']; + + } + echo "

" . $row['template_name'] . " " . TEMPLATE_VIEW . "

"; echo "

" . TEMPLATE_TYPE . " " . $row['template_framework'] . "

"; diff --git a/website_code/php/properties/publish.php b/website_code/php/properties/publish.php index a8a94ecc18..5743cc9f84 100644 --- a/website_code/php/properties/publish.php +++ b/website_code/php/properties/publish.php @@ -87,6 +87,7 @@ echo "

" . PUBLISH_WEB_ADDRESS . " " . $xerte_toolkits_site->site_url . url_return("play",mysql_real_escape_string($_POST['template_id'])) . "

"; + } }else{ diff --git a/website_code/scripts/management.js b/website_code/scripts/management.js index 6b37777787..3baa488be8 100644 --- a/website_code/scripts/management.js +++ b/website_code/scripts/management.js @@ -2,9 +2,6 @@ var function_to_use = null; var management_ajax_php_path = "website_code/php/management/"; - - - if(typeof(String.prototype.trim) === "undefined") { String.prototype.trim = function() @@ -239,6 +236,25 @@ function users_list(){ } } +// Function template_sync +// +// Version 1.0 University of Nottingham +// (pl) +// remove a share, and check who did it + +function template_sync(){ + + if(setup_ajax()!=false){ + + var url="sync.php"; + + management_ajax_send_prepare(url) + + xmlHttp.send('no_id=1'); + + } +} + // Function site list // // Version 1.0 University of Nottingham @@ -290,7 +306,7 @@ function templates_list(){ function update_template(){ if(setup_ajax()!=false){ - + var url="template_details_management.php"; xmlHttp.open("post",management_ajax_php_path + url,true);