Skip to content

Commit

Permalink
Second commit of themes, structures, and pages template editor
Browse files Browse the repository at this point in the history
  • Loading branch information
gregrgay committed Jan 24, 2016
1 parent 57eb13b commit 3791caf
Show file tree
Hide file tree
Showing 25 changed files with 341 additions and 231 deletions.
10 changes: 5 additions & 5 deletions home/editor/editor_tabs/page_template.inc.php
Expand Up @@ -42,8 +42,8 @@
$mod_path['templates'] = realpath(TR_BASE_HREF . 'templates').'/';
$mod_path['templates_int'] = realpath(TR_INCLUDE_PATH . '../templates').'/';
$mod_path['templates_sys'] = $mod_path['templates_int'] . 'system/';
$mod_path['page_template_dir'] = $mod_path['templates'] . 'page_template/';
$mod_path['page_template_dir_int'] = $mod_path['templates_int'] . 'page_template/';
$mod_path['page_template_dir'] = $mod_path['templates'] . 'page_templates/';
$mod_path['page_template_dir_int'] = $mod_path['templates_int'] . 'page_templates/';

// include the file "apply_model" so that he can inherit variables and constants defined by the system
include_once($mod_path['templates_sys'].'Page_template.class.php');
Expand All @@ -64,8 +64,8 @@
$templates_int = TR_INCLUDE_PATH.'../templates/';

// path containing the page_template list
$page_template_dir = $templates.'page_template/';
$page_template_dir_int = $templates_int.'page_template/';
$page_template_dir = $templates.'page_templates/';
$page_template_dir_int = $templates_int.'page_templates/';

