//			$_pages['editor/edit_content_folder.php?cid='.$page['content_id']]['title']    = $page['content_number'] . $page['title'];
    //			$_pages['editor/edit_content_folder.php?cid='.$page['content_id']]['parent']   = 'editor/edit_content_folder.php?cid='.$parent;
    //		}
    //
    //		$_pages['editor/edit_content_folder.php?cid='.$page['content_id']]['ignore'] = true;
    //		$parent = $page['content_id'];
    //	}
    //	$last_page = array_pop($_pages);
    //	$_pages['editor/edit_content_folder.php'] = $last_page;
    reset($path);
    $first_page = current($path);
    ContentUtility::saveLastCid($cid);
    if (isset($top_num) && $top_num != (int) $top_num) {
        $top_num = substr($top_num, 0, strpos($top_num, '.'));
    }
    $_tool_shortcuts = ContentUtility::getToolShortcuts($content_row);
    // used by header.tmpl.php
    // display pre-tests
    //	$sql = 'SELECT * FROM '.TABLE_PREFIX."content_prerequisites WHERE content_id=$_REQUEST[cid] AND type='".CONTENT_PRE_TEST."'";
    //	$result = mysql_query($sql, $db);
    //	while ($row = mysql_fetch_assoc($result)) {
    //		$_POST['pre_tid'][] = $row['item_id'];
    //	}
    $savant->assign('ftitle', $content_row['title']);
    //	$savant->assign('shortcuts', $shortcuts);
    $savant->assign('cid', $cid);
}
if ($pid > 0 || !isset($pid)) {
    $savant->assign('pid', $pid);
    $savant->assign('course_id', $_course_id);
}
示例#2
0
     // 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) {
         // replace glossary content package links to real glossary mark-up using [?] [/?]
         // refer to bug 3641, edited by Harris
         $content = preg_replace('/<a href="([.\\w\\d\\s]+[^"]+)" target="body" class="at-term">([.\\w\\d\\s&;"]+|.*)<\\/a>/i', '[?]\\2[/?]', $content);
     }
     /* potential security risk? */
     if (strpos($content_info['href'], '..') === false && !preg_match('/((.*)\\/)*tests\\_[0-9]+\\.xml$/', $content_info['href'])) {
         //				@unlink($import_path.$content_info['href']);
     }
 } else {
     if ($ext) {
         /* non text file, and can't embed (example: PDF files) */
         $content = '<a href="' . $content_info['href'] . '">' . $content_info['title'] . '</a>';
     }
 }
 /**
  * replace source object with alternatives according to user's preferences
  * @access	public
  * @param	$cid: 				content id.
  * @param	$content:	 		the original content page ($content_row['text'], from content.php).
  * @param    $info_only:         when "true", return the array of info (has_text_alternative, has_audio_alternative, has_visual_alternative, has_sign_lang_alternative)
  * @param    $only_on_secondary_type: 
  * @return	string				$content: the content page with the appropriated resources.
  * @see		$db			        from include/vitals.inc.php
  * @author	Cindy Qi Li
  */
 public static function applyAlternatives($cid, $content, $info_only = false, $only_on_secondary_type = 0)
 {
     global $db, $_course_id;
     include_once TR_INCLUDE_PATH . 'classes/DAO/DAO.class.php';
     $dao = new DAO();
     $video_exts = array("mpg", "avi", "wmv", "mov", "swf", "mp4", "flv");
     $audio_exts = array("mp3", "wav", "ogg", "mid");
     $audio_width = 425;
     $audio_height = 27;
     $txt_exts = array("txt", "html", "htm");
     $image_exts = array("gif", "bmp", "png", "jpg", "jpeg", "png", "tif");
     $only_on_secondary_type = intval($only_on_secondary_type);
     // intialize the 4 returned values when $info_only is on
     if ($info_only) {
         $has_text_alternative = false;
         $has_audio_alternative = false;
         $has_visual_alternative = false;
         $has_sign_lang_alternative = false;
     }
     if (!$info_only && !$only_on_secondary_type && $_SESSION['prefs']['PREF_USE_ALTERNATIVE_TO_TEXT'] == 0 && $_SESSION['prefs']['PREF_USE_ALTERNATIVE_TO_AUDIO'] == 0 && $_SESSION['prefs']['PREF_USE_ALTERNATIVE_TO_VISUAL'] == 0) {
         //No user's preferences related to content format are declared
         if (!$info_only) {
             return $content;
         } else {
             return array($has_text_alternative, $has_audio_alternative, $has_visual_alternative, $has_sign_lang_alternative);
         }
     }
     // get all relations between primary resources and their alternatives
     $sql = "SELECT DISTINCT c.content_path, pr.resource,  prt.type_id primary_type,\r\n                       sr.secondary_resource, srt.type_id secondary_type\r\n\t\t          FROM " . TABLE_PREFIX . "primary_resources pr, " . TABLE_PREFIX . "primary_resources_types prt," . TABLE_PREFIX . "secondary_resources sr," . TABLE_PREFIX . "secondary_resources_types srt," . TABLE_PREFIX . "content c\r\n\t\t         WHERE pr.content_id=" . $cid . "\r\n\t\t\t       AND pr.primary_resource_id = prt.primary_resource_id\r\n\t\t\t       AND pr.primary_resource_id = sr.primary_resource_id\r\n\t\t\t       AND sr.language_code='" . $_SESSION['lang'] . "'\r\n\t\t\t       AND sr.secondary_resource_id = srt.secondary_resource_id\r\n\t\t           AND pr.content_id = c.content_id";
     if ($only_on_secondary_type > 0) {
         $sql .= " AND srt.type_id=" . $only_on_secondary_type;
     }
     $sql .= " ORDER BY pr.primary_resource_id, prt.type_id";
     $rows = $dao->execute($sql);
     if (!is_array($rows)) {
         if (!$info_only) {
             return $content;
         } else {
             return array($has_text_alternative, $has_audio_alternative, $has_visual_alternative, $has_sign_lang_alternative);
         }
     }
     $primary_resource_names = array();
     foreach ($rows as $row) {
         // if the primary resource is defined with multiple resource type,
         // the primary resource would be replaced/appended multiple times.
         // This is what we want at applying alternatives by default, but
         // not when only one secondary type is chosen to apply.
         // This fix is to remove the duplicates on the same primary resource.
         // A dilemma of this fix is, for example, if the primary resource type
         // is "text" and "visual", but
         // $_SESSION['prefs']['PREF_ALT_TO_TEXT_APPEND_OR_REPLACE'] == 'replace'
         // $_SESSION['prefs']['PREF_ALT_TO_VISUAL_APPEND_OR_REPLACE'] == 'append'
         // so, should replace happen or append happen? With this fix, whichever
         // the first in the sql return gets preserved in the array and processed.
         // The further improvement is requried to keep rows based on the selected
         // secondary type (http://www.atutor.ca/atutor/mantis/view.php?id=4598).
         if ($only_on_secondary_type > 0) {
             if (in_array($row['resource'], $primary_resource_names)) {
                 continue;
             } else {
                 $primary_resource_names[] = $row['resource'];
             }
         }
         $alternative_rows[] = $row;
         $youtube_playURL = ContentUtility::convertYoutubeWatchURLToPlayURL($row['resource']);
         if ($row['resource'] != $youtube_playURL) {
             $row['resource'] = $youtube_playURL;
             $alternative_rows[] = $row;
         }
     }
     foreach ($alternative_rows as $row) {
         if ($info_only || $only_on_secondary_type || $_SESSION['prefs']['PREF_USE_ALTERNATIVE_TO_TEXT'] == 1 && $row['primary_type'] == 3 && ($_SESSION['prefs']['PREF_ALT_TO_TEXT'] == "audio" && $row['secondary_type'] == 1 || $_SESSION['prefs']['PREF_ALT_TO_TEXT'] == "visual" && $row['secondary_type'] == 4 || $_SESSION['prefs']['PREF_ALT_TO_TEXT'] == "sign_lang" && $row['secondary_type'] == 2) || $_SESSION['prefs']['PREF_USE_ALTERNATIVE_TO_AUDIO'] == 1 && $row['primary_type'] == 1 && ($_SESSION['prefs']['PREF_ALT_TO_AUDIO'] == "visual" && $row['secondary_type'] == 4 || $_SESSION['prefs']['PREF_ALT_TO_AUDIO'] == "text" && $row['secondary_type'] == 3 || $_SESSION['prefs']['PREF_ALT_TO_AUDIO'] == "sign_lang" && $row['secondary_type'] == 2) || $_SESSION['prefs']['PREF_USE_ALTERNATIVE_TO_VISUAL'] == 1 && $row['primary_type'] == 4 && ($_SESSION['prefs']['PREF_ALT_TO_VISUAL'] == "audio" && $row['secondary_type'] == 1 || $_SESSION['prefs']['PREF_ALT_TO_VISUAL'] == "text" && $row['secondary_type'] == 3 || $_SESSION['prefs']['PREF_ALT_TO_VISUAL'] == "sign_lang" && $row['secondary_type'] == 2)) {
             $ext = substr($row['secondary_resource'], strrpos($row['secondary_resource'], '.') + 1);
             // alternative is video
             if (in_array($ext, $video_exts) || in_array($ext, $audio_exts) || preg_match("/http:\\/\\/.*youtube.com\\/watch.*/", $row['secondary_resource'])) {
                 if (in_array($ext, $audio_exts)) {
                     // display audio medias in a smaller width/height (425 * 27)
                     // A hack for now to handle audio media player size
                     $target = '[media|' . $audio_width . '|' . $audio_height . ']' . $row['secondary_resource'] . '[/media]';
                 } else {
                     // use default media size for video medias
                     $target = '[media]' . $row['secondary_resource'] . '[/media]';
                 }
             } else {
                 if (in_array($ext, $txt_exts)) {
                     if ($row['content_path'] != '') {
                         $file_location = $row['content_path'] . '/' . $row['secondary_resource'];
                     } else {
                         $file_location = $row['secondary_resource'];
                     }
                     $file = TR_CONTENT_DIR . $_SESSION['course_id'] . '/' . $file_location;
                     $target = '<br />' . file_get_contents($file);
                     // check whether html file
                     if (preg_match('/.*\\<html.*\\<\\/html\\>.*/s', $target)) {
                         // is a html file, use iframe to display
                         // get real path to the text file
                         if (defined('TR_FORCE_GET_FILE') && TR_FORCE_GET_FILE) {
                             $course_base_href = 'get.php/';
                         } else {
                             $course_base_href = 'content/' . $_SESSION['course_id'] . '/';
                         }
                         $file = TR_BASE_HREF . $course_base_href . $file_location;
                         $target = '<iframe width="100%" frameborder="0" class="autoHeight" scrolling="auto" src="' . $file . '"></iframe>';
                     } else {
                         // is a text file, insert/replace into content
                         $target = nl2br($target);
                     }
                 } else {
                     if (in_array($ext, $image_exts)) {
                         $target = '<img border="0" alt="' . _AT('alternate_text') . '" src="' . $row['secondary_resource'] . '"/>';
                     } else {
                         $target = '<p><a href="' . $row['secondary_resource'] . '">' . $row['secondary_resource'] . '</a></p>';
                     }
                 }
             }
             // replace or append the target alternative to the source
             if ($row['primary_type'] == 3 && $_SESSION['prefs']['PREF_ALT_TO_TEXT_APPEND_OR_REPLACE'] == 'replace' || $row['primary_type'] == 1 && $_SESSION['prefs']['PREF_ALT_TO_AUDIO_APPEND_OR_REPLACE'] == 'replace' || $row['primary_type'] == 4 && $_SESSION['prefs']['PREF_ALT_TO_VISUAL_APPEND_OR_REPLACE'] == 'replace') {
                 $pattern_replace_to = '${1}' . "\n" . $target . "\n" . '${3}';
             } else {
                 $pattern_replace_to = '${1}${2}' . "<br /><br />\n" . $target . "\n" . '${3}';
             }
             // *** Alternative replace/append starts from here ***
             $processed = false;
             // one primary resource is only processed once
             // append/replace target alternative to [media]source[/media]
             if (!$processed && preg_match("/" . preg_quote("[media") . ".*" . preg_quote("]" . $row['resource'] . "[/media]", "/") . "/sU", $content)) {
                 $processed = true;
                 if (!$info_only) {
                     $content = preg_replace("/(.*)(" . preg_quote("[media") . ".*" . preg_quote("]" . $row['resource'] . "[/media]", "/") . ")(.*)/sU", $pattern_replace_to, $content);
                 } else {
                     if ($row['secondary_type'] == 1) {
                         $has_audio_alternative = true;
                     }
                     if ($row['secondary_type'] == 2) {
                         $has_sign_lang_alternative = true;
                     }
                     if ($row['secondary_type'] == 3) {
                         $has_text_alternative = true;
                     }
                     if ($row['secondary_type'] == 4) {
                         $has_visual_alternative = true;
                     }
                 }
             }
             // append/replace target alternative to <img ... src="source" ...></a>
             if (!$processed && preg_match("/\\<img.*src=\"" . preg_quote($row['resource'], "/") . "\".*\\/\\>/sU", $content)) {
                 $processed = true;
                 if (!$info_only) {
                     $content = preg_replace("/(.*)(\\<img.*src=\"" . preg_quote($row['resource'], "/") . "\".*\\/\\>)(.*)/sU", $pattern_replace_to, $content);
                 } else {
                     if ($row['secondary_type'] == 1) {
                         $has_audio_alternative = true;
                     }
                     if ($row['secondary_type'] == 2) {
                         $has_sign_lang_alternative = true;
                     }
                     if ($row['secondary_type'] == 3) {
                         $has_text_alternative = true;
                     }
                     if ($row['secondary_type'] == 4) {
                         $has_visual_alternative = true;
                     }
                 }
             }
             // append/replace target alternative to <object ... source ...></object>
             if (!$processed && preg_match("/\\<object.*" . preg_quote($row['resource'], "/") . ".*\\<\\/object\\>/sU", $content)) {
                 $processed = true;
                 if (!$info_only) {
                     $content = preg_replace("/(.*)(\\<object.*" . preg_quote($row['resource'], "/") . ".*\\<\\/object\\>)(.*)/sU", $pattern_replace_to, $content);
                 } else {
                     if ($row['secondary_type'] == 1) {
                         $has_audio_alternative = true;
                     }
                     if ($row['secondary_type'] == 2) {
                         $has_sign_lang_alternative = true;
                     }
                     if ($row['secondary_type'] == 3) {
                         $has_text_alternative = true;
                     }
                     if ($row['secondary_type'] == 4) {
                         $has_visual_alternative = true;
                     }
                 }
             }
             // append/replace target alternative to <a>...source...</a> or <a ...source...>...</a>
             // skip this "if" when the source object has been processed in aboved <img> tag
             if (!$processed && preg_match("/\\<a.*" . preg_quote($row['resource'], "/") . ".*\\<\\/a\\>/sU", $content)) {
                 $processed = true;
                 if (!$info_only) {
                     $content = preg_replace("/(.*)(\\<a.*" . preg_quote($row['resource'], "/") . ".*\\<\\/a\\>)(.*)/sU", $pattern_replace_to, $content);
                 } else {
                     if ($row['secondary_type'] == 1) {
                         $has_audio_alternative = true;
                     }
                     if ($row['secondary_type'] == 2) {
                         $has_sign_lang_alternative = true;
                     }
                     if ($row['secondary_type'] == 3) {
                         $has_text_alternative = true;
                     }
                     if ($row['secondary_type'] == 4) {
                         $has_visual_alternative = true;
                     }
                 }
             }
             // append/replace target alternative to <embed ... source ...>
             if (!$processed && preg_match("/\\<embed.*" . preg_quote($row['resource'], "/") . ".*\\>/sU", $content)) {
                 $processed = true;
                 if (!$info_only) {
                     $content = preg_replace("/(.*)(\\<embed.*" . preg_quote($row['resource'], "/") . ".*\\>)(.*)/sU", $pattern_replace_to, $content);
                 } else {
                     if ($row['secondary_type'] == 1) {
                         $has_audio_alternative = true;
                     }
                     if ($row['secondary_type'] == 2) {
                         $has_sign_lang_alternative = true;
                     }
                     if ($row['secondary_type'] == 3) {
                         $has_text_alternative = true;
                     }
                     if ($row['secondary_type'] == 4) {
                         $has_visual_alternative = true;
                     }
                 }
             }
         }
     }
     if (!$info_only) {
         return $content;
     } else {
         return array($has_text_alternative, $has_audio_alternative, $has_visual_alternative, $has_sign_lang_alternative);
     }
 }
