Code style for Woogie - not fixed yet

1.9.x
Yannick Warnier 11 years ago
parent 3e373a87ff
commit dfb1ba063c
  1. 2
      main/newscorm/lp_upload.php
  2. 190
      main/upload/upload_word.php

@ -100,7 +100,7 @@ if( Request::is_post() && $is_error){
break;
case 'woogie':
require_once 'openoffice_text.class.php';
$split_steps = $_POST['split_steps'];
$split_steps = (empty($_POST['split_steps']) || $_POST['split_steps'] == 'per_page') ? 'per_page' : 'per_chapter';
$o_doc = new OpenofficeText($split_steps);
$first_item_id = $o_doc->convert_document($_FILES['user_file']);
break;

@ -1,7 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Action controller for the upload process. The display scripts (web forms) redirect
* Action controller for the upload process. The display scripts (web forms)
* redirect
* the process here to do what needs to be done with each file.
* @package chamilo.upload
* @author Yannick Warnier <ywarnier@beeznest.org>
@ -16,20 +17,18 @@ $language_file[] = "learnpath";
$language_file[] = "scormdocument";
// global settings initialisation
// also provides access to main api (inc/lib/main_api.lib.php)
include("../inc/global.inc.php");
require_once(api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php');
require_once(api_get_path(LIBRARY_PATH) . 'document.lib.php');
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
include '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'document.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'formvalidator/FormValidator.class.php';
$form_style= '
<style>
$form_style= '<style>
.row {
width: 200px;
width: 200px;
}
.convert_button{
background: url("../img/icons/22/learnpath.png") 0px 0px no-repeat;
padding: 2px 0px 2px 22px;
background: url("../img/icons/22/learnpath.png") 0px 0px no-repeat;
padding: 2px 0px 2px 22px;
}
#dynamic_div_container{float:left;margin-right:10px;}
#dynamic_div_waiter_container{float:left;}
@ -37,112 +36,98 @@ $form_style= '
$htmlHeadXtra[] = '<script language="javascript" src="../inc/lib/javascript/upload.js" type="text/javascript"></script>';
$htmlHeadXtra[] = '<script type="text/javascript">
var myUpload = new upload(0);
var myUpload = new upload(0);
</script>';
$htmlHeadXtra[] = $form_style;
if (api_get_setting('search_enabled')=='true')
{
$specific_fields = get_specific_field_list();
if (api_get_setting('search_enabled')=='true') {
$specific_fields = get_specific_field_list();
}
if(isset($_POST['convert'])){
$cwdir = getcwd();
if(isset($_FILES['user_file']))
{
$allowed_extensions = array('doc','docx','odt','txt','sxw','rtf');
if(in_array(strtolower(pathinfo($_FILES['user_file']['name'],PATHINFO_EXTENSION)),$allowed_extensions))
{
require('../newscorm/lp_upload.php');
if(isset($o_doc) && $first_item_id != 0){
if (isset($_POST['convert'])) {
$cwdir = getcwd();
if (isset($_FILES['user_file'])) {
$allowed_extensions = array('doc','docx','odt','txt','sxw','rtf');
if (in_array(strtolower(pathinfo($_FILES['user_file']['name'],PATHINFO_EXTENSION)),$allowed_extensions)) {
require('../newscorm/lp_upload.php');
if (isset($o_doc) && $first_item_id != 0) {
// Search-related section
if (api_get_setting('search_enabled')=='true') {
require_once(api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php');
$specific_fields = get_specific_field_list();
foreach ($specific_fields as $specific_field) {
$values = explode(',', trim($_POST[$specific_field['code']]));
if ( !empty($values) ) {
foreach ($values as $value) {
$value = trim($value);
if ( !empty($value) ) {
add_specific_field_value($specific_field['id'], api_get_course_id(), TOOL_LEARNPATH, $o_doc->lp_id, $value);
}
}
}
}
foreach ($specific_fields as $specific_field) {
$values = explode(',', trim($_POST[$specific_field['code']]));
if (!empty($values)) {
foreach ($values as $value) {
$value = trim($value);
if (!empty($value)) {
add_specific_field_value($specific_field['id'], api_get_course_id(), TOOL_LEARNPATH, $o_doc->lp_id, $value);
}
}
}
}
} //end of search-related section
header('Location: ../newscorm/lp_controller.php?'.api_get_cidreq().'&lp_id='.$o_doc->lp_id.'&action=view_item&id='.$first_item_id);
} else {
if (!empty($o_doc->error)) {
$errorMessage = $o_doc->error;
} else {
$errorMessage = get_lang('OogieUnknownError');
}
header('Location: ../newscorm/lp_controller.php?'.api_get_cidreq().'&lp_id='.$o_doc->lp_id.'&action=view_item&id='.$first_item_id);
}
else {
if(!empty($o_doc->error))
$errorMessage = $o_doc->error;
else
$errorMessage = get_lang('OogieUnknownError');
}
}
else
{
$errorMessage = get_lang('WoogieBadExtension');
}
}
}
} else {
$errorMessage = get_lang('WoogieBadExtension');
}
}
}
event_access_tool(TOOL_UPLOAD);
// check access permissions (edit permission is needed to add a document or a LP)
$is_allowed_to_edit = api_is_allowed_to_edit();
if(!$is_allowed_to_edit){
api_not_allowed(true);
if (!$is_allowed_to_edit) {
api_not_allowed(true);
}
$interbreadcrumb[]= array ("url"=>"../newscorm/lp_controller.php?action=list", "name"=> get_lang("Doc"));
$nameTools = get_lang("WoogieConversionPowerPoint");
Display :: display_header($nameTools);
?>
<img src="../img/mascot.png"><br>
<span style="color: #5577af; font-size: 16px; font-family: Arial; margin-left: 10px;"><?php echo get_lang("WelcomeWoogieSubtitle");?></span><br>
<?php
$message=get_lang("WelcomeWoogieConverter");
echo '<br>';
$s_style="border-width: 1px;
border-style: solid;
margin-left: 0;
margin-top: 10px;
margin-bottom: 0px;
min-height: 30px;
padding: 5px;
position: relative;
width: 500px;
background-color: #E5EDF9;
border-color: #4171B5;
color: #000;";
//echo '<img src="../img/mascot.png"><br />';
echo '<span style="color: #5577af; font-size: 16px; font-family: Arial; margin-left: 10px;">'.get_lang("WelcomeWoogieSubtitle").'</span><br>';
$message = get_lang("WelcomeWoogieConverter");
echo '<br />';
$s_style = "border-width: 1px;
border-style: solid;
margin-left: 0;
margin-top: 10px;
margin-bottom: 0px;
min-height: 30px;
padding: 5px;
position: relative;
width: 500px;
background-color: #E5EDF9;
border-color: #4171B5;
color: #000;";
$s_style_error="border-width: 1px;
border-style: solid;
margin-left: 0;
margin-top: 10px;
margin-bottom: 10px;
min-height: 30px;
padding: 5px;
position: relative;
width: 500px;
background-color: #FFD1D1;
border-color: #FF0000;
color: #000;";
border-style: solid;
margin-left: 0;
margin-top: 10px;
margin-bottom: 10px;
min-height: 30px;
padding: 5px;
position: relative;
width: 500px;
background-color: #FFD1D1;
border-color: #FF0000;
color: #000;";
echo '<div style="'.$s_style.'"><div style="float:left; margin-right:10px;"><img src="'.api_get_path(WEB_IMG_PATH)."message_normal.gif".'" alt="'.$alt_text.'" '.$attribute_list.' /></div><div style="margin-left: 43px">'.$message.'</div></div>';
if(!empty($errorMessage)){
echo '<div style="'.$s_style_error.'"><div style="float:left; margin-right:10px;"><img src="'.api_get_path(WEB_IMG_PATH)."message_error.gif".'" alt="'.$alt_text.'" '.$attribute_list.' /></div><div style="margin-left: 43px">'.$errorMessage.'</div></div>';
if (!empty($errorMessage)) {
echo '<div style="'.$s_style_error.'"><div style="float:left; margin-right:10px;"><img src="'.api_get_path(WEB_IMG_PATH)."message_error.gif".'" alt="'.$alt_text.'" '.$attribute_list.' /></div><div style="margin-left: 43px">'.$errorMessage.'</div></div>';
}
$form = new FormValidator('update_course', 'POST', '', '', 'style="margin: 0;"');
@ -158,8 +143,8 @@ $renderer = $form->defaultRenderer();
$user_file_template =
<<<EOT
<div class="row" style="margin-top:10px;width:100%">
<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->{label}{element}$div_upload_limit
<!-- BEGIN error --><br /><span class="form_error">{error}</span><!-- END error -->
<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->{label}{element}$div_upload_limit
<!-- BEGIN error --><br /><span class="form_error">{error}</span><!-- END error -->
</div>
EOT;
$renderer->setElementTemplate($user_file_template,'user_file');
@ -168,15 +153,14 @@ $renderer->setElementTemplate($user_file_template,'user_file');
$user_file_template =
<<<EOT
<div class="row" style="margin-top:10px;width:100%">
<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->{label}{element}
<!-- BEGIN error --><br /><span class="form_error">{error}</span><!-- END error -->
<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->{label}{element}
<!-- BEGIN error --><br /><span class="form_error">{error}</span><!-- END error -->
</div>
EOT;
$renderer->setElementTemplate($user_file_template);
$form -> addElement ('file', 'user_file','<img src="../img/word_big.gif" align="absbottom" />');
if (api_get_setting('search_enabled')=='true')
{
if (api_get_setting('search_enabled')=='true') {
$form -> addElement ('checkbox', 'index_document','', get_lang('SearchFeatureDoIndexDocument'));
$form -> addElement ('html','<br />');
$form -> addElement ('html', get_lang('SearchFeatureDocumentLanguage').': &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'. api_get_languages_combo());
@ -193,24 +177,12 @@ if (api_get_setting('search_enabled')=='true')
* $form -> addElement ('radio', 'split_steps',null, get_lang('SplitStepsPerChapter'),'per_chapter');
*/
$form -> addElement ('hidden', 'split_steps','per_page');
$form -> addElement ('submit', 'convert', get_lang('ConvertToLP'), 'class="convert_button"');
$form -> addElement ('hidden', 'woogie', 'true');
$form -> add_real_progress_bar(md5(rand(0,10000)), 'user_file', 1, true);
$defaults = array('split_steps'=>'per_page','index_document'=>'checked="checked"');
$form -> setDefaults($defaults);
// display the form
$form -> display();
/*
==============================================================================
FOOTER
==============================================================================
*/
Display::display_footer();
?>
Loading…
Cancel
Save