// directory and file systems to be excluded from the page_template list
$excep = array('.', '..', '.DS_Store', 'desktop.ini', 'Thumbs.db');
Expand Down Expand Up @@ -119,7 +119,7 @@
$with_content=0;
$mod->view_page_templates($with_content);
} else {
echo '<link type="text/css" rel="stylesheet" href="'.TR_BASE_HREF.'templates/layout/'.$layout.'/'.$layout.'.css">';
echo '<link type="text/css" rel="stylesheet" href="'.TR_BASE_HREF.'templates/layouts/'.$layout.'/'.$layout.'.css">';
echo '<div style="margin: 10px; margin-top: 10px; margin-bottom: 15px;">';
echo '<div id="with-cont" style="font-weight:bold;">'. _AT("content_associated") .':</div>';
// Keep track of the old content for rescue
Expand Down
4 changes: 2 additions & 2 deletions home/structs/preview.php
Expand Up @@ -21,9 +21,9 @@

$mod_path['templates_int'] = realpath(TR_INCLUDE_PATH . '../templates').'/';
$mod_path['templates_sys'] = $mod_path['templates_int'] . 'system/';
$mod_path['page_template_dir'] = $mod_path['templates'] . 'page_template/';
$mod_path['page_template_dir'] = $mod_path['templates'] . 'page_templates/';

$mod_path['page_template_dir_int'] = $mod_path['templates_int'] . 'page_template/';
$mod_path['page_template_dir_int'] = $mod_path['templates_int'] . 'page_templates/';
$path = $mod_path['page_template_dir'] . $prev_page_temp . '/';
$path_int = $mod_path['page_template_dir_int'] . $prev_page_temp . '/';

Expand Down
Binary file added images/page_placeholder.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 28 additions & 6 deletions template_editor/delete.php
Expand Up @@ -23,22 +23,44 @@
require('classes/TemplateCommons.php');
$commons=new TemplateCommons('../templates');
$type=strip_tags($addslashes($_GET['type']));
if($_GET['type']=='page') $type='page_template';


if($_GET['type']=='pages') $type='page_templates';

if(isset ($_POST['cancel'])){
$msg->addFeedback('CANCELLED');
Header('Location: index.php?tab='.$type);
if($_GET['type']=='page_templates') $type='page';
if($_GET['type']=='page_templates') $app_type='page';
if($_GET['type']=='structures') $type='structure';
if($_GET['type']=='layouts') $type='layouts';
if($_GET['type']=='layouts') $app_type='layout';
header('Location: edit_'.$app_type.'.php?type='.$type.SEP.'temp='.$_GET['temp'] );
exit;
}

if(isset ($_POST['submit'])) {
if($_GET['type']=='page_templates') $type='page_templates';
if($_GET['type']=='page_templates') $app_type='pages';
if($_GET['type']=='structures') $type='structures';
if($_GET['type']=='layouts') $type='layouts';
$commons->delete_template($type, $_GET['temp']);
//if($commons->delete_template($type, $_GET['temp']) == true){
$msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
header('Location: index.php?tab='.$app_type);
exit;
//}

}

if(!$commons->template_exists($type, $_GET['temp'])){
if($_GET['type']=='page_templates') $type='pages';
if($_GET['type']=='structures') $type='structures';
//if($_GET['type']=='layout') $type='layouts';
if($_GET['type']=='layouts') $type='layouts';
$msg->addError('SELECT_ONE_ITEM');
Header('Location: index.php?tab='.$type);
exit;
}
if(isset ($_POST['submit'])) {
$commons->delete_template($type, $_GET['temp']);
Header('Location: index.php?tab='.$type);
}
require(TR_INCLUDE_PATH.'header.inc.php');
$metadata=$commons->load_metadata($type,$_GET['temp']);
$savant->assign('template_name', $metadata['template_name']);
Expand Down
81 changes: 58 additions & 23 deletions template_editor/edit_meta.php
Expand Up @@ -14,45 +14,80 @@
require(TR_INCLUDE_PATH.'vitals.inc.php');
require_once(TR_INCLUDE_PATH.'classes/DAO/UsersDAO.class.php');

global $_current_user;

global $_current_user, $msg;
$type=htmlspecialchars($_GET['type'], ENT_QUOTES, 'UTF-8');
$temp=htmlspecialchars($_GET['temp'], ENT_QUOTES, 'UTF-8');
if(isset($_POST['cancel'])) {
$msg->addFeedback('CANCELLED');
header('Location:edit_'.$type.'.php?type='.$type.SEP.'temp='.$temp);
exit;
}
if (isset($_current_user) && $_current_user->isAdmin()) {
require(TR_INCLUDE_PATH.'header.inc.php');
require('classes/TemplateCommons.php');
$commons=new TemplateCommons('../templates');

if(isset($_GET['temp']) && isset($_GET['type'])) {
$type=$_GET['type'];
if($_GET['type']=='page') $type='page_template';
if(isset($temp) && isset($type)) {
if($type=='page') $type='page_templates';

if(!$commons->template_exists($type, $_GET['temp']) || isset ($_POST['cancel'])) {
Header('Location: index.php');
if(!$commons->template_exists($type, $temp) || isset ($_POST['cancel'])) {
header('Location: edit_layout.php?temp='.$temp);
exit;
}
if(isset($_POST['submit'])) {
$type=$_GET['type'];
if($_GET['type']=='page') $type='page_template';

if($commons->template_exists($type, $_GET['temp'])) {
$commons->create_template_metadata($type,$_GET['temp'], $_POST['template_name'], $_POST['template_desc'],
$_POST['maintainer_name'], $_POST ['maintainer_email'], $_POST ['template_url'], $_POST['template_license'],
$_POST ['release_version'], $_POST ['release_date'], $_POST ['release_state'], $_POST ['release_notes']);
Header('Location: index.php');
//$type=htmlspecialchars($_GET['type']);
//$temp=htmlspecialchars($_GET['temp']);
if($type=='page') $type='page_templates';
//$_GET['temp'] = htmlspecialchars($_GET['temp'], ENT_QUOTES, 'UTF-8');
$_POST['template_name'] = htmlspecialchars($_POST['template_name'], ENT_QUOTES, 'UTF-8');
$_POST['template_desc'] = htmlspecialchars($_POST['template_desc'], ENT_QUOTES, 'UTF-8');
$_POST['maintainer_name'] = htmlspecialchars($_POST['maintainer_name'], ENT_QUOTES, 'UTF-8');
$_POST ['maintainer_email'] = htmlspecialchars($_POST['maintainer_email'], ENT_QUOTES, 'UTF-8');
$_POST ['template_url'] = htmlspecialchars($_POST['template_url'], ENT_QUOTES, 'UTF-8');
$_POST['template_license'] = htmlspecialchars($_POST['template_license'], ENT_QUOTES, 'UTF-8');
$_POST ['release_version'] = htmlspecialchars($_POST['release_version'], ENT_QUOTES, 'UTF-8');
$_POST ['release_date'] = htmlspecialchars($_POST['release_date'], ENT_QUOTES, 'UTF-8');
$_POST ['release_state'] = htmlspecialchars($_POST['release_state'], ENT_QUOTES, 'UTF-8');
$_POST ['release_notes'] = htmlspecialchars($_POST['release_notes'], ENT_QUOTES, 'UTF-8');
if($commons->template_exists($type, $temp)) {
$commons->create_template_metadata($type,
$temp,
$_POST['template_name'],
$_POST['template_desc'],
$_POST['maintainer_name'],
$_POST ['maintainer_email'],
$_POST ['template_url'],
$_POST['template_license'],
$_POST ['release_version'],
$_POST ['release_date'],
$_POST ['release_state'],
$_POST ['release_notes']);
header('Location:?temp='.$temp);
exit;
}

}else {
$metadata=$commons->load_metadata($type,$_GET['temp']);
}
//else {
require(TR_INCLUDE_PATH.'header.inc.php');
$metadata=$commons->load_metadata($type,$temp);
$savant->assign('metadata', $metadata);
$savant->assign('template_dir', $_GET['temp']);
$savant->assign('template_type', $_GET['type']);
$savant->assign('template_dir', $temp);
$savant->assign('template_type', $type);
$savant->display('template_editor/edit_meta.tmpl.php');
}
//}
require(TR_INCLUDE_PATH.'footer.inc.php');
exit;

}else {
Header('Location: ../index.php');
$msg->addFeedback('FAILED');
header('Location:edit_layout.php?temp='.$temp);
exit;
//Header('Location: ../index.php');
}
}else {
Header('Location: ../index.php');
$msg->addFeedback('FAILED2');
header('Location:edit_layout.php?temp='.$temp);
exit;
//Header('Location: ../index.php');
}

?>
21 changes: 13 additions & 8 deletions template_editor/edit_page.php
Expand Up @@ -6,35 +6,40 @@
$_custom_head .= '<script type="text/javascript" src="template_editor/js/page.js"></script>';

if($_POST['submit'] == _AT('cancel')){
header('Location: '. $_POST['referer']);
$msg->addFeedback('CANCELLED');
header('Location: index.php?tab=pages');
exit;
}

require(TR_INCLUDE_PATH.'header.inc.php');

require('classes/TemplateCommons.php');

$commons=new TemplateCommons('../templates');

$template=$_GET['temp'];
// non existing template name
if(!$commons->template_exists('page_template', $template)) {

if(!$commons->template_exists('page_templates', $template)) {
$msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
Header('Location: index.php');
exit;
}

if(isset ($_POST['submit'])) {
$commons->save_file("page_template/".$template,$template.".html",$_POST['page_text']);
$commons->save_file("page_templates/".$template,$template.".html",$_POST['page_text']);
}
if(isset ($_POST['uploadscrn'])) {
echo $commons->upload_image("page_template/".$template,"screenshot.png");
echo $commons->upload_image("page_templates/".$template,"screenshot.png");
}

$html_path=realpath("../templates/page_template")."/". $template."/".$template.".html";
$screenshot_path=realpath("../templates/page_template")."/". $template."/screenshot.png";
require(TR_INCLUDE_PATH.'header.inc.php');
$html_path=realpath("../templates/page_templates")."/". $template."/".$template.".html";
$screenshot_path=realpath("../templates/page_templates")."/". $template."/screenshot.png";

if(file_exists($html_path)) $savant->assign('html_code', file_get_contents($html_path));
else $savant->assign('html_code', "");
if(file_exists($screenshot_path)) $savant->assign('screenshot',true);
$savant->assign('template', $template);
$savant->assign('types', $type);
$savant->assign('base_path', $_base_path);
$savant->assign('referer', $_SERVER['HTTP_REFERER']);
$savant->display('template_editor/page_tool.tmpl.php');
Expand Down
11 changes: 6 additions & 5 deletions template_editor/edit_structure.php
Expand Up @@ -18,17 +18,16 @@
$_custom_head .= '<script type="text/javascript" src="template_editor/js/jquery.ui.sortable.js"></script>';

if($_POST['submit'] == _AT('cancel')){
header('Location: '. $_POST['referer']);
header('Location: index.php?tab=structures');
exit;
}

require(TR_INCLUDE_PATH.'header.inc.php');
$template=$_GET['temp'];
require('classes/TemplateCommons.php');
$commons=new TemplateCommons('../templates');

$template=$_GET['temp'];
// non existing template name
if(!$commons->template_exists('structure', $template)) {
if($commons->template_exists('structure', $template)) {
Header('Location: index.php');
exit;
}
Expand All @@ -37,12 +36,14 @@
$dom=$commons->parse_to_XML($_POST['xml_text']);
$commons->save_xml($dom, "structures/".$template, "content.xml");
}
require(TR_INCLUDE_PATH.'header.inc.php');

// edit an existing template
$xmlpath=realpath("../templates/structures")."/". $template."/content.xml";
$xmlDoc = new DOMDocument();
$xmlDoc->load($xmlpath);
$x = $xmlDoc->documentElement;
$page_temp_list=$commons->get_template_list("page_template");
$page_temp_list=$commons->get_template_list("page_templates");

$savant->assign('template', $template);
$savant->assign('xml_script', $xmlDoc->saveXML($xmlDoc->documentElement));
Expand Down
2 changes: 1 addition & 1 deletion template_editor/js/structure.js
Expand Up @@ -262,7 +262,7 @@ function delete_from_tree(element){
* @return {string} class name for the node
*/
function get_class_type(node_name) {
if(node_name=="structure" ||node_name=="folder" ) return "tree_folder";
if(node_name=="structures" ||node_name=="folder" ) return "tree_folder";
else if(node_name=="page" ) return "tree_page";
else if(node_name=="page_templates" ) return "tree_page_templates";
else if(node_name=="tests" ) return "tree_tests";
Expand Down
24 changes: 12 additions & 12 deletions templates/structures/knowledge/content.xml
@@ -1,4 +1,4 @@
<?xml version="1.0" ?>
<?xml version="1.0"?>
<structure name="knowledge">
<page max="1" min="1" name="overview">
<page_templates>
Expand Down Expand Up @@ -26,21 +26,21 @@
<page_template name="title_image_text"/>
</page_templates>
</page>
<page max="1" min="1" name="self_assesment">
<page_templates/>
<tests>
<test name="true_or_false"/>
<test name="multiple_choise"/>
<test name="matching_graphical"/>
<test name="matching_simple"/>
</tests>
</page>
<page max="1" min="1" name="self_assesment">
<page_templates/>
<tests>
<test name="true_or_false"/>
<test name="multiple_choise"/>
<test name="matching_graphical"/>
<test name="matching_simple"/>
</tests>
</page>
<page max="1" min="0" name="forum">
<page_templates/>
<forum name="forum"/>
<forum name="forum"/>
</page>
</folder>
<page max="1" min="0" name="retrieval_for_learning">
<page max="1" min="0" name="retrieval_for_learning">
<page_templates>
<page_template name="plain_text"/>
</page_templates>
Expand Down
31 changes: 0 additions & 31 deletions templates/structures/knowledge/structure.xml

This file was deleted.

31 changes: 0 additions & 31 deletions templates/structures/meta-competency/structure.xml

This file was deleted.

0 comments on commit 3791caf

Please sign in to comment.