Minor - format code.

1.9.x
Julio Montoya 11 years ago
parent 4ddc3be3fe
commit d8c1f4b427
  1. 10
      main/coursecopy/classes/CourseRestorer.class.php
  2. 84
      main/coursecopy/classes/Document.class.php
  3. 35
      main/coursecopy/classes/Link.class.php
  4. 42
      main/coursecopy/classes/ScormDocument.class.php
  5. 69
      main/coursecopy/classes/Survey.class.php
  6. 80
      main/inc/lib/document.lib.php

@ -1280,9 +1280,16 @@ class CourseRestorer
$doc = str_replace('/audio/', '', $doc->path);
}
}
if ($id != -1) {
// check resources inside html from fckeditor tool and copy correct urls into recipient course
$quiz->description = DocumentManager::replace_urls_inside_content_html_from_copy_course($quiz->description, $this->course->code, $this->course->destination_path, $this->course->backup_path, $this->course->info['path']);
$quiz->description = DocumentManager::replace_urls_inside_content_html_from_copy_course(
$quiz->description,
$this->course->code,
$this->course->destination_path,
$this->course->backup_path,
$this->course->info['path']
);
global $_custom;
if (isset($_custom['exercises_clean_dates_when_restoring']) && $_custom['exercises_clean_dates_when_restoring']) {
@ -1505,6 +1512,7 @@ class CourseRestorer
)
)
);
foreach ($new_answers as $answer_item) {
$params = array();
$params['correct'] = $old_option_ids[$answer_item['correct']];

@ -1,58 +1,54 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Document class file
* @package chamilo.backup
*/
/**
* Code
*/
require_once 'Resource.class.php';
define('DOCUMENT','file');
define('FOLDER','folder');
/**
* An document
* Class Document
* @author Bart Mollet <bart.mollet@hogent.be>
* @package chamilo.backup
*/
class Document extends Resource
{
var $path;
var $comment;
var $file_type;
var $size;
var $title;
/**
* Create a new Document
* @param int $id
* @param string $path
* @param string $comment
* @param string $title
* @param string $file_type (DOCUMENT or FOLDER);
* @param int $size
*/
function Document($id,$path,$comment,$title,$file_type,$size)
{
parent::Resource($id,RESOURCE_DOCUMENT);
$this->path = 'document'.$path;
$this->comment = $comment;
$this->title = $title;
$this->file_type = $file_type;
$this->size = $size;
}
/**
* Show this document
*/
function show()
{
parent::show();
echo preg_replace('@^document@', '', $this->path);
if (!empty($this->title)) {
if (strpos($this->path, $this->title) === false) {
echo " - ".$this->title;
}
}
}
public $path;
public $comment;
public $file_type;
public $size;
public $title;
/**
* Create a new Document
* @param int $id
* @param string $path
* @param string $comment
* @param string $title
* @param string $file_type (DOCUMENT or FOLDER);
* @param int $size
*/
public function Document($id, $path, $comment, $title, $file_type, $size)
{
parent::Resource($id, RESOURCE_DOCUMENT);
$this->path = 'document' . $path;
$this->comment = $comment;
$this->title = $title;
$this->file_type = $file_type;
$this->size = $size;
}
/**
* Show this document
*/
public function show()
{
parent::show();
echo preg_replace('@^document@', '', $this->path);
if (!empty($this->title)) {
if (strpos($this->path, $this->title) === false) {
echo " - " . $this->title;
}
}
}
}

@ -1,15 +1,10 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Link backup script
* @package chamilo.backup
*/
/**
* Code
*/
require_once 'Resource.class.php';
/**
* Class Link
* A WWW-link from the Links-module in a Chamilo-course.
* @author Bart Mollet <bart.mollet@hogent.be>
* @package chamilo.backup
@ -19,23 +14,23 @@ class Link extends Resource
/**
* The title
*/
var $title;
public $title;
/**
* The URL
*/
var $url;
public $url;
/**
* The description
*/
var $description;
public $description;
/**
* Id of this links category
*/
var $category_id;
public $category_id;
/**
* Display link on course homepage
*/
var $on_homepage;
public $on_homepage;
/**
* Create a new Link
* @param int $id The id of this link in the Chamilo-course
@ -43,7 +38,14 @@ class Link extends Resource
* @param string $url
* @param string $description
*/
function Link($id,$title,$url,$description,$category_id,$on_homepage)
public function Link(
$id,
$title,
$url,
$description,
$category_id,
$on_homepage
)
{
parent::Resource($id,RESOURCE_LINK);
$this->title = $title;
@ -52,12 +54,13 @@ class Link extends Resource
$this->category_id = $category_id;
$this->on_homepage = $on_homepage;
}
/**
/**
* Show this resource
*/
function show()
public function show()
{
parent::show();
echo $this->title.' ('.$this->url.')';
}
}
}

