当前位置: 首页>>代码示例>>PHP>>正文


PHP api_get_course_path函数代码示例

本文整理汇总了PHP中api_get_course_path函数的典型用法代码示例。如果您正苦于以下问题:PHP api_get_course_path函数的具体用法?PHP api_get_course_path怎么用?PHP api_get_course_path使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了api_get_course_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: imsExportResponses

 /**
  * TODO update this to match hotspots instead of copying matching
  * Export the question part as a matrix-choice, with only one possible answer per line.
  */
 function imsExportResponses($questionIdent, $questionStatment, $questionDesc = '', $questionMedia = '')
 {
     global $charset;
     $this->answerList = $this->getAnswersList(true);
     $questionMedia = api_get_path(WEB_COURSE_PATH) . api_get_course_path() . '/document/images/' . $questionMedia;
     $mimetype = mime_content_type($questionMedia);
     if (empty($mimetype)) {
         $mimetype = 'image/jpeg';
     }
     $text = '      <p>' . $questionStatment . '</p>' . "\n";
     $text .= '      <graphicOrderInteraction responseIdentifier="hotspot_' . $questionIdent . '">' . "\n";
     $text .= '        <prompt>' . $questionDesc . '</prompt>' . "\n";
     $text .= '        <object type="' . $mimetype . '" width="250" height="230" data="' . $questionMedia . '">-</object>' . "\n";
     if (is_array($this->answerList)) {
         foreach ($this->answerList as $key => $answer) {
             $key = $answer['id'];
             $answerTxt = $answer['answer'];
             $len = api_strlen($answerTxt);
             //coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663
             $coords = '';
             $type = 'default';
             switch ($answer['hotspot_type']) {
                 case 'square':
                     $type = 'rect';
                     $res = array();
                     $coords = preg_match('/^\\s*(\\d+);(\\d+)\\|(\\d+)\\|(\\d+)\\s*$/', $answer['hotspot_coord'], $res);
                     $coords = $res[1] . ',' . $res[2] . ',' . ((int) $res[1] + (int) $res[3]) . "," . ((int) $res[2] + (int) $res[4]);
                     break;
                 case 'circle':
                     $type = 'circle';
                     $res = array();
                     $coords = preg_match('/^\\s*(\\d+);(\\d+)\\|(\\d+)\\|(\\d+)\\s*$/', $answer['hotspot_coord'], $res);
                     $coords = $res[1] . ',' . $res[2] . ',' . sqrt(pow($res[1] - $res[3], 2) + pow($res[2] - $res[4]));
                     break;
                 case 'poly':
                     $type = 'poly';
                     $coords = str_replace(array(';', '|'), array(',', ','), $answer['hotspot_coord']);
                     break;
                 case 'delineation':
                     $type = 'delineation';
                     $coords = str_replace(array(';', '|'), array(',', ','), $answer['hotspot_coord']);
                     break;
             }
             $text .= '        <hotspotChoice shape="' . $type . '" coords="' . $coords . '" identifier="' . $key . '"/>' . "\n";
         }
     }
     $text .= '      </graphicOrderInteraction>' . "\n";
     $out = $text;
     return $out;
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:54,代码来源:qti2_classes.php

示例2: upload_image

 /**
  * Uploads an author image to the upload/learning_path/images directory
  * @param	array	The image array, coming from the $_FILES superglobal
  * @return	boolean	True on success, false on error
  */
 function upload_image($image_array)
 {
     $image_moved = false;
     if (!empty($image_array['name'])) {
         $upload_ok = process_uploaded_file($image_array);
         $has_attachment = true;
     } else {
         $image_moved = true;
     }
     if ($upload_ok) {
         if ($has_attachment) {
             $courseDir = api_get_course_path() . '/upload/learning_path/images';
             $sys_course_path = api_get_path(SYS_COURSE_PATH);
             $updir = $sys_course_path . $courseDir;
             // Try to add an extension to the file if it hasn't one
             $new_file_name = add_ext_on_mime(stripslashes($image_array['name']), $image_array['type']);
             if (!filter_extension($new_file_name)) {
                 //Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
                 $image_moved = false;
             } else {
                 $file_extension = explode('.', $image_array['name']);
                 $file_extension = strtolower($file_extension[sizeof($file_extension) - 1]);
                 $new_file_name = uniqid('') . '.' . $file_extension;
                 $new_path = $updir . '/' . $new_file_name;
                 //$result= @move_uploaded_file($image_array['tmp_name'], $new_path);
                 // resize the image
                 include_once api_get_path(LIBRARY_PATH) . 'image.lib.php';
                 $temp = new image($image_array['tmp_name']);
                 $picture_infos = @getimagesize($image_array['tmp_name']);
                 // $picture_infos[0]-> width
                 if ($picture_infos[0] > 104) {
                     $thumbwidth = 104;
                 } else {
                     $thumbwidth = $picture_infos[0];
                 }
                 if ($picture_infos[1] > 96) {
                     $new_height = 96;
                 } else {
                     $new_height = $picture_infos[1];
                 }
                 //$new_height = round(($thumbwidth/$picture_infos[0])*$picture_infos[1]);
                 $temp->resize($thumbwidth, $new_height, 0);
                 $type = $picture_infos[2];
                 $result = false;
                 switch ($type) {
                     case 2:
                         $result = $temp->send_image('JPG', $new_path);
                         break;
                     case 3:
                         $result = $temp->send_image('PNG', $new_path);
                         break;
                     case 1:
                         $result = $temp->send_image('GIF', $new_path);
                         break;
                 }
                 $temp->resize($thumbwidth, $new_height, 0);
                 $type = $picture_infos[2];
                 $result = false;
                 switch ($type) {
                     case 2:
                         $result = $temp->send_image('JPG', $new_path);
                         break;
                     case 3:
                         $result = $temp->send_image('PNG', $new_path);
                         break;
                     case 1:
                         $result = $temp->send_image('GIF', $new_path);
                         break;
                 }
                 // Storing the image filename
                 if ($result) {
                     $image_moved = true;
                     $this->set_preview_image($new_file_name);
                     return true;
                 }
             }
         }
     }
     return false;
 }
开发者ID:Eidn,项目名称:shanghai,代码行数:85,代码来源:learnpath.class.php

示例3: display_type_menu

 /**
  * Displays the menu of question types
  * @param Exercise $objExercise
  */
 public static function display_type_menu(Exercise $objExercise)
 {
     $feedback_type = $objExercise->feedback_type;
     $exerciseId = $objExercise->id;
     // 1. by default we show all the question types
     $question_type_custom_list = self::get_question_type_list();
     if (!isset($feedback_type)) {
         $feedback_type = 0;
     }
     if ($feedback_type == 1) {
         //2. but if it is a feedback DIRECT we only show the UNIQUE_ANSWER type that is currently available
         $question_type_custom_list = array(UNIQUE_ANSWER => self::$questionTypes[UNIQUE_ANSWER], HOT_SPOT_DELINEATION => self::$questionTypes[HOT_SPOT_DELINEATION]);
     } else {
         unset($question_type_custom_list[HOT_SPOT_DELINEATION]);
     }
     echo '<div class="actionsbig">';
     echo '<ul class="question_menu">';
     $modelType = $objExercise->getModelType();
     foreach ($question_type_custom_list as $i => $a_type) {
         if ($modelType == EXERCISE_MODEL_TYPE_COMMITTEE) {
             if ($a_type[1] != 'FreeAnswer') {
                 continue;
             }
         }
         // include the class of the type
         require_once $a_type[0];
         // get the picture of the type and the langvar which describes it
         $img = $explanation = '';
         eval('$img = ' . $a_type[1] . '::$typePicture;');
         eval('$explanation = get_lang(' . $a_type[1] . '::$explanationLangVar);');
         echo '<li>';
         echo '<div class="icon_image_content">';
         if ($objExercise->exercise_was_added_in_lp == true) {
             $img = pathinfo($img);
             $img = $img['filename'] . '_na.' . $img['extension'];
             echo Display::return_icon($img, $explanation, array(), ICON_SIZE_BIG);
         } else {
             echo '<a href="admin.php?' . api_get_cidreq() . '&newQuestion=yes&answerType=' . $i . '&exerciseId=' . $exerciseId . '">' . Display::return_icon($img, $explanation, array(), ICON_SIZE_BIG) . '</a>';
         }
         echo '</div>';
         echo '</li>';
     }
     echo '<li>';
     echo '<div class="icon_image_content">';
     if ($objExercise->exercise_was_added_in_lp == true) {
         echo Display::return_icon('database_na.png', get_lang('GetExistingQuestion'));
     } else {
         if ($feedback_type == 1) {
             //echo $url = '<a href="question_pool.php?'.api_get_cidreq().'&type=1&fromExercise='.$exerciseId.'">';
         } else {
             //echo $url = '<a href="question_pool.php?'.api_get_cidreq().'&fromExercise='.$exerciseId.'">';
         }
         echo $url = '<a href="' . api_get_path(WEB_PUBLIC_PATH) . 'courses/' . api_get_course_path() . '/' . api_get_session_id() . '/exercise/' . $exerciseId . '/question-pool">';
         echo Display::return_icon('database.png', get_lang('GetExistingQuestion'));
     }
     echo '</a>';
     echo '</div></li>';
     echo '</ul>';
     echo '</div>';
 }
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:64,代码来源:question.class.php

示例4: api_get_path

     // Add introduction section page.
     break;
 case 'js_api_refresh':
     if ($debug > 0) error_log('New LP - js_api_refresh action triggered', 0);
     if (!$lp_found) { error_log('New LP - No learnpath given for js_api_refresh', 0); require 'lp_message.php'; }
     if (isset($_REQUEST['item_id'])) {
         $htmlHeadXtra[] = $_SESSION['oLP']->get_js_info($_REQUEST['item_id']);
     }
     require 'lp_message.php';
     break;
 case 'return_to_course_homepage':
     if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; }
     else {
         $_SESSION['oLP']->save_current();
         $_SESSION['oLP']->save_last();
         $url = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/index.php?id_session='.api_get_session_id();
         if (isset($_GET['redirectTo']) && $_GET['redirectTo'] == 'lp_list') {
             $url = 'lp_controller.php?'.api_get_cidreq();
         }
         header('location: '.$url);
         exit;
     }
     break;
 case 'search':
     /* Include the search script, it's smart enough to know when we are
      * searching or not.
      */
     require 'lp_list_search.php';
     break;
 case 'impress':
     if ($debug > 0)
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:lp_controller.php

