Style delete button.
[philipp/winterrodeln/mediawiki_extensions/wrreport.git] / wrreport_body.php
index 9e853003d07a55e574ad51695fa24a12ede792e1..4e60a3b5ff2821404d66121c8e5e8cdc43a195bf 100644 (file)
@@ -347,13 +347,11 @@ function wrReportFormRender($hide_save_button = TRUE, $page_title = NULL, $date_
        $tr = $table->appendElement('tr');
        $tr->appendElement('th')->appendText(wfMessage('wrreport-newreport-submit')->text());
        $td = $tr->appendElement('td');
-       $input = $td->appendElement('input', array('name' => 'preview', 'type' => 'submit'));
-       if ($hide_save_button)
-               $input->setAttribute('value', wfMessage('wrreport-newreport-next')->text());
-       else {
-               $input->setAttribute('value', wfMessage('wrreport-newreport-preview')->text());
-
-               $td->appendElement('input', array('name' => 'store', 'type' => 'submit', 'value' => wfMessage('wrreport-newreport-save')->text()));
+       if ($hide_save_button) {
+               $input = $td->appendElement('input', array('name' => 'preview', 'type' => 'submit', 'class' => 'mw-ui-button mw-ui-progressive', 'value' => wfMessage('wrreport-newreport-next')->text()));
+       } else {
+               $input = $td->appendElement('input', array('name' => 'preview', 'type' => 'submit', 'class' => 'mw-ui-button', 'value' => wfMessage('wrreport-newreport-preview')->text()));
+               $td->appendElement('input', array('name' => 'store', 'type' => 'submit', 'class' => 'mw-ui-button mw-ui-constructive', 'value' => wfMessage('wrreport-newreport-save')->text()));
        }
 
        return $doc->saveHTML($form);
@@ -397,8 +395,8 @@ function wrDeleteReportFormRender($reportid, $delete_person_name, $delete_reason
        $tr = $table->appendElement('tr');
        $tr->appendElement('th')->appendText(wfMessage('wrreport-reports-action')->text());
        $td = $tr->appendElement('td');
-       $td->appendElement('input', array('name' => 'deletepreview', 'type' => 'submit', 'value' => wfMessage('wrreport-newreport-preview')->text()));
-       $td->appendElement('input', array('name' => 'delete', 'type' => 'submit', 'value' => wfMessage('wrreport-deletereport-delete')->text()));
+       $td->appendElement('input', array('name' => 'deletepreview', 'type' => 'submit', 'class' => 'mw-ui-button', 'value' => wfMessage('wrreport-newreport-preview')->text()));
+       $td->appendElement('input', array('name' => 'delete', 'type' => 'submit', 'class' => 'mw-ui-button mw-ui-destructive', 'value' => wfMessage('wrreport-deletereport-delete')->text()));
 
        // hidden field
        $input = $td->appendElement('input', array('name' => 'reportid', 'type' => 'hidden', 'value' => (string) $reportid));
@@ -1111,6 +1109,32 @@ class WrReport {
        }
 
 
+       public static function MobileMenuHook($name, \MobileFrontend\MenuBuilder &$menu) {
+               if ($name === 'discovery') {
+                       // delete "Random page". As a removeEntry function is missing,
+                       // a new menu is built here without the random page.
+                       $new_menu = new MobileFrontend\MenuBuilder();
+                       foreach ($menu->getEntries() as $menuEntryRepresentation) {
+                               $new_entry_name = $menuEntryRepresentation['name'];
+                               if ($new_entry_name == 'random') continue;
+                               $new_entry_components = $menuEntryRepresentation['components'];
+                               $new_entry_isjsonly = isset($menuEntryRepresentation['class']) and $menuEntryRepresentation['class'] === 'jsonly';
+                               $new_entry = $new_menu->insert($new_entry_name, $new_entry_isjsonly);
+                               foreach ($new_entry_components as $new_entry_component) {
+                                       $label = $new_entry_component['text'];
+                                       $url = $new_entry_component['href'];
+                                       $className = $new_entry_component['class'];
+                                       $new_entry->addComponent($label, $url, $className, $new_entry_components);
+                               }
+                       }
+                       $menu = $new_menu;
+
+                       // add region menu entry
+                       $icon = MobileUI::iconClass('random', 'before');
+                       $title = Title::newFromText('Region', NS_CATEGORY);
+                       $menu->insert('region')->addComponent('Regionen', $title->getLocalURL(), $icon, array('id' => 'regionButton', 'data-event-name' => 'region'));
+               }
+       }
 
 }
 WrReport::initWrConditions();
@@ -1249,18 +1273,18 @@ class SpecialWrReport extends SpecialPage {
                                $output->addWikiText(wfMessage('wrreport-deletereport-success', '[[' . $row['page_title'] . '#' . wfMessage('wrreport-reports-sectionname')->text() . '|' . $row['page_title'] . ']]')->text());
                        }
                        if ($action == 'deletepreview') {
-                               $output->addWikiText(wfMessage('wrreport-deletereport-preview-before')->text());
+                               $output->addWikiMsg('wrreport-deletereport-preview-before');
                                $format = WRREPORT_COMPACT_PAGE;
                                $output->addHTML(wrReportTableRender(array($row), $format, FALSE, $wgParser));
-                               $output->addWikiText(wfMessage('wrreport-deletereport-preview-after')->text());
+                               $output->addWikiMsg('wrreport-deletereport-preview-after');
                                $row['delete_date'] = date('c');
                                $row['delete_reason_public'] = $delete_reason_public;
                                $row['delete_person_name'] = $delete_person_name;
                                $row['delete_invisible'] = $delete_invisible;
                                $output->addHTML(wrReportTableRender(array($row), $format, FALSE, $wgParser));
-                               $output->addWikiText(wfMessage('wrreport-deletereport-preview-form')->text());
+                               $output->addWikiMsg('wrreport-deletereport-preview-form');
                                $output->addHTML(wrDeleteReportFormRender($reportid, $delete_person_name, $delete_reason_public, $delete_invisible));
-                               $output->addWikiText(wfMessage('wrreport-deletereport-preview-bottom')->text());
+                               $output->addWikiMsg('wrreport-deletereport-preview-bottom');
                        }
                }
 
@@ -1391,7 +1415,7 @@ class SpecialWrReport extends SpecialPage {
                                // $output->redirect($title->getFullURL() . '#' . wfMessage('wrreport-reports-sectionname')->text());
                        }
                        if ($action == 'preview') {
-                               $output->addWikiText(wfMessage('wrreport-newreport-preview-top')->text());
+                               $output->addWikiMsg('wrreport-newreport-preview-top');
                                $format = WRREPORT_COMPACT_PAGE;
                                $row = array_fill_keys(wrReportGetColumnNames(), NULL);
                                $row['page_id'] = $page_id;
@@ -1405,13 +1429,13 @@ class SpecialWrReport extends SpecialPage {
                                $row['author_username'] = $author_username;
 
                                $output->addHTML(wrReportTableRender(array($row), $format, FALSE, $wgParser));
-                               $output->addWikiText(wfMessage('wrreport-newreport-preview-middle')->text());
+                               $output->addWikiMsg('wrreport-newreport-preview-middle');
                                $output->addHTML(wrReportFormRender(FALSE, $page_title, $date_report, $time_report, $condition, $description, $author_name));
-                               $output->addWikiText(wfMessage('wrreport-newreport-preview-bottom')->text());
+                               $output->addWikiMsg('wrreport-newreport-preview-bottom');
                                if ($wgUser->isLoggedIn())
-                                       $output->addWikiText(wfMessage('wrreport-newreport-preview-bottom-loggedin')->text());
+                                       $output->addWikiMsg('wrreport-newreport-preview-bottom-loggedin');
                                else
-                                       $output->addWikiText(wfMessage('wrreport-newreport-preview-bottom-anonymous')->text());
+                                       $output->addWikiMsg('wrreport-newreport-preview-bottom-anonymous');
                        }
 
                }