2015-08-27 08:30:25 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class PortableInfoboxBuilderController extends WikiaController {
|
|
|
|
|
2015-08-27 12:50:02 +00:00
|
|
|
const INFOBOX_BUILDER_PARAM = 'portableInfoboxBuilder';
|
2015-08-27 11:41:33 +00:00
|
|
|
|
2015-08-27 08:30:25 +00:00
|
|
|
public function getAssets() {
|
|
|
|
$response = $this->getResponse();
|
|
|
|
$response->setFormat( WikiaResponse::FORMAT_JSON );
|
|
|
|
$response->setVal( "css", AssetsManager::getInstance()->getURL( "portable_infobox_scss" ) );
|
|
|
|
}
|
2015-08-31 15:42:38 +00:00
|
|
|
|
|
|
|
public function publish() {
|
|
|
|
$status = new Status();
|
|
|
|
$response = $this->getResponse();
|
|
|
|
$response->setFormat( WikiaResponse::FORMAT_JSON );
|
|
|
|
|
|
|
|
$params = $this->getRequest()->getParams();
|
|
|
|
|
|
|
|
if ( $params[ 'title' ] ) {
|
2015-09-04 10:54:07 +00:00
|
|
|
$pageTitleObj = Title::newFromText( $params[ 'title' ], NS_TEMPLATE );
|
2015-09-03 13:58:35 +00:00
|
|
|
if ( $pageTitleObj ) {
|
|
|
|
if ( $pageTitleObj->userCan( 'edit' ) ) {
|
|
|
|
$pageArticleObj = new Article( $pageTitleObj );
|
|
|
|
$editPage = new EditPage( $pageArticleObj );
|
|
|
|
$editPage->initialiseForm();
|
|
|
|
$editPage->edittime = $pageArticleObj->getTimestamp();
|
|
|
|
$editPage->textbox1 = ( new PortableInfoboxBuilderService() )->translate( $params[ 'data' ] );
|
|
|
|
$status = $editPage->internalAttemptSave( $result );
|
|
|
|
} else {
|
|
|
|
$status->fatal( 'user-cant-edit' );
|
|
|
|
}
|
2015-08-31 15:42:38 +00:00
|
|
|
} else {
|
2015-09-03 13:58:35 +00:00
|
|
|
$status->fatal( 'no-title-object' );
|
2015-08-31 15:42:38 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$status->fatal( 'no-title-provided' );
|
|
|
|
}
|
|
|
|
|
|
|
|
$response->setVal( "success", $status->isOK() );
|
|
|
|
$response->setVal( "errors", $status->getErrorsArray() );
|
|
|
|
$response->setVal( "warnings", $status->getWarningsArray() );
|
|
|
|
}
|
2015-08-27 08:30:25 +00:00
|
|
|
}
|