@ -1,12 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* SCORM document backup script
* @package chamilo.backup
*/
/**
* Code
*/
require_once 'Resource.class.php';
/**
* ScormDocument class
@ -15,8 +9,8 @@ require_once 'Resource.class.php';
*/
class ScormDocument extends Resource
{
var $path;
var $title;
public $path;
public $title;
/**
* Create a new Scorm Document
@ -24,25 +18,25 @@ class ScormDocument extends Resource
* @param string $path
* @param string $title
*/
function ScormDocument($id,$path,$title)
public function ScormDocument($id, $path, $title)
{
parent::Resource($id,RESOURCE_SCORM);
$this->path = 'scorm'.$path;
$this->title = $title;
}
/**
* Show this document
*/
function show()
{
parent::show();
$path = preg_replace('@^scorm/@', '', $this->path);
echo $path;
if (!empty($this->title)) {
if (strpos($path, $this->title) === false) {
echo " - ".$this->title;
}
}
}
/**
* Show this document
*/
public function show()
{
parent::show();
$path = preg_replace('@^scorm/@', '', $this->path);
echo $path;
if (!empty($this->title)) {
if (strpos($path, $this->title) === false) {
echo " - " . $this->title;
}
}
}
}

@ -1,13 +1,9 @@
<?php
/* For licensing terms, see /license.txt */
require_once 'Resource.class.php';
/**
* Surveys backup script
* @package chamilo.backup
*/
/**
* A survey
* Survey
* @author Yannick Warnier <yannick.warnier@beeznest.com>
* @package chamilo.backup
*/
@ -16,63 +12,64 @@ class Survey extends Resource
/**
* The survey code
*/
var $code;
public $code;
/**
* The title and subtitle
*/
var $title;
var $subtitle;
public $title;
public $subtitle;
/**
* The author's name
*/
var $author;
public $author;
/**
* The survey's language
*/
var $lang;
public $lang;
/**
* The availability period
*/
var $avail_from;
var $avail_till;
public $avail_from;
public $avail_till;
/**
* Flag for shared status
*/
var $is_shared;
public $is_shared;
/**
* Template used
*/
var $template;
public $template;
/**
* Introduction text
*/
var $intro;
public $intro;
/**
* Thanks text
*/
var $surveythanks;
public $surveythanks;
/**
* Creation date
*/
var $creation_date;
public $creation_date;
/**
* Invitation status
*/
var $invited;
public $invited;
/**
* Answer status
*/
var $answered;
public $answered;
/**
* Invitation and reminder mail contents
*/
var $invite_mail;
var $reminder_mail;
public $invite_mail;
public $reminder_mail;
/**
* Questions and invitations lists
*/
var $question_ids;
var $invitation_ids;
public $question_ids;
public $invitation_ids;
/**
* Create a new Survey
* @param string $code
@ -92,11 +89,25 @@ class Survey extends Resource
* @param string $invite_mail
* @param string $reminder_mail
*/
function Survey($id,$code,$title,$subtitle,
$author,$lang,$avail_from,$avail_till,
$is_shared, $template,$intro,$surveythanks,
$creation_date,$invited,$answered,$invite_mail,$reminder_mail)
{
public function Survey(
$id,
$code,
$title,
$subtitle,
$author,
$lang,
$avail_from,
$avail_till,
$is_shared,
$template,
$intro,
$surveythanks,
$creation_date,
$invited,
$answered,
$invite_mail,
$reminder_mail
) {
parent::Resource($id,RESOURCE_SURVEY);
$this->code = $code;
$this->title = $title;
@ -139,4 +150,4 @@ class Survey extends Resource
parent::show();
echo $this->code.' - '.$this->title;
}
}
}