示例#4
0
$_tool_shortcuts = ContentUtility::getToolShortcuts($content_row);
//if it has test and forum associated with it, still display it even if the content is empty
if ($content_row['text'] == '' && empty($content_test_ids)) {
    $msg->addInfo('NO_PAGE_CONTENT');
    $savant->assign('body', '');
} else {
    // find whether the body has alternatives defined
    list($has_text_alternative, $has_audio_alternative, $has_visual_alternative, $has_sign_lang_alternative) = ContentUtility::applyAlternatives($cid, $content_row['text'], true);
    // apply alternatives
    if (intval($_GET['alternative']) > 0) {
        $content = ContentUtility::applyAlternatives($cid, $content_row['text'], false, intval($_GET['alternative']));
    } else {
        $content = ContentUtility::applyAlternatives($cid, $content_row['text']);
    }
    $content = ContentUtility::formatContent($content, $content_row['formatting']);
    $content_array = ContentUtility::getContentTable($content, $content_row['formatting']);
    $savant->assign('content_table', $content_array[0]);
    $savant->assign('body', $content_array[1]);
    $savant->assign('has_text_alternative', $has_text_alternative);
    $savant->assign('has_audio_alternative', $has_audio_alternative);
    $savant->assign('has_visual_alternative', $has_visual_alternative);
    $savant->assign('has_sign_lang_alternative', $has_sign_lang_alternative);
    $savant->assign('cid', $cid);
    //assign test pages if there are tests associated with this content page
    if (!empty($content_test_ids)) {
        $savant->assign('test_message', $content_row['test_message']);
        $savant->assign('test_ids', $content_test_ids);
    } else {
        $savant->assign('test_message', '');
        $savant->assign('test_ids', array());
    }
示例#5
0
function print_organizations($parent_id, &$_menu, $depth, $path = '', $children, &$string)
{
    global $html_content_template, $default_html_style, $zipfile, $resources, $ims_template_xml, $parser, $my_files;
    global $used_glossary_terms, $course_id, $course_language_charset, $course_language_code;
    static $paths, $zipped_files;
    //	global $glossary;
    global $test_list, $test_zipped_files, $test_files, $test_xml_items, $use_a4a;
    global $contentManager;
    /* added by bologna*/
    //TODO***********BOLOGNA**************REMOVE ME*****************/
    global $db, $forum_list;
    //forum_list contiene tutti i forum distinti associati ai contenuti. poich� la funzione in questione � ricorsiva deve essere globale in modo che in fase di creazione dell'archivio zip i file descrittori dei forum non vengano ripetuti
    require_once TR_INCLUDE_PATH . '../home/classes/ContentUtility.class.php';
    require_once TR_INCLUDE_PATH . 'classes/DAO/ContentForumsAssocDAO.class.php';
    $space = '    ';
    $prefix = '                    ';
    if ($depth == 0) {
        $string .= '<ul>';
    }
    $top_level = $_menu[$parent_id];
    if (!is_array($paths)) {
        $paths = array();
    }
    if (!is_array($zipped_files)) {
        $zipped_files = array();
    }
    if (is_array($top_level)) {
        $counter = 1;
        $num_items = count($top_level);
        foreach ($top_level as $garbage => $content) {
            $link = '';
            //XSL characters handling
            $content['title'] = str_replace('&', '&amp;', $content['title']);
            if ($content['content_path'] && substr($content['content_path'], -1) != '/') {
                $content['content_path'] .= '/';
            }
            /* 
             * generate weblinks 
             * Reason to put it here is cause we don't want the content to be overwrittened.
             */
            if ($content['content_type'] == CONTENT_TYPE_WEBLINK) {
                $wl = new Weblinks($content['title'], $content['text']);
                $wlexport = new WeblinksExport($wl);
                $wl_xml = $wlexport->export();
                $wl_filename = 'weblinks_' . $content['content_id'] . '.xml';
                $zipfile->add_file($wl_xml, 'Weblinks/' . $wl_filename, $content['u_ts']);
                $resources .= str_replace(array('{PATH}', '{CONTENT_ID}'), array($wl_filename, $content['content_id']), $ims_template_xml['resource_weblink']);
                //Done.
                //				continue;
            }
            if ($content['content_type'] == CONTENT_TYPE_FOLDER) {
                $link .= $prefix . '<item identifier="MANIFEST01_FOLDER' . $content['content_id'] . '">' . "\n";
                $link .= $prefix . $space . '<title>' . $content['title'] . '</title>' . "\n";
            } else {
                $link .= '<item identifier="MANIFEST01_ITEM' . $content['content_id'] . '" identifierref="MANIFEST01_RESOURCE' . $content['content_id'] . '">' . "\n";
                $link .= $prefix . $space . '<title>' . $content['title'] . '</title>' . "\n{$prefix}{$space}";
            }
            $html_link = '<a href="resources/' . $content['content_path'] . $content['content_id'] . '.html" target="body">' . $content['title'] . '</a>';
            /* save the content as HTML files */
            $content['text'] = str_replace('CONTENT_DIR/', '', $content['text']);
            /* Commented by Cindy Qi Li on Jan 12, 2010
            			 * AContent does not support glossary
            			// get all the glossary terms used
            			$terms = find_terms($content['text']);
            			if (is_array($terms)) {
            				foreach ($terms[2] as $term) {
            					$used_glossary_terms[] = $term;
            				}
            			}
            */
            $f_count = count($forum_list);
            //count all distinct forum_id associated to a content page
            //la funzione è ricorsiva quindi lo devo ricavare attraverso la variabile globale forum_list
            $contentForumsAssocDAO = new ContentForumsAssocDAO();
            $forums = $contentForumsAssocDAO->getByContent($content[content_id]);
            //                    $sql = "SELECT cf.forum_id, f.title, f.description FROM (SELECT * FROM ".TABLE_PREFIX."content_forums_assoc WHERE content_id=$content[content_id]) AS cf LEFT JOIN ".TABLE_PREFIX."forums f ON cf.forum_id=f.forum_id";
            //                    $result_cf = mysql_query($sql,$db);
            $find = false;
            $forums_dependency = '';
            //template for associate Discussion Topic to the current content into the manifest
            if (is_array($forums)) {
                foreach ($forums as $current_forum) {
                    for ($j = 0; $j < $f_count; $j++) {
                        if ($forum_list[$j]['id'] == $current_forum['forum_id']) {
                            $find = true;
                        }
                    }
                    if (!$find) {
                        $forum_list[$f_count]['id'] = $current_forum['forum_id'];
                        $forum_list[$f_count]['title'] = $current_forum['title'];
                        $forum_list[$f_count]['description'] = $current_forum['description'];
                        $find = false;
                        $f_count++;
                    }
                }
                $forums_dependency .= $prefix . $space . '<dependency identifierref="Forum' . $current_forum['forum_id'] . '_R" />';
            }
            /** Test dependency **/
            require_once TR_INCLUDE_PATH . 'classes/DAO/ContentTestsAssocDAO.class.php';
            $contentTestsAssocDAO = new ContentTestsAssocDAO();
            //			$sql = 'SELECT * FROM '.TABLE_PREFIX.'content_tests_assoc WHERE content_id='.$content['content_id'];
            //			$result = mysql_query($sql, $db);
            //			while ($row = mysql_fetch_assoc($result)){
            $rows = $contentTestsAssocDAO->getByContent($content['content_id']);
            if (is_array($rows)) {
                //add test dependency on top of forum dependency
                foreach ($rows as $row) {
                    $forums_dependency .= $prefix . $space . '<dependency identifierref="MANIFEST01_RESOURCE_QTI' . $row['test_id'] . '" />';
                }
            }
            /* calculate how deep this page is: */
            $path = '../';
            if ($content['content_path']) {
                $depth = substr_count($content['content_path'], '/');
                $path .= str_repeat('../', $depth);
            }
            $content['text'] = ContentUtility::formatContent($content['text'], $content['formatting']);
            // add HTML header and footers to the files
            // use default style if <style> is not in imported html head
            $head = '';
            if ($content['use_customized_head']) {
                if (strpos(strtolower($content['head']), '<style') > 0) {
                    $head = $content['head'];
                } else {
                    if (strlen($content['head']) > 0) {
                        $head = $content['head'] . $default_html_style;
                    } else {
                        $head = $default_html_style;
                    }
                }
            }
            $content['text'] = str_replace(array('{TITLE}', '{CONTENT}', '{KEYWORDS}', '{COURSE_PRIMARY_LANGUAGE_CHARSET}', '{COURSE_PRIMARY_LANGUAGE_CODE}', '{HEAD}'), array($content['title'], $content['text'], $content['keywords'], $course_language_charset, $course_language_code, $head), $html_content_template);
            /* duplicate the paths in the content_path field in the zip file */
            if ($content['content_path']) {
                if (!in_array($content['content_path'], $paths)) {
                    $zipfile->create_dir('resources/' . $content['content_path'], time());
                    $paths[] = $content['content_path'];
                }
            }
            //add the file iff it's a content file
            if ($content['content_type'] == CONTENT_TYPE_CONTENT) {
                $zipfile->add_file($content['text'], 'resources/' . $content['content_path'] . $content['content_id'] . '.html', $content['u_ts']);
            }
            $content['title'] = htmlspecialchars($content['title']);
            /* add the resource dependancies */
            if ($my_files == null) {
                $my_files = array();
            }
            $content_files = "\n";
            $parser->parse($content['text']);
            /* generate the IMS QTI resource and files */
            //check if test export is allowed.
            $content_test_rs = $contentManager->getContentTestsAssoc($content['content_id']);
            $test_ids = array();
            //reset test ids
            //$my_files = array();		//reset myfiles.
            if (is_array($content_test_rs)) {
                foreach ($content_test_rs as $content_test_row) {
                    //export
                    $test_ids[] = $content_test_row['test_id'];
                    //the 'added_files' is for adding into the manifest file in this zip
                    $added_files = test_qti_export($content_test_row['test_id'], '', $zipfile);
                    foreach ($added_files as $xml_file => $chunk) {
                        foreach ($chunk as $xml_filename) {
                            $added_files_xml .= str_replace('{FILE}', 'resources/' . $xml_filename, $ims_template_xml['xml']);
                        }
                    }
                    //Save all the xml files in this array, and then print_organizations will add it to the manifest file.
                    $resources .= str_replace(array('{TEST_ID}', '{PATH}', '{FILES}'), array($content_test_row['test_id'], 'tests_' . $content_test_row['test_id'] . '.xml', $added_files_xml), $ims_template_xml['resource_test']);
                    /*	Taken out since we are gonna use dependency instead
                    					$test_xml_items .= str_replace(	array('{TEST_ID}'),
                    												array($content_test_row['test_id']),
                    												$ims_template_xml['test']); 
                    */
                    foreach ($test_files as $filename => $realfilepath) {
                        $zipfile->add_file(@file_get_contents($realfilepath), 'resources/' . $filename, filemtime($realfilepath));
                    }
                }
            }
            /* generate the a4a files */
            $a4a_xml_array = array();
            //http://atutor.ca/atutor/mantis/view.php?id=4593
            if ($content['formatting'] === 0) {
                $use_a4a = false;
            }
            if ($use_a4a == true) {
                $a4aExport = new A4aExport($content['content_id']);
                //				$a4aExport->setRelativePath('resources/'.$content['content_path']);
                $secondary_files = $a4aExport->getAllSecondaryFiles();
                $a4a_xml_array = $a4aExport->exportA4a();
                $my_files = array_merge($my_files, $a4aExport->getAllSecondaryFiles());
            }
            /* handle @import */
            $import_files = get_import_files($content['text']);
            if (count($import_files) > 0) {
                $my_files = array_merge($my_files, $import_files);
            }
            foreach ($my_files as $file) {
                /* filter out full urls */
                $url_parts = @parse_url($file);
                //				if (isset($url_parts['scheme'])) {
                //					continue;
                //				}
                /* file should be relative to content. let's double check */
                if (substr($file, 0, 1) == '/') {
                    continue;
                }
                if (substr($file, 0, 7) != 'http://' && substr($file, 0, 8) != 'https://') {
                    $file_path = realpath(TR_CONTENT_DIR . $course_id . '/' . $content['content_path'] . $file);
                    /* check if the path contains TR_CONTENT_DIR in it, if not, skip it, it's trying to scan through 
                     * the file system */
                    if (strpos($file_path, TR_CONTENT_DIR) !== 0) {
                        continue;
                        //skip
                    }
                    /* check if this file exists in the content dir, if not don't include it */
                    if (file_exists($file_path) && is_file($file_path) && !in_array($file_path, $zipped_files)) {
                        $zipped_files[] = $file_path;
                        $dir = substr(dirname($file_path), strlen(TR_CONTENT_DIR . $course_id));
                        if (!in_array($dir, $paths) && $dir) {
                            $dir = str_replace('\\', '/', substr($dir, 1));
                            $zipfile->create_dir('resources/' . $dir, time());
                            $paths[] = $dir;
                        }
                        $file_info = stat($file_path);
                        //remove relative path in the content_path.
                        $filepath_array = explode('/', 'resources/' . $content['content_path'] . $file);
                        $new_filepath_array = array();
                        if (in_array('..', $filepath_array)) {
                            while (!empty($filepath_array)) {
                                $temp = array_shift($filepath_array);
                                if ($temp == '..') {
                                    array_pop($new_filepath_array);
                                } else {
                                    array_push($new_filepath_array, $temp);
                                }
                            }
                            $zip_path = implode('/', $new_filepath_array);
                        } else {
                            $zip_path = 'resources/' . $content['content_path'] . $file;
                        }
                        $zipfile->add_file(@file_get_contents($file_path), $zip_path, $file_info['mtime']);
                    }
                }
                //a4a secondary files have mapping, save the ones that we want in order to add the tag in
                $a4a_secondary_files = array();
                foreach ($a4a_xml_array as $a4a_filename => $a4a_filearray) {
                    if (preg_match('/(.*)\\sto\\s(.*)/', $a4a_filename, $matches)) {
                        //save the actual file name
                        $a4a_secondary_files[$matches[1]][] = $a4a_filename;
                        //values are holders
                    }
                }
                /**
                 * A hack to fix youtube links.  one uses youtube.com?watch=xxx, the other uses youtube.com/v/xxx,
                 * in which both points to the same file, but needed different links to play.
                 * in A4a, these youtube links are always stored as "?watch=xxx", however, output.inc.php converted
                 * these to /v/xxx for rendering purposes.  Convert it back if youtube exists in url.
                 * http://atutor.ca/atutor/mantis/view.php?id=4548
                 * @harris 9/30/2010
                 */
                if (strpos($file, 'youtube.com') !== false) {
                    //apply the conversion before linking the alternatives. Otherwise it will not be added.
                    $file = ContentUtility::convertYoutubePlayURLToWatchURL($file);
                }
                // If this file has a4a alternatives, link it.
                if (isset($a4a_xml_array[$file]) || isset($a4a_secondary_files[$file])) {
                    //if this is an array, meaning that it has more than 1 alternatives, print all
                    if (substr($file, 0, 7) == 'http://' || substr($file, 0, 8) == 'https://') {
                        $name_in_file_meta = $file;
                    } else {
                        $name_in_file_meta = 'resources/' . $content['content_path'] . $file;
                    }
                    if (is_array($a4a_secondary_files[$file])) {
                        $all_secondary_files_md = '';
                        //reinitialize string to null
                        foreach ($a4a_secondary_files[$file] as $v) {
                            foreach ($a4a_xml_array[$v] as $v2) {
                                $all_secondary_files_md .= $v2;
                                //all the meta data
                            }
                        }
                        $content_files .= str_replace(array('{FILE}', '{FILE_META_DATA}'), array($name_in_file_meta, $all_secondary_files_md), $ims_template_xml['file_meta']);
                    } else {
                        $content_files .= str_replace(array('{FILE}', '{FILE_META_DATA}'), array($name_in_file_meta, $a4a_xml_array[$file]), $ims_template_xml['file_meta']);
                    }
                } else {
                    //if this file is in the test array, add an extra link to the direct file,
                    if (!empty($test_zipped_files) && in_array($file_path, $test_zipped_files)) {
                        $content_files .= str_replace('{FILE}', $file, $ims_template_xml['file']);
                    } else {
                        if (preg_match('/^http[s]?\\:/', $file) == 1) {
                            $content_files .= str_replace('{FILE}', $file, $ims_template_xml['xml']);
                        } elseif (file_exists($file_path) && is_file($file_path)) {
                            //relative link that goes beyond get.php shouldn't be added
                            //relative link that does not exist shouldn't be added.
                            $filepath_array = explode('/', $content['content_path'] . $file);
                            $new_filepath_array = array();
                            if (in_array('..', $filepath_array)) {
                                while (!empty($filepath_array)) {
                                    $temp = array_shift($filepath_array);
                                    if ($temp == '..') {
                                        array_pop($new_filepath_array);
                                    } else {
                                        array_push($new_filepath_array, $temp);
                                    }
                                }
                                $file = implode('/', $new_filepath_array);
                            } else {
                                $file = $content['content_path'] . $file;
                            }
                            $content_files .= str_replace('{FILE}', $file, $ims_template_xml['file']);
                        }
                    }
                }
                /* check if this file is one of the test xml file, if so, we need to add the dependency
                 * Note:  The file has already been added to the archieve before this is called.
                 */
                if (preg_match('/tests\\_[0-9]+\\.xml$/', $file) && !in_array($file, $test_zipped_files)) {
                    $content_files .= str_replace('{FILE}', 'QTI/' . $file, $ims_template_xml['xml']);
                    $test_zipped_files[] = $file;
                }
            }
            /******************************
             * http://www.atutor.ca/atutor/mantis/view.php?id=4383 
             */
            $my_files = array();
            /******************************/
            //add it to the resources section if it hasn't been added.
            //Weblinks have been added.
            //Folders aren't resourecs, they shouldn't be added
            if ($content['content_type'] == CONTENT_TYPE_CONTENT) {
                $resources .= str_replace(array('{CONTENT_ID}', '{PATH}', '{FILES}', '{DEPENDENCY}'), array($content['content_id'], $content['content_path'], $content_files, $forums_dependency), $ims_template_xml['resource']);
            }
            for ($i = 0; $i < $depth; $i++) {
                $link .= $space;
            }
            if (is_array($_menu[$content['content_id']])) {
                /* has children */
                $html_link = '<li>' . $html_link . '<ul>';
                for ($i = 0; $i < $depth; $i++) {
                    if ($children[$i] == 1) {
                        echo $space;
                        //$html_link = $space.$html_link;
                    } else {
                        echo $space;
                        //$html_link = $space.$html_link;
                    }
                }
            } else {
                /* doesn't have children */
                $html_link = '<li>' . $html_link . '</li>';
                if ($counter == $num_items) {
                    for ($i = 0; $i < $depth; $i++) {
                        if ($children[$i] == 1) {
                            echo $space;
                            //$html_link = $space.$html_link;
                        } else {
                            echo $space;
                            //$html_link = $space.$html_link;
                        }
                    }
                } else {
                    for ($i = 0; $i < $depth; $i++) {
                        echo $space;
                        //$html_link = $space.$html_link;
                    }
                }
                $title = $space . $title;
            }
            echo $prefix . $link;
            //			echo $title;
            echo "\n";
            $string .= $html_link . "\n";
            $depth++;
            print_organizations($content['content_id'], $_menu, $depth, $path . $counter . '.', $children, $string);
            $depth--;
            $counter++;
            for ($i = 0; $i < $depth; $i++) {
                echo $space;
            }
            //			if (!empty($_menu[$content['content_id']])){
            echo $prefix . '</item>';
            //			}
            echo "\n";
        }
        $string .= '</ul>';
        if ($depth > 0) {
            $string .= '</li>';
        }
    }
}
 function display($row, $response = '')
 {
     // print the generic question header
     require_once TR_INCLUDE_PATH . '../home/classes/ContentUtility.class.php';
     $this->displayHeader($row['weight']);
     // print the question specific template
     $row['question'] = ContentUtility::formatContent($row['question'], 1);
     $this->assignDisplayVariables($row, $response);
     $this->savant->display('tests/test_questions/' . $this->sPrefix . '.tmpl.php');
     // print the generic question footer
     $this->displayFooter();
 }
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;
}
示例#8
0
function print_organizations($parent_id, &$_menu, $depth, $path = '', $children, &$string)
{
    global $html_content_template, $default_html_style, $zipfile, $resources, $ims_template_xml, $parser, $my_files;
    global $used_glossary_terms, $course_id, $course_language_charset, $course_language_code;
    static $paths, $zipped_files;
    global $glossary;
    global $test_zipped_files, $use_a4a, $db;
    require_once TR_INCLUDE_PATH . '../home/classes/ContentUtility.class.php';
    $space = '    ';
    $prefix = '                    ';
    if ($depth == 0) {
        $string .= '<ul>';
    }
    $top_level = $_menu[$parent_id];
    if (!is_array($paths)) {
        $paths = array();
    }
    if (!is_array($zipped_files)) {
        $zipped_files = array();
    }
    if (is_array($top_level)) {
        $counter = 1;
        $num_items = count($top_level);
        foreach ($top_level as $garbage => $content) {
            $link = '';
            if ($content['content_path']) {
                $content['content_path'] .= '/';
            }
            //if this is a folder, export it without identifierref
            if ($content['content_type'] == CONTENT_TYPE_FOLDER) {
                $link = $prevfix . '<item identifier="MANIFEST01_ITEM' . $content['content_id'] . '">' . "\n";
            } else {
                $link = $prevfix . '<item identifier="MANIFEST01_ITEM' . $content['content_id'] . '" identifierref="MANIFEST01_RESOURCE' . $content['content_id'] . '" parameters="' . htmlentities($content['test_message'], ENT_QUOTES, 'UTF-8') . '">' . "\n";
            }
            $html_link = '<a href="resources/' . $content['content_path'] . $content['content_id'] . '.html" target="body">' . $content['title'] . '</a>';
            /* save the content as HTML files */
            $content['text'] = str_replace('CONTENT_DIR/', '', $content['text']);
            /* Commented by Cindy Qi Li on Jan 12, 2010
            			 * AContent does not support glossary
            			// get all the glossary terms used
            			$terms = find_terms($content['text']);
            			if (is_array($terms)) {
            				foreach ($terms[2] as $term) {
            					$used_glossary_terms[] = $term;
            				}
            			}
            */
            /** Test dependency **/
            //			$test_dependency = '';	//Template for test
            //			$sql = 'SELECT * FROM '.TABLE_PREFIX.'content_tests_assoc WHERE content_id='.$content['content_id'];
            //			$result = mysql_query($sql, $db);
            //			while ($row = mysql_fetch_assoc($result)){
            require_once TR_INCLUDE_PATH . 'classes/DAO/ContentTestsAssocDAO.class.php';
            $contentTestsAssocDAO = new ContentTestsAssocDAO();
            $rows = $contentTestsAssocDAO->getByContent($content['content_id']);
            if (is_array($rows)) {
                //add test dependency on top of forum dependency
                foreach ($rows as $row) {
                    $test_dependency .= $prefix . $space . '<dependency identifierref="MANIFEST01_RESOURCE_QTI' . $row['test_id'] . '" />';
                }
            }
            /* calculate how deep this page is: */
            $path = '../';
            if ($content['content_path']) {
                $depth = substr_count($content['content_path'], '/');
                $path .= str_repeat('../', $depth);
            }
            $content['text'] = ContentUtility::formatContent($content['text'], $content['formatting']);
            /* add HTML header and footers to the files */
            /* use default style if <style> is not in imported html head */
            $head = '';
            if ($content['use_customized_head']) {
                if (strpos(strtolower($content['head']), '<style') > 0) {
                    $head = $content['head'];
                } else {
                    if (strlen($content['head']) > 0) {
                        $head = $content['head'] . $default_html_style;
                    } else {
                        $head = $default_html_style;
                    }
                }
            }
            $content['text'] = str_replace(array('{TITLE}', '{CONTENT}', '{KEYWORDS}', '{COURSE_PRIMARY_LANGUAGE_CHARSET}', '{COURSE_PRIMARY_LANGUAGE_CODE}', '{HEAD}'), array($content['title'], $content['text'], $content['keywords'], $course_language_charset, $course_language_code, $head), $html_content_template);
            /* duplicate the paths in the content_path field in the zip file */
            if ($content['content_path']) {
                if (!in_array($content['content_path'], $paths)) {
                    $zipfile->create_dir('resources/' . $content['content_path'], time());
                    $paths[] = $content['content_path'];
                }
            }
            $zipfile->add_file($content['text'], 'resources/' . $content['content_path'] . $content['content_id'] . '.html', $content['u_ts']);
            $content['title'] = htmlspecialchars($content['title']);
            /* add the resource dependancies */
            if ($my_files == null) {
                $my_files = array();
            }
            $content_files = "\n";
            $parser->parse($content['text']);
            /* generate the IMS QTI resource and files */
            global $contentManager;
            //check if test export is allowed.
            $content_test_rs = $contentManager->getContentTestsAssoc($content['content_id']);
            $test_ids = array();
            //reset test ids
            //$my_files = array();		//reset myfiles.
            if (is_array($content_test_rs)) {
                foreach ($content_test_rs as $content_test_row) {
                    //export
                    $test_ids[] = $content_test_row['test_id'];
                    //the 'added_files' is for adding into the manifest file in this zip
                    $added_files = test_qti_export($content_test_row['test_id'], '', $zipfile);
                    //Save all the xml files in this array, and then print_organizations will add it to the manifest file.
                    foreach ($added_files as $filename => $file_array) {
                        $my_files[] = $filename;
                        foreach ($file_array as $garbage => $filename2) {
                            if (!in_array($filename2, $my_files)) {
                                $my_files[] = $filename2;
                            }
                        }
                    }
                    //Save all the xml files in this array, and then print_organizations will add it to the manifest file.
                    $resources .= str_replace(array('{TEST_ID}', '{PATH}', '{FILES}'), array($content_test_row['test_id'], 'tests_' . $content_test_row['test_id'] . '.xml', $added_files_xml), $ims_template_xml['resource_test']);
                }
            }
            /* generate the a4a files */
            $a4a_xml_array = array();
            //http://atutor.ca/atutor/mantis/view.php?id=4593
            if ($content['formatting'] === 0) {
                $use_a4a = false;
            }
            if ($use_a4a == true) {
                $a4aExport = new A4aExport($content['content_id']);
                //				$a4aExport->setRelativePath('resources/'.$content['content_path']);
                $secondary_files = $a4aExport->getAllSecondaryFiles();
                $a4a_xml_array = $a4aExport->exportA4a();
                $my_files = array_merge($my_files, $a4aExport->getAllSecondaryFiles());
            }
            /* handle @import */
            $import_files = get_import_files($content['text']);
            if (count($import_files) > 0) {
                $my_files = array_merge($my_files, $import_files);
            }
            foreach ($my_files as $file) {
                /* filter out full urls */
                $url_parts = @parse_url($file);
                if (isset($url_parts['scheme'])) {
                    continue;
                }
                /* file should be relative to content. let's double check */
                if (substr($file, 0, 1) == '/') {
                    continue;
                }
                $file_path = realpath(TR_CONTENT_DIR . $course_id . '/' . $content['content_path'] . $file);
                /* check if this file exists in the content dir, if not don't include it */
                if (file_exists($file_path) && is_file($file_path) && !in_array($file_path, $zipped_files)) {
                    $zipped_files[] = $file_path;
                    $dir = substr(dirname($file_path), strlen(TR_CONTENT_DIR . $course_id));
                    if (!in_array($dir, $paths) && $dir) {
                        $dir = str_replace('\\', '/', substr($dir, 1));
                        $zipfile->create_dir('resources/' . $dir, time());
                        $paths[] = $dir;
                    }
                    $file_info = stat($file_path);
                    //Fixes relative paths, so folder1/folder2/../file.jpg will become just folder1/file.jpg
                    $file_save_path = str_replace(TR_CONTENT_DIR . $course_id . DIRECTORY_SEPARATOR, '', $file_path);
                    $file_save_path = str_replace('\\', '/', $file_save_path);
                    //condition checks if the file has been added, so then the test won't be added to all the subchildren
                    //leads to normal images not capable to be extracted.
                    if ((empty($test_zipped_files) || is_array($test_zipped_files) && !in_array($file_path, $test_zipped_files)) && file_exists($file_path)) {
                        $zipfile->add_file(@file_get_contents($file_path), 'resources/' . $file_save_path, $file_info['mtime']);
                        //						$test_zipped_files[] = $content['content_path'] . $file;
                        $test_zipped_files[] = $file_path;
                    } elseif (!is_array($test_zipped_files) && file_exists($file_path) && !in_array($file_path, $zipped_files)) {
                        $zipfile->add_file(@file_get_contents($file_path), 'resources/' . $file_save_path, $file_info['mtime']);
                    }
                    //a4a secondary files have mapping, save the ones that we want in order to add the tag in
                    $a4a_secondary_files = array();
                    foreach ($a4a_xml_array as $a4a_filename => $a4a_filearray) {
                        if (preg_match('/(.*)\\sto\\s(.*)/', $a4a_filename, $matches)) {
                            //save the actual file name
                            $a4a_secondary_files[$matches[1]][] = $a4a_filename;
                            //values are holders
                        }
                    }
                    // If this file has a4a alternatives, link it.
                    if (isset($a4a_xml_array[$file]) || isset($a4a_secondary_files[$file])) {
                        //if this is an array, meaning that it has more than 1 alternatives, print all
                        if (is_array($a4a_secondary_files[$file])) {
                            $all_secondary_files_md = '';
                            //reinitialize string to null
                            foreach ($a4a_secondary_files[$file] as $v) {
                                foreach ($a4a_xml_array[$v] as $v2) {
                                    $all_secondary_files_md .= $v2;
                                    //all the meta data
                                }
                            }
                            $content_files .= str_replace(array('{FILE}', '{FILE_META_DATA}'), array('resources/' . $file_save_path, $all_secondary_files_md), $ims_template_xml['file_meta']);
                        } else {
                            $content_files .= str_replace(array('{FILE}', '{FILE_META_DATA}'), array('resources/' . $file_save_path, $a4a_xml_array[$file]), $ims_template_xml['file_meta']);
                        }
                    } else {
                        //if this file is in the test array, add an extra link to the direct file,
                        if (!empty($test_zipped_files) && in_array($file_path, $test_zipped_files)) {
                            $content_files .= str_replace('{FILE}', $file_save_path, $ims_template_xml['file']);
                        } else {
                            $content_files .= str_replace('{FILE}', $file_save_path, $ims_template_xml['file']);
                        }
                    }
                }
                /* check if this file is one of the test xml file, if so, we need to add the dependency
                 * Note:  The file has already been added to the archieve before this is called.
                 */
                /* taken out as of nov 17th, used dependency instead
                				if (preg_match('/tests\_[0-9]+\.xml$/', $file) && !in_array($file, $test_zipped_files)){
                					$content_files .= str_replace('{FILE}', $file, $ims_template_xml['xml']);
                					$test_zipped_files[] = $file;
                				}
                */
            }
            /******************************/
            $resources .= str_replace(array('{CONTENT_ID}', '{PATH}', '{FILES}', '{DEPENDENCY}'), array($content['content_id'], $content['content_path'], $content_files, $test_dependency), $ims_template_xml['resource']);
            for ($i = 0; $i < $depth; $i++) {
                $link .= $space;
            }
            $title = $prefix . $space . '<title>' . $content['title'] . '</title>';
            if (is_array($_menu[$content['content_id']])) {
                /* has children */
                $html_link = '<li>' . $html_link . '<ul>';
                for ($i = 0; $i < $depth; $i++) {
                    if ($children[$i] == 1) {
                        echo $space;
                        //$html_link = $space.$html_link;
                    } else {
                        echo $space;
                        //$html_link = $space.$html_link;
                    }
                }
            } else {
                /* doesn't have children */
                $html_link = '<li>' . $html_link . '</li>';
                if ($counter == $num_items) {
                    for ($i = 0; $i < $depth; $i++) {
                        if ($children[$i] == 1) {
                            echo $space;
                            //$html_link = $space.$html_link;
                        } else {
                            echo $space;
                            //$html_link = $space.$html_link;
                        }
                    }
                } else {
                    for ($i = 0; $i < $depth; $i++) {
                        echo $space;
                        //$html_link = $space.$html_link;
                    }
                }
                $title = $space . $title;
            }
            echo $prefix . $link;
            echo $title;
            echo "\n";
            $string .= $html_link . "\n";
            $depth++;
            print_organizations($content['content_id'], $_menu, $depth, $path . $counter . '.', $children, $string);
            $depth--;
            $counter++;
            for ($i = 0; $i < $depth; $i++) {
                echo $space;
            }
            echo $prefix . '</item>';
            echo "\n";
        }
        $string .= '</ul>';
        if ($depth > 0) {
            $string .= '</li>';
        }
    }
}
示例#9
0
if (defined('TR_FORCE_GET_FILE') && TR_FORCE_GET_FILE) {
    $course_base_href = 'get.php/';
} else {
    $course_base_href = 'content/' . $_course_id . '/';
}
if ($content_row['content_path']) {
    $content_base_href .= $content_row['content_path'] . '/';
}
$popup = intval($_GET['popup']);
require TR_INCLUDE_PATH . 'header.inc.php';
?>
	<div class="row">
	<?php 
