本文整理汇总了PHP中EfrontLesson::getDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP EfrontLesson::getDirectory方法的具体用法?PHP EfrontLesson::getDirectory怎么用?PHP EfrontLesson::getDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EfrontLesson
的用法示例。
在下文中一共展示了EfrontLesson::getDirectory方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: EfrontUnit
$legalValues[] = $key;
}
if (isset($_GET['add']) || isset($_GET['edit']) && in_array($_GET['edit'], $legalValues) && eF_checkParameter($_GET['edit'], 'id') && $_change_) {
try {
if ($_GET['edit']) {
$currentUnit = $currentContent->seekNode($_GET['edit']);
//The content tree does not hold data, so assign this unit its data
$unitData = new EfrontUnit($_GET['edit']);
$currentUnit['data'] = $unitData['data'];
$currentUnitName = $unitData['name'];
} else {
unset($currentUnit);
//Needed because we might have the &view_unit specified in the parameters
}
//This page has a file manager, so bring it on with the correct options
$basedir = $currentLesson->getDirectory();
//Default options for the file manager
if (!isset($currentUser->coreAccess['files']) || $currentUser->coreAccess['files'] == 'change') {
$options = array('lessons_ID' => $currentLesson->lesson['id'], 'metadata' => 0);
if (!$currentLesson->options['digital_library']) {
$options['share'] = false;
}
} else {
$options = array('delete' => false, 'edit' => false, 'share' => false, 'upload' => false, 'create_folder' => false, 'zip' => false, 'lessons_ID' => $currentLesson->lesson['id'], 'metadata' => 0);
}
//Default url for the file manager
$url = basename($_SERVER['PHP_SELF']) . '?ctg=content&' . (isset($_GET['edit']) ? 'edit=' . $_GET['edit'] : 'add=1');
$extraFileTools = array(array('image' => 'images/16x16/arrow_right.png', 'title' => _INSERTEDITOR, 'action' => 'insert_editor'));
/**The file manager*/
include "file_manager.php";
//This page also needs an editor and ASCIIMathML
示例2: catch
try {
$currentUser = EfrontUserFactory::factory($_SESSION['s_login']);
} catch (EfrontException $e) {
$message = $e->getMessage() . ' (' . $e->getCode() . ')';
eF_redirect("index.php?message=" . urlencode($message) . "&message_type=failure");
exit;
}
} else {
eF_redirect("index.php?message=" . urlencode(_YOUCANNOTACCESSTHISPAGE) . "&message_type=failure");
exit;
}
try {
//There are 2 legal modes: 'lessons' and 'external'. In the first case, we read the legitimate directory from the session. In the second case, we take it from global constant
if ($_GET['mode'] == 'lesson') {
$currentLesson = new EfrontLesson($_SESSION['s_lessons_ID']);
$rootDir = new EfrontDirectory($currentLesson->getDirectory());
$filesBaseUrl = $currentLesson->getDirectoryUrl();
} elseif ($_GET['mode'] == 'external') {
$rootDir = new EfrontDirectory(G_EXTERNALPATH);
$filesBaseUrl = G_EXTERNALURL;
} elseif ($_GET['mode'] == 'upload') {
$rootDir = new EfrontDirectory(G_UPLOADPATH . $_SESSION['s_login']);
$filesBaseUrl = G_UPLOADPATH . $_SESSION['s_login'];
} else {
throw new Exception(_ILLEGALMODE);
}
//We are inside a directory. Verify that this directory is below the $rootDir, as defined previously
if (isset($_GET['directory'])) {
$directory = new EfrontDirectory($_GET['directory']);
if (strpos($directory['path'], $rootDir['path']) === false) {
$directory = $rootDir;
示例3: copySimpleUnit
/**
* Copy simple unit
*
* This function copies a unit (NOT its children) into the current content tree
* <br/>Example:
* <code>
* $currentContent = new EfrontContentTree(5); //Initialize content for lesson with id 5
* $sourceUnit = new EfrontUnit(20); //Get the unit with id = 20
* $currentContent -> copySimpleUnit($sourceUnit, false); //Copy the source unit into the content tree (at its end)
* </code>
*
* @param EfrontUnit $sourceUnit The unit object to be copied
* @param mixed $targetUnit The id of the parent unit (or the parent EfrontUnit)in which the new unit will be copied, or false (the unit will be appended at the end)
* @param mixed $previousUnit The id of the previous unit (or the unit itself) of the new unit, or false (the unit will be put to the end of the units)
* @param boolean $copyFiles whether to copy files as well.
* @param boolean $copyQuestions Whether to copy questions as well
* @return EfrontUnit The newly created unit object
* @since 3.5.0
* @access public
*/
public function copySimpleUnit($sourceUnit, $targetUnit = false, $previousUnit = false, $copyFiles = true, $copyQuestions = true)
{
if (!$sourceUnit instanceof EfrontUnit) {
$sourceUnit = new EfrontUnit($sourceUnit);
}
$newUnit['name'] = $sourceUnit->offsetGet('name');
$newUnit['ctg_type'] = $sourceUnit->offsetGet('ctg_type');
$newUnit['data'] = $sourceUnit->offsetGet('data');
$options = $sourceUnit->offsetGet('options');
$newOptions['complete_unit_setting'] = $options['complete_unit_setting'];
$newOptions['hide_navigation'] = $options['hide_navigation'];
$newOptions['maximize_viewport'] = $options['maximize_viewport'];
$newOptions['object_ids'] = $options['object_ids'];
$newUnit['options'] = serialize($newOptions);
$newUnit['lessons_ID'] = $this->lessonId;
if ($targetUnit) {
if ($targetUnit instanceof EfrontUnit) {
$newUnit['parent_content_ID'] = $targetUnit->offsetGet('id');
} else {
if (eF_checkParameter($targetUnit, 'id')) {
$newUnit['parent_content_ID'] = $targetUnit;
}
}
if ($previousUnit instanceof EfrontUnit) {
$newUnit['previous_content_ID'] = $previousUnit->offsetGet('id');
} else {
if (eF_checkParameter($previousUnit, 'id')) {
$newUnit['previous_content_ID'] = $previousUnit;
}
}
$unit = $this->insertNode($newUnit);
} else {
$unit = $this->appendUnit($newUnit);
}
if ($copyFiles) {
$files = $unit->getFiles();
$lesson = new EfrontLesson($this->lessonId);
$data = $unit->offsetGet('data');
foreach ($files as $file) {
try {
$sourceFile = new EfrontFile($file);
$sourceFileOffset = preg_replace("#" . G_LESSONSPATH . "#", "", $sourceFile['directory']);
$position = strpos($sourceFileOffset, "/");
//check case that the file is in a subfolder of the lesson
if ($position !== false) {
$sourceLink = mb_substr($sourceFileOffset, $position + 1);
mkdir($lesson->getDirectory() . $sourceLink . '/', 0755, true);
$destinationPath = $lesson->getDirectory() . $sourceLink . '/' . basename($sourceFile['path']);
$copiedFile = $sourceFile->copy($destinationPath, false);
} else {
$destinationPath = $lesson->getDirectory() . basename($sourceFile['path']);
$copiedFile = $sourceFile->copy($destinationPath, false);
}
//@todo view_file.php?action=download&file=10410
//$data = str_replace("view_file.php?file=".$file, "view_file.php?file=".$copiedFile -> offsetGet('id'), $data);
//$data = str_replace("&file=".$file, "&file=".$copiedFile -> offsetGet('id'), $data);
//$data = str_replace("&file=".$file, "&file=".$copiedFile -> offsetGet('id'), $data);
$data = preg_replace('#view_file\\.php(.*)file=' . $file . '#', 'view_file.php${1}file=' . $copiedFile->offsetGet('id'), $data);
$folderId = $lesson->lesson['share_folder'] ? $lesson->lesson['share_folder'] : $lesson->lesson['id'];
$data = preg_replace("#(" . G_SERVERNAME . ")*content/lessons/" . $sourceUnit['lessons_ID'] . "/(.*)#", "content/lessons/" . $folderId . '/${2}', $data);
} catch (EfrontFileException $e) {
if ($e->getCode() == EfrontFileException::FILE_ALREADY_EXISTS) {
$copiedFile = new EfrontFile($destinationPath);
//$data = str_replace("view_file.php?file=".$file, "view_file.php?file=".$copiedFile -> offsetGet('id'), $data);
//$data = str_replace("&file=".$file, "&file=".$copiedFile -> offsetGet('id'), $data);
//$data = str_replace("&file=".$file, "&file=".$copiedFile -> offsetGet('id'), $data);
$data = preg_replace('#view_file\\.php(.*)file=' . $file . '#', 'view_file.php${1}file=' . $copiedFile->offsetGet('id'), $data);
$folderId = $lesson->lesson['share_folder'] ? $lesson->lesson['share_folder'] : $lesson->lesson['id'];
$data = preg_replace("#(" . G_SERVERNAME . ")*content/lessons/" . $sourceUnit['lessons_ID'] . "/(.*)#", "content/lessons/" . $folderId . '/${2}', $data, -1, $count);
}
}
//this means that the file already exists
}
$unit->offsetSet('data', $data);
if ($file && $unit['ctg_type'] == 'scorm' || $unit['ctg_type'] == 'scorm_test') {
$d = new EfrontDirectory(dirname($file));
$d->copy($lesson->getDirectory() . basename(dirname($file)), true);
}
}
$unit->persist();
//.........这里部分代码省略.........
示例4: DOMDocument
/**
* Parse the html and remove <head></head> part if present into html
*
* @param String $html
* @return void
* @access Private
*/
function _parseHtml($html)
{
$html = preg_replace("/<!DOCTYPE((.|\n)*?)>/ims", "", $html);
$html = preg_replace("/<script((.|\n)*?)>((.|\n)*?)<\\/script>/ims", "", $html);
preg_match("/<head>((.|\n)*?)<\\/head>/ims", $html, $matches);
$head = $matches[1];
preg_match("/<title>((.|\n)*?)<\\/title>/ims", $head, $matches);
$this->title = $matches[1];
$html = preg_replace("/<head>((.|\n)*?)<\\/head>/ims", "", $html);
$head = preg_replace("/<title>((.|\n)*?)<\\/title>/ims", "", $head);
$head = preg_replace("/<\\/?head>/ims", "", $head);
$html = preg_replace("/<\\/?body((.|\n)*?)>/ims", "", $html);
$this->htmlHead = $head;
$DOM = new DOMDocument();
$DOM->loadHTML($html);
$imgs = $DOM->getElementsByTagName('img');
foreach ($imgs as $img) {
$src = $img->getAttribute('src');
if (strpos($src, "http://") === false) {
//local image
if (strpos($src, 'content/lessons') !== false) {
$pos = strrpos($src, '/');
$tmp_img = substr($src, $pos + 1);
$path = substr($src, 0, strlen($src) - strlen($tmp_img));
$this->localimgs[] = array('src' => $tmp_img, 'path' => G_ROOTPATH . "www/" . $path);
$src = $tmp_img;
}
if (strpos($src, 'images/16x16') !== false) {
$pos = strrpos($src, '/');
$tmp_img = substr($src, $pos + 1);
$path = substr($src, 0, strlen($src) - strlen($tmp_img));
$this->localimgs[] = array('src' => $tmp_img, 'path' => G_DEFAULTTHEMEPATH . "www/" . $path);
$src = $tmp_img;
}
}
$img->setAttribute('src', $src);
}
$html = $DOM->saveHTML();
$lesson = new EfrontLesson($_SESSION['s_lessons_ID']);
$this->lessonDirectory = $lesson->getDirectory();
$this->htmlBody = $html;
return;
}
示例5: import
//.........这里部分代码省略.........
case 'IMSSS:DELIVERYCONTROLS':
$delivery_controls[$item_key][$key]['objective_set_by_content'] = $value['attributes']['OBJECTIVESETBYCONTENT'];
$delivery_controls[$item_key][$key]['completion_set_by_content'] = $value['attributes']['COMPLETIONSETBYCONTENT'];
$delivery_controls[$item_key][$key]['tracked'] = $value['attributes']['TRACKED'];
break;
case 'ADLCP:MAP':
$maps[$item_key][$key]['target_ID'] = $value['attributes']['TARGETID'];
$maps[$item_key][$key]['read_shared_data'] = $value['attributes']['READSHAREDDATA'];
$maps[$item_key][$key]['write_shared_data'] = $value['attributes']['WRITESHAREDDATA'];
break;
default:
break;
}
}
// exit();
if (G_VERSIONTYPE != 'community') {
#cpp#ifndef COMMUNITY
if (G_VERSIONTYPE != 'standard') {
#cpp#ifndef STANDARD
if ($scorm2004) {
foreach ($references as $key => $value) {
$ref = array_search($value['IDENTIFIERREF'], $resources);
if ($ref !== false && !is_null($ref)) {
/*SCORM 2004: The xml:base attribute provides a relative path offset for the content file(s) contained in the manifest*/
$path_offset = $tagArray[$ref]['attributes']['XML:BASE'];
$data = file_get_contents($scormPath . "/" . $path_offset . $tagArray[$ref]['attributes']['HREF']);
$primitive_hrefs[$ref] = str_replace("\\", "/", $path_offset . $tagArray[$ref]['attributes']['HREF']);
$path_part[$ref] = dirname($primitive_hrefs[$ref]);
foreach ($tagArray[$ref]['children'] as $value2) {
if ($tagArray[$value2]['tag'] == 'DEPENDENCY') {
$idx = array_search($tagArray[$value2]['attributes']['IDENTIFIERREF'], $resources);
foreach ($tagArray[$idx]['children'] as $value3) {
if ($tagArray[$value3]['tag'] == 'FILE') {
$data = preg_replace("#(\\.\\.\\/(\\w+\\/)*)?" . $tagArray[$value3]['attributes']['HREF'] . "#", $currentLesson->getDirectory() . "/" . $scormFolderName . '/' . $path_part[$ref] . "/\$1" . $tagArray[$value3]['attributes']['HREF'], $data);
}
}
}
}
//$total_fields[$key]['data'] = eF_postProcess(str_replace("'","'",$data));
//$total_fields$adl_seq_map_info[$item_key][$key]['target_objective_ID'[$key]['data'] = '<iframe height = "100%" width = "100%" frameborder = "no" name = "scormFrameName" id = "scormFrameID" src = "'.G_RELATIVELESSONSLINK.$lessons_ID."/".$scormFolderName.'/'.$primitive_hrefs[$ref]. $value['PARAMETERS']. '" onload = "eF_js_setCorrectIframeSize()"></iframe><iframe name = "commitFrame" frameborder = "no" id = "commitFrame" width = "1" height = "1" style = "display:none"></iframe>';
//
//
//
if ($parameters['embed_type'] == 'iframe') {
$total_fields[$key]['data'] = '<iframe ' . $parameters['iframe_parameters'] . ' name = "scormFrameName" id = "scormFrameID" src = "' . rtrim($currentLesson->getDirectoryUrl(), "/") . "/" . $scormFolderName . '/' . $primitive_hrefs[$ref] . $value['PARAMETERS'] . '" onload = "if (window.eF_js_setCorrectIframeSize) {eF_js_setCorrectIframeSize();} else {setIframeSize = true;}"></iframe>';
} else {
$total_fields[$key]['data'] = '
<div style = "text-align:center;height:300px">
<span>##CLICKTOSTARTUNIT##</span><br/>
<input type = "button" value = "##STARTUNIT##" class = "flatButton" onclick = \'window.open("' . rtrim($currentLesson->getDirectoryUrl(), "/") . "/" . rawurlencode($scormFolderName) . '/' . rawurlencode($primitive_hrefs[$ref]) . $value['PARAMETERS'] . '", "scormFrameName", "' . $parameters['popup_parameters'] . '")\' >
</div>';
}
/*
$total_fields[$key]['data'] = '
<style>
iframe.scormCommitFrame{width:100%;height:500px;border:1px solid red;}
</style>
<iframe name = "scormFrameName" id = "scormFrameID" class = "scormFrame" src = "'.$currentLesson -> getDirectoryUrl()."/".$scormFolderName.'/'.$primitive_hrefs[$ref]. $value['PARAMETERS']. '" onload = "eF_js_setCorrectIframeSize()"></iframe>
<iframe name = "commitFrame" id = "commitFrame" class = "scormCommitFrame">Sorry, but your browser needs to support iframes to see this</iframe>';
*/
}
}
$lastUnit = $currentContent->getLastNode();
$lastUnit ? $this_id = $lastUnit['id'] : ($this_id = 0);
//$this_id = $tree[sizeof($tree) - 1]['id'];
foreach ($total_fields as $key => $value) {
示例6: replaceQuestionPaths
function replaceQuestionPaths($data, $sourceId, $newId)
{
//$data = $question['text'];
preg_match_all("/view_file\\.php\\?file=(\\d+)/", $data, $matchesId);
$filesId = $matchesId[1];
preg_match_all("#(" . G_SERVERNAME . ")*content/lessons/(.*)\"#U", $data, $matchesPath);
$filesPath = $matchesPath[2];
foreach ($filesId as $file) {
$files[] = $file;
}
foreach ($filesPath as $file) {
$files[] = G_LESSONSPATH . html_entity_decode($file);
}
$lesson = new EfrontLesson($newId);
//$data = $unit -> offsetGet('data');
foreach ($files as $file) {
try {
$sourceFile = new EfrontFile($file);
$sourceFileOffset = preg_replace("#" . G_LESSONSPATH . "#", "", $sourceFile['directory']);
$position = strpos($sourceFileOffset, "/");
//check case that the file is in a subfolder of the lesson
if ($position !== false) {
$sourceLink = mb_substr($sourceFileOffset, $position + 1);
mkdir($lesson->getDirectory() . $sourceLink . '/', 0755, true);
$destinationPath = $lesson->getDirectory() . $sourceLink . '/' . basename($sourceFile['path']);
$copiedFile = $sourceFile->copy($lesson->getDirectory() . $sourceLink . '/' . basename($sourceFile['path']), false);
} else {
$destinationPath = $lesson->getDirectory() . basename($sourceFile['path']);
$copiedFile = $sourceFile->copy($lesson->getDirectory() . basename($sourceFile['path']), false);
}
str_replace("view_file.php?file=" . $file, "view_file.php?file=" . $copiedFile->offsetGet('id'), $data);
$data = preg_replace("#(" . G_SERVERNAME . ")*content/lessons/" . $sourceId . "/(.*)#", "content/lessons/" . $newId . '/${2}', $data);
} catch (EfrontFileException $e) {
if ($e->getCode() == EfrontFileException::FILE_ALREADY_EXISTS) {
$copiedFile = new EfrontFile($destinationPath);
str_replace("view_file.php?file=" . $file, "view_file.php?file=" . $copiedFile->offsetGet('id'), $data);
$data = preg_replace("#(" . G_SERVERNAME . ")*content/lessons/" . $sourceId . "/(.*)#", "content/lessons/" . $newId . '/${2}', $data, -1, $count);
}
}
//this means that the file already exists
}
//$question['text'] = $data;
return $data;
}
示例7: import
/**
*
* @param unknown_type $file
* @return unknown_type
*/
public static function import($lesson, $manifestFile, $scormFolderName, $parameters)
{
if ($lesson instanceof EfrontLesson) {
$currentLesson = $lesson;
} else {
$currentLesson = new EfrontLesson($lesson);
}
$lessons_ID = $currentLesson->lesson['id'];
$currentContent = new EfrontContentTree($currentLesson);
$manifestXML = file_get_contents($manifestFile['path']);
$tagArray = EfrontIMS::parseManifest($manifestXML);
/**
* Now parse XML file as usual
*/
foreach ($tagArray as $key => $value) {
$fields = array();
switch ($value['tag']) {
case 'SCHEMAVERSION':
$scormVersion = $value['value'];
break;
case 'TITLE':
$cur = $value['parent_index'];
$total_fields[$cur]['name'] = $value['value'] ? $value['value'] : " ";
break;
case 'ORGANIZATION':
$item_key = $key;
$total_fields[$key]['lessons_ID'] = $lessons_ID;
$total_fields[$key]['timestamp'] = time();
$total_fields[$key]['ctg_type'] = 'theory';
$total_fields[$key]['identifier'] = $value['attributes']['IDENTIFIER'];
$total_fields[$key]['active'] = !isset($value['attributes']['ISVISIBLE']) || $value['attributes']['ISVISIBLE'] == 'true' ? 1 : 0;
break;
case 'ITEM':
$item_key = $key;
$total_fields[$key]['lessons_ID'] = $lessons_ID;
$total_fields[$key]['timestamp'] = time();
$total_fields[$key]['ctg_type'] = 'theory';
$total_fields[$key]['identifier'] = $value['attributes']['IDENTIFIER'];
$total_fields[$key]['active'] = !isset($value['attributes']['ISVISIBLE']) || $value['attributes']['ISVISIBLE'] == 'true' ? 1 : 0;
$references[$key]['IDENTIFIERREF'] = EfrontIMS::formID($value['attributes']['IDENTIFIERREF']);
$references[$key]['PARAMETERS'] = $value['attributes']['PARAMETERS'];
break;
case 'RESOURCE':
$resources[$key] = EfrontIMS::formID($value['attributes']['IDENTIFIER']);
break;
case 'FILE':
$files[$key] = $value['attributes']['HREF'];
break;
default:
break;
}
}
foreach ($references as $key => $value) {
$ref = array_search($value['IDENTIFIERREF'], $resources);
if ($ref !== false && !is_null($ref)) {
/*SCORM 2004: The xml:base attribute provides a relative path offset for the content file(s) contained in the manifest*/
$path_offset = $tagArray[$ref]['attributes']['XML:BASE'];
if ($tagArray[$ref]['attributes']['TYPE'] == 'imswl_xmlv1p2') {
foreach ($tagArray[$ref]['children'] as $node) {
if ($tagArray[$node]['tag'] == 'FILE') {
$href = $tagArray[$node]['attributes']['HREF'];
//debug();
//pr($currentLesson -> getDirectory()."/".$scormFolderName."/".$path_offset.$href);
$data = file_get_contents($currentLesson->getDirectory() . "/" . $scormFolderName . "/" . $path_offset . $href);
file_put_contents($currentLesson->getDirectory() . "/" . $scormFolderName . "/" . $path_offset . dirname($href) . '/weblink.html', self::createWebLink($data));
$href = dirname($href) . '/weblink.html';
//exit;
//pr($data);exit;
}
}
} else {
if (!$tagArray[$ref]['attributes']['HREF']) {
foreach ($tagArray[$ref]['children'] as $node) {
if ($tagArray[$node]['tag'] == 'FILE') {
$href = $tagArray[$node]['attributes']['HREF'];
}
}
} else {
$href = $tagArray[$ref]['attributes']['HREF'];
}
}
$data = file_get_contents($currentLesson->getDirectory() . "/" . $scormFolderName . "/" . $path_offset . $href);
$primitive_hrefs[$ref] = $path_offset . $href;
$path_part[$ref] = dirname($primitive_hrefs[$ref]);
foreach ($tagArray[$ref]['children'] as $value2) {
if ($tagArray[$value2]['tag'] == 'DEPENDENCY') {
$idx = array_search($tagArray[$value2]['attributes']['IDENTIFIERREF'], $resources);
foreach ($tagArray[$idx]['children'] as $value3) {
if ($tagArray[$value3]['tag'] == 'FILE') {
$data = preg_replace("#(\\.\\.\\/(\\w+\\/)*)?" . $tagArray[$value3]['attributes']['HREF'] . "#", $currentLesson->getDirectory() . "/" . $scormFolderName . '/' . $path_part[$ref] . "/\$1" . $tagArray[$value3]['attributes']['HREF'], $data);
}
}
}
}
if ($parameters['embed_type'] == 'iframe') {
//.........这里部分代码省略.........