示例5: error_log

         error_log('New LP - No learnpath given for js_api_refresh', 0);
         require 'lp_message.php';
     }
     if (isset($_REQUEST['item_id'])) {
         $htmlHeadXtra[] = $_SESSION['oLP']->get_js_info($_REQUEST['item_id']);
     }
     require 'lp_message.php';
     break;
 case 'return_to_course_homepage':
     if (!$lp_found) {
         error_log('New LP - No learnpath given for stats', 0);
         require 'lp_list.php';
     } else {
         $_SESSION['oLP']->save_current();
         $_SESSION['oLP']->save_last();
         header('location: ' . api_get_path(WEB_COURSE_PATH) . api_get_course_path() . '/index.php?id_session=' . api_get_session_id());
         exit;
     }
     break;
 case 'search':
     /* Include the search script, it's smart enough to know when we are
      * searching or not.
      */
     require 'lp_list_search.php';
     break;
 case 'impress':
     if ($debug > 0) {
         error_log('New LP - view action triggered', 0);
     }
     if (!$lp_found) {
         error_log('New LP - No learnpath given for view', 0);
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:lp_controller.php

示例6: import_package

 /**
  * Imports a zip file (presumably AICC) into the Dokeos structure
  * @param	string	Zip file info as given by $_FILES['userFile']
  * @return	string	Absolute path to the AICC config files directory or empty string on error
  */
 function import_package($zip_file_info, $current_dir = '')
 {
     if ($this->debug > 0) {
         error_log('In aicc::import_package(' . print_r($zip_file_info, true) . ',"' . $current_dir . '") method', 0);
     }
     //ini_set('error_log','E_ALL');
     $maxFilledSpace = 1000000000;
     $zip_file_path = $zip_file_info['tmp_name'];
     $zip_file_name = $zip_file_info['name'];
     if ($this->debug > 0) {
         error_log('New LP - aicc::import_package() - Zip file path = ' . $zip_file_path . ', zip file name = ' . $zip_file_name, 0);
     }
     $course_rel_dir = api_get_course_path() . '/scorm';
     //scorm dir web path starting from /courses
     $course_sys_dir = api_get_path(SYS_COURSE_PATH) . $course_rel_dir;
     //absolute system path for this course
     $current_dir = replace_dangerous_char(trim($current_dir), 'strict');
     //current dir we are in, inside scorm/
     if ($this->debug > 0) {
         error_log('New LP - aicc::import_package() - Current_dir = ' . $current_dir, 0);
     }
     //$uploaded_filename = $_FILES['userFile']['name'];
     //get name of the zip file without the extension
     if ($this->debug > 0) {
         error_log('New LP - aicc::import_package() - Received zip file name: ' . $zip_file_path, 0);
     }
     $file_info = pathinfo($zip_file_name);
     $filename = $file_info['basename'];
     $extension = $file_info['extension'];
     $file_base_name = str_replace('.' . $extension, '', $filename);
     //filename without its extension
     $this->zipname = $file_base_name;
     //save for later in case we don't have a title
     if ($this->debug > 0) {
         error_log('New LP - aicc::import_package() - Base file name is : ' . $file_base_name, 0);
     }
     $new_dir = replace_dangerous_char(trim($file_base_name), 'strict');
     $this->subdir = $new_dir;
     if ($this->debug > 0) {
         error_log('New LP - aicc::import_package() - Subdir is first set to : ' . $this->subdir, 0);
     }
     /*
     		if( check_name_exist($course_sys_dir.$current_dir."/".$new_dir) )
     		{
     			$dialogBox = get_lang('FileExists');
     			$stopping_error = true;
     		}
     */
     $zipFile = new pclZip($zip_file_path);
     // Check the zip content (real size and file extension)
     $zipContentArray = $zipFile->listContent();
     $package_type = '';
     //the type of the package. Should be 'aicc' after the next few lines
     $package = '';
     //the basename of the config files (if 'courses.crs' => 'courses')
     $at_root = false;
     //check if the config files are at zip root
     $config_dir = '';
     //the directory in which the config files are. May remain empty
     $files_found = array();
     $subdir_isset = false;
     //the following loop should be stopped as soon as we found the right config files (.crs, .au, .des and .cst)
     foreach ($zipContentArray as $thisContent) {
         if (preg_match('~.(php.*|phtml)$~i', $thisContent['filename'])) {
             //if a php file is found, do not authorize (security risk)
             if ($this->debug > 1) {
                 error_log('New LP - aicc::import_package() - Found unauthorized file: ' . $thisContent['filename'], 0);
             }
             return api_failure::set_failure('php_file_in_zip_file');
         } elseif (preg_match('?.*/aicc/$?', $thisContent['filename'])) {
             //if a directory named 'aicc' is found, package type = aicc, but continue
             //because we need to find the right AICC files
             if ($this->debug > 1) {
                 error_log('New LP - aicc::import_package() - Found aicc directory: ' . $thisContent['filename'], 0);
             }
             $package_type = 'aicc';
         } else {
             //else, look for one of the files we're searching for (something.crs case insensitive)
             $res = array();
             if (preg_match('?^(.*)\\.(crs|au|des|cst|ore|pre|cmp)$?i', $thisContent['filename'], $res)) {
                 if ($this->debug > 1) {
                     error_log('New LP - aicc::import_package() - Found AICC config file: ' . $thisContent['filename'] . '. Now splitting: ' . $res[1] . ' and ' . $res[2], 0);
                 }
                 if ($thisContent['filename'] == basename($thisContent['filename'])) {
                     if ($this->debug > 2) {
                         error_log('New LP - aicc::import_package() - ' . $thisContent['filename'] . ' is at root level', 0);
                     }
                     $at_root = true;
                     if (!is_array($files_found[$res[1]])) {
                         $files_found[$res[1]] = $this->config_exts;
                         //initialise list of expected extensions (defined in class definition)
                     }
                     $files_found[$res[1]][strtolower($res[2])] = $thisContent['filename'];
                     $subdir_isset = true;
                 } else {
//.........这里部分代码省略.........
开发者ID:Eidn,项目名称:shanghai,代码行数:101,代码来源:aicc.class.php

示例7: api_get_course_id

$document_data = DocumentManager::get_document_data_by_id($_GET['id'], api_get_course_id(), true);
if (empty($document_data)) {
    if (api_is_in_group()) {
        $group_properties = GroupManager::get_group_properties(api_get_group_id());
        $document_id = DocumentManager::get_document_id(api_get_course_info(), $group_properties['directory']);
        $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id());
    }
}
$document_id = $document_data['id'];
$dir = $document_data['path'];
//make some vars
$wamidir = $dir;
if ($wamidir == "/") {
    $wamidir = "";
}
$wamiurlplay = api_get_path(WEB_COURSE_PATH) . api_get_course_path() . '/document' . $wamidir . "/";
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
// Please, do not modify this dirname formatting
if (strstr($dir, '..')) {
    $dir = '/';
}
if ($dir[0] == '.') {
    $dir = substr($dir, 1);
}
if ($dir[0] != '/') {
    $dir = '/' . $dir;
}
if ($dir[strlen($dir) - 1] != '/') {
    $dir .= '/';
}
$filepath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document' . $dir;
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:31,代码来源:record_audio_wami.php

示例8: getCustomWebIconPath

 /**
  * @return string
  */
 public static function getCustomWebIconPath()
 {
     // Check if directory exists or create it if it doesn't
     $dir = api_get_path(WEB_COURSE_PATH) . api_get_course_path() . '/upload/course_home_icons/';
     return $dir;
 }
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:9,代码来源:course_home.lib.php

示例9: api_get_system_encoding

<?php

/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
/* @todo move this file in the inc/ajax/ folder */
/**
 * Glossary ajax request code
 * @package chamilo.glossary
 */
/**
 * Search a term and return description from a glossary.
 */
$charset = api_get_system_encoding();
//replace image path
$path_image = api_get_path(WEB_COURSE_PATH) . api_get_course_path();
$path_image_search = '../../courses/' . api_get_course_path();
if (isset($_POST['glossary_id']) && $_POST['glossary_id'] == strval(intval($_POST['glossary_id']))) {
    $glossary_id = Security::remove_XSS($_POST['glossary_id']);
    $glossary_description_by_id = GlossaryManager::get_glossary_term_by_glossary_id($glossary_id);
    $glossary_description_by_id = str_replace($path_image_search, $path_image, $glossary_description_by_id);
    echo api_xml_http_response_encode($glossary_description_by_id);
} elseif (isset($_POST['glossary_data']) && $_POST['glossary_data'] == 'true') {
    //get_glossary_terms
    $glossary_data = GlossaryManager::get_glossary_terms();
    $glossary_all_data = array();
    if (count($glossary_data) > 0) {
        foreach ($glossary_data as $glossary_index => $glossary_value) {
            $glossary_all_data[] = $glossary_value['id'] . '__|__|' . $glossary_value['name'];
        }
        $glossary_all_data = implode('[|.|_|.|-|.|]', $glossary_all_data);
        echo api_xml_http_response_encode($glossary_all_data);
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:31,代码来源:glossary_ajax_request.php

示例10: getimagesize

                            'target' => '_self',
                            'onclick' => 'javascript: window.parent.API.save_asset();'
                        )
                    );


    echo '</div>';
?>
        <!-- end header -->

        <!-- Author image preview -->
        <div id="author_image">
            <div id="author_icon">
                <?php
                if ($_SESSION['oLP']->get_preview_image() != '') {
                    $picture = getimagesize(api_get_path(SYS_COURSE_PATH).api_get_course_path().'/upload/learning_path/images/'.$_SESSION['oLP']->get_preview_image());
                    $style = null;
                    if ($picture['1'] < 96) {
                        $style = ' style="padding-top:'.((94 -$picture['1'])/2).'px;" ';
                    }
                    $size = ($picture['0'] > 104 && $picture['1'] > 96 )? ' width="104" height="96" ': $style;
                    $my_path = $_SESSION['oLP']->get_preview_image_path();
                    echo '<img src="'.$my_path.'">';
                } else {
                    echo Display :: display_icon('unknown_250_100.jpg');
                }
                ?>
            </div>
            <div id="lp_navigation_elem">
                <?php echo $navigation_bar; ?>
                <div id="progress_bar">
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:31,代码来源:lp_view.php

示例11: api_get_cidreq

    $hp_count = Database::num_rows($res);
}
$total = $total_exercises + $hp_count;
if ($is_allowedToEdit && $origin != 'learnpath') {
    echo '<a href="exercise_admin.php?' . api_get_cidreq() . '">' . Display::return_icon('new_exercice.png', get_lang('NewEx'), '', ICON_SIZE_MEDIUM) . '</a>';
    echo '<a href="question_create.php?' . api_get_cidreq() . '">' . Display::return_icon('new_question.png', get_lang('AddQ'), '', ICON_SIZE_MEDIUM) . '</a>';
    // Question category
    echo '<a href="tests_category.php">';
    echo Display::return_icon('question_category_show.gif', get_lang('QuestionCategory'));
    echo '</a>';
    if (api_is_platform_admin()) {
        echo '<a href="tests_category.php?type=global">';
        echo Display::return_icon('folder_global_category.png', get_lang('QuestionGlobalCategory'), array(), ICON_SIZE_MEDIUM);
        echo '</a>';
    }
    echo '<a href="' . api_get_path(WEB_PUBLIC_PATH) . 'courses/' . api_get_course_path() . '/' . api_get_session_id() . '/exercise/question-pool">';
    echo Display::return_icon('database.png', get_lang('QuestionPool'), array('style' => 'width:32px'));
    echo '</a>';
    echo '<a href="media.php?' . api_get_cidreq() . '">';
    echo Display::return_icon('media.png', get_lang('Media'), array(), ICON_SIZE_MEDIUM);
    echo '</a>';
    // end question category
    echo '<a href="hotpotatoes.php?' . api_get_cidreq() . '">' . Display::return_icon('import_hotpotatoes.png', get_lang('ImportHotPotatoesQuiz'), '', ICON_SIZE_MEDIUM) . '</a>';
    // link to import qti2 ...
    echo '<a href="qti2.php?' . api_get_cidreq() . '">' . Display::return_icon('import_qti2.png', get_lang('ImportQtiQuiz'), '', ICON_SIZE_MEDIUM) . '</a>';
    echo '<a href="upload_exercise.php?' . api_get_cidreq() . '">' . Display::return_icon('import_excel.png', get_lang('ImportExcelQuiz'), '', ICON_SIZE_MEDIUM) . '</a>';
}
if ($is_allowedToEdit) {
    echo '</div>';
    // closing the actions div
    echo '<div id="message"></div>';
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:exercice.php

示例12: api_get_path

}
$full_file_name = api_get_path(SYS_COURSE_PATH) . api_get_course_path() . '/upload/announcements/' . $doc_url;
//if the rewrite rule asks for a directory, we redirect to the document explorer
if (is_dir($full_file_name)) {
    //remove last slash if present
    //$doc_url = ($doc_url{strlen($doc_url)-1}=='/')?substr($doc_url,0,strlen($doc_url)-1):$doc_url;
    //mod_rewrite can change /some/path/ to /some/path// in some cases, so clean them all off (René)
    while ($doc_url[$dul = strlen($doc_url) - 1] == '/') {
        $doc_url = substr($doc_url, 0, $dul);
    }
    //create the path
    $document_explorer = api_get_path(WEB_COURSE_PATH) . api_get_course_path();
    // home course path
    //redirect
    header('Location: ' . $document_explorer);
}
$tbl_announcement_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT);
// launch event
Event::event_download($doc_url);
$course_id = api_get_course_int_id();
$doc_url = Database::escape_string($doc_url);
$sql = "SELECT filename FROM {$tbl_announcement_attachment}\n  \t  \tWHERE c_id = {$course_id} AND path LIKE BINARY '{$doc_url}'";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
    $row = Database::fetch_array($result);
    $title = str_replace(' ', '_', $row['filename']);
    if (Security::check_abs_path($full_file_name, api_get_path(SYS_COURSE_PATH) . api_get_course_path() . '/upload/announcements/')) {
        DocumentManager::file_send_for_download($full_file_name, true, $title);
    }
}
exit;
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:31,代码来源:download.php

示例13: getFileContents

/**
 * Get the file contents for an assigment
 * @param int $id
 * @param array $course_info
 * @param int Session ID
 * @return array|bool
 */
function getFileContents($id, $course_info, $sessionId = 0)
{
    $id = intval($id);
    if (empty($course_info) || empty($id)) {
        return false;
    }
    if (empty($sessionId)) {
        $sessionId = api_get_session_id();
    }

    $tbl_student_publication = Database::get_course_table(TABLE_STUDENT_PUBLICATION);

    if (!empty($course_info['real_id'])) {
        $sql = 'SELECT * FROM '.$tbl_student_publication.'
                WHERE c_id = '.$course_info['real_id'].' AND id = "'.$id.'"';
        $result = Database::query($sql);
        if ($result && Database::num_rows($result)) {
            $row = Database::fetch_array($result, 'ASSOC');
            $full_file_name = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/'.$row['url'];

            $item_info = api_get_item_property_info(api_get_course_int_id(), 'work', $row['id'], $sessionId);
            allowOnlySubscribedUser(api_get_user_id(), $row['parent_id'], $course_info['real_id']);

            if (empty($item_info)) {
                api_not_allowed();
            }

            /*
            field show_score in table course :
                0 =>    New documents are visible for all users
                1 =>    New documents are only visible for the teacher(s)
            field visibility in table item_property :
                0 => eye closed, invisible for all students
                1 => eye open
            field accepted in table c_student_publication :
                0 => eye closed, invisible for all students
                1 => eye open
            ( We should have visibility == accepted, otherwise there is an
            inconsistency in the Database)
            field value in table c_course_setting :
                0 => Allow learners to delete their own publications = NO
                1 => Allow learners to delete their own publications = YES

            +------------------+-------------------------+------------------------+
            |Can download work?| doc visible for all = 0 | doc visible for all = 1|
            +------------------+-------------------------+------------------------+
            |  visibility = 0  | editor only             | editor only            |
            |                  |                         |                        |
            +------------------+-------------------------+------------------------+
            |  visibility = 1  | editor                  | editor                 |
            |                  | + owner of the work     | + any student          |
            +------------------+-------------------------+------------------------+
            (editor = teacher + admin + anybody with right api_is_allowed_to_edit)
            */

            $work_is_visible = ($item_info['visibility'] == 1 && $row['accepted'] == 1);
            $doc_visible_for_all = ($course_info['show_score'] == 1);

            $is_editor = api_is_allowed_to_edit(true, true, true);
            $student_is_owner_of_work = user_is_author($row['id'], $row['user_id']);

            if ($is_editor ||
                ($student_is_owner_of_work) ||
                ($doc_visible_for_all && $work_is_visible)
            ) {
                $title = $row['title'];
                if (array_key_exists('filename', $row) && !empty($row['filename'])) {
                    $title = $row['filename'];
                }
                $title = str_replace(' ', '_', $title);
                event_download($title);
                if (Security::check_abs_path(
                    $full_file_name,
                    api_get_path(SYS_COURSE_PATH).api_get_course_path().'/')
                ) {
                    return array(
                        'path' => $full_file_name,
                        'title' => $title
                    );
                }
            }
        }
    }

    return false;
}
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:93,代码来源:work.lib.php

示例14: export2doc

 /**
  * Function export last wiki page version to document area
  * @param int $doc_id wiki page id
  *
  * @author Juan Carlos Raña <herodoto@telefonica.net>
  */
 public function export2doc($doc_id)
 {
     $_course = $this->courseInfo;
     $groupId = api_get_group_id();
     $data = self::get_wiki_data($doc_id);
     if (empty($data)) {
         return false;
     }
     $wikiTitle = $data['title'];
     $wikiContents = $data['content'];
     $template = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
         <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{LANGUAGE}" lang="{LANGUAGE}">
         <head>
         <title>{TITLE}</title>
         <meta http-equiv="Content-Type" content="text/html; charset={ENCODING}" />
         <style type="text/css" media="screen, projection">
         /*<![CDATA[*/
         {CSS}
         /*]]>*/
         </style>
         {ASCIIMATHML_SCRIPT}</head>
         <body dir="{TEXT_DIRECTION}">
         {CONTENT}
         </body>
         </html>';
     $css_file = api_get_path(TO_SYS, WEB_CSS_PATH) . api_get_setting('stylesheets') . '/default.css';
     if (file_exists($css_file)) {
         $css = @file_get_contents($css_file);
     } else {
         $css = '';
     }
     // Fixing some bugs in css files.
     $root_rel = api_get_path(REL_PATH);
     $css_path = 'main/css/';
     $theme = api_get_setting('stylesheets') . '/';
     $css = str_replace('behavior:url("/main/css/csshover3.htc");', '', $css);
     $css = str_replace('main/', $root_rel . 'main/', $css);
     $css = str_replace('images/', $root_rel . $css_path . $theme . 'images/', $css);
     $css = str_replace('../../img/', $root_rel . 'main/img/', $css);
     $asciimathmal_script = api_contains_asciimathml($wikiContents) || api_contains_asciisvg($wikiContents) ? '<script src="' . api_get_path(TO_REL, SCRIPT_ASCIIMATHML) . '" type="text/javascript"></script>' . "\n" : '';
     $template = str_replace(array('{LANGUAGE}', '{ENCODING}', '{TEXT_DIRECTION}', '{TITLE}', '{CSS}', '{ASCIIMATHML_SCRIPT}'), array(api_get_language_isocode(), api_get_system_encoding(), api_get_text_direction(), $wikiTitle, $css, $asciimathmal_script), $template);
     if (0 != $groupId) {
         $groupPart = '_group' . $groupId;
         // and add groupId to put the same document title in different groups
         $group_properties = GroupManager::get_group_properties($groupId);
         $groupPath = $group_properties['directory'];
     } else {
         $groupPart = '';
         $groupPath = '';
     }
     $exportDir = api_get_path(SYS_COURSE_PATH) . api_get_course_path() . '/document' . $groupPath;
     $exportFile = api_replace_dangerous_char($wikiTitle) . $groupPart;
     $wikiContents = trim(preg_replace("/\\[[\\[]?([^\\]|]*)[|]?([^|\\]]*)\\][\\]]?/", "\$1", $wikiContents));
     //TODO: put link instead of title
     $wikiContents = str_replace('{CONTENT}', $wikiContents, $template);
     // replace relative path by absolute path for courses, so you can see items into this page wiki (images, mp3, etc..) exported in documents
     if (api_strpos($wikiContents, '../../courses/') !== false) {
         $web_course_path = api_get_path(WEB_COURSE_PATH);
         $wikiContents = str_replace('../../courses/', $web_course_path, $wikiContents);
     }
     $i = 1;
     //only export last version, but in new export new version in document area
     while (file_exists($exportDir . '/' . $exportFile . '_' . $i . '.html')) {
         $i++;
     }
     $wikiFileName = $exportFile . '_' . $i . '.html';
     $exportPath = $exportDir . '/' . $wikiFileName;
     file_put_contents($exportPath, $wikiContents);
     $doc_id = add_document($_course, $groupPath . '/' . $wikiFileName, 'file', filesize($exportPath), $wikiTitle);
     api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', api_get_user_id(), $groupId);
     return $doc_id;
 }
开发者ID:daffef,项目名称:chamilo-lms,代码行数:78,代码来源:wiki.inc.php

示例15: import_package

 /**
  * Imports a zip file into the Chamilo structure
  * @param    string    Zip file info as given by $_FILES['userFile']
  * @return    string    Absolute path to the imsmanifest.xml file or empty string on error
  */
 function import_package($zip_file_info, $current_dir = '')
 {
     if ($this->debug > 0) {
         error_log('In scorm::import_package(' . print_r($zip_file_info, true) . ',"' . $current_dir . '") method', 0);
     }
     $maxFilledSpace = DocumentManager::get_course_quota();
     $zip_file_path = $zip_file_info['tmp_name'];
     $zip_file_name = $zip_file_info['name'];
     if ($this->debug > 1) {
         error_log('New LP - import_package() - zip file path = ' . $zip_file_path . ', zip file name = ' . $zip_file_name, 0);
     }
     // scorm dir web path starting from /courses
     $course_rel_dir = api_get_course_path() . '/scorm';
     $course_sys_dir = api_get_path(SYS_COURSE_PATH) . $course_rel_dir;
     // Absolute system path for this course.
     if (!is_dir($course_sys_dir)) {
         mkdir($course_sys_dir, api_get_permissions_for_new_directories());
     }
     $current_dir = api_replace_dangerous_char(trim($current_dir), 'strict');
     // Current dir we are in, inside scorm/
     if ($this->debug > 1) {
         error_log('New LP - import_package() - current_dir = ' . $current_dir, 0);
     }
     //$uploaded_filename = $_FILES['userFile']['name'];
     // Get name of the zip file without the extension.
     if ($this->debug > 1) {
         error_log('New LP - Received zip file name: ' . $zip_file_path, 0);
     }
     $file_info = pathinfo($zip_file_name);
     $filename = $file_info['basename'];
     $extension = $file_info['extension'];
     $file_base_name = str_replace('.' . $extension, '', $filename);
     // Filename without its extension.
     $this->zipname = $file_base_name;
     // Save for later in case we don't have a title.
     if ($this->debug > 1) {
         error_log("New LP - base file name is : " . $file_base_name, 0);
     }
     $new_dir = api_replace_dangerous_char(trim($file_base_name), 'strict');
     $this->subdir = $new_dir;
     if ($this->debug > 1) {
         error_log("New LP - subdir is first set to : " . $this->subdir, 0);
     }
     $zipFile = new PclZip($zip_file_path);
     // Check the zip content (real size and file extension).
     $zipContentArray = $zipFile->listContent();
     $package_type = '';
     $at_root = false;
     $manifest = '';
     $realFileSize = 0;
     $manifest_list = array();
     // The following loop should be stopped as soon as we found the right imsmanifest.xml (how to recognize it?).
     foreach ($zipContentArray as $thisContent) {
         $file = $thisContent['filename'];
         //error_log('Looking at  '.$thisContent['filename'], 0);
         if (preg_match('~.(php.*|phtml)$~i', $file)) {
             $this->set_error_msg("File {$file} contains a PHP script");
             //return api_failure::set_failure('php_file_in_zip_file');
         } elseif (stristr($thisContent['filename'], 'imsmanifest.xml')) {
             //error_log('Found imsmanifest at '.$thisContent['filename'], 0);
             if ($thisContent['filename'] == basename($thisContent['filename'])) {
                 $at_root = true;
             } else {
                 //$this->subdir .= '/'.dirname($thisContent['filename']);
                 if ($this->debug > 2) {
                     error_log("New LP - subdir is now " . $this->subdir, 0);
                 }
             }
             $package_type = 'scorm';
             $manifest_list[] = $thisContent['filename'];
             $manifest = $thisContent['filename'];
             //just the relative directory inside scorm/
         } else {
             // Do nothing, if it has not been set as scorm somewhere else, it stays as '' default.
         }
         $realFileSize += $thisContent['size'];
     }
     // Now get the shortest path (basically, the imsmanifest that is the closest to the root).
     $shortest_path = $manifest_list[0];
     $slash_count = substr_count($shortest_path, '/');
     foreach ($manifest_list as $manifest_path) {
         $tmp_slash_count = substr_count($manifest_path, '/');
         if ($tmp_slash_count < $slash_count) {
             $shortest_path = $manifest_path;
             $slash_count = $tmp_slash_count;
         }
     }
     $this->subdir .= '/' . dirname($shortest_path);
     // Do not concatenate because already done above.
     $manifest = $shortest_path;
     if ($this->debug > 1) {
         error_log('New LP - Package type is now ' . $package_type, 0);
     }
     // && defined('CHECK_FOR_SCORM') && CHECK_FOR_SCORM)
     if ($package_type == '') {
//.........这里部分代码省略.........
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:101,代码来源:scorm.class.php


注:本文中的api_get_course_path函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。