echo '<h2>' . AT_print($stripslashes($_POST['title']), 'content.title') . '</h2>';
if ($_POST['formatting'] == CONTENT_TYPE_WEBLINK) {
    $url = $_POST['weblink_text'];
    $validated_url = isValidURL($url);
    if (!validated_url || $validated_url !== $url) {
        $msg->addError(array('INVALID_INPUT', _AT('weblink')));
        $msg->printErrors();
    } else {
        echo ContentUtility::formatContent($url, $_POST['formatting']);
    }
} else {
    echo ContentUtility::formatContent($stripslashes($_POST['body_text']), $_POST['formatting']);
}
?>
		
	</div>
<?php 
require TR_INCLUDE_PATH . 'footer.inc.php';
示例#10
0
/**
 * 	Transforms text based on formatting preferences.  Original $input is also changed (passed by reference).
 *	Can be called as:
 *	1) $output = AT_print($input, $name);
 *	   echo $output;
 *
 *	2) echo AT_print($input, $name); // prefered method
 *
 * @access	public
 * @param	string $input			text being transformed
 * @param	string $name			the unique name of this field (convension: table_name.field_name)
 * @param	boolean $runtime_html	forcefully disables html formatting for $input (only used by fields that 
 *									have the 'formatting' option
 * @return	string					transformed $input
 * @see		TR_FORMAT constants		in include/lib/constants.inc.php
 * @see		query_bit()				in include/vitals.inc.php
 * @author	Joel Kronenberg
 */