@ -2,6 +2,7 @@
/* For licensing terms, see /license.txt */
/**
* Class DocumentManager
* This is the document library for Chamilo.
* It is / will be used to provide a service layer to all document-using tools.
* and eliminate code duplication fro group documents, scorm documents, main documents.
@ -9,10 +10,6 @@
*
* @package chamilo.library
*/
/**
* Code
*/
class DocumentManager
{
private function __construct()
@ -2234,15 +2231,18 @@ class DocumentManager
}
}
}
return $attributes;
}
/**
* Replace urls inside content html from a copy course
* @param string content html
* @param string origin course code
* @param string destination course directory
* @param string
* @param string $content_html
* @param string $origin_course_code
* @param string $destination_course_directory
* @param string $origin_course_path_from_zip
* @param string $origin_course_info_path
*
* @return string new content html with replaced urls or return false if content is not a string
*/
static function replace_urls_inside_content_html_from_copy_course(
@ -2260,7 +2260,8 @@ class DocumentManager
$orig_source_html = DocumentManager::get_resources_from_source_html($content_html);
$orig_course_info = api_get_course_info($origin_course_code);
//Course does not exist in the current DB probably this cames from a zip file?
// Course does not exist in the current DB probably this came from a zip file?
if (empty($orig_course_info)) {
if (!empty($origin_course_path_from_zip)) {
$orig_course_path = $origin_course_path_from_zip.'/';
@ -2274,15 +2275,19 @@ class DocumentManager
$destination_course_code = CourseManager::get_course_id_from_path($destination_course_directory);
$destination_course_info = api_get_course_info($destination_course_code);
$dest_course_path = api_get_path(SYS_COURSE_PATH) . $destination_course_directory . '/';
$dest_course_path_rel = api_get_path(
REL_COURSE_PATH
) . $destination_course_directory . '/';
$user_id = api_get_user_id();
if (!empty($orig_source_html)) {
foreach ($orig_source_html as $source) {
// get information about source url
// Get information about source url
$real_orig_url = $source[0]; // url
$scope_url = $source[1]; // scope (local, remote)
$type_url = $source[2]; // tyle (rel, abs, url)
$type_url = $source[2]; // type (rel, abs, url)
// Get path and query from origin url
$orig_parse_url = parse_url($real_orig_url);
@ -2307,6 +2312,8 @@ class DocumentManager
$origin_filepath = $orig_course_path.$document_file;
$destination_filepath = $dest_course_path.$document_file;
//var_dump($origin_filepath, $destination_filepath);
// copy origin file inside destination course
if (file_exists($origin_filepath)) {
$filepath_dir = dirname($destination_filepath);
@ -2318,8 +2325,24 @@ class DocumentManager
$filepath_to_add = str_replace(array($dest_course_path, 'document'), '', $filepath_dir);
//Add to item properties to the new folder
$doc_id = add_document($destination_course_info, $filepath_to_add, 'folder', 0, basename($filepath_to_add));
api_item_property_update($destination_course_info, TOOL_DOCUMENT, $doc_id, 'FolderCreated', $user_id, null, null, null, null);
$doc_id = add_document(
$destination_course_info,
$filepath_to_add,
'folder',
0,
basename($filepath_to_add)
);
api_item_property_update(
$destination_course_info,
TOOL_DOCUMENT,
$doc_id,
'FolderCreated',
$user_id,
null,
null,
null,
null
);
}
}
@ -2329,20 +2352,36 @@ class DocumentManager
$filepath_to_add = str_replace(array($dest_course_path, 'document'), '', $destination_filepath);
$size = filesize($destination_filepath);
//Add to item properties to the file
$doc_id = add_document($destination_course_info, $filepath_to_add, 'file', $size, basename($filepath_to_add));
api_item_property_update($destination_course_info, TOOL_DOCUMENT, $doc_id, 'FolderCreated', $user_id, null, null, null, null);
// Add to item properties to the file
$doc_id = add_document(
$destination_course_info,
$filepath_to_add,
'file',
$size,
basename($filepath_to_add)
);
api_item_property_update(
$destination_course_info,
TOOL_DOCUMENT,
$doc_id,
'FolderCreated',
$user_id,
null,
null,
null,
null
);
}
}
}
// Replace origin course path by destination course path
// Replace origin course path by destination course path.
if (strpos($content_html, $real_orig_url) !== false) {
//$origin_course_code
$url_course_path = str_replace($orig_course_info_path.'/'.$document_file, '', $real_orig_path);
//var_dump($dest_course_path_rel);
$destination_url = $url_course_path . $destination_course_directory . '/' . $document_file . $dest_url_query;
//If the course code doesn't exist in the path? what we do? Nothing! see BT#1985
// If the course code doesn't exist in the path? what we do? Nothing! see BT#1985
if (strpos($real_orig_path, $origin_course_code) === false) {
$url_course_path = $real_orig_path;
$destination_url = $real_orig_path;
@ -2356,9 +2395,6 @@ class DocumentManager
$dest_url = str_replace($origin_course_code, $destination_course_code, $real_orig_url);
$content_html = str_replace($real_orig_url, $dest_url, $content_html);
}
} else {
if ($type_url == 'url') {
}
}
}
}

Loading…
Cancel
Save