/** * Replace the normal save button with one that says if you are editing * message documentation to try to avoid accidents. * Hook: EditPageBeforeEditButtons */ static function buttonHack(EditPage $editpage, &$buttons, $tabindex) { $handle = new MessageHandle($editpage->getTitle()); if (!$handle->isValid()) { return true; } $context = $editpage->getArticle()->getContext(); if ($handle->isDoc()) { $langCode = $context->getLanguage()->getCode(); $name = TranslateUtils::getLanguageName($handle->getCode(), $langCode); $accessKey = $context->msg('accesskey-save')->plain(); $temp = array('id' => 'wpSave', 'name' => 'wpSave', 'type' => 'submit', 'tabindex' => ++$tabindex, 'value' => $context->msg('translate-save', $name)->text(), 'accesskey' => $accessKey, 'title' => $context->msg('tooltip-save')->text() . ' [' . $accessKey . ']'); $buttons['save'] = Xml::element('input', $temp, ''); } try { $supportUrl = SupportAid::getSupportUrl($handle->getTitle()); } catch (TranslationHelperException $e) { return true; } $temp = array('id' => 'wpSupport', 'name' => 'wpSupport', 'type' => 'button', 'tabindex' => ++$tabindex, 'value' => $context->msg('translate-js-support')->text(), 'title' => $context->msg('translate-js-support-title')->text(), 'data-load-url' => $supportUrl, 'onclick' => "window.open( jQuery(this).attr('data-load-url') );"); $buttons['ask'] = Html::element('input', $temp, ''); return true; }
protected function getSupportButton($title) { try { $supportUrl = SupportAid::getSupportUrl($title); } catch (TranslationHelperException $e) { return ''; } $support = Html::element('input', array('class' => 'mw-translate-support', 'type' => 'button', 'value' => wfMessage('translate-js-support')->text(), 'title' => wfMessage('translate-js-support-title')->text(), 'data-load-url' => $supportUrl)); return $support; }
public function getData() { return array('url' => SupportAid::getSupportUrl($this->handle->getTitle())); }