function AT_print($input, $name, $runtime_html = true)
{
    global $_field_formatting;
    if (!isset($_field_formatting[$name])) {
        /* field not set, check if there's a global setting */
        $parts = explode('.', $name);
        /* check if wildcard is set: */
        if (isset($_field_formatting[$parts[0] . '.*'])) {
            $name = $parts[0] . '.*';
        } else {
            /* field not set, and there's no global setting */
            /* same as TR_FORMTR_NONE */
            return $input;
        }
    }
    if (query_bit($_field_formatting[$name], TR_FORMTR_QUOTES)) {
        $input = str_replace('"', '&quot;', $input);
    }
    if (query_bit($_field_formatting[$name], TR_FORMTR_CONTENT_DIR)) {
        $input = str_replace('CONTENT_DIR/', '', $input);
    }
    if (query_bit($_field_formatting[$name], TR_FORMTR_HTML) && $runtime_html) {
        /* what special things do we have to do if this is HTML ? remove unwanted HTML? validate? */
    } else {
        $input = str_replace('<', '&lt;', $input);
        $input = nl2br($input);
    }
    /* this has to be here, only because TR_FORMTR_HTML is the only check that has an else-block */
    if ($_field_formatting[$name] === TR_FORMTR_NONE) {
        return $input;
    }
    if (query_bit($_field_formatting[$name], TR_FORMTR_EMOTICONS)) {
        $input = smile_replace($input);
    }
    if (query_bit($_field_formatting[$name], TR_FORMTR_ATCODES)) {
        $input = trim(ContentUtility::myCodes(' ' . $input . ' '));
    }
    if (query_bit($_field_formatting[$name], TR_FORMTR_LINKS)) {
        $input = trim(ContentUtility::makeClickable(' ' . $input . ' '));
    }
    if (query_bit($_field_formatting[$name], TR_FORMTR_IMAGES)) {
        $input = trim(ContentUtility::imageReplace(' ' . $input . ' '));
    }
    return $input;
}