jenkins-bot has submitted this change and it was merged.
Change subject: Checklist: using new API
......................................................................
Checklist: using new API
* using new API implementation (with stores and tasks)
* two new message keys for revision history
* several bugfixes
Patch Set 3: Implemented CR
Change-Id: I32483409b9df7ea7ffdb8c18f2afb9631b2c3da9
---
M Checklist/Checklist.class.php
M Checklist/Checklist.setup.php
M Checklist/i18n/en.json
M Checklist/i18n/qqq.json
A Checklist/includes/api/BSApiChecklistAvailableOptionsStore.php
A Checklist/includes/api/BSApiChecklistTasks.php
A Checklist/includes/api/BSApiChecklistTemplateStore.php
M Checklist/resources/BS.Checklist/ChecklistBoxSelect.js
M Checklist/resources/BS.Checklist/Window.js
D Checklist/resources/BS.Checklist/model/Checklist.js
M Checklist/resources/bluespice.checklist.js
D Checklist/views/view.ChecklistCheck.php
12 files changed, 399 insertions(+), 460 deletions(-)
Approvals:
Mglaser: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Checklist/Checklist.class.php b/Checklist/Checklist.class.php
index bd6a958..f8cbfc1 100644
--- a/Checklist/Checklist.class.php
+++ b/Checklist/Checklist.class.php
@@ -71,6 +71,7 @@
$this->setHook( 'BSExtendedEditBarBeforeEditToolbar' );
$this->setHook( 'BSInsertMagicAjaxGetData',
'onBSInsertMagicAjaxGetData' );
$this->setHook( 'VisualEditorConfig' );
+ $this->mCore->registerPermission( 'checklistmodify', array(
'user' ) );
wfProfileOut( 'BS::'.__METHOD__ );
}
@@ -88,187 +89,43 @@
array_splice( $aConfigStandard["toolbar1"], $iIndexStandard +
1, 0, "bscheckbox" );
// Add context menu entry
- $aConfigStandard["contextmenu"] =
str_replace('bsContextMenuMarker', 'bsContextMenuMarker bsChecklist',
$aConfigStandard["contextmenu"] );
+ $aConfigStandard["contextmenu"] = str_replace(
'bsContextMenuMarker', 'bsContextMenuMarker bsChecklist',
$aConfigStandard["contextmenu"] );
return true;
}
- public static function doChangeCheckItem() {
- $oRequest = RequestContext::getMain()->getRequest();
- $iPos = $oRequest->getInt( 'pos', 0 );
- if ( $iPos == 0 ) return 'false';
- $sValue = $oRequest->getVal( 'value', '' );
- if ( $sValue == '' ) return 'false';
- $sArticleId = $oRequest->getInt( 'articleId', 0 );
- if ( $sArticleId == 0 ) return 'false';
-
- $oWikiPage = WikiPage::newFromID( $sArticleId );
- $oContent = $oWikiPage->getContent();
- $sContent = $oContent->getNativeData();
-
- $bChecked = null;
- // Maybe a sanity-check is just enough here
- $sNewValue = 'value="';
- if ( $sValue == 'true' ) {
- $sNewValue .= "checked";
- $bChecked = true;
- } else if ( $sValue == 'false' ) {
- $bChecked = false;
- $sNewValue .= "";
- } else {
- $sNewValue .= $sValue;
- }
- #$sNewValue .= $iPos;
- $sNewValue .= '" ';
-
- $sContent = self::preg_replace_nth( "/(<bs:checklist
)([^>]*?>)/", "$1".$sNewValue."$2", $sContent, $iPos );
-
- #return $sContent;
-
- $sSummary = "Modified Check";
- $oContentHandler = $oContent->getContentHandler();
- $oNewContent = $oContentHandler->makeContent($sContent,
$oWikiPage->getTitle());
- $oResult = $oWikiPage->doEditContent( $oNewContent, $sSummary );
-
- // Create a log entry for the changes on the checklist values
- $oTitle = $oWikiPage->getTitle();
- $oUser = RequestContext::getMain()->getUser();
- if( !is_null( $bChecked ) ) {
- if( $bChecked ) {
- $oLogger = new ManualLogEntry( 'bs-checklist',
'checked' );
- $oLogger->setParameters( array(
- '4::position' => $iPos
- ) );
- } else {
- $oLogger = new ManualLogEntry( 'bs-checklist',
'unchecked' );
- $oLogger->setParameters( array(
- '4::position' => $iPos
- ) );
- }
- } else {
- $oLogger = new ManualLogEntry( 'bs-checklist',
'selected' );
- $oLogger->setParameters( array(
- '4::position' => $iPos,
- '5::selected' => $sValue
- ) );
- }
- $oLogger->setPerformer( $oUser );
- $oLogger->setTarget( $oTitle );
- $oLogger->insert();
-
- return 'true';
- }
-
- public static function ajaxGetTemplateData() {
- $aTemplateData = array();
- $dbr = wfGetDB(DB_SLAVE);
- $res = $dbr->select(
- array( 'page' ),
- array( 'page_namespace', 'page_title' ),
- array(
- 'page_namespace' => NS_TEMPLATE
- )
- );
-
- $aTitles = array();
- foreach( $res as $row ) {
- $oTitle = Title::makeTitle(
- $row->page_namespace,
- $row->page_title
- );
- // only add those titles that do have actual lists
- $aListOptions = self::getListOptions(
$oTitle->getFullText() );
- if (sizeof( $aListOptions ) > 0 ) {
- $aTitles[] = $oTitle->getText();
+ public static function getListOptions( $listTitle ) {
+ $aOptions = array();
+ $oTitle = Title::newFromText( $listTitle, NS_TEMPLATE );
+ //echo $args['list']." ".$oTitle->getArticleID();
+ if ( is_object( $oTitle ) ) {
+ $oWikiPage = WikiPage::newFromID(
$oTitle->getArticleID() );
+ if ( is_object( $oWikiPage ) ) {
+ $sContent =
$oWikiPage->getContent()->getNativeData();
+ $aLines = explode( "\n", $sContent );
+ foreach ( $aLines as $sLine ) {
+ if ( strpos( $sLine, '*' ) !== 0 )
continue;
+ $sNewLine = trim( substr( $sLine, 1 ) );
+ $aOptions[] = $sNewLine;
+ }
}
}
- foreach ($aTitles as $sTitle ) {
- $oTemplate = new stdClass();
- $oTemplate->text = $sTitle;
- $oTemplate->leaf = true;
- $oTemplate->id = $sTitle;
- $aTemplateData[] = $oTemplate;
- }
-
- return FormatJson::encode( $aTemplateData );
+ return $aOptions;
}
- public static function ajaxGetItemStoreData() {
- return FormatJson::encode( array() );
- }
- public static function ajaxSaveOptionsList( $sTitle, $aRecords ) {
- $oTitle = Title::newFromText( $sTitle, NS_TEMPLATE );
-
- $sContent = '';
- foreach( $aRecords as $record ) {
- $sContent .= '* '.$record."\n";
- }
-
- // TODO: i18n
- $sSummary = "Updated list";
-
- $oWikiPage = WikiPage::factory( $oTitle );
- $oContentHandler = $oWikiPage->getContentHandler();
- $oNewContent = $oContentHandler->makeContent($sContent,
$oWikiPage->getTitle());
- $oResult = $oWikiPage->doEditContent( $oNewContent, $sSummary );
-
- //TODO: proper json answer
- return FormatJson::encode( "OK" );
- }
-
- public static function getOptionsList() {
- $oRequest = RequestContext::getMain()->getRequest();
- $sList = $oRequest->getVal( 'listId', '' );
- $theList = self::getListOptions( $sList );
- return FormatJson::encode( $theList );
- }
-
- public static function getAvailableOptions() {
- $aTemplateData = array();
- $dbr = wfGetDB(DB_SLAVE);
- $res = $dbr->select(
- array( 'page' ),
- array( 'page_namespace', 'page_title' ),
- array(
- 'page_namespace' => NS_TEMPLATE
- )
- );
-
- $aAvailableOptions = array();
- foreach( $res as $row ) {
- $oTitle = Title::makeTitle(
- $row->page_namespace,
- $row->page_title
- );
- // only add those titles that do have actual lists
- $aListOptions = self::getListOptions(
$oTitle->getFullText() );
- if (sizeof( $aListOptions ) > 0 ) {
- $aAvailableOptions =
array_merge($aAvailableOptions, $aListOptions);
- }
- }
- foreach ($aAvailableOptions as $sOption ) {
- $oTemplate = new stdClass();
- $oTemplate->text = $sOption;
- $oTemplate->leaf = true;
- $oTemplate->id = $sOption;
- $aTemplateData[] = $oTemplate;
- }
-
- return FormatJson::encode( $aTemplateData );
- }
/*http://www.php.net/manual/en/function.preg-replace.php#112400*/
- protected static function preg_replace_nth($pattern, $replacement,
$subject, $nth=1) {
- return preg_replace_callback($pattern,
- function($found) use (&$pattern, &$replacement, &$nth) {
+ public static function preg_replace_nth( $pattern, $replacement,
$subject, $nth=1 ) {
+ return preg_replace_callback( $pattern,
+ function( $found ) use ( &$pattern, &$replacement,
&$nth ) {
$nth--;
- if ($nth==0) {
- $sResult = preg_replace(
'/value=".*?" /', '', reset($found) );
- $sResult =
preg_replace($pattern, $replacement, $sResult );
+ if ( $nth==0 ) {
+ $sResult = preg_replace(
'/value=".*?" /', '', reset( $found ) );
+ $sResult = preg_replace(
$pattern, $replacement, $sResult );
return $sResult;
}
- return reset($found);
- }, $subject,$nth );
+ return reset( $found );
+ }, $subject,$nth );
}
/**
@@ -282,8 +139,8 @@
}
public function onBSExtendedEditBarBeforeEditToolbar( &$aRows,
&$aButtonCfgs ) {
-
$this->getOutput()->addModuleStyles('ext.bluespice.checklist.styles');
- $this->getOutput()->addModules('ext.bluespice.checklist');
+ $this->getOutput()->addModuleStyles(
'ext.bluespice.checklist.styles' );
+ $this->getOutput()->addModules( 'ext.bluespice.checklist' );
$aRows[0]['dialogs'][60] = 'bs-editbutton-checklist';
@@ -320,68 +177,45 @@
return true;
}
- public static function getListOptions( $listTitle ) {
- $aOptions = array();
- $oTitle = Title::newFromText( $listTitle, NS_TEMPLATE );
- //echo $args['list']." ".$oTitle->getArticleID();
- if ( is_object( $oTitle )) {
- $oWikiPage = WikiPage::newFromID(
$oTitle->getArticleID() );
- if ( is_object( $oWikiPage ) ) {
- $sContent =
$oWikiPage->getContent()->getNativeData();
- $aLines = explode( "\n", $sContent );
- foreach ( $aLines as $sLine ) {
- if ( strpos( $sLine, '*' ) !== 0 )
continue;
- $sNewLine = trim(substr($sLine, 1));
- $aOptions[] = $sNewLine;
- }
- }
- }
- return $aOptions;
- }
public function onMagicWordBsChecklist( $input, $args, $parser ) {
- /*
- *16:37:57: Echt? Ich dachte du machst ein Edit auf der Seite.
Da müsste der Cache doch automatisch invalidiert werden, oder?
- *16:38:56: Und falls das nicht geht sollte ein
$oTitle->invalidateCache(); den gleichen Effekt haben.
- */
$parser->disableCache();
$this->bCheckboxFound = true;
$sOut = array();
- if (isset($args['list'])) {
+ if ( isset( $args['list'] ) ) {
$aOptions = $this->getListOptions( $args['list'] );
}
- if( !isset($args['value']) || $args['value'] === 'false' ) {
+ if( !isset( $args['value'] ) || $args['value'] === 'false' ) {
$args['value'] = '';
}
- //$aOptions = array("grün", "blau", "gelb", "rot");
$sSelectColor = '';
- if (isset($args['type']) && $args['type'] == 'list' ) {
+ if ( isset( $args['type'] ) && $args['type'] == 'list' ) {
$sOut[] = "<select {color} ";
$sOut[] = "id='bs-cb-".$this->getNewCheckboxId()."' ";
$sOut[] = "onchange='BsChecklist.change(this);' ";
$sOut[] = ">";
- $bDefault = empty($args['value']) ? true : false;
+ $bDefault = empty( $args['value'] ) ? true : false;
foreach ( $aOptions as $sOption ) {
- $aOptionSet = explode("|", $sOption);
+ $aOptionSet = explode( "|", $sOption );
- if (!$sSelectColor && isset ($aOptionSet[1])) {
+ if ( !$sSelectColor && isset( $aOptionSet[1] )
) {
$sSelectColor =
"style='color:".$aOptionSet[1].";' ";
}
$sOption = $aOptionSet[0];
$sOut[] = "<option ";
- if (isset ($aOptionSet[1])) {
+ if ( isset( $aOptionSet[1] ) ) {
$sOut[] =
"style='color:".$aOptionSet[1].";' ";
}
- if( $bDefault || $args['value'] == $sOption ) {
+ if ( $bDefault || $args['value'] == $sOption ) {
$bDefault = false;
$sOut[] = "selected='selected'";
- if (isset ($aOptionSet[1])) {
+ if ( isset( $aOptionSet[1] ) ) {
$sSelectColor =
"style='color:".$aOptionSet[1].";' ";
}
}
@@ -399,8 +233,8 @@
}
$sOut[] = "/>";
}
- $sOut = implode($sOut, '');
- $sOut = str_replace('{color}', $sSelectColor, $sOut);
+ $sOut = implode( $sOut, '' );
+ $sOut = str_replace( '{color}', $sSelectColor, $sOut );
return $sOut;
}
@@ -418,7 +252,7 @@
public function onBeforePageDisplay( &$oOutputPage, &$oSkin ) {
// also needed in edit mode
//if ( $this->bCheckboxFound ) {
- $oOutputPage->addModules('ext.bluespice.checklist');
+ $oOutputPage->addModules( 'ext.bluespice.checklist' );
//}
return true;
}
diff --git a/Checklist/Checklist.setup.php b/Checklist/Checklist.setup.php
index 3241d8e..3789502 100644
--- a/Checklist/Checklist.setup.php
+++ b/Checklist/Checklist.setup.php
@@ -4,6 +4,14 @@
$GLOBALS['wgAutoloadClasses']['Checklist'] = __DIR__ . '/Checklist.class.php';
+$GLOBALS['wgAutoloadClasses']['BSApiChecklistAvailableOptionsStore'] = __DIR__
. '/includes/api/BSApiChecklistAvailableOptionsStore.php';
+$GLOBALS['wgAutoloadClasses']['BSApiChecklistTemplateStore'] = __DIR__ .
'/includes/api/BSApiChecklistTemplateStore.php';
+$GLOBALS['wgAutoloadClasses']['BSApiChecklistTasks'] = __DIR__ .
'/includes/api/BSApiChecklistTasks.php';
+
+$wgAPIModules['bs-checklist-available-options-store'] =
'BSApiChecklistAvailableOptionsStore';
+$wgAPIModules['bs-checklist-template-store'] = 'BSApiChecklistTemplateStore';
+$wgAPIModules['bs-checklist-tasks'] = 'BSApiChecklistTasks';
+
$wgExtensionMessagesFiles['Checklist'] = __DIR__ .
'/languages/Checklist.i18n.php';
$aResourceModuleTemplate = array(
@@ -44,14 +52,6 @@
) + $aResourceModuleTemplate;
unset( $aResourceModuleTemplate );
-
-$wgAjaxExportList[] = 'Checklist::doChangeCheckItem';
-$wgAjaxExportList[] = 'Checklist::getOptionsList';
-$wgAjaxExportList[] = 'Checklist::ajaxGetTemplateData';
-$wgAjaxExportList[] = 'Checklist::ajaxSaveOptionsList';
-$wgAjaxExportList[] = 'Checklist::ajaxGetItemStoreData';
-$wgAjaxExportList[] = 'Checklist::getAvailableOptions';
-#$wgAutoloadClasses['ViewChecklistCheck'] = __DIR__ .
'/views/view.ChecklistCheck.php';
$wgLogTypes[] = 'bs-checklist';
$wgFilterLogTypes['bs-checklist'] = true;
diff --git a/Checklist/i18n/en.json b/Checklist/i18n/en.json
index c6a723c..36c329d 100644
--- a/Checklist/i18n/en.json
+++ b/Checklist/i18n/en.json
@@ -31,5 +31,12 @@
"log-show-hide-bs-checklist": "$1 checkbox log",
"logentry-bs-checklist-checked": "$1 {{GENDER:$2|has checked}} checkbox
#$4 on $3",
"logentry-bs-checklist-unchecked": "$1 {{GENDER:$2|has unchecked}}
checkbox #$4 to $3",
- "logentry-bs-checklist-selected": "$1 {{GENDER:$2|has selected}} the
value \"$5\" in select box #$4 on $3"
+ "logentry-bs-checklist-selected": "$1 {{GENDER:$2|has selected}} the
value \"$5\" in select box #$4 on $3",
+ "bs-checklist-savelist-error-invalid-title": "Invalid title provided",
+ "bs-checklist-savelist-error-edit-not-permitted": "Insufficient
permissions to save list",
+ "bs-checklist-modified-check": "Modified checklist value",
+ "bs-checklist-update-list": "Updated list",
+ "apihelp-bs-checklist-available-options-store-description": "Lists all
available options for checklist templates. Allows sorting, filtering and
pagination. Implements ExtJS Store parameters.",
+ "apihelp-bs-checklist-template-store-description": "Lists all templates
that are valid checklist sources. Allows sorting, filtering and pagination.
Implements ExtJS Store parameters.",
+ "apihelp-bs-checklist-tasks-description": "Provides operations for
Checklist extension"
}
diff --git a/Checklist/i18n/qqq.json b/Checklist/i18n/qqq.json
index 2ae6823..3cc22ea 100644
--- a/Checklist/i18n/qqq.json
+++ b/Checklist/i18n/qqq.json
@@ -34,5 +34,12 @@
"log-show-hide-bs-checklist": "Used in [[Special:Log]]. Parameters:\n*
$1 - link text; one of {{msg-mw|Show}} or
{{msg-mw|Hide}}\n{{Related|Log-show-hide}}",
"logentry-bs-checklist-checked": "Log message about checking a check
box on a page.\nParameters:\n* $4 - number of the checkbox",
"logentry-bs-checklist-unchecked": "Log message about unchecking a
check box on a page.\nParameters:\n* $4 - number of the checkbox",
- "logentry-bs-checklist-selected": "Log message about selecting a value
in a select box on a page.\nParameters:\n* $4 - number of the checkbox\n* $5 -
selected value"
+ "logentry-bs-checklist-selected": "Log message about selecting a value
in a select box on a page.\nParameters:\n* $4 - number of the checkbox\n* $5 -
selected value",
+ "bs-checklist-savelist-error-invalid-title": "Error message in case
invalid title was provided",
+ "bs-checklist-savelist-error-edit-not-permitted": "Error message in
case of insufficient user permissions",
+ "bs-checklist-modified-check": "Edit summary about modifing checklist
value",
+ "bs-checklist-update-list": "Edit summary about updating checklist",
+ "apihelp-bs-checklist-available-options-store-description": "Describes
the API endpoint that stores available options of checklist",
+ "apihelp-bs-checklist-template-store-description": "Describes the API
endpoint that stores checklist templates",
+ "apihelp-bs-checklist-tasks-description": "Describes the API endpoint
that handles checklist tasks"
}
diff --git a/Checklist/includes/api/BSApiChecklistAvailableOptionsStore.php
b/Checklist/includes/api/BSApiChecklistAvailableOptionsStore.php
new file mode 100644
index 0000000..2c83379
--- /dev/null
+++ b/Checklist/includes/api/BSApiChecklistAvailableOptionsStore.php
@@ -0,0 +1,39 @@
+<?php
+
+class BSApiChecklistAvailableOptionsStore extends BSApiExtJSStoreBase {
+ protected function makeData( $sQuery = '' ) {
+
+ $aData = array();
+ $dbr = wfGetDB( DB_SLAVE );
+ $res = $dbr->select(
+ array( 'page' ),
+ array( 'page_namespace', 'page_title' ),
+ array(
+ 'page_namespace' => NS_TEMPLATE
+ )
+ );
+
+ $aAvailableOptions = array();
+ foreach( $res as $row ) {
+ $oTitle = Title::makeTitle(
+ $row->page_namespace,
+ $row->page_title
+ );
+ // only add those titles that do have actual lists
+ $aListOptions = Checklist::getListOptions(
$oTitle->getFullText() );
+ if (sizeof( $aListOptions ) > 0 ) {
+ $aAvailableOptions = array_merge(
$aAvailableOptions, $aListOptions );
+ }
+ }
+ foreach ( $aAvailableOptions as $sOption ) {
+ $oTemplate = new stdClass();
+ $oTemplate->text = $sOption;
+ $oTemplate->leaf = true;
+ $oTemplate->id = $sOption;
+ $aData[] = $oTemplate;
+ }
+
+ return $aData;
+ }
+
+}
diff --git a/Checklist/includes/api/BSApiChecklistTasks.php
b/Checklist/includes/api/BSApiChecklistTasks.php
new file mode 100644
index 0000000..b2fd1d0
--- /dev/null
+++ b/Checklist/includes/api/BSApiChecklistTasks.php
@@ -0,0 +1,125 @@
+<?php
+
+class BSApiChecklistTasks extends BSApiTasksBase {
+
+ protected $aTasks = array(
+ 'doChangeCheckItem',
+ 'saveOptionsList'
+ );
+
+ protected function getRequiredTaskPermissions() {
+ return array(
+ 'doChangeCheckItem' => array( 'checklistmodify' ),
+ 'saveOptionsList' => array( 'edit' )
+ );
+ }
+
+ protected $sTaskLogType = 'bs-checklist';
+
+ public function task_doChangeCheckItem( $oTaskData, $aParams ) {
+ $oResponse = $this->makeStandardReturn();
+ $iPos = (int)$oTaskData->pos;
+ if ( $iPos == 0 ) {
+ return $oResponse;
+ }
+
+ $sValue = $oTaskData->value;
+ if ( $sValue === '' ) {
+ return $oResponse;
+ }
+
+ $sArticleId = $this->getTitle()->getArticleID();
+ if ( $sArticleId == 0 ) {
+ return $oResponse;
+ }
+
+ $oWikiPage = WikiPage::newFromID( $sArticleId );
+ $oContent = $oWikiPage->getContent();
+ $sContent = $oContent->getNativeData();
+
+ $bChecked = null;
+ // Maybe a sanity-check is just enough here
+ $sNewValue = 'value="';
+ if ( $sValue === true ) {
+ $sNewValue .= "checked";
+ $bChecked = true;
+ }
+ else if ( $sValue === false ) {
+ $bChecked = false;
+ $sNewValue .= "";
+ }
+ else {
+ $sNewValue .= $sValue;
+ }
+
+ $sNewValue .= '" ';
+
+ $sContent = Checklist::preg_replace_nth( "/(<bs:checklist
)([^>]*?>)/", "$1" . $sNewValue . "$2", $sContent, $iPos );
+
+ $sSummary = wfMessage( "bs-checklist-modified-check" )->plain();
+ $oContentHandler = $oContent->getContentHandler();
+ $oNewContent = $oContentHandler->makeContent( $sContent,
$oWikiPage->getTitle() );
+ $oResult = $oWikiPage->doEditContent( $oNewContent, $sSummary );
+
+ // Create a log entry for the changes on the checklist values
+ if ( !is_null( $bChecked ) ) {
+ if ( $bChecked ) {
+ $this->logTaskAction( 'checked', array(
+ '4::position' => $iPos
+ ));
+ }
+ else {
+ $this->logTaskAction( 'unchecked', array(
+ '4::position' => $iPos
+ ));
+ }
+ }
+ else {
+ $this->logTaskAction( 'selected', array(
+ '4::position' => $iPos,
+ '5::selected' => $sValue
+ ));
+ }
+
+ $oResponse->success = true;
+ return $oResponse;
+ }
+
+ public function task_saveOptionsList( $oTaskData, $aParams ) {
+ $oResponse = $this->makeStandardReturn();
+
+ $oTitle = Title::newFromText( $oTaskData->title, NS_TEMPLATE );
+
+ if ( $oTitle instanceof Title === false ) {
+ $oResponse->message = wfMessage(
"bs-checklist-savelist-error-invalid-title" )->plain();
+ return $oResponse;
+ }
+
+ if ( !$oTitle->userCan( 'edit' ) ) {
+ $oResponse->message = wfMessage(
"bs-checklist-savelist-error-edit-not-permitted" )->plain();
+ return $oResponse;
+ }
+
+ $sContent = '';
+ foreach( $oTaskData->records as $record ) {
+ $sContent .= '* ' . $record . "\n";
+ }
+
+ $sSummary = wfMessage( "bs-checklist-update-list" )->plain();
+
+ $oWikiPage = WikiPage::factory( $oTitle );
+ $oContentHandler = $oWikiPage->getContentHandler();
+ $oNewContent = $oContentHandler->makeContent( $sContent,
$oWikiPage->getTitle() );
+ $oResult = $oWikiPage->doEditContent( $oNewContent, $sSummary );
+
+ if ( $oResult->isGood() ) {
+ $oResponse->success = true;
+ }
+ else {
+ $oResponse->message = $oResult->getMessage()->plain();
+ }
+
+ return $oResponse;
+ }
+
+}
diff --git a/Checklist/includes/api/BSApiChecklistTemplateStore.php
b/Checklist/includes/api/BSApiChecklistTemplateStore.php
new file mode 100644
index 0000000..5ed9ac4
--- /dev/null
+++ b/Checklist/includes/api/BSApiChecklistTemplateStore.php
@@ -0,0 +1,35 @@
+<?php
+
+class BSApiChecklistTemplateStore extends BSApiExtJSStoreBase {
+ protected function makeData($sQuery = '') {
+ $aTemplateData = array();
+ $dbr = wfGetDB(DB_SLAVE);
+ $res = $dbr->select(
+ array( 'page' ),
+ array( 'page_namespace', 'page_title' ),
+ array(
+ 'page_namespace' => NS_TEMPLATE
+ )
+ );
+
+ $aTitles = array();
+ foreach( $res as $row ) {
+ $oTitle = Title::makeTitle(
+ $row->page_namespace,
+ $row->page_title
+ );
+ // only add those titles that do have actual lists
+ $aListOptions = Checklist::getListOptions(
$oTitle->getFullText() );
+ if ( sizeof( $aListOptions ) > 0 ) {
+ $oTemplate = new stdClass();
+ $oTemplate->text = $oTitle->getText();
+ $oTemplate->leaf = true;
+ $oTemplate->id = $oTitle->getPrefixedText();
+ $oTemplate->listOptions = $aListOptions;
+ $aTemplateData[] = $oTemplate;
+ }
+ }
+
+ return $aTemplateData;
+ }
+}
\ No newline at end of file
diff --git a/Checklist/resources/BS.Checklist/ChecklistBoxSelect.js
b/Checklist/resources/BS.Checklist/ChecklistBoxSelect.js
index 2dad82b..80de791 100644
--- a/Checklist/resources/BS.Checklist/ChecklistBoxSelect.js
+++ b/Checklist/resources/BS.Checklist/ChecklistBoxSelect.js
@@ -1,6 +1,6 @@
Ext.define( 'BS.Checklist.ChecklistBoxSelect', {
extend:'Ext.ux.form.field.BoxSelect',
- requires: [ 'BS.Checklist.model.Checklist' ],
+ requires: [ 'BS.store.BSApi' ],
displayField: 'text',
valueField: 'text',
anchor: '95%',
@@ -16,20 +16,12 @@
delimiter: ',',
deferredSetValueConf: false,
initComponent: function() {
- this.store = Ext.create( 'Ext.data.JsonStore', {
- proxy: {
- type: 'ajax',
- url: bs.util.getAjaxDispatcherUrl(
'Checklist::getAvailableOptions' ),
- reader: {
- type: 'json',
- root: 'categories',
- idProperty: 'cat_id'
- }
- },
- model: 'BS.Checklist.model.Checklist'
+ this.store = new BS.store.BSApi({
+ apiAction: 'bs-checklist-available-options-store',
+ fields: [ 'text' ]
});
this.store.load();
this.callParent(arguments);
}
-});
\ No newline at end of file
+});
diff --git a/Checklist/resources/BS.Checklist/Window.js
b/Checklist/resources/BS.Checklist/Window.js
index 2f245e0..c21e7d5 100644
--- a/Checklist/resources/BS.Checklist/Window.js
+++ b/Checklist/resources/BS.Checklist/Window.js
@@ -20,24 +20,21 @@
//this.buttons.unshift( this.btnNew );
this.btnSave = Ext.create( 'Ext.Button', {
- text: mw.message('bs-checklist-dlg-save-list').plain(),
+ text: mw.message( 'bs-checklist-dlg-save-list'
).plain(),
id: this.getId()+'-btn-save'
});
this.btnSave.on( 'click', this.onBtnSaveClick, this );
- //this.buttons.unshift( this.btnSave );
-
- this.strBoxSelect = Ext.create('Ext.data.JsonStore', {
+ this.strBoxSelect = Ext.create( 'Ext.data.JsonStore', {
fields: ['text']
});
- this.bsListItems =
Ext.create('BS.Checklist.ChecklistBoxSelect', {
+ this.bsListItems = Ext.create(
'BS.Checklist.ChecklistBoxSelect', {
disabled: true,
//TODO: i18n
- emptyText:
mw.message('bs-checklist-dlg-items-emptytext').plain(),
+ emptyText: mw.message(
'bs-checklist-dlg-items-emptytext' ).plain(),
id: 'bs-insertchecklist-itembox'
});
- //this.bsListItems.on( 'select', this.onSelect, this );
this.bsListItems.on( 'change', this.onItemChange, this );
this.bsListItemsLabel = Ext.create( 'Ext.form.Label', {
@@ -46,31 +43,31 @@
this.pnlMain = Ext.create( 'Ext.form.FormPanel', {
header: true,
- title:
mw.message('bs-checklist-dlg-items-label').plain(),
+ title: mw.message( 'bs-checklist-dlg-items-label'
).plain(),
region: 'center',
bodyPadding: 5,
items: [
this.bsListItems,
this.bsListItemsLabel,
- //this.btnNew,
this.btnSave
]
});
- this.templateStore = Ext.create('Ext.data.TreeStore', {
+ this.templateStore = Ext.create( 'Ext.data.TreeStore', {
proxy: {
type: 'ajax',
- url: bs.util.getAjaxDispatcherUrl(
'Checklist::ajaxGetTemplateData' )
+ url: bs.api.makeUrl(
'bs-checklist-template-store' )
},
root: {
text: 'Lists',
id: 'src',
expanded: true
},
- model: 'BS.model.Category'
+ defaultRootProperty: 'results',
+ fields: [ 'id', 'listOptions', 'text' ]
});
- this.templateTree = Ext.create('Ext.tree.Panel', {
+ this.templateTree = Ext.create( 'Ext.tree.Panel', {
width: 250,
title: mw.message( 'bs-checklist-dlg-panel-title'
).plain(),
useArrows: true,
@@ -108,11 +105,11 @@
bs.util.prompt(
"bs.checklist-dlg-new",
{
- title:
mw.message('bs-checklist-dlg-new-title').plain(),
- text:
mw.message('bs-checklist-dlg-new-prompt').plain()
+ title: mw.message( 'bs-checklist-dlg-new-title'
).plain(),
+ text: mw.message( 'bs-checklist-dlg-new-prompt'
).plain()
},
{
- ok: function(input) {
+ ok: function( input ) {
this.templateStore.tree.root.appendChild({
id: input.value,
text: input.value,
@@ -126,7 +123,7 @@
)
},
onBtnSaveClick: function() {
- var title =
this.templateTree.getSelectionModel().getLastSelected().get('id');
+ var title =
this.templateTree.getSelectionModel().getLastSelected().get( 'id' );
var valueRecords = this.bsListItems.getValueRecords();
var records = new Array();
for ( var record in valueRecords ) {
@@ -135,21 +132,10 @@
this.setDirty( false );
- $.post(
- bs.util.getAjaxDispatcherUrl(
'Checklist::ajaxSaveOptionsList', { "title":title, "records":records } ),
- function( data ) {
- var responseObj = $.parseJSON( data );
- if ( responseObj.success === false ) {
- bs.util.alert(
- 'bs-checklist-alert',
- {
- textMsg: responseObj.msg
- }
- );
- }
- BsChecklist.getOptionsList( title, true );
- }
- );
+ bs.api.tasks.exec( 'checklist', 'saveOptionsList', {
+ title: title,
+ records: records
+ });
},
onBeforeItemExpand: function( p, animate, eOpts ) {return false;},
onBeforeItemclick: function( sender, td, cellIndex, record, tr,
rowIndex, e, eOpts ) {
@@ -157,19 +143,16 @@
},
onBeforeSelect: function( sender, record, index, eOpts ) {
if ( BS.Checklist.Window.isDirty == true ) {
- var dialog = Ext.create('BS.ConfirmDialog', {
- title:
mw.message('bs-checklist-confirm-dirty-title').plain(),
- text:
mw.message('bs-checklist-confirm-dirty-text').plain(),
+ var dialog = Ext.create( 'BS.ConfirmDialog', {
+ title: mw.message(
'bs-checklist-confirm-dirty-title' ).plain(),
+ text: mw.message(
'bs-checklist-confirm-dirty-text' ).plain(),
});
- dialog.on('ok', function(input) {
+ dialog.on( 'ok', function( input ) {
BS.Checklist.Window.setDirty( false );
-
//BS.Checklist.Window.templateTree.resumeEvents();
-
BS.Checklist.Window.templateTree.fireEvent('select', sender, record, index,
eOpts);
+ BS.Checklist.Window.templateTree.fireEvent(
'select', sender, record, index, eOpts );
});
- BS.Checklist.Window.add(dialog);
+ BS.Checklist.Window.add( dialog );
dialog.show();
- //BS.Checklist.Window.preventDeselect = true;
- //BS.Checklist.Window.templateTree.suspendEvents();
return false;
}
},
@@ -183,9 +166,9 @@
*/
},
onSelect: function( sender, records, index, eOpts) {
- var itemList = BsChecklist.getOptionsList( records.data.text );
- this.bsListItems.setValue( itemList );
- this.listSelected = records.data.text;
+
+ this.bsListItems.setValue( records.get( 'listOptions' ) );
+ this.listSelected = records;
this.setDirty( false );
this.bsListItems.enable();
},
@@ -198,9 +181,9 @@
setDirty: function( dirty ) {
BS.Checklist.Window.isDirty = dirty;
if ( dirty ) {
- this.btnSave.setText( "* " +
mw.message('bs-checklist-dlg-save-list').plain() );
+ this.btnSave.setText( "* " + mw.message(
'bs-checklist-dlg-save-list' ).plain() );
} else {
- this.btnSave.setText(
mw.message('bs-checklist-dlg-save-list').plain() );
+ this.btnSave.setText( mw.message(
'bs-checklist-dlg-save-list' ).plain() );
}
}
});
diff --git a/Checklist/resources/BS.Checklist/model/Checklist.js
b/Checklist/resources/BS.Checklist/model/Checklist.js
deleted file mode 100644
index 7926ae3..0000000
--- a/Checklist/resources/BS.Checklist/model/Checklist.js
+++ /dev/null
@@ -1,7 +0,0 @@
-Ext.define('BS.Checklist.model.Checklist', {
- extend: 'Ext.data.Model',
-
- fields: [
- { name: 'text', type: 'string' }
- ]
-});
\ No newline at end of file
diff --git a/Checklist/resources/bluespice.checklist.js
b/Checklist/resources/bluespice.checklist.js
index 2fbad46..9462f21 100644
--- a/Checklist/resources/bluespice.checklist.js
+++ b/Checklist/resources/bluespice.checklist.js
@@ -31,18 +31,9 @@
id = id.split( "-" );
id = id.pop();
- $.ajax({
- type: "GET",
- url: bs.util.getAjaxDispatcherUrl(
'Checklist::doChangeCheckItem' ),
- data: {
- pos: id,
- value: elem.checked,
- articleId: mw.config.get('wgArticleId')
- },
- //dataType: 'html',
- success: function(result){ // the returned value is
passed back as a _result_
- //alert(result);
- }
+ bs.api.tasks.exec( 'checklist', 'doChangeCheckItem', {
+ pos: id,
+ value: elem.checked
});
},
@@ -50,19 +41,11 @@
var id = elem.id;
id = id.split( "-" );
id = id.pop();
- elem.style.color=elem.options[elem.selectedIndex].style.color;
- $.ajax({
- type: "GET",
- url: bs.util.getAjaxDispatcherUrl(
'Checklist::doChangeCheckItem' ),
- data: {
- pos: id,
- value:$('#'+elem.id).find(":selected").text(),
- articleId:mw.config.get('wgArticleId')
- },
- //dataType: 'html',
- success: function(result){ // the returned value is
passed back as a _result_
- //alert(result);
- }
+ elem.style.color = elem.options[elem.selectedIndex].style.color;
+
+ bs.api.tasks.exec( 'checklist', 'doChangeCheckItem', {
+ pos: id,
+ value: $( '#'+elem.id ).find( ":selected" ).text()
});
},
@@ -73,30 +56,32 @@
$.ajax({
type: "GET",
- url: bs.util.getAjaxDispatcherUrl(
'Checklist::getOptionsList' ),
- async: false,
- data: {
- listId:listId
- },
- //dataType: 'html',
- success: function(result){ // the returned value is
passed back as a _result_
- BsChecklist.optionsLists[listId] = eval(result);
+ url: bs.api.makeUrl( 'bs-checklist-template-store' )
+ + "&filter=" + JSON.stringify( [{
+ type: "string",
+ comparison: "eq",
+ value: listId,
+ field: "text"
+ }] ),
+ async: false, //TODO: Reimplement with aysnc call
+ success: function(response){
+ BsChecklist.optionsLists[listId] =
response.results[0].listOptions;
}
});
return BsChecklist.optionsLists[listId];
- },
+ },
changeSelect: function(elem) {
- var value = $(elem).find(":selected").text();
- tinymce.activeEditor.dom.setAttrib(elem.parentNode,
'data-bs-value', value);
+ var value = $(elem).find( ":selected" ).text();
+ tinymce.activeEditor.dom.setAttrib( elem.parentNode,
'data-bs-value', value );
},
- makeCheckbox: function(checked) {
+ makeCheckbox: function( checked ) {
var innerText;
innerText = '<button contentEditable="false"
class="bsClickableElement" ';
innerText +=
'style="'+BsChecklist.checkboxStyle+'background-image:url(\'';
- if (checked) {
+ if ( checked ) {
innerText += BsChecklist.checkboxImageChecked;
} else {
innerText += BsChecklist.checkboxImage;
@@ -106,12 +91,11 @@
return innerText;
},
- makeSelectbox: function(listname, valueText) {
- var options = BsChecklist.getOptionsList(listname);
+ makeSelectbox: function( options, valueText ) {
var innerText = '<select contenteditable="false"
class="bsClickableElement"
onchange="this.style.color=this.options[this.selectedIndex].style.color;parent.BsChecklist.changeSelect(this);"
{color}>';
var selectedColor = '';
- for (var i = 0; i<options.length; i++) {
- var optionSet = options[i].split("|");
+ for ( var i = 0; i < options.length; i++ ) {
+ var optionSet = options[i].split( "|" );
var optionValue = optionSet[0];
var optionColor = optionSet[1];
@@ -126,13 +110,13 @@
innerText += '>'+optionValue+'</option>';
}
innerText += '</select>';
- innerText = innerText.replace("{color}", selectedColor);
+ innerText = innerText.replace( "{color}", selectedColor );
return innerText;
},
- makeAndRegisterCheckboxSpecialTag: function(ed, checked) {
+ makeAndRegisterCheckboxSpecialTag: function( ed, checked ) {
var id = ed.plugins.bswikicode.getSpecialTagList().length;
- ed.plugins.bswikicode.pushSpecialTagList('<bs:checklist
value="" />');
+ ed.plugins.bswikicode.pushSpecialTagList( '<bs:checklist
value="" />' );
var node = ed.dom.create(
'span',
{
@@ -144,13 +128,16 @@
'data-bs-value' : "false",
'data-bs-cbtype' : "checkbox"
},
- BsChecklist.makeCheckbox(checked));
+ BsChecklist.makeCheckbox( checked ) );
return node;
},
- makeAndRegisterSelectboxSpecialTag: function(ed, listname, value) {
+ makeAndRegisterSelectboxSpecialTag: function( ed, record, value ) {
+ // record can be an object ( if it's called from dialog ) or
string ( it's called from menue item )
+ var listname = record.get ? record.get('text') : record;
+ var options = record.get ? record.get( 'listOptions' ) :
BsChecklist.getOptionsList( listname );
var id = ed.plugins.bswikicode.getSpecialTagList().length;
- ed.plugins.bswikicode.pushSpecialTagList('<bs:checklist
type="list" value="" list="'+listname+'"/>');
+ ed.plugins.bswikicode.pushSpecialTagList( '<bs:checklist
type="list" value="" list="'+listname+'"/>' );
var node = ed.dom.create(
'span',
{
@@ -162,7 +149,7 @@
'data-bs-value' : "false",
'data-bs-cbtype' : "list"
},
- BsChecklist.makeSelectbox(listname, value));
+ BsChecklist.makeSelectbox( options, value ) );
return node;
}
};
@@ -171,113 +158,115 @@
BsChecklist.init();
});
-$(document).on( "BSVisualEditorRenderSpecialTag", function( event, sender,
type, st){
+$(document).on( "BSVisualEditorRenderSpecialTag", function( event, sender,
type, st ){
if ( type != 'bs:checklist' ) return false;
var ed = tinymce.activeEditor;
- var specialtag = ed.dom.createFragment(st[0]).childNodes[0];
+ var specialtag = ed.dom.createFragment( st[0] ).childNodes[0];
- var cbt = ed.dom.getAttrib(specialtag, 'type', 'checkbox');
- var valueText = ed.dom.getAttrib(specialtag, 'value', 'false');
- var listText = ed.dom.getAttrib(specialtag, 'list', '');
+ var cbt = ed.dom.getAttrib( specialtag, 'type', 'checkbox' );
+ var valueText = ed.dom.getAttrib( specialtag, 'value', 'false' );
+ var listText = ed.dom.getAttrib( specialtag, 'list', '' );
var innerText;
- if (cbt == 'checkbox' ) {
- if (valueText == 'checked') {
- innerText = BsChecklist.makeCheckbox(true);
+ if ( cbt == 'checkbox' ) {
+ if ( valueText == 'checked' ) {
+ innerText = BsChecklist.makeCheckbox( true );
} else {
- innerText = BsChecklist.makeCheckbox(false);
+ innerText = BsChecklist.makeCheckbox( false );
}
- } else if (cbt == 'list' ) {
- innerText = BsChecklist.makeSelectbox(listText, valueText);
+ } else if ( cbt == 'list' ) {
+ innerText = BsChecklist.makeSelectbox(
+ BsChecklist.getOptionsList( listText ) , valueText
+ );
}
var moreAttribs = 'data-bs-value="'+valueText+'"';
moreAttribs += ' data-bs-cbtype="'+cbt+'"';
return {
- "innerText":innerText,
- "moreAttribs":moreAttribs
+ innerText: innerText,
+ moreAttribs: moreAttribs
};
});
-$(document).on( "BSVisualEditorRecoverSpecialTag", function( event, sender,
specialTagMatch, innerText){
+$(document).on( "BSVisualEditorRecoverSpecialTag", function( event, sender,
specialTagMatch, innerText ){
if( specialTagMatch == null ) return false;
var valueregex = '<.*?data-bs-value="(.*?)"[^>]*?>';
- var valueMatcher = new RegExp(valueregex, '');
- var value = valueMatcher.exec(specialTagMatch[1]);
+ var valueMatcher = new RegExp( valueregex, '' );
+ var value = valueMatcher.exec( specialTagMatch[1] );
var valueText;
- if (value) {
+ if ( value ) {
valueText = value[1];
} else {
valueText = '';
}
- var newInnerText = innerText.replace(/value="(.*?)"/,
'value="'+valueText+'"');
+ var newInnerText = innerText.replace( /value="(.*?)"/,
'value="'+valueText+'"' );
return {
- "innerText":newInnerText
+ innerText: newInnerText
}
});
-$(document).on( "BSVisualEditorClickSpecialTag", function( event, sender, ed,
e, dataname){
+$(document).on( "BSVisualEditorClickSpecialTag", function( event, sender, ed,
e, dataname ){
if ( dataname == 'bs:checklist' ) {
- var cbtype = ed.dom.getAttrib(e.target.parentNode,
'data-bs-cbtype');
+ var cbtype = ed.dom.getAttrib( e.target.parentNode,
'data-bs-cbtype' );
if ( !cbtype ) {
cbtype = 'checkbox';
}
- var value = ed.dom.getAttrib(e.target.parentNode,
'data-bs-value');
+ var value = ed.dom.getAttrib( e.target.parentNode,
'data-bs-value' );
- if (cbtype == 'checkbox' ) {
- if (value == 'checked') {
+ if ( cbtype == 'checkbox' ) {
+ if ( value == 'checked' ) {
value = 'false';
- ed.dom.setStyle(e.target, 'background-image',
"url('"+BsChecklist.checkboxImage+"')");
+ ed.dom.setStyle(e.target, 'background-image',
"url('"+BsChecklist.checkboxImage+"')" );
} else {
value = 'checked';
- ed.dom.setStyle(e.target, 'background-image',
"url('"+BsChecklist.checkboxImageChecked+"')");
+ ed.dom.setStyle( e.target, 'background-image',
"url('"+BsChecklist.checkboxImageChecked+"')" );
}
}
- ed.dom.setAttrib(e.target.parentNode, 'data-bs-value', value);
+ ed.dom.setAttrib( e.target.parentNode, 'data-bs-value', value );
}
});
-$(document).on('BsVisualEditorActionsInit', function(event, plugin, buttons,
commands, menus) {
+$(document).on( 'BsVisualEditorActionsInit', function( event, plugin, buttons,
commands, menus ) {
var t = plugin;
var ed = t.getEditor();
menus.push({
menuId: 'bsChecklist',
menuConfig: {
- text:
mw.message('bs-checklist-menu-insert-checkbox').plain(),
+ text: mw.message( 'bs-checklist-menu-insert-checkbox'
).plain(),
cmd : 'mceBsChecklistLastCommand'
}
});
var menuItems = [];
- menuItems.push({text: '-'});
+ menuItems.push( {text: '-'} );
menuItems.push({
- text: mw.message('bs-checklist-button-checkbox-title').plain(),
+ text: mw.message( 'bs-checklist-button-checkbox-title'
).plain(),
value: 'Checkbox',
onclick:function(){
BsChecklist.lastCommand = 'mceBsCheckbox';
BsChecklist.lastCommandKey = false;
- ed.execCommand('mceBsCheckbox', false);
+ ed.execCommand( 'mceBsCheckbox', false );
}
});
menuItems.push({
- text: mw.message('bs-checklist-menu-insert-list-title').plain(),
+ text: mw.message( 'bs-checklist-menu-insert-list-title'
).plain(),
onclick: function() {
// Open window
var me = this;
- mw.loader.using('ext.bluespice.extjs').done(function() {
- Ext.require('BS.Checklist.Window', function(){
- BS.Checklist.Window.on('ok',
function(sender, data){
+ mw.loader.using( 'ext.bluespice.extjs' ).done(
function() {
+ Ext.require( 'BS.Checklist.Window', function(){
+ BS.Checklist.Window.on( 'ok', function(
sender, data ){
BsChecklist.lastCommand =
'mceBsSelectbox';
BsChecklist.lastCommandKey =
data;
-
ed.execCommand('mceBsSelectbox', false, data);
+ ed.execCommand(
'mceBsSelectbox', false, data );
});
BS.Checklist.Window.show( me );
@@ -286,8 +275,8 @@
}
});
- ed.addButton('bscheckbox', {
- title: mw.message('bs-checklist-button-checkbox-title').plain(),
+ ed.addButton( 'bscheckbox', {
+ title: mw.message( 'bs-checklist-button-checkbox-title'
).plain(),
cmd: 'mceBsChecklistLastCommand',
type: 'splitbutton',
//icon: 'image',
@@ -295,23 +284,23 @@
onPostRender: function() {
var self = this;
BsChecklist.menuButton = this;
- ed.on('NodeChange', function(evt) {
- self.disabled(false);
+ ed.on( 'NodeChange', function( evt ) {
+ self.disabled( false );
if ( !evt.target.selection.isCollapsed() ) {
- self.disabled(true);
+ self.disabled( true );
}
- $(evt.parents).each(function(){
+ $(evt.parents).each( function(){
if ( this.tagName.toLowerCase() ==
'pre' ) {
- self.disabled(true);
+ self.disabled( true );
}
});
});
},
- onShow: function(e) {
+ onShow: function( e ) {
var listKeys = [];
- e.control.items().each(function(index,value) {
- listKeys.push(index.text());
+ e.control.items().each( function( index,value ) {
+ listKeys.push( index.text() );
});
for ( var thekey in BsChecklist.optionsLists ) {
if ( typeof BsChecklist.optionsLists[thekey]
=== 'function' ) continue;
@@ -319,62 +308,62 @@
var menuItem = new tinymce.ui.MenuItem({
text: thekey,
value : thekey,
- onclick:function(e){
+ onclick:function( e ){
BsChecklist.lastCommand = 'mceBsSelectbox';
BsChecklist.lastCommandKey = this.value();
-
ed.execCommand('mceBsSelectbox', false, this.value());
+ ed.execCommand(
'mceBsSelectbox', false, this.value() );
}
});
- e.control.prepend(menuItem);
+ e.control.prepend( menuItem );
}
}
}
});
- ed.addCommand('mceBsChecklistLastCommand', function(ui, value) {
+ ed.addCommand( 'mceBsChecklistLastCommand', function( ui, value ) {
ed.execCommand( BsChecklist.lastCommand, false,
BsChecklist.lastCommandKey );
});
- ed.addCommand('mceBsCheckbox', function(ui, value) {
+ ed.addCommand( 'mceBsCheckbox', function( ui, value ) {
//needed in FF, apparently to init selection
ed.selection.getBookmark();
//only insert if selection is collapsed
if ( ed.selection.isCollapsed() ) {
- var node =
BsChecklist.makeAndRegisterCheckboxSpecialTag(ed, false);
- ed.dom.insertAfter(node, ed.selection.getNode());
+ var node =
BsChecklist.makeAndRegisterCheckboxSpecialTag( ed, false );
+ ed.dom.insertAfter( node, ed.selection.getNode() );
//Place cursor to end
- ed.selection.select(node, false);
- ed.selection.collapse(false);
+ ed.selection.select( node, false );
+ ed.selection.collapse( false );
}
return;
});
commands.push({
commandId: 'checkbox',
- commandCallback: function(ui, v) {
- this.execCommand('mceBsCheckbox', ui, v);
+ commandCallback: function( ui, v ) {
+ this.execCommand( 'mceBsCheckbox', ui, v );
}
});
- ed.addCommand('mceBsSelectbox', function(ui, value) {
+ ed.addCommand( 'mceBsSelectbox', function( ui, value ) {
//needed in FF, apparently to init selection
ed.selection.getBookmark();
//only insert if selection is collapsed
if ( ed.selection.isCollapsed() ) {
- var node =
BsChecklist.makeAndRegisterSelectboxSpecialTag(ed, value, '');
- ed.dom.insertAfter(node, ed.selection.getNode());
+ var node =
BsChecklist.makeAndRegisterSelectboxSpecialTag( ed, value, '' );
+ ed.dom.insertAfter( node, ed.selection.getNode() );
//Place cursor to end
- ed.selection.select(node, false);
- ed.selection.collapse(false);
+ ed.selection.select( node, false );
+ ed.selection.collapse( false );
}
return;
});
commands.push({
commandId: 'selectbox',
- commandCallback: function(ui, v) {
- this.execCommand('mceBsSelectbox', ui, v);
+ commandCallback: function( ui, v ) {
+ this.execCommand( 'mceBsSelectbox', ui, v );
}
});
});
\ No newline at end of file
diff --git a/Checklist/views/view.ChecklistCheck.php
b/Checklist/views/view.ChecklistCheck.php
deleted file mode 100644
index 8c1b866..0000000
--- a/Checklist/views/view.ChecklistCheck.php
+++ /dev/null
@@ -1,65 +0,0 @@
-<?php
-/**
- * Renders the "CountCharacters" tag from the CountThings extension.
- *
- * Part of BlueSpice for MediaWiki
- *
- * @author Robert Vogel <[email protected]>
- * @version $Id$
- * @package BlueSpice_Extensions
- * @subpackage CountThings
- * @copyright Copyright (C) 2011 Hallo Welt! - Medienwerkstatt GmbH, All
rights reserved.
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License v2 or
later
- * @filesource
- */
-
-/**
- * enders the "CountCharacters" tag from the CountThings extension.
- * @package BlueSpice_Extensions
- * @subpackage CountThings
- */
-class ViewCountCharacters extends ViewBaseElement {
- protected $oTitle = '';
-
- protected $iChars = -1;
- protected $iWords = -1;
- protected $iPages = -1;
-
- public function setChars( $iChars ) {
- $this->iChars = $iChars;
- }
-
- public function setWords( $iWords ) {
- $this->iWords = $iWords;
- }
-
- public function setPages( $iPages ) {
- $this->iPages = $iPages;
- }
-
- public function setTitle( $oTitle ) {
- $this->oTitle = $oTitle;
- }
-
- /**
- * This method actually generates the output
- * @param mixed $params Comes from base class definition. Not used in
this implementation.
- * @return string HTML output
- */
- public function execute( $params = false ) {
- $aOut = array();
- $aOut[] = '<div class="bs-countcharacters"
title="'.$this->oTitle->getText().'">';
- $aOut[] = ' <table class="wikitable">';
- $aOut[] = ' <tr><th colspan="2">'.Linker::link(
$this->oTitle ).'</th></tr>';
- if( $this->iChars != -1 )
- $aOut[] = ' <tr><th>'.wfMessage(
'bs-countthings-countchars-chars-label'
)->plain().'</th><td>'.$this->iChars.'</td></tr>';
- if( $this->iWords != -1 )
- $aOut[] = ' <tr><th>'.wfMessage(
'bs-countthings-countchars-words-label'
)->plain().'</th><td>'.$this->iWords.'</td></tr>';
- if( $this->iPages != -1 )
- $aOut[] = ' <tr><th>'.wfMessage(
'bs-countthings-countchars-pages-label'
)->plain().'</th><td>'.$this->iPages.'</td></tr>';
- $aOut[] = ' </table>';
- $aOut[] = '</div>';
-
- return implode( '', $aOut );
- }
-}
--
To view, visit https://gerrit.wikimedia.org/r/280911
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I32483409b9df7ea7ffdb8c18f2afb9631b2c3da9
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: Dvogel hallowelt <[email protected]>
Gerrit-Reviewer: Ljonka <[email protected]>
Gerrit-Reviewer: Mglaser <[email protected]>
Gerrit-Reviewer: Pwirth <[email protected]>
Gerrit-Reviewer: Robert Vogel <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits