예제 #1
0
 if ($ext == 'mp3') {
     $content = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="200" height="15" codebase="http://www.apple.com/qtactivex/qtplugin.cab"><param name="src" value="' . $content_info['href'] . '" /><param name="autoplay" value="false" /><embed src="' . $content_info['href'] . '" width="200" height="15" autoplay="false" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>';
 } else {
     if (in_array($ext, array('wav', 'au'))) {
         $content = '<embed SRC="' . $content_info['href'] . '" autostart="false" width="145" height="60"><noembed><bgsound src="' . $content_info['href'] . '"></noembed></embed>';
     } else {
         if (in_array($ext, array('txt', 'css', 'html', 'htm', 'csv', 'asc', 'tsv', 'xml', 'xsl'))) {
             /* this is a plain text file */
             $content = file_get_contents($import_path . $content_info['href']);
             if ($content === false) {
                 /* if we can't stat() it then we're unlikely to be able to read it */
                 /* so we'll never get here. */
                 continue;
             }
             // get the contents of the 'head' element
             $head .= ContentUtility::getHtmlHeadByTag($content, $html_head_tags);
             // Specifically handle eXe package
             // NOTE: THIS NEEDS WORK! TO FIND A WAY APPLY EXE .CSS FILES ONLY ON COURSE CONTENT PART.
             // NOW USE OUR OWN .CSS CREATED SOLELY FOR EXE
             $isExeContent = false;
             // check xml file in eXe package
             if (preg_match("/<organization[ ]*identifier=\"eXe*>*/", $ims_manifest_xml)) {
                 $isExeContent = true;
             }
             // use ATutor's eXe style sheet as the ones from eXe conflicts with ATutor's style sheets
             if ($isExeContent) {
                 $head = preg_replace('/(<style.*>)(.*)(<\\/style>)/ms', '\\1@import url(/docs/exestyles.css);\\3', $head);
             }
             // end of specifically handle eXe package
             $content = ContentUtility::getHtmlBody($content);
             if ($contains_glossary_terms) {
function paste_from_file()
{
    global $msg;
    include_once TR_INCLUDE_PATH . '../home/classes/ContentUtility.class.php';
    if ($_FILES['uploadedfile_paste']['name'] == '') {
        $msg->addError('FILE_NOT_SELECTED');
        return;
    }
    if ($_FILES['uploadedfile_paste']['name'] && ($_FILES['uploadedfile_paste']['type'] == 'text/plain' || $_FILES['uploadedfile_paste']['type'] == 'text/html')) {
        $path_parts = pathinfo($_FILES['uploadedfile_paste']['name']);
        $ext = strtolower($path_parts['extension']);
        if (in_array($ext, array('html', 'htm'))) {
            $_POST['body_text'] = file_get_contents($_FILES['uploadedfile_paste']['tmp_name']);
            /* get the <title></title> of this page				*/
            $start_pos = strpos(strtolower($_POST['body_text']), '<title>');
            $end_pos = strpos(strtolower($_POST['body_text']), '</title>');
            if ($start_pos !== false && $end_pos !== false) {
                $start_pos += strlen('<title>');
                $_POST['title'] = trim(substr($_POST['body_text'], $start_pos, $end_pos - $start_pos));
            }
            unset($start_pos);
            unset($end_pos);
            $_POST['head'] = ContentUtility::getHtmlHeadByTag($_POST['body_text'], array("link", "style", "script"));
            if (strlen(trim($_POST['head'])) > 0) {
                $_POST['use_customized_head'] = 1;
            } else {
                $_POST['use_customized_head'] = 0;
            }
            $_POST['body_text'] = ContentUtility::getHtmlBody($_POST['body_text']);
            $msg->addFeedback('FILE_PASTED');
        } else {
            if ($ext == 'txt') {
                $_POST['body_text'] = file_get_contents($_FILES['uploadedfile_paste']['tmp_name']);
                //LAW
                //			debug($_POST);
                $msg->addFeedback('FILE_PASTED');
            }
        }
    } else {
        $msg->addError('BAD_FILE_TYPE');
    }
    return;
}