Index: trunk/phase3/CREDITS |
— | — | @@ -125,6 +125,7 @@ |
126 | 126 | * Stefano Codari |
127 | 127 | * Str4nd |
128 | 128 | * svip |
| 129 | +* Tisane |
129 | 130 | * Zachary Hauri |
130 | 131 | |
131 | 132 | == Translators == |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -1811,28 +1811,8 @@ |
1812 | 1812 | ( $suppressRC ? EDIT_SUPPRESS_RC : 0 ) | |
1813 | 1813 | ( $bot ? EDIT_FORCE_BOT : 0 ); |
1814 | 1814 | |
1815 | | - # If this is a comment, add the summary as headline |
1816 | | - if ( $comment && $summary != "" ) { |
1817 | | - $text = wfMsgForContent( 'newsectionheaderdefaultlevel', $summary ) . "\n\n" . $text; |
1818 | | - } |
| 1815 | + $this->doEdit( $text, $summary, $flags, false, null, $watchthis, $comment, '', true ); |
1819 | 1816 | |
1820 | | - $this->doEdit( $text, $summary, $flags ); |
1821 | | - |
1822 | | - $dbw = wfGetDB( DB_MASTER ); |
1823 | | - if ( $watchthis ) { |
1824 | | - if ( !$this->mTitle->userIsWatching() ) { |
1825 | | - $dbw->begin(); |
1826 | | - $this->doWatch(); |
1827 | | - $dbw->commit(); |
1828 | | - } |
1829 | | - } else { |
1830 | | - if ( $this->mTitle->userIsWatching() ) { |
1831 | | - $dbw->begin(); |
1832 | | - $this->doUnwatch(); |
1833 | | - $dbw->commit(); |
1834 | | - } |
1835 | | - } |
1836 | | - $this->doRedirect( $this->isRedirect( $text ) ); |
1837 | 1817 | } |
1838 | 1818 | |
1839 | 1819 | /** |
— | — | @@ -1843,30 +1823,11 @@ |
1844 | 1824 | ( $minor ? EDIT_MINOR : 0 ) | |
1845 | 1825 | ( $forceBot ? EDIT_FORCE_BOT : 0 ); |
1846 | 1826 | |
1847 | | - $status = $this->doEdit( $text, $summary, $flags ); |
| 1827 | + $status = $this->doEdit( $text, $summary, $flags, false, null, $watchthis, false, $sectionanchor, true ); |
1848 | 1828 | if ( !$status->isOK() ) { |
1849 | 1829 | return false; |
1850 | 1830 | } |
1851 | 1831 | |
1852 | | - $dbw = wfGetDB( DB_MASTER ); |
1853 | | - if ( $watchthis ) { |
1854 | | - if ( !$this->mTitle->userIsWatching() ) { |
1855 | | - $dbw->begin(); |
1856 | | - $this->doWatch(); |
1857 | | - $dbw->commit(); |
1858 | | - } |
1859 | | - } else { |
1860 | | - if ( $this->mTitle->userIsWatching() ) { |
1861 | | - $dbw->begin(); |
1862 | | - $this->doUnwatch(); |
1863 | | - $dbw->commit(); |
1864 | | - } |
1865 | | - } |
1866 | | - |
1867 | | - $extraQuery = ''; // Give extensions a chance to modify URL query on update |
1868 | | - wfRunHooks( 'ArticleUpdateBeforeRedirect', array( $this, &$sectionanchor, &$extraQuery ) ); |
1869 | | - |
1870 | | - $this->doRedirect( $this->isRedirect( $text ), $sectionanchor, $extraQuery ); |
1871 | 1832 | return true; |
1872 | 1833 | } |
1873 | 1834 | |
— | — | @@ -1920,6 +1881,10 @@ |
1921 | 1882 | * |
1922 | 1883 | * @param $baseRevId the revision ID this edit was based off, if any |
1923 | 1884 | * @param $user Optional user object, $wgUser will be used if not passed |
| 1885 | + * @param $watchthis Watch the page if true, unwatch the page if false, do nothing if null |
| 1886 | + * @param $sectionanchor The section anchor for the page; used for redirecting the user back to the page |
| 1887 | + * after the edit is successfully committed |
| 1888 | + * @param $redirect If true, redirect the user back to the page after the edit is successfully committed |
1924 | 1889 | * |
1925 | 1890 | * @return Status object. Possible errors: |
1926 | 1891 | * edit-hook-aborted: The ArticleSave hook aborted the edit but didn't set the fatal flag of $status |
— | — | @@ -1936,7 +1901,8 @@ |
1937 | 1902 | * |
1938 | 1903 | * Compatibility note: this function previously returned a boolean value indicating success/failure |
1939 | 1904 | */ |
1940 | | - public function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null ) { |
| 1905 | + public function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null , $watchthis = null, |
| 1906 | + $comment = false, $sectionanchor = '', $redirect = false) { |
1941 | 1907 | global $wgUser, $wgDBtransactions, $wgUseAutomaticEditSummaries; |
1942 | 1908 | |
1943 | 1909 | # Low-level sanity check |
— | — | @@ -1953,9 +1919,14 @@ |
1954 | 1920 | $this->loadPageData(); |
1955 | 1921 | |
1956 | 1922 | $flags = $this->checkFlags( $flags ); |
| 1923 | + |
| 1924 | + # If this is a comment, add the summary as headline |
| 1925 | + if ( $comment && $summary != "" ) { |
| 1926 | + $text = wfMsgForContent( 'newsectionheaderdefaultlevel', $summary ) . "\n\n" . $text; |
| 1927 | + } |
1957 | 1928 | |
1958 | 1929 | if ( !wfRunHooks( 'ArticleSave', array( &$this, &$user, &$text, &$summary, |
1959 | | - $flags & EDIT_MINOR, null, null, &$flags, &$status ) ) ) |
| 1930 | + $flags & EDIT_MINOR, &$watchthis, null, &$flags, &$status) ) ) |
1960 | 1931 | { |
1961 | 1932 | wfDebug( __METHOD__ . ": ArticleSave hook aborted save!\n" ); |
1962 | 1933 | wfProfileOut( __METHOD__ ); |
— | — | @@ -2085,6 +2056,9 @@ |
2086 | 2057 | Article::onArticleEdit( $this->mTitle ); |
2087 | 2058 | # Update links tables, site stats, etc. |
2088 | 2059 | $this->editUpdates( $text, $summary, $isminor, $now, $revisionId, $changed ); |
| 2060 | + |
| 2061 | + $extraQuery = ''; # Give extensions a chance to modify URL query on update |
| 2062 | + wfRunHooks( 'ArticleUpdateBeforeRedirect', array( $this, &$sectionanchor, &$extraQuery ) ); |
2089 | 2063 | } else { |
2090 | 2064 | # Create new article |
2091 | 2065 | $status->value['new'] = true; |
— | — | @@ -2148,7 +2122,7 @@ |
2149 | 2123 | Article::onArticleCreate( $this->mTitle ); |
2150 | 2124 | |
2151 | 2125 | wfRunHooks( 'ArticleInsertComplete', array( &$this, &$user, $text, $summary, |
2152 | | - $flags & EDIT_MINOR, null, null, &$flags, $revision ) ); |
| 2126 | + $flags & EDIT_MINOR, &$watchthis, null, &$flags, $revision ) ); |
2153 | 2127 | } |
2154 | 2128 | |
2155 | 2129 | # Do updates right now unless deferral was requested |
— | — | @@ -2160,9 +2134,34 @@ |
2161 | 2135 | $status->value['revision'] = $revision; |
2162 | 2136 | |
2163 | 2137 | wfRunHooks( 'ArticleSaveComplete', array( &$this, &$user, $text, $summary, |
2164 | | - $flags & EDIT_MINOR, null, null, &$flags, $revision, &$status, $baseRevId ) ); |
2165 | | - |
| 2138 | + $flags & EDIT_MINOR, &$watchthis, null, &$flags, $revision, &$status, $baseRevId, |
| 2139 | + &$redirect) ); |
| 2140 | + |
| 2141 | + # Watch or unwatch the page |
| 2142 | + if ( $watchthis == true) { |
| 2143 | + if ( !$this->mTitle->userIsWatching() ) { |
| 2144 | + $dbw->begin(); |
| 2145 | + $this->doWatch(); |
| 2146 | + $dbw->commit(); |
| 2147 | + } |
| 2148 | + } elseif ($watchthis == false) { |
| 2149 | + if ( $this->mTitle->userIsWatching() ) { |
| 2150 | + $dbw->begin(); |
| 2151 | + $this->doUnwatch(); |
| 2152 | + $dbw->commit(); |
| 2153 | + } |
| 2154 | + } |
| 2155 | + |
| 2156 | + if ( $redirect ) { |
| 2157 | + if ( $sectionanchor || $extraQuery ) { |
| 2158 | + $this->doRedirect( $this->isRedirect( $text ), $sectionanchor, $extraQuery ); |
| 2159 | + } else { |
| 2160 | + $this->doRedirect( $this->isRedirect( $text ) ); |
| 2161 | + } |
| 2162 | + } |
| 2163 | + |
2166 | 2164 | wfProfileOut( __METHOD__ ); |
| 2165 | + |
2167 | 2166 | return $status; |
2168 | 2167 | } |
2169 | 2168 | |