[MediaWiki-commits] [Gerrit] mediawiki...MOOC[master]: non-JS video URL retrieval
Sebschlicht2 has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/342622 ) Change subject: non-JS video URL retrieval .. non-JS video URL retrieval URLs of video source files are now retrieved using wfFindFile in the extension PHP core instead of error-pronely navigating the DOM tree of an injected video player. The JS code that extracted the URL prior to this change has been removed. Several small UI bugs have been fixed alongside. Change-Id: I07fa114a6b1a2569c29b84ccf8451e575885bd1e --- M MOOC.php M includes/rendering/MoocContentRenderer.php M includes/rendering/MoocLessonRenderer.php M includes/rendering/MoocOverviewRenderer.php M resources/js/ext.mooc.js M resources/less/ext.mooc.less 6 files changed, 94 insertions(+), 117 deletions(-) diff --git a/MOOC.php b/MOOC.php index 92edd07..940f603 100644 --- a/MOOC.php +++ b/MOOC.php @@ -15,7 +15,8 @@ $wgResourceLoaderDebug = true; // TODO get out how to include jquery.ui.effects (includes easing) other than shipping - +// TODO can we automatically prefix classes/ids? at least in LESS? + $wgMOOCSectionConfig = [ 'learning-goals' => [ 'collapsed' => false diff --git a/includes/rendering/MoocContentRenderer.php b/includes/rendering/MoocContentRenderer.php index 8033b93..bc8b4c6 100644 --- a/includes/rendering/MoocContentRenderer.php +++ b/includes/rendering/MoocContentRenderer.php @@ -235,23 +235,27 @@ * Adds an info box emphasising users to contribute to a currently empty section to the output. * * @param string $sectionKey key of the empty section + * @param bool $showActionAddContent whether to show controls to add content * @param string $editHref edit link */ -protected function addEmptySectionBox( $sectionKey, $editHref = null ) { -// TODO can we automatically prefix classes/ids? at least in LESS? -$this->out->addHTML(''); +protected function addEmptySectionBox( $sectionKey, $showActionAddContent = true, $editHref = null ) { +$this->out->addHTML( '' ); -$this->out->addHTML(''); -$this->out->addHTML( $this->loadMessage( 'section-' . $sectionKey . '-empty-description' ) ); -$this->out->addHTML(' '); +// inform about missing content +$this->out->addHTML( "{$this->loadMessage( "section-$sectionKey-empty-description" )}" ); -$editHrefAttr = ( $editHref === null ) ? '' : 'href="' . $editHref . '"'; -$this->out->addHTML( '' ); -$this->out->addHTML($this->loadMessage('section-' . $sectionKey . '-empty-edit-link')); -$this->out->addHTML(''); -// TODO do we need an additional text to point at external resources such as /script or general hints? - -$this->out->addHTML(''); +// add controls to add content +if ( $showActionAddContent ) { +// build edit link +$editHrefAttr = ( $editHref === null ) ? '' : " href='$editHref'"; + +// TODO do we need an additional text to point at external resources such as /script or general hints? +$this->out->addHTML( " " ); +$this->out->addHTML( $this->loadMessage( "section-$sectionKey-empty-edit-link" ) ); +$this->out->addHTML( '' ); +} + +$this->out->addHTML( '' ); } /** diff --git a/includes/rendering/MoocLessonRenderer.php b/includes/rendering/MoocLessonRenderer.php index 13f0555..32c13c5 100644 --- a/includes/rendering/MoocLessonRenderer.php +++ b/includes/rendering/MoocLessonRenderer.php @@ -40,7 +40,13 @@ $this->endSection(); } -protected function addUnitsSectionContent( $lesson ) { +/** + * Adds the content of the units section. + * + * @param MoocLesson $lesson lesson which units to list + * @param bool $showActionAddUnit whether to show controls to add units if none have been added yet + */ +protected function addUnitsSectionContent( $lesson, $showActionAddUnit = true ) { if ( $lesson->hasChildren() ) { // list child units if any foreach ( $lesson->children as $unit ) { @@ -48,7 +54,7 @@ } } else { // show info box if no child units added yet -$this->addEmptySectionBox( self::SECTION_KEY_UNITS ); +$this->addEmptySectionBox( self::SECTION_KEY_UNITS, $showActionAddUnit ); } } @@ -93,7 +99,7 @@ if ( $learningGoals !== null ) { $this->out->addWikiText( $learningGoals ); } else { -$this->out->addHTML( $this->loadMessage( 'section-' . 'learning-goals' . '-empty-description' ) ); +$this->out->addHTML( $this->loadMessage( 'section-learning-goals-empty-description' ) ); } $this->out->addHTML( '' ); @@ -112,19 +118,19 @@ * * @param MoocUnit $unit child un
[MediaWiki-commits] [Gerrit] mediawiki...MOOC[master]: non-JS video URL retrieval
Sebschlicht2 has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/342622 ) Change subject: non-JS video URL retrieval .. non-JS video URL retrieval URLs of video source files are now retrieved using wfFindFile in the extension PHP core instead of error-pronely navigating the DOM tree of an injected video player. The JS code that extracted the URL prior to this change has been removed. Several small UI bugs have been fixed alongside. Change-Id: I07fa114a6b1a2569c29b84ccf8451e575885bd1e --- M MOOC.php M includes/rendering/MoocContentRenderer.php M includes/rendering/MoocLessonRenderer.php M includes/rendering/MoocOverviewRenderer.php M resources/js/ext.mooc.js M resources/less/ext.mooc.less 6 files changed, 94 insertions(+), 117 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MOOC refs/changes/22/342622/1 diff --git a/MOOC.php b/MOOC.php index 92edd07..940f603 100644 --- a/MOOC.php +++ b/MOOC.php @@ -15,7 +15,8 @@ $wgResourceLoaderDebug = true; // TODO get out how to include jquery.ui.effects (includes easing) other than shipping - +// TODO can we automatically prefix classes/ids? at least in LESS? + $wgMOOCSectionConfig = [ 'learning-goals' => [ 'collapsed' => false diff --git a/includes/rendering/MoocContentRenderer.php b/includes/rendering/MoocContentRenderer.php index 8033b93..bc8b4c6 100644 --- a/includes/rendering/MoocContentRenderer.php +++ b/includes/rendering/MoocContentRenderer.php @@ -235,23 +235,27 @@ * Adds an info box emphasising users to contribute to a currently empty section to the output. * * @param string $sectionKey key of the empty section + * @param bool $showActionAddContent whether to show controls to add content * @param string $editHref edit link */ -protected function addEmptySectionBox( $sectionKey, $editHref = null ) { -// TODO can we automatically prefix classes/ids? at least in LESS? -$this->out->addHTML(''); +protected function addEmptySectionBox( $sectionKey, $showActionAddContent = true, $editHref = null ) { +$this->out->addHTML( '' ); -$this->out->addHTML(''); -$this->out->addHTML( $this->loadMessage( 'section-' . $sectionKey . '-empty-description' ) ); -$this->out->addHTML(' '); +// inform about missing content +$this->out->addHTML( "{$this->loadMessage( "section-$sectionKey-empty-description" )}" ); -$editHrefAttr = ( $editHref === null ) ? '' : 'href="' . $editHref . '"'; -$this->out->addHTML( '' ); -$this->out->addHTML($this->loadMessage('section-' . $sectionKey . '-empty-edit-link')); -$this->out->addHTML(''); -// TODO do we need an additional text to point at external resources such as /script or general hints? - -$this->out->addHTML(''); +// add controls to add content +if ( $showActionAddContent ) { +// build edit link +$editHrefAttr = ( $editHref === null ) ? '' : " href='$editHref'"; + +// TODO do we need an additional text to point at external resources such as /script or general hints? +$this->out->addHTML( " " ); +$this->out->addHTML( $this->loadMessage( "section-$sectionKey-empty-edit-link" ) ); +$this->out->addHTML( '' ); +} + +$this->out->addHTML( '' ); } /** diff --git a/includes/rendering/MoocLessonRenderer.php b/includes/rendering/MoocLessonRenderer.php index 13f0555..32c13c5 100644 --- a/includes/rendering/MoocLessonRenderer.php +++ b/includes/rendering/MoocLessonRenderer.php @@ -40,7 +40,13 @@ $this->endSection(); } -protected function addUnitsSectionContent( $lesson ) { +/** + * Adds the content of the units section. + * + * @param MoocLesson $lesson lesson which units to list + * @param bool $showActionAddUnit whether to show controls to add units if none have been added yet + */ +protected function addUnitsSectionContent( $lesson, $showActionAddUnit = true ) { if ( $lesson->hasChildren() ) { // list child units if any foreach ( $lesson->children as $unit ) { @@ -48,7 +54,7 @@ } } else { // show info box if no child units added yet -$this->addEmptySectionBox( self::SECTION_KEY_UNITS ); +$this->addEmptySectionBox( self::SECTION_KEY_UNITS, $showActionAddUnit ); } } @@ -93,7 +99,7 @@ if ( $learningGoals !== null ) { $this->out->addWikiText( $learningGoals ); } else { -$this->out->addHTML( $this->loadMessage( 'section-' . 'learning-goals' . '-empty-description' ) ); +$this->out->addHTML( $this->loadMessage( 'section-learning-goals-empty-description' ) ); } $this->ou