diff --git a/CourseEditorOperations.php b/CourseEditorOperations.php
index fa7ed28..fad2e5e 100644
--- a/CourseEditorOperations.php
+++ b/CourseEditorOperations.php
@@ -1,462 +1,466 @@
courseName);
$template = "{{". $wgCourseEditorTemplates['ReadyToBePublished'] ."}}";
$category = "[[" . $wgContLang->getNsText( NS_CATEGORY ) . ":". $wgCourseEditorCategories['ReadyToBePublished'] ."]]";
$result = CourseEditorUtils::editWrapper($title, null, $template, $category);
CourseEditorUtils::setSingleOperationSuccess($operation, $result);
return json_encode($operation);
}
/**
* Remove the publish category and templte from the course root page
* @param string $operationRequested JSON object with operation type and all
* params used to public the course like the title
* @return string $operation JSON object with all the sended params plus
* a success field
*/
public static function undoPublishCourseOp($operationRequested){
global $wgCourseEditorTemplates, $wgCourseEditorCategories, $wgContLang;
$operation = json_decode($operationRequested);
$title = Title::newFromText($operation->courseName);
$page = WikiPage::factory($title);
$pageText = $page->getText();
$category = "[[" . $wgContLang->getNsText( NS_CATEGORY ) . ":". $wgCourseEditorCategories['ReadyToBePublished'] ."]]";
$template = "{{". $wgCourseEditorTemplates['ReadyToBePublished'] ."}}";
$replacedText = str_replace($category, "", $pageText);
$newPageText = str_replace($template, "", $replacedText);
$result = CourseEditorUtils::editWrapper($title, $newPageText, null, null);
CourseEditorUtils::setSingleOperationSuccess($operation, $result);
$operation->newPageText = $newPageText;
return json_encode($operation);
}
/**
* Like a Façade. It's an entrypoint for course create process
* independently if the course is private/public etc.
* @param string $operationRequested JSON object with operation type and all
* params used to create the course (name, topic, ...)
* @return string $operation JSON object with all the sended params plus
* a success field and the course complete title(with namespace)
*/
public static function createCourseOp($operationRequested){
$operation = json_decode($operationRequested);
switch ($operation->type) {
case 'fromTopic':
$result = self::createNewCourseFromTopic($operation);
CourseEditorUtils::setComposedOperationSuccess($operation, $result);
break;
case 'fromDepartment':
$result = self::createNewCourseFromDepartment($operation);
CourseEditorUtils::setComposedOperationSuccess($operation, $result);
break;
}
return json_encode($operation);
}
public static function manageCourseMetadataOp($operationRequested){
$operation = json_decode($operationRequested);
$params = $operation->params;;
$title = $params[0];
$topic = $params[1];
$description = $params[2];
$bibliography = $params[3];
$exercises = $params[4];
$books = $params[5];
$externalReferences = $params[6];
$isImported = $params[7];
$originalAuthors = $params[8];
$isReviewed = $params[9];
$reviewedOn = $params[10];
$pageTitle = MWNamespace::getCanonicalName(NS_COURSEMETADATA) . ':' . $title;
$metadata = "" . $topic . "\r\n";
if($description !== '' && $description !== null){
$metadata .= "" . $description . "\r\n";
}
if($bibliography !== '' && $bibliography !== null){
$metadata .= "" . $bibliography . "\r\n";
}
if($exercises !== '' && $exercises !== null){
$metadata .= "" . $exercises . "\r\n";
}
if($books !== '' && $books !== null){
$metadata .= "" . $books . "\r\n";
}
if($externalReferences !== '' && $externalReferences !== null){
$metadata .= "" . $externalReferences . "\r\n";
}
if($isImported !== false || $isReviewed !== false){
$metadata .= "" . true . "\r\n";
if($isImported !== false){
$metadata .= "" . $isImported . "\r\n";
$metadata .= "" . $originalAuthors . "\r\n";
}
if($isReviewed !== false){
$metadata .= "" . $isReviewed . "\r\n";
$metadata .= "" . $reviewedOn . "\r\n";
}
}
$resultCreateMetadataPage = CourseEditorUtils::editWrapper($pageTitle, $metadata , null, null);
- CourseEditorUtils::setSingleOperationSuccess($operation, $resultCreateMetadataPage);
+ $resultPurgeCourse = CourseEditorUtils::purgeWrapper($pageTitle);
+ CourseEditorUtils::setComposedOperationSuccess($operation, [$resultCreateMetadataPage, $resultPurgeCourse]);
return json_encode($operation);
}
private function createBasicCourseMetadata($topic, $title, $description){
//Remove username from title (if present) to be used as topic if $topic is null
$explodedString = explode('/', $title, 2);
$titleNoUser = (sizeof($explodedString) === 1) ? $explodedString[0] : $explodedString[1] ;
$topic = ($topic === null ? $titleNoUser : $topic);
$pageTitle = MWNamespace::getCanonicalName(NS_COURSEMETADATA) . ':' . $title;
$metadata = "" . $topic . "\r\n";
if($description !== '' && $description !== null){
$metadata .= "" . $description . "\r\n";
}
$apiResult = CourseEditorUtils::editWrapper($pageTitle, $metadata , null, null);
return $apiResult;
}
private function createNewCourseFromDepartment(&$operation){
$params = $operation->params;
$department = $params[0];
$title = $params[1];
$description = $params[2];
$namespace = $params[3];
if($department != null && $title != null && $namespace != null){
$compareResult = strcmp($namespace, 'NS_COURSE');
$namespaceCostant = ($compareResult == 0 ? NS_COURSE : NS_USER);
$pageTitle = MWNamespace::getCanonicalName($namespaceCostant) . ':';
if($namespaceCostant == NS_USER){
$result = self::createPrivateCourse($pageTitle, $topic, $title, $description);
$user = CourseEditorUtils::getRequestContext()->getUser();
$userPage = $pageTitle . $user->getName();
$operation->courseTitle = $userPage . '/' . $title;
}else{
$result = self::createPublicCourseFromDepartment($pageTitle, $department, $title, $description);
$operation->courseTitle = $pageTitle . $title;
}
}
return $result;
}
private function createNewCourseFromTopic(&$operation){
$params = $operation->params;
$topic = $params[0];
$title = $params[1];
$description = $params[2];
$namespace = $params[3];
if($topic != null && $title != null && $namespace != null){
$compareResult = strcmp($namespace, 'NS_COURSE');
$namespaceCostant = ($compareResult === 0 ? NS_COURSE : NS_USER);
$pageTitle = MWNamespace::getCanonicalName($namespaceCostant) . ':';
if($namespaceCostant == NS_USER){
$result = self::createPrivateCourse($pageTitle, $topic, $title, $description);
$user = CourseEditorUtils::getRequestContext()->getUser();
$userPage = $pageTitle . $user->getName();
$operation->courseTitle = $userPage . '/' . $title;
}else{
$result = self::createPublicCourseFromTopic($pageTitle, $topic, $title, $description);
$operation->courseTitle = $pageTitle . $title;
}
}
return $result;
}
private function createPrivateCourse($pageTitle, $topic, $title, $description){
global $wgCourseEditorTemplates, $wgCourseEditorCategories, $wgContLang;
$context = CourseEditorUtils::getRequestContext();
$user = $context->getUser();
$userPage = $pageTitle . $user->getName();
$titleWithUser = $user->getName() . '/' . $title;
$pageTitle = $userPage . "/" . $title;
$courseText = "{{". $wgCourseEditorTemplates['CourseRoot'] ."|}}\r\n[["
. $wgContLang->getNsText( NS_CATEGORY ) . ":". $wgCourseEditorCategories['CourseRoot'] ."]]";
$resultCreateCourse = CourseEditorUtils::editWrapper($pageTitle, $courseText, null, null);
$resultCreateMetadataPage = self::createBasicCourseMetadata($topic, $titleWithUser, $description);
$textToPrepend = "{{". $wgCourseEditorTemplates['Course'] ."|" . $title . "|" . $user->getName() . "}}";
$resultPrependToUserPage = CourseEditorUtils::editWrapper($userPage, null, $textToPrepend, null);
- return array($resultCreateCourse, $resultCreateMetadataPage, $resultPrependToUserPage);
+ $resultPurgeCourse = CourseEditorUtils::purgeWrapper($pageTitle);
+ return array($resultCreateCourse, $resultCreateMetadataPage, $resultPrependToUserPage, $resultPurgeCourse);
}
private function createPublicCourseFromTopic($pageTitle, $topic, $title, $description){
global $wgCourseEditorTemplates, $wgCourseEditorCategories, $wgContLang;
$pageTitle .= $title;
$courseText = "{{". $wgCourseEditorTemplates['CourseRoot'] ."|}}\r\n[["
. $wgContLang->getNsText( NS_CATEGORY ) . ":". $wgCourseEditorCategories['CourseRoot'] ."]]";
$resultCreateCourse = CourseEditorUtils::editWrapper($pageTitle, $courseText, null, null);
$topicCourses = CourseEditorUtils::getTopicCourses($topic);
$text = $topicCourses . "{{". $wgCourseEditorTemplates['Course'] ."|" . $title . "}}}}";
$resultCreateMetadataPage = self::createBasicCourseMetadata($topic, $title, $description);
$resultAppendToTopic = CourseEditorUtils::editWrapper($topic, $text, null, null);
- return array($resultCreateCourse, $resultCreateMetadataPage, $resultAppendToTopic);
+ $resultPurgeCourse = CourseEditorUtils::purgeWrapper($pageTitle);
+ return array($resultCreateCourse, $resultCreateMetadataPage, $resultAppendToTopic, $resultPurgeCourse);
}
private function createPublicCourseFromDepartment($pageTitle, $department, $title, $description){
global $wgCourseEditorTemplates, $wgCourseEditorCategories, $wgContLang;
$pageTitle .= $title;
$courseText = "{{". $wgCourseEditorTemplates['CourseRoot'] ."|}}\r\n[["
. $wgContLang->getNsText( NS_CATEGORY ) . ":". $wgCourseEditorCategories['CourseRoot'] ."]]";
$resultCreateCourse = CourseEditorUtils::editWrapper($pageTitle, $courseText, null, null);
$text = "{{". $wgCourseEditorTemplates['Topic'] ."|" . "{{". $wgCourseEditorTemplates['Course'] ."|" . $title . "}}}}";
$listElementText = "\r\n* [[" . $title . "]]";
$resultCreateMetadataPage = self::createBasicCourseMetadata(null, $title, $description);
$resultAppendToTopic = CourseEditorUtils::editWrapper($title, $text, null, null);
$resultAppendToDepartment = CourseEditorUtils::editSectionWrapper($department, null, null, $listElementText);
- return array($resultCreateCourse, $resultCreateMetadataPage, $resultAppendToTopic, $resultAppendToDepartment);
+ $resultPurgeCourse = CourseEditorUtils::purgeWrapper($pageTitle);
+ return array($resultCreateCourse, $resultCreateMetadataPage, $resultAppendToTopic, $resultAppendToDepartment, $resultPurgeCourse);
}
public static function applyPublishCourseOp($operation){
global $wgCourseEditorTemplates, $wgCourseEditorCategories, $wgContLang;
$value = json_decode($operation);
switch ($value->action) {
case 'rename-move-task':
$levelTwoName = $value->elementName;
$newLevelTwoName = $value->newElementName;
$apiResult = CourseEditorUtils::moveWrapper($levelTwoName, $newLevelTwoName, true, false);
CourseEditorUtils::setSingleOperationSuccess($value, $apiResult);
break;
case 'rename-update-task':
$levelTwoName = $value->elementName;
$newLevelTwoName = $value->newElementName;
$levelsThree = CourseEditorUtils::getLevelsThree($newLevelTwoName);
$newLevelTwoText = "";
foreach ($levelsThree as $levelThree) {
$newLevelTwoText .= "* [[" . $newLevelTwoName . "/" . $levelThree ."|". $levelThree ."]]\r\n";
}
$newLevelTwoText .= "\r\n[["
. $wgContLang->getNsText( NS_CATEGORY ) . ":". $wgCourseEditorCategories['CourseLevelTwo'] ."]]";
$apiResult = CourseEditorUtils::editWrapper($newLevelTwoName, $newLevelTwoText, null, null);
CourseEditorUtils::setSingleOperationSuccess($value, $apiResult);
break;
case 'move-root':
$courseName = $value->elementName;
$newCourseName = $value->newElementName;
$apiResult = CourseEditorUtils::moveWrapper($courseName, $newCourseName, false, false);
CourseEditorUtils::setSingleOperationSuccess($value, $apiResult);
break;
case 'remove-ready-texts':
$title = Title::newFromText($value->elementName);
$page = WikiPage::factory($title);
$pageText = $page->getText();
$category = "[[" . $wgContLang->getNsText( NS_CATEGORY ) . ":". $wgCourseEditorCategories['ReadyToBePublished'] ."]]";
$template = "{{". $wgCourseEditorTemplates['ReadyToBePublished'] ."}}";
$replacedText = str_replace($category, "", $pageText);
$newPageText = str_replace($template, "", $replacedText);
$result = CourseEditorUtils::editWrapper($title, $newPageText, null, null);
break;
case 'move-metadata':
$metadataPage = $value->elementName;
$newMetadataPage = $value->newElementName;
$apiResult = CourseEditorUtils::moveWrapper($metadataPage, $newMetadataPage, false, false);
CourseEditorUtils::setSingleOperationSuccess($value, $apiResult);
break;
case 'update-collection':
$apiResult = CourseEditorUtils::updateCollection($value->elementName);
CourseEditorUtils::setSingleOperationSuccess($value, $apiResult);
break;
}
return json_encode($value);
}
public static function applyCourseOp($courseName, $operation){
global $wgCourseEditorTemplates, $wgCourseEditorCategories, $wgContLang;
$value = json_decode($operation);
switch ($value->action) {
case 'rename-move-task':
$levelTwoName = $value->elementName;
$newLevelTwoName = $value->newElementName;
$pageTitle = $courseName . "/" . $levelTwoName;
$newPageTitle = $courseName . '/' . $newLevelTwoName;
$apiResult = CourseEditorUtils::moveWrapper($pageTitle, $newPageTitle);
CourseEditorUtils::setSingleOperationSuccess($value, $apiResult);
break;
case 'rename-update-task':
$levelTwoName = $value->elementName;
$newLevelTwoName = $value->newElementName;
$levelsThree = CourseEditorUtils::getLevelsThree($courseName . '/' .$newLevelTwoName);
$newLevelTwoText = "";
foreach ($levelsThree as $levelThree) {
$newLevelTwoText .= "* [[" . $courseName . "/" . $newLevelTwoName . "/" . $levelThree ."|". $levelThree ."]]\r\n";
}
$newLevelTwoText .= "\r\n[["
. $wgContLang->getNsText( NS_CATEGORY ) . ":". $wgCourseEditorCategories['CourseLevelTwo'] ."]]";
$newPageTitle = $courseName . '/' . $newLevelTwoName;
$apiResult = CourseEditorUtils::editWrapper($newPageTitle, $newLevelTwoText, null, null);
CourseEditorUtils::setSingleOperationSuccess($value, $apiResult);
break;
case 'delete-levelsThree-task':
$user = CourseEditorUtils::getRequestContext()->getUser();
$levelTwoName = $value->elementName;
$levelsThree = CourseEditorUtils::getLevelsThree($courseName . '/' . $levelTwoName);
$title = Title::newFromText( $courseName . '/' . $levelTwoName, $defaultNamespace=NS_MAIN );
$pageTitle = $courseName . '/' . $levelTwoName;
if(!$title->userCan('delete', $user, 'secure')){
$prependText = "\r\n{{". $wgCourseEditorTemplates['DeleteMe'] ."}}";
foreach ($levelsThree as $levelThree) {
$pageTitle = $courseName . '/' . $levelTwoName . '/' . $levelThree;
$prependText = "\r\n{{". $wgCourseEditorTemplates['DeleteMe'] ."}}";
$apiResult = CourseEditorUtils::editWrapper($pageTitle, null, $prependText, null);
}
}else {
foreach ($levelsThree as $levelThree) {
$pageTitle = $courseName . '/' . $levelTwoName . '/' . $levelThree;
$apiResult = CourseEditorUtils::deleteWrapper($pageTitle);
}
}
CourseEditorUtils::setSingleOperationSuccess($value, $apiResult);
break;
case 'delete-levelTwo-task':
$user = CourseEditorUtils::getRequestContext()->getUser();
$levelTwoName = $value->elementName;
$title = Title::newFromText( $courseName . '/' . $levelTwoName, $defaultNamespace=NS_MAIN );
$pageTitle = $courseName . '/' . $levelTwoName;
if(!$title->userCan('delete', $user, 'secure')){
$prependText = "\r\n{{". $wgCourseEditorTemplates['DeleteMe'] ."}}";
$apiResult = CourseEditorUtils::editWrapper($pageTitle, null, $prependText, null);
}else {
$apiResult = CourseEditorUtils::deleteWrapper($pageTitle);
}
CourseEditorUtils::setSingleOperationSuccess($value, $apiResult);
break;
case 'add':
$levelTwoName = $value->elementName;
$pageTitle = $courseName . '/' . $levelTwoName;
$text = "\r\n[[" . $wgContLang->getNsText( NS_CATEGORY ) . ":". $wgCourseEditorCategories['CourseLevelTwo'] ."]]";
$apiResult = CourseEditorUtils::editWrapper($pageTitle, $text, null, null);
CourseEditorUtils::setSingleOperationSuccess($value, $apiResult);
break;
case 'update':
$newCourseText = "{{". $wgCourseEditorTemplates['CourseRoot'] ."|\r\n";
$newLevelsTwoArray = json_decode($value->elementsList);
foreach ($newLevelsTwoArray as $levelTwo) {
$newCourseText .= "{{". $wgCourseEditorTemplates['CourseLevelTwo'] ."|" . $levelTwo ."}}\r\n";
}
$newCourseText .= "}}";
/*$categories = CourseEditorUtils::getCategories($courseName);
if(sizeof($categories) > 0){
foreach ($categories as $category) {
//Remode ReadyToBePublished category if user edit the course structure
$readyToBePublishedCategory = $wgContLang->getNsText( NS_CATEGORY ) . ":" . $wgCourseEditorCategories['ReadyToBePublished'];
if (strcmp($category['title'], $readyToBePublishedCategory) != 0) {
$newCourseText .= "\r\n[[" . $category['title'] . "]]";
}
}
}*/
$newCourseText .= "\r\n[[" . $wgContLang->getNsText( NS_CATEGORY ) . ":"
. $wgCourseEditorCategories['CourseRoot']. "]]";
$apiResult = CourseEditorUtils::editWrapper($courseName, $newCourseText, null, null);
CourseEditorUtils::setSingleOperationSuccess($value, $apiResult);
break;
case 'update-collection':
$apiResult = CourseEditorUtils::updateCollection($courseName);
CourseEditorUtils::setSingleOperationSuccess($value, $apiResult);
break;
/*case 'fix-link':
$targetPage = $value->elementName;
$linkToReplace = $value->linkToReplace;
list($course, $levelTwo, $levelThree) = explode('/', $linkToReplace);
$replacement = $course . '/' . $value->replacement . '/' . $levelThree;
$title = Title::newFromText($targetPage);
$page = WikiPage::factory( $title );
$content = $page->getContent( Revision::RAW );
$text = ContentHandler::getContentText( $content );
$newText = str_replace(str_replace(' ', '_', $linkToReplace), $replacement, $text);
$apiResult = CourseEditorUtils::editWrapper($targetPage, $newText, null, null);
CourseEditorUtils::setSingleOperationSuccess($value, $apiResult);
$value->text = $newText;
break;*/
}
return json_encode($value);
}
public static function applyLevelTwoOp($levelTwoName, $operation){
global $wgCourseEditorTemplates, $wgCourseEditorCategories, $wgContLang;
$context = CourseEditorUtils::getRequestContext();
$value = json_decode($operation);
switch ($value->action) {
case 'move':
$chapterName = $value->elementName;
$newSectionName = $value->newElementName;
$from = $sectionName . '/' . $chapterName;
$to = $newSectionName . '/' . $chapterName;
$apiResult = CourseEditorUtils::moveWrapper($from, $to);
$explodedString = explode("/", $sectionName);
$courseName = (sizeof($explodedString) > 2 ? $explodedString[0] . "/" . $explodedString[1] : $explodedString[0]);
$textToAppend = "* [[" .$courseName . "/" . $newSectionName. "/" . $chapterName ."|". $chapterName ."]]\r\n";
CourseEditorUtils::editWrapper($courseName . '/' . $newSectionName, null, null, $textToAppend);
CourseEditorUtils::setSingleOperationSuccess($value, $apiResult);
case 'rename':
$levelThreeName = $value->elementName;
$newLevelThreeName = $value->newElementName;
$from = $levelTwoName . '/' . $levelThreeName;
$to = $levelTwoName . '/' . $newLevelThreeName;
$apiResult = CourseEditorUtils::moveWrapper($from, $to);
CourseEditorUtils::setSingleOperationSuccess($value, $apiResult);
break;
case 'delete':
$user = $context->getUser();
$levelThreeName = $value->elementName;
$title = Title::newFromText($levelTwoName . '/' . $levelThreeName, $defaultNamespace=NS_MAIN);
if(!$title->userCan('delete', $user, 'secure')){
$pageTitle = $levelTwoName . '/' . $levelThreeName;
$prependText = "\r\n{{". $wgCourseEditorTemplates['DeleteMe'] ."}}";
$apiResult = CourseEditorUtils::editWrapper($pageTitle, null, $prependText, null);
}else {
$pageTitle = $levelTwoName . '/' . $levelThreeName;
$apiResult = CourseEditorUtils::deleteWrapper($pageTitle);
}
CourseEditorUtils::setSingleOperationSuccess($value, $apiResult);
break;
case 'add':
$levelThreeName = $value->elementName;
$pageTitle = $levelTwoName . '/' . $levelThreeName;
$text = "";
$apiResult = CourseEditorUtils::editWrapper($pageTitle, $text, null, null);
CourseEditorUtils::setSingleOperationSuccess($value, $apiResult);
break;
case 'update':
$newLevelTwoText = "";
$newLevelsThreeArray = json_decode($value->elementsList);
foreach ($newLevelsThreeArray as $levelThree) {
$newLevelTwoText .= "* [[" . $levelTwoName . "/" . $levelThree ."|". $levelThree ."]]\r\n";
}
$newLevelTwoText .= "\r\n[[" . $wgContLang->getNsText( NS_CATEGORY ) . ":" . $wgCourseEditorCategories['CourseLevelTwo'] ."]]";
$apiResult = CourseEditorUtils::editWrapper($levelTwoName, $newLevelTwoText);
CourseEditorUtils::setSingleOperationSuccess($value, $apiResult);
break;
case 'purge':
$explodedString = explode("/", $levelTwoName);
$pageToBePurged = (sizeof($explodedString) > 2 ? $explodedString[0] . "/" . $explodedString[1] : $explodedString[0]);
$apiResult = CourseEditorUtils::purgeWrapper($pageToBePurged);
CourseEditorUtils::setSingleOperationSuccess($value, $apiResult);
break;
case 'update-collection':
$explodedString = explode("/", $levelTwoName);
$courseName = (sizeof($explodedString) > 2 ? $explodedString[0] . "/" . $explodedString[1] : $explodedString[0]);
$apiResult = CourseEditorUtils::updateCollection($courseName);
CourseEditorUtils::setSingleOperationSuccess($value, $apiResult);
break;
}
return json_encode($value);
}
}
diff --git a/CourseEditorUtils.php b/CourseEditorUtils.php
index cd911e2..ef694c1 100644
--- a/CourseEditorUtils.php
+++ b/CourseEditorUtils.php
@@ -1,504 +1,504 @@
getNamespace();
if(MWNamespace::equals($namespaceIndex, NS_USER)){
self::updateUserCollection($courseName);
}else {
$pageTitle = "Project:" . wfMessage('courseeditor-collection-book-category') ."/" . $name;
$collectionText = "{{" . wfMessage('courseeditor-collection-savedbook-template') . "
\n| setting-papersize = a4
\n| setting-toc = auto
\n| setting-columns = 1
\n| setting-footer = yes\n}}\n";
$collectionText .= "== " . str_replace('_', ' ', $name) . " ==\r\n";
$levelsTwo = self::getLevelsTwo($courseName);
foreach ($levelsTwo as $levelTwo) {
$levelsThree = self::getLevelsThree($courseName . '/' .$levelTwo);
$collectionText .= ";" . $levelTwo . "\r\n";
foreach ($levelsThree as $levelThree) {
$collectionText .= ":[[" . $courseName . "/" . $levelTwo . "/" . $levelThree . "]]\r\n";
}
}
$categoryName = wfMessage('courseeditor-collection-book-category');
if ( !$categoryName->isDisabled() ) {
$catTitle = Title::makeTitle( NS_CATEGORY, $categoryName );
if ( !is_null( $catTitle ) ) {
$collectionText .= "\n[[" . $catTitle->getPrefixedText() ."|" . $name . "]]";
}
}
$editResult = self::editWrapper($pageTitle, $collectionText, null, null);
return $editResult;
}
}
private function updateUserCollection($courseName){
list($namespaceAndUser, $title) = explode('/', $courseName, 2);
$pageTitle = $namespaceAndUser . "/" . wfMessage('courseeditor-collection-book-category') . "/" . $title;
$collectionText = "{{" . wfMessage('courseeditor-collection-savedbook-template') . "
\n| setting-papersize = a4
\n| setting-toc = auto
\n| setting-columns = 1
\n| setting-footer = yes\n}}\n";
$collectionText .= "== " . str_replace('_', ' ', $title). " ==\r\n";
$levelsTwo = self::getLevelsTwo($courseName);
foreach ($levelsTwo as $levelTwo) {
$levelsThree = self::getLevelsThree($courseName . '/' .$levelTwo);
$collectionText .= ";" . $levelTwo . "\r\n";
foreach ($levelsThree as $levelThree) {
$collectionText .= ":[[" . $courseName . "/" . $levelTwo . "/" . $levelThree . "]]\r\n";
}
}
$categoryName = wfMessage('courseeditor-collection-book-category');
if ( !$categoryName->isDisabled() ) {
$catTitle = Title::makeTitle( NS_CATEGORY, $categoryName );
if ( !is_null( $catTitle ) ) {
$collectionText .= "\n[[" . $catTitle->getPrefixedText() ."|" . $title. "]]";
}
}
$editResult = self::editWrapper($pageTitle, $collectionText, null, null);
return $editResult;
}
public static function getMetadata($courseName){
$title = Title::newFromText($courseName, $defaultNamespace=NS_COURSEMETADATA );
$page = WikiPage::factory( $title );
$content = $page->getContent( Revision::RAW );
$text = ContentHandler::getContentText( $content );
if($text === ''){
return null;
}
$regex = "/(.*?)/s";
preg_match_all($regex, $text, $matches, PREG_PATTERN_ORDER);
$metadataResult = array();
$metadataKeys = $matches[1];
$metadataValues = $matches[2];
for ($i=0; $i < sizeof($metadataKeys); $i++) {
$metadataResult[$metadataKeys[$i]] = $metadataValues[$i];
}
return $metadataResult;
}
public static function getTopicCourses($topic){
global $wgCourseEditorTemplates;
$title = Title::newFromText($topic, $defaultNamespace=NS_MAIN );
$page = WikiPage::factory( $title );
$content = $page->getContent( Revision::RAW );
$text = ContentHandler::getContentText( $content );
$textNoNewLines = trim(preg_replace('/\n+/', '', $text));
$regex = "/({{" . $wgCourseEditorTemplates['Topic'] . "|.+)}}.*$/";
preg_match_all($regex, $textNoNewLines, $matches, PREG_PATTERN_ORDER);
return $matches[1][0];
}
/**
* This method is a workaround (read it HACK) to check the API results.
* MediaWiki ApiResult object is not "standard" but if an error/exception
* occurs the result variable is a string.
*/
public static function setSingleOperationSuccess(&$operation, $result){
$isSuccess = true;
if (is_string($result)) {
$isSuccess = false;
}
$operation->success = $isSuccess;
}
/**
* This method is a workaround (read it HACK) to check the API results.
* MediaWiki ApiResult object is not "standard" but if an error/exception
* occurs the result variable is a string.
*/
public static function setComposedOperationSuccess(&$operation, $resultsArray){
$isSuccess = true;
foreach ($resultsArray as $result) {
if (is_string($result)) {
$isSuccess = false;
break;
}
}
$operation->success = $isSuccess;
}
public static function getRequestContext(){
if(self::$requestContext == null)
{
$context = new RequestContext();
self::$requestContext = $context;
}
return self::$requestContext;
}
public static function getCategories($courseName){
try {
$api = new ApiMain(
new DerivativeRequest(
self::getRequestContext()->getRequest(),
array(
'action' => 'query',
'titles' => $courseName,
'prop' => 'categories'
)
),
true
);
$api->execute();
$results = $api->getResult()->getResultData(null, array('Strip' => 'all'));
$page = reset($results['query']['pages']);
return $page['categories'];
} catch(UsageException $e){
return $e->getMessage();
}
}
public static function getLevelsThree($levelTwoName){
$title = Title::newFromText($levelTwoName, $defaultNamespace=NS_MAIN );
$page = WikiPage::factory( $title );
$content = $page->getContent( Revision::RAW );
$text = ContentHandler::getContentText( $content );
$regex = "/\*\s*\[{2}([^|]*)\|?([^\]]*)\]{2}\s*/";
preg_match_all($regex, $text, $matches, PREG_PATTERN_ORDER);
return $matches[2];
}
public static function getLevelsTwo($courseName){
global $wgCourseEditorTemplates;
$title = Title::newFromText( $courseName, $defaultNamespace=NS_MAIN );
$page = WikiPage::factory( $title );
$content = $page->getContent( Revision::RAW );
$text = ContentHandler::getContentText( $content );
$regex = "/\{{2}". $wgCourseEditorTemplates['CourseLevelTwo'] ."\|(.*)\}{2}/";
preg_match_all($regex, $text, $matches, PREG_PATTERN_ORDER);
return $matches[1];
}
public static function getLevelsTwoJson($courseName){
return json_encode(self::getLevelsTwo($courseName));
}
public static function getPreviousAndNext($pageTitle){
$subElements = self::getSubCourseElements($pageTitle);
if($subElements['error']){
return $subElements;
}else {
return self::buildPreviousAndNext($pageTitle, $subElements);
}
}
private function getSubCourseElements($pageTitle) {
$namespace = $pageTitle->getNamespace();
$levels = substr_count($pageTitle->getText(), "/");
$basePage = MWNamespace::getCanonicalName($namespace) . ":" . $pageTitle->getBaseText();
if($namespace === NS_COURSE){
if($levels === 1){
$subElements = self::getLevelsTwo($basePage);
}elseif ($levels === 2) {
$subElements = self::getLevelsThree($basePage);
}else {
return array('error' => "Page levels not valid." );
}
}elseif ($namespace === NS_USER) {
if($levels === 2){
$subElements = self::getLevelsTwo($basePage);
}elseif ($levels === 3) {
$subElements = self::getLevelsThree($basePage);
}else {
return array('error' => "Page levels not valid." );
}
}else {
return array('error' => "Namespace not valid." );
}
return $subElements;
}
private function buildPreviousAndNext($pageTitle, $subElements){
$namespace = $pageTitle->getNamespace();
$basePage = MWNamespace::getCanonicalName($namespace) . ":" . $pageTitle->getBaseText();
$lastPage = $pageTitle->getSubpageText();
$previous = null;
$next = null;
$previousAndNext = array('previous' => $previous, 'next' => $next);
if(sizeof($subElements) < 2){
return $previousAndNext;
}else {
$key = array_search($lastPage, $subElements);
if($key === sizeof($subElements) - 1){
$previousAndNext['previous'] = $basePage . "/" . $subElements[$key - 1];
}else if($key === 0){
$previousAndNext['next'] = $basePage . "/" . $subElements[$key + 1];
}else {
$previousAndNext['previous'] = $basePage . "/" . $subElements[$key - 1];
$previousAndNext['next'] = $basePage . "/" . $subElements[$key + 1];
}
return $previousAndNext;
}
}
public static function deleteWrapper($title){
$context = self::getRequestContext();
try {
$user = $context->getUser();
$token = $user->getEditToken();
$api = new ApiMain(
new DerivativeRequest(
$context->getRequest(),
array(
'action' => 'delete',
'title' => $title,
'token' => $token
),
true
),
true
);
$api->execute();
return $api->getResult()->getResultData(null, array('Strip' => 'all'));
} catch(UsageException $e){
return $e->getMessage();
}
}
public static function purgeWrapper($titles){
$context = self::getRequestContext();
try {
$api = new ApiMain(
new DerivativeRequest(
$context->getRequest(),
array(
'action' => 'purge',
'titles' => $titles,
'forcerecursivelinkupdate' => true
),
true
),
true
);
$api->execute();
return $api->getResult()->getResultData(null, array('Strip' => 'all'));
} catch(UsageException $e){
return $e->getMessage();
}
}
public static function editWrapper($title, $text, $textToPrepend, $textToAppend){
$context = self::getRequestContext();
try {
$user = $context->getUser();
$token = $user->getEditToken();
//$token = $this->getCsrfToken();
$api = new ApiMain(
new DerivativeRequest(
$context->getRequest(),
array(
'action' => 'edit',
'title' => $title,
'text' => $text,
// automatically override text
'prependtext' => $textToPrepend,
// automatically override text
'appendtext' => $textToAppend,
'notminor' => true,
'token' => $token
),
true
),
true
);
$api->execute();
return $api->getResult()->getResultData(null, array('Strip' => 'all'));
} catch(UsageException $e){
return $e->getMessage();
}
}
public static function editSectionWrapper($title, $text, $textToPrepend, $textToAppend){
$context = self::getRequestContext();
try {
$user = $context->getUser();
$token = $user->getEditToken();
$levelTwoExist = self::checkNewCoursesSectionExist($title);
if(!$levelTwoExist){
$api = new ApiMain(
new DerivativeRequest(
$context->getRequest(),
array(
'action' => 'edit',
'title' => $title,
'text' => $text,
'section' => 'new',
- 'sectiontitle' => wfMessage('courseeditor-newcourses-section-title'),
+ 'sectiontitle' => wfMessage('courseeditor-newtopics-section-title'),
// automatically override text
'prependtext' => $textToPrepend,
// automatically override text
'appendtext' => $textToAppend,
'notminor' => true,
'token' => $token
),
true
),
true
);
}else {
$api = new ApiMain(
new DerivativeRequest(
$context->getRequest(),
array(
'action' => 'edit',
'title' => $title,
'text' => $text,
- 'sectiontitle' => wfMessage('courseeditor-newcourses-section-title'),
+ 'sectiontitle' => wfMessage('courseeditor-newtopics-section-title'),
// automatically override text
'prependtext' => $textToPrepend,
// automatically override text
'appendtext' => $textToAppend,
'notminor' => true,
'token' => $token
),
true
),
true
);
}
$api->execute();
return $api->getResult()->getResultData(null, array('Strip' => 'all'));
} catch(UsageException $e){
return $e->getMessage();
}
}
public static function moveWrapper($from, $to, $withSubpages=true, $noRedirect=false){
$context = self::getRequestContext();
$params = array(
'action' => 'move',
'from' => $from,
'to' => $to,
'movetalk' => true
);
if($withSubpages){
$params['movesubpages'] = true;
}
if ($noRedirect) {
$params['noredirect'] = true;
}
try {
$user = $context->getUser();
$token = $user->getEditToken();
$params['token'] = $token;
$api = new ApiMain(
new DerivativeRequest(
$context->getRequest(),
$params,
true
),
true
);
$api->execute();
return $api->getResult()->getResultData(null, array('Strip' => 'all'));
} catch(UsageException $e){
return $e->getMessage();
}
}
public static function getReadyToBePublishedCourses(){
global $wgCourseEditorCategories;
$context = self::getRequestContext();
try {
$user = $context->getUser();
$token = $user->getEditToken();
$api = new ApiMain(
new DerivativeRequest(
$context->getRequest(),
array(
'action' => 'query',
'list' => 'categorymembers',
'cmtitle' => 'Category:' . $wgCourseEditorCategories['ReadyToBePublished']
)
)
);
$api->execute();
$apiResult = $api->getResult()->getResultData(null, array('Strip' => 'all'));
$readyCoursesDirtyArray = $apiResult['query']['categorymembers'];
$readyCourses = [];
foreach ($readyCoursesDirtyArray as $course) {
array_push($readyCourses, $course['title']);
}
return $readyCourses;
} catch(UsageException $e){
return $e->getMessage();
}
}
private function checkNewCoursesSectionExist($department) {
$title = Title::newFromText( $department);
$page = WikiPage::factory( $title);
$context = self::getRequestContext();
$parserOptions = ParserOptions::newFromContext($context);
$levelsTwo = $page->getParserOutput($parserOptions)->getSections();
- $newCoursesSection = wfMessage('courseeditor-newcourses-section-title')->text();
+ $newCoursesSection = wfMessage('courseeditor-newtopics-section-title')->text();
if(!is_array($levelsTwo)){
return false;
}else {
foreach($levelsTwo as $element) {
$ret = in_array($newCoursesSection, $element);
}
}
return $ret;
}
/**
* Generate the url to edit the root level of a course
* @param Title $title the title of the course page
* @return Array $result an array with the 'href' to CourseEditor SpecialPage and
* the localised title for the actiontype
*/
public static function makeEditCourseUrl($title){
$titleText = $title->getNsText() . ":" . $title->getText();
$url = "/Special:CourseEditor?actiontype=editcourse&pagename=" . $titleText;
$result = array('href' => $url, 'text' => wfMessage('courseeditor-editcourse-pagetitle')->text());
return $result;
}
/**
* Generate the url to edit the second level of a course
* @param Title $title the title of the course page
* @return Array $result an array with the 'href' to CourseEditor SpecialPage and
* the localised title for the actiontype
*/
public static function makeEditLevelTwoUrl($title){
$titleText = $title->getNsText() . ":" . $title->getText();
$url = "/Special:CourseEditor?actiontype=editleveltwo&pagename=" . $titleText;
$result = array('href' => $url, 'text' => wfMessage('courseeditor-editlevelTwo-pagetitle')->text());
return $result;
}
/**
* Generate the url to download a whole course through Collection extension
* @param Title $title the title of the course page
* @return string $url the url to Collection SpecialPage
*/
public static function makeDownloadCourseUrl($title){
if($title->getNamespace() === NS_USER){
$user = $title->getRootText();
$collection = $title->getNstext() . ":" . $user . "/" . wfMessage('courseeditor-collection-book-category')->text() . "/" . $title->getSubpageText();
}else {
$collection = "Project:" . wfMessage('courseeditor-collection-book-category')->text() . "/" . $title->getRootText();
}
//Return only the url instead of an array with 'href' and 'title'.
//The title is created within the skin using the titles of the Collection tools
return $url = "/Special:Collection?bookcmd=render_collection&writer=rdf2latex&colltitle=" . $collection;
}
}
diff --git a/SpecialCourseEditor.php b/SpecialCourseEditor.php
index eda51df..a0b8c1d 100644
--- a/SpecialCourseEditor.php
+++ b/SpecialCourseEditor.php
@@ -1,158 +1,160 @@
getRequest();
$user = $this->getUser();
//Redirect user if he is not logged
if ( ! ( $user->isAllowed( 'move' ) ) ) {
global $wgOut;
$title = Title::newFromText('Special:UserLogin');
$pageName = "Special:" . $this->mName;
$params = strstr($request->getRequestURL(), '?');
$returnTo = "returnto=" . $pageName;
if($params != ""){
$returnTo .= "&returntoquery=" . urlencode($params);
}
$wgOut->redirect($title->getFullURL($returnTo));
}
$actionType = $request->getVal('actiontype');
if($par === 'ReadyCourses'){
if (!$user->isAllowed( 'undelete' )){
throw new PermissionsError( 'undelete' );
}
$this->readyToBePublishedCourses();
return;
}
switch ($actionType){
case 'editleveltwo':
$levelTwoName = $request->getVal('pagename');
$this->editLevelTwo($levelTwoName);
return;
case 'editcourse':
$courseName = $request->getVal('pagename');
$this->editCourse($courseName);
return;
case 'readycourses':
if (!$user->isAllowed( 'undelete' )){
throw new PermissionsError( 'undelete' );
}
$this->readyToBePublishedCourses();
return;
case 'createcourse':
if($request->getVal('department')){
$department = $request->getVal('department');
$this->createNewCourseFromDepartment($department);
}else if($request->getVal('topic')){
$topic = $request->getVal('topic');
$this->createNewCourseFromTopic($topic);
}
return;
case 'managemetadata':
$courseName = $request->getVal('pagename');
$this->manageMetadata($courseName);
return;
default:
$this->renderCreditsAndInfo();
return;
}
}
private function editCourse($courseName){
$out = $this->getOutput();
$out->enableOOUI();
$levelsTwo = CourseEditorUtils::getLevelsTwo($courseName);
$this->setHeaders();
$out->setPageTitle(wfMessage('courseeditor-editcourse-pagetitle'));
$out->addInlineScript(" var levelsTwo = " . json_encode($levelsTwo) . ", editStack = [];");
$out->addModules( 'ext.courseEditor.course' );
$template = new CourseEditorTemplate();
$template->setRef('courseEditor', $this);
$template->set('context', $this->getContext());
$template->set('course', $courseName);
$out->addTemplate( $template );
}
private function editLevelTwo($levelTwoName){
$out = $this->getOutput();
$out->enableOOUI();
$levelsThree = CourseEditorUtils::getLevelsThree($levelTwoName);
$this->setHeaders();
$out->setPageTitle(wfMessage('courseeditor-editlevelTwo-pagetitle'));
$out->addInlineScript(" var levelsThree = " . json_encode($levelsThree) . ", editStack = [];");
$out->addModules( 'ext.courseEditor.levelTwo' );
$template = new LevelTwoEditorTemplate();
$template->setRef('courseEditor', $this);
$template->set('context', $this->getContext());
$template->set('levelTwo', $levelTwoName);
$out->addTemplate( $template );
}
private function readyToBePublishedCourses(){
global $wgCourseEditorNamespaces;
$readyCourses = CourseEditorUtils::getReadyToBePublishedCourses();
$out = $this->getOutput();
$out->enableOOUI();
$out->setPageTitle(wfMessage('courseeditor-publish-course-pagetitle'));
$out->addJsConfigVars('wgCourseEditor', $wgCourseEditorNamespaces);
$template = new PublishCourseTemplate();
$template->setRef('courseEditor', $this);
$template->set('context', $this->getContext());
$template->set('readyCourses', $readyCourses);
$out->addTemplate( $template );
}
private function createNewCourseFromDepartment($department){
$out = $this->getOutput();
$out->enableOOUI();
$out->addModules('ext.courseEditor.create');
$out->setPageTitle(wfMessage('courseeditor-createcourse-pagetitle'));
$template = new CourseCreatorTemplate();
$template->setRef('courseEditor', $this);
$template->set('context', $this->getContext());
$template->set('department', $department);
$out->addTemplate( $template );
}
private function createNewCourseFromTopic($topic) {
$out = $this->getOutput();
$out->enableOOUI();
$out->addModules('ext.courseEditor.create');
$out->setPageTitle(wfMessage('courseeditor-createcourse-pagetitle'));
$template = new CourseCreatorTemplate();
$template->setRef('courseEditor', $this);
$template->set('context', $this->getContext());
$template->set('topic', $topic);
$out->addTemplate( $template );
}
private function manageMetadata($courseName){
+ global $wgCourseEditorNamespaces;
$out = $this->getOutput();
$out->enableOOUI();
$out->addModules('ext.courseEditor.manageMetadata');
$out->setPageTitle(wfMessage('courseeditor-managemetata-pagetitle'));
+ $out->addJsConfigVars('wgCourseEditor', $wgCourseEditorNamespaces);
$template = new ManageMetadataTemplate();
$template->setRef('courseEditor', $this);
$template->set('context', $this->getContext());
$template->set('course', $courseName);
$template->set('user', $this->getUser());
$metadataResult = CourseEditorUtils::getMetadata($courseName);
if($metadataResult !== null){
$template->set('metadataResult', $metadataResult);
}
$out->addTemplate( $template );
}
private function renderCreditsAndInfo() {
$out = $this->getOutput();
$out->addWikiMsg('courseeditor-credits-info');
}
}
diff --git a/extension.json b/extension.json
index aa4db21..bfbc564 100644
--- a/extension.json
+++ b/extension.json
@@ -1,220 +1,224 @@
{
"name":"CourseEditor",
"version":"0.1.0",
"author":[
"Alessandro Tundo",
"Gianluca Rigoletti",
"Riccardo Iaconelli"
],
"url":"https://github.com/WikiToLearn/CourseEditor",
"descriptionmsg":"",
"license-name":"GPLv3",
"type":"special",
"AutoloadClasses":{
"CourseEditor":"CourseEditor.php",
"CourseEditorOperations":"CourseEditorOperations.php",
"CourseEditorUtils":"CourseEditorUtils.php",
"LevelTwoEditorTemplate":"CourseEditorTemplates.php",
"CourseEditorTemplate" : "CourseEditorTemplates.php",
"CourseCreatorTemplate" : "CourseEditorTemplates.php",
"ManageMetadataTemplate" : "CourseEditorTemplates.php",
"PublishCourseTemplate" : "CourseEditorTemplates.php",
"SpecialCourseEditor":"SpecialCourseEditor.php"
},
"MessagesDirs":{
"CourseEditor":[
"i18n"
]
},
"ExtensionMessagesFiles": {
"CourseEditorAlias": "CourseEditor.alias.php",
"CourseEditorNamespaces": "CourseEditor.namespaces.php"
},
"ResourceFileModulePaths": {
"localBasePath": ""
},
"ResourceModules": {
"ext.courseEditor.publish": {
"scripts":[
"modules/publishCourse.js",
"modules/commonFunctions.js"
],
"dependencies": [
"oojs-ui",
"mediawiki.util"
],
"messages": [
"courseeditor",
"courseeditor-add-new-levelThree",
"courseeditor-save-levelTwo",
"courseeditor-cancel",
"courseeditor-rename",
"courseeditor-edit-dialog",
"courseeditor-message-dialog-title",
"courseeditor-message-dialog-message",
"courseeditor-message-dialog-cancel",
"courseeditor-message-dialog-restore",
"courseeditor-message-dialog-create-new",
"courseeditor-error-operation",
"courseeditor-operation-action-add",
"courseeditor-operation-action-delete",
"courseeditor-operation-action-delete-levelsThree-task",
"courseeditor-operation-action-delete-levelTwo-task",
"courseeditor-operation-action-rename",
"courseeditor-operation-action-rename-move-task",
"courseeditor-operation-action-rename-update-task",
"courseeditor-operation-action-purge",
"courseeditor-operation-action-update",
"courseeditor-operation-action-move-root",
"courseeditor-operation-action-move-metadati",
"courseeditor-operation-action-remove-ready-texts",
"courseeditor-operation-action-update-collection",
"courseeditor-error-operation-fail"
]
},
"ext.courseEditor.manageMetadata": {
- "scripts":["modules/manageMetadata.js"]
+ "scripts":["modules/manageMetadata.js"],
+ "dependencies": [
+ "mediawiki.util"
+ ]
},
"ext.courseEditor.create": {
"scripts":[
"modules/commonFunctions.js",
"modules/createCourse.js"
],
"dependencies": [
"oojs-ui",
"mediawiki.util"
],
"messages": [
"courseeditor-progressdialog-wait"
]
},
"ext.courseEditor.levelTwo": {
"scripts":[
"modules/commonFunctions.js",
"modules/levelTwoEditor.js"
],
"dependencies": [
"oojs-ui",
"mediawiki.util"
],
"styles": [
"modules/styles/style.css"
],
"messages": [
"courseeditor",
"courseeditor-add-new-levelThree",
"courseeditor-save-levelTwo",
"courseeditor-cancel",
"courseeditor-rename",
"courseeditor-edit-dialog",
"courseeditor-message-dialog-title",
"courseeditor-message-dialog-message",
"courseeditor-message-dialog-cancel",
"courseeditor-message-dialog-restore",
"courseeditor-message-dialog-create-new",
"courseeditor-error-operation",
"courseeditor-operation-action-add",
"courseeditor-operation-action-delete",
"courseeditor-operation-action-delete-levelsThree-task",
"courseeditor-operation-action-delete-levelTwo-task",
"courseeditor-operation-action-rename",
"courseeditor-operation-action-rename-move-task",
"courseeditor-operation-action-rename-update-task",
"courseeditor-operation-action-purge",
"courseeditor-operation-action-update",
"courseeditor-operation-action-update-collection",
"courseeditor-error-operation-fail"
]
},
"ext.courseEditor.course": {
"scripts":[
"modules/commonFunctions.js",
"modules/courseEditor.js"
],
"dependencies": [
"oojs-ui",
"mediawiki.util"
],
"styles": [
"modules/styles/style.css"
],
"messages": [
"courseeditor",
"courseeditor-add-new-levelTwo",
"courseeditor-save-course",
"courseeditor-cancel",
"courseeditor-rename",
"courseeditor-edit-dialog",
"courseeditor-message-dialog-title",
"courseeditor-message-dialog-message",
"courseeditor-message-dialog-cancel",
"courseeditor-message-dialog-restore",
"courseeditor-message-dialog-create-new",
"courseeditor-error-operation",
"courseeditor-operation-action-add",
"courseeditor-operation-action-delete",
"courseeditor-operation-action-delete-levelsThree-task",
"courseeditor-operation-action-delete-levelTwo-task",
"courseeditor-operation-action-rename",
"courseeditor-operation-action-rename-move-task",
"courseeditor-operation-action-rename-update-task",
"courseeditor-operation-action-purge",
"courseeditor-operation-action-update",
"courseeditor-operation-action-update-collection",
"courseeditor-error-operation-fail"
]
}
},
"namespaces": [
{
"id": 2800,
"constant": "NS_COURSE",
"name": "Course",
"subpages" : true
},
{
"id": 2801,
"constant": "NS_COURSE_TALK",
"name": "Course_talk",
"subpages" : true
},
{
"id": 2900,
"constant": "NS_COURSEMETADATA",
"name": "CourseMetadata"
}
],
"config": {
"CourseEditorTemplates":{
"Topic" : "Topic",
"Course" : "Course",
"CourseRoot" : "CourseRoot",
"CourseLevelTwo" : "CourseLevelTwo",
"ReadyToBePublished": "ReadyToBePublished",
"DeleteMe" : "DeleteMe"
},
"CourseEditorCategories":{
"CourseRoot" : "CourseRoot",
"CourseLevelTwo" : "CourseLevelTwo",
"ReadyToBePublished": "ReadyToBePublished"
},
"CourseEditorNamespaces":{
"Course" : "Course",
"CourseMetadata" : "CourseMetadata"
},
"AjaxExportList": [
"CourseEditorOperations::manageCourseMetadataOp",
"CourseEditorOperations::createCourseOp",
"CourseEditorUtils::getLevelsTwoJson",
+ "CourseEditorUtils::purgeWrapper",
"CourseEditorOperations::applyLevelTwoOp",
"CourseEditorOperations::applyCourseOp",
"CourseEditorOperations::publishCourseOp",
"CourseEditorOperations::undoPublishCourseOp",
"CourseEditorOperations::applyPublishCourseOp"
]
},
"SpecialPages": {
"CourseEditor": "SpecialCourseEditor"
},
"manifest_version":1
}
diff --git a/i18n/ca.json b/i18n/ca.json
index e037d4b..6a4d1fe 100644
--- a/i18n/ca.json
+++ b/i18n/ca.json
@@ -1,75 +1,75 @@
{
"courseeditor" : "Editor de cursos",
"courseeditor-createcourse-pagetitle": "Crear curs",
"courseeditor-editcourse-pagetitle" : "Canviar curs",
"courseeditor-editlevelTwo-pagetitle" : "Canviar capítol",
"courseeditor-managemetata-pagetitle": "Gestió de metadades",
"courseeditor-managemetata-description": "Gràcies a aquesta pàgina es poden gestionar les metadades del curs.
Podeu utilitzar la sintaxi wiki (wikitexto) dins de l'àrea de text per afegir enllaços, vinyetes, etc...",
"courseeditor-credits-info": "Editor curs és una extensió per crear i organitzar cursos.",
"courseeditor-add-new-levelThree" : "Afegir una nova secció",
"courseeditor-save-course": "Guardar curs",
"courseeditor-add-new-levelTwo" : "Afegir un nou capítol",
"courseeditor-save-levelTwo" : "Guardar capítol",
"courseeditor-cancel" : "Eliminar",
"courseeditor-edit-dialog" : "Canviar",
"courseeditor-rename" : "Rebatejar",
"courseeditor-organize-levelsTwo" : "Aquí es pot organitzar, afegir i eliminar capítols",
"courseeditor-organize-levelsThree" : "Aquí es pot organitzar, afegir i eliminar seccions",
"courseeditor-input-department-label" : "Departament:",
"courseeditor-input-department-placeholder" : "Introdueixi el departament del curs",
"courseeditor-input-topic-label" : "Tema:",
"courseeditor-input-topic-placeholder" : "Introdueixi el tema del curs",
"courseeditor-input-course-label" : "Títol:",
"courseeditor-input-course-placeholder" : "Introdueixi el títol del curs",
"courseeditor-input-description-label" : "Descripció:",
"courseeditor-input-description-placeholder" : "Introdueixi una descripció",
"courseeditor-input-bibliography-label" : "Bibliografia:",
"courseeditor-input-bibliography-placeholder" : "Introdueixi la bibliografia",
"courseeditor-input-exercises-label" : "Exercicis:",
"courseeditor-input-exercises-placeholder" : "Introdueixi els exercicis",
"courseeditor-input-books-label" : "Llibres:",
"courseeditor-input-books-placeholder" : "Introdueixi els llibres",
"courseeditor-input-externalreferences-label" : "Referències externes:",
"courseeditor-input-externalreferences-placeholder" : "Introdueixi les referències externes",
"courseeditor-input-reviewed-label" : "Revisat",
"courseeditor-input-imported-label" : "Importat",
"courseeditor-input-originalauthors-label" : "Autors originals:",
"courseeditor-input-originalauthors-placeholder" : "Introdueixi els autors originals",
"courseeditor-input-reviewedon-label" : "Revisat el:",
"courseeditor-input-reviewedon-placeholder" : "Introdueixi la data (dd/mm/aaaa)",
"courseeditor-save-button" : "Guardar",
"courseeditor-create-button" : "Crea!",
"courseeditor-alert-same-title-message" : "Escolta, hi ha un camp amb el mateix títol!
Tria un nou títol o comença a contribuir immediatament al curs existent.
",
"courseeditor-alert-similar-title-message" : "Escolta, hi ha un curs amb un títol d'aquest tipus, assegureu-vos que no és exactament el que està buscant!
",
"courseeditor-validate-form" : "Introdueixi el tema i el curs!",
"courseeditor-radiobutton-namespace" : "Vols crear un curs privat en la teva pàgina personal o un curs públic?",
"courseeditor-radiobutton-namespace-private" : "Privat",
"courseeditor-radiobutton-namespace-public" : "Públic",
"courseeditor-message-dialog-title" : "Ops...",
"courseeditor-message-dialog-message" : "Hi ha un element de la cistella amb el mateix nom, què fas?",
"courseeditor-message-dialog-cancel" : "Enrere",
"courseeditor-message-dialog-restore" : "Reiniciar",
"courseeditor-message-dialog-create-new" : "Crea nou",
"courseeditor-alert-message-existing-element" : "Ja existeix un element amb el mateix nom, o està esperant que se elimine.
Si us plau, introdueixi un nom diferent o poseu-vos en contacte amb un administrador. ",
"courseeditor-alert-message-input-notempty" : "Camp d'entrada no està buida! Feu clic a per afegir l'article, en cas contrari el camp buit.
A continuació, es pot procedir al rescat! ",
"courseeditor-recycle-bin" : "Cistella",
"courseeditor-error-operation" : "Malauradament, alguna cosa va sortir malament!:(
",
"courseeditor-operation-action-add" : "Afegir",
"courseeditor-operation-action-rename" : "Rebatejar",
"courseeditor-operation-action-rename-move-task" : "Rebatejar",
"courseeditor-operation-action-rename-update-task" : "Actualització d'enllaç",
"courseeditor-operation-action-delete" : "Eliminar",
"courseeditor-operation-action-delete-levelsTwo-task" : "Eliminar els capítols ",
"courseeditor-operation-action-delete-levelThree-task" : "Eliminar",
"courseeditor-operation-action-purge" : "Actualització índex",
"courseeditor-operation-action-update" : "Actualització",
"courseeditor-operation-action-update-collection" : " Actualització llibre",
"courseeditor-operation-action-move-root": "Mou",
"courseeditor-operation-action-move-metadati": "Moure les metadades",
"courseeditor-operation-action-remove-ready-texts": "Eliminar ReadyToBePublished",
"courseeditor-progressdialog-wait" : "Espere la creació de curs...",
"courseeditor-error-operation-fail" : " error!",
"courseeditor-collection-book-category": "Llibres",
"courseeditor-collection-savedbook-template": "llibre_guardat",
-"courseeditor-newcourses-section-title" : "Nous cursos"
+ "courseeditor-newtopics-section-title" : "Nous tèmas"
}
diff --git a/i18n/de.json b/i18n/de.json
index 983a20d..e7dc5f5 100644
--- a/i18n/de.json
+++ b/i18n/de.json
@@ -1,75 +1,75 @@
{
"courseeditor" : "Kurse editor",
"courseeditor-createcourse-pagetitle": "Kurs erstellen",
"courseeditor-editcourse-pagetitle" : "Ändern Sie Kurs",
"courseeditor-editlevelTwo-pagetitle" : "Ändern Sie Kapitel",
"courseeditor-managemetata-pagetitle": "Metadaten Verwaltung",
"courseeditor-managemetata-description": "Uf diese Seite, kanst du die Kursemetadaten verwalten.
Ins textarea kanst du die Wikisyntax (der Wikitext) benutzen, um links und Aufzählungliste hinzuzugefügen...",
"courseeditor-credits-info": "CourseEditor ist eine Anwendung um Kurse zu erstellen und organizieren.",
"courseeditor-add-new-levelThree" : "Ein neuer Abschnitt hinzufügen",
"courseeditor-save-course": "Kurs speichern",
"courseeditor-add-new-levelTwo" : "Eine neue Kapitel hinzufügen",
"courseeditor-save-levelTwo" : "Abschnitt speichern",
"courseeditor-cancel" : "Entfernen",
"courseeditor-edit-dialog" : "Bearbeiten",
"courseeditor-rename" : "Unbenennen",
"courseeditor-organize-levelsTwo" : "Here kanst du die Kapitel organiseren, hinzufügen und entfernen",
"courseeditor-organize-levelsThree" : "Here kanst du die Abschnitte organiseren, hinzufügen und entfernen",
"courseeditor-input-department-label" : "Fachbereich:",
"courseeditor-input-department-placeholder" : "Kursfachbereich einfügen",
"courseeditor-input-topic-label" : "Gegenstand:",
"courseeditor-input-topic-placeholder" : "Kursgegenstand einfügen",
"courseeditor-input-course-label" : "Überschrift:",
"courseeditor-input-course-placeholder" : "Kursüberschrift einfügen",
"courseeditor-input-description-label" : "Beschreibung:",
"courseeditor-input-description-placeholder" : "Beschreibung einfügen",
"courseeditor-input-bibliography-label" : "Bibliographie:",
"courseeditor-input-bibliography-placeholder" : "Bibliographie einfügen",
"courseeditor-input-exercises-label" : "Übungen:",
"courseeditor-input-exercises-placeholder" : "Übungen einfügen",
"courseeditor-input-books-label" : "Bücher:",
"courseeditor-input-books-placeholder" : "Bücher einfügen",
"courseeditor-input-externalreferences-label" : "Externe Zitaten:",
"courseeditor-input-externalreferences-placeholder" : "Externe Zitaten einfügen",
"courseeditor-input-reviewed-label" : "Editiert",
"courseeditor-input-imported-label" : "Importiert",
"courseeditor-input-originalauthors-label" : "Originalautoren:",
"courseeditor-input-originalauthors-placeholder" : "Originalautoren einfügen",
"courseeditor-input-reviewedon-label" : "Editiert am:",
"courseeditor-input-reviewedon-placeholder" : "die Jahreszahl einfügen (tt/mm/jjjj)",
"courseeditor-save-button" : "Speichern",
"courseeditor-create-button" : "Erstellen!",
"courseeditor-alert-same-title-message" : "Hey, es gibt ein Kurse mit dem gleichen Titel
Wähle einen anderen Titel oder beginn sofort mit dem bestehenden Kurs beizutragen.
",
"courseeditor-alert-similar-title-message": "Hey, es gibt ein Kurs mit einem solchen Titel, stellen Sie sicher, es ist nicht ganz das, was Sie suchen!
",
"courseeditor-validate-form" : "Der Gegestand und der Kurs einfügen!",
"courseeditor-radiobutton-namespace" : "Möchtest du einen privaten Kurs auf deinen Seiten oder einen öffentlichen zu erstellen?",
"courseeditor-radiobutton-namespace-private" : "Privat",
"courseeditor-radiobutton-namespace-public" : "Öffentlich ",
"courseeditor-message-dialog-title" : "Ops...",
"courseeditor-message-dialog-message" : "Es gibt ein Element mit dem gleichen Name in der Papierkorb, was möchtest du machen damit?",
"courseeditor-message-dialog-cancel" : "Zurück",
"courseeditor-message-dialog-restore" : "Wiederherstelle",
"courseeditor-message-dialog-create-new" : "Neue erstellen",
"courseeditor-alert-message-existing-element" : "Es gibt noch ein Element mit dem gleichen Name oder Es ist in Erwartung zu löchen.
Bitte, füge ein anderen Name ein oder wenden den Verwalter.",
"courseeditor-alert-message-input-notempty" : "Eingabefeld ist nicht leer! Klicken Sie auf um das Element hinzuzufügen, sonst ist es leer.
Dann können Sie fortfahren, um die Seite zu speichern! ",
"courseeditor-recycle-bin" : "Papierkorb",
"courseeditor-error-operation" : "Entschuldigung, etwas schiefgelaufen ist!
",
"courseeditor-operation-action-add" : "Hinzufügen",
"courseeditor-operation-action-rename" : "Umbenennen",
"courseeditor-operation-action-rename-move-task" : "Umbenennen",
"courseeditor-operation-action-rename-update-task" : "Links aktualisierung",
"courseeditor-operation-action-delete" : "Löchen",
"courseeditor-operation-action-delete-levelsTwo-task" : "Löchen Kapitel von",
"courseeditor-operation-action-delete-levelThree-task" : "Löchen",
"courseeditor-operation-action-purge" : "Aktualisieren des Indexes",
"courseeditor-operation-action-update" : "Aktualisiere",
"courseeditor-operation-action-update-collection" : "Buch aktualisiere",
"courseeditor-operation-action-move-root": "Verschieben",
"courseeditor-operation-action-move-metadati": "verschieben von Metadaten",
"courseeditor-operation-action-remove-ready-texts": "Entfernen ReadyToBePublished",
"courseeditor-error-operation-fail" : " fehlgeschlagen!",
"courseeditor-progressdialog-wait" : "Warten Schöpfung läuft...",
"courseeditor-collection-book-category": "Bücher",
"courseeditor-collection-savedbook-template": "Gespeichert_buch",
- "courseeditor-newcourses-section-title" : "Neue Kurse"
+ "courseeditor-newtopics-section-title" : "Neue Themen"
}
diff --git a/i18n/en.json b/i18n/en.json
index 9e3a13f..ba4426c 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -1,80 +1,80 @@
{
"courseeditor" : "Course editor",
"courseeditor-createcourse-pagetitle": "Create course",
"courseeditor-editcourse-pagetitle" : "Edit course",
"courseeditor-editlevelTwo-pagetitle" : "Edit chapter",
"courseeditor-managemetata-pagetitle": "Metadata management",
"courseeditor-managemetata-description": "With this page you can manage course's metadata
You can use the wiki syntax (wikitext) within textarea to add links, bullet lists etc...",
"courseeditor-credits-info": "CourseEditor is an extension to create and manage courses.",
"courseeditor-add-new-levelThree" : "Add a new section",
"courseeditor-save-course": "Save course",
"courseeditor-add-new-levelTwo" : "Add new chapter",
"courseeditor-save-levelTwo" : "Save chapter",
"courseeditor-cancel" : "Cancel",
"courseeditor-edit-dialog" : "Edit",
"courseeditor-rename" : "Rename",
"courseeditor-organize-levelsTwo" : "You can organize, add and delete chapters",
"courseeditor-organize-levelsThree" : "You can organize, add and delete sections",
"courseeditor-input-department-label" : "Department:",
"courseeditor-input-department-placeholder" : "Insert the department of the course",
"courseeditor-input-topic-label" : "Topic:",
"courseeditor-input-topic-placeholder" : "Insert the topic of the course",
"courseeditor-input-course-label" : "Title:",
"courseeditor-input-course-placeholder" : "Insert the title of the course",
"courseeditor-input-description-label" : "Description:",
"courseeditor-input-description-placeholder" : "Insert a description",
"courseeditor-input-bibliography-label" : "Bibliography:",
"courseeditor-input-bibliography-placeholder" : "Insert the bibliography",
"courseeditor-input-exercises-label" : "Exercises:",
"courseeditor-input-exercises-placeholder" : "Insersci gli esercizi",
"courseeditor-input-books-label" : "Books:",
"courseeditor-input-books-placeholder" : "Insert the books",
"courseeditor-input-externalreferences-label" : "External references:",
"courseeditor-input-externalreferences-placeholder" : "Insert external references",
"courseeditor-input-reviewed-label" : "Reviewed",
"courseeditor-input-imported-label" : "Imported",
"courseeditor-input-originalauthors-label" : "Original authors:",
"courseeditor-input-originalauthors-placeholder" : "Insert the original authors",
"courseeditor-input-reviewedon-label" : "Reviewed on:",
"courseeditor-input-reviewedon-placeholder" : "Insert the date (dd/mm/yyyy)",
"courseeditor-save-button" : "Save",
"courseeditor-create-button" : "Create!",
"courseeditor-alert-same-title-message" : "Hey, there is a course with the same title yet!
Choose another title or start to contribute immediately to the existing course.",
"courseeditor-alert-similar-title-message" : "Hey, there is a course with a similar title, make sure it is not what you are looking for!
",
"courseeditor-validate-form" : "Please, insert a topic and a name",
"courseeditor-radiobutton-namespace" : "Do you want to create a private course in your personal page or a public one?",
"courseeditor-radiobutton-namespace-private" : "Private",
"courseeditor-radiobutton-namespace-public" : "Public",
"courseeditor-message-dialog-title" : "Oops...",
"courseeditor-message-dialog-message" : "There's an element in the recycle bin with the same name, what do you want to do?",
"courseeditor-message-dialog-cancel" : "Cancel",
"courseeditor-message-dialog-restore" : "Restore",
"courseeditor-message-dialog-create-new" : "Create new",
"courseeditor-alert-message-existing-element" : "There is already an element with the same name or it is waiting to be removed.
Please, enter a different name or contact an administrator.",
"courseeditor-alert-message-input-notempty" : "Input field isn't empty! Click on to add the element, otherwise empty it.
Then you can proceed to save! ",
"courseeditor-recycle-bin" : "Recycle bin",
"courseeditor-error-operation" : "Sorry, something went wrong!
",
"courseeditor-operation-action-add" : "Add",
"courseeditor-operation-action-rename" : "Rename",
"courseeditor-operation-action-rename-move-task" : "Rename",
"courseeditor-operation-action-rename-update-task" : "Update links",
"courseeditor-operation-action-delete" : "Delete",
"courseeditor-operation-action-delete-levelsTwo-task" : "Delete chapters of",
"courseeditor-operation-action-delete-levelThree-task" : "Delete",
"courseeditor-operation-action-purge" : "Update index",
"courseeditor-operation-action-update" : "Update",
"courseeditor-operation-action-update-collection" : "Update book",
"courseeditor-operation-action-move-root": "Move",
"courseeditor-operation-action-move-metadati": "Move metadata",
"courseeditor-operation-action-remove-ready-texts": "Remove ReadyToBePublished",
"courseeditor-error-operation-fail" : " fails!",
"courseeditor-collection-book-category": "Books",
"courseeditor-progressdialog-wait": "Wait creation in progress...",
"courseeditor-collection-savedbook-template": "saved_book",
- "courseeditor-newcourses-section-title" : "New courses",
+ "courseeditor-newtopics-section-title" : "New topics",
"courseeditor-publish-course-pagetitle" : "Publish courses",
"courseeditor-pending-courses": "Pending courses",
"courseeditor-alert-message-success-publish" : "The course is now available here:",
"courseeditor-alert-message-success-publish-add-to" : "You must add it to a topic and department"
}
diff --git a/i18n/es.json b/i18n/es.json
index 4caa56c..53e1f8a 100644
--- a/i18n/es.json
+++ b/i18n/es.json
@@ -1,75 +1,75 @@
{
"courseeditor" : "Editor de cursos",
"courseeditor-createcourse-pagetitle": "Crear curso",
"courseeditor-editcourse-pagetitle" : "Modificar curso",
"courseeditor-editlevelTwo-pagetitle" : "Modificar capítulo",
"courseeditor-managemetata-pagetitle": "Gestión de metadatos",
"courseeditor-managemetata-description": "Gracias a esta página se pueden gestionar los metadatos del curso.
Puede utilizar la sintaxis wiki (wikitexto) dentro del área de texto para añadir enlaces, viñetas, etc...",
"courseeditor-credits-info": "Editor curso es una extensión para crear y organizar cursos.",
"courseeditor-add-new-levelThree" : "Añadir una nueva sección",
"courseeditor-save-course": "Guardar curso",
"courseeditor-add-new-levelTwo" : "Añadir un nuevo capítulo",
"courseeditor-save-levelTwo" : "Guardar capítulo",
"courseeditor-cancel" : "Eliminar",
"courseeditor-edit-dialog" : "Modificar",
"courseeditor-rename" : "Renombrar",
"courseeditor-organize-levelsTwo" : "Aquí se puede organizar, añadir y eliminar capítulos",
"courseeditor-organize-levelsThree" : "Aquí se puede organizar, añadir y eliminar secciones",
"courseeditor-input-department-label" : "Departamento:",
"courseeditor-input-department-placeholder" : "Introduzca el departamento del curso",
"courseeditor-input-topic-label" : "Tema:",
"courseeditor-input-topic-placeholder" : "Introduzca el tema del curso",
"courseeditor-input-course-label" : "Título:",
"courseeditor-input-course-placeholder" : "Introduzca el título del curso",
"courseeditor-input-description-label" : "Descripción:",
"courseeditor-input-description-placeholder" : "Introduzca una descripción ",
"courseeditor-input-bibliography-label" : "Bibliografía:",
"courseeditor-input-bibliography-placeholder" : "Introduzca la bibliografía",
"courseeditor-input-exercises-label" : "Ejercicios:",
"courseeditor-input-exercises-placeholder" : "Introduzca los ejercicios",
"courseeditor-input-books-label" : "Libros:",
"courseeditor-input-books-placeholder" : "Introduzca los libros",
"courseeditor-input-externalreferences-label" : "Referencias externas:",
"courseeditor-input-externalreferences-placeholder" : "Introduzca las referencias externas",
"courseeditor-input-reviewed-label" : "Revisado",
"courseeditor-input-imported-label" : "Importado",
"courseeditor-input-originalauthors-label" : "Autores originales:",
"courseeditor-input-originalauthors-placeholder" : "Introduzca los autores originales",
"courseeditor-input-reviewedon-label" : "Revisionado el:",
"courseeditor-input-reviewedon-placeholder" : "Introduzca la data (dd/mm/aaaa)",
"courseeditor-save-button" : "Guardar",
"courseeditor-create-button" : "Crea!",
"courseeditor-alert-same-title-message" : "Oye, hay un curso con el mismo título!
Elige uno nuevo o empieza a contribuir al curso esitente.
",
"courseeditor-alert-similar-title-message" : "Oye, hay un curso con un título de este tipo, asegúrese de que no es exactamente lo que está buscando!
",
"courseeditor-validate-form" : "Introduzca el tema y el curso!",
"courseeditor-radiobutton-namespace" : "¿Quieres crear un curso privado en tu página personal o uno público?",
"courseeditor-radiobutton-namespace-private" : "Privado",
"courseeditor-radiobutton-namespace-public" : "Público",
"courseeditor-message-dialog-title" : "Ops...",
"courseeditor-message-dialog-message" : "Hay un elemento en la papelera con el mismo nombre, ¿qué quieres hacer?",
"courseeditor-message-dialog-cancel" : "Atrás",
"courseeditor-message-dialog-restore" : "Reiniciar",
"courseeditor-message-dialog-create-new" : "Crear nuevo",
"courseeditor-alert-message-input-notempty" : "Campo de entrada no està vacía! Haga clic en para añadir el elemento, de lo contrario vaciarlo. A continuación, puede proceder a guardar! ",
"courseeditor-alert-message-existing-element" : "Ya existe un elemento con el mismo nombre, o está en espera de ser cancelado.
Por favor, introduzca un nombre diferente o se ponga en contacto con un administrador..",
"courseeditor-recycle-bin" : "Papelera",
"courseeditor-error-operation" : "Lo siento, algo salió mal!
",
"courseeditor-operation-action-add" : "Añadir",
"courseeditor-operation-action-rename" : "Renombrar",
"courseeditor-operation-action-rename-move-task" : "Renombrar",
"courseeditor-operation-action-rename-update-task" : "Actualiza enlaces",
"courseeditor-operation-action-delete" : "Eliminar",
"courseeditor-operation-action-delete-levelsTwo-task" : "Elimina capítulo de",
"courseeditor-operation-action-delete-levelThree-task" : "Eliminar",
"courseeditor-operation-action-purge" : "Actualiza índice",
"courseeditor-operation-action-update" : "Actualiza",
"courseeditor-operation-action-update-collection" : "Actualiza libro",
"courseeditor-operation-action-move-root": "Mueve",
"courseeditor-operation-action-move-metadati": "Mueve metadatos",
"courseeditor-operation-action-remove-ready-texts": "Eliminar ReadyToBePublished",
"courseeditor-error-operation-fail" : "Fallo!",
"courseeditor-progressdialog-wait" : "Espere creación en curso...",
"courseeditor-collection-book-category": "Libros",
"courseeditor-collection-savedbook-template": "Libro_guardado",
- "courseeditor-newcourses-section-title" : "Nuevos cursos"
+ "courseeditor-newtopics-section-title" : "Nuevos temas"
}
diff --git a/i18n/fr.json b/i18n/fr.json
index 4ba4582..0089132 100644
--- a/i18n/fr.json
+++ b/i18n/fr.json
@@ -1,75 +1,75 @@
{
"courseeditor" : "Éditeur de cours",
"courseeditor-createcourse-pagetitle": "Créer cours",
"courseeditor-editcourse-pagetitle" : "Modifier cours",
"courseeditor-editlevelTwo-pagetitle" : "Modifier chapitre",
"courseeditor-managemetata-pagetitle": "Gestion des métadonnées",
"courseeditor-managemetata-description": "Avec cette page, vous pouvez gérer les métadonnées du cours.
Vous pouvez utiliser la syntaxe wiki (wikitexte) dans le textarea pour ajouter des liens, listes de points etc ... i>",
"courseeditor-credits-info": "CourseEditor est une extension pour créer et organiser des cours.",
"courseeditor-add-new-levelThree" : "Ajouter une nouvelle section",
"courseeditor-save-course": "Enregistrer cours",
"courseeditor-add-new-levelTwo" : "Ajouter un nouveau chapitre",
"courseeditor-save-levelTwo" : "Enregistrer chapitre",
"courseeditor-cancel" : "Éliminer",
"courseeditor-edit-dialog" : "Modifier",
"courseeditor-rename" : "Renommer",
"courseeditor-organize-levelsTwo" : "Ici vous pouvez organiser, ajouter et éliminer des chapitres",
"courseeditor-organize-levelsThree" : " Ici vous pouvez organiser, ajouter et éliminer des levelsThree",
"courseeditor-input-department-label" : "Département:",
"courseeditor-input-department-placeholder" : "Entrez le département du cours",
"courseeditor-input-topic-label" : "Thème:",
"courseeditor-input-topic-placeholder" : "Entrez le thème du cours",
"courseeditor-input-course-label" : "Titre:",
"courseeditor-input-course-placeholder" : "Entrez le titre du cours",
"courseeditor-input-description-label" : "Description:",
"courseeditor-input-description-placeholder" : "Entrez la description",
"courseeditor-input-bibliography-label" : "Bibliographie:",
"courseeditor-input-bibliography-placeholder" : "Entrez la bibliographie",
"courseeditor-input-exercises-label" : "Exercices:",
"courseeditor-input-exercises-placeholder" : "Entrez les exercices",
"courseeditor-input-books-label" : "Livres:",
"courseeditor-input-books-placeholder" : "Entrez les livres",
"courseeditor-input-externalreferences-label" : "Références externes:",
"courseeditor-input-externalreferences-placeholder" : "Entrez les références externes",
"courseeditor-input-reviewed-label" : "Révisé",
"courseeditor-input-imported-label" : "Importé",
"courseeditor-input-originalauthors-label" : "Auteurs originaux:",
"courseeditor-input-originalauthors-placeholder" : "Entrez les auteurs originaux",
"courseeditor-input-reviewedon-label" : "Révisé le:",
"courseeditor-input-reviewedon-placeholder" : "Entrez la date (jj/mm/aaaa)",
"courseeditor-save-button" : "Enregistrer",
"courseeditor-create-button" : "Créer!",
"courseeditor-alert-same-title-message" : "Hey, il y a un cours avec le même titre!
Choisir un autre titre ou commencer à contribuer au cours esitente.
",
"courseeditor-alert-similar-title-message" : "Hey, il y a un cours avec un tel titre, assurez-vous qu'il est pas tout à fait ce que vous recherchez!
",
"courseeditor-validate-form" : "Entrez le thème et le cours!",
"courseeditor-radiobutton-namespace" : "Vous voulez créer un cours privé dans votre page personnelle ou un public?",
"courseeditor-radiobutton-namespace-private" : "Privé",
"courseeditor-radiobutton-namespace-public" : "Public",
"courseeditor-message-dialog-title" : "Ops...",
"courseeditor-message-dialog-message" : "Il y a un élément dans le corbeille avec le même nom, Qu'est-ce que vous voulez faire?",
"courseeditor-message-dialog-cancel" : "Retour",
"courseeditor-message-dialog-restore" : "Restaurer",
"courseeditor-message-dialog-create-new" : "Créer nouveau",
"courseeditor-alert-message-input-notempty": "Champ de saisie ne soit pas vide! Cliquez sur pour ajouter l'élément, sinon vider. Ensuite, vous pouvez procéder à enregistrer! ",
"courseeditor-alert-message-existing-element" : "Il existe déjà un élément avec le même nom, ou est en attente d'être éliminé
S'il vous plaît entrer un nom différent ou contacter un administrateur.",
"courseeditor-recycle-bin" : "Corbeille",
"courseeditor-error-operation" : "Désolé, quelque chose a mal tourné!
",
"courseeditor-operation-action-add" : "Ajouter",
"courseeditor-operation-action-rename" : "Renommer",
"courseeditor-operation-action-rename-move-task" : "Renommer",
"courseeditor-operation-action-rename-update-task" : "Actualiser liens",
"courseeditor-operation-action-delete" : "éliminer",
"courseeditor-operation-action-delete-levelsTwo-task" : "Éliminer chapitres de",
"courseeditor-operation-action-delete-levelThree-task" : "Éliminer",
"courseeditor-operation-action-purge" : "Actualiser l'index",
"courseeditor-operation-action-update" : "Actualiser",
"courseeditor-operation-action-update-collection" : "Actualiser livre",
"courseeditor-operation-action-move-root": "Se déplace",
"courseeditor-operation-action-move-metadati": "Se déplace métadonnées",
"courseeditor-operation-action-remove-ready-texts": "Supprimer ReadyToBePublished",
"courseeditor-progressdialog-wait" : "Attendre la création en cours",
"courseeditor-error-operation-fail" : " échec!",
"courseeditor-collection-book-category": "Livres",
"courseeditor-collection-savedbook-template": "livre_enregistré",
- "courseeditor-newcourses-section-title" : "Nouveaux cours"
+ "courseeditor-newtopics-section-title" : "Nouveaux thème"
}
diff --git a/i18n/it.json b/i18n/it.json
index 1197438..30d8598 100644
--- a/i18n/it.json
+++ b/i18n/it.json
@@ -1,79 +1,79 @@
{
"courseeditor" : "Editor di corsi",
"courseeditor-createcourse-pagetitle": "Crea corso",
"courseeditor-editcourse-pagetitle" : "Modifica corso",
"courseeditor-editlevelTwo-pagetitle" : "Modifica capitolo",
"courseeditor-managemetata-pagetitle": "Gestione metadati",
"courseeditor-managemetata-description": "Grazie a questa pagina puoi gestire i metadati del corso.
Puoi usare la sintassi wiki (wikitesto) all'interno delle textarea per aggiungere links, elenchi puntati ecc...",
"courseeditor-credits-info": "CourseEditor è una estensione per creare ed organizzare corsi.",
"courseeditor-add-new-levelThree" : "Aggiungi una nuova sezione",
"courseeditor-save-course": "Salva corso",
"courseeditor-add-new-levelTwo" : "Aggiungi un nuovo capitolo",
"courseeditor-save-levelTwo" : "Salva capitolo",
"courseeditor-cancel" : "Cancella",
"courseeditor-edit-dialog" : "Modifica",
"courseeditor-rename" : "Rinomina",
"courseeditor-organize-levelsTwo" : "Qui puoi organizzare, aggiungere e rimuovere capitoli",
"courseeditor-organize-levelsThree" : "Qui puoi organizzare, aggiungere e rimuovere sezioni",
"courseeditor-input-department-label" : "Dipartimento:",
"courseeditor-input-department-placeholder" : "Inserisci il dipartimento del corso",
"courseeditor-input-topic-label" : "Argomento:",
"courseeditor-input-topic-placeholder" : "Inserisci l'argomento del corso",
"courseeditor-input-course-label" : "Titolo:",
"courseeditor-input-course-placeholder" : "Inserisci il titolo del corso",
"courseeditor-input-description-label" : "Descrizione:",
"courseeditor-input-description-placeholder" : "Insersci la descrizione",
"courseeditor-input-bibliography-label" : "Bibliografia:",
"courseeditor-input-bibliography-placeholder" : "Inserisci la bibliografia",
"courseeditor-input-exercises-label" : "Esercizi:",
"courseeditor-input-exercises-placeholder" : "Inserisci gli esercizi",
"courseeditor-input-books-label" : "Libri:",
"courseeditor-input-books-placeholder" : "Inserisci i libri",
"courseeditor-input-externalreferences-label" : "Riferimenti esterni:",
"courseeditor-input-externalreferences-placeholder" : "Inserisci i riferimenti esterni",
"courseeditor-input-reviewed-label" : "Revisionato",
"courseeditor-input-imported-label" : "Importato",
"courseeditor-input-originalauthors-label" : "Autori originali:",
"courseeditor-input-originalauthors-placeholder" : "Inserisci gli autori originali",
"courseeditor-input-reviewedon-label" : "Revisionato il:",
"courseeditor-input-reviewedon-placeholder" : "Inserisci la data (gg/mm/aaaa)",
"courseeditor-save-button" : "Salva",
"courseeditor-create-button" : "Crea!",
"courseeditor-alert-same-title-message" : "Ehi, c'è un corso con lo stesso titolo!
Scegli un altro titolo o inizia a contribuire subito al corso esitente.
",
"courseeditor-alert-similar-title-message" : "Ehi, c'è un corso con un titolo simile, fai attenzione che non sia proprio quello che cerchi!
",
"courseeditor-validate-form" : "Inserisci l'argomento e il corso!",
"courseeditor-radiobutton-namespace" : "Vuoi creare un corso privato nella tua pagina personale o uno pubblico?",
"courseeditor-radiobutton-namespace-private" : "Privato",
"courseeditor-radiobutton-namespace-public" : "Pubblico",
"courseeditor-message-dialog-title" : "Ops...",
"courseeditor-message-dialog-message" : "C'è un elemento nel cestino con lo stesso nome, cosa vuoi fare?",
"courseeditor-message-dialog-cancel" : "Indietro",
"courseeditor-message-dialog-restore" : "Ripristina",
"courseeditor-message-dialog-create-new" : "Crea nuovo",
"courseeditor-alert-message-existing-element" : "È già presente un elemento con lo stesso nome o è in attesa di essere cancellato.
Per favore, inserire un nome diverso o contattare un amministratore.",
"courseeditor-alert-message-input-notempty" : "Campo di inserimento non vuoto! Fai click su per aggiungere l'elemento, altrimenti svuota il campo.
Successivamente potrai procedere al salvataggio! ",
"courseeditor-recycle-bin" : "Cestino",
"courseeditor-error-operation" : "Scusa, qualcosa è andato storto!
",
"courseeditor-operation-action-add" : "Aggiungi",
"courseeditor-operation-action-rename" : "Rinomina",
"courseeditor-operation-action-rename-move-task" : "Rinomina",
"courseeditor-operation-action-rename-update-task" : "Aggiorna links",
"courseeditor-operation-action-delete" : "Elimina",
"courseeditor-operation-action-delete-levelsTwo-task" : "Elimina capitoli di",
"courseeditor-operation-action-delete-levelThree-task" : "Elimina",
"courseeditor-operation-action-purge" : "Aggiorna indice",
"courseeditor-operation-action-update" : "Aggiorna",
"courseeditor-operation-action-update-collection" : "Aggiorna libro",
"courseeditor-operation-action-move-root": "Sposta",
"courseeditor-operation-action-move-metadati": "Sposta metadati",
"courseeditor-operation-action-remove-ready-texts" : "Rimuovi ReadyToBePublished",
"courseeditor-error-operation-fail" : " fallito!",
"courseeditor-progressdialog-wait" : "Attendere creazione in corso...",
"courseeditor-collection-book-category": "Libri",
"courseeditor-collection-savedbook-template": "libro_salvato",
- "courseeditor-newcourses-section-title" : "Nuovi corsi",
+ "courseeditor-newtopics-section-title" : "Nuovi argomenti",
"courseeditor-pending-courses": "Corsi in attesa",
"courseeditor-alert-message-success-publish" : "Il corso è ora disponibile qui:",
"courseeditor-alert-message-success-publish-add-to" : "Devi aggiungerlo ad un topic e un dipartimento"
}
diff --git a/modules/commonFunctions.js b/modules/commonFunctions.js
index 4775fe8..c9e658b 100644
--- a/modules/commonFunctions.js
+++ b/modules/commonFunctions.js
@@ -1,648 +1,649 @@
/* Create a gloabal windowManager to open dialogs and append it to the body*/
var windowManager = new OO.ui.WindowManager();
$('body').append( windowManager.$element );
/******** UTIL METHODS ********/
var createMicroOperations = function(operation){
switch (operation.action) {
case 'rename':
return createRenameMicroOperations(operation);
break;
case 'delete':
return createDeleteMicroOperations(operation);
break;
default:
return createDefaultMicroOperations(operation);
}
};
var createDefaultMicroOperations = function(operation){
var microOps = [];
microOps.push(operation);
return microOps;
}
var createRenameMicroOperations = function(operation) {
var microOps = [];
microOps.push({
action: 'rename-move-task',
elementName: operation.elementName,
newElementName: operation.newElementName
});
microOps.push({
action: 'rename-update-task',
elementName: operation.elementName,
newElementName: operation.newElementName
});
return microOps;
};
var createDeleteMicroOperations = function(operation) {
var microOps = [];
microOps.push({
action: 'delete-levelsThree-task',
elementName: operation.elementName
});
microOps.push({
action: 'delete-levelTwo-task',
elementName: operation.elementName
});
return microOps;
};
/*
var createMicroDefaultOperations = function(operation, callback) {
var microOps = [];
microOps.push(operation);
callback(microOps);
};
var createMicroRenameOperations = function(operation, callback) {
var title = new mw.Title($('#courseName').text());
var microOps = [];
getSubpages(title, operation, function(subpages){
for (var i = 0; i < subpages.query.allpages.length; i++) {
var page = subpages.query.allpages[i];
//The better HACK ever: not return the callback until the for dosn't
// completed
if(i === subpages.query.allpages.length - 1) {
getMicroOpsFromBacklinks(page, operation, microOps, function(microOps) {
//Move the page and all its subpages
microOps.push(operation);
callback(microOps);
});
} else {
getMicroOpsFromBacklinks(page, operation, microOps, function(){});
}
}
});
};
var getMicroOpsFromBacklinks = function(page, operation, microOps, returnMicroOps){
var api = new mw.Api();
api.get( {
action: 'query',
list: 'backlinks',
bltitle: page.title,
} ).done( function ( data) {
if(data.query.backlinks.length > 0){
var backlinks = data.query.backlinks;
backlinks.shift(); //the course with transcluded pages
for (var i = 0; i < backlinks.length; i++) {
microOps.push({
action: 'fix-link',
elementName: backlinks[i].title,
linkToReplace: page.title,
replacement: operation.newElementName
});
}
}
returnMicroOps(microOps);
});
};
var getSubpages = function (title, operation, returnSubpages){
var api = new mw.Api();
api.get( {
action: 'query',
list: 'allpages',
apprefix: title.getMain() + "/" + operation.elementName,
apnamespace: title.getNamespaceId()
} ).done( function ( data) {
returnSubpages(data);
});
};*/
/**
* Init handlers
* @param {DraggableGroupWidget} [draggableWidget]
* @param {TextInputWidget} [textInputWidget]
* @param {Array} [editStack]
*/
var initHandlers = function(draggableWidget, textInputWidget, editStack){
$('.deleteElementIcon').click(function(){
deleteElement(draggableWidget, $(this).parent().text(), editStack);
});
$('.editElementIcon').click(function(){
editElement(draggableWidget, $(this).parent().text(), editStack);
});
- $('.moveElementIcon').click(function(){
+ /*$('.moveElementIcon').click(function(){
moveElement(draggableWidget, $(this).parent().text(), editStack);
- });
+ });*/
$('#addElementButton').click(function(){
$('#alert').hide();
$('#alertInputNotEmpty').hide();
addElement(draggableWidget, textInputWidget.getValue(), editStack);
textInputWidget.setValue('');
});
$('.oo-ui-inputWidget-input').attr('id', 'addElementInput');
/*$('#addElementInput').blur(function(){
$('#alert').hide();
addElement(draggableWidget, textInputWidget.getValue(), editStack);
textInputWidget.setValue('');
});*/
$('#addElementInput').keypress(function(keypressed) {
$('#alert').hide();
$('#alertInputNotEmpty').hide();
if(keypressed.which === 13) {
addElement(draggableWidget, textInputWidget.getValue(), editStack);
textInputWidget.setValue('');
}
});
};
/**
* Find the index of a deleted element in the editStack
* @param {String} [elementName]
* @param {Array} [editStack]
*/
var findIndexOfDeletedElement = function(editStack, elementName) {
for (var i = 0; i < editStack.length; i++) {
if (editStack[i]['action'] === 'delete' && editStack[i]['elementName'] === elementName) {
return i;
}
}
return null;
};
/**
* Find the index of already added or renamed element in the editStack
* @param {String} [elementName]
* @param {DraggableWidget} [draggableWidget]
* @return boolean
*/
var elementExist = function(draggableWidget, elementName, callback) {
var api = new mw.Api();
api.get({
action : 'query',
titles : $('#parentName').text() + '/' + elementName
}).done( function ( data ) {
var pages = data.query.pages;
if (!pages['-1']) {
callback(true);
return;
}
var items = draggableWidget.getItems();
for (var item in items) {
if (items[item].data === elementName) {
callback(true);
return;
}
}
callback(false);
} );
};
/**
* Create a drag item, its handlers on edit and remove icons and append it to
* to the draggableWidget.
* @param {DraggableGroupWidget} [draggableWidget]
* @param {String} [elementName]
* @param {Array} [editStack]
*/
var createDragItem = function(draggableWidget, elementName, editStack){
//Create item and icons
var dragItem = new DraggableHandledItemWidget( {
data: elementName,
icon: 'menu',
label: elementName
} );
var iconDelete = $("");
- var iconMove = $("");
+ //var iconMove = $("");
var iconEdit = $("");
//Append icons and add the item to draggableWidget
- dragItem.$label.append(iconDelete, iconMove, iconEdit);
+ //dragItem.$label.append(iconDelete, iconMove, iconEdit);
+ dragItem.$label.append(iconDelete, iconEdit);
draggableWidget.addItems([dragItem]);
//Create handlers
$(iconDelete).click(function(){
deleteElement(draggableWidget, $(this).parent().text(), editStack);
});
$(iconEdit).click(function(){
editElement(draggableWidget, $(this).parent().text(), editStack);
});
- $(iconMove).click(function(){
+ /*$(iconMove).click(function(){
moveElement(draggableWidget, $(this).parent().text(), editStack);
- });
+ });*/
};
/**
* Create a button list group item, its handler on undo and append it to
* to the RecycleBin list group.
* @param {DraggableGroupWidget} [draggableWidget]
* @param {String} [elementName]
* @param {Array} [editStack]
*/
var createRecycleBinItem = function(draggableWidget, elementName, editStack){
//Create item and icon
var liButton = $(' ' + elementName +'');
var undoDeleteIcon = $('');
//Append icon and add the item to the list
liButton.prepend(undoDeleteIcon);
$('.list-group').append(liButton);
//Create handler
$(undoDeleteIcon).click(function(){
var elementToRestore = $(this).parent().attr('id');
restoreElement(draggableWidget, elementToRestore, editStack);
});
}
/******** HELPER METHODS ********/
var dequeue = function(queueName){
$(document).dequeue(queueName);
};
/**
* Rename a element
* @param {DraggableGroupWidget} [draggableWidget]
* @param {String} [elementName]
* @param {Array} [editStack]
*/
var moveElement = function(draggableWidget, elementName, editStack){
var dialog = new MoveDialog(draggableWidget, elementName, editStack);
windowManager.addWindows( [ dialog ] );
windowManager.openWindow( dialog );
};
/**
* Delete a element from the draggableWidget and add a item to the
* RecycleBin list.
* @param {DraggableGroupWidget} [draggableWidget]
* @param {String} [elementName]
* @param {Array} [editStack]
*/
var deleteElement = function(draggableWidget, elementName, editStack){
var elementToRemove = draggableWidget.getItemFromData(elementName);
draggableWidget.removeItems([elementToRemove]);
editStack.push({
action: 'delete',
elementName: elementName
});
createRecycleBinItem(draggableWidget, elementName, editStack);
};
/**
* Restore a element from the RecycleBin and remove its deletion
* from the editStack
* @param {DraggableGroupWidget} [draggableWidget]
* @param {String} [elementName]
* @param {Array} [editStack]
*/
var restoreElement = function(draggableWidget, elementName, editStack){
createDragItem(draggableWidget, elementName, editStack);
editStack.splice(editStack.indexOf({action: 'delete', element: elementName}));
$('li[id="' + elementName + '"]').remove();
};
/**
* Add a element to the draggableWidget automatically if its name isn't
* in the RecycleBin list, otherwise open a MessageDialog and ask to the user
* if he/she prefer to restore the element or create a new one.
* @param {DraggableGroupWidget} [draggableWidget]
* @param {String} [elementName]
* @param {Array} [editStack]
*/
var addElement = function(draggableWidget, elementName, editStack){
if($.trim(elementName).length !== 0){
elementExist(draggableWidget, elementName, function(result){
if(result === true){
$('#alert').show();
}else if (findIndexOfDeletedElement(editStack, elementName) !== null){
var messageDialog = new OO.ui.MessageDialog();
windowManager.addWindows( [ messageDialog ] );
windowManager.openWindow( messageDialog, {
title: OO.ui.deferMsg('courseeditor-message-dialog-title'),
message: OO.ui.deferMsg('courseeditor-message-dialog-message'),
actions: [
{ action: 'reject', label: OO.ui.deferMsg('courseeditor-message-dialog-cancel'), flags: 'safe' },
{ action: 'restore', label: OO.ui.deferMsg('courseeditor-message-dialog-restore') },
{
action: 'confirm',
label: OO.ui.deferMsg('courseeditor-message-dialog-create-new'),
flags: [ 'primary', 'constructive' ]
}
]
} ).then( function ( opened ) {
opened.then( function ( closing, data ) {
if ( data && data.action === 'restore' ) {
restoreElement(draggableWidget, elementName, editStack);
} else if(data && data.action === 'confirm') {
createDragItem(draggableWidget, elementName, editStack);
editStack.push({
action: 'add',
elementName: elementName
});
}
} );
} );
}else {
createDragItem(draggableWidget, elementName, editStack);
editStack.push({
action: 'add',
elementName: elementName
});
}
});
}
};
/**
* Rename a element
* @param {DraggableGroupWidget} [draggableWidget]
* @param {String} [elementName]
* @param {Array} [editStack]
*/
var editElement = function(draggableWidget, elementName, editStack){
var dialog = new EditDialog(draggableWidget, elementName, editStack);
windowManager.addWindows( [ dialog ] );
windowManager.openWindow( dialog );
};
/******** OO.UI OBJECTS ********/
function ProgressDialogIndeterminate( config ) {
ProgressDialogIndeterminate.parent.call( this, config );
};
OO.inheritClass( ProgressDialogIndeterminate, OO.ui.Dialog );
ProgressDialogIndeterminate.static.escapable = false;
ProgressDialogIndeterminate.prototype.initialize = function () {
ProgressDialogIndeterminate.parent.prototype.initialize.call( this );
this.progressBar = new OO.ui.ProgressBarWidget();
this.currentOp = new OO.ui.LabelWidget( {
label: OO.ui.msg('courseeditor-progressdialog-wait')
} );
this.content = new OO.ui.PanelLayout( { padded: true, expanded: false } );
this.content.$element.append(this.progressBar.$element, this.currentOp.$element);
this.$body.append( this.content.$element );
};
ProgressDialogIndeterminate.prototype.getBodyHeight = function () {
return this.content.$element.outerHeight( true );
};
function ProgressDialog( config ) {
ProgressDialog.parent.call( this, config );
};
OO.inheritClass( ProgressDialog, OO.ui.Dialog );
ProgressDialog.static.escapable = false;
ProgressDialog.prototype.initialize = function () {
ProgressDialog.parent.prototype.initialize.call( this );
this.progressBar = new OO.ui.ProgressBarWidget({
progress: 0
});
this.currentOp = new OO.ui.LabelWidget( {
label: ''
} );
this.content = new OO.ui.PanelLayout( { padded: true, expanded: false } );
this.content.$element.append(this.progressBar.$element, this.currentOp.$element);
this.$body.append( this.content.$element );
};
ProgressDialog.prototype.getBodyHeight = function () {
return this.content.$element.outerHeight( true );
};
ProgressDialog.prototype.updateProgress = function(unitaryIncrement){
var currentProgress = this.progressBar.getProgress();
this.progressBar.setProgress(currentProgress + unitaryIncrement);
};
ProgressDialog.prototype.setCurrentOp = function(operation){
var labelToSet = OO.ui.msg('courseeditor-operation-action-' + operation.action);
if(operation.elementName){
labelToSet += " " + operation.elementName;
}
this.currentOp.setLabel(labelToSet);
};
/****** Draggable Widget ******/
/**
* Draggable group widget containing drag/drop items
*
* @param {Object} [config] Configuration options
*/
function DraggableGroupWidget( config ) {
// Configuration initialization
config = config || {};
// Parent constructor
DraggableGroupWidget.parent.call( this, config );
// Mixin constructors
OO.ui.mixin.DraggableGroupElement.call( this, $.extend( {}, config, { $group: this.$element } ) );
}
/* Setup */
OO.inheritClass( DraggableGroupWidget, OO.ui.Widget );
OO.mixinClass( DraggableGroupWidget, OO.ui.mixin.DraggableGroupElement );
/**
* Drag/drop items with custom handle
*
* @param {Object} [config] Configuration options
*/
function DraggableHandledItemWidget( config ) {
// Configuration initialization
config = config || {};
// Parent constructor
DraggableHandledItemWidget.parent.call( this, config );
// Mixin constructors
OO.ui.mixin.DraggableElement.call( this, $.extend( { $handle: this.$icon }, config ) );
}
/* Setup */
OO.inheritClass( DraggableHandledItemWidget, OO.ui.DecoratedOptionWidget );
OO.mixinClass( DraggableHandledItemWidget, OO.ui.mixin.DraggableElement );
/****** Edit Dialog ******/
/* Create a dialog */
function EditDialog(draggableWidget, elementName, editStack, config ) {
EditDialog.parent.call( this, config );
this.draggableWidget = draggableWidget;
this.elementName = elementName;
this.editStack = editStack;
this.textInputWidget = new OO.ui.TextInputWidget($.extend( { validate: 'non-empty' }, config ) );
this.textInputWidget.setValue(elementName);
}
/* Inheritance */
OO.inheritClass( EditDialog, OO.ui.ProcessDialog );
/* Static Properties */
EditDialog.static.title = OO.ui.deferMsg( 'courseeditor-edit-dialog' );
EditDialog.static.actions = [
{ action: 'save', label: OO.ui.deferMsg( 'courseeditor-rename' ), flags: 'primary' },
{ label: OO.ui.deferMsg( 'courseeditor-cancel' ), flags: 'safe' }
];
/* Initialize the dialog elements */
EditDialog.prototype.initialize = function () {
EditDialog.parent.prototype.initialize.apply( this, arguments );
this.content = new OO.ui.PanelLayout( { padded: true, expanded: false } );
this.content.$element.append(this.textInputWidget.$element );
this.$body.append( this.content.$element );
};
/* Define actions */
EditDialog.prototype.getActionProcess = function ( action ) {
var dialog = this;
if ( action === 'save' ) {
return new OO.ui.Process( function () {
var newElementName = dialog.textInputWidget.getValue();
var items = dialog.draggableWidget.getItems();
elementExist(dialog.draggableWidget, newElementName, function(result){
if(result === true){
$('#alert').show();
}else {
items.filter(function(element) {
if(element.data === dialog.elementName){
element.setData(newElementName);
element.setLabel(newElementName);
var iconDelete = $("");
var iconEdit = $("");
element.$label.append(iconDelete, iconEdit);
$(iconDelete).click(function(){
deleteElement(dialog.draggableWidget, $(this).parent().text(), dialog.editStack);
});
$(iconEdit).click(function(){
editElement(dialog.draggableWidget, $(this).parent().text(), dialog.editStack);
});
dialog.editStack.push({
action: 'rename',
elementName: dialog.elementName,
newElementName: newElementName
})
}
});
}
});
dialog.close( { action: action } );
} );
}
return EditDialog.parent.prototype.getActionProcess.call( this, action );
};
/****** Move Dialog ******/
/* Create a dialog */
function MoveDialog(draggableWidget, elementName, editStack, config ) {
MoveDialog.parent.call( this, config );
this.draggableWidget = draggableWidget;
this.elementName = elementName;
this.editStack = editStack;
};
/* Inheritance */
OO.inheritClass( MoveDialog, OO.ui.ProcessDialog );
/* Static Properties */
MoveDialog.static.title = 'Sposta sezione';
MoveDialog.static.size = 'large';
MoveDialog.static.actions = [
{ action: 'move', label: 'Conferma', flags: ['primary', 'constructive'], icon: 'check' },
{
'label': 'Annulla',
'flags': 'safe',
'modes': 'intro',
'icon': 'close'
}
];
/* Set the body height */
MoveDialog.prototype.getBodyHeight = function() {
return 250;
};
/* Initialize the dialog elements */
MoveDialog.prototype.initialize = function () {
MoveDialog.parent.prototype.initialize.apply( this, arguments );
var dialog = this;
this.dropdownWidget = new OO.ui.DropdownWidget({
label: 'Seleziona un capitolo di destinazione'
});
this.populateDropdown(function(items){
dialog.dropdownWidget.getMenu().addItems(items);
});
this.layoutSelectLevelTwo = new OO.ui.FieldLayout(this.dropdownWidget,{
align: 'top',
label: 'Capitolo'
});
this.content = new OO.ui.PanelLayout( { padded: true, expanded: false } );
this.content.$element.append(this.layoutSelectLevelTwo.$element);
this.$body.append( this.content.$element );
this.updateSize();
};
MoveDialog.prototype.populateDropdown = function(callback) {
var sectionName = $('#parentName').text();
var splitted = sectionName.split('/');
var courseName;
if(splitted.length > 2){
courseName = splitted[0] + '/' + splitted[1];
}else {
courseName = splitted[0];
}
var dialog = this;
$.getJSON( mw.util.wikiScript(), {
action: 'ajax',
rs: 'CourseEditorUtils::getLevelsTwoJson',
rsargs: [courseName]
}, function ( data ) {
var items = [];
$.each(data, function(key, value){
items.push(new OO.ui.MenuOptionWidget( {
data: value,
label: value,
} ));
});
//dialog.dropdownWidget.getMenu().addItems(items);
callback(items);
});
};
/* Define actions
MoveDialog.prototype.getActionProcess = function ( action ) {
var dialog = this;
if ( action === 'save' ) {
return new OO.ui.Process( function () {
var newElementName = dialog.textInputWidget.getValue();
var items = dialog.draggableWidget.getItems();
elementExist(dialog.draggableWidget, newElementName, function(result){
if(result === true){
$('#alert').show();
}else {
items.filter(function(element) {
if(element.data === dialog.elementName){
element.setData(newElementName);
element.setLabel(newElementName);
var iconDelete = $("");
var iconEdit = $("");
element.$label.append(iconDelete, iconEdit);
$(iconDelete).click(function(){
deleteElement(dialog.draggableWidget, $(this).parent().text(), dialog.editStack);
});
$(iconEdit).click(function(){
editElement(dialog.draggableWidget, $(this).parent().text(), dialog.editStack);
});
dialog.editStack.push({
action: 'rename',
elementName: dialog.elementName,
newElementName: newElementName
})
}
});
}
});
dialog.close( { action: action } );
} );
}
return MoveDialog.parent.prototype.getActionProcess.call( this, action );
};*/
diff --git a/modules/levelTwoEditor.js b/modules/levelTwoEditor.js
index df33783..6c0676c 100644
--- a/modules/levelTwoEditor.js
+++ b/modules/levelTwoEditor.js
@@ -1,116 +1,116 @@
$(function () {
var dragElements = [];
//Add all existing levelsThree to the dragElements array
$.each(levelsThree, function(key, value){
var dragItem = new DraggableHandledItemWidget( {
data: value,
icon: 'menu',
label: value
} );
dragItem.$label.append("",
- "",
+ //"",
"");
dragElements.push(dragItem);
});
//Create a draggableWidget with the items in the dragElements array
var draggableWidget = new DraggableGroupWidget( {
items: dragElements
} );
var fieldDrag = new OO.ui.FieldLayout(draggableWidget);
//Create a textInputWidget for new levelsThree
var textInputWidget = new OO.ui.TextInputWidget( { placeholder: OO.ui.deferMsg( 'courseeditor-add-new-levelThree' ) } );
var addButton = new OO.ui.ButtonWidget({id: 'addElementButton', label: ''});
addButton.$label.append("");
var fieldInput = new OO.ui.ActionFieldLayout( textInputWidget, addButton);
//Append all created elements to DOM
$('#levelsThreeList').append(fieldDrag.$element, fieldInput.$element);
//Init Handlers
initHandlers(draggableWidget, textInputWidget, editStack);
$('#saveLevelTwoButton').click(function(){
var inputWidgetContent = textInputWidget.getValue();
if ($.trim(inputWidgetContent).length !== 0) {
$('#alertInputNotEmpty').show();
return;
}
var newLevelsThree = [];
$.each(draggableWidget.getItems(), function(key, value){
newLevelsThree.push(value.data);
});
editStack.push({
action: 'update',
elementsList: JSON.stringify(newLevelsThree)
});
editStack.push({
action: 'purge'
});
editStack.push({
action: 'update-collection'
});
var progressDialog = new ProgressDialog( {
size: 'medium'
} );
var unitaryIncrement = 100/editStack.length;
windowManager.addWindows( [ progressDialog ] );
windowManager.openWindow( progressDialog );
var createTask = function(operation){
return function(next){
doTask(operation, next);
}
};
var doTask = function(operation, next){
progressDialog.setCurrentOp(operation);
$.getJSON( mw.util.wikiScript(), {
action: 'ajax',
rs: 'CourseEditorOperations::applyLevelTwoOp',
rsargs: [$('#parentName').text(), JSON.stringify(operation)]
}, function ( data ) {
if (data.success !== true) {
$('#alert').html(OO.ui.msg('courseeditor-error-operation'));
$('#alert').append(OO.ui.msg('courseeditor-operation-action-' + data.action));
if(data.elementName){
var localizedMsg = " " + data.elementName + OO.ui.msg('courseeditor-error-operation-fail');
$('#alert').append(localizedMsg);
}else {
$('#alert').append(OO.ui.msg('courseeditor-error-operation-fail'));
}
$('#alert').show();
windowManager.closeWindow(progressDialog);
$(document).clearQueue('tasks');
}else{
progressDialog.updateProgress(unitaryIncrement);
next();
}
});
};
while( editStack.length > 0 ) {
var operation = editStack.shift();
$(document).queue('tasks', createTask(operation));
};
$(document).queue('tasks', function(){
windowManager.closeWindow(progressDialog);
var levelTwoName = $('#parentName').text();
var splitted = levelTwoName.split('/');
var courseName;
if(splitted.length > 2){
courseName = splitted[0] + '/' + splitted[1];
}else {
courseName = splitted[0];
}
window.location.assign('/' + courseName);
});
dequeue('tasks')
});
})