Minor - format code.

1.9.x
Julio Montoya 11 years ago
parent 36e541add2
commit 096199c9bc
  1. 48
      main/course_progress/thematic_controller.php
  2. 32
      main/inc/lib/export.lib.inc.php
  3. 47
      main/inc/lib/pdf.lib.php

@ -1,20 +1,20 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains class used like controller for thematic, it should be included inside a dispatcher file (e.g: index.php)
* Thematic Controller script.
* Prepares the common background variables to give to the scripts corresponding to
* the requested action
*
* This file contains class used like controller for thematic,
* it should be included inside a dispatcher file (e.g: index.php)
*
* !!! WARNING !!! : ALL DATES IN THIS MODULE ARE STORED IN UTC ! DO NOT CONVERT DURING THE TRANSITION FROM CHAMILO 1.8.x TO 2.0
* !!! WARNING !!! : ALL DATES IN THIS MODULE ARE STORED IN UTC !
* DO NOT CONVERT DURING THE TRANSITION FROM CHAMILO 1.8.x TO 2.0
*
* @author Christian Fasanando <christian1827@gmail.com>
* @author Julio Montoya <gugli100@gmail.com> token support improving UI
* @package chamilo.course_progress
*/
/**
* Thematic Controller script. Prepares the common background variables to give to the scripts corresponding to
* the requested action
*
* @package chamilo.course_progress
*/
class ThematicController
@ -171,7 +171,11 @@ class ThematicController
case 'thematic_export_pdf':
$list = $thematic->get_thematic_list();
$table = array();
$table[] = array(get_lang('Thematic'), get_lang('ThematicPlan'), get_lang('ThematicAdvance'));
$table[] = array(
get_lang('Thematic'),
get_lang('ThematicPlan'),
get_lang('ThematicAdvance')
);
foreach ($list as $theme) {
$data = $thematic->get_thematic_plan_data($theme['id']);
$plan_html = null;
@ -260,29 +264,30 @@ class ThematicController
/**
* This method is used for thematic plan control (update, insert or listing)
* @param string Action
* @param string $action
* render to thematic_plan.php
*/
public function thematic_plan($action)
{
$thematic = new Thematic();
$data = array();
$error = false;
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
if (isset($_POST['action']) && ($_POST['action'] == 'thematic_plan_add' || $_POST['action'] == 'thematic_plan_edit')) {
if (isset($_POST['title'])) {
if ($_POST['thematic_plan_token'] == $_SESSION['thematic_plan_token']) {
if (api_is_allowed_to_edit(null, true)) {
$title_list = $_REQUEST['title'];
//$description_list = $_REQUEST['desc'];
$description_list = $_REQUEST['description'];
$description_type = $_REQUEST['description_type'];
for ($i = 1; $i < count($title_list) + 1; $i++) {
$thematic->set_thematic_plan_attributes($_REQUEST['thematic_id'], $title_list[$i], $description_list[$i], $description_type[$i]);
$affected_rows = $thematic->thematic_plan_save();
$thematic->set_thematic_plan_attributes(
$_REQUEST['thematic_id'],
$title_list[$i],
$description_list[$i],
$description_type[$i]
);
$thematic->thematic_plan_save();
}
unset($_SESSION['thematic_plan_token']);
$data['message'] = 'ok';
@ -292,6 +297,7 @@ class ThematicController
$saveRedirect.= 'thematic_plan_save_message=ok';
header("Location: $saveRedirect");
exit;
}
$data['action'] = 'thematic_plan_list';
}
@ -360,8 +366,9 @@ class ThematicController
/**
* This method is used for thematic advance control (update, insert or listing)
* @param string $action
* render to thematic_advance.php
* @param string $action
*
*/
public function thematic_advance($action)
{
@ -400,7 +407,9 @@ class ThematicController
exit;
}
if (($_REQUEST['start_date_type'] == 1 && empty($_REQUEST['start_date_by_attendance'])) || (!empty($_REQUEST['duration_in_hours']) && !is_numeric($_REQUEST['duration_in_hours']))) {
if (($_REQUEST['start_date_type'] == 1 && empty($_REQUEST['start_date_by_attendance'])) ||
(!empty($_REQUEST['duration_in_hours']) && !is_numeric($_REQUEST['duration_in_hours']))
) {
if ($_REQUEST['start_date_type'] == 1 && empty($_REQUEST['start_date_by_attendance'])) {
$start_date_error = true;
$data['start_date_error'] = $start_date_error;
@ -488,5 +497,4 @@ class ThematicController
$this->view->set_template('thematic_advance');
$this->view->render();
}
}

@ -1,26 +1,18 @@
<?php
/* See license terms in /license.txt */
/**
* This is the export library for Chamilo.
* Include/require it in your code to use its functionality.
*
* Several functions below are adaptations from functions distributed by www.nexen.net
*
* @package chamilo.library
*/
/**
* Code
*/
require_once 'document.lib.php';
require_once api_get_path(LIBRARY_PATH).'pdf.lib.php';
/**
* This is the export library for Chamilo.
* Include/require it in your code to use its functionality.
* Several functions below are adaptations from functions distributed by www.nexen.net
*
* @package chamilo.library
* @package chamilo.library
*/
class Export
{
private function __construct()
{
}
@ -38,7 +30,7 @@ class Export
foreach ($data as $index => $row) {
$line = '';
if (is_array($row)) {
foreach($row as $value) {
foreach ($row as $value) {
$line .= '"'.str_replace('"', '""', $value).'";';
}
}
@ -47,6 +39,7 @@ class Export
}
@fclose($handle);
DocumentManager :: file_send_for_download($file, true, $filename.'.csv');
return false;
}
@ -130,7 +123,7 @@ class Export
* @param string Name of the root element. A root element should always be given.
* @param string Encoding in which the data is provided
*/
public static function export_table_xml ($data, $filename = 'export', $item_tagname = 'item', $wrapper_tagname = null, $encoding = null)
public static function export_table_xml($data, $filename = 'export', $item_tagname = 'item', $wrapper_tagname = null, $encoding = null)
{
if (empty($encoding)) {
$encoding = api_get_system_encoding();
@ -192,7 +185,9 @@ class Export
*/
public static function _export_complex_table_xml_helper ($data, $level = 1)
{
if (count($data)<1) { return '';}
if (count($data) < 1) {
return '';
}
$string = '';
foreach ($data as $row) {
$string .= "\n".str_repeat("\t",$level).'<'.$row['name'].'>';
@ -204,12 +199,12 @@ class Export
$string .= '</'.$row['name'].'>';
}
}
return $string;
}
/**
*
* @param array table in array format to be read with the HTML_table class
* @param array $data table to be read with the HTML_table class
*/
public static function export_table_pdf($data, $params = array())
{
@ -237,6 +232,7 @@ class Export
/**
* @param array $data
* @param array $params
*
* @return string
*/
public static function convert_array_to_html($data, $params = array())

@ -1,6 +1,12 @@
<?php
/* See license terms in /license.txt */
/*define("_MPDF_TEMP_PATH", api_get_path(SYS_ARCHIVE_PATH).'mpdf');
if (!is_dir(_MPDF_TEMP_PATH)) {
mkdir(_MPDF_TEMP_PATH, api_get_permissions_for_new_directories(), true);
}
require_once api_get_path(SYS_PATH).'vendor/mpdf/mpdf/mpdf.php';
*/
define('_MPDF_PATH', api_get_path(LIBRARY_PATH).'mpdf/');
require_once _MPDF_PATH.'mpdf.php';
@ -18,12 +24,12 @@ class PDF
/**
* Creates the mPDF object
* @param string $page_format format A4 A4-L see http://mpdf1.com/manual/index.php?tid=184&searchstring=format
* @param string $pageFormat format A4 A4-L see http://mpdf1.com/manual/index.php?tid=184&searchstring=format
* @param string $orientation orientation "P" = Portrait "L" = Landscape
* @param array $params
*/
public function __construct(
$page_format = 'A4',
$pageFormat = 'A4',
$orientation = 'P',
$params = array()
) {
@ -33,7 +39,7 @@ class PDF
if (!in_array($orientation, array('P','L'))) {
$orientation = 'P';
}
//$this->pdf = $pdf = new mPDF('UTF-8', $page_format, '', '', 30, 20, 27, 25, 16, 13, $orientation);
//$this->pdf = $pdf = new mPDF('UTF-8', $pageFormat, '', '', 30, 20, 27, 25, 16, 13, $orientation);
//left, right, top, bottom, margin_header, margin footer
$params['left'] = isset($params['left']) ? $params['left'] : 15;
@ -50,7 +56,7 @@ class PDF
$this->pdf = new mPDF(
'UTF-8',
$page_format,
$pageFormat,
'',
'',
$params['left'],
@ -66,6 +72,7 @@ class PDF
/**
* Export the given HTML to PDF, using a global template
* @param string $content the HTML content
*
* @uses export/table_pdf.tpl
*/
public function html_to_pdf_with_template($content)
@ -73,20 +80,24 @@ class PDF
global $_configuration;
Display :: display_no_header();
//Assignments
// Assignments
Display::$global_template->assign('pdf_content', $content);
$organization = api_get_setting('Institution');
$img = api_get_path(SYS_CODE_PATH).'css/'.api_get_visual_theme().'/images/header-logo.png';
// Search for classic logo
if (file_exists($img)) {
$img = api_get_path(WEB_CODE_PATH).'css/'.api_get_visual_theme().'/images/header-logo.png';
$organization = "<img src='$img'>";
} else {
// Just use the platform title.
if (!empty($organization)) {
$organization = '<h2 align="left">'.$organization.'</h2>';
}
}
// Use custom logo image.
if (isset($_configuration['pdf_logo_header']) &&
$_configuration['pdf_logo_header']
) {
@ -113,7 +124,7 @@ class PDF
Display::$global_template->assign('pdf_title', $this->params['pdf_title']);
Display::$global_template->assign('add_signatures', $this->params['add_signatures']);
//Getting template
// Getting template
$tpl = Display::$global_template->get_template('export/table_pdf.tpl');
$html = Display::$global_template->fetch($tpl);
$html = api_utf8_encode($html);
@ -125,11 +136,15 @@ class PDF
/**
* Converts HTML files to PDF
* @param mixed could be an html file path or an array with paths example:
/var/www/myfile.html or
array('/myfile.html','myotherfile.html') or even an indexed array with both 'title' and 'path' indexes
for each element like
* array(0=>array('title'=>'Hello','path'=>'file.html'),1=>array('title'=>'Bye','path'=>'file2.html'));
* @param mixed $html_file_array could be an html file path or an array
* with paths example:
* /var/www/myfile.html or array('/myfile.html','myotherfile.html') or
* even an indexed array with both 'title' and 'path' indexes
* for each element like
* array(
* 0 => array('title'=>'Hello','path'=>'file.html'),
* 1 => array('title'=>'Bye','path'=>'file2.html')
* );
* @param string pdf name
* @param string course code (if you are using html that are located in the document tool you must provide this)
* @param bool Whether to print the header, footer and watermark (true) or just the content (false)
@ -316,11 +331,11 @@ class PDF
/**
* Converts an html string to PDF
* @param string valid html
* @param string CSS content of a CSS file
* @param string pdf name
* @param string course code (if you are using html that are located in the document tool you must provide this)
* @return string Web path
* @param string $document_html valid html
* @param string $css CSS content of a CSS file
* @param string $pdf_name pdf name
* @param string $course_code course code (if you are using html that are located in the document tool you must provide this)
* @return string Web path
*/
public function content_to_pdf(
$document_html,

Loading…
Cancel
Save